Commit graph

52937 commits

Author SHA1 Message Date
Russ Cox 4c08260c51 doc/go_mem: update revision date
CL 381315 added major revisions but neglected to update the date.

For #50859.

Change-Id: I086a55f0c80579c479bca5268109c9f3ae680adf
Reviewed-on: https://go-review.googlesource.com/c/go/+/410675
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2022-06-06 20:47:51 +00:00
Austin Clements 7271a0a287 doc/go1.19: gc requires -p=importpath
For #51400

Change-Id: I07a805147a6aa0923331f3f940a9e6e5553cbea9
Reviewed-on: https://go-review.googlesource.com/c/go/+/410676
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-06-06 19:55:16 +00:00
Brad Fitzpatrick c1e2ecbaf9 doc/go1.19: document Resolver.PreferGo
Updates #51400

Change-Id: I61733574362d4cf3cb65122bd13361e5c0f6728c
Reviewed-on: https://go-review.googlesource.com/c/go/+/410375
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2022-06-06 19:53:39 +00:00
Michael Matloob 11195c60e6 cmd/go: use index to match packages in dependency modules
If we're trying to search in a module in the module cache, instead
iterate over the packages in the index.
Change-Id: Ia94cbe6e9690110c28b93dbb33810680e3010381
Reviewed-on: https://go-review.googlesource.com/c/go/+/403756
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Peter Weinberger <pjw@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-06 19:32:49 +00:00
Russ Cox ea5d7cbc26 all: boringcrypto post-merge cleanup
This CL addresses the comments on CL 403154.

For #51940.

Change-Id: I99bb3530916d469077bfbd53095bfcd1d2aa82ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/403976
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-06-06 19:10:07 +00:00
Russ Cox 6c7b223c2b go/doc/comment: do not turn `` into “
``` is Markdown, not Go doc comment, but some small fraction of users get confused.

In a set of 55M Go doc comments drawn from the latest version of
all public Go modules known to the module proxy in spring 2020,
the current Go 1.19 gofmt reformats about 1.57M of them.
Out of those 1.57M comments, 8k of them (about 0.5%) contain ```.

Instead of rewriting ``` to “`, leave it alone.

For #51082.

Change-Id: I1c8c88aac7ef75ec03e1a396b84ffe711c46f941
Reviewed-on: https://go-review.googlesource.com/c/go/+/410359
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2022-06-06 19:06:16 +00:00
Russ Cox ce757e94e0 go/doc/comment: add doc comment
A CL in the website repo will add go.dev/doc/comment.

One of the final steps for #51082.

Change-Id: I419b4f6dbb424a8a93a8d09db30f7321af9ae976
Reviewed-on: https://go-review.googlesource.com/c/go/+/410358
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-06-06 19:05:57 +00:00
Joel Sing 95547aee8c cmd/compile: cast riscv64 rewrite shifts to unsigned int
This appeases Go 1.4, making it possible to bootstrap GOARCH=riscv64 with
a Go 1.4 compiler.

Fixes #52583

Change-Id: Ib13c2afeb095b2bb1464dcd7f1502574209bc7ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/409974
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-06-06 19:03:15 +00:00
90364136+butterfly1924@users.noreply.github.com d43ddc1f3f strconv: fix typo in atof.go
strings for 'NaN' -> string for 'NaN'

Change-Id: Ia415644a1b651e6ef9996ad24dd9708a60e57dfc
GitHub-Last-Rev: 877f1c3eb1
GitHub-Pull-Request: golang/go#53246
Reviewed-on: https://go-review.googlesource.com/c/go/+/410494
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-06-06 18:50:50 +00:00
Than McIntosh 2fa45a4fcd cmd/link/internal/loadpe: handle _main reference properly
When building CGO internal linking on windows 386, make sure to avoid
rewriting references to "_main" to "main" when reading symbols during
host object loading; the main routine defined by the Go runtime is
still named "_main" (not "main"). If we don't do this, we wind up with
an SXREF symbol named "main", which can then cause the loader to pull
an actual "main" symbol out of a host archive, which is undesirable.

Updates #35006.

Change-Id: I3768e3617b560552f4522e9e72af879c6adf7705
Reviewed-on: https://go-review.googlesource.com/c/go/+/410124
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Auto-Submit: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-06-06 18:49:49 +00:00
Robert Griesemer fc97075949 go/types, types2: simplify implementation of validType (fix TODO)
Now that validType is using the correct type nest (CL 409694),
the top entry of the type nest corresponds to the instantiated
type. Thus we can use that type instance to look up the value
of type parameters, there's no need anymore to create an environment
to look up type arguments.

Remove the need to pass around the environment and remove all
associated types and functions.

Updates #52698.

Change-Id: Ie37eace88896386e667ef93c77a4fc3cd0be6eb9
Reviewed-on: https://go-review.googlesource.com/c/go/+/410294
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
2022-06-06 18:37:38 +00:00
Robert Griesemer 07eca49055 go/types, types2: use type nest to detect type cycles (fix validType)
validType was using a global type info map to detect invalid recursive
types, which was incorrect. Instead, change the algorithm as follows:

- Rather than using a "seen" (or typeInfo) map which is cumbersome to
  update correctly, use the stack of embedding types (the type nest)
  to check whether a type is embedded within itself, directly or
  indirectly.

- Use Identical for type comparisons which correctly considers identity
  of instantiated generic types.

- As before, maintain the full path of types leading to a cycle. But
  unlike before, track the named types rather than their objects, for
  a smaller slice ([]*Named rather than []Object), and convert to an
  object list only when needed for error reporting.

- As an optimization, keep track of valid *Named types (Checker.valids).
  This prevents pathological cases from consuming excessive computation
  time.

- Add clarifying comments and document invariants.

Based on earlier insights by David Chase (see also CL 408818).

Fixes #52698.

Change-Id: I5e4598c58afcf4ab987a426c5c4b7b28bdfcf5ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/409694
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-06 18:24:19 +00:00
Robert Findley 770146d5a8 doc/go1.19: add TODOs for changes to go/types
Add TODO items for significant changes to go/types: the inclusion of
Origin methods for Var and Func, and a re-working of Named types to
ensure finiteness of reachable types via their API.

Updates #51400

Change-Id: I0f2a972023a5d5f995de3c33e9e2b0a4213e900a
Reviewed-on: https://go-review.googlesource.com/c/go/+/410614
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-06 16:26:54 +00:00
Alejandro Sáez 1b8ca75eaa runtime: fix breakpoint in ppc64x
Currently runtime.Breakpoint generates a SIGSEGV in ppc64.
The solution is an unconditional trap similar to what clang and gcc do. It is documented in the section C.6 of the ABI Book 3.

Fixes #52101

Change-Id: I071d2f2679b695ef268445b04c9222bd74e1f9af
GitHub-Last-Rev: fff4e5e8ff
GitHub-Pull-Request: golang/go#52102
Reviewed-on: https://go-review.googlesource.com/c/go/+/397554
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Paul Murphy <murp@ibm.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-06-06 16:04:48 +00:00
Eli Bendersky 9ce28b518d text/template/parse: fix data race on lexer initialization
Before this change, `startParse` would write `lex.breakOK` and `lex.continueOK` when the lexer goroutine is already running, which is a potential race condition.

Makes `breakOK` and `continueOK` configuration flags passed when `lexer` is created, similarly to how `emitComment` works.

Fixes #53234

Change-Id: Ia65f6135509a758cd4c5a453b249a174f4fb3e21
Reviewed-on: https://go-review.googlesource.com/c/go/+/410414
Reviewed-by: Eli Bendersky <eliben@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2022-06-06 15:54:07 +00:00
Robert Findley 47e34ca533 go/types, types2: ensure that named types never expand infinitely
During type-checking, newly created instances share a type checking
Context which de-duplicates identical instances. However, when
unexpanded types escape the type-checking pass or are created via calls
to Instantiate, they lack this shared context. As reported in #52728,
this may lead to infinitely many identical but distinct types that are
reachable via the API.

This CL introduces a new invariant that ensures we don't create such
infinitely expanding chains: instances created during expansion share a
context with the type that led to their creation. During expansion, the
expanding type passes its Context to any newly created instances.

This ensures that cycles will eventually terminate with a previously
seen instance. For example, if we have an instantiation chain
T1[P]->T2[P]->T3[P]->T1[P], by virtue of this Context passing the
expansion of T3[P] will find the instantiation T1[P].

In general, storing a Context in a Named type could lead to pinning
types in memory unnecessarily, but in this case the Context pins only
those types that are reachable from the original instance. This seems
like a reasonable compromise between lazy and eager expansion.

Our treatment of Context was a little haphazard: Checker.bestContext
made it easy to get a context at any point, but made it harder to reason
about which context is being used. To fix this, replace bestContext with
Checker.context, which returns the type-checking context and panics on a
nil receiver. Update all call-sites to verify that the Checker is
non-nil when context is called.

Also make it a panic to call subst with a nil context. Instead, update
subst to explicitly accept a local (=instance) context along with a
global context, and require that one of them is non-nil. Thread this
through to the call to Checker.instance, and handle context updating
there.

Fixes #52728

Change-Id: Ib7f26eb8c406290325bc3212fda25421a37a1e8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/404885
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
2022-06-06 15:42:19 +00:00
Robert Findley 02e69cfa96 go/types, types2: store Named instance information separately
Separate instance information into an instance struct, to reduce memory
footprint for non-instance Named types. This may induce a sense of
deja-vu: we had a similar construct in the past that was removed as
unnecessary. With additional new fields being added that only apply to
instances, having a separate struct makes sense again.

Updates #52728

Change-Id: I0bb5982d71c27e6b574bfb4f7b886a6aeb9c5390
Reviewed-on: https://go-review.googlesource.com/c/go/+/404884
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-06 15:21:40 +00:00
Robert Findley 1323b0e8f0 go/types, types2: eliminate methodList in favor of just using Named.mu
In order to clean up context after fully expanding a type (in subsequent
CLs), we must use a common mutex. Eliminate the lazy methodList type,
which keeps a sync.Once per method, in favor of Named.mu.

Updates #52728

Change-Id: I2d13319276df1330ee53046ef1823b0167a258d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/404883
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-06-06 15:18:33 +00:00
Robert Findley 846f971daa go/types, types2: remove Named.once in favor of monotonic state
Introduce a monotonic state variable to track the lifecycle of a named
type, replacing the existing sync.Once. Having a single guard for the
state of underlying and methods will allow for cleaning-up when the type
is fully expanded. In the future, this state may also be used for
detecting access to information such as underlying or methods before the
type is fully set-up, though that will require rethinking our
type-checking of invalid cyclic types.

Also remove support for type-type inference. If we ever support this
feature in the future (inference of missing type arguments for named
type instances), it will likely involve additional machinery that does
not yet exist. Remove the current partial support to simplify our
internal APIs. In particular, this means that Named.resolver is only
used for lazy loading. As a result, we can revert the lazy loader
signature to its previous form.

A lot of exposition is added for how Named types work. Along the way,
the terminology we use to describe them is refined.

Some microbenchmarks are added that were useful in evaluating the
tradeoffs between synchronization mechanisms.

Updates #52728

Change-Id: I4e147360bc6e5d8cd4f37e32e86fece0530a6480
Reviewed-on: https://go-review.googlesource.com/c/go/+/404875
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-06 15:15:21 +00:00
Stephen Eckels 66cbf67345 cmd/buildid: reject rewriting legacy buildids
This resolves legacy go binaries crashing the buildid tool when the -w flag is specified.

Fixes #50809

Change-Id: I55a866f285a3c2cebcf2cdbb9cc30e5078e1d18f
GitHub-Last-Rev: 7169a58fd7
GitHub-Pull-Request: golang/go#53163
Reviewed-on: https://go-review.googlesource.com/c/go/+/409535
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-06-06 14:30:53 +00:00
Ben Hoyt 47f806ce81 strconv: clarify ParseFloat accepts Go syntax for float literals
The documentation for strconv.ParseFloat mentions that it "accepts
decimal and hexadecimal floating-point number syntax", but it doesn't
specify what those formats entail. For example, "0x10" is not allowed;
you need an explicit exponent, as in "0x10p0".

This clarifies that ParseFloat accepts the Go syntax for floating-point
literals, and links to that spec section. I've also linked to the
relevant spec section for ParseInt's doc comment, which already said
"as defined by the Go syntax for integer literals".

Change-Id: Ib5d2b408bdd01ea0b9f69381a9dbe858f6d1d424
Reviewed-on: https://go-review.googlesource.com/c/go/+/410335
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-06-04 21:18:25 +00:00
Ikko Ashimine 2730c6af9f runtime: fix typo in libfuzzer_arm64.s
statment -> statement

Change-Id: Ia93a466fdc20157a7d6048903e359fe8717ecb8f
GitHub-Last-Rev: 0a9bc5cab0
GitHub-Pull-Request: golang/go#53231
Reviewed-on: https://go-review.googlesource.com/c/go/+/410374
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-06-04 21:17:14 +00:00
mstmdev a32a592c8c database/sql/driver: fix typo in driver.go
ExecerContext -> ExecContext
QueryerContext -> QueryContext

Change-Id: Id3b1f44de5aa47372d59696523b4379e1fbfc11c
GitHub-Last-Rev: 571d01f805
GitHub-Pull-Request: golang/go#53235
Reviewed-on: https://go-review.googlesource.com/c/go/+/410415
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-04 21:17:03 +00:00
Bryan Boreham 0293c51bc5 regexp: avoid copying each instruction executed
Inst is a 40-byte struct, so avoiding the copy gives a decent speedup:

name                            old time/op    new time/op     delta
Find-8                             160ns ± 4%      109ns ± 4%  -32.22%  (p=0.008 n=5+5)
FindAllNoMatches-8                70.4ns ± 4%     53.8ns ± 0%  -23.58%  (p=0.016 n=5+4)
FindString-8                       154ns ± 6%      107ns ± 0%  -30.37%  (p=0.016 n=5+4)
FindSubmatch-8                     194ns ± 1%      135ns ± 1%  -30.56%  (p=0.008 n=5+5)
FindStringSubmatch-8               193ns ± 8%      131ns ± 0%  -31.82%  (p=0.008 n=5+5)
Literal-8                         42.8ns ± 2%     34.8ns ± 0%  -18.67%  (p=0.008 n=5+5)
NotLiteral-8                       917ns ± 2%      636ns ± 0%  -30.68%  (p=0.008 n=5+5)
MatchClass-8                      1.18µs ± 3%     0.91µs ± 1%  -22.27%  (p=0.016 n=5+4)
MatchClass_InRange-8              1.11µs ± 1%     0.87µs ± 2%  -21.38%  (p=0.008 n=5+5)
ReplaceAll-8                       659ns ± 6%      596ns ± 3%   -9.60%  (p=0.008 n=5+5)
AnchoredLiteralShortNonMatch-8    34.2ns ± 0%     30.4ns ± 1%  -11.20%  (p=0.016 n=4+5)
AnchoredLiteralLongNonMatch-8     38.7ns ± 0%     38.7ns ± 0%     ~     (p=0.579 n=5+5)
AnchoredShortMatch-8              67.0ns ± 1%     52.7ns ± 0%  -21.31%  (p=0.016 n=5+4)
AnchoredLongMatch-8                121ns ± 0%      124ns ±10%     ~     (p=0.730 n=5+5)
OnePassShortA-8                    392ns ± 0%      231ns ± 3%  -41.10%  (p=0.008 n=5+5)
NotOnePassShortA-8                 370ns ± 0%      282ns ± 1%  -23.81%  (p=0.008 n=5+5)
OnePassShortB-8                    280ns ± 0%      179ns ± 1%  -36.05%  (p=0.008 n=5+5)
NotOnePassShortB-8                 226ns ± 0%      185ns ± 3%  -18.26%  (p=0.008 n=5+5)
OnePassLongPrefix-8               51.7ns ± 0%     39.1ns ± 1%  -24.28%  (p=0.016 n=4+5)
OnePassLongNotPrefix-8             213ns ± 2%      132ns ± 1%  -37.86%  (p=0.008 n=5+5)
MatchParallelShared-8             25.3ns ± 3%     23.4ns ± 7%   -7.50%  (p=0.016 n=5+5)
MatchParallelCopied-8             26.5ns ± 7%     22.3ns ± 7%  -16.06%  (p=0.008 n=5+5)
QuoteMetaAll-8                    45.8ns ± 1%     45.8ns ± 1%     ~     (p=1.000 n=5+5)
QuoteMetaNone-8                   24.3ns ± 0%     24.3ns ± 0%     ~     (p=0.325 n=5+5)
Compile/Onepass-8                 1.98µs ± 0%     1.97µs ± 0%   -0.22%  (p=0.016 n=5+4)
Compile/Medium-8                  4.56µs ± 0%     4.55µs ± 1%     ~     (p=0.595 n=5+5)
Compile/Hard-8                    35.7µs ± 0%     35.3µs ± 3%     ~     (p=0.151 n=5+5)
Match/Easy0/16-8                  2.18ns ± 2%     2.19ns ± 5%     ~     (p=0.690 n=5+5)
Match/Easy0/32-8                  27.4ns ± 2%     27.6ns ± 4%     ~     (p=1.000 n=5+5)
Match/Easy0/1K-8                   246ns ± 0%      252ns ± 7%     ~     (p=0.238 n=5+5)
Match/Easy0/32K-8                 4.58µs ± 7%     4.64µs ± 5%     ~     (p=1.000 n=5+5)
Match/Easy0/1M-8                   235µs ± 0%      235µs ± 0%     ~     (p=0.886 n=4+4)
Match/Easy0/32M-8                 7.86ms ± 0%     7.86ms ± 1%     ~     (p=0.730 n=4+5)
Match/Easy0i/16-8                 2.15ns ± 0%     2.15ns ± 0%     ~     (p=0.246 n=5+5)
Match/Easy0i/32-8                  507ns ± 2%      466ns ± 4%   -8.03%  (p=0.008 n=5+5)
Match/Easy0i/1K-8                 14.7µs ± 0%     13.6µs ± 2%   -7.63%  (p=0.008 n=5+5)
Match/Easy0i/32K-8                 571µs ± 1%      570µs ± 1%     ~     (p=0.556 n=4+5)
Match/Easy0i/1M-8                 18.2ms ± 0%     18.8ms ±11%     ~     (p=0.548 n=5+5)
Match/Easy0i/32M-8                 581ms ± 0%      590ms ± 1%   +1.52%  (p=0.016 n=4+5)
Match/Easy1/16-8                  2.17ns ± 0%     2.15ns ± 0%   -0.90%  (p=0.000 n=5+4)
Match/Easy1/32-8                  25.1ns ± 0%     25.4ns ± 4%     ~     (p=0.651 n=5+5)
Match/Easy1/1K-8                   462ns ± 1%      431ns ± 4%   -6.56%  (p=0.008 n=5+5)
Match/Easy1/32K-8                 18.8µs ± 0%     18.8µs ± 1%     ~     (p=1.000 n=5+5)
Match/Easy1/1M-8                   658µs ± 0%      658µs ± 1%     ~     (p=0.841 n=5+5)
Match/Easy1/32M-8                 21.0ms ± 1%     21.0ms ± 2%     ~     (p=0.841 n=5+5)
Match/Medium/16-8                 2.15ns ± 0%     2.16ns ± 0%     ~     (p=0.714 n=4+5)
Match/Medium/32-8                  561ns ± 1%      512ns ± 5%   -8.69%  (p=0.008 n=5+5)
Match/Medium/1K-8                 16.9µs ± 0%     15.2µs ± 1%  -10.40%  (p=0.008 n=5+5)
Match/Medium/32K-8                 632µs ± 0%      631µs ± 1%     ~     (p=0.421 n=5+5)
Match/Medium/1M-8                 20.3ms ± 1%     20.1ms ± 0%     ~     (p=0.190 n=5+4)
Match/Medium/32M-8                 650ms ± 1%      646ms ± 0%   -0.58%  (p=0.032 n=5+4)
Match/Hard/16-8                   2.15ns ± 0%     2.15ns ± 1%     ~     (p=0.111 n=5+5)
Match/Hard/32-8                    870ns ± 2%      667ns ± 1%  -23.28%  (p=0.008 n=5+5)
Match/Hard/1K-8                   26.9µs ± 0%     21.0µs ± 2%  -21.83%  (p=0.008 n=5+5)
Match/Hard/32K-8                   833µs ± 0%      833µs ± 1%     ~     (p=0.548 n=5+5)
Match/Hard/1M-8                   26.6ms ± 0%     26.8ms ± 1%     ~     (p=0.905 n=4+5)
Match/Hard/32M-8                   856ms ± 0%      851ms ± 0%   -0.65%  (p=0.016 n=5+4)
Match/Hard1/16-8                  2.96µs ±12%     1.81µs ± 3%  -38.68%  (p=0.008 n=5+5)
Match/Hard1/32-8                  5.62µs ± 3%     3.48µs ± 0%  -38.07%  (p=0.016 n=5+4)
Match/Hard1/1K-8                   175µs ± 5%      108µs ± 0%  -37.85%  (p=0.016 n=5+4)
Match/Hard1/32K-8                 4.09ms ± 2%     4.05ms ± 0%   -0.85%  (p=0.016 n=5+4)
Match/Hard1/1M-8                   131ms ± 0%      131ms ± 3%     ~     (p=0.151 n=5+5)
Match/Hard1/32M-8                  4.19s ± 0%      4.20s ± 1%     ~     (p=1.000 n=5+5)
Match_onepass_regex/16-8           262ns ± 2%      170ns ± 2%  -35.13%  (p=0.008 n=5+5)
Match_onepass_regex/32-8           463ns ± 0%      306ns ± 0%  -33.90%  (p=0.008 n=5+5)
Match_onepass_regex/1K-8          13.3µs ± 2%      8.8µs ± 0%  -33.84%  (p=0.008 n=5+5)
Match_onepass_regex/32K-8          424µs ± 3%      280µs ± 1%  -33.93%  (p=0.008 n=5+5)
Match_onepass_regex/1M-8          13.4ms ± 0%      9.0ms ± 1%  -32.80%  (p=0.016 n=4+5)
Match_onepass_regex/32M-8          427ms ± 0%      288ms ± 1%  -32.60%  (p=0.008 n=5+5)

Change-Id: I02c54176ed5c9f5b5fc99524a2d5eb1c490f0ebf
Reviewed-on: https://go-review.googlesource.com/c/go/+/355789
Reviewed-by: Peter Weinberger <pjw@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
2022-06-04 20:10:54 +00:00
Russ Cox 865911424d doc: update Go memory model
Following discussion on #47141, make the following changes:

- Document Go's overall approach.
- Document that multiword races can cause crashes.
- Document happens-before for runtime.SetFinalizer.
- Document (or link to) happens-before for more sync types.
- Document happens-before for sync/atomic.
- Document disallowed compiler optimizations.

See also https://research.swtch.com/gomm for background.

Fixes #50859.

Change-Id: I17d837756a77f4d8569f263489c2c45de20a8778
Reviewed-on: https://go-review.googlesource.com/c/go/+/381315
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-06-04 18:42:07 +00:00
Russ Cox fc66cae490 doc/go1.19: remove TODO about LimitedReader
Rolled back in CL 410133.

For #51115.

Change-Id: I009c557acf98a98a9e5648fa82d998d41974ae60
Reviewed-on: https://go-review.googlesource.com/c/go/+/410357
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-04 16:11:54 +00:00
Russ Cox f8a53df314 io: revert: add an Err field to LimitedReader
We are having a hard time deciding the exact semantics
of the Err field, and we need to ship the beta.
So revert the Err field change; it can wait for Go 1.20.

For #51115.

This reverts CL 396215.

Change-Id: I7719386567d3da10a614058a11f19dbccf304b4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/410133
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
2022-06-04 14:00:38 +00:00
Michael Matloob 21f05284c7 cmd/go: index standard library packages
Change-Id: I07594303a1e9833723522d5ff94577a5510ca6f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/404714
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2022-06-04 05:45:20 +00:00
Michael Pratt 9d3dbd78c7 doc/go1.19: add TODOs for undocumented runtime features
As of this CL, release notes for all packages owned by @golang/runtime
on https://dev.golang.org/owners are either complete or have explicit
TODOs.

For #51400

Change-Id: I5b6affd43883991a3b8a065b4aa211efce7427f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/410118
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
2022-06-03 20:54:52 +00:00
Michael Pratt 54a2f4b676 doc/go1.19: add release notes for runtime packages
This documents most of the changes in runtime packages, which the major
exception of GC changes, which will be documented in a future CL.

For #51400

Change-Id: Ibcf501e1b4f7caa3397db6b9136daec07aac5a65
Reviewed-on: https://go-review.googlesource.com/c/go/+/410117
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-06-03 20:54:45 +00:00
Michael Anthony Knyszek 54bd44e573 runtime: track total idle time for GC CPU limiter
Currently the GC CPU limiter only tracks idle GC work time. However, in
very undersubscribed situations, it's possible that all this extra idle
time prevents the enabling of the limiter, since it all gets account for
as mutator time. Fix this by tracking all idle time via pidleget and
pidleput. To support this, pidleget and pidleput also accept and return
"now" parameters like the timer code.

While we're here, let's clean up some incorrect assumptions that some of
the scheduling code makes about "now."

Fixes #52890.

Change-Id: I4a97893d2e5ad1e8c821f8773c2a1d449267c951
Reviewed-on: https://go-review.googlesource.com/c/go/+/410122
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-03 20:16:45 +00:00
Michael Anthony Knyszek 73587b71a6 runtime: avoid string allocation in printDebuglog
Either due to a new nowritebarrierrec annotation or a change in escape
analysis, printDebuglog can't be called from sighandler anymore.

Fix this by avoiding a string allocation that's the primary culprit.

Change-Id: Ic84873a453f45852b0443a46597ed3ab8c9443fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/410121
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-03 20:16:21 +00:00
Michael Anthony Knyszek d7941030c9 runtime: only use CPU time from the current window in the GC CPU limiter
Currently the GC CPU limiter consumes CPU time from a few pools, but
because the events that flush to those pools may overlap, rather than be
strictly contained within, the update window for the GC CPU limiter, the
limiter's accounting is ultimately sloppy.

This sloppiness complicates accounting for idle time more completely,
and makes reasoning about the transient behavior of the GC CPU limiter
much more difficult.

To remedy this, this CL adds a field to the P struct that tracks the
start time of any in-flight event the limiter might care about, along
with information about the nature of that event. This timestamp is
managed atomically so that the GC CPU limiter can come in and perform a
read of the partial CPU time consumed by a given event. The limiter also
updates the timestamp so that only what's left over is flushed by the
event itself when it completes.

The end result of this change is that, since the GC CPU limiter is aware
of all past completed events, and all in-flight events, it can much more
accurately collect the CPU time of events since the last update. There's
still the possibility for skew, but any leftover time will be captured
in the following update, and the magnitude of this leftover time is
effectively bounded by the update period of the GC CPU limiter, which is
much easier to consider.

One caveat of managing this timestamp-type combo atomically is that they
need to be packed in 64 bits. So, this CL gives up the top 3 bits of the
timestamp and places the type information there. What this means is we
effectively have only a 61-bit resolution timestamp. This is fine when
the top 3 bits are the same between calls to nanotime, but becomes a
problem on boundaries when those 3 bits change. These cases may cause
hiccups in the GC CPU limiter by not accounting for some source of CPU
time correctly, but with 61 bits of resolution this should be extremely
rare. The rate of update is on the order of milliseconds, so at worst
the runtime will be off of any given measurement by only a few
CPU-milliseconds (and this is directly bounded by the rate of update).
We're probably more inaccurate from the fact that we don't measure real
CPU time but only approximate it.

For #52890.

Change-Id: I347f30ac9e2ba6061806c21dfe0193ef2ab3bbe9
Reviewed-on: https://go-review.googlesource.com/c/go/+/410120
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-03 20:16:15 +00:00
Michael Anthony Knyszek 162b88265e cmd/compile/internal/escape: escape values with >PtrSize alignment
After CL 381317 there exist values that may have an alignment greater
than the pointer size for that platform. Specifically, atomic.{Ui|I}nt64
may be aligned to 8 bytes on a 32-bit platform. If such a value, or
a container for the value, gets stack-allocated, it's possible that it
won't be aligned correctly, because the maximum alignment we enforce on
stacks is governed by the pointer size. Changing that would be a
significant undertaking, so just escape these values to the heap
instead, where we're sure they'll actually be aligned correctly.

Change is by rsc@, I'm just shepherding it through code review.

For #50860.

Change-Id: I51669561c0a13ecb84f821020e144c58cb528418
Reviewed-on: https://go-review.googlesource.com/c/go/+/410131
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-06-03 20:15:20 +00:00
Michael Matloob ee87cd1dd9 cmd/go: changes to use modindex
This CL makes the changes to actually use the module index when loading
packages and instead of scanning their directories to see if they
contain go files or to extract imports.

Change-Id: I70106181cf64d6fd5a416644ba518b6b90030e0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/403778
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
2022-06-03 20:05:38 +00:00
Michael Matloob 06261062e9 cmd/go: add functions to read index file
The data read is used for three primary functions: ImportPackage,
IsDirWithGoFiles and ScanDir. Functions are also provided to get this
information from the intermediate package representation to cache
the information from reads for non-indexed packages.

Change-Id: I5eed629bb0d6ee5b88ab706d06b074475004c081
Reviewed-on: https://go-review.googlesource.com/c/go/+/403975
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2022-06-03 19:59:31 +00:00
Michael Pratt 0eb7051aad sync/atomic: note that alignment responsibility doesn't apply to types
For #50860.

Change-Id: I8e117f00c5da230d0dc398aaed417fe5e64a5b22
Reviewed-on: https://go-review.googlesource.com/c/go/+/410127
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-06-03 19:58:02 +00:00
Michael Pratt e1036a741c doc/go1.19: add release notes for syscall
For #51400

Change-Id: If5fc131df254d47a989ff61c8e584cb8149cbd09
Reviewed-on: https://go-review.googlesource.com/c/go/+/410116
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
2022-06-03 19:57:46 +00:00
Michael Pratt 559b17fe34 doc/go1.19: add release notes for sync/atomic
For #51400

Change-Id: I32a3aedf1e8a52148a9d78c4f7dae1ea59c810b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/410115
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-06-03 19:57:35 +00:00
eric fang 7846e25418 cmd/link: fix TestLargeText
Do not need to add single quotes '' when passing the parameter value of
 the -ldflags option, otherwise the following error will be reported:
invalid value "'-linkmode=external'" for flag -ldflags: parameter may
not start with quote character.

Change-Id: I322fa7079ac24c8a68d9cb0872b0a20dbc4893d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/410074
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Eric Fang <eric.fang@arm.com>
2022-06-03 00:13:09 +00:00
Bryan C. Mills 74dc84a0e5 doc/go1.19: add a release note for CL 404134
For #51473.

Change-Id: I01a35e5ebc83b8b72e414ed1730e9147ea590959
Reviewed-on: https://go-review.googlesource.com/c/go/+/409176
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-06-02 20:39:24 +00:00
Bryan C. Mills 3b6b9a7ef0 doc/go1.19: add release note for CL 398058
Change-Id: I483de9a6a2016432df13e030c675d42470db9ed1
Reviewed-on: https://go-review.googlesource.com/c/go/+/409175
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-06-02 20:39:23 +00:00
Ian Lance Taylor aae0bef72f archive/zip: use bufio.Reset rather than NewReader
A clean up for CL 408734, suggested by Joe Tsai.

Change-Id: Ida9db0b8d31785d5640938c286c9c6c82c27f457
Reviewed-on: https://go-review.googlesource.com/c/go/+/410154
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
2022-06-02 17:17:19 +00:00
Christian Stewart b3b8d2bfeb cmd/dist: use gohostarch for ssa rewrite check
Fix a build failure when bootstrapping the Go compiler with go-bootstrap 1.4
while the environment contains GOARCH=riscv64.

Building Go toolchain1 using go-1.4-bootstrap-20171003.
src/cmd/compile/internal/ssa/rewriteRISCV64.go:4814
invalid operation: y << x (shift count type int64, must be unsigned integer)

This is because:

 - buildtool.go:198: calls bootstrapRewriteFile(src)
 - bootstrapRewriteFile: buildtool.go:283 calls:
 - isUnneededSSARewriteFile: checks os.Getenv("GOARCH")
 - isUnneededSSARewriteFile: returns "", false
 - bootstrapRewriteFile: calls bootstrapFixImports
 - boostrapFixImports: generates code go1.4 cannot compile

Instead of checking "GOARCH" in the environment, use the gohostarch variable.

Change-Id: Ie9c190498555c4068461fead6278a62e924062c6
GitHub-Last-Rev: 300d7a7fea
GitHub-Pull-Request: golang/go#52362
Reviewed-on: https://go-review.googlesource.com/c/go/+/400376
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
2022-06-02 17:15:54 +00:00
Ian Lance Taylor f70b93a6e9 archive/zip: if non-zero base offset fails, fall back to zero
This permits us to read files that earlier Go releases could read.
It is also compatible with other zip programs.

Change-Id: I7e2999f1073c4db5ba3f51f92681e0b149d55b3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/408734
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-06-02 16:25:34 +00:00
Lukas Joisten 46ab7a5c4f encoding/json: mention SyntaxError in Unmarshal doc comment
Change-Id: I71c9d9ef9d21a7ae9466d8c7b283fdfbba01f5a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/390734
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-01 22:59:44 +00:00
Michael Matloob 293d43e17e cmd/go: add index creation methods
This change functions to scan modules and packages into an intermediate
RawPackage struct and also functions to write them out to and index.

Change-Id: Ia1a3b58b992e9be52c5d1397e85c642f902011cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/398415
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-06-01 20:20:50 +00:00
Bryan C. Mills 8a56c7742d cmd/go: set GIT_TRACE_CURL for tests on builders
We have noticed a pattern of connection timeouts connecting to
github.com on the builders. Adding tracing may shed some light on the
underlying cause.

For #52545.

Change-Id: Ic73b494be9a3ea8ce3c7631ee8f62bd3d0d8e7bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/409575
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-01 02:37:46 +00:00
Cuong Manh Le 085529bd5f cmd/compile: fix wrong unsafe.Offsetof evaluation inside generic function
For instantiated generic functions, all implicit dot operations are
resolved. Thus unsafe.Offsetof may calculating the offset against the
wrong base selector.

To fix it, we must remove any implicit dot operations to find the first
non-implicit one, which is the right base selector for calculating the
offset.

Fixes #53137

Change-Id: I38504067ce0f274615b306edc8f7d7933bdb631a
Reviewed-on: https://go-review.googlesource.com/c/go/+/409355
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2022-05-31 14:58:09 +00:00
Than McIntosh cfd202c701 cmd/link: call syscall.FlushFileBuffers on outbuf Unmap
In the windows version of OutBuf.munmap, call syscall.FlushFileBuffers
after the call to syscall.FlushViewOfFile, on the theory that this
will help flush all associated meta-data for the file the linker is
writing.

Updates #44817.

Change-Id: Ibff7d05008a91eeed7634d2760153851e15e1c18
Reviewed-on: https://go-review.googlesource.com/c/go/+/406814
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2022-05-31 11:37:38 +00:00