Merge List:
+ 2021-08-26 5e6a7e9b86 embed: remove reference to global variables in docs
+ 2021-08-26 166b691b65 cmd/compile/internal/types2: remove need for instance (struct)
+ 2021-08-26 d6bdae33e9 cmd/compile/internal/types2: address some TODOs (cleanup)
+ 2021-08-26 770df2e18d crypto/tls: fix typo in PreferServerCipherSuites comment
+ 2021-08-26 a6ff433d6a cmd/go: pass -gcflags after other flags generated by the go command
+ 2021-08-25 4f2620285d cmd/compile/internal/types2: fix type set printing and add test
+ 2021-08-25 0ac64f6d70 cmd/compile/internal/types2: rename IsMethodSet to IsConstraint (cleanup)
+ 2021-08-25 4068fb6c21 cmd/compile: always accept 1.18 syntax but complain if not 1.18
+ 2021-08-25 bf0bc4122f go/types, types2: don't re-evaluate context string for each function argument (optimization)
+ 2021-08-25 4158e88f64 cmd/compile/internal/syntax: fix position of type parameter field
+ 2021-08-25 647bef6c59 go/types: implement NewTypeList and use it instead of composite literals
+ 2021-08-25 6cf1d5d0fa cmd/compile: generic SSA rules for simplifying 2 and 3 operand integer arithmetic expressions
+ 2021-08-25 5baf60d472 bytes, strings: optimize Trim for single byte cutsets
+ 2021-08-25 3d667671ad cmd/compile: fix function contains no TParam in generic function
+ 2021-08-25 4f2ebfe34b cmd/compile: allow embed into any byte slice type
+ 2021-08-25 d2f002cb39 time/format: avoid growslice in time.String()/time.GoString()
+ 2021-08-25 08d4cc20ca cmd/compile: fix stencil call expression.
+ 2021-08-25 099b819085 cmd/compile: fix CheckSize() calculation for -G=3 and stencils
+ 2021-08-25 e1fcf8857e test: add test that caused gofrontend compiler crash
+ 2021-08-25 d37b8dedf7 test: add test case that gofrontend miscompiled
+ 2021-08-25 41b99dab0f os/user: don't skip TestLookupGroup if supported
+ 2021-08-25 de1c934b97 cmd/compile: fix checkptr false positive for (*[Big]T)(ptr)[:n:n] pattern
+ 2021-08-24 54cdef1f10 reflect: add MapIter.SetKey and MapIter.SetValue
+ 2021-08-24 5d863f89fe cmd/compile: simplify bad conversion check
Change-Id: I29ab927f0e47f44d82f9307c642900f75f4f678f
Refering to variable is both redundant since package scope is used, and
incorrect since global variables are not described in the spec.
Change-Id: Ib08a9f072fc800ee36549f758b68167d8f044878
Reviewed-on: https://go-review.googlesource.com/c/go/+/344214
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
instance was only used to hold the instantiation position for
lazy instantiation (and encode the fact that we have a lazy
instantiation). Just use a (pointer to a) syntax.Pos instead.
We could use a syntax.Pos (no pointer) and rely on the fact
that we have a known position (or fake position, if need be)
to indicate lazy instantiation. But using a pointer leads to
a smaller Named struct.
Change-Id: I441a839a125f453ad6c501de1ce499b72a2f67a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/345177
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
- Address some easy TODOs.
- Remove some TODOs that are not correct anymore or are unimportent.
- Simplify some code on the way.
Change-Id: I4d20de3725b3a735022afe022cbc002b2798936d
Reviewed-on: https://go-review.googlesource.com/c/go/+/345176
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Otherwise, any gc flags set by user using "-gcflags" won't have effect.
Fixes#47682
Change-Id: Icd365577cba1f64f6c7b8320d0c9019de9f062f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/344909
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: Jay Conrod <jayconrod@google.com>
Invert the boolean result to match the new name.
Change-Id: Ide6c649ed8ac3a5d263640309960e61a005c886e
Reviewed-on: https://go-review.googlesource.com/c/go/+/344872
Trust: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
This CL configures the parser to always accept 1.18 syntax
(type parameters, type instantiations, interface elements),
even when -lang is set to an earlier release.
Instead, the type checker looks for 1.18 operations and
complains if the language version is set to an earlier
release.
Doing these checks during type checking is necessary because it
it is possible to write "generic" code using pre-1.18 syntax;
for instance, an imported generic function may be implicitly
instantiated (as in imported.Max(2, 3)), or an imported constraint
interface may be embedded in an "ordinary" interface.
Fixes#47818.
Change-Id: I83ec302b3f4ba7196c0a4743c03670cfb901310d
Reviewed-on: https://go-review.googlesource.com/c/go/+/344871
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Change-Id: Ie1b4d5b64350ea42484adea14df84cacd1d2653b
Reviewed-on: https://go-review.googlesource.com/c/go/+/344576
Trust: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Change-Id: I8bca01b935301e7bd4efa55ed21921dbf31a75b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/344575
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>
Also, simplify a bit of code in predicates.go.
This is a backport of changes in CL 344615 that were made in addition
to the changes of the original CL 343933; it brings go/types in sync
with types2.
Change-Id: I14cd4d4704d29894d0fbb8d129744d65e332ad22
Reviewed-on: https://go-review.googlesource.com/c/go/+/344570
Trust: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Using the latest version of all modules known by the module proxy,
we determine that for all Trim usages (and related functionality):
* 76.6% have cutsets of len=1, and
* 13.4% have cutsets of len=2.
Given that a vast majority of usages only have a cutset of len=1,
we should more heavily optimize for that situation.
Previously, there was some optimization for cutsets of len=1,
but it's within the internal makeCutsetFunc function.
This is sub-optimal as it incurs an allocation in makeCutsetFunc
for the closure over that single byte.
This CL removes special-casing of one-byte cutsets from makeCutsetFunc
and instead distributes it directly in Trim, TrimRight, and TrimLeft.
Whether we should distribute the entire ASCII cutset logic into Trim
is a future CL that should be discussed and handled separately.
The evidence for multibyte cutsets is not as obviously compelling.
name old time/op new time/op delta
bytes/TrimByte-4 84.1ns ± 2% 7.5ns ± 1% -91.10% (p=0.000 n=9+7)
strings/TrimByte-4 86.2ns ± 3% 8.3ns ± 1% -90.33% (p=0.000 n=9+10)
Fixes#46446
Change-Id: Ia0e31a8384c3ce111ae35465605bcec45df2ebec
Reviewed-on: https://go-review.googlesource.com/c/go/+/323318
Trust: Joe Tsai <joetsai@digital-static.net>
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Fixes#47948
Change-Id: I446a9548265d195ae4d88aff6b1361474d1b6214
Reviewed-on: https://go-review.googlesource.com/c/go/+/344910
Trust: Alexander Rakoczy <alex@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Pre-allocate the slice of buf with enough capacity
to avoid growslice calls.
benchmark old ns/op new ns/op delta
BenchmarkTimeString-4 493 409 -17.12%
BenchmarkTimeGoString-4 309 182 -41.30%
benchmark old allocs new allocs delta
BenchmarkTimeString-4 5 3 -40.00%
BenchmarkTimeGoString-4 4 1 -75.00%
benchmark old bytes new bytes delta
BenchmarkTimeString-4 152 128 -15.79%
BenchmarkTimeGoString-4 248 80 -67.74%
Change-Id: I64eabe2ab0b3d4a846453c2e8e548a831d720b8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/343971
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
Before this change, we were arbitrarily picking a module to get the Go
version from in calls to modFileGoVersion. We now pass in the modFile to
modFileGoVersion when we have the file. Most of the calls were to get
the goVersion argument for commitRequirements, so now we have
commitRequirements call modFileGoVersion on the modFile directly
One of the calls to commitRequirements (when running go mod tidy with
a different Go version) passed in a new go version to update the file
to. Now, the modFile is updated before calling commitRequirements.
For the remaining cases of modFileGoVersion, it's replaced by a call to
the new (*MainModuleSet).GoVersion function, which either returns the go
version on the workspace file (in workspace mode) or the version of the
single go.mod file.
Change-Id: Ie88c3ca76c7f29ffc4faa16bb76f6cb7eccb5029
Reviewed-on: https://go-review.googlesource.com/c/go/+/344749
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Address some of the easier todos to address and remove the todos that
have already been done and redundant todos.
For #45713
Change-Id: I3fe4393168b10c6e005325258d9701713c92e9e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/344491
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Because the Align/Width of pointer types are always set when created,
CalcSize() never descends past a pointer. Therefore, we need to do
CheckSize() at every level when creating type. We need to do this for
types creates by types2-to-types1 conversion and also by type
substitution (mostly for stenciling). We also need to do
Defer/ResumeCheckSize() at the top level in each of these cases to deal
with potentially recursive types.
These changes fix issue #47929 and also allow us to remove the
special-case CheckSize() call that causes the problem for issue #47901.
Fixes#47901Fixes#47929
Change-Id: Icd8192431c145009cd6df2f4ade6db7da0f4dd3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/344829
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Updates https://gcc.gnu.org/PR101994
Change-Id: I50dcb90e315792efd7d83b496034ad33b5f199e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/343874
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>
For #47771
Change-Id: I99dfdd48def756bde68445b50741afd6d86b6cf2
Reviewed-on: https://go-review.googlesource.com/c/go/+/344169
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>
CL 37664 implemented this functionality, yet the tests were skipped.
Introduce and use additional variable groupListImplemented to
distinguish between these cases and enable TestLookupGroup for
supported configurations (which looks like all but plan9).
Change-Id: Iabaa7f08b4551dc67e67bdb6e715f15bb20d6218
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/330751
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
The checkptr instrumentation is currently inserted before slice
operation has validated that n <= Big. So instead of panic, checkptr
have false positive throws.
To fix this, just insert the checkptr instrumentation after the bound
checking during SSA generation.
Fixes#46938
Change-Id: I9dbf84441c711842ccc883f3654ca8766ac696d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/343972
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>
These augment the existing MapIter.Key and MapIter.Value methods.
The existing methods return new Values.
Constructing these new Values often requires allocating.
These methods allow the caller to bring their own storage.
The naming is somewhat unfortunate, in that the spec
uses the word "element" instead of "value",
as do the reflect.Type methods.
In a vacuum, MapIter.SetElem would be preferable.
However, matching the existing methods is more important.
Fixes#32424Fixes#46131
Change-Id: I19c4d95c432f63dfe52cde96d2125abd021f24fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/320929
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Now that we're using OCONVIDATA(x) everywhere we formerly used
OIDATA(OCONVIFACE(x)), there should be no OCONVIFACE operations that
take a shape type.
Change-Id: I4fb056456c60481c6dfe7bc111fca6223567e6a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/344577
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>
Fixes#47924
Change-Id: I4325b3c4ed9d369d9ea778478285436e1b2ab08a
Reviewed-on: https://go-review.googlesource.com/c/go/+/344571
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>
Issues 47713 and 47877 were both due to problems with the names used for
instantiated functions/methods, which must be in sync with the names
used by types2.
- Switched to using NameString() for writing out type arguments in
instantiation names. This ensures that we are always adding the
package to type names even for the local package. Previously, we were
explicitly adding the package name for local packages, but that
doesn't handle the case when the local type is embedded inside a
pointer or slice type. By switching to NameString(), we fix#47713.
- types1 and types2 write out 'interface {' differently (vs.
'interface{') and we were already handling that. But we needed to add
similar code to handle 'struct {' vs 'struct{'. This fixes issue
#47877.
While fixing these bugs, I also moved some duplicated code (which
include some of the changes above) into a common function addTargs(). I
also moved InstType() name to subr.go, and renamed: MakeInstName ->
MakeFuncInstSym and MakeDictName -> MakeDictSym.
Also removed a couple of ".inst..inst." prefix checks which are
irrelvant now, since we don't add ".inst." anymore to function
instantiations.
Fixes#47713Fixes#47877Fixes#47922
Change-Id: I19e9a073451f3ababd8ec31b6608cd79ba8cba36
Reviewed-on: https://go-review.googlesource.com/c/go/+/344613
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
This CL changes irgen to wait until all top-level declarations have
been processed before constructing any expressions or statements that
reference them. This is the same approach that typecheck used.
Mechanically, it splits varDecl and funcDecl (the two top-level
declarations that can generate/contain code) into a part that runs
immediately for constructing the ir.ONAME, and then a separate task
that runs later to handle the code.
It also adds an exprStmtOK flag to indicate when it's actually safe to
start constructing (non-trivial) expressions and statements.
Fixes#47928.
Change-Id: I51942af6823aa561d341e2ffc1142948da025fa2
Reviewed-on: https://go-review.googlesource.com/c/go/+/344649
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: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dan Scales <danscales@google.com>
to guarantee the "section .debug_gdb_scripts" is always "$GOROOT/src/runtime/runtime-gdb.py" , a check for package name is needed when search "runtime/proc.go".
Fixes#47881
Change-Id: Ib471314ca1a6777f625b488e5ae3790457540ef9
Reviewed-on: https://go-review.googlesource.com/c/go/+/344229
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
This is a port of CL 343934 from go/types with the necessary
adjustments to the compiler.
Change-Id: I810144e6e2eb2bc8fa0d34dc206403c993cbbe7a
Reviewed-on: https://go-review.googlesource.com/c/go/+/344616
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
This is a port of CL 343933 from go/types with the necessary
adjustments in the compiler.
With this CL type parameters and type lists are now held in
TParamList and TypeList data types which don't expose the
internal representation.
Change-Id: I6d60881b5db995dbc04ed3f4a96e8b5d41f83969
Reviewed-on: https://go-review.googlesource.com/c/go/+/344615
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
This is a port of CL 343932 from go/types, with the necessary adjustments
to the compiler.
This change improves type safety slightly, avoids many internal type
assertions, and simplifies some code paths.
Change-Id: Ie9c4734814f49cd248927152d7b3264d3578428c
Reviewed-on: https://go-review.googlesource.com/c/go/+/344614
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>
Reviewed-by: Dan Scales <danscales@google.com>
This is a port of CL 343930 from go/types, adjusted to work for
the compiler: here Environment carries a *Checker, if available.
Change-Id: I44544fad7da870fa0c02832baa6abd2909d50304
Reviewed-on: https://go-review.googlesource.com/c/go/+/344612
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>
For now don't export TypeSet in the interest of
keeping the types2 API surface small(er).
This is a clean port of CL 341289 from go/types.
Change-Id: I50c747629f25472f2ec5ba59d7f543ee3c1c423b
Reviewed-on: https://go-review.googlesource.com/c/go/+/344610
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>
Reviewed-by: Dan Scales <danscales@google.com>
name old time/op new time/op delta
SearchInts-8 15.5ns ± 2% 13.7ns ± 4% -11.87% (p=0.008 n=5+5)
(see CL 36332 for the original change to sort.Search)
Change-Id: If452818185b92b8b3548b066f475e493d604ea29
GitHub-Last-Rev: 32dd3cffa6
GitHub-Pull-Request: golang/go#47293
Reviewed-on: https://go-review.googlesource.com/c/go/+/335809
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Trust: Than McIntosh <thanm@google.com>
Change stencil.go:getDictionaryValue() and reflect.go:getDictionary() to
reuse any existing name node that has been created for the needed global
dictionary. Otherwise, these functions may set the Def on a specific
dictionary sym to two different name nodes, which means the first node
will not satisfy the invariant 'n.Sym().Def.(*ir.Name) == n' (which is
the assertion in this issue).
Fixes#47896
Change-Id: I1e7ae1efd077a83c7878b4342feb6d28d52476cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/344609
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Includes Robert's suggested fix in validate.go to not fail on
non-constant alignof/offsetof/sizeof calls. Further changes to wait on
transforming these calls until stenciling time, when we can call
EvalConst() to evaluate them once all the relevant types are known.
Added a bunch of new tests for non-constant Sizeof/Alignof/Offsetof.
Fixes#47716
Change-Id: I469af888eb9ce3a853124d919eda753971009b3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/344250
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>
When GO386=sse2 we can assume sse2 to be present without
a runtime check. If GO386=softfloat is set we can avoid
the usage of SSE2 even if detected.
This might cause a memcpy, memclr and bytealg slowdown of Go
binaries compiled with softfloat on machines that support
SSE2. Such setups are rare and should use GO386=sse2 instead
if performance matters.
On targets that support SSE2 we avoid the runtime overhead of
dynamic cpu feature dispatch.
The removal of runtime sse2 checks also allows to simplify
internal/cpu further by removing handling of the required
feature option as a followup after this CL.
Change-Id: I90a853a8853a405cb665497c6d1a86556947ba17
Reviewed-on: https://go-review.googlesource.com/c/go/+/344350
Trust: Martin Möhrmann <martin@golang.org>
Run-TryBot: Martin Möhrmann <martin@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
To measure all instructions having been completed before reading
the time stamp counter with RDTSC an instruction sequence that
has instruction stream serializing properties which guarantee
waiting until all previous instructions have been executed is
needed. This does not necessary mean to wait for all stores to
be globally visible.
This CL aims to remove vendor specific logic for determining the
instruction sequence with CPU feature flag checks that are
CPU vendor independent.
For intel LFENCE has the wanted properties at least
since it was introduced together with SSE2 support.
On AMD instruction stream serializing LFENCE is supported by setting
an MSR C001_1029[1]=1 on AMD family 10h/12h/14h/15h/16h/17h processors.
AMD family 0Fh/11h processors support LFENCE as serializing always.
AMD plans support for this MSR and access to this bit for all future processors.
Source: https://developer.amd.com/wp-content/resources/Managing-Speculation-on-AMD-Processors.pdf
Reading the MSR to determine LFENCE properties is not always possible
or reliable (hypervisors). The Linux kernel is relying on serializing
LFENCE on AMD CPUs since a commit in July 2019: https://lkml.org/lkml/2019/7/22/295
and the MSR C001_1029 to enable serialization has been set by default
with the Spectre v1 mitigations.
Using an MFENCE on AMD is waiting on previous instructions having been executed
but in addition also flushes store buffers.
To align the serialization properties without runtime detection
of CPU manufacturers we can use the newer RDTSCP instruction which
waits until all previous instructions have been executed.
RDTSCP is available on Intel since around 2008 and on AMD CPUs since
around 2006. Support for RDTSCP can be checked independently
of manufacturer by checking CPUID bits.
Using RDTSCP is the default in Linux to read TSC in program order
when the instruction is available.
e22ce8eb63/arch/x86/include/asm/msr.h (L231)
Change-Id: Ifa841843b9abb2816f8f0754a163ebf01385306d
Reviewed-on: https://go-review.googlesource.com/c/go/+/344429
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Martin Möhrmann <martin@golang.org>
Run-TryBot: Martin Möhrmann <martin@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Rather than returning "", we now return "," (which is a no-op). This
ensures that the returned string always overrides DefaultGOEXPERIMENT.
This fixes a bootstrapping issue where GOROOT_BOOTSTRAP was built with
"GOEXPERIMENT=fieldtrack ./make.bash". cmd/dist sets GOEXPERIMENT=none
during bootstrapping, which was causing cmd/go to set GOEXPERIMENT=""
when executing cmd/compile; but then cmd/compile ignores the
environment variable (because it's empty) and instead uses
DefaultGOEXPERIMENT.
Fixes#47921.
Change-Id: I657ff6cdfb294a94f6a2f58c306ceed7f104416b
Reviewed-on: https://go-review.googlesource.com/c/go/+/344511
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Arrays marked noalg are created by the compiler to hold keys and values
to initialize map literals. The ssa backend creates a pointer type for
the array type when creating an OpAddr while processing the loop that
initializes the map from the arrays. The pointer type does not inherit
the noalg property but points to the noalg array type.
This causes values created through reflect of types that should be
equal to compare unequal because the noalg and alg type might be
compared and these are not the same.
A similar problem occurred in #32595 for argument arrays of defer structs.
Created #47904 to track improve noalg handling to be able to
reintroduce this optimization again.
Fixes#47068
Change-Id: I87549342bd404b98d71a3c0f33e3c169e9d4efc8
Reviewed-on: https://go-review.googlesource.com/c/go/+/344349
Trust: Martin Möhrmann <martin@golang.org>
Run-TryBot: Martin Möhrmann <martin@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Currently, write barriers aren't emitted for global addresses, but they
are emitted for addresses offset of global addresses.
This CL changes IsGlobalAddr to recognize offsets of global addresses
as globals too, removing write barriers for staticuint64s based
addresses. The logic added is the same as used in IsStackAddr.
Updates #37612
Change-Id: I537579f85b9ad02987d94f3ee0b4508b90097959
Reviewed-on: https://go-review.googlesource.com/c/go/+/342129
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
If a type T has a method foo, then
var t T
var i interface{} = t.foo
The type of foo is a method type, but the type of t.foo should be a
standard function type. Make sure we always do that conversion.
Fixes#47775
Change-Id: I464ec792196b050aba1914e070a4ede34bfd0bfa
Reviewed-on: https://go-review.googlesource.com/c/go/+/343881
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
When starting a closure that needs a dictionary, copy the closure
variable to a local variable. This lets child closures capture that
dictionary variable correctly.
This is a better fix for #47684, which does not cause problems
like #47723.
Fixes#47723
Update #47684
Change-Id: Ib5d9ffc68a5142e28daa7d0d75683e7a35508540
Reviewed-on: https://go-review.googlesource.com/c/go/+/343871
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>
So it's clear to the reader that if "M" is a promoted method from
embedded field "T", then "x.M" will be expanded to "x.T.M" during the
evaluation of the method value.
Fixes#47863
Change-Id: Id3b82127a2054584b6842c487f6e15c3102dc9fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/344209
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: Rob Pike <r@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>