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

55507 Commits

Author SHA1 Message Date
Cuong Manh Le
8c37d486c8 go/types, types2: refuse pointer to array as argument to "clear" builtin
The accepted proposal only permits map and slice types.

Updates #56351

Change-Id: I95cf4c856a5ecfcdf564601b6215eda3cb6ba86b
Reviewed-on: https://go-review.googlesource.com/c/go/+/463075
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2023-01-24 17:50:44 +00:00
Jeremy Quirke
dc9d219cad cmd/link: remove importcycles function
The importcycles method has not been useful since April 2016 when a large code deletion was performed.

The compiler itself provides some protection against import cycles, and the linker does import cycle detection in linksetup -> postorder.

For #57400

Change-Id: I3095bdb3f16a82ba25681bf4a20ceaa3c9613921
GitHub-Last-Rev: 87a46153b1
GitHub-Pull-Request: golang/go#57462
Reviewed-on: https://go-review.googlesource.com/c/go/+/459475
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
2023-01-24 17:00:10 +00:00
Than McIntosh
733ba92187 cmd/compile: flag 'large' functions when -m=2+ in effect
When -m=N (where N > 1) is in effect, include a note in the trace
output if a given function is considered "big" during inlining
analysis, since this causes the inliner to be less aggressive. If a
small change to a large function happens to nudge it over the large
function threshold, it can be confusing for developers, thus it's
probably worth including this info in the remark output.

Change-Id: Id31a1b76371ab1ef9265ba28a377f97b0247d0a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/460317
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2023-01-24 13:28:54 +00:00
qmuntal
1951857ec0 os: use handle based APIs to read directories on windows
This CL updates File.readdir() on windows so it uses
GetFileInformationByHandleEx with FILE_ID_BOTH_DIR_INFO
instead of Find* APIs. The former is more performant because
it allows us to buffer IO calls and reduces the number of system calls,
passing from 1 per file to 1 every ~100 files
(depending on the size of the file name and the size of the buffer).

This change improve performance of File.ReadDir by 20-30%.

name        old time/op    new time/op    delta
ReadDir-12     562µs ±14%     385µs ± 9%  -31.60%  (p=0.000 n=9+9)

name        old alloc/op   new alloc/op   delta
ReadDir-12    29.7kB ± 0%    29.5kB ± 0%   -0.88%  (p=0.000 n=8+10)

name        old allocs/op  new allocs/op  delta
ReadDir-12       399 ± 0%       397 ± 0%   -0.50%  (p=0.000 n=10+10)

This change also speeds up calls to os.SameFile when using FileStats
returned from File.readdir(), as their file ID can be inferred while
reading the directory.

Change-Id: Id56a338ee66c39656b564105cac131099218fb5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/452995
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-01-24 13:26:00 +00:00
qmuntal
7b5a34418c runtime: remove unused badsignal2 on windows
This CL removes badsignal2 function, as it is unused on Windows.

badsignal2 was originally intended to abort the process when
an exception was raised on a non-Go thread, following the same approach
as Linux and others.

Since it was added, back on https://golang.org/cl/5797068, it has caused
several issues on Windows, see #8224 and #50877. That's because we can't
know wether the signal is bad or not, as our trap might not be at the
end of the exception handler chain.

To fix those issues, https://golang.org/cl/104200046 and CL 442896
stopped calling badsignal2, and CL 458135 removed one last incorrect
call on amd64 and 386.

Change-Id: I5bd31ee2672118ae0f1a2c8b46a1bb0f4893a011
Reviewed-on: https://go-review.googlesource.com/c/go/+/463116
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-24 12:56:06 +00:00
qmuntal
cf9263dee1 runtime: factor out windows sigtramp
This CL factors out part of the Windows sigtramp implementation, which
was duplicated in all four architectures. The new common code is
implemented in Go rather than in assembly, which will make Windows
error handling easier to reason and maintain.

While here, implement the control flow guard workaround on
windows/386, which almost comes for free.

Change-Id: I0bf38c28c54793225126e161bd95527a62de05e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/458135
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2023-01-24 12:05:07 +00:00
qmuntal
e39c7a37f0 runtime: run TestVectoredHandlerDontCrashOnLibrary on 386 and arm64
This CL updates TestVectoredHandlerDontCrashOnLibrary so it can run on
windows/386 and windows/arm64. It still can't run on windows/arm as
it does not support c-shared buildmode (see #43800).

Change-Id: Id1577687e165e77d27633c632634ecf86e6e9d6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/463117
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-01-24 08:46:11 +00:00
qmuntal
030ca34f57 path/filepath: remove extra Clean call in EvalSymlinks on Windows
EvalSymlinks calls Clean twice, one in walkSymlinks and another in
toNorm. The later is not necessary, as toNorm is only called by
EvalSymlinks and just after walkSymlinks cleans the path without any
path manipulation in between.

Change-Id: Ibdb782c7eed59468f0ebb913e98d2a7db0df010d
Reviewed-on: https://go-review.googlesource.com/c/go/+/454615
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
2023-01-24 07:42:17 +00:00
James Yang
7135710e01 archive: error check when parse archive
Add error check when call `r.parseObject` in `parseArchive`.

Change-Id: Ib1739f25941262593cf63837e272b6ee896d8613
GitHub-Last-Rev: 5a17f9aa2c
GitHub-Pull-Request: golang/go#57624
Reviewed-on: https://go-review.googlesource.com/c/go/+/460755
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2023-01-24 01:02:52 +00:00
Koichi Shiraishi
707f888797 cmd/compile/internal/pgo: gofmt and simplify
Change-Id: I29621cb6a3845917e7558be28579fe0e1b2d5afa
Reviewed-on: https://go-review.googlesource.com/c/go/+/446776
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
2023-01-23 23:36:10 +00:00
Bryan C. Mills
3e44b7d07a os: treat non-symlink reparse points as irregular files
Prior to this change (as of CL 143578), our stat function attempted to
resolve all reparse points as if they were symlinks.

This results in an additional call to CreateFile when statting a
symlink file: we use CreateFile once to obtain the reparse tag and
check whether the file is actually a symlink, and if it is we call
CreateFile again without FILE_FLAG_OPEN_REPARSE_POINT to stat the link
target. Fortunately, since symlinks are rare on Windows that overhead
shouldn't be a big deal in practice.

Fixes #42919.

Change-Id: If453930c6e98040cd6525ac4aea60a84498c9579
Reviewed-on: https://go-review.googlesource.com/c/go/+/460595
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
2023-01-23 22:46:55 +00:00
qmuntal
2423370136 utf16: reduce utf16.Decode allocations
This CL avoids allocating in utf16.Decode for code point sequences
with less than 64 elements. It does so by splitting the function in two,
one that can be inlined that preallocates a buffer and the other that
does the heavy-lifting.

The mid-stack inliner will allocate the buffer in the caller stack,
and in many cases this will be enough to avoid the allocation.

unicode/utf16 benchmarks:

name                         old time/op    new time/op    delta
DecodeValidASCII-12            60.1ns ± 3%    16.0ns ±20%   -73.40%  (p=0.000 n=8+10)
DecodeValidJapaneseChars-12    61.3ns ±10%    14.9ns ±39%   -75.71%  (p=0.000 n=10+10)

name                         old alloc/op   new alloc/op   delta
DecodeValidASCII-12             48.0B ± 0%      0.0B       -100.00%  (p=0.000 n=10+10)
DecodeValidJapaneseChars-12     48.0B ± 0%      0.0B       -100.00%  (p=0.000 n=10+10)

name                         old allocs/op  new allocs/op  delta
DecodeValidASCII-12              1.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)
DecodeValidJapaneseChars-12      1.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)

I've also benchmarked os.File.ReadDir with this change applied
to demonstrate that it does make a difference in the caller site, in this
case via syscall.UTF16ToString:

name        old time/op    new time/op    delta
ReadDir-12     592µs ± 8%     620µs ±16%     ~     (p=0.280 n=10+10)

name        old alloc/op   new alloc/op   delta
ReadDir-12    30.4kB ± 0%    22.4kB ± 0%  -26.10%  (p=0.000 n=8+10)

name        old allocs/op  new allocs/op  delta
ReadDir-12       402 ± 0%       272 ± 0%  -32.34%  (p=0.000 n=10+10)

Change-Id: I65cf5caa3fd3b3a466c0ed837a50a96e975bbe6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/453415
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
2023-01-23 20:59:01 +00:00
David Chase
0c8480acfe internal/abi: repair broken self-bootstrap
Fixes bug caused by https://go.dev/cl/462115

Change-Id: Id91a139db827f2962be837b8fd218e7b895ce8b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/463175
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-23 19:14:57 +00:00
Matt Horsnell
b90971b292 runtime: enable sha512 optimizations on arm64 via hwcaps.
Change-Id: I9d88c8eb91106de412a9abc6601cdda06537d818
Reviewed-on: https://go-review.googlesource.com/c/go/+/461747
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
2023-01-23 18:50:54 +00:00
Jorropo
35755d772f cmd/compile: teach prove about unsigned division, modulus and rsh
Fixes: #57077
Change-Id: Icffcac42e28622eadecdba26e3cd7ceca6c4aacc
Reviewed-on: https://go-review.googlesource.com/c/go/+/455095
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2023-01-23 18:35:41 +00:00
Alexander Yastrebov
5e03c634b8 math/big: validate result of Float.GobDecode
Fixes #57946

Change-Id: Ia499ebfd8801432122f89fdf6bda4d1e7b6dd832
GitHub-Last-Rev: 29e0993886
GitHub-Pull-Request: golang/go#57951
Reviewed-on: https://go-review.googlesource.com/c/go/+/463017
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2023-01-23 18:18:05 +00:00
qmuntal
28f8dbd7b9 runtime,cmd/internal/obj/x86: use TEB TLS slots on windows/i386
This CL redesign how we get the TLS pointer on windows/i386.
It applies the same changes as done in CL 431775 for windows/amd64.

We were previously reading it from the [TEB] arbitrary data slot,
located at 0x14(FS), which can only hold 1 TLS pointer.

With this CL, we will read the TLS pointer from the TEB TLS slot array,
located at 0xE10(GS). The TLS slot array can hold multiple
TLS pointers, up to 64, so multiple Go runtimes running on the
same thread can coexists with different TLS.

Each new TLS slot has to be allocated via [TlsAlloc],
which returns the slot index. This index can then be used to get the
slot offset from GS with the following formula: 0xE10 + index*4.

The slot index is fixed per Go runtime, so we can store it
in runtime.tls_g and use it latter on to read/update the TLS pointer.

Loading the TLS pointer requires the following asm instructions:

  MOVQ runtime.tls_g, AX
  MOVQ AX(FS), AX

Notice that this approach will now be implemented in all the supported
windows arches.

[TEB]: https://en.wikipedia.org/wiki/Win32_Thread_Information_Block
[TlsAlloc]: https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-tlsalloc

Change-Id: If4550b0d44694ee6480d4093b851f4991a088b32
Reviewed-on: https://go-review.googlesource.com/c/go/+/454675
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-23 18:15:35 +00:00
Jakub Ciolek
bb5ff5342d cmd/compile: make loopbce handle 8, 16 and 32 bit induction variables
Compute limits and increment values for all integer widths.
Resolves 2 TODO's in loopbce.go

compilecmp linux/amd64:

compress/flate
compress/flate.(*huffmanEncoder).bitCounts 1235 -> 1207  (-2.27%)

cmd/internal/obj/wasm
cmd/internal/obj/wasm.assemble 7443 -> 7303  (-1.88%)
cmd/internal/obj/wasm.assemble.func1 165 -> 138  (-16.36%)

cmd/link/internal/ld
cmd/link/internal/ld.(*Link).findfunctab.func1 1646 -> 1627  (-1.15%)

Change-Id: I2d79b7376eb67d6bcc8fdaf0c197c11e631562d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/435258
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2023-01-23 18:10:40 +00:00
j2gg0s
9411075748 runtime: remove duplicate check of work.full in gcMark.
Change-Id: I659669d7259e7cf73f730232cda11d8525a4aabc
GitHub-Last-Rev: 5d183e8128
GitHub-Pull-Request: golang/go#57901
Reviewed-on: https://go-review.googlesource.com/c/go/+/462281
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-01-23 18:00:36 +00:00
David Chase
e22bd2348c internal/abi,runtime: refactor map constants into one place
Previously TryBot-tested with bucket bits = 4.
Also tested locally with bucket bits = 5.
This makes it much easier to change the size of map
buckets, and hopefully provides pointers to all the
code that in some way depends on details of map layout.

Change-Id: I9f6669d1eadd02f182d0bc3f959dc5f385fa1683
Reviewed-on: https://go-review.googlesource.com/c/go/+/462115
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2023-01-23 15:51:32 +00:00
Daniel Martí
e2fe35363d runtime: use copy as spotted by staticcheck
Change-Id: Ibffe46bad7d30df9380ba18d49eeb6782406a1aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/463115
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-01-23 10:02:20 +00:00
Keith Randall
ba91377454 test: test that we schedule OpArgIntReg early
If OpArgIntReg is incorrectly scheduled, that causes it to be spilled
incorrectly, which causes the argument to not be considered live
at the start of the function.

This is the test for CL 462858

Add a brief mention of why CL 462858 is needed in the scheduling code.

Change-Id: Id199456f88d9ee5ca46d7b0353a3c2049709880e
Reviewed-on: https://go-review.googlesource.com/c/go/+/462899
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
2023-01-21 21:08:30 +00:00
Keith Randall
4ff074945a cmd/compile: sort liveness variable reports
Sort variables before display so that when there are multiple variables
to report, they are in a consistent order.

Otherwise they are ordered in the order they appear in the fn.Dcl list,
which can vary. Particularly, they vary depending on regabi.

Change-Id: I0db380f7cbe6911e87177503a4c3b39851ff1b5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/462898
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-01-21 21:08:00 +00:00
David Chase
780fa24260 net: add testing.Short Skip to test affected by local network configuration
If the local network mangles invalid DNS queries, that is not a Go problem.

Change-Id: I54db392532eed988bca81b70a98cd6d11766af89
Reviewed-on: https://go-review.googlesource.com/c/go/+/461275
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-21 21:06:53 +00:00
fangguizhen
85b49d7f21 bytes,strings: add some examples
Change-Id: Ic93ad59119f3549c0f13c4f366f71e9d01b88c47
GitHub-Last-Rev: afb5180472
GitHub-Pull-Request: golang/go#57907
Reviewed-on: https://go-review.googlesource.com/c/go/+/462283
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-01-20 23:21:39 +00:00
matsuyoshi30
0518e33f6c path/filepath: fix evaluation of symlinks to paths under /tmp on macOS
For symlinks created from symlinks under the root directory created
as the relative path (e.g., symbolic links under /tmp), we update vol and volLen.

Fixes #57905

Change-Id: I45affd1db3b93109de51bf19b181f3cdba061109
Reviewed-on: https://go-review.googlesource.com/c/go/+/461761
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-01-20 22:42:39 +00:00
fangguizhen
27b6ace2b4 errors: move example functions into example_test file
Change-Id: Ide70476698d82a51881802dd6bf05dd7abcd60e8
GitHub-Last-Rev: ddb251ded6
GitHub-Pull-Request: golang/go#57931
Reviewed-on: https://go-review.googlesource.com/c/go/+/462292
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@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>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2023-01-20 21:55:10 +00:00
Than McIntosh
620399ef0d internal/coverage/decodemeta: fix coding error in func literal handling
Fix a coding error in coverage meta-data decoding in the method
decodemeta.CoverageMetaDataDecoder.ReadFunc. The code was not
unconditionally assigning the "function literal" field of the
coverage.FuncDesc object passed in, resulting in bad values depending
on what the state of the field happened to be in the object.

Fixes #57942.

Change-Id: I6dfd7d7f7af6004f05c622f9a7116e9f6018cf4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/462955
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-01-20 21:42:05 +00:00
Than McIntosh
cf70d37967 runtime/coverage: avoid non-test coverage profiles in test report helper
When walking through the set of coverage data files generated from a
"go test -cover" run, it's possible to encounter pods (clumps of data
files) that were generated by a run from an instrumented Go tool (for
example, cmd/compile). Add a guard to the test reporting code to
ensure that it only processes files created by the currently running
test.

Fixes #57924.

Change-Id: I1bb7dce88305e1088162e3cb1df628486ecee1c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/462756
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
2023-01-20 21:41:45 +00:00
Sameer Ajmani
8bec956360 context: add APIs for setting a cancelation cause when deadline or timer expires
Fixes #56661

Change-Id: I1c23ebc52e6b7ae6ee956614e1a0a45d6ecbd5b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/449318
Run-TryBot: Sameer Ajmani <sameer@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-20 21:41:01 +00:00
Robert Findley
59964663e5 go/types: add a test that generated files match types2
Adjust the go/types file generation to run in a test, so that we can
easily reuse the existing logic to verify that the current content of
go/types matches the expected result of generating from types2.

This test will enforce that we don't forget to regenerate go/types when
making changes to types2.

Change-Id: Iee14b1402065f7f0ecbcf28000e07a06c08fa42e
Reviewed-on: https://go-review.googlesource.com/c/go/+/462758
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
2023-01-20 21:15:52 +00:00
Kevin Parsons
e587a7691b cmd/link: fix incorrect DOS header on Windows binaries
The previous DOS header placed on Windows binaries was incorrect, as it had e_crlc (number of relocations) set to 4, instead of e_cparhdr (size of header in 16-bit words) set to 4. This resulted in execution starting at the beginning of the file, instead of where the DOS stub code actually exists.

Fixes #57834

Change-Id: I8c5966b65c72b2474b771b85aaadb61cad9f5be6
GitHub-Last-Rev: c715ad290a
GitHub-Pull-Request: golang/go#57835
Reviewed-on: https://go-review.googlesource.com/c/go/+/462054
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
2023-01-20 20:52:48 +00:00
Keith Randall
b08d5ee5e9 cmd/compile: ensure register args come before on-stack args in schedule
The register allocator doesn't like OpArg coming in between other
OpIntArg operations, as it doesn't put the spills in the right place
in that situation.

This is just a bug in the new scheduler, I didn't copy over the
proper score from the old scheduler correctly.

Change-Id: I3b4ee1754982fb360e99c5864b19e7408d60b5bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/462858
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-20 19:51:06 +00:00
Changkun Ou
f07910bd57 sync: document memory model for Swap/CompareAnd{Swap,Delete} in Map
CL 381316 documented the memory model of Map's APIs. However, the newly
introduced Swap, CompareAndSwap, and CompareAndDelete are missing from
this documentation as CL 399094 did not add this info.

This CL specifies the defined read/write operations of the new Map APIs.

For #51972

Change-Id: I519a04040a0b429a3f978823a183cd62e42c90ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/459715
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Changkun Ou <mail@changkun.de>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-01-20 19:38:29 +00:00
Robert Griesemer
5724daa682 go/types, types2: use go.dev/issue/nnnnn when referring to an issue (cleanup)
Apply the following regex substitutions, in order:

golang/go#(\d+)  =>  go.dev/issue/$1
issue #?(\d+)    =>  go.dev/issue/$1

Providing a link uniformly makes it easier to find the respective issue.

Change-Id: I9b60ffa1adb95be181f6711c2f171be3afe2b315
Reviewed-on: https://go-review.googlesource.com/c/go/+/462856
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2023-01-20 18:13:03 +00:00
Robert Griesemer
4b23068712 types2: add *Config to typecheck functions for tests, factor more code
Some tests in go/types can still not use the typecheck helper functions
because they need a specific fileset for position information.

(We could use a single global file set for all tests to make this work.)

Change-Id: I73552b08a00f08d809c319d3d2328acee9532619
Reviewed-on: https://go-review.googlesource.com/c/go/+/461694
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>
2023-01-20 18:13:01 +00:00
Robert Griesemer
e38cb25b33 go/types: generate instantiate.go
Change-Id: Iad8b78bbf52eb2b0de05471bfd5a5506dc45e055
Reviewed-on: https://go-review.googlesource.com/c/go/+/461693
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-20 18:12:59 +00:00
Robert Griesemer
2507e7897b go/types: provision for generating initorder.go, but disabled for now
Add the code to generate initorder.go but do not enable the generation
of that file for now because the generated  use uses error_ which has
implications for gopls use (error_ produces a single error instead of
pultiple \t-indented follow-on errors).

Change-Id: I5cd8acdeb8845dbb4716f19cf90d88191dd4216c
Reviewed-on: https://go-review.googlesource.com/c/go/+/461692
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2023-01-20 18:12:57 +00:00
Dmitri Shuralyov
1011ccad5c cmd/dist: mark linux/sparc64 as a broken port, remove incomplete map
The linux/sparc64 port is incomplete—it doesn't work, and it doesn't
have a builder. Now that dist supports broken ports, mark it as such.

The incomplete map was created to hide ports that aren't functional
from dist list output. Now that we have the broken port concept, it
seems largely redundant, so remove it for now.

For #56679.
Updates #28944.

Change-Id: I34bd23e913ed6d786a4d0aa8d2852f2b926fe4b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/458516
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.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: Dmitri Shuralyov <dmitshur@google.com>
2023-01-20 17:52:28 +00:00
Dmitri Shuralyov
399ad79fa6 cmd/dist: add map of broken ports and -force flag
It's empty so far. The next CL adds linux/sparc64.

Also add -force flag to the bootstrap.bash script
so that it's possible to use it with broken ports.

For #56679.

Change-Id: I09c733d0df0a68df34fb808eae29be010a6da461
Reviewed-on: https://go-review.googlesource.com/c/go/+/458515
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-20 17:52:26 +00:00
Dmitri Shuralyov
e7495d8737 cmd/dist: remove GOTESTONLY environment variable
This hook was added for the Go build system (x/build) to be able to set
the run flag value, but it's no longer used anywhere. Remove it for now.

Updates #46054.

Change-Id: I64e7d68d2b270303f3bd54f73079600f209e350a
Reviewed-on: https://go-review.googlesource.com/c/go/+/455519
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-20 17:47:38 +00:00
Dmitri Shuralyov
09d852ceac cmd/dist: remove hardcoded timeout scale for arm and mips{,le,64,64le}
Fixes #57117.

Change-Id: If36da5b138a5e92e27688719ffc1c4dafd590957
Reviewed-on: https://go-review.googlesource.com/c/go/+/455518
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-20 17:47:35 +00:00
Anit Gandhi
62a994837a crypto/tls: improve client auth failure alerts
This change makes it easier for clients to debug mutual TLS connection failures. Currently, there are a few situations where invalid client auth leads to a generic "bad certificate" alert. 3 specific situations have a more appropriate TLS alert code, based on the alert descriptions in the appendix of both RFC5246 and RFC8446.
  1. The server is configured to require client auth, but no client cert was provided; the appropriate alert is "certificate required". This applies only to TLS 1.3, which first defined the certificate_required alert code.
  2. The client provided a cert that was signed by an authority that is not in the server's trusted set of CAs; the appropriate alert is "unknown certificate authority".
  3. The client provided an expired (or not yet valid) cert; the appropriate alert is "expired certificate".
Otherwise, we still fall back to "bad certificate".

Fixes #52113

Change-Id: I7d5860fe911cad8a1615f16bfe488a37e936dc36
GitHub-Last-Rev: 34eeab587b
GitHub-Pull-Request: golang/go#53251
Reviewed-on: https://go-review.googlesource.com/c/go/+/410496
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2023-01-20 16:19:42 +00:00
Ian Lance Taylor
8b79c41dd5 cmd/go: update test for change in panic(nil) behavior
panic(nil) now panics with runtime.PanicNilError.

For #25448

Change-Id: I58994aa80d4d11f0c5fcd988714f7b4b45c6b5ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/462293
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2023-01-20 15:49:29 +00:00
Daniel Martí
c641d48afd go/types: use internal/lazyregexp for goVersionRx
With benchinit, we see a noticeable improvement in init times:

	name     old time/op    new time/op    delta
	GoTypes    83.4µs ± 0%    43.7µs ± 1%  -47.57%  (p=0.029 n=4+4)

	name     old alloc/op   new alloc/op   delta
	GoTypes    26.5kB ± 0%    18.8kB ± 0%  -29.15%  (p=0.029 n=4+4)

	name     old allocs/op  new allocs/op  delta
	GoTypes       238 ± 0%       154 ± 0%  -35.29%  (p=0.029 n=4+4)

Port the same change to cmd/compile/internal/types and types2.

Updates #26775.

Change-Id: Ia1f7c4a4ce9a22d66e2aa9c9b9c341036993adca
Reviewed-on: https://go-review.googlesource.com/c/go/+/460544
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2023-01-20 09:35:03 +00:00
Daniel Martí
8259ac4986 encoding/gob: shave off some init time cost
Avoid unnecessary allocations when calling reflect.TypeOf;
we can use nil pointers, which fit into an interface without allocating.
This saves about 1% of CPU time.

The builtin types are limited to typeIds between 0 and firstUserId,
and since firstUserId is 64, builtinIdToType does not need to be a map.
We can simply use an array of length firstUserId, which is simpler.
This saves about 1% of CPU time.

idToType is similar to firstUserId in that it is a map keyed by typeIds.
The difference is that it can grow with the user's types.
However, each added type gets the next available typeId,
meaning that we can use a growing slice, similar to the case above.
nextId then becomes the current length of the slice.
This saves about 1% of CPU time.

typeInfoMap is stored globally as an atomic.Value,
where each modification loads the map, makes a whole copy,
adds the new element, and stores the modified copy.
This is perfectly fine when the user registers types,
as that can happen concurrently and at any point in the future.

However, during init time, we sequentially register many types,
and the overhead of copying maps adds up noticeably.
During init time, use a regular global map instead,
which gets replaced by the atomic.Value when our init work is done.
This saves about 2% of CPU time.

Finally, avoid calling checkId in bootstrapType;
we have just called setTypeId, whose logic for getting nextId is simple,
so the extra check doesn't gain us much.
This saves about 1% of CPU time.

Using benchinit, which transforms GODEBUG=inittrace=1 data into Go
benchmark compatible output, results in a nice improvement:

	name         old time/op    new time/op    delta
	EncodingGob     175µs ± 0%     162µs ± 0%  -7.45%  (p=0.016 n=5+4)

	name         old alloc/op   new alloc/op   delta
	EncodingGob    39.0kB ± 0%    36.1kB ± 0%  -7.35%  (p=0.016 n=5+4)

	name         old allocs/op  new allocs/op  delta
	EncodingGob       588 ± 0%       558 ± 0%  -5.10%  (p=0.000 n=5+4)

Updates #26775.

Change-Id: I28618e8b96ef440480e666ef2cd5c4a9a332ef21
Reviewed-on: https://go-review.googlesource.com/c/go/+/460543
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-20 09:34:41 +00:00
Daniel Martí
f53137f95c internal/profile: use internal/lazyregexp for the legacy parser
Per benchinit, this makes a big difference to init times:

	name             old time/op    new time/op    delta
	InternalProfile     185µs ± 1%       6µs ± 1%  -96.51%  (p=0.008 n=5+5)

	name             old alloc/op   new alloc/op   delta
	InternalProfile     101kB ± 0%       4kB ± 0%  -95.72%  (p=0.008 n=5+5)

	name             old allocs/op  new allocs/op  delta
	InternalProfile       758 ± 0%        25 ± 0%  -96.70%  (p=0.008 n=5+5)

The fixed 0.2ms init cost is saved for any importer of net/http/pprof,
but also for cmd/compile, as it supports PGO now.
A Go program parsing profiles might not even need to compile these
regular expressions at all, if it doesn't encounter any legacy files.
I suspect this will be the case with most invocations of cmd/compile.

Updates #26775.

Change-Id: I8374dc64459f0b6bb09bbdf9d0b6c55d7ae1646e
Reviewed-on: https://go-review.googlesource.com/c/go/+/460545
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-20 09:27:47 +00:00
Daniel Martí
1bef0707a5 cmd/link: use strings.LastIndexByte to fix a TODO
Go 1.20 will require Go 1.17 to bootstrap, so we can stop worrying about
older Go bootstrap versions. https://go.dev/issues/44505 fixed most of
those TODOs, but this one was presumably forgotten about.

Change-Id: I0c19ec4eec65cd807e7db9a57c5969845d915c07
Reviewed-on: https://go-review.googlesource.com/c/go/+/461155
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-01-20 09:27:21 +00:00
Jakub Ciolek
8354f6b5bb cmd/compile: use a boolean as a avoid clobbering flags mov marker
The Value type implements Aux interface because it is being used as a
"avoid clobbering flags" marker by amd64, x86 and s390x SSA parts.

Create a boolean that implements the Aux interface. Use it as the marker
instead. We no longer need Value to implement Aux.

Resolves a TODO.

See CL 275756 for more info.

Change-Id: I8a1eddf7e738b8aa31e82f3c4c590bafd2cdc56b
Reviewed-on: https://go-review.googlesource.com/c/go/+/461156
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-01-20 05:01:15 +00:00
Srinivas Pokala
3e77efc720 cmd/internal/obj/s390x, runtime: fix breakpoint in s390x
Currently runtime.Breakpoint generates SIGSEGV in s390x.
The solution to this is add new asm instruction BRRK of
type FORMAT_E for the breakpoint exception.

Fixes #52103

Change-Id: I8358a56e428849a5d28d5ade141e1d7310bee084
Reviewed-on: https://go-review.googlesource.com/c/go/+/457456
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2023-01-20 05:00:12 +00:00