1
0
mirror of https://github.com/golang/go synced 2024-11-17 05:54:46 -07:00
Commit Graph

45112 Commits

Author SHA1 Message Date
hk
70cad2744b cmd/compile/internal/gc: use plural nouns in comments
Change-Id: I99a5b5b88495cfaef16d41ee4b962c5d0b3488aa
GitHub-Last-Rev: fa0d895b3a
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>
2020-10-19 21:40:56 +00:00
Matthew Dempsky
c216ae80c9 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>
2020-10-19 21:30:43 +00:00
Bryan C. Mills
5647d01ab7 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>
2020-10-19 19:51:19 +00:00
Than McIntosh
4d1cecdee8 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>
2020-10-19 19:27:54 +00:00
Klaus Post
ab541a0560 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: 50fabab0da
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>
2020-10-19 18:48:17 +00:00
Cherry Zhang
06839e3c9a 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>
2020-10-19 18:31:53 +00:00
Cherry Zhang
2ff9e01d72 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>
2020-10-19 18:31:39 +00:00
Cherry Zhang
0040adfd0f 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>
2020-10-19 18:31:05 +00:00
Cherry Zhang
bb44c90a94 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>
2020-10-19 18:25:30 +00:00
hk
178b0f59ff cmd/compile/internal/gc: remove an unused method
Change-Id: Ib496d1e9a47d2cf69509ffd0009038b7d34a0149
GitHub-Last-Rev: 5b5589dd03
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>
2020-10-19 17:23:00 +00:00
avivklas
58eadc232e 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>
2020-10-19 17:19:18 +00:00
Aofei Sheng
9c017ff30d 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>
2020-10-19 17:17:28 +00:00
Katie Hockman
2a206c7fcc 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>
2020-10-19 15:00:02 +00:00
Tobias Klauser
19f6422e00 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>
2020-10-19 14:55:41 +00:00
Cherry Zhang
6398b4725c 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>
2020-10-19 13:50:22 +00:00
Alberto Donizetti
3853272573 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>
2020-10-19 13:49:50 +00:00
Than McIntosh
53094ac844 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>
2020-10-19 12:40:52 +00:00
Than McIntosh
dd58239dd2 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>
2020-10-19 11:25:35 +00:00
Joel Sing
9499a2e108 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>
2020-10-18 08:32:19 +00:00
Joel Sing
15eaa870e1 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>
2020-10-18 08:30:18 +00:00
Alex Brainman
515e6a9b12 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>
2020-10-18 08:22:01 +00:00
zikaeroh
fc981654c7 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>
2020-10-17 22:58:33 +00:00
Matthew Dempsky
76a615b20a 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>
2020-10-17 21:30:53 +00:00
Bryan C. Mills
30119bcca9 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>
2020-10-17 19:22:49 +00:00
Alberto Donizetti
c8f6135d4f 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>
2020-10-17 07:18:20 +00:00
Cherry Zhang
5faa828651 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>
2020-10-17 02:48:03 +00:00
Ian Lance Taylor
11cfb48df1 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>
2020-10-17 00:32:32 +00:00
Nigel Tao
a2eb53c571 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>
2020-10-17 00:26:52 +00:00
Cherry Zhang
689a7a1378 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>
2020-10-17 00:01:16 +00:00
Cherry Zhang
f1e3c8f142 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>
2020-10-17 00:01:00 +00:00
Ian Lance Taylor
05739d6f17 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>
2020-10-16 23:50:26 +00:00
Cherry Zhang
3eae1a9058 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>
2020-10-16 20:51:49 +00:00
Tobias Klauser
9cec50f50c 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>
2020-10-16 19:53:34 +00:00
Bryan C. Mills
41162be44a 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>
2020-10-16 19:13:40 +00:00
Bryan C. Mills
ff052737a9 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>
2020-10-16 19:13:28 +00:00
Russ Cox
ae162554f9 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>
2020-10-16 19:04:24 +00:00
Bryan C. Mills
570b49d6fc 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>
2020-10-16 18:54:38 +00:00
Russ Cox
03f181a90e 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>
2020-10-16 17:52:59 +00:00
Austin Clements
83317d9e3c 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>
2020-10-16 17:31:17 +00:00
Austin Clements
afba990169 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>
2020-10-16 17:31:16 +00:00
Cherry Zhang
e7259c07d4 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>
2020-10-16 17:01:43 +00:00
Ross Light
606d4a38b9 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>
2020-10-16 16:53:27 +00:00
Ross Light
dfee3332e6 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>
2020-10-16 16:52:13 +00:00
Cuong Manh Le
c06a699fb6 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>
2020-10-16 16:51:46 +00:00
Russ Cox
96fc07af1c 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>
2020-10-16 16:41:55 +00:00
Cherry Zhang
20819440fc 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>
2020-10-16 14:40:50 +00:00
Daniel Martí
771f5f2e48 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>
2020-10-16 14:23:21 +00:00
Jay Conrod
8ee4d6e1bf 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>
2020-10-16 14:02:35 +00:00
Lynn Boger
e981936855 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>
2020-10-16 12:48:42 +00:00
Russ Cox
af8748054b 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>
2020-10-16 04:13:45 +00:00