Commit graph

48342 commits

Author SHA1 Message Date
Rob Findley 7c8a5be2d6 [dev.typeparams] go/types: factor out constraint satisfaction check
This is a port of CL 322070 to go/types, adjusted for the different
error reporting API.

Change-Id: I75eafe015b5b00554116527ea021e7a5f9e0343b
Reviewed-on: https://go-review.googlesource.com/c/go/+/324759
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>
2021-06-07 17:29:52 +00:00
Rob Findley 7497e57a39 [dev.typeparams] go/types: simplify Interface accessors
This is a straightforward port of CL 321850 to go/types.

Change-Id: I719c19b8839390fdfa961255c6f1e79561cda6e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/324757
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>
2021-06-07 17:07:23 +00:00
Rob Findley 2f26adc232 [dev.typeparams] go/types: re-use existing code for Interface.Complete
This is a port of CL 321751 to go/types, adjusted to use token.Pos, and
to exclude a missing position from a panic message (an unresolved
comment on the original CL).

Change-Id: I5814067aecb67aca9d73f2093fb6004b769924f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/324756
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>
2021-06-07 17:07:10 +00:00
Rob Findley 1395952075 [dev.typeparams] go/types: add Named.SetTParams and Named.Orig methods
This is a port of CL 309832 to go/types, adjusted to not export the new
API and to amend TestSizeof.

Change-Id: I67efd3ba9b921c8431528eba1cd88ec1f41898bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/324755
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>
2021-06-07 17:06:56 +00:00
Rob Findley 991dca0112 [dev.typeparams] go/types: move signature checking into separate file
This is a port of CL 321590 to go/types. Specifically, the same checker
methods were moved.

Change-Id: If4522d316f29c6b6f887580aa037e6b6dedbb6ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/324754
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>
2021-06-07 17:06:42 +00:00
Robert Griesemer c23294d6b3 [dev.typeparams] cmd/compile/internal/types2: return Universe for ((*Package)(nil)).Scope()
For #46594.

Change-Id: I53776cbdc1b8f6da511abe2c6659a7313d7a163a
Reviewed-on: https://go-review.googlesource.com/c/go/+/325469
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-06 17:31:50 +00:00
Matthew Dempsky a5be3eaee2 [dev.typeparams] cmd/compile: refactor export writing
This CL reorganizes export writing in preparation for unified IR:

1. It moves dumpexport into noder as noder.WriteExports so that it can
be extended to include unified IR's export data.

2. Adds an "extensions" flag to typecheck.WriteExports to control
whether the compiler-only extension data (e.g., function bodies and
linker symbol info) is included in the exports.

3. It moves the gc.exporter type into typecheck and renames it to
"crawler". The type originated as the implementation of
the (pre-iexport) binary exporter, but since the removal of bexport
it's been relegated to simply crawling the exported functions/bodies
graph to identify which inline bodies need to be included.

4. It changes inline.Inline_Flood into the method crawler.markInlBody.
Inline_Flood doesn't actually have anything to do with the rest of
inlining; its current name and location are just historical quirks.

Passes toolstash -cmp.

Change-Id: I6445e2de9d3ce500a3aded5a8e20b09f46d23dbc
Reviewed-on: https://go-review.googlesource.com/c/go/+/325212
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-05 23:29:09 +00:00
Matthew Dempsky 4c072c94dc [dev.typeparams] cmd/compile: refactor import reading
This CL restructures the gcimports importer to mmap the export data
into memory as a string, and then pass that same string to both the
typecheck and types2 importers.

This is primarily motivated by preparation for unified IR; but it
should also improve performance (fewer string copies) and reduces
divergance between the two importers.

Passes toolstash -cmp.

Change-Id: I397f720693e9e6360bfcb5acb12609ab339d251f
Reviewed-on: https://go-review.googlesource.com/c/go/+/325210
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-05 23:28:52 +00:00
Matthew Dempsky 4e001a8d9e [dev.typeparams] runtime/race: make test compatible with types2
types2 correctly distinguishes variable assignment from use even
within function literals. Whatever the outcome of #3059, the test
cases in runtime/race need to be fixed to accomodate that.

Change-Id: Ibe3547f07b681ff41225caabaf050872a48c98d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/325030
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-05 02:01:10 +00:00
Robert Griesemer 246a5570be [dev.typeparams] cmd/compile: rename (types2.Inferred.)Targs to TArgs
This is consistent with Named.TArgs.

This is a straight-forward port of https://golang.org/cl/321289
plus the necessary compiler noder changes.

Change-Id: I50791e5abe0d7f294293bed65cebc8dde8bf8c06
Reviewed-on: https://go-review.googlesource.com/c/go/+/325010
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-06-05 01:52:30 +00:00
Robert Griesemer 692399fbaa [dev.typeparams] cmd/compile/internal/syntax: not all index expressions can be instantiated types
An index expression followed by an opening "{" may indicate
a composite literal but only if the index expression can be
a type. Exclude cases where the index expression cannot be
a type (e.g. s[0], a[i+j], etc.).

This leads to a better error message in code that is erroneous.

Fixes #46558.

Change-Id: Ida9291ca30683c211812dfb95abe4969f44c474f
Reviewed-on: https://go-review.googlesource.com/c/go/+/325009
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-06-05 01:52:24 +00:00
Matthew Dempsky a94e4f5a85 [dev.typeparams] cmd/compile: point StructKeyExpr at the types.Field
When constructing struct literals, importers need a way to specify
precisely which field to initialize without worrying about visibility
or those fields being blank. (A blank field doesn't actually need to
be initialized, but the expression needs to be evaluated still, and
with the right order-of-operations.)

This CL changes StructKeyExpr's Field field to point directly to the
corresponding types.Field, rather than merely holding a copy of its
Sym and Offset. This is akin to past changes to add
SelectorExpr.Selection.

Change-Id: I95b72b1788f73206fcebc22b456cf6b1186db6a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/325031
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-04 21:07:19 +00:00
Keith Randall bad388744b [dev.typeparams] cmd/compile: handle dictionaries for top-level instantiations
There's no outer function in these cases, so we won't be reading
the dictionary as a subdictionary from the outer scope's dictionary.
It will always be a compile-time constant.

Change-Id: I754b126652a6ffb62255734d53fcec29d77cfa9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/324949
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
2021-06-04 18:11:39 +00:00
Dan Scales de61465156 [dev.typeparams] cmd/compile: allow inlining in instantiated functions
Change markType to scan generic types and methods, so that inlineable
functions inside generic functions/methods will be properly marked for
export, which means inlining inside instantiated functions will work
correctly.

Also, fix handling of closures for instantiated functions. Some code
needs to be adjusted, since instantiated functions/methods are compiled
as if in the package of the source generic function/type, rather than in
the local package. When we create the closure struct, we want to make
sure that the .F field has the same package as the other fields for the
closure variables. Also, we need to disable a check in tcCompLit() when
being done for an instantiated function, since fields of the closure
struct will be from the source package, not the local package.

Re-enabled part of the orderedmapsimp test that was disabled because of
these issues.

Change-Id: Ic4dba8917da0a36b17c0bdb69d6d6edfdf14104a
Reviewed-on: https://go-review.googlesource.com/c/go/+/324331
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2021-06-04 17:48:10 +00:00
Cherry Mui 4cf7f5f694 [dev.typeparams] test: test regabidefers in live.go
Previously, live.go is conditioned on not using regabidefers. Now
we have regabidefers enabled by default everywhere, and we may
remove the fallback path in the near future, test that
configuration instead.

Change-Id: Idf910aee323bdd6478bc7a2062b2052d82ce003f
Reviewed-on: https://go-review.googlesource.com/c/go/+/325111
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-06-04 17:00:48 +00:00
Cherry Mui 3298c749ac [dev.typeparams] runtime: undo go'd closure argument workaround
In CL 298669 we added defer/go wrapping, and, as it is not
allowed for closures to escape when compiling runtime, we worked
around it by rewriting go'd closures to argumentless
non-capturing closures, so it is not a real closure and so not
needed to escape.

Previous CL removes the restriction. Now we can undo the
workaround.

Updates #40724.

Change-Id: Ic7bf129da4aee7b7fdb7157414eca943a6a27264
Reviewed-on: https://go-review.googlesource.com/c/go/+/325110
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-06-04 17:00:32 +00:00
Cherry Mui 46beeed0ac [dev.typeparams] cmd/compile: allow go'd closure to escape when compiling runtime
When compiling runtime, we don't allow closures to escape,
because we don't want (implicit) allocations to occur when it is
not okay to allocate (e.g. in the allocator itself). However, for
go statement, it already allocates a new goroutine anyway. It is
okay to allocate the closure. Allow it.

Also include the closure's name when reporting error.

Updates #40724.

Change-Id: Id7574ed17cc27709609a059c4eaa67ba1c4436dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/325109
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-06-04 17:00:19 +00:00
Dan Scales 8e6dfe1b31 [dev.typeparams] cmd/compile: export/import of recursive generic types.
Deal with export/import of recursive generic types. This includes
typeparams which have bounds that reference the typeparam.

There are three main changes:

  - Change export/import of typeparams to have an implicit "declaration"
    (doDecl). We need to do a declaration of typeparams (via the
    typeparam's package and unique name), because it may be referenced
    within its bound during its own definition.

  - We delay most of the processing of the Instantiate call until we
    finish the creation of the top-most type (similar to the way we
    delay CheckSize). This is because we can't do the full instantiation
    properly until the base type is fully defined (with methods). The
    functions delayDoInst() and resumeDoInst() delay and resume the
    processing of the instantiations.

  - To do the full needed type substitutions for type instantiations
    during import, I had to separate out the type subster in stencil.go
    and move it to subr.go in the typecheck package. The subster in
    stencil.go now does node substitution and makes use of the type
    subster to do type substitutions.

Notable other changes:
 - In types/builtins.go, put the newly defined typeparam for a union type
   (related to use of real/imag, etc.) in the current package, rather
   than the builtin package, so exports/imports work properly.

 - In types2, allowed NewTypeParam() to be called with a nil bound, and
   allow setting the bound later. (Needed to import a typeparam whose
   bound refers to the typeparam itself.)

 - During import of typeparams in types2 (importer/import.go), we need
   to keep an index of the typeparams by their package and unique name
   (with id). Use a new map typParamIndex[] for that. Again, this is
   needed to deal with typeparams whose bounds refer to the typeparam
   itself.

 - Added several new tests absdiffimp.go and orderedmapsimp.go. Some of
   the orderemapsimp tests are commented out for now, because there are
   some issues with closures inside instantiations (relating to unexported
   names of closure structs).

 - Renamed some typeparams in test value.go to make them all T (to make
   typeparam uniqueness is working fine).

Change-Id: Ib47ed9471c19ee8e9fbb34e8506907dad3021e5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/323029
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-04 16:43:27 +00:00
Rob Findley 93a886a165 [dev.typeparams] go/types: move struct checking into separate file
This is a port of CL 321589 to go/types. Specifically, the same checker
methods were moved.

Change-Id: If07d96faa77d2f9409d8895f970149c42cbfe440
Reviewed-on: https://go-review.googlesource.com/c/go/+/324753
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>
2021-06-04 11:01:22 +00:00
Rob Findley ffc74ad5d3 [dev.typeparams] go/types: move interface checking into separate file
This is a port of CL 321549 to go/types. Specifically, the same checker
methods were moved.

Change-Id: I491a8c5a985d71ebb23e4b34541a557da0af0cfc
Reviewed-on: https://go-review.googlesource.com/c/go/+/324752
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>
2021-06-04 11:01:02 +00:00
Rob Findley 090a17c998 [dev.typeparams] go/types: use correct type parameter list in missingMethod
This is a port of CL 321232 to go/types, adjusted to add a missing
comment and to remove optional support for method type params.

Fixes #46275

Change-Id: I63fcbb669e7607876a888fca89b9064568805448
Reviewed-on: https://go-review.googlesource.com/c/go/+/324751
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>
2021-06-04 11:00:45 +00:00
Rob Findley 62c40878e4 [dev.typeparams] go/types: better recv Var for method expressions
This is a port of CL 320489 to go/types, adjusted to be consistent about
named/unnamed parameters. TestEvalPos was failing without this addition.

For #46209

Change-Id: Icdf86e84ebce8ccdb7846a63b5605e360e2b8781
Reviewed-on: https://go-review.googlesource.com/c/go/+/324733
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>
2021-06-04 10:59:39 +00:00
Rob Findley e32fab145b [dev.typeparams] go/types: fix panic with nil package name
This is a straightforward port of CL 320490 to go/types.

Change-Id: I763c806c777f926a563d8f9384764e5b3f7f083c
Reviewed-on: https://go-review.googlesource.com/c/go/+/324732
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>
2021-06-04 10:59:23 +00:00
Rob Findley cd6e9df446 [dev.typeparams] go/types: print "incomplete" for interfaces in debug mode only
This is a straightforward port of CL 320150 to go/types.

Fixes #46167

Change-Id: Id1845046f598ac4fefd68cda6a5a03b7a5fc5a4a
Reviewed-on: https://go-review.googlesource.com/c/go/+/324731
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>
2021-06-04 10:59:00 +00:00
Rob Findley 655246f99a [dev.typeparams] go/types: make TestManual work for directories
This is a port of CL 315769 to go/types, adjusted for the additional
testPkg indirection in go/types on top of testFiles, and to remove the
colDelta argument.

Change-Id: Ieb722d77866313a01645aeec49912c16cb475462
Reviewed-on: https://go-review.googlesource.com/c/go/+/324730
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-06-04 10:58:49 +00:00
Rob Findley d7592ab424 [dev.typeparams] go/types: implement types.Instantiate
This is a straightforward port of CL 314773 to go/types.

Change-Id: If9e2d6d99790d694615389acbe6ccb3c8c0bd1da
Reviewed-on: https://go-review.googlesource.com/c/go/+/324729
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>
2021-06-04 10:04:16 +00:00
Rob Findley 410fa4c75b [dev.typeparams] go/types: rename Inferred.Targs to TArgs
This is consistent with Named.TArgs.

Change-Id: Ib25f7ac5b7242e169c8c1701dfa407f763f26125
Reviewed-on: https://go-review.googlesource.com/c/go/+/321289
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>
2021-06-04 10:02:50 +00:00
Rob Findley 298149a915 [dev.typeparams] go/types: use Checker-provided type parameter IDs when possible
Incrementing type parameter subscripts for each type checking pass is
distracting for an interactive program where packages are type-checked
on each keystroke.

We should perhaps hide the type parameter ID altogether, but for now at
least add a layer of indirection so that type parameters for a single
type-checked package can be stabilized.

This change should have no effect on non-generic type checking.

For #46003

Change-Id: I60d747e0a2bfb68e7d64e897eac23f609a2a4429
Reviewed-on: https://go-review.googlesource.com/c/go/+/321269
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>
2021-06-04 10:02:38 +00:00
Matthew Dempsky 2175e2f573 [dev.typeparams] cmd/compile: lazy import resolution for types2
This CL adds three new functions to the types2 API to support lazy
import resolution:

1. A new Scope.InsertLazy method to allow recording that Objects exist
in a particular Scope (in particular, package scopes) without having
to yet fully construct those objects. Instead, types2 will call the
provided `resolve` function if/when the object is actually needed.

2. Similarly, a new NewTypeNameLazy function to create TypeName
objects without yet instantiating their underlying Named
instance.

3. Finally, an InstantiateLazy method, that allows creating type
instances without requiring any of the types to be expanded right
away. Importantly, this requires providing a types2.Checker argument
to handle recursive types correctly.

The APIs as-is are a bit clumsy (esp. NewTypeNameLazy), but seem to
work well for cmd/compile's needs. In particular, they simplify some
of the complexities of handling recursive type definitions within the
importer.

Also, the current prototype is a bit fragile. It uses sync.Once to
manage concurrent lazy resolution, which is frustrating to debug in
the presence of reentrancy issues. It also means the importer needs to
deal with concurrency as well. These aren't issues for types2 though
as cmd/compile only walks the type-checked AST sequentially.

Finally, it looks like some of the details of lazy type names are
similar to the lazy "instance" stuff used for generics, so maybe
there's opportunity for unifying them under a more general (but still
internal) lazy type mechanism.

I had originally intended for this CL to also update the types2
importer, but (1) it doesn't have access to the types2.Checker
instance needed to call InstantiateLazy, and (2) it creates a new
TypeName/TypeParam at each use rather than reusing them, which
evidently works with types2.Instantiate but not
types2.(*Checker).instantiate (i.e., InstantiateLazy). I spent a while
trying to fix these issues, but kept running into more subtle
issues. Instead, I've included my WIP "unified IR" CL as a followup CL
that demonstrates these Lazy methods (see noder/reader2.go).

Updates #46449.

Change-Id: I4d1e8e649f6325a11790d25fd90c39fa07c8d41d
Reviewed-on: https://go-review.googlesource.com/c/go/+/323569
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-04 04:28:10 +00:00
Cherry Mui 4d2b528795 [dev.typeparams] internal/buildcfg: turn on register ABI by default on ARM64
This CL enables all regabi experiments on ARM64 by default.
regabiwrappers and regabireflect are enabled in the previous CLs.
regabidefer is already enabled everywhere. regabig is no-op on
ARM64 as it already has a G register. regabiargs is enabled in
this CL.

Go1 benchmarks results (GOEXPERIMENT=regabi vs. none, on macOS/ARM64):

name                     old time/op    new time/op     delta
BinaryTree17-8              1.20s ± 1%      1.02s ± 0%  -15.08%  (p=0.000 n=9+9)
Fannkuch11-8                1.55s ± 0%      1.57s ± 0%   +1.53%  (p=0.000 n=9+8)
FmtFprintfEmpty-8          22.5ns ± 3%     14.7ns ± 1%  -34.47%  (p=0.000 n=10+8)
FmtFprintfString-8         38.4ns ± 0%     28.8ns ± 0%  -24.99%  (p=0.000 n=9+9)
FmtFprintfInt-8            38.7ns ± 2%     34.5ns ± 0%  -10.79%  (p=0.000 n=10+7)
FmtFprintfIntInt-8         61.1ns ± 1%     57.9ns ± 0%   -5.23%  (p=0.000 n=10+8)
FmtFprintfPrefixedInt-8    69.9ns ± 0%     64.4ns ± 0%   -7.78%  (p=0.000 n=8+8)
FmtFprintfFloat-8           106ns ± 0%       76ns ± 0%  -28.12%  (p=0.000 n=7+10)
FmtManyArgs-8               273ns ± 0%      236ns ± 1%  -13.57%  (p=0.000 n=9+10)
GobDecode-8                3.09ms ± 1%     2.02ms ± 0%  -34.70%  (p=0.000 n=9+10)
GobEncode-8                2.45ms ± 1%     1.44ms ± 1%  -41.26%  (p=0.000 n=10+10)
Gzip-8                      128ms ± 0%      124ms ± 0%   -2.89%  (p=0.000 n=7+8)
Gunzip-8                   23.6ms ± 1%     19.8ms ± 0%  -16.15%  (p=0.000 n=10+9)
HTTPClientServer-8         27.4µs ± 1%     26.3µs ± 0%   -4.05%  (p=0.000 n=10+10)
JSONEncode-8               4.47ms ± 1%     3.45ms ± 1%  -22.73%  (p=0.000 n=10+9)
JSONDecode-8               21.5ms ± 0%     17.2ms ± 0%  -19.78%  (p=0.000 n=9+9)
Mandelbrot200-8            2.33ms ± 1%     2.33ms ± 1%     ~     (p=0.842 n=9+10)
GoParse-8                  1.62ms ± 1%     1.32ms ± 1%  -18.67%  (p=0.000 n=10+10)
RegexpMatchEasy0_32-8      33.1ns ± 0%     26.3ns ± 0%  -20.50%  (p=0.000 n=8+10)
RegexpMatchEasy0_1K-8       121ns ± 6%      121ns ± 8%     ~     (p=0.926 n=10+10)
RegexpMatchEasy1_32-8      31.4ns ± 0%     24.7ns ± 0%  -21.50%  (p=0.000 n=9+10)
RegexpMatchEasy1_1K-8       177ns ± 0%      140ns ± 0%  -20.70%  (p=0.000 n=10+9)
RegexpMatchMedium_32-8     3.02ns ± 3%     2.12ns ± 0%  -29.73%  (p=0.000 n=10+10)
RegexpMatchMedium_1K-8     19.8µs ± 2%     17.1µs ± 0%  -13.50%  (p=0.000 n=9+9)
RegexpMatchHard_32-8        940ns ± 0%      872ns ± 0%   -7.20%  (p=0.000 n=9+8)
RegexpMatchHard_1K-8       28.5µs ± 1%     26.5µs ± 0%   -7.06%  (p=0.000 n=10+10)
Revcomp-8                   186ms ± 1%      179ms ± 1%   -3.66%  (p=0.000 n=10+10)
Template-8                 30.3ms ± 0%     22.3ms ± 0%  -26.58%  (p=0.000 n=8+9)
TimeParse-8                 133ns ± 0%      117ns ± 0%  -12.40%  (p=0.000 n=10+10)
TimeFormat-8                176ns ± 0%      141ns ± 0%  -19.92%  (p=0.000 n=8+9)
[Geo mean]                 21.4µs          17.8µs       -16.81%

name                     old speed      new speed       delta
GobDecode-8               249MB/s ± 1%    381MB/s ± 0%  +53.13%  (p=0.000 n=9+10)
GobEncode-8               314MB/s ± 1%    534MB/s ± 1%  +70.25%  (p=0.000 n=10+10)
Gzip-8                    152MB/s ± 0%    156MB/s ± 0%   +2.97%  (p=0.000 n=7+8)
Gunzip-8                  822MB/s ± 1%    981MB/s ± 0%  +19.26%  (p=0.000 n=10+9)
JSONEncode-8              434MB/s ± 1%    562MB/s ± 1%  +29.41%  (p=0.000 n=10+9)
JSONDecode-8             90.3MB/s ± 0%  112.5MB/s ± 0%  +24.66%  (p=0.000 n=9+9)
GoParse-8                35.7MB/s ± 1%   43.9MB/s ± 1%  +22.96%  (p=0.000 n=10+10)
RegexpMatchEasy0_32-8     967MB/s ± 0%   1216MB/s ± 0%  +25.78%  (p=0.000 n=8+10)
RegexpMatchEasy0_1K-8    8.46GB/s ± 6%   8.45GB/s ± 7%     ~     (p=0.912 n=10+10)
RegexpMatchEasy1_32-8    1.02GB/s ± 0%   1.30GB/s ± 0%  +27.40%  (p=0.000 n=9+10)
RegexpMatchEasy1_1K-8    5.78GB/s ± 0%   7.29GB/s ± 0%  +26.10%  (p=0.000 n=10+9)
RegexpMatchMedium_32-8    331MB/s ± 2%    471MB/s ± 0%  +42.29%  (p=0.000 n=10+10)
RegexpMatchMedium_1K-8   51.7MB/s ± 2%   59.8MB/s ± 0%  +15.60%  (p=0.000 n=9+9)
RegexpMatchHard_32-8     34.0MB/s ± 0%   36.7MB/s ± 0%   +7.75%  (p=0.000 n=9+8)
RegexpMatchHard_1K-8     35.9MB/s ± 1%   38.6MB/s ± 0%   +7.59%  (p=0.000 n=10+10)
Revcomp-8                1.37GB/s ± 1%   1.42GB/s ± 1%   +3.79%  (p=0.000 n=10+10)
Template-8               64.0MB/s ± 0%   87.1MB/s ± 0%  +36.20%  (p=0.000 n=8+9)
[Geo mean]                299MB/s         368MB/s       +23.16%

Binary sizes:
                old            new
hello           1180994        1162626      -1.6%
cmd/compile     23455858       22833970     -2.7%
cmd/link        6425010        6332978      -1.4%

Text sizes:
                old            new
hello           458752         425984       -7.1%
cmd/compile     10190848       9355264      -8.2%
cmd/link        2621440        2441216      -6.9%

Change-Id: I52c10c11bb8fe5952b7043f9dbf09573ef71d2b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/324890
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2021-06-03 21:55:26 +00:00
Cherry Mui 5f034f9b46 [dev.typeparams] internal/buildcfg: turn on regabireflect by default on ARM64
Change-Id: I4a0a093b07a287cc3a3e0ee939e7ee82d8e9b1aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/324889
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-03 20:58:43 +00:00
Matthew Dempsky 026480d06b [dev.typeparams] cmd/compile: allow nil Syms in Sym.Less
Allows sorting interfaces that contain embedded anonymous types.

Fixes #46556.

Change-Id: If19afa1d62432323b2e98957087867afbf3f9097
Reviewed-on: https://go-review.googlesource.com/c/go/+/324812
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2021-06-03 20:52:22 +00:00
Cherry Mui a2d6a2caeb [dev.typeparams] internal/buildcfg: turn on regabiwrappers by default on ARM64
Change-Id: I8db0a797a745630ec35af3e56406fcb250ea59fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/324768
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-06-03 20:17:38 +00:00
Cherry Mui 55b4310acd [dev.typeparams] runtime: crash the GC at clobberdead pointer on ARM64
Extend CL 310330 to ARM64, which now has clobberdead mode
implemented in the compiler.

Change-Id: I07f6951d81a0797ef7a74e48b79db5cea2bf876b
Reviewed-on: https://go-review.googlesource.com/c/go/+/324766
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-03 20:00:56 +00:00
Cherry Mui 6b1e4430bb [dev.typeparams] cmd/compile: implement clobberdead mode on ARM64
For debugging.

Change-Id: I5875ccd2413b8ffd2ec97a0ace66b5cae7893b24
Reviewed-on: https://go-review.googlesource.com/c/go/+/324765
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-03 20:00:30 +00:00
Dan Scales 1c947e4f31 [dev.typeparams] cmd/compile: properly copy tilde value for unions in types2-to-types1 conversion
Change-Id: I2211020141886b348cddf9e33ab31b71c8478987
Reviewed-on: https://go-review.googlesource.com/c/go/+/324811
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-06-03 19:59:18 +00:00
Cherry Mui e9ba0750b6 [dev.typeparams] reflect: guard abi_test.go with regabiargs build tag
The test in abi_test.go relies on the compiler to generate
register-ABI calls using a magic name. As of CL 300150 the name
loses its magic. Guard it with regabiargs for the use of
register-ABI calls.

Change-Id: Ib8b3c24f71ea5161d607c9becfb3027ceee40ac1
Reviewed-on: https://go-review.googlesource.com/c/go/+/324767
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-03 19:48:38 +00:00
Cherry Mui 28bd325e41 [dev.typeparams] runtime: use ABIInternal callbackWrap in callbackasm1 on ARM64
On Windows/ARM64, callbackasm1 calls callbackWrap via cgocallback.
cgocallback uses ABIInternal calling convention to call the
function. Pass the ABIInternal entry point to cgocallback.

Change-Id: I79d21b77525f6ac8dd50d34f4f304749419b2ad4
Reviewed-on: https://go-review.googlesource.com/c/go/+/324735
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-06-03 16:28:44 +00:00
Cherry Mui 3de4986852 [dev.typeparams] runtime: call cgocallbackg indirectly on ARM64
This is CL 312669, for ARM64.

cgocallback calls cgocallbackg after switching the stack. Call it
indirectly to bypass the linker's nosplit check. In particular,
this avoids a nosplit stack overflow on Windows when register ABI
is enabled.

Change-Id: I7054a750fb0ec2579d46004f94b46b6f7b9e3a21
Reviewed-on: https://go-review.googlesource.com/c/go/+/324734
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-06-03 16:28:28 +00:00
Cherry Mui 5a40fab19f [dev.typeparams] runtime, internal/bytealg: port performance-critical functions to register ABI on ARM64
This CL ports a few performance-critical assembly functions to use
register arguments directly. This is similar to CL 308931 and
CL 310184.

Change-Id: I6e30dfff17f76b8578ce8cfd51de21b66610fdb0
Reviewed-on: https://go-review.googlesource.com/c/go/+/324400
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-03 16:28:19 +00:00
Dan Scales 370ff5ff96 [dev.typeparams] test: update all the typeparam tests to use the new union/tilde syntax
Did a mix of tilde and non-tilde usage. Tilde notation is not quite
fully functional, so no tests are currently trying to distinguish
(fail/not fail) based on tilde usage.

Change-Id: Ib50cec2fc0684f9d9f3561c889fd44c7a7af458c
Reviewed-on: https://go-review.googlesource.com/c/go/+/324572
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-03 16:05:22 +00:00
Cherry Mui 5a008a92e8 [dev.typeparams] internal/bytealg: call memeqbody directly in memequal_varlen on ARM64
Currently, memequal_varlen opens up a frame and call memequal,
which then tail-calls memeqbody. This CL changes memequal_varlen
tail-calls memeqbody directly.

This makes it simpler to switch to the register ABI in the next
CL.

Change-Id: Ia1367c0abb7f4755fe736c404411793fb9e5c04f
Reviewed-on: https://go-review.googlesource.com/c/go/+/324399
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-06-03 14:29:14 +00:00
Cherry Mui 165d39a1d4 [dev.typeparams] test: adjust codegen test for register ABI on ARM64
In codegen/arithmetic.go, previously there are MOVD's that match
for loads of arguments. With register ABI there are no more such
loads. Remove the MOVD matches.

Change-Id: I920ee2629c8c04d454f13a0c08e283d3528d9a64
Reviewed-on: https://go-review.googlesource.com/c/go/+/324251
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-06-03 14:28:14 +00:00
Cherry Mui b5f37faf3b [dev.typeparams] cmd/internal/goobj: add duffzero/duffcopy to builtin list
duffzero and duffcopy are commonly referenced functions. Add them
to builtin list, so they are referenced by index, not by name.

Also change gcWriteBarrier to ABIInternal, which is changed in
CL 266638.

Regenerate the file.

Change-Id: If8550d9ed300ac2be930a7c58657a9cf1933ac1d
Reviewed-on: https://go-review.googlesource.com/c/go/+/324250
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-06-03 14:28:02 +00:00
Cherry Mui 9c054f4137 [dev.typeparams] cmd/link: take function address in assembly in TestFuncAlign
In TestFuncAlign we want to get the address of an assembly
function. Take the address in assembly, so we get the actual
function's address, not the wrapper's.

Change-Id: Idc1fe2c8426562c70f8f7d6e489584ef059bc556
Reviewed-on: https://go-review.googlesource.com/c/go/+/324249
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-06-03 14:27:08 +00:00
Robert Griesemer 95c618e99a [dev.typeparams] cmd/compile/internal/types2: add Config.AllowTypeLists to control type list handling
Eventually the flag should not be set anymore, but we set it in the
compiler until all tests have been converted.

Also, convert some more types2 tests to use the type set notation.

Change-Id: I616599a3473451ab75d67272016b2bd3de6835af
Reviewed-on: https://go-review.googlesource.com/c/go/+/324571
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-06-03 03:55:44 +00:00
Robert Griesemer 10d6b36ca3 [dev.typeparams] cmd/compile/internal/types2: disallow ~T where T is a defined type or an interface
Change-Id: I35f6f43db00d56847da48320308f2fcfff924738
Reviewed-on: https://go-review.googlesource.com/c/go/+/324570
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>
2021-06-03 03:55:37 +00:00
Robert Griesemer 8cdce85bdf [dev.typeparams] cmd/compile/internal/types2: convert testdata/check tests to type set sytax
Change-Id: I0c2dda10ba7cb40330545fd10fbacb8c84f66a2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/324569
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-06-02 23:28:39 +00:00
Robert Griesemer c790964ae4 [dev.typeparams] cmd/compile/internal/types2: convert testdata/fixedbugs tests to type set sytax
Change-Id: I2ad94c71bebb93e0e3f4eba9d5199a3b3e9fa63d
Reviewed-on: https://go-review.googlesource.com/c/go/+/324530
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-06-02 23:19:31 +00:00
Robert Griesemer 9a99e728fe [dev.typeparams] cmd/compile/internal/types2: convert testdata/examples tests to type set sytax
Change-Id: Ida3837c9cbb970a2b49cd1598c6e6e9de8aa9690
Reviewed-on: https://go-review.googlesource.com/c/go/+/324529
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-06-02 23:19:30 +00:00