]> Cypherpunks repositories - gostls13.git/log
gostls13.git
3 years agodebug/macho: fail on invalid dynamic symbol table command
Roland Shoemaker [Thu, 14 Oct 2021 20:02:01 +0000 (13:02 -0700)]
debug/macho: fail on invalid dynamic symbol table command

Fail out when loading a file that contains a dynamic symbol table
command that indicates a larger number of symbols than exist in the
loaded symbol table.

Thanks to Burak Çarıkçı - Yunus Yıldırım (CT-Zer0 Crypttech) for
reporting this issue.

Fixes #48990
Fixes CVE-2021-41771

Change-Id: Ic3d6e6529241afcc959544b326b21b663262bad5
Reviewed-on: https://go-review.googlesource.com/c/go/+/355990
Reviewed-by: Julie Qiu <julie@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Katie Hockman <katie@golang.org>

3 years agogo/types: implement generic conversions
Robert Findley [Wed, 27 Oct 2021 16:06:46 +0000 (12:06 -0400)]
go/types: implement generic conversions

This is a port of 4 CLs from types2: CL 356010, CL 357333, CL 357410,
and CL 357249. These 4 CLs are all related to implementing conversions,
and porting them together saved time (particularly because go/types was
already threading a *reason argument in some places).

Change-Id: Ic89b608d7096b61bfb9f7d71fdae2cc50b0ed70e
Reviewed-on: https://go-review.googlesource.com/c/go/+/359137
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: add debugging support for delayed actions
Robert Findley [Wed, 27 Oct 2021 15:23:06 +0000 (11:23 -0400)]
go/types: add debugging support for delayed actions

This is a port of CL 355871 to go/types.

Change-Id: I2dbc3c625c16b545a271a19606ef34ce04a4a6df
Reviewed-on: https://go-review.googlesource.com/c/go/+/359136
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types, types2, go/ast, go/parser: remove support for type lists
Robert Findley [Wed, 27 Oct 2021 15:14:24 +0000 (11:14 -0400)]
go/types, types2, go/ast, go/parser: remove support for type lists

This is a rough port of CL 354131 to go/* libraries, though in practice
I just tried to reconcile any places where the phrase "type list"
occurred in the source. This resulted in adjusting quite a bit more code
than initially expected, including a few lingering cases in the
compiler.

Change-Id: Ie62a9e1aeb831b73931bc4c78bbb6ccb24f53fb0
Reviewed-on: https://go-review.googlesource.com/c/go/+/359135
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/parser: fix parsing of array or slice constraint types
Robert Findley [Wed, 27 Oct 2021 13:19:50 +0000 (09:19 -0400)]
go/parser: fix parsing of array or slice constraint types

Now that we allow eliding 'interface' from constraint types, we need to
be a bit more careful about not consuming a '[' when parsing the next
expression after "type T [". We want to check if the next expression is
an identifier not followed by ']', in which case we're in a generic
type, but need to avoid parsing index or slice expressions. Such
expressions aren't valid array lengths because these expressions are
never constant, so when encountering a following '[' we can instead
assume that this is a type parameter field with array or slice type
constraint.

Test cases are added for the related issues #49174 and #49175, along
with a flag to enable tracing error tests.

For #49174
For #49175

Change-Id: I0476ef20c4c134ac537118272f20caaf123ee70e
Reviewed-on: https://go-review.googlesource.com/c/go/+/359134
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agoruntime: fix noopt builder
Cuong Manh Le [Thu, 28 Oct 2021 03:40:54 +0000 (10:40 +0700)]
runtime: fix noopt builder

CL 352057 added track argument stack slot liveness, and updated
TestTracebackArgs for argument liveness. But when optimization is
disabled, all arguments are considered lived. The abiSel does not
consider this case and return wrong expected result.

To fix this, checking if we are running in a noopt builder and return
the correct expected result. Also, skipping TestTracebackArgs in quick
mode, since when quick mode run the test without optimization disable.

Updates #45728

Change-Id: I3737a1b1a5fa0c711fbb3218205f2f6e34f36260
Reviewed-on: https://go-review.googlesource.com/c/go/+/359196
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/compile: allow inlining of ORANGE
nimelehin [Tue, 19 Oct 2021 15:59:34 +0000 (18:59 +0300)]
cmd/compile: allow inlining of ORANGE

Updates #14768

Change-Id: I33831f616eae5eeb099033e2b9cf90fa70d6ca86
Reviewed-on: https://go-review.googlesource.com/c/go/+/356869
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>

3 years agoreflect: undeprecate Ptr, PtrTo
Brad Fitzpatrick [Wed, 27 Oct 2021 17:13:50 +0000 (10:13 -0700)]
reflect: undeprecate Ptr, PtrTo

Fixes #48665

Change-Id: Id838f7508f6e93c4546a2aeefc2db194e647db77
Reviewed-on: https://go-review.googlesource.com/c/go/+/359175
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agogo/build: update for //go:build lines
Russ Cox [Thu, 28 Oct 2021 00:21:07 +0000 (20:21 -0400)]
go/build: update for //go:build lines

Look for //go:build ignore, not // +build ignore, in deps_test.go.

For #41184.

Change-Id: Iba8617230aa620223e2bc170f18d0c54557318c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/359315
Trust: Russ Cox <rsc@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
3 years agocmd/dist: implement //go:build parsing
Russ Cox [Wed, 27 Oct 2021 22:53:02 +0000 (18:53 -0400)]
cmd/dist: implement //go:build parsing

The bootstrap directories are built with the Go 1.4 go command,
and they will retain the // +build lines until we bump the bootstrap
toolchain to Go 1.17 or later.

cmd/dist builds cmd/go and all its dependencies, using the
assembler, compiler, and linker that were built using Go 1.4.
We don't want to have to keep // +build lines in cmd/go and
all its dependencies, so this CL changes cmd/dist to understand
the //go:build lines.

cmd/dist is a standalone Go program that must itself build with
very old Go releases, so we cannot assume go/build/constraint
is available. Instead, implement a trivial parser/evaluator.

For #41184.

Change-Id: I84e259dec3bd3daec3f82024eb3500120f53096d
Reviewed-on: https://go-review.googlesource.com/c/go/+/359314
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agoreflect: undeprecate Value.{Pointer,UnsafeAddr}
Cuong Manh Le [Wed, 27 Oct 2021 17:33:19 +0000 (00:33 +0700)]
reflect: undeprecate Value.{Pointer,UnsafeAddr}

Fixes #49187

Change-Id: I4d8c87af8a709f1b909dd4fae3734d422eb36900
Reviewed-on: https://go-review.googlesource.com/c/go/+/359194
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile: resolve the TODO of processPragmas
Leonard Wang [Wed, 7 Jul 2021 14:33:09 +0000 (22:33 +0800)]
cmd/compile: resolve the TODO of processPragmas

Change-Id: Id723ecc2480aea2d8acb4d3e05db4a6c8eef9cc8
Reviewed-on: https://go-review.googlesource.com/c/go/+/333109
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Cherry Mui <cherryyz@google.com>

3 years agocmd/compile/internal/types2: export Structure function
Robert Griesemer [Thu, 28 Oct 2021 00:28:36 +0000 (17:28 -0700)]
cmd/compile/internal/types2: export Structure function

For #48538.

Change-Id: I258b0c8af5801692ad238e47397dde0b4e3c44c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/359275
Trust: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
3 years agocmd/compile/internal/types2: disallow lone type parameter on RHS of type declaration
Robert Griesemer [Wed, 27 Oct 2021 20:55:15 +0000 (13:55 -0700)]
cmd/compile/internal/types2: disallow lone type parameter on RHS of type declaration

We may revisit this decision in a future release. By disallowing this
for Go 1.18 we are ensuring that we don't lock in the generics design
in a place that may need to change later. (Type declarations are the
primary construct where it crucially matters what the underlying type
of a type parameter is.)

Comment out all tests that rely on this feature; add comments referring
to issue so we can find all places easily should we change our minds.

Fixes #45639.

Change-Id: I730510e4da66d3716d455a9071c7778a1e4a1152
Reviewed-on: https://go-review.googlesource.com/c/go/+/359177
Trust: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
3 years agoconstraints: remove Slice/Map/Chan
Ian Lance Taylor [Wed, 27 Oct 2021 21:11:33 +0000 (14:11 -0700)]
constraints: remove Slice/Map/Chan

Now that we permit arbitrary types as constraints, we no longer need them.

For #48424

Change-Id: I15fef26a563988074650cb0801895b002c44148a
Reviewed-on: https://go-review.googlesource.com/c/go/+/359258
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agodoc/go1.18: document Fossil/Bazaar and commit time build tag support
Mark Pulford [Fri, 22 Oct 2021 07:41:41 +0000 (18:41 +1100)]
doc/go1.18: document Fossil/Bazaar and commit time build tag support

Change-Id: I032791a3cda1916099b0fd2955dcca4e69763660
Reviewed-on: https://go-review.googlesource.com/c/go/+/357958
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/go: stamp Bazaar VCS status into binaries
Mark Pulford [Fri, 22 Oct 2021 07:23:18 +0000 (18:23 +1100)]
cmd/go: stamp Bazaar VCS status into binaries

For #37475

Change-Id: I728b7aeee5c38ec337e9a5b073050c3b0afc720d
Reviewed-on: https://go-review.googlesource.com/c/go/+/357956
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agoreflect: skip duplicate check in StructOf when the name of a field is "_"
zhouguangyuan [Fri, 22 Oct 2021 09:00:46 +0000 (17:00 +0800)]
reflect: skip duplicate check in StructOf when the name of a field is "_"

Fixes #49110

Change-Id: I32c2cb26cca067a4a676ce4bbc3e51f1e0cdb259
Reviewed-on: https://go-review.googlesource.com/c/go/+/357959
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: Dan Kortschak <dan@kortschak.io>
Reviewed-by: Sebastien Binet <s@sbinet.org>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>

3 years agocmd/go: stamp Fossil VCS status into binaries
Mark Pulford [Fri, 22 Oct 2021 00:21:28 +0000 (11:21 +1100)]
cmd/go: stamp Fossil VCS status into binaries

For #37475

Change-Id: I09fa1344051088ce37727176d9ec6b38891d1a9f
Reviewed-on: https://go-review.googlesource.com/c/go/+/357955
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/go: fix recognition of Fossil checkout directories
Mark Pulford [Fri, 22 Oct 2021 01:36:00 +0000 (12:36 +1100)]
cmd/go: fix recognition of Fossil checkout directories

Use ".fslckout" or "_FOSSIL_" files to correctly identify the root of
Fossil checkout directories.

Previously, Go has assumed VCS checkouts are indicated by a dot-file
named after the VCS command (eg, .git, .hg, .fossil). This is not
normally true for Fossil, but has worked so far since Go downloads
repositories into a ".fossil" file before opening (checking out).

Using the incorrect path prevents Go identifying Fossil checkouts and
correctly tagging with -buildvcs (to be added in a follow up CL).

Change-Id: I3c030a0b600dfe7f4b3fcf1551b1d7cb84629b81
Reviewed-on: https://go-review.googlesource.com/c/go/+/357954
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agoruntime/testdata/testprogcgo: fix TestCgoPanicCallback
Cuong Manh Le [Wed, 27 Oct 2021 18:55:10 +0000 (01:55 +0700)]
runtime/testdata/testprogcgo: fix TestCgoPanicCallback

A cgo file with "//export" declarations is not permitted to have function
definitions in the cgo comments.

Fixes #49188

Change-Id: I5c24b62b259871473ee984cea96a0edd7d42d23a
Reviewed-on: https://go-review.googlesource.com/c/go/+/359195
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/compile, runtime: track argument stack slot liveness
Cherry Mui [Fri, 24 Sep 2021 20:46:05 +0000 (16:46 -0400)]
cmd/compile, runtime: track argument stack slot liveness

Currently, for stack traces (e.g. at panic or when runtime.Stack
is called), we print argument values from the stack. With register
ABI, we may never store the argument to stack therefore the
argument value on stack may be meaningless. This causes confusion.

This CL makes the compiler keep trace of which argument stack
slots are meaningful. If it is meaningful, it will be printed in
stack traces as before. If it may not be meaningful, it will be
printed as the stack value with a question mark ("?"). In general,
the value could be meaningful on some code paths but not others
depending on the execution, and the compiler couldn't know
statically, so we still print the stack value, instead of not
printing it at all. Also note that if the argument variable is
updated in the function body the printed value may be stale (like
before register ABI) but still considered meaningful.

Arguments passed on stack are always meaningful therefore always
printed without a question mark. Results are never printed, as
before.

(Due to a bug in the compiler we sometimes don't spill args into
their dedicated spill slots (as we should), causing it having
fewer meaningful values than it should be.)

This increases binary sizes a bit:
            old       new
hello      1129760   1142080  +1.09%
cmd/go    13932320  14088016  +1.12%
cmd/link   6267696   6329168  +0.98%

Fixes #45728.

Change-Id: I308a0402e5c5ab94ca0953f8bd85a56acd28f58c
Reviewed-on: https://go-review.googlesource.com/c/go/+/352057
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 years agocmd/compile/internal/types2: implement singleType and structure (type)
Robert Griesemer [Wed, 27 Oct 2021 00:07:32 +0000 (17:07 -0700)]
cmd/compile/internal/types2: implement singleType and structure (type)

Rename structuralType to singleType throughout. This reflects
more closely what the function does: if a type set consists of
exactly one type term, singleType returns the corresponding type.

Rename singleUnder to structure. The structure function returns
the "type structure" of a type, either its underlying type for
a non-type parameter, or the single underlying type (if it exists)
for a type parameter.

Change constraint type inference to use the structure type for
inference, unless the structure type is the underlying type of
a single defined type, in which case it uses the latter. This
preserves existing behavior while making constraint type inference
slightly more flexible.

Change-Id: I38ee89ffdabd12bfeaa0be2ad6af8fb373c11fc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/359015
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: remove unused position computation (cleanup)
Robert Griesemer [Tue, 26 Oct 2021 20:55:53 +0000 (13:55 -0700)]
cmd/compile/internal/types2: remove unused position computation (cleanup)

The position computation was needed for type list support.
With that gone, we don't need this code anymore.

Change-Id: I3f36b3d108a1fae9947fd259d4892e0287cb78ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/358701
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: rename isNamed predicate to hasName
Robert Griesemer [Tue, 26 Oct 2021 04:43:07 +0000 (21:43 -0700)]
cmd/compile/internal/types2: rename isNamed predicate to hasName

isNamed(t) is easily confused with asNamed(t) != nil (e.g., we
have isPointer(t) that is defined as asPointer(t) != nil).

This rename also helped clarifying a couple of places in the
assignability rules where it makes sense to simply look for
types that have names.

Change-Id: Ie995908613a26883ffe0562343d297a1e981e9ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/358621
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: clean up asT converters (step 2 of 2)
Robert Griesemer [Tue, 26 Oct 2021 03:54:05 +0000 (20:54 -0700)]
cmd/compile/internal/types2: clean up asT converters (step 2 of 2)

This CL renames the toT converters back to their asT names.

Change-Id: If4bda5a78525f9722f044f5544f400fa8bb6f437
Reviewed-on: https://go-review.googlesource.com/c/go/+/358774
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: clean up asT converters (step 1 of 2)
Robert Griesemer [Tue, 26 Oct 2021 00:22:55 +0000 (17:22 -0700)]
cmd/compile/internal/types2: clean up asT converters (step 1 of 2)

This CL changes the convenience converters asT to use under instead
of optype. To make sure the effect is well understood, in a first
step, all asT functions are renamed to toT so that we can see which
call sites are affected. In almost all places, the change is what we
want. In some places we may get more conservative behavior (which is
easy to relax if need be). In some places (function calls through a
type parameter, append built-in) we now use singleUnder instead, for
a more general behavior, matching other primary expressions or built-
ins.

This change removes the last use of optype and thus also theTop and
top, all of which have been deleted from the code.

The next CL renames the toT converters back to their asT form.

Change-Id: I35d1ad866ce46de175a055b36ef577d99bb9de22
Reviewed-on: https://go-review.googlesource.com/c/go/+/358597
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: generalize assignability to generic types
Robert Griesemer [Fri, 22 Oct 2021 16:49:15 +0000 (09:49 -0700)]
cmd/compile/internal/types2: generalize assignability to generic types

Similar to conversions, handle ordinary cases first, followed by
type-by-type assignability tests in case of type parameters with
specific types in their type sets.

Add a new class of type checker tests, in testdata/spec, which
I hope we can populate over time with tests following the spec
organization. Moved the conversions.go2 tests in the same dir.

Change-Id: Iac253ae375c08022bdc39e92e3951ec3f509e432
Reviewed-on: https://go-review.googlesource.com/c/go/+/357917
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: clarify is/underIs semantics and implementation
Robert Griesemer [Mon, 25 Oct 2021 16:13:16 +0000 (09:13 -0700)]
cmd/compile/internal/types2: clarify is/underIs semantics and implementation

The behavior of is/underIs was murky with the presence of a top type term
(corresponding to a type set that is not constrained by any types, yet the
function argument f of is/underIs was called with that term).

Change is/underIs to call f explicitly for existing specific type terms,
otherwise return the result of f(nil). Review all uses of is/underIs and
variants.

This makes the conversion code slightly more complicated because we need
to explicitly exclude type parameters without specific types; but the
code is clearer now.

Change-Id: I6115cb46f7f2a8d0f54799aafff9a67c4cca5e30
Reviewed-on: https://go-review.googlesource.com/c/go/+/358594
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/go: remove support for -buildmode=shared
Bryan C. Mills [Wed, 27 Oct 2021 18:29:29 +0000 (14:29 -0400)]
cmd/go: remove support for -buildmode=shared

It never worked in module mode (or with a read-only GOROOT).
A proposal to drop it was filed (and approved) in
https://golang.org/issue/47788.

Fixes #47788

Change-Id: I0c12f38eb0c5dfe9384fbdb49ed202301fa4273d
Reviewed-on: https://go-review.googlesource.com/c/go/+/359096
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/go: fix testdata/script/mod_vendor_goversion for new compiler output
Russ Cox [Wed, 27 Oct 2021 19:06:23 +0000 (15:06 -0400)]
cmd/go: fix testdata/script/mod_vendor_goversion for new compiler output

The message is now a single line, but I couldn't get '\n?' to work.

(This test does not run in short mode.)

Change-Id: I3d7033f78ac2bf41db7fdfe96cbb988c4533d834
Reviewed-on: https://go-review.googlesource.com/c/go/+/359095
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agointernal/fuzz: don't deflake coverage found while fuzzing
Katie Hockman [Fri, 22 Oct 2021 19:59:15 +0000 (15:59 -0400)]
internal/fuzz: don't deflake coverage found while fuzzing

Previously, the worker would attempt to deflake
an input that was reported to have caused new
coverage. The chances of a flake causing new
coverage seem pretty low to me, and even if it
was a flake that caused it, adding that input to
the cache doesn't seem like a bad thing. The
input is already going to be deflaked during
minimization anyway. If by some off-chance the
code is causing a lot of flaky coverage
increases, and the user doesn't want minimization
to occur, then setting -fuzzminimizetime=1x will
deflake in the way they want without minimizing.
This can be documented as needed.

This fixes a bug where the mem.header().count
could have been one too large if an unrecoverable
crash occured while deflaking an input that
caused code coverage.

Fixes #49047

Change-Id: Ibdf893d7a89a46dd700702afb09e35623615390e
Reviewed-on: https://go-review.googlesource.com/c/go/+/358094
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/compile: enable branchelim pass on ppc64
Paul E. Murphy [Tue, 24 Aug 2021 19:09:26 +0000 (14:09 -0500)]
cmd/compile: enable branchelim pass on ppc64

and fix/cleanup lowering of the SSA operator created by the pass.

Change-Id: I7e6153194fd16013e3b24da8aa40683adafa3d15
Reviewed-on: https://go-review.googlesource.com/c/go/+/344573
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>

3 years agocmd/compile/internal/syntax: fix constraint literal parsing for generic functions
Robert Griesemer [Wed, 27 Oct 2021 04:12:31 +0000 (21:12 -0700)]
cmd/compile/internal/syntax: fix constraint literal parsing for generic functions

Fixes #49174.

Change-Id: I943c370f7abd5f50a541e682f130b3526c3b5bdb
Reviewed-on: https://go-review.googlesource.com/c/go/+/359014
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agogo/types: remove a stale comment
Robert Findley [Mon, 25 Oct 2021 17:26:54 +0000 (13:26 -0400)]
go/types: remove a stale comment

Clean up a comment that was deleted in types2 in CL 353135.

Change-Id: If339efa133e2a3d1eaa3b1e69458471677018261
Reviewed-on: https://go-review.googlesource.com/c/go/+/358517
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agocmd: move internal/str back to cmd/go
Russ Cox [Mon, 11 Oct 2021 15:57:24 +0000 (11:57 -0400)]
cmd: move internal/str back to cmd/go

cmd/go is not subject to all the same restrictions as most of cmd.
In particular it need not be buildable with the bootstrap toolchain.
So it is better to keep as little code shared between cmd/go and
cmd/compile, cmd/link, cmd/cgo as possible.

cmd/internal/str started as cmd/go/internal/str but was moved
to cmd/internal in order to make use of the quoted string code.
Move that code to cmd/internal/quoted and then move the rest of
cmd/internal/str back to cmd/go/internal/str.

Change-Id: I3a98f754d545cc3af7e9a32c2b77a5a035ea7b9a
Reviewed-on: https://go-review.googlesource.com/c/go/+/355010
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/go: add darwin/arm64 in the list of supported systems in help message
Cholerae Hu [Wed, 27 Oct 2021 03:41:47 +0000 (11:41 +0800)]
cmd/go: add darwin/arm64 in the list of supported systems in help message

Fixes #49173.

Change-Id: I71270b4ff7e9ede3cdfa5946b73142a731752adf
Reviewed-on: https://go-review.googlesource.com/c/go/+/358901
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agointernal/poll: improve the padding calculation inside struct splicePipe
Andy Pan [Tue, 26 Oct 2021 01:15:17 +0000 (09:15 +0800)]
internal/poll: improve the padding calculation inside struct splicePipe

Updates #48968 and CL 358114

Change-Id: Ic68b4c5420c1c32f78b56874b53d717fa9af1f74
Reviewed-on: https://go-review.googlesource.com/c/go/+/358734
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>

3 years agosyscall: use dup3 in forkAndExecInChild on NetBSD
Tobias Klauser [Tue, 26 Oct 2021 07:13:16 +0000 (09:13 +0200)]
syscall: use dup3 in forkAndExecInChild on NetBSD

Use dup3(oldfd, newfd, O_CLOEXEC) to atomically duplicate the file
descriptor and mark is as close-on-exec instead of dup2 & fcntl.

The dup3 syscall was added in NetBSD 6.0.

Change-Id: I01a4f8c62bfa8fb7f9f3166070380dd2002bb564
Reviewed-on: https://go-review.googlesource.com/c/go/+/358755
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/compile: fix generic type handling when crawling inline body
Cuong Manh Le [Mon, 25 Oct 2021 07:16:53 +0000 (14:16 +0700)]
cmd/compile: fix generic type handling when crawling inline body

For base generic type that is written to export file, we need to mark
all of its methods, include exported+unexported methods, as reachable,
so they can be available for instantiation if necessary. But markType
only looks for exported methods, thus causing the crash in #49143.

To fix this, we introduce new method p.markGeneric, to mark all methods
of the base generic type.

This issue has happend for a while (maybe since we add generic
import/export during go1.18 cycle), and was un-intentionally "fixed" in
CL 356254, when we agresssively call p.markEmbed(t). CL 357232 fixed
that wrong agressive behavior, thus reproduce the bug on tip.

Fixes #49143

Change-Id: Ie64574a05fffb282e9dcc8739df4378c5b6b0468
Reviewed-on: https://go-review.googlesource.com/c/go/+/358814
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
3 years agoembed/internal/embedtest: use parenthesized vars for one test
Ian Lance Taylor [Tue, 26 Oct 2021 16:01:34 +0000 (09:01 -0700)]
embed/internal/embedtest: use parenthesized vars for one test

The gofrontend code mishandled this case, so add it to the test.

Change-Id: I183b8fab57552320b04c4826c590b7c6d36b6548
Reviewed-on: https://go-review.googlesource.com/c/go/+/358836
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>
3 years agocrypto/elliptic: use a const string for precomputed P256 table
Josh Bleecher Snyder [Wed, 28 Jul 2021 18:59:01 +0000 (11:59 -0700)]
crypto/elliptic: use a const string for precomputed P256 table

Const strings can be marked readonly. This is particularly
important for this relatively large table (88kb).
This is a follow-up to CL 315189.

The generation script is a bit awkward. It needs access to crypto/elliptic
internals, but also needs to be package main. Work around this by
exporting those internals with the "tablegen" build tag.

This requires changing the function signature at the Go-asm bridge.
As long as we're here, shrink the point argument type as well;
the net result is three fewer words of params.

Performance impact is probably noise.

name                   old time/op    new time/op    delta
ScalarBaseMult/P256-8    11.4µs ± 2%    11.3µs ± 1%  -1.32%  (p=0.000 n=19+16)
ScalarBaseMult/P224-8     579µs ± 1%     577µs ± 0%  -0.30%  (p=0.024 n=19+20)
ScalarBaseMult/P384-8    2.31ms ± 4%    2.34ms ± 4%  +1.25%  (p=0.033 n=20+20)
ScalarBaseMult/P521-8    1.33ms ± 0%    1.33ms ± 1%    ~     (p=0.173 n=18+17)
ScalarMult/P256-8        42.7µs ± 0%    42.7µs ± 2%    ~     (p=0.989 n=20+20)
ScalarMult/P224-8         579µs ± 0%     579µs ± 0%    ~     (p=0.538 n=19+18)
ScalarMult/P384-8        2.32ms ± 3%    2.34ms ± 5%    ~     (p=0.235 n=19+20)
ScalarMult/P521-8        1.33ms ± 1%    1.34ms ± 2%    ~     (p=0.141 n=17+20)

Change-Id: I3bee56df34ae61ca8829791d2e67e058ecc8ddbe
Reviewed-on: https://go-review.googlesource.com/c/go/+/339591
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocrypto/x509: generate new-style build tags for iOS
Josh Bleecher Snyder [Tue, 26 Oct 2021 21:47:07 +0000 (14:47 -0700)]
crypto/x509: generate new-style build tags for iOS

Make the input match gofmt's output,
to make our lives easier as we phase out
old style build tags.

Change-Id: I95dc5a77058bf17cb02e289703f60784616db006
Reviewed-on: https://go-review.googlesource.com/c/go/+/358934
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agoruntime: handle async fatal signals in VDSO
Michael Pratt [Wed, 4 Aug 2021 21:33:50 +0000 (17:33 -0400)]
runtime: handle async fatal signals in VDSO

If we receive an async signal while running in the VDSO, such as a
SIGABRT or SIGSEGV sent from another process, we fail to print the
stacktrace with "runtime: unknown pc <vdso PC>".

We already have machinery to handle SIGPROF in the VDSO, but it isn't
hooked up for other signals. Add it to the general signal traceback
path.

This case is covered by TestSegv by making the test more strict w.r.t.
accepted output.

Fixes #47537

Change-Id: I755585f70e0c23e207e135bc6bd2aa68298e5d24
Reviewed-on: https://go-review.googlesource.com/c/go/+/339990
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agoruntime: fix cgo signals detection
Michael Pratt [Wed, 4 Aug 2021 15:24:28 +0000 (11:24 -0400)]
runtime: fix cgo signals detection

CL 64070 removed lockOSThread from the cgocall path, but didn't update
the signal-in-cgo detection in sighandler. As a result, signals that
arrive during a cgo call are treated like they arrived during Go
execution, breaking the traceback.

Update the cgo detection to fix the backtrace.

Fixes #47522

Change-Id: I61d77ba6465f55e3e6187246d79675ba8467ec23
Reviewed-on: https://go-review.googlesource.com/c/go/+/339989
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
3 years agosync/atomic: use a better first-store-in-progress marker
Keith Randall [Thu, 9 Jul 2020 16:13:34 +0000 (09:13 -0700)]
sync/atomic: use a better first-store-in-progress marker

Unlike what the comment says, the GC can see this pointer.
Might as well make it a real pointer, even though ^uintptr(0)
isn't currently causing problems.

Removed the comment about GC not seeing the pointer.

Change-Id: I04bc1fd4848698bec6afb79bd5fda671dfc9a073
Reviewed-on: https://go-review.googlesource.com/c/go/+/241661
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Colin Arnott <colin@urandom.co.uk>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Keith Randall <khr@golang.org>

3 years agoruntime: rename _m_ to mp [generated]
Michael Pratt [Thu, 1 Apr 2021 21:01:51 +0000 (17:01 -0400)]
runtime: rename _m_ to mp [generated]

_g_, _p_, and _m_ are primarily vestiges of the C version of the
runtime, while today we prefer Go-style variable names (generally gp,
pp, and mp).

This change replaces all remaining uses of _m_ with mp. There are very
few remaining and all replacements are trivial.

[git-generate]
cd src/runtime

rf 'mv canpanic._m_ canpanic.mp'
GOOS=solaris \
  rf 'mv semasleep._m_ semasleep.mp'
GOOS=aix GOARCH=ppc64 \
  rf 'mv semasleep._m_ semasleep.mp'

Change-Id: I83690f7b4d4dc57557963100e9a2560ff343f3e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/307813
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 years agocmd/compile: clean up the switch statements in (*genInst).node()
Dan Scales [Tue, 19 Oct 2021 01:11:48 +0000 (18:11 -0700)]
cmd/compile: clean up the switch statements in (*genInst).node()

There were two main outer switch statements in node() that can just be
combined. Also, for simplicity, changed an IsCmp() conditional into just
another case in the switch statement.

Also, the inner OCALL switch statement had a bunch of fairly duplicate
cases. Combined the cases that all had no special semantics, into a
single default case calling transformCall().

In the OCALL case in dictPass(), got rid of a check for OFUNCINST (which
will always have been removed by this point). Also, eliminated an assert
that could cause unneded failures. transformCall() should always be
called if the node op is still OCALL, so no need to assert on the ops of
call.X.

Added an extra test in issue47078.go, to explicitly check for case where
the X argument of a call is a DOTTYPE.

Change-Id: Ifb3f812ce12820a4ce08afe2887f00f7fc00cd2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/358596
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agointernal/fuzz: tiny refactor+fix
Katie Hockman [Fri, 22 Oct 2021 15:37:28 +0000 (11:37 -0400)]
internal/fuzz: tiny refactor+fix

Change-Id: I8db9c31ead3e5905b7f9d1faed36555e8aaa00cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/358054
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/go: stamp VCS commit time into binaries
Mark Pulford [Sat, 16 Oct 2021 06:53:31 +0000 (17:53 +1100)]
cmd/go: stamp VCS commit time into binaries

Only Git and Mercurial are supported for now.

This CL also:
- Skips tagging "revision" and "committime" for empty repositories.
- Stores the full Mercurial changeset ID instead of the short form.

Fixes #37475

Change-Id: I62ab7a986d1ddb2a0e7166a6404b5aa80c2ee387
Reviewed-on: https://go-review.googlesource.com/c/go/+/356251
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/compile/internal/typecheck: update doc for the 1.18 export format
Robert Findley [Tue, 26 Oct 2021 13:47:18 +0000 (09:47 -0400)]
cmd/compile/internal/typecheck: update doc for the 1.18 export format

Update the documentation in iexport.go to use the word 'Constraint'
rather than 'Bound', and to account for recent changes to the export
format.

Change-Id: I83fbcd336d5f865af804bc8bef4f5d997cd9f325
Reviewed-on: https://go-review.googlesource.com/c/go/+/358547
Trust: Robert Findley <rfindley@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
3 years agoall: use reflect.{Pointer,PointerTo}
Cuong Manh Le [Mon, 25 Oct 2021 16:00:56 +0000 (23:00 +0700)]
all: use reflect.{Pointer,PointerTo}

Updates #47651
Updates #48665

Change-Id: I69a87b45a5cad7a07fbd855040cd9935cf874554
Reviewed-on: https://go-review.googlesource.com/c/go/+/358454
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
3 years agoall: update vendored golang.org/x/tools
Dmitri Shuralyov [Tue, 26 Oct 2021 04:27:27 +0000 (00:27 -0400)]
all: update vendored golang.org/x/tools

Pull in CL 358034 (and some more changes with passing tests) with:

go get -d golang.org/x/tools@f916b54
go mod tidy
go mod vendor

This teaches x/tools/cmd/bundle and the package loader it uses about
the new export data version.

Fixes #49159.

Change-Id: Icc36e77e602b1cd2da03708f20d05a66fcf693cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/358620
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/internal/obj/ppc64: fix usage of CR bit arguments
Paul E. Murphy [Tue, 10 Aug 2021 14:50:56 +0000 (09:50 -0500)]
cmd/internal/obj/ppc64: fix usage of CR bit arguments

CR bits and CR fields should be treated separately. Some instructions
modify an entire CR, a CR field, or a single CR bit.

Add a new argument class for CR bits, and teach the assembler the
recognize them as names like CR0LT or CR2SO, and update the CR
bit logic instructions to use them. They will no longer accept
register field (CRn) type arguments.

Fixes #46422
Change-Id: Iaba127d88abada0c2a49b8d3b07a976180565ae4
Reviewed-on: https://go-review.googlesource.com/c/go/+/357774
Run-TryBot: Paul Murphy <murp@ibm.com>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agosyscall: add utimensat libc wrapper on darwin
Tobias Klauser [Mon, 25 Oct 2021 05:48:12 +0000 (07:48 +0200)]
syscall: add utimensat libc wrapper on darwin

Add utimensat as a wrapper around the libc function of the same name.
utimensat was added in macOS 10.13 which is the minimum supported
release since Go 1.17 dropped support for macOS 10.12.

This also allows to drop the fallback to setattrlistTimes which was
used to set timestamps with nanosecond resolution before utimensat could
be used, see #22528 and CL 74952.

Updates #22528

Change-Id: I87b6a76acf1d642ceede9254f7d9d06dddc3fd71
Reviewed-on: https://go-review.googlesource.com/c/go/+/358274
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agosyscall: use fcntl F_DUP2FD_CLOEXEC in forkAndExecInChild on illumos
Tobias Klauser [Mon, 25 Oct 2021 11:37:29 +0000 (13:37 +0200)]
syscall: use fcntl F_DUP2FD_CLOEXEC in forkAndExecInChild on illumos

Use fcntl(oldfd, F_DUP2FD_CLOEXEC, newfd) to duplicate the file
descriptor and mark is as close-on-exec instead of dup2 & fcntl.

Illumos implements dup3 like this in libc.

Change-Id: I9782bce553ffb832e9b1a12bbf3c0a40c821f56e
Reviewed-on: https://go-review.googlesource.com/c/go/+/358374
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agoruntime, runtime/asan: add asan runtime support
fanzha02 [Mon, 4 Jan 2021 09:53:37 +0000 (17:53 +0800)]
runtime, runtime/asan: add asan runtime support

These are the runtime support functions for letting Go code interoperate
with the C/C++ address sanitizer. Calls to asanread/asanwrite are now
inserted by the compiler with the -asan option.  Calls to
asanunpoison/asanpoison will be from other runtime functions in a
subsequent CL.

Updates #44853.

Change-Id: I9e8fc0ce937828bc7f4a8b6637453ddc3862c47b
Reviewed-on: https://go-review.googlesource.com/c/go/+/298613
Trust: fannie zhang <Fannie.Zhang@arm.com>
Run-TryBot: fannie zhang <Fannie.Zhang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/go: add -asan option
Fannie Zhang [Wed, 6 Jan 2021 08:57:44 +0000 (08:57 +0000)]
cmd/go: add -asan option

The -asan option compiles Go code to use the address sanitizer.  This is
intended for use when linking with C/C++ code compiled with -fsanitize=address.
When memory blocks are passed back and forth between C/C++ and Go, code in
both languages will agree as to whether the memory is validly allocated or not,
and will report errors for any use of invalid memory.

Updates #44853.

Change-Id: I0209002ef795cc1c823daae557fb80c906158db3
Reviewed-on: https://go-review.googlesource.com/c/go/+/298612
Trust: fannie zhang <Fannie.Zhang@arm.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/internal/obj/arm64: add a restriction on move constant instructions
fanzha02 [Wed, 17 Mar 2021 06:52:27 +0000 (14:52 +0800)]
cmd/internal/obj/arm64: add a restriction on move constant instructions

For MOVK/MOVN/MOVZ instructions, the assembler does not accept zero
shifts, and the CL 275812 added the error check. This CL adds this
restriction to the document.

Change-Id: I8818d76ca2f11dade2307f3678ca521f4e64d164
Reviewed-on: https://go-review.googlesource.com/c/go/+/312210
Trust: fannie zhang <Fannie.Zhang@arm.com>
Run-TryBot: fannie zhang <Fannie.Zhang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agodoc/go1.18.html: fix a typo
gosoon [Wed, 20 Oct 2021 11:13:29 +0000 (11:13 +0000)]
doc/go1.18.html: fix a typo

gofmt -> <code>gofmt</code>

Change-Id: Idc01b01d8eb185f5e378000d11d622935b14db6e
GitHub-Last-Rev: 8d55dc7b86ce0f7dfbdbd57c349b4c472eccf907
GitHub-Pull-Request: golang/go#49084
Reviewed-on: https://go-review.googlesource.com/c/go/+/357251
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>

3 years agocontainer/list: remove unnecessary code
Gusted [Mon, 25 Oct 2021 23:45:44 +0000 (01:45 +0200)]
container/list: remove unnecessary code

Remove a unnecessary statement in the test function, the variables
aren't checked afterwards. Also remove return statements in helper
functions and remove the declaration that a the helper function return a
value. The return value isn't used in the current state of code

Change-Id: I5bc384104c1002c4138e0894938778ae9710ce4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/358714
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>

3 years agocmd/internal/obj/riscv: don't split ADD to SP to two adds
Cherry Mui [Mon, 25 Oct 2021 16:18:40 +0000 (12:18 -0400)]
cmd/internal/obj/riscv: don't split ADD to SP to two adds

When adding a large constant to a register we generate two adds,
we may generate two ADD instructions if the constant does not fit
in one ADD but does fit in two. This is generally fine except that
if the target register is SP (such as in function prologues or
epilogues for functions with large frames), this creates an
intermediate state that the SP is not 0 nor the full frame size.
For signal safety (preemption signal and profiling signal) we
require that the frame is either not created at all or fully
created, meaning that the SP must be written in a single
instruction. Splitting to two adds breaks the requirement. So not
splitting it.

(We could mark such instructions not async-preemptible. But
profiling signal can still cause problems.)

(We could generate "ADD $c1, SP, Rtmp; ADD $c2; Rtmp; SP" to save
an instruction if that is desired, while still ensuring that SP
is written in a single instruction.)

May fix flaky failures like https://build.golang.org/log/11537ec020a902b0ec0fc065f61161b729eb9880

Change-Id: I5cf38a6a028afe01aa3b6eeb163487bbd504b64f
Reviewed-on: https://go-review.googlesource.com/c/go/+/358436
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/compile: update the export version for generics
Dan Scales [Tue, 19 Oct 2021 20:28:54 +0000 (13:28 -0700)]
cmd/compile:  update the export version for generics

Bump the export version to a new value iexportVersionGo1_18 (2). This
will give a better error message when old compilers/tools encounter the
new export format (that includes parameterized types and functions).

We are also making a breaking change in the format:
 - a 'kind' byte is added to constant values

Also updated tinter() to pass the implicit bit through during type
substitution.

Tested that all tests still pass if the iexportVersionCurrent is changed
back to 1 in typecheck/iexport.go, iimporter/iimport.go, and
gcimporter/iimport.go

Updates #47654

Change-Id: I1dbeb167a97f6c7e0b7e0c011d6bada5db312b36
Reviewed-on: https://go-review.googlesource.com/c/go/+/357049
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Dan Scales <danscales@google.com>

3 years agocmd/compile: add -asan option
fanzha02 [Mon, 4 Jan 2021 09:14:35 +0000 (17:14 +0800)]
cmd/compile: add -asan option

The -asan option causes the compiler to add instrumentation for the
C/C++ address sanitizer.  Every memory read/write will be replaced
by a call to asanread/asanwrite.

This CL also inserts asan instrumentation during SSA building.

This CL passes tests but is not usable by itself. The actual
implementation of asanread/asanwrite in the runtime package, and
support for -asan in the go tool and tests, will follow in subsequent
CLs.

Updates #44853.

Change-Id: Ia18c9c5d5c351857420d2f6835f0daec2ad31096
Reviewed-on: https://go-review.googlesource.com/c/go/+/298611
Trust: fannie zhang <Fannie.Zhang@arm.com>
Run-TryBot: fannie zhang <Fannie.Zhang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agointernal/poll: avoid tiny allocator for splicePipe
Ian Lance Taylor [Fri, 22 Oct 2021 21:19:34 +0000 (14:19 -0700)]
internal/poll: avoid tiny allocator for splicePipe

We want to set a finalizer on splicePipe, so make it large enough to
not use the tiny allocator. Otherwise the finalizer will not run until
the rest of the tiny allocation can be freed. This only matters on
32-bit systems.

Fixes #48968

Change-Id: I8eb3c9f48fdccab7dc79c5b918d4257b6151ee91
Reviewed-on: https://go-review.googlesource.com/c/go/+/358114
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/compile: fix typo in comment in CL 358435
Cherry Mui [Mon, 25 Oct 2021 20:48:07 +0000 (16:48 -0400)]
cmd/compile: fix typo in comment in CL 358435

Change-Id: I0d8128668fc7a80b29aabc58dbc9a2929b889ec9
Reviewed-on: https://go-review.googlesource.com/c/go/+/358614
Trust: Cherry Mui <cherryyz@google.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
3 years agocmd/link: escape % characters in symbols when reporting errors
Keith Randall [Fri, 22 Oct 2021 01:28:50 +0000 (18:28 -0700)]
cmd/link: escape % characters in symbols when reporting errors

Generic function symbols sometimes have % in them, like:

    main.B2[%2eshape.string_0].m2·f

Which confuses this code because it doesn't esacpe % when
using this string as a format string, instead of a format argument.

Or could we get rid of the . -> %2e rewrite somehow?
I think it comes from LinkString.

Change-Id: I3275501f44cf30485e9d4577e0dfa77996d4939e
Reviewed-on: https://go-review.googlesource.com/c/go/+/357837
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
3 years agocmd/compile: revert most of CL 349169
Keith Randall [Fri, 22 Oct 2021 01:09:07 +0000 (18:09 -0700)]
cmd/compile: revert most of CL 349169

The method of using references to dictionaries to hold methods
live during linker deadcode elimination wasn't working very well.
I implemented a new scheme in the CL below this, so this CL strips
out the old method.

The new method has the added benefit of having 0 runtime overhead
(unlike the stuff we're ripping out here, which does have a small overhead).

Update #48047

Change-Id: I68ac57119792d53c58f1480f407de6ab2bb53211
Reviewed-on: https://go-review.googlesource.com/c/go/+/357836
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
3 years agocmd/compile: remove MarkUsedIfaceMethodIndex mechanism
Keith Randall [Fri, 22 Oct 2021 02:15:24 +0000 (19:15 -0700)]
cmd/compile: remove MarkUsedIfaceMethodIndex mechanism

We don't need it any more, after CL 357835.

Change-Id: I1ff5f24b5540c3e80c4b35be8215a1c378952274
Reviewed-on: https://go-review.googlesource.com/c/go/+/357894
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
3 years agocmd/compile,cmd/link: introduce generic interface call relocations
Keith Randall [Fri, 22 Oct 2021 01:04:55 +0000 (18:04 -0700)]
cmd/compile,cmd/link: introduce generic interface call relocations

To capture the fact that a method was called on a generic interface,
so we can make sure the linker doesn't throw away any implementations
that might be the method called.

See the comment in reflect.go for details.

Fixes #49049

Change-Id: I0be74b6e727c1ecefedae072b149f59d539dc1e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/357835
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
3 years agocmd/link: increase reserved space for passing env on wasm
Richard Musiol [Sun, 24 Oct 2021 10:28:18 +0000 (12:28 +0200)]
cmd/link: increase reserved space for passing env on wasm

On wasm, the wasm_exec.js helper passes the command line arguments and
environment variables via a reserved space in the wasm linear memory.
Increase this reserved space from 4096 to 8192 bytes so more environment
variables can fit into the limit.

Later, after https://golang.org/cl/350737 landed, we can switch to the
WASI interface for getting the arguments and environment. This would
remove the limit entirely.

Fixes #49011

Change-Id: I48a6e952a97d33404ed692c98e9b49c5cd6b269b
Reviewed-on: https://go-review.googlesource.com/c/go/+/358194
Trust: Richard Musiol <neelance@gmail.com>
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/go/testdata/script: fix flaky test_fuzz_fuzztime test
Katie Hockman [Fri, 22 Oct 2021 15:56:23 +0000 (11:56 -0400)]
cmd/go/testdata/script: fix flaky test_fuzz_fuzztime test

Previously, the test would panic if the short timeout
was reached before fuzzing began. Increasing the
timeout should stop this test from being flaky.

Fixes #49046

Change-Id: Iaa0b3b3e8ea29d9a42ab5fc1c801fc73fffe1675
Reviewed-on: https://go-review.googlesource.com/c/go/+/358055
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocrypto/tls: add Conn.NetConn method
Agniva De Sarker [Sat, 5 Jun 2021 05:34:37 +0000 (11:04 +0530)]
crypto/tls: add Conn.NetConn method

NetConn method gives us access to the underlying net.Conn
value.

Fixes #29257

Change-Id: I68b2a92ed9dab4be9900807c94184f8c0aeb4f72
Reviewed-on: https://go-review.googlesource.com/c/go/+/325250
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Trust: Agniva De Sarker <agniva.quicksilver@gmail.com>
Trust: Katie Hockman <katie@golang.org>

3 years agocmd/compile: don't clobber LR for tail calls
Cherry Mui [Mon, 25 Oct 2021 15:51:25 +0000 (11:51 -0400)]
cmd/compile: don't clobber LR for tail calls

When doing a tail call the link register is live as the callee
will directly return to the caller (of the function that does the
tail call). Don't allocate or clobber the link register.

Fixes #49032.

Change-Id: I2d60f2354e5b6c14aa285c8983a9786687b90223
Reviewed-on: https://go-review.googlesource.com/c/go/+/358435
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/compile: use SetInit instead of *PtrInit
wdvxdr [Mon, 25 Oct 2021 10:15:43 +0000 (18:15 +0800)]
cmd/compile: use SetInit instead of *PtrInit

Change-Id: Ie802ff27b611ed248d7b14f6e972e6300c181f43
Reviewed-on: https://go-review.googlesource.com/c/go/+/358316
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
3 years agocmd/compile/internal/typecheck: record whether an interface is implicit
Robert Findley [Tue, 19 Oct 2021 22:40:27 +0000 (18:40 -0400)]
cmd/compile/internal/typecheck: record whether an interface is implicit

In preparation for capturing the implicit interface bit in export data,
thread through the IsImplicit property from types2 into typecheck.

Change-Id: I9b46fe73de102935a127e6ececaacd76738b557e
Reviewed-on: https://go-review.googlesource.com/c/go/+/357109
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
3 years agogo/types: remove subscripts from type parameter names
Robert Findley [Thu, 21 Oct 2021 22:36:14 +0000 (18:36 -0400)]
go/types: remove subscripts from type parameter names

Now that we've removed the necessity for subscripts in importers, we can
effectively eliminate them from the the type parameter API by removing
them from the type string.

Change-Id: Ic4491b0dea27b0e0ce2d0636dccfaf05168ef9e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/357814
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agonet/http: correct Content-Length parsing for js/wasm
Charlotte Brandhorst-Satzkorn [Sat, 23 Oct 2021 02:46:46 +0000 (22:46 -0400)]
net/http: correct Content-Length parsing for js/wasm

The Content-Length was incorrectly set to 0 for ill-formed and invalid
values. In these cases, return an error.

If the Content-Length header was omitted, it was incorrectly set to 0.
In this case, set the Content-Length value to -1.

Fixes #49108

Change-Id: I24fe9a31ed5b6ddb53f2b2bd10f2c84e428823e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/358134
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Trust: David Crawshaw <crawshaw@golang.org>

3 years agocmd/compile: fix inlining labeled switch statements
wdvxdr [Mon, 25 Oct 2021 09:54:11 +0000 (17:54 +0800)]
cmd/compile: fix inlining labeled switch statements

CL 357649 fixes inlining labeled FOR/RANGE loops,
we should do same translation for inlined SWITCH's label

Fixes #49145

Change-Id: I9a6f365f57e974271a1eb279b38e81f9b5148788
Reviewed-on: https://go-review.googlesource.com/c/go/+/358315
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
3 years agotesting: skip extra -count iterations if there are no tests
Michael Pratt [Mon, 18 Oct 2021 22:34:24 +0000 (18:34 -0400)]
testing: skip extra -count iterations if there are no tests

When running benchmarks with high -count and no tests (either at all or
filtered with -run), the time for runTests to check for tests -count
times can add a significant delay to starting benchmarks.

To avoid this delay, make runTests bail out on the second iteration if
the first found no tests to run. We expect the same tests to run every
time, so there is no reason to duplicate work.

One caveat: the testing docs do not explicitly require the same subtests
to be run on every call, so this could break tests that depend on
multiple runs to actually run all tests. I consider such tests invalid,
but some may exist.

Fixes #49050

Change-Id: I7b34f3832b31493cc089ee0555e231f4dc690154
Reviewed-on: https://go-review.googlesource.com/c/go/+/356669
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile/internal/types2: better error messages for empty type sets
Robert Griesemer [Sat, 23 Oct 2021 23:39:32 +0000 (16:39 -0700)]
cmd/compile/internal/types2: better error messages for empty type sets

- change _TypeSet.hasTerms() to report if a type set has actual types
  (excluding a "universe" term)
- handle empty type set type arguments correctly
- bring comments up-to-date in Checker.satisfies

Change-Id: I87f9a1096ebb21a1b08c87a9b59f400f3bc2f040
Reviewed-on: https://go-review.googlesource.com/c/go/+/358175
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agotesting: reference benchmark format spec
Austin Clements [Thu, 21 Oct 2021 15:11:13 +0000 (11:11 -0400)]
testing: reference benchmark format spec

This updates the testing package documentation to reference the
specification for the benchmark format, and points users to our
standard tools for working with benchmark data. (It's somewhat
remarkable how widely used benchstat appears to be given that we don't
mention it anywhere!)

Change-Id: Idbb4416d2fde9606ea7e6c15595f3b9e6a38f3b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/357589
Trust: Austin Clements <austin@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agoimage/draw: improve performances if mask is *image.Alpha
Olivier Wulveryck [Mon, 31 May 2021 06:03:57 +0000 (08:03 +0200)]
image/draw: improve performances if mask is *image.Alpha

The existing DrawMask method is generic and is therefore calling the At().RGBA() method for every pixel of the mask and the source.
Do a specific implementation when the mask is *image.Alpha (which is
common) and use use the PixOffset method to increase performances.

name                old time/op  new time/op  delta
RGBA2-12            1.60ms ± 0%  1.13ms ± 1%  -29.16%  (p=0.008 n=5+5)
GenericMaskOver-12   915µs ± 4%   926µs ± 1%     ~     (p=0.190 n=5+4)
RGBA64Over-12       1.53ms ± 3%  1.21ms ± 2%  -20.74%  (p=0.008 n=5+5)
GrayOver-12         1.36ms ± 2%  1.01ms ± 7%  -26.27%  (p=0.008 n=5+5)

Fixes: #46395
Change-Id: Iaeaa8cfcc6a3fe93eb19b361f3bf076e41cac5b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/323749
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Trust: Nigel Tao <nigeltao@golang.org>
Trust: Andrew Gerrand <adg@golang.org>
Run-TryBot: Nigel Tao <nigeltao@golang.org>

3 years agocmd/compile: factor out code to remove phi argument
Cuong Manh Le [Sun, 24 Oct 2021 06:46:54 +0000 (13:46 +0700)]
cmd/compile: factor out code to remove phi argument

CL 358117 fixed a bug that Phi's argument wasn't updated correctly after
removing a predecessor of Block. This CL factor out the code that
updates phi argument into a Block's method, so it's easier to use,
maintain and hopefully prevent that kind of bug in the future.

Change-Id: Ie9741e19ea28f56860425089b6093a381aa10f5b
Reviewed-on: https://go-review.googlesource.com/c/go/+/357964
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agocmd/compile: remove Value.RemoveArg
Cuong Manh Le [Sun, 24 Oct 2021 18:02:12 +0000 (01:02 +0700)]
cmd/compile: remove Value.RemoveArg

It's only used in two places:

 - The one in regalloc.go can be replaced with v.resetArgs()
 - The one in rewrite.go can be open coded

and can cause wrong usage like the bug that CL 358117 fixed.

Change-Id: I125baf237db159d056fe4b1c73072331eea4d06a
Reviewed-on: https://go-review.googlesource.com/c/go/+/357965
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agocmd/compile: fix fuse pass to do CFG surgery correctly
Keith Randall [Sat, 23 Oct 2021 17:16:41 +0000 (10:16 -0700)]
cmd/compile: fix fuse pass to do CFG surgery correctly

removePred and removeArg do different things. removePred moves the last
predecessor to index k, whereas removeArg slides all the args k or
greater down by 1 index.

Kind of unfortunate different behavior in things named similarly.

Fixes #49122

Change-Id: I9ae409bdac744e713f4c121f948e43db6fdc8542
Reviewed-on: https://go-review.googlesource.com/c/go/+/358117
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
3 years agocmd/compile/internal/types2: comp literals to accept type sets with single underlying...
Robert Griesemer [Fri, 22 Oct 2021 03:01:51 +0000 (20:01 -0700)]
cmd/compile/internal/types2: comp literals to accept type sets with single underlying types

Change-Id: Ib51bcdf023910d244739ec176880a16e700851e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/357915
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: slice exprs to accept type sets with single underlying...
Robert Griesemer [Thu, 21 Oct 2021 23:17:07 +0000 (16:17 -0700)]
cmd/compile/internal/types2: slice exprs to accept type sets with single underlying types

Change-Id: Ib9bd08ab6153129aaf8b77b41fc6ea302d0c1589
Reviewed-on: https://go-review.googlesource.com/c/go/+/357779
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: range clause to accept type sets with single underlying...
Robert Griesemer [Thu, 21 Oct 2021 22:56:08 +0000 (15:56 -0700)]
cmd/compile/internal/types2: range clause to accept type sets with single underlying types

This generalizes range clauses. Removed some dead code and cleaned
up the surrounding bits.

Change-Id: Icd8384205afa3f52b7e7df9abed5de2bb556861d
Reviewed-on: https://go-review.googlesource.com/c/go/+/357778
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: make built-in to accept type sets with single underlying...
Robert Griesemer [Thu, 21 Oct 2021 20:29:00 +0000 (13:29 -0700)]
cmd/compile/internal/types2: make built-in to accept type sets with single underlying types

This generalizes make the same way copy was generalized and eliminates
a use of optype.

Change-Id: I8221abd53d77dde8ead47c0075c13fd2a3221642
Reviewed-on: https://go-review.googlesource.com/c/go/+/357776
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: factor out slice elem computation for copy built-in
Robert Griesemer [Wed, 20 Oct 2021 22:06:35 +0000 (15:06 -0700)]
cmd/compile/internal/types2: factor out slice elem computation for copy built-in

Implement singleUnder[String] which determines a single underlying type
for a given type: either the underlying type, or the single underlying
type for a type parameter, if it exists. Use singleUnder[String] instead
of optype for copy built-in.

This CL removes a dependency on optype and also makes the copy built-in
slighty more general for generic arguments (the source argument may be
constrained by a slice or string simultaneously).

Change-Id: Ia329e96afc69a09d2ca3b1f82fe712d4f7ba1d9f
Reviewed-on: https://go-review.googlesource.com/c/go/+/357413
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/go: update test script for reformatted error message (fix long builds)
Robert Griesemer [Fri, 22 Oct 2021 23:57:58 +0000 (16:57 -0700)]
cmd/go: update test script for reformatted error message (fix long builds)

TBR=iant

Change-Id: Ic72af52e5ff8d28f8102c07b03e4930df61445ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/358115
Trust: Robert Griesemer <gri@golang.org>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile: prevent compiling closures more than once
Cuong Manh Le [Fri, 22 Oct 2021 10:05:35 +0000 (17:05 +0700)]
cmd/compile: prevent compiling closures more than once

Since CL 282892, functions are always compiled before closures. To do
that, when walking the closure, it is added to its outer function queue
for scheduling compilation later. Thus, a closure may be added to queue
more than once, causing the ICE dues to being compiled twice.

To fix this, catching the re-walking of the closure expression and do
not add it to the compilation queue.

Fixes #49029

Change-Id: I7d188e8f5b4d5c4248a0d8e6389da26f1084e464
Reviewed-on: https://go-review.googlesource.com/c/go/+/357960
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agodoc: document new reflect.UnsafePointer function
Cuong Manh Le [Mon, 18 Oct 2021 16:54:02 +0000 (23:54 +0700)]
doc: document new reflect.UnsafePointer function

Updates #40592

Change-Id: If66629e47ca9859128ee3ad8fb584e022d7a6982
Reviewed-on: https://go-review.googlesource.com/c/go/+/356255
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/link: add -asan option
fanzha02 [Mon, 4 Jan 2021 08:23:01 +0000 (16:23 +0800)]
cmd/link: add -asan option

The -asan option causes the linker to link against the runtime/asan
package in order to use the C/C++ address sanitizer.

This CL passes tests but is not usable by itself.  The actual
runtime/asan package, and support for -asan in the go tool and the
compiler, and tests, are in separate CLs.

Updates #44853.

Change-Id: Ifc6046c1f75ba52777cbb3d937a4b66e91d5798d
Reviewed-on: https://go-review.googlesource.com/c/go/+/298610
Trust: fannie zhang <Fannie.Zhang@arm.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile/internal/types2: more detailed error messages for generic conversions
Robert Griesemer [Wed, 20 Oct 2021 01:09:30 +0000 (18:09 -0700)]
cmd/compile/internal/types2: more detailed error messages for generic conversions

- slightly refactor convertibleTo and convertibleToImpl
- provide ability to return a conversion failure cause
- add detailed cause for generic conversions

For #47150.

Change-Id: Ie97d89be0234414ef4df22a6920e18acc944a102
Reviewed-on: https://go-review.googlesource.com/c/go/+/357249
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: reduce output when describing type parameters
Robert Griesemer [Wed, 20 Oct 2021 20:12:43 +0000 (13:12 -0700)]
cmd/compile/internal/types2: reduce output when describing type parameters

There's no need to say "type parameter" for a type parameter. The
name is sufficient (they are always named), and the prose is followed
by "constrained by".

Change-Id: I98df8caa1432b8b7a874e58da6e3ed6be102b4a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/357410
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agointernal/poll: fix a few function names on comments
Andy Pan [Fri, 22 Oct 2021 07:29:41 +0000 (15:29 +0800)]
internal/poll: fix a few function names on comments

Change-Id: I5b1dfeeb0ae5ac32667633151ef83bcf4654c43f
Reviewed-on: https://go-review.googlesource.com/c/go/+/357957
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/compile: only look for struct type when crawling inline body
Cuong Manh Le [Thu, 21 Oct 2021 07:31:40 +0000 (14:31 +0700)]
cmd/compile: only look for struct type when crawling inline body

CL 356254 fixed crawling of embeddable types during inline. However, we
are too agressive, since when we call markEmbed for every type seen
during inlining function body. That leads to false positive that for a
non-embedded type, its unexported methods are also marked inline.

Instead, we should only look at struct type that we seen during inlining
function body, and calling markEmbed for all of its embedded fields.

Fixes #49094

Change-Id: I6ef9a8bf1fc649ec6bf75e4883f6031ec8560ba1
Reviewed-on: https://go-review.googlesource.com/c/go/+/357232
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agoreflect: make Value.Pointer panic on bad notinheap pointers
Cuong Manh Le [Thu, 21 Oct 2021 16:35:05 +0000 (23:35 +0700)]
reflect: make Value.Pointer panic on bad notinheap pointers

Same as CL 350153 did for Value.Elem to panic on bad notinheap pointers.
While at it, also add more tests for notinheap deref.

Change-Id: Id7d9d12ad8467de5926b6a7e8f9d659fea5fedb5
Reviewed-on: https://go-review.googlesource.com/c/go/+/357630
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>