1
0
mirror of https://github.com/golang/go synced 2024-11-15 02:00:33 -07:00
Commit Graph

45434 Commits

Author SHA1 Message Date
ipriver
8098dbb30e runtime: update docs for GOMAXPROCS
https://github.com/golang/go/blob/master/doc/effective_go.html#L3211 is used to update the docs comment for `GOMAXPROCS` function.

Fixes #41275

Change-Id: I39f58e93a267c6e9f3ac6638ed51acbe5284ada2
GitHub-Last-Rev: e45c8ac587
GitHub-Pull-Request: golang/go#41276
Reviewed-on: https://go-review.googlesource.com/c/go/+/253537
Reviewed-by: Keith Randall <khr@golang.org>
2020-09-10 14:44:25 +00:00
Cuong Manh Le
07d19b2597 all: check GOROOT_BOOTSTRAP executable before bootsrappping
Otherwise we’d still be writing that we're building cmd/dist
even if GOROOT_BOOTSTRAP we’re wrongly set.

Change-Id: I940e18c3cebae5664f85babc9919e9eb215d5093
Reviewed-on: https://go-review.googlesource.com/c/go/+/253877
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-09-10 12:11:16 +00:00
fanzha02
dfdc3880b0 cmd/internal/obj/arm64: enable some SIMD instructions
Enable VBSL, VBIT, VCMTST, VUXTL VUXTL2 and FMOVQ SIMD
instructions required by the issue #40725. And FMOVQ
instrucion is used to move a large constant to a Vn
register.

Add test cases.

Fixes #40725

Change-Id: I1cac1922a0a0165d698a4b73a41f7a5f0a0ad549
Reviewed-on: https://go-review.googlesource.com/c/go/+/249758
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-09-10 02:22:19 +00:00
Bryan C. Mills
aa476ba6f4 cmd/go/internal/modload: refactor pathInModuleCache
I found the control flow of this function a bit tricky to reason about
due to nesting and interaction between conditions and iteration. This
change factors out a helper function that can return early instead of
mixing conditionals and 'continue' statements.

Also remove the (unused) ModuleUsedDirectly function.

For #36460

Change-Id: I60a2a5a1b32989e5a17a14e1a8c858b280cda8f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/251998
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2020-09-09 22:39:28 +00:00
Bryan C. Mills
564b350c08 cmd/go/internal/modload: rename LoadBuildList and BuildList
With lazy loading, the “build list” can be refined as packages are loaded.
Rename functions that return the build list to more precisely describe
the set of modules returned by the call.

Also eliminate a redundant call to LoadBuildList (right before
ListModules, which itself begins with the same call).

For #36460

Change-Id: I0fc4f9dd7602e0df5e166e329ee5d516d810ca53
Reviewed-on: https://go-review.googlesource.com/c/go/+/249878
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2020-09-09 22:39:02 +00:00
Bryan C. Mills
521393e7e0 cmd/go/internal/modget: move MVS code to a separate file
For #36460

Change-Id: Ie81c03df18c6987527da765d5f6575556340cb01
Reviewed-on: https://go-review.googlesource.com/c/go/+/249877
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-09-09 22:38:35 +00:00
Bryan C. Mills
363fb4bcc8 cmd/go/internal/modload: consolidate buildList and associated functions into one file
Change-Id: I310c37c7f0ce5581f07cf6e27d1f6361d03b92ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/244077
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-09-09 22:38:16 +00:00
Bryan C. Mills
d27ebc7b86 cmd/go/internal/modload: implement the "all" pattern for lazy loading
The new semantics of the "all" package pattern can be implemented
without actually changing module loading per se. This change
implements those semantics, so that the change can be decoupled from
the changes to the module requirement graph.

For #36460

Change-Id: I0ee8b17afa8b728dc470a42a540fcc01764a4442
Reviewed-on: https://go-review.googlesource.com/c/go/+/240623
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2020-09-09 22:37:22 +00:00
Tzu-Chiao Yeh
b4944ef310 cmd: update golang.org/x/tools to v0.0.0-20200901153117-6e59e24738da
Includes the latest fix on vet to warn unused context.WithValue result.

Fixes #41149

Change-Id: I06c204f40ef12b0f62f59b1bbdf1fe06ccd6565d
Reviewed-on: https://go-review.googlesource.com/c/go/+/252941
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-09-09 22:03:39 +00:00
Bryan C. Mills
cd91ab5d96 cmd/go/internal/modload: fix spurious import resolution error
Due to a bug in CL 173017, if QueryPackages found multiple candidates
for the given package and *at least* one of those candidates was not
available to add, we would reject *all* such candidates — even those
that were still viable.

Now, we return the first viable candidate, and only return an error if
*no* candidate is viable given the current build list.

Fixes #41113

Change-Id: Idb2e77244be7c0f5dd511efb142c3059925d7336
Reviewed-on: https://go-review.googlesource.com/c/go/+/251446
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2020-09-09 21:29:10 +00:00
Steven Hartland
2c8d2a0c51 net/http: fix data race due to writeLoop goroutine left running
Fix a data race for clients that mutate requests after receiving a
response error which is caused by the writeLoop goroutine left
running, this can be seen on cancelled requests.

Fixes #37669

Change-Id: Ia4743c6b8abde3a7503de362cc6a3782e19e7f60
Reviewed-on: https://go-review.googlesource.com/c/go/+/251858
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-09-09 21:25:35 +00:00
Bryan C. Mills
015a5a5c5c cmd/go/internal/modload: rework import resolution
modload.Import previously performed two otherwise-separable tasks:

1. Identify which module in the build list contains the requested
   package.

2. If no such module exists, search available modules to try to find
   the missing package.

This change splits those two tasks into two separate unexported
functions, and reports import-resolution errors by attaching them to
the package rather than emitting them directly to stderr. That allows
'list' to report the errors, but 'list -e' to ignore them.

With the two tasks now separate, it will be easier to avoid the
overhead of resolving missing packages during lazy loading if we
discover that some existing dependency needs to be promoted to the top
level (potentially altering the main module's selected versions, and
thus suppling packages that were previously missing).

For #36460
Updates #26909

Change-Id: I32bd853b266d7cd231d1f45f92b0650d95c4bcbd
Reviewed-on: https://go-review.googlesource.com/c/go/+/251445
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2020-09-09 20:53:04 +00:00
Bryan C. Mills
26d27f96fe cmd/go/internal/modload: remove (*loader).forceStdVendor
forceStdVendor was a special-case mechanism to allow Go contributors
to use vendored dependencies by default when working in GOROOT/src.

As of Go 1.14,¹ the 'go' command uses vendored dependencies by default
within all modules, so the 'std' and 'cmd' modules no longer need to
be special cases, and we can remove this special-case code.

¹ https://golang.org/doc/go1.14#vendor

Updates #33848
Updates #30241

Change-Id: Ib2fb5841c253113b17fa86a086ce85a22ac3d121
Reviewed-on: https://go-review.googlesource.com/c/go/+/251159
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2020-09-09 20:47:23 +00:00
Bryan C. Mills
b96d32bd92 cmd/go/internal/modload: track which packages are in 'all' during loading
If the user requests the 'all' pattern in addition to explicit roots
outside of 'all', we should not load the transitive dependencies of
those explicit roots as if they were *in* 'all'. Without the '-test'
flag, we should not load test dependencies of any package outside of
'all'. Even *with* the '-test' flag, we should only load test
dependencies of the requested roots, not test dependencies of other
packages that happen to be imported by those roots.

More precise tracking of membership in 'all' will be important when we
implement lazy loading, because membership in 'all' determines which
module dependencies we will record in the main module's go.mod file.

This change also reduces reliance on global state, factors out the
loading process into several smaller functions, and sets us up to
reuse the 'go mod vendor' version of the 'all' pattern for lazy
loading.

For #36460
Fixes #40799

Change-Id: I5ca21c86a860daee1316f732cea131a331d8ddf9
Reviewed-on: https://go-review.googlesource.com/c/go/+/240505
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2020-09-09 20:46:48 +00:00
Ian Lance Taylor
2556eb76c8 runtime: ignore SIGPROF if profiling disable for thread
This avoids a deadlock on prof.signalLock between setcpuprofilerate
and cpuprof.add if a SIGPROF is delivered to the thread between the
call to setThreadCPUProfiler and acquiring prof.signalLock.

Fixes #41014

Change-Id: Ie825e8594f93a19fb1a6320ed640f4e631553596
Reviewed-on: https://go-review.googlesource.com/c/go/+/253758
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-09-09 18:04:10 +00:00
Michael Anthony Knyszek
34835df048 runtime: fix ReadMemStatsSlow's and CheckScavengedBits' chunk iteration
Both ReadMemStatsSlow and CheckScavengedBits iterate over the page
allocator's chunks but don't actually check if they exist. During the
development process the chunks index became sparse, so now this was a
possibility. If the runtime tests' heap is sparse we might end up
segfaulting in either one of these functions, though this will generally
be very rare.

The pattern here to return nil for a nonexistent chunk is also useful
elsewhere, so this change introduces tryChunkOf which won't throw, but
might return nil. It also updates the documentation of chunkOf.

Fixes #41296.

Change-Id: Id5ae0ca3234480de1724fdf2e3677eeedcf76fa0
Reviewed-on: https://go-review.googlesource.com/c/go/+/253777
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-09-09 17:48:56 +00:00
Cuong Manh Le
9ef3ee3396 cmd/link: remove unnecessary type conversion for nitablinks
It's already an uint64.

Change-Id: Ic4cdb957aa4f9245c1ea3f946bcb740f116dd04b
Reviewed-on: https://go-review.googlesource.com/c/go/+/253679
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-09-09 17:18:41 +00:00
Cherry Zhang
83ed734df0 cmd/link: pre-resolve package reference
Pre-resolve package index references, so it doesn't need to do a
map lookup in every cross-package symbol reference resolution. It
increases the memory usage very slightly (O(# imported packages)).

Change-Id: Ia76c97ac51f1c2c2d5ea7ae34853850ec69ef0a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/253604
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-09-09 15:15:33 +00:00
Jay Conrod
bdad428570 cmd/go: make 'go get' preserve sums for content of new requirements
This preserves zip sums when 'go get' is run on a module that does not
have a package in the root directory. The zip must be fetched to
determine whether the package should be loaded, so we already load and
verify the sum.

Note that 'go mod tidy' may still remove these sums, since they
aren't needed to load packages.

Fixes #41103

Change-Id: I78f10a25f0392461fdc98518a7c92a38ee3233c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/251880
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-09-09 13:30:35 +00:00
Cuong Manh Le
518369601c cmd/compile: add Type.IsUintptr() to detect type is an uintptr
Passes toolstash-check.

Change-Id: I7051d45eafbfd4dea73a3d4b5ea6cff39d76cbc1
Reviewed-on: https://go-review.googlesource.com/c/go/+/253658
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-09-09 08:03:14 +00:00
Cuong Manh Le
9cf88333e8 cmd/compile: consistently use Type.IsUnsafePtr()
Passes toolstash-check.

Change-Id: Iaeae7cc20e26af733642c7c8c7ca0a059e5b07b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/253657
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-09-09 08:03:05 +00:00
Cuong Manh Le
bdb480fd62 cmd/compile: fix mishandling of unsafe-uintptr arguments in go/defer
Currently, the statement:

	go g(uintptr(f()))

gets rewritten into:

	tmp := f()
	newproc(8, g, uintptr(tmp))
	runtime.KeepAlive(tmp)

which doesn't guarantee that tmp is still alive by time the g call is
scheduled to run.

This CL fixes the issue, by wrapping g call in a closure:

	go func(p unsafe.Pointer) {
		g(uintptr(p))
	}(f())

then this will be rewritten into:

	tmp := f()
	go func(p unsafe.Pointer) {
		g(uintptr(p))
		runtime.KeepAlive(p)
	}(tmp)
	runtime.KeepAlive(tmp)  // superfluous, but harmless

So the unsafe.Pointer p will be kept alive at the time g call runs.

Updates #24491

Change-Id: Ic10821251cbb1b0073daec92b82a866c6ebaf567
Reviewed-on: https://go-review.googlesource.com/c/go/+/253457
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-09-09 07:50:01 +00:00
Cherry Zhang
1e6ad65b43 cmd/link: enable DWARF combining on macOS ARM64
It appears the machoCalcStart function is meant to align the
segment, but it doesn't. Replace it with an actual alignment
calculation. Also, use the alignment from the configuration,
instead of hardcode.

With this fix we could enable DWARF combining on macOS ARM64.

Change-Id: I19ec771b77d752b83a54c53b6ee65af78a31b8ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/253558
Reviewed-by: Than McIntosh <thanm@google.com>
2020-09-08 18:52:38 +00:00
Cherry Zhang
a52a5d8a43 cmd/link: mark ELF PLT sections executable
Change-Id: Ie0316a06c30485f783c2175590d7e9fc4fa3e0cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/253021
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-09-08 17:19:24 +00:00
Cherry Zhang
ae3680b30b cmd/link: rewrite some code without using reflection
In Mach-O DWARF combining, some code was written using reflection,
so it could support both 32-bit and 64-bit Mach-O files without
duplicating code. We no longer support 32-bit darwin platforms
now. 32-bit support can go. Rewrite it with direct field access,
for 64-bit only.

Change-Id: If1338c3cd37cecf603f4df0c6eb0c890eaebfe5f
Reviewed-on: https://go-review.googlesource.com/c/go/+/253557
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-09-08 17:01:02 +00:00
Cherry Zhang
e8f918535e cmd/link: strip STAB (symbolic debugging) symbols on darwin
On darwin, with external linking, the system linker produces STAB
(symbolic debugging) symbols in the binary's symbol table. These
include paths of the intermediate object files, like
<tmpdir>/go.o, which changes from run to run, making the build
non-reproducible.

Since we run dsymutil to produce debug info and combine them
back into the binary, we don't need those STAB symbols anymore.
Strip them after running dsymutil.

If DWARF is not enabled, we don't run dsymutil. We can pass
"-Wl,-S" to let the system linker not generate those symbols.

While here, also make it more consistent about DWARF combining.
Currently we only do DWARF combining on macOS/AMD64, when DWARF
is enabled. On ARM64, we run dsymutil, but then throw the result
away. This CL changes it to not run dsymutil (and strip) on
ARM64.

TODO: add a test. We don't do it here as it fails on some
(non-darwin) platforms.

Fixes #40979.

Change-Id: If770f7828cdb858857d6079e0585bf067f8f7a92
Reviewed-on: https://go-review.googlesource.com/c/go/+/250944
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-09-08 15:09:48 +00:00
chainhelen
565ad134c9 runtime: make PCDATA_RegMapUnsafe more clear and remove magic number
Change-Id: Ibf3ee755c3fbec03a9396840dc92ce148c49d9f7
GitHub-Last-Rev: 945d8aaa13
GitHub-Pull-Request: golang/go#41262
Reviewed-on: https://go-review.googlesource.com/c/go/+/253377
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-09-08 15:07:20 +00:00
Martin Möhrmann
f98f3b0c30 runtime: remove outdated comment in mkduff.go about usage of STOSQ
Change-Id: I71966cc5def4615d64876165872e5e7f2956b270
Reviewed-on: https://go-review.googlesource.com/c/go/+/253397
Run-TryBot: Martin Möhrmann <martisch@uos.de>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-09-07 19:01:17 +00:00
Cuong Manh Le
dc025c0f9b cmd/compile: handle ODDD in exprformat
Fixes #41247

Change-Id: Iaa9502cc610e2cc64be5dfd91ba3187f86f87cbd
Reviewed-on: https://go-review.googlesource.com/c/go/+/252942
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2020-09-07 05:44:53 +00:00
fanzha02
0e19aaabc0 cmd/asm: fix the error of checking the post-index offset of VLD[1-4]R instructions of arm64
The post-index offset of VLD[1-4]R instructions is decided by the
"size" field not "Q" field, the current assembler uses "Q" fileld
to check the correctness of post-index offset which is not correct.
This patch fixes it.

Fixes #40725

Change-Id: If1cde7f21c6b3ee0e491649eb567700bd1475c84
Reviewed-on: https://go-review.googlesource.com/c/go/+/249757
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-09-07 03:28:25 +00:00
Cuong Manh Le
1a119edd8b runtime: rotate map key seed on clearing up maps
Same thing as CL 253020 did for map clear idiom.

name                        old time/op  new time/op  delta
MapDelete/Int32/100-12      30.0ns ± 1%  30.7ns ± 3%   ~     (p=0.400 n=3+3)
MapDelete/Int32/1000-12     26.6ns ± 2%  28.1ns ± 3%   ~     (p=0.100 n=3+3)
MapDelete/Int32/10000-12    28.6ns ± 1%  31.9ns ± 1%   ~     (p=0.100 n=3+3)
MapDelete/Int64/100-12      30.2ns ± 0%  32.1ns ± 3%   ~     (p=0.100 n=3+3)
MapDelete/Int64/1000-12     26.5ns ± 1%  27.5ns ± 3%   ~     (p=0.100 n=3+3)
MapDelete/Int64/10000-12    29.6ns ± 1%  29.3ns ± 1%   ~     (p=0.300 n=3+3)
MapDelete/Str/100-12        19.5ns ± 3%  19.6ns ± 2%   ~     (p=0.800 n=3+3)
MapDelete/Str/1000-12       31.6ns ± 1%  31.4ns ± 1%   ~     (p=0.500 n=3+3)
MapDelete/Str/10000-12      37.8ns ± 1%  37.1ns ± 1%   ~     (p=0.100 n=3+3)
MapDelete/Pointer/100-12    15.9ns ± 1%  16.8ns ± 9%   ~     (p=0.200 n=3+3)
MapDelete/Pointer/1000-12   26.9ns ± 1%  26.2ns ± 2%   ~     (p=0.200 n=3+3)
MapDelete/Pointer/10000-12  30.6ns ± 1%  30.7ns ± 4%   ~     (p=0.700 n=3+3)

Fixes #25237

Change-Id: I353cf44a2f6158549f0ef563d867f0844fec7095
Reviewed-on: https://go-review.googlesource.com/c/go/+/252940
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
2020-09-07 02:46:24 +00:00
Alberto Donizetti
5cc030aa19 go/ast: note that in BasicLit CHARs and STRINGs are quoted
The Value field of ast.BasicLit is a string field holding the literal
string. For CHARs and STRINGs, the BasicLit.Value literal includes
quotes, so to use the value in practise one will often need to Unquote
it.

Since this is a common gotcha (I've been bitten by this a few times),
document it, and suggest the use of the strconv.Unquote functions.

Fixes #39590

Change-Id: Ie3e13f5a2a71bb1b59e03bc5b3a16d8e2e7c01d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/244960
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2020-09-06 20:23:50 +00:00
Michael Fraenkel
617f2c3e35 net/http: mark http/2 connections active
On Server.Shutdown, all idle connections are closed.
A caveat for new connections is that they are marked idle
after 5 seconds.
Previously new HTTP/2 connections were marked New, and after 5 seconds,
they would then become idle. With this change, we now mark HTTP/2
connections as Active to allow the proper shutdown sequence to occur.

Fixes #36946
Fixes #39776

Change-Id: I31efbf64b9a2850ca544da797f86d7e1b3378e8b
Reviewed-on: https://go-review.googlesource.com/c/go/+/240278
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-09-06 17:26:55 +00:00
Ainar Garipov
b60ec4cc4b mime: add examples for FormatMediaType and ParseMediaType
Change-Id: Ic129c58784ad1f0b8b90fc9d33e52bee61bdf0eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/253237
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-09-06 05:12:37 +00:00
Ainar Garipov
c489330987 doc/go1.16: reformat the minor changes section as a definition list
Change the section to use <dl>, <dt>, and <dd> tags to match
previous documents.

Change-Id: Ide0bea698a84ed6b61b364ef9e2f3801ebb8d4d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/250897
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-09-05 18:40:02 +00:00
Paschalis Tsilias
62fe10bf4e src/go.mod, net/http: update bundled and latest golang.org/x/net
Updates x/net/http2 to git rev 62affa334b73ec65ed44a326519ac12c421905e3

    x/net/http2: reject HTTP/2 Content-Length headers containing a sign
    https://go-review.googlesource.com/c/net/+/236098/ (fixes #39017)

also updates the vendored version of golang.org/x/net by running

go get golang.org/x/net@62affa334b73ec65ed44a326519ac12c421905e3
go mod tidy
go mod vendor
go generate -run bundle net/http

Change-Id: I7ecfdb7644574c44c3616e3b47664eefd4c926f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/253238
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-09-05 16:55:51 +00:00
David Chase
bf833ead62 cmd/compile: ensure that ssa.Func constant cache is consistent
It was not necessarily consistent before, we were just lucky.

Change-Id: I3a92dc724e0af7b4d810a6a0b7b1d58844eb8f87
Reviewed-on: https://go-review.googlesource.com/c/go/+/251440
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-09-05 14:11:21 +00:00
Changkun Ou
721819e7ba testing: make TempDir idempotent for both Cleanup and Benchmark
Ensures that calling TempDir() in either of Cleanup or Benchmark
doesn't cause test failures which were previously caused by the
created directory having been deleted after the first run, yet
we prevented the recreation of the directory due to our selection
of concurrency primitive sync.Once. This change recreates the
temporary directory if it doesn't exist, regardless of how
many times Cleanup and Benchmark are invoked.

Fixes #41062

Change-Id: I925d9f7207d7c369a193d1e17da7a59a586244a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/251297
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-09-05 04:21:49 +00:00
Benjamin Barenblat
93810ac1f4 runtime: opportunistically rotate map key seed
When clearing a map, reinitialize the hash seed with random data. This
makes it more difficult for attackers to trigger pathological
performance via repeated hash collisions.

The extra reinitialization causes no statistically significant slowdown:

name                              old time/op  new time/op  delta
GoMapClear/Reflexive/1-12         18.3ns ± 0%  20.0ns ± 0%   ~             (p=1.000 n=1+1)
GoMapClear/Reflexive/10-12        18.2ns ± 0%  19.8ns ± 0%   ~             (p=1.000 n=1+1)
GoMapClear/Reflexive/100-12       44.6ns ± 0%  46.1ns ± 0%   ~             (p=1.000 n=1+1)
GoMapClear/Reflexive/1000-12       592ns ± 0%   592ns ± 0%   ~     (all samples are equal)
GoMapClear/Reflexive/10000-12     3.88µs ± 0%  3.88µs ± 0%   ~             (p=1.000 n=1+1)
GoMapClear/NonReflexive/1-12      62.7ns ± 0%  63.9ns ± 0%   ~             (p=1.000 n=1+1)
GoMapClear/NonReflexive/10-12     75.0ns ± 0%  76.1ns ± 0%   ~             (p=1.000 n=1+1)
GoMapClear/NonReflexive/100-12     203ns ± 0%   206ns ± 0%   ~             (p=1.000 n=1+1)
GoMapClear/NonReflexive/1000-12   2.33µs ± 0%  2.33µs ± 0%   ~     (all samples are equal)
GoMapClear/NonReflexive/10000-12  18.1µs ± 0%  18.1µs ± 0%   ~             (p=1.000 n=1+1)

Fixes #25237

Change-Id: I629a79dd7c562ba18bd94159673c3b9b653da643
Reviewed-on: https://go-review.googlesource.com/c/go/+/253020
Reviewed-by: Keith Randall <khr@golang.org>
2020-09-03 22:08:58 +00:00
Cherry Zhang
612b119447 cmd/link: pass darwin/amd64-specific flags only on AMD64
The linker assumed macOS is AMD64 (and 386 in the past). It
passes darwin/amd64-specific flags to the external linker when
building for macOS. They don't work for ARM64-based macOS. So
only pass them on AMD64.

Disable DWARF combining for macOS ARM64 for now. The generated
binary doesn't run. (TODO: fix.)

For macOS ARM64 port. External linking now works.

Change-Id: Iab53bc48f4fadd9b91de8898b4b450ea442667a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/253019
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-09-03 21:50:25 +00:00
Cherry Zhang
e61d17d3b9 cmd/link: MACHOPLT is executable
The PLT stubs are executable. Put it together with executable
sections, instead of read-only data sections.

Change-Id: I3818414aa0b87c6968c6c7eccce19b0db7c43193
Reviewed-on: https://go-review.googlesource.com/c/go/+/253018
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-09-03 21:49:52 +00:00
Jeremy Faller
5402d40d5b [dev.link] cmd/link: fix memory growth on dev.link
CL 247399 caused memory growth in the linker. Fix this by adjusting how
we preallocate the number of symbols we'll need.

cmd/compile (Darwin), alloc/op:
Loadlib_GC                   33.5MB ± 0%    27.3MB ± 0%

Change-Id: I34997329ea4412716114df97fc9dad6ad0c171ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/249024
Run-TryBot: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-09-03 15:50:46 +00:00
fanzha02
ae658cb19a cmd/compile: store the comparison pseudo-ops of arm64 conditional instructions in AuxInt
The current implementation stores the comparison pseudo-ops of arm64
conditional instructions (CSEL/CSEL0) in Aux, this patch modifies it
and stores it in AuxInt, which can avoid the allocation.

Change-Id: I0b69e51f63acd84c6878c6a59ccf6417501a8cfc
Reviewed-on: https://go-review.googlesource.com/c/go/+/252517
Run-TryBot: fannie zhang <Fannie.Zhang@arm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-09-03 14:45:27 +00:00
Austin Clements
a538b59fd2 cmd/go: define an asm macro for GOEXPERIMENT=regabi
This defines a macro for the regabi GOEXPERIMENT when assembling
runtime assembly code.

In general, assembly code will be shielded from the calling convention
change, but there is a small amount of runtime assembly that is going
to have to change. By defining a macro, we can easily make the small
necessary changes. The other option is to use build tags, but that
would require duplicating nontrivial amounts of unaffected code,
leading to potential divergence issues. (And unlike Go code, assembly
code can't depend on the compiler optimizing away branches on a
feature constant.) We consider the macro preferable, especially since
this is expected to be temporary as we transition to the new calling
convention.

Updates #40724.

Change-Id: I73984065123968337ec10b47bb12c4a1cbc07dc5
Reviewed-on: https://go-review.googlesource.com/c/go/+/252258
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-09-03 12:55:47 +00:00
Austin Clements
2b8b06ebbf cmd/internal/objabi: add regabi GOEXPERIMENT
This is the "feature flag" for the register calling convention work
(though since this work is expected to extend over a few releases,
it's not version-prefixed). This will let us develop the register
calling convention on the main branch while maintaining an easy toggle
between the old and new ABIs.

Updates #40724.

Change-Id: I129c8d87d34e6fa0910b6fa43efb35b706021637
Reviewed-on: https://go-review.googlesource.com/c/go/+/252257
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-09-03 12:55:46 +00:00
Nigel Tao
6c76edeb1b image/gif: have BenchmarkEncodeRealisticRGBA convert to RGBA
Change-Id: I98f5d987b92a29dcff06ae23b92f293cc7d6c02f
Reviewed-on: https://go-review.googlesource.com/c/go/+/252597
Reviewed-by: David Symonds <dsymonds@golang.org>
2020-09-03 05:33:35 +00:00
Cuong Manh Le
a4171d85d7 cmd/compile: do not declare func nodes
The primary responsibility of declare() to associate a symbol (Sym) with
a declaration (Node), so "oldname" will work. Function literals are
anonymous, so their symbols does not need to be declared.

Passes toolstash-check.

Change-Id: I739b1054e3953e85fbd74a99148b9cfd7e5a57eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/249078
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-09-03 02:48:11 +00:00
Cuong Manh Le
ace37d35f1 cmd/compile: do not push functions literal node to Func.Dcl
They are skipped while processing Func.Dcl anyway.

This CL does not pass toolstash-check, because it reduces the length
of Func.Dcl length, while that length is used to generate autotmp
variables name.

Change-Id: I408183e62ce6c34e5f04c89814ebb9570957e37b
Reviewed-on: https://go-review.googlesource.com/c/go/+/252418
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-09-03 02:48:04 +00:00
Dan Kortschak
0e48c674f5 cmd/go: add -Wl,-Bsymbolic-functions to cgo flags whitelist
Closes #41199

Change-Id: Iab69358e8c39e6d2b2797c7ce750df63aa7e96b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/252698
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-09-02 23:39:37 +00:00
Emmanuel T Odeke
ef20f76b8b net/http: reject negative suffix-length Range:bytes=--N with 416 status code
Fixes the file server to reject requests of the form:
    "Range": "bytes=--N"
where "-N" is a negative suffix-length as designated by the
grammar in RFC 7233 Section 2.1, "Byte-Ranges", which specifies
that suffix-length MUST be of the form 1*DIGIT aka a non-negative digit.

Thus requests such as:
    "Range": "bytes=--2"
will be rejected with a "416 Range Not Satisfiable" response.

Fixes #40940

Change-Id: I3e89f8326c14af30d8bdb126998a50e02ba002d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/252497
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-09-02 21:50:41 +00:00