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

23533 Commits

Author SHA1 Message Date
Brad Fitzpatrick
4e8c113793 log/syslog: document that Dial uses net.Dial parameters, add example
Fixes #16761

Change-Id: I709daa87926a31e5f8fd46a4c5ef69718ae349b1
Reviewed-on: https://go-review.googlesource.com/27209
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2016-08-19 01:01:47 +00:00
Brad Fitzpatrick
55ea153b78 os: reference LookupEnv from the Getenv docs
Fixes #16782

Change-Id: If54917bf5ca1588d8a6d443c3aa6e1d4ada6b620
Reviewed-on: https://go-review.googlesource.com/27322
Reviewed-by: anatoly techtonik <techtonik@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-08-19 00:30:37 +00:00
Josh Bleecher Snyder
794442375d cmd/vet: allow large shifts of constants
Large shifts of constants are frequently
used for fancy 32/64 bit detection.

This removes 14 false positives from the
standard library.

Updates #11041

Change-Id: Ib39346e5c161da04c38a6a3067932ef43bf74f2d
Reviewed-on: https://go-review.googlesource.com/27155
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-18 23:39:37 +00:00
Adam Langley
4e79c152b1 crypto/tls: don't generate random ticket keys if already set.
If SetSessionTicketKeys was called on a fresh tls.Config, the configured
keys would be overridden with a random key by serverInit.

Fixes #15421.

Change-Id: I5d6cc81fc3e5de4dfa15eb614d102fb886150d1b
Reviewed-on: https://go-review.googlesource.com/27317
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-18 22:48:53 +00:00
Robert Griesemer
89d085de9f go/types: better doc string for Object.Parent and test
Fixes #14647.

Change-Id: Ib9012a9141e815f5b95f8ca2307e65ffc4587a5b
Reviewed-on: https://go-review.googlesource.com/27370
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-18 22:47:45 +00:00
Adam Langley
da2a938910 crypto/tls: fix comment typo.
This was pointed out in https://go-review.googlesource.com/#/c/27315/1
but I changed and uploaded the wrong branch. This actually makes the
fix.

Change-Id: Ib615b06c9141b914648b6abbeeb688c5ffa0d2e3
Reviewed-on: https://go-review.googlesource.com/27360
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-18 21:52:31 +00:00
Adam Langley
8741504888 crypto/tls: support AES-128-CBC cipher suites with SHA-256.
These were new with TLS 1.2 and, reportedly, some servers require it.
Since it's easy, this change adds suport for three flavours of
AES-128-CBC with SHA-256 MACs.

Other testdata/ files have to be updated because this changes the list
of cipher suites offered by default by the client.

Fixes #15487.

Change-Id: I1b14330c31eeda20185409a37072343552c3464f
Reviewed-on: https://go-review.googlesource.com/27315
Run-TryBot: Adam Langley <agl@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Jonathan Rudenberg <jonathan@titanous.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-18 21:46:46 +00:00
Matthew Dempsky
36f61ed7ed cmd/dist: build cmd/compile/internal/syntax
Change-Id: Ie6dd2318e031be445c0b1ae65d4c78723d5a1167
Reviewed-on: https://go-review.googlesource.com/27197
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-18 21:33:53 +00:00
Robert Griesemer
c8683ff797 cmd/compile/internal/syntax: fast Go syntax trees, initial commit.
Syntax tree nodes, scanner, parser, basic printers.

Builds syntax trees for entire Go std lib at a rate of ~1.8M lines/s
in warmed up state (MacMini, 2.3 GHz Intel Core i7, 8GB RAM):

$ go test -run StdLib -fast
parsed 1074617 lines (2832 files) in 579.66364ms (1853863 lines/s)
allocated 282.212Mb (486.854Mb/s)
PASS

Change-Id: Ie26d9a7bf4e5ff07457aedfcc9b89f0eba72ae3f
Reviewed-on: https://go-review.googlesource.com/27195
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-18 21:33:38 +00:00
Robert Griesemer
fd8028dec9 go/types: fix scope extents for range and type switch variables
The changes match the existing compilers, and assume an adjusted
spec (per issue #16794).

Fixes #15686.

Change-Id: I72677ce75888c41a8f3c2963117a2f2d5501c42b
Reviewed-on: https://go-review.googlesource.com/27290
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-18 20:07:05 +00:00
Josh Bleecher Snyder
604efe1281 runtime: disable TestCgoCallbackGC on FreeBSD
The trybot flakes are a nuisance.

Updates #16396

Change-Id: I8202adb554391676ba82bca44d784c6a81bf2085
Reviewed-on: https://go-review.googlesource.com/27313
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-18 17:13:39 +00:00
Robert Griesemer
021f243213 go/types: set Info.Types.Type for array composite literals of the form [...]T
Fixes #14092.

Change-Id: I00692f60a416348e38cab256b94fda07e334d258
Reviewed-on: https://go-review.googlesource.com/27316
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-18 17:11:03 +00:00
Josh Bleecher Snyder
29df4c8f00 unsafe: document use of &^ to round/align pointers
Follow-up to CL 27156

Change-Id: I4f1cfced2dced9c9fc8a05bbc00ec4229e85c5c9
Reviewed-on: https://go-review.googlesource.com/27314
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-08-18 16:45:17 +00:00
Cherry Zhang
a7277e5494 cmd/compile: compare size in dead store elimination
Only remove stores that is shadowed by another store with same or
larger size. Normally we don't need this check because we did check
the types, but unsafe pointer casting can get around it.

Fixes #16769.

Change-Id: I3f7c6c57807b590a2f735007dec6c65a4fa01a34
Reviewed-on: https://go-review.googlesource.com/27320
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-18 16:38:56 +00:00
David Chase
5b9ff11c3d cmd/compile: ppc64le working, not optimized enough
This time with the cherry-pick from the proper patch of
the old CL.

Stack size increased.
Corrected NaN-comparison glitches.
Marked g register as clobbered by calls.
Fixed shared libraries.

live_ssa.go still disabled because of differences.
Presumably turning on more optimization will fix
both the stack size and the live_ssa.go glitches.

Enhanced debugging output for shared libs test.

Rebased onto master.

Updates #16010.

Change-Id: I40864faf1ef32c118fb141b7ef8e854498e6b2c4
Reviewed-on: https://go-review.googlesource.com/27159
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-08-18 16:34:47 +00:00
Brad Fitzpatrick
dea6dab40c cmd/yacc: remove go tool yacc
It is no longer used by Go.

It's now moved to golang.org/x/tools/cmd/goyacc for anybody who needs it.

Fixes #11229

Change-Id: Ia431d5a380c7ff784a2050dee2f5bc8acee015da
Reviewed-on: https://go-review.googlesource.com/27325
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-18 16:15:23 +00:00
Michael Matloob
795ad07b3b cmd: generate DWARF for functions in compile instead of link.
This is a copy of golang.org/cl/22092 by Ryan Brown.

Here's his original comment:
On my machine this increases the average time for 'go build cmd/go' from
2.25s to 2.36s. I tried to measure compile and link separately but saw
no significant change.

Change-Id: If0d2b756d52a0d30d4eda526929c82794d89dd7b
Reviewed-on: https://go-review.googlesource.com/25311
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-08-18 15:06:27 +00:00
Josh Bleecher Snyder
11e93aa24a cmd/vet: allow any printf verb with any interface
fmt treats interfaces as being transparent.
As a result, we cannot say with confidence
that any particular verb is wrong.

This fixes the following vet false positives
in the standard library:

database/sql/sql_test.go:210: arg dep for printf verb %p of wrong type: sql.finalCloser
fmt/fmt_test.go:1663: arg nil for printf verb %s of wrong type: untyped nil
go/ast/commentmap.go:328: arg node for printf verb %p of wrong type: ast.Node
net/http/transport_test.go:120: arg c for printf verb %p of wrong type: net.Conn
net/http/httptest/server.go:198: arg c for printf verb %p of wrong type: net.Conn
net/http/httputil/dump_test.go:258: arg body for printf verb %p of wrong type: io.Reader
reflect/set_test.go:81: arg x for printf verb %p of wrong type: io.Writer
reflect/set_test.go:141: arg bb for printf verb %p of wrong type: io.Reader

Updates #11041
Updates #16314

Change-Id: I76df01abb3c34a97b6960f551bed9c1c91377cfc
Reviewed-on: https://go-review.googlesource.com/27127
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-18 02:01:25 +00:00
Alex Brainman
0ece9c4b59 debug/pe: revert CL 22720
CL 22720 hid all recently added functionality for go1.7.
Make everything exported again, so we could use it now.

Updates #15345

Change-Id: Id8ccba7199422b554407ec14c343d2c28fbb8f72
Reviewed-on: https://go-review.googlesource.com/27212
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-08-18 01:19:29 +00:00
Adam Langley
e41b0e2bcb crypto/x509: support PSS signatures.
Although the term “RSA” is almost synonymous with PKCS#1 v1.5, that
standard is quite flawed, cryptographically speaking. Bellare and
Rogaway fixed PKCS#1 v1.5 with OAEP (for encryption) and PSS (for
signatures) but they only see a fraction of the use of v1.5.

This change adds support for creating and verifying X.509 certificates
that use PSS signatures. Sadly, every possible dimension of flexibility
seems to have been reflected in the integration of X.509 and PSS
resulting in a huge amount of excess complexity. This change only
supports one “sane” configuration for each of SHA-{256, 384, 512}.
Hopefully this is sufficient because it saves a lot of complexity in the
code.

Although X.509 certificates with PSS signatures are rare, I'm inclined
to look favourably on them because they are sufficiently superior.

Fixes #15958.

Change-Id: I7282e0b68ad0177209f8b2add473b94aa5224c07
Reviewed-on: https://go-review.googlesource.com/24743
Run-TryBot: Adam Langley <agl@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-18 00:40:17 +00:00
Adam Langley
59aeac20c0 crypto/x509: require a NULL parameters for RSA public keys.
The RFC is clear that the Parameters in an AlgorithmIdentifer for an RSA
public key must be NULL. BoringSSL enforces this so we have strong
evidence that this is a widely compatible change.

Embarrassingly enough, the major source of violations of this is us. Go
used to get this correct in only one of two places. This was only fixed
in 2013 (with 4874bc9b). That's why lots of test certificates are
updated in this change.

Fixes #16166.

Change-Id: Ib9a4551349354c66e730d44eb8cee4ec402ea8ab
Reviewed-on: https://go-review.googlesource.com/27312
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-17 23:47:18 +00:00
Alberto Donizetti
57370a87d8 encoding/hex: change lookup table from string to array
name            old time/op  new time/op  delta
Encode/256-4     431ns ± 2%   391ns ± 2%   -9.36%  (p=0.000 n=8+8)
Encode/1024-4   1.68µs ± 0%  1.51µs ± 0%   -9.91%  (p=0.001 n=7+7)
Encode/4096-4   6.68µs ± 0%  6.03µs ± 1%   -9.69%  (p=0.000 n=8+8)
Encode/16384-4  27.0µs ± 1%  24.0µs ± 0%  -11.03%  (p=0.000 n=8+7)

Change-Id: I6994e02f77797349c4e188377d84f97dffe98399
Reviewed-on: https://go-review.googlesource.com/27254
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-17 23:35:32 +00:00
Robert Griesemer
17eee31020 go/types: enable disabled test for comma-ok expressions
This was fixed long ago but the test was not enabled.

For #8189.

Change-Id: Ia44ef752b6bf076f3e243d2d0db326a392a20193
Reviewed-on: https://go-review.googlesource.com/27310
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-17 23:28:20 +00:00
Adam Langley
69371671c7 crypto/hmac: don't test for length equality in Equal.
subtle.ConstantTimeCompare now tests the length of the inputs (although
it didn't when this code was written) so this test in crypto/hmac is now
superfluous.

Fixes #16336.

Change-Id: Ic02d8537e776fa1dd5694d3af07a28c4d840d14b
Reviewed-on: https://go-review.googlesource.com/27239
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-17 23:23:28 +00:00
Adam Langley
b23b9a762c crypto/x509: return error for missing SerialNumber.
If the SerialNumber is nil in the template then the resulting panic is
rather deep in encoding/asn1 and it's not obvious what went wrong.

This change tests and returns a more helpful error in this case.

Fixes #16603.

Change-Id: Ib30d652555191eb78f705dff8d909e4b5808f9ca
Reviewed-on: https://go-review.googlesource.com/27238
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-17 23:23:18 +00:00
Jaana Burcu Dogan
c2322b7ea6 runtime: fix the absolute URL to pprof tools
Change-Id: I82eaf5c14a5b8b9ec088409f946adf7b5fd5dbe3
Reviewed-on: https://go-review.googlesource.com/27311
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-17 23:22:53 +00:00
Jess Frazelle
c3f05d9593 text/template: remove unused Tree.parse return value
Fixes #13993

Change-Id: Ic61b2bcd9f4f71457d3a8581574633d505d5750e
Reviewed-on: https://go-review.googlesource.com/27240
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-17 22:36:27 +00:00
Robert Griesemer
d1272a8b5c go/types: better error message for invalid fallthrough case
Now matches the gc compiler.

Fixes #15594.

Change-Id: I9f3942367bc0acf883c6216b8ca44820832f5fe3
Reviewed-on: https://go-review.googlesource.com/27241
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-17 21:23:39 +00:00
Radu Berinde
0c819b654f hash/crc32: improve the processing of the last bytes in the SSE4.2 code for AMD64
This commit improves the processing of the final few bytes in
castagnoliSSE42: instead of processing one byte at a time, we use all
versions of the CRC32 instruction to process 4 bytes, then 2, then 1.
The difference is only noticeable for small "odd" sized buffers.

We do the similar improvement for processing the first few bytes in
the case of unaligned buffer.

Fixing the test which was not actually verifying the results for
misaligned buffers (WriteString was creating an internal copy which
was aligned).

Adding benchmarks for length 15 (aligned and misaligned), results
below.

name                          old time/op    new time/op    delta
CastagnoliCrc15B-4              25.1ns ± 0%    22.1ns ± 1%  -12.14%
CastagnoliCrc15BMisaligned-4    25.2ns ± 0%    22.9ns ± 1%   -9.03%
CastagnoliCrc40B-4              23.1ns ± 0%    23.4ns ± 0%   +1.08%
CastagnoliCrc1KB-4               127ns ± 0%     128ns ± 0%   +1.18%
CastagnoliCrc4KB-4               462ns ± 0%     464ns ± 0%     ~
CastagnoliCrc32KB-4             3.58µs ± 0%    3.60µs ± 0%   +0.58%

name                          old speed      new speed      delta
CastagnoliCrc15B-4             597MB/s ± 0%   679MB/s ± 1%  +13.77%
CastagnoliCrc15BMisaligned-4   596MB/s ± 0%   655MB/s ± 1%   +9.94%
CastagnoliCrc40B-4            1.73GB/s ± 0%  1.71GB/s ± 0%   -1.14%
CastagnoliCrc1KB-4            8.01GB/s ± 0%  7.93GB/s ± 1%   -1.06%
CastagnoliCrc4KB-4            8.86GB/s ± 0%  8.83GB/s ± 0%     ~
CastagnoliCrc32KB-4           9.14GB/s ± 0%  9.09GB/s ± 0%   -0.58%

Change-Id: I499e37af2241d28e3e5d522bbab836c1a718430a
Reviewed-on: https://go-review.googlesource.com/24470
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-17 21:20:50 +00:00
Cherry Zhang
3d5cf72ca9 cmd/compile: CSE copied tuple selectors
In CSE if a tuple generator is CSE'd to a different block, its
selectors are copied to the same block. In this case, also CES
the copied selectors.

Test copied from Keith's CL 27202.

Fixes #16741.

Change-Id: I2fc8b9513d430f10d6104275cfff5fb75d3ef3d9
Reviewed-on: https://go-review.googlesource.com/27236
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-17 21:03:26 +00:00
Josh Bleecher Snyder
2b8e143dc3 cmd/vet: infer asm arch from build context
If we cannot infer the asm arch from the filename
or the build tags, assume that it is the
current build arch. Assembly files with no
restrictions ought to be usable on all arches.

Updates #11041

Change-Id: I0ae807dbbd5fb67ca21d0157fe180237a074113a
Reviewed-on: https://go-review.googlesource.com/27151
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-17 20:49:59 +00:00
Josh Bleecher Snyder
752e161587 cmd/vet: allow ^& uintptr arithmetic
The unsafe.Pointer check allows adding to
and subtracting from uintptrs in order to do
arithmetic.

Some code needs to round uintptrs.
Allow &^ for that purpose.

Updates #11041

Change-Id: Ib90dd2954bb6c78427058271e13f2ce4c4af38fb
Reviewed-on: https://go-review.googlesource.com/27156
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-17 20:48:57 +00:00
Atin M
ebcd179793 crypto/tls: set Conn.ConnectionState.ServerName unconditionally
Moves the state.ServerName assignment to outside the if
statement that checks for handshakeComplete.

Fixes #15571

Change-Id: I6c4131ddb16389aed1c410a975f9aa3b52816965
Reviewed-on: https://go-review.googlesource.com/22862
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2016-08-17 20:21:08 +00:00
Cherry Zhang
659dd4f1d7 cmd/compile: add more ARM64 optimizations
- Use machine instructions for uint64<->float conversions
- Do not enforce alignment on Zero/Move
	ARM64 supports unaligned load/stores, but only aligned offset
	or small offset can be encoded into instructions.
- Do combined loads

Change-Id: Iffca7dd0f13070b17b784861ce5a30af584680eb
Reviewed-on: https://go-review.googlesource.com/27086
Reviewed-by: David Chase <drchase@google.com>
2016-08-17 18:44:39 +00:00
Alberto Donizetti
cda633b39b math/big: avoid allocation in float.{Add, Sub} when there's no aliasing
name               old time/op    new time/op    delta
FloatAdd/10-4         116ns ± 1%      82ns ± 0%   -28.74%  (p=0.008 n=5+5)
FloatAdd/100-4        124ns ± 0%      86ns ± 1%   -30.34%  (p=0.016 n=4+5)
FloatAdd/1000-4       192ns ± 1%     123ns ± 0%   -35.94%  (p=0.008 n=5+5)
FloatAdd/10000-4      826ns ± 0%     438ns ± 0%   -46.99%  (p=0.000 n=4+5)
FloatAdd/100000-4    6.82µs ± 1%    3.36µs ± 0%   -50.74%  (p=0.008 n=5+5)
FloatSub/10-4         108ns ± 1%      77ns ± 1%   -29.06%  (p=0.008 n=5+5)
FloatSub/100-4        115ns ± 0%      79ns ± 0%   -31.48%  (p=0.029 n=4+4)
FloatSub/1000-4       168ns ± 0%      99ns ± 0%   -41.09%  (p=0.029 n=4+4)
FloatSub/10000-4      690ns ± 2%     288ns ± 1%   -58.24%  (p=0.008 n=5+5)
FloatSub/100000-4    5.37µs ± 1%    2.10µs ± 1%   -60.89%  (p=0.008 n=5+5)

name               old alloc/op   new alloc/op   delta
FloatAdd/10-4         48.0B ± 0%     0.0B ±NaN%  -100.00%  (p=0.008 n=5+5)
FloatAdd/100-4        64.0B ± 0%     0.0B ±NaN%  -100.00%  (p=0.008 n=5+5)
FloatAdd/1000-4        176B ± 0%       0B ±NaN%  -100.00%  (p=0.008 n=5+5)
FloatAdd/10000-4     1.41kB ± 0%   0.00kB ±NaN%  -100.00%  (p=0.008 n=5+5)
FloatAdd/100000-4    13.6kB ± 0%    0.0kB ±NaN%  -100.00%  (p=0.008 n=5+5)
FloatSub/10-4         48.0B ± 0%     0.0B ±NaN%  -100.00%  (p=0.008 n=5+5)
FloatSub/100-4        64.0B ± 0%     0.0B ±NaN%  -100.00%  (p=0.008 n=5+5)
FloatSub/1000-4        176B ± 0%       0B ±NaN%  -100.00%  (p=0.008 n=5+5)
FloatSub/10000-4     1.41kB ± 0%   0.00kB ±NaN%  -100.00%  (p=0.008 n=5+5)
FloatSub/100000-4    13.6kB ± 0%    0.0kB ±NaN%  -100.00%  (p=0.008 n=5+5)

Fixes #14868

Change-Id: Ia2b8b1a8ef0868288ecb25f812b17bd03ff40d1c
Reviewed-on: https://go-review.googlesource.com/23568
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-17 17:56:42 +00:00
Robert Griesemer
f542576b9e cmd/compile: add compiler phase timing
Timings is a simple data structure that collects times of labeled
Start/Stop events describing timed phases, which later can be written
to a file.

Adjacent phases with common label prefix are automatically collected
in a group together with the accumulated phase time.

Timing data can be appended to a file in benchmark data format
using the new -bench flag:

$ go build -gcflags="-bench=/dev/stdout" -o /dev/null go/types
commit: devel +8847c6b Mon Aug 15 17:51:53 2016 -0700
goos: darwin
goarch: amd64
BenchmarkCompile:go/types:fe:init              1       663292 ns/op      0.07 %
BenchmarkCompile:go/types:fe:loadsys           1      1337371 ns/op      0.14 %
BenchmarkCompile:go/types:fe:parse             1     47008869 ns/op      4.91 %    10824 lines    230254 lines/s
BenchmarkCompile:go/types:fe:typecheck:top1    1      2843343 ns/op      0.30 %
BenchmarkCompile:go/types:fe:typecheck:top2    1       447457 ns/op      0.05 %
BenchmarkCompile:go/types:fe:typecheck:func    1     15119595 ns/op      1.58 %      427 funcs     28241 funcs/s
BenchmarkCompile:go/types:fe:capturevars       1        56314 ns/op      0.01 %
BenchmarkCompile:go/types:fe:inlining          1      9805767 ns/op      1.02 %
BenchmarkCompile:go/types:fe:escapes           1     53598646 ns/op      5.60 %
BenchmarkCompile:go/types:fe:xclosures         1       199302 ns/op      0.02 %
BenchmarkCompile:go/types:fe:subtotal          1    131079956 ns/op     13.70 %
BenchmarkCompile:go/types:be:compilefuncs      1    692009428 ns/op     72.33 %      427 funcs       617 funcs/s
BenchmarkCompile:go/types:be:externaldcls      1        54591 ns/op      0.01 %
BenchmarkCompile:go/types:be:dumpobj           1    133478173 ns/op     13.95 %
BenchmarkCompile:go/types:be:subtotal          1    825542192 ns/op     86.29 %
BenchmarkCompile:go/types:unaccounted          1       106101 ns/op      0.01 %
BenchmarkCompile:go/types:total                1    956728249 ns/op    100.00 %

For #16169.

Change-Id: I93265fe0cb08e47cd413608d0824c5dd35ba7899
Reviewed-on: https://go-review.googlesource.com/24462
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-17 17:27:04 +00:00
Tom Wilkie
289df4e6e6 net: don't avoid resolving .local addresses
.local addresses are used by things like Kubernetes and Weave DNS; Go
should not avoid resolving them.

This is a partial revert of https://golang.org/cl/21328 which was too
strict of an interpretation of RFC 6762.

Fixes #16739

Change-Id: I349415b4eab5d61240dd18217bd95dc7d2105cd5
Reviewed-on: https://go-review.googlesource.com/27250
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-17 17:14:26 +00:00
Matthew Dempsky
73fdba2601 cmd/compile/internal/s390x: cleanup betypeinit
The Width{int,ptr,reg} assignments are no longer necessary since
golang.org/cl/21623. The other arch's betypeinit functions were
cleaned up, but apparently this one was missed.

Change-Id: I1c7f074d7864a561659c1f98aef604f57f285fd0
Reviewed-on: https://go-review.googlesource.com/27272
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-17 16:24:22 +00:00
Dan Peterson
2f73fe7a0d net: use libresolv rules for ndots range and validation
BIND libresolv allows values from 0 to 15.

For invalid values and negative numbers, 0 is used.
For numbers greater than 15, 15 is used.

Fixes #15419

Change-Id: I1009bc119c3e87919bcb55a80a35532e9fc3ba52
Reviewed-on: https://go-review.googlesource.com/24901
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-17 15:20:24 +00:00
Florian Uekermann
507144c011 math/rand: Document origin of cooked pseudo-random numbers
The Source provided by math/rand relies on an array of cooked
pseudo-random 63bit integers for seeding. The origin of these
numbers is undocumented.

Add a standalone program in math/rand folder that generates
the 63bit integer array as well as a 64bit version supporting
extension of the Source to 64bit pseudo-random number
generation while maintaining the current sequence in the
lower 63bit.

The code is largely based on the initial implementation of the
random number generator in the go repository by Ken Thompson
(revision 399).

Change-Id: Ib4192aea8127595027116a0f5a7be53f11dc110b
Reviewed-on: https://go-review.googlesource.com/22230
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-17 14:50:18 +00:00
Austin Clements
336dad2a07 runtime: fix check for vacuous page boundary rounding
sysUnused (e.g., madvise MADV_FREE) is only sensible to call on
physical page boundaries, so scavengelist rounds in the bounds of the
region being released to the nearest physical page boundaries.
However, if the region is smaller than a physical page and neither the
start nor end fall on a boundary, then rounding the start up to a page
boundary and the end down to a page boundary will result in end < start.
Currently, we only give up on the region if start == end, so if we
encounter end < start, we'll call madvise with a negative length and
the madvise will fail.

Issue #16644 gives a concrete example of this:

    start = 0x1285ac000
    end   = 0x1285ae000 (1 8K page)

This leads to the rounded values

    start = 0x1285b0000
    end   = 0x1285a0000

which leads to len = -65536.

Fix this by giving up on the region if end <= start, not just if
end == start.

Fixes #16644.

Change-Id: I8300db492dbadc82ac1ad878318b36bcb7c39524
Reviewed-on: https://go-review.googlesource.com/27230
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-17 14:04:16 +00:00
Yasuhiro Matsumoto
5dc7525b3e syscall: mksyscall_windows.go: put path separator in suffix for matching GOROOT
fixes #16493

Change-Id: I86bec2f9bd7965449c43e94733791f7cb18c5c4c
Reviewed-on: https://go-review.googlesource.com/25165
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2016-08-17 05:57:30 +00:00
Dan Peterson
00b779aeed net: simplify internal dtoi and xtoi funcs
Callers pass strings sliced as necessary instead of giving
an offset.

Fixes #16350

Change-Id: I7ba896f6ff09e0fd0094ca6c5af5d9a81622f15e
Reviewed-on: https://go-review.googlesource.com/27206
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-17 03:12:29 +00:00
Joe Tsai
9c13eb3729 go/build: introduce go1.8 build tag
Change-Id: Ib8855f8125970fc7ffb271635c28d31d310fcb5b
Reviewed-on: https://go-review.googlesource.com/27192
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-17 01:42:00 +00:00
Josh Bleecher Snyder
1a7fc7b3a7 cmd/compile: handle e == T comparison more efficiently
Instead of making a runtime call, compare types and values.

Change-Id: Id302083d5a6a5f18e04f36f304f3d290c46976ad
Reviewed-on: https://go-review.googlesource.com/26660
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-17 01:12:23 +00:00
Josh Bleecher Snyder
615a52b95b cmd/compile: inline x, ok := y.(T) where T is a scalar
When T is a scalar, there are no runtime calls
required, which makes this a clear win.

encoding/binary:
WriteInts-8                958ns ± 3%     864ns ± 2%   -9.80%  (p=0.000 n=15+15)

This also considerably shrinks a core fmt
routine:

Before: "".(*pp).printArg t=1 size=3952 args=0x20 locals=0xf0
After:  "".(*pp).printArg t=1 size=2624 args=0x20 locals=0x98

Unfortunately, I find it very hard to get stable
numbers out of the fmt benchmarks due to thermal scaling.

Change-Id: I1278006b030253bf8e48dc7631d18985cdaa143d
Reviewed-on: https://go-review.googlesource.com/26659
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-17 01:12:01 +00:00
Robert Griesemer
074d6a649c cmd/compile: remove conditional code dealing with two export formats
This removes some scaffolding introduced pre-1.7, introduced to
fix an export format bug, and to minimize conflicts with older
formats. The currently deployed and recognized format is "v1",
so don't worry about other versions. This is a step towards a
better scheme for internal export format versioning.

For #16244.

Change-Id: Ic7cf99dd2a24ad5484cc54aed44fa09332c2cf72
Reviewed-on: https://go-review.googlesource.com/27205
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
2016-08-17 00:57:35 +00:00
Robert Griesemer
f50ced6d73 cmd/compile: remove encoding of safemode bit from export data
Removes the encoding of this bit which was ignored but left behind
for 1.7 to minimize pre-1.7 export format changes. See the issue
for more details.

Fixes #15772.

Change-Id: I46cd7a66ad4c6003b78c64295cf3bda503ebf2dd
Reviewed-on: https://go-review.googlesource.com/27201
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-16 23:59:38 +00:00
Jess Frazelle
2b583a190e text/template: fix Parse when called twice with empty text
Fixes #16156

Change-Id: I6989db4fd392583a2d490339cefc525b07c11b90
Reviewed-on: https://go-review.googlesource.com/24380
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Andrew Gerrand <adg@golang.org>
2016-08-16 23:49:42 +00:00
Josh Bleecher Snyder
9b88fac00c cmd/internal/obj: reduce per-architecture opcode space
s390x took up the last available chunk of int16 opcodes.
There are RISC-V and sparc64 ports in progress out of tree,
and there will likely be other architectures.
Reduce the opcode space to allow more architectures to
fit without increasing to int32.

This is the smallest power of two that accomodates all
existing architectures. All else being equal, smaller is
better--smaller numbers are easier to generate immediates
for and easier on the eyes when debugging.

Change-Id: I4d0824b28913892fbd0579d3f90bea34e44c8946
Reviewed-on: https://go-review.googlesource.com/24223
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2016-08-16 22:53:48 +00:00
Robert Griesemer
b4e9f70412 cmd/compile: remove support for textual export format
Fixes #15323.

Change-Id: I50e996e6fde6b24327cb45dd84da31deef4dcc56
Reviewed-on: https://go-review.googlesource.com/27171
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 22:35:00 +00:00
Keith Randall
e492d9f018 runtime: fix map iterator concurrent map check
We should check whether there is a concurrent writer at the
start of every mapiternext, not just in mapaccessK (which is
only called during certain map growth situations).

Tests turned off by default because they are inherently flaky.

Fixes #16278

Change-Id: I8b72cab1b8c59d1923bec6fa3eabc932e4e91542
Reviewed-on: https://go-review.googlesource.com/24749
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-08-16 21:52:44 +00:00
Keith Randall
5ae8230769 cmd/compile: use shorter versions of zero-extend ops
Only need to zero-extend to 32 bits and we get the top
32 bits zeroed for free.

Only the WQ change actually generates different code.
The assembler did this optimization for us in the other two cases.
But we might as well do it during SSA so -S output more closely
matches the actual generated instructions.

Change-Id: I3e4ac50dc4da124014d4e31c86e9fc539d94f7fd
Reviewed-on: https://go-review.googlesource.com/23711
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-08-16 21:32:21 +00:00
Josh Bleecher Snyder
0cd8faf744 cmd/internal/obj: add opcode space safety check
This CL adds a safety mechanism
for changing the number of opcodes
available per architecture.

A subsequent CL will actually make the change.

Change-Id: I6332ed5514f2f153c54d11b7da0cc8a6be1c8066
Reviewed-on: https://go-review.googlesource.com/24222
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 20:26:16 +00:00
Tamir Duberstein
f88a88402c regexp: add some tests that were fixed in #12980
Also includes a minor golint cleanup in the tests.

Change-Id: I8c0fc81479e635e7cca18d5c48c28b654afa59d8
Reviewed-on: https://go-review.googlesource.com/25380
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 18:36:43 +00:00
Jaana Burcu Dogan
8c9a797894 cmd/go: document -v flag for get
Fixes #16719.

Change-Id: I20550628814e3454f17d6f8ae8b66cce17f09859
Reviewed-on: https://go-review.googlesource.com/27118
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 18:35:34 +00:00
Keith Randall
64214792e2 cmd/compile: allow unsafe.Pointer(nil) as static data
Fixes #16306

Change-Id: If8e2f411fe9a5a5c198f10765fee7261ba8feaf2
Reviewed-on: https://go-review.googlesource.com/24836
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-08-16 17:47:50 +00:00
Josh Bleecher Snyder
9d2b988e4a cmd/compile: accept literals in samesafeexpr
This only triggers a few places in the stdlib,
but it helps a lot when it does.

Before:

runtime.mapassign1 t=1 size=2400 args=0x20 locals=0xe0

After:

runtime.mapassign1 t=1 size=2352 args=0x20 locals=0xd8

name           old time/op  new time/op  delta
MapPop100-8    19.8µs ±11%  18.4µs ± 9%  -7.16%  (p=0.000 n=20+19)
MapPop1000-8    367µs ±17%   335µs ±11%  -8.63%  (p=0.000 n=19+19)
MapPop10000-8  7.29ms ±15%  6.86ms ±12%  -5.84%  (p=0.020 n=20+20)

Change-Id: I9faf32f95a6ba6a6d5d0818eab32cc271e01d10a
Reviewed-on: https://go-review.googlesource.com/26666
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-16 17:28:07 +00:00
Cherry Zhang
e6f1a886bc cmd/compile: fix uint<->float conversion on 386
The frontend rewriting lowers them to runtime calls on 386. It
matches explicitly uint32, but missed uint.

Fixes #16738.

Change-Id: Iece7a45edf74615baca052a53273c208f057636d
Reviewed-on: https://go-review.googlesource.com/27085
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 17:20:11 +00:00
Keith Randall
1faea596e4 cmd/compile: add size hint to map literal allocations
Might as well tell the runtime how large the map is going to be.
This avoids grow work and allocations while the map is being built.

Will wait for 1.8.

Fixes #15880
Fixes #16279

Change-Id: I377e3e5ec1e2e76ea2a50cc00810adda20ad0e79
Reviewed-on: https://go-review.googlesource.com/23558
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-08-16 17:19:48 +00:00
Josh Bleecher Snyder
35e25ef62e cmd/internal/obj/x86: minor code cleanup
Update #16415

Change-Id: I83e0966931ada2f1ed02304685bb45effdd71268
Reviewed-on: https://go-review.googlesource.com/26665
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 17:19:07 +00:00
Josh Bleecher Snyder
e85265e8c2 cmd/compile: optimize bool to int conversion
This CL teaches SSA to recognize code of the form

// b is a boolean value, i is an int of some flavor
if b {
	i = 1
} else {
	i = 0
}

and use b's underlying 0/1 representation for i
instead of generating jumps.

Unfortunately, it does not work on the obvious code:

func bool2int(b bool) int {
	if b {
		return 1
	}
	return 0
}

This is left for future work.
Note that the existing phiopt optimizations also don't work for:

func neg(b bool) bool {
	if b {
		return false
	}
	return true
}

In the meantime, runtime authors and the like can use:

func bool2int(b bool) int {
	var i int
	if b {
		i = 1
	} else {
		i = 0
	}
	return i
}

This compiles to:

"".bool2int t=1 size=16 args=0x10 locals=0x0
	0x0000 00000 (x.go:25)	TEXT	"".bool2int(SB), $0-16
	0x0000 00000 (x.go:25)	FUNCDATA	$0, gclocals·23e8278e2b69a3a75fa59b23c49ed6ad(SB)
	0x0000 00000 (x.go:25)	FUNCDATA	$1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
	0x0000 00000 (x.go:32)	MOVBLZX	"".b+8(FP), AX
	0x0005 00005 (x.go:32)	MOVBQZX	AL, AX
	0x0008 00008 (x.go:32)	MOVQ	AX, "".~r1+16(FP)
	0x000d 00013 (x.go:32)	RET

The extraneous MOVBQZX is #15300.

This optimization also helps range and slice.
The compiler must protect against pointers pointing
to the end of a slice/string. It does this by increasing
a pointer by either 0 or 1 * elemsize, based on a condition.
This CL optimizes away a jump in that code.

This CL triggers 382 times while compiling the standard library.

Updating code to utilize this optimization is left for future CLs.

Updates #6011

Change-Id: Ia7c1185f8aa223c543f91a3cd6d4a2a09c691c70
Reviewed-on: https://go-review.googlesource.com/22711
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-16 17:14:52 +00:00
Robert Griesemer
c7b9bd7456 cmd/compile: don't crash when exporting self-recursive interfaces
For #16369.

Change-Id: I4c9f5a66b95558adcc1bcface164b9b2b4382d2f
Reviewed-on: https://go-review.googlesource.com/24979
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-08-16 17:07:03 +00:00
David Crawshaw
56752eb2b8 reflect: clear tflag on new types
Fixes #16722

Change-Id: I50a0e69d3e79d13bc1860cd983267c3db087a4b8
Reviewed-on: https://go-review.googlesource.com/27119
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 16:58:15 +00:00
Keith Randall
d251030fa6 cmd/compile: don't fold >32bit constants into a MULQ
Don't fold constant factors into a multiply
beyond the capacity of a MULQ instruction (32 bits).

Fixes #16733

Change-Id: Idc213c6cb06f7c94008a8cf9e60a9e77d085fd89
Reviewed-on: https://go-review.googlesource.com/27160
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 16:46:48 +00:00
Josh Bleecher Snyder
562d06fc23 cmd/compile: inline _, ok = i.(T)
We already inlined

_, ok = e.(T)
_, ok = i.(E)
_, ok = e.(E)

The only ok-only variants not inlined are now

_, ok = i.(I)
_, ok = e.(I)

These call getitab, so are non-trivial.

Change-Id: Ie45fd8933ee179a679b92ce925079b94cff0ee12
Reviewed-on: https://go-review.googlesource.com/26658
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-16 15:24:33 +00:00
Michael Pratt
e6e26eeb29 cmd/internal/obj: convert Aconv to a stringer
Now that assembler opcodes have their own type, they can have a true
stringer, rather than explicit calls to Aconv, which makes for nicer
format strings.

Change-Id: Ic77f5f8ac38b4e519dcaa08c93e7b732226f7bfe
Reviewed-on: https://go-review.googlesource.com/25045
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-08-16 15:03:07 +00:00
Josh Bleecher Snyder
5693bee0f1 cmd/compile/internal/big: re-vendor
Pick up a bunch of changes and fixes.

Change-Id: If4101f7185d433a4c89096bc786ee5de8eeabac0
Reviewed-on: https://go-review.googlesource.com/27123
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 14:51:21 +00:00
Josh Bleecher Snyder
6f74c0774c runtime: move printing of extra newline
No functional changes, makes vet happy.

Updates #11041

Change-Id: I59f3aba46d19b86d605508978652d76a1fe7ac7b
Reviewed-on: https://go-review.googlesource.com/27125
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 14:37:17 +00:00
Josh Bleecher Snyder
297d1d736e net/http: use keyed composite literal
Makes vet happy.

Updates #11041

Change-Id: I23ca413c03ff387359440af8114786cd7880a048
Reviewed-on: https://go-review.googlesource.com/27124
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 14:37:02 +00:00
Josh Bleecher Snyder
302dd7b71e crypto/cipher, math/big: fix example names
Fixes (legit) vet warnings.
Fix some verb tenses while we're here.

Updates #11041

Change-Id: I27e995f55b38f4cf584e97a67b8545e8247e83d6
Reviewed-on: https://go-review.googlesource.com/27122
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-08-16 14:36:32 +00:00
Josh Bleecher Snyder
6d2db0986f crypto/tls: fix WriteTo method signature
Give *recordingConn the correct WriteTo signature
to be an io.WriterTo. This makes vet happy.
It also means that it'll report errors,
which were previously being ignored.

Updates #11041

Change-Id: I13f171407d63f4b62427679bff362eb74faddca5
Reviewed-on: https://go-review.googlesource.com/27121
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 14:36:19 +00:00
Josh Bleecher Snyder
12292754d3 net: change t.Error to t.Errorf
Caught by vet.

Updates #11041

Change-Id: I4dbb2eeaf633eea5976074840064edc2349e01d8
Reviewed-on: https://go-review.googlesource.com/27120
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-08-16 14:35:55 +00:00
Josh Bleecher Snyder
88858fa58f container/list: silence vet warnings
container/list/list_test.go:274: self-assignment of e1 to e1
container/list/list_test.go:274: self-assignment of e4 to e4
container/list/list_test.go:282: self-assignment of e1 to e1
container/list/list_test.go:286: self-assignment of e1 to e1
container/list/list_test.go:286: self-assignment of e4 to e4

Updates #11041

Change-Id: Ibd90cf6a924e93497908f437b814c3fc82937f4a
Reviewed-on: https://go-review.googlesource.com/27114
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 14:35:37 +00:00
Cherry Zhang
4c4ca83120 cmd/compile: remove nil check in accessing PAUTOHEAP variable
CL 23393 introduces PAUTOHEAP, and access of PAUTOHEAP variable is
rewritten to indirection of a PAUTO variable. Mark this variable
non-nil, so this indirection does not introduce extra nil checks.

Change-Id: I31853eed5e60238b6c5bc0546e2e9ab340dcddd9
Reviewed-on: https://go-review.googlesource.com/26831
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-16 14:32:13 +00:00
Josh Bleecher Snyder
40cf4ad0ef all: fix "result not used" vet warnings
For tests, assign to _.
For benchmarks, assign to a sink.

Updates #11041

Change-Id: I87c5543245c7bc74dceb38902f4551768dd37948
Reviewed-on: https://go-review.googlesource.com/27116
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 14:15:10 +00:00
Josh Bleecher Snyder
c70bdd3788 cmd/compile: fix bad generated format strings in test
We were generating format strings containing
a lone %. Vet legitimately complains:

cmd/compile/internal/gc/constFold_test.go:339: unrecognized printf verb ' '

The fix doesn't make for very readable code,
but it is simple and obviously correct.

Updates #11041

Change-Id: I90bd2d1d140887f5229752a279f7e46921472fbb
Reviewed-on: https://go-review.googlesource.com/27115
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 14:14:51 +00:00
Josh Bleecher Snyder
2cbe735366 syscall: unify unix/amd64 asm implementations
Updates #11041

Change-Id: I77e5ca0b61ffc530ee46848721a177867c81d548
Reviewed-on: https://go-review.googlesource.com/25116
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 14:12:58 +00:00
Josh Bleecher Snyder
a5464af554 syscall: split out unix Syscall9 asm support
This is preliminary work to unifying them.
Aside from Syscall9, all are identical.
Syscall9 has a netbsd/openbsd variant
and a dragonfly/freebsd variant.

Updates #11041

Change-Id: Ia5ce95d5e9115d4c0492d5e53aa7a4316deafd1f
Reviewed-on: https://go-review.googlesource.com/25115
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 14:12:40 +00:00
Josh Bleecher Snyder
33f95ec4ec syscall: superficial cleanup of amd64 unix assembly
This is preliminary work to unifying them.

Updates #11041

Change-Id: Ibe83da3d626f1da9e8888e26cedd3af2152b42e6
Reviewed-on: https://go-review.googlesource.com/25114
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 14:12:29 +00:00
Josh Bleecher Snyder
856342d844 syscall: fix dragonfly/amd64 assembly argument sizes
This is preliminary work to unifying the
unix amd64 assembly implementations,
which is preliminary work to making the
assembly vet-friendly.

Updates #11041

Change-Id: Ic64985124f8fb86cc08898be2ec7fca972ced4ca
Reviewed-on: https://go-review.googlesource.com/25113
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 14:12:16 +00:00
Josh Bleecher Snyder
b173298c89 syscall: unify unix 386 implementations
They were identical.

This will allow us to do the TODO at the top
of the file only once.

Updates #11041

Change-Id: I07aaca27ae46b66b65780082988bdc7546ed534b
Reviewed-on: https://go-review.googlesource.com/25112
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 14:12:02 +00:00
Cherry Zhang
1e94d79f9d cmd/compile: disable Duff's device on darwin/arm64
Darwin linker does not support BR26 reloc with non-zero addend.

Fixes #16724.

Change-Id: I1b5b4dc7159141bde3e273490f435c08c583afaf
Reviewed-on: https://go-review.googlesource.com/27081
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2016-08-16 10:41:53 +00:00
Brad Fitzpatrick
6fd2d2cf16 net/http: make Transport retry non-idempotent requests if no bytes written
If the server failed on us before we even tried to write any bytes,
it's safe to retry the request on a new connection, regardless of the
HTTP method/idempotence.

Fixes #15723

Change-Id: I25360f82aac530d12d2b3eef02c43ced86e62906
Reviewed-on: https://go-review.googlesource.com/27117
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 06:20:12 +00:00
Josh Bleecher Snyder
fe27291c00 cmd/compile: reduce garbage from autolabel
Follow-up to CL 26661

Change-Id: I67c58d17313094675cf0f30ce50d486818ae0dcb
Reviewed-on: https://go-review.googlesource.com/27113
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 04:29:32 +00:00
Gyu-Ho Lee
77e68ea78a archive/tar: preallocate slice from paxHeaders
Preallocate keys slice with the length of paxHeaders map
to prevent slice growth with append operations.

Change-Id: Ic9a927c4eaa775690a4ef912d61dd06f38e11510
Reviewed-on: https://go-review.googlesource.com/23782
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 02:46:50 +00:00
Mikio Hara
2cb471e40d crypto/tls: gofmt -w -s
Change-Id: Iedf9000e3bb1fa73b4c3669eae846e85f1f5fdfe
Reviewed-on: https://go-review.googlesource.com/24489
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 02:30:53 +00:00
Brad Fitzpatrick
5a59516dd7 net/http: deflake BenchmarkClient and its use of a fixed port for testing
Let the kernel pick a port for testing, and have the server in the
child process tell the parent (benchmarking) process the port that
was selected.

Fixes flakes like seen in https://golang.org/cl/27050 (and previously)

Change-Id: Ia2b705dc4152f70e0a5725015bdae09984d09d53
Reviewed-on: https://go-review.googlesource.com/27051
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-08-16 01:46:41 +00:00
Jan Mercl
52fcff3ec1 go/token: Fix race in FileSet.PositionFor.
Methods of FileSet are documented to be safe for concurrent use by
multiple goroutines, so FileSet is protected by a mutex and all its
methods use it to prevent concurrent mutations. All methods of File that
mutate the respective FileSet, including AddLine, do also lock its
mutex, but that does not help when PositionFor is invoked concurrently
and reads without synchronization what AddLine mutates.

The change adds acquiring a RLock around the racy call of File.position
and the respective test.

Fixes #16548

Change-Id: Iecaaa02630b2532cb29ab555376633ee862315dd
Reviewed-on: https://go-review.googlesource.com/25345
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 01:45:25 +00:00
Carlos C
14e446d909 bytes: add examples
`bytes` and `strings` are pretty similar to each other, this commit
brings `strings` examples to its counter-part.

Partially addresses #16360

Change-Id: I551320eaa78be9df69012035f1c3333f500e04c9
Reviewed-on: https://go-review.googlesource.com/25062
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 01:33:32 +00:00
Mikio Hara
7c31043cca os/exec: fix nit found by vet
Change-Id: I8085ed43d63215237a4871cc1e44257132a7f5de
Reviewed-on: https://go-review.googlesource.com/27130
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 00:44:45 +00:00
Sina Siadat
b98d8cd5ce container/heap: remove one unnecessary comparison in Fix
The heap.Fix function calls both down and up.  If the element is moved
down, we don't need to call up and we could save a comparison.

(per suggestion by Radu Berinde)

Fixes #16098.

Change-Id: I83a74710e66cf0d274d8c0743338c26f89f31afe
Reviewed-on: https://go-review.googlesource.com/24273
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-16 00:40:03 +00:00
Michael Hudson-Doyle
b5e43e669a cmd/link: when dynlinking, do not mangle short symbol names
When dynamically linking, a type symbol's name is replaced with a name based on
the SHA1 of the name as type symbol's names can be very long.  However, this
can make a type's symbol name longer in some cases. So skip it in that case.
One of the symbols this changes the treatment of is 'type.string' and that fixes a
bug where -X doesn't work when dynamically linking.

Fixes #16671

Change-Id: If5269038261b76fb0ec52e25a9c1d64129631e3c
Reviewed-on: https://go-review.googlesource.com/26890
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-08-16 00:37:09 +00:00
Brad Fitzpatrick
3ddc9ad916 strings: add special cases for Join of 2 and 3 strings
We already had special cases for 0 and 1. Add 2 and 3 for now too.
To be removed if the compiler is improved later (#6714).

This halves the number of allocations and total bytes allocated via
common filepath.Join calls, improving filepath.Walk performance.

Noticed as part of investigating filepath.Walk in #16399.

Change-Id: If7b1bb85606d4720f3ebdf8de7b1e12ad165079d
Reviewed-on: https://go-review.googlesource.com/25005
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 00:33:15 +00:00
Josh Bleecher Snyder
c88e868030 cmd/internal/obj: add generated String method for AddrType
Generated with:

stringer -type AddrType cmd/internal/obj

Change-Id: I74509cffab774035c5ca2ac0634638d73dbd33f3
Reviewed-on: https://go-review.googlesource.com/26657
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 00:28:57 +00:00
Josh Bleecher Snyder
a9ed47735f cmd/compile: move auto label gen variables to local function
This still depends on Curfn, but it's progress.

Updates #15756

Change-Id: Ic32fe56f44fcfbc023e7668d4dee07f8b47bf3a4
Reviewed-on: https://go-review.googlesource.com/26661
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-16 00:28:22 +00:00
Josh Bleecher Snyder
d94409d651 go/types: fix bad printf verbs
This fixes the following vet warnings:

go/types/builtins.go:437: arg call for printf verb %s of wrong type: *go/ast.CallExpr
go/types/builtins.go:598: arg call for printf verb %s of wrong type: *go/ast.CallExpr

Updates #11041

Change-Id: I746d054e8e49b330fbdf961912a98f55dd5f3ff9
Reviewed-on: https://go-review.googlesource.com/26997
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-16 00:24:37 +00:00
Josh Bleecher Snyder
e0d8064ed4 go/types: fix multiword data structure alignment on nacl
Fixes #16464

Change-Id: Ibf5625c1b5fa3abd18623023f18664e8f81fa45a
Reviewed-on: https://go-review.googlesource.com/26996
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-16 00:24:16 +00:00
Carlos C
7a974a4c60 encoding/json: add example for RawMessage marshalling
Fixes #16648

Change-Id: I3ab21ab33ca3f41219de9518ac6a39f49131e5e5
Reviewed-on: https://go-review.googlesource.com/26692
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 00:22:47 +00:00
Josh Bleecher Snyder
3357a02b74 math/big: use array instead of slice for deBruijn lookups
This allows the compiler to remove a bounds check.

math/big/nat.go:681: index bounds check elided
math/big/nat.go:683: index bounds check elided

Change-Id: Ieecb89ec5e988761b06764bd671672015cd58e9d
Reviewed-on: https://go-review.googlesource.com/26663
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 00:22:13 +00:00
Ilya Tocar
4e24e1d999 cmd/internal/obj/x86: VPSHUFD takes an unsigned byte.
VPSHUFD should take an unsigned argument to be consistent with
PSHUFD. Also fix all usage.

Fixes #16499

Change-Id: Ie699c102afed0379445914a251710365b14d89b6
Reviewed-on: https://go-review.googlesource.com/25383
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16 00:21:50 +00:00
Josh Bleecher Snyder
df9eeb1922 go/types: remove struct Sizeof cache
It was not responsive to the sizes param.
Remove it, and unwind the extra layers.

Fixes #16316

Change-Id: I940a57184a1601f52348d4bff8638f3f7462f5cd
Reviewed-on: https://go-review.googlesource.com/26995
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-16 00:21:27 +00:00
Brad Fitzpatrick
133d231a89 cmd/compile/internal/gc: get rid of useless autopkg variable
autopkg == localpkg, so it appears to be a remnant of earlier code.

Change-Id: I65b6c074535e877317cbf9f1f35e94890f0ebf14
Reviewed-on: https://go-review.googlesource.com/26662
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-16 00:19:16 +00:00
Robert Griesemer
3dc082f8fe go/types: minor cleanups
1) Removed mark field from declInfo struct. Instead use a visited map
   in ordering.go which was the only use place for the mark field.

2) Introduced objSet type for the common map[Object]bool type.

3) Improved comments.

Change-Id: I7544e7458d844b0ca08193f11de6238d317eaf2d
Reviewed-on: https://go-review.googlesource.com/24153
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-08-16 00:18:34 +00:00
Robert Griesemer
5c84441d88 go/types: fix computation of initialization order
The old algorithm operated on a dependency graph that included
all objects (including functions) for simplicity: it was based
directly on the dependencies collected for each object during
type checking an object's initialization expression. It also
used that graph to compute the objects involved in an erroneous
initialization cycle.

Cycles that consist only of (mutually recursive) functions are
permitted in initialization code; so those cycles were silently
ignored if encountered. However, such cycles still inflated the
number of dependencies a variable might have (due to the cycle),
which in some cases lead to the wrong variable being scheduled
for initialization before the one with the inflated dependency
count.

Correcting for the cycle when it is found is too late since at
that point another variable may have already been scheduled.

The new algorithm computes the initialization dependency graph as
before but adds an extra pass during which functions are eliminated
from the graph (and their dependencies are "back-propagated").
This eliminates the problem of cycles only involving functions
(there are no functions).

When a cycle is found, the new code computes the cycle path from
the original object dependencies so it can still include functions
on the path as before, for the same detailed error message.

The new code also more clearly distinguishes between objects that
can be in the dependency graph (constants, variables, functions),
and objects that cannot, by introducing the dependency type, a new
subtype of Object. As a consequence, the dependency graph is smaller.

Fixes #10709.

Change-Id: Ib58d6ea65cfb279041a0286a2c8e865f11d244eb
Reviewed-on: https://go-review.googlesource.com/24131
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-08-16 00:18:06 +00:00
Brad Fitzpatrick
66da885594 syscall: test Gettimeofday everywhere, not just on Darwin
The Darwin-only restriction was because we were late in the Go 1.7
cycle when the test was added.

In the process, I noticed Gettimeofday wasn't in the "unimplemented
midden heap" section of syscall_nacl.go, despite this line in the
original go1.txt:

pkg syscall, func Gettimeofday(*Timeval) error

So, add it, returning ENOSYS like the others.

Change-Id: Id7e02e857b753f8d079bee335c22368734e92254
Reviewed-on: https://go-review.googlesource.com/26772
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Quentin Smith <quentin@golang.org>
2016-08-16 00:17:21 +00:00
Hiroshi Ioka
664c4a1f87 os: consolidate files
Code movement only.

If someone finds function 'foo' in "foo_linux.go",
they will expect that the Window version of 'foo' exists in "foo_windows.go".

Current code doesn't follow this manner.

For example, 'sameFile' exists in "file_unix.go",
"stat_plan9.go" and "types_windows.go".

The CL address that problem by following rules:

* readdir family => dir.go, dir_$GOOS.go
* stat family => stat.go, stat_$GOOS.go
* path-functions => path_$GOOS.go
* sameFile => types.go, types_$GOOS.go
* process-functions => exec.go, exec_$GOOS.go
* hostname => sys.go, sys_$GOOS.go

Change-Id: Ic3c64663ce0b2a364d7a414351cd3c772e70187b
Reviewed-on: https://go-review.googlesource.com/27035
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 00:15:36 +00:00
Keith Randall
88c8b7c7f9 Merge remote-tracking branch 'origin/dev.ssa' into merge
Merging from dev.ssa back into master.

Contains complete SSA backends for arm, arm64, 386, amd64p32.
Work in progress for PPC64.

Change-Id: Ifd7075e3ec6f88f776e29f8c7fd55830328897fd
2016-08-15 17:07:16 -07:00
David Chase
d08010f94e [dev.ssa] cmd/compile: PPC64, FP to/from int conversions.
Passes ssa_test.

Requires a few new instructions and some scratchpad
memory to move data between G and F registers.

Also fixed comparisons to be correct in case of NaN.
Added missing instructions for run.bash.
Removed some FP registers that are apparently "reserved"
(but that are also apparently also unused except for a
gratuitous multiplication by two when y = x+x would work
just as well).

Currently failing stack splits.

Updates #16010.

Change-Id: I73b161bfff54445d72bd7b813b1479f89fc72602
Reviewed-on: https://go-review.googlesource.com/26813
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-08-15 14:47:49 +00:00
Cherry Zhang
d99cee79b9 [dev.ssa] cmd/compile, etc.: more ARM64 optimizations, and enable SSA by default
Add more ARM64 optimizations:
- use hardware zero register when it is possible.
- use shifted ops.
  The assembler supports shifted ops but not documented, nor knows
  how to print it. This CL adds them.
- enable fast division.
  This was disabled because it makes the old backend generate slower
  code. But with SSA it generates faster code.

Turn on SSA by default, also adjust tests.

Change-Id: I7794479954c83bb65008dcb457bc1e21d7496da6
Reviewed-on: https://go-review.googlesource.com/26950
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-08-15 03:37:34 +00:00
Keith Randall
94c8e59ae1 [dev.ssa] cmd/compile: simplify 386+PIC+globals a bit
We shouldn't issue instructions like MOVL foo(SB), AX directly from the
SSA backend.  Instead we should do LEAL foo(SB), AX; MOVL (AX), AX.

This simplifies obj logic because now only LEAL needs to be treated
specially.  The register allocator uses the LEAL to in effect allocate
the temporary register required for the shared library thunk calls.

Also, the LEALs can now be CSEd.  So code like
    var g int
    func f() { g += 5 }
Requires only one thunk call instead of 2.

Change-Id: Ib87d465f617f73af437445871d0ea91a630b2355
Reviewed-on: https://go-review.googlesource.com/26814
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-08-11 20:34:47 +00:00
Keith Randall
8f955d3664 [dev.ssa] cmd/compile: fix fp constant loads for 386+PIC
In position-independent 386 code, loading floating-point constants from
the constant pool requires two steps: materializing the address of
the constant pool entry (requires calling a thunk) and then loading
from that address.

Before this CL, the materializing happened implicitly in CX, which
clobbered that register.

Change-Id: Id094e0fb2d3be211089f299e8f7c89c315de0a87
Reviewed-on: https://go-review.googlesource.com/26811
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-11 19:52:45 +00:00
Cherry Zhang
ed1ad8f56c [dev.ssa] cmd/compile: add some ARM64 optimizations
Mostly mirrors ARM, includes:
- constant folding
- simplification of load, store, extension, and arithmetics
- nilcheck removal

Change-Id: Iffaa5fcdce100fe327429ecab316cb395e543469
Reviewed-on: https://go-review.googlesource.com/26710
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-08-11 18:08:47 +00:00
Cherry Zhang
748aa84424 [dev.ssa] cmd/internal/obj/arm64: fix encoding constant into some instructions
When a constant can be encoded in a logical instruction (BITCON), do
it this way instead of using the constant pool. The BITCON testing
code runs faster than table lookup (using map):

(on AMD64 machine, with pseudo random input)
BenchmarkIsBitcon-4   	300000000	         4.04 ns/op
BenchmarkTable-4      	50000000	        27.3 ns/op

The equivalent C code of BITCON testing is formally verified with
model checker CBMC against linear search of the lookup table.

Also handle cases when a constant can be encoded in a MOV instruction.
In this case, materializa the constant into REGTMP without using the
constant pool.

When constants need to be added to the constant pool, make sure to
check whether it fits in 32-bit. If not, store 64-bit.

Both legacy and SSA compiler backends are happy with this.

Fixes #16226.

Change-Id: I883e3069dee093a1cdc40853c42221a198a152b0
Reviewed-on: https://go-review.googlesource.com/26631
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-10 20:33:11 +00:00
Josh Bleecher Snyder
31ad583ab2 testing: respect benchtime on very fast benchmarks
When ns/op dropped below 1, the old code
ignored benchtime and reverted to 1s.

Change-Id: I59752cef88d8d73bfd5b085f5400ae657f78504e
Reviewed-on: https://go-review.googlesource.com/26664
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
2016-08-10 19:44:08 +00:00
Keith Randall
c069bc4996 [dev.ssa] cmd/compile: implement GO386=387
Last part of the 386 SSA port.

Modify the x86 backend to simulate SSE registers and
instructions with 387 registers and instructions.
The simulation isn't terribly performant, but it works,
and the old implementation wasn't very performant either.
Leaving to people who care about 387 to optimize if they want.

Turn on SSA backend for 386 by default.

Fixes #16358

Change-Id: I678fb59132620b2c47e993c1c10c4c21135f70c0
Reviewed-on: https://go-review.googlesource.com/25271
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-10 17:41:01 +00:00
Keith Randall
77ef597f38 [dev.ssa] cmd/compile: more fixes for 386 shared libraries
Use the destination register for materializing the pc
for GOT references also. See https://go-review.googlesource.com/c/25442/
The SSA backend assumes CX does not get clobbered for these instructions.

Mark duffzero as clobbering CX. The linker needs to clobber CX
to materialize the address to call. (This affects the non-shared-library
duffzero also, but hopefully forbidding one register across duffzero
won't be a big deal.)

Hopefully this is all the cases where the linker is clobbering CX
under the hood and SSA assumes it isn't.

Change-Id: I080c938170193df57cd5ce1f2a956b68a34cc886
Reviewed-on: https://go-review.googlesource.com/26611
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2016-08-10 17:09:38 +00:00
David Chase
ff37d0e681 [dev.ssa] cmd/compile: PPC: FP load/store/const/cmp/neg; div/mod
FP<->int conversions remain.

Updates #16010.

Change-Id: I38d7a4923e34d0a489935fffc4c96c020cafdba2
Reviewed-on: https://go-review.googlesource.com/25589
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-09 17:13:43 +00:00
Keith Randall
2cbdd55d64 [dev.ssa] cmd/compile: fix PIC for SSA-generated code
Access to globals requires a 2-instruction sequence on PIC 386.

    MOVL foo(SB), AX

is translated by the obj package into:

    CALL getPCofNextInstructionInTempRegister(SB)
    MOVL (&foo-&thisInstruction)(tmpReg), AX

The call returns the PC of the next instruction in a register.
The next instruction then offsets from that register to get the
address required.  The tricky part is the allocation of the
temp register.  The legacy compiler always used CX, and forbid
the register allocator from allocating CX when in PIC mode.
We can't easily do that in SSA because CX is actually a required
register for shift instructions. (I think the old backend got away
with this because the register allocator never uses CX, only
codegen knows that shifts must use CX.)

Instead, we allow the temp register to be anything.  When the
destination of the MOV (or LEA) is an integer register, we can
use that register.  Otherwise, we make sure to compile the
operation using an LEA to reference the global.  So

    MOVL AX, foo(SB)

is never generated directly.  Instead, SSA generates:

    LEAL foo(SB), DX
    MOVL AX, (DX)

which is then rewritten by the obj package to:

    CALL getPcInDX(SB)
    LEAL (&foo-&thisInstruction)(DX), AX
    MOVL AX, (DX)

So this CL modifies the obj package to use different thunks
to materialize the pc into different registers.  We use the
registers that regalloc chose so that SSA can still allocate
the full set of registers.

Change-Id: Ie095644f7164a026c62e95baf9d18a8bcaed0bba
Reviewed-on: https://go-review.googlesource.com/25442
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-08-09 15:50:07 +00:00
Keith Randall
69a755b602 [dev.ssa] cmd/compile: port SSA backend to amd64p32
It's not a new backend, just a PtrSize==4 modification
of the existing AMD64 backend.

Change-Id: Icc63521a5cf4ebb379f7430ef3f070894c09afda
Reviewed-on: https://go-review.googlesource.com/25586
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-08-09 15:48:26 +00:00
Gerrit Code Review
f3b4e78516 Merge "[dev.ssa] Merge commit 'f135c326402aaa757aa96aad283a91873d4ae124' into mergebranch" into dev.ssa 2016-08-08 18:21:58 +00:00
Brad Fitzpatrick
7a62274065 net/http: make Transport use new connection if over HTTP/2 concurrency limit
The Go HTTP/1 client will make as many new TCP connections as the user requests.

The HTTP/2 client tried to have that behavior, but the policy of
whether a connection is re-usable didn't take into account the extra 1
stream counting against SETTINGS_MAX_CONCURRENT_STREAMS so in practice
users were getting errors.

For example, if the server's advertised max concurrent streams is 100
and 200 concurrrent Go HTTP requests ask for a connection at once, all
200 will think they can reuse that TCP connection, but then 100 will
fail later when the number of concurrent streams exceeds 100.

Instead, recognize the "no cached connections" error value in the
shouldRetryRequest method, so those 100 will retry a new connection.

This is the conservative fix for Go 1.7 so users don't get errors, and
to match the HTTP/1 behavior. Issues #13957 and #13774 are the more
involved bugs for Go 1.8.

Updates #16582
Updates #13957

Change-Id: I1f15a7ce60c07a4baebca87675836d6fe03993e8
Reviewed-on: https://go-review.googlesource.com/25580
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Chris Broadfoot <cbro@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-08 17:53:51 +00:00
Cherry Zhang
0484052358 [dev.ssa] cmd/compile: remove flags from regMask
Reg allocator skips flag-typed values. Flag allocator uses the type
and whether the op has "clobberFlags" set.

Tested on AMD64, ARM, ARM64, 386. Passed 'toolstash -cmp' on AMD64.
PPC64 is coded blindly.

Change-Id: Ib1cc27efecef6a1bb27f7d7ed035a582660d244f
Reviewed-on: https://go-review.googlesource.com/25480
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-08-07 03:08:03 +00:00
David Chase
01ae4b1da4 [dev.ssa] cmd/compile: PPC64, load/store by type, shifts, divisions, bools
Updates #16010.

Change-Id: Ie520d64fd1c4f881f45623303ed0b7cbdf0e4764
Reviewed-on: https://go-review.googlesource.com/25493
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-08-06 04:09:01 +00:00
Shenghou Ma
26015b9563 runtime: make stack 16-byte aligned for external code in _rt0_amd64_linux_lib
Fixes #16618.

Change-Id: Iffada12e8672bbdbcf2e787782c497e2c45701b1
Reviewed-on: https://go-review.googlesource.com/25550
Run-TryBot: Minux Ma <minux@golang.org>
Reviewed-by: Arjan Van De Ven <arjan.van.de.ven@intel.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-05 23:56:07 +00:00
Shenghou Ma
9fde86b012 runtime, syscall: fix kernel gettimeofday ABI change on iOS 10
Fixes #16570 on iOS.

Thanks Daniel Burhans for reporting the bug and testing the fix.

Change-Id: I43ae7b78c8f85a131ed3d93ea59da9f32a02cd8f
Reviewed-on: https://go-review.googlesource.com/25481
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-05 20:47:34 +00:00
Ian Lance Taylor
3a03e877cc os: check for waitid returning ENOSYS
Reportedly waitid is not available for Ubuntu on Windows.

Fixes #16610.

Change-Id: Ia724f45a85c6d3467b847da06d8c65d280781dcd
Reviewed-on: https://go-review.googlesource.com/25507
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-05 19:48:42 +00:00
Brad Fitzpatrick
10316757ce net/http: update bundled http2 for flow control window adjustment fix
Updates bundled http2 to x/net/http2 git rev 075e191 for:

   http2: adjust flow control on open streams when processing SETTINGS
   https://golang.org/cl/25508

Fixes #16612

Change-Id: Ib0513201bff44ab747a574ae6894479325c105d2
Reviewed-on: https://go-review.googlesource.com/25543
Run-TryBot: Chris Broadfoot <cbro@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Chris Broadfoot <cbro@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-05 17:08:52 +00:00
Brad Fitzpatrick
da070bed19 syscall: fix Gettimeofday on macOS Sierra
Fixes #16606

Change-Id: I57465061b90e901293cd8b6ef756d6aa84ebd4a3
Reviewed-on: https://go-review.googlesource.com/25495
Reviewed-by: Quentin Smith <quentin@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Quentin Smith <quentin@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-04 21:42:44 +00:00
David Chase
dd1d9b36c6 [dev.ssa] cmd/compile: PPC64, add cmp->bool, some shifts, hmul
Includes hmul (all widths)
compare for boolean result and simplifications
shift operations plus changes/additions for implementation
(ORN, ADDME, ADDC)

Also fixed a backwards-operand CMP.

Change-Id: Id723c4e25125c38e0d9ab9ec9448176b75f4cdb4
Reviewed-on: https://go-review.googlesource.com/25410
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-08-04 18:17:52 +00:00
Keith Randall
01dbfb81a0 [dev.ssa] Merge commit 'f135c326402aaa757aa96aad283a91873d4ae124' into mergebranch
Pick up shared library fix in dev.ssa.

Change-Id: I5bdd0e9e0f1d6f7c14b518343ee323ed9a894b9c
2016-08-04 10:52:24 -07:00
David Crawshaw
f135c32640 runtime: initialize hash algs before typemap
When compiling with -buildmode=shared, a map[int32]*_type is created for
each extra module mapping duplicate types back to a canonical object.
This is done in the function typelinksinit, which is called before the
init function that sets up the hash functions for the map
implementation. The result is typemap becomes unusable after
runtime initialization.

The fix in this CL is to move algorithm init before typelinksinit in
the runtime setup process. (For 1.8, we may want to turn typemap into
a sorted slice of types and use binary search.)

Manually tested on GOOS=linux with:

	GOHOSTARCH=386 GOARCH=386 ./make.bash && \
		go install -buildmode=shared std && \
		cd ../test && \
		go run run.go -linkshared

Fixes #16590

Change-Id: Idc08c50cc70d20028276fbf564509d2cd5405210
Reviewed-on: https://go-review.googlesource.com/25469
Run-TryBot: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-04 17:39:05 +00:00
Keith Randall
d2286ea284 [dev.ssa] Merge remote-tracking branch 'origin/master' into mergebranch
Semi-regular merge from tip into dev.ssa.

Change-Id: Iadb60e594ef65a99c0e1404b14205fa67c32a9e9
2016-08-04 10:08:20 -07:00
Josh Bleecher Snyder
6a1153acb4 [dev.ssa] cmd/compile: refactor out rulegen value parsing
Previously, genMatch0 and genResult0 contained
lots of duplication: locating the op, parsing
the value, validation, etc.
Parsing and validation was mixed in with code gen.

Extract a helper, parseValue. It is responsible
for parsing the value, locating the op, and doing
shared validation.

As a bonus (and possibly as my original motivation),
make op selection pay attention to the number
of args present.
This allows arch-specific ops to share a name
with generic ops as long as there is no ambiguity.
It also detects and reports unresolved ambiguity,
unlike before, where it would simply always
pick the generic op, with no warning.

Also use parseValue when generating the top-level
op dispatch, to ensure its opinion about ops
matches genMatch0 and genResult0.

The order of statements in the generated code used
to depend on the exact rule. It is now somewhat
independent of the rule. That is the source
of some of the generated code changes in this CL.
See rewritedec64 and rewritegeneric for examples.
It is a one-time change.

The op dispatch switch and functions used to be
sorted by opname without architecture. The sort
now includes the architecture, leading to further
generated code changes.
See rewriteARM and rewriteAMD64 for examples.
Again, it is a one-time change.

There are no functional changes.

Change-Id: I22c989183ad5651741ebdc0566349c5fd6c6b23c
Reviewed-on: https://go-review.googlesource.com/24649
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-03 22:51:51 +00:00
Brad Fitzpatrick
2da5633eb9 runtime: fix nanotime for macOS Sierra, again.
macOS Sierra beta4 changed the kernel interface for getting time.
DX now optionally points to an address for additional info.
Set it to zero to avoid corrupting memory.

Fixes #16570

Change-Id: I9f537e552682045325cdbb68b7d0b4ddafade14a
Reviewed-on: https://go-review.googlesource.com/25400
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Quentin Smith <quentin@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-02 20:17:50 +00:00
Joe Tsai
6317c213c9 cmd/doc: ensure functions with unexported return values are shown
The commit in golang.org/cl/22354 groups constructors functions under
the type that they construct to. However, this caused a minor regression
where functions that had unexported return values were not being printed
at all. Thus, we forgo the grouping logic if the type the constructor falls
under is not going to be printed.

Fixes #16568

Change-Id: Idc14f5d03770282a519dc22187646bda676af612
Reviewed-on: https://go-review.googlesource.com/25369
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-02 03:24:48 +00:00
Joe Tsai
f5758739a8 cmd/doc: handle embedded interfaces properly
Changes made:
* Disallow star expression on interfaces as this is not possible.
* Show an embedded "error" in an interface as public similar to
how godoc does it.
* Properly handle selector expressions in both structs and interfaces.
This is possible since a type may refer to something defined in
another package (e.g. io.Reader).

Before:
<<<
$ go doc runtime.Error
type Error interface {

    // RuntimeError is a no-op function but
    // serves to distinguish types that are run time
    // errors from ordinary errors: a type is a
    // run time error if it has a RuntimeError method.
    RuntimeError()
    // Has unexported methods.
}

$ go doc compress/flate Reader
doc: invalid program: unexpected type for embedded field
doc: invalid program: unexpected type for embedded field
type Reader interface {
    io.Reader
    io.ByteReader
}
>>>

After:
<<<
$ go doc runtime.Error
type Error interface {
    error

    // RuntimeError is a no-op function but
    // serves to distinguish types that are run time
    // errors from ordinary errors: a type is a
    // run time error if it has a RuntimeError method.
    RuntimeError()
}

$ go doc compress/flate Reader
type Reader interface {
    io.Reader
    io.ByteReader
}
>>>

Fixes #16567

Change-Id: I272dede971eee9f43173966233eb8810e4a8c907
Reviewed-on: https://go-review.googlesource.com/25365
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-02 01:58:14 +00:00
Brad Fitzpatrick
28ee179657 net: prevent cancelation goroutine from adjusting fd timeout after connect
This was previously fixed in https://golang.org/cl/21497 but not enough.

Fixes #16523

Change-Id: I678543a656304c82d654e25e12fb094cd6cc87e8
Reviewed-on: https://go-review.googlesource.com/25330
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-02 00:55:45 +00:00
Brad Fitzpatrick
c558a539b5 net/http: update bundled http2
Updates bundled http2 to x/net/http2 rev 28d1bd4f for:

    http2: make Transport work around mod_h2 bug
    https://golang.org/cl/25362

    http2: don't ignore DATA padding in flow control
    https://golang.org/cl/25382

Updates #16519
Updates #16556
Updates #16481

Change-Id: I51f5696e977c91bdb2d80d2d56b8a78e3222da3f
Reviewed-on: https://go-review.googlesource.com/25388
Reviewed-by: Chris Broadfoot <cbro@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-02 00:33:01 +00:00
David Chase
dede2061f3 [dev.ssa] cmd/compile: PPC64, add more zeroing and moves
Passes light testing.
Modified to avoid possible exposure of "exterior" pointers
to GC.

Updates #16010.

Change-Id: I41fced4fa83cefb9542dff8c8dee1a0c48056b3c
Reviewed-on: https://go-review.googlesource.com/25310
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-01 18:26:03 +00:00
Cherry Zhang
111d590f86 cmd/compile: fix possible spill of invalid pointer with DUFFZERO on AMD64
SSA compiler on AMD64 may spill Duff-adjusted address as scalar. If
the object is on stack and the stack moves, the spilled address become
invalid.

Making the spill pointer-typed does not work. The Duff-adjusted address
points to the memory before the area to be zeroed and may be invalid.
This may cause stack scanning code panic.

Fix it by doing Duff-adjustment in genValue, so the intermediate value
is not seen by the reg allocator, and will not be spilled.

Add a test to cover both cases. As it depends on allocation, it may
be not always triggered.

Fixes #16515.

Change-Id: Ia81d60204782de7405b7046165ad063384ede0db
Reviewed-on: https://go-review.googlesource.com/25309
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-07-29 01:09:55 +00:00
Cherry Zhang
0069240216 [dev.ssa] cmd/compile: fix build for old backend on ARM64
Apparently the old backend needs NEG instruction having RegRead set,
even this instruction does not take a Reg field... I don't think SSA
uses this flag, so just leave it as it was. SSA is still happy.

Fix ARM64 build on https://build.golang.org/?branch=dev.ssa

Change-Id: Ia7e7f2ca217ddae9af314d346af5406bbafb68e8
Reviewed-on: https://go-review.googlesource.com/25302
Reviewed-by: David Chase <drchase@google.com>
2016-07-28 02:14:24 +00:00
Rhys Hiltner
ccca9c9cc0 runtime: reduce GC assist extra credit
Mutator goroutines that allocate memory during the concurrent mark
phase are required to spend some time assisting the garbage
collector. The magnitude of this mandatory assistance is proportional
to the goroutine's allocation debt and subject to the assistance
ratio as calculated by the pacer.

When assisting the garbage collector, a mutator goroutine will go
beyond paying off its allocation debt. It will build up extra credit
to amortize the overhead of the assist.

In fast-allocating applications with high assist ratios, building up
this credit can take the affected goroutine's entire time slice.
Reduce the penalty on each goroutine being selected to assist the GC
in two ways, to spread the responsibility more evenly.

First, do a consistent amount of extra scan work without regard for
the pacer's assistance ratio. Second, reduce the magnitude of the
extra scan work so it can be completed within a few hundred
microseconds.

Commentary on gcOverAssistWork is by Austin Clements, originally in
https://golang.org/cl/24704

Updates #14812
Fixes #16432

Change-Id: I436f899e778c20daa314f3e9f0e2a1bbd53b43e1
Reviewed-on: https://go-review.googlesource.com/25155
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2016-07-27 18:56:04 +00:00
Cherry Zhang
114c05962c [dev.ssa] cmd/compile: fix possible invalid pointer spill in large Zero/Move on ARM
Instead of comparing the address of the end of the memory to zero/copy,
comparing the address of the last element, which is a valid pointer.
Also unify large and unaligned Zero/Move, by passing alignment as AuxInt.

Fixes #16515 for ARM.

Change-Id: I19a62b31c5acf5c55c16a89bea1039c926dc91e5
Reviewed-on: https://go-review.googlesource.com/25300
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-07-27 18:00:19 +00:00
Cherry Zhang
83208504fe [dev.ssa] cmd/compile: add more on ARM64 SSA
Support the following:
- Shifts. ARM64 machine instructions only use lowest 6 bits of the
  shift (i.e. mod 64). Use conditional selection instruction to
  ensure Go semantics.
- Zero/Move. Alignment is ensured.
- Hmul, Avg64u, Sqrt.
- reserve R18 (platform register in ARM64 ABI) and R29 (frame pointer
  in ARM64 ABI).

Everything compiles, all.bash passed (with non-SSA test disabled).

Change-Id: Ia8ed58dae5cbc001946f0b889357b258655078b1
Reviewed-on: https://go-review.googlesource.com/25290
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-07-27 16:37:23 +00:00
Brad Fitzpatrick
c80e0d374b net/http: fix data race with concurrent use of Server.Serve
Fixes #16505

Change-Id: I0afabcc8b1be3a5dbee59946b0c44d4c00a28d71
Reviewed-on: https://go-review.googlesource.com/25280
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2016-07-27 05:43:36 +00:00
Brad Fitzpatrick
4a15508c66 crypto/x509: detect OS X version for FetchPEMRoots at run time
https://golang.org/cl/25233 was detecting the OS X release at compile
time, not run time. Detect it at run time instead.

Fixes #16473 (again)

Change-Id: I6bec4996e57aa50c52599c165aa6f1fae7423fa7
Reviewed-on: https://go-review.googlesource.com/25281
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2016-07-26 23:16:15 +00:00
Brad Fitzpatrick
66b47431cb net/http: update bundled http2
Updates x/net/http2 to git rev 6a513af for:

  http2: return flow control for closed streams
  https://golang.org/cl/25231

  http2: make Transport prefer HTTP response header recv before body write error
  https://golang.org/cl/24984

  http2: make Transport treat "Connection: close" the same as Request.Close
  https://golang.org/cl/24982

Fixes golang/go#16481

Change-Id: Iaddb166387ca2df1cfbbf09a166f8605578bec49
Reviewed-on: https://go-review.googlesource.com/25282
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-07-26 23:04:15 +00:00
Austin Clements
b11fff3886 runtime/pprof: document use of pprof package
Currently the pprof package gives almost no guidance for how to use it
and, despite the standard boilerplate used to create CPU and memory
profiles, this boilerplate appears nowhere in the pprof documentation.

Update the pprof package documentation to give the standard
boilerplate in a form people can copy, paste, and tweak. This
boilerplate is based on rsc's 2011 blog post on profiling Go programs
at https://blog.golang.org/profiling-go-programs, which is where I
always go when I need to copy-paste the boilerplate.

Change-Id: I74021e494ea4dcc6b56d6fb5e59829ad4bb7b0be
Reviewed-on: https://go-review.googlesource.com/25182
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-07-26 22:16:55 +00:00
Brad Fitzpatrick
ff60da6962 crypto/x509: use Go 1.6 implementation for FetchPEMRoots for OS X 10.8
Conservative fix for the OS X 10.8 crash. We can unify them back together
during the Go 1.8 dev cycle.

Fixes #16473

Change-Id: If07228deb2be36093dd324b3b3bcb31c23a95035
Reviewed-on: https://go-review.googlesource.com/25233
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-07-26 21:18:26 +00:00