]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
6 years agodoc: add a link to the code of conduct
Leigh McCulloch [Mon, 13 Nov 2017 06:27:06 +0000 (06:27 +0000)]
doc: add a link to the code of conduct

GitHub has defined a set of standard meta files to include with projects
hosted on GitHub. According to the GitHub Insights Community page for
go project the only one missing is the code of conduct.

Go has a code of conduct on it's website and we should link to it in the
prescribed `.github/CODE_OF_CONDUCT.md` so that people can find it in
the standard location on GitHub. This would be consistent with the
contribution guidelines that are linked to in `.github/CONTRIBUTING.md`.

Ref: https://help.github.com/articles/adding-a-code-of-conduct-to-your-project/

Fixes #22685

Change-Id: Ie89aa39d3df741d7d6ed2dba5c8ba3d0e0dbf618
Reviewed-on: https://go-review.googlesource.com/77231
Reviewed-by: Gabriel Aszalos <gabriel.aszalos@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/compile: record original and absolute file names for line directives
griesemer [Fri, 10 Nov 2017 19:38:51 +0000 (11:38 -0800)]
cmd/compile: record original and absolute file names for line directives

Also, with this change, error locations don't print absolute positions
in [] brackets following positions relative to line directives. To get
the absolute positions as well, specify the -L flag.

Fixes #22660.

Change-Id: I9ecfa254f053defba9c802222874155fa12fee2c
Reviewed-on: https://go-review.googlesource.com/77090
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/cover: modify source as text, not as AST
Russ Cox [Fri, 10 Nov 2017 04:39:12 +0000 (23:39 -0500)]
cmd/cover: modify source as text, not as AST

cmd/cover rewrites Go source code to add coverage annotations.
The approach to date has been to parse the code to AST, analyze it,
rewrite the AST, and print it back out. This approach fails to preserve
line numbers in the original code and has a very difficult time with
comments, because go/printer does as well.

This CL changes cmd/cover to decide what to modify based on the
AST but to apply the modifications as purely textual substitutions.
In this way, cmd/cover can be sure it never adds or removes a newline
character, nor a comment, so all line numbers and comments are
preserved.

This also allows us to emit a single //line comment at the beginning
of the translated file and have the compiler report errors with
correct line numbers in the original file.

Fixes #6329.
Fixes #15757.

Change-Id: Ia95f6f894bb498e80d1f91fde56cd4a8009d7f9b
Reviewed-on: https://go-review.googlesource.com/77150
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/go: more refined handling of cmd/compile magic environment variables
Russ Cox [Fri, 10 Nov 2017 19:50:03 +0000 (14:50 -0500)]
cmd/go: more refined handling of cmd/compile magic environment variables

Per discussion with David Chase, need to check GOSSAHASH$n
for increasing n until one is missing. Also if GSHS_LOGFILE is set,
the compiler writes to that file, so arrange never to cache in that case.

Change-Id: I3931b4e296251b99abab9bbbbbdcf94ae8c1e2a6
Reviewed-on: https://go-review.googlesource.com/77111
Reviewed-by: David Chase <drchase@google.com>
6 years agocmd/go: cache and replay command output during build
Russ Cox [Fri, 10 Nov 2017 19:44:31 +0000 (14:44 -0500)]
cmd/go: cache and replay command output during build

It's nice that

go build -gcflags=-m errors
go build -gcflags=-m errors

uses the cache for the second command.

Even nicer is to make the second command
print the same output as the first command.

Fixes #22587.

Change-Id: I64350839f01c86c9a095d9d22f6924cd7a0b9105
Reviewed-on: https://go-review.googlesource.com/77110
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/compile: use stringer on types.EType
Daniel Martí [Sun, 12 Nov 2017 16:55:11 +0000 (16:55 +0000)]
cmd/compile: use stringer on types.EType

Another one that is possible thanks to the new -trimprefix stringer
flag.

The only subtle difference is that, in the previous version, some values
such as TUNSAFEPTR were stringified as "TUNSAFEPTR" instead of
"UNSAFEPTR". The new String method is always consistent in removing the
"T" prefix.

Passes toolstash -cmp on std cmd.

Change-Id: I68407f391795403dfcbbfa68c813018c0235bbb5
Reviewed-on: https://go-review.googlesource.com/77250
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Marvin Stenger <marvin.stenger94@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agocmd/compile: replace classnames with Class.String
Daniel Martí [Fri, 10 Nov 2017 18:35:30 +0000 (18:35 +0000)]
cmd/compile: replace classnames with Class.String

Since the slice of names is almost exactly the same as what stringer is
already generating for us.

Passes toolstash -cmp on std cmd.

Change-Id: I3f1e95efc690c0108236689e721627f00f79a461
Reviewed-on: https://go-review.googlesource.com/77190
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
6 years agocrypto/x509: handle name constraints with cryptobyte
Adam Langley [Mon, 30 Oct 2017 02:20:33 +0000 (19:20 -0700)]
crypto/x509: handle name constraints with cryptobyte

This allows better precision and (the motivation) empty strings to
be handled correctly. With that in place tests for the behaviour of
empty name constraints can be added.

Also fixes a compatibility issue with NSS. See #22616.

Fixes #22616

Change-Id: I5139439bb58435d5f769828a4eebf8bed2d858e8
Reviewed-on: https://go-review.googlesource.com/74271
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agonet/http/httputil: make ReverseProxy close response body if ModifyResponse returns...
Edan B [Sat, 11 Nov 2017 08:10:14 +0000 (10:10 +0200)]
net/http/httputil: make ReverseProxy close response body if ModifyResponse returns an error

Fixes #22658

Change-Id: I00e2b007d77b6f54798f7755d0b08e4fea824392
Reviewed-on: https://go-review.googlesource.com/77170
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/go: skip TestGoTestJSON on uniprocessor machines
David du Colombier [Fri, 10 Nov 2017 20:46:41 +0000 (21:46 +0100)]
cmd/go: skip TestGoTestJSON on uniprocessor machines

CL 76873 added TestGoTestJSON. However, this test
is only succeeding on SMP machines.

This change skips TestGoTestJSON on uniprocessor machines.

Fixes #22665.

Change-Id: I3989d3331fb71193a25a3f0bbb84ff3e1b730890
Reviewed-on: https://go-review.googlesource.com/77130
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agonet: ignore duplicate interfaces in TestInterfaceHardwareAddrWithGetmac
Alex Brainman [Mon, 28 Aug 2017 02:21:44 +0000 (12:21 +1000)]
net: ignore duplicate interfaces in TestInterfaceHardwareAddrWithGetmac

Sometimes getmac lists many interfaces for the same MAC address,
while Interfaces returns only single name for that address. Adjust
the test to ignore the names that are not returned by the Interfaces.

Fixes #21027

Change-Id: I08d98746a7c669f2d730dba2da36e07451a6f405
Reviewed-on: https://go-review.googlesource.com/59411
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
6 years agocmd/objdump: pass the correct execution mode to x86asm.Decode in disasm_x86 on 386
Hiroshi Ioka [Sun, 1 Oct 2017 23:17:15 +0000 (08:17 +0900)]
cmd/objdump: pass the correct execution mode to x86asm.Decode in disasm_x86 on 386

Fixes #22093
Fixes #19988

Change-Id: Ibd8ec89e091fd527f363999e484676931d7aa6e2
Reviewed-on: https://go-review.googlesource.com/67450
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/go: document test -json
Russ Cox [Fri, 10 Nov 2017 18:37:28 +0000 (13:37 -0500)]
cmd/go: document test -json

Added in CL 76873 but forgot to add the flag docs.

Change-Id: I448f85cc8cf51399c0d799691226b94f88f327da
Reviewed-on: https://go-review.googlesource.com/77030
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Caleb Spare <cespare@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/go: redefine -coverpkg to be a pattern list
Russ Cox [Thu, 9 Nov 2017 15:29:23 +0000 (10:29 -0500)]
cmd/go: redefine -coverpkg to be a pattern list

If you run

go test -coverpkg=all fmt

one possible interpretation is that you want coverage for all the
packages involved in the fmt test, not all the packages in the world.
Because coverpkg was previously defined as a list of packages
to be loaded, however, it meant all packages in the world.

Now that the go command has a concept of package notation
being used as a matching filter instead of a direct enumeration,
apply that to -coverpkg, so that -coverpkg=all now has the
more useful filter interpretation.

Fixes #10271.
Fixes #21283.

Change-Id: Iddb77b21ba286d3dd65b62507af27e244865072d
Reviewed-on: https://go-review.googlesource.com/76876
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
6 years agocmd/go: allow -coverprofile with multiple packages being tested
Russ Cox [Fri, 10 Nov 2017 02:23:08 +0000 (21:23 -0500)]
cmd/go: allow -coverprofile with multiple packages being tested

It's easy to merge the coverage profiles from the
multiple executed tests, so do that.

Also ensures that at least an empty coverage profile
is always written.

Fixes #6909.
Fixes #18909.

Change-Id: I28b88e1fb0fb773c8f57e956b18904dc388cdd82
Reviewed-on: https://go-review.googlesource.com/76875
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
6 years agocmd/test2json: document time.Time JSON format
Russ Cox [Fri, 10 Nov 2017 17:58:31 +0000 (12:58 -0500)]
cmd/test2json: document time.Time JSON format

This is already documented in the time.Time package
but people might not look there.

Followup to CL 76872, which I submitted accidentally
(Gerrit has placed the Submit button next to Reply again.)

Change-Id: Ibfd6a4da241982d591a8698282a0c15fe9f2e775
Reviewed-on: https://go-review.googlesource.com/77010
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agonet: mark condFatalf as a test helper
Aman Gupta [Fri, 10 Nov 2017 06:19:49 +0000 (22:19 -0800)]
net: mark condFatalf as a test helper

Fixes unintended consequence of CL 76393

Change-Id: I7e4644a0bc6a8b37eb41196687d9661f902ba183
Reviewed-on: https://go-review.googlesource.com/76890
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
6 years agocmd/go: add go test -json flag
Russ Cox [Thu, 9 Nov 2017 03:03:19 +0000 (22:03 -0500)]
cmd/go: add go test -json flag

This CL finally adds one of our longest-requested cmd/go features:
a way for test-running harnesses to access test output in structured form.

In fact the structured json output is more informative than the text
output, because the output from multiple parallel tests can be
interleaved as it becomes available, instead of needing to wait for
the previous test to finish before showing any output from the
next test.

See CL 76872 for the conversion details.

Fixes #2981.

Change-Id: I749c4fc260190af9fe633437a781ec0cf56b7260
Reviewed-on: https://go-review.googlesource.com/76873
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/test2json: go tool test2json converts test output to JSON
Russ Cox [Thu, 9 Nov 2017 03:01:18 +0000 (22:01 -0500)]
cmd/test2json: go tool test2json converts test output to JSON

Also add cmd/internal/test2json, the actual implementation,
which will be called directly from cmd/go in addition to being
a standalone command (like cmd/buildid and cmd/internal/buildid).

For #2981.

Change-Id: I244ce36d665f424bbf13f5ae00ece10b705d367d
Reviewed-on: https://go-review.googlesource.com/76872
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/go: guarantee all test output is on stdout
Russ Cox [Fri, 10 Nov 2017 00:54:42 +0000 (19:54 -0500)]
cmd/go: guarantee all test output is on stdout

In past releases, whether test output appears on stdout or stderr
has varied depending on exactly how go test was invoked and
also (indefensibly) on the number of CPUs available.
Standardize on standard output for all test output.
This is easy to explain and makes go test | go tool test2json work nicely.

Change-Id: I605641213fbc6c7ff49e1fd38a0f732045a8383d
Reviewed-on: https://go-review.googlesource.com/76871
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/compile: replace opnames with stringer
Daniel Martí [Thu, 9 Nov 2017 23:10:43 +0000 (23:10 +0000)]
cmd/compile: replace opnames with stringer

Now possible, since stringer just got the -trimprefix flag added.

While at it, simplify a few Op stringifications since we can now use %v,
and no longer have to worry about o<len(opnames).

Passes toolstash -cmp on std cmd.

Fixes #15462.

Change-Id: Icdcde0b0a5eb165d18488918175024da274f782b
Reviewed-on: https://go-review.googlesource.com/76790
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
6 years agocmd/vet: don't warn on escaped newlines in Println
Daniel Martí [Tue, 7 Nov 2017 11:34:35 +0000 (11:34 +0000)]
cmd/vet: don't warn on escaped newlines in Println

The old code only worked for double-quoted strings, and only checked
that the end of the literal value was \n". This worked most of the time,
except for some strings like "foo\\n", which doesn't actually translate
into a trailing newline when unquoted.

To fix this, unquote the string first and look for a real newline at the
end of it. Ignore errors, as we don't have anything to do with string
literals using back quotes.

Fixes #22613.

Change-Id: I7cf96916dd578b7068216c2051ec2622cce0b740
Reviewed-on: https://go-review.googlesource.com/76194
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agonet/http: simplify ctx.Err() call in test
Sina Siadat [Tue, 17 Oct 2017 10:20:26 +0000 (13:50 +0330)]
net/http: simplify ctx.Err() call in test

See CL 40291. ctx.Err() is defined to only return non-nil exactly
when ctx.Done() returns a closed channel.

Change-Id: I12f51d8c42228f759273319b3ccc28012cb9fc73
Reviewed-on: https://go-review.googlesource.com/71310
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agonet: implement ReadMsg/WriteMsg on windows
Aman Gupta [Tue, 7 Nov 2017 18:19:10 +0000 (10:19 -0800)]
net: implement ReadMsg/WriteMsg on windows

This means {Read,Write}Msg{UDP,IP} now work on windows.

Fixes #9252

Change-Id: Ifb105f9ad18d61289b22d7358a95faabe73d2d02
Reviewed-on: https://go-review.googlesource.com/76393
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
6 years agonet/textproto: ignore initial lines with leading whitespaces in ReadMIMEHeader
Wèi Cōngruì [Thu, 2 Nov 2017 06:23:32 +0000 (14:23 +0800)]
net/textproto: ignore initial lines with leading whitespaces in ReadMIMEHeader

A header line with leading whitespaces is not valid in HTTP as per
RFC7230. This change ignores these invalid lines in ReadMIMEHeader.

Updates #22464

Change-Id: Iff9f00380d28a9617a55ff7888a76fba82001402
Reviewed-on: https://go-review.googlesource.com/75350
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agonet/http: fix copy-paste error in the ServeTLS docs
Ian Kent [Sat, 23 Sep 2017 20:45:35 +0000 (21:45 +0100)]
net/http: fix copy-paste error in the ServeTLS docs

Change-Id: Id7f0d978ce5b0471a404d6e6673b789e7db04650
Reviewed-on: https://go-review.googlesource.com/65653
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agotext/template: remove unnecessary lexer field
Ariel Mashraki [Sat, 1 Jul 2017 16:12:59 +0000 (19:12 +0300)]
text/template: remove unnecessary lexer field

this change removes the state field from the lexer,
because it's only used by the run method and can be
replaced with a local variable

Change-Id: Ib7a90ab6e9a894716cba2c7d9ed71bf2ad1240c0
Reviewed-on: https://go-review.googlesource.com/47338
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocrypto/subtle: simplify and speed up constant-time primitives
Bryan A Ford [Sat, 10 Jun 2017 07:34:40 +0000 (09:34 +0200)]
crypto/subtle: simplify and speed up constant-time primitives

This changes improves the ConstantTimeByteEq and ConstantTimeEq
primitives to both simplify them and improve their performance.

Also, since there were no benchmarks for this package before,
this change adds benchmarks for ConstantTimeByteEq,
ConstantTimeEq, and ConstantTimeLessOrEq.

benchmarks on darwin/amd64, 10 runs on old vs new code:

name                    old time/op  new time/op  delta
ConstantTimeByteEq-4    2.28ns ±16%  1.53ns ± 2%  -33.09%  (p=0.000 n=10+9)
ConstantTimeEq-4        2.77ns ±10%  1.51ns ± 2%  -45.59%  (p=0.000 n=10+9)
ConstantTimeLessOrEq-4  1.52ns ± 8%  1.50ns ± 2%     ~     (p=0.866 n=9+9)

Change-Id: I29b8cbcf158e1f30411720db82d38b4ecd166b15
Reviewed-on: https://go-review.googlesource.com/45310
Reviewed-by: Adam Langley <agl@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/vendor/.../pprof: do not run test that opens web browser
Russ Cox [Fri, 10 Nov 2017 01:38:11 +0000 (20:38 -0500)]
cmd/vendor/.../pprof: do not run test that opens web browser

Obviously not OK.

For #22651.

Change-Id: I4238045bec6e50788daaa27a7fbc1d547e72cde9
Reviewed-on: https://go-review.googlesource.com/76870
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/go: close unintentionally left open file
Alex Brainman [Thu, 9 Nov 2017 23:26:05 +0000 (10:26 +1100)]
cmd/go: close unintentionally left open file

cmd/go/internal/work.Builder.updateBuildID left a file opened.
But opened files cannot be deleted on Windows, so cmd/go just
leaves these files in %TMP% directory.

Close the file so deletion can succeed.

Fixes #22650

Change-Id: Ia3ea62f6ec7208d73972eae2e17fb4a766407914
Reviewed-on: https://go-review.googlesource.com/76810
Reviewed-by: Dave Cheney <dave@cheney.net>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agoarchive/zip: use Time.UTC instead of Time.In(time.UTC)
Joe Tsai [Fri, 10 Nov 2017 00:07:29 +0000 (16:07 -0800)]
archive/zip: use Time.UTC instead of Time.In(time.UTC)

The former is more succinct and readable.

Change-Id: Ic249d1261a705ad715aeb611c70c7fa91db98254
Reviewed-on: https://go-review.googlesource.com/76830
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/go: avoid crashing on 'go test -n'
Than McIntosh [Thu, 9 Nov 2017 20:41:45 +0000 (15:41 -0500)]
cmd/go: avoid crashing on 'go test -n'

Fix a buglet in the go command support for 'go test -n': check for
nil output buffer in action routine.

Fixes #22644

Change-Id: I2566e3bb3d53d0324c4ddd6fec5d30224bf290df
Reviewed-on: https://go-review.googlesource.com/76710
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agotext/template: remove unused lexer field
Ariel Mashraki [Tue, 18 Jul 2017 19:14:17 +0000 (22:14 +0300)]
text/template: remove unused lexer field

The lastPos field used in the past to track the line number of a token.
it's irrelevant anymore, and we can remove it.

Change-Id: I42c0bf55e884b79574a7da4926489f2d77618cd0
Reviewed-on: https://go-review.googlesource.com/49591
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/compile: remove unnecessary tmpdir in ssa_test
Cherry Zhang [Thu, 9 Nov 2017 19:28:02 +0000 (14:28 -0500)]
cmd/compile: remove unnecessary tmpdir in ssa_test

I added this in CL 76024 in order to do compile+link+run. This
is no longer necessary after CL 76551, which changed it back to
"go run". Remove it.

Change-Id: Ifa744d4b2f73f33cad056b24051821e43638cc7f
Reviewed-on: https://go-review.googlesource.com/76690
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/compile: do not write slices/strings > 2g
Jeff R. Allen [Wed, 8 Nov 2017 08:43:56 +0000 (09:43 +0100)]
cmd/compile: do not write slices/strings > 2g

The linker will refuse to work on objects larger than
2e9 bytes (see issue #9862 for why).

With this change, the compiler gives a useful error
message explaining this, instead of leaving it to the
linker to give a cryptic message later.

Fixes #1700.

Change-Id: I3933ce08ef846721ece7405bdba81dff644cb004
Reviewed-on: https://go-review.googlesource.com/74330
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/vendor/github.com/google/pprof: fix iOS builders
Alberto Donizetti [Thu, 9 Nov 2017 12:48:35 +0000 (13:48 +0100)]
cmd/vendor/github.com/google/pprof: fix iOS builders

The recent vendored pprof update broke the iOS builders. The issue was
reported and patched upstream. Re-vendor the internal pprof copy.

Updates vendored pprof to commit 9e20b5b106e946f4cd1df94c1f6fe3f88456628d
from github.com/google/pprof (2017-11-08).

Fixes #22612

Change-Id: I74c46c75e92ce401e605c55e27d8545c0d66082c
Reviewed-on: https://go-review.googlesource.com/76651
Reviewed-by: Elias Naur <elias.naur@gmail.com>
6 years agocmd/go: always update mtime during go install / go build -o / go test -c
Russ Cox [Wed, 8 Nov 2017 18:34:31 +0000 (13:34 -0500)]
cmd/go: always update mtime during go install / go build -o / go test -c

Even if the go command can see that the target is up-to-date
an mtime-based build system invoking the go command may not
be able to tell. Update the mtime to make clear that the target is
up-to-date, and also to hide exactly how smart the go command
is or is not. This keeps users (and programs) from depending on
the exact details of the go command's staleness determination.

Without this I believe we will get a stream of (completely reasonable)
bug reports that "go install (or go test -c) did not update the binary
after I trivially changed the source code or touched a source file".

Change-Id: I920e4aaed2a57319e3c0c37717f872bc059e484e
Reviewed-on: https://go-review.googlesource.com/76590
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
6 years agocmd/go: treat cached test results as satisfying any timeout
Russ Cox [Wed, 8 Nov 2017 16:54:34 +0000 (11:54 -0500)]
cmd/go: treat cached test results as satisfying any timeout

We want test caching to work even for people with scripts
that set a non-default test timeout. But then that raises the
question of what to do about runs with different timeouts:
is a cached success with one timeout available for use when
asked to run the test with a different timeout?

This CL answers that question by saying that the timeout applies
to the overall execution of either running the test or displaying
the cached result, and displaying a cached result takes no time.
So it's always OK to record a cached result, regardless of timeout,
and it's always OK to display a cached result, again regardless of timeout.

Fixes #22633.

Change-Id: Iaef3602710e3be107602267bbc6dba9a2250796c
Reviewed-on: https://go-review.googlesource.com/76552
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: roger peppe <rogpeppe@gmail.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
6 years agocmd/go: implement per-package asmflags, gcflags, ldflags, gccgoflags
Russ Cox [Wed, 8 Nov 2017 15:58:58 +0000 (10:58 -0500)]
cmd/go: implement per-package asmflags, gcflags, ldflags, gccgoflags

It has always been problematic that there was no way to specify
tool flags that applied only to the build of certain packages;
it was only to specify flags for all packages being built.
The usual workaround was to install all dependencies of something,
then build just that one thing with different flags. Since the
dependencies appeared to be up-to-date, they were not rebuilt
with the different flags. The new content-based staleness
(up-to-date) checks see through this trick, because they detect
changes in flags. This forces us to address the underlying problem
of providing a way to specify per-package flags.

The solution is to allow -gcflags=pattern=flags, which means
that flags apply to packages matching pattern, in addition to the
usual -gcflags=flags, which is now redefined to apply only to
the packages named on the command line.

See #22527 for discussion and rationale.

Fixes #22527.

Change-Id: I6716bed69edc324767f707b5bbf3aaa90e8e7302
Reviewed-on: https://go-review.googlesource.com/76551
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
6 years agocmd/go: move cfg.ExternalLinkingForced to internal/load
Russ Cox [Wed, 8 Nov 2017 01:39:54 +0000 (20:39 -0500)]
cmd/go: move cfg.ExternalLinkingForced to internal/load

It needs to refer to packages, so it can no longer be in cfg.
No semantic changes here.

Can now be unexported, so that was a net win anyway.

Change-Id: I58bf6cdcd435e6e019291bb8dcd5d5b7f1ac03a3
Reviewed-on: https://go-review.googlesource.com/76550
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
6 years agocrypto/tls: limit number of consecutive warning alerts
filewalkwithme [Fri, 3 Nov 2017 02:45:04 +0000 (03:45 +0100)]
crypto/tls: limit number of consecutive warning alerts

In the current implementation, it is possible for a client to
continuously send warning alerts, which are just dropped on the floor
inside readRecord.

This can enable scenarios in where someone can try to continuously
send warning alerts to the server just to keep it busy.

This CL implements a simple counter that triggers an error if
we hit the warning alert limit.

Fixes #22543

Change-Id: Ief0ca10308cf5a4dea21a5a67d3e8f6501912da6
Reviewed-on: https://go-review.googlesource.com/75750
Reviewed-by: Adam Langley <agl@golang.org>
Reviewed-by: Filippo Valsorda <hi@filippo.io>
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/compile: adjust Pos setting for "empty" blocks
David Chase [Sun, 29 Oct 2017 15:53:18 +0000 (11:53 -0400)]
cmd/compile: adjust Pos setting for "empty" blocks

Plain blocks that contain only uninteresting instructions
(that do not have reliable Pos information themselves)
need to have their Pos left unset so that they can
inherit it from their successors.  The "uninteresting"
test was not properly applied and not properly defined.
OpFwdRef does not appear in the ssa.html debugging output,
but at the time of the test these instructions did appear,
and it needs to be part of the test.

Fixes #22365.

Change-Id: I99e5b271acd8f6bcfe0f72395f905c7744ea9a02
Reviewed-on: https://go-review.googlesource.com/74252
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agocrypto/tls: advertise support for SHA-512 signatures in 1.2
Filippo Valsorda [Tue, 31 Oct 2017 23:43:05 +0000 (19:43 -0400)]
crypto/tls: advertise support for SHA-512 signatures in 1.2

This is the equivalent change to 1c105980 but for SHA-512.

SHA-512 certificates are already supported by default since b53bb2ca,
but some servers will refuse connections if the algorithm is not
advertised in the overloaded signatureAndHash extension (see 09b238f1).

This required adding support for SHA-512 signatures on CertificateVerify
and ServerKeyExchange messages, because of said overloading.

Some testdata/Client-TLSv1{0,1} files changed because they send a 1.2
ClientHello even if the server picks a lower version.

Closes #22422

Change-Id: I16282d03a3040260d203711ec21e6b20a0e1e105
Reviewed-on: https://go-review.googlesource.com/74950
Run-TryBot: Filippo Valsorda <hi@filippo.io>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
6 years agostrings: optimize ToLower
Agniva De Sarker [Wed, 8 Nov 2017 03:45:53 +0000 (09:15 +0530)]
strings: optimize ToLower

Handling the ASCII case inline and call unicode.ToLower only
for non-ASCII cases.

Gives good improvements for the ASCII case and minor perf
degrade for non-ASCII case

name                                     old time/op    new time/op    delta
ToLower/#00                                10.8ns ± 1%     9.0ns ± 1%  -16.83%  (p=0.008 n=5+5)
ToLower/abc                                23.3ns ± 4%    12.6ns ± 1%  -46.01%  (p=0.008 n=5+5)
ToLower/AbC123                             91.0ns ± 2%    70.4ns ± 0%  -22.59%  (p=0.008 n=5+5)
ToLower/azAZ09_                             104ns ± 3%      75ns ± 1%  -28.35%  (p=0.008 n=5+5)
ToLower/longStrinGwitHmixofsmaLLandcAps     254ns ± 4%     157ns ± 0%  -38.19%  (p=0.016 n=5+4)
ToLower/LONGⱯSTRINGⱯWITHⱯNONASCIIⱯCHARS     446ns ± 1%     451ns ± 1%     ~     (p=0.056 n=5+5)
ToLower/ⱭⱭⱭⱭⱭ                               345ns ± 1%     348ns ± 0%   +0.93%  (p=0.016 n=5+5)

name                                     old alloc/op   new alloc/op   delta
ToLower/#00                                 0.00B          0.00B          ~     (all equal)
ToLower/abc                                 0.00B          0.00B          ~     (all equal)
ToLower/AbC123                              16.0B ± 0%     16.0B ± 0%     ~     (all equal)
ToLower/azAZ09_                             24.0B ± 0%     16.0B ± 0%  -33.33%  (p=0.008 n=5+5)
ToLower/longStrinGwitHmixofsmaLLandcAps     80.0B ± 0%     64.0B ± 0%  -20.00%  (p=0.008 n=5+5)
ToLower/LONGⱯSTRINGⱯWITHⱯNONASCIIⱯCHARS     96.0B ± 0%     96.0B ± 0%     ~     (all equal)
ToLower/ⱭⱭⱭⱭⱭ                               48.0B ± 0%     48.0B ± 0%     ~     (all equal)

Ran on a machine with Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz

Fixes #17859

Change-Id: Iacc1e6b77e1aedba9447a6e94352606f131ea597
Reviewed-on: https://go-review.googlesource.com/76470
Reviewed-by: Marvin Stenger <marvin.stenger94@gmail.com>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
6 years agocmd/compile: optimize noding of long summation expressions
Matthew Dempsky [Tue, 7 Nov 2017 23:55:26 +0000 (15:55 -0800)]
cmd/compile: optimize noding of long summation expressions

Fixes #16394.

Change-Id: I7108c9e8e67d86678bdb6015f0862e5c92bcf911
Reviewed-on: https://go-review.googlesource.com/76450
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agoencoding/json: permit encoding uintptr as a string
Ian Lance Taylor [Wed, 8 Nov 2017 15:16:07 +0000 (07:16 -0800)]
encoding/json: permit encoding uintptr as a string

Fixes #22629

Change-Id: I31e85f9faa125ee0dfd6d3c5fa89334b00d61e6e
Reviewed-on: https://go-review.googlesource.com/76530
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Joe Tsai <joetsai@google.com>
6 years agoencoding/xml: add Marshal doc about name conflicts
Leigh McCulloch [Tue, 7 Nov 2017 05:33:35 +0000 (05:33 +0000)]
encoding/xml: add Marshal doc about name conflicts

The docs for xml.Marshal state that the XML elements name is derived
from one of five locations in a specific order of precedence, but does
not mention that if the field is a struct type and has its name defined
in a tag and in the types XMLName field that an error will occur. This
is documented in the structFieldInfo function but not in the function
documentation, and the existing docs in Marshal are misleading without
this behavior being discussed.

Fixes #18564

Change-Id: I29042f124a534bd1bc993f1baeddaa0af2e72fed
Reviewed-on: https://go-review.googlesource.com/76321
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agovendor: add golang.org/x/crypto/cryptobyte
Adam Langley [Mon, 30 Oct 2017 00:43:53 +0000 (17:43 -0700)]
vendor: add golang.org/x/crypto/cryptobyte

This change adds the cryptobyte package from x/crypto at git revision
faadfbdc035307d901e69eea569f5dda451a3ee3.

Updates #22616, #15196

Change-Id: Iffd0b022ca129d340ef429697e05b581f04e5c4f
Reviewed-on: https://go-review.googlesource.com/74270
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/go: don't run TestUserOverrideFlags in parallel
Ian Lance Taylor [Tue, 7 Nov 2017 23:03:53 +0000 (15:03 -0800)]
cmd/go: don't run TestUserOverrideFlags in parallel

It creates files in the cmd/go directory, which can confuse other tests.

Fixes #22584.

Change-Id: Iad5a25c62e7d413af1648dbc5359ed78bfd61d2a
Reviewed-on: https://go-review.googlesource.com/76398
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocrypto/x509: enforce EKU nesting at chain-construction time.
Adam Langley [Sun, 15 Oct 2017 19:21:00 +0000 (12:21 -0700)]
crypto/x509: enforce EKU nesting at chain-construction time.

crypto/x509 has always enforced EKUs as a chain property (like CAPI, but
unlike the RFC). With this change, EKUs will be checked at
chain-building time rather than in a target-specific way.

Thus mis-nested EKUs will now cause a failure in Verify, irrespective of
the key usages requested in opts. (This mirrors the new behaviour w.r.t.
name constraints, where an illegal name in the leaf will cause a Verify
failure, even if the verified name is permitted.).

Updates #15196

Change-Id: Ib6a15b11a9879a9daf5b1d3638d5ebbbcac506e5
Reviewed-on: https://go-review.googlesource.com/71030
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/compile: don't put Noalg types in typelinks
Ian Lance Taylor [Tue, 7 Nov 2017 02:51:12 +0000 (18:51 -0800)]
cmd/compile: don't put Noalg types in typelinks

They could get picked up by reflect code, yielding the wrong type.

Fixes #22605

Change-Id: Ie11fb361ca7f3255e662037b3407565c8f0a2c4c
Reviewed-on: https://go-review.googlesource.com/76315
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
6 years agocmd/dist: correct default C++ compiler when using gcc
Ian Lance Taylor [Tue, 7 Nov 2017 21:56:05 +0000 (13:56 -0800)]
cmd/dist: correct default C++ compiler when using gcc

Fixes #22609

Change-Id: Ic948345e7d1623a7defee6a6493eb81fe7393111
Reviewed-on: https://go-review.googlesource.com/76396
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/vet: change docs to prefer "go vet" over "go tool vet"
Ian Lance Taylor [Tue, 7 Nov 2017 15:53:55 +0000 (07:53 -0800)]
cmd/vet: change docs to prefer "go vet" over "go tool vet"

Updates #22530

Change-Id: I161b5e706483744321e6089f747bd761310774eb
Reviewed-on: https://go-review.googlesource.com/76390
Reviewed-by: Rob Pike <r@golang.org>
6 years agosyscall: change SysProcAttr.Token type to Token
Alex Brainman [Tue, 7 Nov 2017 01:09:59 +0000 (12:09 +1100)]
syscall: change SysProcAttr.Token type to Token

CL 75253 introduced new SysProcAttr.Token field as Handle.
But we already have exact type for it - Token. Use Token
instead of Handle everywhere - it saves few type conversions
and provides better documentation for new API.

Change-Id: Ibc5407a234a1f49804de15a24b27c8e6a6eba7e0
Reviewed-on: https://go-review.googlesource.com/76314
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agonet: use WSASocket instead of socket call
Alex Brainman [Mon, 23 Oct 2017 05:23:43 +0000 (16:23 +1100)]
net: use WSASocket instead of socket call

WSASocket (unlike socket call) allows to create sockets that
will not be inherited by child process. So call WSASocket to
save on using syscall.ForkLock and calling syscall.CloseOnExec.

Some very old versions of Windows do not have that functionality.
Call socket, if WSASocket failed, to support these.

Change-Id: I2dab9fa00d1a8609dd6feae1c9cc31d4e55b8cb5
Reviewed-on: https://go-review.googlesource.com/72590
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocrypto/x509: enforce all name constraints and support IP, email and URI constraints
Adam Langley [Sun, 10 Sep 2017 00:05:41 +0000 (17:05 -0700)]
crypto/x509: enforce all name constraints and support IP, email and URI constraints

This change makes crypto/x509 enforce name constraints for all names in
a leaf certificate, not just the name being validated. Thus, after this
change, if a certificate validates then all the names in it can be
trusted – one doesn't have a validate again for each interesting name.

Making extended key usage work in this fashion still remains to be done.

Updates #15196

Change-Id: I72ed5ff2f7284082d5bf3e1e86faf76cef62f9b5
Reviewed-on: https://go-review.googlesource.com/62693
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agoarchive/tar: a cosmetic fix after checking by golint
Stanislav Afanasev [Tue, 7 Nov 2017 19:43:44 +0000 (22:43 +0300)]
archive/tar: a cosmetic fix after checking by golint

Existing methods regFileReader.LogicalRemaining and regFileReader.PhysicalRemaining have inconsistent reciever names with the previous name

Change-Id: Ief2024716737eaf482c4311f3fdf77d92801c36e
Reviewed-on: https://go-review.googlesource.com/76430
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>

6 years agostrings: optimize ToUpper
Agniva De Sarker [Thu, 28 Sep 2017 09:37:48 +0000 (15:07 +0530)]
strings: optimize ToUpper

Handling the ASCII case inline and call unicode.ToUpper only
for non-ascii cases.

Gives good improvements for the ascii case and minor perf
degrade for non-ascii case

name                                     old time/op    new time/op    delta
ToUpper/#00                                11.7ns ± 8%     8.0ns ± 1%  -31.95%  (p=0.008 n=5+5)
ToUpper/ONLYUPPER                          45.6ns ± 5%    19.9ns ± 1%  -56.40%  (p=0.008 n=5+5)
ToUpper/abc                                77.4ns ± 1%    57.0ns ± 1%  -26.32%  (p=0.008 n=5+5)
ToUpper/AbC123                             92.1ns ± 4%    67.7ns ± 2%  -26.57%  (p=0.008 n=5+5)
ToUpper/azAZ09_                             105ns ± 6%      67ns ± 2%  -36.26%  (p=0.000 n=5+4)
ToUpper/longStrinGwitHmixofsmaLLandcAps     255ns ± 1%     140ns ± 1%  -45.01%  (p=0.029 n=4+4)
ToUpper/longɐstringɐwithɐnonasciiⱯchars     440ns ± 1%     447ns ± 0%   +1.49%  (p=0.016 n=5+4)
ToUpper/ɐɐɐɐɐ                               370ns ± 4%     366ns ± 1%     ~     (p=0.667 n=5+5)

name                                     old alloc/op   new alloc/op   delta
ToUpper/#00                                 0.00B          0.00B          ~     (all equal)
ToUpper/ONLYUPPER                           0.00B          0.00B          ~     (all equal)
ToUpper/abc                                 16.0B ± 0%      6.0B ± 0%  -62.50%  (p=0.008 n=5+5)
ToUpper/AbC123                              16.0B ± 0%     16.0B ± 0%     ~     (all equal)
ToUpper/azAZ09_                             24.0B ± 0%     16.0B ± 0%  -33.33%  (p=0.008 n=5+5)
ToUpper/longStrinGwitHmixofsmaLLandcAps     80.0B ± 0%     64.0B ± 0%  -20.00%  (p=0.008 n=5+5)
ToUpper/longɐstringɐwithɐnonasciiⱯchars     96.0B ± 0%     96.0B ± 0%     ~     (all equal)
ToUpper/ɐɐɐɐɐ                               64.0B ± 0%     64.0B ± 0%     ~     (all equal)

Ran on a machine with Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz

Updates #17859

Change-Id: I0735ac4a4a36e8a8f6cc06f2c16b871f12b4abf9
Reviewed-on: https://go-review.googlesource.com/68370
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agoruntime: flush assist credit on goroutine exit
Austin Clements [Fri, 1 Jul 2016 15:31:04 +0000 (11:31 -0400)]
runtime: flush assist credit on goroutine exit

Currently dead goroutines retain their assist credit. This credit can
be used if the goroutine gets recycled, but in general this can make
assist pacing over-aggressive by hiding an amount of credit
proportional to the number of exited (and not reused) goroutines.

Fix this "hidden credit" by flushing assist credit to the global
credit pool when a goroutine exits.

Updates #14812.

Change-Id: I65f7f75907ab6395c04aacea2c97aea963b60344
Reviewed-on: https://go-review.googlesource.com/24703
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
6 years agoruntime: only call netpoll if netpollinited returns true
Ian Lance Taylor [Tue, 7 Nov 2017 04:51:36 +0000 (20:51 -0800)]
runtime: only call netpoll if netpollinited returns true

This fixes a race on old Linux kernels, in which we might temporarily
set epfd to an invalid value other than -1. It's also the right thing
to do. No test because the problem only occurs on old kernels.

Fixes #22606

Change-Id: Id84bdd6ae6d7c5d47c39e97b74da27576cb51a54
Reviewed-on: https://go-review.googlesource.com/76319
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
6 years agocmd/compile: fix SSA immediate sign extension on s390x
Michael Munday [Tue, 7 Nov 2017 09:40:56 +0000 (04:40 -0500)]
cmd/compile: fix SSA immediate sign extension on s390x

The CMPWUconst op (32-bit unsigned comparison with immediate) takes
an unsigned immediate value. In SSA this should be sign extended to
64-bits to match the Int32 type given in the op and then zero
extended when producing the final assembly. Before this CL we were
zero extending in SSA which caused ssacheck to fail.

While we are here also ensure other 32-bit immediates are sign
extended in SSA.

Passes toolstash -cmp on std on s390x.

Fixes #22611.

Change-Id: I5c061a76a710b10ecb0650c9c42efd9fa1c123cc
Reviewed-on: https://go-review.googlesource.com/76336
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agoruntime/pprof: harden CPU profile test against smart backend
Than McIntosh [Mon, 6 Nov 2017 20:33:31 +0000 (15:33 -0500)]
runtime/pprof: harden CPU profile test against smart backend

A couple of the CPU profiling testpoints make calls to helper
functions (cpuHog1, for example) where the computed value is always
thrown away by the caller without being used. A smart compiler back
end (in this case LLVM) can detect this fact and delete the contents
of the called function, which can cause tests to fail. Harden the test
slighly by passing in a value read from a global and insuring that the
caller stores the value back to a global; this prevents any optimizer
mischief.

Change-Id: Icbd6e3e32ff299c68a6397dc1404a52b21eaeaab
Reviewed-on: https://go-review.googlesource.com/76230
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
6 years agocmd/go: accept relative -pkgdir argument
Russ Cox [Mon, 6 Nov 2017 20:43:47 +0000 (15:43 -0500)]
cmd/go: accept relative -pkgdir argument

Fixes #21309.

Change-Id: I8ff1b0f37e34a3a4e9f8448d66a64fe3863d081f
Reviewed-on: https://go-review.googlesource.com/76250
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/go: include package source dir in build action for non-GOROOT packages
Russ Cox [Mon, 6 Nov 2017 15:16:34 +0000 (10:16 -0500)]
cmd/go: include package source dir in build action for non-GOROOT packages

The package source dir is recorded in the archives,
so it must be recorded in the build action hash too.

Fixes #22596.

Change-Id: I1d3c2523181c302e9917e5fb79c26b00ea03077a
Reviewed-on: https://go-review.googlesource.com/76025
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
6 years agocmd/compile/internal/syntax: better syntax errors for typos in if/switch/for headers
griesemer [Mon, 6 Nov 2017 23:01:33 +0000 (15:01 -0800)]
cmd/compile/internal/syntax: better syntax errors for typos in if/switch/for headers

Be more pessimistic when parsing if/switch/for headers for better error
messages when things go wrong.

Fixes #22581.

Change-Id: Ibb99925291ff53f35021bc0a59a4c9a7f695a194
Reviewed-on: https://go-review.googlesource.com/76290
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
6 years agoruntime: improve IndexByte for ppc64x
Carlos Eduardo Seo [Mon, 7 Aug 2017 18:44:38 +0000 (15:44 -0300)]
runtime: improve IndexByte for ppc64x

This change adds a better implementation of IndexByte in asm that uses the
vector registers/instructions on ppc64x.

benchmark                            old ns/op     new ns/op     delta
BenchmarkIndexByte/10-8              9.70          9.37          -3.40%
BenchmarkIndexByte/32-8              10.9          10.9          +0.00%
BenchmarkIndexByte/4K-8              254           92.8          -63.46%
BenchmarkIndexByte/4M-8              249246        118435        -52.48%
BenchmarkIndexByte/64M-8             10737987      7383096       -31.24%

benchmark                            old MB/s     new MB/s     speedup
BenchmarkIndexByte/10-8              1030.63      1067.24      1.04x
BenchmarkIndexByte/32-8              2922.69      2928.53      1.00x
BenchmarkIndexByte/4K-8              16065.95     44156.45     2.75x
BenchmarkIndexByte/4M-8              16827.96     35414.21     2.10x
BenchmarkIndexByte/64M-8             6249.67      9089.53      1.45x

Change-Id: I81dbdd620f7bb4e395ce4d1f2a14e8e91e39f9a1
Reviewed-on: https://go-review.googlesource.com/71710
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
6 years agoarchive/zip: add FileHeader.NonUTF8 field
Joe Tsai [Thu, 2 Nov 2017 20:53:16 +0000 (13:53 -0700)]
archive/zip: add FileHeader.NonUTF8 field

The NonUTF8 field provides users with a way to explictly tell the
ZIP writer to avoid setting the UTF-8 flag.
This is necessary because many readers:
1) (Still) do not support UTF-8
2) And use the local system encoding instead

Thus, even though character encodings other than CP-437 and UTF-8
are not officially supported by the ZIP specification, pragmatically
the world has permitted use of them.

When a non-standard encoding is used, it is the user's responsibility
to ensure that the target system is expecting the encoding used
(e.g., producing a ZIP file you know is used on a Chinese version of Windows).

We adjust the detectUTF8 function to account for Shift-JIS and EUC-KR
not being identical to ASCII for two characters.

We don't need an API for users to explicitly specify that they are encoding
with UTF-8 since all single byte characters are compatible with all other
common encodings (Windows-1256, Windows-1252, Windows-1251, Windows-1250,
IEC-8859, EUC-KR, KOI8-R, Latin-1, Shift-JIS, GB-2312, GBK) except for
the non-printable characters and the backslash character (all of which
are invalid characters in a path name anyways).

Fixes #10741

Change-Id: I9004542d1d522c9137973f1b6e2b623fa54dfd66
Reviewed-on: https://go-review.googlesource.com/75592
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/compile: lock in test for column numbers in unused error
Emmanuel Odeke [Mon, 6 Nov 2017 08:32:55 +0000 (01:32 -0700)]
cmd/compile: lock in test for column numbers in unused error

Updates #21317

@mdempsky fixed issue #21317 with CL 66810,
so lock a test in to ensure we don't regress.

The test is manual for now before test/run.go
has support for matching column numbers so do
it old school and match expected output after
an exec.

Change-Id: I6c2a66ddf04248f79d17ed7033a3280d50e41562
Reviewed-on: https://go-review.googlesource.com/76150
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/compile: []T where T is go:notinheap does not need write barriers
Austin Clements [Thu, 2 Nov 2017 16:37:25 +0000 (12:37 -0400)]
cmd/compile: []T where T is go:notinheap does not need write barriers

Currently, assigning a []T where T is a go:notinheap type generates an
unnecessary write barrier for storing the slice pointer.

This fixes this by teaching HasHeapPointer that this type does not
have a heap pointer, and tweaking the lowering of slice assignments so
the pointer store retains the correct type rather than simply lowering
it to a *uint8 store.

Change-Id: I8bf7c66e64a7fefdd14f2bd0de8a5a3596340bab
Reviewed-on: https://go-review.googlesource.com/76027
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/dist: include "cmd/buildid" in toolchain in debug mode
Cherry Zhang [Mon, 6 Nov 2017 17:40:49 +0000 (12:40 -0500)]
cmd/dist: include "cmd/buildid" in toolchain in debug mode

Fixes #22599.

Change-Id: I2d59a8fae457881f681184fc6ed1f2aa597699b3
Reviewed-on: https://go-review.googlesource.com/76026
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/dist: do not reinstall runtime/cgo with -tags lldb on ios builders
Russ Cox [Mon, 6 Nov 2017 00:36:35 +0000 (19:36 -0500)]
cmd/dist: do not reinstall runtime/cgo with -tags lldb on ios builders

The cache will take care of keeping go test -tags lldb fast.
Installing runtime/cgo this way just makes all the checkNotStale
tests think runtime/cgo is out of date.

Should fix ios builders.

Fixes #22509.

Change-Id: If092cc4feb189eb848b6a22f6d22b89b70df219c
Reviewed-on: https://go-review.googlesource.com/76020
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
6 years agocmd/dist, cmd/go: make GODEBUG=godebughash=1 ./make.bash work better
Russ Cox [Mon, 6 Nov 2017 00:35:14 +0000 (19:35 -0500)]
cmd/dist, cmd/go: make GODEBUG=godebughash=1 ./make.bash work better

The change in cmd/dist ignores debug output, instead of assuming
any output is from the template.

The change in cmd/go makes the debug output show the package name
on every line, so that interlaced prints can be deinterlaced.

Change-Id: Ic3d59ee0256271067cb9be2fde643a0e19405375
Reviewed-on: https://go-review.googlesource.com/76019
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
6 years agocmd/dist, cmd/cgo, cmd/go: allow per-goos/goarch default CC
Russ Cox [Sun, 5 Nov 2017 22:09:54 +0000 (17:09 -0500)]
cmd/dist, cmd/cgo, cmd/go: allow per-goos/goarch default CC

Even though cmd/dist has historically distinguished "CC for gohostos/gohostarch"
from "CC for target goos/goarch", it has not recorded that distinction
for later use by cmd/cgo and cmd/go. Now that content-based staleness
includes the CC setting in the decision about when to rebuild packages,
the go command needs to know the details of which CC to use when.
Otherwise lots of things look out of date and (worse) may be rebuilt with
the wrong CC.

A related issue is that users may want to be able to build a toolchain
capable of cross-compiling for two different non-host targets, and
to date we've required that CC_FOR_TARGET apply to both.
This CL introduces CC_FOR_${GOOS}_${GOARCH}, so that you can
(for example) set CC_FOR_linux_arm and CC_FOR_linux_arm64
separately on a linux/ppc64 host and be able to cross-compile to
either arm or arm64 with the right toolchain.

Fixes #8161.
Half of a fix for #22509.

Change-Id: I7a43769f39d859f659d31bc96980918ba102fb83
Reviewed-on: https://go-review.googlesource.com/76018
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
6 years agocmd/go: ignore stderr from tool version checks
Russ Cox [Sun, 5 Nov 2017 21:31:24 +0000 (16:31 -0500)]
cmd/go: ignore stderr from tool version checks

There are multiple valid reasons a tool might print to stderr.
As long as we get the expected output on stdout, that's fine.

Fixes #22588.

Change-Id: I9c5d32da08288cb26dd575530a8257cd5f375367
Reviewed-on: https://go-review.googlesource.com/76017
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
6 years agocmd/go: do not use cache when -a is specified
Russ Cox [Sun, 5 Nov 2017 21:25:00 +0000 (16:25 -0500)]
cmd/go: do not use cache when -a is specified

Clearly -a means don't use the cache.
An oversight that it did.

Fixes #22586.

Change-Id: I250b351439bd3fb5f8d6efc235b614f0a75ca64c
Reviewed-on: https://go-review.googlesource.com/76016
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
6 years agocmd/go: drop runtime, runtime/internal/sys, runtime/internal/atomic, unsafe as deps...
Russ Cox [Sun, 5 Nov 2017 21:22:02 +0000 (16:22 -0500)]
cmd/go: drop runtime, runtime/internal/sys, runtime/internal/atomic, unsafe as deps of everything

This was a hack to make a new make.bash avoid reusing installed packages.
The new content-based staleness is precise enough not to need this hack;
now it's just causing unnecessary rebuilds: if a package doesn't import "runtime",
for example, it doesn't need to be recompiled when runtime changes.
(It does need to be relinked, and we still arrange that.)

Change-Id: I4ddf6e16d754cf21b16e9db1ed52bddbf82e96c6
Reviewed-on: https://go-review.googlesource.com/76015
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
6 years agocmd/compile: enable ssacheck for tests in ssa_test.go
Cherry Zhang [Mon, 6 Nov 2017 15:47:02 +0000 (10:47 -0500)]
cmd/compile: enable ssacheck for tests in ssa_test.go

I thought SSA check was enabled for those tests, but in fact it
was not. Enable it. So we have SSA check on for at least some
tests on all architectures.

Updates #22499.

Change-Id: I51fcdda3af7faab5aeb33bf46c6db309285ce42c
Reviewed-on: https://go-review.googlesource.com/76024
Reviewed-by: Keith Randall <khr@golang.org>
6 years agoarchive/zip: add FileHeader.Modified field
Joe Tsai [Mon, 28 Aug 2017 19:07:58 +0000 (12:07 -0700)]
archive/zip: add FileHeader.Modified field

The ModifiedTime and ModifiedDate fields are not expressive enough
for many of the time extensions that have since been added to ZIP,
nor are they easy to access since they in a legacy MS-DOS format,
and must be set and retrieved via the SetModTime and ModTime methods.

Instead, we add new field Modified of time.Time type that contains
all of the previous information and more.

Support for extended timestamps have been attempted before, but the
change was reverted because it provided no ability for the user to
specify the timezone of the legacy MS-DOS fields.
Technically the old API did not either, but users were manually offsetting
the timestamp to achieve the same effect.

The Writer now writes the legacy timestamps according to the timezone
of the FileHeader.Modified field. When the Modified field is set via
the SetModTime method, it is in UTC, which preserves the old behavior.

The Reader attempts to determine the timezone if both the legacy
and extended timestamps are present since it can compute the delta
between the two values.

Since Modified is a superset of the information in ModifiedTime and ModifiedDate,
we mark ModifiedTime, ModifiedDate, ModTime, and SetModTime as deprecated.

Fixes #18359

Change-Id: I29c6bc0a62908095d02740df3e6902f50d3152f1
Reviewed-on: https://go-review.googlesource.com/74970
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agostrings: add Builder
Caleb Spare [Tue, 31 Oct 2017 23:51:21 +0000 (16:51 -0700)]
strings: add Builder

This is like a write-only subset of bytes.Buffer with an
allocation-free String method.

Fixes #18990.

Change-Id: Icdf7240f4309a52924dc3af04a39ecd737a210f4
Reviewed-on: https://go-review.googlesource.com/74931
Run-TryBot: Caleb Spare <cespare@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agotime: example in doc for time.AppendFormat func
Radek Sohlich [Fri, 3 Nov 2017 19:36:12 +0000 (20:36 +0100)]
time: example in doc for time.AppendFormat func

The simple example would contribute to better understanding
what function does.

Change-Id: I36a2952df8b0e1762ec0cd908a867c457f39366e
Reviewed-on: https://go-review.googlesource.com/75970
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agosyscall: fix NaCl Link syscall error handling
Tim Wright [Sun, 5 Nov 2017 02:35:23 +0000 (19:35 -0700)]
syscall: fix NaCl Link syscall error handling

The existing NaCl filesystem Link system call erroneously allowed
a caller to call Link on an existing target which violates the POSIX
standard and effectively corrupted the internal filesystem
representation.

Fixes #22383

Change-Id: I77b16c37af9bf00a1799fa84277f066180edac47
Reviewed-on: https://go-review.googlesource.com/76110
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agomath/big: add security warning to (*Int).Rand
Filippo Valsorda [Sun, 5 Nov 2017 19:33:21 +0000 (14:33 -0500)]
math/big: add security warning to (*Int).Rand

Change-Id: I22a67733aa2d07298e124077654c9b1473802100
Reviewed-on: https://go-review.googlesource.com/76012
Reviewed-by: Aliaksandr Valialkin <valyala@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/go: fix corner case missed rebuild of binary
Russ Cox [Sun, 5 Nov 2017 21:09:46 +0000 (16:09 -0500)]
cmd/go: fix corner case missed rebuild of binary

If the only thing changing in the binary is the embedded main.a action ID,
go install was declining to install the binary, but go list could see that the
binary needed reinstalling (was stale).

Fixes #22531.

Change-Id: I4a53b0ebd4c34aad907bab7da571fada545f3c6f
Reviewed-on: https://go-review.googlesource.com/76014
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
6 years agocmd/dist: read dependencies from source files
Russ Cox [Mon, 6 Nov 2017 01:30:35 +0000 (20:30 -0500)]
cmd/dist: read dependencies from source files

I do not remember why we require deps.go to have a hard-coded
copy of the dependency information for cmd/go, when we can
read it from the source files instead. The answer probably involves
cmd/dist once being a C program.

In any event, stop doing that, which will eliminate the builder-only
failures in the builder-only deps test.

Change-Id: I0abd384c47401940ca08427b5be544812edcbe7f
Reviewed-on: https://go-review.googlesource.com/76021
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
6 years agocmd/go: do not print entire help text for unrecognized flag
Russ Cox [Sat, 4 Nov 2017 17:14:19 +0000 (13:14 -0400)]
cmd/go: do not print entire help text for unrecognized flag

I typed 'go list -josn' without realizing I'd mistyped json, and I was confused for
quite a while as to why I was staring at the 'go help json' text: the actual problem
(a missing flag) scrolls far off the screen. If people want the full text, they can
easily ask for it, but don't drown the important bit - unrecognized flag or other
improper usage - with pages of supporting commentary. The help text does not
help people who just need to be told about a typo.

Change-Id: I179c431baa831e330f3ee495ce0a5369319962d5
Reviewed-on: https://go-review.googlesource.com/76013
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/compile: test for omitted ICE diagnostics after normal messages
Emmanuel Odeke [Tue, 31 Oct 2017 05:44:14 +0000 (22:44 -0700)]
cmd/compile: test for omitted ICE diagnostics after normal messages

Updates #22389

@mdempsky's CL 70850 fixed the unnecessary
compile stack trace printing during ICE diagnostics.

This CL adds a test to lock in this behavior.

Change-Id: I9ce49923c80b78cb8c0bb5dc4af3c860a43d63ba
Reviewed-on: https://go-review.googlesource.com/74630
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
6 years agocrypto/aes: use s390x KMA instruction for AES-GCM if available
Michael Munday [Fri, 31 Mar 2017 15:08:40 +0000 (11:08 -0400)]
crypto/aes: use s390x KMA instruction for AES-GCM if available

Adds support for the cipher message with authentication (KMA)
instruction added in message-security-assist extension 8. This
instruction encapsulates most of the operations required for
AES-GCM and is faster than executing the operations independently.

name          old speed      new speed       delta
AESGCMSeal1K  1.96GB/s ± 0%   6.79GB/s ± 0%  +246.47%  (p=0.000 n=8+10)
AESGCMOpen1K  1.85GB/s ± 0%   5.76GB/s ± 0%  +211.18%  (p=0.000 n=10+10)
AESGCMSign8K  12.0GB/s ± 0%   14.5GB/s ± 0%   +20.43%  (p=0.000 n=10+8)
AESGCMSeal8K  3.75GB/s ± 0%  14.16GB/s ± 0%  +277.57%  (p=0.000 n=9+10)
AESGCMOpen8K  3.70GB/s ± 0%  13.57GB/s ± 0%  +266.50%  (p=0.000 n=10+9)

Change-Id: I57c46573fc5a0bd63c32ce5cba6e37cab85e3de6
Reviewed-on: https://go-review.googlesource.com/73550
Run-TryBot: Michael Munday <mike.munday@ibm.com>
Reviewed-by: Bill O'Farrell <billotosyr@gmail.com>
Reviewed-by: Volodymyr Paprotski <paprots@gmail.com>
Reviewed-by: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agoos: fix RemoveAll on large directories on Plan 9 and NaCl
David du Colombier [Mon, 6 Nov 2017 06:35:42 +0000 (07:35 +0100)]
os: fix RemoveAll on large directories on Plan 9 and NaCl

On Plan 9, some file servers, like ramfs, handle the read
offset when reading directories. However, the offset isn't
valid anymore after directory entries have been removed
between successive calls to read.

This issue happens when os.RemoveAll is called on a
directory that doesn't fit on a single 9P response message.

In this case, the first part of the directory is read,
then directory entries are removed and the second read
will be incomplete because the read offset won't be valid
anymore. Consequently, the content of the directory will
only be partially removed.

We change RemoveAll to call fd.Seek(0, 0) before calling
fd.Readdirnames, so the read offset will always be reset
after removing the directory entries.

After adding TestRemoveAllLarge, we noticed the same issue
appears on NaCl and the same fix applies as well.

Fixes #22572.

Change-Id: Ifc76ea7ccaf0168c34dc8ec0f400dc04db1baf8f
Reviewed-on: https://go-review.googlesource.com/75974
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocrypto/x509/pkix: consider now==NextUpdate to be expired.
Anmol Sethi [Thu, 19 Oct 2017 22:29:43 +0000 (18:29 -0400)]
crypto/x509/pkix: consider now==NextUpdate to be expired.

If the current time is equal to the NextUpdate time, then the CRL
should be considered expired.

Fixes #22568.

Change-Id: I55bcc95c881097e826d43eb816a43b9b377b0265
Reviewed-on: https://go-review.googlesource.com/71972
Reviewed-by: Adam Langley <agl@golang.org>
Reviewed-by: Filippo Valsorda <hi@filippo.io>
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agosyscall: add Token to Windows SysProcAttr
Paul Querna [Wed, 1 Nov 2017 22:11:52 +0000 (15:11 -0700)]
syscall: add Token to Windows SysProcAttr

Fixes #21105

Change-Id: Ia2dea9b82a356795f581ce75616198b46e97abb6
Reviewed-on: https://go-review.googlesource.com/75253
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
6 years agocmd/compile: fix test to use correct go binary
Keith Randall [Sat, 4 Nov 2017 21:09:50 +0000 (14:09 -0700)]
cmd/compile: fix test to use correct go binary

Use internal/testenv package to get the right go binary.
Otherwise, I think we're just grabbing an old one from the environment.

Fixes #22560.

Change-Id: Id5b743b24717e15ec8ffbcfae4dc3e5f6a87b9a9
Reviewed-on: https://go-review.googlesource.com/76090
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: David Chase <drchase@google.com>
6 years agocmd/go: skip "exclude all Go files" error in fmt
Daniel Martí [Fri, 3 Nov 2017 18:14:37 +0000 (18:14 +0000)]
cmd/go: skip "exclude all Go files" error in fmt

Otherwise, one can't run "go fmt" on a directory containing Go files if
none of them are buildable (e.g. because of build tags). This is
counter-intuitive, as fmt will format all Go files anyway.

If we encounter such a load error, ignore it and carry on. All other
load errors, such as when a package can't be found, should still be
shown to the user.

Add a test for the two kinds of load errors. Use fmt -n so that any
changes to the formatting of the files in testdata don't actually get
applied. The load errors still occur with -n, so the test does its job.

Fixes #22183.

Change-Id: I99d0c0cdd29015b6a3f5286a9bbff50757c78e0d
Reviewed-on: https://go-review.googlesource.com/75930
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/compile: adjust locationlist lifetimes
David Chase [Fri, 27 Oct 2017 21:02:11 +0000 (17:02 -0400)]
cmd/compile: adjust locationlist lifetimes

A statement like

  foo = bar + qux

might compile to

  AX := AX + BX

resulting in a regkill for AX before this instruction.
The buggy behavior is to kill AX "at" this instruction,
before it has executed.  (Code generation of no-instruction
values like RegKills applies their effects at the
next actual instruction emitted).

However, bar is still associated with AX until after the
instruction executes, so the effect of the regkill must
occur at the boundary between this instruction and the
next.  Similarly, the new value bound to AX is not visible
until this instruction executes (and in the case of values
that require multiple instructions in code generation, until
all of them have executed).

The ranges are adjusted so that a value's start occurs
at the next following instruction after its evaluation,
and the end occurs after (execution of) the first
instruction following the end of the lifetime as a value.

(Notice the asymmetry; the entire value must be finished
before it is visible, but execution of a single instruction
invalidates.  However, the value *is* visible before that
next instruction executes).

The test was adjusted to make it insensitive to the result
numbering for variables printed by gdb, since that is not
relevant to the test and makes the differences introduced
by small changes larger than necessary/useful.

The test was also improved to present variable probes
more intuitively, and also to allow explicit indication
of "this variable was optimized out"

Change-Id: I39453eead8399e6bb05ebd957289b112d1100c0e
Reviewed-on: https://go-review.googlesource.com/74090
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agocmd/compile: repair name propagation into aggregate parts
David Chase [Tue, 24 Oct 2017 21:51:05 +0000 (17:51 -0400)]
cmd/compile: repair name propagation into aggregate parts

For structs, slices, strings, interfaces, etc, propagation of
names to their components (e.g., complex.real, complex.imag)
is fragile (depends on phase ordering) and not done right
for the "dec" pass.

The dec pass is subsumed into decomposeBuiltin,
and then names are pushed into the args of all
OpFooMake opcodes.

compile/ssa/debug_test.go was fixed to pay attention to
variable values, and the reference files include checks
for the fixes in this CL (which make debugging better).

Change-Id: Ic2591ebb1698d78d07292b92c53667e6c37fa0cd
Reviewed-on: https://go-review.googlesource.com/73210
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
6 years agocmd/compile: inline closures with captures
Hugues Bruant [Sat, 21 Oct 2017 22:58:37 +0000 (15:58 -0700)]
cmd/compile: inline closures with captures

When inlining a closure with captured variables, walk up the
param chain to find the one that is defined inside the scope
into which the function is being inlined, and map occurrences
of the captures to temporary inlvars, similarly to what is
done for function parameters.

No noticeable impact on compilation speed and binary size.

Minor improvements to go1 benchmarks on darwin/amd64

name                     old time/op    new time/op    delta
BinaryTree17-4              2.59s ± 3%     2.58s ± 1%    ~     (p=0.470 n=19+19)
Fannkuch11-4                3.15s ± 2%     3.15s ± 1%    ~     (p=0.647 n=20+19)
FmtFprintfEmpty-4          43.7ns ± 3%    43.4ns ± 4%    ~     (p=0.178 n=18+20)
FmtFprintfString-4         74.0ns ± 2%    77.1ns ± 7%  +4.13%  (p=0.000 n=20+20)
FmtFprintfInt-4            77.2ns ± 3%    79.2ns ± 6%  +2.53%  (p=0.000 n=20+20)
FmtFprintfIntInt-4          112ns ± 4%     112ns ± 2%    ~     (p=0.672 n=20+19)
FmtFprintfPrefixedInt-4     136ns ± 1%     135ns ± 2%    ~     (p=0.827 n=16+20)
FmtFprintfFloat-4           232ns ± 2%     233ns ± 1%    ~     (p=0.194 n=20+20)
FmtManyArgs-4               490ns ± 2%     484ns ± 2%  -1.28%  (p=0.001 n=20+20)
GobDecode-4                6.68ms ± 2%    6.72ms ± 2%    ~     (p=0.113 n=20+19)
GobEncode-4                5.62ms ± 2%    5.71ms ± 2%  +1.64%  (p=0.000 n=20+19)
Gzip-4                      235ms ± 3%     236ms ± 2%    ~     (p=0.607 n=20+19)
Gunzip-4                   37.1ms ± 2%    36.8ms ± 3%    ~     (p=0.060 n=20+20)
HTTPClientServer-4         61.9µs ± 2%    62.7µs ± 4%  +1.24%  (p=0.007 n=18+19)
JSONEncode-4               12.5ms ± 2%    12.4ms ± 3%    ~     (p=0.192 n=20+20)
JSONDecode-4               51.6ms ± 3%    51.0ms ± 3%  -1.19%  (p=0.008 n=20+19)
Mandelbrot200-4            4.12ms ± 6%    4.06ms ± 5%    ~     (p=0.063 n=20+20)
GoParse-4                  3.12ms ± 5%    3.10ms ± 2%    ~     (p=0.402 n=19+19)
RegexpMatchEasy0_32-4      80.7ns ± 2%    75.1ns ± 9%  -6.94%  (p=0.000 n=17+20)
RegexpMatchEasy0_1K-4       197ns ± 2%     186ns ± 2%  -5.43%  (p=0.000 n=20+20)
RegexpMatchEasy1_32-4      77.5ns ± 4%    71.9ns ± 7%  -7.25%  (p=0.000 n=20+18)
RegexpMatchEasy1_1K-4       341ns ± 3%     341ns ± 3%    ~     (p=0.732 n=20+20)
RegexpMatchMedium_32-4      113ns ± 2%     112ns ± 3%    ~     (p=0.102 n=20+20)
RegexpMatchMedium_1K-4     36.6µs ± 2%    35.8µs ± 2%  -2.26%  (p=0.000 n=18+20)
RegexpMatchHard_32-4       1.75µs ± 3%    1.74µs ± 2%    ~     (p=0.473 n=20+19)
RegexpMatchHard_1K-4       52.6µs ± 2%    52.0µs ± 3%  -1.15%  (p=0.005 n=20+20)
Revcomp-4                   381ms ± 4%     377ms ± 2%    ~     (p=0.067 n=20+18)
Template-4                 57.3ms ± 2%    57.7ms ± 2%    ~     (p=0.108 n=20+20)
TimeParse-4                 291ns ± 3%     292ns ± 2%    ~     (p=0.585 n=20+20)
TimeFormat-4                314ns ± 3%     315ns ± 1%    ~     (p=0.681 n=20+20)
[Geo mean]                 47.4µs         47.1µs       -0.73%

name                     old speed      new speed      delta
GobDecode-4               115MB/s ± 2%   114MB/s ± 2%    ~     (p=0.115 n=20+19)
GobEncode-4               137MB/s ± 2%   134MB/s ± 2%  -1.63%  (p=0.000 n=20+19)
Gzip-4                   82.5MB/s ± 3%  82.4MB/s ± 2%    ~     (p=0.612 n=20+19)
Gunzip-4                  523MB/s ± 2%   528MB/s ± 3%    ~     (p=0.060 n=20+20)
JSONEncode-4              155MB/s ± 2%   156MB/s ± 3%    ~     (p=0.192 n=20+20)
JSONDecode-4             37.6MB/s ± 3%  38.1MB/s ± 3%  +1.21%  (p=0.007 n=20+19)
GoParse-4                18.6MB/s ± 4%  18.7MB/s ± 2%    ~     (p=0.405 n=19+19)
RegexpMatchEasy0_32-4     396MB/s ± 2%   426MB/s ± 8%  +7.56%  (p=0.000 n=17+20)
RegexpMatchEasy0_1K-4    5.18GB/s ± 2%  5.48GB/s ± 2%  +5.79%  (p=0.000 n=20+20)
RegexpMatchEasy1_32-4     413MB/s ± 4%   444MB/s ± 6%  +7.46%  (p=0.000 n=20+19)
RegexpMatchEasy1_1K-4    3.00GB/s ± 3%  3.00GB/s ± 3%    ~     (p=0.678 n=20+20)
RegexpMatchMedium_32-4   8.82MB/s ± 2%  8.90MB/s ± 3%  +0.99%  (p=0.044 n=20+20)
RegexpMatchMedium_1K-4   28.0MB/s ± 2%  28.6MB/s ± 2%  +2.32%  (p=0.000 n=18+20)
RegexpMatchHard_32-4     18.3MB/s ± 3%  18.4MB/s ± 2%    ~     (p=0.482 n=20+19)
RegexpMatchHard_1K-4     19.5MB/s ± 2%  19.7MB/s ± 3%  +1.18%  (p=0.004 n=20+20)
Revcomp-4                 668MB/s ± 4%   674MB/s ± 2%    ~     (p=0.066 n=20+18)
Template-4               33.8MB/s ± 2%  33.6MB/s ± 2%    ~     (p=0.104 n=20+20)
[Geo mean]                124MB/s        126MB/s       +1.54%

Updates #15561
Updates #18270

Change-Id: I980086efe28b36aa27f81577065e2a729ff03d4e
Reviewed-on: https://go-review.googlesource.com/72490
Reviewed-by: Hugues Bruant <hugues.bruant@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agobytes: reduce work in IndexNearPageBoundary test
Keith Randall [Sat, 4 Nov 2017 04:57:08 +0000 (21:57 -0700)]
bytes: reduce work in IndexNearPageBoundary test

This test was taking too long on ppc64x.
There were a few reasons.

The first is that the page size on ppc64x is 64k instead of 4k.
That's 16x more work.

The second is that the generic Index is pretty bad in this case.
It first calls IndexByte which does a bunch of setup work only to find
the byte we're looking for at index 0.  Then it calls Equal which
has to look at the whole string to find a difference on the last byte.

To fix, just limit our attention to near the end of the page.

Change-Id: I6b8bcbb94652a2da853862acc23803def0c49303
Reviewed-on: https://go-review.googlesource.com/76050
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/compile: add mul by ±2ⁿ code-generation tests for arm/arm64
Alberto Donizetti [Fri, 3 Nov 2017 10:11:27 +0000 (11:11 +0100)]
cmd/compile: add mul by ±2ⁿ code-generation tests for arm/arm64

This change adds code generation tests for multiplication by ±2ⁿ for
arm and arm64, in preparation for a future CL which will remove the
relevant architecture-specific SSA rules (the reduction is already
performed by rules in generic.rules added in CL 36323).

Change-Id: Iebdd5c3bb2fc632c85888569ff0c49f78569a862
Reviewed-on: https://go-review.googlesource.com/75752
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agointernal/testenv: mark SkipFlaky and SkipFlakyNet as helpers
Alex Brainman [Sat, 4 Nov 2017 01:35:23 +0000 (12:35 +1100)]
internal/testenv: mark SkipFlaky and SkipFlakyNet as helpers

This makes the output they print refer to the code that called them.

For example, instead of

=== RUN   TestWindowsStackMemoryCgo
--- SKIP: TestWindowsStackMemoryCgo (0.00s)
        testenv.go:213: skipping known flaky test ...
PASS

we see

=== RUN   TestWindowsStackMemoryCgo
--- SKIP: TestWindowsStackMemoryCgo (0.00s)
        crash_cgo_test.go:471: skipping known flaky test ...
PASS

Change-Id: I5f4c77c3aeab5c0e43c6dde2f15db70a6df24603
Reviewed-on: https://go-review.googlesource.com/76031
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agoall: change github.com issue links to golang.org
Leigh McCulloch [Fri, 3 Nov 2017 05:48:43 +0000 (05:48 +0000)]
all: change github.com issue links to golang.org

The go repository contains a mix of github.com/golang/go/issues/xxxxx
and golang.org/issues/xxxxx URLs for references to issues in the issue
tracker. We should use one for consistency, and golang.org is preferred
in case the project moves the issue tracker in the future.

This reasoning is taken from a comment Sam Whited left on a CL I
recently opened: https://go-review.googlesource.com/c/go/+/73890.

In that CL I referenced an issue using its github.com URL, because other
tests in the file I was changing contained references to issues using
their github.com URL. Sam Whited left a comment on the CL stating I
should change it to the golang.org URL.

If new code is intended to reference issues via golang.org and not
github.com, existing code should be updated so that precedence exists
for contributors who are looking at the existing code as a guide for the
code they should write.

Change-Id: I3b9053fe38a1c56fc101a8b7fd7b8f310ba29724
Reviewed-on: https://go-review.googlesource.com/75673
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agohash: add marshaling, unmarshaling example
Tim Cooper [Fri, 3 Nov 2017 23:17:08 +0000 (20:17 -0300)]
hash: add marshaling, unmarshaling example

Example usage of functionality implemented in CL 66710.

Change-Id: I87d6e4d2fb7a60e4ba1e6ef02715480eb7e8f8bd
Reviewed-on: https://go-review.googlesource.com/76011
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>