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

40005 Commits

Author SHA1 Message Date
Keith Randall
43001a0dc9 cmd/compile: use correct package name for stack object symbol
Stack object generation code was always using the local package name
for its symbol. Normally that doesn't matter, as we usually only
compile functions in the local package. But for wrappers, the compiler
generates functions which live in other packages. When there are two
other packages with identical functions to wrap, the same name appears
twice, and the compiler goes boom.

Fixes #31252

Change-Id: I7026eebabe562cb159b8b6046cf656afd336ba25
Reviewed-on: https://go-review.googlesource.com/c/go/+/171464
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-04-22 17:40:48 +00:00
Maya Rashish
d1f43ccef7 runtime: use named macros on NetBSD
It will use the full names that appear in netbsd's /usr/include/sys/syscall.h names.
This adds some compat-goo (sys_sigprocmask->SYS_sigprocmask14), which might not be pretty, but the information about whether the compat version is used is probably important, as Go will keep using interfaces even after they are considered compatibility, which has caused problems in the past.
also, the same names appear in ktrace (with the numbers).

Change-Id: Idc1bb254ee33757a39ba224d91e8fbb0331e2149
GitHub-Last-Rev: b915e8f8a3
GitHub-Pull-Request: golang/go#31594
Reviewed-on: https://go-review.googlesource.com/c/go/+/173158
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-22 17:19:23 +00:00
Austin Clements
744fcfec4e runtime: improve mstart comments
Some of the comments were unclear or outdated.

Change-Id: I02e01bf60def0074c1fa760e94aa992e9e4969b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/172987
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2019-04-22 16:01:16 +00:00
Daniel Martí
fe1afe8d4c encoding/json: avoid work when unquoting strings
We can work out how many bytes can be unquoted trivially in
rescanLiteral, which already iterates over a string's bytes.

Removing the extra loop in unquoteBytes simplifies the function and
speeds it up, especially when decoding simple strings, which are common.

While at it, we can remove unnecessary checks like len(s)<2 and
s[0]=='"'. Add a comment explaining why.

name           old time/op    new time/op    delta
CodeDecoder-8    11.2ms ± 0%    11.1ms ± 1%  -1.63%  (p=0.000 n=9+10)

name           old speed      new speed      delta
CodeDecoder-8   173MB/s ± 0%   175MB/s ± 1%  +1.66%  (p=0.000 n=9+10)

Updates #28923.

Change-Id: I2436a3a7f8148a2f7a6a4cdbd7dec6b32ef5e20c
Reviewed-on: https://go-review.googlesource.com/c/go/+/151157
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-22 15:07:38 +00:00
erifan01
d17d41e58d math/big: optimize mulAddVWW on arm64 for better performance
Unroll the cycle 4 times to reduce load overhead.

Benchmarks:
name                old time/op    new time/op    delta
MulAddVWW/1-8         15.9ns ± 0%    11.9ns ± 0%  -24.92%  (p=0.000 n=8+8)
MulAddVWW/2-8         16.1ns ± 0%    13.9ns ± 1%  -13.82%  (p=0.000 n=8+8)
MulAddVWW/3-8         18.9ns ± 0%    17.3ns ± 0%   -8.47%  (p=0.000 n=8+8)
MulAddVWW/4-8         21.7ns ± 0%    19.5ns ± 0%  -10.14%  (p=0.000 n=8+8)
MulAddVWW/5-8         25.1ns ± 0%    22.5ns ± 0%  -10.27%  (p=0.000 n=8+8)
MulAddVWW/10-8        41.6ns ± 0%    40.0ns ± 0%   -3.79%  (p=0.000 n=8+8)
MulAddVWW/100-8        368ns ± 0%     363ns ± 0%   -1.36%  (p=0.000 n=8+8)
MulAddVWW/1000-8      3.52µs ± 0%    3.52µs ± 0%   -0.14%  (p=0.000 n=8+8)
MulAddVWW/10000-8     35.1µs ± 0%    35.1µs ± 0%   -0.01%  (p=0.000 n=7+6)
MulAddVWW/100000-8     351µs ± 0%     351µs ± 0%   +0.15%  (p=0.038 n=8+8)

Change-Id: I052a4db286ac6e4f3293289c7e9a82027da0405e
Reviewed-on: https://go-review.googlesource.com/c/go/+/155780
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-04-22 14:45:16 +00:00
erifan01
f8f265b9cf cmd/compile: intrinsify math/bits.Sub64 for arm64
This CL instrinsifies Sub64 with arm64 instruction sequence NEGS, SBCS,
NGC and NEG, and optimzes the case of borrowing chains.

Benchmarks:
name              old time/op       new time/op       delta
Sub-64            2.500000ns +- 0%  2.048000ns +- 1%  -18.08%  (p=0.000 n=10+10)
Sub32-64          2.500000ns +- 0%  2.500000ns +- 0%     ~     (all equal)
Sub64-64          2.500000ns +- 0%  2.080000ns +- 0%  -16.80%  (p=0.000 n=10+7)
Sub64multiple-64  7.090000ns +- 0%  2.090000ns +- 0%  -70.52%  (p=0.000 n=10+10)

Change-Id: I3d2664e009a9635e13b55d2c4567c7b34c2c0655
Reviewed-on: https://go-review.googlesource.com/c/go/+/159018
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-22 14:40:20 +00:00
Austin Clements
db42bb3b70 runtime: error formatting fix
g.m is an muintptr, but we want to print it in hex like a pointer.

Change-Id: Ifc48ed77fb2e93cff7a49d98adc7b9679d26c3b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/172988
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-22 14:08:47 +00:00
Josh Bleecher Snyder
68d4b1265e cmd/compile: reduce bits.Div64(0, lo, y) to 64 bit division
With this change, these two functions generate identical code:

func f(x uint64) (uint64, uint64) {
	return bits.Div64(0, x, 5)
}

func g(x uint64) (uint64, uint64) {
	return x / 5, x % 5
}

Updates #31582

Change-Id: Ia96c2e67f8af5dd985823afee5f155608c04a4b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/173197
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-20 19:34:03 +00:00
Maya Rashish
d23cba683e all: add start of netbsd/arm64 support
This works well enough to run some code natively on arm64, but not well enough for more complicated code. I've been suggested to start a pull request anyway.

Updates #30824

Change-Id: Ib4f63e0e8a9edfc862cf65b5f1b0fbf9a8a1628e
GitHub-Last-Rev: b01b105e04
GitHub-Pull-Request: golang/go#29398
Reviewed-on: https://go-review.googlesource.com/c/go/+/155739
Run-TryBot: Benny Siegert <bsiegert@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2019-04-20 15:02:01 +00:00
Maya Rashish
78f0de10ec runtime: move linux specific code into linux specific files
Allows us to stop whitelisting this error on many OS/arch combinations

XXX I'm not sure I am running vet correctly, and testing all platforms right.

Change-Id: I29f548bd5f4a63bd13c4d0667d4209c75c886fd9
GitHub-Last-Rev: 52f6ff4a6b
GitHub-Pull-Request: golang/go#31583
Reviewed-on: https://go-review.googlesource.com/c/go/+/173157
Run-TryBot: Benny Siegert <bsiegert@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2019-04-20 14:20:24 +00:00
Bryan C. Mills
a1c481d851 cmd/go: only add a 'go' directive on 'go mod tidy' or when a conversion occurs
If the go.mod file exists and is empty, we initialize it from any of
various formats supported by legacy dependency-management tools.

We also initialize the 'go' directive at that point: we know that the
go.mod file is incomplete, because it does not reflect the information
in the legacy configuration file, and since we know that the go.mod
file is incomplete, we should complete it with as much information as
we have — including the version of the language currently in use.

However, if there is no legacy configuration file present, then we
cannot infer that the go.mod file is incomplete: it may correctly
specify a module without external dependencies. In that case, we
should not initialize the 'go' directive either: the user will not be
expecting unnecessary edits to the go.mod file, and we generally do
not make unnecessary-but-helpful edits unless 'go mod tidy' is invoked
explicitly.

Fixes #30790
Fixes #31100

Change-Id: I05a7872bce54a917c10d910cd9a616cab52e2730
Reviewed-on: https://go-review.googlesource.com/c/go/+/169877
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-19 21:16:38 +00:00
Matthew Dempsky
9f9e17a82f cmd/compile: fix ICE from go/defer call to variadic function
The special case logic for go/defer arguments in Escape.call was
scattered around a bit and was somewhat inconsistently handled across
different types of function calls and parameters. This CL pulls the
logic out into a separate callStmt method that's used uniformly for
all kinds of function calls and arguments.

Fixes #31573.

Change-Id: Icdcdf611754dc3fcf1af7cb52879fb4b73a7a31f
Reviewed-on: https://go-review.googlesource.com/c/go/+/173019
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-04-19 20:45:14 +00:00
David Chase
376ce8c880 cmd/compile: shortcut intrinsic inlining AFTER getcallerXX check
A check in inl.go to prevent inlining of functions calling
either getcallerpc or getcallersp does not work when these
functions are intrinsics. Swap checks to fix.

Includes test.

No bug, this was discovered in the course of a ridiculous
experiment with inlining.

Change-Id: Ie1392523bb89882d586678f2674e1a4eadc5e431
Reviewed-on: https://go-review.googlesource.com/c/go/+/172217
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-04-19 20:18:29 +00:00
Than McIntosh
dc193dee15 go/internal/gccgoimporter: improve alias handling for anonymous fields
The code in the parser that deals with anonymous structure fields
records the fact that a field is anonymous, then tries to install a proxy
name for the field based on the name of the type used to declare
the field. If that type was an alias, the current recipe for determining
the proxy name was not working properly; enhance the code to recover
and report the alias name used.

Fixes #31540.

Change-Id: I9b7369ed558a288b56d85170c6f1144daf5228eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/172603
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-19 19:47:53 +00:00
Than McIntosh
4590abe072 cmd/link: adjust whitelist for -strictdups checking for plan9
Add a couple of additional entries to the white list used to screen
out errors for builtin functions; these correspond to cases
that appear to come up only on the plan9 builder.

Updates #31503.

Change-Id: I48ab942ab2894240efe651ec7b7eace7aa5cb45e
Reviewed-on: https://go-review.googlesource.com/c/go/+/172986
Reviewed-by: David du Colombier <0intro@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-19 19:47:04 +00:00
Yuval Pavel Zholkover
059f2d4a46 os: disable the use of netpoll on directories as well on *BSDs
Follow up CL 156379.

Updates #19093

Change-Id: I5ea3177fc5911d3af71cbb32584249e419e9d4a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/172937
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-19 19:24:47 +00:00
Bryan C. Mills
14b5b4a2a1 cmd/go/internal/modload: fix boundary conditions in matchPackages
This makes the boundary logic of matchPackages consistent with
modload.dirInModule.

Previously, matchPackages always stopped at go.mod file, even within
the vendor tree. However, we do not guarantee that the vendor tree is
free of such files in general.

matchPackages also issued needless stat operations for modules in the
module cach, which we already know to be free of nested modules. On
systems with slow filesystems (such as macOS), those extra calls could
potentially slow package matching considerably.

Change-Id: I71979ab752e1d3971b370b37085d30502690413b
Reviewed-on: https://go-review.googlesource.com/c/go/+/172985
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-04-19 18:37:41 +00:00
Cherry Zhang
dbe32284ff cmd/link: mmap object data
This resurrects CL 121198, except that this time we map read-only.

In case that we need to apply relocations to the symbol's
content that is backed by read-only memory, we do our own copy-
on-write. This can happen if we failed to mmap the output file,
or we build for Wasm.

Memory profile for building k8s.io/kubernetes/cmd/kube-apiserver
on Linux/AMD64:

Old (before this sequence of CLs):
inuse_space 1598.75MB total
669.87MB 41.90% 41.90%   669.87MB 41.90%  cmd/link/internal/objfile.(*objReader).readSlices

New:
inuse_space 1280.45MB total
441.18MB 34.46% 34.46%   441.18MB 34.46%  cmd/link/internal/objfile.(*objReader).readSlices

Change-Id: I6b4d29d6eee9828089ea3120eb38c212db21330b
Reviewed-on: https://go-review.googlesource.com/c/go/+/170741
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-19 18:25:56 +00:00
Cherry Zhang
f957a7e357 cmd/link: apply relocations later
Move the phase of applying relocations later, after the sections
and segments are written to the mmap'd output region. Then apply
relocations directly in the output region, instead of the input.
So the input slices we read in don't need to be modified.

This is in preparation for mmap'ing input files read-only.

Change-Id: If9c80657b4469da36aec5a9ab6acf664f5af8fa0
Reviewed-on: https://go-review.googlesource.com/c/go/+/170739
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2019-04-19 18:25:33 +00:00
Cherry Zhang
248444d5eb cmd/link: apply DWARF relocations while doing compression
We are preparing for applying relocations to the output buffer.
However, for DWARF compression, relocations need to be applied
before compression, but we don't have an output buffer at that
time. We also cannot delay DWARF compression to when we mmap the
output file, because we need the size of the DWARF sections to
compute the file size.

Instead of applying all the relocations together, we apply
relocations in DWARF sections one symbol at a time, right before
it is writing out for compression. As the symbol content may be
in read-only memory (in the future), we use a temporary buffer
for applying the relocations, and immediately write it out.

If compression is not used, relocations are still applied all
together.

This is in preparation for mmap'ing input files read-only.

Change-Id: Iae6d2dd71313897d5054bcc458d3bb78075b30c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/171397
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2019-04-19 18:25:20 +00:00
Cherry Zhang
15a31bd9c8 cmd/link: apply R_DWARFFILEREF later
Apply R_DWARFFILEREF relocations later, along with other
relocations, so that we don't modify symbols' contents before
they are written to the output buffer.

This is in preparation for mmap'ing input files read-only.

Change-Id: I8e9ffb2f05acf8f198589b8770f277beb3847541
Reviewed-on: https://go-review.googlesource.com/c/go/+/170740
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2019-04-19 18:25:09 +00:00
Cherry Zhang
b2f94d3e88 cmd/link: mmap output file
Use mmap for writing most of the output file content,
specifically, the sections and segments. After layout, we
already know the sizes and file offsets for the sections and
segments. So we can just write the bytes by copying to a mmap'd
backing store.

The writing of the output file is split into two parts. The first
part writes the sections and segments to the mmap'd region. The
second part writes some extra content, for which we don't know
the size, so we use direct file IO.

This is in preparation for mmap'ing input files read-only.

Change-Id: I9f3b4616a9f96bfd5c940d74c50aacd6d330f7d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/170738
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2019-04-19 18:24:44 +00:00
Bryan C. Mills
47150aafbf cmd/go/internal/modfetch: comment on known bug in isVendoredPackage
Fixes #31562

Change-Id: Ida30dd8071eccb6b490ab89a1de087038fe26796
Reviewed-on: https://go-review.googlesource.com/c/go/+/172977
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-04-19 18:08:17 +00:00
Brad Fitzpatrick
64e29f94e2 internal/goversion: add new package, move Go 1.x constant there out of go/build
Found by Josh, who says in the bug that it shrinks cmd/compile by 1.6 MB (6.5%).

Fixes #31563

Change-Id: I35127af539630e628a0a4f2273af519093536c38
Reviewed-on: https://go-review.googlesource.com/c/go/+/172997
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2019-04-19 18:04:35 +00:00
Cherry Zhang
97252f620f runtime: suppress thread event prints in gdb test
Pass "set print thread-events off" to gdb to suppress thread
event prints, like "[New Thread 0xe7b83b40 (LWP 18609)]". We
don't check them, and the extra output may confuse our other
checks, in particular, checkCleanBacktrace.

Hopefully fixes #31569.

Change-Id: I6549e1280da7afa1d2e38da2b2fa7cc18c2f0373
Reviewed-on: https://go-review.googlesource.com/c/go/+/172980
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-19 17:12:13 +00:00
Ian Lance Taylor
4a11914130 bootstrap.bash: make source writable before cleaning
Otherwise the "git clean" command fails with errors like
    rm: cannot remove '/home/iant/go-linux-ppc64-bootstrap/pkg/mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/simplifiedchinese/all.go': Permission denied

Change-Id: Iecfb1fed6d59819d7fdceb9e391a2b3f81ea620c
Reviewed-on: https://go-review.googlesource.com/c/go/+/172998
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-19 17:04:30 +00:00
Ian Lance Taylor
4c236b9b09 cmd/link: require cgo support for TestSectionsWithSameName
The test doesn't really require cgo, but it does require that we know
the right flags to use to run the C compiler, and that is not
necessarily correct if we don't support cgo.

Fixes #31565

Change-Id: I04dc8db26697caa470e91ad712376aa621cf765d
Reviewed-on: https://go-review.googlesource.com/c/go/+/172981
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-19 17:03:55 +00:00
Kai Dong
5ccaf2c6ad sync: update comment
Comment update.

Change-Id: If0d054216f9953f42df04647b85c38008b85b026
GitHub-Last-Rev: 133b4670be
GitHub-Pull-Request: golang/go#31539
Reviewed-on: https://go-review.googlesource.com/c/go/+/172700
Reviewed-by: Austin Clements <austin@google.com>
2019-04-19 16:15:36 +00:00
Josh Bleecher Snyder
4aeac68c92 runtime, cmd/compile: re-order PCDATA and FUNCDATA indices
The pclntab encoding supports writing only some PCDATA and FUNCDATA values.
However, the encoding is dense: The max index in use determines the space used.
We should thus choose a numbering in which frequently used indices are smaller.

This change re-orders the PCDATA and FUNCDATA indices using that principle,
using a quick and dirty instrumentation to measure index frequency.

It shrinks binaries by about 0.5%.

Updates #6853

file      before    after     Δ       %       
go        14745044  14671316  -73728  -0.500% 
addr2line 4305128   4280552   -24576  -0.571% 
api       6095800   6058936   -36864  -0.605% 
asm       4930928   4906352   -24576  -0.498% 
buildid   2881520   2861040   -20480  -0.711% 
cgo       4896584   4867912   -28672  -0.586% 
compile   25868408  25770104  -98304  -0.380% 
cover     5319656   5286888   -32768  -0.616% 
dist      3654528   3634048   -20480  -0.560% 
doc       4719672   4691000   -28672  -0.607% 
fix       3418312   3393736   -24576  -0.719% 
link      6137952   6109280   -28672  -0.467% 
nm        4250536   4225960   -24576  -0.578% 
objdump   4665192   4636520   -28672  -0.615% 
pack      2297488   2285200   -12288  -0.535% 
pprof     14735332  14657508  -77824  -0.528% 
test2json 2834952   2818568   -16384  -0.578% 
trace     11679964  11618524  -61440  -0.526% 
vet       8452696   8403544   -49152  -0.581% 

Change-Id: I30665dce57ec7a52e7d3c6718560b3aa5b83dd0b
Reviewed-on: https://go-review.googlesource.com/c/go/+/171760
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2019-04-19 15:40:42 +00:00
Josh Bleecher Snyder
c1544ff906 cmd/compile: move phi tighten after critical
The phi tighten pass moves rematerializable phi args
to the immediate predecessor of the phis.
This reduces value lifetimes for regalloc.

However, the critical edge removal pass can introduce
new blocks, which can change what a block's
immediate precedessor is. This can result in tightened
phi args being spilled unnecessarily.

This change moves the phi tighten pass after the
critical edge pass, when the block structure is stable.

This improves the code generated for

func f(s string) bool { return s == "abcde" }

Before this change:

"".f STEXT nosplit size=44 args=0x18 locals=0x0
	0x0000 00000 (x.go:3)	MOVQ	"".s+16(SP), AX
	0x0005 00005 (x.go:3)	CMPQ	AX, $5
	0x0009 00009 (x.go:3)	JNE	40
	0x000b 00011 (x.go:3)	MOVQ	"".s+8(SP), AX
	0x0010 00016 (x.go:3)	CMPL	(AX), $1684234849
	0x0016 00022 (x.go:3)	JNE	36
	0x0018 00024 (x.go:3)	CMPB	4(AX), $101
	0x001c 00028 (x.go:3)	SETEQ	AL
	0x001f 00031 (x.go:3)	MOVB	AL, "".~r1+24(SP)
	0x0023 00035 (x.go:3)	RET
	0x0024 00036 (x.go:3)	XORL	AX, AX
	0x0026 00038 (x.go:3)	JMP	31
	0x0028 00040 (x.go:3)	XORL	AX, AX
	0x002a 00042 (x.go:3)	JMP	31

Observe the duplicated blocks at the end.
After this change:

"".f STEXT nosplit size=40 args=0x18 locals=0x0
	0x0000 00000 (x.go:3)	MOVQ	"".s+16(SP), AX
	0x0005 00005 (x.go:3)	CMPQ	AX, $5
	0x0009 00009 (x.go:3)	JNE	36
	0x000b 00011 (x.go:3)	MOVQ	"".s+8(SP), AX
	0x0010 00016 (x.go:3)	CMPL	(AX), $1684234849
	0x0016 00022 (x.go:3)	JNE	36
	0x0018 00024 (x.go:3)	CMPB	4(AX), $101
	0x001c 00028 (x.go:3)	SETEQ	AL
	0x001f 00031 (x.go:3)	MOVB	AL, "".~r1+24(SP)
	0x0023 00035 (x.go:3)	RET
	0x0024 00036 (x.go:3)	XORL	AX, AX
	0x0026 00038 (x.go:3)	JMP	31

Change-Id: I12c81aa53b89456cb5809aa5396378245f3beda9
Reviewed-on: https://go-review.googlesource.com/c/go/+/172597
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-04-19 15:39:53 +00:00
Bryan C. Mills
d68ac59113 {,cmd/}vendor: rerun 'go mod vendor' to prune ignored files
Updates #31088

Change-Id: Ia126e4e83ac5cb12c2c4151d5e5c975497598f24
Reviewed-on: https://go-review.googlesource.com/c/go/+/172979
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-19 15:36:19 +00:00
Bryan C. Mills
7f1612652b cmd/go/internal/modcmd: skip files with the "ignore" constraint in 'go mod vendor'
'go mod vendor' already drops test files and testdata directories, so
users should not expect the vendored module to include unnecessary
files in general.

Files tagged "ignore" are typically only used to refresh or regenerate
source files within the module to be vendored, so users of that module
do not need them.

Fixes #31088

Change-Id: I1ce9545e9b37c8e779a1826a9d494ac29d2cbfb8
Reviewed-on: https://go-review.googlesource.com/c/go/+/172978
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-19 15:36:02 +00:00
LE Manh Cuong
bdd7bb5526 cmd/compile: remove unused func nodfltconst
Its only usage was removed in golang.org/cl/103860

Change-Id: I2a230b9475b0aadf3892b89f5e4ee6d4c5b70394
Reviewed-on: https://go-review.googlesource.com/c/go/+/172917
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-19 12:32:46 +00:00
Brad Fitzpatrick
c8aaec2f70 runtime/trace: also treat plan9 as a low memory system
Fixes #31554
Updates #12032 (also originally about plan9, but later openbsd/arm)

Change-Id: Ib9f35d27a2304f38bf271c38c0b9153d210d8f95
Reviewed-on: https://go-review.googlesource.com/c/go/+/172837
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-18 21:49:02 +00:00
Rob Pike
02bd0fd39c testing/quick: simplify explanation of -quickchecks flag
CL 172698 documented this flag but the description was missing
punctuation and could be clearer.

Change-Id: I310d91ae8c6b947ce7d1ae7559882f49778f770a
Reviewed-on: https://go-review.googlesource.com/c/go/+/172817
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-18 21:21:21 +00:00
jfbus
825ff1e317 net: use DNS over TCP when use-vc is set in resolv.conf
There is a DNS resolution bug in Kubernetes (UDP response packets get dropped by conntrack, causing timeouts in DNS queries).

The recommended workaround on Linux is to configure the resolver to use TCP for DNS queries, by setting the use-vc option in resolv.conf.

With this PR, the pure Go resolver searches for "use-vc" in resolv.conf and switches to TCP when found.

Fixes #29358

Change-Id: I26b935cae2c80e5bb9955da83299a8dea84591de
GitHub-Last-Rev: 70bc00fe41
GitHub-Pull-Request: golang/go#29594
Reviewed-on: https://go-review.googlesource.com/c/go/+/156366
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-18 18:51:13 +00:00
Andrew Z Allen
e900964e0f testing/quick: clarify that Config.MaxCount is from a flag
Document that the default quickcheck configuration is to run 100 times
and that there is a flag that configures it called "quickchecks".

Change-Id: I46fdab9d572e132ccc23ef907f9cc6b2d06b37c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/172698
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-18 18:18:04 +00:00
Josh Bleecher Snyder
24a6478be3 cmd/compile: use named fields in newnamel
CL 172579 added field names in nodl. See that CL for an explanation.
Cuong Manh Le pointed out that we should do the same in newnamel.

This cuts 40k off the cmd/compile binary.

Change-Id: I427b117531c59630dee36f1257aad8975626b2c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/172604
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-18 17:27:12 +00:00
Rens Rikkerink
3e2ceaf4de cmd/go: mod init outside of GOPATH silently fails
Running `go mod init` outside of GOPATH with `GO111MODULE=off`
silently fails. This behavior was undocumented.

This CL makes go mod fail with the error:

   go: modules disabled by GO111MODULE=off; see 'go help modules'
Comparing with already erroring GO111MODULE=<value> conditions:

* With GO111MODULE=auto, inside GOPATH:
    go modules disabled inside GOPATH/src by GO111MODULE=auto; see 'go help modules'
* With GO111MODULE=auto outside of GOPATH:
    go: cannot determine module path for source directory /path/to/dir (outside GOPATH, no import comments)

Fixes #31342

Change-Id: I749787d2a8640913c4ac263072d051314d76e778
GitHub-Last-Rev: b38447457d
GitHub-Pull-Request: golang/go#31255
Reviewed-on: https://go-review.googlesource.com/c/go/+/170697
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-18 17:23:47 +00:00
Ian Lance Taylor
3235f7c072 cmd/link: don't fail if multiple ELF sections have the same name
New versions of clang can generate multiple sections named ".text"
when using vague C++ linkage. This is valid ELF, but would cause the
Go linker to report an error when using internal linking:
    symbol PACKAGEPATH(.text) listed multiple times
Avoid the problem by renaming section symbol names if there is a name
collision.

Change-Id: I41127e95003d5b4554aaf849177b3fe000382c02
Reviewed-on: https://go-review.googlesource.com/c/go/+/172697
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-04-18 15:07:12 +00:00
Rob Pike
c226f6432d strconv: pre-allocate in appendQuotedWith
The byte-at-a-time allocation done quoting strings in appendQuotedWith
grows the output incrementally, which is poor behavior for very large
strings. An easy fix is to make sure the buffer has enough room at
least for an unquoted string.

Add a benchmark with a megabyte of non-ASCII data.
	Before: 39 allocations.
	After: 7 allocations.

We could do better by doing a lot more work but this seems like a big
result for little effort.

Fixes #31472.

Change-Id: I852139e0a2bd13722c4dd329ded8ae1759abad5b
Reviewed-on: https://go-review.googlesource.com/c/go/+/172677
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-18 04:30:46 +00:00
Clément Chigot
cbaa8e5f93 runtime: move libcall to stack for runtime syscalls on AIX
As the stackguard was increased on AIX by CL 157117, every syscalls can
now have libcall directly on the stack. This fixes some concurrency bugs
which seems to occur when semasleep is interrupted by a SIGPROF signal.

Change-Id: I905a9618d13ef227dad6f8328b0f958f2f917a5b
Reviewed-on: https://go-review.googlesource.com/c/go/+/172359
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-18 00:07:22 +00:00
erifan01
4312a18b8a runtime/cgo: declare variable setg_gcc as static
variable setg_gcc in runtime/cgo/*.c should be static, otherwise it
will be mixed with the function of the same name in runtime/asm_*.s or
tls_*.s, which causes an error when building PIE with internal linking
mode.

Fixes #31485

Change-Id: I79b311ffcaf450984328db65397840ae7d85e65d
Reviewed-on: https://go-review.googlesource.com/c/go/+/172498
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-18 00:06:12 +00:00
erifan01
3b37ff453e cmd/link: increase the reserved space for ELF relocations
Currently the offset values of ELF relocations and Macho relocations
are 256 and 512 respectively, which means that the space reserved for
ELF relocations is only 256. But AARCH64 has more than 256 ELF relocation
types, in fact the maximum AARCH64 ELF relocation type recorded in file
src/debug/elf/elf.go is 1032 currently. So this CL increases the offset
of Macho relocations to 2048 to leave enough space for AARCH64 ELF
relocations.

Change-Id: I784ac38aeb3e102ac7825f6d621086849c8d3146
Reviewed-on: https://go-review.googlesource.com/c/go/+/172497
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-17 23:31:28 +00:00
Matthew Dempsky
b5946ed48d test: fix escape_runtime_atomic.go
Casp1 is implemented in Go on js/wasm, so escape analysis correctly
determines that the "old" parameter does not escape (which is good).

Unfortunately, test/run.go doesn't have a way to indicate that ERROR
messages are optional, and cmd/compile only emits diagnostics for "var
x int" when it's moved to the heap; not when it stays on the stack.

To accomodate that this test currently passes on some GOARCHes but not
others, rewrite the Casp1 test to use "x := new(int)" and allow both
"new(int) escapes to heap" or "new(int) does not escape".

Updates #31525.

Change-Id: I40150a7ff9042f184386ccdb2d4d428f63e8ba4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/172602
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-17 22:55:26 +00:00
Josh Bleecher Snyder
e92853523d cmd/compile: use named fields in nodl
We use a struct to allocate two structs simultaneously.
Because we embed structs rather than using named fields,
the compiler generates forwarding method stubs for the
anonymous type.

In theory, the compiler could detect that these stubs are unnecessary:
The value in question has a very limited scope, the methods are not
called, and there are operations where an interface would need
to be satisfied.

This compiler optimization is unlikely to happen, though;
the ROI is likely to be low.

Instead, just give the fields names. Cuts 64k off the cmd/compile binary.

Change-Id: Id10ec69c23cd2dd33306f4c1bc75724e3c571b56
Reviewed-on: https://go-review.googlesource.com/c/go/+/172579
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-17 20:52:24 +00:00
Matthew Dempsky
9dce58d30d runtime/internal/atomic: remove bad go:noescape annotations on Loadp
The //go:noescape directive says that arguments don't leak at all,
which is too aggressive of a claim for functions that return pointers
derived from their parameters.

Remove the directive for now. Long term fix will require a new
directive that allows more fine-grained control over escape analysis
information supplied for functions implemented in assembly.

Also, update the BAD comments in the test cases for Loadp: we really
want that *ptr leaks to the result parameter, not that *ptr leaks to
the heap.

Updates #31525.

Change-Id: Ibfa61f2b70daa7ed3223056b57eeee777eef2e31
Reviewed-on: https://go-review.googlesource.com/c/go/+/172578
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2019-04-17 19:09:15 +00:00
Baokun Lee
e5986209e0 cmd/go: Remove old mod helper prints in Go 1.12.
Change-Id: I43d233739ce6a6fbc4ee281b569d6230dd552cb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/160057
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-17 17:58:26 +00:00
Michael Fraenkel
f85d0e32e5 test: add escape regress for empty variadic function
Fixes #30898

Change-Id: I903dd8ed2b10c49b2291ad0858774f3ca2f5b223
Reviewed-on: https://go-review.googlesource.com/c/go/+/172422
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-17 17:05:53 +00:00
Matthew Dempsky
ff3ae455d9 test: add regress test cases for self-assignment
Cherry pointed out this case in review for CL 136496. That CL was
slightly too aggressive, and I likely would have made the same mistake
if I tried it myself.

Updates #27772.

Change-Id: I1fafabb9f8d9aba0494aa71333a4e17cf1bac5c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/172421
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-04-17 16:36:56 +00:00