1
0
mirror of https://github.com/golang/go synced 2024-09-30 02:24:43 -06:00
Commit Graph

47438 Commits

Author SHA1 Message Date
Robert Griesemer
b95e4b7850 go/types: minor simplification in assignableTo (cleanup)
Also, clarify doc string.

Change-Id: If1c5f8e29e2c2080dd899ef76196e97b7b992389
Reviewed-on: https://go-review.googlesource.com/c/go/+/302758
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-03-18 18:50:58 +00:00
Dan Scales
f47fab938e cmd/compile: remove unneeded calls to typecheck in noder2
Remove unneeded calls to typecheck in noder2 associated with g.use() and
g.obj(). These routines are already setting the types2-derived type
correctly for ONAME nodes, and there is no typechecker1-related
transformations related to ONAME nodes, other than making sure that
newly created closure variables have their type set.

Tested through normal -G=3 testing in all.bash (all of go/tests).

Change-Id: I1b790ab9948959685fca3a768401458201833671
Reviewed-on: https://go-review.googlesource.com/c/go/+/303029
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
2021-03-18 17:14:39 +00:00
Austin Clements
eaa1ddee84 all: explode GOEXPERIMENT=regabi into 5 sub-experiments
This separates GOEXPERIMENT=regabi into five sub-experiments:
regabiwrappers, regabig, regabireflect, regabidefer, and regabiargs.
Setting GOEXPERIMENT=regabi now implies the working subset of these
(currently, regabiwrappers, regabig, and regabireflect).

This simplifies testing, helps derisk the register ABI project,
and will also help with performance comparisons.

This replaces the -abiwrap flag to the compiler and linker with
the regabiwrappers experiment.

As part of this, regabiargs now enables registers for all calls
in the compiler. Previously, this was statically disabled in
regabiEnabledForAllCompilation, but now that we can control it
independently, this isn't necessary.

For #40724.

Change-Id: I5171e60cda6789031f2ef034cc2e7c5d62459122
Reviewed-on: https://go-review.googlesource.com/c/go/+/302070
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
2021-03-18 16:51:27 +00:00
Austin Clements
c71acbfe83 test: make nosplit test invariant to ABI wrappers
Currently, the nosplit test disables ABI wrapper generation because it
generates a main.main in assembly, and so the ABI wrapper for calling
from runtime.main to main.main counts against the nosplit limit, which
cases some of the tests to fail.

Fix this by first entering ABI0 in a splittable context and then
calling from there into the test entry point, since this doesn't
introduce an ABI wrapper.

While we're here, this CL removes the test's check for the
framepointer experiment. That's now statically enabled, so it doesn't
appear in the experiment line, and enabling any other experiment
causes the test to think that the framepointer experiment *isn't*
enabled.

For #40724.

Change-Id: I6291eb9391f129779e726c5fc8c41b7b4a14eeb9
Reviewed-on: https://go-review.googlesource.com/c/go/+/302772
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-03-18 16:51:25 +00:00
Austin Clements
af4388aee1 cmd/internal/objabi: support boolean GOEXPERIMENTs
Currently, objabi exports GOEXPERIMENT flags as ints that are either 0
or 1. Since the dawn of time, there's been a comment saying that we
*could* support general integers here, but it's never happened and all
the "== 0" and "!= 0" and "== 1" are driving me crazy and are making
the code harder to read and maintain. Hence, this CL adds support for
boolean GOEXPERIMENT flags. We'll introduce some bool-typed flags in
the next CL.

Change-Id: I7813400db130a9b8f71a644fe7912808dbe645bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/302069
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-18 16:51:24 +00:00
Austin Clements
6461d74bf2 cmd/dist: build bootstrap without GOEXPERIMENT
Currently, dist attempts to build the bootstrap with the GOEXPERIMENT
set in the environment. However, the logic is incomplete and notably
requires a hack to enable the appropriate build tags for
GOEXPERIMENT=regabi. Without this hack, the build becomes skewed
between a compiler that uses regabi and a runtime that doesn't when
building toolchain2.

We could try to improve the GOEXPERIMENT processing in cmd/dist, but
it will always chase cmd/internal/objabi and it's quite difficult to
share the logic with objabi because of the constraints on building
cmd/dist.

Instead, we switch to building go_bootstrap without any GOEXPERIMENT
and only start using GOEXPERIMENT once we have a working, modern
cmd/go (which has all the GOEXPERIMENT logic in it). We also build
toolchain1 without any GOEXPERIMENT set, in case the bootstrap
toolchain is recent enough to understand build-time GOEXPERIMENT
settings.

As part of this, we make GOEXPERIMENT=none mean "no experiments". This
is necessary since, now that we support setting GOEXPERIMENT at build
time, we need an explicit way to say "ignore all baked-in experiments".

For #40724.

Change-Id: I115399579b766a7a8b2f352f7e5efea5305666cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/302050
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-18 16:51:22 +00:00
Austin Clements
06ca809410 cmd/internal/objabi: centralize GOEXPERIMENT parsing
objabi parses GOEXPERIMENT, but most of the consumers look at the raw
GOEXPERIMENT string that objabi gets from the environment. Centralize
this logic by only exposing the parsed GOEXPERIMENT value from objabi.
This sets us up for the next few changes. It also has the nice but
mostly useless property that the order of experiment names will be
canonicalized in build cache hashes.

After this, the only remaining place that looks at raw GOEXPERIMENT is
cmd/dist, which we'll fix in the next CL.

For #40724.

Change-Id: Idb150f848e17c184fae91372ca8b361591472f51
Reviewed-on: https://go-review.googlesource.com/c/go/+/302049
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-18 16:51:20 +00:00
Michael Matloob
b7cb92ad12 cmd/go: remove renameio package and its last usage
The last primary usage of renameio was the WriteFile in
modfetch.WriteDiskCache. Because it's not guaranteed that the fsync in
WriteDiskCache will eliminate file corruption, and it slows down tests
on Macs significantly, inline that last usage, removing the fsync.

Also, remove the uses of renameio.Pattern. The ziphash file is no
longer written to a temporary location before being copied to its
final location, so that usage can just be cut. The remaining use is
for the zipfile . Remove the first because the files are no longer
written using the pattern anyway, so that the pattern variable has no
effect. Replace it with a local pattern variable that is also passed
to os.CreateTemp.

Change-Id: Icf3adabf2a26c37b82afa1d07f821a46b30d69ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/301889
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-03-18 15:45:32 +00:00
Bryan C. Mills
e726e2a608 cmd/go: suppress errors for 'go get' of module paths that are also constrained-out packages
Fixes #33526

Change-Id: Iedd2d6dbe440499bf074ac632513319a22f2d648
Reviewed-on: https://go-review.googlesource.com/c/go/+/297009
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-03-18 14:43:33 +00:00
Andy Pan
6b6ea3271f cmd/go: use the global rooted path name
Change-Id: I4a450af5f35f0ad4e4652789f1eda4d3171610e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/302852
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
2021-03-18 14:20:08 +00:00
Cherry Zhang
db4adb1a9b cmd/link: print symbol versions in stack bound check
When the stack bound check fails, print the call chain with
symbol versions (along with the names). Now that we have ABI
wrappers and wrappers do consume stack space, it is clearer to
distinguish the wrappers vs. the underlying functions.

Change-Id: Id1d922e3e7934b31317f233aff3d9667b6ac90c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/302869
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-03-18 14:09:57 +00:00
Richard Pickering
9de49ae01a crypto/rsa: correct EncryptOAEP doc comment
Fixes #44777

Corrected the documentation comment on the EncryptOAEP function from
'if a given public key is used to decrypt two types of messages' to
'if a given public key is used to encrypt two types of messages'.

Change-Id: I02aff90d0414960eae72352c0e4d8ba2e8f8eca6
GitHub-Last-Rev: ea28663f87
GitHub-Pull-Request: golang/go#45032
Reviewed-on: https://go-review.googlesource.com/c/go/+/301714
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>
2021-03-18 13:31:52 +00:00
Rabin Gaire
732ea4c2dc sort: add example tests for SearchFloat64s and SearchInts
Change-Id: I5fa4773467e3f515250deead72fdce3e4bd0973b
Reviewed-on: https://go-review.googlesource.com/c/go/+/275457
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Griesemer <gri@golang.org>
2021-03-18 08:25:24 +00:00
Joel Sing
c2d625168f cmd/compile,cmd/internal/obj/riscv: load >32-bit constants from memory for riscv64
Follow what MIPS does and load >32-bit constants from memory using two instructions,
rather than generating a four to six instruction sequence. This removes more than 2,500
instructions from the Go binary. This also makes it possible to load >32-bit constants
via a single assembly instruction, if required.

Change-Id: Ie679a0754071e6d8c52fe0d027f00eb241b3a758
Reviewed-on: https://go-review.googlesource.com/c/go/+/302609
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-18 04:17:00 +00:00
Joel Sing
42c25e65f3 cmd/compile: actually intrinsify runtime/internal/atomic.{And,Or}{8,} on RISCV64
Actually enable intrinsics for runtime/internal/atomic.{And,Or}{8,} on RISCV64.
This seems to have been lost when CL 268098 was rebased.

Change-Id: If072daa79c8964b186c127d5e065a7cc9e23ba27
Reviewed-on: https://go-review.googlesource.com/c/go/+/302229
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-18 03:52:02 +00:00
Joel Sing
6517844129 cmd/compile: use a single const MOV operand for riscv64
Most platforms only use a single MOV const operand - remove the MOV{B,H,W}const
operands from riscv64 and consistently use MOVDconst instead. The implementation
of all four is the same and there is no benefit gained from having multiple const
operands (in fact it requires a lot more rewrite rules).

Change-Id: I0ba7d7554e371a1de762ef5f3745e9c0c30d41ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/302610
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Michael Munday <mike.munday@lowrisc.org>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-03-18 03:42:56 +00:00
fanzha02
f5e6d3e879 cmd/compile: add rewrite rules for conditional instructions on arm64
This CL adds rewrite rules for CSETM, CSINC, CSINV, and CSNEG. By adding
these rules, we can save one instruction.

For example,

  func test(cond bool, a int) int {
    if cond {
      a++
    }
    return a
  }

Before:

  MOVD "".a+8(RSP), R0
  ADD $1, R0, R1
  MOVBU "".cond(RSP), R2
  CMPW $0, R2
  CSEL NE, R1, R0, R0

After:

  MOVBU "".cond(RSP), R0
  CMPW $0, R0
  MOVD "".a+8(RSP), R0
  CSINC EQ, R0, R0, R0

This patch is a copy of CL 285694. Co-authored-by: JunchenLi
<junchen.li@arm.com>

Change-Id: Ic1a79e8b8ece409b533becfcb7950f11e7b76f24
Reviewed-on: https://go-review.googlesource.com/c/go/+/302231
Trust: fannie zhang <Fannie.Zhang@arm.com>
Run-TryBot: fannie zhang <Fannie.Zhang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-03-18 01:46:58 +00:00
Robert Griesemer
51e4bb236c cmd/compile/internal/types2: delay recording types of untyped operands when checking against type parameters
Don't eagerly record the target type for an untyped operand if the
target type is just one of possibly many types in the type list of
a type parameter. Instead, record expression type only after we
checked that all types in the type list are ok.

Also, update assertion in Checker.recordTypeAndValue since (currently),
a type parameter is not considered a const type. We may change that,
eventually.

This is a temporary (but working) solution. Eventually we should
copy the approach taken in go/types.

Fixes #45096.

Change-Id: Icf61ee893aca6ead32bfc45ee5831572e672357b
Reviewed-on: https://go-review.googlesource.com/c/go/+/302755
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-03-18 00:23:25 +00:00
Robert Griesemer
2583c1b4df go/types: add test case for issue #45096
This verifies that issue #45096 is not an issue for go/types.

Updates #45096.

Change-Id: I4e987b5d4928f0c864d0d2c0379149443beb4d5c
Reviewed-on: https://go-review.googlesource.com/c/go/+/302754
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-03-18 00:08:55 +00:00
Tobias Klauser
f38b6428a2 crypto/rand, internal/syscall/unix: add support for getentropy syscall on darwin
The getentropy syscall is available on macOS since version 10.12, which
is the minimum required version since Go 1.15.

Change-Id: I294259af0b11df9669e4dc5fa891d2f2f039d91a
Reviewed-on: https://go-review.googlesource.com/c/go/+/302489
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-03-17 22:14:28 +00:00
Ian Lance Taylor
f82ce7fb23 cmd/link: improve nonexistent package error message
Change-Id: I207541efa6a34bc21e7a00584376622b59e2bf6d
Reviewed-on: https://go-review.googlesource.com/c/go/+/302749
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-03-17 21:48:40 +00:00
Bryan C. Mills
7e00049b55 cmd/go: only add a 'go' directive to the main module when the go.mod file will be written
Then, write the 'go.mod' file with that version before further
processing. That way, if the command errors out due to a change in
behavior, the reason for the change in behavior will be visible in the
file diffs.

If the 'go.mod' file cannot be written (due to -mod=readonly or
-mod=vendor), assume Go 1.11 instead of the current Go release.
(cmd/go has added 'go' directives automatically, including in 'go mod
init', since Go 1.12.)

For #44976

Change-Id: If9d4af557366f134f40ce4c5638688ba3bab8380
Reviewed-on: https://go-review.googlesource.com/c/go/+/302051
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-03-17 21:24:05 +00:00
Andrey Bokhanko
4313c28861 cmd/cgo: check whether C compiler exists
Currently we print a cryptic message if a C compiler doesn't exist.
This patch adds more graceful handling.

Fixes #44271

Change-Id: I44f16ef6eb2853fee22fa1d996e41ec6c9ee82f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/301249
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2021-03-17 20:29:22 +00:00
Andy Pan
a5df88355c time: check int64 overflow in Time.addSec
Change-Id: Ibbed54239228e7ea31ef5978d427425899c3b943
Reviewed-on: https://go-review.googlesource.com/c/go/+/300890
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Baokun Lee <bk@golangcn.org>
2021-03-17 19:48:52 +00:00
Ian Lance Taylor
5423f6023c test: add bug that failed when run with gccgo
Change-Id: Ie52d70d2ae8a21acacf0745a4093650b03ac43f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/302371
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-17 19:15:18 +00:00
Cherry Zhang
8628bf9a97 cmd/compile: resurrect clobberdead mode
This CL resurrects the clobberdead debugging mode (CL 23924).
When -clobberdead flag is set (TODO: make it GOEXPERIMENT?), the
compiler inserts code that clobbers all dead stack slots that
contains pointers.

Mark windows syscall functions cgo_unsafe_args, as the code
actually does that, by taking the address of one argument and
passing it to cgocall.

Change-Id: Ie09a015f4bd14ae6053cc707866e30ae509b9d6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/301791
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-03-17 17:50:50 +00:00
Rob Findley
0bd308ff27 go/parser: avoid formatting a panic message if an assertion succeeds
tryResolve is an extremely hot method on the parser. Eliminating this
formatting led to a 20% performance improvement in BenchmarkParse.

Change-Id: Idf8850404bd72d45d1351356427a85086422ea68
Reviewed-on: https://go-review.googlesource.com/c/go/+/302629
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-03-17 17:13:50 +00:00
Dan Scales
70d54df4f6 cmd/compile: getting more built-ins to work with generics
For Builtin ops, we currently stay with using the old
typechecker to transform the call to a more specific expression
and possibly use more specific ops. However, for a bunch of the
ops, we delay calling the old typechecker if any of the args have
type params, for a variety of reasons.

In the near future, we will start creating separate functions that do
the same transformations as the old typechecker for calls, builtins,
indexing, comparisons, etc. These functions can then be called at noder
time for nodes with no type params, and at stenciling time for nodes
with type params.

Remove unnecessary calls to types1 typechecker for most kinds of
statements (still need it for SendStmt, AssignStmt, ReturnStmt, and
SelectStmt). In particular, we don't need it for RangeStmt, and this
avoids some complaints by the types1 typechecker on generic code.

Other small changes:
 - Fix check on whether to delay calling types1-typechecker on type
   conversions. Should check if HasTParam is true, rather than if the
   type is directly a TYPEPARAM.

 - Don't call types1-typechecker on an indexing operation if the left
   operand has a typeparam in its type and is not obviously a TMAP,
   TSLICE, or TARRAY. As above, we will eventually have to create a new
   function that can do the required transformations (for complicated
   cases) at noder time or stenciling time.

 - Copy n.BuiltinOp in subster.node()

 - The complex arithmetic example in absdiff.go now works.

 - Added new tests double.go and append.go

 - Added new example with a new() call in settable.go

Change-Id: I8f377afb6126cab1826bd3c2732aa8cdf1f7e0b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/301951
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-03-17 16:53:00 +00:00
Johan Brandhorst
2f3db220d1 crypto/tls: remove flaky cancellation test
This will be reintroduced again once the source of the
flakiness has been determined and fixed.

Fixes #45084

Change-Id: I6677b27fcd71e8c9bb8edbe8e3be70e5a271ebd3
Reviewed-on: https://go-review.googlesource.com/c/go/+/302569
Trust: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Run-TryBot: Katie Hockman <katie@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-03-17 16:19:21 +00:00
Agniva De Sarker
72b501cb03 compress/lzw: add Reset method to Reader and Writer
We add a Reset method which clears any internal state of an encoder
or a decoder to let it be reused again as a new Writer or Reader respectively.

We also export the encoder and decoder structs, renaming them
to be Reader and Writer, and we guarantee that the underlying types
from the constructors will always be Reader and Writer respectively.

Benchmark results by reusing the encoder:
on cpu: Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz

name                 time/op
Decoder/1e4-8          93.6µs ± 1%
Decoder/1e-Reuse4-8    87.7µs ± 1%
Decoder/1e5-8           877µs ± 1%
Decoder/1e-Reuse5-8     860µs ± 3%
Decoder/1e6-8          8.79ms ± 1%
Decoder/1e-Reuse6-8    8.82ms ± 4%
Encoder/1e4-8           168µs ± 2%
Encoder/1e-Reuse4-8     160µs ± 1%
Encoder/1e5-8          1.64ms ± 1%
Encoder/1e-Reuse5-8    1.61ms ± 2%
Encoder/1e6-8          16.2ms ± 6%
Encoder/1e-Reuse6-8    15.8ms ± 2%

name                 speed
Decoder/1e4-8         107MB/s ± 1%
Decoder/1e-Reuse4-8   114MB/s ± 1%
Decoder/1e5-8         114MB/s ± 1%
Decoder/1e-Reuse5-8   116MB/s ± 3%
Decoder/1e6-8         114MB/s ± 1%
Decoder/1e-Reuse6-8   113MB/s ± 5%
Encoder/1e4-8        59.7MB/s ± 2%
Encoder/1e-Reuse4-8  62.4MB/s ± 1%
Encoder/1e5-8        61.1MB/s ± 1%
Encoder/1e-Reuse5-8  62.0MB/s ± 2%
Encoder/1e6-8        61.7MB/s ± 5%
Encoder/1e-Reuse6-8  63.4MB/s ± 2%

name                 alloc/op
Decoder/1e4-8          21.8kB ± 0%
Decoder/1e-Reuse4-8     50.0B ± 0%
Decoder/1e5-8          21.8kB ± 0%
Decoder/1e-Reuse5-8     70.4B ± 2%
Decoder/1e6-8          21.9kB ± 0%
Decoder/1e-Reuse6-8      271B ± 3%
Encoder/1e4-8          77.9kB ± 0%
Encoder/1e-Reuse4-8    4.17kB ± 0%
Encoder/1e5-8          77.9kB ± 0%
Encoder/1e-Reuse5-8    4.27kB ± 0%
Encoder/1e6-8          77.9kB ± 0%
Encoder/1e-Reuse6-8    5.22kB ± 0%

name                 allocs/op
Decoder/1e4-8            2.00 ± 0%
Decoder/1e-Reuse4-8      1.00 ± 0%
Decoder/1e5-8            2.00 ± 0%
Decoder/1e-Reuse5-8      1.00 ± 0%
Decoder/1e6-8            2.00 ± 0%
Decoder/1e-Reuse6-8      1.00 ± 0%
Encoder/1e4-8            3.00 ± 0%
Encoder/1e-Reuse4-8      2.00 ± 0%
Encoder/1e5-8            3.00 ± 0%
Encoder/1e-Reuse5-8      2.00 ± 0%
Encoder/1e6-8            3.00 ± 0%
Encoder/1e-Reuse6-8      2.00 ± 0%

Fixes #26535

Change-Id: Icde613fea6234a5bdce95f1e49910f5687e30b22
Reviewed-on: https://go-review.googlesource.com/c/go/+/273667
Trust: Agniva De Sarker <agniva.quicksilver@gmail.com>
Trust: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2021-03-17 07:01:00 +00:00
Meng Zhuo
119d76d98e math/bits: folded reverse tables by using const string
linux/mips64le

name            old time/op  new time/op  delta
Reverse         2.31ns ± 1%  2.27ns ± 1%  -1.53%  (p=0.001 n=10+10)
Reverse8        0.65ns ± 1%  0.65ns ± 1%  -1.19%  (p=0.000 n=9+10)
Reverse16       1.15ns ± 2%  1.14ns ± 2%    ~     (p=0.062 n=9+10)
Reverse32       1.96ns ± 1%  1.94ns ± 1%  -1.16%  (p=0.000 n=10+9)
Reverse64       2.29ns ± 1%  2.26ns ± 0%  -0.94%  (p=0.000 n=9+9)
ReverseBytes    0.66ns ± 3%  0.65ns ± 1%  -1.58%  (p=0.006 n=9+10)
ReverseBytes16  0.66ns ± 2%  0.65ns ± 1%  -2.05%  (p=0.000 n=10+9)
ReverseBytes32  0.41ns ± 1%  0.40ns ± 0%  -1.68%  (p=0.000 n=10+10)
ReverseBytes64  0.66ns ± 1%  0.65ns ± 1%  -1.50%  (p=0.000 n=10+9)

cpu=1 benchtime=100ms count=100

name            old time/op  new time/op  delta
Reverse         28.0ns ± 3%  27.7ns ± 3%   -0.80%  (p=0.000 n=100+98)
Reverse8        2.24ns ± 1%  2.24ns ± 1%     ~     (p=0.142 n=98+100)
Reverse16       4.07ns ± 3%  4.05ns ± 3%   -0.66%  (p=0.000 n=99+99)
Reverse32       11.3ns ± 0%  11.3ns ± 0%     ~     (p=0.283 n=94+97)
Reverse64       12.6ns ± 0%  12.6ns ± 0%   +0.60%  (p=0.000 n=100+98)
ReverseBytes    5.25ns ± 1%  5.24ns ± 1%   -0.18%  (p=0.000 n=100+100)
ReverseBytes16  2.00ns ± 0%  2.21ns ± 3%  +10.07%  (p=0.000 n=88+100)
ReverseBytes32  4.08ns ± 2%  4.13ns ± 2%   +1.39%  (p=0.000 n=99+99)
ReverseBytes64  5.48ns ± 1%  5.45ns ± 1%   -0.50%  (p=0.000 n=98+99)

Update #43403

Change-Id: I7e7e00bb17608739d9f6b927c6dfef2580493a0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/280645
Trust: Meng Zhuo <mzh@golangcn.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-03-17 03:18:12 +00:00
Andrey Bokhanko
a98a0a75b4 os/user: make user.LookupGroupId function work for large entries
The existing implementation of user.LookupGroupId function works
incorrectly with very large (>64K symbols) entries in /etc/group file.
This patch fixes this.

Fixes #43636

Change-Id: I453321f1ab15fd4d0002f97fcec7d0789e1e0da5
Reviewed-on: https://go-review.googlesource.com/c/go/+/283601
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2021-03-17 03:08:07 +00:00
Ian Lance Taylor
a826f7dc45 debug/dwarf: support DW_FORM_rnglistx aka formRnglistx
Change-Id: I7df915978af3488f46a27595a1b04d0d33f81f7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/302369
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-03-17 00:54:09 +00:00
Robert Griesemer
63b0a0a5b8 spec: fix rendering of >=
Follow-up on https://golang.org/cl/297249.

Change-Id: Ib4df91df530e4e7d7dd8c54d89c834cee55031f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/302370
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-03-17 00:18:28 +00:00
Robert Griesemer
68f8e1af29 cmd/compile/internal/types2: review of call.go
The changes between (equivalent, and reviewed) go/types/call.go
and call.go can be seen by comparing patchset 1 and 2. The actual
changes are removing the "// UNREVIEWED" marker, renaming of
sig_params to sigParams, and a couple of comment adjustments.
These additional changes reduce the difference between this
file and the go/types version.

Note that the verification pass using a MethodSet doesn't
exist because there's no MethodSet in types2.

Change-Id: I4d49460e0457401ed705dff5cfd17c9ff259d89f
Reviewed-on: https://go-review.googlesource.com/c/go/+/300998
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-03-17 00:17:33 +00:00
Cherry Zhang
7a1e963058 cmd/compile, cmd/link: dynamically export writable static tmps
Static tmps are private to a package, but with plugins a package
can be shared among multiple DSOs. They need to have a consistent
view of the static tmps, especially for writable ones. So export
them. (Read-only static tmps have the same values anyway, so it
doesn't matter. Also Mach-O doesn't support dynamically exporting
read-only symbols anyway.)

Fixes #44956.

Change-Id: I921e25b7ab73cd5d5347800eccdb7931e3448779
Reviewed-on: https://go-review.googlesource.com/c/go/+/301793
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-03-16 23:14:54 +00:00
Cherry Zhang
dc1556eaef cmd/compile: update some comments
Update some symbol references after refactoring.

Change-Id: I134eec453b69efae97eb8a13e52ff8c14d38442a
Reviewed-on: https://go-review.googlesource.com/c/go/+/301790
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-03-16 22:40:59 +00:00
Keith Randall
c870e86329 cmd/asm: when dynamic linking, reject code that uses a clobbered R15
The assember uses R15 as scratch space when assembling global variable
references in dynamically linked code. If the assembly code uses the
clobbered value of R15, report an error. The user is probably expecting
some other value in that register.

Getting rid of the R15 use isn't very practical (we could save a
register to a field in the G maybe, but that gets cumbersome).

Fixes #43661

Change-Id: I43f848a3d8b8a28931ec733386b85e6e9a42d8ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/283474
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-16 21:18:43 +00:00
Bryan C. Mills
72d98df88e cmd/go: bail out from script tests earlier when a timeout occurs
(I needed this to debug an accidental infinite-recursion I introduced
while revising CL 293689.)

Fixes #38768

Change-Id: I306122f15b5bbd2fc5e836b32fd4dd5992ea891e
Reviewed-on: https://go-review.googlesource.com/c/go/+/302052
Trust: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-03-16 20:46:00 +00:00
cui
1824667259 cmd/compile/internal/ssa: delete unused files
Change-Id: I5d640091375feb873517368ce05f0ba46c35714f
GitHub-Last-Rev: cdaf6ba336
GitHub-Pull-Request: golang/go#44997
Reviewed-on: https://go-review.googlesource.com/c/go/+/301630
Reviewed-by: David Chase <drchase@google.com>
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-03-16 20:44:34 +00:00
nobishino
13a0f7b502 spec: clarify that signed integers>=0 are permitted as shift counts
In Go1.13 and above, signed integers are permitted as shift counts as long as they are >=0.
However, the comments in the "Arithmetic operators" section says shift operators accept "unsigned integer" as of right operands. Replacing this with "integer>=0" resolves the misunderstanding that shift
operators permit only unsigned integers.

Reference: Go1.13 Release Notes: https://golang.org/doc/go1.13

Change-Id: Icd3c7734d539ab702590e992a618c9251c653c37
GitHub-Last-Rev: 4f263a48d3
GitHub-Pull-Request: golang/go#44664
Reviewed-on: https://go-review.googlesource.com/c/go/+/297249
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Robert Griesemer <gri@golang.org>
2021-03-16 19:51:31 +00:00
David Chase
d206ca5cac cmd/compile: fix open defer of method call
Code generation for open defers failed to account for
presence of method receiver and thus was OFF BY ONE.

Fixes #45062.
Updates #44816.
Updates #40724.

Change-Id: Ia90ea8fd0f7d823e1f757c406f9127136c2ffdd2
Reviewed-on: https://go-review.googlesource.com/c/go/+/302249
Trust: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-16 19:23:36 +00:00
David Chase
0ec2c4abba cmd/compile: (fixed) spill output parameters passed in registers as autos
Repair of CL 300749.

ALSO:
found evidence that stack maps for bodyless methods are wrong.
gofmt in test/abi
removed never-executed code in types/size.go

Updates #44816.
Updates #40724.

Change-Id: Ifeb5fee60f60e7c7b58ee0457f58a3265d6cf3f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/302071
Trust: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-16 19:22:44 +00:00
Dan Scales
832a01aad4 cmd/compile: deal with comparable embedded in a constraint
Ignore an embedded type in an interface which is the predeclared
interface "comparable" (which currently can only be in a type
constraint), since the name doesn't resolve and the "comparable" type
doesn't have any relevant methods (for the purposes of the compiler).

Added new test case graph.go that needs this fix.

Change-Id: I2443d2c3dfeb9d0a78aaaaf91a2808ae2759d247
Reviewed-on: https://go-review.googlesource.com/c/go/+/301831
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-03-16 18:42:06 +00:00
Meng Zhuo
e31e84010e cmd/asm: add rotr/drotr for mips64
This CL encodes:

ROTR rd, rt, sa
ROTRV rd, rt, rs

=> ROTR (SCON|REG), (REG,)? REG

DROTR rd, rt, sa
DROTR32 rd, rt, sa
DROTRV rd, rt, rs

=> ROTRV (SCON|REG), (REG,)? REG

Note: ROTRV will handle const over 32
Ref: The MIPS64® Instruction Set Reference Manual Revision 6.05
Change-Id: Ibe69f999b83eb43843d088cf1ac5a13c995269a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/280114
Trust: Meng Zhuo <mzh@golangcn.org>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-16 14:31:05 +00:00
Paul E. Murphy
bd0fc0b9c3 cmd/link: preserve elf phdr flags when loading external objects
Preserve program header flags when passing them through loadelf.Load.
They shouldn't be coerced to 0 on non-ARM platforms which set them
such as ppc64le.

Change-Id: I022613356f910d812de2fc22eac949960eeb53b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/300950
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2021-03-16 14:20:35 +00:00
Johan Brandhorst
860704317e crypto/tls: add HandshakeContext method to Conn
Adds the (*tls.Conn).HandshakeContext method. This allows
us to pass the context provided down the call stack to
eventually reach the tls.ClientHelloInfo and
tls.CertificateRequestInfo structs.
These contexts are exposed to the user as read-only via Context()
methods.

This allows users of (*tls.Config).GetCertificate and
(*tls.Config).GetClientCertificate to use the context for
request scoped parameters and cancellation.

Replace uses of (*tls.Conn).Handshake with (*tls.Conn).HandshakeContext
where appropriate, to propagate existing contexts.

Fixes #32406

Change-Id: I259939c744bdc9b805bf51a845a8bc462c042483
Reviewed-on: https://go-review.googlesource.com/c/go/+/295370
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Katie Hockman <katie@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2021-03-16 14:05:45 +00:00
Bryan C. Mills
0089f8b2f5 cmd/go: test that 'go mod tidy' retains upgraded indirect dependencies
For #36460

Change-Id: I63596e1c95d0c702073cdb016579598d79cc95ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/300158
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-03-16 13:39:46 +00:00
Bryan C. Mills
120b9eb1c3 cmd/go/internal/modload: in readonly mode, do not read go.mod files missing checksums
This was causing test failures while revising CL 293689: splitting the
roots out from the rest of the module graph may allow 'go list -e' to
proceed even when the rest of the module graph can't be loaded (e.g.
due to missing go.mod checksums). If that occurs, it becomes more
important that the moduleInfo helper function itself avoid fetching
unchecked files.

For #36460

Change-Id: I088509eeb3008cc6e8bfe85a00ec2bf500bf9423
Reviewed-on: https://go-review.googlesource.com/c/go/+/301371
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-03-16 13:06:17 +00:00
Bryan C. Mills
26c32de7c9 cmd/go/internal/modcmd: in 'go mod tidy', suspend go.mod writes until tidy
For #36460

Change-Id: Ia8633f37aec8c7ed532bf7278867251e5e2a4285
Reviewed-on: https://go-review.googlesource.com/c/go/+/301370
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-03-16 13:06:04 +00:00