1
0
mirror of https://github.com/golang/go synced 2024-11-14 08:40:27 -07:00
Commit Graph

33644 Commits

Author SHA1 Message Date
Josh Bleecher Snyder
3f972df4a7 runtime: don't clear pointer-free memory when growing maps
If there are no pointers, then clearing memory doesn't help GC,
and the memory is otherwise dead, so don't bother clearing it.

Change-Id: I953f4a3264939f2825e82292030eda2e835cbb97
Reviewed-on: https://go-review.googlesource.com/57350
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
2017-08-20 15:46:43 +00:00
Elias Naur
ff90f4af66 Revert "misc/cgo/testcshared: temporarily skip testing on android"
This reverts commit a6ffab6b67.

Reason for revert: with CL 57290 the tests run on Android again.

Change-Id: Ifeb29762a4cd0178463acfeeb3696884d99d2993
Reviewed-on: https://go-review.googlesource.com/57310
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2017-08-19 12:56:24 +00:00
Elias Naur
a9e0204c1e misc/cgo/testcshared: fix tests on android
The testcshared test.bash was rewritten in Go, but the rewritten script
broke on Android. Make the tests run on Android again by:

- Restoring the LD_LIBRARY_PATH path (.).
- Restoring the Android specific C flags (-pie -fuse-ld=gold).
- Adding runExe to run test executables. All other commands must run on
the host.

Fixes #21513.

Change-Id: I3ea617a943c686b15437cc5c118e9802a913d93a
Reviewed-on: https://go-review.googlesource.com/57290
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2017-08-19 12:55:05 +00:00
Alex Brainman
a6ffab6b67 misc/cgo/testcshared: temporarily skip testing on android
For #21513

Change-Id: Ibe9479f8afc6f425779a737a807ff2f839a4f311
Reviewed-on: https://go-review.googlesource.com/57250
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2017-08-19 08:18:09 +00:00
Josh Bleecher Snyder
fc583c542b .github: update ISSUE_TEMPLATE to be closer to 'go bug'
Ask whether the issue reproduces with the latest release.

'go bug' places the version and system details last,
in part because they're automatically filled.
I'd like to do the same here, but I worry
that they'll get ignored.

Change-Id: Iec636a27e6e36d61dca421deaf24ed6fe35d4b11
Reviewed-on: https://go-review.googlesource.com/50931
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Avelino <t@avelino.xxx>
2017-08-19 04:06:10 +00:00
Russ Cox
6f0b1aa0e2 cmd/go: test and fix missing deep dependencies in list Deps output
Fixes #21522.

Change-Id: Ifec1681b265576c47a4d736f6f124cc25485c593
Reviewed-on: https://go-review.googlesource.com/57011
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-19 03:33:15 +00:00
Alex Brainman
e2cdec77c6 misc/cgo/testcshared: cd into work directory before running android command
Hopefully this will fix android build.

Maybe fixes #21513

Change-Id: I98f760562646f06b56e385c36927e79458465b92
Reviewed-on: https://go-review.googlesource.com/56790
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-19 02:27:34 +00:00
Joe Tsai
3bece2fa0e archive/tar: refactor Reader support for sparse files
This CL is the first step (of two) for adding sparse file support
to the Writer. This CL only refactors the logic of sparse-file handling
in the Reader so that common logic can be easily shared by the Writer.

As a result of this CL, there are some new publicly visible API changes:
	type SparseEntry struct { Offset, Length int64 }
	type Header struct { ...; SparseHoles []SparseEntry }

A new type is defined to represent a sparse fragment and a new field
Header.SparseHoles is added to represent the sparse holes in a file.
The API intentionally represent sparse files using hole fragments,
rather than data fragments so that the zero value of SparseHoles
naturally represents a normal file (i.e., a file without any holes).
The Reader now populates SparseHoles for sparse files.

It is necessary to export the sparse hole information, otherwise it would
be impossible for the Writer to specify that it is trying to encode
a sparse file, and what it looks like.

Some unexported helper functions were added to common.go:
	func validateSparseEntries(sp []SparseEntry, size int64) bool
	func alignSparseEntries(src []SparseEntry, size int64) []SparseEntry
	func invertSparseEntries(src []SparseEntry, size int64) []SparseEntry

The validation logic that used to be in newSparseFileReader is now moved
to validateSparseEntries so that the Writer can use it in the future.
alignSparseEntries is currently unused by the Reader, but will be used
by the Writer in the future. Since TAR represents sparse files by
only recording the data fragments, we add the invertSparseEntries
function to convert a list of data fragments to a normalized list
of hole fragments (and vice-versa).

Some other high-level changes:
* skipUnread is deleted, where most of it's logic is moved to the
Discard methods on regFileReader and sparseFileReader.
* readGNUSparsePAXHeaders was rewritten to be simpler.
* regFileReader and sparseFileReader were completely rewritten
in simpler and easier to understand logic.
* A bug was fixed in sparseFileReader.Read where it failed to
report an error if the logical size of the file ends before
consuming all of the underlying data.
* The tests for sparse-file support was completely rewritten.

Updates #13548

Change-Id: Ic1233ae5daf3b3f4278fe1115d34a90c4aeaf0c2
Reviewed-on: https://go-review.googlesource.com/56771
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-19 00:57:31 +00:00
Vlad Krasnov
b2174a16c0 crypto/aes: make the GHASH part of AES-GCM faster
By processing 8 blocks in parallel GHASH achieves higher throughput on amd64

Results on Skylake i7:

benchmark                   old ns/op     new ns/op     delta
BenchmarkAESGCMSeal1K-8     316           314           -0.63%
BenchmarkAESGCMOpen1K-8     282           281           -0.35%
BenchmarkAESGCMSign8K-8     5611          1099          -80.41%
BenchmarkAESGCMSeal8K-8     1869          1922          +2.84%
BenchmarkAESGCMOpen8K-8     1718          1724          +0.35%

benchmark                   old MB/s     new MB/s     speedup
BenchmarkAESGCMSeal1K-8     3237.10      3260.94      1.01x
BenchmarkAESGCMOpen1K-8     3629.74      3638.10      1.00x
BenchmarkAESGCMSign8K-8     1459.82      7452.99      5.11x
BenchmarkAESGCMSeal8K-8     4382.45      4260.93      0.97x
BenchmarkAESGCMOpen8K-8     4766.41      4750.54      1.00x

Change-Id: I479f2a791a968caa1c516115b0b6b96a791a20d2
Reviewed-on: https://go-review.googlesource.com/57150
Reviewed-by: Adam Langley <agl@golang.org>
2017-08-18 21:40:57 +00:00
Austin Clements
57584a0ee1 runtime: fix false positive race in profile label reading
Because profile labels are copied from the goroutine into the tag
buffer by the signal handler, there's a carefully-crafted set of race
detector annotations to create the necessary happens-before edges
between setting a goroutine's profile label and retrieving it from the
profile tag buffer.

Given the constraints of the signal handler, we have to approximate
the true synchronization behavior. Currently, that approximation is
too weak.

Ideally, runtime_setProfLabel would perform a store-release on
&getg().labels and copying each label into the profile would perform a
load-acquire on &getg().labels. This would create the necessary
happens-before edges through each individual g.labels object.

Since we can't do this in the signal handler, we instead synchronize
on a "labelSync" global. The problem occurs with the following
sequence:

1. Goroutine 1 calls setProfLabel, which does a store-release on
   labelSync.

2. Goroutine 2 calls setProfLabel, which does a store-release on
   labelSync.

3. Goroutine 3 reads the profile, which does a load-acquire on
   labelSync.

The problem is that the load-acquire only synchronizes with the *most
recent* store-release to labelSync, and the two store-releases don't
synchronize with each other. So, once goroutine 3 touches the label
set by goroutine 1, we report a race.

The solution is to use racereleasemerge. This is like a
read-modify-write, rather than just a store-release. Each RMW of
labelSync in runtime_setProfLabel synchronizes with the previous RMW
of labelSync, and this ultimately carries forward to the load-acquire,
so it synchronizes with *all* setProfLabel operations, not just the
most recent.

Change-Id: Iab58329b156122002fff12cfe64fbeacb31c9613
Reviewed-on: https://go-review.googlesource.com/56670
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2017-08-18 21:40:37 +00:00
Ilya Tocar
ac29f4d01c cmd/compile/internal/amd64: add ADD[Q|L]constmem
We can add a constant to loaction in memory with 1 instruction,
as opposed to load+add+store, so add a new op and relevent ssa rules.
Triggers in e. g. encoding/json isValidNumber:
NumberIsValid-6          36.4ns ± 0%    35.2ns ± 1%  -3.32%  (p=0.000 n=6+10)
Shaves ~2.5 kb from go tool.

Change-Id: I7ba576676c2522432360f77b290cecb9574a93c3
Reviewed-on: https://go-review.googlesource.com/54431
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-08-18 18:55:44 +00:00
Daniel Martí
943dd0fe33 cmd/*: remove negative uint checks
All of these are uints of different sizes, so checking >= 0 or < 0 are
effectively no-ops.

Found with staticcheck.

Change-Id: I16ac900eb7007bc8f9018b302136d42e483a4180
Reviewed-on: https://go-review.googlesource.com/56950
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-18 18:45:05 +00:00
Josh Bleecher Snyder
776c33ee5e runtime: make evacDst a top level type
This will reduce duplication when evacuate is specialized.

Change-Id: I34cdfb7103442d3e0ea908c970fb46334b86d5c4
Reviewed-on: https://go-review.googlesource.com/56934
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Avelino <t@avelino.xxx>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-18 18:21:10 +00:00
Josh Bleecher Snyder
e0b34e7be7 runtime: split advanceEvacuationMark from evacuate
Minor refactoring. This is a step towards specializing evacuate
for mapfast key types.

Change-Id: Icffe2759b7d38e5c008d03941918d5a912ce62f6
Reviewed-on: https://go-review.googlesource.com/56933
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-08-18 18:20:55 +00:00
Josh Bleecher Snyder
43d4c9f4f1 runtime: tiny refactor in evacuate
Since oldbucket == h.nevacuate, we can just increment h.nevacuate here.
This removes oldbucket from scope, which will be useful shortly.

Change-Id: I70f81ec3995f17845ebf5d77ccd20ea4338f23e6
Reviewed-on: https://go-review.googlesource.com/56932
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Avelino <t@avelino.xxx>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-18 18:20:32 +00:00
Josh Bleecher Snyder
b5c4211159 runtime: don't cache t.key.alg in evacuate
The number of times that alg has to be spilled
and restored makes it better to just reload it.

Change-Id: I2674752a889ecad59dab54da1d68fad03db1ca85
Reviewed-on: https://go-review.googlesource.com/56931
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-18 18:20:10 +00:00
Josh Bleecher Snyder
8a9d4184e6 runtime: simplify evacuate's handling of NaNs
The new code is not quite equivalent to the old,
in that if newbit was very large it might have altered the new tophash.
The old behavior is unnecessary and probably undesirable.

Change-Id: I7fb3222520cb61081a857adcddfbb9078ead7122
Reviewed-on: https://go-review.googlesource.com/56930
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-08-18 18:19:47 +00:00
Marvin Stenger
1ba4556a2c bytes: clean-up of buffer.go
Clean-up changes in no particular order:
- use uint8 instead of int for readOp
- remove duplicated code in ReadFrom()
- introduce (*Buffer).empty()
- remove naked returns

Change-Id: Ie6e673c20c398f980f8be0448969a36ad4778804
Reviewed-on: https://go-review.googlesource.com/42816
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-18 17:41:11 +00:00
Cherry Zhang
99fe3f8c63 cmd/compile: add rules handling unsigned div/mod by constant 1<<63
Normally 64-bit div/mod is turned into runtime calls on 32-bit
arch, but the front end leaves power-of-two constant division
and hopes the SSA backend turns into a shift or AND. The SSA rule is

(Mod64u <t> n (Const64 [c])) && isPowerOfTwo(c) -> (And64 n (Const64 <t> [c-1]))

But isPowerOfTwo returns true only for positive int64, which leaves
out 1<<63 unhandled. Add a special case for 1<<63.

Fixes #21517.

Change-Id: I02d27dc7177d4af0ee8d7f5533714edecddf8c95
Reviewed-on: https://go-review.googlesource.com/56890
Reviewed-by: Keith Randall <khr@golang.org>
2017-08-18 17:12:14 +00:00
Kevin Burke
839b28246f time: add leap year test for Date
I'm writing a matching implementation of the time package and missed
the "add one day in a leap year" block. This test would have caught my
error.

I understand we can't add test cases for every Date but it seems like
"tripped up someone attempting to reimplement this" is a good
indicator it may trip up people in the future.

Change-Id: I4c3b51e52e269215ec0e52199afe604482326edb
Reviewed-on: https://go-review.googlesource.com/56490
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-18 16:55:11 +00:00
Russ Cox
e9983165dd cmd/vendor/golang.org/x/arch: import latest (Aug 18 2017 ffd22fb365cd)
Fixes #21486.

Change-Id: I01794f008404f0e2d8a1408309ae6055513c5b49
Reviewed-on: https://go-review.googlesource.com/57030
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2017-08-18 16:18:24 +00:00
isharipo
9f5f51af7c cmd/asm: uncomment tests for amd64 PHADD{SW,W}, PHSUB{D,SW,W}
Instructions added in https://golang.org/cl/18853

2nd change out of 3 to cover AMD64 SSSE3 instruction set in Go asm.
This commit does not actually add any new instructions, only
enables some test cases.

Change-Id: I9596435b31ee4c19460a51dd6cea4530aac9d198
Reviewed-on: https://go-review.googlesource.com/56835
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
2017-08-18 16:10:21 +00:00
Russ Cox
a2b70ebf2d cmd/dist: disable broken TestDeps
Will debug soon but wanted to fix builders.

Change-Id: I921d58d1272370f3102ba1f86ad535f4c0f6b8db
Reviewed-on: https://go-review.googlesource.com/56970
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2017-08-18 15:08:25 +00:00
Keith Randall
77871cc664 runtime: no need to protect key/value increments against end of bucket
After the key and value arrays, we have an overflow pointer.
So there's no way a past-the-end key or value pointer could point
past the end of the containing bucket.

So we don't need this additional protection.

Update #21459

Change-Id: I7726140033b06b187f7a7d566b3af8cdcaeab0b0
Reviewed-on: https://go-review.googlesource.com/56772
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Avelino <t@avelino.xxx>
2017-08-18 14:52:25 +00:00
Russ Cox
a93753401d cmd/go: remove Package.Internal.Deps
Package.Internal.Imports is enough in nearly all cases,
and not maintaining a separate Package.Internal.Deps
avoids the two lists ending up out of sync.
(In some synthesized packages created during go test,
only Internal.Imports is initialized.)

Change-Id: I83f6a3ec6e6cbd75382f1fa0e439d31feec32d5a
Reviewed-on: https://go-review.googlesource.com/56278
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-18 14:31:39 +00:00
Russ Cox
4a52038c03 cmd/go: use objdir as consistent variable name for per-package work dir
Before it was obj, but if you don't have everything paged in
that sounds a bit like an object file. Use objdir, which is more
clearly a directory and also matches the Action.Objdir struct field.

Change-Id: I268042800f9ca05721814d7f18c728acb4831232
Reviewed-on: https://go-review.googlesource.com/56277
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-18 14:31:12 +00:00
Russ Cox
d52413d62d cmd/go: document that BinaryOnly packages must have accurate import info
Update BinaryOnly test by adding import _ "fmt".

Change-Id: I3a1dcfb83a27d8ff50a658060a46e1a3f481f6c7
Reviewed-on: https://go-review.googlesource.com/56276
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-18 14:29:16 +00:00
Russ Cox
13f7fe00d4 cmd/go: rename local variable ImportPaths to importPaths
ImportPaths is also the name of a top-level function.
It is confusing to have a capitalized local variable.

Change-Id: I1313e05ade4934d4ee250a67e5af6d1bd6229aca
Reviewed-on: https://go-review.googlesource.com/56275
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-18 14:26:25 +00:00
Russ Cox
dca29095be cmd/go: add t.Helper calls to test helpers
Now that we have t.Helper, might as well use it to make the
reported failure lines more helpful.

Change-Id: I2a0c64e9ca7bdc0eaf2b62f9f855c41467767084
Reviewed-on: https://go-review.googlesource.com/56274
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2017-08-18 14:26:09 +00:00
Russ Cox
2bc2b10314 cmd/go: make TestBuildDashIInstallsDependencies not depend only on time
When we make the go command pay attention to content
instead of time, we want this test to continue working.

Change-Id: Ib7d9d0d62bfe87810d71bdfc4f29561a8c70eccc
Reviewed-on: https://go-review.googlesource.com/56273
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-18 14:25:57 +00:00
Russ Cox
c6f3e98eb5 cmd/go: rewrite TestCgoFlagContainsSpace not to use a fake CC
Using a fake CC fails today if runtime/cgo is stale, because the
build will try to rebuild runtime/cgo using the fake CC, and the
fake CC is not a working C compiler.

Worse, in the future, when the go command is sensitive to details like
the fact that different CCs produce different outputs, putting in
the fake CC will make runtime/cgo look stale even if it was
formerly up-to-date.

Fix both problems by not overriding CC and instead looking at
the command being run to make sure the flags are quoted as expected.

Change-Id: I4417e35cfab33a07546cc90748ddb6119d8fdb2d
Reviewed-on: https://go-review.googlesource.com/56272
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-18 14:25:36 +00:00
Russ Cox
e2c30e1fc5 cmd/go: change testMainDeps from map to slice
This makes the construction of pmain.Internal.Imports consistently ordered.

Change-Id: I82348a18c7824378aa7e5bc5b6bcd550d4b758da
Reviewed-on: https://go-review.googlesource.com/56271
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-18 14:25:02 +00:00
Ben Shi
75cb22cb2f cmd/internal/obj/arm: support new arm instructions
There are two changes in this CL.

1. Add new forms of MOVH/MOVHS/MOVHU.
   MOVHS R0<<0(R1), R2   // ldrsh
   MOVH  R0<<0(R1), R2   // ldrsh
   MOVHU R0<<0(R1), R2   // ldrh
   MOVHS R2, R5<<0(R1)   // strh
   MOVH  R2, R5<<0(R1)   // strh
   MOVHU R2, R5<<0(R1)   // strh

2. Simpify "MVN $0xffffffaa, Rn" to "MOVW $0x55, Rn".
   It is originally assembled to two instructions.
   "MOVW offset(PC), R11"
   "MVN R11, Rn"

Change-Id: I8e863dcfb2bd8f21a04c5d627fa7beec0afe65fb
Reviewed-on: https://go-review.googlesource.com/53690
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2017-08-18 14:13:41 +00:00
pvoicu
310be7be5c runtime: fix usleep by correctly setting nanoseconds parameter for pselect6
Fixes #21518

Change-Id: Idd67e3f0410d0ce991b34dcc0c8f15e0d5c529c9
Reviewed-on: https://go-review.googlesource.com/56850
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-18 13:35:47 +00:00
Lakshay Garg
77412b9300 math: implement the erfinv function
This commit defines the inverse of error function (erfinv) in the
math package. The function is based on the rational approximation
of percentage points of normal distribution available at
https://www.jstor.org/stable/pdf/2347330.pdf.

Fixes #6359

Change-Id: Icfe4508f623e0574c7fffdbf7aa929540fd4c944
Reviewed-on: https://go-review.googlesource.com/46990
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-08-18 13:30:46 +00:00
Brian Kessler
497f891fce math/big: recognize squaring for Floats
Updates #13745

Recognize z.Mul(x, x) as squaring for Floats and use
the internal z.sqr(x) method for nat on the mantissa.

Change-Id: I0f792157bad93a13cae1aecc4c10bd20c6397693
Reviewed-on: https://go-review.googlesource.com/56774
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-18 12:48:10 +00:00
Brian Kessler
fe08ebaebb math/big: use internal square for Rat
updates #13745

A squared rational is always positive and can not
be reduced since the numerator and denominator had
no previous common factors.  The nat multiplication
can be performed using the internal sqr method.

Change-Id: I558f5b38e379bfd26ff163c9489006d7e5a9cfaa
Reviewed-on: https://go-review.googlesource.com/56776
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-18 12:47:46 +00:00
Martin Möhrmann
66a1d37bf7 cmd/compile: fix language in makeslice comment
Change-Id: I1929ea7e4ed88631ef729472ffe474016efec3e8
Reviewed-on: https://go-review.googlesource.com/56370
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-18 09:28:16 +00:00
Daniel Martí
59413d34c9 all: unindent some big chunks of code
Found with mvdan.cc/unindent. Prioritized the ones with the biggest wins
for now.

Change-Id: I2b032e45cdd559fc9ed5b1ee4c4de42c4c92e07b
Reviewed-on: https://go-review.googlesource.com/56470
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-18 06:59:48 +00:00
Alex Brainman
b73d46de36 misc/cgo/testcshared: fix syntax error in the test
Another attempt to fix build

Change-Id: I26137c115ad4b5f5a69801ed981c146adf6e824c
Reviewed-on: https://go-review.googlesource.com/56750
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-18 05:29:56 +00:00
Alex Brainman
54f6911af5 misc/cgo/testcshared: use adb instead of ./adb on android
Hopefully fixes build.

Change-Id: If0629b95b923a65e4507073cf7aa44a5e178fc0f
Reviewed-on: https://go-review.googlesource.com/56711
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2017-08-18 04:45:49 +00:00
Christopher Nelson
ef94870cc8 misc/cgo/testcshared: rewrite test.bash in Go
Change-Id: Id717054cb3c4537452f8ff848445b0c20196a373
Reviewed-on: https://go-review.googlesource.com/33579
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2017-08-18 03:23:12 +00:00
Hiroshi Ioka
3d124b1a81 debug/macho: support LC_RPATH
Updates #21487

Change-Id: Ia549a87a8a305cc80da11ea9bd904402f1a14689
Reviewed-on: https://go-review.googlesource.com/56321
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-17 23:48:27 +00:00
Hiroshi Ioka
2763672ecb cmd/link: show native relocation type name in error messages
Change-Id: I7f7b1e7ef832d53a93562b08ae914d023247c2c0
Reviewed-on: https://go-review.googlesource.com/56312
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-17 23:41:25 +00:00
Keith Randall
bf4d8d3d05 cmd/compile: rename SSA Register.Name to Register.String
Just to get rid of lots of .Name() stutter in printf calls.

Change-Id: I86cf00b3f7b2172387a1c6a7f189c1897fab6300
Reviewed-on: https://go-review.googlesource.com/56630
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2017-08-17 21:53:08 +00:00
Martin Möhrmann
455775dae6 runtime: improve makechan memory checks and allocation calls
Use mallogc instead of newarray to save some overhead since
makechan already checks for _MaxMem constraints.

Flattens the if else construct that determines if buf and hchan struct
should be allocated in one mallocgc call and where buf should point to.

Uses maxSliceCap to avoid divisions similar to makeslice.

name                old time/op  new time/op  delta
MakeChan/Byte       82.0ns ± 8%  81.4ns ± 7%    ~     (p=0.643 n=10+10)
MakeChan/Int        97.9ns ± 2%  96.6ns ± 2%  -1.40%  (p=0.009 n=10+10)
MakeChan/Ptr         128ns ± 3%   120ns ± 1%  -6.63%  (p=0.000 n=10+10)
MakeChan/Struct/0   66.7ns ± 4%  66.4ns ± 2%    ~     (p=0.697 n=10+10)
MakeChan/Struct/32   136ns ± 1%   130ns ± 0%  -4.42%  (p=0.000 n=10+10)
MakeChan/Struct/40   150ns ± 1%   150ns ± 1%    ~     (p=0.725 n=10+10)

Change-Id: Ibb5675d0843a072aae2bfa58ecd39cf4cd926533
Reviewed-on: https://go-review.googlesource.com/55132
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-08-17 20:24:15 +00:00
Martin Möhrmann
b6296426a0 runtime: avoid zeroing hmap fields in makemap twice
Stack allocated hmap structs are explicitly zeroed before being
passed by pointer to makemap.

Heap allocated hmap structs are created with newobject
which also zeroes on allocation.

Therefore, setting the hmap fields to 0 or nil is redundant
since they will have been zeroed when hmap was allocated.

Change-Id: I5fc55b75e9dc5ba69f5e3588d6c746f53b45ba66
Reviewed-on: https://go-review.googlesource.com/56291
Reviewed-by: Keith Randall <khr@golang.org>
2017-08-17 20:10:23 +00:00
Kyle Shannon
541f8fef30 cmd/go: add fossil to general server regexp in get
Fix a missed change from:

https://golang.org/cl/56190

pointed out on the fossil mailing list shortly after submission
of the change mentioned above.  See:

http://www.mail-archive.com/fossil-users@lists.fossil-scm.org/msg25736.html

This change adds fossil to the general regular expression that is checked last
in the import path check.

For #10010

Change-Id: I6b711cdb1a8d4d767f61e1e28dc29dce529e0fad
Reviewed-on: https://go-review.googlesource.com/56491
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-17 18:26:42 +00:00
Bryan C. Mills
d5b0ec858b {net,os/user,plugin}: eliminate unnecessary C round-trips
We're making two extra round-trips to C to malloc and free strings
that originate in Go and don't escape. Skip those round-trips by
allocating null-terminated slices in Go memory instead.

Change-Id: I9e4c5ad999a7924ba50b82293c52073ec75518be
Reviewed-on: https://go-review.googlesource.com/56530
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-17 18:14:16 +00:00
Ian Lance Taylor
6711fa70ce test: add test that caused gccgo compiler crash
Updates #21253

Change-Id: Iece71a27207b578618cafb378dac2362517363d0
Reviewed-on: https://go-review.googlesource.com/52531
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-08-17 18:09:52 +00:00