1
0
mirror of https://github.com/golang/go synced 2024-11-24 04:00:13 -07:00
Commit Graph

39926 Commits

Author SHA1 Message Date
Bryan C. Mills
2ebdb5ec06 os: fix aliasing bug in RemoveAllTestHook restoration
The code to swap RemoveAllTestHook in and out in
TestRemoveAllWithMoreErrorThanReqSize was making a copy of the
RemoveAllTestHook pointer, then attempting to restore by loading from
the copy of that pointer. Since the two copies of the pointer aliased
the same address, the restore operation had no effect, and any
RemoveAll tests that happened to run after
TestRemoveAllWithMoreErrorThanReqSize would fail.

Fixes #31421

Change-Id: I7028475f5ceb3b0a2fa69d22af8d3379508c4531
Reviewed-on: https://go-review.googlesource.com/c/go/+/171777
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-11 20:03:44 +00:00
Cherry Zhang
8d86ef2216 runtime: set itab.fun[0] only on successful conversion
For a failed interface conversion not in ",ok" form, getitab
calls itab.init to get the name of the missing method for the
panic message. itab.init will try to find the methods, populate
the method table as it goes. When some method is missing, it sets
itab.fun[0] to 0 before return. There is a small window that
itab.fun[0] could be non-zero.

If concurrently, another goroutine tries to do the same interface
conversion, it will read the same itab's fun[0]. If this happens
in the small window, it sees a non-zero fun[0] and thinks the
conversion succeeded, which is bad.

Fix the race by setting fun[0] to non-zero only when we know the
conversion succeeds. While here, also simplify the syntax
slightly.

Fixes #31419.

Change-Id: Ied34d3043079eb933e330c5877b85e13f98f1916
Reviewed-on: https://go-review.googlesource.com/c/go/+/171759
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-04-11 18:59:57 +00:00
Keith Randall
770f2a17d2 syscall: enforce minimum buffer size to call ReadDirent
freebsd and netbsd require a minimum buffer size of 1K.

Note this doesn't quite fix freebsd, it has other bugs,
I'll file a separate issue.

Fixes #31403

Change-Id: I9d7e78f6d30859b34715afadc4b8bd3b1ecc606b
Reviewed-on: https://go-review.googlesource.com/c/go/+/171757
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-11 16:25:40 +00:00
Aman Gupta
3cb92fcba7 cmd/link/internal/ld: fix c-archive mach-o compatibility
These workarounds predate proper DWARF support
and are no longer necessary.

Before this patch, running `/usr/bin/symbols go.o`
using the object in the c-archive would fail, causing
App Store rejections.

Fixes #31022 #28997

Change-Id: I6a210b6369c13038777c6e21e874e81afcb50c2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/170377
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-11 04:49:51 +00:00
Michael Anthony Knyszek
7b33b6274f runtime: introduce treapForSpan to reduce code duplication
Currently which treap a span should be inserted into/removed from is
checked by looking at the span's properties. This logic is repeated in
four places. As this logic gets more complex, it makes sense to
de-duplicate this, so introduce treapForSpan instead which captures this
logic by returning the appropriate treap for the span.

For #30333.

Change-Id: I4bd933d93dc50c5fc7c7c7f56ceb95194dcbfbcc
Reviewed-on: https://go-review.googlesource.com/c/go/+/170857
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2019-04-10 22:01:12 +00:00
Michael Anthony Knyszek
d13a9312f5 runtime: add tests for runtime mTreap
This change exports the runtime mTreap in export_test.go and then adds a
series of tests which check that the invariants of the treap are
maintained under different operations. These tests also include tests
for the treap iterator type.

Also, we note that the find() operation on the treap never actually was
best-fit, so the tests just ensure that it returns an appropriately
sized span.

For #30333.

Change-Id: If81f7c746dda6677ebca925cb0a940134701b894
Reviewed-on: https://go-review.googlesource.com/c/go/+/164100
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2019-04-10 22:00:53 +00:00
Michael Anthony Knyszek
2ab6d0172e runtime: throw if scavenge necessary during coalescing
Currently when coalescing if two adjacent spans are scavenged, we
subtract their sizes from memstats and re-scavenge the new combined
span. This is wasteful however, since the realignment semantics make
this case of having to re-scavenge impossible.

In realign() inside of coalesce(), there was also a bug: on systems
where physPageSize > pageSize, we wouldn't realign because a condition
had the wrong sign. This wasteful re-scavenging has been masking this
bug this whole time. So, this change fixes that first.

Then this change gets rid of the needsScavenge logic and instead checks
explicitly for the possibility of unscavenged pages near the physical
page boundary. If the possibility exists, it throws. The intent of
throwing here is to catch changes to the runtime which cause this
invariant to no longer hold, at which point it would likely be
appropriate to scavenge the additional pages (and only the additional
pages) at that point.

Change-Id: I185e3d7b53e36e90cf9ace5fa297a9e8008d75f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/158377
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2019-04-10 22:00:03 +00:00
Mihai Moldovan
512b3c63b7 cmd/dist: add BOOT_GO_LDFLAGS - counterpart of BOOT_GO_GCFLAGS
This allows passing custom LDFLAGS while building the bootstrapping
tool.

Afterwards, GO_LDFLAGS will be used as usual.

Change-Id: I1e224e3ce8bf7b2ce1ef8fec1894720338f04396
GitHub-Last-Rev: 17d40dc2dd
GitHub-Pull-Request: golang/go#31298
Reviewed-on: https://go-review.googlesource.com/c/go/+/171037
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-10 21:23:18 +00:00
LE Manh Cuong
c349505878 os: fix RemoveAll hangs on large directory
golang.org/cl/121255 added close and re-open the directory when looping, prevent
us from missing some if previous iteration deleted files.

The CL introdued a bug. If we can not delete all entries in one request,
the looping never exits, causing RemoveAll hangs.

To fix that, simply discard the entries if we can not delete all of them
in one iteration, then continue reading entries and delete them.

Also make sure removeall_at return first error it encounters.

Fixes #29921

Change-Id: I8ec3a4c822d8d2d95d9f1ab71547879da395bc4a
Reviewed-on: https://go-review.googlesource.com/c/go/+/171099
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-10 20:14:25 +00:00
Keith Randall
a6af1041f6 syscall: store skip count in file descriptor offset
Multiple calls to ReadDirent expect to return subsequent
portions of the directory listing. There's no place to store
our progress other than the file descriptor offset.

Fortunately, the file descriptor offset doesn't need to be
a real offset. We can store any int64 we want there.

Fixes #31368

Change-Id: I49e4e0e7ff707d3e96aa5d43e3b0199531013cde
Reviewed-on: https://go-review.googlesource.com/c/go/+/171477
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-10 20:06:50 +00:00
Ahsun Ahmed
fda5e6d6fa errors: return false if nil error is passed to As
Fixes #30970

Change-Id: I333676b55a2364e329fffeafca8fc57d45a0b84b
Reviewed-on: https://go-review.googlesource.com/c/go/+/168598
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-10 15:59:35 +00:00
smileeye
607493bed6 cmd/asm/internal/arch: improve the comment of function IsMIPSMUL
The check of MADD&MSUB was added to the function IsMIPSMUL in
a previous commit, and the comments should also be updated.

Change-Id: I2d3da055d55b459b908714c542dff99ab5c6cf99
Reviewed-on: https://go-review.googlesource.com/c/go/+/171102
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-10 14:39:34 +00:00
Elias Naur
eddb41eb2c runtime: correct the TLS base offset on Android
CL 170955 set tlsg to the Android Q free TLS slot offset in the linker
data (16 on amd64, 8 on 386), offsetting all TLS relative access.
We need the 0'th slot (TLS_SLOT_SELF) at initialization, so
compensate with a corresponding negative offset.

Fixes the android/386 and android/amd64 builders broken by CL 170955.

Change-Id: I9882088c0c8bc6a777d2aabc9404cb76f02b6cea
Reviewed-on: https://go-review.googlesource.com/c/go/+/170956
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-04-10 14:21:20 +00:00
Nigel Tao
9a0a150c9f all: spell "Deprecated: Use etc" consistently
Change-Id: I209b75dc8dc4da881b68e5c5d98cbf08c1032dfc
Reviewed-on: https://go-review.googlesource.com/c/go/+/171098
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-04-10 01:28:25 +00:00
Cherry Zhang
68c664141c cmd/internal/obj/x86: allow non-zero offset in TLS reference
An instruction that references TLS, e.g.

MOVQ	0(TLS), AX

on some platforms (e.g. Android), or in shared mode, may be
translated to (assuming TLS offset already loaded to CX)

MOVQ	0(CX)(TLS*1), AX

which in turns translates to

movq	%fs:(%rcx), %rax

We have rejected non-zero offset for TLS reference, like 16(TLS).
Actually, the instruction can take offset, i.e. it is a valid
instruction for, e.g.,

movq	%fs:16(%rcx),%rcx

So, allow offset in TLS reference.

Change-Id: Iaf1996bad7fe874e0c298ea441af5acb136a4028
Reviewed-on: https://go-review.googlesource.com/c/go/+/171151
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-09 18:57:21 +00:00
Tobias Klauser
016625c265 strings: add TestIndexByte
Add TestIndexByte to package strings similar to the already existing
TestIndexByte in package bytes.

Change-Id: Ib60695cb326156a4fe48138c66393ebbd11e4a25
Reviewed-on: https://go-review.googlesource.com/c/go/+/171197
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-09 14:14:41 +00:00
Tobias Klauser
78175474c4 strings: use Go style character range comparison in ToUpper/ToLower
As noted by Brad in CL 170954 for package bytes.

Change-Id: I2772a356299e54ba5b7884d537e6649039adb9be
Reviewed-on: https://go-review.googlesource.com/c/go/+/171198
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-09 13:57:16 +00:00
Andrei Vagin
4166ff42c0 runtime: preempt a goroutine which calls a lot of short system calls
A goroutine should be preempted if it runs for 10ms without blocking.
We found that this doesn't work for goroutines which call short system calls.

For example, the next program can stuck for seconds without this fix:

$ cat main.go
package main

import (
	"runtime"
	"syscall"
)

func main() {
	runtime.GOMAXPROCS(1)
	c := make(chan int)
	go func() {
		c <- 1
		for {
			t := syscall.Timespec{
				Nsec: 300,
			}
			if true {
				syscall.Nanosleep(&t, nil)
			}
		}
	}()
	<-c
}

$ time go run main.go

real	0m8.796s
user	0m0.367s
sys	0m0.893s

Updates #10958

Change-Id: Id3be54d3779cc28bfc8b33fe578f13778f1ae2a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/170138
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-09 07:45:26 +00:00
Tobias Klauser
08e1823a63 bytes: optimize ToLower and ToUpper for ASCII-only case
Follow what CL 68370 and CL 76470 did for the respective functions in
package strings.

Also adjust godoc strings to match the respective strings functions and
mention the special case for ASCII-only byte slices which don't need
conversion.

name                                       old time/op  new time/op  delta
ToUpper/#00-8                              9.35ns ± 3%  6.08ns ± 2%  -35.04%  (p=0.000 n=9+9)
ToUpper/ONLYUPPER-8                        77.7ns ± 1%  16.9ns ± 2%  -78.22%  (p=0.000 n=10+10)
ToUpper/abc-8                              36.5ns ± 1%  22.1ns ± 1%  -39.43%  (p=0.000 n=10+8)
ToUpper/AbC123-8                           56.9ns ± 2%  28.2ns ± 2%  -50.54%  (p=0.000 n=8+10)
ToUpper/azAZ09_-8                          62.3ns ± 1%  26.9ns ± 1%  -56.82%  (p=0.000 n=9+10)
ToUpper/longStrinGwitHmixofsmaLLandcAps-8   219ns ± 2%    63ns ± 2%  -71.17%  (p=0.000 n=10+10)
ToUpper/longɐstringɐwithɐnonasciiⱯchars-8   367ns ± 2%   374ns ± 3%   +2.05%  (p=0.000 n=9+10)
ToUpper/ɐɐɐɐɐ-8                             200ns ± 1%   206ns ± 1%   +2.49%  (p=0.000 n=10+10)
ToUpper/a\u0080\U0010ffff-8                90.4ns ± 1%  93.8ns ± 0%   +3.82%  (p=0.000 n=10+7)
ToLower/#00-8                              9.59ns ± 1%  6.13ns ± 2%  -36.08%  (p=0.000 n=10+10)
ToLower/abc-8                              36.4ns ± 1%  10.4ns ± 1%  -71.50%  (p=0.000 n=10+10)
ToLower/AbC123-8                           55.8ns ± 1%  27.5ns ± 1%  -50.61%  (p=0.000 n=10+10)
ToLower/azAZ09_-8                          61.7ns ± 1%  30.2ns ± 1%  -50.98%  (p=0.000 n=8+10)
ToLower/longStrinGwitHmixofsmaLLandcAps-8   226ns ± 1%    64ns ± 1%  -71.53%  (p=0.000 n=10+9)
ToLower/LONGⱯSTRINGⱯWITHⱯNONASCIIⱯCHARS-8   354ns ± 0%   361ns ± 0%   +2.18%  (p=0.000 n=10+10)
ToLower/ⱭⱭⱭⱭⱭ-8                             180ns ± 1%   186ns ± 0%   +3.45%  (p=0.000 n=10+9)
ToLower/A\u0080\U0010ffff-8                91.7ns ± 0%  94.5ns ± 0%   +2.99%  (p=0.000 n=10+10)

Change-Id: Ifdb8ae328ff9feacd1c170db8eebbf98c399e204
Reviewed-on: https://go-review.googlesource.com/c/go/+/170954
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-04-09 05:45:34 +00:00
Mikio Hara
2ab75c0f40 syscall: gofmt -w -s
Change-Id: Ib46f1a528e16cd0c2617defbf4dcd1f1b582cdc2
Reviewed-on: https://go-review.googlesource.com/c/go/+/171101
Run-TryBot: Mikio Hara <mikioh.public.networking@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-09 01:48:33 +00:00
Mikio Hara
7ea4cd3fa9 cmd/cover: rename temporary directory prefix for consistency
This change renames the temporary directory prefix for testing to
go-testcover from gotestcover. It looks like other packages have the
"go-" prefix for temporary directories, such as go-build, go-tool-dist
and go-nettest.

Change-Id: I91ab570d33c4c1bb48e6e01451a811272f6f8b77
Reviewed-on: https://go-review.googlesource.com/c/go/+/171100
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-09 01:48:12 +00:00
Neven Sajko
7756a72b35 all: change the old assembly style AX:CX to CX, AX
Assembly files with "/vendor/" or "testdata" in their paths were ignored.

Change-Id: I3882ff07eb4426abb9f8ee96f82dff73c81cd61f
GitHub-Last-Rev: 51ae8c324d
GitHub-Pull-Request: golang/go#31166
Reviewed-on: https://go-review.googlesource.com/c/go/+/170197
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-09 00:22:03 +00:00
Josh Bleecher Snyder
336f951b07 cmd/compile: add ORESULT, remove OINDREGSP
This change is mostly cosmetic.

OINDREGSP was used only for reading the results of a function call.
In recognition of that fact, rename it to ORESULT.
Along the way, trim down our handling of it to the bare minimum,
and rely on the increased clarity of ORESULT to inline nodarg.

Passes toolstash-check.

Change-Id: I25b177df4ea54a8e94b1698d044c297b7e453c64
Reviewed-on: https://go-review.googlesource.com/c/go/+/170705
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-04-08 21:33:15 +00:00
Elias Naur
e4665da9bc cmd/go/internal/work: make toolchain builds reproducible when buildmode=pie
When buildmode=pie, external linking is forced, and our toolchain build id
will be included in the external build id, resulting in the building of
a toolchain tool will never reach a fixed point id.

More importantly, this change will make make.bash converge on self-hosted
Android builds (Android refuses to run non-PIE executables).

Fixes #31320
Updates #18968

Change-Id: Icb5db9f4b1b688afe37f4dafe261ffda580fa4e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/170942
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-08 20:38:29 +00:00
Elias Naur
f18c31a49c runtime,runtime/cgo: set up TLS storage for Android Q without cgo
Android Q frees a static TLS slot for us to use. Use the offset of
that slot as the default for our TLS offset.

As a result, runtime/cgo is no more a requirement for Android Q and
newer.

Updates #31343
Updates #29674

Change-Id: I759049b2e2865bd3d4fdc05a8cfc6db8b0da1f5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/170955
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-04-08 20:21:51 +00:00
Andrew Bonventre
973c0312e3 doc: correct link in 1.12.3 notes
Change-Id: I6dd60ea7b8a8756be97503e163c2386af16e4e12
Reviewed-on: https://go-review.googlesource.com/c/go/+/171144
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-08 20:13:20 +00:00
Andrew Bonventre
6f512c8d66 doc: correct link in 1.11.8 notes
Change-Id: I09e0c2720ec0a51dc73c24b4550a749448656025
Reviewed-on: https://go-review.googlesource.com/c/go/+/171143
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-08 20:10:30 +00:00
Andrew Bonventre
739a78f2b8 doc: document Go 1.11.8
Change-Id: Ia06f7005f466e55a22c76bf2b47d74ee8eb77dd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/171139
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-08 20:06:15 +00:00
Andrew Bonventre
8759b4d384 doc: document Go 1.12.3
Change-Id: I84c9a8ddbd3101dd478e4a8a4e191863e68c6af6
Reviewed-on: https://go-review.googlesource.com/c/go/+/171140
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-08 20:03:55 +00:00
Jingnan Si
bec67e1130 runtime: follow Windows calling convention for _cgo_sys_thread_create
Windows requires space for four pointers on the stack.

Change-Id: I9f7ba3e09b6c660f86d15139bb51954fffc8ccb1
GitHub-Last-Rev: 76d21bcc2b
GitHub-Pull-Request: golang/go#30944
Reviewed-on: https://go-review.googlesource.com/c/go/+/168351
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-08 19:05:25 +00:00
Elias Naur
81c7beb04e cmd/dist: set buildmode=pie on Android
Android refuses to run non-PIE binaries, a restriction already
encoded in the cmd/go tool's buildModeInit function. This CL adds
the necessary flags to cmd/dist to make ./make.bash run on an
Android device.

Change-Id: I162084f573befaa41dcb47a2b78448bce5b83d35
Reviewed-on: https://go-review.googlesource.com/c/go/+/170943
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-04-08 18:28:43 +00:00
Elias Naur
00530918db misc/cgo/testcshared: use adb exec-out instead of adb shell
Adb exec-out is like adb shell except non-flaky in non-interactive
settings. Don't ask why.

Change-Id: I7ac3c72912883d80bc787c1d0fc101db6bae9c52
Reviewed-on: https://go-review.googlesource.com/c/go/+/170952
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-08 18:21:14 +00:00
Daniel Theophanes
081bc62d72 cmd/go: do not write output when -o is not specified, but folder with same name exists
Fixes #31296

Change-Id: Ib8850fe22749ca0bf268614ba045ffe3fc68f5cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/171057
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-04-08 17:21:02 +00:00
Keith Randall
c46ebec322 cmd/compile: get rid of unnecessary inline marks
If no other instruction mentions an inline mark, we can get rid of it.
This normally happens when the inlined function is empty, or when all
of its code is folded into other instructions.

Also use consistent statement-ness for inline mark positions, so that
more of them can be removed in favor of existing instructions.

Update #29571
Fixes #31172

Change-Id: I71f84d355101f37a27960d9e8528f42f92767496
Reviewed-on: https://go-review.googlesource.com/c/go/+/170445
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2019-04-08 16:46:20 +00:00
Michael Anthony Knyszek
7bb8fc1033 runtime: use iterator instead of raw node for treap find
Right now the mTreap structure exposes the treapNode structure through
only one interface: find. There's no reason (performance or otherwise)
for exposing this, and we get a cleaner abstraction through the
iterators this way. This change also makes it easier to make changes to
the mTreap implementation without violating its interface.

Change-Id: I5ef86b8ac81a47d05d8404df65af9ec5f419dc40
Reviewed-on: https://go-review.googlesource.com/c/go/+/164098
Reviewed-by: Austin Clements <austin@google.com>
2019-04-08 15:41:43 +00:00
Michael Anthony Knyszek
23d4c6cdd6 runtime: merge codepaths in scavengeLargest
This change just makes the code in scavengeLargest easier to reason
about by reducing the number of exit points to the method. It should
still be correct either way because the condition checked at the end
(released > nbytes) will always be false if we return, but this just
makes the code a little easier to maintain.

Change-Id: If60da7696aca3fab3b5ddfc795d600d87c988238
Reviewed-on: https://go-review.googlesource.com/c/go/+/160617
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2019-04-08 15:36:03 +00:00
Tobias Klauser
f70d457a36 strings: unindent Fields
CL 56470 unindented bytes.Fields, but not strings.Fields. Do so now to
make it easier to diff the two functions for potential differences.

Change-Id: Ifef81f50cee64e8277e91efa5ec5521d8d21d3bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/170951
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-08 08:18:38 +00:00
Jannis Andrija Schnitzer
20995f6274 archive/zip: use Modified in FileHeader.FileInfo
The Modified field allows representation of extended timestamps, which provide more accuracy than the legacy MS-DOS timestamps.
The FileInfo method provides an implementation of the os.FileInfo interface for files inside archives.

With this change, we make FileInfo use the Modified field, if present, to return more detailed timestamps from its ModTime method.

Fixes #28350

Change-Id: Ia31b5b871a3e61df38a3a1325787ae23ea0b8088
GitHub-Last-Rev: 13e94be3f8
GitHub-Pull-Request: golang/go#28352
Reviewed-on: https://go-review.googlesource.com/c/go/+/144382
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-04-08 07:55:52 +00:00
Elias Naur
9017b6149e misc/cgo/test: skip Setgid test on Android
The setgid syscall is blocked on Android in app context.

Change-Id: I1ff25840bbc25d472ad4e29eb1b51f183a6c4392
Reviewed-on: https://go-review.googlesource.com/c/go/+/170949
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-08 05:56:14 +00:00
Elias Naur
ef38e21eb5 net: pass TMPDIR to test client process
Fixes the TestSplice test on Android where the default
TMPDIR (/data/local/tmp) might not be available.

Change-Id: I4f104d11254ba855b1bd2dfa0547d69b7bce4878
Reviewed-on: https://go-review.googlesource.com/c/go/+/170947
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-07 18:55:23 +00:00
Elias Naur
7331edcef5 os/exec: skip unsupported test on Android
The underlying system call tested by TestCredentialNoSetGroups
is blocked on Android.

Discovered while running all.bash from an Android device; the syscall
is only blocked in an app context.

Change-Id: I16fd2e64636a0958b0ec86820723c0577b8f8f24
Reviewed-on: https://go-review.googlesource.com/c/go/+/170945
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-07 18:34:41 +00:00
Elias Naur
71371d850f os: skip Open("/") on Android
It's not supported in an app context:

$ go test -short os
--- FAIL: TestChdirAndGetwd (0.00s)
    os_test.go:1213: Open /: open /: permission denied

Change-Id: I56b951f925a50fd67715ee2f1de64951ee867e91
Reviewed-on: https://go-review.googlesource.com/c/go/+/170946
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-07 18:34:25 +00:00
Elias Naur
1cff98d4fe bootstrap.bash: remove exec wrappers
Without this change, building an Android toolchain fails:

$ CGO_ENABLED=1 GOARCH=arm64 GOOS=android ./bootstrap.bash
...
rmdir: failed to remove 'bin/go_android_arm64_exec': Not a directory

Change-Id: Ibc3b1e2fd24b73a63bd3020ce1e813f2b4496125
Reviewed-on: https://go-review.googlesource.com/c/go/+/170941
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-07 14:32:14 +00:00
Nigel Tao
1c00deeaf9 image: deprecate ZP and ZR
They were added a very long time ago, as a convenience before Go had
struct literals. Today, it is better to use the zero-valued literal. For
example, the compiler cannot prove that ZP or ZR have not been modified.

Change-Id: I7469f1c751e91bf76fe1eab07b5772eccb5d6405
Reviewed-on: https://go-review.googlesource.com/c/go/+/171097
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2019-04-07 03:44:17 +00:00
Keith Randall
ad6c691542 cmd/compile: remove AUNDEF opcode
This opcode was only used to mark unreachable code for plive to use.
plive now uses the SSA representation, so it knows locations are
unreachable because they are ends of Exit blocks. It doesn't need
these opcodes any more.

These opcodes actually used space in the binary, 2 bytes per undef
on x86 and more for other archs.

Makes the amd64 go binary 0.2% smaller.

Change-Id: I64c84c35db7c7949617a3a5830f09c8e5fcd2620
Reviewed-on: https://go-review.googlesource.com/c/go/+/171058
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-07 01:15:28 +00:00
Daniel Martí
cb6646234c encoding/json: use SetBytes in UnmarshalReuse benchmark
This was the only benchmark missing the SetBytes call, as spotted
earlier by Bryan.

It's not required to make the benchmark useful, but it can still be a
good way to see how its speed is affected by the reduced allocations:

name                  time/op
CodeUnmarshal-8        12.1ms ± 1%
CodeUnmarshalReuse-8   11.4ms ± 1%

name                  speed
CodeUnmarshal-8       161MB/s ± 1%
CodeUnmarshalReuse-8  171MB/s ± 1%

name                  alloc/op
CodeUnmarshal-8        3.28MB ± 0%
CodeUnmarshalReuse-8   1.94MB ± 0%

name                  allocs/op
CodeUnmarshal-8         92.7k ± 0%
CodeUnmarshalReuse-8    77.6k ± 0%

While at it, remove some unnecessary empty lines.

Change-Id: Ib2bd92d5b3237b8f3092e8c6f863dab548fee2f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/170938
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-05 20:54:50 +00:00
Keith Randall
06cff114cf syscall: use openat instead of dup to make a really new file descriptor
Update #31269

Change-Id: I0e7184420055b8dfd23688dab9f9d8cba1fa2485
Reviewed-on: https://go-review.googlesource.com/c/go/+/170892
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-05 20:40:01 +00:00
Austin Clements
68d89bb8e0 runtime: separate stack freeing from stack shrinking
Currently, shrinkstack will free the stack if the goroutine is dead.
There are only two places that call shrinkstack: scanstack, which will
never call it if the goroutine is dead; and markrootFreeGStacks, which
only calls it on dead goroutines.

Clean this up by separating stack freeing out of shrinkstack.

Change-Id: I7d7891e620550c32a2220833923a025704986681
Reviewed-on: https://go-review.googlesource.com/c/go/+/170890
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2019-04-05 20:19:59 +00:00
Austin Clements
ea9859f858 runtime: use acquirem/releasem more widely
We've copy-pasted the pattern of releasem in many places. This CL
replaces almost everywhere that manipulates g.m.locks and g.preempt
with calls to acquirem/releasem. There are a few where we do something
more complicated, like where exitsyscall has to restore the stack
bound differently depending on the preempt flag, which this CL leaves
alone.

Change-Id: Ia7a46c261daea6e7802b80e7eb9227499f460433
Reviewed-on: https://go-review.googlesource.com/c/go/+/170064
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-05 19:00:12 +00:00
Austin Clements
ac40a7fb9e runtime: fix sanity check in notetsleep
CL 3660 replaced m.gcing with m.preemptoff, but unintentionally
reversed the sense of part of a sanity check in notetsleep.
Originally, notetsleep required that it be called from g0 or with
preemption disabled (specifically from within the garbage collector).
CL 3660 made it require that it be called from g0 or that preemption
be *enabled*.

I'm not sure why it had the original exception for being called from a
user g within the garbage collector, but the current garbage collector
certainly doesn't need that, and the new condition is completely wrong.

Make the sanity check just require that it's called on g0.

Change-Id: I6980d44f5a4461935e10b1b33a981e32b1b7b0c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/170063
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-05 18:59:58 +00:00