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

37280 Commits

Author SHA1 Message Date
Elias Naur
51bda1ff08 compress/gzip: skip builder-only test on iOS
The new iOS test harness forwards environment variables to the
test program, which means that it runs builder-only tests that were
previously skipped because GO_BUILDER_NAME was missing.

Skip one such unblocked test, TestGZIPFilesHaveZeroMTimes, which
assumes a valid GOROOT.

Change-Id: I5daf0f4c1897afbeb8b1a380669a1d2aa47e764a
Reviewed-on: https://go-review.googlesource.com/111475
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-04 14:46:19 +00:00
Elias Naur
42219419ba net: skip unsupported tests on iOS
The new iOS test harness forwards environment variables, such that
tests that skipped on non-builders now run because GO_BUILDER_NAME
is set.

Skip the net tests that rely on resolv.conf being present.

Change-Id: I7875dc4252b2ab696c9aae13a9106ddf296ee8ec
Reviewed-on: https://go-review.googlesource.com/111476
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-04 14:46:05 +00:00
Elias Naur
164718ae2a misc/ios: improve detection of missing developer image
It turns out that a non-empty result from ideviceimagemounter does
not mean an image is mounted. Use ideviceimagemounter's xml output
mode to improve the check.

Also, iOS versions are reported as major.minor or major.minor.patch.
Developer images are only specific to major.minor version, so cut
off the patch number in the search, if present.

Change-Id: Ia182e6f4655b7e6aa6feb8005cd3b533535b73cd
Reviewed-on: https://go-review.googlesource.com/111235
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-05-04 05:47:22 +00:00
Martin Möhrmann
8c62fc0ca3 strings: fix encoding of \u0080 in map
Fix encoding of PAD (U+0080) which has the same value as utf8.RuneSelf
being incorrectly encoded as \x80 in strings.Map due to using <= instead
of a < comparison operator to check one byte encodings for utf8.

Fixes #25242

Change-Id: Ib6c7d1f425a7ba81e431b6d64009e713d94ea3bc
Reviewed-on: https://go-review.googlesource.com/111286
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-04 05:37:45 +00:00
Daniel Martí
98409a44d5 cmd/vet: better align print warnings with fmt
fmt's %d, %x, and %X all accept pointer arguments. However, in cmd/vet's
printVerbs table, they were defined as if they did not accept pointer
arguments.

This inconsistency with fmt did not manifest to users since the vet
codebase worked around it. In particular, pointer arguments were usually
allowed for verbs that accepted integers, as the *types.Pointer argument
type case read the following:

	t&(argInt|argPointer) != 0

As a result, using the %q verb with a pointer resulted in a bug in
cmd/vet:

	$ go run f.go
	%!q(*int=0xc000014140)
	$ go vet f.go
	[no warning]

As documented, fmt's %q verb only accepts runes (integers), strings, and
byte slices. It should not accept pointers, and it does not. But since
vet mixed integers and pointers, it wasn't properly warning about the
misuse of fmt.

This patch surfaced another bug with fmt.Printf("%p", nil):

	$ go run f.go
	%!p(<nil>)
	$ go vet f.go
	[no warning]

As documented, fmt's %p verb only accepts pointers, and untyped nil is
not a valid pointer. But vet did not warn about it, which is another
inconsistency with fmt's documented rules. Fix that too, with a test,
also getting rid of the TODO associated with the code.

As a result of those changes, fix a wrong use of the fmt format verbs in
the standard library, now correctly spotted by vet.

Fixes #25233.

Change-Id: Id0ad31fbc25adfe1c46c6b6879b8d02b23633b3a
Reviewed-on: https://go-review.googlesource.com/111284
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-05-04 02:57:37 +00:00
Brad Fitzpatrick
17fbb83693 cmd/go, cmd/compile: use Windows response files to avoid arg length limits
Fixes #18468

Change-Id: Ic88a8daf67db949e5b59f9aa466b37e7f7890713
Reviewed-on: https://go-review.googlesource.com/110395
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-04 01:01:50 +00:00
Ian Lance Taylor
498c803c19 cmd/go, go/build: add support for gccgo tooldir
The gccgo toolchain does not put tools (cgo, vet, etc.) in
$GOROOT/pkg/tool, but instead in a directory available at
runtime.GCCGOTOOLDIR.

Update the go/build package and the cmd/go tool to use this tool
directory when using gccgo.

Change-Id: Ib827336ff53601208300aceb77f76c2e1b069859
Reviewed-on: https://go-review.googlesource.com/111097
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-04 00:46:12 +00:00
Marvin Stenger
b44ca1f3b3 cmd/go: update alldocs.go
Ran go generate in order to update docs.

Change-Id: Ideb903427d153d0ff35e5164b7e79426b83b1afb
Reviewed-on: https://go-review.googlesource.com/111336
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-03 23:05:32 +00:00
Sam Whited
dc4b9cffde net/http: don't write redirect body if content-type is set
Fixes #25166

Change-Id: Id1fe18899579365519ac08ebedf74cd23c0fbd9f
Reviewed-on: https://go-review.googlesource.com/110296
Run-TryBot: Sam Whited <sam@samwhited.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-03 23:05:07 +00:00
Matthew Dempsky
6f7fa68b91 cmd: re-generate SymKind.String for SDWARFMISC
SDWARFMISC was added in golang.org/cl/93664.

Change-Id: Ifab0a5effd8e64a2b7916004aa35d51030f23d15
Reviewed-on: https://go-review.googlesource.com/111261
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-03 21:52:05 +00:00
Josh Bleecher Snyder
e3beabdb8f cmd/compile: regenerate ssa ops
Must have been missed in a previous CL.

Change-Id: I303736e82585be8d58b330235c76ed4b24a92952
Reviewed-on: https://go-review.googlesource.com/111259
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-03 21:42:18 +00:00
Cherry Zhang
14f929af91 runtime/internal/atomic: improve ARM atomics
This is a follow-up of CL 93637. There, when we redirect sync/atomic
to runtime/internal/atomic, a few good implementations of ARM atomics
were lost. This CL brings most of them back, with some improvements.

- Change atomic Store to a plain store with memory barrier, as we
  already changed atomic Load to plain load with memory barrier.

- Use native 64-bit atomics on ARMv7, jump to Go implementations
  on older machines. But drop the kernel helper. In particular,
  for Load64, just do loads, not using Cas on the address being
  load from, so it works also for read-only memory (since we have
  already fixed 32-bit Load).

Change-Id: I725cd65cf945ae5200db81a35be3f251c9f7af14
Reviewed-on: https://go-review.googlesource.com/111315
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-05-03 21:37:31 +00:00
Cherry Zhang
150b728675 runtime: use native CAS and memory barrier on ARMv7
This gets us around the kernel helpers on ARMv7.

It is slightly faster than using the kernel helper.

name           old time/op  new time/op  delta
AtomicLoad-4   72.5ns ± 0%  69.5ns ± 0%  -4.08%  (p=0.000 n=9+9)
AtomicStore-4  57.6ns ± 1%  54.4ns ± 0%  -5.58%  (p=0.000 n=10+9)
[Geo mean]     64.6ns       61.5ns       -4.83%

If performance is really critical, we can even do compiler intrinsics
on GOARM=7.

Fixes #23792.

Change-Id: I36497d880890b26bdf01e048b542bd5fd7b17d23
Reviewed-on: https://go-review.googlesource.com/94076
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-05-03 21:35:39 +00:00
Cherry Zhang
1b6fec862c sync/atomic: redirect many functions to runtime/internal/atomic
The implementation of atomics are inherently tricky. It would
be good to have them implemented in a single place, instead of
multiple copies.

Mostly a simple redirect.

On 386, some functions in sync/atomic have better implementations,
which are moved to runtime/internal/atomic.

On ARM, some functions in sync/atomic have better implementations.
They are dropped by this CL, but restored with an improved
version in a follow-up CL. On linux/arm, 64-bit CAS kernel helper
is dropped, as we're trying to move away from kernel helpers.

Fixes #23778.

Change-Id: Icb9e1039acc92adbb2a371c34baaf0b79551c3ea
Reviewed-on: https://go-review.googlesource.com/93637
Reviewed-by: Austin Clements <austin@google.com>
2018-05-03 21:35:01 +00:00
Josh Bleecher Snyder
4a1baf8bd1 cmd/compile: optimize a - b == 0 into a == b
These rules trigger 1141 times during make.bash.

Shrinks a few object files a tiny bit:

name        old object-bytes  new object-bytes  delta
Template          476kB ± 0%        476kB ± 0%  +0.00%  (p=0.008 n=5+5)
Unicode           218kB ± 0%        218kB ± 0%    ~     (all equal)
GoTypes          1.58MB ± 0%       1.58MB ± 0%    ~     (all equal)
Compiler         6.25MB ± 0%       6.25MB ± 0%  -0.00%  (p=0.008 n=5+5)
Flate             304kB ± 0%        304kB ± 0%  -0.01%  (p=0.008 n=5+5)
GoParser          370kB ± 0%        370kB ± 0%    ~     (all equal)
Reflect          1.27MB ± 0%       1.27MB ± 0%    ~     (all equal)
Tar               421kB ± 0%        421kB ± 0%  -0.05%  (p=0.008 n=5+5)
XML               518kB ± 0%        518kB ± 0%    ~     (all equal)

archive/tar benchmarks:

name             old time/op    new time/op    delta
/Writer/USTAR-8    3.97µs ± 1%    3.88µs ± 0%  -2.26%  (p=0.000 n=26+26)
/Writer/GNU-8      4.67µs ± 0%    4.54µs ± 1%  -2.72%  (p=0.000 n=28+27)
/Writer/PAX-8      8.20µs ± 0%    8.01µs ± 0%  -2.32%  (p=0.000 n=29+29)
/Reader/USTAR-8    3.61µs ± 0%    3.54µs ± 1%  -2.04%  (p=0.000 n=25+28)
/Reader/GNU-8      2.27µs ± 2%    2.17µs ± 0%  -4.08%  (p=0.000 n=30+28)
/Reader/PAX-8      7.75µs ± 0%    7.63µs ± 0%  -1.60%  (p=0.000 n=28+28)
[Geo mean]         4.61µs         4.50µs       -2.51%

Change-Id: Ib4dfade5069a7463ccaba073ea91c8213e9714a0
Reviewed-on: https://go-review.googlesource.com/110235
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
Reviewed-by: Keith Randall <khr@golang.org>
2018-05-03 20:35:21 +00:00
Ben Shi
fc48dcb15f cmd/internal/obj/arm64: add more atomic instructions
More atomic instructions were introduced in ARMv8.1. And this CL
adds support for them and corresponding test cases.

LDADD Rs, (Rb), Rt: (Rb) -> Rt, Rs+(Rb) -> (Rb)
LDAND Rs, (Rb), Rt: (Rb) -> Rt, Rs&(Rb) -> (Rb)
LDEOR Rs, (Rb), Rt: (Rb) -> Rt, Rs^(Rb) -> (Rb)
LDOR  Rs, (Rb), Rt: (Rb) -> Rt, Rs|(Rb) -> (Rb)

Change-Id: Ifb9df86583c4dc54fb96274852c3b93a197045e4
Reviewed-on: https://go-review.googlesource.com/110535
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-03 20:27:05 +00:00
Marvin Stenger
3c0bf181b7 strconv: simplify and optimize Itoa(small)
Use substring of digits for values < 10.

name                 old time/op  new time/op  delta
FormatIntSmall/7-4   4.54ns ± 1%  3.70ns ± 1%  -18.41%  (p=0.000 n=18+17)
FormatIntSmall/42-4  4.54ns ± 1%  4.13ns ± 1%   -9.02%  (p=0.000 n=16+18)

Change-Id: I0b521b563c13ef88aa2701049fa4a43760e884af
Reviewed-on: https://go-review.googlesource.com/111285
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-03 18:07:02 +00:00
Richard Musiol
63756e0c8f crypto/rand, crypto/x509: add js/wasm architecture
This commit adds the js/wasm architecture to the crypto packages.

Updates #18892

Change-Id: Id41a9d54920746d5019cbeedcff1b83874f2ef73
Reviewed-on: https://go-review.googlesource.com/110095
Reviewed-by: Austin Clements <austin@google.com>
2018-05-03 18:00:24 +00:00
Richard Musiol
7b83636800 syscall/js: add package
This commit adds the syscall/js package, which is used by the wasm
architecture to access the WebAssembly host environment (and the
operating system through it). Currently, web browsers and Node.js
are supported hosts, which is why the API is based on JavaScript APIs.
There is no common API standardized in the WebAssembly ecosystem yet.

This package is experimental. Its current scope is only to allow
tests to run, but not yet to provide a comprehensive API for users.

Updates #18892

Change-Id: I236ea10a70d95cdd50562212f2c18c3db5009230
Reviewed-on: https://go-review.googlesource.com/109195
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-03 18:00:07 +00:00
Josh Bleecher Snyder
1e27e4807b cmd/compile: shrink liveness maps
The GC maps don't care about trailing non-pointers in args.
Work harder to eliminate them.

This should provide a slight speedup to everything that reads these
maps, mainly GC and stack copying.

The non-ptr-y runtime benchmarks happen to go from having a non-empty
args map to an empty args map, so they have a significant speedup.

name                old time/op  new time/op  delta
StackCopyPtr-8      80.2ms ± 4%  79.7ms ± 2%  -0.63%  (p=0.001 n=94+91)
StackCopy-8         63.3ms ± 3%  59.2ms ± 3%  -6.45%  (p=0.000 n=98+97)
StackCopyNoCache-8   107ms ± 3%    98ms ± 3%  -8.00%  (p=0.000 n=95+88)

It also shrinks object files a tiny bit:

name        old object-bytes  new object-bytes  delta
Template          476kB ± 0%        476kB ± 0%  -0.03%  (p=0.008 n=5+5)
Unicode           218kB ± 0%        218kB ± 0%  -0.09%  (p=0.008 n=5+5)
GoTypes          1.58MB ± 0%       1.58MB ± 0%  -0.03%  (p=0.008 n=5+5)
Compiler         6.25MB ± 0%       6.24MB ± 0%  -0.06%  (p=0.008 n=5+5)
SSA              15.9MB ± 0%       15.9MB ± 0%  -0.06%  (p=0.008 n=5+5)
Flate             304kB ± 0%        303kB ± 0%  -0.29%  (p=0.008 n=5+5)
GoParser          370kB ± 0%        370kB ± 0%  +0.02%  (p=0.008 n=5+5)
Reflect          1.27MB ± 0%       1.27MB ± 0%  -0.07%  (p=0.008 n=5+5)
Tar               421kB ± 0%        421kB ± 0%  -0.05%  (p=0.008 n=5+5)
XML               518kB ± 0%        517kB ± 0%  -0.06%  (p=0.008 n=5+5)
[Geo mean]        934kB             933kB       -0.07%

Note that some object files do grow;
this can happen because some maps that were
duplicates of each others must be stored separately.

Change-Id: Ie076891bd8e9d269ff2ff5435d5d25c721e0e31d
Reviewed-on: https://go-review.googlesource.com/104175
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-05-03 17:31:29 +00:00
Josh Bleecher Snyder
4d7cf3fedb runtime: convert g.waitreason from string to uint8
Every time I poke at #14921, the g.waitreason string
pointer writes show up.

They're not particularly important performance-wise,
but it'd be nice to clear the noise away.

And it does open up a few extra bytes in the g struct
for some future use.

This is a re-roll of CL 99078, which was rolled
back because of failures on s390x.
Those failures were apparently due to an old version of gdb.

Change-Id: Icc2c12f449b2934063fd61e272e06237625ed589
Reviewed-on: https://go-review.googlesource.com/111256
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
2018-05-03 17:04:22 +00:00
Elias Naur
4704149e04 misc/ios: retry lldb launch if the iOS app is busy
Sometimes, a newly installed the test app is not ready to launch
or the reported app path is stale. Pause and retry the launch if
the lldb script did not run the program.

Change-Id: Ic7745d4b5a02f2e3cb8134341859039812f65a65
Reviewed-on: https://go-review.googlesource.com/111216
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-03 15:23:13 +00:00
Elias Naur
64f715beb6 misc/ios: clean up debugger instance on failure
Also replace repeated `or` clauses with the Python idiomatic list
operator `in`.

Change-Id: I4b178f93eb92996d8b5449ee5d252543624aed9e
Reviewed-on: https://go-review.googlesource.com/111215
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-03 15:15:27 +00:00
Elias Naur
8b9ecbf374 misc/ios: ensure deferred cleanup functions are run even on error
log.Fatal exits the process and doesn't allow deferred functions
to run. Extract log.Fatal calls to main where all deferred functions
have completed.

For the iOS builder.

Change-Id: Id1ef9955bed19944a819d6137a611d6ecbe624a6
Reviewed-on: https://go-review.googlesource.com/110955
Run-TryBot: Elias Naur <elias.naur@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-03 15:15:12 +00:00
Elias Naur
78cb5d7a68 misc/ios: retry app install
Sometimes ideviceinstaller fails to install the app. Retry a few
times before giving up.

For the iOS builder.

Change-Id: Ib066ffd4f97ae8d22c0fa9a78ea4d04f67c17410
Reviewed-on: https://go-review.googlesource.com/111055
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-03 07:45:46 +00:00
Antonin Amand
7b451dc715 archive/zip: avoid data descriptor when writing directories
Java fails to unzip archives created by archive/zip because directories are
written with the "data descriptor" flag (bit 3) set, but emits no such
descriptor. To fix this, we explicitly clear the flag.

Fixes #25215

Change-Id: Id3af4c7f863758197063df879717c1710f86c0e5
Reviewed-on: https://go-review.googlesource.com/110795
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-02 23:34:50 +00:00
Elias Naur
8cd0094b4e misc/ios: don't override TMPDIR on idevice
If TMPDIR is not set, the iOS runtime will automatically set TMPDIR
to a valid app temporary path.

For the iOS builders.

Change-Id: Ia82404059dcb10678f0a6e0c96d5efc79a5485fd
Reviewed-on: https://go-review.googlesource.com/110956
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-02 19:44:38 +00:00
Robert Griesemer
28b40f3528 go/types: add doc strings to various undocumented exported objects
Fixes #22747.

Change-Id: I498cb29f18bd9b59b13dc2ddc3a613cc12ac2a14
Reviewed-on: https://go-review.googlesource.com/110975
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2018-05-02 18:42:09 +00:00
Fangming.Fang
e8d417d272 runtime: enable memory sanitizer on arm64
Changes include:
1. open compilation option -msan for arm64
2. modify doc to explain -msan is also supported on linux/arm64
3. wrap msan lib API in msan_arm64.s
4. use libc for sigaction syscalls when cgo is enabled
5. use libc for mmap syscalls when cgo is enabled

Change-Id: I26ebe61ff7ce1906125f54a0182a720f9d58ec11
Reviewed-on: https://go-review.googlesource.com/109255
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-02 17:52:14 +00:00
Anmol Sethi
eff1e68528 testing: fix racey access to t.failed
We need to grab the mutex before we can access it.

Fixes #24438

Change-Id: Idd6130036691acec5bc5f8b40d6884f8db1d9d3c
Reviewed-on: https://go-review.googlesource.com/101283
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-02 17:51:26 +00:00
Robert Griesemer
0dcdbc772e go/types: fix internal documentation and strengthen assumptions
Imported (incl. dot-imported) objects are always in file scope,
never in package scope. Fix misleading comment.

Package-scope declared objects must have objMap entry by
construction (of that map). Remove unnecessary check and
corresponding misleading comment.

Found while investigating solutions for @23203.

Change-Id: Idadfdd1576681ae56e11daa27bdcee2c73733c41
Reviewed-on: https://go-review.googlesource.com/110916
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-05-02 17:36:17 +00:00
fanzha02
73c7378e4d cmd/asm/internal/asm: update the test cases in arm64enc.s file
Uncomment the test cases in arm64enc.s because they can be handled
by current assembler. In addition, CL supplements more test cases.

Change-Id: I583d45793b8227c6ec370868652dd8bcbfaa1ecf
Reviewed-on: https://go-review.googlesource.com/109275
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-02 17:24:56 +00:00
Wei Xiao
20102594a0 cmd/compile: intrinsify runtime.getcallerpc on all link register architectures
Add a compiler intrinsic for getcallerpc on following architectures:
  arm
  mips mipsle mips64 mips64le
  ppc64 ppc64le
  s390x

Change-Id: I758f3d4742fc214b206bcd07d90408622c17dbef
Reviewed-on: https://go-review.googlesource.com/110835
Run-TryBot: Wei Xiao <Wei.Xiao@arm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-05-02 16:59:27 +00:00
Alessandro Arzilli
836fe697c4 cmd/link: let writelines work when pcstmt symbol doesn't exist
The assembler does not produce pcstmt symbols, writeline should be able
to work even if no pcstmt symbol exists for a given function.

Fixes #25216, #25191

Change-Id: I41e16df1e7c8ca59d27e7514537609e309a51c51
Reviewed-on: https://go-review.googlesource.com/110816
Reviewed-by: David Chase <drchase@google.com>
2018-05-02 15:58:52 +00:00
Tobias Klauser
fc9c69a693 os: remove superfluous comments
It's apparent from the file names or build tags to which OS the code in
question applies.

Change-Id: I628ee2bf1d29a6bc30ca5fa6f9eecf809e78a182
Reviewed-on: https://go-review.googlesource.com/110815
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-02 14:41:57 +00:00
Alberto Donizetti
7e960d06d2 cmd/go: enable upx compression test on linux/386
We have a cmd/go test ensuring that upx (an executable
packer/compressor) works on linux/amd64 Go binaries.

The linux-386-sid builder is built from the same dockerfile as the
linux-amd64-sid builder, so upx should also already be available on
the former. Since upx support 386 executables, we can enable the upx
test for GOARCH=386.

Updates #16706

Change-Id: I94e19ff1001de83a0386754a5104a377c72fb221
Reviewed-on: https://go-review.googlesource.com/110817
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-02 14:41:32 +00:00
Martin Möhrmann
500d79c410 cmd/compile: refactor memclrrange for arrays and slices
Rename memclrrange to signify that it does not handle
all types of range clears.

Simplify checks to detect the range clear idiom for
arrays and slices.

Add tests to verify the optimization for the slice
range clear idiom is being applied by the compiler.

Change-Id: I5c3b7c9a479699ebdb4c407fde692f30f377860c
Reviewed-on: https://go-review.googlesource.com/110477
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-02 04:20:25 +00:00
Matthew Dempsky
eec8fb5ef3 cmd/compile: explicitly disallow mixing -iexport={false,true}
flagiexport currently controls not just whether to use the indexed
export format when writing out package data, but also how symbol
import logic works. In particular, it enables lazy loading logic that
currently doesn't work with packages imported via bimport.

We could change the import logic to base decisions on the export data
format used by the packages that individual symbols were loaded from,
but since we expect to deprecate and remove bimport anyway and there's
no need for mixing bimport and iimport, it's simpler to just disallow
mixing them.

Change-Id: I02dbac45062e9dd85a1a647ee46bfa0efbb67e9d
Reviewed-on: https://go-review.googlesource.com/110715
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-05-01 22:31:24 +00:00
Agniva De Sarker
c2366b27ab go/ast: hide unexported fields in composite literals
In ast/ast.go, added an Incomplete field inside CompositeLit
to denote that fields are missing.

In ast/filter.go, added a new function to go through the expression list
checking for KeyValue expressions inside composite literals.
Filter out entries with an unexported key.

In printer/nodes.go, checking if the Incomplete field is set,
and accordingly print the filtered message with proper indentation.

Copying over similar functionality in doc/exports.go so as to
maintain parity with ast/filter.go and such that godoc
can show the output correctly.

Fixes #22803

Change-Id: I57a3b999521933e32411a18e02d0b94d2ea2e6f6
Reviewed-on: https://go-review.googlesource.com/106395
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-05-01 19:53:32 +00:00
Josh Bleecher Snyder
548e1f8936 cmd/compile: recognize some OpRsh64Ux64 Values as non-negative
Proves IsSliceInBounds one additional time building std+cmd,
at encoding/hex/hex.go:187:8.

The code is:

	if numAvail := len(d.in) / 2; len(p) > numAvail {
		p = p[:numAvail]
	}

Previously we were unable to prove that numAvail >= 0.

Change-Id: Ie74e0aef809f9194c45e129ee3dae60bc3eae02f
Reviewed-on: https://go-review.googlesource.com/109415
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Giovanni Bajo <rasky@develer.com>
2018-05-01 19:38:09 +00:00
Josh Bleecher Snyder
31cfa7f2f2 runtime: allow inlining of stackmapdata
Also do very minor code cleanup.

name                old time/op  new time/op  delta
StackCopyPtr-8      84.8ms ± 6%  82.9ms ± 5%  -2.19%  (p=0.000 n=95+94)
StackCopy-8         68.4ms ± 5%  65.3ms ± 4%  -4.54%  (p=0.000 n=99+99)
StackCopyNoCache-8   107ms ± 2%   105ms ± 2%  -2.13%  (p=0.000 n=91+95)

Change-Id: I2d85ede48bffada9584d437a08a82212c0da6d00
Reviewed-on: https://go-review.googlesource.com/109001
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-05-01 19:14:17 +00:00
Eric Pauley
9d11c63b64 bytes, strings: improve EqualFold fast version for ASCII
The existing implementation only considers the special ASCII
case when the lower character is an upper case letter. This
means that most ASCII comparisons use unicode.SimpleFold even
when it is not necessary.

benchmark                old ns/op     new ns/op     delta
BenchmarkEqualFold-8     450           390           -13.33%

Change-Id: I735ca3c30fc0145c186d2a54f31fd39caab2c3fa
Reviewed-on: https://go-review.googlesource.com/110018
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-01 18:52:19 +00:00
Matthew Dempsky
a5b80d469a cmd/compile: update liveness comments
The explanation about VARDEF/VARKILL is from when liveness analysis
was performed on Progs. Now that it's performed on SSA, it should
reference their corresponding SSA ops (OpVarDef/OpVarKill) instead.

Change-Id: Icc4385b52768f6987cda162824b75340aee0b223
Reviewed-on: https://go-review.googlesource.com/76313
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-05-01 18:22:06 +00:00
Josh Bleecher Snyder
2f2e8f9c81 runtime: use staticbytes in intstring for small v
Triggers 21 times during make.bash.

Change-Id: I7efb34200439256151304bb66cd309913f7c9c9e
Reviewed-on: https://go-review.googlesource.com/110557
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-01 18:03:57 +00:00
Brad Fitzpatrick
6a8cff5730 os: fix missing break bug in earlier CL 110295's use of Uname
The Uname name was never being used because it always generated a
too-long string.

The new test looking for zero bytes wouldn't have caught it (I thought
it would've), but is still nice to have.

Updates #24701

Change-Id: I2648074452609e4ad1b9736973e1b3a95eac658d
Reviewed-on: https://go-review.googlesource.com/110436
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-01 15:55:49 +00:00
Martin Möhrmann
d46980995b internal/cpu: remove platform specific prefix from cpu hwcap variables
Go runtime currently only populates hwcap for ppc64 and arm64.
While the interpretation of hwcap is platform specific the hwcap
information is generally available on linux.

Changing the runtime variable name to cpu_hwcap for cpu.hwcap makes it
consistent with the general naming of runtime variables that are linked
to other packages.

Change-Id: I1e1f932a73ed624a219b9298faafbb6355e47ada
Reviewed-on: https://go-review.googlesource.com/94757
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-01 15:50:19 +00:00
Michael Munday
5d9c78201f cmd/compile: allow R11 to be allocated on s390x
R11 is only used as a temporary by a very small set of instructions
(DIV, MOD, MULH and extended MVC/XC instructions). By marking these
instructions as clobbering R11 we can allocate R11 in the general
case.

Change-Id: I0d4ffe80e57c164d42a5ea5ef6308756a5b0f742
Reviewed-on: https://go-review.googlesource.com/110255
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-01 15:48:17 +00:00
Martin Möhrmann
d29ec40e19 strconv: use bounded bits.TrailingZeros instead of shifts table
The strconv shifts table is 320 bytes (amd64) and is present in
many binaries since integer formatting is very common.

Instead of using a precalculated table with shift amounts
use a bounded bits.TrailingZeros to determine the shift amount
to format numbers in a base that is a power of 2.

amd64:
name        old time/op  new time/op  delta
AppendUint   379ns ± 1%   286ns ± 2%  -24.62%  (p=0.000 n=20+19)

Change-Id: Ib94d9b033321b41e975868943c7fcd9428c5111e
Reviewed-on: https://go-review.googlesource.com/110478
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-01 15:48:15 +00:00
erifan01
f8ef6ed24a internal/bytealg: optimize Index (substring lengths from 9 to 32) on arm64
The current code is not optimized for cases where the length of the
substring to be searched is between 9 bytes and 32 bytes. This CL
optimizes the situations.

Benchmark:
name                             old time/op  new time/op  delta
pkg:strings goos:linux goarch:arm64
IndexHard1-8                     1.06ms ± 0%  1.06ms ± 0%   -0.44%  (p=0.000 n=7+8)
IndexHard2-8                     1.25ms ± 1%  1.26ms ± 2%     ~     (p=0.328 n=8+8)
IndexHard3-8                     2.85ms ± 1%  1.18ms ± 1%  -58.59%  (p=0.000 n=8+8)
IndexHard4-8                     2.90ms ± 1%  2.87ms ± 1%   -0.96%  (p=0.021 n=8+8)

pkg:bytes goos:linux goarch:arm64
IndexByte/4M-8                      726124.200000ns +- 6%     560021.400000ns +-20%  -22.88%  (p=0.008 n=5+5)
IndexRune/4M-8                      928768.600000ns +- 0%     793144.600000ns +- 6%  -14.60%  (p=0.008 n=5+5)

Change-Id: Ieebeb784ae69b2a0642ea96e9486a1d120923568
Reviewed-on: https://go-review.googlesource.com/109895
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-01 15:45:54 +00:00
Martin Möhrmann
8c4170b2c9 math/bits: move tests into their own package
This makes math/bits not have any explicit imports even
when compiling tests and thereby avoids import cycles when
dependencies of testing want to import math/bits.

Change-Id: I95eccae2f5c4310e9b18124abfa85212dfbd9daa
Reviewed-on: https://go-review.googlesource.com/110479
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-01 15:33:01 +00:00