]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
14 months agolog/slog: initial commit
Jonathan Amsterdam [Fri, 17 Mar 2023 14:20:01 +0000 (10:20 -0400)]
log/slog: initial commit

The slog structured logging package.

This code was copied from the slog directory of the x/exp repo
at commit 642cacee5cc05231f45555a333d07f1005ffc287, with the
following changes:

- Change import paths.
- Delete unused files list.go, list_test.go.
- Rename example_depth_test.go to example_wrap_test.go and
  adjust example output.
- Change the tag safe_values to safe_slog_values.
- Make captureHandler goroutine-safe to fix a race condition
  in benchmarks.
- Other small changes as suggested in review comments.

Also, add dependencies to go/build/deps_test.go.

Also, add new API for the API checker.

Updates golang/go#56345.

Change-Id: Id8d720967571ced5c5f32c84a8dd9584943cd7df
Reviewed-on: https://go-review.googlesource.com/c/go/+/477295
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
14 months agoruntime: bias the pacer's cons/mark smoothing against noise
Michael Anthony Knyszek [Mon, 13 Feb 2023 21:45:38 +0000 (21:45 +0000)]
runtime: bias the pacer's cons/mark smoothing against noise

Currently the pacer is designed to pace against the edge. Specifically,
it tries to find the sweet spot at which there are zero assists, but
simultaneously finishes each GC perfectly on time.

This pretty much works, despite the noisiness of the measurement of the
cons/mark ratio, which is central to the pacer's function. (And this
noise is basically a given; the cons/mark ratio is used as a prediction
under a steady-state assumption.) Typically, this means that the GC
might assist a little bit more because it started the GC late, or it
might execute more GC cycles because it started early. In many cases the
magnitude of this variation is small.

However, we can't possibly control for all sources of noise, especially
since some noise can come from the underlying system. Furthermore, there
are inputs to the measurement that have effectively no restrictions on
how they vary, and the pacer needs to assume that they're essentially
static when they might not be in some applications (i.e. goroutine
stacks).

The result of high noise is that the variation in when a GC starts is
much higher, leading to a significant amount of assists in some GC
cycles. While the GC cycle frequency basically averages out in the
steady-state in the face of this variation, starting a GC late has the
significant drawback of reducing application latencies.

This CL thus biases the pacer toward avoiding assists by picking a
cons/mark smoothing function that takes the maximum measured cons/mark
over 5 cycles total. I picked 5 cycles because empirically this was the
best trade-off between window size and smoothness for a uniformly
distributed jitter in the cons/mark signal. The cost here is that if
there's a significant phase change in the application that makes it less
active with the GC, then we'll be using a stale cons/mark measurement
for 5 cycles. I suspect this is fine precisely because this only happens
when the application becomes less active, i.e. when latency matters
less.

Another good reason for this particular bias is that even though the GC
might start earlier and end earlier on average, resulting in more
frequent GC cycles and potentially worse throughput, it also means that
it uses less memory used on average. As a result, there's a reasonable
workaround in just turning GOGC up slightly to reduce GC cycle
frequency and bringing memory (and hopefully throughput) levels back to
the same baseline. Meanwhile, there should still be fewer assists than
before which is just a clear improvement to latency.

Lastly, this CL updates the GC pacer tests to capture this bias against
assists and toward GC cycles starting earlier in the face of noise.

Sweet benchmarks didn't show any meaningful difference, but real
production applications showed a reduction in tail latencies of up
to 45%.

Updates #56966.

Change-Id: I8f03d793f9a1c6e7ef3524d18294dbc0d7de6122
Reviewed-on: https://go-review.googlesource.com/c/go/+/467875
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>

14 months agoruntime: for deep stacks, print both the top 50 and bottom 50 frames
Austin Clements [Mon, 13 Mar 2023 18:02:16 +0000 (14:02 -0400)]
runtime: for deep stacks, print both the top 50 and bottom 50 frames

This is relatively easy using the new traceback iterator.

Ancestor tracebacks are now limited to 50 frames. We could keep that
at 100, but the fact that it used 100 before seemed arbitrary and
unnecessary.

Fixes #7181
Updates #54466

Change-Id: If693045881d84848f17e568df275a5105b6f1cb0
Reviewed-on: https://go-review.googlesource.com/c/go/+/475960
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
14 months agoruntime: let (*sigctxt).r9 return the correct register value on netbsd
Tobias Klauser [Tue, 21 Mar 2023 16:44:29 +0000 (17:44 +0100)]
runtime: let (*sigctxt).r9 return the correct register value on netbsd

Fixes #59152

Change-Id: I7f89e2b48db9ff120d7cd094b72ded865874e961
Reviewed-on: https://go-review.googlesource.com/c/go/+/478135
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
14 months agocmd/link: improve error message and debugging
Cherry Mui [Wed, 15 Mar 2023 21:38:35 +0000 (17:38 -0400)]
cmd/link: improve error message and debugging

Correct an error message to missing section, not unreachable
symbol.

Also, under -v >= 2, dump symbol info on error for debugging.

Updates #58966.

Change-Id: I0f832c517d64f4b672b313a8b9be2d028744f945
Reviewed-on: https://go-review.googlesource.com/c/go/+/476735
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
14 months agointernal/bytealg: rewrite PPC64 Compare
Paul E. Murphy [Mon, 27 Feb 2023 22:04:50 +0000 (16:04 -0600)]
internal/bytealg: rewrite PPC64 Compare

Merge the P8 and P9 paths into one. This removes the need for
a runtime CPU check and maintaining two separate code paths.

This takes advantage of overlapping checks, and the P9 SETB
(emulated with little overhead on P8) to speed up comparisons
of small strings.

Similarly, the SETB instruction can be used on GOPPC64=power9
which provides a small speedup over using a couple ISELs. This
only accounts for a few percent on very small strings, thus
results of running P8 codegen on P9 are left out.

For the baseline on a power8 machine:

BytesCompare/1     7.76ns ± 0%  6.38ns ± 0%  -17.71%
BytesCompare/2     7.77ns ± 0%  6.36ns ± 0%  -18.12%
BytesCompare/3     7.56ns ± 0%  6.36ns ± 0%  -15.79%
BytesCompare/4     7.76ns ± 0%  5.74ns ± 0%  -25.99%
BytesCompare/5     7.48ns ± 0%  5.74ns ± 0%  -23.29%
BytesCompare/6     7.56ns ± 0%  5.74ns ± 0%  -24.06%
BytesCompare/7     7.14ns ± 0%  5.74ns ± 0%  -19.63%
BytesCompare/8     5.58ns ± 0%  5.19ns ± 0%   -7.03%
BytesCompare/9     7.85ns ± 0%  5.19ns ± 0%  -33.86%
BytesCompare/10    7.87ns ± 0%  5.19ns ± 0%  -34.06%
BytesCompare/11    7.59ns ± 0%  5.19ns ± 0%  -31.59%
BytesCompare/12    7.87ns ± 0%  5.19ns ± 0%  -34.02%
BytesCompare/13    7.55ns ± 0%  5.19ns ± 0%  -31.24%
BytesCompare/14    7.47ns ± 0%  5.19ns ± 0%  -30.53%
BytesCompare/15    7.88ns ± 0%  5.19ns ± 0%  -34.09%
BytesCompare/16    6.07ns ± 0%  5.58ns ± 0%   -8.08%
BytesCompare/17    9.05ns ± 0%  5.62ns ± 0%  -37.94%
BytesCompare/18    8.95ns ± 0%  5.62ns ± 0%  -37.24%
BytesCompare/19    8.49ns ± 0%  5.62ns ± 0%  -33.81%
BytesCompare/20    9.07ns ± 0%  5.62ns ± 0%  -38.05%
BytesCompare/21    8.69ns ± 0%  5.62ns ± 0%  -35.37%
BytesCompare/22    8.57ns ± 0%  5.62ns ± 0%  -34.43%
BytesCompare/23    8.31ns ± 0%  5.62ns ± 0%  -32.38%
BytesCompare/24    8.42ns ± 0%  5.62ns ± 0%  -33.23%
BytesCompare/25    9.70ns ± 0%  5.56ns ± 0%  -42.69%
BytesCompare/26    9.53ns ± 0%  5.56ns ± 0%  -41.66%
BytesCompare/27    9.29ns ± 0%  5.56ns ± 0%  -40.15%
BytesCompare/28    9.53ns ± 0%  5.56ns ± 0%  -41.65%
BytesCompare/29    9.37ns ± 0%  5.56ns ± 0%  -40.63%
BytesCompare/30    9.17ns ± 0%  5.56ns ± 0%  -39.36%
BytesCompare/31    9.07ns ± 0%  5.56ns ± 0%  -38.71%
BytesCompare/32    5.81ns ± 0%  5.49ns ± 0%   -5.49%
BytesCompare/33    9.36ns ± 0%  5.32ns ± 0%  -43.17%
BytesCompare/34    9.44ns ± 0%  5.32ns ± 0%  -43.68%
BytesCompare/35    8.91ns ± 0%  5.32ns ± 0%  -40.29%
BytesCompare/36    9.45ns ± 0%  5.32ns ± 0%  -43.71%
BytesCompare/37    8.94ns ± 0%  5.32ns ± 0%  -40.53%
BytesCompare/38    9.08ns ± 0%  5.32ns ± 0%  -41.44%
BytesCompare/39    8.62ns ± 0%  5.32ns ± 0%  -38.33%
BytesCompare/40    7.93ns ± 0%  5.32ns ± 0%  -32.93%
BytesCompare/41    10.1ns ± 0%   5.3ns ± 0%  -47.08%
BytesCompare/42    10.1ns ± 0%   5.3ns ± 0%  -47.43%
BytesCompare/43    9.80ns ± 0%  5.32ns ± 0%  -45.66%
BytesCompare/44    10.3ns ± 0%   5.3ns ± 0%  -48.26%
BytesCompare/45    9.88ns ± 0%  5.33ns ± 0%  -46.08%
BytesCompare/46    9.82ns ± 0%  5.32ns ± 0%  -45.81%
BytesCompare/47    9.73ns ± 0%  5.33ns ± 0%  -45.25%
BytesCompare/48    8.31ns ± 0%  5.22ns ± 0%  -37.19%
BytesCompare/49    11.2ns ± 0%   5.2ns ± 0%  -53.28%
BytesCompare/50    11.1ns ± 0%   5.2ns ± 0%  -52.86%
BytesCompare/51    10.8ns ± 0%   5.2ns ± 0%  -51.37%
BytesCompare/52    11.1ns ± 0%   5.2ns ± 0%  -52.94%
BytesCompare/53    10.8ns ± 0%   5.2ns ± 0%  -51.50%
BytesCompare/54    10.7ns ± 0%   5.2ns ± 0%  -51.09%
BytesCompare/55    10.3ns ± 0%   5.2ns ± 0%  -49.49%
BytesCompare/56    10.9ns ± 0%   5.2ns ± 0%  -51.73%
BytesCompare/57    12.2ns ± 0%   5.3ns ± 0%  -56.92%
BytesCompare/58    12.2ns ± 0%   5.3ns ± 0%  -56.81%
BytesCompare/59    11.5ns ± 0%   5.3ns ± 0%  -54.45%
BytesCompare/60    12.1ns ± 0%   5.3ns ± 0%  -56.67%
BytesCompare/61    11.7ns ± 0%   5.3ns ± 0%  -54.96%
BytesCompare/62    11.9ns ± 0%   5.3ns ± 0%  -55.76%
BytesCompare/63    11.4ns ± 0%   5.3ns ± 0%  -53.73%
BytesCompare/64    6.08ns ± 0%  5.47ns ± 0%   -9.96%
BytesCompare/65    9.87ns ± 0%  5.96ns ± 0%  -39.57%
BytesCompare/66    9.81ns ± 0%  5.96ns ± 0%  -39.25%
BytesCompare/67    9.49ns ± 0%  5.96ns ± 0%  -37.18%
BytesCompare/68    9.81ns ± 0%  5.96ns ± 0%  -39.26%
BytesCompare/69    9.44ns ± 0%  5.96ns ± 0%  -36.84%
BytesCompare/70    9.58ns ± 0%  5.96ns ± 0%  -37.75%
BytesCompare/71    9.24ns ± 0%  5.96ns ± 0%  -35.50%
BytesCompare/72    8.26ns ± 0%  5.94ns ± 0%  -28.09%
BytesCompare/73    10.6ns ± 0%   5.9ns ± 0%  -43.70%
BytesCompare/74    10.6ns ± 0%   5.9ns ± 0%  -43.87%
BytesCompare/75    10.2ns ± 0%   5.9ns ± 0%  -41.83%
BytesCompare/76    10.7ns ± 0%   5.9ns ± 0%  -44.55%
BytesCompare/77    10.3ns ± 0%   5.9ns ± 0%  -42.51%
BytesCompare/78    10.3ns ± 0%   5.9ns ± 0%  -42.29%
BytesCompare/79    10.2ns ± 0%   5.9ns ± 0%  -41.95%
BytesCompare/80    8.74ns ± 0%  5.93ns ± 0%  -32.23%
BytesCompare/81    11.7ns ± 0%   6.8ns ± 0%  -41.87%
BytesCompare/82    11.7ns ± 0%   6.8ns ± 0%  -41.54%
BytesCompare/83    11.1ns ± 0%   6.8ns ± 0%  -38.32%
BytesCompare/84    11.7ns ± 0%   6.8ns ± 0%  -41.59%
BytesCompare/85    11.2ns ± 0%   6.8ns ± 0%  -38.93%
BytesCompare/86    11.2ns ± 0%   6.8ns ± 0%  -38.87%
BytesCompare/87    10.8ns ± 0%   6.8ns ± 0%  -37.07%
BytesCompare/88    11.3ns ± 0%   6.7ns ± 0%  -40.57%
BytesCompare/89    12.6ns ± 0%   6.7ns ± 0%  -46.57%
BytesCompare/90    12.6ns ± 0%   6.7ns ± 0%  -46.44%
BytesCompare/91    11.9ns ± 0%   6.7ns ± 0%  -43.66%
BytesCompare/92    12.5ns ± 0%   6.7ns ± 0%  -46.09%
BytesCompare/93    12.2ns ± 0%   6.7ns ± 0%  -44.90%
BytesCompare/94    12.4ns ± 0%   6.7ns ± 0%  -45.62%
BytesCompare/95    11.8ns ± 0%   6.7ns ± 0%  -43.00%
BytesCompare/96    7.25ns ± 0%  6.62ns ± 0%   -8.70%
BytesCompare/97    11.1ns ± 0%   7.2ns ± 0%  -34.98%
BytesCompare/98    10.9ns ± 0%   7.2ns ± 0%  -34.03%
BytesCompare/99    10.4ns ± 0%   7.2ns ± 0%  -31.19%
BytesCompare/100   10.9ns ± 0%   7.2ns ± 0%  -33.97%
BytesCompare/101   10.4ns ± 0%   7.2ns ± 0%  -31.19%
BytesCompare/102   10.7ns ± 0%   7.2ns ± 0%  -32.72%
BytesCompare/103   10.2ns ± 0%   7.2ns ± 0%  -29.28%
BytesCompare/104   9.38ns ± 0%  7.19ns ± 0%  -23.33%
BytesCompare/105   11.7ns ± 0%   7.2ns ± 0%  -38.60%
BytesCompare/106   11.7ns ± 0%   7.2ns ± 0%  -38.28%
BytesCompare/107   11.3ns ± 0%   7.2ns ± 0%  -36.48%
BytesCompare/108   11.7ns ± 0%   7.2ns ± 0%  -38.49%
BytesCompare/109   11.4ns ± 0%   7.2ns ± 0%  -36.76%
BytesCompare/110   11.3ns ± 0%   7.2ns ± 0%  -36.37%
BytesCompare/111   11.1ns ± 0%   7.2ns ± 0%  -35.05%
BytesCompare/112   9.95ns ± 0%  7.19ns ± 0%  -27.71%
BytesCompare/113   12.7ns ± 0%   7.0ns ± 0%  -44.71%
BytesCompare/114   12.6ns ± 0%   7.0ns ± 0%  -44.23%
BytesCompare/115   12.3ns ± 0%   7.0ns ± 0%  -42.83%
BytesCompare/116   12.7ns ± 0%   7.0ns ± 0%  -44.67%
BytesCompare/117   12.2ns ± 0%   7.0ns ± 0%  -42.41%
BytesCompare/118   12.2ns ± 0%   7.0ns ± 0%  -42.50%
BytesCompare/119   11.9ns ± 0%   7.0ns ± 0%  -40.76%
BytesCompare/120   12.3ns ± 0%   7.0ns ± 0%  -43.01%
BytesCompare/121   13.7ns ± 0%   7.0ns ± 0%  -48.55%
BytesCompare/122   13.6ns ± 0%   7.0ns ± 0%  -48.06%
BytesCompare/123   12.9ns ± 0%   7.0ns ± 0%  -45.44%
BytesCompare/124   13.5ns ± 0%   7.0ns ± 0%  -47.91%
BytesCompare/125   13.0ns ± 0%   7.0ns ± 0%  -46.03%
BytesCompare/126   13.2ns ± 0%   7.0ns ± 0%  -46.72%
BytesCompare/127   12.9ns ± 0%   7.0ns ± 0%  -45.36%
BytesCompare/128   7.53ns ± 0%  6.78ns ± 0%   -9.95%
BytesCompare/256   10.1ns ± 0%   9.6ns ± 0%   -4.35%
BytesCompare/512   23.0ns ± 0%  15.3ns ± 0%  -33.30%
BytesCompare/1024  36.4ns ± 0%  32.8ns ± 0%   -9.83%
BytesCompare/2048  62.0ns ± 0%  56.0ns ± 0%   -9.77%

For GOPPC64=power9 on power9:

BytesCompare/1     5.95ns ± 0%  4.83ns ± 0%  -18.89%
BytesCompare/2     6.37ns ± 0%  4.69ns ± 0%  -26.39%
BytesCompare/3     6.87ns ± 0%  4.68ns ± 0%  -31.79%
BytesCompare/4     5.86ns ± 0%  4.63ns ± 0%  -20.98%
BytesCompare/5     5.84ns ± 0%  4.63ns ± 0%  -20.67%
BytesCompare/6     5.84ns ± 0%  4.63ns ± 0%  -20.70%
BytesCompare/7     5.82ns ± 0%  4.63ns ± 0%  -20.40%
BytesCompare/8     5.81ns ± 0%  4.64ns ± 0%  -20.23%
BytesCompare/9     5.83ns ± 0%  4.71ns ± 0%  -19.19%
BytesCompare/10    6.22ns ± 0%  4.71ns ± 0%  -24.32%
BytesCompare/11    6.94ns ± 0%  4.71ns ± 0%  -32.16%
BytesCompare/12    5.77ns ± 0%  4.71ns ± 0%  -18.34%
BytesCompare/13    5.77ns ± 0%  4.71ns ± 0%  -18.44%
BytesCompare/14    5.77ns ± 0%  4.71ns ± 0%  -18.31%
BytesCompare/15    6.31ns ± 0%  4.71ns ± 0%  -25.32%
BytesCompare/16    4.99ns ± 0%  5.03ns ± 0%   +0.72%
BytesCompare/17    5.07ns ± 0%  5.03ns ± 0%   -0.87%
BytesCompare/18    5.07ns ± 0%  5.03ns ± 0%   -0.81%
BytesCompare/19    5.07ns ± 0%  5.03ns ± 0%   -0.85%
BytesCompare/20    5.07ns ± 0%  5.03ns ± 0%   -0.73%
BytesCompare/21    5.07ns ± 0%  5.03ns ± 0%   -0.81%
BytesCompare/22    5.07ns ± 0%  5.03ns ± 0%   -0.77%
BytesCompare/23    5.07ns ± 0%  5.03ns ± 0%   -0.75%
BytesCompare/24    5.08ns ± 0%  5.07ns ± 0%   -0.12%
BytesCompare/25    5.03ns ± 0%  5.00ns ± 0%   -0.60%
BytesCompare/26    5.02ns ± 0%  5.00ns ± 0%   -0.56%
BytesCompare/27    5.03ns ± 0%  5.00ns ± 0%   -0.60%
BytesCompare/28    5.03ns ± 0%  5.00ns ± 0%   -0.72%
BytesCompare/29    5.03ns ± 0%  5.00ns ± 0%   -0.68%
BytesCompare/30    5.03ns ± 0%  5.00ns ± 0%   -0.76%
BytesCompare/31    5.03ns ± 0%  5.00ns ± 0%   -0.60%
BytesCompare/32    5.02ns ± 0%  5.05ns ± 0%   +0.56%
BytesCompare/33    6.78ns ± 0%  5.16ns ± 0%  -23.84%
BytesCompare/34    7.26ns ± 0%  5.16ns ± 0%  -28.93%
BytesCompare/35    7.78ns ± 0%  5.16ns ± 0%  -33.65%
BytesCompare/36    6.72ns ± 0%  5.16ns ± 0%  -23.24%
BytesCompare/37    7.32ns ± 0%  5.16ns ± 0%  -29.55%
BytesCompare/38    7.26ns ± 0%  5.16ns ± 0%  -28.95%
BytesCompare/39    7.99ns ± 0%  5.16ns ± 0%  -35.40%
BytesCompare/40    6.67ns ± 0%  5.11ns ± 0%  -23.41%
BytesCompare/41    7.25ns ± 0%  5.14ns ± 0%  -29.05%
BytesCompare/42    7.47ns ± 0%  5.14ns ± 0%  -31.11%
BytesCompare/43    7.97ns ± 0%  5.14ns ± 0%  -35.42%
BytesCompare/44    7.29ns ± 0%  5.14ns ± 0%  -29.38%
BytesCompare/45    8.06ns ± 0%  5.14ns ± 0%  -36.20%
BytesCompare/46    7.89ns ± 0%  5.14ns ± 0%  -34.77%
BytesCompare/47    8.59ns ± 0%  5.14ns ± 0%  -40.13%
BytesCompare/48    5.57ns ± 0%  5.12ns ± 0%   -8.18%
BytesCompare/49    6.05ns ± 0%  5.17ns ± 0%  -14.48%
BytesCompare/50    6.05ns ± 0%  5.17ns ± 0%  -14.51%
BytesCompare/51    6.06ns ± 0%  5.17ns ± 0%  -14.61%
BytesCompare/52    6.05ns ± 0%  5.17ns ± 0%  -14.54%
BytesCompare/53    6.06ns ± 0%  5.17ns ± 0%  -14.56%
BytesCompare/54    6.05ns ± 0%  5.17ns ± 0%  -14.54%
BytesCompare/55    6.05ns ± 0%  5.17ns ± 0%  -14.54%
BytesCompare/56    6.02ns ± 0%  5.11ns ± 0%  -15.13%
BytesCompare/57    6.01ns ± 0%  5.14ns ± 0%  -14.56%
BytesCompare/58    6.02ns ± 0%  5.14ns ± 0%  -14.59%
BytesCompare/59    6.02ns ± 0%  5.14ns ± 0%  -14.65%
BytesCompare/60    6.03ns ± 0%  5.14ns ± 0%  -14.71%
BytesCompare/61    6.02ns ± 0%  5.14ns ± 0%  -14.69%
BytesCompare/62    6.01ns ± 0%  5.14ns ± 0%  -14.55%
BytesCompare/63    6.02ns ± 0%  5.14ns ± 0%  -14.65%
BytesCompare/64    6.09ns ± 0%  5.15ns ± 0%  -15.34%
BytesCompare/65    7.83ns ± 0%  5.93ns ± 0%  -24.17%
BytesCompare/66    7.86ns ± 0%  5.93ns ± 0%  -24.52%
BytesCompare/67    8.56ns ± 0%  5.93ns ± 0%  -30.68%
BytesCompare/68    7.90ns ± 0%  5.93ns ± 0%  -24.88%
BytesCompare/69    8.58ns ± 0%  5.93ns ± 0%  -30.84%
BytesCompare/70    8.54ns ± 0%  5.93ns ± 0%  -30.48%
BytesCompare/71    9.18ns ± 0%  5.94ns ± 0%  -35.34%
BytesCompare/72    7.89ns ± 0%  5.86ns ± 0%  -25.76%
BytesCompare/73    8.59ns ± 0%  5.82ns ± 0%  -32.25%
BytesCompare/74    8.52ns ± 0%  5.82ns ± 0%  -31.61%
BytesCompare/75    9.17ns ± 0%  5.82ns ± 0%  -36.50%
BytesCompare/76    8.54ns ± 0%  5.82ns ± 0%  -31.85%
BytesCompare/77    9.25ns ± 0%  5.82ns ± 0%  -37.07%
BytesCompare/78    9.17ns ± 0%  5.82ns ± 0%  -36.48%
BytesCompare/79    10.0ns ± 0%   5.8ns ± 0%  -41.66%
BytesCompare/80    6.76ns ± 0%  5.69ns ± 0%  -15.90%
BytesCompare/81    7.63ns ± 0%  6.70ns ± 0%  -12.23%
BytesCompare/82    7.63ns ± 0%  6.70ns ± 0%  -12.23%
BytesCompare/83    7.63ns ± 0%  6.70ns ± 0%  -12.24%
BytesCompare/84    7.63ns ± 0%  6.70ns ± 0%  -12.24%
BytesCompare/85    7.63ns ± 0%  6.70ns ± 0%  -12.23%
BytesCompare/86    7.63ns ± 0%  6.70ns ± 0%  -12.24%
BytesCompare/87    7.63ns ± 0%  6.70ns ± 0%  -12.24%
BytesCompare/88    7.53ns ± 0%  6.56ns ± 0%  -12.90%
BytesCompare/89    7.53ns ± 0%  6.55ns ± 0%  -12.93%
BytesCompare/90    7.53ns ± 0%  6.55ns ± 0%  -12.93%
BytesCompare/91    7.53ns ± 0%  6.55ns ± 0%  -12.93%
BytesCompare/92    7.53ns ± 0%  6.55ns ± 0%  -12.93%
BytesCompare/93    7.53ns ± 0%  6.55ns ± 0%  -12.93%
BytesCompare/94    7.53ns ± 0%  6.55ns ± 0%  -12.93%
BytesCompare/95    7.53ns ± 0%  6.55ns ± 0%  -12.94%
BytesCompare/96    7.02ns ± 0%  6.45ns ± 0%   -8.09%
BytesCompare/97    8.73ns ± 0%  7.39ns ± 0%  -15.35%
BytesCompare/98    8.71ns ± 0%  7.39ns ± 0%  -15.15%
BytesCompare/99    9.42ns ± 0%  7.39ns ± 0%  -21.57%
BytesCompare/100   8.73ns ± 0%  7.39ns ± 0%  -15.36%
BytesCompare/101   9.43ns ± 0%  7.39ns ± 0%  -21.70%
BytesCompare/102   9.42ns ± 0%  7.39ns ± 0%  -21.59%
BytesCompare/103   10.2ns ± 0%   7.4ns ± 0%  -27.58%
BytesCompare/104   8.74ns ± 0%  7.35ns ± 0%  -15.95%
BytesCompare/105   9.44ns ± 0%  7.30ns ± 0%  -22.67%
BytesCompare/106   9.44ns ± 0%  7.30ns ± 0%  -22.69%
BytesCompare/107   10.2ns ± 0%   7.3ns ± 0%  -28.53%
BytesCompare/108   9.48ns ± 0%  7.30ns ± 0%  -23.04%
BytesCompare/109   10.2ns ± 0%   7.3ns ± 0%  -28.81%
BytesCompare/110   10.2ns ± 0%   7.3ns ± 0%  -28.39%
BytesCompare/111   10.9ns ± 0%   7.3ns ± 0%  -33.18%
BytesCompare/112   7.75ns ± 0%  7.16ns ± 0%   -7.60%
BytesCompare/113   8.57ns ± 0%  7.83ns ± 0%   -8.60%
BytesCompare/114   8.57ns ± 0%  7.83ns ± 0%   -8.63%
BytesCompare/115   8.57ns ± 0%  7.83ns ± 0%   -8.56%
BytesCompare/116   8.57ns ± 0%  7.83ns ± 0%   -8.57%
BytesCompare/117   8.57ns ± 0%  7.83ns ± 0%   -8.56%
BytesCompare/118   8.57ns ± 0%  7.83ns ± 0%   -8.56%
BytesCompare/119   8.57ns ± 0%  7.83ns ± 0%   -8.61%
BytesCompare/120   8.46ns ± 0%  7.71ns ± 0%   -8.80%
BytesCompare/121   8.46ns ± 0%  7.72ns ± 0%   -8.77%
BytesCompare/122   8.46ns ± 0%  7.72ns ± 0%   -8.78%
BytesCompare/123   8.46ns ± 0%  7.72ns ± 0%   -8.76%
BytesCompare/124   8.46ns ± 0%  7.72ns ± 0%   -8.70%
BytesCompare/125   8.46ns ± 0%  7.72ns ± 0%   -8.70%
BytesCompare/126   8.46ns ± 0%  7.72ns ± 0%   -8.70%
BytesCompare/127   8.46ns ± 0%  7.72ns ± 0%   -8.71%
BytesCompare/128   8.19ns ± 0%  7.35ns ± 0%  -10.29%
BytesCompare/256   12.8ns ± 0%  11.4ns ± 0%  -11.23%
BytesCompare/512   22.2ns ± 0%  20.7ns ± 0%   -6.80%
BytesCompare/1024  41.1ns ± 0%  39.8ns ± 0%   -3.12%
BytesCompare/2048  86.5ns ± 0%  81.1ns ± 0%   -6.31%

Change-Id: I7c7fb1f7b891c23c6cade580e7b9928ca1a6efc3
Reviewed-on: https://go-review.googlesource.com/c/go/+/474496
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Archana Ravindar <aravind5@in.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
14 months agocmd/internal/obj/loong64: add support for movgr2cf and movcf2gr instructions
Huang Qiqi [Mon, 13 Mar 2023 10:50:49 +0000 (18:50 +0800)]
cmd/internal/obj/loong64: add support for movgr2cf and movcf2gr instructions

Change-Id: I7ff3c8df24ed7990fe104bc2530354c0bd5fe018
Reviewed-on: https://go-review.googlesource.com/c/go/+/475576
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
Reviewed-by: WANG Xuerui <git@xen0n.name>
14 months agocmd/asm, runtime: remove the RSB register from loong64
WANG Xuerui [Mon, 13 Mar 2023 08:20:50 +0000 (16:20 +0800)]
cmd/asm, runtime: remove the RSB register from loong64

It was carryover from the mips64 port (where it represented the platform
GP register) but LoongArch platform ABI doesn't have the GP concept.

Change-Id: Iea326ae13676e95b040b52aaadc08d311b507bd3
Reviewed-on: https://go-review.googlesource.com/c/go/+/475815
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
14 months agoruntime: reuse freed memory blocks on wasm
Achille Roussel [Mon, 20 Mar 2023 22:16:21 +0000 (22:16 +0000)]
runtime: reuse freed memory blocks on wasm

When compiling Go programs to WebAssembly, the memory allocation
strategy was neither releasing memory to the OS nor reusing blocks freed
by calls to runtime.sysFreeOS.

This CL unifies the plan9 and wasm memory management strategy
since both platforms use a linear memory space and do not have a
mechanism for returning memory blocks to the OS.

Fixes #59061

Change-Id: I282ba93c0fe1a0961a31c0825b2a7e0478b8713d
GitHub-Last-Rev: 1c485be4fb798679fde7db148392de558a6fa97c
GitHub-Pull-Request: golang/go#59065
Reviewed-on: https://go-review.googlesource.com/c/go/+/476717
Reviewed-by: Julien Fabre <ju.pryz@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Evan Phoenix <evan@phx.io>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
14 months agocmd/go: use platform.MustLinkExternal in externalLinkingForced
Ian Lance Taylor [Mon, 20 Mar 2023 21:39:05 +0000 (14:39 -0700)]
cmd/go: use platform.MustLinkExternal in externalLinkingForced

This is a roll-forward of CL 477395 which was rolled back in CL 477736.
The earlier CL failed because we didn't account for the fact that
on some targets PIE is the default. That is now fixed.

Change-Id: I3e93faa9506033d27040cc9920836f010e05cd26
Reviewed-on: https://go-review.googlesource.com/c/go/+/477919
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agocmd/go: rewrite externalLinkingForced slightly for clarity
Ian Lance Taylor [Mon, 20 Mar 2023 21:30:09 +0000 (14:30 -0700)]
cmd/go: rewrite externalLinkingForced slightly for clarity

Change-Id: I8f8d38c48d4ffe70d15330ea0d4794f264c88f25
Reviewed-on: https://go-review.googlesource.com/c/go/+/477918
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
14 months agocmd/go: use DefaultPIE to see if external linking is forced
Ian Lance Taylor [Mon, 20 Mar 2023 21:20:22 +0000 (14:20 -0700)]
cmd/go: use DefaultPIE to see if external linking is forced

Before this CL, the code checked whether external linking was
required for -buildmode=pie. This CL changes it to also consider
whether external linking is required if PIE is the default build mode.

Change-Id: I5ac62fc027622576a152a8b7b5d97bc1d112adb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/477917
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agointernal/platform: pass race mode to DefaultPIE
Ian Lance Taylor [Mon, 20 Mar 2023 21:08:59 +0000 (14:08 -0700)]
internal/platform: pass race mode to DefaultPIE

On Windows we default to PIE, except in race mode.
Pass isRace to platform.DefaultPIE to centralize that decision.
This is in preparation for adding another call to DefaultPIE.

Change-Id: I91b75d307e7d4d260246a934f98734ddcbca372a
Reviewed-on: https://go-review.googlesource.com/c/go/+/477916
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

14 months agoall: gofmt
Damien Neil [Mon, 20 Mar 2023 20:01:14 +0000 (13:01 -0700)]
all: gofmt

Change-Id: I926388ee5aeeff11f765cbd4558b66645d1bbc08
Reviewed-on: https://go-review.googlesource.com/c/go/+/477836
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
14 months agocmd/go: import runtime/cgo when externally linking
Ian Lance Taylor [Mon, 20 Mar 2023 19:53:22 +0000 (12:53 -0700)]
cmd/go: import runtime/cgo when externally linking

Restore CL 477195, which was reverted in CL 477795.
This version includes CL 477397, which fixes the test problems
with CL 477195. CL 477397 was not submitted because it had an
unrelated failure on darwin-amd64. That failure is fixed by CL 477736.

Fixes #31544

Change-Id: I3a2258cd0ca295cede3511ab212e56fd0114f94a
Reviewed-on: https://go-review.googlesource.com/c/go/+/477839
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agoRevert "cmd/go: use platform.MustLinkExternal in externalLinkingForced"
Ian Lance Taylor [Mon, 20 Mar 2023 17:54:31 +0000 (10:54 -0700)]
Revert "cmd/go: use platform.MustLinkExternal in externalLinkingForced"

This reverts CL 477395.

Failing on darwin-amd64 builders:
https://build.golang.org/log/b07ec5e40a896f5d099e4c85f4094321ecc84f21

loadinternal: cannot find runtime/cgo
signal: trace/BPT trap
FAIL crypto/x509 0.024s
FAIL
2023/03/20 12:16:35 Failed: exit status 1

Change-Id: Ib9923f9ff7e24c3b5f8690ba1d6b5d0b6693d49c
Reviewed-on: https://go-review.googlesource.com/c/go/+/477736
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

14 months agocmd/link/internal/ld: emit better complex types for COFF symbols
qmuntal [Mon, 13 Mar 2023 14:10:59 +0000 (15:10 +0100)]
cmd/link/internal/ld: emit better complex types for COFF symbols

The Go linker has always used IMAGE_SYM_TYPE_NULL as COFF symbol
type [1] when external linking and array of structs
(IMAGE_SYM_DTYPE_ARRAY<<4+IMAGE_SYM_TYPE_STRUCT) when internal linking.
This behavior seems idiosyncratic, and looking at the git history it
seems that it has probably been cargo culted from earlier toolchains.

This CL updates the Go linker to use IMAGE_SYM_DTYPE_FUNCTION<<4 for
those symbols representing functions, and IMAGE_SYM_TYPE_NULL otherwise.

This new behavior better represents the symbol types, and can help
other tools interpreting the intent of each symbol, e.g. debuggers or
tools extracting debug info from Go binaries. It also mimics what other
toolchains do, i.e. MSVC, LLVM, and GCC.

[1] https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#type-representation

Change-Id: I6b39b2048e95f0324b2eb90c85802ce42db455d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/475856
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>

14 months agocmd/compile: add rewrite rules for arithmetic operations
Yi Yang [Sun, 19 Mar 2023 07:24:04 +0000 (07:24 +0000)]
cmd/compile: add rewrite rules for arithmetic operations

Add the following common local transformations

(t + x) - (t + y) == x - y
(t + x) - (y + t) == x - y
(x + t) - (y + t) == x - y
(x + t) - (t + y) == x - y
(x - t) + (t + y) == x + y
(x - t) + (y + t) == x + y

The compiler itself matches such patterns many times. This also aligns with other popular compilers.

Fixes #59111

Change-Id: Ibdfdb414782f8fcaa20b84ac5d43d0d9ae2c7b60
GitHub-Last-Rev: 1aad82e62e61e89789932c2070851a023f130dd8
GitHub-Pull-Request: golang/go#59119
Reviewed-on: https://go-review.googlesource.com/c/go/+/477555
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>

14 months agoRevert "cmd/go: import runtime/cgo when externally linking"
Bryan Mills [Mon, 20 Mar 2023 14:31:59 +0000 (14:31 +0000)]
Revert "cmd/go: import runtime/cgo when externally linking"

This reverts CL 477195.

Reason for revert: test fails on darwin and solaris builders.

Change-Id: I68085f06bc84b0b8649804b8968626ed0e788931
Reviewed-on: https://go-review.googlesource.com/c/go/+/477795
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Bypass: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agodebug/dwarf: return ErrUnknownPC rather than nil on unknown PC
Joel Sing [Thu, 2 Mar 2023 14:24:06 +0000 (01:24 +1100)]
debug/dwarf: return ErrUnknownPC rather than nil on unknown PC

Currently, on e == nil or e.Tag == 0, SeekPC returns with a nil error.
Instead, indicate that the PC is unknown.

Change-Id: I9594296034e2df872e399bd800b00cb565c413c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/473695
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

15 months agoruntime: provide and use a GO_PPC64X_HAS_FUNCDESC define
Joel Sing [Tue, 14 Mar 2023 09:50:38 +0000 (20:50 +1100)]
runtime: provide and use a GO_PPC64X_HAS_FUNCDESC define

Rather than implying that all ppc64 GOARCHs use function descriptors,
provide a define for platforms that make use of function descriptors.
Condition on GO_PPC64X_HAS_FUNCDESC when choosing whether or not
to load the entry address from the first slot of the function
descriptor.

Updates #56001.

Change-Id: I9cdc788f2de70a1262c17d8485b555383d1374b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/476117
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agointernal/cpu: add default osinit for ppc64/ppc64le
Joel Sing [Thu, 2 Mar 2023 14:23:52 +0000 (01:23 +1100)]
internal/cpu: add default osinit for ppc64/ppc64le

This will be used for operating systems other than AIX and Linux (both of
which provide a more specific version).

Updates #56001

Change-Id: Ia1de994866b66f03c83696faa92d0531a0b75273
Reviewed-on: https://go-review.googlesource.com/c/go/+/473698
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/dist: add openbsd/ppc64 as a known GOOS/GOARCH
Joel Sing [Sat, 11 Mar 2023 15:08:45 +0000 (02:08 +1100)]
cmd/dist: add openbsd/ppc64 as a known GOOS/GOARCH

Also map uname output containing powerpc64 to ppc64 on openbsd.

Updates #56001

Change-Id: I6a4470cb0e5d6c6940d5268a6a06d23430c7859a
Reviewed-on: https://go-review.googlesource.com/c/go/+/475635
Reviewed-by: Eric Grosse <grosse@gmail.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agoerrors: clarify Join documentation
David Bendory [Fri, 17 Mar 2023 14:04:01 +0000 (14:04 +0000)]
errors: clarify Join documentation

The previous documentation used a double-negative in describing Join behavior; this use of language could be confusing.

This update removes the double-negative.

Change-Id: If13e88682e865314a556e7d381143a97fa5486d9
GitHub-Last-Rev: 92b3f88a5d49229e71adafcfa7b1d01dcb7646f3
GitHub-Pull-Request: golang/go#59082
Reviewed-on: https://go-review.googlesource.com/c/go/+/477095
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

15 months agocmd/go: make sure linker -o for plugin doesn't include tempdir path
Michael Matloob [Fri, 17 Mar 2023 15:40:25 +0000 (11:40 -0400)]
cmd/go: make sure linker -o for plugin doesn't include tempdir path

There is already a case that when buildmode=shared passes only the
basename of the -o argument to the link command to the linker (and
runs in the directory of that argument) to avoid having that
(temporary) directory of the file be included in the LC_ID_DYLIB load
command. Extend the case to buildmode=plugin, because the same thing
can happen there.

This can only happen on darwin: the -o command can be embedded into
Mach-O and PE binaries, but plugin isn't supported on Windows.

For #58557

Change-Id: I7a4a5627148e77c6906ac4583af3d9f053d5b249
Reviewed-on: https://go-review.googlesource.com/c/go/+/477296
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
15 months agocmd/go: use platform.MustLinkExternal in externalLinkingForced
Ian Lance Taylor [Fri, 17 Mar 2023 19:40:25 +0000 (12:40 -0700)]
cmd/go: use platform.MustLinkExternal in externalLinkingForced

Change-Id: If5613ae73d03c196f26340fd6293e37c78c29bd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/477395
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agocmd/go: import runtime/cgo when externally linking
Ian Lance Taylor [Fri, 17 Mar 2023 00:45:02 +0000 (17:45 -0700)]
cmd/go: import runtime/cgo when externally linking

Fixes #31544

Change-Id: Ic99875ad227876eb741e93653589310327c9c0ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/477195
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agocmd/compile/internal/ssa: drop overwritten regalloc basic block input requirements
Michael Pratt [Tue, 21 Feb 2023 18:20:49 +0000 (13:20 -0500)]
cmd/compile/internal/ssa: drop overwritten regalloc basic block input requirements

For the following description, consider the following basic block graph:

      b1 ───┐┌──── b2
            ││
            ││
            ▼▼
            b3

For register allocator transitions between basic blocks, there are two
key passes (significant paraphrasing):

First, each basic block is visited in some predetermined visit order.
This is the core visitOrder range loop in regAllocState.regalloc. The
specific ordering heuristics aren't important here, except that the
order guarantees that when visiting a basic block at least one of its
predecessors has already been visited.

Upon visiting a basic block, that block sets its expected starting
register state (regAllocState.startRegs) based on the ending register
state (regAlloc.State.endRegs) of one of its predecessors. (How it
chooses which predecessor to use is not important here.)

From that starting state, registers are assigned for all values in the
block, ultimately resulting in some ending register state.

After all blocks have been visited, the shuffle pass
(regAllocState.shuffle) ensures that for each edge, endRegs of the
predecessor == startRegs of the successor. That is, it makes sure that
the startRegs assumptions actually hold true for each edge. It does this
by adding moves to the end of the predecessor block to place values in
the expected register for the successor block. These may be moves from
other registers, or from memory if the value is spilled.

Now on to the actual problem:

Assume that b1 places some value v1 into register R10, and thus ends
with endRegs containing R10 = v1.

When b3 is visited, it selects b1 as its model predecessor and sets
startRegs with R10 = v1.

b2 does not have v1 in R10, so later in the shuffle pass, we will add a
move of v1 into R10 to the end of b2 to ensure it is available for b3.

This is all perfectly fine and exactly how things should work.

Now suppose that b3 does not use v1. It does need to use some other
value v2, which is not currently in a register. When assigning v2 to a
register, it finds all registers are already in use and it needs to dump
a value. Ultimately, it decides to dump v1 from R10 and replace it with
v2.

This is fine, but it has downstream effects on shuffle in b2. b3's
startRegs still state that R10 = v1, so b2 will add a move to R10 even
though b3 will unconditionally overwrite it. i.e., the move at the end
of b2 is completely useless and can result in code like:

// end of b2
MOV n(SP), R10 // R10 = v1 <-- useless
// start of b3
MOV m(SP), R10 // R10 = v2

This is precisely what happened in #58298.

This CL addresses this problem by dropping registers from startRegs if
they are never used in the basic block prior to getting dumped. This
allows the shuffle pass to avoid placing those useless values into the
register.

There is a significant limitation to this CL, which is that it only
impacts the immediate predecessors of an overwriting block. We can
discuss this by zooming out a bit on the previous graph:

b4 ───┐┌──── b5
      ││
      ││
      ▼▼
      b1 ───┐┌──── b2
            ││
            ││
            ▼▼
            b3

Here we have the same graph, except we can see the two predecessors of
b1.

Now suppose that rather than b1 assigning R10 = v1 as above, the
assignment is done in b4. b1 has startRegs R10 = v1, doesn't use the
value at all, and simply passes it through to endRegs R10 = v1.

Now the shuffle pass will require both b2 and b5 to add a move to
assigned R10 = v1, because that is specified in their successor
startRegs.

With this CL, b3 drops R10 = v1 from startRegs, but there is no
backwards propagation, so b1 still has R10 = v1 in startRegs, and b5
still needs to add a useless move.

Extending this CL with such propagation may significantly increase the
number of useless moves we can remove, though it will add complexity to
maintenance and could potentially impact build performance depending on
how efficiently we could implement the propagation (something I haven't
considered carefully).

As-is, this optimization does not impact much code. In bent .text size
geomean is -0.02%. In the container/heap test binary, 18 of ~2500
functions are impacted by this CL. Bent and sweet do not show a
noticeable performance impact one way or another, however #58298 does
show a case where this can have impact if the useless instructions end
up in the hot path of a tight loop.

For #58298.

Change-Id: I2fcef37c955159d068fa0725f995a1848add8a5f
Reviewed-on: https://go-review.googlesource.com/c/go/+/471158
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
15 months agonet/http: eliminate more arbitrary timeouts in tests
Bryan C. Mills [Fri, 17 Mar 2023 16:42:02 +0000 (12:42 -0400)]
net/http: eliminate more arbitrary timeouts in tests

Change-Id: I5b3158ecd0eb20dc433a53a2b03eb4551cbb3f7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/477196
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
15 months agonet/http/httputil: use response controller in reverse proxy
Shang Ding [Thu, 16 Feb 2023 03:04:33 +0000 (21:04 -0600)]
net/http/httputil: use response controller in reverse proxy

Previously, the reverse proxy is unable to detect
the support for hijack or flush if those things
are residing in the response writer in a wrapped
manner.

The reverse proxy now makes use of the new http
response controller as the means to discover
the underlying flusher and hijacker associated
with the response writer, allowing wrapped flusher
and hijacker become discoverable.

Change-Id: I53acbb12315c3897be068e8c00598ef42fc74649
Reviewed-on: https://go-review.googlesource.com/c/go/+/468755
Run-TryBot: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agoruntime: remove arm64 non-register ABI fallback code
Joel Sing [Sat, 11 Mar 2023 16:12:40 +0000 (03:12 +1100)]
runtime: remove arm64 non-register ABI fallback code

This presumably got missed in CL 393875.

Change-Id: I4f2de00ebd6ec405d5e289a7f8c2fc781607260b
Reviewed-on: https://go-review.googlesource.com/c/go/+/475617
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
15 months agoruntime: remove the fake mstart caller in systemstack on linux/loong64
Guoqi Chen [Mon, 4 Jul 2022 06:29:52 +0000 (14:29 +0800)]
runtime: remove the fake mstart caller in systemstack on linux/loong64

The backtrace knows to stop in the system stack due to writing to the SP,
so here the fake mstart caller in the system stack is no longer needed and
can be removed

ref. CL 288799

Change-Id: I0841e75fd515cf6a0d98abe4cffc3f63fc275e0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/416035
Auto-Submit: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: WANG Xuerui <git@xen0n.name>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/compile: fix extraneous diff in generated files
Keith Randall [Thu, 16 Mar 2023 21:41:44 +0000 (14:41 -0700)]
cmd/compile: fix extraneous diff in generated files

Looks like CL 475735 contained a not-quite-up-to-date version
of the generated file. Maybe ABSFL was in an earlier version of the CL
and was removed before checkin without regenerating the generated file?

In any case, update the generated file. Shouldn't cause a problem, as
that field isn't used in x86/ssa.go.

Change-Id: I3f0b7d41081ba3ce2cdcae385fea16b37d7de81b
Reviewed-on: https://go-review.googlesource.com/c/go/+/477096
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/compile: reorder BlankNode assignment to make SetType more clear
ezzno [Thu, 16 Mar 2023 10:20:23 +0000 (10:20 +0000)]
cmd/compile: reorder BlankNode assignment to make SetType more clear

Change-Id: I9e6bf9ed100de2039961a6f6558daaa09c176861
GitHub-Last-Rev: 594331fa10cfe22cc34801a09a642d31156bfdab
GitHub-Pull-Request: golang/go#59072
Reviewed-on: https://go-review.googlesource.com/c/go/+/476895
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>

15 months agocmd/go/internal/lockedfile/internal/filelock: use errors.ErrUnsupported
Tobias Klauser [Thu, 16 Mar 2023 21:05:06 +0000 (22:05 +0100)]
cmd/go/internal/lockedfile/internal/filelock: use errors.ErrUnsupported

All platform specific errors are now covered by errors.ErrUnsupported.

Updates #41198

Change-Id: Ia9c0cad7c493305835bd5a1f349446cec409f686
Reviewed-on: https://go-review.googlesource.com/c/go/+/476917
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>

15 months agocmd/compile: add -url flag, print URL with error messages if applicable
Robert Griesemer [Wed, 15 Mar 2023 21:03:49 +0000 (14:03 -0700)]
cmd/compile: add -url flag, print URL with error messages if applicable

If the -url flag is provided, when encountering a type checking error,
the compiler will also print a URL to a more detailed description of
the error and an example, if available.

Example uses:

        go tool compile -url filename.go
        go build -gcflags=-url pkg/path

For instance, a duplicate declaration of an identifier will report

        https://pkg.go.dev/internal/types/errors#DuplicateDecl

We may refine the provided URL over time.

Change-Id: Iabe3008a49d9dd88bf690f99e4a4a5432dc08786
Reviewed-on: https://go-review.googlesource.com/c/go/+/476716
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
15 months agointernal/fuzz: release lock when reading file fails
Roland Shoemaker [Thu, 16 Mar 2023 03:53:10 +0000 (20:53 -0700)]
internal/fuzz: release lock when reading file fails

When corpusEntryData failed in workerClient.fuzz and
workerClient.minimize, the shared memory mutex wasn't properly given up,
which would cause a deadlock when worker.cleanup was called.

This was tickled by #59062, wherein the fuzz cache directory would be
removed during operation of the fuzzer, causing corpusEntryData to fail
because the entry files no longer existed.

Updates #51484

Change-Id: Iea284041c20d1581c662bddbbc7e12191771a364
Reviewed-on: https://go-review.googlesource.com/c/go/+/476815
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agoruntime/trace: record HeapGoal when StartTrace
Leonard Wang [Sun, 24 Apr 2022 07:01:22 +0000 (15:01 +0800)]
runtime/trace: record HeapGoal when StartTrace

Fixes #52517

Change-Id: I06aa6112f14f264360c3bb0ffd4e1cd54ad22514
Reviewed-on: https://go-review.googlesource.com/c/go/+/401777
Reviewed-by: hopehook <hopehook@golangcn.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>

15 months agoos: don't check for TTY before calling splice
Ian Lance Taylor [Thu, 16 Mar 2023 19:14:03 +0000 (12:14 -0700)]
os: don't check for TTY before calling splice

I think I confused myself in CL 476335. The TTY check did fix the
problem with os.Stdout, but it was still possible to get the same
problem in other ways. I fixed that by making the splice call blocking,
but it turns out that doing that is enough to fix the TTY problem also.
So we can just remove the TTY check.

Fixes #59041

Change-Id: I4d7ca9dad8361001edb4cfa96bb29b1badb54df0
Reviewed-on: https://go-review.googlesource.com/c/go/+/477035
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agosyscall: let errors.ErrUnsupported match ERROR_NOT_SUPPORTED and ERROR_CALL_NOT_IMPLE...
Tobias Klauser [Thu, 16 Mar 2023 18:23:34 +0000 (19:23 +0100)]
syscall: let errors.ErrUnsupported match ERROR_NOT_SUPPORTED and ERROR_CALL_NOT_IMPLEMENTED

These error codes are returned on windows in case a particular functions
is not supported.

Updates #41198

Change-Id: Ic31755a131d4e7c96961ba54f5bb51026fc7a563
Reviewed-on: https://go-review.googlesource.com/c/go/+/476916
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/compile: restore return-in-loop loopvar optimization
David Chase [Tue, 28 Feb 2023 22:36:38 +0000 (17:36 -0500)]
cmd/compile: restore return-in-loop loopvar optimization

but this time, correctly.
children of Returns can have For/Range loops in them,
and those must be visited.

Includes test to verify that the optimization occurs,
and also that the problematic case that broke the original
optimization is now correctly handled.

Change-Id: If5a94fd51c862d4bfb318fec78456b7b202f3fcd
Reviewed-on: https://go-review.googlesource.com/c/go/+/472355
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
15 months agocmd/go/internal/lockedfile/internal/filelock: re-use filelock_other.go for plan9
Tobias Klauser [Thu, 16 Mar 2023 12:12:10 +0000 (13:12 +0100)]
cmd/go/internal/lockedfile/internal/filelock: re-use filelock_other.go for plan9

The implementation for lockType, lock, unlock and isNotSupported is the
same on plan9 as on other platforms where filelocks are unsupported.

Change-Id: I8b9c0bdc429e23346ab9145ec3814622319427fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/476915
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agosyscall: let ENOSYS, ENOTSUP and EOPNOTSUPP implement errors.ErrUnsupported
Tobias Klauser [Thu, 16 Mar 2023 09:59:04 +0000 (10:59 +0100)]
syscall: let ENOSYS, ENOTSUP and EOPNOTSUPP implement errors.ErrUnsupported

As suggested by Bryan, also update (Errno).Is on windows to include the
missing oserror cases that are covered on other platforms.

Quoting Bryan:
> Windows syscalls don't actually return those errors, but the dummy Errno
> constants defined on Windows should still have the same meaning as on
> Unix.

Updates #41198

Change-Id: I15441abde4a7ebaa3c6518262c052530cd2add4b
Reviewed-on: https://go-review.googlesource.com/c/go/+/476875
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agoruntime: improve equal on ppc64x/power10
Archana R [Mon, 6 Mar 2023 09:17:47 +0000 (03:17 -0600)]
runtime: improve equal on ppc64x/power10

Rewrite equal asm function to use the new power10 instruction lxvl
and stxvl- load and store with variable length which can simplify
the tail end bytes comparison process. Cleaned up code on CR
register usage.

On power9 and power8 the code remains unchanged. The performance
for multiple sizes<=16 improve on power10 with the change.

name      old time/op    new time/op    delta
Equal/1     5.28ns ± 0%    4.19ns ± 9%  -20.80%
Equal/2     5.30ns ± 0%    4.29ns ± 6%  -19.06%
Equal/3     5.10ns ± 5%    4.20ns ± 6%  -17.73%
Equal/4     5.05ns ± 0%    4.42ns ± 4%  -12.50%
Equal/5     5.27ns ± 1%    4.44ns ± 4%  -15.69%
Equal/6     5.30ns ± 0%    4.38ns ±12%  -17.44%
Equal/7     5.02ns ± 6%    4.48ns ± 2%  -10.64%
Equal/9     4.53ns ± 0%    4.34ns ± 7%   -4.21%
Equal/16    4.52ns ± 0%    4.29ns ± 6%   -5.16%

Change-Id: Ie124906e3a5012dfe634bfe09af06be42f1b178b
Reviewed-on: https://go-review.googlesource.com/c/go/+/473536
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Paul Murphy <murp@ibm.com>
15 months agocmd/internal/obj/loong64: add the PCALAU12I instruction for reloc use
WANG Xuerui [Sat, 3 Dec 2022 12:57:52 +0000 (20:57 +0800)]
cmd/internal/obj/loong64: add the PCALAU12I instruction for reloc use

The LoongArch ELF psABI v2.00 revamped the relocation design, largely
moving to using the `pcalau12i + addi/ld/st` pair for PC-relative
addressing within +/- 32 bits. The "pcala" in `pcalau12i` stands for
"PC-aligned add"; the instruction's semantics happen to coincide with
arm64's `adrp`.

Add support for emitting this instruction as part of the relevant
addressing ops, for use with new reloc types later.

Updates #58784

Change-Id: Ic1747cd9745aad0d1abb9bd78400cd5ff5978bc8
Reviewed-on: https://go-review.googlesource.com/c/go/+/455016
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Auto-Submit: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/go/testdata/script: consistently set GOCACHE in fuzz tests
Roland Shoemaker [Wed, 15 Mar 2023 22:37:26 +0000 (15:37 -0700)]
cmd/go/testdata/script: consistently set GOCACHE in fuzz tests

The fuzzing cache for interesting inputs is shared across all
invocations of scripts by default. When 'go clean -fuzzcache' is called,
or fuzz targets in different scripts have the same names, we can get
race-y unexpected behavior.

Since there isn't a easy way to set just the fuzz cache directory (test
has the flag -test.fuzzcachedir, but it requires setting it on each call
to 'go test'), instead we just consistently set GOCACHE to point to a
directory in the WORK dir. As a byproduct this also prevents usage of a
shared build cache, so we see an increase in build time for these tests.

Updates #59062

Change-Id: Ie78f2943b94f3302c5bdf1f8a1e93b207853666a
Reviewed-on: https://go-review.googlesource.com/c/go/+/476755
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agoflag: add BoolFunc; FlagSet.BoolFunc
Carl Johnson [Tue, 14 Mar 2023 13:06:20 +0000 (13:06 +0000)]
flag: add BoolFunc; FlagSet.BoolFunc

Fixes #53747

Based on CL 416514

Change-Id: I1ff79c6290b06dfa8672a473045e8fe80c22afcf
GitHub-Last-Rev: 74fba9b3096487c04c8dc1f2237f67f3558212f1
GitHub-Pull-Request: golang/go#59013
Reviewed-on: https://go-review.googlesource.com/c/go/+/476015
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocrypto/elliptic: deprecate unsafe APIs
Filippo Valsorda [Thu, 29 Dec 2022 14:38:18 +0000 (15:38 +0100)]
crypto/elliptic: deprecate unsafe APIs

Per the updated go.dev/wiki/Deprecated, those APIs replaced by
crypto/ecdh (added in Go 1.20) can now be marked as deprecated
in Go 1.21.

Updates #52221
Updates #34648

Change-Id: Id0e11d7faa3a58a1716ce1ec6e2fff97bab96259
Reviewed-on: https://go-review.googlesource.com/c/go/+/459977
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocrypto/rsa: deprecate multiprime RSA support
Filippo Valsorda [Thu, 29 Dec 2022 13:16:10 +0000 (14:16 +0100)]
crypto/rsa: deprecate multiprime RSA support

Fixes #56921

Change-Id: I03f9969a5146ab7becd983784d8cb5b23a3fbb18
Reviewed-on: https://go-review.googlesource.com/c/go/+/459976
TryBot-Bypass: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
15 months agoerrors: correct spelling
Vasili Revelas [Wed, 15 Mar 2023 11:22:04 +0000 (11:22 +0000)]
errors: correct spelling

Change-Id: Iba64f3d88b541c7fef15046720bfaba361291d94
GitHub-Last-Rev: 22cfd6382c42abfa7e1952cccf6e0ecb5990fdbf
GitHub-Pull-Request: golang/go#59047
Reviewed-on: https://go-review.googlesource.com/c/go/+/476395
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agointernal/fuzz: fix debug statement
Roland Shoemaker [Thu, 16 Mar 2023 01:16:57 +0000 (18:16 -0700)]
internal/fuzz: fix debug statement

Meant to check if the slice was empty, accidentally dumped the entire
slice to stdout...

Change-Id: I968cb2f20ffb006e4dcfea65a1bad794aac05d17
Reviewed-on: https://go-review.googlesource.com/c/go/+/476795
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Roland Shoemaker <roland@golang.org>

15 months agointernal/fuzz: more debug logging
Roland Shoemaker [Wed, 15 Mar 2023 23:44:36 +0000 (16:44 -0700)]
internal/fuzz: more debug logging

Change-Id: I2c36baf423dde419aaa940ce9308088f3bf431f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/476718
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
15 months agoruntime: fix callee tracking in traceback printing
Austin Clements [Wed, 15 Mar 2023 18:27:10 +0000 (14:27 -0400)]
runtime: fix callee tracking in traceback printing

In CL 466099, we accidentally stopped tracking callees while unwinding
inlined frames during traceback printing. The effect is that if you
have a call stack like:

  f -> wrapper -> inlined into wrapper -> panic

when considering whether to print the frame for "wrapper", we'll think
that wrapper called panic, rather than the inlined function.

Fix this in the traceback code and add a test.

Change-Id: I30ec836cc316846ce93de94e28a650e23dca184e
Reviewed-on: https://go-review.googlesource.com/c/go/+/476579
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
15 months agoos, internal/poll: don't use splice with tty
Ian Lance Taylor [Tue, 14 Mar 2023 21:49:16 +0000 (14:49 -0700)]
os, internal/poll: don't use splice with tty

Also don't try to wait for a non-pollable FD.

Fixes #59041

Change-Id: Ife469d8738f2cc27c0beba223bdc8f8bc757b2a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/476335
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agointernal/types/errors: add String method to Code
Robert Griesemer [Wed, 15 Mar 2023 20:15:28 +0000 (13:15 -0700)]
internal/types/errors: add String method to Code

Change-Id: Ia9fb7bdc39c1001c5cbb387d840ed923cf46b9e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/476715
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>

15 months agosyscall: let EPLAN9 and EWINDOWS implement errors.ErrUnsupported
Tobias Klauser [Wed, 15 Mar 2023 18:26:33 +0000 (19:26 +0100)]
syscall: let EPLAN9 and EWINDOWS implement errors.ErrUnsupported

As suggested by Bryan. This should fix the failing
TestIPConnSpecificMethods on plan9 after CL 476217 was submitted.

For #41198

Change-Id: I18e87b3aa7c9f7d48a1bd9c2819340acd1d2ca4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/476578
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/asm: improve detector for incorrect R15 usage when dynamic linking
Keith Randall [Tue, 14 Mar 2023 18:34:51 +0000 (11:34 -0700)]
cmd/asm: improve detector for incorrect R15 usage when dynamic linking

Fixes #58632

Change-Id: Idb19af2ac693ea5920da57c1808f1bc02702929d
Reviewed-on: https://go-review.googlesource.com/c/go/+/476295
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>

15 months agointernal/fuzz: improve debugging messages
Roland Shoemaker [Wed, 15 Mar 2023 18:22:53 +0000 (11:22 -0700)]
internal/fuzz: improve debugging messages

Also enable debugging information in TestScript/test_fuzz_cov, which
hits a deadlock on builders, but I am unable to trigger locally. This
should make it somewhat easier to track down where the issue actually
is.

Updates #51484

Change-Id: I98124f862242798f2d9eba15cacefbd02924cfe2
Reviewed-on: https://go-review.googlesource.com/c/go/+/476595
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agonet: correct TestIPConnSpecificMethods comment after CL 476217
Tobias Klauser [Wed, 15 Mar 2023 17:11:06 +0000 (18:11 +0100)]
net: correct TestIPConnSpecificMethods comment after CL 476217

As suggested by Cherry in
https://go-review.googlesource.com/c/go/+/476217/5/src/net/protoconn_test.go#171

Change-Id: I4ce3c034b44953720c543a87639fd173f86af7dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/476535
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agoruntime: pass M to traceReleaseBuffer
Michael Pratt [Wed, 15 Mar 2023 17:58:44 +0000 (13:58 -0400)]
runtime: pass M to traceReleaseBuffer

This change is a no-op, but makes the acquire-release pair
traceAcquireBuffer / traceReleaseBuffer more explicit, since the former
does acquirem and the latter releasm.

Change-Id: If8a5b1ba8709bf6f39c8ff27b2d3e0c0b0da0e58
Reviewed-on: https://go-review.googlesource.com/c/go/+/476575
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>

15 months agonet/http: avoid making a request to a closed server in TestServerShutdown
Bryan C. Mills [Mon, 13 Mar 2023 21:36:36 +0000 (17:36 -0400)]
net/http: avoid making a request to a closed server in TestServerShutdown

As soon as the test server closes its listener, its port may be reused
for another test server. On some platforms port reuse takes a long
time, because they cycle through the available ports before reusing an
old one. However, other platforms reuse ports much more aggressively.
net/http shouldn't know or care which kind of platform it is on —
dialing wild connections is risky and can interfere with other tests
no matter what platform we do it on.

Instead of making the second request after the server has completely
shut down, we can start (and finish!) the entire request while we are
certain that the listener has been closed but the port is still open
serving an existing request. If everything synchronizes as we expect,
that should guarantee that the second request fails.

Fixes #56421.

Change-Id: I56add243bb9f76ee04ead8f643118f9448fd1280
Reviewed-on: https://go-review.googlesource.com/c/go/+/476036
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
15 months agocmd/link/internal/arm: fix off-by-1 in trampoline reachability computation
Than McIntosh [Mon, 13 Mar 2023 16:02:36 +0000 (12:02 -0400)]
cmd/link/internal/arm: fix off-by-1 in trampoline reachability computation

Tweak the code in trampoline generation that determines if a given
call branch will reach, changing the lower limit guard from "x <
-0x800000" to "x <= -0x800000". This is to resolve linking failures
when the computed displacement is exactly -0x800000, which results in
errors of the form

  .../ld.gold: internal error in arm_branch_common, at ../../gold/arm.cc:4079

when using the Gold linker, and

  ...:(.text+0x...): relocation truncated to fit: R_ARM_CALL against `runtime.morestack_noctxt'

when using the bfd linker.

Fixes #59034.
Updates #58425.

Change-Id: I8a76986b38727df1b961654824c2af23f06b9fcf
Reviewed-on: https://go-review.googlesource.com/c/go/+/475957
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agosyscall: restore original NOFILE rlimit in child process
Ian Lance Taylor [Tue, 14 Mar 2023 03:59:14 +0000 (20:59 -0700)]
syscall: restore original NOFILE rlimit in child process

If we increased the NOFILE rlimit when starting the program,
restore the original rlimit when forking a child process.

For #46279

Change-Id: Ia5d2af9ef435e5932965c15eec2e428d2130d230
Reviewed-on: https://go-review.googlesource.com/c/go/+/476097
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>

15 months agoos, syscall: move rlimit code to syscall
Ian Lance Taylor [Mon, 13 Mar 2023 22:20:11 +0000 (15:20 -0700)]
os, syscall: move rlimit code to syscall

In CL 393354 the os package was changed to raise the open file rlimit
at program start. That code is not inherently tied to the os package.
This CL moves it into the syscall package.

This is in preparation for future changes to restore the original
soft rlimit when exec'ing a new program.

For #46279

Change-Id: I981401b0345d017fd39fdd3dfbb58069be36c272
Reviewed-on: https://go-review.googlesource.com/c/go/+/476096
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agonet: skip tests if creating a socket is disallowed
Tobias Klauser [Wed, 15 Mar 2023 14:17:11 +0000 (15:17 +0100)]
net: skip tests if creating a socket is disallowed

In a container environment, creating a socket may be disallowed. Try to
detect these cases and skip the tests instead of failing them.

Fixes #58114

Change-Id: I681d19107e946d2508e2d1704956360f13c7335b
Reviewed-on: https://go-review.googlesource.com/c/go/+/476217
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agonet: remove max timeout from TestDialTimeout
Ian Lance Taylor [Wed, 15 Mar 2023 05:15:21 +0000 (22:15 -0700)]
net: remove max timeout from TestDialTimeout

Just rely on the testsuite timeout. If this hangs we will hopefully
get some real information.

Fixes #57475

Change-Id: I18dc5cae54ad5d2d8cc472056b8a3b4d5455c8b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/476356
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agoencoding/json: make use of Buffer.AvailableBuffer
Joe Tsai [Sat, 11 Mar 2023 20:03:28 +0000 (12:03 -0800)]
encoding/json: make use of Buffer.AvailableBuffer

Use the explicit API for acquiring an empty available buffer,
rather than the hack that's implemented in terms of Bytes and Len.

Change-Id: If286ed42693acd61ffe28dc849ed4b76c3ae4434
Reviewed-on: https://go-review.googlesource.com/c/go/+/476337
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agointernal/testenv, syscall: move isNotSupported to internal/testenv
Tobias Klauser [Wed, 15 Mar 2023 14:16:45 +0000 (15:16 +0100)]
internal/testenv, syscall: move isNotSupported to internal/testenv

This allows to use this helper function in packages other than syscall,
namely package net.

For #58114

Change-Id: I72c59ab013e9195801ff1315019ae1aef4396287
Reviewed-on: https://go-review.googlesource.com/c/go/+/476216
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agosyscall: handle errors.ErrUnsupported in isNotSupported
Tobias Klauser [Wed, 15 Mar 2023 14:15:04 +0000 (15:15 +0100)]
syscall: handle errors.ErrUnsupported in isNotSupported

Updates #41198

Change-Id: Ifed913f6088b77abc7a21d2a79168a20799f9d0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/475857
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>

15 months agointernal/platform: add a function to report whether default builds are PIE
Bryan C. Mills [Fri, 10 Mar 2023 20:37:17 +0000 (15:37 -0500)]
internal/platform: add a function to report whether default builds are PIE

This consolidates a condition that was previously repeated (in
different approximations) in several different places in the code.

For #58807.

Change-Id: Idd308759f6262b1f5c61f79022965612319edf94
Reviewed-on: https://go-review.googlesource.com/c/go/+/475457
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agoruntime: add arg storage to ppc64le/linux runtime.sigprofNonGoWrapper frame
Paul E. Murphy [Tue, 14 Mar 2023 21:30:38 +0000 (16:30 -0500)]
runtime: add arg storage to ppc64le/linux runtime.sigprofNonGoWrapper frame

CL 475935 fixed the the ELFv2 ABI violations, but in the process created a
Go ABI violation by failing to allocate stack space for arguments.

Allocate this space while keeping the frame 16 byte aligned.

Updates #58953

Change-Id: I9942d9a433118b391ef8cd7bcea5808695cf94d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/476296
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Archana Ravindar <aravind5@in.ibm.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agocmd/link/internal/loong64: use BREAK 0 as the code pad sequence
WANG Xuerui [Sat, 11 Mar 2023 14:38:01 +0000 (22:38 +0800)]
cmd/link/internal/loong64: use BREAK 0 as the code pad sequence

As the comment on CodePad goes, we "might want to pad with a trap
instruction to catch wayward programs". The current behavior of
zero-padding is equivalent to padding with an instruction of 0x00000000,
which is invalid according to the LoongArch manuals nevertheless, but
rumor has it that some early and/or engineering samples of Loongson
3A5000 recognized it (maybe behaving like NOP). It is better to avoid
undocumented behavior and ensure execution flow would not overflow the
pads.

Change-Id: I531b1eabeb355e9ad4a2d5340e61f2fe71349297
Reviewed-on: https://go-review.googlesource.com/c/go/+/475616
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agocmd/compile/internal, runtime: use NOOP for hardware NOPs on loong64
WANG Xuerui [Sat, 11 Mar 2023 14:26:39 +0000 (22:26 +0800)]
cmd/compile/internal, runtime: use NOOP for hardware NOPs on loong64

The canonical LoongArch NOP instruction form is "andi r0, r0, 0", as
described in the LoongArch Reference Manual Volume 1, Section 2.2.1.10.
We currently use NOR instead, which may or may not change anything (e.g.
performance on less capable micro-architectures) but is deviation from
upstream standards nevertheless. Fix them to use the explicit hardware
NOP which happens to be supported as `NOOP`.

Change-Id: I0a799a1da959e9c3b582feb88202df2bab0ab23a
Reviewed-on: https://go-review.googlesource.com/c/go/+/475615
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agoruntime: mark morestack_noctxt SPWRITE for linux/loong64
Guoqi Chen [Fri, 4 Nov 2022 05:27:23 +0000 (13:27 +0800)]
runtime: mark morestack_noctxt SPWRITE for linux/loong64

ref. CL 425396

Updates #54332.

Change-Id: I1a235b0cca4dbf79cf61cf5f40b594fc2d940857
Reviewed-on: https://go-review.googlesource.com/c/go/+/446895
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: WANG Xuerui <git@xen0n.name>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
15 months agoruntime: refactor the linux/loong64 entrypoint
Guoqi Chen [Mon, 25 Jul 2022 07:30:53 +0000 (15:30 +0800)]
runtime: refactor the linux/loong64 entrypoint

Remove the meaningless jump, and add the missing NOFRAME flag to _rt0_loong64_linux.

Change-Id: I1aec68c556615b42042684bd176dfc2a8af094d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/420977
Run-TryBot: M Zhuo <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: WANG Xuerui <git@xen0n.name>
15 months agoos: don't hide all methods in recursive call to io.Copy
Ian Lance Taylor [Sat, 11 Mar 2023 04:41:14 +0000 (20:41 -0800)]
os: don't hide all methods in recursive call to io.Copy

In order to avoid a recursive call to ReadFrom, we were converting
a *File to an io.Writer. But all we really need to do is hide
the ReadFrom method. In particular, this gives us the option of
adding a WriteTo method.

For #58808

Change-Id: I20d3a45749d528c93c23267c467e607fc17dc83f
Reviewed-on: https://go-review.googlesource.com/c/go/+/475535
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agocmd/go/internal/modfetch: use errors.ErrUnsupported
Tobias Klauser [Tue, 14 Mar 2023 07:51:02 +0000 (08:51 +0100)]
cmd/go/internal/modfetch: use errors.ErrUnsupported

CL 473935 added errors.ErrUnsupported, let's use it.

Updates #41198

Change-Id: If6534d19cb31ca979ff00d529bd6bdfc964a616d
Reviewed-on: https://go-review.googlesource.com/c/go/+/476135
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>

15 months agodatabase/sql: remove a distracting alloc, use atomic.Bool
Brad Fitzpatrick [Fri, 10 Mar 2023 17:38:49 +0000 (09:38 -0800)]
database/sql: remove a distracting alloc, use atomic.Bool

This removes an allocation in Conn.grabConn that, while not super
important, was distracting me when optimizing code elsewhere.

While here, convert an atomic that was forgotten when this package was
earlier updated to use the new Go 1.19 typed atomics.

Change-Id: I4666256b4c0512e2162bd485c389130699f9d5ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/475415
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>

15 months agoruntime,runtime/cgo: fix tsan/pprof/cgo issues
Paul E. Murphy [Fri, 10 Mar 2023 22:05:47 +0000 (16:05 -0600)]
runtime,runtime/cgo: fix tsan/pprof/cgo issues

The tsan13 test highlighted a few bugs.

The first being runtime.sigprofNonGoWrapper was being
called from C code and violating the C ABI.

The second was a missed tsan acquire/release after
thread creation.

The third was runtime.cgoSigtramp violating ELFv2
ABI constraints when loading g. It is reworked to
avoid clobbering R30 and R31 via runtime.load_g.

Change-Id: Ib2d98047fa1b4e72b8045767e86457a8ddfe492e
Reviewed-on: https://go-review.googlesource.com/c/go/+/475935
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Archana Ravindar <aravind5@in.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agocmd/go,cmd/link: prefer external linking when strange cgo flags seen
Than McIntosh [Fri, 10 Mar 2023 15:29:38 +0000 (10:29 -0500)]
cmd/go,cmd/link: prefer external linking when strange cgo flags seen

This patch changes the Go command to examine the set of compiler
flags feeding into the C compiler when packages that use cgo are built.
If any of a specific set of strange/dangerous flags are in use,
then the Go command generates a token file ("preferlinkext") and
embeds it into the compiled package's archive.

When the Go linker reads the archives of the packages feeding into the
link and detects a "preferlinkext" token, it will then use external
linking for the program by default (although this default can be
overridden with an explicit "-linkmode" flag).

The intent here is to avoid having to teach the Go linker's host object
reader to grok/understand the various odd symbols/sections/types that
can result from boutique flag use, but rather to just boot the objects
in question over to the C linker instead.

Updates #58619.
Updates #58620.
Updates #58848.

Change-Id: I56382dd305de8dac3841a7a7e664277826061eaa
Reviewed-on: https://go-review.googlesource.com/c/go/+/475375
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/link: store COFF symbol complex type in the LSB instead of the MSB
qmuntal [Mon, 13 Mar 2023 13:34:38 +0000 (14:34 +0100)]
cmd/link: store COFF symbol complex type in the LSB instead of the MSB

Microsoft's PE documentation is contradictory. It says that the
symbol's complex type [1] is stored in the pesym.Type most significant
byte (MSB), but MSVC, LLVM, and mingw store it in the 4 high bits of
the less significant byte (LSB). dumpbin understands both encoding.

Previous to CL 475355 the Go compiler mixed MSB and LSB encoding.
CL 475355 updated to compiler to use the MSB, but this causes problems
with mingw, which emits a warning when MSB is used.

For reference, LLVM also hit this issue long time ago:
https://github.com/llvm/llvm-project/issues/8692

[1] https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#type-representation

Change-Id: I7e750bde9c20e2c4c1c023203d7abd6fb26d9d30
Reviewed-on: https://go-review.googlesource.com/c/go/+/475855
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agocmd/go: restore 'extend path shortening to all paths in messages'
David Chase [Sun, 12 Mar 2023 17:19:57 +0000 (18:19 +0100)]
cmd/go: restore 'extend path shortening to all paths in messages'

The problem requiring a revert was creation (somehow) of /-containing
paths in compiler messages on Windows.  The new code deals with this
existing-but-unexpected behavior.

original was CL 465805
revert was CL 473795

this is the original, plus a correction for unexpected paths on Windows.

Change-Id: I786e875e704c2d7018c8248960f2ff7188cac3ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/474015
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: David Chase <drchase@google.com>

15 months agoruntime/internal/sys: remove 386 assembly code
Wayne Zuo [Sun, 12 Mar 2023 08:02:19 +0000 (16:02 +0800)]
runtime/internal/sys: remove 386 assembly code

Change-Id: Ia4f8638d626c30b91729caa0c58a96451c627f67
Reviewed-on: https://go-review.googlesource.com/c/go/+/475736
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/compile: instrinsify TrailingZeros{8,32,64} for 386
Wayne Zuo [Sun, 12 Mar 2023 07:34:20 +0000 (15:34 +0800)]
cmd/compile: instrinsify TrailingZeros{8,32,64} for 386

This CL add support for instrinsifying the TrialingZeros{8,32,64}
functions for 386 architecture. We need handle the case when the input
is 0, which could lead to undefined output from the BSFL instruction.

Next CL will remove the assembly code in runtime/internal/sys package.

Change-Id: Ic168edf68e81bf69a536102100fdd3f56f0f4a1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/475735
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agoregexp/syntax: test for lowercase letters first in IsWordChar
Ludi Rehak [Wed, 4 May 2022 22:22:21 +0000 (15:22 -0700)]
regexp/syntax: test for lowercase letters first in IsWordChar

Lowercase letters occur more frequently than uppercase letters
in English text.  In IsWordChar, evaluate the most common case
(lowercase letters) first to minimize the expected value of its
execution time. Code clarity does not suffer by rearranging the
order of the checks.

Add a benchmark on a sentence demonstrating the performance
improvement.

name           old time/op  new time/op  delta
IsWordChar-10   122ns ± 0%   114ns ± 1%  -6.68%  (p=0.000 n=8+10)

Change-Id: Ieee8126a4bd8ee8703905b4f75724623029f6fa2
Reviewed-on: https://go-review.googlesource.com/c/go/+/404100
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: thepudds <thepudds1460@gmail.com>

15 months agoruntime/debug: replace "GOARM64" with "GOARM" in docs
Tianon Gravi [Mon, 13 Mar 2023 21:32:49 +0000 (21:32 +0000)]
runtime/debug: replace "GOARM64" with "GOARM" in docs

The former does not exist (yet) but the latter very much exists and is in active use.

Change-Id: Ic8812b98a10f01061a211a0de4caa9e9cfff36fa
GitHub-Last-Rev: 0dab9f524c778b176e4e4b3652f53ea5e2873d26
GitHub-Pull-Request: golang/go#59014
Reviewed-on: https://go-review.googlesource.com/c/go/+/476016
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/dist: add needCC comment, fix needCC
Russ Cox [Mon, 13 Mar 2023 17:14:35 +0000 (13:14 -0400)]
cmd/dist: add needCC comment, fix needCC

This was missed in CL 475377.

Change-Id: I4e8c4c0459a92029a3f448c1e4172d3343280c57
Reviewed-on: https://go-review.googlesource.com/c/go/+/475958
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agocmd/compile: tighten for huge functions in -N mode
Cherry Mui [Fri, 10 Mar 2023 21:28:57 +0000 (16:28 -0500)]
cmd/compile: tighten for huge functions in -N mode

Currently, in -N mode we skip the tighten pass. However, for very
large functions, many values live across blocks can cause
pathological behavior in the register allocator, which could use
a huge amount of memory or cause the program to hang. For
functions that large, debugging using a debugger is unlikely to be
very useful (the function is probably generated anyway). So we do
a little optimization to make fewer values live across blocks and
make it easier for the compiler.

Fixes #52180.

Change-Id: I355fe31bb87ea5d0870bb52dd06405dd5d791dab
Reviewed-on: https://go-review.googlesource.com/c/go/+/475339
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
15 months agotesting: add Testing function
Ian Lance Taylor [Thu, 9 Mar 2023 00:16:59 +0000 (16:16 -0800)]
testing: add Testing function

The Testing function reports whether the program is a test created
by "go test".

Fixes #52600

Change-Id: Ie0fff7c7dfdfdf997c18b4b6112632600b327cc8
Reviewed-on: https://go-review.googlesource.com/c/go/+/475496
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

15 months agonet/http: remove more arbitrary timeouts from server tests
Bryan C. Mills [Mon, 13 Mar 2023 20:16:32 +0000 (16:16 -0400)]
net/http: remove more arbitrary timeouts from server tests

This change eliminates the easy, arbitrary timouts that should
never happen. It leaves in place a couple of more complicated ones
that will probably need retry loops for robustness.

For #49336.
For #36179.

Change-Id: I657ef223a66461413a915da5ce9150f49acec04a
Reviewed-on: https://go-review.googlesource.com/c/go/+/476035
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
15 months agocrypto/x509: surface ReasonCode in RevocationList API
Aaron Gable [Wed, 15 Feb 2023 22:25:34 +0000 (14:25 -0800)]
crypto/x509: surface ReasonCode in RevocationList API

Creates x509.RevocationListEntry, a new type representing a single
revoked certificate entry in a CRL. Like the existing Certificate and
RevocationList types, this new type has a field for its Raw bytes, and
exposes its mostly-commonly-used extension (ReasonCode) as a top-level
field. This provides more functionality to the user than the existing
pkix.RevokedCertificate type.

Adds a RevokedCertificateEntries field which is a []RevocationListEntry
to RevocationList. This field deprecates the RevokedCertificates field.
When the RevokedCertificates field is removed in a future release, this
will remove one of the last places where a pkix type is directly exposed
in the x509 package API.

Updates the ParseRevocationList function to populate both fields for
now, and updates the CreateRevocationList function to prefer the new
field if it is populated, but use the deprecated field if not. Finally,
also updates the x509 unit tests to use the new .ReasonCode field in
most cases.

Fixes #53573

Change-Id: Ia6de171802a5bd251938366508532e806772d7d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/468875
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
15 months agosyscall: use clone3 syscall with CLONE_NEWTIME
Tobias Klauser [Wed, 8 Mar 2023 11:49:10 +0000 (12:49 +0100)]
syscall: use clone3 syscall with CLONE_NEWTIME

CLONE_NEWTIME can only be used with the clone3 and unshare system calls,
see https://github.com/torvalds/linux/commit/769071ac9f20b6a447410c7eaa55d1a5233ef40c:

> All available clone flags have been used, so CLONE_NEWTIME uses the highest
> bit of CSIGNAL. It means that it can be used only with the unshare() and
> the clone3() system calls.

The clone3 syscall was added in Linux kernel version 5.3 and
CLONE_NEWTIME was added in version 5.6. However, it was non-functional
until version 6.3 (and stable versions with the corresponding fix [1]).

[1] https://lore.kernel.org/lkml/20230308105126.10107-1-tklauser@distanz.ch/

In case CLONE_NEWTIME is set in SysProcAttr.Cloneflags on an unsupported
kernel version, the fork/exec call will fail.

Fixes #49779

Change-Id: Ic3ecfc2b601bafaab12b1805d7f9512955a8c7e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/474356
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agocrypto/internal/nistec: refactor scalar multiplication
Filippo Valsorda [Mon, 13 Feb 2023 19:49:38 +0000 (20:49 +0100)]
crypto/internal/nistec: refactor scalar multiplication

The assumptions of some of the assembly functions were still scarcely
documented and even disregarded: p256ScalarMult was relying on the fact
that the "undefined behavior" of p256PointAddAsm with regards to
infinity inputs was returning the infinity.

Aside from expanding comments, moving the bit window massaging into a
more easily understood p256OrdRsh function, and fixing the above, this
change folds the last iteration of p256ScalarMult into the loop to
reduce special cases and inverts the iteration order of p256BaseMult so
it matches p256ScalarMult for ease of comparison.

Updates #58647

Change-Id: Ie5712ea778aadbe5adcdb478d111c2527e83caa0
Reviewed-on: https://go-review.googlesource.com/c/go/+/471256
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>

15 months agotime: fix timezone lookup logic for non-DST zones
Geon Kim [Sat, 11 Mar 2023 00:57:57 +0000 (00:57 +0000)]
time: fix timezone lookup logic for non-DST zones

This change fixes time.LoadLocationFromTZData and time.Location.lookup logic if the given time is after the last transition and the extend string doesn't have the DST rule.

Fixes #58682

Change-Id: Ie34a6d658d14c2b33098b29ab83c041ef0d34266
GitHub-Last-Rev: f6681eb44c0ea0772004e56eb68fcbd9023d971e
GitHub-Pull-Request: golang/go#58684
Reviewed-on: https://go-review.googlesource.com/c/go/+/471020
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>

15 months agobytes: add Buffer.Available and Buffer.AvailableBuffer
Joe Tsai [Mon, 6 Feb 2023 19:37:39 +0000 (11:37 -0800)]
bytes: add Buffer.Available and Buffer.AvailableBuffer

This adds a new Buffer.AvailableBuffer method that returns
an empty buffer with a possibly non-empty capacity for use
with append-like APIs.

The typical usage pattern is something like:

b := bb.AvailableBuffer()
b = appendValue(b, v)
bb.Write(b)

It allows logic combining append-like APIs with Buffer
to avoid needing to allocate and manage buffers themselves and
allows the append-like APIs to directly write into the Buffer.

The Buffer.Write method uses the builtin copy function,
which avoids copying bytes if the source and destination are identical.
Thus, Buffer.Write is a constant-time call for this pattern.

Performance:

BenchmarkBufferAppendNoCopy  2.909 ns/op  5766942167.24 MB/s

This benchmark should only be testing the cost of bookkeeping
and never the copying of the input slice.
Thus, the MB/s should be orders of magnitude faster than RAM.

Fixes #53685

Change-Id: I0b41e54361339df309db8d03527689b123f99085
Reviewed-on: https://go-review.googlesource.com/c/go/+/474635
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agocmd/go: unify the format of the go help xxx command
cui fliter [Wed, 8 Mar 2023 11:00:51 +0000 (19:00 +0800)]
cmd/go: unify the format of the go help xxx command

Fixes #58871
Updates #58871

Change-Id: I947b71083e9559859b3ae6e17b5daad03a976707
Reviewed-on: https://go-review.googlesource.com/c/go/+/474375
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

15 months agoall: fix some problematic comments
cui fliter [Sat, 11 Mar 2023 02:33:57 +0000 (10:33 +0800)]
all: fix some problematic comments

Change-Id: Ia110d19fe5ff3adc8bbf86dd2112f9702164d495
Reviewed-on: https://go-review.googlesource.com/c/go/+/475515
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

15 months agocmd/dist: omit DWARF in build release toolchain binaries
Russ Cox [Wed, 8 Mar 2023 19:48:41 +0000 (14:48 -0500)]
cmd/dist: omit DWARF in build release toolchain binaries

The vast majority of users of Go toolchains have no need for
binaries like the go command and compiler to include DWARF
information, and the DWARF information is 34% of the size of
the overall Go toolchain zip files (14% when the toolchain is
unzipped on disk, because other parts get bigger).

To save network and disk, disable DWARF in build release binaries.
DWARF remains enabled when developing in the main branch
(signaled by no VERSION file existing), for better debuggability
when actually working on the compiler and go command.

Note that removing DWARF does not break the backtraces shown
when a binary panics, nor does it break other uses of stack traces
from within a Go program, such as runtime.Callers.

To build a release toolchain with DWARF included, people can use

GO_LDFLAGS=-w=0 ./make.bash

Change-Id: Ib0bbe1446adca4599066b2fb2f2734e6825c1106
Reviewed-on: https://go-review.googlesource.com/c/go/+/475378
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/dist: reproducibility fixes
Russ Cox [Sun, 5 Mar 2023 18:05:25 +0000 (13:05 -0500)]
cmd/dist: reproducibility fixes

Fix a few lingering reproducibility problems.

- Do not set CC during go install std if it is unset,
  so that the automatic disabling of cgo in cmd/go can run.

- Since CC is not necessary, remove code insisting on it.

- Use a fixed quoting algorithm instead of %q from the
  bootstrap toolchain, which can differ from release to release.

- Remove go_bootstrap tool successfully on Windows.

For #24904.

Change-Id: I5c29ba6a8592e93bfab37f123b69f55c02f12ce3
Reviewed-on: https://go-review.googlesource.com/c/go/+/475377
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agoruntime: remove NOFRAME from asmcgocall, systemstack and mcall
qmuntal [Tue, 28 Feb 2023 18:30:32 +0000 (19:30 +0100)]
runtime: remove NOFRAME from asmcgocall, systemstack and mcall

This CL removes the NOFRAME flag from runtime.asmcgocall,
runtime.systemstack and runtime.mcall so the compiler can place
the frame pointer on the stack.

This will help unwinding cgo stack frames, and might be all what's
needed for tools that only use the frame pointer to unwind the stack.
That's not the case for gdb, which uses DWARF CFI, and windbg,
which uses SEH. Yet, having the frame pointer correctly set lays
the foundation for supporting cgo unwinding with DWARF CFI and SEH.

Updates #58378

Change-Id: I7655363b3fb619acccd9d5a7f0e3d3dec953cd52
Reviewed-on: https://go-review.googlesource.com/c/go/+/472195
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>