]> Cypherpunks repositories - gostls13.git/log
gostls13.git
4 years agoruntime: add lock rank partial-order edge between fin and mheap
Michael Anthony Knyszek [Mon, 19 Oct 2020 17:55:55 +0000 (17:55 +0000)]
runtime: add lock rank partial-order edge between fin and mheap

finlock may be held across a write barrier, which could then acquire the
mheap lock. Notably, this occurs in the mp.unlockf write in gopark where
finlock is held by the finalizer goroutines and is going to sleep.

Fixes #42062.

Change-Id: Icf76637ae6fc12795436272633dca3d473780875
Reviewed-on: https://go-review.googlesource.com/c/go/+/263678
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
4 years agocmd/compile/internal/gc: use plural nouns in comments
hk [Mon, 19 Oct 2020 12:11:13 +0000 (12:11 +0000)]
cmd/compile/internal/gc: use plural nouns in comments

Change-Id: I99a5b5b88495cfaef16d41ee4b962c5d0b3488aa
GitHub-Last-Rev: fa0d895b3a87e45f499f02651a5f0e4946124765
GitHub-Pull-Request: golang/go#42059
Reviewed-on: https://go-review.googlesource.com/c/go/+/263617
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Keith Randall <khr@golang.org>
Trust: Robert Griesemer <gri@golang.org>

4 years agocmd/compile: fix ICE in reporting of invalid recursive types
Matthew Dempsky [Mon, 19 Oct 2020 21:14:40 +0000 (14:14 -0700)]
cmd/compile: fix ICE in reporting of invalid recursive types

asNode(t.Nod).Name.Param will be nil for builtin types (i.e., the
universal predeclared types and unsafe.Pointer). These types can't be
part of a cycle anyway, so we can just skip them.

Fixes #42075.

Change-Id: Ic7a44de65c6bfd16936545dee25e36de8850acf3
Reviewed-on: https://go-review.googlesource.com/c/go/+/263717
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
4 years agoRevert "net/http: test that ParseMultipartForm returns an error for int overflow"
Bryan C. Mills [Mon, 19 Oct 2020 18:03:51 +0000 (18:03 +0000)]
Revert "net/http: test that ParseMultipartForm returns an error for int overflow"

This reverts CL 254977.

Reason for revert: introduced test failures on longtest builders.

Change-Id: I75e868245f980189ad85dd4103d9178989e06ecf
Reviewed-on: https://go-review.googlesource.com/c/go/+/263658
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
4 years agocmd/dist,cmd/go: broaden use of asm macro GOEXPERIMENT_REGABI
Than McIntosh [Wed, 14 Oct 2020 12:06:54 +0000 (08:06 -0400)]
cmd/dist,cmd/go: broaden use of asm macro GOEXPERIMENT_REGABI

This extends a change made in https://golang.org/cl/252258 to the go
command (to define an asm macro when GOEXPERIMENT=regabi is in
effect); we need this same macro during the bootstrap build in order
to build the runtime correctly.

In addition, expand the set of packages where the macro is applied to
{runtime, reflect, syscall, runtime/internal/*}, and move the logic
for deciding when something is a "runtime package" out of the
assembler and into cmd/{go,dist}, introducing a new assembler command
line flag instead.

Updates #27539, #40724.

Change-Id: Ifcc7f029f56873584de1e543c55b0d3e54ad6c49
Reviewed-on: https://go-review.googlesource.com/c/go/+/262317
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocompress/flate: fix corrupted output
Klaus Post [Sat, 17 Oct 2020 15:19:53 +0000 (15:19 +0000)]
compress/flate: fix corrupted output

The fastest compression mode can pick up a false match for every 2GB
of input data resulting in incorrectly decompressed data.

Since matches are allowed to be up to and including at maxMatchOffset
we must offset the buffer by an additional element to prevent the first
4 bytes to match after an out-of-reach value after shiftOffsets has
been called.

We offset by `maxMatchOffset + 1` so offset 0 in the table will now
fail the `if offset > maxMatchOffset` in all cases.

Fixes #41420

Change-Id: If1fbe01728e132b8a207e3f3f439edd832dcc710
GitHub-Last-Rev: 50fabab0da874c37543b139459a810e12e83cee2
GitHub-Pull-Request: golang/go#41477
Reviewed-on: https://go-review.googlesource.com/c/go/+/255879
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Joe Tsai <thebrokentoaster@gmail.com>
Trust: Matthew Dempsky <mdempsky@google.com>

4 years agocmd/link: run generator functions along with symbol writing
Cherry Zhang [Sat, 17 Oct 2020 18:00:35 +0000 (14:00 -0400)]
cmd/link: run generator functions along with symbol writing

Like we do for applying relocations, for generator symbols, run
the generator function along with symbol writing. This will
probably have better locality and parallelism.

Linking cmd/compile,

Asmb          29.9ms ± 5%    19.1ms ±12%  -36.18%  (p=0.000 n=10+9)
TotalTime      351ms ± 3%     339ms ± 2%   -3.51%  (p=0.000 n=11+10)

Change-Id: I9cda6718bf70b3bcf1b7a501a845d6136234d2ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/263640
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/link: fix TestDWARFiOS
Cherry Zhang [Sat, 17 Oct 2020 01:42:01 +0000 (21:42 -0400)]
cmd/link: fix TestDWARFiOS

Use GOOS=ios.

Run "xcodebuild -showsdks" correctly.

Wrap testDWARF in subtests, as it calls t.Parallel, otherwise
the two calls of testDWARF will cause t.Parallel being called
twice, which panics.

Updates #38485.

Change-Id: I614c8daa99c83cbfd05a4cfa041968d49279f16a
Reviewed-on: https://go-review.googlesource.com/c/go/+/263639
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agoruntime: define ios/arm64 entry points
Cherry Zhang [Sat, 17 Oct 2020 01:39:36 +0000 (21:39 -0400)]
runtime: define ios/arm64 entry points

Updates #38485.

Change-Id: I030346c7f0c3ce89209588525b210284fdea4efd
Reviewed-on: https://go-review.googlesource.com/c/go/+/263638
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agoRevert "cmd/link: put C static symbols in the symbol table"
Cherry Zhang [Mon, 19 Oct 2020 18:16:31 +0000 (18:16 +0000)]
Revert "cmd/link: put C static symbols in the symbol table"

This reverts CL 263259.

Reason for revert: break AIX builder.

Change-Id: I3abb0b1f509961a06f1567d8c87679b0ca5782d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/263660
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/compile/internal/gc: remove an unused method
hk [Mon, 19 Oct 2020 12:13:25 +0000 (12:13 +0000)]
cmd/compile/internal/gc: remove an unused method

Change-Id: Ib496d1e9a47d2cf69509ffd0009038b7d34a0149
GitHub-Last-Rev: 5b5589dd03e1d781e4cedc643d5e8a7f8bda2139
GitHub-Pull-Request: golang/go#42060
Reviewed-on: https://go-review.googlesource.com/c/go/+/263618
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agonet/http: test that ParseMultipartForm returns an error for int overflow
avivklas [Tue, 15 Sep 2020 05:48:44 +0000 (08:48 +0300)]
net/http: test that ParseMultipartForm returns an error for int overflow

ParseMultipartForm has been changed to return an error if maxMemory
parameter + 10MB causes int overflows. This adds a test for the new
behaviour.

For #40430

Change-Id: I4f66ce8a9382940182011d22a84ee52b1d1364cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/254977
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>

4 years agonet/http/httputil: copy response header back to http.ResponseWriter in ReverseProxy...
Aofei Sheng [Sat, 26 Sep 2020 05:21:41 +0000 (13:21 +0800)]
net/http/httputil: copy response header back to http.ResponseWriter in ReverseProxy.handleUpgradeResponse

Fixes: #41634
Change-Id: Ib78cc37a4d2ca0753d567eafb616238e4103484e
Reviewed-on: https://go-review.googlesource.com/c/go/+/257777
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocrypto/hmac: panic if reusing hash.Hash values
Katie Hockman [Tue, 13 Oct 2020 20:33:46 +0000 (16:33 -0400)]
crypto/hmac: panic if reusing hash.Hash values

Also put Reset in the correct place for the other
benchmarks.

name           old time/op    new time/op    delta
NewWriteSum-8    1.01µs ± 0%    1.01µs ± 1%   ~     (p=0.945 n=9+9)

name           old speed      new speed      delta
NewWriteSum-8  31.7MB/s ± 0%  31.6MB/s ± 1%   ~     (p=0.948 n=9+9)

name           old alloc/op   new alloc/op   delta
NewWriteSum-8      544B ± 0%      544B ± 0%   ~     (all equal)

name           old allocs/op  new allocs/op  delta
NewWriteSum-8      7.00 ± 0%      7.00 ± 0%   ~     (all equal)

Fixes #41089

Change-Id: I3dae660adbe4993963130bf3c2636bd53899164b
Reviewed-on: https://go-review.googlesource.com/c/go/+/261960
Trust: Katie Hockman <katie@golang.org>
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
4 years agointernal/bytealg: add assembly implementation of Count/CountString for riscv64
Tobias Klauser [Mon, 19 Oct 2020 09:09:10 +0000 (11:09 +0200)]
internal/bytealg: add assembly implementation of Count/CountString for riscv64

Simple single-byte loop count for now, to be further improved in future
CLs.

Benchmark on linux/riscv64 (HiFive Unleashed):

name               old time/op    new time/op     delta
CountSingle/10-4      190ns ± 1%      145ns ± 1%  -23.66%  (p=0.000 n=10+9)
CountSingle/32-4      422ns ± 1%      268ns ± 0%  -36.43%  (p=0.000 n=10+7)
CountSingle/4K-4     43.3µs ± 0%     23.8µs ± 0%  -45.09%  (p=0.000 n=8+10)
CountSingle/4M-4     54.2ms ± 1%     33.3ms ± 1%  -38.48%  (p=0.000 n=10+10)
CountSingle/64M-4     1.52s ± 1%      1.20s ± 1%  -21.20%  (p=0.000 n=9+9)

name               old speed      new speed       delta
CountSingle/10-4   52.7MB/s ± 1%   69.1MB/s ± 1%  +31.03%  (p=0.000 n=10+9)
CountSingle/32-4   75.9MB/s ± 1%  119.5MB/s ± 0%  +57.34%  (p=0.000 n=10+8)
CountSingle/4K-4   94.6MB/s ± 0%  172.2MB/s ± 0%  +82.10%  (p=0.000 n=8+10)
CountSingle/4M-4   77.4MB/s ± 1%  125.8MB/s ± 1%  +62.54%  (p=0.000 n=10+10)
CountSingle/64M-4  44.2MB/s ± 1%   56.1MB/s ± 1%  +26.91%  (p=0.000 n=9+9)

Change-Id: I2a6bd50d22d5f598517bb3c5a50066c54280cac5
Reviewed-on: https://go-review.googlesource.com/c/go/+/263541
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
4 years agocmd/link: put C static symbols in the symbol table
Cherry Zhang [Fri, 16 Oct 2020 21:37:52 +0000 (17:37 -0400)]
cmd/link: put C static symbols in the symbol table

We don't put Go static symbols in the symbol table, as they are
always compiler-generated (there is no way to define a static
symbol in user code in Go). We retain static symbols in assembly
code, as it may be user-defined. Also retain static symbols in C.

Change-Id: Ie0425bb4df33f183857b1fd5ba4b2bdfdc497571
Reviewed-on: https://go-review.googlesource.com/c/go/+/263259
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agoRevert "test: add regression test from #41474"
Alberto Donizetti [Sun, 18 Oct 2020 20:21:03 +0000 (20:21 +0000)]
Revert "test: add regression test from #41474"

This reverts CL 263097.

Reason for revert: broke the noopt builder.

Change-Id: Ie36d2c3ed9449b4425732072db624c8e18f965f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/263537
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>

4 years agocmd: go get golang.org/x/tools@d1624618 && go mod vendor
Than McIntosh [Wed, 14 Oct 2020 12:14:44 +0000 (08:14 -0400)]
cmd: go get golang.org/x/tools@d1624618 && go mod vendor

This brings in CL 262197, which enables handling of ABI selector
syntax in the asmdecl checker.

Updates #27539, #40724.

Change-Id: I088f5eeacb3588ed49c4aa2277641049bf5b9083
Reviewed-on: https://go-review.googlesource.com/c/go/+/262318
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Than McIntosh <thanm@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/asm: allow def/ref of func ABI when compiling runtime
Than McIntosh [Wed, 7 Oct 2020 16:31:05 +0000 (12:31 -0400)]
cmd/asm: allow def/ref of func ABI when compiling runtime

Function symbols defined and referenced by assembly source currently
always default to ABI0; this patch adds preliminary support for
accepting an explicit ABI selector clause for func defs/refs. This
functionality is currently only enabled when compiling runtime-related
packages (runtime, syscall, reflect). Examples:

  TEXT ·DefinedAbi0Symbol<ABI0>(SB),NOSPLIT,$0
        RET

  TEXT ·DefinedAbi1Symbol<ABIInternal>(SB),NOSPLIT,$0
        CALL    ·AbiZerolSym<ABI0>(SB)
...
        JMP     ·AbiInternalSym<ABIInternal>(SB)
        RET

Also included is a small change to the code in the compiler that reads
the symabis file emitted by the assembler.

New behavior is currently gated under GOEXPERIMENT=regabi.

Updates #27539, #40724.

Change-Id: Ia22221fe26df0fa002191cfb13bdfaaa38d7df38
Reviewed-on: https://go-review.googlesource.com/c/go/+/260477
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Than McIntosh <thanm@google.com>

4 years agocmd/dist: detect gohostarch for openbsd/mips64
Joel Sing [Tue, 25 Aug 2020 17:18:30 +0000 (03:18 +1000)]
cmd/dist: detect gohostarch for openbsd/mips64

On OpenBSD/octeon `uname -m` returns 'octeon' and we need `uname -p` to determine
the processor type (mips64).

Update #40995

Change-Id: I37c53ca2c372ab958fff17917d82d41f4b0a0393
Reviewed-on: https://go-review.googlesource.com/c/go/+/250583
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/link: add support for external linking on linux/riscv64
Joel Sing [Thu, 13 Aug 2020 14:13:28 +0000 (00:13 +1000)]
cmd/link: add support for external linking on linux/riscv64

Fixes #36739

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

4 years agoruntime: use CreateWaitableTimerEx to implement usleep
Alex Brainman [Sun, 19 Jul 2020 06:06:48 +0000 (16:06 +1000)]
runtime: use CreateWaitableTimerEx to implement usleep

@jstarks suggested that recent versions of Windows provide access to high resolution timers. See

https://github.com/golang/go/issues/8687#issuecomment-656259353

for details.

I tried to run this C program on my Windows 10 computer

```
 #include <stdio.h>
 #include <Windows.h>

 #pragma comment(lib, "Winmm.lib")

// Apparently this is already defined when I use msvc cl.
//#define CREATE_WAITABLE_TIMER_HIGH_RESOLUTION = 0x00000002;

int usleep(HANDLE timer, LONGLONG d) {
LARGE_INTEGER liDueTime;
DWORD ret;
LARGE_INTEGER StartingTime, EndingTime, ElapsedMicroseconds;
LARGE_INTEGER Frequency;

QueryPerformanceFrequency(&Frequency);
QueryPerformanceCounter(&StartingTime);

liDueTime.QuadPart = d;
liDueTime.QuadPart = liDueTime.QuadPart * 10; // us into 100 of ns units
liDueTime.QuadPart = -liDueTime.QuadPart; // negative for relative dure time

if (!SetWaitableTimer(timer, &liDueTime, 0, NULL, NULL, 0)) {
printf("SetWaitableTimer failed: errno=%d\n", GetLastError());
return 1;
}

ret = WaitForSingleObject(timer, INFINITE);
if (ret != WAIT_OBJECT_0) {
printf("WaitForSingleObject failed: ret=%d errno=%d\n", ret, GetLastError());
return 1;
}

QueryPerformanceCounter(&EndingTime);
ElapsedMicroseconds.QuadPart = EndingTime.QuadPart - StartingTime.QuadPart;
ElapsedMicroseconds.QuadPart *= 1000000;
ElapsedMicroseconds.QuadPart /= Frequency.QuadPart;

printf("delay is %lld us - slept for %lld us\n", d, ElapsedMicroseconds.QuadPart);

return 0;
}

int testTimer(DWORD createFlag)
{
HANDLE timer;

timer = CreateWaitableTimerEx(NULL, NULL, createFlag, TIMER_ALL_ACCESS);
if (timer == NULL) {
printf("CreateWaitableTimerEx failed: errno=%d\n", GetLastError());
return 1;
}

usleep(timer, 1000LL);
usleep(timer, 100LL);
usleep(timer, 10LL);
usleep(timer, 1LL);

CloseHandle(timer);

return 0;
}

int main()
{
printf("\n1. CREATE_WAITABLE_TIMER_HIGH_RESOLUTION is off - timeBeginPeriod is off\n");
testTimer(0);

printf("\n2. CREATE_WAITABLE_TIMER_HIGH_RESOLUTION is on - timeBeginPeriod is off\n");
testTimer(CREATE_WAITABLE_TIMER_HIGH_RESOLUTION);

timeBeginPeriod(1);

printf("\n3. CREATE_WAITABLE_TIMER_HIGH_RESOLUTION is off - timeBeginPeriod is on\n");
testTimer(0);

printf("\n4. CREATE_WAITABLE_TIMER_HIGH_RESOLUTION is on - timeBeginPeriod is on\n");
testTimer(CREATE_WAITABLE_TIMER_HIGH_RESOLUTION);
}
```

and I see this output

```
1. CREATE_WAITABLE_TIMER_HIGH_RESOLUTION is off - timeBeginPeriod is off
delay is 1000 us - slept for 4045 us
delay is 100 us - slept for 3915 us
delay is 10 us - slept for 3291 us
delay is 1 us - slept for 2234 us

2. CREATE_WAITABLE_TIMER_HIGH_RESOLUTION is on - timeBeginPeriod is off
delay is 1000 us - slept for 1076 us
delay is 100 us - slept for 569 us
delay is 10 us - slept for 585 us
delay is 1 us - slept for 17 us

3. CREATE_WAITABLE_TIMER_HIGH_RESOLUTION is off - timeBeginPeriod is on
delay is 1000 us - slept for 742 us
delay is 100 us - slept for 893 us
delay is 10 us - slept for 414 us
delay is 1 us - slept for 920 us

4. CREATE_WAITABLE_TIMER_HIGH_RESOLUTION is on - timeBeginPeriod is on
delay is 1000 us - slept for 1466 us
delay is 100 us - slept for 559 us
delay is 10 us - slept for 535 us
delay is 1 us - slept for 5 us
```

That shows, that indeed using CREATE_WAITABLE_TIMER_HIGH_RESOLUTION
will provide sleeps as low as about 500 microseconds, while our
current approach provides about 1 millisecond sleep.

New approach also does not require for timeBeginPeriod to be on,
so this change solves long standing problem with go programs draining
laptop battery, because it calls timeBeginPeriod.

This change will only run on systems where
CREATE_WAITABLE_TIMER_HIGH_RESOLUTION flag is available. If not
available, the runtime will fallback to original code that uses
timeBeginPeriod.

This is how this change affects benchmark reported in issue #14790

name               old time/op  new time/op  delta
ChanToSyscallPing  1.05ms ± 2%  0.68ms ±11%  -35.43%  (p=0.000 n=10+10)

The benchmark was run with GOMAXPROCS set to 1.

Fixes #8687
Updates #14790

Change-Id: I5b97ba58289c088c17c05292e12e45285c467eae
Reviewed-on: https://go-review.googlesource.com/c/go/+/248699
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Austin Clements <austin@google.com>
4 years agosort: fix grammar in updated Less comment
zikaeroh [Sat, 17 Oct 2020 07:25:58 +0000 (00:25 -0700)]
sort: fix grammar in updated Less comment

The rewritten comment didn't sound right to my ears. Tweak it to be
grammatically correct.

Change-Id: Iae7d9f8810fff78cfd964bb3117099bce4479c14
Reviewed-on: https://go-review.googlesource.com/c/go/+/263180
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Robert Griesemer <gri@golang.org>

4 years agocmd/compile: fix defer/go calls to variadic unsafe-uintptr functions
Matthew Dempsky [Sat, 17 Oct 2020 08:10:06 +0000 (01:10 -0700)]
cmd/compile: fix defer/go calls to variadic unsafe-uintptr functions

Before generating wrapper function, turn any f(a, b, []T{c, d, e}...)
calls back into f(a, b, c, d, e). This allows the existing code for
recognizing and specially handling unsafe.Pointer->uintptr conversions
to correctly handle variadic arguments too.

Fixes #41460.

Change-Id: I0a1255abdd1bd5dafd3e89547aedd4aec878394c
Reviewed-on: https://go-review.googlesource.com/c/go/+/263297
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.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>
4 years agocmd/go/internal/modload: fix sort condition in (*replacementRepo).Versions
Bryan C. Mills [Sat, 17 Oct 2020 01:57:46 +0000 (21:57 -0400)]
cmd/go/internal/modload: fix sort condition in (*replacementRepo).Versions

In CL 258220 I added replacement versions to the repo versions used in
the modload.Query functions. The versions are computed from a map in
the modfile index, which has a nondeterministic iteration order.

I added a short-circuit condition to skip sorting in the (vastly
common) case where no replacement versions are added. However, while
cleaning up the change I accidentally deleted the line of code that
sets that condition. As a result, the test of that functionality
(mod_get_replaced) has been failing nondeterministically.

This change fixes the condition by comparing the slices before and
after adding versions, rather than by setting a separate variable.
The test now passes reliably (tested with -count=200).

Updates #41577
Updates #41416
Updates #37438
Updates #26241

Change-Id: I49a66a3a5510da00ef42b47f20a168de66100db6
Reviewed-on: https://go-review.googlesource.com/c/go/+/263266
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
4 years agotest: add regression test from #41474
Alberto Donizetti [Fri, 16 Oct 2020 15:48:29 +0000 (17:48 +0200)]
test: add regression test from #41474

This issue was fixed with multiple individual compiler optimizations,
each of which had their own respective test cases. This CL just adds
the capstone test case to demonstrate that the issue has been fixed
and doesn't regress again.

Updates #41474.

Change-Id: Iae752d4b0e7b83ee356b946843340a4fbc254058
Reviewed-on: https://go-review.googlesource.com/c/go/+/263097
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/link: use GOOS=ios for TestBuildForTvOS
Cherry Zhang [Sat, 17 Oct 2020 00:25:54 +0000 (20:25 -0400)]
cmd/link: use GOOS=ios for TestBuildForTvOS

Updates #38485.

Fix darwin-amd64-10_15 build.

Change-Id: I1833c23788acafc9530bb91fb6182fc5cb44f6cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/263265
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agosyscall: use MustHaveExec in TestExec
Ian Lance Taylor [Thu, 15 Oct 2020 21:19:10 +0000 (14:19 -0700)]
syscall: use MustHaveExec in TestExec

For #41702

Change-Id: Ib2b15e52aa1fef2f5e644b316c726150252fa9f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/262738
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agostrconv: use the Eisel-Lemire ParseFloat algorithm
Nigel Tao [Fri, 9 Oct 2020 12:18:05 +0000 (23:18 +1100)]
strconv: use the Eisel-Lemire ParseFloat algorithm

Also fix BenchmarkAtof64Random* to initialize the test data when none
of the TestAtof* tests are run.

Passing "go test -test.count=5 -test.run=xxx -test.bench=Atof64" on to
benchstat:

name                  old time/op  new time/op  delta
Atof64Decimal-4       47.9ns ± 0%  48.3ns ± 1%     ~     (p=0.238 n=4+5)
Atof64Float-4         58.3ns ± 3%  57.7ns ± 0%     ~     (p=0.151 n=5+5)
Atof64FloatExp-4       107ns ± 0%    71ns ± 1%  -33.89%  (p=0.016 n=4+5)
Atof64Big-4            163ns ± 0%   166ns ± 2%     ~     (p=0.159 n=4+5)
Atof64RandomBits-4     299ns ± 1%   166ns ± 1%  -44.41%  (p=0.008 n=5+5)
Atof64RandomFloats-4   188ns ± 1%   144ns ± 0%  -23.03%  (p=0.008 n=5+5)

The canada.json file from github.com/miloyip/nativejson-benchmark is
full of geospatial coordinates (i.e. numbers). With this program:

    src, _ := ioutil.ReadFile("canada.json")
    for i := 0; i < 5; i++ {
        now := time.Now()
        for j := 0; j < 10; j++ {
            dst := interface{}(nil)
            if err := json.Unmarshal(src, &dst); err != nil {
                log.Fatal(err)
            }
        }
        fmt.Println(time.Since(now))
    }

Median of the 5 printed numbers, lower is better.
Before: 760.819549ms
After:  702.651646ms
Ratio:  1.08x

The new detailedPowersOfTen table weighs in at 596 * 16 = 9536 bytes,
but some of that weight gain can be clawed back, in a follow-up commit,
that folds in the existing powersOfTen table in extfloat.go.

RELNOTE=yes

Change-Id: I3953110deaa1f5f6941e88e8417c4665b649ed80
Reviewed-on: https://go-review.googlesource.com/c/go/+/260858
Run-TryBot: Nigel Tao <nigeltao@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Nigel Tao <nigeltao@golang.org>

4 years agoruntime/cgo: fix build tag placement vet warning
Cherry Zhang [Fri, 16 Oct 2020 23:11:42 +0000 (19:11 -0400)]
runtime/cgo: fix build tag placement vet warning

Change-Id: Ie6583b46213caae897fc2189d4973c88759f5f4b
Reviewed-on: https://go-review.googlesource.com/c/go/+/263258
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agoruntime/cgo: build iOS-specific code only on iOS
Cherry Zhang [Wed, 14 Oct 2020 23:26:20 +0000 (19:26 -0400)]
runtime/cgo: build iOS-specific code only on iOS

Don't build them on macOS/ARM64.

Updates #38485.

Change-Id: I9fbea838fdce52db22742487926879761dea0d6a
Reviewed-on: https://go-review.googlesource.com/c/go/+/262559
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agoruntime: wait for preemption signals before syscall.Exec
Ian Lance Taylor [Thu, 15 Oct 2020 21:39:12 +0000 (14:39 -0700)]
runtime: wait for preemption signals before syscall.Exec

Fixes #41702
Fixes #42023

Change-Id: If07f40b1d73b8f276ee28ffb8b7214175e56c24d
Reviewed-on: https://go-review.googlesource.com/c/go/+/262817
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/objdump: skip TestDisasmExtld on AIX
Cherry Zhang [Fri, 16 Oct 2020 19:29:25 +0000 (15:29 -0400)]
cmd/objdump: skip TestDisasmExtld on AIX

Fixes #42025.

Change-Id: I34bed3364902e37df24ed6f56cddf163c7a4dc52
Reviewed-on: https://go-review.googlesource.com/c/go/+/263147
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agointernal/poll, net, syscall: use accept4 on illumos
Tobias Klauser [Fri, 16 Oct 2020 17:35:09 +0000 (19:35 +0200)]
internal/poll, net, syscall: use accept4 on illumos

Illumos supports the accept4 syscall, use it in internal/poll.accept
like on other platforms.

Add Accept4 to package syscall despite the package being frozen. The
other option would have been to add this to internal/syscall/unix, but
adding it to syscall avoids duplicating a lot of code in internal/poll
and net/internal/socktest. Also, all other platforms supporting the
accept4 syscall already export Accept4.

Follow CL 97196, CL 40895 and CL 94295

Change-Id: I13b32f0163a683840c02b16722730d9dfdb98f56
Reviewed-on: https://go-review.googlesource.com/c/go/+/256101
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
4 years agocmd/go/internal/modload: avoid using the global build list in QueryPattern
Bryan C. Mills [Mon, 12 Oct 2020 19:32:49 +0000 (15:32 -0400)]
cmd/go/internal/modload: avoid using the global build list in QueryPattern

The Query function allows the caller to specify the current version of
the requested module, but the QueryPattern function is missing that
parameter: instead, it always assumes that the current version is the
one selected from the global build list.

This change removes that assumption, instead adding a callback
function to determine the current version. (The callback is currently
invoked once per candidate module, regardless of whether that module
exists, but in a future change we can refactor it to invoke the
callback only when needed.)

For #36460
For #40775

Change-Id: I001a4a8ab24f5b4fcc66a670d9bd305b47e948ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/261640
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
4 years agocmd/go/internal/modload: allow 'go get' to use replaced versions
Bryan C. Mills [Tue, 29 Sep 2020 00:59:47 +0000 (20:59 -0400)]
cmd/go/internal/modload: allow 'go get' to use replaced versions

'go mod tidy' has been able to use replaced versions since CL 152739,
but 'go get' failed for many of the same paths. Now that we are
recommending 'go get' more aggressively due to #40728, we should make
that work too.

In the future, we might consider factoring out the new replacementRepo
type so that 'go list' can report the new versions as well.

For #41577
For #41416
For #37438
Updates #26241

Change-Id: I9140c556424b584fdd9bdd0a747842774664a7d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/258220
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agonet/http: try to deflake TestTransportDiscardsUnneededConns
Russ Cox [Fri, 16 Oct 2020 17:39:50 +0000 (13:39 -0400)]
net/http: try to deflake TestTransportDiscardsUnneededConns

Fixes #33585.
Fixes #36797.

Change-Id: I9202b624642368089a9ce827e3e7a7427100bf4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/263144
Trust: Russ Cox <rsc@golang.org>
Trust: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/go: normalize paths in TestScript/build_overlay
Bryan C. Mills [Fri, 16 Oct 2020 18:01:04 +0000 (14:01 -0400)]
cmd/go: normalize paths in TestScript/build_overlay

Fixes #42008

Change-Id: I1652e8cc4e72b4b7e52571ab12da29e717218a0b
Reviewed-on: https://go-review.googlesource.com/c/go/+/263145
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoio: unexport ErrBadWriteCount
Russ Cox [Fri, 16 Oct 2020 03:32:51 +0000 (23:32 -0400)]
io: unexport ErrBadWriteCount

It was added in CL 240740 to fix #39978
but without any discussion of the exported API.

The error can still be returned to fix the issue,
without adding new public API to package io.

Also fix the error message to refer to lower-case write
like the other errors in the package.

Change-Id: I134de5eaf3ac903d73913c5cadcde904c5255d79
Reviewed-on: https://go-review.googlesource.com/c/go/+/262877
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoruntime/internal/atomic: panic nicely on unaligned 64-bit atomics
Austin Clements [Thu, 15 Oct 2020 19:52:58 +0000 (15:52 -0400)]
runtime/internal/atomic: panic nicely on unaligned 64-bit atomics

On 386 and arm, unaligned 64-bit atomics aren't safe, so we check for
this and panic. Currently, we panic by dereferencing nil, which may be
expedient but is pretty user-hostile since it gives no hint of what
the actual problem was.

This CL replaces this with an actual panic. The only subtlety here is
now the atomic assembly implementations are calling back into Go, so
they have to play nicely with stack maps and stack scanning. On 386,
this just requires declaring NO_LOCAL_POINTERS. On arm, this is
somewhat more complicated: first, we have to move the alignment check
into the functions that have Go signatures. Then we have to support
both the tail call from these functions to the underlying
implementation (which requires that they have no frame) and the call
into Go to panic (which requires that they have a frame). We resolve
this by forcing them to have no frame and setting up the frame
manually just before the panic call.

Change-Id: I19f1e860045df64088013db37a18acea47342c69
Reviewed-on: https://go-review.googlesource.com/c/go/+/262778
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agoruntime/internal/atomic: drop package prefixes
Austin Clements [Thu, 15 Oct 2020 20:11:10 +0000 (16:11 -0400)]
runtime/internal/atomic: drop package prefixes

This drops package prefixes from the assembly code on 386 and arm. In
addition to just being nicer, this allows the assembler to
automatically pick up the argument stack map from the Go signatures of
these functions. This doesn't matter right now because these functions
never call back out to Go, but prepares us for the next CL.

Change-Id: I90fed7d4dd63ad49274529c62804211b6390e2e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/262777
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agocmd/objdump: skip tests on unsupported platforms
Cherry Zhang [Fri, 16 Oct 2020 16:11:02 +0000 (12:11 -0400)]
cmd/objdump: skip tests on unsupported platforms

Should fix mips(64)(le) and s390x builds.

Change-Id: I2c80339ce22b0ce5dceb595e504740e74bc840cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/263137
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
4 years agonet/http: ensure Request.Body.Close is called once and only once
Ross Light [Sat, 26 Sep 2020 15:49:56 +0000 (08:49 -0700)]
net/http: ensure Request.Body.Close is called once and only once

Makes *Request.write always close the body, so that callers no longer
have to close the body on returned errors, which was the trigger for
double-close behavior.

Fixes #40382

Change-Id: I128f7ec70415f240d82154cfca134b3f692191e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/257819
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Damien Neil <dneil@google.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agonet/http: document concurrency expectations for Request.Body
Ross Light [Thu, 27 Aug 2020 20:08:29 +0000 (13:08 -0700)]
net/http: document concurrency expectations for Request.Body

This is primarily aimed at client requests where the user can supply
their own io.ReadCloser, but also clarifies server request behavior.
A server request body can be one of:

- *body
- *http2RequestBody
- *expectContinueReader
- *maxBytesReader

Of those, *expectContinueReader did not meet these expectations, so this
change also removes the data race.

Change-Id: Id4f1ae573d938347b1123a7b612b271aabb045a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/251087
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile: remove deltaNewFile
Cuong Manh Le [Fri, 16 Oct 2020 15:39:51 +0000 (22:39 +0700)]
cmd/compile: remove deltaNewFile

CL 196963 removed last usages of deltaNewFile, this CL remove it. While
at it, move the comment to go/internal/gcimporter.

Change-Id: Ieea47db405cf43744689f50b79be8ca710e21c85
Reviewed-on: https://go-review.googlesource.com/c/go/+/263077
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>
4 years agogo/build: allow io/fs to depend on time
Russ Cox [Mon, 6 Jul 2020 13:42:52 +0000 (09:42 -0400)]
go/build: allow io/fs to depend on time

In preparation for moving os.FileInfo into io/fs.
Also keep syscall from depending on io again.
We want to keep them separated, in case io ever
needs to start depending on time.

For #41190.

Change-Id: I98350fa03accf4a20c75ddebb0e961aa1ccccd2c
Reviewed-on: https://go-review.googlesource.com/c/go/+/243905
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years agocmd/internal/objfile: correct file table reading for Go object file
Cherry Zhang [Thu, 15 Oct 2020 22:04:08 +0000 (18:04 -0400)]
cmd/internal/objfile: correct file table reading for Go object file

Apparently I never actually understood the new file table in Go
object files. The PC value stream actually encodes the file index
in the per-CU table. I thought it was indexing into a per-function
table, which then contains index to the per-CU table. Remove the
extra indirection.

Change-Id: I0aea5629f7b3888ebe3a04fea437aa15ce89519e
Reviewed-on: https://go-review.googlesource.com/c/go/+/262779
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
4 years agocompress/flate: revert a goto for-loop
Daniel Martí [Fri, 16 Oct 2020 14:05:04 +0000 (15:05 +0100)]
compress/flate: revert a goto for-loop

In https://golang.org/cl/16528, a goto loop was chosen over a regular
for loop since that would make the function inlinable.

Thanks to the recent https://golang.org/cl/256459, for loops without a
label can now be inlined. So we can undo the workaround and simplify the
code.

Also add the function to TestIntendedInlining, which passes both before
and after the change, as expected.

For #14768.

Change-Id: Ie5df55a6bcb07c538ca331eef2f908807ff0b516
Reviewed-on: https://go-review.googlesource.com/c/go/+/263037
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/go/internal/modload: move fetch to import.go
Jay Conrod [Thu, 15 Oct 2020 19:53:09 +0000 (15:53 -0400)]
cmd/go/internal/modload: move fetch to import.go

From a comment in CL 262341. It makes more sense in import.go than in
mvs.go.

Change-Id: If4dfa1091077e110c5041bc849d99bc0be2bd8e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/262780
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/internal/obj/ppc64,cmd/asm/internal/asm/testdata: fix up ppc64 testcases
Lynn Boger [Tue, 6 Oct 2020 21:08:31 +0000 (17:08 -0400)]
cmd/internal/obj/ppc64,cmd/asm/internal/asm/testdata: fix up ppc64 testcases

When a fix was made at the end of the last release related to
NOPs, it was discovered that the ppc64.s testcase was out of date
and contained comments that weren't being processed. Essentially the
instructions in that test were being assembled but there was no
verification that the encodings weres correct. The ppc64enc.s file
was mostly complete and included the valid encodings for verification.
This change moves ppc64enc.s to ppc64.s and adds the instructions
that were missing.

This also adds a minor fix to asm9.go on the assembly of the
addex that was discovered during this testing.

Change-Id: Iaada1563b137849ad195fa88f32ecc9ab3e1e95f
Reviewed-on: https://go-review.googlesource.com/c/go/+/260217
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>

4 years agosort: update comments
Russ Cox [Thu, 15 Oct 2020 16:09:56 +0000 (12:09 -0400)]
sort: update comments

- Describe requirements on Less more precisely.
- Standardize on x for the variable name of the data being sorted
  (was variously a, p, slice).
- Many other minor wording changes.

Fixes #41951.

Change-Id: Ic9e222a53ec035fcc3b5ddfc7f0eefbe1bb2890d
Reviewed-on: https://go-review.googlesource.com/c/go/+/262657
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years agocmd/internal/obj: move LSym.Func into LSym.Extra
Russ Cox [Sun, 19 Jul 2020 04:30:12 +0000 (00:30 -0400)]
cmd/internal/obj: move LSym.Func into LSym.Extra

This creates space for a different kind of extension field
in LSym without making the struct any larger.
(There are many LSym, so we care about keeping the struct small.)

Change-Id: Ib16edb9e15f54c2a7351c8b875e19684058711e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/243943
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agonet/http: deflake TestServerEmptyBodyRace_h1, or at least try
Russ Cox [Tue, 13 Oct 2020 01:09:18 +0000 (21:09 -0400)]
net/http: deflake TestServerEmptyBodyRace_h1, or at least try

Fixes #22540.
For #33585.

Change-Id: I504b5a91ce1a39cd4ffd2380178a1b8f82f49dd3
Reviewed-on: https://go-review.googlesource.com/c/go/+/261698
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
4 years agonet/http: remove DualStack in DefaultTransport
ananya saxena [Thu, 15 Oct 2020 17:08:50 +0000 (17:08 +0000)]
net/http: remove DualStack in DefaultTransport

Removing `DualStack` from `http.DefaultTransport` since it is deprecated
https://github.com/golang/go/blob/master/src/net/dial.go#L61

Change-Id: Id8ea1e68796ef8a8d49f7a04d0c4815aa92a1804
GitHub-Last-Rev: 0907b59fa793dafc764188c70487a61a720bbc7c
GitHub-Pull-Request: golang/go#41233
Reviewed-on: https://go-review.googlesource.com/c/go/+/253198
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Damien Neil <dneil@google.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>

4 years agocmd/go: rewrite paths for overlaid files using -trimpath
Michael Matloob [Wed, 14 Oct 2020 20:21:39 +0000 (16:21 -0400)]
cmd/go: rewrite paths for overlaid files using -trimpath

Pass the trimpath flag to cmd/compile to use the correct file paths
for files that are overlaid: that is, the "destination" path in the
overlay's Replace mapping rather than the "source" path.

Also fix paths to go source files provided to the gccgo compiler.

For #39958

Change-Id: I3741aeb2272bd0d5aa32cb28133b61e58264fd39
Reviewed-on: https://go-review.googlesource.com/c/go/+/257198
Trust: Michael Matloob <matloob@golang.org>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/dist: only build ios_exec wrapper for ios
Cherry Zhang [Wed, 14 Oct 2020 00:44:04 +0000 (20:44 -0400)]
cmd/dist: only build ios_exec wrapper for ios

Not for darwin/arm64.

Updates #38485.

Change-Id: I08a5f00fd77f20c9c483755a36755a63cf10aa1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/262558
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
4 years agocmd/compile: use staticValue for inlining logic
Matthew Dempsky [Tue, 22 Sep 2020 09:19:14 +0000 (02:19 -0700)]
cmd/compile: use staticValue for inlining logic

This CL replaces the ad hoc and duplicated logic for detecting
inlinable calls with a single "inlCallee" function, which uses the
"staticValue" helper function introduced in an earlier commit.

Updates #41474.

Change-Id: I103d4091b10366fce1344ef2501222b7df68f21d
Reviewed-on: https://go-review.googlesource.com/c/go/+/256460
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Matthew Dempsky <mdempsky@google.com>

4 years agoruntime: stop preemption during syscall.Exec on Darwin
Ian Lance Taylor [Wed, 14 Oct 2020 23:03:48 +0000 (16:03 -0700)]
runtime: stop preemption during syscall.Exec on Darwin

On current macOS versions a program that receives a signal during an
execve can fail with a SIGILL signal. This appears to be a macOS
kernel bug. It has been reported to Apple.

This CL partially works around the problem by using execLock to not
send preemption signals during execve. Of course some other stray
signal could occur, but at least we can avoid exacerbating the problem.
We can't simply disable signals, as that would mean that the exec'ed
process would start with all signals blocked, which it likely does not
expect.

Fixes #41702

Change-Id: I91b0add967b315671ddcf73269c4d30136e579b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/262438
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: allow inlining of "for" loops
Matthew Dempsky [Tue, 22 Sep 2020 03:20:00 +0000 (20:20 -0700)]
cmd/compile: allow inlining of "for" loops

We already allow inlining "if" and "goto" statements, so we might as
well allow "for" loops too. The majority of frontend support is
already there too.

The critical missing feature at the moment is that inlining doesn't
properly reassociate OLABEL nodes with their control statement (e.g.,
OFOR) after inlining. This eventually causes SSA construction to fail.

As a workaround, this CL only enables inlining for unlabeled "for"
loops. It's left to a (yet unplanned) future CL to add support for
labeled "for" loops.

The increased opportunity for inlining leads to a small growth in
binary size. For example:

$ size go.old go.new
   text    data     bss     dec     hex filename
9740163  320064  230656 10290883  9d06c3 go.old
9793399  320064  230656 10344119  9dd6b7 go.new

Updates #14768.
Fixes #41474.

Change-Id: I827db0b2b9d9fa2934db05caf6baa463f0cd032a
Reviewed-on: https://go-review.googlesource.com/c/go/+/256459
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
4 years agocmd/compile: improve escape analysis of known calls
Matthew Dempsky [Tue, 22 Sep 2020 09:12:03 +0000 (02:12 -0700)]
cmd/compile: improve escape analysis of known calls

Escape analysis is currently very naive about identifying calls to
known functions: it only recognizes direct calls to a declared
function, or direct calls to a closure.

This CL adds a new "staticValue" helper function that can trace back
through local variables that were initialized and never reassigned
based on a similar optimization already used by inlining. (And to be
used by inlining in a followup CL.)

Updates #41474.

Change-Id: I8204fd3b1e150ab77a27f583985cf099a8572b2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/256458
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
4 years agocmd/compile: set n.Name.Defn for inlined parameters
Matthew Dempsky [Tue, 22 Sep 2020 04:24:00 +0000 (21:24 -0700)]
cmd/compile: set n.Name.Defn for inlined parameters

Normally, when variables are declared and initialized using ":=", we
set the variable's n.Name.Defn to point to the initialization
assignment node (i.e., OAS or OAS2). Further, some frontend
optimizations look for variables that are initialized but never
reassigned.

However, when inl.go inlines calls, it was declaring the inlined
variables, and then separately assigning to them. This CL changes
inl.go tweaks the AST to fit the combined declaration+initialization
pattern.

This isn't terribly useful by itself, but it allows further followup
optimizations.

Updates #41474.

Change-Id: I62a9752c60414305679e0ed15a6563baa0224efa
Reviewed-on: https://go-review.googlesource.com/c/go/+/256457
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
4 years agocmd/compile: make assignop/convertop reason a return param
Alberto Donizetti [Tue, 13 Oct 2020 13:58:10 +0000 (15:58 +0200)]
cmd/compile: make assignop/convertop reason a return param

On a negative answer, the assignop and convertop functions write the
reason why to a string pointer passed as an argument, likely a C-ism
leftover since the compiler's machine assisted translation to Go.

This change makes why a return parameter.

It also fixes a few places where the assignop/convertop result was
compared to 0. While OXXX's value may be zero now, using the named
constant is more robust.

Change-Id: Id9147ed4c1b97d658d30a2f778f876b7867006b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/261857
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>

4 years agocmd/compile: clean up C->Go translation artifacts in badtype
Alberto Donizetti [Thu, 15 Oct 2020 12:48:26 +0000 (14:48 +0200)]
cmd/compile: clean up C->Go translation artifacts in badtype

Change-Id: I576a596ed8e9ce14e3750031d0e338e9276eff1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/262537
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/compile: simplify exprformat untyped condition checking
Cuong Manh Le [Thu, 15 Oct 2020 15:49:30 +0000 (22:49 +0700)]
cmd/compile: simplify exprformat untyped condition checking

L1337 in fmt.go can be checked just by using "!n.Type.IsUntyped".

Passes toolstash-check.

Change-Id: I5b0c81543bc929367f70713d0ca40b289f905b48
Reviewed-on: https://go-review.googlesource.com/c/go/+/262637
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>
4 years agocmd/link/internal/arm64: handle calls to SDYNIMPORT with internal linking
Joel Sing [Mon, 24 Aug 2020 15:27:23 +0000 (01:27 +1000)]
cmd/link/internal/arm64: handle calls to SDYNIMPORT with internal linking

Handle calls to symbols that are SDYNIMPORT when linking internally on arm64.

Update #36435

Change-Id: I8b5421171bf471cf31c91d90b8ba99511d2c9e2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/250181
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoruntime: remove debugCachedWork
Michael Pratt [Wed, 14 Oct 2020 21:18:27 +0000 (17:18 -0400)]
runtime: remove debugCachedWork

debugCachedWork and all of its dependent fields and code were added to
aid in debugging issue #27993. Now that the source of the problem is
known and mitigated (via the extra work check after STW in gcMarkDone),
these extra checks are no longer required and simply make the code more
difficult to follow.

Remove it all.

Updates #27993

Change-Id: I594beedd5ca61733ba9cc9eaad8f80ea92df1a0d
Reviewed-on: https://go-review.googlesource.com/c/go/+/262350
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
4 years agocmd/go: make sure CC and CXX are absolute
Obeyda Djeffal [Thu, 16 Apr 2020 11:45:37 +0000 (12:45 +0100)]
cmd/go: make sure CC and CXX are absolute

Add check in cmd/go/internal/work.BuildInit and
cmd/go/internal/envcmd.checkEnvWrite.

Fixes #38372

Change-Id: I196ea93a0469e4667ef785f7c1dc4574bdf7ff78
Reviewed-on: https://go-review.googlesource.com/c/go/+/228517
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Trust: Michael Matloob <matloob@golang.org>

4 years agotoken: more descriptive panics
Jean de Klerk [Tue, 13 Oct 2020 22:16:24 +0000 (16:16 -0600)]
token: more descriptive panics

Currently, there are several panics in token that simply say "illegal!". This CL
adds the values.

This is valuable when the token call is wrapped under several layers and you
can't easily see which value is being passed to token.

Change-Id: Ib04b55cafcd9b9ec6820dcf416fc4d49afaea15f
Reviewed-on: https://go-review.googlesource.com/c/go/+/262017
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Trust: Jean de Klerk <deklerk@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/link: support internal linking on darwin/arm64
Cherry Zhang [Mon, 12 Oct 2020 17:44:21 +0000 (13:44 -0400)]
cmd/link: support internal linking on darwin/arm64

Add support of internal linking on darwin/arm64 (macOS).

Still incomplete. Pure Go binaries work. Cgo doesn't. TLS is not
set up when cgo is not used (as before) (so asynchronous
preemption is not enabled).

Internal linking is not enabled by default but can be requested
via -ldflags=-linkmode=internal.

Updates #38485.

Change-Id: I1e0c81b6028edcb1ac26dcdafeb9bb3f788cf732
Reviewed-on: https://go-review.googlesource.com/c/go/+/261643
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocrypto/x509: add signature verification to CreateCertificate
Roland Shoemaker [Mon, 5 Oct 2020 20:18:20 +0000 (13:18 -0700)]
crypto/x509: add signature verification to CreateCertificate

This changes checks the signature generated during CreateCertificate
and returns an error if the verification fails. A benchmark is also
added. For RSA keys the delta looks to be insignificant, but for
ECDSA keys it introduces a much larger delta which is not ideal.

name          old time/op  new time/op   delta
RSA_2048-8    1.38ms ± 6%   1.41ms ± 2%      ~     (p=0.182 n=10)
ECDSA_P256-8  42.6µs ± 4%  116.8µs ± 4%  +174.00%  (p=0.000 n=1

Fixes #40458

Change-Id: I22827795bb9bb6868b4fa47391927db1d3bc19a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/259697
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
Trust: Roland Shoemaker <roland@golang.org>

4 years agosort: document requirements of Less relation
alandonovan [Tue, 13 Oct 2020 20:22:29 +0000 (16:22 -0400)]
sort: document requirements of Less relation

Fixes #34915

Change-Id: Ia62ff3b6f198ddcd79e8afc7b4f5514a44f2442c
Reviewed-on: https://go-review.googlesource.com/c/go/+/261959
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Akhil Indurti <aindurti@gmail.com>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>

4 years agonet/http: return 505 status for rejected protocol version
Damien Neil [Tue, 13 Oct 2020 20:02:45 +0000 (13:02 -0700)]
net/http: return 505 status for rejected protocol version

When rejecting a request with an unsupported HTTP protocol version,
return a 505 error ("HTTP Version Not Supported") instead of 400.

Fixes #40454.

Change-Id: I0269f0f5755d90d1b772ba0094a6bb24b5eb4701
Reviewed-on: https://go-review.googlesource.com/c/go/+/261977
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Urban Ishimwe <urbainishimwe@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
4 years agoio: add a new ReadSeekCloser interface
Mohamed Attahri [Tue, 13 Oct 2020 02:26:19 +0000 (02:26 +0000)]
io: add a new ReadSeekCloser interface

Research showed that this interface is defined frequently enough in
real-world usage to justify its addition to the standard library.

Fixes #40962

Change-Id: I522fe8f9b8753c3fa42ccc1def49611cf88cd340
GitHub-Last-Rev: 6a45be66b42e482a06d9809d9da20c195380988b
GitHub-Pull-Request: golang/go#41939
Reviewed-on: https://go-review.googlesource.com/c/go/+/261577
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>

4 years agocmd: go get golang.org/x/tools@d88ec18 && go mod vendor
Russ Cox [Tue, 13 Oct 2020 18:19:20 +0000 (14:19 -0400)]
cmd: go get golang.org/x/tools@d88ec18 && go mod vendor

This brings in CL 261725, which applies the vet buildtag checker
to ignored files.

For #41184.

Change-Id: I5f241db5a71fa84d0af0b9e9f8a75ff5bb3dd116
Reviewed-on: https://go-review.googlesource.com/c/go/+/261958
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agocmd/go: update go list docs for IgnoredOtherFiles
Russ Cox [Tue, 13 Oct 2020 03:35:25 +0000 (23:35 -0400)]
cmd/go: update go list docs for IgnoredOtherFiles

Change-Id: I8eb7f34754c7be899d389fe807af65aa5fd5bbc4
Reviewed-on: https://go-review.googlesource.com/c/go/+/261957
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agosync: fix typo in pooldequeue
ZhangYunHao [Wed, 14 Oct 2020 03:34:57 +0000 (03:34 +0000)]
sync: fix typo in pooldequeue

.

Change-Id: I26fa26d67d01bcd583a1efaaf9a38398cbf793f7
GitHub-Last-Rev: ded020d02ca2e429f7c31065e5a27dae6eb7a611
GitHub-Pull-Request: golang/go#41932
Reviewed-on: https://go-review.googlesource.com/c/go/+/261477
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Austin Clements <austin@google.com>
4 years agolib/time, time, time/tzdata: use slim tz data format
Tobias Klauser [Tue, 13 Oct 2020 15:07:34 +0000 (17:07 +0200)]
lib/time, time, time/tzdata: use slim tz data format

Follow-up for CL 261363 which had to retain the fat tz data format due
to failing test.

The reason for the failed tests was that when caching location data, the
extended time format past the end of zone transitions was not
considered. The respective change was introduced in (*Location).lookup
by CL 215539.

This slims down zoneinfo.zip (and thus also the embedded copy in
time/tzdata) by ~350KB.

Change-Id: I412f79de98ba45358b8696aca784999b3479135e
Reviewed-on: https://go-review.googlesource.com/c/go/+/261877
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agosyscall: remove stray TODO comment
Tobias Klauser [Tue, 13 Oct 2020 08:18:35 +0000 (10:18 +0200)]
syscall: remove stray TODO comment

This was addressed by CL 2816 and the same comment was deleted from
asm_linux_386.s.

Change-Id: Icc797993161d67e7c4f4cdb11c2b96ac88e00dd9
Reviewed-on: https://go-review.googlesource.com/c/go/+/261458
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/compile: rename strlit, Bool, and Int64 *Node accessors
Alberto Donizetti [Mon, 12 Oct 2020 13:02:59 +0000 (15:02 +0200)]
cmd/compile: rename strlit, Bool, and Int64 *Node accessors

The Node type has shortcuts to access bool and int Values:

  func (n *Node) Int64() int64
    for n.Val().U.(*Mpint).Int64()

  func (n *Node) Bool() bool
    for n.Val().U.(bool)

I was convinced we didn't have one for string literal nodes, until I
noticed that we do, it's just called strlit, it's not a method, and
it's later in the file:

  func strlit(n *Node) string

This change, for consistency:
- Renames strlit to StringVal and makes it a *Node method
- Renames Bool and Int64 to BoolVal and Int64Val
- Moves StringVal near the other two

Change-Id: I18e635384c35eb3a238fd52b1ccd322b1a74d733
Reviewed-on: https://go-review.googlesource.com/c/go/+/261361
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agoruntime: implement GODEBUG=inittrace=1 support
Martin Möhrmann [Mon, 14 Sep 2020 14:55:34 +0000 (16:55 +0200)]
runtime: implement GODEBUG=inittrace=1 support

Setting inittrace=1 causes the runtime to emit a single line to standard error for
each package with init work, summarizing the execution time and memory allocation.

The emitted debug information for init functions can be used to find bottlenecks
or regressions in Go startup performance.

Packages with no init function work (user defined or compiler generated) are omitted.

Tracing plugin inits is not supported as they can execute concurrently. This would
make the implementation of tracing more complex while adding support for a very rare
use case. Plugin inits can be traced separately by testing a main package importing
the plugins package imports explicitly.

$ GODEBUG=inittrace=1 go test
init internal/bytealg @0.008 ms, 0 ms clock, 0 bytes, 0 allocs
init runtime @0.059 ms, 0.026 ms clock, 0 bytes, 0 allocs
init math @0.19 ms, 0.001 ms clock, 0 bytes, 0 allocs
init errors @0.22 ms, 0.004 ms clock, 0 bytes, 0 allocs
init strconv @0.24 ms, 0.002 ms clock, 32 bytes, 2 allocs
init sync @0.28 ms, 0.003 ms clock, 16 bytes, 1 allocs
init unicode @0.44 ms, 0.11 ms clock, 23328 bytes, 24 allocs
...

Inspired by stapelberg@google.com who instrumented doInit
in a prototype to measure init times with GDB.

Fixes #41378

Change-Id: Ic37c6a0cfc95488de9e737f5e346b8dbb39174e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/254659
Trust: Martin Möhrmann <moehrmann@google.com>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/link: support PIE internal linking on darwin/amd64
Cherry Zhang [Sun, 11 Oct 2020 19:48:22 +0000 (15:48 -0400)]
cmd/link: support PIE internal linking on darwin/amd64

This CL adds support of PIE internal linking on darwin/amd64.

This is also preparation for supporting internal linking on
darwin/arm64 (macOS), which requires PIE for everything.

Updates #38485.

Change-Id: I2ed58583dcc102f5e0521982491fc7ba6f2754ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/261642
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/internal/obj: remove LSym.RefIdx
Cherry Zhang [Tue, 13 Oct 2020 22:28:25 +0000 (18:28 -0400)]
cmd/internal/obj: remove LSym.RefIdx

LSym.RefIdx was for the old object files. I should have deleted
it when I deleted old object file code.

Change-Id: I8294f43a1e7ba45b1d75e84cc83cbaf2cb32f025
Reviewed-on: https://go-review.googlesource.com/c/go/+/262077
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
4 years agotest: add test that fails with gofrontend
Ian Lance Taylor [Tue, 13 Oct 2020 00:19:49 +0000 (17:19 -0700)]
test: add test that fails with gofrontend

The gofrontend code doesn't correctly handle inlining a function that
refers to a constant with methods.

For #35739

Change-Id: I6bd0b5cd4272dbe9969634b4821e668acacfdcf9
Reviewed-on: https://go-review.googlesource.com/c/go/+/261662
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: fix and improve alias detection
Matthew Dempsky [Mon, 12 Oct 2020 21:02:36 +0000 (14:02 -0700)]
cmd/compile: fix and improve alias detection

"aliased" is the function responsible for detecting whether we can
turn "a, b = x, y" into just "a = x; b = y", or we need to pre-compute
y and save it in a temporary variable because it might depend on a.

It currently has two issues:

1. It suboptimally treats assignments to blank as writes to heap
   memory. Users generally won't write "_, b = x, y" directly, but it
   comes up a lot in generated code within the compiler.

   This CL changes it to ignore blank assignments.

2. When deciding whether the assigned variable might be referenced by
   pointers, it mistakenly checks Class() and Name.Addrtaken() on "n"
   (the *value* expression being assigned) rather than "a" (the
   destination expression).

   It doesn't appear to result in correctness issues (i.e.,
   incorrectly reporting no aliasing when there is potential aliasing),
   due to all the (overly conservative) rewrite passes before code
   reaches here. But it generates unnecessary code and could have
   correctness issues if we improve those other passes to be more
   aggressive.

   This CL fixes the misuse of "n" for "a" by renaming the variables
   to "r" and "l", respectively, to make their meaning clearer.

Improving these two cases shaves 4.6kB of text from cmd/go, and 93kB
from k8s.io/kubernetes/cmd/kubelet:

       text    data     bss     dec     hex filename
    9732136  290072  231552 10253760  9c75c0 go.before
    9727542  290072  231552 10249166  9c63ce go.after
    97977637 1007051  301344 99286032 5eafc10 kubelet.before
    97884549 1007051  301344 99192944 5e99070 kubelet.after

While here, this CL also collapses "memwrite" and "varwrite" into a
single variable. Logically, they're detecting the same thing: are we
assigning to a memory location that a pointer might alias. There's no
need for two variables.

Updates #6853.
Updates #23017.

Change-Id: I5a307b8e20bcd2196e85c55eb025d3f01e303008
Reviewed-on: https://go-review.googlesource.com/c/go/+/261677
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/go/internal/modfetch: remove error return from Lookup
Bryan C. Mills [Fri, 2 Oct 2020 20:25:17 +0000 (16:25 -0400)]
cmd/go/internal/modfetch: remove error return from Lookup

We generally don't care about errors in resolving a repo if the result
we're looking for is already in the module cache. Moreover, we can
avoid some expense in initializing the repo if all of the methods we
plan to call on it hit in the cache — especially when using
GOPROXY=direct.

This also incidentally fixes a possible (but rare) bug in Download:
we had forgotten to reset the downloaded file in case the Zip method
returned an error after writing a nonzero number of bytes.

For #37438

Change-Id: Ib64f10f763f6d1936536b8e1f7d31ed1b463e955
Reviewed-on: https://go-review.googlesource.com/c/go/+/259158
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agocmd/go: adjust ImportMissingError when module lookup is disabled
Bryan C. Mills [Tue, 29 Sep 2020 21:45:02 +0000 (17:45 -0400)]
cmd/go: adjust ImportMissingError when module lookup is disabled

Previously, ImportMissingError said
"cannot find module providing package …"
even when we didn't even attempt to find such a module.

Now, we write "no module requirement provides package …"
when we did not attempt to identify a suitable module,
and suggest either 'go mod tidy' or 'go get -d' as appropriate.

Fixes #41576

Change-Id: I979bb999da4066828c54d99a310ea66bb31032ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/258298
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agofmt: explain how Formatter interface affects verbs and flags
Bryan Boreham [Mon, 12 Oct 2020 14:29:28 +0000 (14:29 +0000)]
fmt: explain how Formatter interface affects verbs and flags

Formatter is mentioned further down, but it's helpful
to add it amongst the verbs and flags.

Background: I spent a while puzzling how "%+v" prints
a stack trace for github.com/pkg/errors when this isn't
documented under 'flags'.

Change-Id: Ic70145902a36780147dedca568b3cf482974fc38
GitHub-Last-Rev: 6571b499f211a2266812af66dd3b88dff602cabf
GitHub-Pull-Request: golang/go#39860
Reviewed-on: https://go-review.googlesource.com/c/go/+/240000
Reviewed-by: Rob Pike <r@golang.org>
Trust: Rob Pike <r@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>

4 years agoruntime: remove unused alg constants
Martin Möhrmann [Tue, 13 Oct 2020 06:26:36 +0000 (08:26 +0200)]
runtime: remove unused alg constants

CL 191198 removed algarray from the runtime
which used these constants as indices.

Change-Id: Ia669cf410372ef5113dadccd115a39ff8d47e5c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/261364
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
Trust: Martin Möhrmann <moehrmann@google.com>

4 years agointernal/cpu: remove unused arm64 capabilities
Martin Möhrmann [Tue, 13 Oct 2020 06:32:41 +0000 (08:32 +0200)]
internal/cpu: remove unused arm64 capabilities

Change-Id: I038b0fe165931b8ec3ef59f08dc73c8128d56572
Reviewed-on: https://go-review.googlesource.com/c/go/+/261365
Trust: Martin Möhrmann <moehrmann@google.com>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoio: add ErrBadWriteCount
Tao Qingyun [Tue, 13 Oct 2020 05:56:48 +0000 (05:56 +0000)]
io: add ErrBadWriteCount

Fixes #39978

Change-Id: Ib41459861ba9f7cf0bf1fc95b1479c358c4bdbd8
GitHub-Last-Rev: 19cbb1461ca04a8eb64f0c4f354d8fb81a70d4f3
GitHub-Pull-Request: golang/go#39989
Reviewed-on: https://go-review.googlesource.com/c/go/+/240740
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agocmd/go/internal/fsys: skip symlink test on Plan 9
Fazlul Shahriar [Tue, 13 Oct 2020 15:36:11 +0000 (11:36 -0400)]
cmd/go/internal/fsys: skip symlink test on Plan 9

Fixes #41950
Fixes #41954

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

4 years agocmd/link: update plt size appropriately on ppc64
Lynn Boger [Tue, 13 Oct 2020 13:15:52 +0000 (09:15 -0400)]
cmd/link: update plt size appropriately on ppc64

When attempting to enable internal linking with cgo on ppc64
it was discovered that the plt size was not being updated
after adding entries to it, which resulted in this error:

  .plt: initialize bounds (16 < 24)

This changes fixes that problem.

Updates #21961

Change-Id: Ie17539c329f5a4802e5defd93852dcdde19ded8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/261837
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/link: set runtime.text to the address of the first function
Cherry Zhang [Mon, 12 Oct 2020 22:00:25 +0000 (18:00 -0400)]
cmd/link: set runtime.text to the address of the first function

In CL 240065 we changed it to set to FlagTextAddr. Normally it
is the address of the first function, except on plan9/amd64
where, as FlagTextAddr is not aligned, it is rounded up. Set it
to the actual text start address.

Fixes #41137.

Change-Id: I1bba67f5eb4e24d9f745a11350fc999ff48bff45
Reviewed-on: https://go-review.googlesource.com/c/go/+/261644
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David du Colombier <0intro@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agolib/time, time/tzdata: update tz data to 2020b
Tobias Klauser [Mon, 12 Oct 2020 13:49:59 +0000 (15:49 +0200)]
lib/time, time/tzdata: update tz data to 2020b

Set ZFLAGS="-b fat" as the default was changed to '-b slim', see
http://mm.icann.org/pipermail/tz-announce/2020-October/000059.html
This will make sure that backwards-compatibibilty data is still emitted.

Updates #22487

Change-Id: I310a1b3a91e435673d1df41fbf8bb76abce1f94d
Reviewed-on: https://go-review.googlesource.com/c/go/+/261363
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agointernal/bytealg: fix typo in IndexRabinKarp{,Bytes} godoc
Tobias Klauser [Mon, 12 Oct 2020 09:19:41 +0000 (11:19 +0200)]
internal/bytealg: fix typo in IndexRabinKarp{,Bytes} godoc

Change-Id: I09ba19e19b195e345a0fe29d542e0d86529b0d31
Reviewed-on: https://go-review.googlesource.com/c/go/+/261359
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agogo/build: reject //go:build without // +build
Russ Cox [Fri, 22 May 2020 18:46:52 +0000 (14:46 -0400)]
go/build: reject //go:build without // +build

We are converting from using error-prone ad-hoc syntax // +build lines
to less error-prone, standard boolean syntax //go:build lines.
The timeline is:

Go 1.16: prepare for transition
 - Builds still use // +build for file selection.
 - Source files may not contain //go:build without // +build.
 - Builds fail when a source file contains //go:build lines without // +build lines. <<<

Go 1.17: start transition
 - Builds prefer //go:build for file selection, falling back to // +build
   for files containing only // +build.
 - Source files may contain //go:build without // +build (but they won't build with Go 1.16).
 - Gofmt moves //go:build and // +build lines to proper file locations.
 - Gofmt introduces //go:build lines into files with only // +build lines.
 - Go vet rejects files with mismatched //go:build and // +build lines.

Go 1.18: complete transition
 - Go fix removes // +build lines, leaving behind equivalent // +build lines.

This CL provides part of the <<< marked line above in the Go 1.16 step:
rejecting files containing //go:build but not // +build.

For #41184.

Change-Id: I29b8a789ab1526ab5057f613d5533bd2060ba9cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/240600
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/asm: reject misplaced go:build comments
Russ Cox [Mon, 29 Jun 2020 21:08:49 +0000 (17:08 -0400)]
cmd/asm: reject misplaced go:build comments

We are converting from using error-prone ad-hoc syntax // +build lines
to less error-prone, standard boolean syntax //go:build lines.
The timeline is:

Go 1.16: prepare for transition
 - Builds still use // +build for file selection.
 - Source files may not contain //go:build without // +build.
 - Builds fail when a source file contains //go:build lines without // +build lines. <<<

Go 1.17: start transition
 - Builds prefer //go:build for file selection, falling back to // +build
   for files containing only // +build.
 - Source files may contain //go:build without // +build (but they won't build with Go 1.16).
 - Gofmt moves //go:build and // +build lines to proper file locations.
 - Gofmt introduces //go:build lines into files with only // +build lines.
 - Go vet rejects files with mismatched //go:build and // +build lines.

Go 1.18: complete transition
 - Go fix removes // +build lines, leaving behind equivalent // +build lines.

This CL provides part of the <<< marked line above in the Go 1.16 step:
rejecting files containing //go:build but not // +build.

Reject any //go:build comments found after actual assembler code
(include #include etc directives), because the go command itself
doesn't read that far.

For #41184.

Change-Id: Ib460bfd380cce4239993980dd208afd07deff3f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/240602
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/compile: reject misplaced go:build comments
Russ Cox [Fri, 22 May 2020 19:22:52 +0000 (15:22 -0400)]
cmd/compile: reject misplaced go:build comments

We are converting from using error-prone ad-hoc syntax // +build lines
to less error-prone, standard boolean syntax //go:build lines.
The timeline is:

Go 1.16: prepare for transition
 - Builds still use // +build for file selection.
 - Source files may not contain //go:build without // +build.
 - Builds fail when a source file contains //go:build lines without // +build lines. <<<

Go 1.17: start transition
 - Builds prefer //go:build for file selection, falling back to // +build
   for files containing only // +build.
 - Source files may contain //go:build without // +build (but they won't build with Go 1.16).
 - Gofmt moves //go:build and // +build lines to proper file locations.
 - Gofmt introduces //go:build lines into files with only // +build lines.
 - Go vet rejects files with mismatched //go:build and // +build lines.

Go 1.18: complete transition
 - Go fix removes // +build lines, leaving behind equivalent // +build lines.

This CL provides part of the <<< marked line above in the Go 1.16 step:
rejecting files containing //go:build but not // +build.
The standard go command checks only consider the top of the file.
This compiler check, along with a separate go vet check for ignored files,
handles the remainder of the file.

For #41184.

Change-Id: I014006eebfc84ab5943de18bc90449e534f150a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/240601
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agopath: avoid import of strings
Russ Cox [Tue, 14 Jul 2020 02:24:52 +0000 (22:24 -0400)]
path: avoid import of strings

Pushing path lower in the hierarchy, to allow path < io/fs < os
in the io/fs prototype. But this change is worth doing even if io/fs
is not accepted.

Change-Id: Id51b3a638167ca005dadfb9b730287e518ec12a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/243904
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years agosyscall: remove dependency on io
Russ Cox [Sun, 5 Jul 2020 20:34:27 +0000 (16:34 -0400)]
syscall: remove dependency on io

Keep syscall and io separated; neither should depend on the other.

Change-Id: Icdd61bd0c05d874cabd7b5ae6631dd09dec90112
Reviewed-on: https://go-review.googlesource.com/c/go/+/243902
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>