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

27127 Commits

Author SHA1 Message Date
Austin Clements
4dcba023c6 runtime: use pselect6 for usleep on linux/amd64 and linux/arm
Android O black-lists the select system call because its libc, Bionic,
does not use this system call. Replace our use of select with pselect6
(which is allowed) on the platforms that support targeting Android.
linux/arm64 already uses pselect6 because there is no select on arm64,
so only linux/amd64 and linux/arm need changing. pselect6 has been
available since Linux 2.6.16, which is before Go's minimum
requirement.

Fixes #20409.

Change-Id: Ic526b5b259a9e01d2f145a1f4d2e76e8c49ce809
Reviewed-on: https://go-review.googlesource.com/43641
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-05-19 16:05:39 +00:00
Mikio Hara
366bb678aa net: make {TCP,UDP,IP,Unix}Conn compliant of syscall.Conn interface
This change makes {TCP,UDP,IP,Unix}Conn types compliant of
syscall.Conn interface and adds type rawConn as an implementation of
syscall.RawConn interface.

By this change, the long-standing issues regarding unsupported socket
options and system calls can be solved partly and the broken x/net
packages due to https://go-review.googlesource.com/36799 can be
repaired.

Fixes #3661.
Updates #9661.
Updates #19051.
Updates #19435.

Change-Id: Ic996b040418b54f6d043bc70591789d5a5b23270
Reviewed-on: https://go-review.googlesource.com/37039
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-05-19 09:10:27 +00:00
Mikio Hara
0a09c72c2e internal/poll: add RawControl, RawRead and RawWrite methods to FD
This change adds RawControl, RawRead and RawWrite methods to type FD
to make the runtime-integrated network poller work together with a
user-defined function. The methods are used via the net package from
external packages and type FD is considered as an implementation of
syscall.Conn and syscall.RawConn interfaces.

Updates #19435.

Change-Id: I4ad04b10ffddb2b54fa8d70587440960d73c0a2d
Reviewed-on: https://go-review.googlesource.com/37038
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-05-19 09:10:16 +00:00
Mikio Hara
de5c573baa syscall: add Conn and RawConn interfaces
This change adds Conn and RawConn interfaces which can be used to
manipulate raw network connection end points typically represented as
socket descriptors.

Fixes #19435.

Change-Id: Ide2d28eeab91bfd27473ab47a87bec69950b64c9
Reviewed-on: https://go-review.googlesource.com/37913
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2017-05-19 09:10:04 +00:00
Alex Brainman
64f064cac6 net: make syscall name consistent with others
Change-Id: Ic6d2de92e1f533a9f9a0cd6d7dab463bdafb0e11
Reviewed-on: https://go-review.googlesource.com/43691
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
2017-05-19 07:15:06 +00:00
Alex Brainman
e309dd938f internal/poll: remove unused ioSrv.ExecIO parameter
Change-Id: If5cb80c3c086684ce6c2e8ed9bb23b2a20c8aacd
Reviewed-on: https://go-review.googlesource.com/43690
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-19 07:14:25 +00:00
Alex Brainman
6144c7270e os: make windows Stat as fast as Lstat for files and directories
Recent CL 41834 made windows Stat work for all symlinks.
But CL 41834 also made Stat slow.

John Starks sugested
(see https://github.com/golang/go/issues/19922#issuecomment-300031421)
to use GetFileAttributesEx for files and directories instead.
This makes Stat as fast as at go1.9.

I see these improvements on my Windows 7

name       old time/op  new time/op  delta
StatDot    26.5µs ± 1%  20.6µs ± 2%  -22.37%  (p=0.000 n=9+10)
StatFile   22.8µs ± 2%   6.2µs ± 1%  -72.69%  (p=0.000 n=10+10)
StatDir    21.0µs ± 2%   6.1µs ± 3%  -71.12%  (p=0.000 n=10+9)
LstatDot   20.1µs ± 1%  20.7µs ± 6%   +3.37%  (p=0.000 n=9+10)
LstatFile  6.23µs ± 1%  6.36µs ± 8%     ~     (p=0.587 n=9+10)
LstatDir   6.10µs ± 0%  6.14µs ± 4%     ~     (p=0.590 n=9+10)

and on my Windows XP

name         old time/op  new time/op  delta
StatDot-2    20.6µs ± 0%  10.8µs ± 0%  -47.44%  (p=0.000 n=10+10)
StatFile-2   20.2µs ± 0%   7.9µs ± 0%  -60.91%  (p=0.000 n=8+10)
StatDir-2    19.3µs ± 0%   7.6µs ± 0%  -60.51%  (p=0.000 n=10+9)
LstatDot-2   10.8µs ± 0%  10.8µs ± 0%   -0.48%  (p=0.000 n=10+8)
LstatFile-2  7.83µs ± 0%  7.83µs ± 0%     ~     (p=0.844 n=10+8)
LstatDir-2   7.59µs ± 0%  7.56µs ± 0%   -0.46%  (p=0.000 n=10+10)

Updates #19922

Change-Id: Ice1fb5825defb05c79bab4dec0692e0fd1bcfcd5
Reviewed-on: https://go-review.googlesource.com/43071
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-19 05:55:01 +00:00
Kevin Burke
7f6ce5168d cmd/compile/internal/ssa: fix spelling mistake
Change-Id: I4b8f1b61c10f60ddb3687759af0be1641c1f78ce
Reviewed-on: https://go-review.googlesource.com/43111
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2017-05-19 05:03:37 +00:00
David du Colombier
9fdf77c373 cmd/compile: skip TestScopeRanges on Plan 9
TestScopeRanges has been added in CL 40095. This
test is failing on Plan 9 because executables don't
have a DWARF symbol table.

Fixes #20418.

Change-Id: I6dd3baa636998134ccd042203c8b5c3199a4d6e1
Reviewed-on: https://go-review.googlesource.com/43670
Run-TryBot: David du Colombier <0intro@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-05-19 00:29:20 +00:00
Brad Fitzpatrick
ca598e3cd4 os: add some comments and remove an unused variable in rename func
This slightly clarifies the just-submitted CL 40577.

Updates #19647

Change-Id: I5584ad0e1abbc31796e3e5752351857f2a13d6d7
Reviewed-on: https://go-review.googlesource.com/43625
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-05-18 23:43:24 +00:00
Alessandro Arzilli
2ad41a3090 cmd/compile: output DWARF lexical blocks for local variables
Change compiler and linker to emit DWARF lexical blocks in .debug_info
section when compiling with -N -l.

Version of debug_info is updated from DWARF v2 to DWARF v3 since
version 2 does not allow lexical blocks with discontinuous PC ranges.

Remaining open problems:
- scope information is removed from inlined functions
- variables records do not have DW_AT_start_scope attributes so a
variable will shadow other variables with the same name as soon as its
containing scope begins, even before its declaration.

Updates #6913.
Updates #12899.

Change-Id: Idc6808788512ea20e7e45bcf782453acb416fb49
Reviewed-on: https://go-review.googlesource.com/40095
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2017-05-18 23:10:50 +00:00
Alexander Menzhinsky
0f0a51f1d1 os: lstat oldname before renaming
Fixes #19647

Change-Id: Ife4f98cf2c55ee9490843797213dae2f2647b0a3
Reviewed-on: https://go-review.googlesource.com/40577
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-18 22:40:35 +00:00
Mark Ryan
1ea796ee69 encoding/base32: ensure base32 decoder propagates errors correctly
A number of issues in decoder.Read and newlineFilteringReader.Read were
preventing errors from the reader supplying the encoded data from being
propagated to the caller.  Fixing these issues revealed some additional
problems in which valid decoded data was not always returned to the user
when errors were actually propagated.

This commit fixes both the error propagation and the lost decoded data
problems.  It also adds some new unit tests to ensure errors are handled
correctly by decoder.Read.  The new unit tests increase the test coverage
of this package from 96.2% to 97.9%.

Fixes #20044

Change-Id: I1a8632da20135906e2d191c2a8825b10e7ecc4c5
Reviewed-on: https://go-review.googlesource.com/42094
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-18 22:37:49 +00:00
Daniel Theophanes
a9bf3b2e19 database/sql: allow drivers to support custom arg types
Previously all arguments were passed through driver.IsValid.
This checked arguments against a few fundamental go types and
prevented others from being passed in as arguments.

The new interface driver.NamedValueChecker may be implemented
by both driver.Stmt and driver.Conn. This allows
this new interface to completely supersede the
driver.ColumnConverter interface as it can be used for
checking arguments known to a prepared statement and
arbitrary query arguments. The NamedValueChecker may be
skipped with driver.ErrSkip after all special cases are
exhausted to use the default argument converter.

In addition if driver.ErrRemoveArgument is returned
the argument will not be passed to the query at all,
useful for passing in driver specific per-query options.

Add a canonical Out argument wrapper to be passed
to OUTPUT parameters. This will unify checks that need to
be written in the NameValueChecker.

The statement number check is also moved to the argument
converter so the NamedValueChecker may remove arguments
passed to the query.

Fixes #13567
Fixes #18079
Updates #18417
Updates #17834
Updates #16235
Updates #13067
Updates #19797

Change-Id: I89088bd9cca4596a48bba37bfd20d987453ef237
Reviewed-on: https://go-review.googlesource.com/38533
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-18 22:22:31 +00:00
Josh Bleecher Snyder
85b2940f5c cmd/compile: search for remaining WB ops from end to beginning
The writebarrier pass processes WB ops from beginning to end,
replacing them by other values.
But it also checks whether there are more ops to process
by walking from beginning to end.
This is quadratic, so walk from end to beginning instead.

This speeds up compiling the code in issue 13554:

name  old time/op       new time/op       delta
Pkg         11.9s ± 2%         8.3s ± 3%  -29.88%  (p=0.000 n=18+17)

Updates #13554

Passes toolstash-check.

Change-Id: I5f8a872ddc4b783540220d89ea2ee188a6d2b2ff
Reviewed-on: https://go-review.googlesource.com/43571
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2017-05-18 20:14:12 +00:00
Josh Bleecher Snyder
638ebb04f2 cmd/compile: don't break up contiguous blocks in looprotate
looprotate finds loop headers and arranges for them to be placed
after the body of the loop. This eliminates a jump from the body.

However, if the loop header is a series of contiguously laid out blocks,
the rotation introduces a new jump in that series.
This CL expands the "loop header" to move to be the entire
run of contiguously laid out blocks in the same loop.

This shrinks object files a little, and actually speeds up
the compiler noticeably. Numbers below.

Fannkuch performance seems to vary a lot by machine. On my laptop:

name          old time/op  new time/op  delta
Fannkuch11-8   2.89s ± 2%   2.85s ± 3%  -1.22%  (p=0.000 n=50+50)

This has a significant affect on the append benchmarks in #14758:

name   old time/op    new time/op    delta
Foo-8     312ns ± 3%     276ns ± 2%  -11.37%  (p=0.000 n=30+29)
Bar-8     565ns ± 2%     456ns ± 2%  -19.27%  (p=0.000 n=27+28)

Updates #18977
Fixes #20355

name        old time/op       new time/op       delta
Template          205ms ± 5%        204ms ± 8%    ~     (p=0.903 n=92+99)
Unicode          85.3ms ± 4%       85.1ms ± 3%    ~     (p=0.191 n=92+94)
GoTypes           512ms ± 4%        507ms ± 4%  -0.93%  (p=0.000 n=95+97)
Compiler          2.38s ± 3%        2.35s ± 3%  -1.27%  (p=0.000 n=98+95)
SSA               4.67s ± 3%        4.64s ± 3%  -0.62%  (p=0.000 n=95+96)
Flate             117ms ± 3%        117ms ± 3%    ~     (p=0.099 n=84+86)
GoParser          139ms ± 4%        137ms ± 4%  -0.90%  (p=0.000 n=97+98)
Reflect           329ms ± 5%        326ms ± 6%  -0.97%  (p=0.002 n=99+98)
Tar               102ms ± 6%        101ms ± 5%  -0.97%  (p=0.006 n=97+97)
XML               198ms ±10%        196ms ±13%    ~     (p=0.087 n=100+100)
[Geo mean]        318ms             316ms       -0.72%

name        old user-time/op  new user-time/op  delta
Template          250ms ± 7%        250ms ± 7%    ~     (p=0.850 n=94+92)
Unicode           107ms ± 8%        106ms ± 5%  -0.76%  (p=0.005 n=98+91)
GoTypes           665ms ± 5%        659ms ± 5%  -0.85%  (p=0.003 n=93+98)
Compiler          3.15s ± 3%        3.10s ± 3%  -1.60%  (p=0.000 n=99+98)
SSA               6.82s ± 3%        6.72s ± 4%  -1.55%  (p=0.000 n=94+98)
Flate             138ms ± 8%        138ms ± 6%    ~     (p=0.369 n=94+92)
GoParser          170ms ± 5%        168ms ± 6%  -1.13%  (p=0.002 n=96+98)
Reflect           412ms ± 8%        416ms ± 8%    ~     (p=0.169 n=100+100)
Tar               123ms ±18%        123ms ±14%    ~     (p=0.896 n=100+100)
XML               236ms ± 9%        234ms ±11%    ~     (p=0.124 n=100+100)
[Geo mean]        401ms             398ms       -0.63%

name        old alloc/op      new alloc/op      delta
Template         38.8MB ± 0%       38.8MB ± 0%    ~     (p=0.222 n=5+5)
Unicode          28.7MB ± 0%       28.7MB ± 0%    ~     (p=0.421 n=5+5)
GoTypes           109MB ± 0%        109MB ± 0%    ~     (p=0.056 n=5+5)
Compiler          457MB ± 0%        457MB ± 0%  +0.07%  (p=0.008 n=5+5)
SSA              1.10GB ± 0%       1.10GB ± 0%  +0.05%  (p=0.008 n=5+5)
Flate            24.5MB ± 0%       24.5MB ± 0%    ~     (p=0.222 n=5+5)
GoParser         30.9MB ± 0%       31.0MB ± 0%  +0.21%  (p=0.016 n=5+5)
Reflect          73.4MB ± 0%       73.4MB ± 0%    ~     (p=0.421 n=5+5)
Tar              25.5MB ± 0%       25.5MB ± 0%    ~     (p=0.548 n=5+5)
XML              40.9MB ± 0%       40.9MB ± 0%    ~     (p=0.151 n=5+5)
[Geo mean]       71.6MB            71.6MB       +0.07%

name        old allocs/op     new allocs/op     delta
Template           394k ± 0%         394k ± 0%    ~     (p=1.000 n=5+5)
Unicode            344k ± 0%         343k ± 0%    ~     (p=0.310 n=5+5)
GoTypes           1.16M ± 0%        1.16M ± 0%    ~     (p=1.000 n=5+5)
Compiler          4.42M ± 0%        4.42M ± 0%    ~     (p=1.000 n=5+5)
SSA               9.80M ± 0%        9.80M ± 0%    ~     (p=0.095 n=5+5)
Flate              237k ± 1%         238k ± 1%    ~     (p=0.310 n=5+5)
GoParser           320k ± 0%         322k ± 1%  +0.50%  (p=0.032 n=5+5)
Reflect            958k ± 0%         957k ± 0%    ~     (p=0.548 n=5+5)
Tar                252k ± 1%         252k ± 0%    ~     (p=1.000 n=5+5)
XML                400k ± 0%         400k ± 0%    ~     (p=0.841 n=5+5)
[Geo mean]         741k              742k       +0.06%

name        old object-bytes  new object-bytes  delta
Template           386k ± 0%         386k ± 0%  -0.05%  (p=0.008 n=5+5)
Unicode            202k ± 0%         202k ± 0%  -0.01%  (p=0.008 n=5+5)
GoTypes           1.16M ± 0%        1.16M ± 0%  -0.06%  (p=0.008 n=5+5)
Compiler          3.91M ± 0%        3.91M ± 0%  -0.06%  (p=0.008 n=5+5)
SSA               7.91M ± 0%        7.92M ± 0%  +0.01%  (p=0.008 n=5+5)
Flate              228k ± 0%         227k ± 0%  -0.04%  (p=0.008 n=5+5)
GoParser           283k ± 0%         283k ± 0%  -0.06%  (p=0.008 n=5+5)
Reflect            952k ± 0%         951k ± 0%  -0.02%  (p=0.008 n=5+5)
Tar                187k ± 0%         187k ± 0%  -0.04%  (p=0.008 n=5+5)
XML                406k ± 0%         406k ± 0%  -0.05%  (p=0.008 n=5+5)
[Geo mean]         648k              648k       -0.04%

Change-Id: I8630c4291a0eb2f7e7927bc04d7cc0efef181094
Reviewed-on: https://go-review.googlesource.com/43491
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-18 17:58:39 +00:00
Alberto Donizetti
9a432552cb os: document that NewFile can return nil
Fixes #20023

Change-Id: I1bec3e69031ffcfd7ad71716be9597ec322528ff
Reviewed-on: https://go-review.googlesource.com/41211
Reviewed-by: Russ Cox <rsc@golang.org>
2017-05-18 17:14:11 +00:00
Alberto Donizetti
2d1829b539 cmd/compile: don't panic in complex division
Updates #20227

Change-Id: Idadc3137490181a5d380367660cee21e8313cf3b
Reviewed-on: https://go-review.googlesource.com/42650
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-05-18 16:39:05 +00:00
Ben Shi
c7cae34b19 cmd/internal/obj/arm: remove illegal form of the SWI instruction
SWI only support "SWI $imm", but currently "SWI (Reg)" is also
accepted. This patch fixes it.

And more instruction tests are added to cmd/asm/internal/asm/testdata/arm.s

fixes #20375

Change-Id: Id437d853924a403e41da9b6cbddd20d994b624ff
Reviewed-on: https://go-review.googlesource.com/43552
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2017-05-18 13:38:13 +00:00
Alex Brainman
0927b4728d net: adjust TestInterfaceHardwareAddrWithGetmac
Ignore adapters with "Transport Name:   N/A" line in getmac
command output. This allows us to skip duplicate MAC addresses.

Fixes #19537.

Change-Id: I6b7be9d31322f963e02023c8f1037f6e9042b479
Reviewed-on: https://go-review.googlesource.com/39071
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Avelino <t@avelino.xxx>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-18 05:33:56 +00:00
Alex Brainman
b5e964cc1c cmd/link: make sure that runtime.epclntab lives in .text section
Second attempt to fix #14710.

CL 35272 already tried to fix this issue. But CL 35272 assumed
that runtime.epclntab type is STEXT, while it is actually SRODATA.

This CL uses Symbol.Sect.Seg to determine if symbol is part
of Segtext or Segdata.

Fixes #14710

Change-Id: Ic6b6f657555c87a64d2bc36cc4c07ab0591d00c4
Reviewed-on: https://go-review.googlesource.com/42390
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-05-18 05:32:41 +00:00
Austin Clements
c34add780b runtime/pprof: don't produce 0 location in count profiles
profileBuilder.locForPC returns 0 to mean "no location" because 0 is
an invalid location index. However, the code to build count profiles
doesn't check the result of locForPC, so this 0 location index ends up
in the profile's location list. This, in turn, causes problems later
when we decode the profile because it puts a nil *Location in the
sample's location slice, which can later lead to a nil pointer panic.

Fix this by making printCountProfile correctly discard the result of
locForPC if it returns 0. This makes this call match the other two
calls of locForPC.

Updates #15156.

Change-Id: I4492b3652b513448bc56f4cfece4e37da5e42f94
Reviewed-on: https://go-review.googlesource.com/43630
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-17 18:58:31 +00:00
Carl Henrik Lunde
2dc27839df runtime/pprof: deflake TestGoroutineCounts
TestGoroutineCounts was flaky when running on a system under load.
This happened on three builds the last couple of days.

Fix this by running this test with a single operating system thread, so
we do not depend on the operating system scheduler.  50 000 tests ran
without failure with the new version, the old version failed 0.5% of the
time.

Fixes #15156.

Change-Id: I1e5a18d0fef4f72cc9a56e376822b2849cdb0f8b
Reviewed-on: https://go-review.googlesource.com/43590
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2017-05-17 18:53:33 +00:00
Josh Bleecher Snyder
b3e577b9e7 cmd/compile: fuse from end to beginning
fuseBlockPlain was accidentally quadratic.
If you had plain blocks b1 -> b2 -> b3 -> b4,
each containing single values v1, v2, v3, and v4 respectively,
fuseBlockPlain would move v1 from b1 to b2 to b3 to b4,
then v2 from b2 to b3 to b4, etc.

There are two obvious fixes.

* Look for runs of blocks in fuseBlockPlain
  and handle them in a single go.
* Fuse from end to beginning; any given value in a run
  of blocks to fuse then moves only once.

The latter is much simpler, so that's what this CL does.

Somewhat surprisingly, this change does not pass toolstash-check.

The resulting set of blocks is the same,
and the values in them are the same,
but the order of values in them differ,
and that order of values (while arbitrary)
is enough to change the compiler's output.
This may be due to #20178; deadstore is the next pass after fuse.

Adding basic sorting to the beginning of deadstore
is enough to make this CL pass toolstash-check:

	for _, b := range f.Blocks {
		obj.SortSlice(b.Values, func(i, j int) bool { return b.Values[i].ID < b.Values[j].ID })
	}

Happily, this CL appears to result in better code on average,
if only by accident. It cuts 4k off of cmd/go; go1 benchmarks
are noisy as always but don't regress (numbers below).

No impact on the standard compilebench benchmarks.
For the code in #13554, this speeds up compilation dramatically:

name  old time/op       new time/op       delta
Pkg         53.1s ± 2%        12.8s ± 3%  -75.92%  (p=0.008 n=5+5)

name  old user-time/op  new user-time/op  delta
Pkg         55.0s ± 2%        14.9s ± 3%  -73.00%  (p=0.008 n=5+5)

name  old alloc/op      new alloc/op      delta
Pkg        2.04GB ± 0%       2.04GB ± 0%   +0.18%  (p=0.008 n=5+5)

name  old allocs/op     new allocs/op     delta
Pkg         6.21M ± 0%        6.21M ± 0%     ~     (p=0.222 n=5+5)

name  old object-bytes  new object-bytes  delta
Pkg         28.4M ± 0%        28.4M ± 0%   +0.00%  (p=0.008 n=5+5)

name  old export-bytes  new export-bytes  delta
Pkg           208 ± 0%          208 ± 0%     ~     (all equal)


Updates #13554


go1 benchmarks:

name                     old time/op    new time/op    delta
BinaryTree17-8              2.29s ± 2%     2.26s ± 2%  -1.43%  (p=0.000 n=48+50)
Fannkuch11-8                2.74s ± 2%     2.79s ± 2%  +1.63%  (p=0.000 n=50+49)
FmtFprintfEmpty-8          36.6ns ± 3%    34.6ns ± 4%  -5.29%  (p=0.000 n=49+50)
FmtFprintfString-8         58.3ns ± 3%    59.1ns ± 3%  +1.35%  (p=0.000 n=50+49)
FmtFprintfInt-8            62.4ns ± 2%    63.2ns ± 3%  +1.19%  (p=0.000 n=49+49)
FmtFprintfIntInt-8         95.1ns ± 2%    96.7ns ± 3%  +1.61%  (p=0.000 n=49+50)
FmtFprintfPrefixedInt-8     118ns ± 3%     113ns ± 2%  -4.00%  (p=0.000 n=50+49)
FmtFprintfFloat-8           191ns ± 2%     192ns ± 2%  +0.40%  (p=0.034 n=50+50)
FmtManyArgs-8               419ns ± 2%     420ns ± 2%    ~     (p=0.228 n=49+49)
GobDecode-8                5.26ms ± 3%    5.19ms ± 2%  -1.33%  (p=0.000 n=50+49)
GobEncode-8                4.12ms ± 2%    4.15ms ± 3%  +0.68%  (p=0.007 n=49+50)
Gzip-8                      198ms ± 2%     197ms ± 2%  -0.50%  (p=0.018 n=48+48)
Gunzip-8                   31.9ms ± 3%    31.8ms ± 3%  -0.47%  (p=0.024 n=50+50)
HTTPClientServer-8         64.4µs ± 0%    64.0µs ± 0%  -0.55%  (p=0.000 n=43+46)
JSONEncode-8               10.6ms ± 2%    10.6ms ± 3%    ~     (p=0.543 n=49+49)
JSONDecode-8               43.3ms ± 3%    43.1ms ± 2%    ~     (p=0.079 n=50+50)
Mandelbrot200-8            3.70ms ± 2%    3.70ms ± 2%    ~     (p=0.553 n=47+50)
GoParse-8                  2.70ms ± 2%    2.71ms ± 3%    ~     (p=0.843 n=49+50)
RegexpMatchEasy0_32-8      70.5ns ± 4%    70.4ns ± 4%    ~     (p=0.867 n=48+50)
RegexpMatchEasy0_1K-8       162ns ± 3%     162ns ± 2%    ~     (p=0.739 n=48+48)
RegexpMatchEasy1_32-8      66.1ns ± 5%    66.2ns ± 4%    ~     (p=0.970 n=50+50)
RegexpMatchEasy1_1K-8       297ns ± 7%     296ns ± 7%    ~     (p=0.406 n=50+50)
RegexpMatchMedium_32-8      105ns ± 5%     105ns ± 5%    ~     (p=0.702 n=50+50)
RegexpMatchMedium_1K-8     32.3µs ± 4%    32.2µs ± 3%    ~     (p=0.614 n=49+49)
RegexpMatchHard_32-8       1.75µs ±18%    1.74µs ±12%    ~     (p=0.738 n=50+48)
RegexpMatchHard_1K-8       52.2µs ±14%    51.3µs ±13%    ~     (p=0.230 n=50+50)
Revcomp-8                   366ms ± 3%     367ms ± 3%    ~     (p=0.745 n=49+49)
Template-8                 48.5ms ± 4%    48.5ms ± 4%    ~     (p=0.824 n=50+48)
TimeParse-8                 263ns ± 2%     256ns ± 2%  -2.98%  (p=0.000 n=48+49)
TimeFormat-8                265ns ± 3%     262ns ± 3%  -1.35%  (p=0.000 n=48+49)
[Geo mean]                 41.1µs         40.9µs       -0.48%


Change-Id: Ib35fa15b54282abb39c077d150beee27f610891a
Reviewed-on: https://go-review.googlesource.com/43570
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>
2017-05-17 16:28:09 +00:00
Josh Bleecher Snyder
ff262913fe cmd/compile: seed rand with time when race enabled
When the race detector is enabled,
the compiler randomizes the order in which functions are compiled,
in an attempt to shake out bugs.
But we never re-seed the rand source, so every execution is identical.
Fix that to get more coverage.

Change-Id: If5cdde03ef4f1bab5f45e07f03fb6614945481d7
Reviewed-on: https://go-review.googlesource.com/43572
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-17 16:18:45 +00:00
Hiroshi Ioka
7555a45dc2 cmd/cgo: support large unsigned macros
Currently, cgo converts integer macros into int64 if it's possible.
As a result, some macros which satisfy

math.MaxInt64 < x <= math.MaxUint64

will lose their original values.

This CL introduces the new probe to check signs,
so we can handle signed ints and unsigned ints separately.

Fixes #20369

Change-Id: I002ba452a82514b3a87440960473676f842cc9ee
Reviewed-on: https://go-review.googlesource.com/43476
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-17 14:42:29 +00:00
Ian Lance Taylor
c20e54533e cmd/go: don't fail on missing runtime/internal/sys/zversion.go
The generated file runtime/internal/sys/zversion.go is deleted by
`go tool cmd dist clean` as part of running clean.bash. Don't treat
a missing file as a reason to stop running the go tool; just treat
is as meaning that runtime/internal/sys is stale.

No test because I don't particularly want to clobber $GOROOT.

Fixes #20385.

Change-Id: I5251a99542cc93c33f627f133d7118df56e18af1
Reviewed-on: https://go-review.googlesource.com/43559
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-17 01:30:51 +00:00
Ian Lance Taylor
acc56909f2 cmd/go: fix TestExecutableGOROOT if GOROOT is a symlink
Fixes #20365.

Change-Id: If1a4866193cff3bc836d8bbf18b6a1f5deb9808d
Reviewed-on: https://go-review.googlesource.com/43550
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
2017-05-17 01:22:12 +00:00
Ian Lance Taylor
0fd7de4971 os: fix handling of ErrShortWrite in (*File).Write
Restore the handling of io.ErrShortWrite in (*File).Write:
if we write less than the requested amount, and there is no error from
the syscall, then return io.ErrShortWrite.

I can't figure out how to write a test for this. It would require a
non-pollable file (not a pipe) on a device that is almost but not
quite entirely full. The original code (https://golang.org/cl/36800043,
committed as part of https://golang.org/cl/36930044) does not have a test.

Fixes #20386.

Change-Id: Ied7b411e621e1eaf49f864f8db90069f276256f5
Reviewed-on: https://go-review.googlesource.com/43558
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-17 01:04:53 +00:00
Sean Chittenden
13cdd814ea runtime: mmap(2) on Solaris & Illumos can return EAGAIN.
In low memory situations mmap(2) on Illumos[2] can return EAGAIN when it
is unable to reserve the necessary space for the requested mapping.  Go
was not previously handling this correctly for Illumos and would fail to
recognize it was in a low-memory situation, the result being the program
would terminate with a panic instead of running the GC.

Fixes: #14930

[1]: https://www.illumos.org/man/2/mmap

Change-Id: I889cc0547e23f9d6c56e4fdd7bcbd0e15403873a
Reviewed-on: https://go-review.googlesource.com/43461
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-16 21:01:42 +00:00
Cherry Zhang
3b263e43a9 runtime, syscall: in Plan 9 ARM asm, replace "SWI 0" with "SWI $0"
On other systems we use "SWI $n". Change Plan 9 files to be
consistent. Generated binary is unchanged.

Fixes #20378.

Change-Id: Ia2a722061da2450c7b30cb707ed4f172fafecf74
Reviewed-on: https://go-review.googlesource.com/43533
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-16 20:01:07 +00:00
Adam Langley
46f4bfb2d1 crypto/tls: pass argument to serverInit rather than using a field in Config.
Updates #20164.

Change-Id: Ib900095e7885f25cd779750674a712c770603ca8
Reviewed-on: https://go-review.googlesource.com/42137
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-16 18:23:28 +00:00
Cherry Zhang
b53acd89db cmd/internal/obj/mips: add support of LLV, SCV, NOOP instructions
LLV and SCV are 64-bit load-linked and store-conditional. They
were used in runtime as #define WORD. Change them to normal
instruction form.

NOOP is hardware no-op. It was written as WORD $0. Make a name
for it for better disassembly output.

Fixes #12561.
Fixes #18238.

Change-Id: I82c667ce756fa83ef37b034b641e8c4366335e83
Reviewed-on: https://go-review.googlesource.com/40297
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-16 17:15:11 +00:00
Mark Harrison
84a51432a8 path: add examples
This change adds several examples, with emphasis on special or edge
cases such as a directory parameter consisting of an empty string.

Change-Id: Ib4ac3d0f6d503493eeed0c4fda7c12acf782e9e2
Reviewed-on: https://go-review.googlesource.com/43010
Reviewed-by: Steve Francia <spf@golang.org>
Run-TryBot: Jaana Burcu Dogan <jbd@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-16 15:44:29 +00:00
Josh Bleecher Snyder
5548f7d5cf cmd/compile: eliminate some bounds checks from generated rewrite rules
Noticed while looking at #20356.

Cuts 160k (1%) off of the cmd/compile binary.

Change-Id: If2397bc6971d6be9be6975048adecb0b5efa6d66
Reviewed-on: https://go-review.googlesource.com/43501
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-16 14:08:08 +00:00
Josh Bleecher Snyder
4b0d74f89d cmd/compile: lay out exit blocks last
In Go 1.8.x, panics are generally scheduled at the very end of functions.
That property was lost in Go 1.9; this CL restores it.

This helps with the Fannkuch benchmark:

name          old time/op  new time/op  delta
Fannkuch11-8   2.74s ± 2%   2.55s ± 2%  -7.03%  (p=0.000 n=20+20)

This increases the fannkuch function size from 801 bytes to 831 bytes,
but that is still smaller than Go 1.8.1 at 844 bytes.

It generally increases binary size a tiny amount.
Negligible compiler performance impact.

For the code in #14758:

name   old time/op    new time/op    delta
Foo-8     326ns ± 3%     312ns ± 3%  -4.32%  (p=0.000 n=28+30)
Bar-8     560ns ± 2%     565ns ± 2%  +0.96%  (p=0.002 n=30+27)

Updates #18977

name        old alloc/op      new alloc/op      delta
Template         38.8MB ± 0%       38.8MB ± 0%    ~     (p=0.690 n=5+5)
Unicode          28.7MB ± 0%       28.7MB ± 0%    ~     (p=0.841 n=5+5)
GoTypes           109MB ± 0%        109MB ± 0%    ~     (p=0.690 n=5+5)
Compiler          457MB ± 0%        457MB ± 0%    ~     (p=0.841 n=5+5)
SSA              1.10GB ± 0%       1.10GB ± 0%  +0.03%  (p=0.032 n=5+5)
Flate            24.4MB ± 0%       24.5MB ± 0%    ~     (p=0.690 n=5+5)
GoParser         30.9MB ± 0%       30.9MB ± 0%    ~     (p=0.421 n=5+5)
Reflect          73.3MB ± 0%       73.3MB ± 0%    ~     (p=1.000 n=5+5)
Tar              25.5MB ± 0%       25.5MB ± 0%    ~     (p=0.095 n=5+5)
XML              40.8MB ± 0%       40.9MB ± 0%    ~     (p=0.056 n=5+5)
[Geo mean]       71.6MB            71.6MB       +0.01%

name        old allocs/op     new allocs/op     delta
Template           395k ± 0%         394k ± 1%    ~     (p=1.000 n=5+5)
Unicode            344k ± 0%         344k ± 0%    ~     (p=0.690 n=5+5)
GoTypes           1.16M ± 0%        1.16M ± 0%    ~     (p=0.421 n=5+5)
Compiler          4.41M ± 0%        4.41M ± 0%    ~     (p=0.841 n=5+5)
SSA               9.79M ± 0%        9.79M ± 0%    ~     (p=0.310 n=5+5)
Flate              237k ± 0%         237k ± 0%    ~     (p=0.841 n=5+5)
GoParser           321k ± 0%         321k ± 1%    ~     (p=0.421 n=5+5)
Reflect            956k ± 0%         956k ± 0%    ~     (p=1.000 n=5+5)
Tar                251k ± 1%         252k ± 0%    ~     (p=0.095 n=5+5)
XML                399k ± 0%         400k ± 0%    ~     (p=0.222 n=5+5)
[Geo mean]         741k              741k       +0.03%

name        old object-bytes  new object-bytes  delta
Template           386k ± 0%         386k ± 0%  +0.05%  (p=0.008 n=5+5)
Unicode            202k ± 0%         202k ± 0%  +0.02%  (p=0.008 n=5+5)
GoTypes           1.16M ± 0%        1.16M ± 0%  +0.07%  (p=0.008 n=5+5)
Compiler          3.91M ± 0%        3.91M ± 0%  +0.05%  (p=0.008 n=5+5)
SSA               7.86M ± 0%        7.87M ± 0%  +0.07%  (p=0.008 n=5+5)
Flate              227k ± 0%         227k ± 0%  +0.10%  (p=0.008 n=5+5)
GoParser           283k ± 0%         283k ± 0%  +0.04%  (p=0.008 n=5+5)
Reflect            950k ± 0%         951k ± 0%  +0.04%  (p=0.008 n=5+5)
Tar                187k ± 0%         187k ± 0%  -0.03%  (p=0.008 n=5+5)
XML                406k ± 0%         406k ± 0%  +0.04%  (p=0.008 n=5+5)
[Geo mean]         647k              647k       +0.04%

Change-Id: I2015aa26338b90cf41e47f89564e336dc02608df
Reviewed-on: https://go-review.googlesource.com/43293
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-16 13:46:10 +00:00
Wei Xiao
b2363ee9f6 cmd/internal/objabi: fix the bug of shrinking SymType down to a uint8
Previous CL (cmd/internal/objabi: shrink SymType down to a uint8) shrinks
SymType down to a uint8 but forgot making according change in goobj.

Fixes #20296
Also add a test to catch such Goobj format inconsistency bug

Change-Id: Ib43dd7122cfcacf611a643814e95f8c5a924941f
Reviewed-on: https://go-review.googlesource.com/42971
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2017-05-16 12:26:10 +00:00
Robert Griesemer
5088b64b07 go/types: fewer spurious "declared but not used" follow-on errors
Mark variables as used even when they appear within an expression
context which we can't type-check; e.g., because the expression is
erroneous, or comes from an import "C" declaration.

Fixes #20358.

Change-Id: Ib28cc78d3867c597c7a1ace54de09ada02f5b33a
Reviewed-on: https://go-review.googlesource.com/43500
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-05-15 21:15:06 +00:00
David Chase
27da3ba5af cmd/compile: don't attach lines to SB, SP, similar constants
Attaching positions to SB, SP, initial mem can result in
less-good line-numbering when compiled for debugging.
This "fix" also removes source position from a zero-valued
struct (but not from its fields) and from a zero-length
array constant.

This may be a general problem for constants in entry blocks.

Fixes #20367.

Change-Id: I7e9df3341be2e2f60f127d35bb31e43cdcfce9a1
Reviewed-on: https://go-review.googlesource.com/43531
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-15 20:39:40 +00:00
Keith Randall
256210c719 cmd/compile: better check for single live memory
Enhance the one-live-memory-at-a-time check to run during many
more phases of the SSA backend. Also make it work in an interblock
fashion.

Change types.IsMemory to return true for tuples containing a memory type.

Fix trim pass to build the merged phi correctly. Doesn't affect
code but allows the check to pass after trim runs.

Switch the AddTuple* ops to take the memory-containing tuple argument second.

Update #20335

Change-Id: I5b03ef3606b75a9e4f765276bb8b183cdc172b43
Reviewed-on: https://go-review.googlesource.com/43495
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2017-05-15 19:17:35 +00:00
Dmitri Shuralyov
67e47124fc go/build: return partial information on Import error, for local import paths
Documentation of build.Import says:

	// If the path is a local import path naming a package that can be imported
	// using a standard import path, the returned package will set p.ImportPath
	// to that path.
	// ...
	// If an error occurs, Import returns a non-nil error and a non-nil
	// *Package containing partial information.

That behavior was previously untested, and broken by change in CL 33158.

Fix that by avoiding returning early on error for local import paths.
First, gather partial information, and only then check that the p.Dir
directory exists.

Add tests for this behavior.

Fixes #19769.
Fixes #20175 (duplicate of #19769).
Updates #17863.

Change-Id: I169cb35291099d05e02aaa3cb23a7403d1cc3657
Reviewed-on: https://go-review.googlesource.com/42350
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-15 18:44:46 +00:00
Austin Clements
9e83c11fca runtime/pprof: expand inlined frames in symbolized proto profiles
Currently proto symbolization uses runtime.FuncForPC and assumes each
PC maps to a single frame. This isn't true in the presence of inlining
(even with leaf-only inlining this can get incorrect results).

Change PC symbolization to use runtime.CallersFrames to expand each PC
to all of the frames at that PC.

Change-Id: I8d20dff7495a5de495ae07f569122c225d433ced
Reviewed-on: https://go-review.googlesource.com/41256
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2017-05-15 18:20:23 +00:00
Austin Clements
1dc0f9696b runtime/pprof: clean up call/return PCs in memory profiles
Proto profile conversion is inconsistent about call vs return PCs in
profile locations. The proto defines locations to be call PCs. This is
what we do when proto-izing CPU profiles, but we fail to convert the
return PCs in memory and count profile stacks to call PCs when
converting them to proto locations.

Fix this in the heap and count profile conversion functions.
TestConvertMemProfile also hard-codes this failure to convert from
return PCs to call PCs, so fix up the addresses in the synthesized
profile to be return PCs while checking that we get call PCs out of
the conversion.

Change-Id: If1fc028b86fceac6d71a2d9fa6c41ff442c89296
Reviewed-on: https://go-review.googlesource.com/42951
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2017-05-15 18:20:20 +00:00
Alex Brainman
1d44c4e378 cmd/link: actually generate .debug_gdb_scripts section on windows
Adjust finddebugruntimepath to look for runtime/debug.go file
instead of runtime/runtime.go. This actually finds runtime.GOMAXPROCS
in every Go executable (including windows).

I also included "-Wl,-T,fix_debug_gdb_scripts.ld" parameter to gcc
invocation on windows to work around gcc bug (see #20183 for details).

This CL only fixes windows -buildmode=exe, buildmode=c-archive
is still broken.

Thanks to Egon Elbre and Nick Clifton for investigation.

Fixes #20183
Fixes #20218

Change-Id: I5369a4db3913226aef3d9bd6317446856b0a1c34
Reviewed-on: https://go-review.googlesource.com/43331
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-05-15 06:16:19 +00:00
Robert Griesemer
fca6ad45e2 text/scanner: clarify documentation on Pos and Position
For #20292. (See discussion in that issue.)

Change-Id: I44cd69394fc47a01776905ec34305ba524c89883
Reviewed-on: https://go-review.googlesource.com/43452
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-14 20:24:34 +00:00
Josh Bleecher Snyder
cfae61b65a cmd/compile: tweak ssa.html colors
Make yellow the last highlight color rather than the first.
Yellow is also the color that Chrome uses to highlight
search results, which can be confusing.
Also, when Night Shift is on on macOS,
yellow highlighting is completely invisible.
I suppose should be sleeping instead.

Also, remove a completed TODO.

Change-Id: I0eb4439272fad9ccb5fe8e2cf409fdd5dc15b26e
Reviewed-on: https://go-review.googlesource.com/43463
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-14 12:54:30 +00:00
Josh Bleecher Snyder
61336b78c1 cmd/compile: don't update outer variables after capturevars is complete
When compiling concurrently, we walk all functions before compiling
any of them. Walking functions can cause variables to switch from
being non-addrtaken to addrtaken, e.g. to prepare for a runtime call.
Typechecking propagates addrtaken-ness of closure variables to
their outer variables, so that capturevars can decide whether to
pass the variable's value or a pointer to it.

When all functions are compiled immediately, as long as the containing
function is compiled prior to the closure, this propagation has no effect.
When compilation is deferred, though, in rare cases, this results in 
a change in the addrtaken-ness of a variable in the outer function,
which in turn changes the compiler's output.
(This is rare because in a great many cases, a temporary has been
introduced, insulating the outer variable from modification.)
But concurrent compilation must generate identical results.

To fix this, track whether capturevars has run.
If it has, there is no need to update outer variables
when closure variables change.
Capturevars always runs before any functions are walked or compiled.

The remainder of the changes in this CL are to support the test.
In particular, -d=compilelater forces the compiler to walk all
functions before compiling any of them, despite being non-concurrent.
This is useful because -live is fundamentally incompatible with
concurrent compilation, but we want -c=1 to have no behavior changes.

Fixes #20250

Change-Id: I89bcb54268a41e8588af1ac8cc37fbef856a90c2
Reviewed-on: https://go-review.googlesource.com/42853
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-05-14 00:27:25 +00:00
wuyunzhou
ee57e36dfa container/heap: avoid up() invoke if down() success at heap.Remove()
Change-Id: I6c210e0c23ca533e1f303f88ef9dcb629a294a2a
Reviewed-on: https://go-review.googlesource.com/43472
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
2017-05-13 19:10:24 +00:00
Brad Fitzpatrick
1fcd7861e3 builtin: fix signature of the builtin function make
Fixes #20325

Change-Id: Ie363fef73d0deae40af41ee3f4403ad18546eba6
Reviewed-on: https://go-review.googlesource.com/43460
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-05-13 16:16:48 +00:00
Lars Jeppesen
66b5a2f3f0 archive/tar: remove file type bits from mode field
When writing tar files by using the FileInfoHeader
the type bits was set in the mode field of the header
This is not correct according to the standard (GNU/Posix) and
other implementations.

Fixed #20150

Change-Id: I3be7d946a1923ad5827cf45c696546a5e287ebba
Reviewed-on: https://go-review.googlesource.com/42093
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-13 00:22:29 +00:00
Robert Griesemer
8f06e217ea text/scanner: use correct token position in example
While at it, unindent source text so column values are easier
to read, remove unnecessary text in output, and simplify the
loop.

Fixes #20346.

Change-Id: I0fde02b9e4242383da427f4cf4c6c13dd0ab3b47
Reviewed-on: https://go-review.googlesource.com/43450
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-12 19:45:59 +00:00
Matt Harden
380aa884b8 net: allow Resolver to use a custom dialer
In some cases it is desirable to customize the way the DNS server is
contacted, for instance to use a specific LocalAddr. While most
operating-system level resolvers do not allow this, we have the
opportunity to do so with the Go resolver. Most of the code was
already in place to allow tests to override the dialer. This exposes
that functionality, and as a side effect eliminates the need for a
testing hook.

Fixes #17404

Change-Id: I1c5e570f8edbcf630090f8ec6feb52e379e3e5c0
Reviewed-on: https://go-review.googlesource.com/37260
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-12 18:08:12 +00:00
Austin Clements
3b5637ff2b runtime: doubly fix "double wakeup" panic
runtime.gchelper depends on the non-atomic load of work.ndone
happening strictly before the atomic add of work.nwait. Until very
recently (commit 978af9c2db, fixing #20334), the compiler reordered
these operations. This created a race since work.ndone can change as
soon as work.nwait is equal to work.ndone. If that happened, more than
one gchelper could attempt to wake up the work.alldone note, causing a
"double wakeup" panic.

This was fixed in the compiler, but to make this code less subtle,
make the load of work.ndone atomic. This clearly forces the order of
these operations, ensuring the race doesn't happen.

Fixes #19305 (though really 978af9c2db fixed it).

Change-Id: Ieb1a84e1e5044c33ac612c8a5ab6297e7db4c57d
Reviewed-on: https://go-review.googlesource.com/43311
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-12 15:33:09 +00:00
Austin Clements
29e88d5130 runtime: print debug info on "base out of range"
This adds debugging information when we panic with "heapBitsForSpan:
base out of range".

Updates #20259.

Change-Id: I0dc1a106aa9e9531051c7d08867ace5ef230eb3f
Reviewed-on: https://go-review.googlesource.com/43310
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-12 14:28:15 +00:00
Ian Lance Taylor
dddd1dd481 cmd/go: fix TestExecutableGOROOT on Windows
On Windows the drive letter is sometime "c:" and sometimes "C:".

Fixes #20336.

Change-Id: I38c86999af9522c51470d60016729d41cfec6b25
Reviewed-on: https://go-review.googlesource.com/43390
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-12 14:26:32 +00:00
Hiroshi Ioka
22538477a3 cmd/go: use filepath.Base for getting $CC name in TestCgoContainsSpace
Change-Id: If7329b81073d7c98fdcb8a2c0b35f8708000606e
Reviewed-on: https://go-review.googlesource.com/43332
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-12 13:30:24 +00:00
Hiroshi Ioka
482da51803 cmd/go: fix TestCgoContainsSpace
TestCgoContainsSpace builds a small program which mimics $CC.
Usually, $CC attempts to compile a trivial code to detect its own
supported flags (i.e. "-no-pie", which must be passed on some systems),
however the mimic didn't consider these cases.

This CL solve the issue.

Also, use the same name as $CC, it may solve other potential problems.

Fixes #20324

Change-Id: I7a00ac016a5fd0667540f2a715371f8152edc395
Reviewed-on: https://go-review.googlesource.com/43330
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-12 01:10:11 +00:00
Keith Randall
978af9c2db cmd/compile: fix store chain in schedule pass
Tuple ops are weird. They are essentially a pair of ops,
one which consumes a mem and one which generates a mem (the Select1).
The schedule pass didn't handle these quite right.

Fix the scheduler to include both parts of the paired op in
the store chain. That makes sure that loads are correctly ordered
with respect to the first of the pair.

Add a check for the ssacheck builder, that there is only one
live store at a time. I thought we already had such a check, but
apparently not...

Fixes #20335

Change-Id: I59eb3446a329100af38d22820b1ca2190ca46a78
Reviewed-on: https://go-review.googlesource.com/43294
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2017-05-11 22:16:08 +00:00
Josh Bleecher Snyder
e5bb5e397d cmd/compile: restore panic deduplication
The switch to detailed position information broke
the removal of duplicate panics on the same line.
Restore it.

Neutral compiler performance impact:

name        old alloc/op      new alloc/op      delta
Template         38.8MB ± 0%       38.8MB ± 0%    ~     (p=0.690 n=5+5)
Unicode          28.7MB ± 0%       28.7MB ± 0%  +0.13%  (p=0.032 n=5+5)
GoTypes           109MB ± 0%        109MB ± 0%    ~     (p=1.000 n=5+5)
Compiler          457MB ± 0%        457MB ± 0%    ~     (p=0.151 n=5+5)
SSA              1.09GB ± 0%       1.10GB ± 0%  +0.17%  (p=0.008 n=5+5)
Flate            24.6MB ± 0%       24.5MB ± 0%  -0.35%  (p=0.008 n=5+5)
GoParser         30.9MB ± 0%       31.0MB ± 0%    ~     (p=0.421 n=5+5)
Reflect          73.4MB ± 0%       73.4MB ± 0%    ~     (p=0.056 n=5+5)
Tar              25.6MB ± 0%       25.5MB ± 0%  -0.61%  (p=0.008 n=5+5)
XML              40.9MB ± 0%       40.9MB ± 0%    ~     (p=0.841 n=5+5)
[Geo mean]       71.6MB            71.6MB       -0.07%

name        old allocs/op     new allocs/op     delta
Template           394k ± 0%         395k ± 1%    ~     (p=0.151 n=5+5)
Unicode            343k ± 0%         344k ± 0%  +0.38%  (p=0.032 n=5+5)
GoTypes           1.16M ± 0%        1.16M ± 0%    ~     (p=1.000 n=5+5)
Compiler          4.41M ± 0%        4.42M ± 0%    ~     (p=0.151 n=5+5)
SSA               9.79M ± 0%        9.79M ± 0%    ~     (p=0.690 n=5+5)
Flate              238k ± 1%         238k ± 0%    ~     (p=0.151 n=5+5)
GoParser           321k ± 0%         321k ± 1%    ~     (p=0.548 n=5+5)
Reflect            958k ± 0%         957k ± 0%    ~     (p=0.841 n=5+5)
Tar                252k ± 0%         252k ± 1%    ~     (p=0.151 n=5+5)
XML                401k ± 0%         400k ± 0%    ~     (p=1.000 n=5+5)
[Geo mean]         741k              742k       +0.08%


Reduces object files a little bit:

name        old object-bytes  new object-bytes  delta
Template           386k ± 0%         386k ± 0%  -0.04%  (p=0.008 n=5+5)
Unicode            202k ± 0%         202k ± 0%    ~     (all equal)
GoTypes           1.16M ± 0%        1.16M ± 0%  -0.04%  (p=0.008 n=5+5)
Compiler          3.91M ± 0%        3.91M ± 0%  -0.08%  (p=0.008 n=5+5)
SSA               7.91M ± 0%        7.91M ± 0%  -0.04%  (p=0.008 n=5+5)
Flate              228k ± 0%         227k ± 0%  -0.28%  (p=0.008 n=5+5)
GoParser           283k ± 0%         283k ± 0%  -0.01%  (p=0.008 n=5+5)
Reflect            952k ± 0%         951k ± 0%  -0.03%  (p=0.008 n=5+5)
Tar                188k ± 0%         187k ± 0%  -0.09%  (p=0.008 n=5+5)
XML                406k ± 0%         406k ± 0%  -0.04%  (p=0.008 n=5+5)
[Geo mean]         648k              648k       -0.06%


This was discovered in the context for the Fannkuch benchmark.
It shrinks the number of panicindex calls in that function
from 13 back to 9, their 1.8.1 level.

It shrinks the function text a bit, from 829 to 801 bytes.
It slows down execution a little, presumably due to alignment (?).

name          old time/op  new time/op  delta
Fannkuch11-8   2.68s ± 2%   2.74s ± 1%  +2.09%  (p=0.000 n=19+20)

After this CL, 1.8.1 and tip are identical:

name          old time/op  new time/op  delta
Fannkuch11-8   2.74s ± 2%   2.74s ± 1%   ~     (p=0.301 n=20+20)

Fixes #20332

Change-Id: I2aeacc3e8cf2ac1ff10f36c572a27856f4f8f7c9
Reviewed-on: https://go-review.googlesource.com/43291
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-11 19:34:11 +00:00
Josh Bleecher Snyder
ee69c21747 cmd/compile: don't use statictmps for SSA-able composite literals
The writebarrier test has to change.
Now that T23 composite literals are passed to the backend,
they get SSA'd, so writes to their fields are treated separately,
so the relevant part of the first write to t23 is now a dead store.
Preserve the intent of the test by splitting it up into two functions.

Reduces code size a bit:

name        old object-bytes  new object-bytes  delta
Template           386k ± 0%         386k ± 0%    ~     (all equal)
Unicode            202k ± 0%         202k ± 0%    ~     (all equal)
GoTypes           1.16M ± 0%        1.16M ± 0%    ~     (all equal)
Compiler          3.92M ± 0%        3.91M ± 0%  -0.19%  (p=0.008 n=5+5)
SSA               7.91M ± 0%        7.91M ± 0%    ~     (all equal)
Flate              228k ± 0%         228k ± 0%  -0.05%  (p=0.008 n=5+5)
GoParser           283k ± 0%         283k ± 0%    ~     (all equal)
Reflect            952k ± 0%         952k ± 0%  -0.06%  (p=0.008 n=5+5)
Tar                188k ± 0%         188k ± 0%  -0.09%  (p=0.008 n=5+5)
XML                406k ± 0%         406k ± 0%  -0.02%  (p=0.008 n=5+5)
[Geo mean]         649k              648k       -0.04%

Fixes #18872

Change-Id: Ifeed0f71f13849732999aa731cc2bf40c0f0e32a
Reviewed-on: https://go-review.googlesource.com/43154
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2017-05-11 18:28:40 +00:00
Josh Bleecher Snyder
dccc653aeb cmd/compile: avoid checkwidth of [...] arrays
Fixes #20333

Change-Id: I0653cc859076f146d8ea8f5bd55cb22b0b8d987f
Reviewed-on: https://go-review.googlesource.com/43290
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-11 18:18:55 +00:00
Tom Bergan
8f36668178 net/http: for http2, use the priority write scheduler by default
Updates #18318

Change-Id: Ibd4ebc7708abf87eded8da9661378b5777b8a400
Reviewed-on: https://go-review.googlesource.com/43231
Run-TryBot: Tom Bergan <tombergan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-11 17:46:43 +00:00
Ben Shi
6897030fe3 cmd/internal/obj: continue to optimize ARM's constant pool
Both Keith's https://go-review.googlesource.com/c/41612/ and
and Ben's https://go-review.googlesource.com/c/41679/ optimized ARM's
constant pool. But neither was complete.

First, BIC was forgotten.
1. "BIC $0xff00ff00, Reg" can be optimized to
   "BIC $0xff000000, Reg
    BIC $0x0000ff00, Reg"
2. "BIC $0xffff00ff, Reg" can be optimized to
   "AND $0x0000ff00, Reg"
3. "AND $0xffff00ff, Reg" can be optimized to
   "BIC $0x0000ff00, Reg"

Second, break a non-ARMImmRot to the subtraction of two ARMImmRots was
left as TODO.
1. "ADD $0x00fffff0, Reg" can be optimized to
   "ADD $0x01000000, Reg
    SUB $0x00000010, Reg"
2. "SUB $0x00fffff0, Reg" can be optimized to
   "SUB $0x01000000, Reg
    ADD $0x00000010, Reg"

This patch fixes them and issue #19844.

The go1 benchmark shows improvements.

name                     old time/op    new time/op    delta
BinaryTree17-4              41.4s ± 1%     41.7s ± 1%  +0.54%  (p=0.000 n=50+49)
Fannkuch11-4                24.7s ± 1%     25.1s ± 0%  +1.70%  (p=0.000 n=50+49)
FmtFprintfEmpty-4           853ns ± 1%     852ns ± 1%    ~     (p=0.833 n=50+50)
FmtFprintfString-4         1.33µs ± 1%    1.33µs ± 1%    ~     (p=0.163 n=50+50)
FmtFprintfInt-4            1.40µs ± 1%    1.40µs ± 0%    ~     (p=0.293 n=50+35)
FmtFprintfIntInt-4         2.09µs ± 1%    2.08µs ± 1%  -0.39%  (p=0.000 n=50+49)
FmtFprintfPrefixedInt-4    2.43µs ± 1%    2.43µs ± 1%    ~     (p=0.552 n=50+50)
FmtFprintfFloat-4          4.57µs ± 1%    4.42µs ± 1%  -3.18%  (p=0.000 n=50+50)
FmtManyArgs-4              8.62µs ± 1%    8.52µs ± 0%  -1.08%  (p=0.000 n=50+50)
GobDecode-4                 101ms ± 1%     101ms ± 2%  +0.45%  (p=0.001 n=49+49)
GobEncode-4                90.7ms ± 1%    91.1ms ± 2%  +0.51%  (p=0.001 n=50+50)
Gzip-4                      4.23s ± 1%     4.21s ± 1%  -0.62%  (p=0.000 n=50+50)
Gunzip-4                    623ms ± 1%     619ms ± 0%  -0.63%  (p=0.000 n=50+42)
HTTPClientServer-4          721µs ± 5%     683µs ± 3%  -5.25%  (p=0.000 n=50+47)
JSONEncode-4                251ms ± 1%     253ms ± 1%  +0.54%  (p=0.000 n=49+50)
JSONDecode-4                941ms ± 1%     944ms ± 1%  +0.30%  (p=0.001 n=49+50)
Mandelbrot200-4            49.3ms ± 1%    49.3ms ± 0%    ~     (p=0.918 n=50+48)
GoParse-4                  47.1ms ± 1%    47.2ms ± 1%  +0.18%  (p=0.025 n=50+50)
RegexpMatchEasy0_32-4      1.23µs ± 1%    1.24µs ± 1%  +0.30%  (p=0.000 n=49+50)
RegexpMatchEasy0_1K-4      7.74µs ± 7%    7.76µs ± 5%    ~     (p=0.888 n=50+50)
RegexpMatchEasy1_32-4      1.32µs ± 1%    1.32µs ± 1%  +0.23%  (p=0.003 n=50+50)
RegexpMatchEasy1_1K-4      10.6µs ± 2%    10.5µs ± 3%  -1.29%  (p=0.000 n=49+50)
RegexpMatchMedium_32-4     2.19µs ± 1%    2.10µs ± 1%  -3.79%  (p=0.000 n=49+49)
RegexpMatchMedium_1K-4      544µs ± 0%     545µs ± 0%    ~     (p=0.123 n=41+50)
RegexpMatchHard_32-4       28.8µs ± 0%    28.8µs ± 1%    ~     (p=0.580 n=46+50)
RegexpMatchHard_1K-4        863µs ± 1%     865µs ± 1%  +0.31%  (p=0.027 n=47+50)
Revcomp-4                  82.2ms ± 2%    82.3ms ± 2%    ~     (p=0.894 n=48+49)
Template-4                  1.06s ± 1%     1.04s ± 1%  -1.18%  (p=0.000 n=50+49)
TimeParse-4                7.25µs ± 1%    7.35µs ± 0%  +1.48%  (p=0.000 n=50+50)
TimeFormat-4               13.3µs ± 1%    13.2µs ± 1%  -0.13%  (p=0.007 n=50+50)
[Geo mean]                  736µs          733µs       -0.37%

name                     old speed      new speed      delta
GobDecode-4              7.60MB/s ± 1%  7.56MB/s ± 2%  -0.46%  (p=0.001 n=49+49)
GobEncode-4              8.47MB/s ± 1%  8.42MB/s ± 2%  -0.50%  (p=0.001 n=50+50)
Gzip-4                   4.58MB/s ± 1%  4.61MB/s ± 1%  +0.59%  (p=0.000 n=50+50)
Gunzip-4                 31.2MB/s ± 1%  31.4MB/s ± 0%  +0.63%  (p=0.000 n=50+42)
JSONEncode-4             7.73MB/s ± 1%  7.69MB/s ± 1%  -0.53%  (p=0.000 n=49+50)
JSONDecode-4             2.06MB/s ± 1%  2.06MB/s ± 1%    ~     (p=0.052 n=44+50)
GoParse-4                1.23MB/s ± 0%  1.23MB/s ± 2%    ~     (p=0.526 n=26+50)
RegexpMatchEasy0_32-4    25.9MB/s ± 1%  25.9MB/s ± 1%  -0.30%  (p=0.000 n=49+50)
RegexpMatchEasy0_1K-4     132MB/s ± 7%   132MB/s ± 6%    ~     (p=0.885 n=50+50)
RegexpMatchEasy1_32-4    24.2MB/s ± 1%  24.1MB/s ± 1%  -0.22%  (p=0.003 n=50+50)
RegexpMatchEasy1_1K-4    96.4MB/s ± 2%  97.8MB/s ± 3%  +1.36%  (p=0.000 n=50+50)
RegexpMatchMedium_32-4    460kB/s ± 0%   476kB/s ± 1%  +3.43%  (p=0.000 n=49+50)
RegexpMatchMedium_1K-4   1.88MB/s ± 0%  1.88MB/s ± 0%    ~     (all equal)
RegexpMatchHard_32-4     1.11MB/s ± 0%  1.11MB/s ± 1%  +0.34%  (p=0.000 n=45+50)
RegexpMatchHard_1K-4     1.19MB/s ± 1%  1.18MB/s ± 1%  -0.34%  (p=0.033 n=50+50)
Revcomp-4                30.9MB/s ± 2%  30.9MB/s ± 2%    ~     (p=0.894 n=48+49)
Template-4               1.84MB/s ± 1%  1.86MB/s ± 2%  +1.19%  (p=0.000 n=48+50)
[Geo mean]               6.63MB/s       6.65MB/s       +0.26%


Fixes #19844.

Change-Id: I5ad16cc0b29267bb4579aca3dcc10a0b8ade1aa4
Reviewed-on: https://go-review.googlesource.com/42430
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2017-05-11 13:53:54 +00:00
Daniel Martí
19b05acd13 reflect: remove dead v.typ assignment
v is not a pointer receiver, and v.typ isn't used in the lines below.
The assignment is dead. Remove it.

Keep the comment, as it refers to the whole case block and not just the
removed line.

Change-Id: Icb2d20c287d9a41bf620ebe5cdec764cd84178a7
Reviewed-on: https://go-review.googlesource.com/43134
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-11 08:07:21 +00:00
Ian Lance Taylor
c061f51e72 os: remove extraneous 's' from TestStdPipe error message
Change-Id: I73674a90d88da630b09dcb75ced5d9f0d96c3c09
Reviewed-on: https://go-review.googlesource.com/43153
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-10 20:19:50 +00:00
David Chase
643be70045 cmd/compile: repair copy-pasted method comment
Inadvertent copy-pasta in CL
https://go-review.googlesource.com/c/36207/

Is this allowed for 1.9 post-freeze?

Change-Id: I00dd27f9f53babeded3695346986a7a491f8a771
Reviewed-on: https://go-review.googlesource.com/43092
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-10 19:30:42 +00:00
Martin Möhrmann
aeee34cb24 runtime: remove unused cpuid_X variables
They are not exported and not used in the compiler or standard library.

Change-Id: Ie1d210464f826742d282f12258ed1792cbd2d188
Reviewed-on: https://go-review.googlesource.com/43135
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-10 19:28:42 +00:00
Josh Bleecher Snyder
201fd16568 cmd/link: set Fieldtrack symbol type to SDATA
Fixes #20316

Change-Id: I2553ad9a82dfcb30f020c2a3e37b868111425a20
Reviewed-on: https://go-review.googlesource.com/43151
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-10 19:24:29 +00:00
David Chase
00263a8968 cmd/compile: reduce debugger-worsening line number churn
Reuse block head or preceding instruction's line number for
register allocator's spill, fill, copy, rematerialization
instructionsl; and also for phi, and for no-src-pos
instructions.  Assembler creates same line number tables
for copy-predecessor-line and for no-src-pos,
but copy-predecessor produces better-looking assembly
language output with -S and with GOSSAFUNC, and does not
require changes to tests of existing assembly language.

Split "copyInto" into two cases, one for register allocation,
one for otherwise.  This caused the test score line change
count to increase by one, which may reflect legitimately
useful information preserved.  Without any special treatment
for copyInto, the change count increases by 21 more, from
51 to 72 (i.e., quite a lot).

There is a test; using two naive "scores" for line number
churn, the old numbering is 2x or 4x worse.

Fixes #18902.

Change-Id: I0a0a69659d30ee4e5d10116a0dd2b8c5df8457b1
Reviewed-on: https://go-review.googlesource.com/36207
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-10 17:16:44 +00:00
Hiroshi Ioka
1df777f6a4 go/build: accept spaces in cgo directives
Fixes #7906

Change-Id: Ibcf9cd670593241921ab3c426ff7357f799ebc3e
Reviewed-on: https://go-review.googlesource.com/43072
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-10 17:14:57 +00:00
Martin Möhrmann
69972aea74 internal/cpu: new package to detect cpu features
Implements detection of x86 cpu features that
are used in the go standard library.

Changes all standard library packages to use the new cpu package
instead of using runtime internal variables to check x86 cpu features.

Updates: #15403

Change-Id: I2999a10cb4d9ec4863ffbed72f4e021a1dbc4bb9
Reviewed-on: https://go-review.googlesource.com/41476
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-10 17:02:21 +00:00
Michael Munday
4fc498d89a cmd/compile: add generic rules to eliminate some unnecessary stores
Eliminates stores of values that have just been loaded from the same
location. Handles the common case where there are up to 3 intermediate
stores to non-overlapping struct fields.

For example the loads and stores of x.a, x.b and x.d in the following
function are now removed:

type T struct {
	a, b, c, d int
}

func f(x *T) {
	y := *x
	y.c += 8
	*x = y
}

Before this CL (s390x):

TEXT    "".f(SB)
	MOVD    "".x(R15), R5
	MOVD    (R5), R1
	MOVD    8(R5), R2
	MOVD    16(R5), R0
	MOVD    24(R5), R4
	ADD     $8, R0, R3
	STMG    R1, R4, (R5)
	RET

After this CL (s390x):

TEXT	"".f(SB)
	MOVD	"".x(R15), R1
	MOVD	16(R1), R0
	ADD	$8, R0, R0
	MOVD	R0, 16(R1)
	RET

In total these rules are triggered ~5091 times during all.bash,
which is broken down as:

Intermediate stores | Triggered
--------------------+----------
0                   | 1434
1                   | 2508
2                   | 888
3                   | 261
--------------------+----------

Change-Id: Ia4721ae40146aceec1fdd3e65b0e9283770bfba5
Reviewed-on: https://go-review.googlesource.com/38793
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-10 15:58:43 +00:00
Michael Munday
cb83924d5b cmd/compile/internal/ssa: fix generation of ppc64x rules
The files PPC64.rules and rewritePPC64.go were out of sync due to
conflicts between CL 41630 and CL 42145 (i.e. running 'go run *.go'
in the gen directory resulted in unexpected changes).

Change-Id: I1d409656b66afeab6cb9c6df9b3dcab7859caa75
Reviewed-on: https://go-review.googlesource.com/43091
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2017-05-10 15:32:12 +00:00
David Chase
41d0bbdc16 cmd/link: include DW_AT_producer in .debug_info
This can make life easier for Delve (and other debuggers),
and can help them with bug reports.

Sample producer field (from objdump):
<48> DW_AT_producer : Go cmd/compile devel +8a59dbf41a Mon May 8 16:02:44 2017 -0400

Change-Id: I0605843c959b53a60a25a3b870aa8755bf5d5b13
Reviewed-on: https://go-review.googlesource.com/33588
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-05-10 14:47:41 +00:00
Daniel Martí
9bced47706 reflect: don't panic in ArrayOf if elem size is 0
We do a division by the elem type size to check if the array size would
be too large for the virtual address space. This is a silly check if the
size is 0, but the problem is that it means a division by zero and a
panic.

Since arrays of empty structs are valid in a regular program, make them
also work in reflect.

Use a separate, explicit test with struct{}{} to make sure the test for
a zero-sized type is not confused with the rest.

Fixes #20313.

Change-Id: I47b8b87e6541631280b79227bdea6a0f6035c9e0
Reviewed-on: https://go-review.googlesource.com/43131
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-10 13:44:53 +00:00
Lynn Boger
8304d10763 cmd/compile: ppc64x intrinsics for math/bits
This adds math/bits intrinsics for OnesCount, Len, TrailingZeros on
ppc64x.

benchmark                       old ns/op     new ns/op     delta
BenchmarkLeadingZeros-16        4.26          1.71          -59.86%
BenchmarkLeadingZeros16-16      3.04          1.83          -39.80%
BenchmarkLeadingZeros32-16      3.31          1.82          -45.02%
BenchmarkLeadingZeros64-16      3.69          1.71          -53.66%
BenchmarkTrailingZeros-16       2.55          1.62          -36.47%
BenchmarkTrailingZeros32-16     2.55          1.77          -30.59%
BenchmarkTrailingZeros64-16     2.78          1.62          -41.73%
BenchmarkOnesCount-16           3.19          0.93          -70.85%
BenchmarkOnesCount32-16         2.55          1.18          -53.73%
BenchmarkOnesCount64-16         3.22          0.93          -71.12%

Update #18616

I also made a change to bits_test.go because when debugging some failures
the output was not quite providing the right argument information.

Change-Id: Ia58d31d1777cf4582a4505f85b11a1202ca07d3e
Reviewed-on: https://go-review.googlesource.com/41630
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-10 12:10:56 +00:00
Daniel Martí
a4864094f0 reflect: fix String of new array types
When constructing a new type for an array type in ArrayOf, we don't
reset tflag to 0. All the other methods in the package, such as SliceOf,
do this already. This results in the new array type having weird issues
when being printed, such as having tflagExtraStar set when it shouldn't.

That flag removes the first char to get rid of '*', but when used
incorrectly in this case it eats the '[' character leading to broken
strings like "3]int".

This was fixed in 56752eb2 for issue #16722, but ArrayOf was missed.

Also make the XM test struct have a non-zero size as that leads to a
division by zero panic in ArrayOf.

Fixes #20311.

Change-Id: I18f1027fdbe9f71767201e7424269c3ceeb23eb5
Reviewed-on: https://go-review.googlesource.com/43130
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-10 11:42:46 +00:00
Marvin Stenger
266a3b66ca cmd/compile/internal/gc: rename signatlist to signatset
Also change type from map[*types.Type]bool to map[*types.Type]struct{}.
This is basically a clean-up.

Change-Id: I167583eff0fa1070a7522647219476033b52b840
Reviewed-on: https://go-review.googlesource.com/41859
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-10 01:47:54 +00:00
Josh Bleecher Snyder
1213776650 cmd/compile: use a buffered channel for the function queue
Updates #20307

With -c=2:

name        old time/op       new time/op       delta
Template          140ms ± 3%        139ms ± 4%  -1.06%  (p=0.003 n=50+50)
Unicode          81.1ms ± 4%       81.9ms ± 4%  +0.96%  (p=0.006 n=50+49)
GoTypes           375ms ± 3%        374ms ± 3%    ~     (p=0.094 n=48+48)
Compiler          1.69s ± 2%        1.68s ± 2%  -0.41%  (p=0.004 n=49+48)
SSA               3.05s ± 1%        3.05s ± 2%    ~     (p=0.953 n=47+49)
Flate            86.3ms ± 2%       85.9ms ± 2%  -0.49%  (p=0.011 n=49+48)
GoParser         99.5ms ± 3%       99.3ms ± 3%    ~     (p=0.394 n=48+49)
Reflect           262ms ± 3%        261ms ± 3%    ~     (p=0.354 n=47+49)
Tar              81.4ms ± 3%       79.7ms ± 4%  -1.98%  (p=0.000 n=47+50)
XML               133ms ± 3%        133ms ± 3%    ~     (p=0.992 n=50+49)
[Geo mean]        236ms             235ms       -0.36%

name        old user-time/op  new user-time/op  delta
Template          249ms ± 5%        242ms ± 7%  -2.61%  (p=0.000 n=48+50)
Unicode           111ms ± 4%        111ms ± 6%    ~     (p=0.407 n=46+47)
GoTypes           753ms ± 2%        748ms ± 3%  -0.65%  (p=0.010 n=48+50)
Compiler          3.28s ± 2%        3.27s ± 2%  -0.40%  (p=0.026 n=49+47)
SSA               7.03s ± 2%        7.01s ± 3%    ~     (p=0.154 n=45+50)
Flate             154ms ± 3%        154ms ± 3%    ~     (p=0.306 n=49+49)
GoParser          180ms ± 4%        179ms ± 4%    ~     (p=0.148 n=48+48)
Reflect           427ms ± 2%        428ms ± 3%    ~     (p=0.502 n=46+49)
Tar               142ms ± 5%        135ms ± 9%  -4.83%  (p=0.000 n=46+50)
XML               247ms ± 3%        247ms ± 4%    ~     (p=0.921 n=49+49)
[Geo mean]        426ms             422ms       -0.92%


Change-Id: I4746234439ddb9a7e5840fc783b8857da6a4a680
Reviewed-on: https://go-review.googlesource.com/43110
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-10 01:44:12 +00:00
Josh Bleecher Snyder
94a017f3f5 cmd/compile: allow OpVarXXX calls to be duplicated in writebarrier blocks
OpVarXXX Values don't generate instructions,
so there's no reason not to duplicate them,
and duplicating them generates better code
(fewer branches).

This requires changing the start/end accounting
to correctly handle the case in which we have run
of Values beginning with an OpVarXXX, e.g.
OpVarDef, OpZeroWB, OpMoveWB.
In that case, the sequence of values should begin
at the OpZeroWB, not the OpVarDef.

This also lays the groundwork for experimenting
with allowing duplication of some scalar stores.

Shrinks function text sizes a tiny amount:

name        old object-bytes  new object-bytes  delta
Template           381k ± 0%         381k ± 0%  -0.01%  (p=0.008 n=5+5)
Unicode            203k ± 0%         203k ± 0%  -0.04%  (p=0.008 n=5+5)
GoTypes           1.17M ± 0%        1.17M ± 0%  -0.01%  (p=0.008 n=5+5)
SSA               8.24M ± 0%        8.24M ± 0%  -0.00%  (p=0.008 n=5+5)
Flate              230k ± 0%         230k ± 0%    ~     (all equal)
GoParser           286k ± 0%         286k ± 0%    ~     (all equal)
Reflect           1.00M ± 0%        1.00M ± 0%    ~     (all equal)
Tar                189k ± 0%         189k ± 0%    ~     (all equal)
XML                415k ± 0%         415k ± 0%  -0.01%  (p=0.008 n=5+5)

Updates #19838

Change-Id: Ic5ef30855919f1468066eba08ae5c4bd9a01db27
Reviewed-on: https://go-review.googlesource.com/42011
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2017-05-09 23:54:14 +00:00
Ian Lance Taylor
5331e7e9df cmd/internal/obj, cmd/link: fix st_other field on PPC64
In PPC64 ELF files, the st_other field indicates the number of
prologue instructions between the global and local entry points.
We add the instructions in the compiler and assembler if -shared is used.
We were assuming that the instructions were present when building a
c-archive or PIE or doing dynamic linking, on the assumption that those
are the cases where the go tool would be building with -shared.
That assumption fails when using some other tool, such as Bazel,
that does not necessarily use -shared in exactly the same way.

This CL records in the object file whether a symbol was compiled
with -shared (this will be the same for all symbols in a given compilation)
and uses that information when setting the st_other field.

Fixes #20290.

Change-Id: Ib2b77e16aef38824871102e3c244fcf04a86c6ea
Reviewed-on: https://go-review.googlesource.com/43051
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-05-09 23:36:51 +00:00
Todd Neal
08dca4c649 cmd/compile: ignore types when considering tuple select for CSE
Fixes #20097

Change-Id: I3c9626ccc8cd0c46a7081ea8650b2ff07a5d4fcd
Reviewed-on: https://go-review.googlesource.com/41505
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-09 23:22:00 +00:00
Josh Bleecher Snyder
46b88c9fbc cmd/compile: change ssa.Type into *types.Type
When package ssa was created, Type was in package gc.
To avoid circular dependencies, we used an interface (ssa.Type)
to represent type information in SSA.

In the Go 1.9 cycle, gri extricated the Type type from package gc.
As a result, we can now use it in package ssa.
Now, instead of package types depending on package ssa,
it is the other way.
This is a more sensible dependency tree,
and helps compiler performance a bit.

Though this is a big CL, most of the changes are
mechanical and uninteresting.

Interesting bits:

* Add new singleton globals to package types for the special
  SSA types Memory, Void, Invalid, Flags, and Int128.
* Add two new Types, TSSA for the special types,
  and TTUPLE, for SSA tuple types.
  ssa.MakeTuple is now types.NewTuple.
* Move type comparison result constants CMPlt, CMPeq, and CMPgt
  to package types.
* We had picked the name "types" in our rules for the handy
  list of types provided by ssa.Config. That conflicted with
  the types package name, so change it to "typ".
* Update the type comparison routine to handle tuples and special
  types inline.
* Teach gc/fmt.go how to print special types.
* We can now eliminate ElemTypes in favor of just Elem,
  and probably also some other duplicated Type methods
  designed to return ssa.Type instead of *types.Type.
* The ssa tests were using their own dummy types,
  and they were not particularly careful about types in general.
  Of necessity, this CL switches them to use *types.Type;
  it does not make them more type-accurate.
  Unfortunately, using types.Type means initializing a bit
  of the types universe.
  This is prime for refactoring and improvement.

This shrinks ssa.Value; it now fits in a smaller size class
on 64 bit systems. This doesn't have a giant impact,
though, since most Values are preallocated in a chunk.

name        old alloc/op      new alloc/op      delta
Template         37.9MB ± 0%       37.7MB ± 0%  -0.57%  (p=0.000 n=10+8)
Unicode          28.9MB ± 0%       28.7MB ± 0%  -0.52%  (p=0.000 n=10+10)
GoTypes           110MB ± 0%        109MB ± 0%  -0.88%  (p=0.000 n=10+10)
Flate            24.7MB ± 0%       24.6MB ± 0%  -0.66%  (p=0.000 n=10+10)
GoParser         31.1MB ± 0%       30.9MB ± 0%  -0.61%  (p=0.000 n=10+9)
Reflect          73.9MB ± 0%       73.4MB ± 0%  -0.62%  (p=0.000 n=10+8)
Tar              25.8MB ± 0%       25.6MB ± 0%  -0.77%  (p=0.000 n=9+10)
XML              41.2MB ± 0%       40.9MB ± 0%  -0.80%  (p=0.000 n=10+10)
[Geo mean]       40.5MB            40.3MB       -0.68%

name        old allocs/op     new allocs/op     delta
Template           385k ± 0%         386k ± 0%    ~     (p=0.356 n=10+9)
Unicode            343k ± 1%         344k ± 0%    ~     (p=0.481 n=10+10)
GoTypes           1.16M ± 0%        1.16M ± 0%  -0.16%  (p=0.004 n=10+10)
Flate              238k ± 1%         238k ± 1%    ~     (p=0.853 n=10+10)
GoParser           320k ± 0%         320k ± 0%    ~     (p=0.720 n=10+9)
Reflect            957k ± 0%         957k ± 0%    ~     (p=0.460 n=10+8)
Tar                252k ± 0%         252k ± 0%    ~     (p=0.133 n=9+10)
XML                400k ± 0%         400k ± 0%    ~     (p=0.796 n=10+10)
[Geo mean]         428k              428k       -0.01%


Removing all the interface calls helps non-trivially with CPU, though.

name        old time/op       new time/op       delta
Template          178ms ± 4%        173ms ± 3%  -2.90%  (p=0.000 n=94+96)
Unicode          85.0ms ± 4%       83.9ms ± 4%  -1.23%  (p=0.000 n=96+96)
GoTypes           543ms ± 3%        528ms ± 3%  -2.73%  (p=0.000 n=98+96)
Flate             116ms ± 3%        113ms ± 4%  -2.34%  (p=0.000 n=96+99)
GoParser          144ms ± 3%        140ms ± 4%  -2.80%  (p=0.000 n=99+97)
Reflect           344ms ± 3%        334ms ± 4%  -3.02%  (p=0.000 n=100+99)
Tar               106ms ± 5%        103ms ± 4%  -3.30%  (p=0.000 n=98+94)
XML               198ms ± 5%        192ms ± 4%  -2.88%  (p=0.000 n=92+95)
[Geo mean]        178ms             173ms       -2.65%

name        old user-time/op  new user-time/op  delta
Template          229ms ± 5%        224ms ± 5%  -2.36%  (p=0.000 n=95+99)
Unicode           107ms ± 6%        106ms ± 5%  -1.13%  (p=0.001 n=93+95)
GoTypes           696ms ± 4%        679ms ± 4%  -2.45%  (p=0.000 n=97+99)
Flate             137ms ± 4%        134ms ± 5%  -2.66%  (p=0.000 n=99+96)
GoParser          176ms ± 5%        172ms ± 8%  -2.27%  (p=0.000 n=98+100)
Reflect           430ms ± 6%        411ms ± 5%  -4.46%  (p=0.000 n=100+92)
Tar               128ms ±13%        123ms ±13%  -4.21%  (p=0.000 n=100+100)
XML               239ms ± 6%        233ms ± 6%  -2.50%  (p=0.000 n=95+97)
[Geo mean]        220ms             213ms       -2.76%


Change-Id: I15c7d6268347f8358e75066dfdbd77db24e8d0c1
Reviewed-on: https://go-review.googlesource.com/42145
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-09 23:01:51 +00:00
Josh Bleecher Snyder
6a24b2d0c1 cmd/compile: add boolean simplification rules
These collectively fire a few hundred times during make.bash,
mostly rewriting XOR SETNE -> SETEQ.

Fixes #17905.

Change-Id: Ic5eb241ee93ed67099da3de11f59e4df9fab64a3
Reviewed-on: https://go-review.googlesource.com/42491
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-09 21:50:55 +00:00
Marvin Stenger
9aeced650f cmd/compile/internal/ssa: mark boolean instructions commutative
Mark AndB, OrB, EqB, and NeqB as commutative.

Change-Id: Ife7cfcb9780cc5dd669617cb52339ab336667da4
Reviewed-on: https://go-review.googlesource.com/42515
Reviewed-by: Giovanni Bajo <rasky@develer.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-09 21:31:38 +00:00
Josh Bleecher Snyder
6f2ee0f3df cmd/compile: make builds reproducible in presence of **byte and **int8
CL 39915 introduced sorting of signats by ShortString
for reproducible builds. But ShortString treats types
byte and uint8 identically; same for rune and uint32.
CL 39915 attempted to compensate for this by only
adding the underlying type (uint8) to signats in addsignat.

This only works for byte and uint8. For e.g. *byte and *uint,
both get added, and their sort order is random,
leading to non-reproducible builds.

One fix would be to add yet another type printing mode
that doesn't eliminate byte and rune, and use it
for sorting signats. But the formatting routines
are complicated enough as it is.

Instead, just sort first by ShortString and then by String.
We can't just use String, because ShortString makes distinctions
that String doesn't. ShortString is really preferred here;
String is serving only as a backstop for handling of bytes and runes.

The long series of types in the test helps increase the odds of
failure, allowing a smaller number of iterations in the test.
On my machine, a full test takes 700ms.

Passes toolstash-check.

Updates #19961
Fixes #20272

name        old alloc/op      new alloc/op      delta
Template         37.9MB ± 0%       37.9MB ± 0%  +0.12%  (p=0.032 n=5+5)
Unicode          28.9MB ± 0%       28.9MB ± 0%    ~     (p=0.841 n=5+5)
GoTypes           110MB ± 0%        110MB ± 0%    ~     (p=0.841 n=5+5)
Compiler          463MB ± 0%        463MB ± 0%    ~     (p=0.056 n=5+5)
SSA              1.11GB ± 0%       1.11GB ± 0%  +0.02%  (p=0.016 n=5+5)
Flate            24.7MB ± 0%       24.8MB ± 0%  +0.14%  (p=0.032 n=5+5)
GoParser         31.1MB ± 0%       31.1MB ± 0%    ~     (p=0.421 n=5+5)
Reflect          73.9MB ± 0%       73.9MB ± 0%    ~     (p=1.000 n=5+5)
Tar              25.8MB ± 0%       25.8MB ± 0%  +0.15%  (p=0.016 n=5+5)
XML              41.2MB ± 0%       41.2MB ± 0%    ~     (p=0.310 n=5+5)
[Geo mean]       72.0MB            72.0MB       +0.07%

name        old allocs/op     new allocs/op     delta
Template           384k ± 0%         385k ± 1%    ~     (p=0.056 n=5+5)
Unicode            343k ± 0%         344k ± 0%    ~     (p=0.548 n=5+5)
GoTypes           1.16M ± 0%        1.16M ± 0%    ~     (p=0.421 n=5+5)
Compiler          4.43M ± 0%        4.44M ± 0%  +0.26%  (p=0.032 n=5+5)
SSA               9.86M ± 0%        9.87M ± 0%  +0.10%  (p=0.032 n=5+5)
Flate              237k ± 1%         238k ± 0%  +0.49%  (p=0.032 n=5+5)
GoParser           319k ± 1%         320k ± 1%    ~     (p=0.151 n=5+5)
Reflect            957k ± 0%         957k ± 0%    ~     (p=1.000 n=5+5)
Tar                251k ± 0%         252k ± 1%  +0.49%  (p=0.016 n=5+5)
XML                399k ± 0%         401k ± 1%    ~     (p=0.310 n=5+5)
[Geo mean]         739k              741k       +0.26%

Change-Id: Ic27995a8d374d012b8aca14546b1df9d28d30df7
Reviewed-on: https://go-review.googlesource.com/42955
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-05-09 21:15:12 +00:00
Josh Bleecher Snyder
9fda4df9a0 cmd/compile: make "imported and not used" errors deterministic
If there were more unused imports than
the maximum default number of errors to report,
the set of reported imports was non-deterministic.

Fix by accumulating and sorting them prior to output.

Fixes #20298

Change-Id: Ib3d5a15fd7dc40009523fcdc1b93ddc62a1b05f2
Reviewed-on: https://go-review.googlesource.com/42954
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-05-09 21:14:56 +00:00
Cherry Zhang
fb0ccc5d0a cmd/internal/obj/arm64, cmd/compile: improve offset folding on ARM64
ARM64 assembler backend only accepts loads and stores with small
or aligned offset. The compiler therefore can only fold small or
aligned offsets into loads and stores. For locals and args, their
offsets to SP are not known until very late, and the compiler
makes conservative decision not folding some of them. However,
in most cases, the offset is indeed small or aligned, and can
be folded into load and store (but actually not).

This CL adds support of loads and stores with large and unaligned
offsets. When the offset doesn't fit into the instruction, it
uses two instructions and (for very large offset) the constant
pool. This way, the compiler doesn't need to be conservative,
and can simply fold the offset.

To make it work, the assembler's optab matching rules need to be
changed. Before, MOVD accepts C_UAUTO32K which matches multiple
of 8 between 0 and 32K, and also C_UAUTO16K, which may not be
multiple of 8 and does not fit into MOVD instruction. The
assembler errors in the latter case. This change makes it only
matches multiple of 8 (or offsets within ±256, which also fits
in instruction), and uses the large-or-unaligned-offset rule
for things doesn't fit (without error). Other sized move rules
are changed similarly.

Class C_UAUTO64K and C_UOREG64K are removed, as they are never
used.

In shared library, load/store of global is rewritten to using
GOT and temp register, which conflicts with the use of temp
register for assembling large offset. So the folding is disabled
for globals in shared library mode.

Reduce cmd/go binary size by 2%.

name                     old time/op    new time/op    delta
BinaryTree17-8              8.67s ± 0%     8.61s ± 0%   -0.60%  (p=0.000 n=9+10)
Fannkuch11-8                6.24s ± 0%     6.19s ± 0%   -0.83%  (p=0.000 n=10+9)
FmtFprintfEmpty-8           116ns ± 0%     116ns ± 0%     ~     (all equal)
FmtFprintfString-8          196ns ± 0%     192ns ± 0%   -1.89%  (p=0.000 n=10+10)
FmtFprintfInt-8             199ns ± 0%     198ns ± 0%   -0.35%  (p=0.001 n=9+10)
FmtFprintfIntInt-8          294ns ± 0%     293ns ± 0%   -0.34%  (p=0.000 n=8+8)
FmtFprintfPrefixedInt-8     318ns ± 1%     318ns ± 1%     ~     (p=1.000 n=10+10)
FmtFprintfFloat-8           537ns ± 0%     531ns ± 0%   -1.17%  (p=0.000 n=9+10)
FmtManyArgs-8              1.19µs ± 1%    1.18µs ± 1%   -1.41%  (p=0.001 n=10+10)
GobDecode-8                17.2ms ± 1%    17.3ms ± 2%     ~     (p=0.165 n=10+10)
GobEncode-8                14.7ms ± 1%    14.7ms ± 2%     ~     (p=0.631 n=10+10)
Gzip-8                      837ms ± 0%     836ms ± 0%   -0.14%  (p=0.006 n=9+10)
Gunzip-8                    141ms ± 0%     139ms ± 0%   -1.24%  (p=0.000 n=9+10)
HTTPClientServer-8          256µs ± 1%     253µs ± 1%   -1.35%  (p=0.000 n=10+10)
JSONEncode-8               40.1ms ± 1%    41.3ms ± 1%   +3.06%  (p=0.000 n=10+9)
JSONDecode-8                157ms ± 1%     156ms ± 1%   -0.83%  (p=0.001 n=9+8)
Mandelbrot200-8            8.94ms ± 0%    8.94ms ± 0%   +0.02%  (p=0.000 n=9+9)
GoParse-8                  8.69ms ± 0%    8.54ms ± 1%   -1.69%  (p=0.000 n=8+10)
RegexpMatchEasy0_32-8       227ns ± 1%     228ns ± 1%   +0.48%  (p=0.016 n=10+9)
RegexpMatchEasy0_1K-8      1.92µs ± 0%    1.63µs ± 0%  -15.08%  (p=0.000 n=10+9)
RegexpMatchEasy1_32-8       256ns ± 0%     251ns ± 0%   -2.19%  (p=0.000 n=10+9)
RegexpMatchEasy1_1K-8      2.38µs ± 0%    2.09µs ± 0%  -12.49%  (p=0.000 n=10+9)
RegexpMatchMedium_32-8      352ns ± 0%     354ns ± 0%   +0.39%  (p=0.002 n=10+9)
RegexpMatchMedium_1K-8      106µs ± 0%     106µs ± 0%   -0.05%  (p=0.005 n=10+9)
RegexpMatchHard_32-8       5.92µs ± 0%    5.89µs ± 0%   -0.40%  (p=0.000 n=9+8)
RegexpMatchHard_1K-8        180µs ± 0%     179µs ± 0%   -0.14%  (p=0.000 n=10+9)
Revcomp-8                   1.20s ± 0%     1.13s ± 0%   -6.29%  (p=0.000 n=9+8)
Template-8                  159ms ± 1%     154ms ± 1%   -3.14%  (p=0.000 n=9+10)
TimeParse-8                 800ns ± 3%     769ns ± 1%   -3.91%  (p=0.000 n=10+10)
TimeFormat-8                826ns ± 2%     817ns ± 2%   -1.04%  (p=0.050 n=10+10)
[Geo mean]                  145µs          143µs        -1.79%

Change-Id: I5fc42087cee9b54ea414f8ef6d6d020b80eb5985
Reviewed-on: https://go-review.googlesource.com/42172
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
2017-05-09 19:41:00 +00:00
Josh Bleecher Snyder
5e0bcb3893 cmd/go: enable concurrent backend compilation by default
It can be disabled by setting the environment variable
GO19CONCURRENTCOMPILATION=0, or with -gcflags=-c=1.

Fixes #15756.

Change-Id: I7acbf16330512b62ee14ecbab1f46b53ec5a67b6
Reviewed-on: https://go-review.googlesource.com/41820
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-09 19:22:10 +00:00
Josh Bleecher Snyder
f4e5bd483b cmd/go: add support for concurrent backend compilation
It is disabled by default.
It can be enabled by setting the environment variable
GO19CONCURRENTCOMPILATION=1.

Benchmarking results are presented in a grid.
Columns are different values of c (compiler backend concurrency);
rows are different values of p (process concurrency).

'go build -a std cmd', a 4 core raspberry pi 3:

            c=1        c=2        c=4
StdCmd/p=1  504s ± 2%  413s ± 4%  367s ± 3%
StdCmd/p=2  314s ± 3%  266s ± 4%  267s ± 4%
StdCmd/p=4  254s ± 5%  241s ± 5%  238s ± 6%

'go build -a std cmd', an 8 core darwin/amd64 laptop:

            c=1         c=2         c=4         c=6         c=8
StdCmd/p=1  40.4s ± 7%  31.0s ± 1%  27.3s ± 1%  27.8s ± 0%  27.7s ± 0%
StdCmd/p=2  21.9s ± 1%  17.9s ± 1%  16.9s ± 1%  17.0s ± 1%  17.2s ± 0%
StdCmd/p=4  17.4s ± 2%  14.5s ± 2%  13.3s ± 2%  13.5s ± 2%  13.6s ± 2%
StdCmd/p=6  16.9s ± 1%  14.2s ± 2%  13.1s ± 2%  13.2s ± 2%  13.3s ± 2%
StdCmd/p=8  16.7s ± 2%  14.2s ± 2%  13.2s ± 3%  13.2s ± 2%  13.4s ± 2%

'go build -a std cmd', a 96 core arm64 server:

             c=1         c=2         c=4         c=6         c=8         c=16        c=32        c=64        c=96
StdCmd/p=1    173s ± 1%   133s ± 1%   114s ± 1%   109s ± 1%   106s ± 0%   106s ± 1%   107s ± 1%   110s ± 1%   113s ± 1%
StdCmd/p=2   94.2s ± 2%  71.5s ± 1%  61.7s ± 1%  58.7s ± 1%  57.5s ± 2%  56.9s ± 1%  58.0s ± 1%  59.6s ± 1%  61.0s ± 1%
StdCmd/p=4   74.1s ± 2%  53.5s ± 1%  43.7s ± 2%  40.5s ± 1%  39.2s ± 2%  38.9s ± 2%  39.5s ± 3%  40.3s ± 2%  40.8s ± 1%
StdCmd/p=6   69.3s ± 1%  50.2s ± 2%  40.3s ± 2%  37.3s ± 3%  36.0s ± 3%  35.3s ± 2%  36.0s ± 2%  36.8s ± 2%  37.5s ± 2%
StdCmd/p=8   66.1s ± 2%  47.7s ± 2%  38.6s ± 2%  35.7s ± 2%  34.4s ± 1%  33.6s ± 2%  34.2s ± 2%  34.6s ± 1%  35.0s ± 1%
StdCmd/p=16  63.4s ± 2%  45.3s ± 2%  36.3s ± 2%  33.3s ± 2%  32.0s ± 3%  31.6s ± 2%  32.1s ± 2%  32.5s ± 2%  32.7s ± 2%
StdCmd/p=32  62.2s ± 1%  44.2s ± 2%  35.3s ± 2%  32.4s ± 2%  31.2s ± 2%  30.9s ± 2%  31.1s ± 2%  31.7s ± 2%  32.0s ± 2%
StdCmd/p=64  62.2s ± 1%  44.3s ± 2%  35.4s ± 2%  32.4s ± 2%  31.2s ± 2%  30.9s ± 2%  31.2s ± 2%  31.8s ± 3%  32.2s ± 3%
StdCmd/p=96  62.2s ± 2%  44.4s ± 2%  35.3s ± 2%  32.3s ± 2%  31.1s ± 2%  30.9s ± 3%  31.3s ± 2%  31.7s ± 1%  32.1s ± 2%

benchjuju, an 8 core darwin/amd64 laptop:

               c=1         c=2         c=4         c=6         c=8
BuildJuju/p=1  55.3s ± 0%  46.3s ± 0%  41.9s ± 0%  41.4s ± 1%  41.3s ± 0%
BuildJuju/p=2  33.7s ± 1%  28.4s ± 1%  26.7s ± 1%  26.6s ± 1%  26.8s ± 1%
BuildJuju/p=4  24.7s ± 1%  22.3s ± 1%  21.4s ± 1%  21.7s ± 1%  21.8s ± 1%
BuildJuju/p=6  20.6s ± 1%  19.3s ± 2%  19.4s ± 1%  19.7s ± 1%  19.9s ± 1%
BuildJuju/p=8  20.6s ± 2%  19.5s ± 2%  19.3s ± 2%  19.6s ± 1%  19.8s ± 2%

Updates #15756

Change-Id: I8a56e88953071a05eee764002024c54cd888a56c
Reviewed-on: https://go-review.googlesource.com/41819
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-09 19:18:18 +00:00
Ibrahim AshShohail
541029636a go/token: remove excess parenthesis in NoPos.IsValid() documentation
Fixes #20294

Change-Id: I32ac862fe00180210a04103cc94c4d9fef5d1b6c
Reviewed-on: https://go-review.googlesource.com/42992
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-09 15:05:14 +00:00
Austin Clements
d659682de2 runtime/pprof: deflake TestGoroutineCounts
TestGoroutineCounts currently depends on timing to get 100 goroutines
to a known blocking point before taking a profile. This fails
frequently, with different goroutines captured at different stacks.
The test is disabled on openbsd because it was too flaky, but in fact
it flakes on all platforms.

Fix this by using Gosched instead of timing. This is both much more
reliable and makes the test run faster.

Fixes #15156.

Change-Id: Ia6e894196d717655b8fb4ee96df53f6cc8bc5f1f
Reviewed-on: https://go-review.googlesource.com/42953
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-09 15:04:46 +00:00
Ian Lance Taylor
9eacd977a0 cmd/go: put user flags after code generation flag
This permits the user to override the code generation flag when they
know better. This is always a good policy for all flags automatically
inserted by the build system.

Doing this now so that I can write a test for #20290.

Update #20290

Change-Id: I5c6708a277238d571b8d037993a5a59e2a442e98
Reviewed-on: https://go-review.googlesource.com/42952
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-09 14:23:50 +00:00
Rob Phoenix
1e732ca388 net: fix ExampleParseCIDR IPv4 prefix length
Issue #15228 describes that reserved address blocks should be used for
documentation purposes. This change updates the prefix length so the
IPv4 address adheres to this.

Change-Id: I237d9cce1a71f4fd95f927ec894ce53fa806047f
Reviewed-on: https://go-review.googlesource.com/42991
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-09 13:47:33 +00:00
Alex Brainman
096e2bffdf cmd/go: run tests that require symlinks
Change-Id: I19a724ea4eb1ba0ff558721650c89a949e53b7c7
Reviewed-on: https://go-review.googlesource.com/42895
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-09 04:49:30 +00:00
Alex Brainman
6dcaa095c5 os: avoid calulating fileStat.path until it is needed
This CL improves

on my Windows 7

name         old time/op    new time/op    delta
Readdirname    58.1µs ± 1%    58.1µs ± 0%     ~     (p=0.817 n=8+8)
Readdir        58.0µs ± 3%    57.8µs ± 0%     ~     (p=0.944 n=9+8)

name         old alloc/op   new alloc/op   delta
Readdirname    3.03kB ± 0%    2.84kB ± 0%   -6.33%  (p=0.000 n=10+10)
Readdir        3.00kB ± 0%    2.81kB ± 0%   -6.40%  (p=0.000 n=10+10)

name         old allocs/op  new allocs/op  delta
Readdirname      34.0 ± 0%      30.0 ± 0%  -11.76%  (p=0.000 n=10+10)
Readdir          33.0 ± 0%      29.0 ± 0%  -12.12%  (p=0.000 n=10+10)

on my Windows XP

name           old time/op    new time/op    delta
Readdirname-2    85.5µs ± 0%    84.0µs ± 0%   -1.83%  (p=0.000 n=10+10)
Readdir-2        84.6µs ± 0%    83.5µs ± 0%   -1.31%  (p=0.000 n=10+9)

name           old alloc/op   new alloc/op   delta
Readdirname-2    6.52kB ± 0%    5.66kB ± 0%  -13.25%  (p=0.000 n=10+10)
Readdir-2        6.39kB ± 0%    5.53kB ± 0%  -13.52%  (p=0.000 n=10+10)

name           old allocs/op  new allocs/op  delta
Readdirname-2      78.0 ± 0%      66.0 ± 0%  -15.38%  (p=0.000 n=10+10)
Readdir-2          77.0 ± 0%      65.0 ± 0%  -15.58%  (p=0.000 n=10+10)

Change-Id: I5d698eca86b8e94a46b6cfbd5947898b7b3fbdbd
Reviewed-on: https://go-review.googlesource.com/42894
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-09 04:47:47 +00:00
ltnwgl
f5352a7763 container/heap: optimization when selecting smaller child
In down(), if two children are equal, we can choose either one.
Inspired by https://codereview.appspot.com/6613064/

Change-Id: Iaad4ca5e2f5111bf3abb87f606584e7d274c620b
Reviewed-on: https://go-review.googlesource.com/38612
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-05-09 03:38:37 +00:00
Rob Phoenix
716761b8b1 net: add examples for IPv4, ParseCIDR & IPv4Mask
Further examples to support the net package.

See issue #5757

Change-Id: I839fd97a468c8d9195e8f4a0ee886ba50ca3f382
Reviewed-on: https://go-review.googlesource.com/42912
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-09 00:34:38 +00:00
Robert Griesemer
bcf2d74ce8 cmd/compile: better errors for float constants with large exponents
Also: Removed misleading comment.

Fixes #20232.

Change-Id: I0b141b1360ac53267b7ebfcec7a2e2a238f3f46c
Reviewed-on: https://go-review.googlesource.com/42930
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-05-08 22:56:10 +00:00
Bill O'Farrell
88672de7af math: use SIMD to accelerate additional scalar math functions on s390x
As necessary, math functions were structured to use stubs, so that they can
be accelerated with assembly on any platform.

Technique used was minimax polynomial approximation using tables of
polynomial coefficients, with argument range reduction.

Benchmark         New     Old     Speedup
BenchmarkAcos     12.2    47.5    3.89
BenchmarkAcosh    18.5    56.2    3.04
BenchmarkAsin     13.1    40.6    3.10
BenchmarkAsinh    19.4    62.8    3.24
BenchmarkAtan     10.1    23      2.28
BenchmarkAtanh    19.1    53.2    2.79
BenchmarkAtan2    16.5    33.9    2.05
BenchmarkCbrt     14.8    58      3.92
BenchmarkErf      10.8    20.1    1.86
BenchmarkErfc     11.2    23.5    2.10
BenchmarkExp      8.77    53.8    6.13
BenchmarkExpm1    10.1    38.3    3.79
BenchmarkLog      13.1    40.1    3.06
BenchmarkLog1p    12.7    38.3    3.02
BenchmarkPowInt   31.7    40.5    1.28
BenchmarkPowFrac  33.1    141     4.26
BenchmarkTan      11.5    30      2.61

Accuracy was tested against a high precision
reference function to determine maximum error.
Note: ulperr is error in "units in the last place"

       max
      ulperr
Acos  1.15
Acosh 1.07
Asin  2.22
Asinh 1.72
Atan  1.41
Atanh 3.00
Atan2 1.45
Cbrt  1.18
Erf   1.29
Erfc  4.82
Exp   1.00
Expm1 2.26
Log   0.94
Log1p 2.39
Tan   3.14

Pow will have 99.99% correctly rounded results with reasonable inputs
producing numeric (non Inf or NaN) results

Change-Id: I850e8cf7b70426e8b54ec49d74acd4cddc8c6cb2
Reviewed-on: https://go-review.googlesource.com/38585
Reviewed-by: Michael Munday <munday@ca.ibm.com>
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-08 19:52:30 +00:00
Marvin Stenger
8c49c06b48 bytes: skip inline test by default
The test "TestTryGrowByResliceInlined" introduced in c08ac36 broke the
noopt builder as it fails when inlining is disabled.
Since there are currently no other options at hand for checking
inlined-ness other than looking at emited symbols of the compilation,
we for now skip the problem causing test by default and only run
it on one specific builder ("linux-amd64").
Also see CL 42813, which introduced the test and contains comments
suggesting this temporary solution.

Change-Id: I3978ab0831da04876cf873d78959f821c459282b
Reviewed-on: https://go-review.googlesource.com/42820
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-08 15:16:21 +00:00
Alex Brainman
ddcb975ffc internal/poll: remove allocation in windows FD.Writev
Use closure parameter instead of external variable to
remove 1 allocation.

I tried to add test, but it is difficult to add something simple
and not flake here. I did test this with:

diff --git a/src/net/writev_test.go b/src/net/writev_test.go
index 4c05be4..e417d68 100644
--- a/src/net/writev_test.go
+++ b/src/net/writev_test.go
@@ -99,6 +99,15 @@ func TestBuffers_WriteTo(t *testing.T) {
 	}
 }

+func TestBuffers_WriteToAllocs(t *testing.T) {
+	allocs := testing.AllocsPerRun(10, func() {
+		testBuffer_writeTo(t, 10, false)
+	})
+	if allocs > 0 {
+		t.Fatalf("got %v; want 0", allocs)
+	}
+}
+
 func testBuffer_writeTo(t *testing.T, chunks int, useCopy bool) {
 	oldHook := poll.TestHookDidWritev
 	defer func() { poll.TestHookDidWritev = oldHook }()

It makes allocation count go down by 1 after the fix.

Before:

C:\>u:\test -test.v -test.run=WriteToAllocs
=== RUN   TestBuffers_WriteToAllocs
--- FAIL: TestBuffers_WriteToAllocs (0.05s)
        writev_test.go:107: got 66; want 0
FAIL

and after:

C:\>u:\test -test.v -test.run=WriteToAllocs
=== RUN   TestBuffers_WriteToAllocs
--- FAIL: TestBuffers_WriteToAllocs (0.04s)
        writev_test.go:107: got 65; want 0
FAIL

Thanks to @MichaelMonashev for report and the fix.

Fixes #19222

Change-Id: I0f73cd9e2c8bbaa0653083f81f3ccb83b5ea84e1
Reviewed-on: https://go-review.googlesource.com/42893
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-08 01:50:49 +00:00
Elias Naur
45d42fdcea cmd/link/internal/ld: don't link with -no_pie on darwin/arm64
Ever since CL 33301 linking darwin/arm64 excutables has resulted in
warnings like:

ld: warning: -no_pie ignored for arm64

Remove -no_pie on darwin/arm64.

Change-Id: I9f7685351fa8cce29795283e1a24fc7a6753d698
Reviewed-on: https://go-review.googlesource.com/42815
Run-TryBot: Elias Naur <elias.naur@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-07 19:12:26 +00:00
Kevin Burke
9058b9ae49 os, cmd/link: fix typos
Also switch "stating" to "statting" to describe applying os.Stat to
a resource; the former is more confusable than the latter.

Change-Id: I9d8e3506bd383f8f1479c05948c03b8c633dc4af
Reviewed-on: https://go-review.googlesource.com/42855
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-07 18:13:02 +00:00
Marvin Stenger
c08ac36761 bytes: optimize Buffer's Write, WriteString, WriteByte, and WriteRune
In the common case, the grow method only needs to reslice the internal
buffer. Making another function call to grow can be expensive when Write
is called very often with small pieces of data (like a byte or rune).
Thus, we add a tryGrowByReslice method that is inlineable so that we can
avoid an extra call in most cases.

name                       old time/op    new time/op    delta
WriteByte-4                  35.5µs ± 0%    17.4µs ± 1%   -51.03%  (p=0.000 n=19+20)
WriteRune-4                  55.7µs ± 1%    38.7µs ± 1%   -30.56%  (p=0.000 n=18+19)
BufferNotEmptyWriteRead-4     304µs ± 5%     283µs ± 3%    -6.86%  (p=0.000 n=19+17)
BufferFullSmallReads-4       87.0µs ± 5%    66.8µs ± 2%   -23.26%  (p=0.000 n=17+17)

name                       old speed      new speed      delta
WriteByte-4                 115MB/s ± 0%   235MB/s ± 1%  +104.19%  (p=0.000 n=19+20)
WriteRune-4                 221MB/s ± 1%   318MB/s ± 1%   +44.01%  (p=0.000 n=18+19)

Fixes #17857

Change-Id: I08dfb10a1c7e001817729dbfcc951bda12fe8814
Reviewed-on: https://go-review.googlesource.com/42813
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-07 17:44:46 +00:00
Damien Lespiau
23c5db9bbb cmd/asm: enable MOVSD in the encoding end-to-end test
MOVSD is properly handled but its encoding test wasn't enabled. Enable
it.

For reference this was found with a little tool I wrote [1] to explore
which instructions are missing or not tested in the go obj package and
assembler:

"which SSE2 instructions aren't tested? And don't list instructions
which can take MMX operands"

$ x86db-gogen list --extension SSE2 --not-tested --not-mmx
CLFLUSH mem           [m:  np 0f ae /7] WILLAMETTE,SSE2
MOVSD   xmmreg,xmmreg [rm: f2 0f 10 /r] WILLAMETTE,SSE2
MOVSD   xmmreg,xmmreg [mr: f2 0f 11 /r] WILLAMETTE,SSE2
MOVSD   mem64,xmmreg  [mr: f2 0f 11 /r] WILLAMETTE,SSE2
MOVSD   xmmreg,mem64  [rm: f2 0f 10 /r] WILLAMETTE,SSE2

(CLFLUSH was introduced with SSE2, but has its own CPUID bit)

[1] https://github.com/dlespiau/x86db

Change-Id: Ic3af3028cb8d4f02e53fdebb9b30fb311f4ee454
Reviewed-on: https://go-review.googlesource.com/42814
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-07 17:00:58 +00:00
Alex Brainman
5300362172 os: reimplement windows os.Stat
Currently windows Stat uses combination of Lstat and Readlink to
walk symlinks until it reaches file or directory. Windows Readlink
is implemented via Windows DeviceIoControl(FSCTL_GET_REPARSE_POINT, ...)
call, but that call does not work on network shares or inside of
Docker container (see issues #18555 ad #19922 for details).

But Raymond Chen suggests different approach:
https://blogs.msdn.microsoft.com/oldnewthing/20100212-00/?p=14963/
- he suggests to use Windows I/O manager to dereferences the
symbolic link.

This appears to work for all normal symlinks, but also for network
shares and inside of Docker container.

This CL implements described procedure.

I also had to adjust TestStatSymlinkLoop, because the test is
expecting Stat to return syscall.ELOOP for symlink with a loop.
But new Stat returns Windows error of ERROR_CANT_RESOLVE_FILENAME
= 1921 instead. I could map ERROR_CANT_RESOLVE_FILENAME into
syscall.ELOOP, but I suspect the former is broader than later.
And ERROR_CANT_RESOLVE_FILENAME message text of "The name of
the file cannot be resolved by the system." sounds fine to me.

Fixes #10935
Fixes #18555
Fixes #19922

Change-Id: I979636064cdbdb9c7c840cf8ae73fe2c24499879
Reviewed-on: https://go-review.googlesource.com/41834
Reviewed-by: Harshavardhana <hrshvardhana@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-05-07 01:26:02 +00:00
Egon Elbre
e94b9d4143 cmd/link/internal/ld: fix external linking on windows
gcc on windows writes invalid location for .debug_gdb_scripts
which causes the executable loading to fail.

Fixes #20183

Change-Id: I5134013bc926b44a55b528f66ab79555855d1f4d
Reviewed-on: https://go-review.googlesource.com/42651
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-06 06:11:31 +00:00
Ben Shi
4b2f7b4b51 cmd/asm: fix operand order of ARM's MULA instruction
As discussion in issue #19141, the addend should be the third
argument of MULA. This patch fixes it in both the front end
and the back end of the assembler. And also tests are added to
the encoding test.

Fixes #19141

Change-Id: Idbc6f338b8fdfcad97a135f27a98c5b375b27d43
Reviewed-on: https://go-review.googlesource.com/42028
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2017-05-06 01:28:38 +00:00
Nigel Tao
6d9b900a6f image/gif: don't panic on large or nil-containing color.Palettes.
Fixes #20249

Change-Id: I5dceaef31de96345f8e6c155e12775dc4cc31bfb
Reviewed-on: https://go-review.googlesource.com/42790
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-06 00:37:43 +00:00
Robert Griesemer
2eeaba4172 go/types: remove invalid documentation and assertion on package names
NewPackage required through documentation that the package name not
be blank (which wasn't true since each time we check a new package
we create one with a blank name (api.go:350). NewPackage also asserted
that a package name not be "_". While it is invalid for a package name
to be "_", one could conceivably create a package named "_" through
export data manipulation. Furthermore, it is ok to import a package
with package path "_" as long as the package itself is not named "_".

- removed misleading documentation
- removed unnecessary assertion
- added safety checks when we actually do the import

Fixes #20231.

Change-Id: I1eb1ab7b5e3130283db715374770cf05d749d159
Reviewed-on: https://go-review.googlesource.com/42852
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-05-05 23:03:50 +00:00
Robert Griesemer
0e7518296d go/importer: report import path if package is not found
Fixes #20230.

Change-Id: I2e9b9e9d2540eb66c8411ac7910962933bc2c0e9
Reviewed-on: https://go-review.googlesource.com/42870
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2017-05-05 23:03:37 +00:00
Josh Bleecher Snyder
53e62aba2f cmd/compile: add Func.SetNilCheckDisabled
Generated hash and eq routines don't need nil checks.
Prior to this CL, this was accomplished by
temporarily incrementing the global variable disable_checknil.
However, that increment lasted only the lifetime of the
call to funccompile. After CL 41503, funccompile may
do nothing but enqueue the function for compilation,
resulting in nil checks being generated.

Fix this by adding an explicit flag to a function
indicating whether nil checks should be disabled
for that function.

While we're here, allow concurrent compilation
with the -w and -W flags, since that was needed
to investigate this issue.

Fixes #20242

Change-Id: Ib9140c22c49e9a09e62fa3cf350f5d3eff18e2bd
Reviewed-on: https://go-review.googlesource.com/42591
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Marvin Stenger <marvin.stenger94@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-05-05 19:34:09 +00:00
Carlos Eduardo Seo
09b71d563a cmd/internal/obj/ppc64, cmd/link/internal/ppc64: Change function alignment to 16
The Power processor manual states that "Branches not from the last instruction
of an aligned quadword and not to the first instruction of an aligned quadword
cause inefficiencies in the IBuffer". This changes the function alignment from 8
to 16 bytes to comply with that.

Fixes #18963

Change-Id: Ibce9bf8302110a86c6ab05948569af9ffdfcf4bb
Reviewed-on: https://go-review.googlesource.com/36390
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
2017-05-05 19:03:05 +00:00
Samuel Tan
3a2fee0389 html/template: allow safe usage of predefined escapers in pipelines
Allow the predefined escapers "html", "urlquery", and "js" to be used
in pipelines when they have no potential to affect the correctness or
safety of the escaped pipeline output. Specifically:
- "urlquery" may be used if it is the last command in the pipeline.
- "html" may be used if it is the last command in the pipeline, and
  the pipeline does not occur in an unquoted HTML attribute value
  context.
- "js" may be used in any pipeline, since it does not affect the
  merging of contextual escapers.

This change will loosens the restrictions on predefined escapers
introduced in golang.org/cl/37880, which will hopefully ease the
upgrade path for existing template users.

This change brings back the escaper-merging logic, and associated
unit tests, that were removed in golang.org/cl/37880. However, a
few notable changes have been made:
- "_html_template_nospaceescaper" is no longer considered
  equivalent to "html", since the former escapes spaces, while
  the latter does not (see #19345). This change should not silently
  break any templates, since pipelines where this substituion will
  happen will already trigger an explicit error.
- An "_eval_args_" internal directive has been added to
  handle pipelines containing a single explicit call to a
  predefined escaper, e.g. {{html .X}} (see #19353).

Also, the HTMLEscape function called by the predefined
text/template "html" function now escapes the NULL character as
well. This effectively makes it as secure as the internal
html/template HTML escapers (see #19345). While this change is
backward-incompatible, it will only affect illegitimate uses
of this escaper, since the NULL character is always illegal in
valid HTML.

Fixes #19952

Change-Id: I9b5570a80a3ea284b53901e6a1f842fc59b33d3a
Reviewed-on: https://go-review.googlesource.com/40936
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-05 18:56:31 +00:00
Dieter Plaetinck
1acff5fe61 template: warn about interleaved nature of writes
Execute incurs separate writes for each "step", e.g. each
variable that needs to be printed, and the final newline.
While it is correct to state that templates can be executed
concurrently, there is a more subtle nuance that is easily missed:
when writing to the same writer, the writes from concurrent execute
calls can be interleaved, leading to unexpected output.

Change-Id: I0abbd7960d8a8d15e109a8a3eeff3b43b852bbbf
Reviewed-on: https://go-review.googlesource.com/37444
Reviewed-by: Rob Pike <r@golang.org>
2017-05-05 17:58:56 +00:00
David Crawshaw
27a10f7da7 cmd/link: stop passing unused read_only_relocs
The external darwin linker has been printing:

	ld: warning: -read_only_relocs cannot be used with x86_64

for a long time. Now that it is printed by CL 33301, we may as
well get rid of it.

Fixes #20246

Change-Id: I1147cf1ff197fdfda228a1349f13627bcf9fc72f
Reviewed-on: https://go-review.googlesource.com/42730
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-05 11:35:58 +00:00
Alex Brainman
507f4d5f48 cmd/link: do not read .bss sections in ldpe
For .bss section symbol ldelf does not set P (raw symbol data).
Make ldpe do the same.

Change-Id: Ib3d558456f505ee568d0972465fa9b08b5794a87
Reviewed-on: https://go-review.googlesource.com/42631
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-05 01:00:11 +00:00
Josh Bleecher Snyder
8d63408f46 go/constant: avoid generating rats for large negative exponents
Fixes #20228

Change-Id: I1893ae3e192da01f9befe5469b2a32e534a691ba
Reviewed-on: https://go-review.googlesource.com/42592
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-05-04 21:55:36 +00:00
Josh Bleecher Snyder
d62c6c3c39 cmd/compile: suppress duplicate type errors
If we've already complained about a type T,
don't complain again about further expressions
involving it.

Fixes #20245 and hopefully all of its ilk.

Change-Id: Ic0abe8235d52e8a7ac40e3615aea8f3a54fd7cec
Reviewed-on: https://go-review.googlesource.com/42690
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-05-04 21:53:49 +00:00
Ian Lance Taylor
39c07ce9e5 cmd/link: set ELF CPIC bit in mips64 objects
We already set it for mips32 objects. The native ELF linker warns when
linking PIC objects with non-PIC objects. Our objects are PIC, but we
were not marking them as such.

Fixes #20243.

Change-Id: Ifab131200b263e4c72cf81f7b131a65ac02a13a9
Reviewed-on: https://go-review.googlesource.com/42710
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-04 20:35:56 +00:00
David Crawshaw
98b3e3a064 cmd/go, cmd/compile: match tool versions
This change passes runtime.Version from the go tool to the compiler.
If the versions do not match, the compilation fails.
The result is a go tool from one GOROOT will complain loudly if it
is invoked with a different GOROOT value.

Only release versions are checked, so that when developing Go
you can still use "go install cmd/go" and "go install cmd/compile"
separately.

Fixes #19064

Change-Id: I17e184d07d3c1092b1d9af53ba55ed3ecf67791d
Reviewed-on: https://go-review.googlesource.com/42595
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-05-04 20:19:48 +00:00
Brad Fitzpatrick
71e63fa44f all: use time.Time.Equal instead of == in some tests
(Found by making time.Time uncomparable and rerunning std tests
locally.)

Change-Id: I4fa6fb0ba7334965362387e2f6541c17a27ac3aa
Reviewed-on: https://go-review.googlesource.com/42616
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-04 15:17:13 +00:00
David Crawshaw
b8c7fddd58 cmd/go: use os.Executable to find GOROOT
Before this change, building a GOROOT using make.bash, and then
moving the entire to a new path confused the go tool. Correct
operation of the go tool under these conditions required either
running make.bash again (not always possible if the new location
was owned by a different system user) or setting the GOROOT
environment variable. Setting GOROOT is unfortunate and
discouraged, as it makes it too easy to use the go tool from
one GOROOT and the compiler from another GOROOT.

With this change, the go tool finds its GOROOT relative to its
own location, using os.Executable. It checks it is in a GOROOT
by searching for the GOROOT/pkg/tool directory, to avoid two
plausible situations:

	ln -s $GOROOT/bin/go /usr/local/bin/go

and

	PATH=$HOME/bin:$PATH
	GOPATH=$HOME
	ln -s $GOROOT/bin/go $HOME/bin/go

Additionally, if the current executable path is not in a GOROOT,
the tool will follow any symlinks for the executable and check
to see if its original path is a GOROOT.

Fixes #18678

Change-Id: I151d7d449d213164f98193cc176b616849e6332c
Reviewed-on: https://go-review.googlesource.com/42533
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-05-04 13:23:23 +00:00
Brad Fitzpatrick
ec0ee7d357 crypto: revise wording about cryptographically broken algorithms
Updates text from https://golang.org/cl/42511

Updates #14395

Change-Id: I711100525e074ab360e577520280c37645db1c95
Reviewed-on: https://go-review.googlesource.com/42614
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
2017-05-04 12:31:18 +00:00
Josh Bleecher Snyder
f2c5f57a87 cmd/compile: prevent panic while formatting func(...T) with unknown T
Compile:

package p

var f = func(...A)


Before this CL:

x.go:3:13: type %!v(PANIC=runtime error: invalid memory address or nil pointer dereference) is not an expression
x.go:3:17: undefined: A


After this CL:

x.go:3:13: type func(...<T>) is not an expression
x.go:3:17: undefined: A


Found with go-fuzz.

Fixes #20233

Change-Id: Ibb232b3954c4091071440eba48b44c4022a8083f
Reviewed-on: https://go-review.googlesource.com/42610
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-05-04 00:37:17 +00:00
Andreas Auernhammer
25db5d1a87 crypto: document insecure algorithms
This change explicitly documents that DES, MD5, RC4 and SHA-1 are
insecure / broken - at all or at least within a commonly used scenario.

Fixes #14395

Change-Id: Id1d543c85d67968ba64ed7495313501953c3ef3a
Reviewed-on: https://go-review.googlesource.com/42511
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-03 18:35:48 +00:00
Brad Fitzpatrick
724fd13186 net/http: update bundled http2
Updates bundled http2 to x/net/http2 git rev feeb485 for:

    http2: add all bad ciphers, use package constants
    https://golang.org/cl/42510

Updates #20213

Change-Id: I851453e3785e6b126db7a5c5eec2ebbbf61358ae
Reviewed-on: https://go-review.googlesource.com/42494
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Savintsev <dsavints@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-03 17:07:11 +00:00
Steven Hartland
e83bcd95a4 crypto/x509: load certs from env vars + extra locations
Add the ability to override the default file and directory from
which certificates are loaded by setting the OpenSSL compatible
environment variables: SSL_CERT_FILE, SSL_CERT_DIR.

If the variables are set the default locations are not checked.

Added new default file "/usr/local/etc/ssl/cert.pem" for FreeBSD.

Certificates in the first valid location found for both file and
directory are added, instead of only the first file location if
a valid one was found, which is consistent with OpenSSL.

Fixes #3905
Fixes #14022
Fixes #14311
Fixes #16920
Fixes #18813 - If user sets SSL_CERT_FILE.

Change-Id: Ia24fb7c1c2ffff4338b4cf214bd040326ce27bb0
Reviewed-on: https://go-review.googlesource.com/36093
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-03 15:39:29 +00:00
Shenghou Ma
4d7a5edb7e cmd/link/internal/ld: always show output from external linker
Fixes #17935.

Change-Id: I49b0f6cee29ea76ed62b8faa5d6d1f51be41bf84
Reviewed-on: https://go-review.googlesource.com/33301
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-03 15:01:06 +00:00
Josh Bleecher Snyder
e41fb5591f cmd/compile: avoid panic when printing *<N>
When compiling the program:

package p

func _(){
	*;:=
}

Before:

x.go:4:3: syntax error: unexpected semicolon, expecting expression
x.go:4:4: non-name *%!v(PANIC=runtime error: invalid memory address or nil pointer dereference) on left side of :=
x.go:5:1: syntax error: unexpected }, expecting expression

After:

x.go:4:3: syntax error: unexpected semicolon, expecting expression
x.go:4:4: non-name *<N> on left side of :=
x.go:5:1: syntax error: unexpected }, expecting expression

No test because:

(1) we don't have a good mechanism to check for the
    absence of the string "PANIC" in an error message
(2) the string "*<N>", while better, is itself ugly enough
    that I don't want to actively check for it
(3) the bug isn't very important, the kind of thing only fuzzers encounter
(4) the fix is obvious and trivial

Fixes #20220

Change-Id: I35faa986b60b671414ee999d6264b06937f250e3
Reviewed-on: https://go-review.googlesource.com/42498
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-03 14:59:29 +00:00
Martin Möhrmann
6e9b6e1d22 vendor/golang_org/x/crypto/chacha20poly1305: revendor
Brings in chacha20poly1305 directory from golang.org/x/crypto revision
12e9ca725de4806fbda1610fd95aacad15bd6810, adding:

CL 41862: chacha20poly1305: add runtime internal independent cpu feature detection
CL 39952: add import comment

Change-Id: Ic46ff24b081bc1c66b6317334d33180e33bfd318
Reviewed-on: https://go-review.googlesource.com/42513
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-03 13:47:50 +00:00
feilengcui008
0dd7b8f879 runtime: clean redundant call of environ function
Change-Id: Ica7179d225c1fb79381f82f58ea5050ac6418b9c
Reviewed-on: https://go-review.googlesource.com/42493
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-03 10:02:26 +00:00
Filip Gruszczyński
f504bc0055 encoding/gob: use MakeMapWithSize when decoding map
This allows to pre-allocate the final size of the hashmap and avoid
re-allocating as we insert entries. Furthermore for the current
implementation of the hashmap it allows avoiding several rounds of
evacuating hashmap entries after each re-allocation.

DecodeComplex128Slice-8  51.9µs ± 1%  51.9µs ± 2%     ~     (p=0.797 n=30+29)
DecodeFloat64Slice-8     31.5µs ± 2%  31.6µs ± 2%     ~     (p=0.050 n=28+28)
DecodeInt32Slice-8       32.0µs ± 2%  31.9µs ± 3%     ~     (p=0.666 n=29+28)
DecodeStringSlice-8      57.7µs ± 2%  57.8µs ± 3%     ~     (p=0.780 n=27+30)
DecodeInterfaceSlice-8    498µs ± 2%   495µs ± 2%     ~     (p=0.070 n=28+29)
DecodeMap-8               300µs ± 2%   230µs ± 5%  -23.31%  (p=0.000 n=27+27)

Updates #19525

Change-Id: Ia7233da49f05bae7a86c064d9ecebca966f5f2f7
Reviewed-on: https://go-review.googlesource.com/40113
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-03 02:43:40 +00:00
Filip Gruszczynski
f9531448b8 runtime: don't panic for bad size hint in hashmap
Because the hint parameter is supposed to be treated
purely as a hint, if it doesn't meet the requirements
we disregard it and continue as if there was no hint
at all.

Fixes #19926

Change-Id: I86e7f99472fad6b99ba4e2fd33e4a9e55d55115e
Reviewed-on: https://go-review.googlesource.com/40854
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-02 20:51:39 +00:00
Michael Munday
35cf3843a4 cmd/{asm,compile}: avoid zeroAuto clobbering flags on s390x
This CL modifies how MOV[DWHB] instructions that store a constant to
memory are assembled to avoid them clobbering the condition code
(flags). It also modifies zeroAuto to use MOVD instructions instead of
CLEAR (which is assembled as XC).

MOV[DWHB]storeconst ops also no longer clobbers flags.

Note: this CL modifies the assembler so that it can no longer handle
immediates outside the range of an int16 or offsets from SB, which
reflects what the machine instructions support. The compiler doesn't
need this capability any more and I don't think this affects any existing
assembly, but it is easy to workaround if it does.

Fixes #20187.

Change-Id: Ie54947ff38367bd6a19962bf1a6d0296a4accffb
Reviewed-on: https://go-review.googlesource.com/42179
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-02 17:43:31 +00:00
Bryan C. Mills
e9702c0c85 expvar: reduce sync.Map overhead for (*Map).Set
Use Load instead of LoadOrStore in the fast path to save 1 alloc/op
for existing keys.

name                          old time/op    new time/op    delta
IntAdd                          6.39ns ± 7%    6.97ns ±19%     ~     (p=0.105 n=8+8)
IntAdd-6                        12.3ns ± 1%    12.2ns ± 1%     ~     (p=0.396 n=7+7)
IntSet                          6.41ns ± 6%    6.94ns ±21%     ~     (p=0.168 n=8+8)
IntSet-6                        12.1ns ± 3%    11.7ns ± 9%     ~     (p=0.496 n=7+8)
FloatAdd                        14.3ns ± 9%    14.7ns ± 4%     ~     (p=0.088 n=8+8)
FloatAdd-6                      36.5ns ± 1%    36.6ns ± 0%     ~     (p=0.709 n=7+6)
FloatSet                        6.59ns ± 7%    6.47ns ± 7%     ~     (p=0.397 n=8+7)
FloatSet-6                      12.2ns ± 1%    12.2ns ± 2%     ~     (p=0.748 n=7+7)
StringSet                       67.8ns ± 6%    68.7ns ± 6%     ~     (p=0.342 n=8+8)
StringSet-6                     41.8ns ± 5%    41.7ns ± 5%     ~     (p=0.979 n=8+8)
MapSet                           294ns ± 6%     234ns ± 4%  -20.35%  (p=0.000 n=8+8)
MapSet-6                        95.8ns ± 2%    89.4ns ± 3%   -6.73%  (p=0.000 n=8+8)
MapSetDifferent                 1.31µs ± 5%    1.07µs ± 4%  -18.21%  (p=0.000 n=8+8)
MapSetDifferent-6                260ns ± 8%     210ns ± 9%  -19.44%  (p=0.000 n=8+8)
MapSetString                     294ns ± 6%     236ns ± 4%  -19.92%  (p=0.000 n=8+8)
MapSetString-6                  95.6ns ± 2%    89.9ns ± 2%   -5.97%  (p=0.000 n=7+8)
MapAddSame                      1.46µs ± 3%    1.46µs ± 5%     ~     (p=0.721 n=8+8)
MapAddSame-6                     328ns ± 6%     330ns ± 4%     ~     (p=0.776 n=8+8)
MapAddDifferent                 4.89µs ± 7%    4.98µs ± 6%     ~     (p=0.505 n=8+8)
MapAddDifferent-6               1.02µs ± 3%    1.01µs ± 4%     ~     (p=0.352 n=7+8)
MapAddSameSteadyState           62.1ns ± 7%    60.8ns ± 4%     ~     (p=0.521 n=8+8)
MapAddSameSteadyState-6         38.1ns ± 3%    37.7ns ± 0%     ~     (p=0.185 n=7+6)
MapAddDifferentSteadyState       290ns ± 5%     293ns ± 4%     ~     (p=0.515 n=8+8)
MapAddDifferentSteadyState-6    63.0ns ± 7%    63.7ns ±11%     ~     (p=0.482 n=7+8)
RealworldExpvarUsage            7.39µs ± 5%    7.51µs ± 5%     ~     (p=0.382 n=8+8)
RealworldExpvarUsage-6          3.07µs ±28%    3.04µs ±43%     ~     (p=0.798 n=8+8)

name                          old alloc/op   new alloc/op   delta
IntAdd                           0.00B          0.00B          ~     (all equal)
IntAdd-6                         0.00B          0.00B          ~     (all equal)
IntSet                           0.00B          0.00B          ~     (all equal)
IntSet-6                         0.00B          0.00B          ~     (all equal)
FloatAdd                         0.00B          0.00B          ~     (all equal)
FloatAdd-6                       0.00B          0.00B          ~     (all equal)
FloatSet                         0.00B          0.00B          ~     (all equal)
FloatSet-6                       0.00B          0.00B          ~     (all equal)
StringSet                        16.0B ± 0%     16.0B ± 0%     ~     (all equal)
StringSet-6                      16.0B ± 0%     16.0B ± 0%     ~     (all equal)
MapSet                           48.0B ± 0%     32.0B ± 0%  -33.33%  (p=0.000 n=8+8)
MapSet-6                         48.0B ± 0%     32.0B ± 0%  -33.33%  (p=0.000 n=8+8)
MapSetDifferent                   192B ± 0%      128B ± 0%  -33.33%  (p=0.000 n=8+8)
MapSetDifferent-6                 192B ± 0%      128B ± 0%  -33.33%  (p=0.000 n=8+8)
MapSetString                     48.0B ± 0%     32.0B ± 0%  -33.33%  (p=0.000 n=8+8)
MapSetString-6                   48.0B ± 0%     32.0B ± 0%  -33.33%  (p=0.000 n=8+8)
MapAddSame                        480B ± 0%      480B ± 0%     ~     (all equal)
MapAddSame-6                      480B ± 0%      480B ± 0%     ~     (all equal)
MapAddDifferent                 1.09kB ± 0%    1.09kB ± 0%     ~     (all equal)
MapAddDifferent-6               1.09kB ± 0%    1.09kB ± 0%     ~     (all equal)
MapAddSameSteadyState            0.00B          0.00B          ~     (all equal)
MapAddSameSteadyState-6          0.00B          0.00B          ~     (all equal)
MapAddDifferentSteadyState       0.00B          0.00B          ~     (all equal)
MapAddDifferentSteadyState-6     0.00B          0.00B          ~     (all equal)
RealworldExpvarUsage             0.00B          0.00B          ~     (all equal)
RealworldExpvarUsage-6           0.00B          0.00B          ~     (all equal)

name                          old allocs/op  new allocs/op  delta
IntAdd                            0.00           0.00          ~     (all equal)
IntAdd-6                          0.00           0.00          ~     (all equal)
IntSet                            0.00           0.00          ~     (all equal)
IntSet-6                          0.00           0.00          ~     (all equal)
FloatAdd                          0.00           0.00          ~     (all equal)
FloatAdd-6                        0.00           0.00          ~     (all equal)
FloatSet                          0.00           0.00          ~     (all equal)
FloatSet-6                        0.00           0.00          ~     (all equal)
StringSet                         1.00 ± 0%      1.00 ± 0%     ~     (all equal)
StringSet-6                       1.00 ± 0%      1.00 ± 0%     ~     (all equal)
MapSet                            3.00 ± 0%      2.00 ± 0%  -33.33%  (p=0.000 n=8+8)
MapSet-6                          3.00 ± 0%      2.00 ± 0%  -33.33%  (p=0.000 n=8+8)
MapSetDifferent                   12.0 ± 0%       8.0 ± 0%  -33.33%  (p=0.000 n=8+8)
MapSetDifferent-6                 12.0 ± 0%       8.0 ± 0%  -33.33%  (p=0.000 n=8+8)
MapSetString                      3.00 ± 0%      2.00 ± 0%  -33.33%  (p=0.000 n=8+8)
MapSetString-6                    3.00 ± 0%      2.00 ± 0%  -33.33%  (p=0.000 n=8+8)
MapAddSame                        11.0 ± 0%      11.0 ± 0%     ~     (all equal)
MapAddSame-6                      11.0 ± 0%      11.0 ± 0%     ~     (all equal)
MapAddDifferent                   31.0 ± 0%      31.0 ± 0%     ~     (all equal)
MapAddDifferent-6                 31.0 ± 0%      31.0 ± 0%     ~     (all equal)
MapAddSameSteadyState             0.00           0.00          ~     (all equal)
MapAddSameSteadyState-6           0.00           0.00          ~     (all equal)
MapAddDifferentSteadyState        0.00           0.00          ~     (all equal)
MapAddDifferentSteadyState-6      0.00           0.00          ~     (all equal)
RealworldExpvarUsage              0.00           0.00          ~     (all equal)
RealworldExpvarUsage-6            0.00           0.00          ~     (all equal)

https://perf.golang.org/search?q=upload:20170501.1

Change-Id: I28fc3906473f2b7307f6d1ae05a8d9b01ef8a6f8
Reviewed-on: https://go-review.googlesource.com/42211
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-02 17:13:40 +00:00
Chris Manghane
48def43fd6 net/http: bgErr is unused; remove it
Fixes #20196.

Change-Id: Ib87f6e9e27a38f21f860b7150c818d77be653dd3
Reviewed-on: https://go-review.googlesource.com/42370
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-02 15:49:13 +00:00
Josh Bleecher Snyder
a93e9f0fad cmd/dist: spin up fewer test dir runners
5 shards, each of which spins up NumCPU processes,
each of which is running at GOMAXPROCS=NumCPU,
is too much for one machine. It makes my laptop unusable.

It might also be in part responsible for test flakes
that require a moderately responsive system,
like #18589 (backedge scheduling) and #19276 (locklinear).

It's possible that Go should be a better neighbor in general;
that's #17969. In the meantime, fix this corner of the world.

Builders snapshot the world and run shards on different
machines, so keeping sharding high for them is good.

This is a partial reversion of CL 18199.

Fixes #20141.

Change-Id: I123cf9436f4f4da3550372896265c38117b78071
Reviewed-on: https://go-review.googlesource.com/42431
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-02 13:39:51 +00:00
Josh Bleecher Snyder
18fb670e5e cmd/internal/obj: fix LSym.Type during compilation, not linking
Prior to this CL, the compiler and assembler
were sloppy about the LSym.Type for LSyms
containing static data.

The linker then fixed this up, converting
Sxxx and SBSS to SDATA, and SNOPTRBSS to SNOPTRDATA
if it noticed that the symbol had associated data.

It is preferable to just get this right in cmd/compile
and cmd/asm, because it removes an unnecessary traversal
of the symbol table from the linker (see #14624).
Do this by touching up the LSym.Type fixes in
LSym.prepwrite and Link.Globl.

I have confirmed by instrumenting the linker
that the now-eliminated code paths were unreached.
And an additional check in the object file writing code
will help preserve that invariant.

There was a case in the Windows linker,
with internal linking and cgo,
where we were generating SNOPTRBSS symbols with data.
For now, convert those at the site at which they occur
into SNOPTRDATA, just like they were.

Does not pass toolstash-check,
but does generate identical linked binaries.

No compiler performance changes.

Change-Id: I77b071ab103685ff8e042cee9abb864385488872
Reviewed-on: https://go-review.googlesource.com/40864
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2017-05-02 00:21:33 +00:00
Martin Möhrmann
f9bec9eb42 cmd/compile: use MOVL instead of MOVQ for small constants on amd64
The encoding of MOVL to a register is 2 bytes shorter than for MOVQ.
The upper 32bit are automatically zeroed when MOVL to a register is used.

Replaces 1657 MOVQ by MOVL in the go binary.
Reduces go binary size by 4 kilobyte.

name                   old time/op    new time/op    delta
BinaryTree17              1.93s ± 0%     1.93s ± 0%  -0.32%  (p=0.000 n=9+9)
Fannkuch11                2.66s ± 0%     2.48s ± 0%  -6.60%  (p=0.000 n=9+9)
FmtFprintfEmpty          31.8ns ± 0%    31.6ns ± 0%  -0.63%  (p=0.000 n=10+10)
FmtFprintfString         52.0ns ± 0%    51.9ns ± 0%  -0.19%  (p=0.000 n=10+10)
FmtFprintfInt            55.6ns ± 0%    54.6ns ± 0%  -1.80%  (p=0.002 n=8+10)
FmtFprintfIntInt         87.7ns ± 0%    84.8ns ± 0%  -3.31%  (p=0.000 n=9+9)
FmtFprintfPrefixedInt    98.9ns ± 0%   102.0ns ± 0%  +3.10%  (p=0.000 n=10+10)
FmtFprintfFloat           165ns ± 0%     164ns ± 0%  -0.61%  (p=0.000 n=10+10)
FmtManyArgs               368ns ± 0%     361ns ± 0%  -1.98%  (p=0.000 n=8+10)
GobDecode                4.53ms ± 0%    4.58ms ± 0%  +1.08%  (p=0.000 n=9+10)
GobEncode                3.74ms ± 0%    3.73ms ± 0%  -0.27%  (p=0.000 n=10+10)
Gzip                      164ms ± 0%     163ms ± 0%  -0.48%  (p=0.000 n=10+10)
Gunzip                   26.7ms ± 0%    26.6ms ± 0%  -0.13%  (p=0.000 n=9+10)
HTTPClientServer         30.4µs ± 1%    30.3µs ± 1%  -0.41%  (p=0.016 n=10+10)
JSONEncode               10.9ms ± 0%    11.0ms ± 0%  +0.70%  (p=0.000 n=10+10)
JSONDecode               36.8ms ± 0%    37.0ms ± 0%  +0.59%  (p=0.000 n=9+10)
Mandelbrot200            3.20ms ± 0%    3.21ms ± 0%  +0.44%  (p=0.000 n=9+10)
GoParse                  2.35ms ± 0%    2.35ms ± 0%  +0.26%  (p=0.000 n=10+9)
RegexpMatchEasy0_32      58.3ns ± 0%    58.4ns ± 0%  +0.17%  (p=0.000 n=10+10)
RegexpMatchEasy0_1K       138ns ± 0%     142ns ± 0%  +2.68%  (p=0.000 n=10+10)
RegexpMatchEasy1_32      55.1ns ± 0%    55.6ns ± 1%    ~     (p=0.104 n=10+10)
RegexpMatchEasy1_1K       242ns ± 0%     243ns ± 0%  +0.41%  (p=0.000 n=10+10)
RegexpMatchMedium_32     87.4ns ± 0%    89.9ns ± 0%  +2.86%  (p=0.000 n=10+10)
RegexpMatchMedium_1K     27.4µs ± 0%    27.4µs ± 0%  +0.15%  (p=0.000 n=10+10)
RegexpMatchHard_32       1.30µs ± 0%    1.32µs ± 1%  +1.91%  (p=0.000 n=10+10)
RegexpMatchHard_1K       39.0µs ± 0%    39.5µs ± 0%  +1.38%  (p=0.000 n=10+10)
Revcomp                   316ms ± 0%     319ms ± 0%  +1.13%  (p=0.000 n=9+8)
Template                 40.6ms ± 0%    40.6ms ± 0%    ~     (p=0.123 n=10+10)
TimeParse                 224ns ± 0%     224ns ± 0%    ~     (all equal)
TimeFormat                230ns ± 0%     225ns ± 0%  -2.17%  (p=0.000 n=10+10)

Change-Id: I32a099b65f9e6d4ad7288ed48546655c534757d8
Reviewed-on: https://go-review.googlesource.com/38630
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-01 20:59:58 +00:00
Martin Möhrmann
5a6c580990 runtime: refactor cpu feature detection for 386 & amd64
Changes all cpu features to be detected and stored in bools in rt0_go.

Updates: #15403

Change-Id: I5a9961cdec789b331d09c44d86beb53833d5dc3e
Reviewed-on: https://go-review.googlesource.com/41950
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-01 20:46:03 +00:00
Michael Hudson-Doyle
1f85d3ad09 cmd/internal/obj/x86: use LEAx rather than ADDx when calling DUFFxxxx via GOT
DUFFZERO on 386 is not marked as clobbering flags, but rewriteToUseGot rewrote
"ADUFFZERO $offset" to "MOVL runtime.duffxxx@GOT, CX; ADDL $offset, CX; CALL CX"
which does. Luckily the fix is easier than figuring out what the problem was:
replace the ADDL $offset, CX with LEAL $offset(CX), CX.

On amd64 DUFFZERO clobbers flags, on arm, arm64 and ppc64 ADD does not clobber
flags and s390x does not use the duff functions, so I'm fairly confident this
is the only fix required.

I don't know how to write a test though.

Change-Id: I69b0958f5f45771d61db5f5ecb4ded94e8960d4d
Reviewed-on: https://go-review.googlesource.com/41821
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-01 18:57:35 +00:00
Damien Lespiau
a2da2108ee cmd/internal/obj/x86: fix ANDPS encoding
ANDPS, like all others PS (Packed Single precision floats) instructions,
need Ym: they don't use the 0x66 prefix.

From the manual:

    NP 0F 54 /r        ANDPS xmm1, xmm2/m128

NP meaning, quoting the manual:

  NP - Indicates the use of 66/F2/F3 prefixes (beyond those already part
  of the instructions opcode) are not allowed with the instruction.

And indeed, the same instruction prefixed by 0x66 is ANDPD.

Updates #14069

Change-Id: If312a6f1e77113ab8c0febe66bdb1b4171e41e0a
Reviewed-on: https://go-review.googlesource.com/42090
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-01 18:32:52 +00:00
Josh Bleecher Snyder
d1b544c7eb cmd/compile: avoid giant init functions due to many user inits
We generate code that calls each user init function one at a time.
When there are lots of user init functions,
usually due to generated code, like test/rotate* or
github.com/juju/govmomi/vim25/types,
we can end up with a giant function,
which can be slow to compile.

This CL puts in an escape valve.
When there are more than 500 functions, instead of doing:

init.0()
init.1()
// ...

we construct a static array of functions:

var fns = [...]func(){init.0, init.1, ... }

and call them in a loop.

This generates marginally bigger, marginally worse code,
so we restrict it to cases in which it might start to matter.

500 was selected as a mostly arbitrary threshold for "lots".
Each call uses two Progs, one for PCDATA and one for the call,
so at 500 calls we use ~1000 Progs.
At concurrency==8, we get a Prog cache of about
1000 Progs per worker.
So a threshold of 500 should more or less avoid
exhausting the Prog cache in most cases.

Change-Id: I276b887173ddbf65b2164ec9f9b5eb04d8c753c2
Reviewed-on: https://go-review.googlesource.com/41500
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-01 18:00:11 +00:00
Josh Bleecher Snyder
b666f2860b runtime: use 64 bit calculation in overLoadFactor
overLoadFactor used a uintptr for its calculations.
When the number of potential buckets was large,
perhaps due to a coding error or corrupt/malicious user input
leading to a very large map size hint,
this led to overflow on 32 bit systems.
This overflow resulted in an infinite loop.

Prevent it by always using a 64 bit calculation.

Updates #20195

Change-Id: Iaabc710773cd5da6754f43b913478cc5562d89a2
Reviewed-on: https://go-review.googlesource.com/42185
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-01 17:35:57 +00:00
Josh Bleecher Snyder
00db0cbf86 cmd/compile: add minor bit twiddling optimizations
Noticed while adding to the bitset implementation
in cmd/compile/internal/gc.

The (Com (Const)) optimizations were already present
in the AMD64 lowered optimizations.
They trigger 118, 44, 262, and 108 times
respectively for int sizes 8, 16, 32, and 64
in a run of make.bash.

The (Or (And)) optimization is new.
It triggers 3 times for int size 8
and once for int size 64 during make.bash,
in packages internal/poll, reflect,
encoding/asn1, and go/types,
so there is a bit of natural test coverage.

Change-Id: I44072864ff88831d5ec7dce37c516d29df056e98
Reviewed-on: https://go-review.googlesource.com/41758
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-05-01 17:18:06 +00:00
Josh Bleecher Snyder
c095e92c40 cmd/compile: add comments to trackAllTypes
Per gri's suggestion on CL 41623,
add a comment to trackAllTypes
about the trade-offs of enabling it.

Change-Id: Iec42b0da7933543200729003d1b2c6e0d9dcc5f0
Reviewed-on: https://go-review.googlesource.com/42186
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-01 15:22:20 +00:00
Damien Lespiau
51995aa434 cmd/asm: enable CMPPS, CMPPD, CMPSS and CMPSD encoding tests
The generated test cases had their arguments reversed, putting them back
in order makes those tests pass.

  CMPPS SRC, DEST, CC

Change-Id: Ie15021edc533d5681a6a78d10d88b665e3de9017
Reviewed-on: https://go-review.googlesource.com/42097
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-01 14:19:54 +00:00
Michael Hudson-Doyle
164f99e584 Revert "cmd/link: replace SHIDDEN bit in SymKind with a bit of Attribute"
This reverts commit a69222d949.

Reason for revert: broke ppc64le

Change-Id: I57d275177e90f036caf7dbade9669b8121dfa437
Reviewed-on: https://go-review.googlesource.com/42194
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2017-05-01 00:56:40 +00:00
Michael Hudson-Doyle
a69222d949 cmd/link: replace SHIDDEN bit in SymKind with a bit of Attribute
Change-Id: I02dab81393cc9339895f0076df41a652aded5b60
Reviewed-on: https://go-review.googlesource.com/42025
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-30 23:28:47 +00:00
Michael Hudson-Doyle
3bcb481aa3 cmd/link: rename AttrHidden to AttrNotInSymbolTable
I want to move the SHIDDEN type bit into Attribute, but AttrHidden is already
there and means something completely different, so rename it. (I'll give the
SHIDDEN bit a better name when it moves too).

Change-Id: I075403d9542b7626d4c1f6db9094329c4181aad3
Reviewed-on: https://go-review.googlesource.com/42024
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-30 23:28:29 +00:00
Michael Hudson-Doyle
f72534ab6a cmd/link: document the various Attribute values
Change-Id: I11c14111b6c72eab5fc11e9e28cd8b37ad99b401
Reviewed-on: https://go-review.googlesource.com/42019
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-30 23:27:46 +00:00
Todd Neal
cee5cd5a02 cmd/compile: fix error when typeswitching on untyped
Fixes #20185
Fixes #19977

Change-Id: I8434713d20616ff0c0bc8f33f017e2548a5cccfa
Reviewed-on: https://go-review.googlesource.com/42210
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2017-04-30 17:25:47 +00:00
Josh Bleecher Snyder
5e157db37a cmd/compile: make Class a Stringer
Change-Id: I7fd137d01ab5a0690773ca6e47d2bd796f0e393e
Reviewed-on: https://go-review.googlesource.com/42177
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-30 16:26:09 +00:00
Ingo Oeser
a8e3852a05 sync: really test DeepCopyMap
since there current version suffers from a copy'n'paste error.

Change-Id: I1ef97a4413198dde10c5c926a2a9806724cd6d44
Reviewed-on: https://go-review.googlesource.com/42095
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-30 14:17:36 +00:00
Alex Brainman
37c2d6b277 os: skip TestNetworkSymbolicLink if Server service is not started
Fixes #20179

Change-Id: I2b405c9a212a75aae628ad51885616d33c054191
Reviewed-on: https://go-review.googlesource.com/42190
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-30 07:04:30 +00:00
Josh Bleecher Snyder
dfeecda91d cmd/compile: checkwidth T when constructing *T
Without this, T can sneak through to the backend
with its width unknown.

Fixes #20174

Change-Id: I9b21e0e2641f75e360cc5e45dcb4eefe8255b675
Reviewed-on: https://go-review.googlesource.com/42175
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-30 00:45:42 +00:00
Bryan C. Mills
34fd5db147 archive/zip: replace RWMutex with sync.Map
This change replaces the compressors and decompressors maps with
instances of sync.Map, eliminating the need for Mutex locking in
NewReader and NewWriter.

The impact for encoding large payloads is miniscule, but as the
payload size decreases, the reduction in setup costs becomes
measurable.

updates #17973
updates #18177

name                        old time/op    new time/op    delta
CompressedZipGarbage          13.6ms ± 3%    13.8ms ± 4%    ~     (p=0.275 n=14+16)
CompressedZipGarbage-6        2.81ms ±10%    2.80ms ± 9%    ~     (p=0.616 n=16+16)
CompressedZipGarbage-48        606µs ± 4%     600µs ± 3%    ~     (p=0.110 n=16+15)
Zip64Test                     88.7ms ± 5%    87.5ms ± 5%    ~     (p=0.150 n=14+14)
Zip64Test-6                   88.6ms ± 8%    94.5ms ±13%    ~     (p=0.070 n=14+16)
Zip64Test-48                   102ms ±19%     101ms ±19%    ~     (p=0.599 n=16+15)
Zip64TestSizes/4096           21.7µs ±10%    23.0µs ± 2%    ~     (p=0.076 n=14+12)
Zip64TestSizes/4096-6         7.58µs ±13%    7.49µs ±18%    ~     (p=0.752 n=16+16)
Zip64TestSizes/4096-48        19.5µs ± 8%    18.0µs ± 4%  -7.74%  (p=0.000 n=16+15)
Zip64TestSizes/1048576        1.36ms ± 9%    1.40ms ± 8%  +2.79%  (p=0.029 n=24+25)
Zip64TestSizes/1048576-6       262µs ±11%     260µs ±10%    ~     (p=0.506 n=24+24)
Zip64TestSizes/1048576-48      120µs ± 7%     116µs ± 7%  -3.05%  (p=0.006 n=24+25)
Zip64TestSizes/67108864       86.8ms ± 6%    85.1ms ± 5%    ~     (p=0.149 n=14+17)
Zip64TestSizes/67108864-6     15.9ms ± 2%    16.1ms ± 6%    ~     (p=0.279 n=14+17)
Zip64TestSizes/67108864-48    4.51ms ± 5%    4.53ms ± 4%    ~     (p=0.766 n=15+17)

name                        old alloc/op   new alloc/op   delta
CompressedZipGarbage          5.63kB ± 0%    5.63kB ± 0%    ~     (all equal)
CompressedZipGarbage-6        15.4kB ± 0%    15.4kB ± 0%    ~     (all equal)
CompressedZipGarbage-48       25.5kB ± 3%    25.6kB ± 2%    ~     (p=0.450 n=16+16)
Zip64Test                     20.0kB ± 0%    20.0kB ± 0%    ~     (p=0.060 n=16+13)
Zip64Test-6                   20.0kB ± 0%    20.0kB ± 0%    ~     (p=0.136 n=16+14)
Zip64Test-48                  20.0kB ± 0%    20.0kB ± 0%    ~     (p=1.000 n=16+16)
Zip64TestSizes/4096           20.0kB ± 0%    20.0kB ± 0%    ~     (all equal)
Zip64TestSizes/4096-6         20.0kB ± 0%    20.0kB ± 0%    ~     (all equal)
Zip64TestSizes/4096-48        20.0kB ± 0%    20.0kB ± 0%  -0.00%  (p=0.002 n=16+13)
Zip64TestSizes/1048576        20.0kB ± 0%    20.0kB ± 0%    ~     (all equal)
Zip64TestSizes/1048576-6      20.0kB ± 0%    20.0kB ± 0%    ~     (all equal)
Zip64TestSizes/1048576-48     20.1kB ± 0%    20.1kB ± 0%    ~     (p=0.775 n=24+25)
Zip64TestSizes/67108864       20.0kB ± 0%    20.0kB ± 0%    ~     (all equal)
Zip64TestSizes/67108864-6     20.0kB ± 0%    20.0kB ± 0%    ~     (p=0.272 n=16+17)
Zip64TestSizes/67108864-48    20.1kB ± 0%    20.1kB ± 0%    ~     (p=0.098 n=14+15)

name                        old allocs/op  new allocs/op  delta
CompressedZipGarbage            44.0 ± 0%      44.0 ± 0%    ~     (all equal)
CompressedZipGarbage-6          44.0 ± 0%      44.0 ± 0%    ~     (all equal)
CompressedZipGarbage-48         44.0 ± 0%      44.0 ± 0%    ~     (all equal)
Zip64Test                       53.0 ± 0%      53.0 ± 0%    ~     (all equal)
Zip64Test-6                     53.0 ± 0%      53.0 ± 0%    ~     (all equal)
Zip64Test-48                    53.0 ± 0%      53.0 ± 0%    ~     (all equal)
Zip64TestSizes/4096             53.0 ± 0%      53.0 ± 0%    ~     (all equal)
Zip64TestSizes/4096-6           53.0 ± 0%      53.0 ± 0%    ~     (all equal)
Zip64TestSizes/4096-48          53.0 ± 0%      53.0 ± 0%    ~     (all equal)
Zip64TestSizes/1048576          53.0 ± 0%      53.0 ± 0%    ~     (all equal)
Zip64TestSizes/1048576-6        53.0 ± 0%      53.0 ± 0%    ~     (all equal)
Zip64TestSizes/1048576-48       53.0 ± 0%      53.0 ± 0%    ~     (all equal)
Zip64TestSizes/67108864         53.0 ± 0%      53.0 ± 0%    ~     (all equal)
Zip64TestSizes/67108864-6       53.0 ± 0%      53.0 ± 0%    ~     (all equal)
Zip64TestSizes/67108864-48      53.0 ± 0%      53.0 ± 0%    ~     (all equal)

https://perf.golang.org/search?q=upload:20170428.4

Change-Id: Idb7bec091a210aba833066f8d083d66e27788286
Reviewed-on: https://go-review.googlesource.com/42113
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-29 17:21:43 +00:00
Josh Bleecher Snyder
e5c9358fe2 cmd/compile: move writebarrier pass after dse
This avoids generating writeBarrier.enabled
blocks for dead stores.

Change-Id: Ib11d8e2ba952f3f1f01d16776e40a7200a7683cf
Reviewed-on: https://go-review.googlesource.com/42012
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2017-04-29 16:37:02 +00:00
Emmanuel Odeke
cf1b323fc8 net/http: enable TestRequestDoesntBodyCloseDoesntBlock
Fixes #7121.

CL 31173 inadvertently fixed this issue in the Go1.8 cycle.
This CL enables the test for that issue.

Change-Id: I8e73b41f646fa89c75bff833c1b07e1cdb2b1e62
Reviewed-on: https://go-review.googlesource.com/42149
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-29 15:56:48 +00:00
Austin Clements
11eaf42886 runtime: reduce Windows timer resolution when idle
Currently Go sets the system-wide timer resolution to 1ms the whole
time it's running. This has negative affects on system performance and
power consumption. Unfortunately, simply reducing the timer resolution
to the default 15ms interferes with several sleeps in the runtime
itself, including sysmon's ability to interrupt goroutines.

This commit takes a hybrid approach: it only reduces the timer
resolution when the Go process is entirely idle. When the process is
idle, nothing needs a high resolution timer. When the process is
non-idle, it's already consuming CPU so it doesn't really matter if
the OS also takes timer interrupts more frequently.

Updates #8687.

Change-Id: I0652564b4a36d61a80e045040094a39c19da3b06
Reviewed-on: https://go-review.googlesource.com/38403
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2017-04-29 04:15:49 +00:00
Hiroshi Ioka
b225396f93 mime: re-accept empty encoded-text
https://go-review.googlesource.com/37812 prohibits empty encoded-text.
This CL accepts it again for backward compatibility.

Change-Id: I0e0840b501927f147160b999bb59d2d029ea314c
Reviewed-on: https://go-review.googlesource.com/40051
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-29 04:14:36 +00:00
Ben Shi
38fbada557 cmd/compile/internal/ssa: more constant folding rules for ARM
(ADDconst [c] x) && !isARMImmRot(uint32(c)) && isARMImmRot(uint32(-c)) -> (SUBconst [int64(int32(-c))] x)
(SUBconst [c] x) && !isARMImmRot(uint32(c)) && isARMImmRot(uint32(-c)) -> (ADDconst [int64(int32(-c))] x)
Currently
a = a + 0xfffffff1 is compiled to (variable a is in R0)
MVN $14, R11
ADD R11, R0, R0
After applying the above 2 rules, it becomes
SUB $15, R0, R0

(BICconst [c] (BICconst [d] x)) -> (BICconst [int64(int32(c|d))] x)
This rule also optimizes the generated ARM code.

The other rules are added to avoid to generate less optimized ARM code
when substitutions ADD->SUB happen.

Change-Id: I3ead9aae2b446b674e2ab42d37259d38ceb93a4d
Reviewed-on: https://go-review.googlesource.com/41679
Reviewed-by: Keith Randall <khr@golang.org>
2017-04-29 02:53:46 +00:00
Josh Bleecher Snyder
c4335f81a2 cmd/compile: checkwidthj all expressions in walk
Instead of playing whack-a-mole finding all
the non-dowidth'd expressions that can sneak
out of the frontend and then deciding on
just the right place to handle them,
use a big hammer.

Fixes #20152

Change-Id: Id452d9e8c4e9585216bd8bf0e0004c85aba4f9f7
Reviewed-on: https://go-review.googlesource.com/42021
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-28 23:38:15 +00:00
Austin Clements
c1ac70ff92 runtime/pprof: use symbol information already in profile in tests
Currently the pprof tests re-symbolize PCs in profiles, and do so in a
way that can't handle inlining. Proto profiles already contain full
symbol information, so this modifies the tests to use the symbol
information already present in the profile.

Change-Id: I63cd491de7197080fd158b1e4f782630f1bbbb56
Reviewed-on: https://go-review.googlesource.com/41255
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2017-04-28 22:58:11 +00:00
Daniel Theophanes
2133d63fa8 database/sql: ensure releaseConn is defined before a possible close
When running a Query on Stmt a dependency is added to the stmt and
rows. To do that it needs a reference to Rows, so the releaseConn
function is defined after the definition. However the
rows.initContextClose was set to run before the releaseConn was
set on rows, setting up a situation where the connection could
be canceled before the releaseConn was set and resulting in
a segfault.

Fixes #20160

Change-Id: I5592e7db2cf653dfc48d42cbc2b03ca20501b1a0
Reviewed-on: https://go-review.googlesource.com/42139
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-28 22:55:26 +00:00
Austin Clements
295d160e01 runtime: make _TinySizeClass an int8 to prevent use as spanClass
Currently _TinySizeClass is untyped, which means it can accidentally
be used as a spanClass (not that I would know this from experience or
anything). Make it an int8 to avoid this mix up.

This is a cherry-pick of dev.garbage commit 81b74bf9c5.

Change-Id: I1e69eccee436ea5aa45e9a9828a013e369e03f1a
Reviewed-on: https://go-review.googlesource.com/41254
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2017-04-28 22:50:39 +00:00
Austin Clements
8e25d4ccef runtime: eliminate heapBitsSetTypeNoScan
It's no longer necessary to maintain the bitmap of noscan objects
since we now use the span metadata to determine that they're noscan
instead of the bitmap.

The combined effect of segregating noscan spans and the follow-on
optimizations is roughly a 1% improvement in performance across the
go1 benchmarks and the x/benchmarks, with no increase in heap size.

Benchmark details: https://perf.golang.org/search?q=upload:20170420.1

name                       old time/op    new time/op    delta
Garbage/benchmem-MB=64-12    2.27ms ± 0%    2.25ms ± 1%  -0.96% (p=0.000 n=15+18)

name                      old time/op    new time/op    delta
BinaryTree17-12              2.53s ± 2%     2.55s ± 1%  +0.68%        (p=0.001 n=17+16)
Fannkuch11-12                3.02s ± 0%     3.01s ± 0%  -0.15%        (p=0.000 n=16+16)
FmtFprintfEmpty-12          47.1ns ± 7%    47.0ns ± 5%    ~           (p=0.886 n=20+17)
FmtFprintfString-12         73.6ns ± 3%    73.8ns ± 1%  +0.30%        (p=0.026 n=19+17)
FmtFprintfInt-12            80.3ns ± 2%    80.2ns ± 1%    ~           (p=0.994 n=20+18)
FmtFprintfIntInt-12          124ns ± 0%     124ns ± 0%    ~     (all samples are equal)
FmtFprintfPrefixedInt-12     172ns ± 1%     171ns ± 1%  -0.72%        (p=0.003 n=20+18)
FmtFprintfFloat-12           217ns ± 1%     216ns ± 1%  -0.27%        (p=0.019 n=18+19)
FmtManyArgs-12               490ns ± 1%     488ns ± 0%  -0.36%        (p=0.014 n=18+18)
GobDecode-12                6.71ms ± 1%    6.73ms ± 1%  +0.42%        (p=0.000 n=20+20)
GobEncode-12                5.25ms ± 0%    5.24ms ± 0%  -0.20%        (p=0.001 n=18+20)
Gzip-12                      227ms ± 0%     226ms ± 1%    ~           (p=0.107 n=20+19)
Gunzip-12                   38.8ms ± 0%    38.8ms ± 0%    ~           (p=0.221 n=19+18)
HTTPClientServer-12         75.4µs ± 1%    76.3µs ± 1%  +1.26%        (p=0.000 n=20+19)
JSONEncode-12               14.7ms ± 0%    14.7ms ± 1%  -0.14%        (p=0.002 n=18+17)
JSONDecode-12               57.6ms ± 0%    55.2ms ± 0%  -4.13%        (p=0.000 n=19+19)
Mandelbrot200-12            3.73ms ± 0%    3.73ms ± 0%  -0.09%        (p=0.000 n=19+17)
GoParse-12                  3.18ms ± 1%    3.15ms ± 1%  -0.90%        (p=0.000 n=18+20)
RegexpMatchEasy0_32-12      73.3ns ± 2%    73.2ns ± 1%    ~           (p=0.994 n=20+18)
RegexpMatchEasy0_1K-12       236ns ± 2%     234ns ± 1%  -0.70%        (p=0.002 n=19+17)
RegexpMatchEasy1_32-12      69.7ns ± 2%    69.9ns ± 2%    ~           (p=0.416 n=20+20)
RegexpMatchEasy1_1K-12       366ns ± 1%     365ns ± 1%    ~           (p=0.376 n=19+17)
RegexpMatchMedium_32-12      109ns ± 1%     108ns ± 1%    ~           (p=0.461 n=17+18)
RegexpMatchMedium_1K-12     35.2µs ± 1%    35.2µs ± 3%    ~           (p=0.238 n=19+20)
RegexpMatchHard_32-12       1.77µs ± 1%    1.77µs ± 1%  +0.33%        (p=0.007 n=17+16)
RegexpMatchHard_1K-12       53.2µs ± 0%    53.3µs ± 0%  +0.26%        (p=0.001 n=17+17)
Revcomp-12                  1.13s ±117%    0.87s ±184%    ~           (p=0.813 n=20+19)
Template-12                 63.9ms ± 1%    64.6ms ± 1%  +1.18%        (p=0.000 n=19+20)
TimeParse-12                 313ns ± 5%     312ns ± 0%    ~           (p=0.114 n=20+19)
TimeFormat-12                336ns ± 0%     333ns ± 0%  -0.97%        (p=0.000 n=18+16)
[Geo mean]                  50.6µs         50.1µs       -1.04%

This is a cherry-pick of dev.garbage commit edb54c300f, with updated
benchmark results.

Change-Id: Ic77faaa15cdac3bfbbb0032dde5c204e05a0fd8e
Reviewed-on: https://go-review.googlesource.com/41253
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2017-04-28 22:50:37 +00:00
Austin Clements
c44d031bf0 runtime: eliminate heapBits.hasPointers
This is no longer necessary now that we can more efficiently consult
the span's noscan bit.

This is a cherry-pick of dev.garbage commit 312aa09996.

Change-Id: Id0b00b278533660973f45eb6efa5b00f373d58af
Reviewed-on: https://go-review.googlesource.com/41252
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2017-04-28 22:50:34 +00:00
Austin Clements
1a033b1a70 runtime: separate spans of noscan objects
Currently, we mix objects with pointers and objects without pointers
("noscan" objects) together in memory. As a result, for every object
we grey, we have to check that object's heap bits to find out if it's
noscan, which adds to the per-object cost of GC. This also hurts the
TLB footprint of the garbage collector because it decreases the
density of scannable objects at the page level.

This commit improves the situation by using separate spans for noscan
objects. This will allow a much simpler noscan check (in a follow up
CL), eliminate the need to clear the bitmap of noscan objects (in a
follow up CL), and improves TLB footprint by increasing the density of
scannable objects.

This is also a step toward eliminating dead bits, since the current
noscan check depends on checking the dead bit of the first word.

This has no effect on the heap size of the garbage benchmark.

We'll measure the performance change of this after the follow-up
optimizations.

This is a cherry-pick from dev.garbage commit d491e550c3. The only
non-trivial merge conflict was in updatememstats in mstats.go, where
we now have to separate the per-spanclass stats from the per-sizeclass
stats.

Change-Id: I13bdc4869538ece5649a8d2a41c6605371618e40
Reviewed-on: https://go-review.googlesource.com/41251
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2017-04-28 22:50:31 +00:00
Austin Clements
390fdead0b runtime: document runtime.Frames better
In particular, this says that Frames.Function uniquely identifies a
function within a program. We depend on this in various places that
use runtime.Frames in std, but it wasn't actually written down.

Change-Id: Ie7ede348c17673e11ae513a094862b60c506abc5
Reviewed-on: https://go-review.googlesource.com/41610
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-04-28 22:43:20 +00:00
Bryan C. Mills
fb0fe4277d expvar: replace RWMutex usage with sync.Map and atomics
Int and Float already used atomics.

When many goroutines on many CPUs concurrently update a StringSet or a
Map with different keys per goroutine, this change results in dramatic
steady-state speedups.

This change does add some overhead for single-CPU and ephemeral maps.
I believe that is mostly due to an increase in allocations per call
(to pack the map keys and values into interface{} values that may
escape into the heap). With better inlining and/or escape analysis,
the single-CPU penalty may decline somewhat.

There are still two RWMutexes in the package: one for the keys in the
global "vars" map, and one for the keys in individual Map variables.

Those RWMutexes could also be eliminated, but avoiding excessive
allocations when adding new keys would require care. The remaining
RWMutexes are only acquired in Do functions, which I believe are not
typically on the fast path.

updates #17973
updates #18177

name             old time/op    new time/op    delta
StringSet          65.9ns ± 8%    55.7ns ± 1%   -15.46%  (p=0.000 n=8+7)
StringSet-6         416ns ±22%     127ns ±19%   -69.37%  (p=0.000 n=8+8)
StringSet-48        309ns ± 8%      94ns ± 3%   -69.43%  (p=0.001 n=7+7)

name             old alloc/op   new alloc/op   delta
StringSet           0.00B         16.00B ± 0%     +Inf%  (p=0.000 n=8+8)
StringSet-6         0.00B         16.00B ± 0%     +Inf%  (p=0.000 n=8+8)
StringSet-48        0.00B         16.00B ± 0%     +Inf%  (p=0.000 n=8+8)

name             old allocs/op  new allocs/op  delta
StringSet            0.00           1.00 ± 0%     +Inf%  (p=0.000 n=8+8)
StringSet-6          0.00           1.00 ± 0%     +Inf%  (p=0.000 n=8+8)
StringSet-48         0.00           1.00 ± 0%     +Inf%  (p=0.000 n=8+8)

https://perf.golang.org/search?q=upload:20170427.3

name                           old time/op    new time/op    delta
IntAdd                           5.64ns ± 3%    5.58ns ± 1%      ~     (p=0.185 n=8+8)
IntAdd-6                         18.6ns ±32%    21.4ns ±21%      ~     (p=0.078 n=8+8)
IntAdd-48                        19.6ns ±13%    20.6ns ±19%      ~     (p=0.702 n=8+8)
IntSet                           5.50ns ± 1%    5.48ns ± 0%      ~     (p=0.222 n=7+8)
IntSet-6                         18.5ns ±16%    20.4ns ±30%      ~     (p=0.314 n=8+8)
IntSet-48                        19.7ns ±12%    20.4ns ±16%      ~     (p=0.522 n=8+8)
FloatAdd                         14.5ns ± 1%    14.6ns ± 2%      ~     (p=0.237 n=7+8)
FloatAdd-6                       69.9ns ±13%    68.4ns ± 7%      ~     (p=0.557 n=7+7)
FloatAdd-48                       110ns ± 9%     109ns ± 6%      ~     (p=0.667 n=8+8)
FloatSet                         7.62ns ± 3%    7.64ns ± 5%      ~     (p=0.939 n=8+8)
FloatSet-6                       20.7ns ±22%    21.0ns ±23%      ~     (p=0.959 n=8+8)
FloatSet-48                      20.4ns ±24%    20.8ns ±19%      ~     (p=0.899 n=8+8)
MapSet                           88.1ns ±15%   200.9ns ± 7%  +128.11%  (p=0.000 n=8+8)
MapSet-6                          453ns ±12%     202ns ± 8%   -55.43%  (p=0.000 n=8+8)
MapSet-48                         432ns ±12%     240ns ±15%   -44.49%  (p=0.000 n=8+8)
MapSetDifferent                   349ns ± 1%     876ns ± 2%  +151.08%  (p=0.001 n=6+7)
MapSetDifferent-6                1.74µs ±32%    0.25µs ±17%   -85.71%  (p=0.000 n=8+8)
MapSetDifferent-48               1.77µs ±10%    0.14µs ± 2%   -91.84%  (p=0.000 n=8+8)
MapSetString                     88.1ns ± 7%   205.3ns ± 5%  +132.98%  (p=0.001 n=7+7)
MapSetString-6                    438ns ±30%     205ns ± 9%   -53.15%  (p=0.000 n=8+8)
MapSetString-48                   419ns ±14%     241ns ±15%   -42.39%  (p=0.000 n=8+8)
MapAddSame                        686ns ± 9%    1010ns ± 5%   +47.41%  (p=0.000 n=8+8)
MapAddSame-6                      238ns ±10%     300ns ±11%   +26.22%  (p=0.000 n=8+8)
MapAddSame-48                     366ns ± 4%     483ns ± 3%   +32.06%  (p=0.000 n=8+8)
MapAddDifferent                  1.96µs ± 4%    3.24µs ± 6%   +65.58%  (p=0.000 n=8+8)
MapAddDifferent-6                 553ns ± 3%     948ns ± 8%   +71.43%  (p=0.000 n=7+8)
MapAddDifferent-48                548ns ± 4%    1242ns ±10%  +126.81%  (p=0.000 n=8+8)
MapAddSameSteadyState            31.5ns ± 7%    41.7ns ± 6%   +32.61%  (p=0.000 n=8+8)
MapAddSameSteadyState-6           239ns ± 7%     101ns ±30%   -57.53%  (p=0.000 n=7+8)
MapAddSameSteadyState-48          152ns ± 4%      85ns ±13%   -43.84%  (p=0.000 n=8+7)
MapAddDifferentSteadyState        151ns ± 5%     177ns ± 1%   +17.32%  (p=0.001 n=8+6)
MapAddDifferentSteadyState-6      861ns ±15%      62ns ±23%   -92.85%  (p=0.000 n=8+8)
MapAddDifferentSteadyState-48     617ns ± 2%      20ns ±14%   -96.75%  (p=0.000 n=8+8)
RealworldExpvarUsage             4.33µs ± 4%    4.48µs ± 6%      ~     (p=0.336 n=8+7)
RealworldExpvarUsage-6           2.12µs ±20%    2.28µs ±10%      ~     (p=0.228 n=8+6)
RealworldExpvarUsage-48          1.23µs ±19%    1.36µs ±16%      ~     (p=0.152 n=7+8)

name                           old alloc/op   new alloc/op   delta
IntAdd                            0.00B          0.00B           ~     (all equal)
IntAdd-6                          0.00B          0.00B           ~     (all equal)
IntAdd-48                         0.00B          0.00B           ~     (all equal)
IntSet                            0.00B          0.00B           ~     (all equal)
IntSet-6                          0.00B          0.00B           ~     (all equal)
IntSet-48                         0.00B          0.00B           ~     (all equal)
FloatAdd                          0.00B          0.00B           ~     (all equal)
FloatAdd-6                        0.00B          0.00B           ~     (all equal)
FloatAdd-48                       0.00B          0.00B           ~     (all equal)
FloatSet                          0.00B          0.00B           ~     (all equal)
FloatSet-6                        0.00B          0.00B           ~     (all equal)
FloatSet-48                       0.00B          0.00B           ~     (all equal)
MapSet                            0.00B         48.00B ± 0%     +Inf%  (p=0.000 n=8+8)
MapSet-6                          0.00B         48.00B ± 0%     +Inf%  (p=0.000 n=8+8)
MapSet-48                         0.00B         48.00B ± 0%     +Inf%  (p=0.000 n=8+8)
MapSetDifferent                   0.00B        192.00B ± 0%     +Inf%  (p=0.000 n=8+8)
MapSetDifferent-6                 0.00B        192.00B ± 0%     +Inf%  (p=0.000 n=8+8)
MapSetDifferent-48                0.00B        192.00B ± 0%     +Inf%  (p=0.000 n=8+8)
MapSetString                      0.00B         48.00B ± 0%     +Inf%  (p=0.000 n=8+8)
MapSetString-6                    0.00B         48.00B ± 0%     +Inf%  (p=0.000 n=8+8)
MapSetString-48                   0.00B         48.00B ± 0%     +Inf%  (p=0.000 n=8+8)
MapAddSame                         456B ± 0%      480B ± 0%    +5.26%  (p=0.000 n=8+8)
MapAddSame-6                       456B ± 0%      480B ± 0%    +5.26%  (p=0.000 n=8+8)
MapAddSame-48                      456B ± 0%      480B ± 0%    +5.26%  (p=0.000 n=8+8)
MapAddDifferent                    672B ± 0%     1088B ± 0%   +61.90%  (p=0.000 n=8+8)
MapAddDifferent-6                  672B ± 0%     1088B ± 0%   +61.90%  (p=0.000 n=8+8)
MapAddDifferent-48                 672B ± 0%     1088B ± 0%   +61.90%  (p=0.000 n=8+8)
MapAddSameSteadyState             0.00B          0.00B           ~     (all equal)
MapAddSameSteadyState-6           0.00B          0.00B           ~     (all equal)
MapAddSameSteadyState-48          0.00B          0.00B           ~     (all equal)
MapAddDifferentSteadyState        0.00B          0.00B           ~     (all equal)
MapAddDifferentSteadyState-6      0.00B          0.00B           ~     (all equal)
MapAddDifferentSteadyState-48     0.00B          0.00B           ~     (all equal)
RealworldExpvarUsage              0.00B          0.00B           ~     (all equal)
RealworldExpvarUsage-6            0.00B          0.00B           ~     (all equal)
RealworldExpvarUsage-48           0.00B          0.00B           ~     (all equal)

name                           old allocs/op  new allocs/op  delta
IntAdd                             0.00           0.00           ~     (all equal)
IntAdd-6                           0.00           0.00           ~     (all equal)
IntAdd-48                          0.00           0.00           ~     (all equal)
IntSet                             0.00           0.00           ~     (all equal)
IntSet-6                           0.00           0.00           ~     (all equal)
IntSet-48                          0.00           0.00           ~     (all equal)
FloatAdd                           0.00           0.00           ~     (all equal)
FloatAdd-6                         0.00           0.00           ~     (all equal)
FloatAdd-48                        0.00           0.00           ~     (all equal)
FloatSet                           0.00           0.00           ~     (all equal)
FloatSet-6                         0.00           0.00           ~     (all equal)
FloatSet-48                        0.00           0.00           ~     (all equal)
MapSet                             0.00           3.00 ± 0%     +Inf%  (p=0.000 n=8+8)
MapSet-6                           0.00           3.00 ± 0%     +Inf%  (p=0.000 n=8+8)
MapSet-48                          0.00           3.00 ± 0%     +Inf%  (p=0.000 n=8+8)
MapSetDifferent                    0.00          12.00 ± 0%     +Inf%  (p=0.000 n=8+8)
MapSetDifferent-6                  0.00          12.00 ± 0%     +Inf%  (p=0.000 n=8+8)
MapSetDifferent-48                 0.00          12.00 ± 0%     +Inf%  (p=0.000 n=8+8)
MapSetString                       0.00           3.00 ± 0%     +Inf%  (p=0.000 n=8+8)
MapSetString-6                     0.00           3.00 ± 0%     +Inf%  (p=0.000 n=8+8)
MapSetString-48                    0.00           3.00 ± 0%     +Inf%  (p=0.000 n=8+8)
MapAddSame                         6.00 ± 0%     11.00 ± 0%   +83.33%  (p=0.000 n=8+8)
MapAddSame-6                       6.00 ± 0%     11.00 ± 0%   +83.33%  (p=0.000 n=8+8)
MapAddSame-48                      6.00 ± 0%     11.00 ± 0%   +83.33%  (p=0.000 n=8+8)
MapAddDifferent                    14.0 ± 0%      31.0 ± 0%  +121.43%  (p=0.000 n=8+8)
MapAddDifferent-6                  14.0 ± 0%      31.0 ± 0%  +121.43%  (p=0.000 n=8+8)
MapAddDifferent-48                 14.0 ± 0%      31.0 ± 0%  +121.43%  (p=0.000 n=8+8)
MapAddSameSteadyState              0.00           0.00           ~     (all equal)
MapAddSameSteadyState-6            0.00           0.00           ~     (all equal)
MapAddSameSteadyState-48           0.00           0.00           ~     (all equal)
MapAddDifferentSteadyState         0.00           0.00           ~     (all equal)
MapAddDifferentSteadyState-6       0.00           0.00           ~     (all equal)
MapAddDifferentSteadyState-48      0.00           0.00           ~     (all equal)
RealworldExpvarUsage               0.00           0.00           ~     (all equal)
RealworldExpvarUsage-6             0.00           0.00           ~     (all equal)
RealworldExpvarUsage-48            0.00           0.00           ~     (all equal)

https://perf.golang.org/search?q=upload:20170427.1

Change-Id: I388b2e8a3cadb84fc1418af8acfc27338f799273
Reviewed-on: https://go-review.googlesource.com/41930
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-04-28 21:59:55 +00:00
Brad Fitzpatrick
95e7897bd8 Revert "build: fail nicely if somebody runs all.bash from a binary tarball package"
This reverts commit 3d86d45dd6.

Reason for revert: Fixing a different way. See #20008.

Change-Id: I6f4382ffdfff83a4504b013ba37100319b2c1aad
Reviewed-on: https://go-review.googlesource.com/42138
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-28 21:19:32 +00:00
Bryan C. Mills
e8d7e5d1fa mime: use sync.Map instead of RWMutex for type lookups
This provides a significant speedup for TypeByExtension and
ExtensionsByType when using many CPU cores.

updates #17973
updates #18177

name                                          old time/op    new time/op    delta
QEncodeWord                                      526ns ± 3%     525ns ± 3%     ~     (p=0.990 n=15+28)
QEncodeWord-6                                    945ns ± 7%     913ns ±20%     ~     (p=0.220 n=14+28)
QEncodeWord-48                                  1.02µs ± 2%    1.00µs ± 6%   -2.22%  (p=0.036 n=13+27)
QDecodeWord                                      311ns ±18%     323ns ±20%     ~     (p=0.107 n=16+28)
QDecodeWord-6                                    595ns ±12%     612ns ±11%     ~     (p=0.093 n=15+27)
QDecodeWord-48                                   592ns ± 6%     606ns ± 8%   +2.39%  (p=0.045 n=16+26)
QDecodeHeader                                    389ns ± 4%     394ns ± 8%     ~     (p=0.161 n=12+26)
QDecodeHeader-6                                  685ns ±12%     674ns ±20%     ~     (p=0.773 n=14+27)
QDecodeHeader-48                                 658ns ±13%     669ns ±14%     ~     (p=0.457 n=16+28)
TypeByExtension/.html                           77.4ns ±15%    55.5ns ±13%  -28.35%  (p=0.000 n=8+8)
TypeByExtension/.html-6                          263ns ± 9%      10ns ±21%  -96.29%  (p=0.000 n=8+8)
TypeByExtension/.html-48                         175ns ± 5%       2ns ±16%  -98.88%  (p=0.000 n=8+8)
TypeByExtension/.HTML                            113ns ± 6%      97ns ± 6%  -14.37%  (p=0.000 n=8+8)
TypeByExtension/.HTML-6                          273ns ± 7%      17ns ± 4%  -93.93%  (p=0.000 n=7+8)
TypeByExtension/.HTML-48                         175ns ± 4%       4ns ± 4%  -97.73%  (p=0.000 n=8+8)
TypeByExtension/.unused                          116ns ± 4%      90ns ± 4%  -22.89%  (p=0.001 n=7+7)
TypeByExtension/.unused-6                        262ns ± 5%      15ns ± 4%  -94.17%  (p=0.000 n=8+8)
TypeByExtension/.unused-48                       176ns ± 4%       3ns ±10%  -98.10%  (p=0.000 n=8+8)
ExtensionsByType/text/html                       630ns ± 5%     522ns ± 5%  -17.19%  (p=0.000 n=8+7)
ExtensionsByType/text/html-6                     314ns ±20%     136ns ± 6%  -56.80%  (p=0.000 n=8+8)
ExtensionsByType/text/html-48                    298ns ± 4%     104ns ± 6%  -65.06%  (p=0.000 n=8+8)
ExtensionsByType/text/html;_charset=utf-8       1.12µs ± 3%    1.05µs ± 7%   -6.19%  (p=0.004 n=8+7)
ExtensionsByType/text/html;_charset=utf-8-6      402ns ±11%     307ns ± 4%  -23.77%  (p=0.000 n=8+8)
ExtensionsByType/text/html;_charset=utf-8-48     422ns ± 3%     309ns ± 4%  -26.86%  (p=0.000 n=8+8)
ExtensionsByType/application/octet-stream        810ns ± 2%     747ns ± 5%   -7.74%  (p=0.000 n=8+8)
ExtensionsByType/application/octet-stream-6      289ns ± 9%     185ns ± 8%  -36.15%  (p=0.000 n=7+8)
ExtensionsByType/application/octet-stream-48     267ns ± 6%      94ns ± 2%  -64.91%  (p=0.000 n=8+7)

name                                          old alloc/op   new alloc/op   delta
QEncodeWord                                      48.0B ± 0%     48.0B ± 0%     ~     (all equal)
QEncodeWord-6                                    48.0B ± 0%     48.0B ± 0%     ~     (all equal)
QEncodeWord-48                                   48.0B ± 0%     48.0B ± 0%     ~     (all equal)
QDecodeWord                                      48.0B ± 0%     48.0B ± 0%     ~     (all equal)
QDecodeWord-6                                    48.0B ± 0%     48.0B ± 0%     ~     (all equal)
QDecodeWord-48                                   48.0B ± 0%     48.0B ± 0%     ~     (all equal)
QDecodeHeader                                    48.0B ± 0%     48.0B ± 0%     ~     (all equal)
QDecodeHeader-6                                  48.0B ± 0%     48.0B ± 0%     ~     (all equal)
QDecodeHeader-48                                 48.0B ± 0%     48.0B ± 0%     ~     (all equal)
TypeByExtension/.html                            0.00B          0.00B          ~     (all equal)
TypeByExtension/.html-6                          0.00B          0.00B          ~     (all equal)
TypeByExtension/.html-48                         0.00B          0.00B          ~     (all equal)
TypeByExtension/.HTML                            0.00B          0.00B          ~     (all equal)
TypeByExtension/.HTML-6                          0.00B          0.00B          ~     (all equal)
TypeByExtension/.HTML-48                         0.00B          0.00B          ~     (all equal)
TypeByExtension/.unused                          0.00B          0.00B          ~     (all equal)
TypeByExtension/.unused-6                        0.00B          0.00B          ~     (all equal)
TypeByExtension/.unused-48                       0.00B          0.00B          ~     (all equal)
ExtensionsByType/text/html                        192B ± 0%      176B ± 0%   -8.33%  (p=0.000 n=8+8)
ExtensionsByType/text/html-6                      192B ± 0%      176B ± 0%   -8.33%  (p=0.000 n=8+8)
ExtensionsByType/text/html-48                     192B ± 0%      176B ± 0%   -8.33%  (p=0.000 n=8+8)
ExtensionsByType/text/html;_charset=utf-8         480B ± 0%      464B ± 0%   -3.33%  (p=0.000 n=8+8)
ExtensionsByType/text/html;_charset=utf-8-6       480B ± 0%      464B ± 0%   -3.33%  (p=0.000 n=8+8)
ExtensionsByType/text/html;_charset=utf-8-48      480B ± 0%      464B ± 0%   -3.33%  (p=0.000 n=8+8)
ExtensionsByType/application/octet-stream         160B ± 0%      160B ± 0%     ~     (all equal)
ExtensionsByType/application/octet-stream-6       160B ± 0%      160B ± 0%     ~     (all equal)
ExtensionsByType/application/octet-stream-48      160B ± 0%      160B ± 0%     ~     (all equal)

name                                          old allocs/op  new allocs/op  delta
QEncodeWord                                       1.00 ± 0%      1.00 ± 0%     ~     (all equal)
QEncodeWord-6                                     1.00 ± 0%      1.00 ± 0%     ~     (all equal)
QEncodeWord-48                                    1.00 ± 0%      1.00 ± 0%     ~     (all equal)
QDecodeWord                                       2.00 ± 0%      2.00 ± 0%     ~     (all equal)
QDecodeWord-6                                     2.00 ± 0%      2.00 ± 0%     ~     (all equal)
QDecodeWord-48                                    2.00 ± 0%      2.00 ± 0%     ~     (all equal)
QDecodeHeader                                     2.00 ± 0%      2.00 ± 0%     ~     (all equal)
QDecodeHeader-6                                   2.00 ± 0%      2.00 ± 0%     ~     (all equal)
QDecodeHeader-48                                  2.00 ± 0%      2.00 ± 0%     ~     (all equal)
TypeByExtension/.html                             0.00           0.00          ~     (all equal)
TypeByExtension/.html-6                           0.00           0.00          ~     (all equal)
TypeByExtension/.html-48                          0.00           0.00          ~     (all equal)
TypeByExtension/.HTML                             0.00           0.00          ~     (all equal)
TypeByExtension/.HTML-6                           0.00           0.00          ~     (all equal)
TypeByExtension/.HTML-48                          0.00           0.00          ~     (all equal)
TypeByExtension/.unused                           0.00           0.00          ~     (all equal)
TypeByExtension/.unused-6                         0.00           0.00          ~     (all equal)
TypeByExtension/.unused-48                        0.00           0.00          ~     (all equal)
ExtensionsByType/text/html                        3.00 ± 0%      3.00 ± 0%     ~     (all equal)
ExtensionsByType/text/html-6                      3.00 ± 0%      3.00 ± 0%     ~     (all equal)
ExtensionsByType/text/html-48                     3.00 ± 0%      3.00 ± 0%     ~     (all equal)
ExtensionsByType/text/html;_charset=utf-8         4.00 ± 0%      4.00 ± 0%     ~     (all equal)
ExtensionsByType/text/html;_charset=utf-8-6       4.00 ± 0%      4.00 ± 0%     ~     (all equal)
ExtensionsByType/text/html;_charset=utf-8-48      4.00 ± 0%      4.00 ± 0%     ~     (all equal)
ExtensionsByType/application/octet-stream         2.00 ± 0%      2.00 ± 0%     ~     (all equal)
ExtensionsByType/application/octet-stream-6       2.00 ± 0%      2.00 ± 0%     ~     (all equal)
ExtensionsByType/application/octet-stream-48      2.00 ± 0%      2.00 ± 0%     ~     (all equal)

https://perf.golang.org/search?q=upload:20170427.4

Change-Id: I35438be087ad6eb3d5da9119b395723ea5babaf6
Reviewed-on: https://go-review.googlesource.com/41990
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-04-28 20:49:29 +00:00
Bryan C. Mills
ce5263ff8d net/rpc: use a sync.Map for serviceMap instead of RWMutex
This has no measurable impact on performance, but somewhat simplifies
the code.

updates #18177

name                  old time/op    new time/op    delta
EndToEnd                54.3µs ±10%    55.7µs ±12%    ~     (p=0.505 n=8+8)
EndToEnd-6              31.4µs ± 9%    32.7µs ± 6%    ~     (p=0.130 n=8+8)
EndToEnd-48             25.5µs ±12%    26.4µs ± 6%    ~     (p=0.195 n=8+8)
EndToEndHTTP            53.7µs ± 8%    51.2µs ±15%    ~     (p=0.463 n=7+8)
EndToEndHTTP-6          30.9µs ±18%    31.2µs ±14%    ~     (p=0.959 n=8+8)
EndToEndHTTP-48         24.9µs ±11%    25.7µs ± 6%    ~     (p=0.382 n=8+8)
EndToEndAsync           23.6µs ± 7%    24.2µs ± 6%    ~     (p=0.383 n=7+7)
EndToEndAsync-6         21.0µs ±23%    22.0µs ±20%    ~     (p=0.574 n=8+8)
EndToEndAsync-48        22.8µs ±16%    23.3µs ±13%    ~     (p=0.721 n=8+8)
EndToEndAsyncHTTP       25.8µs ± 7%    24.7µs ±14%    ~     (p=0.161 n=8+8)
EndToEndAsyncHTTP-6     22.1µs ±19%    22.6µs ±12%    ~     (p=0.645 n=8+8)
EndToEndAsyncHTTP-48    22.9µs ±13%    22.1µs ±20%    ~     (p=0.574 n=8+8)

name                  old alloc/op   new alloc/op   delta
EndToEnd                  320B ± 0%      321B ± 0%    ~     (p=1.000 n=8+8)
EndToEnd-6                320B ± 0%      321B ± 0%  +0.20%  (p=0.037 n=8+7)
EndToEnd-48               326B ± 0%      326B ± 0%    ~     (p=0.124 n=8+8)
EndToEndHTTP              320B ± 0%      320B ± 0%    ~     (all equal)
EndToEndHTTP-6            320B ± 0%      321B ± 0%    ~     (p=0.077 n=8+8)
EndToEndHTTP-48           324B ± 0%      324B ± 0%    ~     (p=1.000 n=8+8)
EndToEndAsync             227B ± 0%      227B ± 0%    ~     (p=0.154 n=8+7)
EndToEndAsync-6           226B ± 0%      226B ± 0%    ~     (all equal)
EndToEndAsync-48          230B ± 1%      229B ± 1%    ~     (p=0.072 n=8+8)
EndToEndAsyncHTTP         227B ± 0%      227B ± 0%    ~     (all equal)
EndToEndAsyncHTTP-6       226B ± 0%      226B ± 0%    ~     (p=0.400 n=8+7)
EndToEndAsyncHTTP-48      228B ± 0%      228B ± 0%    ~     (p=0.949 n=8+6)

name                  old allocs/op  new allocs/op  delta
EndToEnd                  9.00 ± 0%      9.00 ± 0%    ~     (all equal)
EndToEnd-6                9.00 ± 0%      9.00 ± 0%    ~     (all equal)
EndToEnd-48               9.00 ± 0%      9.00 ± 0%    ~     (all equal)
EndToEndHTTP              9.00 ± 0%      9.00 ± 0%    ~     (all equal)
EndToEndHTTP-6            9.00 ± 0%      9.00 ± 0%    ~     (all equal)
EndToEndHTTP-48           9.00 ± 0%      9.00 ± 0%    ~     (all equal)
EndToEndAsync             8.00 ± 0%      8.00 ± 0%    ~     (all equal)
EndToEndAsync-6           8.00 ± 0%      8.00 ± 0%    ~     (all equal)
EndToEndAsync-48          8.00 ± 0%      8.00 ± 0%    ~     (all equal)
EndToEndAsyncHTTP         8.00 ± 0%      8.00 ± 0%    ~     (all equal)
EndToEndAsyncHTTP-6       8.00 ± 0%      8.00 ± 0%    ~     (all equal)
EndToEndAsyncHTTP-48      8.00 ± 0%      8.00 ± 0%    ~     (all equal)

https://perf.golang.org/search?q=upload:20170428.2

Change-Id: I8ef7f71a7602302aa78c144327270dfce9211539
Reviewed-on: https://go-review.googlesource.com/42112
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-28 20:42:11 +00:00
Bryan C. Mills
d6ce7e4fec encoding/json: replace encoderCache RWMutex with a sync.Map
This provides a moderate speedup for encoding when using many CPU cores.

name                    old time/op    new time/op    delta
CodeEncoder               14.1ms ±10%    13.5ms ± 4%      ~     (p=0.867 n=8+7)
CodeEncoder-6             2.58ms ± 8%    2.72ms ± 6%      ~     (p=0.065 n=8+8)
CodeEncoder-48             629µs ± 1%     629µs ± 1%      ~     (p=0.867 n=8+7)
CodeMarshal               14.9ms ± 5%    14.9ms ± 5%      ~     (p=0.721 n=8+8)
CodeMarshal-6             3.28ms ±11%    3.24ms ±12%      ~     (p=0.798 n=8+8)
CodeMarshal-48             739µs ± 1%     745µs ± 2%      ~     (p=0.328 n=8+8)
CodeDecoder               49.7ms ± 4%    49.2ms ± 4%      ~     (p=0.463 n=7+8)
CodeDecoder-6             10.1ms ± 8%    10.4ms ± 3%      ~     (p=0.232 n=7+8)
CodeDecoder-48            2.60ms ± 3%    2.61ms ± 2%      ~     (p=1.000 n=8+8)
DecoderStream              352ns ± 5%     344ns ± 4%      ~     (p=0.077 n=8+8)
DecoderStream-6            485ns ± 8%     503ns ± 6%      ~     (p=0.123 n=8+8)
DecoderStream-48           522ns ± 7%     520ns ± 5%      ~     (p=0.959 n=8+8)
CodeUnmarshal             52.2ms ± 5%    54.4ms ±18%      ~     (p=0.955 n=7+8)
CodeUnmarshal-6           12.4ms ± 6%    12.3ms ± 6%      ~     (p=0.878 n=8+8)
CodeUnmarshal-48          3.46ms ± 7%    3.40ms ± 9%      ~     (p=0.442 n=8+8)
CodeUnmarshalReuse        48.9ms ± 6%    50.3ms ± 7%      ~     (p=0.279 n=8+8)
CodeUnmarshalReuse-6      10.3ms ±11%    10.3ms ±10%      ~     (p=0.959 n=8+8)
CodeUnmarshalReuse-48     2.68ms ± 3%    2.67ms ± 4%      ~     (p=0.878 n=8+8)
UnmarshalString            476ns ± 7%     474ns ± 7%      ~     (p=0.644 n=8+8)
UnmarshalString-6          164ns ± 9%     160ns ±10%      ~     (p=0.556 n=8+8)
UnmarshalString-48         181ns ± 0%     177ns ± 2%    -2.36%  (p=0.001 n=7+7)
UnmarshalFloat64           414ns ± 4%     418ns ± 4%      ~     (p=0.382 n=8+8)
UnmarshalFloat64-6         147ns ± 9%     143ns ±16%      ~     (p=0.457 n=8+8)
UnmarshalFloat64-48        176ns ± 2%     174ns ± 2%      ~     (p=0.118 n=8+8)
UnmarshalInt64             369ns ± 4%     354ns ± 1%    -3.85%  (p=0.005 n=8+7)
UnmarshalInt64-6           132ns ±11%     132ns ±10%      ~     (p=0.982 n=8+8)
UnmarshalInt64-48          177ns ± 3%     174ns ± 2%    -1.84%  (p=0.028 n=8+7)
Issue10335                 540ns ± 5%     535ns ± 0%      ~     (p=0.330 n=7+7)
Issue10335-6               159ns ± 8%     164ns ± 8%      ~     (p=0.246 n=8+8)
Issue10335-48              186ns ± 1%     182ns ± 2%    -1.89%  (p=0.010 n=8+8)
Unmapped                  1.74µs ± 2%    1.76µs ± 6%      ~     (p=0.181 n=6+8)
Unmapped-6                 414ns ± 5%     402ns ±10%      ~     (p=0.244 n=7+8)
Unmapped-48                226ns ± 2%     224ns ± 2%      ~     (p=0.144 n=7+8)
NumberIsValid             20.1ns ± 4%    19.7ns ± 3%      ~     (p=0.204 n=8+8)
NumberIsValid-6           20.4ns ± 8%    22.2ns ±16%      ~     (p=0.129 n=7+8)
NumberIsValid-48          23.1ns ±12%    23.8ns ± 8%      ~     (p=0.104 n=8+8)
NumberIsValidRegexp        629ns ± 5%     622ns ± 0%      ~     (p=0.148 n=7+7)
NumberIsValidRegexp-6      757ns ± 2%     725ns ±14%      ~     (p=0.351 n=8+7)
NumberIsValidRegexp-48     757ns ± 2%     723ns ±13%      ~     (p=0.521 n=8+8)
SkipValue                 13.2ms ± 9%    13.3ms ± 1%      ~     (p=0.130 n=8+8)
SkipValue-6               15.1ms ±10%    14.8ms ± 2%      ~     (p=0.397 n=7+8)
SkipValue-48              13.9ms ±12%    14.3ms ± 1%      ~     (p=0.694 n=8+7)
EncoderEncode              433ns ± 4%     410ns ± 3%    -5.48%  (p=0.001 n=8+8)
EncoderEncode-6            221ns ±15%      75ns ± 5%   -66.15%  (p=0.000 n=7+8)
EncoderEncode-48           161ns ± 4%      19ns ± 7%   -88.29%  (p=0.000 n=7+8)

name                    old speed      new speed      delta
CodeEncoder              139MB/s ±10%   144MB/s ± 4%      ~     (p=0.844 n=8+7)
CodeEncoder-6            756MB/s ± 8%   714MB/s ± 6%      ~     (p=0.065 n=8+8)
CodeEncoder-48          3.08GB/s ± 1%  3.09GB/s ± 1%      ~     (p=0.867 n=8+7)
CodeMarshal              130MB/s ± 5%   130MB/s ± 5%      ~     (p=0.721 n=8+8)
CodeMarshal-6            594MB/s ±10%   601MB/s ±11%      ~     (p=0.798 n=8+8)
CodeMarshal-48          2.62GB/s ± 1%  2.60GB/s ± 2%      ~     (p=0.328 n=8+8)
CodeDecoder             39.0MB/s ± 4%  39.5MB/s ± 4%      ~     (p=0.463 n=7+8)
CodeDecoder-6            189MB/s ±13%   187MB/s ± 3%      ~     (p=0.505 n=8+8)
CodeDecoder-48           746MB/s ± 2%   745MB/s ± 2%      ~     (p=1.000 n=8+8)
CodeUnmarshal           37.2MB/s ± 5%  35.9MB/s ±16%      ~     (p=0.955 n=7+8)
CodeUnmarshal-6          157MB/s ± 6%   158MB/s ± 6%      ~     (p=0.878 n=8+8)
CodeUnmarshal-48         561MB/s ± 7%   572MB/s ±10%      ~     (p=0.442 n=8+8)
SkipValue                141MB/s ±10%   139MB/s ± 1%      ~     (p=0.130 n=8+8)
SkipValue-6              131MB/s ± 3%   133MB/s ± 2%      ~     (p=0.662 n=6+8)
SkipValue-48             138MB/s ±11%   132MB/s ± 1%      ~     (p=0.281 n=8+7)

name                    old alloc/op   new alloc/op   delta
CodeEncoder               45.9kB ± 0%    45.9kB ± 0%    -0.02%  (p=0.002 n=7+8)
CodeEncoder-6             55.1kB ± 0%    55.1kB ± 0%    -0.01%  (p=0.002 n=7+8)
CodeEncoder-48             110kB ± 0%     110kB ± 0%    -0.00%  (p=0.030 n=7+8)
CodeMarshal               4.59MB ± 0%    4.59MB ± 0%    -0.00%  (p=0.000 n=8+8)
CodeMarshal-6             4.59MB ± 0%    4.59MB ± 0%    -0.00%  (p=0.000 n=8+8)
CodeMarshal-48            4.59MB ± 0%    4.59MB ± 0%    -0.00%  (p=0.001 n=7+8)
CodeDecoder               2.28MB ± 5%    2.21MB ± 0%      ~     (p=0.257 n=8+7)
CodeDecoder-6             2.43MB ±11%    2.51MB ± 0%      ~     (p=0.473 n=8+8)
CodeDecoder-48            2.93MB ± 0%    2.93MB ± 0%      ~     (p=0.554 n=7+8)
DecoderStream              16.0B ± 0%     16.0B ± 0%      ~     (all equal)
DecoderStream-6            16.0B ± 0%     16.0B ± 0%      ~     (all equal)
DecoderStream-48           16.0B ± 0%     16.0B ± 0%      ~     (all equal)
CodeUnmarshal             3.28MB ± 0%    3.28MB ± 0%      ~     (p=1.000 n=7+7)
CodeUnmarshal-6           3.28MB ± 0%    3.28MB ± 0%      ~     (p=0.593 n=8+8)
CodeUnmarshal-48          3.28MB ± 0%    3.28MB ± 0%      ~     (p=0.670 n=8+8)
CodeUnmarshalReuse        1.87MB ± 0%    1.88MB ± 1%    +0.48%  (p=0.011 n=7+8)
CodeUnmarshalReuse-6      1.90MB ± 1%    1.90MB ± 1%      ~     (p=0.589 n=8+8)
CodeUnmarshalReuse-48     1.96MB ± 0%    1.96MB ± 0%    +0.00%  (p=0.002 n=7+8)
UnmarshalString             304B ± 0%      304B ± 0%      ~     (all equal)
UnmarshalString-6           304B ± 0%      304B ± 0%      ~     (all equal)
UnmarshalString-48          304B ± 0%      304B ± 0%      ~     (all equal)
UnmarshalFloat64            292B ± 0%      292B ± 0%      ~     (all equal)
UnmarshalFloat64-6          292B ± 0%      292B ± 0%      ~     (all equal)
UnmarshalFloat64-48         292B ± 0%      292B ± 0%      ~     (all equal)
UnmarshalInt64              289B ± 0%      289B ± 0%      ~     (all equal)
UnmarshalInt64-6            289B ± 0%      289B ± 0%      ~     (all equal)
UnmarshalInt64-48           289B ± 0%      289B ± 0%      ~     (all equal)
Issue10335                  312B ± 0%      312B ± 0%      ~     (all equal)
Issue10335-6                312B ± 0%      312B ± 0%      ~     (all equal)
Issue10335-48               312B ± 0%      312B ± 0%      ~     (all equal)
Unmapped                    344B ± 0%      344B ± 0%      ~     (all equal)
Unmapped-6                  344B ± 0%      344B ± 0%      ~     (all equal)
Unmapped-48                 344B ± 0%      344B ± 0%      ~     (all equal)
NumberIsValid              0.00B          0.00B           ~     (all equal)
NumberIsValid-6            0.00B          0.00B           ~     (all equal)
NumberIsValid-48           0.00B          0.00B           ~     (all equal)
NumberIsValidRegexp        0.00B          0.00B           ~     (all equal)
NumberIsValidRegexp-6      0.00B          0.00B           ~     (all equal)
NumberIsValidRegexp-48     0.00B          0.00B           ~     (all equal)
SkipValue                  0.00B          0.00B           ~     (all equal)
SkipValue-6                0.00B          0.00B           ~     (all equal)
SkipValue-48              15.0B ±167%      0.0B           ~     (p=0.200 n=8+8)
EncoderEncode              8.00B ± 0%     0.00B       -100.00%  (p=0.000 n=8+8)
EncoderEncode-6            8.00B ± 0%     0.00B       -100.00%  (p=0.000 n=8+8)
EncoderEncode-48           8.00B ± 0%     0.00B       -100.00%  (p=0.000 n=8+8)

name                    old allocs/op  new allocs/op  delta
CodeEncoder                 1.00 ± 0%      0.00       -100.00%  (p=0.000 n=8+8)
CodeEncoder-6               1.00 ± 0%      0.00       -100.00%  (p=0.000 n=8+8)
CodeEncoder-48              1.00 ± 0%      0.00       -100.00%  (p=0.000 n=8+8)
CodeMarshal                 17.0 ± 0%      16.0 ± 0%    -5.88%  (p=0.000 n=8+8)
CodeMarshal-6               17.0 ± 0%      16.0 ± 0%    -5.88%  (p=0.000 n=8+8)
CodeMarshal-48              17.0 ± 0%      16.0 ± 0%    -5.88%  (p=0.000 n=8+8)
CodeDecoder                89.6k ± 0%     89.5k ± 0%      ~     (p=0.154 n=8+7)
CodeDecoder-6              89.8k ± 0%     89.9k ± 0%      ~     (p=0.467 n=8+8)
CodeDecoder-48             90.5k ± 0%     90.5k ± 0%      ~     (p=0.533 n=8+7)
DecoderStream               2.00 ± 0%      2.00 ± 0%      ~     (all equal)
DecoderStream-6             2.00 ± 0%      2.00 ± 0%      ~     (all equal)
DecoderStream-48            2.00 ± 0%      2.00 ± 0%      ~     (all equal)
CodeUnmarshal               105k ± 0%      105k ± 0%      ~     (all equal)
CodeUnmarshal-6             105k ± 0%      105k ± 0%      ~     (all equal)
CodeUnmarshal-48            105k ± 0%      105k ± 0%      ~     (all equal)
CodeUnmarshalReuse         89.5k ± 0%     89.6k ± 0%      ~     (p=0.246 n=7+8)
CodeUnmarshalReuse-6       89.8k ± 0%     89.8k ± 0%      ~     (p=1.000 n=8+8)
CodeUnmarshalReuse-48      90.5k ± 0%     90.5k ± 0%      ~     (all equal)
UnmarshalString             2.00 ± 0%      2.00 ± 0%      ~     (all equal)
UnmarshalString-6           2.00 ± 0%      2.00 ± 0%      ~     (all equal)
UnmarshalString-48          2.00 ± 0%      2.00 ± 0%      ~     (all equal)
UnmarshalFloat64            2.00 ± 0%      2.00 ± 0%      ~     (all equal)
UnmarshalFloat64-6          2.00 ± 0%      2.00 ± 0%      ~     (all equal)
UnmarshalFloat64-48         2.00 ± 0%      2.00 ± 0%      ~     (all equal)
UnmarshalInt64              2.00 ± 0%      2.00 ± 0%      ~     (all equal)
UnmarshalInt64-6            2.00 ± 0%      2.00 ± 0%      ~     (all equal)
UnmarshalInt64-48           2.00 ± 0%      2.00 ± 0%      ~     (all equal)
Issue10335                  3.00 ± 0%      3.00 ± 0%      ~     (all equal)
Issue10335-6                3.00 ± 0%      3.00 ± 0%      ~     (all equal)
Issue10335-48               3.00 ± 0%      3.00 ± 0%      ~     (all equal)
Unmapped                    4.00 ± 0%      4.00 ± 0%      ~     (all equal)
Unmapped-6                  4.00 ± 0%      4.00 ± 0%      ~     (all equal)
Unmapped-48                 4.00 ± 0%      4.00 ± 0%      ~     (all equal)
NumberIsValid               0.00           0.00           ~     (all equal)
NumberIsValid-6             0.00           0.00           ~     (all equal)
NumberIsValid-48            0.00           0.00           ~     (all equal)
NumberIsValidRegexp         0.00           0.00           ~     (all equal)
NumberIsValidRegexp-6       0.00           0.00           ~     (all equal)
NumberIsValidRegexp-48      0.00           0.00           ~     (all equal)
SkipValue                   0.00           0.00           ~     (all equal)
SkipValue-6                 0.00           0.00           ~     (all equal)
SkipValue-48                0.00           0.00           ~     (all equal)
EncoderEncode               1.00 ± 0%      0.00       -100.00%  (p=0.000 n=8+8)
EncoderEncode-6             1.00 ± 0%      0.00       -100.00%  (p=0.000 n=8+8)
EncoderEncode-48            1.00 ± 0%      0.00       -100.00%  (p=0.000 n=8+8)

https://perf.golang.org/search?q=upload:20170427.2

updates #17973
updates #18177

Change-Id: I5881c7a2bfad1766e6aa3444bb630883e0be467b
Reviewed-on: https://go-review.googlesource.com/41931
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-28 20:19:10 +00:00
Josh Bleecher Snyder
92363d52c0 cmd/compile: check width of embedded interfaces in expandiface
The code in #20162 contains an embedded interface.

It didn't get dowidth'd by the frontend,
and during DWARF generation, ngotype asked
for a string description of it,
which triggered a request for the number of fields
in the interface, which triggered a dowidth,
which is disallowed in the backend.

The other changes in this CL are to support the test.

Fixes #20162

Change-Id: I4d0be5bd949c361d4cdc89a8ed28b10977e40cf9
Reviewed-on: https://go-review.googlesource.com/42131
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-28 20:07:38 +00:00
Michael Hudson-Doyle
e29ea14100 cmd/link/internal/ld: unexport ReadOnly and RelROMap
Change-Id: I08e33b92dd8a22e28ec15aa5753904aa8e1c71f5
Reviewed-on: https://go-review.googlesource.com/42031
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-28 20:02:50 +00:00
Michael Hudson-Doyle
4aca8b00ff cmd/internal/objabi: shrink SymType down to a uint8
Now that it only takes small values.

Change-Id: I08086d392529d8775b470d65afc2475f8d0e7f4a
Reviewed-on: https://go-review.googlesource.com/42030
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-28 20:02:20 +00:00
Michael Hudson-Doyle
d2a9545178 cmd/internal: remove SymKind values that are only checked for, never set
Change-Id: Id152767c033c12966e9e12ae303b99f38776f919
Reviewed-on: https://go-review.googlesource.com/40987
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-28 20:01:54 +00:00
Josh Bleecher Snyder
794d29a46f cmd/compile: use a map to track liveness variable indices
It is not safe to modify Node.Opt in the backend.
Instead of using Node.Opt to store liveness variable indices, use a map.
This simplifies the code and makes it much more clearly race-free.
There are generally few such variables, so the maps are not a significant
source of allocations; this also remove some allocations from putting
int32s into interfaces.

Because map lookups are more expensive than interface value extraction,
reorder valueEffects to do the map lookup last.

The only remaining use of Node.Opt is now in esc.go.

Passes toolstash-check.

Fixes #20144

name        old alloc/op      new alloc/op      delta
Template         37.8MB ± 0%       37.9MB ± 0%    ~     (p=0.548 n=5+5)
Unicode          28.9MB ± 0%       28.9MB ± 0%    ~     (p=0.548 n=5+5)
GoTypes           110MB ± 0%        110MB ± 0%  +0.16%  (p=0.008 n=5+5)
Compiler          461MB ± 0%        462MB ± 0%  +0.08%  (p=0.008 n=5+5)
SSA              1.11GB ± 0%       1.11GB ± 0%  +0.11%  (p=0.008 n=5+5)
Flate            24.7MB ± 0%       24.7MB ± 0%    ~     (p=0.690 n=5+5)
GoParser         31.1MB ± 0%       31.1MB ± 0%    ~     (p=0.841 n=5+5)
Reflect          73.7MB ± 0%       73.8MB ± 0%  +0.23%  (p=0.008 n=5+5)
Tar              25.8MB ± 0%       25.7MB ± 0%    ~     (p=0.690 n=5+5)
XML              41.2MB ± 0%       41.2MB ± 0%    ~     (p=0.841 n=5+5)
[Geo mean]       71.9MB            71.9MB       +0.06%

name        old allocs/op     new allocs/op     delta
Template           385k ± 0%         384k ± 0%    ~     (p=0.548 n=5+5)
Unicode            344k ± 0%         343k ± 1%    ~     (p=0.421 n=5+5)
GoTypes           1.16M ± 0%        1.16M ± 0%    ~     (p=0.690 n=5+5)
Compiler          4.43M ± 0%        4.42M ± 0%    ~     (p=0.095 n=5+5)
SSA               9.86M ± 0%        9.84M ± 0%  -0.19%  (p=0.008 n=5+5)
Flate              238k ± 0%         238k ± 0%    ~     (p=1.000 n=5+5)
GoParser           321k ± 0%         320k ± 0%    ~     (p=0.310 n=5+5)
Reflect            956k ± 0%         956k ± 0%    ~     (p=1.000 n=5+5)
Tar                252k ± 0%         251k ± 0%    ~     (p=0.056 n=5+5)
XML                402k ± 1%         400k ± 1%  -0.57%  (p=0.032 n=5+5)
[Geo mean]         740k              739k       -0.19%

Change-Id: Id5916c9def76add272e89c59fe10968f0a6bb01d
Reviewed-on: https://go-review.googlesource.com/42135
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-28 19:50:53 +00:00
Brad Fitzpatrick
07a22bbc11 net/http: re-simplify HTTP/1.x status line writing
It used to be simple, and then it got complicated for speed (to reduce
allocations, mostly), but that involved a mutex and hurt multi-core
performance, contending on the mutex.

A change was sent to try to improve that mutex contention in
https://go-review.googlesource.com/c/42110/2/src/net/http/server.go
but that introduced its own allocations (the string->interface{}
boxing for the sync.Map key), which runs counter to the whole point of
that statusLine function: to remove allocations.

Instead, make the code simple again and not have a mutex. It's a bit
slower for the single-core case, but nobody with a single-user HTTP
server cares about 50 nanoseconds:

name                  old time/op    new time/op    delta
ResponseStatusLine      37.5ns ± 2%    87.1ns ± 2%  +132.42%          (p=0.029 n=4+4)
ResponseStatusLine-2    63.1ns ± 1%    43.1ns ±12%   -31.67%          (p=0.029 n=4+4)
ResponseStatusLine-4    53.8ns ± 8%    40.2ns ± 2%   -25.29%          (p=0.029 n=4+4)

name                  old alloc/op   new alloc/op   delta
ResponseStatusLine      0.00B ±NaN%    0.00B ±NaN%      ~     (all samples are equal)
ResponseStatusLine-2    0.00B ±NaN%    0.00B ±NaN%      ~     (all samples are equal)
ResponseStatusLine-4    0.00B ±NaN%    0.00B ±NaN%      ~     (all samples are equal)

name                  old allocs/op  new allocs/op  delta
ResponseStatusLine       0.00 ±NaN%     0.00 ±NaN%      ~     (all samples are equal)
ResponseStatusLine-2     0.00 ±NaN%     0.00 ±NaN%      ~     (all samples are equal)
ResponseStatusLine-4     0.00 ±NaN%     0.00 ±NaN%      ~     (all samples are equal)

(Note the code could be even simpler with fmt.Fprintf, but that is
 relatively slow and involves a bunch of allocations getting arguments
 into interface{} for the call)

Change-Id: I1fa119132dbbf97a8e7204ce3e0707d433060da2
Reviewed-on: https://go-review.googlesource.com/42133
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2017-04-28 19:11:17 +00:00
Daniel Martí
16b6bb88eb cmd/go: error on space-separated list with comma
Using 'go build -tags "foo,bar"' might seem to work when you wanted
-tags "foo bar", since they make up a single tag that doesn't exist and
the build is unaffected.

Instead, error on any tag that contains a comma.

Fixes #18800.

Change-Id: I6641e03e2ae121c8878d6301c4311aef97026b73
Reviewed-on: https://go-review.googlesource.com/41951
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-04-28 19:08:35 +00:00
Ian Lance Taylor
60db9fb6bc cmd/go: don't run TestTestRaceInstall in short mode
Fixes #20158

Change-Id: Iefa9a33569eb805f5ab678d17c37787835bc7efa
Reviewed-on: https://go-review.googlesource.com/42134
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-28 18:34:49 +00:00
Justin Nuß
585be4639b os/exec: document that non-comparable writers may race
The comment for Cmd.Stdout and Cmd.Stderr says that it's safe to
set both to the same writer, but it doesn't say that this only
works when both writers are comparable.

This change updates the comment to explain that using a
non-comparable writer may still lead to a race.

Fixes #19804

Change-Id: I63b420034666209a2b6fab48b9047c9d07b825e2
Reviewed-on: https://go-review.googlesource.com/42052
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-04-28 17:57:01 +00:00
Michael Matloob
f105c91757 runtime/pprof: propagate profile labels into profile proto
Profile labels added by the user using pprof.Do, if present will
be in a *labelMap stored in the unsafe.Pointer 'tag' field of
the profile map entry. This change extracts the labels from the tag
field and writes them to the profile proto.

Change-Id: Ic40fdc58b66e993ca91d5d5effe0e04ffbb5bc46
Reviewed-on: https://go-review.googlesource.com/39613
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2017-04-28 17:37:58 +00:00
Russ Cox
c82efb1fa3 runtime: fix profile handling of labels for race detector
If g1 sets its labels and then they are copied into a profile buffer
and then g2 reads the profile buffer and inspects the labels,
the race detector must understand that g1's recording of the labels
happens before g2's use of the labels. Make that so.

Fixes race test failure in CL 39613.

Change-Id: Id7cda1c2aac6f8eef49213b5ca414f7154b4acfa
Reviewed-on: https://go-review.googlesource.com/42111
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2017-04-28 17:37:46 +00:00
Robert Griesemer
86cfe93515 bytes: clarify documentation for UnreadByte/Rune
Fixes #19522.

Change-Id: Ib3cf0336e0bf91580d533704ec1a9d45eb0bf62d
Reviewed-on: https://go-review.googlesource.com/42020
Reviewed-by: Rob Pike <r@golang.org>
2017-04-28 16:37:13 +00:00
Josh Bleecher Snyder
85d6a29ae6 cmd/compile: prevent infinite recursion printing types in Fatalf
Updates #20162

Change-Id: Ie289bae0d0be8430e492ac73fd6e6bf36991d4a1
Reviewed-on: https://go-review.googlesource.com/42130
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-28 16:08:01 +00:00
Dmitri Shuralyov
6511931810 cmd/go/internal/get: allow go get on github.com/ import paths with Unicode letters
More specifically, allow Unicode letters in the directories of GitHub
repositories, which can occur and don't have a valid reason to be
disallowed by go get.

Do so by using a predefined character class, the Unicode character
property class \p{L} that describes the Unicode characters that are
letters:

	http://www.regular-expressions.info/unicode.html#category

Since it's not possible to create GitHub usernames or repositories
containing Unicode letters at this time, those parts of the import path
are still restricted to ASCII letters only.

Fix name of tested func in t.Errorf messages.

Fixes #18660.

Change-Id: Ia0ef4742bfd8317d989ef1eb1d7065e382852fe2
Reviewed-on: https://go-review.googlesource.com/41822
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-28 15:32:18 +00:00
Bryan C. Mills
eb6adc27d5 encoding/xml: replace tinfoMap RWMutex with sync.Map
This simplifies the code a bit and provides a modest speedup for
Marshal with many CPUs.

updates #17973
updates #18177

name          old time/op    new time/op    delta
Marshal         15.8µs ± 1%    15.9µs ± 1%   +0.67%  (p=0.021 n=8+7)
Marshal-6       5.76µs ±11%    5.17µs ± 2%  -10.36%  (p=0.002 n=8+8)
Marshal-48      9.88µs ± 5%    7.31µs ± 6%  -26.04%  (p=0.000 n=8+8)
Unmarshal       44.7µs ± 3%    45.1µs ± 5%     ~     (p=0.645 n=8+8)
Unmarshal-6     12.1µs ± 7%    11.8µs ± 8%     ~     (p=0.442 n=8+8)
Unmarshal-48    18.7µs ± 3%    18.2µs ± 4%     ~     (p=0.054 n=7+8)

name          old alloc/op   new alloc/op   delta
Marshal         5.78kB ± 0%    5.78kB ± 0%     ~     (all equal)
Marshal-6       5.78kB ± 0%    5.78kB ± 0%     ~     (all equal)
Marshal-48      5.78kB ± 0%    5.78kB ± 0%     ~     (all equal)
Unmarshal       8.58kB ± 0%    8.58kB ± 0%     ~     (all equal)
Unmarshal-6     8.58kB ± 0%    8.58kB ± 0%     ~     (all equal)
Unmarshal-48    8.58kB ± 0%    8.58kB ± 0%     ~     (p=1.000 n=8+8)

name          old allocs/op  new allocs/op  delta
Marshal           23.0 ± 0%      23.0 ± 0%     ~     (all equal)
Marshal-6         23.0 ± 0%      23.0 ± 0%     ~     (all equal)
Marshal-48        23.0 ± 0%      23.0 ± 0%     ~     (all equal)
Unmarshal          189 ± 0%       189 ± 0%     ~     (all equal)
Unmarshal-6        189 ± 0%       189 ± 0%     ~     (all equal)
Unmarshal-48       189 ± 0%       189 ± 0%     ~     (all equal)

https://perf.golang.org/search?q=upload:20170427.5

Change-Id: I4ee95a99540d3e4e47e056fff18357efd2cd340a
Reviewed-on: https://go-review.googlesource.com/41991
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-04-28 14:36:14 +00:00
Alberto Donizetti
8db4d02e8f cmd/go: reject buildmode=pie when -race is enabled
Fixes #20038

Change-Id: Id692790ea406892bbe29090d461356bac28b6150
Reviewed-on: https://go-review.googlesource.com/41333
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-28 07:27:25 +00:00
Kevin Burke
89ebdbb5fd regexp: speed up QuoteMeta with a lookup table
This is the same technique used in CL 24466. By adding a little bit of
size to the binary, we can remove a function call and gain a lot of
performance.

A raw array ([128]bool) would be faster, but is also be 128 bytes
instead of 16.

Running tip on a Mac:

name             old time/op    new time/op     delta
QuoteMetaAll-4      192ns ±12%      120ns ±11%   -37.27%  (p=0.000 n=10+10)
QuoteMetaNone-4     186ns ± 6%       64ns ± 6%   -65.52%  (p=0.000 n=10+10)

name             old speed      new speed       delta
QuoteMetaAll-4   73.2MB/s ±11%  116.6MB/s ±10%   +59.21%  (p=0.000 n=10+10)
QuoteMetaNone-4   139MB/s ± 6%    405MB/s ± 6%  +190.74%  (p=0.000 n=10+10)

Change-Id: I68ce9fe2ef1c28e2274157789b35b0dd6ae3efb5
Reviewed-on: https://go-review.googlesource.com/41495
Run-TryBot: Kevin Burke <kev@inburke.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-28 06:43:14 +00:00
Nigel Tao
642a1cc756 compress/lzw: fix hi code overflow.
Change-Id: I2d3c3c715d857305944cd96c45554a16cb7967e9
Reviewed-on: https://go-review.googlesource.com/42032
Reviewed-by: David Symonds <dsymonds@golang.org>
2017-04-28 05:59:30 +00:00
Tommy Schaefer
4fcceca192 syscall: fix typo in documentation for StringToUTF16Ptr
Fixes #20133

Change-Id: Ic1a6eb35de1f9ddac9527335eb49bf0b52963b6a
Reviewed-on: https://go-review.googlesource.com/41992
Reviewed-by: Rob Pike <r@golang.org>
2017-04-28 05:28:27 +00:00
Josh Bleecher Snyder
c51559813f cmd/compile: add sizeCalculationDisabled flag
Use it to ensure that dowidth is not called
from the backend on a type whose size
has not yet been calculated.

This is an alternative to CL 42016.

Change-Id: I8c7b4410ee4c2a68573102f6b9b635f4fdcf392e
Reviewed-on: https://go-review.googlesource.com/42018
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-28 01:24:52 +00:00
Josh Bleecher Snyder
dae5389d3d Revert "cmd/compile: add Type.MustSize and Type.MustAlignment"
This reverts commit 94d540a4b6.

Reason for revert: prefer something along the lines of CL 42018.

Change-Id: I876fe32e98f37d8d725fe55e0fd0ea429c0198e0
Reviewed-on: https://go-review.googlesource.com/42022
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-28 01:24:13 +00:00
Mikio Hara
3a342af977 net: simplify probeWindowsIPStack
Change-Id: Ia45f05c63611ade4fe605b389c404953a7afbd1d
Reviewed-on: https://go-review.googlesource.com/41837
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-04-28 00:03:30 +00:00
Mikio Hara
bf4cd98c8b net: make zone helpers into methods of ipv6ZoneCache
Change-Id: Id93e78f0c8bef125f124a0a919053208e24a63cd
Reviewed-on: https://go-review.googlesource.com/41836
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-04-28 00:03:17 +00:00
Mikio Hara
cf74533b6b syscall: stylistic cleanup and typo fixes in syscall_dragonfly.go
Now it's not very different from syscall_dragonfly.go in
golang.org/x/sys/unix repository.

Change-Id: I8dfd22e1ebce9dc2cc71ab9ab7f0c92d93b2b762
Reviewed-on: https://go-review.googlesource.com/41835
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-04-28 00:03:04 +00:00
Josh Bleecher Snyder
12c286c149 cmd/compile: minor writebarrier cleanup
This CL mainly moves some work to the switch on w.Op,
to make a follow-up change simpler and clearer.

Updates #19838

Change-Id: I86f3181c380dd60960afcc24224f655276b8956c
Reviewed-on: https://go-review.googlesource.com/42010
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2017-04-27 23:44:49 +00:00
Josh Bleecher Snyder
fc08a19cef cmd/compile: move Used from gc.Node to gc.Name
Node.Used was written to from the backend
concurrently with reads of Node.Class
for the same ONAME Nodes.
I do not know why it was not failing consistently
under the race detector, but it is a race.

This is likely also a problem with Node.HasVal and Node.HasOpt.
They will be handled in a separate CL.

Fix Used by moving it to gc.Name and making it a separate bool.
There was one non-Name use of Used, marking OLABELs as used.
That is no longer needed, now that goto and label checking
happens early in the front end.

Leave the getters and setters in place,
to ease changing the representation in the future
(or changing to an interface!).

Updates #20144

Change-Id: I9bec7c6d33dcb129a4cfa9d338462ea33087f9f7
Reviewed-on: https://go-review.googlesource.com/42015
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-27 22:58:13 +00:00
Josh Bleecher Snyder
94d540a4b6 cmd/compile: add Type.MustSize and Type.MustAlignment
Type.Size and Type.Alignment are for the front end:
They calculate size and alignment if needed.

Type.MustSize and Type.MustAlignment are for the back end:
They call Fatal if size and alignment are not already calculated.

Most uses are of MustSize and MustAlignment,
but that's because the back end is newer,
and this API was added to support it.

This CL was mostly generated with sed and selective reversion.
The only mildly interesting bit is the change of the ssa.Type interface
and the supporting ssa dummy types.

Follow-up to review feedback on CL 41970.

Passes toolstash-check.

Change-Id: I0d9b9505e57453dae8fb6a236a07a7a02abd459e
Reviewed-on: https://go-review.googlesource.com/42016
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-27 22:57:57 +00:00
Josh Bleecher Snyder
0b6a10ef24 cmd/compile: dowidth more in the front end
dowidth is fundamentally unsafe to call from the back end;
it will cause data races.

Replace all calls to dowidth in the backend with
assertions that the width has been calculated.

Then fix all the cases in which that was not so,
including the cases from #20145.

Fixes #20145.

Change-Id: Idba3d19d75638851a30ec2ebcdb703c19da3e92b
Reviewed-on: https://go-review.googlesource.com/41970
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-27 22:10:32 +00:00
Michael Hudson-Doyle
be2ee2a4b4 cmd/internal/objabi, cmd/link: move linker-only symkind values into linker
Many (most!) of the values of objapi.SymKind are used only in the linker, so
this creates a separate cmd/link/internal/ld.SymKind type, removes most values
from SymKind and maps one to the other when reading object files in the linker.

Two of the remaining objapi.SymKind values are only checked for, never set and
so will never be actually found but I wanted to keep this to the most
mechanical change possible.

Change-Id: I4bbc5aed6713cab3e8de732e6e288eb77be0474c
Reviewed-on: https://go-review.googlesource.com/40985
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-27 21:56:12 +00:00
Hana Kim
b1868cf107 dwarf: add marker for embedded fields in dwarf
Currently, the following two codes generate the identical dwarf info
for type Foo.

prog 1)
type Foo struct {
   Bar
}

prog 2)
type Foo struct {
   Bar Bar
}

This change adds a go-specific attribute DW_AT_go_embedded_field
to annotate each member entry. Its absence or false value indicates
the corresponding member is not an embedded field.

Update #20037

Change-Id: Ibcbd2714f3e4d97c7b523d7398f29ab2301cc897
Reviewed-on: https://go-review.googlesource.com/41873
Reviewed-by: David Chase <drchase@google.com>
2017-04-27 19:57:02 +00:00
Josh Bleecher Snyder
f5c878e030 cmd/compile: randomize compilation order when race-enabled
There's been one failure on the race builder so far,
before we started sorting functions by length.

The race detector can only detect actual races,
and ordering functions by length might reduce the odds
of catching some kinds of races. Give it more to chew on.

Updates #20144

Change-Id: I0206ac182cb98b70a729dea9703ecb0fef54d2d0
Reviewed-on: https://go-review.googlesource.com/41973
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-27 19:27:22 +00:00
Josh Bleecher Snyder
26e126d6e6 cmd/compile: move nodarg to walk.go
Its sole use is in walk.go. 100% code movement.

gsubr.go increasingly contains backend-y things.
With a few more relocations, it could probably be
fruitfully renamed progs.go.

Change-Id: I61ec5c2bc1f8cfdda64c6d6f580952c154ff60e0
Reviewed-on: https://go-review.googlesource.com/41972
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-27 19:08:26 +00:00
Josh Bleecher Snyder
fcee3777fd cmd/compile: move addrescapes and moveToHeap to esc.go
They were used only in esc.go. 100% code movement.

Also, remove the rather outdated comment at the top of gen.go.
It's not really clear what gen.go is for any more.

Change-Id: Iaedfe7015ef6f5c11c49f3e6721b15d779a00faa
Reviewed-on: https://go-review.googlesource.com/41971
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-27 19:08:20 +00:00
Keith Randall
14f3ca56ed cmd/internal/obj: ARM, use immediates instead of constant pool entries
When a constant doesn't fit in a single instruction, use two
paired instructions instead of the constant pool.  For example

  ADD $0xaa00bb, R0, R1

Used to rewrite to:

  MOV ?(IP), R11
  ADD R11, R0, R1

Instead, do:

  ADD $0xaa0000, R0, R1
  ADD $0xbb, R1, R1

Same number of instructions.
Good:
  4 less bytes (no constant pool entry)
  One less load.
Bad:
  Critical path is one instruction longer.

It's probably worth it to avoid the loads, they are expensive.

Dave Cheney got us some performance numbers: https://perf.golang.org/search?q=upload:20170426.1
TL;DR mean 1.37% improvement.

Change-Id: Ib206836161fdc94a3962db6f9caa635c87d57cf1
Reviewed-on: https://go-review.googlesource.com/41612
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2017-04-27 16:45:01 +00:00
Bryan C. Mills
c120e449fb encoding/gob: replace RWMutex usage with sync.Map
This provides a significant speedup for encoding and decoding when
using many CPU cores.

name                        old time/op  new time/op  delta
EndToEndPipe                5.26µs ± 2%  5.38µs ± 7%     ~     (p=0.121 n=8+7)
EndToEndPipe-6              1.86µs ± 5%  1.80µs ±11%     ~     (p=0.442 n=8+8)
EndToEndPipe-48             1.39µs ± 2%  1.41µs ± 4%     ~     (p=0.645 n=8+8)
EndToEndByteBuffer          1.54µs ± 5%  1.57µs ± 5%     ~     (p=0.130 n=8+8)
EndToEndByteBuffer-6         620ns ± 6%   310ns ± 8%  -50.04%  (p=0.000 n=8+8)
EndToEndByteBuffer-48        506ns ± 4%   110ns ± 3%  -78.22%  (p=0.000 n=8+8)
EndToEndSliceByteBuffer      149µs ± 3%   153µs ± 5%   +2.80%  (p=0.021 n=8+8)
EndToEndSliceByteBuffer-6    103µs ±17%    31µs ±12%  -70.06%  (p=0.000 n=8+8)
EndToEndSliceByteBuffer-48  93.2µs ± 2%  18.0µs ± 5%  -80.66%  (p=0.000 n=7+8)
EncodeComplex128Slice       20.6µs ± 5%  20.9µs ± 8%     ~     (p=0.959 n=8+8)
EncodeComplex128Slice-6     4.10µs ±10%  3.75µs ± 8%   -8.58%  (p=0.004 n=8+7)
EncodeComplex128Slice-48    1.14µs ± 2%  0.81µs ± 2%  -28.98%  (p=0.000 n=8+8)
EncodeFloat64Slice          10.2µs ± 7%  10.1µs ± 6%     ~     (p=0.694 n=7+8)
EncodeFloat64Slice-6        2.01µs ± 6%  1.80µs ±11%  -10.30%  (p=0.004 n=8+8)
EncodeFloat64Slice-48        701ns ± 3%   408ns ± 2%  -41.72%  (p=0.000 n=8+8)
EncodeInt32Slice            11.8µs ± 7%  11.7µs ± 6%     ~     (p=0.463 n=8+7)
EncodeInt32Slice-6          2.32µs ± 4%  2.06µs ± 5%  -10.89%  (p=0.000 n=8+8)
EncodeInt32Slice-48          731ns ± 2%   445ns ± 2%  -39.10%  (p=0.000 n=7+8)
EncodeStringSlice           9.13µs ± 9%  9.18µs ± 8%     ~     (p=0.798 n=8+8)
EncodeStringSlice-6         1.91µs ± 5%  1.70µs ± 5%  -11.07%  (p=0.000 n=8+8)
EncodeStringSlice-48         679ns ± 3%   397ns ± 3%  -41.50%  (p=0.000 n=8+8)
EncodeInterfaceSlice         449µs ±11%   461µs ± 9%     ~     (p=0.328 n=8+8)
EncodeInterfaceSlice-6       503µs ± 7%    88µs ± 7%  -82.51%  (p=0.000 n=7+8)
EncodeInterfaceSlice-48      335µs ± 8%    22µs ± 1%  -93.55%  (p=0.000 n=8+7)
DecodeComplex128Slice       67.2µs ± 4%  67.0µs ± 6%     ~     (p=0.721 n=8+8)
DecodeComplex128Slice-6     22.0µs ± 8%  18.9µs ± 5%  -14.44%  (p=0.000 n=8+8)
DecodeComplex128Slice-48    46.8µs ± 3%  34.9µs ± 3%  -25.48%  (p=0.000 n=8+8)
DecodeFloat64Slice          39.4µs ± 4%  40.3µs ± 3%     ~     (p=0.105 n=8+8)
DecodeFloat64Slice-6        16.1µs ± 2%  11.2µs ± 7%  -30.64%  (p=0.001 n=6+7)
DecodeFloat64Slice-48       38.1µs ± 3%  24.0µs ± 7%  -37.10%  (p=0.000 n=8+8)
DecodeInt32Slice            39.1µs ± 4%  40.1µs ± 5%     ~     (p=0.083 n=8+8)
DecodeInt32Slice-6          16.3µs ±21%  10.6µs ± 1%  -35.17%  (p=0.000 n=8+7)
DecodeInt32Slice-48         36.5µs ± 6%  21.9µs ± 9%  -39.89%  (p=0.000 n=8+8)
DecodeStringSlice           82.9µs ± 6%  85.5µs ± 5%     ~     (p=0.121 n=8+7)
DecodeStringSlice-6         32.4µs ±11%  26.8µs ±16%  -17.37%  (p=0.000 n=8+8)
DecodeStringSlice-48        76.0µs ± 2%  57.0µs ± 5%  -25.02%  (p=0.000 n=8+8)
DecodeInterfaceSlice         718µs ± 4%   752µs ± 5%   +4.83%  (p=0.038 n=8+8)
DecodeInterfaceSlice-6       500µs ± 6%   165µs ± 7%  -66.95%  (p=0.000 n=7+8)
DecodeInterfaceSlice-48      470µs ± 5%   120µs ± 6%  -74.55%  (p=0.000 n=8+7)
DecodeMap                   3.29ms ± 5%  3.34ms ± 5%     ~     (p=0.279 n=8+8)
DecodeMap-6                 7.73ms ± 8%  7.53ms ±18%     ~     (p=0.779 n=7+8)
DecodeMap-48                7.46ms ± 6%  7.71ms ± 3%     ~     (p=0.161 n=8+8)

https://perf.golang.org/search?q=upload:20170426.4

Change-Id: I335874028ef8d7c991051004f8caadd16c92d5cc
Reviewed-on: https://go-review.googlesource.com/41872
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-04-27 15:34:57 +00:00
Bryan C. Mills
33b92cd6ce reflect: use sync.Map instead of RWMutex for type caches
This provides a significant speedup when using reflection-heavy code
on many CPU cores, such as when marshaling or unmarshaling protocol
buffers.

updates #17973
updates #18177

name                       old time/op    new time/op     delta
Call                          239ns ±10%      245ns ± 7%       ~     (p=0.562 n=10+9)
Call-6                        201ns ±38%       48ns ±29%    -76.39%  (p=0.000 n=10+9)
Call-48                       133ns ± 8%       12ns ± 2%    -90.92%  (p=0.000 n=10+8)
CallArgCopy/size=128          169ns ±12%      197ns ± 2%    +16.35%  (p=0.000 n=10+7)
CallArgCopy/size=128-6        142ns ± 9%       34ns ± 7%    -76.10%  (p=0.000 n=10+9)
CallArgCopy/size=128-48       125ns ± 3%        9ns ± 7%    -93.01%  (p=0.000 n=8+8)
CallArgCopy/size=256          177ns ± 8%      197ns ± 5%    +11.24%  (p=0.000 n=10+9)
CallArgCopy/size=256-6        148ns ±11%       35ns ± 6%    -76.23%  (p=0.000 n=10+9)
CallArgCopy/size=256-48       127ns ± 4%        9ns ± 9%    -92.66%  (p=0.000 n=10+9)
CallArgCopy/size=1024         196ns ± 6%      228ns ± 7%    +16.09%  (p=0.000 n=10+9)
CallArgCopy/size=1024-6       143ns ± 6%       42ns ± 5%    -70.39%  (p=0.000 n=8+8)
CallArgCopy/size=1024-48      130ns ± 7%       10ns ± 1%    -91.99%  (p=0.000 n=10+8)
CallArgCopy/size=4096         330ns ± 9%      351ns ± 5%     +6.20%  (p=0.004 n=10+9)
CallArgCopy/size=4096-6       173ns ±14%       62ns ± 6%    -63.83%  (p=0.000 n=10+8)
CallArgCopy/size=4096-48      141ns ± 6%       15ns ± 6%    -89.59%  (p=0.000 n=10+8)
CallArgCopy/size=65536       7.71µs ±10%     7.74µs ±10%       ~     (p=0.859 n=10+9)
CallArgCopy/size=65536-6     1.33µs ± 4%     1.34µs ± 6%       ~     (p=0.720 n=10+9)
CallArgCopy/size=65536-48     347ns ± 2%      344ns ± 2%       ~     (p=0.202 n=10+9)
PtrTo                        30.2ns ±10%     41.3ns ±11%    +36.97%  (p=0.000 n=10+9)
PtrTo-6                       126ns ± 6%        7ns ±10%    -94.47%  (p=0.000 n=9+9)
PtrTo-48                     86.9ns ± 9%      1.7ns ± 9%    -98.08%  (p=0.000 n=10+9)
FieldByName1                 86.6ns ± 5%     87.3ns ± 7%       ~     (p=0.737 n=10+9)
FieldByName1-6               19.8ns ±10%     18.7ns ±10%       ~     (p=0.073 n=9+9)
FieldByName1-48              7.54ns ± 4%     7.74ns ± 5%     +2.55%  (p=0.023 n=9+9)
FieldByName2                 1.63µs ± 8%     1.70µs ± 4%     +4.13%  (p=0.020 n=9+9)
FieldByName2-6                481ns ± 6%      490ns ±10%       ~     (p=0.474 n=9+9)
FieldByName2-48               723ns ± 3%      736ns ± 2%     +1.76%  (p=0.045 n=8+8)
FieldByName3                 10.5µs ± 7%     10.8µs ± 7%       ~     (p=0.234 n=8+8)
FieldByName3-6               2.78µs ± 3%     2.94µs ±10%     +5.87%  (p=0.031 n=9+9)
FieldByName3-48              3.72µs ± 2%     3.91µs ± 5%     +4.91%  (p=0.003 n=9+9)
InterfaceBig                 10.8ns ± 5%     10.7ns ± 5%       ~     (p=0.849 n=9+9)
InterfaceBig-6               9.62ns ±81%     1.79ns ± 4%    -81.38%  (p=0.003 n=9+9)
InterfaceBig-48              0.48ns ±34%     0.50ns ± 7%       ~     (p=0.071 n=8+9)
InterfaceSmall               10.7ns ± 5%     10.9ns ± 4%       ~     (p=0.243 n=9+9)
InterfaceSmall-6             1.85ns ± 5%     1.79ns ± 1%     -2.97%  (p=0.006 n=7+8)
InterfaceSmall-48            0.49ns ±20%     0.48ns ± 5%       ~     (p=0.740 n=7+9)
New                          28.2ns ±20%     26.6ns ± 3%       ~     (p=0.617 n=9+9)
New-6                        4.69ns ± 4%     4.44ns ± 3%     -5.33%  (p=0.001 n=9+9)
New-48                       1.10ns ± 9%     1.08ns ± 6%       ~     (p=0.285 n=9+8)

name                       old alloc/op   new alloc/op    delta
Call                          0.00B           0.00B            ~     (all equal)
Call-6                        0.00B           0.00B            ~     (all equal)
Call-48                       0.00B           0.00B            ~     (all equal)

name                       old allocs/op  new allocs/op   delta
Call                           0.00            0.00            ~     (all equal)
Call-6                         0.00            0.00            ~     (all equal)
Call-48                        0.00            0.00            ~     (all equal)

name                       old speed      new speed       delta
CallArgCopy/size=128        757MB/s ±11%    649MB/s ± 1%    -14.33%  (p=0.000 n=10+7)
CallArgCopy/size=128-6      901MB/s ± 9%   3781MB/s ± 7%   +319.69%  (p=0.000 n=10+9)
CallArgCopy/size=128-48    1.02GB/s ± 2%  14.63GB/s ± 6%  +1337.98%  (p=0.000 n=8+8)
CallArgCopy/size=256       1.45GB/s ± 9%   1.30GB/s ± 5%    -10.17%  (p=0.000 n=10+9)
CallArgCopy/size=256-6     1.73GB/s ±11%   7.28GB/s ± 7%   +320.76%  (p=0.000 n=10+9)
CallArgCopy/size=256-48    2.00GB/s ± 4%  27.46GB/s ± 9%  +1270.85%  (p=0.000 n=10+9)
CallArgCopy/size=1024      5.21GB/s ± 6%   4.49GB/s ± 8%    -13.74%  (p=0.000 n=10+9)
CallArgCopy/size=1024-6    7.18GB/s ± 7%  24.17GB/s ± 5%   +236.64%  (p=0.000 n=9+8)
CallArgCopy/size=1024-48   7.87GB/s ± 7%  98.43GB/s ± 1%  +1150.99%  (p=0.000 n=10+8)
CallArgCopy/size=4096      12.3GB/s ± 6%   11.7GB/s ± 5%     -5.00%  (p=0.008 n=9+9)
CallArgCopy/size=4096-6    23.8GB/s ±16%   65.6GB/s ± 5%   +175.02%  (p=0.000 n=10+8)
CallArgCopy/size=4096-48   29.0GB/s ± 7%  279.6GB/s ± 6%   +862.87%  (p=0.000 n=10+8)
CallArgCopy/size=65536     8.52GB/s ±11%   8.49GB/s ± 9%       ~     (p=0.842 n=10+9)
CallArgCopy/size=65536-6   49.3GB/s ± 4%   49.0GB/s ± 6%       ~     (p=0.720 n=10+9)
CallArgCopy/size=65536-48   189GB/s ± 2%    190GB/s ± 2%       ~     (p=0.211 n=10+9)

https://perf.golang.org/search?q=upload:20170426.3

Change-Id: Iff68f18ef69defb7f30962e21736ac7685a48a27
Reviewed-on: https://go-review.googlesource.com/41871
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-27 15:34:41 +00:00
Weichao Tang
e51e0f9cdd net/http: close resp.Body when error occurred during redirection
Fixes #19976

Change-Id: I48486467066784a9dcc24357ec94a1be85265a6f
Reviewed-on: https://go-review.googlesource.com/40940
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-27 14:28:47 +00:00
Wei Xiao
2b6c58f6d5 cmd/internal/obj/arm64: fix encoding of condition
The current code treats condition as special register and write
its raw data directly into instruction.

The fix converts the raw data into correct condition encoding.
Also fix the operand catogery of FCCMP.

Add tests to cover all cases.

Change-Id: Ib194041bd9017dd0edbc241564fe983082ac616b
Reviewed-on: https://go-review.googlesource.com/41511
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2017-04-27 13:35:59 +00:00
Ian Lance Taylor
220e0e0f73 os: use kernel limit on pipe size if possible
Fixes #20134

Change-Id: I92699d118c713179961c037a6bbbcbec4efa63ba
Reviewed-on: https://go-review.googlesource.com/41823
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-27 04:42:21 +00:00
Nigel Tao
35cbc3b55b image/jpeg: fix extended sequential Huffman table selector (Th).
Previously, the package did not distinguish between baseline and
extended sequential images. Both are non-progressive images, but the Th
range differs between the two, as per Annex B of
https://www.w3.org/Graphics/JPEG/itu-t81.pdf

Extended sequential images are often emitted by the Guetzli encoder.

Fixes #19913

Change-Id: I3d0f9e16d5d374ee1c65e3a8fb87519de61cff94
Reviewed-on: https://go-review.googlesource.com/41831
Reviewed-by: David Symonds <dsymonds@golang.org>
2017-04-27 03:48:40 +00:00
Josh Bleecher Snyder
6664ccb453 cmd/compile: compile more complex functions first
When using a concurrent backend,
the overall compilation time is bounded
in part by the slowest function to compile.
The number of top-level statements in a function
is an easily calculated and fairly reliable
proxy for compilation time.

Here's a standard compilecmp output for -c=8 with this CL:

name       old time/op       new time/op       delta
Template         127ms ± 4%        125ms ± 6%   -1.33%  (p=0.000 n=47+50)
Unicode         84.8ms ± 4%       84.5ms ± 4%     ~     (p=0.217 n=49+49)
GoTypes          289ms ± 3%        287ms ± 3%   -0.78%  (p=0.002 n=48+50)
Compiler         1.36s ± 3%        1.34s ± 2%   -1.29%  (p=0.000 n=49+47)
SSA              2.95s ± 3%        2.77s ± 4%   -6.23%  (p=0.000 n=50+49)
Flate           70.7ms ± 3%       70.9ms ± 2%     ~     (p=0.112 n=50+49)
GoParser        85.0ms ± 3%       83.0ms ± 4%   -2.31%  (p=0.000 n=48+49)
Reflect          229ms ± 3%        225ms ± 4%   -1.83%  (p=0.000 n=49+49)
Tar             70.2ms ± 3%       69.4ms ± 3%   -1.17%  (p=0.000 n=49+49)
XML              115ms ± 7%        114ms ± 6%     ~     (p=0.158 n=49+47)

name       old user-time/op  new user-time/op  delta
Template         352ms ± 5%        342ms ± 8%   -2.74%  (p=0.000 n=49+50)
Unicode          117ms ± 5%        118ms ± 4%   +0.88%  (p=0.005 n=46+48)
GoTypes          986ms ± 3%        980ms ± 4%     ~     (p=0.110 n=46+48)
Compiler         4.39s ± 2%        4.43s ± 4%   +0.97%  (p=0.002 n=50+50)
SSA              12.0s ± 2%        13.3s ± 3%  +11.33%  (p=0.000 n=49+49)
Flate            222ms ± 5%        219ms ± 6%   -1.56%  (p=0.002 n=50+50)
GoParser         271ms ± 5%        268ms ± 4%   -0.83%  (p=0.036 n=49+48)
Reflect          560ms ± 4%        571ms ± 3%   +1.90%  (p=0.000 n=50+49)
Tar              183ms ± 3%        183ms ± 3%     ~     (p=0.903 n=45+50)
XML              364ms ±13%        391ms ± 4%   +7.16%  (p=0.000 n=50+40)

A more interesting way of viewing the data is by
looking at the ratio of the time taken to compile
the slowest-to-compile function to the overall
time spent compiling functions.

If this ratio is small (near 0), then increased concurrency might help.
If this ratio is big (near 1), then we're bounded by that single function.

I instrumented the compiler to emit this ratio per-package,
ran 'go build -a -gcflags=-c=C -p=P std cmd' three times,
for varying values of C and P,
and collected the ratios encountered into an ASCII histogram.

Here's c=1 p=1, which is a non-concurrent backend, single process at a time:

 90%|
 80%|
 70%|
 60%|
 50%|
 40%|
 30%|
 20%|**
 10%|***
  0%|*********
----+----------
    |0123456789

The x-axis is floor(10*ratio), so the first column indicates the percent of
ratios that fell in the 0% to 9.9999% range.
We can see in this histogram that more concurrency will help;
in most cases, the ratio is small.

Here's c=8 p=1, before this CL:

 90%|
 80%|
 70%|
 60%|
 50%|
 40%|
 30%|         *
 20%|         *
 10%|*   *    *
  0%|**********
----+----------
    |0123456789

In 30-40% of cases, we're mostly bound by the compilation time
of a single function.

Here's c=8 p=1, after this CL:

 90%|
 80%|
 70%|
 60%|
 50%|         *
 40%|         *
 30%|         *
 20%|         *
 10%|         *
  0%|**********
----+----------
    |0123456789

The sorting pays off; we are bound by the
compilation time of a single function in over half of packages.
The single * in the histogram indicates 0-10%.
The actual values for this chart are:
0: 5%, 1: 1%, 2: 1%, 3: 4%, 4: 5%, 5: 7%, 6: 7%, 7: 7%, 8: 9%, 9: 55%

This indicates that efforts to increase or enable more concurrency,
e.g. by optimizing mutexes or increasing the value of c,
will probably not yield fruit.
That matches what compilecmp tells us.

Further optimization efforts should thus focus instead on one of:

(1) making more functions compile concurrently
(2) improving the compilation time of the slowest functions
(3) speeding up the remaining serial parts of the compiler
(4) automatically splitting up some large autogenerated functions
    into small ones, as discussed in #19751

I hope to spend more time on (1) before the freeze.

Adding process parallelism doesn't change the story much.
For example, here's c=8 p=8, after this CL:

 90%|
 80%|
 70%|
 60%|
 50%|
 40%|         *
 30%|         *
 20%|         *
 10%|       ***
  0%|**********
----+----------
    |0123456789

Since we don't need to worry much about p,
these histograms can help us select a good
general value of c to use as a default,
assuming we're not bounded by GOMAXPROCS.

Here are some charts after this CL, for c from 1 to 8:

c=1 p=1

 90%|
 80%|
 70%|
 60%|
 50%|
 40%|
 30%|
 20%|**
 10%|***
  0%|*********
----+----------
    |0123456789

c=2 p=1

 90%|
 80%|
 70%|
 60%|
 50%|
 40%|
 30%|
 20%|
 10%| ****    *
  0%|**********
----+----------
    |0123456789

c=3 p=1

 90%|
 80%|
 70%|
 60%|
 50%|
 40%|
 30%|
 20%|         *
 10%|  ** *   *
  0%|**********
----+----------
    |0123456789

c=4 p=1

 90%|
 80%|
 70%|
 60%|
 50%|
 40%|
 30%|         *
 20%|         *
 10%|     *   *
  0%|**********
----+----------
    |0123456789

c=5 p=1

 90%|
 80%|
 70%|
 60%|
 50%|
 40%|
 30%|         *
 20%|         *
 10%|     *   *
  0%|**********
----+----------
    |0123456789

c=6 p=1

 90%|
 80%|
 70%|
 60%|
 50%|
 40%|         *
 30%|         *
 20%|         *
 10%|         *
  0%|**********
----+----------
    |0123456789

c=7 p=1

 90%|
 80%|
 70%|
 60%|
 50%|         *
 40%|         *
 30%|         *
 20%|         *
 10%|        **
  0%|**********
----+----------
    |0123456789

c=8 p=1

 90%|
 80%|
 70%|
 60%|
 50%|         *
 40%|         *
 30%|         *
 20%|         *
 10%|         *
  0%|**********
----+----------
    |0123456789

Given the increased user-CPU costs as
c increases, it looks like c=4 is probably
the sweet spot, at least for now.

Pleasingly, this matches (and explains)
the results of the standard benchmarking
that I have done.

Updates #15756

Change-Id: I82b606c06efd34a5dbd1afdbcf66a605905b2aeb
Reviewed-on: https://go-review.googlesource.com/41192
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-27 01:08:35 +00:00
Josh Bleecher Snyder
756b9ce3a5 cmd/compile: add initial backend concurrency support
This CL adds initial support for concurrent backend compilation.

BACKGROUND

The compiler currently consists (very roughly) of the following phases:

1. Initialization.
2. Lexing and parsing into the cmd/compile/internal/syntax AST.
3. Translation into the cmd/compile/internal/gc AST.
4. Some gc AST passes: typechecking, escape analysis, inlining,
   closure handling, expression evaluation ordering (order.go),
   and some lowering and optimization (walk.go).
5. Translation into the cmd/compile/internal/ssa SSA form.
6. Optimization and lowering of SSA form.
7. Translation from SSA form to assembler instructions.
8. Translation from assembler instructions to machine code.
9. Writing lots of output: machine code, DWARF symbols,
   type and reflection info, export data.

Phase 2 was already concurrent as of Go 1.8.

Phase 3 is planned for eventual removal;
we hope to go straight from syntax AST to SSA.

Phases 5–8 are per-function; this CL adds support for
processing multiple functions concurrently.
The slowest phases in the compiler are 5 and 6,
so this offers the opportunity for some good speed-ups.

Unfortunately, it's not quite that straightforward.
In the current compiler, the latter parts of phase 4
(order, walk) are done function-at-a-time as needed.
Making order and walk concurrency-safe proved hard,
and they're not particularly slow, so there wasn't much reward.
To enable phases 5–8 to be done concurrently,
when concurrent backend compilation is requested,
we complete phase 4 for all functions
before starting later phases for any functions.

Also, in reality, we automatically generate new
functions in phase 9, such as method wrappers
and equality and has routines.
Those new functions then go through phases 4–8.
This CL disables concurrent backend compilation
after the first, big, user-provided batch of
functions has been compiled.
This is done to keep things simple,
and because the autogenerated functions
tend to be small, few, simple, and fast to compile.

USAGE

Concurrent backend compilation still defaults to off.
To set the number of functions that may be backend-compiled
concurrently, use the compiler flag -c.
In future work, cmd/go will automatically set -c.

Furthermore, this CL has been intentionally written
so that the c=1 path has no backend concurrency whatsoever,
not even spawning any goroutines.
This helps ensure that, should problems arise
late in the development cycle,
we can simply have cmd/go set c=1 always,
and revert to the original compiler behavior.

MUTEXES

Most of the work required to make concurrent backend
compilation safe has occurred over the past month.
This CL adds a handful of mutexes to get the rest of the way there;
they are the mutexes that I didn't see a clean way to avoid.
Some of them may still be eliminable in future work.

In no particular order:

* gc.funcsymsmu. The global funcsyms slice is populated
  lazily when we need function symbols for closures.
  This occurs during gc AST to SSA translation.
  The function funcsym also does a package lookup,
  which is a source of races on types.Pkg.Syms;
  funcsymsmu also covers that package lookup.
  This mutex is low priority: it adds a single global,
  it is in an infrequently used code path, and it is low contention.
  Since funcsyms may now be added in any order,
  we must sort them to preserve reproducible builds.

* gc.largeStackFramesMu. We don't discover until after SSA compilation
  that a function's stack frame is gigantic.
  Recording that error happens basically never,
  but it does happen concurrently.
  Fix with a low priority mutex and sorting.

* obj.Link.hashmu. ctxt.hash stores the mapping from
  types.Syms (compiler symbols) to obj.LSyms (linker symbols).
  It is accessed fairly heavily through all the phases.
  This is the only heavily contended mutex.

* gc.signatlistmu. The global signatlist map is
  populated with types through several of the concurrent phases,
  including notably via ngotype during DWARF generation.
  It is low priority for removal.

* gc.typepkgmu. Looking up symbols in the types package
  happens a fair amount during backend compilation
  and DWARF generation, particularly via ngotype.
  This mutex helps us to avoid a broader mutex on types.Pkg.Syms.
  It has low-to-moderate contention.

* types.internedStringsmu. gc AST to SSA conversion and
  some SSA work introduce new autotmps.
  Those autotmps have their names interned to reduce allocations.
  That interning requires protecting types.internedStrings.
  The autotmp names are heavily re-used, and the mutex
  overhead and contention here are low, so it is probably
  a worthwhile performance optimization to keep this mutex.

TESTING

I have been testing this code locally by running
'go install -race cmd/compile'
and then doing
'go build -a -gcflags=-c=128 std cmd'
for all architectures and a variety of compiler flags.
This obviously needs to be made part of the builders,
but it is too expensive to make part of all.bash.
I have filed #19962 for this.

REPRODUCIBLE BUILDS

This version of the compiler generates reproducible builds.
Testing reproducible builds also needs automation, however,
and is also too expensive for all.bash.
This is #19961.

Also of note is that some of the compiler flags used by 'toolstash -cmp'
are currently incompatible with concurrent backend compilation.
They still work fine with c=1.
Time will tell whether this is a problem.

NEXT STEPS

* Continue to find and fix races and bugs,
  using a combination of code inspection, fuzzing,
  and hopefully some community experimentation.
  I do not know of any outstanding races,
  but there probably are some.
* Improve testing.
* Improve performance, for many values of c.
* Integrate with cmd/go and fine tune.
* Support concurrent compilation with the -race flag.
  It is a sad irony that it does not yet work.
* Minor code cleanup that has been deferred during
  the last month due to uncertainty about the
  ultimate shape of this CL.

PERFORMANCE

Here's the buried lede, at last. :)

All benchmarks are from my 8 core 2.9 GHz Intel Core i7 darwin/amd64 laptop.

First, going from tip to this CL with c=1 has almost no impact.

name        old time/op       new time/op       delta
Template          195ms ± 3%        194ms ± 5%    ~     (p=0.370 n=30+29)
Unicode          86.6ms ± 3%       87.0ms ± 7%    ~     (p=0.958 n=29+30)
GoTypes           548ms ± 3%        555ms ± 4%  +1.35%  (p=0.001 n=30+28)
Compiler          2.51s ± 2%        2.54s ± 2%  +1.17%  (p=0.000 n=28+30)
SSA               5.16s ± 3%        5.16s ± 2%    ~     (p=0.910 n=30+29)
Flate             124ms ± 5%        124ms ± 4%    ~     (p=0.947 n=30+30)
GoParser          146ms ± 3%        146ms ± 3%    ~     (p=0.150 n=29+28)
Reflect           354ms ± 3%        352ms ± 4%    ~     (p=0.096 n=29+29)
Tar               107ms ± 5%        106ms ± 3%    ~     (p=0.370 n=30+29)
XML               200ms ± 4%        201ms ± 4%    ~     (p=0.313 n=29+28)
[Geo mean]        332ms             333ms       +0.10%

name        old user-time/op  new user-time/op  delta
Template          227ms ± 5%        225ms ± 5%    ~     (p=0.457 n=28+27)
Unicode           109ms ± 4%        109ms ± 5%    ~     (p=0.758 n=29+29)
GoTypes           713ms ± 4%        721ms ± 5%    ~     (p=0.051 n=30+29)
Compiler          3.36s ± 2%        3.38s ± 3%    ~     (p=0.146 n=30+30)
SSA               7.46s ± 3%        7.47s ± 3%    ~     (p=0.804 n=30+29)
Flate             146ms ± 7%        147ms ± 3%    ~     (p=0.833 n=29+27)
GoParser          179ms ± 5%        179ms ± 5%    ~     (p=0.866 n=30+30)
Reflect           431ms ± 4%        429ms ± 4%    ~     (p=0.593 n=29+30)
Tar               124ms ± 5%        123ms ± 5%    ~     (p=0.140 n=29+29)
XML               243ms ± 4%        242ms ± 7%    ~     (p=0.404 n=29+29)
[Geo mean]        415ms             415ms       +0.02%

name        old obj-bytes     new obj-bytes     delta
Template           382k ± 0%         382k ± 0%    ~     (all equal)
Unicode            203k ± 0%         203k ± 0%    ~     (all equal)
GoTypes           1.18M ± 0%        1.18M ± 0%    ~     (all equal)
Compiler          3.98M ± 0%        3.98M ± 0%    ~     (all equal)
SSA               8.28M ± 0%        8.28M ± 0%    ~     (all equal)
Flate              230k ± 0%         230k ± 0%    ~     (all equal)
GoParser           287k ± 0%         287k ± 0%    ~     (all equal)
Reflect           1.00M ± 0%        1.00M ± 0%    ~     (all equal)
Tar                190k ± 0%         190k ± 0%    ~     (all equal)
XML                416k ± 0%         416k ± 0%    ~     (all equal)
[Geo mean]         660k              660k       +0.00%

Comparing this CL to itself, from c=1 to c=2
improves real times 20-30%, costs 5-10% more CPU time,
and adds about 2% alloc.
The allocation increase comes from allocating more ssa.Caches.

name       old time/op       new time/op       delta
Template         202ms ± 3%        149ms ± 3%  -26.15%  (p=0.000 n=49+49)
Unicode         87.4ms ± 4%       84.2ms ± 3%   -3.68%  (p=0.000 n=48+48)
GoTypes          560ms ± 2%        398ms ± 2%  -28.96%  (p=0.000 n=49+49)
Compiler         2.46s ± 3%        1.76s ± 2%  -28.61%  (p=0.000 n=48+46)
SSA              6.17s ± 2%        4.04s ± 1%  -34.52%  (p=0.000 n=49+49)
Flate            126ms ± 3%         92ms ± 2%  -26.81%  (p=0.000 n=49+48)
GoParser         148ms ± 4%        107ms ± 2%  -27.78%  (p=0.000 n=49+48)
Reflect          361ms ± 3%        281ms ± 3%  -22.10%  (p=0.000 n=49+49)
Tar              109ms ± 4%         86ms ± 3%  -20.81%  (p=0.000 n=49+47)
XML              204ms ± 3%        144ms ± 2%  -29.53%  (p=0.000 n=48+45)

name       old user-time/op  new user-time/op  delta
Template         246ms ± 9%        246ms ± 4%     ~     (p=0.401 n=50+48)
Unicode          109ms ± 4%        111ms ± 4%   +1.47%  (p=0.000 n=44+50)
GoTypes          728ms ± 3%        765ms ± 3%   +5.04%  (p=0.000 n=46+50)
Compiler         3.33s ± 3%        3.41s ± 2%   +2.31%  (p=0.000 n=49+48)
SSA              8.52s ± 2%        9.11s ± 2%   +6.93%  (p=0.000 n=49+47)
Flate            149ms ± 4%        161ms ± 3%   +8.13%  (p=0.000 n=50+47)
GoParser         181ms ± 5%        192ms ± 2%   +6.40%  (p=0.000 n=49+46)
Reflect          452ms ± 9%        474ms ± 2%   +4.99%  (p=0.000 n=50+48)
Tar              126ms ± 6%        136ms ± 4%   +7.95%  (p=0.000 n=50+49)
XML              247ms ± 5%        264ms ± 3%   +6.94%  (p=0.000 n=48+50)

name       old alloc/op      new alloc/op      delta
Template        38.8MB ± 0%       39.3MB ± 0%   +1.48%  (p=0.008 n=5+5)
Unicode         29.8MB ± 0%       30.2MB ± 0%   +1.19%  (p=0.008 n=5+5)
GoTypes          113MB ± 0%        114MB ± 0%   +0.69%  (p=0.008 n=5+5)
Compiler         443MB ± 0%        447MB ± 0%   +0.95%  (p=0.008 n=5+5)
SSA             1.25GB ± 0%       1.26GB ± 0%   +0.89%  (p=0.008 n=5+5)
Flate           25.3MB ± 0%       25.9MB ± 1%   +2.35%  (p=0.008 n=5+5)
GoParser        31.7MB ± 0%       32.2MB ± 0%   +1.59%  (p=0.008 n=5+5)
Reflect         78.2MB ± 0%       78.9MB ± 0%   +0.91%  (p=0.008 n=5+5)
Tar             26.6MB ± 0%       27.0MB ± 0%   +1.80%  (p=0.008 n=5+5)
XML             42.4MB ± 0%       43.4MB ± 0%   +2.35%  (p=0.008 n=5+5)

name       old allocs/op     new allocs/op     delta
Template          379k ± 0%         378k ± 0%     ~     (p=0.421 n=5+5)
Unicode           322k ± 0%         321k ± 0%     ~     (p=0.222 n=5+5)
GoTypes          1.14M ± 0%        1.14M ± 0%     ~     (p=0.548 n=5+5)
Compiler         4.12M ± 0%        4.11M ± 0%   -0.14%  (p=0.032 n=5+5)
SSA              9.72M ± 0%        9.72M ± 0%     ~     (p=0.421 n=5+5)
Flate             234k ± 1%         234k ± 0%     ~     (p=0.421 n=5+5)
GoParser          316k ± 1%         315k ± 0%     ~     (p=0.222 n=5+5)
Reflect           980k ± 0%         979k ± 0%     ~     (p=0.095 n=5+5)
Tar               249k ± 1%         249k ± 1%     ~     (p=0.841 n=5+5)
XML               392k ± 0%         391k ± 0%     ~     (p=0.095 n=5+5)

From c=1 to c=4, real time is down ~40%, CPU usage up 10-20%, alloc up ~5%:

name       old time/op       new time/op       delta
Template         203ms ± 3%        131ms ± 5%  -35.45%  (p=0.000 n=50+50)
Unicode         87.2ms ± 4%       84.1ms ± 2%   -3.61%  (p=0.000 n=48+47)
GoTypes          560ms ± 4%        310ms ± 2%  -44.65%  (p=0.000 n=50+49)
Compiler         2.47s ± 3%        1.41s ± 2%  -43.10%  (p=0.000 n=50+46)
SSA              6.17s ± 2%        3.20s ± 2%  -48.06%  (p=0.000 n=49+49)
Flate            126ms ± 4%         74ms ± 2%  -41.06%  (p=0.000 n=49+48)
GoParser         148ms ± 4%         89ms ± 3%  -39.97%  (p=0.000 n=49+50)
Reflect          360ms ± 3%        242ms ± 3%  -32.81%  (p=0.000 n=49+49)
Tar              108ms ± 4%         73ms ± 4%  -32.48%  (p=0.000 n=50+49)
XML              203ms ± 3%        119ms ± 3%  -41.56%  (p=0.000 n=49+48)

name       old user-time/op  new user-time/op  delta
Template         246ms ± 9%        287ms ± 9%  +16.98%  (p=0.000 n=50+50)
Unicode          109ms ± 4%        118ms ± 5%   +7.56%  (p=0.000 n=46+50)
GoTypes          735ms ± 4%        806ms ± 2%   +9.62%  (p=0.000 n=50+50)
Compiler         3.34s ± 4%        3.56s ± 2%   +6.78%  (p=0.000 n=49+49)
SSA              8.54s ± 3%       10.04s ± 3%  +17.55%  (p=0.000 n=50+50)
Flate            149ms ± 6%        176ms ± 3%  +17.82%  (p=0.000 n=50+48)
GoParser         181ms ± 5%        213ms ± 3%  +17.47%  (p=0.000 n=50+50)
Reflect          453ms ± 6%        499ms ± 2%  +10.11%  (p=0.000 n=50+48)
Tar              126ms ± 5%        149ms ±11%  +18.76%  (p=0.000 n=50+50)
XML              246ms ± 5%        287ms ± 4%  +16.53%  (p=0.000 n=49+50)

name       old alloc/op      new alloc/op      delta
Template        38.8MB ± 0%       40.4MB ± 0%   +4.21%  (p=0.008 n=5+5)
Unicode         29.8MB ± 0%       30.9MB ± 0%   +3.68%  (p=0.008 n=5+5)
GoTypes          113MB ± 0%        116MB ± 0%   +2.71%  (p=0.008 n=5+5)
Compiler         443MB ± 0%        455MB ± 0%   +2.75%  (p=0.008 n=5+5)
SSA             1.25GB ± 0%       1.27GB ± 0%   +1.84%  (p=0.008 n=5+5)
Flate           25.3MB ± 0%       26.9MB ± 1%   +6.31%  (p=0.008 n=5+5)
GoParser        31.7MB ± 0%       33.2MB ± 0%   +4.61%  (p=0.008 n=5+5)
Reflect         78.2MB ± 0%       80.2MB ± 0%   +2.53%  (p=0.008 n=5+5)
Tar             26.6MB ± 0%       27.9MB ± 0%   +5.19%  (p=0.008 n=5+5)
XML             42.4MB ± 0%       44.6MB ± 0%   +5.20%  (p=0.008 n=5+5)

name       old allocs/op     new allocs/op     delta
Template          380k ± 0%         379k ± 0%   -0.39%  (p=0.032 n=5+5)
Unicode           321k ± 0%         321k ± 0%     ~     (p=0.841 n=5+5)
GoTypes          1.14M ± 0%        1.14M ± 0%     ~     (p=0.421 n=5+5)
Compiler         4.12M ± 0%        4.14M ± 0%   +0.52%  (p=0.008 n=5+5)
SSA              9.72M ± 0%        9.76M ± 0%   +0.37%  (p=0.008 n=5+5)
Flate             234k ± 1%         234k ± 1%     ~     (p=0.690 n=5+5)
GoParser          316k ± 0%         317k ± 1%     ~     (p=0.841 n=5+5)
Reflect           981k ± 0%         981k ± 0%     ~     (p=1.000 n=5+5)
Tar               250k ± 0%         249k ± 1%     ~     (p=0.151 n=5+5)
XML               393k ± 0%         392k ± 0%     ~     (p=0.056 n=5+5)

Going beyond c=4 on my machine tends to increase CPU time and allocs
without impacting real time.

The CPU time numbers matter, because when there are many concurrent
compilation processes, that will impact the overall throughput.

The numbers above are in many ways the best case scenario;
we can take full advantage of all cores.
Fortunately, the most common compilation scenario is incremental
re-compilation of a single package during a build/test cycle.

Updates #15756

Change-Id: I6725558ca2069edec0ac5b0d1683105a9fff6bea
Reviewed-on: https://go-review.googlesource.com/40693
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-27 00:59:07 +00:00
Alex Brainman
1989921aef os: do not report ModeDir for symlinks on windows
When using Lstat against symlinks that point to a directory,
the function returns FileInfo with both ModeDir and ModeSymlink set.
Change that to never set ModeDir if ModeSymlink is set.

Fixes #10424
Fixes #17540
Fixes #17541

Change-Id: Iba280888aad108360b8c1f18180a24493fe7ad2b
Reviewed-on: https://go-review.googlesource.com/41830
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-26 23:17:23 +00:00
Mostyn Bramley-Moore
3d86d45dd6 build: fail nicely if somebody runs all.bash from a binary tarball package
Fixes golang/go#20008.

Change-Id: I7a429490320595fc558a8c5e260ec41bc3a788e2
Reviewed-on: https://go-review.googlesource.com/41858
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-26 22:57:29 +00:00
Damien Lespiau
92d918da03 cmd/internal/obj/x86: fix adcb r/mem8,reg8 encoding
Taken from the Intel Software Development Manual (of course, in the line
below it's ADC DST, SRC; The opposite of the commit subject).

  12 /r		ADC r8, r/m8

We need 0x12 for the corresponding ytab line, not 0x10.

  {Ymb, Ynone, Yrb, Zm_r, 1},

Updates #14069

Change-Id: Id37cbd0c581c9988c2de355efa908956278e2189
Reviewed-on: https://go-review.googlesource.com/41857
Reviewed-by: Keith Randall <khr@golang.org>
2017-04-26 20:41:12 +00:00
Josh Bleecher Snyder
92607fdd30 cmd/compile: split dumptypestructs further
This is preparatory cleanup to make future changes clearer.

Change-Id: I20fb9c78257de61b8bd096fce6b1e751995c01f2
Reviewed-on: https://go-review.googlesource.com/41818
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-26 20:16:41 +00:00
Russ Cox
3ddf65015a runtime/pprof: ignore dummy huge page mapping in /proc/self/maps
Change-Id: I72bea1450386100482b4681b20eb9a9af12c7522
Reviewed-on: https://go-review.googlesource.com/41816
Reviewed-by: Michael Matloob <matloob@golang.org>
2017-04-26 19:34:56 +00:00
Russ Cox
d1ac592717 runtime/pprof: add /proc/self/maps parsing test
Delete old TestRuntimeFunctionTrimming, which is testing a dead API
and is now handled in end-to-end tests.

Change-Id: I64fc2991ed4a7690456356b5f6b546f36935bb67
Reviewed-on: https://go-review.googlesource.com/41815
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2017-04-26 19:34:01 +00:00
Bryan C. Mills
c5b6c2abe2 encoding/json: parallelize most benchmarks
Don't bother with BenchmarkDecoderStream — it's doing something subtle
with the input buffer that isn't easy to replicate in a parallel test.

Results remain comparable with the non-parallel version with -cpu=1:

benchmark                          old ns/op     new ns/op     delta
BenchmarkCodeEncoder               22815832      21058729      -7.70%
BenchmarkCodeEncoder-6             22190561      3579757       -83.87%
BenchmarkCodeMarshal               25356621      25396429      +0.16%
BenchmarkCodeMarshal-6             25359813      4944908       -80.50%
BenchmarkCodeDecoder               94794556      88016360      -7.15%
BenchmarkCodeDecoder-6             93795028      16726283      -82.17%
BenchmarkDecoderStream             532           583           +9.59%
BenchmarkDecoderStream-6           598           550           -8.03%
BenchmarkCodeUnmarshal             97644168      89162504      -8.69%
BenchmarkCodeUnmarshal-6           96615302      17036419      -82.37%
BenchmarkCodeUnmarshalReuse        91747073      90298479      -1.58%
BenchmarkCodeUnmarshalReuse-6      89397165      15518005      -82.64%
BenchmarkUnmarshalString           808           843           +4.33%
BenchmarkUnmarshalString-6         912           220           -75.88%
BenchmarkUnmarshalFloat64          695           732           +5.32%
BenchmarkUnmarshalFloat64-6        710           191           -73.10%
BenchmarkUnmarshalInt64            635           640           +0.79%
BenchmarkUnmarshalInt64-6          618           185           -70.06%
BenchmarkIssue10335                916           947           +3.38%
BenchmarkIssue10335-6              879           216           -75.43%
BenchmarkNumberIsValid             34.7          34.3          -1.15%
BenchmarkNumberIsValid-6           34.9          36.7          +5.16%
BenchmarkNumberIsValidRegexp       1174          1121          -4.51%
BenchmarkNumberIsValidRegexp-6     1134          1119          -1.32%
BenchmarkSkipValue                 20506938      20708060      +0.98%
BenchmarkSkipValue-6               21627665      22375630      +3.46%
BenchmarkEncoderEncode             690           726           +5.22%
BenchmarkEncoderEncode-6           649           157           -75.81%

benchmark                    old MB/s     new MB/s     speedup
BenchmarkCodeEncoder         85.05        92.15        1.08x
BenchmarkCodeEncoder-6       87.45        542.07       6.20x
BenchmarkCodeMarshal         76.53        76.41        1.00x
BenchmarkCodeMarshal-6       76.52        392.42       5.13x
BenchmarkCodeDecoder         20.47        22.05        1.08x
BenchmarkCodeDecoder-6       20.69        116.01       5.61x
BenchmarkCodeUnmarshal       19.87        21.76        1.10x
BenchmarkCodeUnmarshal-6     20.08        113.90       5.67x
BenchmarkSkipValue           90.55        89.67        0.99x
BenchmarkSkipValue-6         90.83        87.80        0.97x

benchmark                    old allocs     new allocs     delta
BenchmarkIssue10335          4              4              +0.00%
BenchmarkIssue10335-6        4              4              +0.00%
BenchmarkEncoderEncode       1              1              +0.00%
BenchmarkEncoderEncode-6     1              1              +0.00%

benchmark                    old bytes     new bytes     delta
BenchmarkIssue10335          320           320           +0.00%
BenchmarkIssue10335-6        320           320           +0.00%
BenchmarkEncoderEncode       8             8             +0.00%
BenchmarkEncoderEncode-6     8             8             +0.00%

updates #18177

Change-Id: Ia4f5bf5ac0afbadb1705ed9f9e1b39dabba67b40
Reviewed-on: https://go-review.googlesource.com/36724
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-26 19:23:06 +00:00
Bryan C. Mills
f5f5a00b92 reflect: parallelize benchmarks
Add a benchmark for PtrTo: it's the motivation for #17973, which is
the motivation for #18177.

Results remain comparable with the non-parallel version with -cpu=1:

benchmark                             old ns/op     new ns/op     delta
BenchmarkCall                         357           360           +0.84%
BenchmarkCall-6                       90.3          90.7          +0.44%
BenchmarkCallArgCopy/size=128         319           323           +1.25%
BenchmarkCallArgCopy/size=128-6       329           82.2          -75.02%
BenchmarkCallArgCopy/size=256         354           335           -5.37%
BenchmarkCallArgCopy/size=256-6       340           85.2          -74.94%
BenchmarkCallArgCopy/size=1024        374           703           +87.97%
BenchmarkCallArgCopy/size=1024-6      378           95.8          -74.66%
BenchmarkCallArgCopy/size=4096        627           631           +0.64%
BenchmarkCallArgCopy/size=4096-6      643           120           -81.34%
BenchmarkCallArgCopy/size=65536       10502         10169         -3.17%
BenchmarkCallArgCopy/size=65536-6     10298         2240          -78.25%
BenchmarkFieldByName1                 139           132           -5.04%
BenchmarkFieldByName1-6               144           24.9          -82.71%
BenchmarkFieldByName2                 2721          2778          +2.09%
BenchmarkFieldByName2-6               3953          578           -85.38%
BenchmarkFieldByName3                 19136         18357         -4.07%
BenchmarkFieldByName3-6               23072         3850          -83.31%
BenchmarkInterfaceBig                 12.7          15.5          +22.05%
BenchmarkInterfaceBig-6               14.2          2.48          -82.54%
BenchmarkInterfaceSmall               13.1          15.1          +15.27%
BenchmarkInterfaceSmall-6             13.0          2.54          -80.46%
BenchmarkNew                          43.8          43.0          -1.83%
BenchmarkNew-6                        40.5          6.67          -83.53%

benchmark                             old MB/s     new MB/s     speedup
BenchmarkCallArgCopy/size=128         400.24       395.15       0.99x
BenchmarkCallArgCopy/size=128-6       388.74       1557.76      4.01x
BenchmarkCallArgCopy/size=256         722.44       762.44       1.06x
BenchmarkCallArgCopy/size=256-6       751.98       3003.83      3.99x
BenchmarkCallArgCopy/size=1024        2733.22      1455.50      0.53x
BenchmarkCallArgCopy/size=1024-6      2706.40      10687.53     3.95x
BenchmarkCallArgCopy/size=4096        6523.32      6488.25      0.99x
BenchmarkCallArgCopy/size=4096-6      6363.85      34003.09     5.34x
BenchmarkCallArgCopy/size=65536       6239.88      6444.46      1.03x
BenchmarkCallArgCopy/size=65536-6     6363.83      29255.26     4.60x

benchmark           old allocs     new allocs     delta
BenchmarkCall       0              0              +0.00%
BenchmarkCall-6     0              0              +0.00%

benchmark           old bytes     new bytes     delta
BenchmarkCall       0             0             +0.00%
BenchmarkCall-6     0             0             +0.00%

updates #17973
updates #18177

Change-Id: If70c5c742e8d1b138347f4963ad7cff38fffc018
Reviewed-on: https://go-review.googlesource.com/36831
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-26 19:04:30 +00:00
Bryan C. Mills
3058b1f538 encoding/gob: parallelize Encode/Decode benchmarks
Results remain comparable with the non-parallel version with -cpu=1:

benchmark                              old ns/op     new ns/op     delta
BenchmarkEndToEndPipe                  6200          6171          -0.47%
BenchmarkEndToEndPipe-6                1073          1024          -4.57%
BenchmarkEndToEndByteBuffer            2925          2664          -8.92%
BenchmarkEndToEndByteBuffer-6          516           560           +8.53%
BenchmarkEndToEndSliceByteBuffer       231683        237450        +2.49%
BenchmarkEndToEndSliceByteBuffer-6     59080         59452         +0.63%
BenchmarkEncodeComplex128Slice         67541         66003         -2.28%
BenchmarkEncodeComplex128Slice-6       72740         11316         -84.44%
BenchmarkEncodeFloat64Slice            25769         27899         +8.27%
BenchmarkEncodeFloat64Slice-6          26655         4557          -82.90%
BenchmarkEncodeInt32Slice              18685         18845         +0.86%
BenchmarkEncodeInt32Slice-6            18389         3462          -81.17%
BenchmarkEncodeStringSlice             19089         19354         +1.39%
BenchmarkEncodeStringSlice-6           20155         3237          -83.94%
BenchmarkEncodeInterfaceSlice          659601        677129        +2.66%
BenchmarkEncodeInterfaceSlice-6        640974        251621        -60.74%
BenchmarkDecodeComplex128Slice         117130        129955        +10.95%
BenchmarkDecodeComplex128Slice-6       155447        24924         -83.97%
BenchmarkDecodeFloat64Slice            67695         68776         +1.60%
BenchmarkDecodeFloat64Slice-6          82966         15225         -81.65%
BenchmarkDecodeInt32Slice              63102         62733         -0.58%
BenchmarkDecodeInt32Slice-6            77857         13003         -83.30%
BenchmarkDecodeStringSlice             130240        129562        -0.52%
BenchmarkDecodeStringSlice-6           165500        31507         -80.96%
BenchmarkDecodeInterfaceSlice          937637        1060835       +13.14%
BenchmarkDecodeInterfaceSlice-6        973495        270613        -72.20%

updates #18177

Change-Id: Ib3579010faa70827d5cbd02a826dbbb66ca13eb7
Reviewed-on: https://go-review.googlesource.com/36722
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-26 19:04:18 +00:00
Bryan C. Mills
9d37d4c88a encoding/xml: parallelize benchmarks
Results remain comparable with the non-parallel version with -cpu=1:
benchmark                old ns/op     new ns/op     delta
BenchmarkMarshal         31220         28618         -8.33%
BenchmarkMarshal-6       37181         7658          -79.40%
BenchmarkUnmarshal       81837         83522         +2.06%
BenchmarkUnmarshal-6     96339         18244         -81.06%

benchmark                old allocs     new allocs     delta
BenchmarkMarshal         23             23             +0.00%
BenchmarkMarshal-6       23             23             +0.00%
BenchmarkUnmarshal       189            189            +0.00%
BenchmarkUnmarshal-6     189            189            +0.00%

benchmark                old bytes     new bytes     delta
BenchmarkMarshal         5776          5776          +0.00%
BenchmarkMarshal-6       5776          5776          +0.00%
BenchmarkUnmarshal       8576          8576          +0.00%
BenchmarkUnmarshal-6     8576          8576          +0.00%

updates #18177

Change-Id: I7e7055a11d18896bd54d7d773f2ec64767cdb4c8
Reviewed-on: https://go-review.googlesource.com/36810
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-26 19:04:03 +00:00
Bryan C. Mills
959025c0ac sync: import Map from x/sync/syncmap
This is a direct port of the version from
commit a60ad46e0ed33d02e09bda439efaf9c9727dbc6c
(https://go-review.googlesource.com/c/37342/).

updates #17973
updates #18177

Change-Id: I63fa5ef6951b1edd39f84927d1181a4df9b15385
Reviewed-on: https://go-review.googlesource.com/36617
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-26 18:05:06 +00:00
Josh Bleecher Snyder
e1a7db7f3b cmd/compile: minor cleanup
Follow-up to review comments on CL 41797.

Mask the input to set2 and set3, so that at the very least,
we won't corrupt the rest of the flags in case of a bad input.
It also seems more semantically appropriate.

Do minor cleanup in addrescapes. I started on larger cleanup,
but it wasn't clear that it was an improvement.

Add warning comments and sanity checks to Initorder and Class constants,
to attempt to prevent them from overflowing their allotted flag bits.

Passes toolstash-check.

Change-Id: I57b9661ba36f56406aa7a1d8da9b7c70338f9119
Reviewed-on: https://go-review.googlesource.com/41817
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-26 18:01:14 +00:00
Lynn Boger
6910e1085b cmd/internal/obj/ppc64: use MOVDU to update stack reg for leaf functions where possible
When the stack register is decremented to acquire stack space at
the beginning of a function, a MOVDU should be used so it is done
atomically, unless the size of the stack frame is too large for
that instruction.  The code to determine whether to use MOVDU
or MOVD was checking if the function was a leaf and always generating MOVD
when it was.  The choice of MOVD vs. MOVDU should only depend on the stack
frame size.  This fixes that problem.

Change-Id: I0e49c79036f1e8f7584179e1442b938fc6da085f
Reviewed-on: https://go-review.googlesource.com/41813
Reviewed-by: Michael Munday <munday@ca.ibm.com>
2017-04-26 17:39:33 +00:00
Josh Bleecher Snyder
386765afdf cmd/compile: move Node.Class to flags
Put it at position zero, since it is fairly hot.

This shrinks gc.Node into a smaller size class on 64 bit systems.

name        old time/op       new time/op       delta
Template          193ms ± 5%        192ms ± 3%    ~     (p=0.353 n=94+93)
Unicode          86.1ms ± 5%       85.0ms ± 4%  -1.23%  (p=0.000 n=95+98)
GoTypes           546ms ± 3%        544ms ± 4%  -0.40%  (p=0.007 n=94+97)
Compiler          2.56s ± 3%        2.54s ± 3%  -0.67%  (p=0.000 n=99+97)
SSA               5.13s ± 2%        5.10s ± 3%  -0.55%  (p=0.000 n=94+98)
Flate             122ms ± 6%        121ms ± 4%  -0.75%  (p=0.002 n=97+95)
GoParser          144ms ± 5%        144ms ± 4%    ~     (p=0.298 n=98+97)
Reflect           348ms ± 4%        349ms ± 4%    ~     (p=0.350 n=98+97)
Tar               105ms ± 5%        104ms ± 5%    ~     (p=0.154 n=96+98)
XML               200ms ± 5%        198ms ± 4%  -0.71%  (p=0.015 n=97+98)
[Geo mean]        330ms             328ms       -0.52%

name        old user-time/op  new user-time/op  delta
Template          229ms ±11%        224ms ± 7%  -2.16%  (p=0.001 n=100+87)
Unicode           109ms ± 5%        109ms ± 6%    ~     (p=0.897 n=96+91)
GoTypes           712ms ± 4%        709ms ± 4%    ~     (p=0.085 n=96+98)
Compiler          3.41s ± 3%        3.36s ± 3%  -1.43%  (p=0.000 n=98+98)
SSA               7.46s ± 3%        7.31s ± 3%  -2.02%  (p=0.000 n=100+99)
Flate             145ms ± 6%        143ms ± 6%  -1.11%  (p=0.001 n=99+97)
GoParser          177ms ± 5%        176ms ± 5%  -0.78%  (p=0.018 n=95+95)
Reflect           432ms ± 7%        435ms ± 9%    ~     (p=0.296 n=100+100)
Tar               121ms ± 7%        121ms ± 5%    ~     (p=0.072 n=100+95)
XML               241ms ± 4%        239ms ± 5%    ~     (p=0.085 n=97+99)
[Geo mean]        413ms             410ms       -0.73%

name        old alloc/op      new alloc/op      delta
Template         38.4MB ± 0%       37.7MB ± 0%  -1.85%  (p=0.008 n=5+5)
Unicode          30.1MB ± 0%       28.8MB ± 0%  -4.09%  (p=0.008 n=5+5)
GoTypes           112MB ± 0%        110MB ± 0%  -1.69%  (p=0.008 n=5+5)
Compiler          470MB ± 0%        461MB ± 0%  -1.91%  (p=0.008 n=5+5)
SSA              1.13GB ± 0%       1.11GB ± 0%  -1.70%  (p=0.008 n=5+5)
Flate            25.0MB ± 0%       24.6MB ± 0%  -1.67%  (p=0.008 n=5+5)
GoParser         31.6MB ± 0%       31.1MB ± 0%  -1.66%  (p=0.008 n=5+5)
Reflect          77.1MB ± 0%       75.8MB ± 0%  -1.69%  (p=0.008 n=5+5)
Tar              26.3MB ± 0%       25.7MB ± 0%  -2.06%  (p=0.008 n=5+5)
XML              41.9MB ± 0%       41.1MB ± 0%  -1.93%  (p=0.008 n=5+5)
[Geo mean]       73.5MB            72.0MB       -2.03%

name        old allocs/op     new allocs/op     delta
Template           383k ± 0%         383k ± 0%    ~     (p=0.690 n=5+5)
Unicode            343k ± 0%         343k ± 0%    ~     (p=0.841 n=5+5)
GoTypes           1.16M ± 0%        1.16M ± 0%    ~     (p=0.310 n=5+5)
Compiler          4.43M ± 0%        4.42M ± 0%  -0.17%  (p=0.008 n=5+5)
SSA               9.85M ± 0%        9.85M ± 0%    ~     (p=0.310 n=5+5)
Flate              236k ± 0%         236k ± 1%    ~     (p=0.841 n=5+5)
GoParser           320k ± 0%         320k ± 0%    ~     (p=0.421 n=5+5)
Reflect            988k ± 0%         987k ± 0%    ~     (p=0.690 n=5+5)
Tar                252k ± 0%         251k ± 0%    ~     (p=0.095 n=5+5)
XML                399k ± 0%         399k ± 0%    ~     (p=1.000 n=5+5)
[Geo mean]         741k              740k       -0.07%

Change-Id: I9e952b58a98e30a12494304db9ce50d0a85e459c
Reviewed-on: https://go-review.googlesource.com/41797
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Marvin Stenger <marvin.stenger94@gmail.com>
2017-04-26 16:58:33 +00:00
Justin Nuß
2181653be6 encoding/csv: add option to reuse slices returned by Read
In many cases the records returned by Reader.Read will only be used between calls
to Read and become garbage once a new record is read. In this case, instead of
allocating a new slice on each call to Read, we can reuse the last allocated slice
for successive calls to avoid unnecessary allocations.

This change adds a new field ReuseRecord to the Reader struct to enable this reuse.

ReuseRecord is false by default to avoid breaking existing code which dependss on
the current behaviour.

I also added 4 new benchmarks, corresponding to the existing Read benchmarks, which
set ReuseRecord to true.

Benchstat on my local machine (old is ReuseRecord = false, new is ReuseRecord = true)

name                          old time/op    new time/op    delta
Read-8                          2.75µs ± 2%    1.88µs ± 1%  -31.52%  (p=0.000 n=14+15)
ReadWithFieldsPerRecord-8       2.75µs ± 0%    1.89µs ± 1%  -31.43%  (p=0.000 n=13+13)
ReadWithoutFieldsPerRecord-8    2.77µs ± 1%    1.88µs ± 1%  -32.06%  (p=0.000 n=15+15)
ReadLargeFields-8               55.4µs ± 1%    54.2µs ± 0%   -2.07%  (p=0.000 n=15+14)

name                          old alloc/op   new alloc/op   delta
Read-8                            664B ± 0%       24B ± 0%  -96.39%  (p=0.000 n=15+15)
ReadWithFieldsPerRecord-8         664B ± 0%       24B ± 0%  -96.39%  (p=0.000 n=15+15)
ReadWithoutFieldsPerRecord-8      664B ± 0%       24B ± 0%  -96.39%  (p=0.000 n=15+15)
ReadLargeFields-8               3.94kB ± 0%    2.98kB ± 0%  -24.39%  (p=0.000 n=15+15)

name                          old allocs/op  new allocs/op  delta
Read-8                            18.0 ± 0%       8.0 ± 0%  -55.56%  (p=0.000 n=15+15)
ReadWithFieldsPerRecord-8         18.0 ± 0%       8.0 ± 0%  -55.56%  (p=0.000 n=15+15)
ReadWithoutFieldsPerRecord-8      18.0 ± 0%       8.0 ± 0%  -55.56%  (p=0.000 n=15+15)
ReadLargeFields-8                 24.0 ± 0%      12.0 ± 0%  -50.00%  (p=0.000 n=15+15)

Fixes #19721

Change-Id: I79b14128bb9bb3465f53f40f93b1b528a9da6f58
Reviewed-on: https://go-review.googlesource.com/41730
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-26 15:55:56 +00:00
Brandon Bennett
ba8ff87dbe testing: add argument to list tests, benchmarks, and examples
Some large testing/build systems require some form of test discovery before
running tests.  This usually allows for analytics, history, and stats on a per
tests basis.  Typically these systems are meant used in multi-language
environments and the original source code is not known or available.

This adds a -test.list option which takes a regular expression as an
argument. Any tests, benchmarks, or examples that match that regular
expression will be printed, one per line, to stdout and then the program
will exit.

Since subtests are named/discovered at run time this will only show
top-level tests names and is a known limitation.

Fixes #17209

Change-Id: I7e607f5f4f084d623a1cae88a1f70e7d92b7f13e
Reviewed-on: https://go-review.googlesource.com/41195
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-26 15:53:32 +00:00
Russ Cox
6e2c4bc012 context: define behavior for Err before Done is closed
The Context definition to date has not defined what Err returns
before the Done channel is closed. Define that it returns nil,
as most implementations do.

All the standard context implementations (those in package
context and in golang.org/x/net/context) return Err() == nil
when Done is not yet closed. However, some non-standard
implementations may exist that return Err() != nil in this case,
as permitted by the Context definition before this date.
Call these "errorful implementations".

Because all the standard context implementations ensure that
Err() == nil when Done is not yet closed, clients now exist that
assume Err() != nil implies Done is closed and use calling Err
as a quick short-circuit check instead of first doing a non-blocking
receive from Done and then, if that succeeds, needing to call Err.
This assumption holds for all the standard Context implementations,
so these clients work fine in practice, even though they are making
unwarranted assumptions about the Context implementations.
Call these "technically incorrect clients".

If a technically incorrect client encounters an errorful
implementation, the client misbehaves. Because there are few
errorful implementations, over time we expect that many clients
will end up being technically incorrect without realizing it,
leading to latent, subtle bugs. If we want to eliminate these
latent, subtle bugs, there are two ways to do this:
either make errorful implementations more common
(exposing the client bugs more often) or redefine the Context
interface so that the clients are not buggy after all.

If we make errorful implementations more common, such
as by changing the standard context implementations to
return ErrNotDone instead of nil when Err is called before
Done is closed, this will shake out essentially all of the
technically incorrect clients, forcing people to find and fix
those clients during the transition to Go 1.9.
Technically this is allowed by the compatibility policy,
but we expect there are many pieces of code assuming
that Err() != nil means done, so updating will cause real pain.

If instead we disallow errorful implementations, then they
will need to be fixed as they are discovered, but the fault
will officially lie in the errorful Context implementation,
not in the clients. Technically this is disallowed by the compatibility
policy, because these errorful implementations were "correct"
in earlier versions of Go, except that they didn't work with
common client code. We expect there are hardly any errorful
implementations, so that disallowing them will be less disruptive
and more in the spirit of the compatibility policy.

This CL takes the path of expected least disruption,
narrowing the Context interface semantics and potentially
invalidating existing implementations. A survey of the
go-corpus v0.01 turned up only five Context implementations,
all trivial and none errorful (details in #19856).
We are aware of one early Context implementation inside Google,
from before even golang.org/x/net/context existed,
that is errorful. The misbehavior of an open-source library
when passed such a context is what prompted #19856.
That context implementation would be disallowed after this CL
and would need to be corrected. We are aware of no other
affected context implementations. On the other hand, a survey
of the go-corpus v0.01 turned up many instances of client
code assuming that Err() == nil implies not done yet
(details also in #19856). On balance, narrowing Context and
thereby allowing Err() == nil checks should invalidate significantly
less code than a push to flush out all the currently technically
incorrect Err() == nil checks.

If release feedback shows that we're wrong about this balance,
we can roll back this CL and try again in Go 1.10.

Fixes #19856.

Change-Id: Id45d126fac70e1fcc42d73e5a87ca1b66935b831
Reviewed-on: https://go-review.googlesource.com/40291
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Sameer Ajmani <sameer@golang.org>
2017-04-26 15:39:18 +00:00
David du Colombier
8a4087aee6 net: fix close on closed listener on Plan 9
Since close errors have been cleaned up in CL 39997,
TestCloseError is failing on Plan 9, because
TCPListener.Close didn't check that the listener
has already been closed before writing the "hangup"
string to the listener control file.

This change fixes TCPListener.Close on Plan 9,
by closing poll.FD before writing the "hangup"
string.

Fixes #20128.

Change-Id: I13862b23a9055dd1be658acef7066707d98c591f
Reviewed-on: https://go-review.googlesource.com/41850
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-26 15:04:43 +00:00
Fangming.Fang
aecf73fc31 cmd/internal: fix bug getting wrong indicator in DRconv()
Change-Id: I251ae497b0ab237d4b3fe98e397052394142d437
Reviewed-on: https://go-review.googlesource.com/41653
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-26 14:09:18 +00:00
Mike Strosaker
48582e1524 crypto/sha256,crypto/sha512: improve performance for sha{256,512}.block on ppc64le
This updates sha256.block and sha512.block to use vector instructions.  While
each round must still be performed independently, this allows for the use of
the vshasigma{w,d} crypto acceleration instructions.

For crypto/sha256:

benchmark               old ns/op     new ns/op     delta
BenchmarkHash8Bytes     570           300           -47.37%
BenchmarkHash1K         7529          3018          -59.91%
BenchmarkHash8K         55308         21938         -60.33%

benchmark               old MB/s     new MB/s     speedup
BenchmarkHash8Bytes     14.01        26.58        1.90x
BenchmarkHash1K         136.00       339.23       2.49x
BenchmarkHash8K         148.11       373.40       2.52x

For crypto/sha512:

benchmark               old ns/op     new ns/op     delta
BenchmarkHash8Bytes     725           394           -45.66%
BenchmarkHash1K         5062          2107          -58.38%
BenchmarkHash8K         34711         13918         -59.90%

benchmark               old MB/s     new MB/s     speedup
BenchmarkHash8Bytes     11.03        20.29        1.84x
BenchmarkHash1K         202.28       485.84       2.40x
BenchmarkHash8K         236.00       588.56       2.49x

Fixes #20069

Change-Id: I28bffe6e9eb484a83a004116fce84acb4942abca
Reviewed-on: https://go-review.googlesource.com/41391
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2017-04-26 12:34:03 +00:00
Aliaksandr Valialkin
259d60995d runtime: align mcentral by cache line size
This may improve perormance during concurrent access
to mheap.central array from multiple CPU cores.

Change-Id: I8f48dd2e72aa62e9c32de07ae60fe552d8642782
Reviewed-on: https://go-review.googlesource.com/41550
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-26 03:48:23 +00:00
Emmanuel Odeke
c433c374b5 net: defer file.close() + minor style cleanup
Moved the relevant file.close() usages close to after the
file opens and put them in defer statements, so that readers
don't have to think too much as to where the file is
being closed.

Change-Id: Ic4190b02ea2f5ac281b9ba104e0023e9f87ca8c7
Reviewed-on: https://go-review.googlesource.com/41796
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-26 03:12:20 +00:00
Ian Lance Taylor
e3d7ec006f os: consistently return ErrClosed for closed file
Catch all the cases where a file operation might return ErrFileClosing,
and convert to ErrClosed. Use a new method for the conversion, which
permits us to remove some KeepAlive calls.

Change-Id: I584178f297efe6cb86f3090b2341091b412f1041
Reviewed-on: https://go-review.googlesource.com/41793
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-26 02:54:59 +00:00
Josh Bleecher Snyder
502a03ffcf cmd/compile: move Node.Typecheck to flags
Change-Id: Id5aa4a1499068bf2d3497b21d794f970b7e47fdf
Reviewed-on: https://go-review.googlesource.com/41795
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-26 01:27:28 +00:00
Josh Bleecher Snyder
e2560ace3c cmd/compile: move Node.Initorder to flags
Grand savings: 6 bits.

Change-Id: I364be54cc41534689e01672ed0fe2c10a560d3d4
Reviewed-on: https://go-review.googlesource.com/41794
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-26 01:12:09 +00:00
Josh Bleecher Snyder
af7da9a53b cmd/compile: convert Node.Embedded into a flag
Change-Id: I30c59ba84dcacc3de39c42f94484b47bb7c36eba
Reviewed-on: https://go-review.googlesource.com/41792
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-26 01:01:53 +00:00
Todd Neal
7a92395ddd plugin: resolve plugin import path issue
Resolve import paths to get plugin symbol prefixes.

Fixes #19534

Change-Id: Ic25d83e72465ba8f6be0337218a1627b5dc702dc
Reviewed-on: https://go-review.googlesource.com/40994
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-04-26 00:54:54 +00:00
Michael Fraenkel
819d1cce6e net/http: make LocalAddrContext handle wildcard interface
The LocalAddrContext should have the network address of the actual
interface.

Fixes #18686

Change-Id: I9c401eda312f3a0e7e65b013af827aeeef3b4d3d
Reviewed-on: https://go-review.googlesource.com/35490
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-26 00:52:20 +00:00
Josh Bleecher Snyder
d286399641 cmd/compile: move Node.Walkdef into flags
Node.Walkdef is 0, 1, or 2, so it only requires two bits.
Add support for 2-bit values to bitset,
and use it for Node.Walkdef.

Class, Embedded, Typecheck, and Initorder will follow suit
in subsequent CLs.

The multi-bit flags will go at the beginning,
since that generates (marginally) more efficient code.

Change-Id: Id6e2e66e437f10aaa05b8a6e1652efb327d06128
Reviewed-on: https://go-review.googlesource.com/41791
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-26 00:43:48 +00:00
Josh Bleecher Snyder
804784c8ba cmd/compile: delete bitset16
It is no longer used.

Change-Id: Id64f387867a0503d13eaecda12e6606682c24595
Reviewed-on: https://go-review.googlesource.com/41790
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-26 00:42:33 +00:00
Ian Lance Taylor
fb4b4342fe os, net, internal/poll: return consistent error for closed socket
In the past we returned "use of closed network connection" when using
a closed network descriptor in some way. In CL 36799 that was changed
to return "use of closed file or network connection". Because programs
have no access to a value of this error type (see issue #4373) they
resort to doing direct string comparisons (see issue #19252). This CL
restores the old error string so that we don't break programs
unnecessarily with the 1.9 release.

This adds a test to the net package for the expected string.

For symmetry check that the os package returns the expected error,
which for os already exists as os.ErrClosed.

Updates #4373.
Fixed #19252.

Change-Id: I5b83fd12cfa03501a077cad9336499b819f4a38b
Reviewed-on: https://go-review.googlesource.com/39997
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2017-04-26 00:03:14 +00:00