]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
2 years ago[dev.boringcrypto] all: merge master into dev.boringcrypto
Chressie Himpel [Wed, 20 Apr 2022 14:56:54 +0000 (16:56 +0200)]
[dev.boringcrypto] all: merge master into dev.boringcrypto

Change-Id: I52009bf809dda4fbcff03aa82d0ea8aa2a978fa2

2 years agocrypto/rand: batch and buffer calls to getrandom/getentropy
Jason A. Donenfeld [Fri, 10 Dec 2021 16:23:08 +0000 (17:23 +0100)]
crypto/rand: batch and buffer calls to getrandom/getentropy

We're using bufio to batch reads of /dev/urandom to 4k, but we weren't
doing the same on newer platforms with getrandom/getentropy. Since the
overhead is the same for these -- one syscall -- we should batch reads
of these into the same 4k buffer. While we're at it, we can simplify a
lot of the constant dispersal.

This also adds a new test case to make sure the buffering works as
desired.

Change-Id: I7297d4aa795c00712e6484b841cef8650c2be4ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/370894
Reviewed-by: Filippo Valsorda <valsorda@google.com>
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
Auto-Submit: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agocmd/compile: more negation related generic SSA rewrite rules
Jorropo [Mon, 18 Apr 2022 17:46:43 +0000 (17:46 +0000)]
cmd/compile: more negation related generic SSA rewrite rules

The x + (-y) => x - y rule is hitted 75 times while building stage 3 and tools
and make the linux-amd64 go binary 0.007% smaller.
It transform:
  NEG AX
  ADD BX, AX
Into:
  SUB BX, AX
Which is 2X faster (assuming this assembly in a vacum).

The x ^ (-1) => ^x rule is not hitted in the toolchain.
It transforms:
  XOR $-1, AX
Into:
  NOT AX
Which is more compact as it doesn't encode the immediate.
Cache usage aside, this does not affect performance
(assuming this assembly in a vacum).
On my ryzen 3600, with some surrouding code, this randomly might be 2X faster,
I guess this has to do with loading the immediate into a temporary register.
Combined to an other rule that already exists it also rewrite manual two's
complement negation from:
  XOR $-1, AX
  INC AX
Into:
  NEG AX
Which is 2X faster.

The other rules just eliminates similar trivial cases and help constants
folding.

This should generalise to other architectures.

Change-Id: Ia1e51b340622e7ed88e5d856f3b1aa424aa039de
GitHub-Last-Rev: ce35ff2efdd8911f1e812806ec41a41e8cabc4c7
GitHub-Pull-Request: golang/go#52395
Reviewed-on: https://go-review.googlesource.com/c/go/+/400714
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agoreflect: adjust MapRange allocation test for noopt builder, take 2
Keith Randall [Tue, 19 Apr 2022 17:33:46 +0000 (10:33 -0700)]
reflect: adjust MapRange allocation test for noopt builder, take 2

Change-Id: If2887f84b3d14fac3c059fc5bad4186ec9d69d0f
Reviewed-on: https://go-review.googlesource.com/c/go/+/401077
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agoreflect: adjust MapRange allocation test for noopt builder
Keith Randall [Tue, 19 Apr 2022 15:55:04 +0000 (08:55 -0700)]
reflect: adjust MapRange allocation test for noopt builder

Change-Id: I55899ff0ed2c3c01f24ab1ccf133ce4236049e39
Reviewed-on: https://go-review.googlesource.com/c/go/+/401074
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2 years agodoc/go1.19: move the description of the runtime.GOROOT change from 'cmd/go' to 'runtime'
Bryan C. Mills [Mon, 18 Apr 2022 14:56:19 +0000 (10:56 -0400)]
doc/go1.19: move the description of the runtime.GOROOT change from 'cmd/go' to 'runtime'

Even though the change in the behavior of 'runtime.GOROOT' was
not actually due to a change in the runtime package proper, I
suspect that users who notice it will look for the release note
in that section, not the 'cmd/go' section.

Fixes #51461.

Change-Id: I271752968d4152a7fdf3e170537e3072bf87ce86
Reviewed-on: https://go-review.googlesource.com/c/go/+/400814
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agoio/ioutil: provide an equivalent for the deprecated ReadDir
Daniel Martí [Tue, 12 Apr 2022 06:11:28 +0000 (07:11 +0100)]
io/ioutil: provide an equivalent for the deprecated ReadDir

All APIs in the now-deprecated io/ioutil package have a direct
replacement in either the io or os package with the same signature,
with the notable exception of ioutil.ReadDir, as os.ReadDir has a
slightly different signature with fs.DirEntry rather than fs.FileInfo.

New code can easily make use of []fs.DirEntry directly,
but existing code may need to continue using []fs.FileInfo for backwards
compatibility reasons. For instance, I had a bit of code that exposed
the slice as a public API, like:

return ioutil.ReadDir(name)

It took me a couple of minutes to figure out what the exact equivalent
in terms of os.ReadDir would be, and a code sample would have helped.
Add one for future reference.

For #42026.
For #51927.

Change-Id: I76d46cd7d68fc609c873821755fdcfc299ffd56c
Reviewed-on: https://go-review.googlesource.com/c/go/+/399854
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
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>

2 years agocmd/link: faster algorithm for nosplit stack checking, better errors
Austin Clements [Fri, 1 Apr 2022 19:51:12 +0000 (15:51 -0400)]
cmd/link: faster algorithm for nosplit stack checking, better errors

The linker performs a global analysis of all nosplit call chains to
check they fit in the stack space ensured by splittable functions.
That analysis has two problems right now:

1. It's inefficient. It performs a top-down analysis, starting with
every nosplit function and the nosplit stack limit and walking *down*
the call graph to compute how much stack remains at every call. As a
result, it visits the same functions over and over, often with
different remaining stack depths. This approach is historical: this
check was originally written in C and this approach avoided the need
for any interesting data structures.

2. If some call chain is over the limit, it only reports a single call
chain. As a result, if the check does fail, you often wind up playing
whack-a-mole by guessing where the problem is in the one chain, trying
to reduce the stack size, and then seeing if the link works or reports
a different path.

This CL completely rewrites the nosplit stack check. It now uses a
bottom-up analysis, computing the maximum stack height required by
every function's call tree. This visits every function exactly once,
making it much more efficient. It uses slightly more heap space for
intermediate storage, but still very little in the scheme of the
overall link. For example, when linking cmd/go, the new algorithm
virtually eliminates the time spent in this pass, and reduces overall
link time:

           │   before    │                after                │
           │   sec/op    │   sec/op     vs base                │
Dostkcheck   7.926m ± 4%   1.831m ± 6%  -76.90% (p=0.000 n=20)
TotalTime    301.3m ± 1%   296.4m ± 3%   -1.62% (p=0.040 n=20)

           │    before    │                 after                  │
           │     B/op     │     B/op       vs base                 │
Dostkcheck   40.00Ki ± 0%   212.15Ki ± 0%  +430.37% (p=0.000 n=20)

Most of this time is spent analyzing the runtime, so for larger
binaries, the total time saved is roughly the same, and proportionally
less of the overall link.

If the new implementation finds an error, it redoes the analysis,
switching to preferring quality of error reporting over performance.
For error reporting, it computes stack depths top-down (like the old
algorithm), and reports *all* paths that are over the stack limit,
presented as a tree for compactness. For example, this is the output
from a simple test case from test/nosplit with two over-limit paths
from f1:

        main.f1: nosplit stack overflow
        main.f1
            grows 768 bytes, calls main.f2
                grows 56 bytes, calls main.f4
                    grows 48 bytes
                    80 bytes over limit
            grows 768 bytes, calls main.f3
                grows 104 bytes
                80 bytes over limit

While we're here, we do a few nice cleanups:

- We add a debug output flag, which will be useful for understanding
  what our nosplit chains look like and which ones are close to
  running over.

- We move the implementation out of the fog of lib.go to its own file.

- The implementation is generally more Go-like and less C-like.

Change-Id: If1ab31197f5215475559b93695c44a01bd16e276
Reviewed-on: https://go-review.googlesource.com/c/go/+/398176
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agotest/nosplit: add more complicated recursion tests
Austin Clements [Mon, 4 Apr 2022 19:41:08 +0000 (15:41 -0400)]
test/nosplit: add more complicated recursion tests

Change-Id: I301ed8bcc93f31147d247e60a7aab8ed42421bbd
Reviewed-on: https://go-review.googlesource.com/c/go/+/398175
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agotest/nosplit: apply stack limit adjustment in the right place
Austin Clements [Mon, 4 Apr 2022 18:51:39 +0000 (14:51 -0400)]
test/nosplit: apply stack limit adjustment in the right place

The nosplit test was originally written when the stack limit was a
mere 128 bytes. Now it's much larger, but rather than rewriting all of
the tests, we apply a hack to just add the extra space into the stack
frames of the existing tests.

Unfortunately, we add it in the wrong place. The extra space should be
added just once per chain of nosplit functions, but instead we add it
to every frame that appears first on a line in the test's little
script language. This means that for tests like

    start 0 call f1
    f1 16 nosplit call f2
    f2 16 nosplit call f3
    f3 16 nosplit call f4
    f4 16 nosplit call f5
    f5 16 nosplit call f6
    f6 16 nosplit call f7
    f7 16 nosplit call f8
    f8 16 nosplit call end
    end 1000
    REJECT

we add 672 bytes to *every* frame, meaning that we wind up way over
the stack limit by the end of the stanza, rather than just a little as
originally intended.

Fix this by instead adding the extra space to the first nosplit
function in a stanza. This isn't perfect either, since we could have a
nosplit -> split -> nosplit chain, but it's the best we can do without
a graph analysis.

Change-Id: Ibf156c68fe3eb1b64a438115f4a17f1a6c7e2bd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/398174
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile,cmd/internal/obj: replace Ctxt.FixedFrameSize method with Arch field
Austin Clements [Mon, 18 Apr 2022 17:41:08 +0000 (13:41 -0400)]
cmd/compile,cmd/internal/obj: replace Ctxt.FixedFrameSize method with Arch field

And delete now-unused FixedFrameSize methods.

Change-Id: Id257e1647dbeb4eb4ab866c53744010c4efeb953
Reviewed-on: https://go-review.googlesource.com/c/go/+/400819
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agointernal/sys: add LR and fixed frame size to sys.Arch
Austin Clements [Mon, 18 Apr 2022 17:39:52 +0000 (13:39 -0400)]
internal/sys: add LR and fixed frame size to sys.Arch

Storing this information in the Arch eliminates some code duplication
between the compiler and linker. This information is entirely
determined by the Arch, so the current approach of attaching it to an
entire Ctxt is a little silly. This will also make it easier to use
this information from tests.

The next CL will be a rote refactoring to eliminate the
Ctxt.FixedFrameSize methods.

Change-Id: I315c524fa66a0ea99f63ae5a2a6fdc367d843bad
Reviewed-on: https://go-review.googlesource.com/c/go/+/400818
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/link: use TOC-relative trampolines on PPC64 when needed
Paul E. Murphy [Mon, 3 May 2021 16:00:54 +0000 (11:00 -0500)]
cmd/link: use TOC-relative trampolines on PPC64 when needed

When linking a PIE binary with the internal linker, TOC relative
relocations need to be generated. Update trampolines to indirect
call using R12 to more closely match the AIX/ELFv2 regardless of
buildmode, and work with position-indepdent code.

Likewise, update the check for offseting R_CALLPOWER relocs to
make a local call. It should be checking ldr.AttrExternal, not
ldr.IsExternal. This offset should not be adjusted for external
(non-go) object files, it is handled when ELF reloc are translated
into go relocs.

And, update trampoline tests to verify these are generated correctly
and produce a working binary using -buildmode=pie on ppc64le.

Fixes #52337

Change-Id: I8a2dea06c3237bdf0e87888b56a17b6c4c99a7de
Reviewed-on: https://go-review.googlesource.com/c/go/+/400234
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocrypto/x509: move sha1 removal to unspecified future release
Jordan Liggitt [Wed, 30 Mar 2022 13:53:58 +0000 (09:53 -0400)]
crypto/x509: move sha1 removal to unspecified future release

Updates #41682

Change-Id: I3a2d6eedf4030cdc7308001aef549eb20eeb11c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/396774
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Filippo Valsorda <valsorda@google.com>
Run-TryBot: Filippo Valsorda <valsorda@google.com>
Auto-Submit: Filippo Valsorda <valsorda@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocrypto/x509: reject duplicate extensions
Roland Shoemaker [Fri, 4 Feb 2022 17:24:23 +0000 (09:24 -0800)]
crypto/x509: reject duplicate extensions

When parsing certificates and CSRs, reject duplicate extensions (and
additionally duplicate requested extensions in CSRs.)

Fixes #50988

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

2 years agoreflect: make Value.MapRange inlineable
Joe Tsai [Sun, 17 Apr 2022 03:23:28 +0000 (20:23 -0700)]
reflect: make Value.MapRange inlineable

This allows the caller to decide whether MapIter should be
stack allocated or heap allocated based on whether it escapes.
In most cases, it does not escape and thus removes the utility
of MapIter.Reset (#46293). In fact, use of sync.Pool with MapIter
and calling MapIter.Reset is likely to be slower.

Change-Id: Ic93e7d39e5dd4c83e7fca9e0bdfbbcd70777f0e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/400675
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agonet/http: eliminate arbitrary timeouts in TestServerRequestContextCancel_ConnClose
Bryan C. Mills [Mon, 18 Apr 2022 16:55:30 +0000 (12:55 -0400)]
net/http: eliminate arbitrary timeouts in TestServerRequestContextCancel_ConnClose

These timeouts are empirically sometimes (but rarely) too short on
slower builders, and at any rate if this test fails “for real” we'll
want a goroutine dump in order to debug it anyway. A goroutine dump is
exactly what we get if we let the test time out on its own.

Fixes #52414.

Change-Id: Id2dd3839977bd8a41f296d67d1cccbf068fd73f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/400816
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agocmd/compile: fix missing source information in ssa view
hopehook [Fri, 8 Apr 2022 09:59:05 +0000 (17:59 +0800)]
cmd/compile: fix missing source information in ssa view

Endlineno is lost when we call "genericSubst" to create the new
instantiation of the generic function. This will cause "readFuncLines"
to fail to read the target function.

To fix this issue, as @mdempsky pointed out, add the line in
cmd/compile/internal/noder/stencil.go:
    newf.Endlineno = gf.Endlineno

Fixes #51988

Change-Id: Ib408e4ed0ceb68df8dedda4fb551309e8385aada
Reviewed-on: https://go-review.googlesource.com/c/go/+/399057
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2 years agoruntime: improve memclr on ppc64x
Lynn Boger [Tue, 12 Apr 2022 14:37:31 +0000 (09:37 -0500)]
runtime: improve memclr on ppc64x

This improves performance for memclr for sizes >= 64 and < 512 by
unrolling the loop to clear 64 bytes at a time, whereas before it was
doing 32 bytes.

On a power9, the improvement is:

Memclr/64       6.07ns ± 0%    5.17ns ± 0%  -14.86%  (p=1.000 n=1+1)
Memclr/256      11.8ns ± 0%     8.3ns ± 0%  -30.10%  (p=1.000 n=1+1)

GoMemclr/64     5.58ns ± 0%    5.02ns ± 0%  -10.04%  (p=1.000 n=1+1)
GoMemclr/256    12.0ns ± 0%     8.8ns ± 0%  -26.62%  (p=1.000 n=1+1)

Change-Id: I929389ae9e50128cba81e0c412e7ba431da7facc
Reviewed-on: https://go-review.googlesource.com/c/go/+/399895
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agonet/http: correctly show error types in transfer test
Jorropo [Fri, 15 Apr 2022 17:42:17 +0000 (17:42 +0000)]
net/http: correctly show error types in transfer test

actualReader and tc.expectedReader are reflect.Type instances,
not the actual objects.

Change-Id: I7c9cfa489e3297b94c603b62bad1ed84bd207057
GitHub-Last-Rev: d581402375aea0c911fef663ec7e89a24c4e5524
GitHub-Pull-Request: golang/go#52339
Reviewed-on: https://go-review.googlesource.com/c/go/+/400235
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

2 years agoreflect: make Value.Type inlineable
Joe Tsai [Sat, 16 Apr 2022 01:09:48 +0000 (18:09 -0700)]
reflect: make Value.Type inlineable

This allows the result of Type to be computed much faster.

Performance:

old     new     delta
1.76ns  0.66ns  -62.27%

Change-Id: Ie007fd175aaa41b2f67c71fa2a34ab8d292dd0e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/400335
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

2 years agobytes: explode checks for n too large
Philippe Antoine [Fri, 15 Apr 2022 11:36:32 +0000 (11:36 +0000)]
bytes: explode checks for n too large

As is already done in strings package.

Change-Id: Ia45e6443ddf6beac5e70a1cc493119030e173139
GitHub-Last-Rev: 1174c250350f31eced1513169d62a8a3e679dcf6
GitHub-Pull-Request: golang/go#52348
Reviewed-on: https://go-review.googlesource.com/c/go/+/400239
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2 years agogo/doc: fix incorrect identifier parsing in comments
Jorropo [Fri, 15 Apr 2022 22:02:21 +0000 (22:02 +0000)]
go/doc: fix incorrect identifier parsing in comments

This code was trying to iterate codepoints, but didn't reslice the string,
so it was reading the first codepoint over and over, if the string length was
not a multiple of the first codepoint length, this would cause to overshoot
past the end of the string.

This was a latent bug introduced in CL 384265 but was revealed to
Ngolo-fuzzing in OSS-Fuzz in CL 397277.

Fixes #52353

Change-Id: I13f0352e6ad13a42878927f3b1c18c58360dd40c
GitHub-Last-Rev: 424f6cfad1bc7d66314911e6b4b4ce6751330435
GitHub-Pull-Request: golang/go#52356
Reviewed-on: https://go-review.googlesource.com/c/go/+/400240
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

2 years agoruntime: don't block preemption signal in new M's or ensureSigM
Ian Lance Taylor [Fri, 15 Apr 2022 20:46:00 +0000 (13:46 -0700)]
runtime: don't block preemption signal in new M's or ensureSigM

No test because we already have a test in the syscall package.
The issue reports 1 failure per 100,000 iterations, which is rare enough
that our builders won't catch the problem.

Fixes #52226

Change-Id: I17633ff6cf676b6d575356186dce42cdacad0746
Reviewed-on: https://go-review.googlesource.com/c/go/+/400315
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agocmd/link: preserve symbol attributes when cloning to external
Cherry Mui [Fri, 15 Apr 2022 15:52:01 +0000 (11:52 -0400)]
cmd/link: preserve symbol attributes when cloning to external

There are some symbol attributes that are encoded in the object
file. Currently, they are lost when cloning a symbol to external.
Copy them over.

Also delete CopyAttributes as it is no longer called anywhere.

Change-Id: I1497e3223a641704bf35aa3e904dd0eda2f8ec3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/400574
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2 years agodebug/pe: read string table in 10M chunks
Ian Lance Taylor [Thu, 14 Apr 2022 23:25:43 +0000 (16:25 -0700)]
debug/pe: read string table in 10M chunks

No separate test because this makes no difference for valid PE files.

Fixes #52350

Change-Id: I2aa011a4e8b34cb08052222e94c52627ebe99fbf
Reviewed-on: https://go-review.googlesource.com/c/go/+/400378
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

2 years agomime: ignore non-extension globs2 entries
Ville Skyttä [Wed, 16 Feb 2022 21:00:04 +0000 (21:00 +0000)]
mime: ignore non-extension globs2 entries

Change-Id: Ic2315b593dca5648c02f793b7650b5936a997bff
GitHub-Last-Rev: ee55edcf087416c6f0d50d5dd51cbddfd1d77620
GitHub-Pull-Request: golang/go#51226
Reviewed-on: https://go-review.googlesource.com/c/go/+/386334
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2 years agonet/http: optimize StatusText implementation
João Penteado [Tue, 30 Nov 2021 18:59:41 +0000 (18:59 +0000)]
net/http: optimize StatusText implementation

The current implementation, although more succinct, relies on a runtime
lookup to a "constant" unexported map (which also needs to be
initialized at runtime).

The proposed implementation is able to be optimized by the compiler at
build-time, resulting in *much* more efficient instructions.
Additionally, unused string literals may even be removed altogether
from the generated binary in some cases.

This change is fully backwards-compatible behavior-wise with the
existing implementation.

Change-Id: I36450320aacff5b322195820552f2831d4fecd52
GitHub-Last-Rev: e2058f132ef7a193529d4b0e84329ac93e5d1dcb
GitHub-Pull-Request: golang/go#49811
Reviewed-on: https://go-review.googlesource.com/c/go/+/367201
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2 years agocrypto/x509: don't create certs with negative serials
Roland Shoemaker [Fri, 15 Apr 2022 00:57:22 +0000 (17:57 -0700)]
crypto/x509: don't create certs with negative serials

Refuse to create certificates with negative serial numbers, as they
are explicitly disallowed by RFC 5280.

We still allow parsing certificates with negative serial numbers,
because in the past there were buggy CA implementations which would
produce them (although there are currently *no* trusted certificates
that have this issue). We may want to revisit this decision if we can
find metrics about the prevalence of this issue in enterprise settings.

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

2 years agointernal/bytealg: optimize indexbyte function for ppc64le/power9
Archana R [Fri, 1 Apr 2022 17:05:07 +0000 (12:05 -0500)]
internal/bytealg: optimize indexbyte function for ppc64le/power9

Added specific code For POWER9 that does not need prealignment prior
to load vector. Optimized vector loop to jump out as soon as there is
a match instead of accumulating matches for 4 indices and then processing
the same. For small input size 10, the caller function dominates
performance.

name                      old time/op    new time/op    delta
IndexByte/10                9.20ns ± 0%   10.40ns ± 0%  +13.08%
IndexByte/32                9.77ns ± 0%    9.20ns ± 0%   -5.84%
IndexByte/4K                 171ns ± 0%     136ns ± 0%  -20.51%
IndexByte/4M                 154µs ± 0%     126µs ± 0%  -17.92%
IndexByte/64M               2.48ms ± 0%    2.03ms ± 0%  -18.27%
IndexAnyASCII/1:32          10.2ns ± 1%     9.2ns ± 0%   -9.19%
IndexAnyASCII/1:64          11.3ns ± 0%    10.1ns ± 0%  -11.29%
IndexAnyUTF8/1:64           11.4ns ± 0%     9.8ns ± 0%  -13.73%
IndexAnyUTF8/16:64           156ns ± 1%     131ns ± 0%  -16.23%
IndexAnyUTF8/256:64         2.27µs ± 0%    1.86µs ± 0%  -18.03%
LastIndexAnyUTF8/1:64       11.8ns ± 0%    10.5ns ± 0%  -10.81%
LastIndexAnyUTF8/16:64       165ns ±11%     132ns ± 0%  -19.75%
LastIndexAnyUTF8/256:2      1.68µs ± 0%    1.44µs ± 0%  -14.33%
LastIndexAnyUTF8/256:4      1.68µs ± 0%    1.49µs ± 0%  -11.10%
LastIndexAnyUTF8/256:8      1.68µs ± 0%    1.50µs ± 0%  -11.05%
LastIndexAnyUTF8/256:64     2.30µs ± 0%    1.90µs ± 0%  -17.56%
Change-Id: I3d2550bdfdea38fece2da9960bbe62fe6cb1840c
Reviewed-on: https://go-review.googlesource.com/c/go/+/397614
Reviewed-by: Paul Murphy <murp@ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Archana Ravindar <aravind5@in.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2 years agonet/http: remove cloneURL call in WithContext
Bobby Powers [Fri, 8 Apr 2022 19:21:33 +0000 (12:21 -0700)]
net/http: remove cloneURL call in WithContext

Fixes #52239

Change-Id: I08b75e613e3c976855e39d01a6757d94e4207bf8
Reviewed-on: https://go-review.googlesource.com/c/go/+/399155
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agoencoding/binary: add AppendVarint AppendUvarint
Joe Tsai [Wed, 13 Apr 2022 20:21:30 +0000 (13:21 -0700)]
encoding/binary: add AppendVarint AppendUvarint

This adds a straight-forward implementation of the functionality.
A more performant version could be added that unrolls the loop
as is done in google.golang.org/protobuf/encoding/protowire,
but usages that demand high performance can use that package instead.

Fixes #51644

Change-Id: I9d3b615a60cdff47e5200e7e5d2276adf4c93783
Reviewed-on: https://go-review.googlesource.com/c/go/+/400176
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime: don't discard value from panic while panicking
hopehook [Tue, 12 Apr 2022 09:46:36 +0000 (17:46 +0800)]
runtime: don't discard value from panic while panicking

In issue #17671, there are a endless loop if printing
the panic value panics, CL 30358 has fixed that.

As issue #52257 pointed out, above change should not
discard the value from panic while panicking.

With this CL, when we recover from a panic in error.Error()
or stringer.String(), and the recovered value is string,
then we can print it normally.

Fixes #52257

Change-Id: Icfcc4a1a390635de405eea04904b4607ae9e3055
Reviewed-on: https://go-review.googlesource.com/c/go/+/399874
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2 years agocmd/compile: turn jump tables off with -N
Keith Randall [Thu, 14 Apr 2022 22:04:34 +0000 (15:04 -0700)]
cmd/compile: turn jump tables off with -N

The noopt builder is broken, because with -N we get two OpSB opcodes
(one for the function as a whole, one introduced by the jumptable
rewrite rule), and they fight each other for a register.

Without -N, the two OpSB get CSEd, so optimized builds are ok.

Maybe we fix regalloc to deal with this case, but it's simpler
(and maybe more correct?) to disable jump tables with -N.

Change-Id: I75c87f12de6262955d1df787f47c53de976f8a5f
Reviewed-on: https://go-review.googlesource.com/c/go/+/400455
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agocrypto/x509: don't allow too long serials
Roland Shoemaker [Thu, 14 Apr 2022 21:02:25 +0000 (14:02 -0700)]
crypto/x509: don't allow too long serials

Don't create certificates that have serial numbers that are longer
than 20 octets (when encoded), since these are explicitly disallowed
by RFC 5280.

Change-Id: I292b7001f45bed0971b2d519b6de26f0b90860ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/400377
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2 years agocmd/compile: add jump table codegen test
Keith Randall [Thu, 14 Apr 2022 20:14:18 +0000 (13:14 -0700)]
cmd/compile: add jump table codegen test

Change-Id: Ic67f676f5ebe146166a0d3c1d78a802881320e49
Reviewed-on: https://go-review.googlesource.com/c/go/+/400375
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2 years agocmd/compile: modify switches of strings to use jump table for lengths
Keith Randall [Sun, 6 Mar 2022 20:07:54 +0000 (12:07 -0800)]
cmd/compile: modify switches of strings to use jump table for lengths

Reorganize the way we rewrite expression switches on strings, so that
jump tables are naturally used for the outer switch on the string length.

The changes to the prove pass in this CL are required so as to not repeat
the test for string length in each case.

name                         old time/op  new time/op  delta
SwitchStringPredictable    2.28ns ± 9%  2.08ns ± 5%   -9.04%  (p=0.000 n=10+10)
SwitchStringUnpredictable  10.5ns ± 1%   9.5ns ± 1%   -9.08%  (p=0.000 n=9+10)

Update #5496
Update #34381

Change-Id: Ie6846b1dd27f3e472f7c30dfcc598c68d440b997
Reviewed-on: https://go-review.googlesource.com/c/go/+/395714
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2 years agocmd/compile: constant-fold switches early in compilation
Keith Randall [Mon, 7 Feb 2022 07:25:04 +0000 (23:25 -0800)]
cmd/compile: constant-fold switches early in compilation

So that the inliner knows all the other cases are dead and doesn't
accumulate any cost for them.

The canonical case for this is switching on runtime.GOOS, which occurs
several places in the stdlib.

Fixes #50253

Change-Id: I44823aaebb6c1b03c9b0c12d10086db81954350f
Reviewed-on: https://go-review.googlesource.com/c/go/+/399694
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile: implement jump tables
Keith Randall [Mon, 4 Oct 2021 19:17:46 +0000 (12:17 -0700)]
cmd/compile: implement jump tables

Performance is kind of hard to exactly quantify.

One big difference between jump tables and the old binary search
scheme is that there's only 1 branch statement instead of O(n) of
them. That can be both a blessing and a curse, and can make evaluating
jump tables very hard to do.

The single branch can become a choke point for the hardware branch
predictor. A branch table jump must fit all of its state in a single
branch predictor entry (technically, a branch target predictor entry).
With binary search that predictor state can be spread among lots of
entries. In cases where the case selection is repetitive and thus
predictable, binary search can perform better.

The big win for a jump table is that it doesn't consume so much of the
branch predictor's resources. But that benefit is essentially never
observed in microbenchmarks, because the branch predictor can easily
keep state for all the binary search branches in a microbenchmark. So
that benefit is really hard to measure.

So predictable switch microbenchmarks are ~useless - they will almost
always favor the binary search scheme. Fully unpredictable switch
microbenchmarks are better, as they aren't lying to us quite so
much. In a perfectly unpredictable situation, a jump table will expect
to incur 1-1/N branch mispredicts, where a binary search would incur
lg(N)/2 of them. That makes the crossover point at about N=4. But of
course switches in real programs are seldom fully unpredictable, so
we'll use a higher crossover point.

Beyond the branch predictor, jump tables tend to execute more
instructions per switch but have no additional instructions per case,
which also argues for a larger crossover.

As far as code size goes, with this CL cmd/go has a slightly smaller
code segment and a slightly larger overall size (from the jump tables
themselves which live in the data segment).

This is a case where some FDO (feedback-directed optimization) would
be really nice to have. #28262

Some large-program benchmarks might help make the case for this
CL. Especially if we can turn on branch mispredict counters so we can
see how much using jump tables can free up branch prediction resources
that can be gainfully used elsewhere in the program.

name                         old time/op  new time/op  delta
Switch8Predictable         1.89ns ± 2%  1.27ns ± 3%  -32.58%  (p=0.000 n=9+10)
Switch8Unpredictable       9.33ns ± 1%  7.50ns ± 1%  -19.60%  (p=0.000 n=10+9)
Switch32Predictable        2.20ns ± 2%  1.64ns ± 1%  -25.39%  (p=0.000 n=10+9)
Switch32Unpredictable      10.0ns ± 2%   7.6ns ± 2%  -24.04%  (p=0.000 n=10+10)

Fixes #5496
Update #34381

Change-Id: I3ff56011d02be53f605ca5fd3fb96b905517c34f
Reviewed-on: https://go-review.googlesource.com/c/go/+/357330
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2 years agodebug/dwarf: better stmt list attr checking in LineReader
Than McIntosh [Thu, 14 Apr 2022 15:14:36 +0000 (11:14 -0400)]
debug/dwarf: better stmt list attr checking in LineReader

Check for insane statement list attribute values when
constructing LineReader's for a compilation unit.

Fixes #52354.

Change-Id: Icb5298db31f6c5fe34c44e0ed4fe277a7cd676b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/400255
Run-TryBot: Than McIntosh <thanm@google.com>
Auto-Submit: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agomath: improve documentation of Copysign
Joe Tsai [Wed, 13 Apr 2022 20:31:24 +0000 (13:31 -0700)]
math: improve documentation of Copysign

Name the arguments in a way that is more self-describing.
Many code editor tools show a snippet of the function and
its arguments. However, "x" and "y" are not helpful in determining
which is the sign and which is the magnitude,
short of reading the documentation itself.

Name the sign argument as "sign" to be explicit.
This follows the same naming convention as IsInf.

Change-Id: Ie3055009e475f96c92d5ea7bfe9828eed908c78b
Reviewed-on: https://go-review.googlesource.com/c/go/+/400177
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2 years agocmd/compile: fold constant shifts into (SHL|SHR|SAR)Xload ops
Keith Randall [Thu, 14 Apr 2022 00:33:24 +0000 (17:33 -0700)]
cmd/compile: fold constant shifts into (SHL|SHR|SAR)Xload ops

We should prefer a constant shift op to a X shift op.
That way we don't have to materialize the constant to shift by.

Should fix GOAMD64=v3 builder

Change-Id: I56b45d2940c959382b970e3f962ed4a09cc2a239
Reviewed-on: https://go-review.googlesource.com/c/go/+/400254
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2 years agocmd/compile: remove unused offset calculation in ssagen#rtcall
Jorropo [Wed, 13 Apr 2022 00:32:15 +0000 (00:32 +0000)]
cmd/compile: remove unused offset calculation in ssagen#rtcall

This offR accumulation isn't used and some really similar code is done
later in the Load results block.

Change-Id: I2f77a7bfd568e7e5eb9fc519e7c552401b3af9b8
GitHub-Last-Rev: 2c91e5c8987d21203c494f278ff1e05aa3941211
GitHub-Pull-Request: golang/go#52316
Reviewed-on: https://go-review.googlesource.com/c/go/+/400094
Run-TryBot: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2 years agosort: use pdqsort
zhangyunhao [Tue, 14 Dec 2021 05:52:05 +0000 (13:52 +0800)]
sort: use pdqsort

- Across all benchmarks, pdqsort is never significantly slower than the previous algorithm.
- In common patterns, pdqsort is often faster (i.e. 10x faster in sorted slices).

The pdqsort is described at https://arxiv.org/pdf/2106.05123.pdf

This CL is inspired by both C++ implementation and Rust implementation.
- C++ implementation: https://github.com/orlp/pdqsort
- Rust implementation: https://docs.rs/pdqsort/latest/pdqsort/

For #50154

name                   old time/op  new time/op  delta
SearchWrappers-16      72.8ns ± 3%  75.1ns ± 2%   +3.25%  (p=0.000 n=20+10)
SortString1K-16        85.2µs ± 3%  86.2µs ± 5%     ~     (p=0.247 n=19+10)
SortString1K_Slice-16  84.6µs ± 4%  86.1µs ± 4%     ~     (p=0.120 n=20+10)
StableString1K-16       112µs ± 5%   112µs ± 5%     ~     (p=0.604 n=19+10)
SortInt1K-16           44.8µs ± 3%  43.2µs ± 2%   -3.68%  (p=0.000 n=20+10)
SortInt1K_Sorted-16    28.2µs ± 3%   3.3µs ± 3%  -88.16%  (p=0.000 n=19+10)
SortInt1K_Reversed-16  29.4µs ± 3%   4.8µs ± 2%  -83.59%  (p=0.000 n=20+10)
SortInt1K_Mod8-16      25.1µs ± 2%  20.0µs ± 2%  -20.35%  (p=0.000 n=18+10)
StableInt1K-16         51.3µs ± 3%  50.9µs ± 2%     ~     (p=0.562 n=20+9)
StableInt1K_Slice-16   49.5µs ± 2%  50.7µs ± 4%   +2.55%  (p=0.009 n=19+10)
SortInt64K-16          4.73ms ± 3%  4.49ms ± 4%   -5.08%  (p=0.000 n=20+10)
SortInt64K_Slice-16    4.51ms ± 3%  4.35ms ± 1%   -3.42%  (p=0.000 n=20+8)
StableInt64K-16        4.85ms ± 2%  4.82ms ± 2%     ~     (p=0.267 n=20+10)
Sort1e2-16             27.9µs ± 1%  28.1µs ± 2%     ~     (p=0.198 n=20+10)
Stable1e2-16           56.6µs ± 2%  55.0µs ± 2%   -2.88%  (p=0.000 n=20+10)
Sort1e4-16             5.51ms ± 1%  5.36ms ± 1%   -2.58%  (p=0.000 n=19+9)
Stable1e4-16           17.8ms ± 1%  17.3ms ± 1%   -2.40%  (p=0.000 n=20+10)
Sort1e6-16              833ms ± 1%   807ms ± 1%   -3.02%  (p=0.000 n=20+10)
Stable1e6-16            3.49s ± 2%   3.44s ± 1%   -1.41%  (p=0.001 n=20+10)

Change-Id: Iecded047d237b9330b5a4101001a5fdc2f50646a
Reviewed-on: https://go-review.googlesource.com/c/go/+/371574
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Eli Bendersky <eliben@google.com>
2 years agocrypto/x509: add CertPool.Clone
Roland Shoemaker [Wed, 13 Apr 2022 18:49:15 +0000 (11:49 -0700)]
crypto/x509: add CertPool.Clone

Export the previously private method copy as Clone.

Fixes #35044

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

2 years ago[dev.boringcrypto] misc/boring: add new releases to RELEASES file
Dmitri Shuralyov [Wed, 13 Apr 2022 18:23:08 +0000 (18:23 +0000)]
[dev.boringcrypto] misc/boring: add new releases to RELEASES file

Change-Id: I5d2d64acd501bae90e2027f55ac6398f71dafca3
Reviewed-on: https://go-review.googlesource.com/c/go/+/400157
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocrypto/x509: support nil pools in CertPool.Equal
Roland Shoemaker [Wed, 13 Apr 2022 15:58:01 +0000 (08:58 -0700)]
crypto/x509: support nil pools in CertPool.Equal

Otherwise we panic if either pool is nil.

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

2 years agocrypto/x509: omit empty extensions SEQUENCE
Roland Shoemaker [Wed, 13 Apr 2022 04:22:22 +0000 (21:22 -0700)]
crypto/x509: omit empty extensions SEQUENCE

In CreateCertificate, if there are no extensions, don't include the
extensions SEQUENCE in the encoded certificate.

Why, you might ask, does the encoding/asn1 tag 'optional' not do
the same thing as 'omitempty'? Good question, no clue, fixing that
would probably break things in horrific ways.

Fixes #52319

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

2 years agocmd/compile: add SHLX&SHRX without load
Wayne Zuo [Sat, 9 Apr 2022 06:40:40 +0000 (14:40 +0800)]
cmd/compile: add SHLX&SHRX without load

Change-Id: I79eb5e7d6bcb23f26d3a100e915efff6dae70391
Reviewed-on: https://go-review.googlesource.com/c/go/+/399061
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agocmd/compile: add SARXQload and SARXLload
Wayne Zuo [Fri, 8 Apr 2022 09:33:50 +0000 (17:33 +0800)]
cmd/compile: add SARXQload and SARXLload

Change-Id: I4e8dc5009a5b8af37d71b62f1322f94806d3e9d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/399056
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: 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>
2 years ago[dev.boringcrypto] misc/boring: remove -trust and individual reviewers
Dmitri Shuralyov [Tue, 12 Apr 2022 18:54:51 +0000 (14:54 -0400)]
[dev.boringcrypto] misc/boring: remove -trust and individual reviewers

The -trust flag has become obsolete.

A list of individual reviewers may become out of date, and these
scripts (and their backports) are probably not the optimal place
for it.

Change-Id: Ibf1bc508f0192b160c955e3deabae34f4d1ab54c
Reviewed-on: https://go-review.googlesource.com/c/go/+/399538
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2 years agoruntime: port memmove, memclr to register ABI on riscv64
Meng Zhuo [Sat, 6 Nov 2021 14:38:51 +0000 (22:38 +0800)]
runtime: port memmove, memclr to register ABI on riscv64

This allows memmove and memclr to be invoked using the new
register ABI on riscv64.

Change-Id: I3308d52e06547836cffcc533740fe535624e78d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/361975
Run-TryBot: mzh <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agocmd/asm: update comment to refer to #44505
hopehook [Mon, 11 Apr 2022 10:38:08 +0000 (18:38 +0800)]
cmd/asm: update comment to refer to #44505

Updates #44505

Change-Id: I400110c33e69decf133fe9c4b582a450b7258b39
Reviewed-on: https://go-review.googlesource.com/c/go/+/399514
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/link: mangle symbol ABI name for linker-generated symbols
Cherry Mui [Mon, 11 Apr 2022 22:57:44 +0000 (18:57 -0400)]
cmd/link: mangle symbol ABI name for linker-generated symbols

The ABI mangling code skips symbols that are not loaded from Go
objects. Usually that is fine, as other symbols don't need name
mangling. But trampolines are linker generated and have the same
symbol version (ABI) as the underlying symbol. We need to avoid
symbol name collisions for trampolines, such as a trampoline to
f<ABI0> and a trampoline to f<ABIInternal>. We could explicitly
incorportate the ABI into the trampoline name. But as we already
have the name mangling scheme we could just use that.

The original code excludes external symbols probably because
symbols from C object don't need mangling. But a C symbol and a
Go symbol shouldn't have same name, and so the condition won't
apply.

Also exclude static symbols as they don't need mangling.

Change-Id: I298eb1d64bc0c3da0154f0146b95c4d26ca2f47a
Reviewed-on: https://go-review.googlesource.com/c/go/+/399894
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2 years agocmd/link: don't sort pclntab entries
Keith Randall [Tue, 12 Apr 2022 20:34:42 +0000 (13:34 -0700)]
cmd/link: don't sort pclntab entries

They are already in a good order. The sort here does nothing, as
all the SymValues are 0. Sorting just arbitrarily permutes items
because everything is equal and the sort isn't stable.

Not sure why the ordering of these symbols matter. That ordering was
added in CL 243223.

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

2 years agocmd/go: fix TestScript/test_fuzz_minimize_interesting flake
Roland Shoemaker [Tue, 12 Apr 2022 00:52:55 +0000 (17:52 -0700)]
cmd/go: fix TestScript/test_fuzz_minimize_interesting flake

check_testdata/check_testdata.go used the encoding of the corpus entry
file, rather than the input string itself, when checking the expected
size of the minimized value. Instead, use the actual byte length, which
should bypass flakiness.

While we are here, use somewhat simpler fuzz targets, that use byte
slices rather than strings, and only execute the targets when fuzzing (
skipping the 'run' phase.)

Fixes #52285

Change-Id: I48c3780934891eec4a9e38d93abb4666091cb580
Reviewed-on: https://go-review.googlesource.com/c/go/+/399814
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2 years agomath/big: Implement shlVU and shrVU in ASM for PPC64
Archana R [Wed, 9 Feb 2022 13:37:12 +0000 (07:37 -0600)]
math/big: Implement shlVU and shrVU in ASM for PPC64

Currently the shift left and shift right functions are coded in .go
on PPC64. Implementing them in ASM just like AMD and ARM results in
overall speedup of shift benchmarks on POWER8/9/10.

name                        old time/op  new time/op  delta
NonZeroShifts/1/shrVU       8.50ns ± 0%  5.21ns ± 0%  -38.66%
NonZeroShifts/1/shlVU       8.85ns ± 1%  5.24ns ± 0%  -40.78%
NonZeroShifts/2/shrVU       9.16ns ± 0%  5.51ns ± 0%  -39.80%
NonZeroShifts/2/shlVU       9.24ns ± 2%  5.61ns ± 0%  -39.28%
NonZeroShifts/3/shrVU       10.6ns ± 0%   6.8ns ± 0%  -35.78%
NonZeroShifts/3/shlVU       10.7ns ± 2%   6.4ns ± 0%  -40.82%
NonZeroShifts/4/shrVU       12.4ns ± 0%   7.7ns ± 0%  -38.12%
NonZeroShifts/4/shlVU       12.3ns ± 1%   7.5ns ± 0%  -38.67%
NonZeroShifts/5/shrVU       13.2ns ± 0%   8.5ns ± 0%  -35.51%
NonZeroShifts/5/shlVU       13.3ns ± 2%   9.3ns ± 0%  -30.05%
NonZeroShifts/10/shrVU      16.5ns ± 0%  13.1ns ± 0%  -20.12%
NonZeroShifts/10/shlVU      16.8ns ± 1%  14.1ns ± 0%  -16.02%
NonZeroShifts/100/shrVU      122ns ± 0%    94ns ± 0%  -22.87%
NonZeroShifts/100/shlVU      115ns ± 0%   103ns ± 0%  -10.50%
NonZeroShifts/1000/shrVU    1.10µs ± 0%  0.91µs ± 0%  -17.03%
NonZeroShifts/1000/shlVU    1.02µs ± 0%  0.93µs ± 0%   -8.74%
NonZeroShifts/10000/shrVU   10.9µs ± 0%   9.1µs ± 0%  -16.66%
NonZeroShifts/10000/shlVU   10.1µs ± 0%   9.3µs ± 0%   -8.19%
NonZeroShifts/100000/shrVU   109µs ± 0%    91µs ± 0%  -16.01%
NonZeroShifts/100000/shlVU   101µs ± 0%    94µs ± 0%   -7.16%

Change-Id: Ia31951cc29a4169beb494d2951427cbe1e963b11
Reviewed-on: https://go-review.googlesource.com/c/go/+/384474
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agodoc/go1.19: document cmd/go changes involving -trimpath
Bryan C. Mills [Fri, 8 Apr 2022 20:02:59 +0000 (16:02 -0400)]
doc/go1.19: document cmd/go changes involving -trimpath

Updates #51461.

Change-Id: Ie878a9f630062d62027de895750a070b50428a9f
Reviewed-on: https://go-review.googlesource.com/c/go/+/399214
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agosyscall: check correct group in Faccessat
Damien Neil [Tue, 12 Apr 2022 20:38:17 +0000 (13:38 -0700)]
syscall: check correct group in Faccessat

The Faccessat call checks the user, group, or other permission bits of a
file to see if the calling process can access it. The test to see if the
group permissions should be used was made with the wrong group id, using
the process's group id rather than the file's group id. Fix this to use
the correct group id.

No test since we cannot easily change file permissions when not running
as root and the test is meaningless if running as root.

For #52313

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

2 years agocmd/go: allow '-buildvcs=auto' and treat it as the default
Bryan C. Mills [Thu, 7 Apr 2022 21:25:23 +0000 (17:25 -0400)]
cmd/go: allow '-buildvcs=auto' and treat it as the default

When we added VCS stamping in the Go 1.18 release, we defaulted to
-buildvcs=true, on the theory that most folks will actually want VCS
information stamped.

We also made -buildvcs=true error out if a VCS directory is found and
no VCS tool is available, on the theory that a user who builds with
'-buildvcs=true' will be very surprised if the VCS metadata is
silently missing.

However, that causes a problem for CI environments that don't have the
appropriate VCS tool installed. (And we know that's a common situation
because we're in that situation ourselves — see #46693!)

The new '-buildvcs=auto' setting provides a middle ground: it stamps
VCS information by default when the tool is present (and reports
explicit errors if the tool errors out), but omits the metadata
when the tool isn't present at all.

Fixes #51748.
Updates #51999.

Change-Id: Iebc955c2af0abca9b7517f62ca48b1d944eb2df4
Reviewed-on: https://go-review.googlesource.com/c/go/+/398855
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile: always write fun[0] in incomplete itab
Wayne Zuo [Fri, 8 Apr 2022 15:44:40 +0000 (23:44 +0800)]
cmd/compile: always write fun[0] in incomplete itab

runtime.getitab need filled fun[0] to identify whether
implemented the interface.

Fixes #51700
Fixes #52228

Change-Id: I0173b98f4e1b45e3a0183a5b60229d289140d1e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/399058
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
2 years agocmd/go: open correct path when loading embeds from root directory
tenkoh [Wed, 30 Mar 2022 06:30:19 +0000 (15:30 +0900)]
cmd/go: open correct path when loading embeds from root directory

The existing implementation of `load.resolveEmbed`
uses an expression like `path[len(pkgdir)+1:]`.
Though the `+1` is intended to remove a prefix slash,
the expression returns an incorrect path when `pkgdir`
is "/". (ex.: when removing "/" from "/foo", want "foo",
but got "oo")

It seems that `str.TrimFilePathPrefix` would solve
the problem, but the function contains the same bug.

So, this commit fixes `str.TrimFilePathPrefix` then
applies it to `load.resolveEmbed` to solve the issue.
The fix is quite simple. First, remove prefix. Then
check whether the remained first letter is equal to
`filepath.Separator`. If so, remove it then return.

Fixed #49570

Change-Id: I26ab727ee4dfcbf51ed9bd0a573957ced2154515
Reviewed-on: https://go-review.googlesource.com/c/go/+/396694
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2 years agocmd/go/internal/modload: remove aix from stat_openfile.go comment
Tobias Klauser [Tue, 29 Mar 2022 06:51:16 +0000 (08:51 +0200)]
cmd/go/internal/modload: remove aix from stat_openfile.go comment

syscall.Access is supported and used on aix since CL 263540.

Change-Id: Ie50cc3da68b49b22d622d94faec0231c52502037
Reviewed-on: https://go-review.googlesource.com/c/go/+/396374
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2 years agoencoding/pem: fix stack overflow in Decode
Julie Qiu [Tue, 1 Mar 2022 16:19:38 +0000 (10:19 -0600)]
encoding/pem: fix stack overflow in Decode

Previously, Decode called decodeError, a recursive function that was
prone to stack overflows when given a large PEM file containing errors.

Credit to Juho Nurminen of Mattermost who reported the error.

Fixes CVE-2022-24675
Fixes #51853

Change-Id: Iffe768be53c8ddc0036fea0671d290f8f797692c
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1391157
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Filippo Valsorda <valsorda@google.com>
(cherry picked from commit 794ea5e828010e8b68493b2fc6d2963263195a02)
Reviewed-on: https://go-review.googlesource.com/c/go/+/399820
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime: improve memmove for ppc64x
Lynn Boger [Fri, 8 Apr 2022 18:50:00 +0000 (13:50 -0500)]
runtime: improve memmove for ppc64x

This improves performance of memmove for larger moves by
unrolling the main loop from 32 byte to 64 byte moves.

The improvement of the relevant sizes on a power9:

Memmove/64      5.11ns ± 0%    5.00ns ± 0%   -2.21%
Memmove/128     8.26ns ± 0%    5.88ns ± 0%  -28.83%
Memmove/256     12.7ns ± 0%     8.6ns ± 0%  -31.94%
Memmove/512     17.9ns ± 0%    14.3ns ± 0%  -19.87%
Memmove/1024    33.3ns ± 0%    27.0ns ± 0%  -18.92%
Memmove/2048    72.1ns ± 0%    51.8ns ± 0%  -28.25%
Memmove/4096     126ns ± 0%     110ns ± 0%  -12.63%

Change-Id: I74162a9f152d7752a8281da1b89a66da99a3fdc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/399499
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agocmd/compile: add SARX instruction for GOAMD64>=3
Wayne Zuo [Fri, 8 Apr 2022 08:44:13 +0000 (16:44 +0800)]
cmd/compile: add SARX instruction for GOAMD64>=3

name                    old time/op  new time/op  delta
ShiftArithmeticRight-8  0.68ns ± 5%  0.30ns ± 6%  -56.14%  (p=0.000 n=10+10)

Change-Id: I052a0d7b9e6526d526276444e588b0cc288beff4
Reviewed-on: https://go-review.googlesource.com/c/go/+/399055
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agotest: add //go:build support to run.go
Matthew Dempsky [Tue, 12 Apr 2022 00:35:24 +0000 (17:35 -0700)]
test: add //go:build support to run.go

gofmt is rewriting +build comments into //go:build anyway, so update
the test script to support both.

Change-Id: Ia6d950cfaa2fca9f184b8b2d3625a551bff88dde
Reviewed-on: https://go-review.googlesource.com/c/go/+/399794
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agocmd/go: set GOROOT explicitly for 'go generate' subprocesses
Bryan C. Mills [Fri, 8 Apr 2022 19:26:38 +0000 (15:26 -0400)]
cmd/go: set GOROOT explicitly for 'go generate' subprocesses

Code generators may reasonably expect to find the GOROOT for which the
code is being generated.

If the generator invokes 'go run' (which ought to be reasonable to do)
and the user has set 'GOFLAGS=trimpath' (which also ought to be
reasonable), then either 'go generate' or 'go run' needs to set GOROOT
explicitly.

I would argue that it is more appropriate for 'go generate' to set
GOROOT than for 'go run' to do so, since a user may reasonably invoke
'go run' to reproduce a user-reported bug in a standalone Go program,
but should not invoke 'go generate' except to regenerate code for a Go
package.

Updates #51461.

Change-Id: Iceba233b4eebd57c40cf5dcd4af9031d210dc9d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/399157
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/go: fix TestScript/build_trimpath_goroot when built with a mismatched GOROOT_FINAL
Bryan C. Mills [Fri, 8 Apr 2022 19:23:14 +0000 (15:23 -0400)]
cmd/go: fix TestScript/build_trimpath_goroot when built with a mismatched GOROOT_FINAL

Fixes #52236.
Updates #51461.

Change-Id: Ie91e0256afd45e9bbd60fd8cdc696363027ab696
Reviewed-on: https://go-review.googlesource.com/c/go/+/399156
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoRevert "cmd/compile/internal: fix test error on loong64"
Bryan Mills [Tue, 12 Apr 2022 02:53:29 +0000 (02:53 +0000)]
Revert "cmd/compile/internal: fix test error on loong64"

This reverts CL 367043.

Reason for revert: auto-submitted prematurely, breaking tests on most builders.

Change-Id: I6da319fb042b629bcd6f549be638497a357e7d28
Reviewed-on: https://go-review.googlesource.com/c/go/+/399795
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile/internal: fix test error on loong64
Xiaodong Liu [Thu, 25 Nov 2021 06:20:39 +0000 (14:20 +0800)]
cmd/compile/internal: fix test error on loong64

For TestLogOpt test case, add loong64 support to test the host
architecture and os.

The Ctz64 is not intrinsified on loong64 for TestIntendedInlining.

Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I4ca290bf725425a9a6ac2c6767a5bf4ff2339d0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/367043
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>

2 years agoruntime/chan.go: improve closed channel receive performance
champly [Tue, 12 Apr 2022 01:54:45 +0000 (01:54 +0000)]
runtime/chan.go: improve closed channel receive performance

Use this benchmark ut:

```go
func BenchmarkReceiveDataFromClosedChan(b *testing.B) {
count := b.N
ch := make(chan struct{}, count)
for i := 0; i < count; i++ {
ch <- struct{}{}
}

b.ResetTimer()
for range ch {
}
}
```

Benchmark 10 times(`go test -bench=.`), and then use `benchstat` got the result:

```shell
name                         old time/op  new time/op  delta
ReceiveDataFromClosedChan-5  12.0ns ± 1%  11.4ns ± 0%  -5.54%  (p=0.000 n=10+8)
```

Fixes: #52067
Change-Id: I8db398cc8c04a46cb66ffb6768ab72a87903812f
GitHub-Last-Rev: 1e0142416f223c1ebfc4a7c136bb8fca242d7934
GitHub-Pull-Request: golang/go#52068
Reviewed-on: https://go-review.googlesource.com/c/go/+/396884
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>

2 years agoos: mark Solaris nam/door/port files as irregular
Ian Lance Taylor [Sun, 10 Apr 2022 04:00:59 +0000 (21:00 -0700)]
os: mark Solaris nam/door/port files as irregular

No test because I'm too lazy to figure out how to create such files.

Fixes #52259

Change-Id: I7a07f49993cf046888729e9206ed53dddcf9cb13
Reviewed-on: https://go-review.googlesource.com/c/go/+/399435
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2 years agocmd/compile: add a test case and some comments for deadlock on syntax error
hopehook [Fri, 8 Apr 2022 05:37:40 +0000 (13:37 +0800)]
cmd/compile: add a test case and some comments for deadlock on syntax error

After CL 398014 fixed a compiler deadlock on syntax errors,
this CL adds a test case and more details for that.

How it was fixed:

CL 57751 introduced a channel "sem" to limit the number of
simultaneously open files.

Unfortunately, when the number of syntax processing goroutines
exceeds this limit, will easily trigger deadlock.

In the original implementation, "sem" only limited the number
of open files, not the number of concurrent goroutines, which
will cause extra goroutines to block on "sem". When the p.err
of the following iteration happens to be held by the blocking
goroutine, it will fall into a circular wait, which is a deadlock.

CL 398014 fixed the above deadlock, also see issue #52127.

First, move "sem <- struct{}{}" to the outside of the syntax
processing goroutine, so that the number of concurrent goroutines
does not exceed the number of open files, to ensure that all
goroutines in execution can eventually write to p.err.

Second, move the entire syntax processing logic into a separate
goroutine to avoid blocking on the producer side.

Change-Id: I1bb89bfee3d2703784f0c0d4ded82baab2ae867a
Reviewed-on: https://go-review.googlesource.com/c/go/+/399054
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agocmd/compile: fix compilation crash with several blank labels
nimelehin [Mon, 11 Apr 2022 16:54:30 +0000 (19:54 +0300)]
cmd/compile: fix compilation crash with several blank labels

Fixes #52278

Change-Id: Ibf67c7b019feec277d316e04d93b458efea133fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/399574
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agoruntime: fix name of type parameter
zhouguangyuan [Sat, 19 Mar 2022 16:07:37 +0000 (00:07 +0800)]
runtime: fix name of type parameter

CL 372774 is for reflect, this CL is for _type in runtime.
Add a test case to ensure the name method of _type can be exercised.

Updates #50208

Change-Id: I26ccf8c5c574dd9e78510cf29eb40ae7c8d449ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/393917
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agonet/http/httptest: allow multiple fields be present in one Trailer field
Maxime Soulé [Thu, 17 Mar 2022 16:01:24 +0000 (17:01 +0100)]
net/http/httptest: allow multiple fields be present in one Trailer field

Fixes #51761

Change-Id: Ibaa17076ba51b666e25333e78180b8c7c4c940ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/393616
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agoruntime: align m.procid to 8 bytes on 32-bit systems
Keith Randall [Mon, 11 Apr 2022 21:56:11 +0000 (14:56 -0700)]
runtime: align m.procid to 8 bytes on 32-bit systems

https://go-review.googlesource.com/c/go/+/383434 started using
atomic Load64 on this field, which breaks 32 bit platforms which
require 64-bit alignment of uint64s that are passed to atomic operations.

Not sure why this doesn't break everywhere, but I saw it break on
my laptop during all.bash.

Change-Id: Ida27b23068b3cc7208fce3c97b69a464ccf68209
Reviewed-on: https://go-review.googlesource.com/c/go/+/399754
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2 years agoA+C: add Wen Yang (individual CLA)
yangwenmai [Sun, 10 Apr 2022 08:04:22 +0000 (16:04 +0800)]
A+C: add Wen Yang (individual CLA)

Change-Id: Iaac18d78b4a11698d0b5f70b1d5143c0da8a6943
Reviewed-on: https://go-review.googlesource.com/c/go/+/399299
Reviewed-by: mzh <mzh@golangcn.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agogo/ast, go/printer: recognize export and extern line directives
Russ Cox [Mon, 11 Apr 2022 21:19:09 +0000 (17:19 -0400)]
go/ast, go/printer: recognize export and extern line directives

Now that gofmt is reformatting these, we can't get away with
not knowing about directives such as //export and //extern (for gccgo).
Otherwise "//export foo" and "//extern foo" turn into "// export foo",
and "// extern foo", which are completely different meanings.

For #51082.

Change-Id: Id0970331fa0b52ab5fa621631b5fa460767068bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/399734
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agoall: gofmt main repo
Russ Cox [Thu, 3 Feb 2022 19:12:08 +0000 (14:12 -0500)]
all: gofmt main repo

[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]

Run the updated gofmt, which reformats doc comments,
on the main repository. Vendored files are excluded.

For #51082.

Change-Id: I7332f099b60f716295fb34719c98c04eb1a85407
Reviewed-on: https://go-review.googlesource.com/c/go/+/384268
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agocmd/doc: use new go/doc APIs
Russ Cox [Tue, 8 Feb 2022 18:43:40 +0000 (13:43 -0500)]
cmd/doc: use new go/doc APIs

[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]

Use the new per-Package go/doc API instead of the
top-level functions from go/doc. These handle links better.

For #51082.

Change-Id: I169b46d973673abdb6f126352c9f1e30f9fe1122
Reviewed-on: https://go-review.googlesource.com/c/go/+/384266
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agogo/doc: use go/doc/comment
Russ Cox [Mon, 7 Feb 2022 22:24:40 +0000 (17:24 -0500)]
go/doc: use go/doc/comment

[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]

Use go/doc/comment to implement the existing go/doc comment APIs,
as well as adding new APIs more tailored to the new world.

For #51082.

Change-Id: I05b97ecedbf7cf7b8dede7ace6736ed6d89204a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/384265
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agocmd/go: gofmt alldocs.go
Russ Cox [Thu, 3 Feb 2022 19:09:32 +0000 (14:09 -0500)]
cmd/go: gofmt alldocs.go

[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]

Reformat alldocs.go using the new doc comment formatter.

This file is so large it gets its own gofmt CL.

For #51082.

Change-Id: Ie14cf1aad776e6f4180d88245d05a86e5fb6a3b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/384267
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agogo/printer: format doc comments
Russ Cox [Sat, 29 Jan 2022 23:25:41 +0000 (18:25 -0500)]
go/printer: format doc comments

[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]

Use go/doc/comment to reformat doc comments into a
standard form, enabling future expansion later and generally
making it easier to edit and read doc comments.

For #51082.

Change-Id: I6ab3b80846f03d781951111e4c36f86f47d21bb2
Reviewed-on: https://go-review.googlesource.com/c/go/+/384264
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agogo/doc/comment: parse and print lists
Russ Cox [Sun, 3 Apr 2022 20:45:18 +0000 (16:45 -0400)]
go/doc/comment: parse and print lists

[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]

Implement lists, like:

Three numbers:

  - One
  - Two
  - Three

For #51082.

Change-Id: Id87d9c19bca677be968f3803809a9ea6c705f3ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/397286
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agogo/doc/comment: parse and print code
Russ Cox [Sun, 3 Apr 2022 20:40:03 +0000 (16:40 -0400)]
go/doc/comment: parse and print code

[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]

Implement indented code blocks.

For #51082.

Change-Id: I0eacbf56e101424a875386cb6f26174b239561f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/397285
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agogo/doc/comment: parse and print headings
Russ Cox [Sun, 3 Apr 2022 20:30:08 +0000 (16:30 -0400)]
go/doc/comment: parse and print headings

[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]

Implement both old-style and new-style headings, like:

Text here.

Old Style Heading

More text here.

# New Style Heading

More text here.

For #51082.

Change-Id: I0d735782d0d345794fc2d4e1bdaa0251b8d4bba2
Reviewed-on: https://go-review.googlesource.com/c/go/+/397284
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2 years agogo/doc/comment: add text wrapping
Russ Cox [Sun, 3 Apr 2022 20:21:18 +0000 (16:21 -0400)]
go/doc/comment: add text wrapping

[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]

Implement wrapping of text output, for the “go doc” command.
The algorithm is from D. S. Hirschberg and L. L. Larmore,
“The least weight subsequence problem,” FOCS 1985, pp. 137-143.

For #51082.

Change-Id: I07787be3b4f1716b8ed9de9959f94ecbc596cc43
Reviewed-on: https://go-review.googlesource.com/c/go/+/397283
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agogo/doc/comment: parse and print explicit links
Russ Cox [Sun, 3 Apr 2022 20:16:46 +0000 (16:16 -0400)]
go/doc/comment: parse and print explicit links

[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]

Implement parsing and printing of explicit links, like:

Visit the [Go home page].

[Go home page]: https://go.dev

For #51082.

Change-Id: If8104e45558314dae0346df614b03d5664421cf1
Reviewed-on: https://go-review.googlesource.com/c/go/+/397282
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agogo/doc/comment: parse and print doc links
Russ Cox [Tue, 5 Apr 2022 18:12:41 +0000 (14:12 -0400)]
go/doc/comment: parse and print doc links

[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]

Implement parsing and printing of documentation links,
like [math.Sqrt] or [*golang.org/x/text/runes.Set].

For #51082.

Change-Id: I1cc73afbac1c6568773f921ce4b73e52f17acef6
Reviewed-on: https://go-review.googlesource.com/c/go/+/397281
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agogo/doc/comment: parse and print identifiers, automatic links
Russ Cox [Sun, 3 Apr 2022 12:59:56 +0000 (08:59 -0400)]
go/doc/comment: parse and print identifiers, automatic links

[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]

Implement parsing and printing of unmarked identifiers
and automatic URL links in plain text.

For #51082.

Change-Id: Ib83ad482937501a6fc14fa788eab289533a68e3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/397280
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agogo/doc/comment: add Printer and basic comment printing
Russ Cox [Sun, 3 Apr 2022 12:20:31 +0000 (08:20 -0400)]
go/doc/comment: add Printer and basic comment printing

[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]

Implement printing of plain text doc paragraphs.

For #51082.

Change-Id: Ieff0af64a900f566bfc833c3b5706488f1444798
Reviewed-on: https://go-review.googlesource.com/c/go/+/397279
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agogo/doc/comment: add paragraph parsing and test framework
Russ Cox [Sun, 3 Apr 2022 12:15:40 +0000 (08:15 -0400)]
go/doc/comment: add paragraph parsing and test framework

[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]

Implement parsing of plain text doc paragraphs,
as well as a txtar-based test framework. Subsequent CLs will
implement the rest of the possible markup.

For #51082.

Change-Id: I449aac69b44089f241fde8050ac134e17cb25116
Reviewed-on: https://go-review.googlesource.com/c/go/+/397278
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agogo/doc/comment: add low-level parsing helpers
Russ Cox [Sun, 3 Apr 2022 12:00:55 +0000 (08:00 -0400)]
go/doc/comment: add low-level parsing helpers

[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]

Implement helpers to recognize old-style headings,
plain text (not marked up) URLs, and Go identifiers.

For #51082.

Change-Id: Ibabce72ef3ffd79a9d33366091f8c76ef27d0182
Reviewed-on: https://go-review.googlesource.com/c/go/+/397277
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agogo/doc/comment: add data structures
Russ Cox [Sun, 3 Apr 2022 11:55:25 +0000 (07:55 -0400)]
go/doc/comment: add data structures

[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]

Implement just the data structures of the new API for
parsing and printing doc comments, as well as a syntax tree
form for inspecting and manipulating them.

The API itself was discussed and accepted as part of the
proposal process in #51082.

For #51082.

Change-Id: Iae7fbc85705964585273b970c5c62e394feb1288
Reviewed-on: https://go-review.googlesource.com/c/go/+/397276
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile: add MOVBE index load/store
Wayne Zuo [Thu, 24 Mar 2022 14:53:41 +0000 (22:53 +0800)]
cmd/compile: add MOVBE index load/store

Fixes #51724

Change-Id: I94e650a7482dc4c479d597f0162a6a89d779708d
Reviewed-on: https://go-review.googlesource.com/c/go/+/395474
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Cherry Mui <cherryyz@google.com>

2 years agotest: adjust load and store test
Wayne Zuo [Mon, 4 Apr 2022 08:32:29 +0000 (16:32 +0800)]
test: adjust load and store test

In the load tests, we only want to test the assembly produced by
the load operations. If we use the global variable sink, it will produce
one load operation and one store operation(assign to sink).

For example:

func load_be64(b []byte) uint64 {
sink64 = binary.BigEndian.Uint64(b)
}

If we compile this function with GOAMD64=v3, it may produce MOVBEQload
and MOVQstore or MOVQload and MOVBEQstore, but we only want MOVBEQload.
Discovered when developing CL 395474.

Same for the store tests.

Change-Id: I65c3c742f1eff657c3a0d2dd103f51140ae8079e
Reviewed-on: https://go-review.googlesource.com/c/go/+/397875
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Cherry Mui <cherryyz@google.com>

2 years agocmd/asm: fix MOVK when constant has high bit set
Keith Randall [Sun, 10 Apr 2022 16:12:43 +0000 (09:12 -0700)]
cmd/asm: fix MOVK when constant has high bit set

Fixes #52261

Change-Id: I1dc4c19c95a91f9e1e99d1e74afeb69f5bf8a979
Reviewed-on: https://go-review.googlesource.com/c/go/+/399455
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Eric Fang <eric.fang@arm.com>
2 years agoarchive/zip: fail fast if UncompressedSize64 < nread
Meng Zhuo [Wed, 24 Nov 2021 08:33:14 +0000 (16:33 +0800)]
archive/zip: fail fast if UncompressedSize64 < nread

The zip reader checks that the uncompressed file size is valid
after all compressed files read until EOF.
However in between reading each file, there could have already
been an overflow where nread > UncompressedSize64 hence this
change will now return ErrFormat in such situations.

Fixes #49791

Change-Id: If3584a57d173de6a97bf35c07d2a99ff6972f820
Reviewed-on: https://go-review.googlesource.com/c/go/+/366854
Trust: mzh <mzh@golangcn.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>