1
0
mirror of https://github.com/golang/go synced 2024-11-23 15:30:05 -07:00
Commit Graph

46965 Commits

Author SHA1 Message Date
Rob Findley
a6eeb4add4 go/parser,go/types: hide API changes related to type parameters
While the dev.typeparams branch was merged, the type parameter API is
slated for go1.18. Hide these changes to the go/parser and go/types API.

This was done as follows:
 + For APIs that will probably not be needed for go1.18, simply unexport
   them.
 + For APIs that we expect to export in go1.18, prefix symbols with '_',
   so that the planned (upper-cased) symbol name is apparent.
 + For APIs that must be exported for testing, move both API and tests
   to files guarded by the go1.18 build constraint.
 + parser.ParseTypeParams is unexported and copied wherever it is
   needed.
 + The -G flag is removed from gofmt, replaced by enabling type
   parameters if built with the go1.18 build constraint.

Notably, changes related to type parameters in go/ast are currently left
exported. We're looking at the AST API separately.

The new API diff from 1.16 is:
+pkg go/ast, method (*FuncDecl) IsMethod() bool
+pkg go/ast, method (*ListExpr) End() token.Pos
+pkg go/ast, method (*ListExpr) Pos() token.Pos
+pkg go/ast, type FuncType struct, TParams *FieldList
+pkg go/ast, type ListExpr struct
+pkg go/ast, type ListExpr struct, ElemList []Expr
+pkg go/ast, type TypeSpec struct, TParams *FieldList
+pkg go/types, type Config struct, GoVersion string

Change-Id: I1baf67e26279b49092e774309a836c460979774a
Reviewed-on: https://go-review.googlesource.com/c/go/+/295929
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-03-02 01:50:12 +00:00
YunQiang Su
ff5cf4ced3 cmd/link,debug/elf: mips32, add .gnu.attributes and .MIPS.abiflags sections
MIPS32 uses .gnu.attributes and .MIPS.abiflags sections to mark FP ABI
the object is using, and the kernel will set the correct FP mode for it.

Currrently Go doesn't generate these 2 sections. If we link object
without these 2 sections togather FPXX objects, the result will be FPXX,
which is wrong:
   FP32 + FPXX -> FP32
   FPXX + FP64 -> FP64
   FP32 + FP64 -> reject

These 2 sections is also needed to support FPXX and FP64 in future.

More details about FP32/FPXX/FP64 are explained in:
    https://web.archive.org/web/20180828210612/https://dmz-portal.mips.com/wiki/MIPS_O32_ABI_-_FR0_and_FR1_Interlinking

Fixes #39677

Change-Id: Ia34e7461dee38a4f575dd8ace609988744512ac1
Reviewed-on: https://go-review.googlesource.com/c/go/+/239217
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Meng Zhuo <mzh@golangcn.org>
2021-03-02 00:51:00 +00:00
Cherry Zhang
700b73975e runtime: use entersyscall in syscall_syscallX on Darwin
CL 197938 changed syscall* functions to call entersyscall, instead
of entersyscallblock. It missed syscall_syscallX, probably because
it was in sys_darwin_64.go, not sys_darwin.go like others. Change
that one as well.

Found during the review of CL 270380 (thanks Joel).

Change-Id: I0884fc766703f555a3895be332dccfa7d2431374
Reviewed-on: https://go-review.googlesource.com/c/go/+/286435
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-03-01 22:49:36 +00:00
Rob Findley
a69c45213d go/types: review of expr.go
The changes from the (reviewed) dev.regabi copy of expr.go can be seen
by comparing patchset 2 and 7. The actual change is some small
improvements to readability and consistency in untyped conversion,
adding some missing documentation, and removing the "// REVIEW
INCOMPLETE" marker.

Note that expr.go diverges from types2 in its handling of untyped
conversion.

Change-Id: I13a85f6e08f43343e249818245aa857b1f4bf29c
Reviewed-on: https://go-review.googlesource.com/c/go/+/295729
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-03-01 21:11:10 +00:00
Dan Scales
b98ce3b606 cmd/compile: import empty closure function correctly
On import, make sure that an empty closure is represented as a single
empty block statement. Otherwise, the closure is dropped. Block
statements are not exported explicitly, so must recreate on import.

Fixes #44330

Change-Id: I061598f0f859dd71d2d0cbd10c77cdd81525d1f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/297569
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
2021-03-01 20:59:43 +00:00
Jay Conrod
97bdac03ae cmd: upgrade golang.org/x/mod to relax import path check
This incorporates CL 297089, which allows leading dots in import path
elements but not module path elements. Also added a test.

Fixes #43985
Updates #34992

Change-Id: I2d5faabd8f7b23a7943d3f3ccb6707ab5dc2ce3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/297530
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-03-01 20:20:41 +00:00
Than McIntosh
f6a74c6568 cmd/compile/internal/ir: fix up stale comment
Fix a small stale comment in FinishCaptureNames (refers to old code
structure before the big refactoring).

Change-Id: I2dfb84ce238f919f6e17061439a8bd9b09459dae
Reviewed-on: https://go-review.googlesource.com/c/go/+/296829
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-03-01 20:00:13 +00:00
Jordan Liggitt
87beecd6df cmd/go: add missing newline to retraction warning message
Fixes #44674

Change-Id: Icbdb79084bf7bd2f52cc0a53abcc1ec6f0c4a1bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/297350
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
2021-03-01 19:39:18 +00:00
Bryan C. Mills
a400eb3261 Revert "cmd/compile: check frame offsets against abi"
This reverts CL 293392.

Reason for revert: broke most non-x86 builders

Fixes #44675

Change-Id: I1e815c3ab27a02e83a2f0d221a617909dd021403
Reviewed-on: https://go-review.googlesource.com/c/go/+/297549
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2021-03-01 15:24:01 +00:00
Jay Conrod
5fafc0bbd4 cmd/go/internal/modload: don't query when fixing canonical versions
If a canonical version is passed to fixVersion when loading the main
go.mod and that version don't match the module path's major version
suffix, don't call Query.

Query doesn't return a useful error in this case when the path is
malformed, for example, when it doens't have a dot in the first path
element. It's better to report the major version mismatch error.

Fixes #44494

Change-Id: I97b1f64aee894fa0db6fb637aa03a51357ee782c
Reviewed-on: https://go-review.googlesource.com/c/go/+/296590
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-03-01 14:46:14 +00:00
Jason A. Donenfeld
2a8df4488e os: mark pipes returned by os.Pipe() as inheritable by default
Now that we don't automatically pass all inheritable handles to new
processes, we can make pipes returned by os.Pipe() inheritable, just
like they are on Unix. This then allows them to be passed through the
SysProcAttr.AdditionalInheritedHandles parameter simply.

Updates #44011.
Fixes #21085.

Change-Id: I8eae329fbc74f9dc7962136fa9aae8fb66879751
Reviewed-on: https://go-review.googlesource.com/c/go/+/288299
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2021-03-01 09:17:40 +00:00
David Chase
5ff7ec98b7 cmd/compile: check frame offsets against abi
this is in preparation for turning off calculation of frame offsets
in types.CalcSize

For #40724.

Change-Id: I2c29fd289c014674076e5ec5170055dbca5ea64b
Reviewed-on: https://go-review.googlesource.com/c/go/+/293392
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2021-02-27 22:39:54 +00:00
Matthew Dempsky
a429926159 cmd/compile: fix escape analysis of heap-allocated results
One of escape analysis's responsibilities is to summarize whether/how
each function parameter flows to the heap so we can correctly
incorporate those flows into callers' escape analysis data flow
graphs.

As an optimization, we separately record when parameters flow to
result parameters, so that we can more precisely analyze parameter
flows based on how the results are used at the call site. However, if
a named result parameter itself needs to be heap allocated, this
optimization isn't safe and the parameter needs to be recorded as
flowing to heap rather than flowing to result.

Escape analysis used to get this correct because it conservatively
rewalked the data-flow graph multiple times. So even though it would
incorrectly record the result parameter flow, it would separately find
a flow to the heap. However, CL 196811 (specifically, case 3)
optimized the walking logic to reduce unnecessary rewalks causing us
to stop finding the extra heap flow.

This CL fixes the issue by correcting location.leakTo to be sensitive
to sink.escapes and not record result-flows when the result parameter
escapes to the heap.

Fixes #44614.

Change-Id: I48742ed35a6cab591094e2d23a439e205bd65c50
Reviewed-on: https://go-review.googlesource.com/c/go/+/297289
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-02-27 19:01:19 +00:00
David Chase
998fe70b68 cmd/compile: fixed which-result confusion in presence of 0-width types
A function returning multiple results, some of them zero-width,
will have more than one result present at an offset.  Be sure
that offset AND type match.

Includes test.

Change-Id: I3eb1f56116d989b4e73f533fefabb1bf554c901b
Reviewed-on: https://go-review.googlesource.com/c/go/+/297169
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2021-02-27 18:38:31 +00:00
Ian Lance Taylor
d9fd38e68b time: correct unusual extension string cases
This fixes two uncommon cases.

First, the tzdata code permits timezone offsets up to 24 * 7, although
the POSIX TZ parsing does not. The tzdata code uses this to specify a
day of week in some cases.

Second, we incorrectly rejected a negative time offset for when a time
zone change comes into effect.

Fixes #44385

Change-Id: I5f2efc1d385e9bfa974a0de3fa81e7a94b827602
Reviewed-on: https://go-review.googlesource.com/c/go/+/296392
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-02-27 03:03:29 +00:00
Michael Anthony Knyszek
cda8ee095e reflect: fix register ABI spill space calculation
Currently this does things the old way by computing the number of
registers, but we're going to be using their ABI0 layout for the spill
space for now.

Change-Id: Ibcef1ee48fd834af7cbdaabe704bcabe066ed358
Reviewed-on: https://go-review.googlesource.com/c/go/+/293011
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
2021-02-26 20:49:57 +00:00
Dan Scales
d8e33d558e cmd/compile: deal with closures in generic functions and instantiated function values
- Deal with closures in generic functions by fixing the stenciling code

 - Deal with instantiated function values (instantiated generic
   functions that are not immediately called) during stenciling. This
   requires changing the OFUNCINST node to an ONAME node for the
   appropriately instantiated function. We do this in a second pass,
   since this is uncommon, but requires editing the tree at multiple
   levels.

 - Check global assignments (as well as functions) for generic function
   instantiations.

 - Fix a bug in (*subst).typ where a generic type in a generic function
   may definitely not use all the type args of the function, so we need
   to translate the rparams of the type based on the tparams/targs of
   the function.

 - Added new test combine.go that tests out closures in generic
   functions and instantiated function values.

 - Added one new variant to the settable test.

 - Enabling inlining functions with closures for -G=3. (For now, set
   Ntype on closures in -G=3 mode to keep compatibility with later parts
   of compiler, and allow inlining of functions with closures.)

Change-Id: Iea63d5704c322e42e2f750a83adc8b44f911d4ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/296269
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
2021-02-26 18:57:20 +00:00
Jason A. Donenfeld
19f96e73bf syscall: introduce SysProcAttr.ParentProcess on Windows
This allows users to specify which process should be used as the parent
process when creating a new process.

Note that this doesn't just trivially pass the handle onward to
PROC_THREAD_ATTRIBUTE_PARENT_PROCESS, because inherited handles must be
valid in the parent process, so if we're changing the destination
process, then we must also change the origin of the parent handles. And,
the StartProcess function must clean up these handles successfully when
exiting, regardless of where the duplication happened. So, we take care
in this commit to use DuplicateHandle for both duplicating and for
closing the inherited handles.

The test was taken originally from CL 288272 and adjusted for use here.

Fixes #44011.

Change-Id: Ib3b132028dcab1aded3dc0e65126c8abebfa35eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/288300
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2021-02-26 18:27:57 +00:00
Jason A. Donenfeld
3146166baa syscall: introduce SysProcAttr.AdditionalInheritedHandles on Windows
This allows users to specify handles that they explicitly want to be
inherited by the new process. These handles must already be marked as
inheritable.

Updates #44011.
Updates #21085.

Change-Id: Ib18322e7dc2909e68c4209e80385492804fa15d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/288298
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2021-02-26 18:23:47 +00:00
Jason A. Donenfeld
2d760816ff syscall: restrict inherited handles on Windows
Windows does not have CLOEXEC, but rather handles are marked explicitly
for being inherited by new processes. This can cause problems when
different Windows functions create new processes from different threads.
syscall.StartProcess has traditionally used a mutex to prevent races
with itself, but this doesn't handle races with other win32 functions.

Fortunately there's a solution: PROC_THREAD_ATTRIBUTE_HANDLE_LIST allows
us to pass the entire list of handles that we want to be inherited. This
lets us get rid of the mutex and also makes process creation safe across
the Go runtime, no matter the context.

Updates #44011.

Change-Id: Ia3424cd2ec64868849cbd6cbb5b0d765224bf4ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/288297
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2021-02-26 18:23:29 +00:00
Jason A. Donenfeld
ba9168bd07 syscall: add support for proc thread attribute lists
This will allow us to pass additional attributes when starting
processes.

Updates #44011.

Change-Id: I4af365c5544a6d421830f247593ec970200e5e03
Reviewed-on: https://go-review.googlesource.com/c/go/+/288296
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2021-02-26 18:23:16 +00:00
Jason A. Donenfeld
f41460145e cmd/link: recognize ARM64 PE files and relocations
For now, this only add a single relocation type, which is sufficient for
Windows resources. Later we'll see if we need more for cgo.

In order to ensure these code paths are actually tested, this expands
the rsrc tests to include all the architectures of PE objects that we
need to be recognizing, and splits things more clearly between binutils
and llvm objects, which have a slightly different layout, so that we
test both.

This CL is part of a stack adding windows/arm64
support (#36439), intended to land in the Go 1.17 cycle.

Change-Id: Ia1ee840265e9d12c0b12dd1c5d0810f8b300e557
Reviewed-on: https://go-review.googlesource.com/c/go/+/289429
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-02-26 18:15:09 +00:00
Cherry Zhang
a655208c9e cmd/link: handle types as converted to interface when dynlink
When using plugins, a type (whose value) may be pass to a plugin
and get converted to interface there, or vice versa. We need to
treat the type as potentially converted to interface, and retain
its methods.

Should fix #44586.

Change-Id: I80dd35e68baedaa852a317543ccd78d94628d13b
Reviewed-on: https://go-review.googlesource.com/c/go/+/296709
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-02-26 16:27:08 +00:00
Cuong Manh Le
23943a6737 cmd/compile: fix mishandling of unsafe-uintptr arguments with call method in go/defer
In CL 253457, we did the same fix for direct function calls. But for
method calls, the receiver argument also need to be passed through the
wrapper function, which we are not doing so the compiler crashes with
the code in #44415.

It will be nicer if we can rewrite OCALLMETHOD to normal OCALLFUNC, but
that will be for future CL. The passing receiver argument to wrapper
function is easier for backporting to go1.16 branch.

Fixes #44415

Change-Id: I03607a64429042c6066ce673931db9769deb3124
Reviewed-on: https://go-review.googlesource.com/c/go/+/296490
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-02-26 10:18:26 +00:00
David Chase
e25040d162 cmd/compile: change StaticCall to return a "Results"
StaticLECall (multiple value in +mem, multiple value result +mem) ->
StaticCall (multiple ergister value in +mem,
   multiple register-sized-value result +mem) ->
ARCH CallStatic (multiple ergister value in +mem,
   multiple register-sized-value result +mem)

But the architecture-dependent stuff is indifferent to whether
it is mem->mem or (mem)->(mem) until Prog generation.

Deal with OpSelectN -> Prog in ssagen/ssa.go, others, as they
appear.

For #40724.

Change-Id: I1d0436f6371054f1881862641d8e7e418e4a6a16
Reviewed-on: https://go-review.googlesource.com/c/go/+/293391
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-02-26 02:52:33 +00:00
Dan Scales
9a555fc24c cmd/compile: fix missing descend in Addrtaken for closures.
ComputeAddrtaken needs to descend into closures, now that imported
bodies can include closures. The bug was that we weren't properly
setting Addrtaken for a variable inside a closure inside a function that
we were importing.

For now, still disable inlining of functions with closures for -G mode.
I'll enable it in a later change -- there are just a few fixes related
to the fact that we don't need to set Ntype for closure functions.

Added a test derived from the cilium repro in the issue.

Fixes #44370

Change-Id: Ida2a403636bf8740b471b3ad68b5474951811e19
Reviewed-on: https://go-review.googlesource.com/c/go/+/296649
Run-TryBot: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-02-26 02:11:50 +00:00
Josh Bleecher Snyder
a61524d103 cmd/internal/obj: add Prog.SetFrom3{Reg,Const}
These are the the most common uses, and they reduce line noise.

I don't love adding new deprecated APIs,
but since they're trivial wrappers,
it'll be very easy to update them along with the rest.
No functional changes; passes toolstash-check.

Change-Id: I691a8175cfef9081180e463c63f326376af3f3a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/296009
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-02-25 23:19:16 +00:00
Bryan C. Mills
5f15af111c syscall: comment on fields omitted from the win32finddata1 struct
Updates #42637

Change-Id: I4c7d38034b60c2c04efdeb530a97d96deddfd6fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/284152
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2021-02-25 22:38:21 +00:00
Matthew Dempsky
9a7fe196e4 Revert "cmd/compile: fix mishandling of unsafe-uintptr arguments with call method in go/defer"
This reverts commit CL 294849.

Reason for revert: this doesn't actually fix the issue, as revealed
by the noopt builder's failures.

Change-Id: Ib4ea9ceb4d75e46b3b91ec348b365fd8c83316ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/296629
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-02-25 21:52:49 +00:00
Joe Tsai
b83d073e9e reflect: add Method.IsExported and StructField.IsExported methods
The IsExported method is a more intuitive helper for checking whether
the method or field is exported than checking whether PkgPath is empty.

In the same CL, modify the standard library to make use of this helper.

Fixes #41563

Change-Id: Iaacfb3b74449501f98e2707aa32095a32bd3c3c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/266197
Trust: Joe Tsai <joetsai@digital-static.net>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-25 21:21:51 +00:00
Josh Bleecher Snyder
7fcf9893f7 cmd/internal/obj: fix typo in docs
Change-Id: I5a3d26a4cc59b327d46ca24bcb01ef594758c230
Reviewed-on: https://go-review.googlesource.com/c/go/+/296531
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-25 19:58:05 +00:00
Matthew Dempsky
6c3bcda866 cmd/compile: declare inlined result params early for empty returns
The code for delayed declaration of inlined result parameters only
handles non-empty return statements. This is generally okay, because
we already early declare if there are any (non-blank) named result
parameters.

But if a user writes a function with only blank result parameters and
with exactly one return statement, which is empty, then they could end
up hitting the dreaded "Value live at entry" ICE.

This CL fixes the issue by ensuring we always early declare inlined
result parameters if there are any empty return statements.

Fixes #44355.

Change-Id: I315f3853be436452883b1ce31da1bdffdf24d506
Reviewed-on: https://go-review.googlesource.com/c/go/+/293293
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
2021-02-25 19:57:49 +00:00
Josh Bleecher Snyder
526ee96f49 os: avoid allocation in File.WriteString
Instead of alloc+copy to convert the string
to a byte slice, do an unsafe conversion.

Rely on the kernel not to scribble on the
buffer during the write.

Fixes #42406

Change-Id: I66f4838b43a11bcc3d67bbfa1706726318d55343
Reviewed-on: https://go-review.googlesource.com/c/go/+/268020
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-02-25 19:42:00 +00:00
Ivan Trubach
194b636f8f database/sql: close driver.Connector if it implements io.Closer
This change allows driver implementations to manage resources in
driver.Connector, e.g. to share the same underlying database handle
between multiple connections. That is, it allows embedded databases
with in-memory backends like SQLite and Genji to safely release the
resources once the sql.DB is closed.

This makes it possible to address oddities with in-memory stores in
SQLite and Genji drivers without introducing too much complexity in
the driver implementations.

See also:
- https://github.com/mattn/go-sqlite3/issues/204
- https://github.com/mattn/go-sqlite3/issues/511
- https://github.com/genjidb/genji/issues/210

Fixes #41790

Change-Id: Idbd19763134438ed38288b9d44f16608e4e97fd7
GitHub-Last-Rev: 962c785dfb
GitHub-Pull-Request: golang/go#41710
Reviewed-on: https://go-review.googlesource.com/c/go/+/258360
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-02-25 19:34:27 +00:00
Josh Bleecher Snyder
4ebb6f5110 cmd/compile: automate resultInArg0 register checks
No functional changes; passes toolstash-check.
No measureable performance changes.

Change-Id: I2629f73d4a3cc56d80f512f33cf57cf41d8f15d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/296010
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-02-25 18:57:20 +00:00
Cuong Manh Le
1a3e968b1f cmd/compile: fix mishandling of unsafe-uintptr arguments with call method in go/defer
In CL 253457, we did the same fix for direct function calls. But for
method calls, the receiver argument also need to be passed through the
wrapper function, which we are not doing so the compiler crashes with
the code in #44415.

As we already rewrite t.M(...) into T.M(t, ...) during walkCall1, to fix
this, we can do the same trick in wrapCall, so the receiver argument
will be treated as others.

Fixes #44415

Change-Id: I396182983c85d9c5e4494657da79d25636e8a079
Reviewed-on: https://go-review.googlesource.com/c/go/+/294849
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-02-25 18:49:25 +00:00
Tobias Klauser
ee2a45e5fb runtime: use pipe2 for nonblockingPipe on dragonfly
The pipe2 syscall is available since DragonflyBSD 4.2, see
https://www.dragonflybsd.org/release42/

Change-Id: Ifc67c4935cc59bae29be459167e2fa765843ac03
Reviewed-on: https://go-review.googlesource.com/c/go/+/295471
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-25 18:43:17 +00:00
Andy Pan
1f7a01459b runtime: batch moving gFree list between local p and global schedt
Change-Id: I0ca1fcee6d3f08bdfcfa51f0dc774118d7355636
Reviewed-on: https://go-review.googlesource.com/c/go/+/271914
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2021-02-25 18:08:41 +00:00
Jay Conrod
bcac57f89c cmd: upgrade golang.org/x/mod to fix go.mod parser
modfile.Parse passed an empty string to the VersionFixer for the
module path. This caused errors for v2+ versions.

Fixes #44494

Change-Id: I13b86b6ecf6815c4bc9a96ec0668284c9228c205
Reviewed-on: https://go-review.googlesource.com/c/go/+/296131
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-02-25 17:50:59 +00:00
Bryan C. Mills
3137da82fd cmd/go: add a script test corresponding to the downhiddenartifact MVS test
For #36460

Change-Id: I95abff45bb325732a19eb8b9c0d3fc34df08b4d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/294293
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-02-25 17:28:44 +00:00
Bryan C. Mills
2c4c189bba cmd/go/internal/mvs: add test cases for downgrade interaction with hidden versions
For #36460

Change-Id: I889c4ece0d2caff7528cf437f89f7446dbd83955
Reviewed-on: https://go-review.googlesource.com/c/go/+/294292
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-02-25 16:45:36 +00:00
Ian Lance Taylor
9fe8ebf9b4 test: add test case that failed with gccgo
bug511.dir/b.go:10:14: error: reference to undefined field or method 'M'

Change-Id: I9f96dc5c7254b310bc3e15b0bc588d62718cb4b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/292009
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-02-25 15:24:25 +00:00
Ian Lance Taylor
ad17b65b34 testing/fstest: treat dash specially when building glob
"[-]" is not a valid path.Match pattern.

Fixes #44474

Change-Id: I0932bbf08ffb8ad0c5337d69d0893f53c1ba89ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/294869
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2021-02-25 15:23:02 +00:00
Jason A. Donenfeld
37ca84a9cd syscall: return error if GetQueuedCompletionStatus truncates key
This function has the wrong signature, so return an error when that
actually might lead to unexpected results. Users should switch to
x/sys/windows for the real version of this function.

Updates #44538.

Change-Id: I4d1f3d1e380815733ecfea683f939b1d25dcc32a
Reviewed-on: https://go-review.googlesource.com/c/go/+/296154
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-25 09:46:02 +00:00
Tobias Klauser
76c0003cd5 syscall, os: use pipe2 syscall on DragonflyBSD instead of pipe
Follow the implementation used by the other BSDs and account for the
intricacy of having to pass the fds array even though the file
descriptors are returned.

Re-submit of CL 130996 with corrected pipe2 wrapper.

Change-Id: Ie36d8214cba60c4fdb579f18bfc1c1ab3ead3ddc
Reviewed-on: https://go-review.googlesource.com/c/go/+/295372
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-25 09:20:03 +00:00
Ikko Ashimine
666ad85df4 cmd/compile: fix typo in rewrite_test.go
insted -> instead

Change-Id: Ib8a0423cf99f615976f058468873fb576dd96db6
GitHub-Last-Rev: 8e1a1d0880
GitHub-Pull-Request: golang/go#44598
Reviewed-on: https://go-review.googlesource.com/c/go/+/296309
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-02-25 04:55:35 +00:00
Egon Elbre
d822ffebc5 test: fix inline.go test for linux-amd64-noopt
math.Float32bits was not being inlined across package boundaries.
Create a private func that can be inlined with -l.

Change-Id: Ic50bf4727dd8ade09d011eb204006b7ee88db34a
Reviewed-on: https://go-review.googlesource.com/c/go/+/295989
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-02-25 02:22:12 +00:00
Jason A. Donenfeld
ff614b13d9 runtime: subtract one from ip when determining abort
On windows/arm, the abort is given from one byte off of the function
address, perhaps because Windows wants to simulate x86/amd64 modes, or
because it's jumping from thumb mode. This is not the case with
windows/arm64, though.

This prevents a failure in the builders with the TestAbort test:

    crash_test.go:727: output contains BAD:
        panic: runtime error: invalid memory address or nil pointer dereference [recovered]
                panic: BAD: recovered from abort
        [signal 0xc0000005 code=0x0 addr=0x0 pc=0x6a5721]

Change-Id: I8939c60611863cc0c325e179a772601acea9fd4a
Reviewed-on: https://go-review.googlesource.com/c/go/+/296153
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-02-25 01:30:37 +00:00
Jason A. Donenfeld
dbbc5ec7e8 syscall: restore broken GetQueuedCompletionStatus signature but make it not crash
This reverts commit dc4698f52b, and then
fixes the memory corruption issue. It also suggests users switch to
x/sys/windows for the proper function.

This requires CL 295174 to be submitted first.

Updates #44538.

Change-Id: I0ee602f1c1d6a89cc585aff426833a4cb3f2be50
Reviewed-on: https://go-review.googlesource.com/c/go/+/296149
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-24 23:35:00 +00:00
David Chase
d0d21b7c4c cmd/compile: plumb abi info into expandCalls
Work in progress.

TODO:
- insert debugging output for all the steps listed below
- emit modified call instructions w/ multiple register inputs
  and Result-typed outputs (next CL)
  - initially just change output from "mem" to "Result{mem}"
  = most places this hits will be future work.
- change OpArg to use registerized variants
  - (done) match abi paramresultinfo with particular arg, use Name
  - (this CL) push register offsets for "loads" and "stores" into
    recursive decomposition.
- hand registerized Result to exit block

For #40724.

Change-Id: Ie5de9d71f8fd4e092f5ee9260b54de35abf91016
Reviewed-on: https://go-review.googlesource.com/c/go/+/293390
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2021-02-24 23:05:10 +00:00