1
0
mirror of https://github.com/golang/go synced 2024-11-07 09:36:11 -07:00
Commit Graph

47994 Commits

Author SHA1 Message Date
Austin Clements
60abe01321 cmd/link: fix file-local checks in xcoff
The xcoff writer has several "ldr.SymVersion(s) != 0" checks. The
intent of these is to check for file-local (or static) symbols. Prior
to the introduction of symbol ABIs, this was indeed equivalent since
only file-local symbols has non-zero versions, but ABIs also use the
symbol version space. This still happened to work until much more
recently because we were only ever cgo-exporting version 0 symbols,
but CL 309341 changed this, causing these checks to fail on symbols
that were okay to export.

Replace these checks with ldr.IsFileLocal(s).

This should fix the AIX builder.

(Originally based on CL 309772.)

Fixes #45553.
Updates #40724.

Change-Id: I0a3a7f621ad8f9fe078d34e667286275257691ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/310729
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-16 17:19:08 +00:00
ian woolf
acb189ea59 net/http: make ReadRequest return an error when requests have multiple Host headers
Fixes #45513

Change-Id: I59e717a4bbd3e71320deff519e4f9587ee5c8756
Reviewed-on: https://go-review.googlesource.com/c/go/+/308952
Trust: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-04-16 16:40:34 +00:00
Peng Gao
2f0e5bf907 net/http: using errors.Is in fs error detection
Compare error by errors.Is to detect wrapped fs errors.

Fixes #44923

Change-Id: Idf32b96a661728278b7006c3b3bcc581b8588259
GitHub-Last-Rev: dba01ddae0
GitHub-Pull-Request: golang/go#45314
Reviewed-on: https://go-review.googlesource.com/c/go/+/306051
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-16 16:36:57 +00:00
Cherry Zhang
abbb82957d cmd/compile: don't insert VarDef for already-initialized results
Currently, when we about to emit code that sets the function
results and returns, it emits a VarDef. But in some cases, the
result node is actually live and holding useful data. VarDef
means that we are about to (re)initialize it so all previous
data are dead, but that is not true. Don't insert that.

Also don't add VarDef for register results. We are not going to
store anything (currently it doesn't cause problem, just
unnecessary).

Change-Id: I9dd3b70b4a3f5035af028b143fde8fafa2f11fa0
Reviewed-on: https://go-review.googlesource.com/c/go/+/310589
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-04-16 16:36:45 +00:00
Jay Conrod
04e1176fd2 cmd/go: support 'go run cmd@version'
'go run' can now build a command at a specific version in module-aware
mode, ignoring the go.mod file in the current directory if there is one.

For #42088

Change-Id: I0bd9bcbe40c0442a268cd1cc315a8a2cbb5adeee
Reviewed-on: https://go-review.googlesource.com/c/go/+/310074
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-04-16 16:11:09 +00:00
Austin Clements
639cb1b629 runtime: mark stdcallN functions cgo_unsafe_args
These functions take the address of an argument and expect to be able
to reach later arguments from that pointer. This means they must be
laid out sequentially in memory (using ABI0) and all arguments must be
live even though they don't all appear to be referenced. This is
exactly what go:cgo_unsafe_args does.

Without this, GOEXPERIMENT=regabi,regabiargs on windows/amd64 crashes
on runtime startup because the stdcall functions are called with their
arguments in registers, so taking the address of one of them has no
bearing on the memory locations of the following arguments.

With this, GOEXPERIMENT=regabi,regabiargs on windows/amd64 passes
all.bash.

For #40724.

Change-Id: I4a4d6a913f85799b43f61c234d21ebb113a9b527
Reviewed-on: https://go-review.googlesource.com/c/go/+/310733
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-16 16:09:59 +00:00
Jay Conrod
0613c748e8 cmd/go: move 'go install cmd@version' code into internal/load
'go run cmd@version' will use the same code.

This changes error messages a bit.

For #42088

Change-Id: Iaed3997a3d27f9fc0e868013ab765f1fb638a0b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/310410
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-04-16 14:15:49 +00:00
Jay Conrod
dc76c47565 cmd/go/internal/load: convert two global flags to an options struct
PackageOpts is a new struct type accepted by package loading
functions. It initially has two fields: IgnoreImports, and
ModResolveTests. Previously, these were global variables set by
clients. We'll add more to this in the future.

For #40775

Change-Id: I6956e56502de836d3815ce788bdf16fc5f3e5338
Reviewed-on: https://go-review.googlesource.com/c/go/+/310669
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-04-16 14:15:42 +00:00
Jay Conrod
cde92846e2 doc: add release note for module deprecation
Fixes #40357

Change-Id: I876edd7364530b77343ebcdd4032390493f8d031
Reviewed-on: https://go-review.googlesource.com/c/go/+/309549
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-04-16 14:13:38 +00:00
David Chase
52df9291aa test/abi: reenable test on windows
Reverses CL 308889.
Fixes #45465.
Updates #40724.

Change-Id: I34b0d396dc34d0ec8c216e9b6a668de9dfce677c
Reviewed-on: https://go-review.googlesource.com/c/go/+/310649
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-04-16 13:38:02 +00:00
Tobias Klauser
c692f752b5 cmd/link/internal/ld: re-enable tests on darwin
It looks like these are fixed again for darwin on current tip after CL
111258 marked them to be skipped.

Updates #23168

Change-Id: I4abecee1152ccd4f2d44d76d1acdecb0d6140981
Reviewed-on: https://go-review.googlesource.com/c/go/+/308994
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-16 12:28:49 +00:00
Tobias Klauser
e1f4feb3d6 cmd/link/internal/ld: fix GOARCH in TestAbstractOriginSanityIssue25459
There is no x86 GOARCH, this should likely be 386.

Change-Id: I16f1cf5edb0cce156d42ecb621b2ae481c8f1789
Reviewed-on: https://go-review.googlesource.com/c/go/+/308995
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-16 12:28:37 +00:00
Austin Clements
d26fc68aa1 cmd/internal/objabi,test: use correct GOEXPERIMENT build tags in test/run.go
Currently, run.go sets GOEXPERIMENT build tags based on the
*difference* from the baseline experiment configuration, rather than
the absolute experiment configuration. This differs from cmd/go. As a
result, if we set a baseline configuration and don't override it with
a GOEXPERIMENT setting, run.go won't set any GOEXPERIMENT build tags,
instead of setting the tags corresponding to the baseline
configuration.

Fix this by making compile -V=goexperiment produce the full
GOEXPERIMENT configuration, which run.go can then use to set exactly
the right set of build tags.

For #40724.

Change-Id: Ieda6ea62f1a1fabbe8d749d6d09c198fd5ca8377
Reviewed-on: https://go-review.googlesource.com/c/go/+/310171
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-16 03:16:55 +00:00
Austin Clements
cf2396c70e internal/goexperiment: move baseline configuration to objabi
We need to adjust baseline experiment configuration based on the
configured GOOS and GOARCH, so it can't live in goexperiment. Move it
to objabi.

Change-Id: I65f4ce56902c6c1a82735050773c58f2d1320cc6
Reviewed-on: https://go-review.googlesource.com/c/go/+/310169
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2021-04-16 03:16:11 +00:00
Joshua Harshman
f08c552dab net/http: add to deadlines only when positive
The existing implementation allows read / write deadlines to exist
in the past. This updates conditionals to only add to the deadline
when the value is positive.

Fixes: #39177
Change-Id: I841c30ba2849a337e7bc98c8aa136c4527c314ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/235437
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Damien Neil <dneil@google.com>
2021-04-16 01:54:27 +00:00
Austin Clements
bdddfd10ec runtime: improve synchronization in TestFinalizerRegisterABI
Replace busy-wait with a channel.

Change-Id: I51ddfd5dbde15fff56c62c618570e66930902cbb
Reviewed-on: https://go-review.googlesource.com/c/go/+/310630
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-16 00:01:58 +00:00
Paul E. Murphy
c8fb0ec5a0 cmd/compile: fix ANDI/SRWI merge on ppc64
The shift amount should be masked to avoid rotation values
beyond the numer of bits. In this case, if the shift amount
is 0, it should rotate 0, not 32.

Fixes #45589

Change-Id: I1e764497a39d0ec128e29af42352b70c70b2ecc5
Reviewed-on: https://go-review.googlesource.com/c/go/+/310569
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
Trust: Carlos Eduardo Seo <carlos.seo@linaro.org>
2021-04-15 21:57:02 +00:00
Aofei Sheng
699a7c0fe9 cmd/go/internal/modconv: involve GOPROXY in ConvertLegacyConfig
Fixes #33767

Change-Id: Ia2d6dd32bcb0e142f59346232b3b1aa3babb034a
Reviewed-on: https://go-review.googlesource.com/c/go/+/306809
Trust: Jay Conrod <jayconrod@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Aofei Sheng <aofei@aofeisheng.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-15 20:13:20 +00:00
Robert Griesemer
7ed6d1f2fb cmd/compile/internal/types2: add sizeof test
Change-Id: I75d3c8546b7ad51d8c7369e7289036b697d6b913
Reviewed-on: https://go-review.googlesource.com/c/go/+/310530
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-15 19:41:39 +00:00
Robert Griesemer
a63ff398d5 cmd/compile/internal/syntax: fix error message for ... without type
Only complain about missing type; leave it to type-checking
to decide whether "..." is permitted in the first place.

Fixes #43674.

Change-Id: Icbc8f084e364fe3ac16076406a134354219c08d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/310209
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-15 19:41:38 +00:00
Paul E. Murphy
ddd8d7c0a6 cmd/internal/obj: consolidate AMOVW and AMOVWZ optab entries
This requires consolidating the register move operations into a
single case entry in asmout.  These moves are also used to
sign/zero-extend register values.

Combine the three asmout cases for register moves.  This allows
AMOVWZ and AMOVW to be handled with the same optab entries.

Likewise, remove the diagnostic error for non-zero constant
loads into R0 using the register move operations, it is not
possible to match this asmout case with a non-zero constant.

Finally, fix the load constant 0 via "MOV[BHW]{,Z} $0, Rx".
These now generate "li Rx, $0" instead of a zero/sign-extend
of the contents of R0.

Change-Id: Ia4a263661582f10feda27ee21cb121e05ea931dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/308190
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
Trust: Carlos Eduardo Seo <carlos.seo@linaro.org>
2021-04-15 18:21:15 +00:00
Lynn Boger
8009a81f7a bytes: add asm implementation for index on ppc64x
This adds an asm implementation of index on ppc64le and
ppc64. It results in a significant improvement in some
of the benchmarks that use bytes.Index.

The implementation is based on a port of the s390x asm
implementation. Comments on the design are found
with the code.

The following improvements occurred on power8:

Index/10       70.7ns ± 0%    18.8ns ± 0%   -73.4
Index/32        165ns ± 0%      95ns ± 0%   -42.6
Index/4K       9.23µs ± 0%    4.91µs ± 0%   -46
Index/4M       9.52ms ± 0%    5.10ms ± 0%   -46.4
Index/64M       155ms ± 0%      85ms ± 0%   -45.1

Count/10       83.0ns ± 0%    32.1ns ± 0%   -61.3
Count/32        178ns ± 0%     109ns ± 0%   -38.8
Count/4K       9.24µs ± 0%    4.93µs ± 0%   -46
Count/4M       9.52ms ± 0%    5.10ms ± 0%   -46.4
Count/64M       155ms ± 0%      85ms ± 0%   -45.1

IndexHard1     2.36ms ± 0%    0.13ms ± 0%   -94.4
IndexHard2     2.36ms ± 0%    1.28ms ± 0%   -45.8
IndexHard3     2.36ms ± 0%    1.19ms ± 0%   -49.4
IndexHard4     2.36ms ± 0%    2.35ms ± 0%    -0.1

CountHard1     2.36ms ± 0%    0.13ms ± 0%   -94.4
CountHard2     2.36ms ± 0%    1.28ms ± 0%   -45.8
CountHard3     2.36ms ± 0%    1.19ms ± 0%   -49.4

IndexPeriodic/IndexPeriodic2  146µs ± 0%       8µs ± 0%   -94
IndexPeriodic/IndexPeriodic4  146µs ± 0%       8µs ± 0%   -94

Change-Id: I7dd2bb7e278726e27f51825ca8b2f8317d460e60
Reviewed-on: https://go-review.googlesource.com/c/go/+/309730
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Paul Murphy <murp@ibm.com>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
Trust: Carlos Eduardo Seo <carlos.seo@linaro.org>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
2021-04-15 17:32:04 +00:00
Michael Fraenkel
5631c4b3bf net/http: allow multiple dials in TestTransportMaxConnsPerHost
If there is more than the expected single dial, the channel will block.
Allow at least one connection per client, and do the expected cleanup.

Updates #45570

Change-Id: Iaecd45298a7d7c591b7d7b1be13cea6e4a1e2e85
Reviewed-on: https://go-review.googlesource.com/c/go/+/310213
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2021-04-15 16:09:16 +00:00
Austin Clements
1d20a362d0 math: avoid assembly stubs
Currently almost all math functions have the following pattern:

func Sin(x float64) float64

func sin(x float64) float64 {
    // ... pure Go implementation ...
}

Architectures that implement a function in assembly provide the
assembly implementation directly as the exported function (e.g., Sin),
and architectures that don't implement it in assembly use a small stub
to jump back to the Go code, like:

TEXT ·Sin(SB), NOSPLIT, $0
	JMP ·sin(SB)

However, most functions are not implemented in assembly on most
architectures, so this jump through assembly is a waste. It defeats
compiler optimizations like inlining. And, with regabi, it actually
adds a small but non-trivial overhead because the jump from assembly
back to Go must go through an ABI0->ABIInternal bridge function.

Hence, this CL reorganizes this structure across the entire package.
It now leans on inlining to achieve peak performance, but allows the
compiler to see all the way through the pure Go implementation.

Now, functions follow this pattern:

func Sin(x float64) float64 {
	if haveArchSin {
		return archSin(x)
	}
	return sin(x)
}

func sin(x float64) float64 {
    // ... pure Go implementation ...
}

Architectures that have assembly implementations use build-tagged
files to set haveArchX to true an provide an archX implementation.
That implementation can also still call back into the Go
implementation (some of them do this).

Prior to this change, enabling ABI wrappers results in a geomean
slowdown of the math benchmarks of 8.77% (full results:
https://perf.golang.org/search?q=upload:20210415.6) and of the Tile38
benchmarks by ~4%. After this change, enabling ABI wrappers is
completely performance-neutral on Tile38 and all but one math
benchmark (full results:
https://perf.golang.org/search?q=upload:20210415.7). ABI wrappers slow
down SqrtIndirectLatency-12 by 2.09%, which makes sense because that
call must still go through an ABI wrapper.

With ABI wrappers disabled (which won't be an option on amd64 much
longer), on linux/amd64, this change is largely performance-neutral
and slightly improves the performance of a few benchmarks:

(Because there are so many benchmarks, I've applied the Šidák
correction to the alpha threshold. It makes relatively little
difference in which benchmarks are statistically significant.)

name                    old time/op  new time/op  delta
Acos-12                 22.3ns ± 0%  18.8ns ± 1%  -15.44%  (p=0.000 n=18+16)
Acosh-12                28.2ns ± 0%  28.2ns ± 0%     ~     (p=0.404 n=18+20)
Asin-12                 18.1ns ± 0%  18.2ns ± 0%   +0.20%  (p=0.000 n=18+16)
Asinh-12                32.8ns ± 0%  32.9ns ± 1%     ~     (p=0.891 n=18+20)
Atan-12                 9.92ns ± 0%  9.90ns ± 1%   -0.24%  (p=0.000 n=17+16)
Atanh-12                27.7ns ± 0%  27.5ns ± 0%   -0.72%  (p=0.000 n=16+20)
Atan2-12                18.5ns ± 0%  18.4ns ± 0%   -0.59%  (p=0.000 n=19+19)
Cbrt-12                 22.1ns ± 0%  22.1ns ± 0%     ~     (p=0.804 n=16+17)
Ceil-12                 0.84ns ± 0%  0.84ns ± 0%     ~     (p=0.663 n=18+16)
Copysign-12             0.84ns ± 0%  0.84ns ± 0%     ~     (p=0.762 n=16+19)
Cos-12                  12.7ns ± 0%  12.7ns ± 1%     ~     (p=0.145 n=19+18)
Cosh-12                 22.2ns ± 0%  22.5ns ± 0%   +1.60%  (p=0.000 n=17+19)
Erf-12                  11.1ns ± 1%  11.1ns ± 1%     ~     (p=0.010 n=19+19)
Erfc-12                 12.6ns ± 1%  12.7ns ± 0%     ~     (p=0.066 n=19+15)
Erfinv-12               16.1ns ± 0%  16.1ns ± 0%     ~     (p=0.462 n=17+20)
Erfcinv-12              16.0ns ± 1%  16.0ns ± 1%     ~     (p=0.015 n=17+16)
Exp-12                  16.3ns ± 0%  16.5ns ± 1%   +1.25%  (p=0.000 n=19+16)
ExpGo-12                36.2ns ± 1%  36.1ns ± 1%     ~     (p=0.242 n=20+18)
Expm1-12                18.6ns ± 0%  18.7ns ± 0%   +0.25%  (p=0.000 n=16+19)
Exp2-12                 34.7ns ± 0%  34.6ns ± 1%     ~     (p=0.010 n=19+18)
Exp2Go-12               34.8ns ± 1%  34.8ns ± 1%     ~     (p=0.372 n=19+19)
Abs-12                  0.56ns ± 0%  0.56ns ± 0%     ~     (p=0.766 n=18+16)
Dim-12                  0.84ns ± 1%  0.84ns ± 1%     ~     (p=0.167 n=17+19)
Floor-12                0.84ns ± 0%  0.84ns ± 0%     ~     (p=0.993 n=18+16)
Max-12                  3.35ns ± 0%  3.35ns ± 0%     ~     (p=0.894 n=17+19)
Min-12                  3.35ns ± 0%  3.36ns ± 1%     ~     (p=0.214 n=18+18)
Mod-12                  35.2ns ± 0%  34.7ns ± 0%   -1.45%  (p=0.000 n=18+17)
Frexp-12                5.31ns ± 0%  4.75ns ± 0%  -10.51%  (p=0.000 n=19+18)
Gamma-12                14.8ns ± 0%  16.2ns ± 1%   +9.21%  (p=0.000 n=20+19)
Hypot-12                6.16ns ± 0%  6.17ns ± 0%   +0.26%  (p=0.000 n=19+20)
HypotGo-12              7.79ns ± 1%  7.78ns ± 0%     ~     (p=0.497 n=18+17)
Ilogb-12                4.47ns ± 0%  4.47ns ± 0%     ~     (p=0.167 n=19+19)
J0-12                   76.0ns ± 0%  76.3ns ± 0%   +0.35%  (p=0.000 n=19+18)
J1-12                   76.8ns ± 1%  75.9ns ± 0%   -1.14%  (p=0.000 n=18+18)
Jn-12                    167ns ± 1%   168ns ± 1%     ~     (p=0.038 n=18+18)
Ldexp-12                6.98ns ± 0%  6.43ns ± 0%   -7.97%  (p=0.000 n=17+18)
Lgamma-12               15.9ns ± 0%  16.0ns ± 1%     ~     (p=0.011 n=20+17)
Log-12                  13.3ns ± 0%  13.4ns ± 1%   +0.37%  (p=0.000 n=15+18)
Logb-12                 4.75ns ± 0%  4.75ns ± 0%     ~     (p=0.831 n=16+18)
Log1p-12                19.5ns ± 0%  19.5ns ± 1%     ~     (p=0.851 n=18+17)
Log10-12                15.9ns ± 0%  14.0ns ± 0%  -11.92%  (p=0.000 n=17+16)
Log2-12                 7.88ns ± 1%  8.01ns ± 0%   +1.72%  (p=0.000 n=20+20)
Modf-12                 4.75ns ± 0%  4.34ns ± 0%   -8.66%  (p=0.000 n=19+17)
Nextafter32-12          5.31ns ± 0%  5.31ns ± 0%     ~     (p=0.389 n=17+18)
Nextafter64-12          5.03ns ± 1%  5.03ns ± 0%     ~     (p=0.774 n=17+18)
PowInt-12               29.9ns ± 0%  28.5ns ± 0%   -4.69%  (p=0.000 n=18+19)
PowFrac-12              91.0ns ± 0%  91.1ns ± 0%     ~     (p=0.029 n=19+19)
Pow10Pos-12             1.12ns ± 0%  1.12ns ± 0%     ~     (p=0.363 n=20+20)
Pow10Neg-12             3.90ns ± 0%  3.90ns ± 0%     ~     (p=0.921 n=17+18)
Round-12                2.31ns ± 0%  2.31ns ± 1%     ~     (p=0.390 n=18+18)
RoundToEven-12          0.84ns ± 0%  0.84ns ± 0%     ~     (p=0.280 n=18+19)
Remainder-12            31.6ns ± 0%  29.6ns ± 0%   -6.16%  (p=0.000 n=18+17)
Signbit-12              0.56ns ± 0%  0.56ns ± 0%     ~     (p=0.385 n=19+18)
Sin-12                  12.5ns ± 0%  12.5ns ± 0%     ~     (p=0.080 n=18+18)
Sincos-12               16.4ns ± 2%  16.4ns ± 2%     ~     (p=0.253 n=20+19)
Sinh-12                 26.1ns ± 0%  26.1ns ± 0%   +0.18%  (p=0.000 n=17+19)
SqrtIndirect-12         3.91ns ± 0%  3.90ns ± 0%     ~     (p=0.133 n=19+19)
SqrtLatency-12          2.79ns ± 0%  2.79ns ± 0%     ~     (p=0.226 n=16+19)
SqrtIndirectLatency-12  6.68ns ± 0%  6.37ns ± 2%   -4.66%  (p=0.000 n=17+20)
SqrtGoLatency-12        49.4ns ± 0%  49.4ns ± 0%     ~     (p=0.289 n=18+16)
SqrtPrime-12            3.18µs ± 0%  3.18µs ± 0%     ~     (p=0.084 n=17+18)
Tan-12                  13.8ns ± 0%  13.9ns ± 2%     ~     (p=0.292 n=19+20)
Tanh-12                 25.4ns ± 0%  25.4ns ± 0%     ~     (p=0.101 n=17+17)
Trunc-12                0.84ns ± 0%  0.84ns ± 0%     ~     (p=0.765 n=18+16)
Y0-12                   75.8ns ± 0%  75.9ns ± 1%     ~     (p=0.805 n=16+18)
Y1-12                   76.3ns ± 0%  75.3ns ± 1%   -1.34%  (p=0.000 n=19+17)
Yn-12                    164ns ± 0%   164ns ± 2%     ~     (p=0.356 n=18+20)
Float64bits-12          0.56ns ± 0%  0.56ns ± 0%     ~     (p=0.383 n=18+18)
Float64frombits-12      0.56ns ± 0%  0.56ns ± 0%     ~     (p=0.066 n=18+19)
Float32bits-12          0.56ns ± 0%  0.56ns ± 0%     ~     (p=0.889 n=16+19)
Float32frombits-12      0.56ns ± 0%  0.56ns ± 0%     ~     (p=0.007 n=18+19)
FMA-12                  23.9ns ± 0%  24.0ns ± 0%   +0.31%  (p=0.000 n=16+17)
[Geo mean]              9.86ns       9.77ns        -0.87%

(https://perf.golang.org/search?q=upload:20210415.5)

For #40724.

Change-Id: I44fbba2a17be930ec9daeb0a8222f55cd50555a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/310331
Trust: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-15 15:48:19 +00:00
Paul E. Murphy
31e12b953a cmd/link: issue error if elf header overruns
This is probably unlikely in practice, but when debugging alignment
related issues on ppc64 using very small text section splits, the elf
header could grow beyond the preallocated space and quietly stomp
on the first few text sections.

Change-Id: Ided58aa0b1e60f9da4b3cb277e4ebafcee4ec693
Reviewed-on: https://go-review.googlesource.com/c/go/+/307430
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
2021-04-15 14:58:38 +00:00
Austin Clements
7ad496b6f5 runtime: unify C->Go ABI transitions
The previous CL introduced macros for transitions from the Windows ABI
to the Go ABI. This CL does the same for SysV and uses them in almost
all places where we transition from the C ABI to the Go ABI.

Compared to Windows, this transition is much simpler and I didn't find
any places that were getting it wrong. But this does let us unify a
lot of code nicely and introduces some degree of abstraction around
these ABI transitions.

Change-Id: Ib6bdecafce587ce18fca4c8300fcf401284a2bcd
Reviewed-on: https://go-review.googlesource.com/c/go/+/309930
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-15 12:38:13 +00:00
Austin Clements
dba2eab826 runtime,runtime/cgo: save all necessary registers on entry to Go on Windows
There are several assembly functions that transition from the Windows
ABI to the Go ABI. These all need to save all registers that are
callee-save in the Windows ABI and caller-save in the Go ABI and
prepare the register state for Go. However, they all do this slightly
differently and most of them don't save the necessary XMM registers
for this transition (which could corrupt them in the C caller).
Furthermore, now that we have a carefully specified Go ABI, it's clear
that none of these actually get all of the details 100% right.

So, unify this code into two macros in a shared header in
runtime/cgo/abi_amd64.h that handle all necessary registers and setup
and use these macros everywhere on Windows that handles transitions
from C to Go.

Change-Id: I62f41345a507aad1ca383814ac8b7e2a9ffb821e
Reviewed-on: https://go-review.googlesource.com/c/go/+/309769
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-15 12:38:11 +00:00
Austin Clements
3e0b1cdb5d runtime: minor refactoring of _rt0_amd64_lib
This function bounces between the C and Go ABIs a few times. This CL
narrows the scope of the Go -> C transition to just around the branch
that calls C. This lets us take advantage of C callee-save registers
to simplify the code a little.

Change-Id: I1ffa0b9e50325425c5ec66596978aeb6450a6b57
Reviewed-on: https://go-review.googlesource.com/c/go/+/309929
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-15 12:38:09 +00:00
Tobias Klauser
b1c4cc5589 mime: keep builtinTypesLower sorted alphabetically
Updates #44602

Change-Id: I2c32e388143e56928850821587f57d9729434220
Reviewed-on: https://go-review.googlesource.com/c/go/+/310034
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-15 10:21:10 +00:00
Rémy Oudompheng
61a08fc6ce strconv: Implement Ryū algorithm for ftoa shortest mode
This patch implements the algorithm from Ulf Adams,
"Ryū: Fast Float-to-String Conversion" (doi:10.1145/3192366.3192369)
for formatting floating-point numbers with a fixed number of decimal
digits.

It is not a direct translation of the reference C implementation
but still follows the original paper. In particular, it uses full
128-bit powers of 10, which allows for more precision in the other
modes (fixed ftoa, atof).

name                              old time/op  new time/op   delta
AppendFloat/Decimal-4             49.6ns ± 3%   59.3ns ± 0%  +19.59%  (p=0.008 n=5+5)
AppendFloat/Float-4                122ns ± 1%     91ns ± 1%  -25.92%  (p=0.008 n=5+5)
AppendFloat/Exp-4                 89.3ns ± 1%  100.0ns ± 1%  +11.98%  (p=0.008 n=5+5)
AppendFloat/NegExp-4              88.3ns ± 2%   97.1ns ± 1%   +9.87%  (p=0.008 n=5+5)
AppendFloat/LongExp-4              143ns ± 2%    103ns ± 0%  -28.17%  (p=0.016 n=5+4)
AppendFloat/Big-4                  144ns ± 1%    110ns ± 1%  -23.26%  (p=0.008 n=5+5)
AppendFloat/BinaryExp-4           46.2ns ± 2%   46.0ns ± 1%     ~     (p=0.603 n=5+5)
AppendFloat/32Integer-4           49.1ns ± 1%   58.7ns ± 1%  +19.57%  (p=0.008 n=5+5)
AppendFloat/32ExactFraction-4     95.6ns ± 1%   88.6ns ± 1%   -7.30%  (p=0.008 n=5+5)
AppendFloat/32Point-4              122ns ± 1%     87ns ± 1%  -28.63%  (p=0.008 n=5+5)
AppendFloat/32Exp-4               88.6ns ± 2%   95.0ns ± 1%   +7.29%  (p=0.008 n=5+5)
AppendFloat/32NegExp-4            87.2ns ± 1%   91.3ns ± 1%   +4.63%  (p=0.008 n=5+5)
AppendFloat/32Shortest-4           107ns ± 1%     82ns ± 0%  -24.08%  (p=0.008 n=5+5)
AppendFloat/Slowpath64-4          1.00µs ± 1%   0.10µs ± 0%  -89.92%  (p=0.016 n=5+4)
AppendFloat/SlowpathDenormal64-4  34.1µs ± 3%    0.1µs ± 1%  -99.72%  (p=0.008 n=5+5)

Fixes #15672

Change-Id: Ib90dfa245f62490a6666671896013cf3f9a1fb22
Reviewed-on: https://go-review.googlesource.com/c/go/+/170080
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Nigel Tao <nigeltao@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2021-04-15 09:18:03 +00:00
Rémy Oudompheng
0184b445c0 strconv: implement Ryū-like algorithm for fixed precision ftoa
This patch implements a simplified version of Ulf Adams,
"Ryū: Fast Float-to-String Conversion" (doi:10.1145/3192366.3192369)
for formatting floating-point numbers with a fixed number of decimal
digits.

It uses the same principles but does not need to handle
the complex task of finding a shortest representation.
This allows to handle a few more cases than Grisu3, notably
formatting with up to 18 significant digits.

name                         old time/op  new time/op  delta
AppendFloat/32Fixed8Hard-4   72.0ns ± 2%  56.0ns ± 2%  -22.28%  (p=0.000 n=10+10)
AppendFloat/32Fixed9Hard-4   74.8ns ± 0%  64.2ns ± 2%  -14.16%  (p=0.000 n=8+10)
AppendFloat/64Fixed1-4       60.4ns ± 1%  54.2ns ± 1%  -10.31%  (p=0.000 n=10+9)
AppendFloat/64Fixed2-4       66.3ns ± 1%  53.3ns ± 1%  -19.54%  (p=0.000 n=10+9)
AppendFloat/64Fixed3-4       61.0ns ± 1%  55.0ns ± 2%   -9.80%  (p=0.000 n=9+10)
AppendFloat/64Fixed4-4       66.9ns ± 0%  52.0ns ± 2%  -22.20%  (p=0.000 n=8+10)
AppendFloat/64Fixed12-4      95.5ns ± 1%  76.2ns ± 3%  -20.19%  (p=0.000 n=10+9)
AppendFloat/64Fixed16-4      1.62µs ± 0%  0.07µs ± 2%  -95.69%  (p=0.000 n=10+10)
AppendFloat/64Fixed12Hard-4  1.27µs ± 1%  0.07µs ± 1%  -94.83%  (p=0.000 n=9+9)
AppendFloat/64Fixed17Hard-4  3.68µs ± 1%  0.08µs ± 2%  -97.86%  (p=0.000 n=10+9)
AppendFloat/64Fixed18Hard-4  3.67µs ± 0%  3.72µs ± 1%   +1.44%  (p=0.000 n=9+10)

Updates #15672

Change-Id: I160963e141dd48287ad8cf57bcc3c686277788e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/170079
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Nigel Tao <nigeltao@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-15 08:44:21 +00:00
Austin Clements
8f4c5068e0 internal/bytealg: port more performance-critical functions to ABIInternal
CL 308931 ported several runtime assembly functions to ABIInternal so
that compiler-generated ABIInternal calls don't go through ABI
wrappers, but it missed the runtime assembly functions that are
actually defined in internal/bytealg.

This eliminates the cost of wrappers for the BleveQuery and
GopherLuaKNucleotide benchmarks, but there's still more to do for
Tile38.

                                      0-base                1-wrappers
                                     sec/op        sec/op            vs base
BleveQuery                          6.507 ± 0%    6.477 ± 0%  -0.46% (p=0.004 n=20)
GopherLuaKNucleotide                30.39 ± 1%    30.34 ± 0%       ~ (p=0.301 n=20)
Tile38IntersectsCircle100kmRequest 1.038m ± 1%   1.080m ± 2%  +4.03% (p=0.000 n=20)

For #40724.

Change-Id: I0b722443f684fcb997b1d70802c5ed4b8d8f9829
Reviewed-on: https://go-review.googlesource.com/c/go/+/310184
Trust: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-15 04:10:33 +00:00
eric fang
48b7432e3f cmd/internal/obj/arm64: fix the wrong sp dst register of ADDS/SUBS instructions
According the armv8-a specification, the destination register of the ADDS/ADDSW/
SUBS/SUBSW instructions can not be RSP, the current implementation does not
check this and encodes this wrong instruction format as a CMN instruction. This
CL adds a check and test cases for this situation.

Change-Id: I92cc2f8e17dbda70f0dce8fddf1ca6d5d7730589
Reviewed-on: https://go-review.googlesource.com/c/go/+/309989
Reviewed-by: eric fang <eric.fang@arm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: eric fang <eric.fang@arm.com>
Run-TryBot: eric fang <eric.fang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-15 01:54:41 +00:00
Damien Neil
566a87c16b time: add missing "os" import to zoneinfo_test.go
Updates #45448

Change-Id: I2e79ae6b9cf43a481aa703578712619ea344e421
Reviewed-on: https://go-review.googlesource.com/c/go/+/310212
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-15 00:40:43 +00:00
Keith Randall
083a26c7d2 cmd/compile: propagate pragmas from generic function to stenciled implementation
Change-Id: I28a1910890659aaa449ffd2a847cd4ced5a8600d
Reviewed-on: https://go-review.googlesource.com/c/go/+/310211
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2021-04-15 00:29:05 +00:00
Dan Scales
bf634c76b2 cmd/compile: look for function in instantiations in all global assignments
Add in some missing global assignment ops to the list of globals ops
that should be traversed to look for generic function instantiations.
The most common other one for global assigments (and the relevant one
for this bug) is OAS2FUNC, but also look at global assigments with
OAS2DOTTYPE, OAS2MAPR, OAS2RECV, and OASOP.

Bonus small fix: get rid of -G=3 case in ir.IsAddressable. Now that we
don't call the old typechecker from noder2, we don't need this -G-3
check anymore.

Fixes #45547.

Change-Id: I75fecec55ea0d6f62e1c2294d4d77447ed9be6ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/310210
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-15 00:14:55 +00:00
Amit Kumar
567a9322ad mime: add mime type for avif image file format
Fixes #44602

Change-Id: I28b6df5e2523fc2ece6fd8251fcabc83c7c38d89
Reviewed-on: https://go-review.googlesource.com/c/go/+/256478
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-14 23:26:26 +00:00
Manlio Perillo
d27bb8ba2e go/build: replace os.Setenv with T.Setenv
Updates #45448

Change-Id: I4d8e5d7e57818355ef2bc33b57ddf9c8b8da3e62
Reviewed-on: https://go-review.googlesource.com/c/go/+/310030
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
2021-04-14 23:26:15 +00:00
Manlio Perillo
f18715c18f time: replace os.Setenv with T.Setenv
Updates #45448

Change-Id: Ic096fe1c58c124fb8d84ee15c9446e7ed060b24f
Reviewed-on: https://go-review.googlesource.com/c/go/+/310032
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
2021-04-14 23:26:02 +00:00
ian woolf
c3931ab1b7 net/http/httptest: panic on non-3 digit (XXX) status code in Recorder.WriteHeader
This change conforms Recorder with net/http servers, to panic
when a handler writes a non-3 digit XXX status code.

Fixes #45353

Change-Id: Id5ed4af652e8c150ae86bf50402b800d935e2203
Reviewed-on: https://go-review.googlesource.com/c/go/+/308950
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
2021-04-14 21:58:06 +00:00
Bryan C. Mills
cbf9caaf22 cmd/go: add a Go source file in TestScript/mod_sumdb
This test expects 'go mod tidy' to fail if the existing module graph
has a bad checksum. However, there is no intrinsic reason why 'go mod
tidy' should fail in that case: the module contains no packages, and
thus no imports, so 'go mod tidy' can justifiably remove all
requirements without regard to any errors that may have already been
present in the module graph.

Adding a source file that imports a package from the module with the
bad checksum should guarantee that 'go mod tidy' reports the checksum
eror.

For #36460

Change-Id: I59734ac524031288bc03a11f58eed5abe2db76b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/309334
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-04-14 21:50:26 +00:00
Cherry Zhang
23f8c203f0 cmd/compile: rework/reduce partially lived argument spilling
In CL 307909 we generate code that spills pointer-typed argument
registers if it is part of an SSA-able aggregate. The current
code spill the register unconditionally. Sometimes it is
unnecessary, because it is already spilled, or it is never live.

This CL reworks the spill generation. We move it to the end of
compilation, after liveness analysis, so we have information about
if a spill is necessary, and only generate spills for the
necessary ones.

Change-Id: I8d60be9b2c47651aeda14f5e2d1bbd207c134b26
Reviewed-on: https://go-review.googlesource.com/c/go/+/309331
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-14 21:00:20 +00:00
Than McIntosh
1a8f0a7961 runtime: fix data race in abi finalizer test
Fix a buglet in TestFinalizerRegisterABI that was causing problems
when run with GOEXPERIMENT=regabi.

Updates #40724.

Change-Id: I950c4aa3df69eada23e600f01e6804eb136ce806
Reviewed-on: https://go-review.googlesource.com/c/go/+/310077
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-14 19:57:35 +00:00
Michael Anthony Knyszek
a89ace106f runtime: update debug call protocol for register ABI
The debug call tests currently assume that the target Go function is
ABI0; this is clearly no longer true when we switch to the new ABI, so
make the tests set up argument register state in the debug call handler
and copy back results returned in registers.

A small snag in calling a Go function that follows the new ABI is that
the debug call protocol depends on the AX register being set to a
specific value as it bounces in and out of the handler, but this
register is part of the new register ABI, so results end up being
clobbered. Use R12 instead.

Next, the new desugaring behavior for "go" statements means that
newosproc1 must always call a function with no frame; if it takes any
arguments, it closes over them and they're passed in the context
register. Currently when debugCallWrap creates a new goroutine, it uses
newosproc1 directly and passes a non-zero-sized frame, so that needs to
be updated. To fix this, briefly use the g's param field which is
otherwise only used for channels to pass an explicitly allocated object
containing the "closed over" variables. While we could manually do the
desugaring ourselves (we cannot do so automatically because the Go
compiler prevents heap-allocated closures in the runtime), that bakes in
more ABI details in a place that really doesn't need to care about them.

Finally, there's an old bug here where the context register was set up
in CX, so technically closure calls never worked. Oops. It was otherwise
harmless for other types of calls before, but now CX is an argument
register, so now that interferes with regular calls, too.

For #40724.

Change-Id: I652c25ed56a25741bb04c24cfb603063c099edde
Reviewed-on: https://go-review.googlesource.com/c/go/+/309169
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-14 19:54:26 +00:00
Manlio Perillo
de7a87ef06 go/internal/gccgoimporter: replace os.MkdirTemp with T.TempDir
Updates #45402

Change-Id: Ie84795ed456883c0558fa9b5e3f2186f5f2c0fd9
Reviewed-on: https://go-review.googlesource.com/c/go/+/309356
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
2021-04-14 19:38:50 +00:00
Martin Sucha
d1f8104b58 time: move slim test tzdata to testdata directory
The lines with tzdata are quite long.

It is easier to just copy a file than to encode it as
a string literal when adding a new test case.

Change-Id: Ibcaf347c3101a0f05b094e582b3473c7c35b685a
Reviewed-on: https://go-review.googlesource.com/c/go/+/308998
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
2021-04-14 19:38:36 +00:00
Manlio Perillo
b161b57c3f go/build: replace os.MkdirTemp with T.TempDir
Updates #45402

Change-Id: Ic2f696837034de17333a6a53127a4bfd301e96a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/309354
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
2021-04-14 19:38:22 +00:00
Robert Griesemer
892cad7a9b cmd/compile/internal/types2: add Named.SetTParams and Named.Orig methods
Named.SetTParams sets the type parameters for a named type.

Named.Orig returns the original generic type an instantiated
type is derived from. Added a new field orig for that purpose
and renamed the already existing orig field to fromRHS.

Finally, updated various comments.

Change-Id: Ic9d173e42740422d195713d8bdc62a54dc8c5f54
Reviewed-on: https://go-review.googlesource.com/c/go/+/309832
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-14 19:35:43 +00:00
Rob Findley
283f9fdbd3 cmd/dist: add tests using the typeparams build tag
Now that go/ast changes have been guarded behind the typeparams build
tag, we no longer have coverage for tests involving generic code.

Add a new testing step to cmd/dist to run go/... and cmd/gofmt tests
using -tags=typeparams.

Comment out parser object resolution assertions that currently fail, and
which will be fixed by CL 304456.

Fixes #44933

Change-Id: I481dd4246a016f410307865b6c6c2bb3c8e6e3bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/310071
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-14 19:32:56 +00:00
Rob Findley
bcbde83c20 go/ast: fix broken build with typeparams build constraint
My rebase of https://golang.org/cl/300649 before submitting broke the
build (and tests) when using the typeparams build constraint. In a
subsequent CL I add test coverage back to cmd/dist.

This time, I've tested by running:
 - go test -tags=typeparams go/...
 - go test -tags=typeparams cmd/gofmt

All tests pass except for the new TestResolution/typeparams.go2, which I
will fix in a follow-up CL.

For #44933

Change-Id: I439d387841604cf43a90e2ce41dbe6bbbdb0306d
Reviewed-on: https://go-review.googlesource.com/c/go/+/310070
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-04-14 19:32:31 +00:00