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

21742 Commits

Author SHA1 Message Date
Rob Pike
998aaf8a64 cmd/vet: add a README explaining the criteria for new checks
Correctness, Frequency, Precision.

Change-Id: I7f202c220aef8512d611dc04a4370b4a237f217c
Reviewed-on: https://go-review.googlesource.com/20003
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-01 20:48:20 +00:00
David Chase
6b3462c784 [dev.ssa] cmd/compile: adjust branch likeliness for calls/loops
Static branch predictions (which guide block ordering) are
adjusted based on:

loop/not-loop     (favor looping)
abnormal-exit/not (avoid panic)
call/not-call     (avoid call)
ret/default       (treat returns as rare)

This appears to make no difference in performance of real
code, meaning the compiler itself.  The earlier version of
this has been stripped down to help make the cost of this
only-aesthetic-on-Intel phase be as cheap as possible (we
probably want information about inner loops for improving
register allocation, but because register allocation follows
close behind this pass, conceivably the information could be
reused -- so we might do this anyway just to normalize
output).

For a ./make.bash that takes 200 user seconds, about .75
second is reported in likelyadjust (summing nanoseconds
reported with -d=ssa/likelyadjust/time ).

Upstream predictions are respected.
Includes test, limited to build on amd64 only.
Did several iterations on the debugging output to allow
some rough checks on behavior.
Debug=1 logging notes agree/disagree with earlier passes,
allowing analysis like the following:

Run on make.bash:
GO_GCFLAGS=-d=ssa/likelyadjust/debug \
   ./make.bash >& lkly5.log

grep 'ranch prediction' lkly5.log | wc -l
   78242 // 78k predictions

grep 'ranch predi' lkly5.log | egrep -v 'agrees with' | wc -l
   29633 // 29k NEW predictions

grep 'disagrees' lkly5.log | wc -l
     444 // contradicted 444 times

grep '< exit' lkly5.log | wc -l
   10212 // 10k exit predictions

grep '< exit' lkly5.log | egrep 'disagrees' | wc -l
       5 // 5 contradicted by previous prediction

grep '< exit' lkly5.log | egrep -v 'agrees' | wc -l
     702 // 702-5 redundant with previous prediction

grep '< call' lkly5.log | egrep -v 'agrees' | wc -l
   16699 // 16k new call predictions

grep 'stay in loop' lkly5.log | egrep -v 'agrees' | wc -l
    3951 // 4k new "remain in loop" predictions

Fixes #11451.

Change-Id: Iafb0504f7030d304ef4b6dc1aba9a5789151a593
Reviewed-on: https://go-review.googlesource.com/19995
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-01 20:09:41 +00:00
Matthew Dempsky
9ace455e78 cmd/compile/internal/ssa: cleanup godocs
Add a blank line before the "package ssa" lines so the "autogenerated
don't edit" comments don't end up in godoc output.

Change-Id: I82bf90d52d426ce1a8e21483fc8f47b3689259c7
Reviewed-on: https://go-review.googlesource.com/20086
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-01 19:20:24 +00:00
David Crawshaw
dd0a128a02 cmd/link: make rddataBufMax a const
Change-Id: I1ece7463d35efba0e8d2b1e61727dd25283ff720
Reviewed-on: https://go-review.googlesource.com/20059
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-01 18:08:02 +00:00
Alexandru Moșoi
e197f467d5 [dev.ssa] cmd/compile/internal/ssa: simplify boolean phis
* Decreases the generated code slightly.
* Similar to phiopt pass from gcc, except it only handles
booleans. Handling Eq/Neq had no impact on the generated code.

name       old time/op     new time/op     delta
Template       453ms ± 4%      451ms ± 4%    ~           (p=0.468 n=24+24)
GoTypes        1.55s ± 1%      1.55s ± 2%    ~           (p=0.287 n=24+25)
Compiler       6.53s ± 2%      6.56s ± 1%  +0.46%        (p=0.050 n=23+23)
MakeBash       45.8s ± 2%      45.7s ± 2%    ~           (p=0.866 n=24+25)

name       old text-bytes  new text-bytes  delta
HelloSize       676k ± 0%       676k ± 0%    ~     (all samples are equal)
CmdGoSize      8.07M ± 0%      8.07M ± 0%  -0.03%        (p=0.000 n=25+25)

Change-Id: Ia62477b7554127958a14cb27f85849b095d63663
Reviewed-on: https://go-review.googlesource.com/20090
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-01 17:56:13 +00:00
Alexandru Moșoi
1f6e9e36b0 [dev.ssa] cmd/compile/internal/ssa: distribute multiplication into addition
* This is a very basic form of straight line strength reduction.
* Removes one multiplication from a[b].c++; a[b+1].c++
* It increases pressure on the register allocator because
CSE creates more copies of the multiplication sizeof(a[0])*b.

Change-Id: I686a18e9c24cc6f8bdfa925713afed034f7d36d0
Reviewed-on: https://go-review.googlesource.com/20091
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-01 17:05:13 +00:00
Ilya Tocar
e96b232993 [dev.ssa] cmd/compile: promote byte/word operation
Writing to low 8/16 bits of register creates false dependency
Generate 32-bit operations when possible.

Change-Id: I8eb6c1c43a66424eec6baa91a660bceb6b80d1d3
Reviewed-on: https://go-review.googlesource.com/19506
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-01 15:54:52 +00:00
Matthew Dempsky
ac006ad103 cmd/compile: change defaultlit2's force param to bool
Change-Id: I5546c4e8092ef61648cdae9c04288bb7d6f32476
Reviewed-on: https://go-review.googlesource.com/20084
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-01 08:50:45 +00:00
Martin Möhrmann
33c0ef2de3 fmt: make identification of string arguments consistent
Use only reflect.TypeOf to detect if argument is a string.

The wasString return is only needed in doPrint with the 'v' verb.
This type of string detection is handled correctly by reflect.TypeOf
which is used already in doPrint for identifying a string argument.

Remove now obsolete wasString computations and return values.

Change-Id: Iea2de7ac0f5c536a53eec63f7e679d628f5af8dc
Reviewed-on: https://go-review.googlesource.com/19976
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-03-01 07:36:06 +00:00
Matthew Dempsky
8ad027c0c4 go/types: nicer shift error message
Updates #13940.

Change-Id: I41974c292dd981d82ac03b9b8b406713445362c3
Reviewed-on: https://go-review.googlesource.com/20081
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-01 06:05:49 +00:00
Matthew Dempsky
86235d5dd7 go/constant: fix typos in MakeFromLiteral docs
Change-Id: I99c737415a082df883a9c12cdb43bdd5a1b9a8ad
Reviewed-on: https://go-review.googlesource.com/20082
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-01 06:04:27 +00:00
Matthew Dempsky
35dd2ed58d cmd/compile: give mparith{2,3}.go files more meaningful names
Also, relocate related const and type definitions from go.go.

Change-Id: Ieb9b672da8dd510ca67022b4f7ae49a778a56579
Reviewed-on: https://go-review.googlesource.com/20080
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-01 05:03:58 +00:00
Matthew Dempsky
a6c95ae1df cmd/compile: remove some unnecessary EType/int conversions
Change-Id: I2d8efef333f2441da6742e125e23ff57c9853ebd
Reviewed-on: https://go-review.googlesource.com/20078
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2016-03-01 04:38:05 +00:00
Matthew Dempsky
55e7636f9c cmd/compile: remove some unused consts from the old yacc parser
Change-Id: I42f370b987fcc85201f7aaa055b9e58ee9b9a99e
Reviewed-on: https://go-review.googlesource.com/20079
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-01 04:30:46 +00:00
Keith Randall
6a8a9da572 [dev.ssa] cmd/compile: Make PPARAMOUT variables SSAable
Add writeback code to each return location which copies
the final result back to the correct stack location.

Cgo plays tricky games by taking the address of a
in f(a int) (b int) and then using that address to
modify b.  So for cgo-generated Go code, disable the
SSAing of output args.

Update #14511

Change-Id: I95cba727d53699d31124eef41db0e03935862be9
Reviewed-on: https://go-review.googlesource.com/19988
Reviewed-by: Todd Neal <todd@tneal.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-01 02:00:04 +00:00
Shahar Kohanim
d3b00a8cc4 cmd/link: batch writing of bytes
In best of 10, linking cmd/go shows a ~10% improvement.

tip:              real  0m1.152s user  0m1.005s
this:             real  0m1.065s user  0m0.924s

Change-Id: I303a20b94332feaedc1033c453247a0e4c05c843
Reviewed-on: https://go-review.googlesource.com/19978
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-02-29 23:54:19 +00:00
Gerrit Code Review
acdb0da47d Merge "[dev.ssa] Merge remote-tracking branch 'origin/master' into ssamerge" into dev.ssa 2016-02-29 23:19:17 +00:00
Josh Bleecher Snyder
194c79c163 [dev.ssa] cmd/compile: add constant cache
The cache gets a 62% hit rate while compiling
the standard library.


name      old time/op    new time/op    delta
Template     449ms ± 2%     443ms ± 4%  -1.40%  (p=0.006 n=23+25)
GoTypes      1.54s ± 1%     1.50s ± 2%  -2.53%  (p=0.000 n=22+22)
Compiler     5.51s ± 1%     5.39s ± 1%  -2.29%  (p=0.000 n=23+25)

name      old alloc/op   new alloc/op   delta
Template    90.4MB ± 0%    90.0MB ± 0%  -0.45%  (p=0.000 n=25+25)
GoTypes      334MB ± 0%     331MB ± 0%  -1.05%  (p=0.000 n=25+25)
Compiler    1.12GB ± 0%    1.10GB ± 0%  -1.57%  (p=0.000 n=25+24)

name      old allocs/op  new allocs/op  delta
Template      681k ± 0%      682k ± 0%  +0.26%  (p=0.000 n=25+25)
GoTypes      2.23M ± 0%     2.23M ± 0%  +0.05%  (p=0.000 n=23+24)
Compiler     6.46M ± 0%     6.46M ± 0%  +0.02%  (p=0.000 n=24+25)


Change-Id: I2629c291892827493d7b55ec4d83f6973a2ab133
Reviewed-on: https://go-review.googlesource.com/20026
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-29 22:40:43 +00:00
Keith Randall
4fffd4569d [dev.ssa] Merge remote-tracking branch 'origin/master' into ssamerge
(Last?) Semi-regular merge from tip to dev.ssa.

Conflicts:
	src/cmd/compile/internal/gc/closure.go
	src/cmd/compile/internal/gc/gsubr.go
	src/cmd/compile/internal/gc/lex.go
	src/cmd/compile/internal/gc/pgen.go
	src/cmd/compile/internal/gc/syntax.go
	src/cmd/compile/internal/gc/walk.go
	src/cmd/internal/obj/pass.go

Change-Id: Ib5ea8bf74d420f4902a9c6208761be9f22371ae7
2016-02-29 13:32:20 -08:00
Keith Randall
f1f366c1e7 [dev.ssa] cmd/compile: MOVBconst might also clobber flags
It gets rewritten to an xor by the linker also.

Change-Id: Iae35130325d41bd1a09b7e971190cae6f4e17fac
Reviewed-on: https://go-review.googlesource.com/20058
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-29 19:39:15 +00:00
David Crawshaw
07ccc21295 cmd/link: skip allocation when reading symbol name
The object file reader in cmd/link reads the symbol name into a scratch
[]byte, converts it to a string, and then does a substring replacement.
Instead, this CL does the replacement on the []byte into the scratch
space and then creates the final string.

Linking godoc without DWARF, best of ten, shows a ~10% improvement.

tip:           real 0m1.099s user 0m1.541s
this:          real 0m0.990s user 0m1.280s

This is part of an attempt to make suffixarray string deduping
come out as a wash, but it's not there yet:

cl/19987:      real 0m1.335s user 0m1.794s
cl/19987+this: real 0m1.225s user 0m1.540s

Change-Id: Idf061fdfbd7f08aa3a1f5933d3f111fdd1659210
Reviewed-on: https://go-review.googlesource.com/20025
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-29 19:30:48 +00:00
David Crawshaw
6d0b551931 cmd/link: track offset instead of using seek
The Cpos function is used frequently (at least once per symbol) and
it is implemented with the seek syscall. Instead, track current
output offset and use it.

Building the godoc binary with DWARF, best of ten:

tip:  real 0m1.287s user 0m1.573s
this: real 0m1.208s user 0m1.555s

Change-Id: I068148695cd6b4d32cd145db25e59e6f6bae6945
Reviewed-on: https://go-review.googlesource.com/20055
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-29 19:14:20 +00:00
Robert Griesemer
ed1a5e5da6 cmd/compile: cleanup number lexing
Change-Id: Ib0dd458d4ab1c58a2baf36491e288ac32e2ff99e
Reviewed-on: https://go-review.googlesource.com/19962
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-29 19:00:10 +00:00
David Crawshaw
36f25a7e7b cmd/link: allocate small []byte reads together
Reduces number of memory allocations by 12%:

Before: 1816664
After:  1581591

Small speed improvement.

Change-Id: I61281fb852e8e31851a350e3ae756676705024a4
Reviewed-on: https://go-review.googlesource.com/20027
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-29 18:45:35 +00:00
Shahar Kohanim
8096881927 cmd/link: batch allocations of Lsym
Reduces best of 10 linking of cmd/go by ~5%

Change-Id: If673b877ee12595dae517d7eb48430451e5cadba
Reviewed-on: https://go-review.googlesource.com/20060
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-29 17:32:11 +00:00
Shahar Kohanim
e0b04fa508 cmd/link: Preallocate Lsym map
Preallocate ~2MB for Lsym map (size calculation from http://play.golang.org/p/9L7F5naXRr).
Reduces best of 10 link time of cmd/go by ~4%.
On cmd/go max resident size unaffected, on println hello world max resident size grows by 4mb from 18mb->22mb. Performance improves in both cases.

tip:  real  0m1.283s user  0m1.502s sys 0m0.144s
this: real  0m1.341s user  0m1.598s sys 0m0.136s

Change-Id: I4a95e45fe552f1f64f53e868421b9f45a34f8b96
Reviewed-on: https://go-review.googlesource.com/19979
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-02-29 17:30:13 +00:00
Benoit Sigoure
21f2cb60ea syscall: Fix generator for Linux syscalls.
In golang.org/cl/14449 the `getdents' system call got changed to use
_SYS_getdents as a layer of indirection instead of SYS_GETDENTS64 for
compatibility with mips64, but this broke mksyscall.pl, which then
died with with:
  syscall_linux.go:840: malformed //sys declaration

Change-Id: Icb61965d8730f6e81f9fb0fa28c7bab635470f09
Reviewed-on: https://go-review.googlesource.com/20051
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-29 17:28:00 +00:00
Ilya Tocar
5c5fa3628c [dev.ssa] cmd/compile/internal/ssa: replace load of store with a copy
This is a AMD64 version of CL19743.
Saves additional 1574 bytes in go binary.
This also speeds up bzip2 by 1-4%

Change-Id: I031ba423663c4e83fdefe44e5296f24143e303da
Reviewed-on: https://go-review.googlesource.com/19939
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-29 14:29:28 +00:00
Ilya Tocar
1b1d0a9a80 [dev.ssa] cmd/compile: Use movups for xmm->xmm mov
Movups is 1 byte smaller than movapd that we currently use.

Change-Id: I22f771f066529352722a28543535ec43497cb9c5
Reviewed-on: https://go-review.googlesource.com/19938
Reviewed-by: David Chase <drchase@google.com>
2016-02-29 14:23:44 +00:00
Brad Fitzpatrick
351c15f1ce all: remove public named return values when useless
Named returned values should only be used on public funcs and methods
when it contributes to the documentation.

Named return values should not be used if they're only saving the
programmer a few lines of code inside the body of the function,
especially if that means there's stutter in the documentation or it
was only there so the programmer could use a naked return
statement. (Naked returns should not be used except in very small
functions)

This change is a manual audit & cleanup of public func signatures.

Signatures were not changed if:

* the func was private (wouldn't be in public godoc)
* the documentation referenced it
* the named return value was an interesting name. (i.e. it wasn't
  simply stutter, repeating the name of the type)

There should be no changes in behavior. (At least: none intended)

Change-Id: I3472ef49619678fe786e5e0994bdf2d9de76d109
Reviewed-on: https://go-review.googlesource.com/20024
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-02-29 03:31:19 +00:00
Shenghou Ma
28ce6f3600 time: document Tick will return nil if d <= 0
Fixes #14557.

Change-Id: I9610b79aafe9c15f9c998739b586fd0b41b90d70
Reviewed-on: https://go-review.googlesource.com/20031
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-29 02:33:26 +00:00
Josh Bleecher Snyder
1b417e20ff cmd/compile: superficial cleanup in maplit
Mostly renaming variables for clarity.

Passes toolstash -cmp.

Change-Id: I9867137c34c14985cbbbdb2d34fbbe4cc65cb6fb
Reviewed-on: https://go-review.googlesource.com/20023
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-29 02:17:58 +00:00
Ian Lance Taylor
1d5001afef cmd/compile: change Node.Nbody, Func.Inl from *NodeList to Nodes
Passes toolstash -cmp.

Casual timings show about a 3% improvement in compile times.

Update #14473.

Change-Id: I584add2e8f1a52486ba418b25ba6122b7347b643
Reviewed-on: https://go-review.googlesource.com/19989
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-29 00:33:32 +00:00
Martin Möhrmann
75cc05fa55 fmt: fix formatting of numbers with f.space and f.plus specified
Do not replace the sign in front of a number with a space if both
f.space and f.plus are both specified for number formatting.
This was already the case for integers but not for floats
and complex numbers.

Updates: #14543.

Change-Id: I07ddeb505003db84a8a7d2c743dc19fc427a00bd
Reviewed-on: https://go-review.googlesource.com/19974
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-02-29 00:17:07 +00:00
Ian Lance Taylor
f5ab890c18 cmd/go: only check SWIG intsize once per build
Besides being more efficient in a large build, this avoids a possible
race when creating the input file.

Change-Id: Ifc2cb055925a76be9c90eac56d84ebd9e14f2bbc
Reviewed-on: https://go-review.googlesource.com/19392
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2016-02-29 00:08:51 +00:00
David Chase
8107b0012f [dev.ssa] cmd/compile: use 32-bit load to read writebarrier
Avoid targeting a partial register with load;
ensure source of load (writebarrier) is aligned.

Better yet would be "CMPB $1,writebarrier" but that requires
wrestling with flagalloc (mem operand complicates moving
instruction around).

Didn't see a change in time for
   benchcmd -n 10 Build go build net/http

Verified that we clean the code up properly:
   0x20a8 <main.main+104>:	mov    0xc30a2(%rip),%eax
                            # 0xc5150 <runtime.writeBarrier>
   0x20ae <main.main+110>:	test   %al,%al

Change-Id: Id5fb8c260eaec27bd727cb0ae1476c60343b0986
Reviewed-on: https://go-review.googlesource.com/19998
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-28 22:29:23 +00:00
David Chase
34f048c9d9 [dev.ssa] cmd/compile: small optimization to prove using sdom tweak
Exposed data already in sdom to avoid recreating it in prove.

Change-Id: I834c9c03ed8faeaee013e5a1b3f955908f0e0915
Reviewed-on: https://go-review.googlesource.com/19999
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alexandru Moșoi <alexandru@mosoi.ro>
2016-02-28 22:28:24 +00:00
Tamir Duberstein
622780b1c1 crypto/tls: don't log expected errors in test
This is minor cleanup that reduces test output noise.

Change-Id: Ib6db4daf8cb67b7784b2d5b222fa37c7f78a6a04
Reviewed-on: https://go-review.googlesource.com/19997
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-28 20:36:38 +00:00
Alexandru Moșoi
bdea1d58cf [dev.ssa] cmd/compile/internal/ssa: remove proven redundant controls.
* It does very simple bounds checking elimination. E.g.
removes the second check in for i := range a { a[i]++; a[i++]; }
* Improves on the following redundant expression:
return a6 || (a6 || (a6 || a4)) || (a6 || (a4 || a6 || (false || a6)))
* Linear in the number of block edges.

I patched in CL 12960 that does bounds, nil and constant propagation
to make sure this CL is not just redundant. Size of pkg/tool/linux_amd64/*
(excluding compile which is affected by this change):

With IsInBounds and IsSliceInBounds
-this -12960 92285080
+this -12960 91947416
-this +12960 91978976
+this +12960 91923088

Gain is ~110% of 12960.

Without IsInBounds and IsSliceInBounds (older run)
-this -12960 95515512
+this -12960 95492536
-this +12960 95216920
+this +12960 95204440

Shaves 22k on its own.

* Can we handle IsInBounds better with this? In
for i := range a { a[i]++; } the bounds checking at a[i]
is not eliminated.

Change-Id: I98957427399145fb33693173fd4d5a8d71c7cc20
Reviewed-on: https://go-review.googlesource.com/19710
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-28 19:48:20 +00:00
Tamir Duberstein
186d3e30be crypto/tls: tests prefer constants to opaque literals
This is minor cleanup that makes the tests more readable.

Change-Id: I9f1f98f0f035096c284bdf3501e7520517a3e4d9
Reviewed-on: https://go-review.googlesource.com/19993
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-28 19:31:48 +00:00
Justin Nuß
92408107dc mime: Fix BenchmarkQDecodeHeader to call DecodeHeader
Found this while reading through the code. The benchmark
accidently called the wrong function.

Change-Id: Idb88aa71e7098a4e29e7f5f39e64f8c5f8936a2a
Reviewed-on: https://go-review.googlesource.com/19977
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-28 17:24:01 +00:00
Todd Neal
4e95dfed01 [dev.ssa] cmd/compile: add max arg length to opcodes
Add the max arg length to opcodes and use it in zcse.  Doesn't affect
speed, but allows better checking in checkFunc and removes the need
to keep a list of zero arg opcodes up to date.

Change-Id: I157c6587154604119720ec6228b767b6e52bb5c7
Reviewed-on: https://go-review.googlesource.com/19994
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-28 14:50:19 +00:00
Joe Tsai
ff27421067 compress/bzip2: fix benchmark to actually measure decompression rate
Motivation:
* Previously, the size of the compressed data was used for metrics,
rather than the uncompressed size. This causes the library to appear
to perform poorly relative to C or other implementation. Switch it
to use the uncompressed size so that it matches how decompression
benchmarks are usually done (like in compress/flate). This also makes
it easier to compare bzip2 rates to other algorithms since they measure
performance in this way.
* Also, reset the timer after doing initialization work.

Change-Id: I32112c2ee8e7391e658c9cf31039f70a689d9b9d
Reviewed-on: https://go-review.googlesource.com/17611
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-28 11:06:40 +00:00
Joe Tsai
47379929f1 compress/bzip2: use correct block size
The bzip2 block size is a multiple of 100*1000 not 100*1024.
Thus, the bzip2 decoder would incorrectly decode files with larger
block sizes when it should have otherwise failed.
Fortunately, we can correct this in a backwards compatible way since
Go has no implementation of a bzip2 encoder to produce bad blocks :)

To confirm that the C bzip2 utlity chokes on this data:
	$ echo "425a683131415926535936dc55330063ffc0006000200020a40830008b00
	08b8bb9229c28481b6e2a998" | xxd -r -p | bzip2 -d

	bzip2: Data integrity error when decompressing.

Fixes #13941

Change-Id: I2402e8829a8027ef94dd4fac050b200440a3d4e4
Reviewed-on: https://go-review.googlesource.com/20011
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-28 10:54:03 +00:00
Joe Tsai
5fc4decd10 compress/flate: extract LZ77 dictionary logic into seperate struct
The LZ77 portion of DEFLATE is relatively self-contained. For the
decompression side of things, we extract this logic out for the
following reasons:
* It is easier to test just the LZ77 portion of the logic.
* It reduces the noise in the inflate.go

Also, we adjust the way that callbacks are handled in the inflate.
Instead of using functions to abstract the logical componets of
huffmanBlock(), use goto statements to jump between the necessary
sections. This is faster since it avoids a function call and is
arguably more readable.

benchmark                              old MB/s     new MB/s     speedup
BenchmarkDecodeDigitsSpeed1e4-4        53.62        60.11        1.12x
BenchmarkDecodeDigitsSpeed1e5-4        61.90        69.07        1.12x
BenchmarkDecodeDigitsSpeed1e6-4        63.24        70.58        1.12x
BenchmarkDecodeDigitsDefault1e4-4      54.10        59.00        1.09x
BenchmarkDecodeDigitsDefault1e5-4      69.50        74.07        1.07x
BenchmarkDecodeDigitsDefault1e6-4      71.54        75.85        1.06x
BenchmarkDecodeDigitsCompress1e4-4     54.39        58.94        1.08x
BenchmarkDecodeDigitsCompress1e5-4     69.21        73.96        1.07x
BenchmarkDecodeDigitsCompress1e6-4     71.14        75.75        1.06x
BenchmarkDecodeTwainSpeed1e4-4         53.15        58.13        1.09x
BenchmarkDecodeTwainSpeed1e5-4         66.56        72.29        1.09x
BenchmarkDecodeTwainSpeed1e6-4         69.13        75.11        1.09x
BenchmarkDecodeTwainDefault1e4-4       56.00        60.23        1.08x
BenchmarkDecodeTwainDefault1e5-4       77.84        82.27        1.06x
BenchmarkDecodeTwainDefault1e6-4       82.07        86.85        1.06x
BenchmarkDecodeTwainCompress1e4-4      56.13        60.38        1.08x
BenchmarkDecodeTwainCompress1e5-4      78.23        82.62        1.06x
BenchmarkDecodeTwainCompress1e6-4      82.38        86.73        1.05x

Change-Id: I8c6ae0e6bed652dd0570fc113c999977f5e71636
Reviewed-on: https://go-review.googlesource.com/16528
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-28 10:36:01 +00:00
Caio Marcelo de Oliveira Filho
3cb870d47b testing: make failure in benchmark cause non-zero exit status
Moves the implementation of RunBenchmarks to a non-exported function
that returns whether the execution was OK, and uses that to identify
failure in benchmarks.The exported function is kept for compatibility.

Like before, benchmarks will only be executed if tests and examples
pass. The PASS message will not be printed if there was a failure in
a benchmark.

Example output

	BenchmarkThatCallsFatal-8	--- FAIL: BenchmarkThatCallsFatal-8
		x_test.go:6: called by benchmark
	FAIL
	exit status 1
	FAIL	_/.../src/cmd/go/testdata/src/benchfatal	0.009s

Fixes #14307.

Change-Id: I6f3ddadc7da8a250763168cc099ae8b325a79602
Reviewed-on: https://go-review.googlesource.com/19889
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-28 05:19:05 +00:00
Ian Lance Taylor
c8ef0df06c cmd/cgo: add hooks for thread sanitizer
When Go code is used with C code compiled with -fsanitize=thread, adds
thread sanitizer calls so that correctly synchronized Go code does not
cause spurious failure reports from the thread sanitizer.  This may
cause some false negatives, but for the thread sanitizer what is most
important is avoiding false positives.

Change-Id: If670e4a6f2874c7a2be2ff7db8728c6036340a52
Reviewed-on: https://go-review.googlesource.com/17421
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2016-02-28 04:56:17 +00:00
Austin Clements
d62d831882 runtime: clean up adjustpointer and eliminate write barrier
Commit a5c3bbe modified adjustpointers to use *uintptrs instead of
*unsafe.Pointers for manipulating stack pointers for clarity and to
eliminate the unnecessary write barrier when writing the updated stack
pointer.

This commit makes the equivalent change to adjustpointer.

Change-Id: I6dc309590b298bdd86ecdc9737db848d6786c3f7
Reviewed-on: https://go-review.googlesource.com/17148
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-28 04:19:01 +00:00
Ian Lance Taylor
71cc445cf9 cmd/cgo: recognize known C typedefs as types
Fixes #14483.

Change-Id: I0cddfe27fd8d00ba85659d0b618410e39ebf45cb
Reviewed-on: https://go-review.googlesource.com/19860
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-27 22:51:51 +00:00
Ian Lance Taylor
922ce58de0 cmd/compile: change Func.Cvars to the new Nodes type
Update #14473.

Change-Id: Iba1ecf42d9ab5a93144941439d5cc6b0b4f4a3ac
Reviewed-on: https://go-review.googlesource.com/19992
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-27 22:43:26 +00:00
Martin Möhrmann
7da4ceddd0 fmt: simplify buffer write methods and adjust calls to them
Once upon a time fmt did use bytes.Buffer for its buffer.
The buffer write methods still mimic the bytes.Buffer signatures.
The current code depends on manipulating the buffer []bytes array directly
which makes going back to bytes.Buffer by only changing the type of buffer
impossible. Since type buffer is not exported the methods can be simplified
to the needs of fmt. This saves space and avoids unnecessary overhead.

Use WriteString instead of Write for known inputs since
WriteString is faster than Write to append the same data.
This also saves space in the binary.

Remove the add method from Printer and depending on the data to be written
use WriteRune or WriteByte directly instead.

In total makes the go binary around 4 kilobyte smaller.

name                  old time/op  new time/op  delta
SprintfEmpty-2        24.1ns ± 3%  23.8ns ± 1%  -1.14%  (p=0.000 n=20+20)
SprintfString-2        114ns ± 2%   114ns ± 4%    ~     (p=0.558 n=20+19)
SprintfInt-2           116ns ± 9%   118ns ± 7%    ~     (p=0.086 n=20+20)
SprintfIntInt-2        195ns ± 6%   193ns ± 5%    ~     (p=0.345 n=20+19)
SprintfPrefixedInt-2   251ns ±16%   241ns ± 9%  -3.69%  (p=0.024 n=20+19)
SprintfFloat-2         203ns ± 4%   205ns ± 5%    ~     (p=0.153 n=20+20)
SprintfBoolean-2       101ns ± 7%    96ns ±11%  -5.23%  (p=0.005 n=19+20)
ManyArgs-2             651ns ± 7%   628ns ± 7%  -3.44%  (p=0.002 n=20+20)
FprintInt-2            164ns ± 2%   158ns ± 2%  -3.62%  (p=0.000 n=20+18)
FprintfBytes-2         215ns ± 1%   216ns ± 1%  +0.58%  (p=0.000 n=20+20)
FprintIntNoAlloc-2     115ns ± 0%   112ns ± 0%  -2.61%  (p=0.000 n=20+20)
ScanInts-2             700µs ± 0%   702µs ± 1%  +0.38%  (p=0.000 n=18+20)
ScanRecursiveInt-2    82.7ms ± 0%  82.7ms ± 0%    ~     (p=0.820 n=20+20)

Change-Id: I0409eb170b8a26d9f4eb271f6292e5d39faf2d8b
Reviewed-on: https://go-review.googlesource.com/19955
Reviewed-by: Rob Pike <r@golang.org>
2016-02-27 21:12:19 +00:00
Justin Nuß
9d73a6dcad strconv: Avoid allocation in AppendQuote*
The current implementations of the AppendQuote functions use quoteWith
(through Quote) for quoting the given value and appends the returned
string to the dst byte slice. quoteWith internally creates a byte slice
on each call which gets converted to a string in Quote.

This means the AppendQuote functions always allocates a new byte slice
and a string only to append them to an existing byte slice. In the case
of (Append)QuoteRune the string passed to quoteWith will also needs to
be allocated from a rune first.

Split quoteWith into two functions (quoteWith and appendQuotedWith) and
replace the call to Quote inside AppendQuote with appendQuotedWith,
which appends directly to the byte slice passed to AppendQuote and also
avoids the []byte->string conversion.

Also introduce the 2 functions quoteRuneWith and appendQuotedRuneWith
that work the same way as quoteWith and appendQuotedWith, but take a
single rune instead of a string, to avoid allocating a new string when
appending a single rune, and use them in (Append)QuoteRune.

Also update the ToASCII and ToGraphic variants to use the new functions.

Benchmark results:

benchmark                      old ns/op     new ns/op     delta
BenchmarkQuote-8               428           503           +17.52%
BenchmarkQuoteRune-8           148           105           -29.05%
BenchmarkAppendQuote-8         435           307           -29.43%
BenchmarkAppendQuoteRune-8     158           23.5          -85.13%

benchmark                      old allocs     new allocs     delta
BenchmarkQuote-8               3              3              +0.00%
BenchmarkQuoteRune-8           3              2              -33.33%
BenchmarkAppendQuote-8         3              0              -100.00%
BenchmarkAppendQuoteRune-8     3              0              -100.00%

benchmark                      old bytes     new bytes     delta
BenchmarkQuote-8               144           144           +0.00%
BenchmarkQuoteRune-8           16            16            +0.00%
BenchmarkAppendQuote-8         144           0             -100.00%
BenchmarkAppendQuoteRune-8     16            0             -100.00%

Change-Id: I77c148d5c7242f1b0edbbeeea184878abb51a522
Reviewed-on: https://go-review.googlesource.com/18962
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-27 17:15:01 +00:00
Mikio Hara
f3f920ff8d crypto/tls: don't send IPv6 literals and absolute FQDNs as SNI values
This is a followup change to #13111 for filtering out IPv6 literals and
absolute FQDNs from being as the SNI values.

Updates #13111.
Fixes #14404.

Change-Id: I09ab8d2a9153d9a92147e57ca141f2e97ddcef6e
Reviewed-on: https://go-review.googlesource.com/19704
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-27 10:05:53 +00:00
Martin Möhrmann
abcad1e59d fmt: change padding functions to avoid package init
Move the decision if zero padding is allowed to doPrintf
where the other formatting decisions are made.

Removes some dead code for negative f.wid that was never used
due to f.wid always being positive and f.minus deciding if left
or right padding should be used.

New padding code writes directly into the buffer and is as fast
as the old version but avoids the cost of needing package init.

name              old time/op  new time/op  delta
SprintfPadding-2   246ns ± 5%   245ns ± 4%   ~     (p=0.345 n=50+47)

Change-Id: I7dfddbac8e328f4ef0cdee8fafc0d06c784b2711
Reviewed-on: https://go-review.googlesource.com/19957
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-02-27 06:59:39 +00:00
Matthew Dempsky
8b96bc6818 cmd/compile: remove unneeded test binary
Accidentally added in https://golang.org/cl/19968.

Change-Id: Id70917c4d1f69db149688d797c90a19557d16f72
Reviewed-on: https://go-review.googlesource.com/19985
Reviewed-by: Minux Ma <minux@golang.org>
2016-02-27 06:17:36 +00:00
David du Colombier
ccf39a23b1 debug/gosym: fix TestPCLine on Plan 9
Plan 9 doesn't define main, so the INITENTRY
symbol remains with the SXREF type, which leads
Entryvalue to fail on "entry not text: main".

Fixes #14536.

Change-Id: Id9b7d61e5c2202aba3ec9cd52f5b56e0a38f7c47
Reviewed-on: https://go-review.googlesource.com/19973
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-27 05:13:33 +00:00
Keith Randall
91f69c675d [dev.ssa] cmd/compile: with -N, don't put JMPs after calls
plive doesn't like the fact that we put JMPs right
after CALL ops to select{send,recv}.

Fixes SSA -N build.

Change-Id: I9b3c9e5293196094fd5a6206dd2f99784951f7a9
Reviewed-on: https://go-review.googlesource.com/19982
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-27 02:42:19 +00:00
Matthew Dempsky
52f099c426 cmd/compile: simplify lexinit and lexfini
Split the syms array into separate basicTypes and builtinFuncs arrays.

Also, in lexfini, instead of duplicating the code from lexinit to
declare the builtin identifiers in the user package, just import them
from builtinpkg like how importdot works.

Change-Id: Ic3b3b454627a46f7bd5f290d0e31443e659d431f
Reviewed-on: https://go-review.googlesource.com/19936
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-27 01:02:25 +00:00
Ian Lance Taylor
188e3d2515 cmd/compile: change Func.{Enter,Exit} from NodeList to slice
Introduces a new types Nodes that can be used to replace NodeList.

Update #14473.

Change-Id: Id77c5dcae0cbeb898ba12dd46bd400aad408871c
Reviewed-on: https://go-review.googlesource.com/19969
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-27 00:59:47 +00:00
Martin Möhrmann
6520da6ed5 fmt: use public io.RuneScanner interface for ScanState reader
All io.Reader that are passed to newScanState in all the standard
library tests that implement io.RuneReader also implement io.RuneScanner.

Do not check on each call ScanState's UnreadRune that the used RuneReader
also implements the UnreadRune method by using a private interface.
Instead require the used Reader to implement the public RuneScanner
interface.

The extra implementation logic for UnreadRune is removed from ScanState.
Instead the readRune wrapper is extended to implement UnreadRune for the
RuneScanner interface. If the Reader passed to newScanstate does not
implement RuneScanner the readRune wrapper is used to implement the
missing functionality.

Note that a RuneReader that does not implement RuneScanner will also
be wrapped by runeRead which was not the case before.
Performance with the readRune wrapper is better than without before.

Add benchmark to compare performance with and without using the
readRune wrapper.

name                             old time/op  new time/op  delta
ScanInts-2                        704µs ± 0%   615µs ± 1%  -12.73%  (p=0.000 n=20+20)
ScanRecursiveInt-2               82.6ms ± 0%  51.4ms ± 0%  -37.71%  (p=0.000 n=20+20)
ScanRecursiveIntReaderWrapper-2  85.1ms ± 0%  52.4ms ± 0%  -38.36%  (p=0.000 n=20+20)

Change-Id: I8c6e85db9b87a8171caab12f020b6e256b498e81
Reviewed-on: https://go-review.googlesource.com/19895
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-02-26 23:46:51 +00:00
Josh Bleecher Snyder
b30e1d728c cmd/compile: consolidate alg code
Pull all alg-related code into its own file.
subr.go is a Hobbesian Leviathan.

100% code movement. Cleanup and improvements to follow.

Change-Id: Ib9c8f66563fdda90c6e8cf646d366a9487a4648d
Reviewed-on: https://go-review.googlesource.com/19980
Reviewed-by: Dave Cheney <dave@cheney.net>
Run-TryBot: Dave Cheney <dave@cheney.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-26 23:39:01 +00:00
Matthew Dempsky
f5f8b38462 cmd/compile: eliminate prectab
While here, merge LINC and LDEC into LINCOP.

Fixes #13244.

Change-Id: I8ea426f986d60d35c3b1a80c056a7aa49d22d802
Reviewed-on: https://go-review.googlesource.com/19928
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-26 23:12:43 +00:00
Ian Lance Taylor
6abc8c9a88 cmd/compile: change Func.Inldcl from []*Node to *[]*Node
Save a few bytes in Func.

Passes toolstash -cmp.

Update #14473.

Change-Id: I824fa7d5cb2d93f6f59938ccd86114abcbea0043
Reviewed-on: https://go-review.googlesource.com/19968
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-26 22:45:21 +00:00
Ian Lance Taylor
52d9479e3b cmd/compile: convert Func.Cvars from *NodeList to *[]*Node
Passes toolstash -cmp.

Update #14473.

Change-Id: I7285175b1992a29033fdc9e81d6f30545e5cc30d
Reviewed-on: https://go-review.googlesource.com/19967
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-26 22:38:44 +00:00
Josh Bleecher Snyder
92bf58c238 cmd/compile: recognize more memory runs in generated algs
The old implementation assumed that all memory runs
were terminated by non-memory fields.
This isn't necessarily so.
They might be terminated by padding or blank fields.

For example, given

type T struct {
	a int64
	b byte
	c, d, e int64
}

the old implementation did a memory comparison on a+b, on c, and on d+e.

Instead, check for memory runs at the beginning of every round.
This now generates a memory comparison on a+b and on c+d+e.

Also, delete some now-dead code.

Change-Id: I66bffb111420adf6919bd708e4fb3a1e1f07fadd
Reviewed-on: https://go-review.googlesource.com/19841
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-02-26 22:18:30 +00:00
Josh Bleecher Snyder
0f5d78f678 cmd/compile: factor shared code from geneq and genhash
Passes toolstash -cmp.

Change-Id: Ifae69e5ba673f01da3dfc1fd30cdc51873481623
Reviewed-on: https://go-review.googlesource.com/19840
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-02-26 22:17:31 +00:00
Robert Griesemer
3c0fae5306 cmd/compile: track pragmas in lexer rather than global variables
By using a Pragma bit set (8 bits) rather than 8 booleans, also
reduce Func type size by 8 bytes (208B -> 200B on 64bit platforms,
116B -> 108B on 32bit platforms).

Change-Id: Ibb7e1f8c418a0b5bc6ff813cbdde7bc6f0013b5a
Reviewed-on: https://go-review.googlesource.com/19966
Reviewed-by: Dave Cheney <dave@cheney.net>
2016-02-26 22:01:16 +00:00
Matthew Dempsky
071e43a958 cmd/compile: stop representing keywords as Syms
Instead add a dedicated keywords map for use in lexer.ident and drop
Sym's Lexical field.

Change-Id: Ia668e65499035ff7167fabbbd0cd027102b21231
Reviewed-on: https://go-review.googlesource.com/19935
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-26 21:25:59 +00:00
Matthew Dempsky
af558acc47 cmd/compile: fix contrived line number errors
If a general comment contains multiple newline characters, we can't
simply unread one and then re-lex it via the general whitespace lexing
phase, because then we'll reset lineno to the line before the "*/"
marker, rather than keeping it where we found the "/*" marker.

Also, for processing imports, call importfile before advancing the
lexer with p.next(), so that lineno reflects the line where we found
the import path, and not the token afterwards.

Fixes #14520.

Change-Id: I785a2d83d632280113d4b757de0d57c88ba2caf4
Reviewed-on: https://go-review.googlesource.com/19934
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-26 21:25:43 +00:00
Ian Lance Taylor
a131a66e63 cmd/compile: create test binary in temp directory
The new TestDashS was leaving a dreg "test" file in
cmd/compile/internal/gc.  Create it in the temporary directory instead.

Also change path.Join to filepath.Join throughout global_test.go.

Change-Id: Ib7707fada2b3ab5e8abc2ba74e4c402821c1408b
Reviewed-on: https://go-review.googlesource.com/19965
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-26 21:24:42 +00:00
Ian Lance Taylor
b66a892358 cmd/compile: change Func.{Dcl,Inldcl} from NodeList to slice
A slice uses less memory than a NodeList, and has better memory locality
when walking the list.

This uncovered a tricky case involving closures: the escape analysis
pass when run on a closure was appending to the Dcl list of the OCLOSURE
rather than the ODCLFUNC.  This happened to work because they shared the
same NodeList.  Fixed with a change to addrescapes, and a check to
Tempname to catch any recurrences.

This removes the last use of the listsort function outside of tests.
I'll send a separate CL to remove it.

Unfortunately, while this passes all tests, it does not pass toolstash
-cmp.  The problem is that cmpstackvarlt does not fully determine the
sort order, and the change from listsort to sort.Sort, while generally
desirable, produces a different ordering.  I could stage this by first
making cmpstackvarlt fully determined, but no matter what toolstash -cmp
is going to break at some point.

In my casual testing the compiler is 2.2% faster.

Update #14473.

Change-Id: I367d66daa4ec73ed95c14c66ccda3a2133ad95d5
Reviewed-on: https://go-review.googlesource.com/19919
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-26 20:43:23 +00:00
Matthew Dempsky
67dbde0d71 cmd: stop looking for __.(GO)?SYMDEF entries in archives
The Go toolchain stopped creating them before Go 1.3, so no point in
worrying about them today.

History:

- Git commit 250a091 added cmd/ar, which wrote Plan 9 __.SYMDEF
entries into archive files.

- golang.org/cl/6500117 renamed __.SYMDEF to __.GOSYMDEF.  (Notably,
the commit message suggests users need to use Go nm to read symbols,
but even back then the toolchain did nothing with __.(GO)?SYMDEF files
except skip over them.)

- golang.org/cl/42880043 added the -pack flag to cmd/gc to directly
produce archives by the Go compiler, and did not write __.GOSYMDEF
entries.

- golang.org/cl/52310044 rewrote cmd/pack in Go, and removed support
for producing __.GOSYMDEF entries.

Change-Id: I255edf40d0d3690e3447e488039fcdef73c6d6b1
Reviewed-on: https://go-review.googlesource.com/19924
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-26 20:26:17 +00:00
Richard Miller
5c613e9162 sync/atomic: new file for plan9_arm support
Atomic load/store/add/swap routines, as for other ARM platforms, but with DMB inserted
for load/store (assuming that "atomic" also implies acquire/release memory ordering).

Change-Id: I70a283d8f0ae61a66432998ce59eac76fd940c67
Reviewed-on: https://go-review.googlesource.com/18965
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-26 20:16:34 +00:00
Caio Marcelo de Oliveira Filho
5c72c6f889 cmd/go: show position in error for wrong signature in test functions
Change-Id: Ie915dc2fc32a31d31f566ac931ccecb506559645
Reviewed-on: https://go-review.googlesource.com/19888
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-26 20:13:44 +00:00
Matt T. Proud
0ccabe2e0b testing/quick: generate more map and slice states
This change adds support in testing/quick to generate maps and slices
in additional states:

  (1.) nil maps

  (2.) nil slices

  (3.) empty slice occupancy: `len(s) == 0 && s != nil`

  (4.) partial slice occupancy: `len(s) < cap(s) && s != nil`

  (5.) full slice occupancy: `len(s) == cap(s) && s != nil`

Prior to this, only #5 was ever generated, thereby not sufficiently
exercising all of the fuzzable code path outcomes.

This change depends on https://go-review.googlesource.com/#/c/17499/.

Change-Id: I9343c475cefbd72ffc5237281826465c25872206
Reviewed-on: https://go-review.googlesource.com/16470
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-26 20:04:04 +00:00
Richard Miller
763e8fcc89 syscall: new files for plan_arm support
Implementation closely follows plan9_386 version.

Change-Id: Ifb76e001fb5664e6a23541cf4768d7f11b2be68b
Reviewed-on: https://go-review.googlesource.com/18967
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-26 20:03:16 +00:00
Michael McConville
ddfe7b3dc0 crypto/rand: use the getentropy syscall on OpenBSD
Go already supports Linux's getrandom, which is a slightly modified
version of getentropy.

getentropy was added in OpenBSD 5.6. All supported versions of OpenBSD
include it so, unlike with Linux and getrandom, we don't need to test
for its presence.

Fixes #13785.

Change-Id: Ib536b96675f257cd8c5de1e3a36165e15c9abac9
Reviewed-on: https://go-review.googlesource.com/18219
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-26 19:58:09 +00:00
Keith Randall
c747fce242 cmd/internal/obj: Fix generation of assembly with -S
We can't drop Prog entries when we want to print disassembly.

Added a test for -S.

Fixes #14515

Change-Id: I44c72f70f7a3919acc01c559d30335d26669e76f
Reviewed-on: https://go-review.googlesource.com/19930
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-26 19:21:32 +00:00
Ian Lance Taylor
8d94b9b820 runtime: more deflaking of TestCgoCheckBytes
Fixes #14519.

Change-Id: I8f78f67a463e6467e09df90446f7ebd28789d6c9
Reviewed-on: https://go-review.googlesource.com/19933
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2016-02-26 19:20:47 +00:00
Caio Marcelo de Oliveira Filho
c2d3e1123c cmd/go: better error for test functions with wrong signature
Check the function types before compiling the tests. Extend the same
approach taken by the type check used for TestMain function.

To keep existing behavior, wrong arguments for TestMain are ignored
instead of causing an error.

Fixes #14226.

Change-Id: I488a2555cddb273d35c1a8c4645bb5435c9eb91d
Reviewed-on: https://go-review.googlesource.com/19763
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-26 17:00:30 +00:00
Dmitry Vyukov
e1035c5e87 sync/atomic: reduce test in short mode
In normal mode the test runs for 9+ seconds on my machine (48 cores).
But the real problem is race mode, in race mode it hits 10m test timeout.
Reduce test size in short mode. Now it runs for 100ms without race.

Change-Id: I9493a0e84f630b930af8f958e2920025df37c268
Reviewed-on: https://go-review.googlesource.com/19956
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-26 16:41:12 +00:00
Rick Arnold
9f26170a02 net/url: support query string without values
Previously, RawQuery was used to indicate the presence of a query
string in url.URL. However, this approach was not able to differentiate
between URLs that have no query string at all (http://foo.bar/) and
those that have a query with no values (http://foo.bar/?).

Add a ForceQuery field to indicate the latter form of URL and use it
in URL.String to create a matching URL with a trailing '?'.

Fixes #13488

Change-Id: Ifac663c73d35759bc6c33a00f84ab116b9b81684
Reviewed-on: https://go-review.googlesource.com/19931
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-26 16:13:26 +00:00
Dmitry Vyukov
bdc14698f8 runtime: unwire g/m in dropg always
Currently dropg does not unwire locked g/m.
This is unnecessary distiction between locked and non-locked g/m.
We always restart goroutines with execute which re-wires g/m.

First, this produces false sense that this distinction is necessary.
Second, it can confuse some sanity and cross checks. For example,
if we check that g/m are unwired before we wire them in execute,
the check will fail for locked g/m. I've hit this while doing some
race detector changes, When we deschedule a goroutine and run
scheduler code, m.curg is generally nil, but not for locked ms.

Remove the distinction.

Change-Id: I3b87a28ff343baa1d564aab1f821b582a84dee07
Reviewed-on: https://go-review.googlesource.com/19950
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-26 15:45:45 +00:00
Austin Clements
3b3d58e119 runtime: remove workbuf logging
Early in Go 1.5 we had bugs with ownership of workbufs, so we added a
system for tracing their ownership to help debug these issues.
However, this system has both CPU and space overhead even when
disabled, it clutters up the workbuf API, the higher level gcWork
abstraction makes it very difficult to mess up the ownership of
workbufs in practice, and the tracing hasn't been enabled or needed
since 5b66e5d nine months ago. Hence, remove it.

Benchmarks show the usual noise from changes at this level, but little
overall movement.

name              old time/op  new time/op  delta
XBenchGarbage-12  2.48ms ± 1%  2.47ms ± 0%  -0.68%  (p=0.000 n=21+21)

name                      old time/op    new time/op    delta
BinaryTree17-12              2.98s ± 7%     2.98s ± 6%    ~     (p=0.799 n=20+20)
Fannkuch11-12                2.61s ± 3%     2.55s ± 5%  -2.55%  (p=0.003 n=20+20)
FmtFprintfEmpty-12          52.8ns ± 6%    53.6ns ± 6%    ~     (p=0.228 n=20+20)
FmtFprintfString-12          177ns ± 4%     177ns ± 4%    ~     (p=0.280 n=20+20)
FmtFprintfInt-12             162ns ± 5%     162ns ± 3%    ~     (p=0.347 n=20+20)
FmtFprintfIntInt-12          277ns ± 7%     273ns ± 4%  -1.62%  (p=0.005 n=20+20)
FmtFprintfPrefixedInt-12     237ns ± 4%     242ns ± 4%  +2.13%  (p=0.005 n=20+20)
FmtFprintfFloat-12           315ns ± 4%     312ns ± 4%  -0.97%  (p=0.001 n=20+20)
FmtManyArgs-12              1.11µs ± 3%    1.15µs ± 4%  +3.41%  (p=0.004 n=20+20)
GobDecode-12                8.50ms ± 7%    8.53ms ± 7%    ~     (p=0.429 n=20+20)
GobEncode-12                6.86ms ± 9%    6.93ms ± 7%  +0.93%  (p=0.030 n=20+20)
Gzip-12                      326ms ± 4%     329ms ± 4%  +0.98%  (p=0.020 n=20+20)
Gunzip-12                   43.3ms ± 3%    43.8ms ± 9%  +1.25%  (p=0.003 n=20+20)
HTTPClientServer-12         72.0µs ± 3%    71.5µs ± 3%    ~     (p=0.053 n=20+20)
JSONEncode-12               17.0ms ± 6%    17.3ms ± 7%  +1.32%  (p=0.006 n=20+20)
JSONDecode-12               64.2ms ± 4%    63.5ms ± 3%  -1.05%  (p=0.005 n=20+20)
Mandelbrot200-12            4.00ms ± 3%    3.99ms ± 3%    ~     (p=0.121 n=20+20)
GoParse-12                  3.74ms ± 5%    3.75ms ± 9%    ~     (p=0.383 n=20+20)
RegexpMatchEasy0_32-12       104ns ± 4%     104ns ± 6%    ~     (p=0.392 n=20+20)
RegexpMatchEasy0_1K-12       358ns ± 3%     361ns ± 4%  +0.95%  (p=0.003 n=20+20)
RegexpMatchEasy1_32-12      86.3ns ± 5%    86.1ns ± 6%    ~     (p=0.614 n=20+20)
RegexpMatchEasy1_1K-12       523ns ± 4%     518ns ± 3%  -1.14%  (p=0.008 n=20+20)
RegexpMatchMedium_32-12      137ns ± 3%     134ns ± 4%  -1.90%  (p=0.005 n=20+20)
RegexpMatchMedium_1K-12     41.0µs ± 3%    40.6µs ± 4%  -1.11%  (p=0.004 n=20+20)
RegexpMatchHard_32-12       2.13µs ± 4%    2.11µs ± 5%  -1.31%  (p=0.014 n=20+20)
RegexpMatchHard_1K-12       64.1µs ± 3%    63.2µs ± 5%  -1.38%  (p=0.005 n=20+20)
Revcomp-12                   555ms ±10%     548ms ± 7%  -1.17%  (p=0.011 n=20+20)
Template-12                 84.2ms ± 5%    88.2ms ± 4%  +4.73%  (p=0.000 n=20+20)
TimeParse-12                 365ns ± 4%     371ns ± 5%  +1.77%  (p=0.002 n=20+20)
TimeFormat-12                361ns ± 4%     365ns ± 3%  +1.08%  (p=0.002 n=20+20)
[Geo mean]                  64.7µs         64.8µs       +0.19%

Change-Id: Ib043a7a0d18b588b298873d60913d44cd19f3b44
Reviewed-on: https://go-review.googlesource.com/19887
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-02-26 15:14:32 +00:00
David Crawshaw
0231f5420f cmd/compile: remove uncommonType.name
Reduces binary size of cmd/go by 0.5%.
For #6853.

Change-Id: I5a4b814049580ab5098ad252d979f80b70d8a5f9
Reviewed-on: https://go-review.googlesource.com/19694
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-26 12:02:39 +00:00
Datong Sun
c8ae2e82c7 crypto/x509: better documentation for ParsePKIXPublicKey
The existing documentation for ParsePKIXPublicKey is difficult to understand
and the return type of the parsed public key are not mentioned explicitly.

Descriptions about types of public key supported, as well as an example on
how to use type assertions to determine return type of a parsed public key
has been added.

Fixes #14355

Change-Id: Ib9561efb34255292735742c0b3e835c4b97ac589
Reviewed-on: https://go-review.googlesource.com/19757
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-26 06:36:10 +00:00
Matthew Dempsky
49d1e30710 cmd/compile, go/parser: simpler binary expression parsing
The existing nested loops are too tricky for me to grok and don't seem
necessary.

Change-Id: I75c65c8470b799d6f4cfb05bb1b4796c5d7d32e7
Reviewed-on: https://go-review.googlesource.com/19927
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-26 06:33:57 +00:00
Keith Randall
4a346e7489 [dev.ssa] cmd/compile: get rid of nil checks before float loads/stores
Just like we do for integer loads/stores.

Update #14511

Change-Id: Ic6ca6b54301438a5701ea5fb0be755451cb24d45
Reviewed-on: https://go-review.googlesource.com/19923
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Keith Randall <khr@golang.org>
2016-02-26 04:33:46 +00:00
Shenghou Ma
c8579e57cb build: use go tool dist list
Change-Id: I9b79bd301d0b75ca1f16d4a05e3cb687a8428c14
Reviewed-on: https://go-review.googlesource.com/19884
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-26 03:58:58 +00:00
Matthew Dempsky
a5b7a8d6dd cmd/compile: simplify error sorting
Errors have unique seq values (their index within the errors slice),
so errcmp never needs to fallback to sorting by message text.
Moreover, comparing by original index is exactly the purpose of using
a stable sort algorithm (and sort.Stable was added in Go 1.2), so we
really only need to compare by lineno.

Change-Id: I7f534b72a05d899ae9788dc7ef0541dd92a8b578
Reviewed-on: https://go-review.googlesource.com/19929
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-26 03:10:13 +00:00
Matthew Dempsky
e0fa809f4c cmd/compile: rationalize (lex)?lineno handling
Previously, many error messages inconsistantly used either lexlineno
and lineno.  In general this works out okay because they're almost
always the same.  The only exceptional case is after lexing a
multi-line raw string literal, where lineno will be the line number of
the opening quote and lexlineno is the line number of the closing
quote.

This CL makes the compiler's error message more consistent:

- Lexer error messages related to invalid byte sequences (i.e., NUL
bytes, bad UTF-8 sequences, and non-initial BOMs) are emitted at
lexlineno (i.e., the source line that contains the invalid byte
sequence).

- All other error messages (notably the parser's "syntax errors") now
use lineno.  The minor change from this is that bogus input like:

    package `
    bogus`

will emit "syntax error: unexpected string literal, expecting name"
error at line 1, instead of line 2.

- Instead of maintaining prevlineno all the time, just record it
when/where actually needed and not already available elsewhere (which
turns out to be just one function).

- Lastly, we remove the legacy "syntax error near ..." fallback in
Yerror, now that the parser always emits more detailed syntax error
messages.

Change-Id: Iaf5f784223d0385fa3a5b09ef2b2ad447feab02f
Reviewed-on: https://go-review.googlesource.com/19925
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-26 01:46:07 +00:00
Keith Randall
687abca1ea runtime: avoid using REP prefix for IndexByte
REP-prefixed instructions have a large startup cost.
Avoid them like the plague.

benchmark                  old ns/op     new ns/op     delta
BenchmarkIndexByte10-8     22.4          5.34          -76.16%

Fixes #13983

Change-Id: I857e956e240fc9681d053f2584ccf24c1b272bb3
Reviewed-on: https://go-review.googlesource.com/18703
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-26 01:09:53 +00:00
kortschak
a337e30620 cmd/dist: don't run fortran test if fortran compilation fails
Fixes #14498.

Change-Id: I4cfab3e45898466179cefbd31c6f7f796da82363
Reviewed-on: https://go-review.googlesource.com/19874
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-25 23:52:28 +00:00
Austin Clements
cbe849fc38 runtime: eliminate unused _Genqueue state
_Genqueue and _Gscanenqueue were introduced as part of the GC quiesce
code. The quiesce code was removed by 197aa9e, but these states and
some associated code stuck around. Remove them.

Change-Id: I69df81881602d4a431556513dac2959668d27c20
Reviewed-on: https://go-review.googlesource.com/19638
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-25 23:37:32 +00:00
Austin Clements
4eb33f6b8d runtime: eliminate a conditional branch from heapBits.bits
Change-Id: I1fa5e629b2890a8509559ce4ea17b74f47d71925
Reviewed-on: https://go-review.googlesource.com/19637
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-25 23:37:29 +00:00
Austin Clements
0168c2676f runtime: use only per-P gcWork
Currently most uses of gcWork use the per-P gcWork, but there are two
places that still use a stack-based gcWork. Simplify things by making
these instead use the per-P gcWork.

Change-Id: I712d012cce9dd5757c8541824e9641ac1c2a329c
Reviewed-on: https://go-review.googlesource.com/19636
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-25 23:37:27 +00:00
Austin Clements
7b229001e7 runtime: pass gcWork to markroot
Currently markroot uses a gcWork on the stack and disposes of it
immediately after marking one root. This used to be necessary because
markroot was called from the depths of parfor, but now that we call it
directly and have ready access to a gcWork at the call site, pass the
gcWork in, use it directly in markroot, and share it across calls to
markroot from the same P.

Change-Id: Id7c3b811bfb944153760e01873c07c8d18909be1
Reviewed-on: https://go-review.googlesource.com/19635
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
2016-02-25 23:37:25 +00:00
Austin Clements
98130b39f5 runtime: remove noescape hacks from gcWork
When gcWork was first introduced, the compiler's escape analysis
wasn't good enough to detect that that method receiver didn't escape,
so we had to hack around this.

Now that the compiler can figure out this for itself, remove these
hacks.

Change-Id: I9f73fab721e272410b8b6905b564e7abc03c0dfe
Reviewed-on: https://go-review.googlesource.com/19634
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-25 23:37:22 +00:00
Austin Clements
0d26efb12a runtime: remove unnecessary clears of the heap bitmap
Currently we clear the heap bitmap of a span both when we allocate
that span *and* when we free it. There's no point in doing both, and
we definitely have to write the heap bitmap when we allocate a span
for pointer-sized objects, so switch to clearing only when we allocate
a span.

This results in a slight overall performance improvement; however,
most of the benchmarks that get slower are very short, while the
longer benchmarks generally got faster.

name              old time/op  new time/op  delta
XBenchGarbage-12  2.48ms ± 1%  2.47ms ± 1%  -0.58%  (p=0.000 n=91+91)

name                      old time/op    new time/op    delta
BinaryTree17-12              2.85s ± 2%     2.85s ± 2%    ~     (p=0.550 n=20+19)
Fannkuch11-12                2.54s ± 0%     2.47s ± 1%  -2.72%  (p=0.000 n=19+18)
FmtFprintfEmpty-12          51.3ns ± 4%    51.0ns ± 3%    ~     (p=0.223 n=20+20)
FmtFprintfString-12          169ns ± 0%     167ns ± 0%  -1.18%  (p=0.000 n=17+16)
FmtFprintfInt-12             160ns ± 0%     161ns ± 0%  +0.63%  (p=0.000 n=16+15)
FmtFprintfIntInt-12          267ns ± 0%     269ns ± 1%  +0.62%  (p=0.000 n=17+20)
FmtFprintfPrefixedInt-12     234ns ± 1%     240ns ± 0%  +2.80%  (p=0.000 n=20+20)
FmtFprintfFloat-12           316ns ± 0%     313ns ± 0%  -0.76%  (p=0.000 n=20+19)
FmtManyArgs-12              1.04µs ± 0%    1.05µs ± 0%  +0.45%  (p=0.000 n=19+16)
GobDecode-12                7.90ms ± 1%    7.81ms ± 0%  -1.10%  (p=0.000 n=18+18)
GobEncode-12                6.61ms ± 1%    6.58ms ± 0%  -0.46%  (p=0.000 n=20+15)
Gzip-12                      320ms ± 1%     322ms ± 1%  +0.47%  (p=0.030 n=20+20)
Gunzip-12                   42.4ms ± 1%    42.6ms ± 0%  +0.37%  (p=0.000 n=20+20)
HTTPClientServer-12         70.7µs ± 1%    70.6µs ± 2%    ~     (p=0.784 n=18+20)
JSONEncode-12               16.9ms ± 1%    16.8ms ± 0%  -0.64%  (p=0.000 n=20+20)
JSONDecode-12               60.8ms ± 0%    58.6ms ± 1%  -3.50%  (p=0.000 n=17+18)
Mandelbrot200-12            3.92ms ± 0%    3.91ms ± 0%  -0.25%  (p=0.000 n=19+19)
GoParse-12                  3.65ms ± 0%    3.68ms ± 1%  +0.67%  (p=0.000 n=17+16)
RegexpMatchEasy0_32-12       102ns ± 1%     102ns ± 2%  +0.67%  (p=0.009 n=19+19)
RegexpMatchEasy0_1K-12       350ns ± 0%     351ns ± 1%  +0.34%  (p=0.002 n=20+20)
RegexpMatchEasy1_32-12      84.1ns ± 2%    84.2ns ± 2%    ~     (p=0.799 n=20+18)
RegexpMatchEasy1_1K-12       510ns ± 1%     508ns ± 1%  -0.45%  (p=0.000 n=20+17)
RegexpMatchMedium_32-12      132ns ± 1%     134ns ± 1%  +0.85%  (p=0.000 n=20+19)
RegexpMatchMedium_1K-12     40.0µs ± 1%    39.9µs ± 1%  -0.29%  (p=0.014 n=19+18)
RegexpMatchHard_32-12       2.09µs ± 1%    2.05µs ± 0%  -1.76%  (p=0.000 n=20+18)
RegexpMatchHard_1K-12       62.7µs ± 1%    61.8µs ± 1%  -1.39%  (p=0.000 n=20+19)
Revcomp-12                   541ms ± 1%     534ms ± 0%  -1.16%  (p=0.000 n=19+20)
Template-12                 71.1ms ± 0%    69.1ms ± 0%  -2.83%  (p=0.000 n=18+19)
TimeParse-12                 356ns ± 0%     357ns ± 0%  +0.36%  (p=0.000 n=17+19)
TimeFormat-12                358ns ± 0%     372ns ± 1%  +3.74%  (p=0.000 n=15+18)
[Geo mean]                  62.6µs         62.5µs       -0.25%

Change-Id: Ied190b77c7a4d91ec7b2218c592fc31cf7acf362
Reviewed-on: https://go-review.googlesource.com/19633
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-25 23:37:19 +00:00
Austin Clements
1e91e2a25a runtime: document non-obvious requirement on sudog.elem
The channel code must not allow stack splits between when it assigns a
potential stack pointer to sudog.elem (or sudog.selectdone) and when
it makes the sudog visible to copystack by putting it on the g.waiting
list. We do get this right everywhere, but add a comment about this
subtlety for future eyes.

Change-Id: I941da150437167acff37b0e56983c793f40fcf79
Reviewed-on: https://go-review.googlesource.com/19632
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-25 23:37:17 +00:00
Austin Clements
39f2bd737b runtime: improve initSpan documentation
Change-Id: I9c45aad1c35a99da4c3b8990649dcd962fd23b81
Reviewed-on: https://go-review.googlesource.com/19631
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-25 23:37:14 +00:00
Austin Clements
e1024b6030 runtime: fix heapBitsSweepSpan comment
Currently the heapBitsSweepSpan comment claims that heapBitsSweepSpan
sets the heap bitmap for the first two words to dead. In fact, it sets
the first *four* words to scalar/dead. This is important because first
two words don't actually have a dead bit, so for objects larger than
two words it *must* set a dead bit in third word to reset the object
to a "noscan" state. For example, we use this in heapBits.hasPointers
to detect that an object larger than two words is noscan.

Change-Id: Ie166a628bed5060851db083475c7377adb349d6c
Reviewed-on: https://go-review.googlesource.com/19630
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-25 23:37:09 +00:00
Keith Randall
d3f15ff6bc [dev.ssa] cmd/compile: shrink stack guard
Our stack frame sizes look pretty good now.  Lower the stack
guard from 1024 to 720.
Tip is currently using 720.
We could go lower (to 640 at least) except PPC doesn't like that.

Change-Id: Ie5f96c0e822435638223f1e8a2bd1a1eed68e6aa
Reviewed-on: https://go-review.googlesource.com/19922
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-25 22:32:48 +00:00
Dmitriy Dudkin
ca42f1f50e cmd/go: clear cmd cache to avoid duplicate loads errors
go get -u all command updates all packages including standard
commands. We need to get commands evicted from their cache to
avoid loading old versions of the packages evicted from the
packages cache.

Fixes #14444

Change-Id: Icd581a26e1db34ca634aba595fed62b097094c2f
Reviewed-on: https://go-review.googlesource.com/19899
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-25 21:31:39 +00:00
Brad Fitzpatrick
b24c6fbfb3 net/textproto: permit all valid token chars in CanonicalMIMEHeaderKey input
Fixes #13767

Change-Id: Ib743db7d9d72022ea911bc5ac535243489425642
Reviewed-on: https://go-review.googlesource.com/18725
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-25 21:00:57 +00:00
David Chase
378a863682 [dev.ssa] cmd/compile: enhance command line option processing for SSA
The -d compiler flag can also specify ssa phase and flag,
for example -d=ssa/generic_cse/time,ssa/generic_cse/stats

Spaces in the phase names can be specified with an
underscore.  Flags currently parsed (not necessarily
recognized by the phases yet) are:

   on, off, mem, time, debug, stats, and test

On, off and time are handled in the harness,
debug, stats, and test are interpreted by the phase itself.

The pass is now attached to the Func being compiled, and a
new method logStats(key, ...value) on *Func to encourage a
semi-standardized format for that output.  Output fields
are separated by tabs to ease digestion by awk and
spreadsheets.  For example,
	if f.pass.stats > 0 {
		f.logStat("CSE REWRITES", rewrites)
	}

Change-Id: I16db2b5af64c50ca9a47efeb51d961147a903abc
Reviewed-on: https://go-review.googlesource.com/19885
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2016-02-25 20:32:15 +00:00
Ian Lance Taylor
ad03af66eb runtime, runtime/pprof: add Frames to get file/line for Callers
This indirectly implements a small fix for runtime/pprof: it used to
look for runtime.gopanic when it should have been looking for
runtime.sigpanic.

Update #11432.

Change-Id: I5e3f5203b2ac5463efd85adf6636e64174aacb1d
Reviewed-on: https://go-review.googlesource.com/19869
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-25 19:42:19 +00:00
Ian Lance Taylor
14113b3a89 cmd/internal/obj: don't crash on nil in Prog.String
I can't remember just how this happened to me, but I got an unfortunate
crash with some set of cmd/compile debug options and source code.

Change-Id: Ibef6129c50b68dad0594ac439466bfbc4b32a095
Reviewed-on: https://go-review.googlesource.com/19920
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-25 19:13:11 +00:00
Emmanuel Odeke
d44088f173 net/http: refactored internal shouldClose for readability
Change-Id: Ie89c0945a4cc3aebfa9f7ad7f107bc7ab59ab61c
Reviewed-on: https://go-review.googlesource.com/19685
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-25 19:11:55 +00:00
Dmitry Vyukov
db44223fde runtime: fix getcallerpc args
Change-Id: I6b14b8eecf125dd74bd40f4e7fff6b49de150e42
Reviewed-on: https://go-review.googlesource.com/19897
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-25 18:57:28 +00:00
David Crawshaw
30f93f0994 cmd/compile: remove rtype.ptrToThis
Simplifies some code as ptrToThis was unreliable under dynamic
linking. Now the same type lookup is used regardless of execution
mode.

A synthetic relocation, R_USETYPE, is introduced to make sure the
linker includes *T on use of T, if *T is carrying methods.

Changes the heap dump format. Anything reading the format needs to
look at the last bool of a type of an interface value to determine
if the type should be the pointer-to type.

Reduces binary size of cmd/go by 0.2%.
For #6853.

Change-Id: I79fcb19a97402bdb0193f3c7f6d94ddf061ee7b2
Reviewed-on: https://go-review.googlesource.com/19695
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-25 17:47:42 +00:00
Rick Arnold
5abd327d00 expvar: document that Get returns nil for non-existent vars
Also added a test to ensure the behavior.

Fixes #14150

Change-Id: Ib3ee9fdae59826fa594ce1be3c49b51d740b56eb
Reviewed-on: https://go-review.googlesource.com/19915
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-25 16:48:08 +00:00
Keith Randall
fb54e0305f [dev.ssa] cmd/compile: small improvements
Found looking at mapaccess1_faststr.

runtime.throw never returns.
Do x+y+c with an LEA.

Change-Id: I27ea6669324242a6302397cbdc73230891d97591
Reviewed-on: https://go-review.googlesource.com/19911
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-25 07:10:07 +00:00
Mikio Hara
4accfe1be5 net: re-enable TestDualStack{TCP,UDP}Listener on dragonfly
It looks like the latest DragonFly BSD kernels, at least 4.4 and above,
have finished working on handling of shared IP control blocks. Let's
re-enbale test cases referring to IP control blocks and see what
happens.

Updates #13146.

Change-Id: Icbe2250e788f6a445a648541272c99b598c3013d
Reviewed-on: https://go-review.googlesource.com/19406
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-25 03:14:01 +00:00
Mikio Hara
b48120ca3a net: make TestGoLookupIPWithResolverConfig robust
It crashes when the node under the test is shaken up.

-- FAIL: TestGoLookupIPWithResolverConfig (11.73s)
panic: interface conversion: error is nil, not *net.DNSError [recovered]
	panic: interface conversion: error is nil, not *net.DNSError

goroutine 23 [running]:
panic(0x2e2620, 0xc820181440)
	/go/src/runtime/panic.go:483 +0x3f3
testing.tRunner.func1(0xc820136d80)
	/go/src/testing/testing.go:467 +0x192
panic(0x2e2620, 0xc820181440)
	/go/src/runtime/panic.go:441 +0x4f6
net.TestGoLookupIPWithResolverConfig(0xc820136d80)
	/go/src/net/dnsclient_unix_test.go:358 +0x7ca
testing.tRunner(0xc820136d80, 0x49ddc0)
	/go/src/testing/testing.go:473 +0x98
created by testing.RunTests
	/go/src/testing/testing.go:582 +0x892
exit status 2

Change-Id: I9631f41a3c73f3269c7e30d679c025ae64d71a98
Reviewed-on: https://go-review.googlesource.com/19870
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-25 03:12:59 +00:00
Mikio Hara
7c90abe206 net: fix typo
Change-Id: Ic828256efe0f50a3e11a25d85092d7531b342d2e
Reviewed-on: https://go-review.googlesource.com/19873
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-25 03:11:55 +00:00
Robert Griesemer
d2e1dae3fe cmd/compile: adjust starting token value
The actual values assigned to tokens was inherited from the yacc-based
grammar. With the most recent cleanups, all single-char tokens such as
commas, semis, parens, etc., that get returned from lexer.next simply
as their Unicode values are below utf8.RuneSelf (i.e., 7bit ASCII).
Lower the initial starting value for named token constants accordingly.

Change-Id: I7eb8e584dbb3bc7f9dab849d1b68a91320cffebd
Reviewed-on: https://go-review.googlesource.com/19913
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-02-25 00:50:56 +00:00
Matthew Dempsky
772cea817d cmd/compile: fix off-by-1 in getr
Introduced by (and missed during code review of) golang.org/cl/19847.

Change-Id: I03b76f36e5da69c31730380592dfa1c32570e17f
Reviewed-on: https://go-review.googlesource.com/19912
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-25 00:46:16 +00:00
Tal Shprecher
45c4ebec5b cmd/asm: fix EOF message on operand parsing errors.
If the parsing of an operand completes but the parser thinks there
is more to read, return an "expected end of operand" error message
instead of "expected EOF." This also removes extra "asm: " prefixes
in error strings since "asm: " is already set as the global log
prefix.

Fixes #14071

Change-Id: I7d621c1aea529a0eca3bcba032359bd25b3e1080
Reviewed-on: https://go-review.googlesource.com/19731
Reviewed-by: Rob Pike <r@golang.org>
2016-02-25 00:21:14 +00:00
Matthew Dempsky
d17727bdb4 cmd/compile: cleanup escape sequence lexing
Change-Id: I7fe4d0cdcc284d5319c130ee3c351f23489af273
Reviewed-on: https://go-review.googlesource.com/19902
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-25 00:11:16 +00:00
Damien Neil
5888763428 cmd/go: skip consistent cgo build test on Solaris.
See #13247.

Change-Id: I06636157028d98430eb29277c822270592907856
Reviewed-on: https://go-review.googlesource.com/19910
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-24 23:58:10 +00:00
Josh Bleecher Snyder
0625fc8e82 cmd/compile: clean up getlinepragma
Passes toolstash -cmp.

Change-Id: Ia497b51c74a9c760a873e1ed690e4408fd0fe596
Reviewed-on: https://go-review.googlesource.com/19844
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-24 22:54:41 +00:00
Keith Randall
a5325761cd [dev.ssa] cmd/compile: identical values are the same pointer
Forgot the obvious case.  Allows us to remove the load in:

func f(p *int, x int) int {
	*p = x + 5
	return *p
}

Change-Id: I93686d8240bab3a1d166b88e224cf71e3d947aef
Reviewed-on: https://go-review.googlesource.com/19905
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-24 22:21:01 +00:00
Keith Randall
ed737fd8cd [dev.ssa] cmd/compile: fix @ rewrite rules
The @ directive used to read the target block after some value
structure had already changed.  I don't think it was ever really
a bug, but it's confusing.

It might fail like this:

(Foo x y) -> @v.Args[0].Block (Bar y (Baz ...))

v.Op = Bar
v.Args[0] = y
v.Args[1] = v.Args[0].Block.NewValue(Baz, ...)

That new value is allocated in the block of y, not the
block of x.

Anyway, read the destination block first so this
potential bug can't happen.

Change-Id: Ie41d2fc349b35cefaa319fa9327808bcb781b4e2
Reviewed-on: https://go-review.googlesource.com/19900
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2016-02-24 22:20:24 +00:00
Keith Randall
e173ab1434 [dev.ssa] cmd/compile: update TODO
Remove the stuff that's already done.

Change-Id: I3b4fc827240d45dd051dc36897883532d8900a0c
Reviewed-on: https://go-review.googlesource.com/19906
Reviewed-by: David Chase <drchase@google.com>
2016-02-24 22:19:56 +00:00
Keith Randall
9c269e6a46 cmd/compile: don't free the Prog list if we look at it after flush
Only tests do this, provide them a hook to disable freeing
after flush.

Change-Id: I810c6c51414a93f476a18ba07b807e16092bf8cf
Reviewed-on: https://go-review.googlesource.com/19907
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-24 22:10:27 +00:00
Alberto Donizetti
a9581e2e7a unicode/utf16: speed up and clean up Encode and EncodeRune
name                        old time/op  new time/op  delta
EncodeValidASCII-4          74.1ns ± 1%  70.1ns ± 1%   -5.46%  (p=0.000 n=10+10)
EncodeValidJapaneseChars-4  61.3ns ± 0%  58.9ns ± 0%   -3.82%  (p=0.000 n=10+10)
EncodeRune-4                13.1ns ± 1%   9.8ns ± 0%  -25.24%   (p=0.000 n=10+9)

Fixes #6957

Change-Id: I9dde6d77420c34c6e2ef3e6213bb6be9b58a3074
Reviewed-on: https://go-review.googlesource.com/19891
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-24 21:07:03 +00:00
Burcu Dogan
47b0422885 os: fix tests on brillo
Not every Android contains the /system/framework directory, e.g. Brillo.
Test against other Android-only system files.

Fixes #14489.

Change-Id: I6d9ec1c4d4ceba3803798015e6917d59cf515de8
Reviewed-on: https://go-review.googlesource.com/19904
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Burcu Dogan <jbd@google.com>
Run-TryBot: Burcu Dogan <jbd@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-24 21:05:40 +00:00
Keith Randall
f388b58540 cmd/compile: reuseable cache of Prog structs
Reuseable cache of Prog entries.

Improves compiler speed by ~10%.

Update #13646

Change-Id: I01bd8606540d989ea8b8ba5131d1275ba380d976
Reviewed-on: https://go-review.googlesource.com/19868
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-24 18:52:28 +00:00
Keith Randall
45c2e38b37 cmd/compile: Drop references to Prog structs after each function
Don't accumulate a massive list of Prog structs during
compilation and write them all out at the end of compilation.
Instead, convert them to code+relocs (or data+relocs) after each
function is compiled.

Track down a few other places that were keeping Progs alive
and nil them out so the Progs get GCd promptly.

Saves ~20% in peak memory usage for the compiler.  Surprisingly not much
help speed-wise (only because we end up doing more GCs.  With a
compensating GOGC=120, it does help a bit), but this provides a base for
more changes (e.g. reusing a cache of Progs).

Change-Id: I838e01017c228995a687a8110d0cd67bf8596407
Reviewed-on: https://go-review.googlesource.com/19867
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-24 18:47:57 +00:00
Martin Möhrmann
fdd0179bb1 all: fix typos and spelling
Change-Id: Icd06d99c42b8299fd931c7da821e1f418684d913
Reviewed-on: https://go-review.googlesource.com/19829
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-24 18:42:29 +00:00
Eric Lagergren
4feb47bc76 encoding/csv: clarify that TrimLeadingSpace can trim the delimiter
Fixes #14464

Change-Id: Iafc21641cca7d35b7a5631cfc94742ee8e7d5042
Reviewed-on: https://go-review.googlesource.com/19861
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-24 18:42:09 +00:00
David du Colombier
039d455f9d cmd/compile: don't use duffzero on Plan 9
In CL 14408, the implementation of duffzero on amd64
was changed to replace the use of the MOVQ instructions
by MOVUPS.

However, it broke the build on plan9/amd64, since
Plan 9 doesn't allow floating point in note handler.

This change disables the use of duffzero on Plan 9.
We also take care to not use the MOVUPS instruction.

Fixes #14471.

Change-Id: I8277b485dfe65a68d7d8338e52a048c5d45069bf
Reviewed-on: https://go-review.googlesource.com/19890
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-24 18:05:10 +00:00
David Crawshaw
a858931200 cmd/compile: embed type string header in rtype
Reduces binary size of cmd/go by 1%.

For #6853.

Change-Id: I6f2992a4dd3699db1b532ab08683e82741b9c2e4
Reviewed-on: https://go-review.googlesource.com/19692
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-24 17:12:15 +00:00
David Chase
288817b05a [dev.ssa] cmd/compile: reduce line number churn in generated code
In regalloc, make LoadReg instructions use the line number
of their *use*, not their *source*.  This reduces the
tendency of debugger stepping to "jump around" the program.

Change-Id: I59e2eeac4dca9168d8af3a93effbc5bdacac2881
Reviewed-on: https://go-review.googlesource.com/19836
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-24 16:57:36 +00:00
Todd Neal
b96189d1a0 [dev.ssa] cmd/compile: speed up cse
Construct better initial partitions by recursively comparing values and
their arguments.  This saves one second on compile of arithConst_ssa.go
(4.3s to 3.3s) and shows a 3-5% increase with compilebench.

name       old time/op     new time/op     delta
Template       266ms ± 3%      253ms ± 4%  -5.08%          (p=0.032 n=5+5)
GoTypes        927ms ± 3%      885ms ± 2%  -4.55%          (p=0.016 n=5+5)
Compiler       3.91s ± 3%      3.73s ± 2%  -4.49%          (p=0.008 n=5+5)
MakeBash       31.6s ± 1%      30.5s ± 3%  -3.51%          (p=0.016 n=5+5)

Change-Id: I6ede31ff459131ccfed69531acfbd06b19837700
Reviewed-on: https://go-review.googlesource.com/19838
Reviewed-by: David Chase <drchase@google.com>
2016-02-24 16:57:05 +00:00
Robert Griesemer
8dd2ce2b98 cmd/compile: factor our literal lexing from main lexer function
Further reduces complexity of lexer.next which is now readable.
Also removes the need to initialize various local variables in
each next call even if they are not used for the current token.

No measurable performance change for `time go build -a net/http`
(best of 5 runs): difference < 0.3% (in the noise).

Change-Id: I0d74caa2768920af1ceee027e0f46595119d4210
Reviewed-on: https://go-review.googlesource.com/19865
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-02-24 16:56:51 +00:00
Keith Randall
8906d2a171 [dev.ssa] cmd/compile: leave JMPs in when using -N
Helps keep line numbers around for debugging, particularly
for break and continue statements (which often compile
down to nothing).

Update #14379

Change-Id: I6ea06aa887b0450d9ba4f11e319e5c263f5a98ba
Reviewed-on: https://go-review.googlesource.com/19848
Reviewed-by: David Chase <drchase@google.com>
2016-02-24 16:53:00 +00:00
Jure Ham
38d4511b10 sort: fix for nondeterministic less function in quicksort pivot
Fixes #14377

Change-Id: I130a6e1b8bc827db44efd0a74e759b894ecc4977
Reviewed-on: https://go-review.googlesource.com/19823
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-24 15:30:45 +00:00
kortschak
50c38d46e8 cmd/go, go/build: add support for Fortran
This change adds support for Fortran files (.f, .F, .for, .f90) to the
go tool, in a similar fashion to Objective-C/C++. Only gfortran is
supported out of the box so far but leaves other Fortran compiler
toolchains the ability to pass the correct link options via CGO_LDFLAGS.
A simple test (misc/cgo/fortran) has been added and plugged into the
general test infrastructure. This test is only enabled when the $FC
environment variable is defined (or if 'gfortran' was found in $PATH.)

Derived from CL 4114.

Change-Id: Ifc855091942f95c6e9b17d91c17ceb4eee376408
Reviewed-on: https://go-review.googlesource.com/19670
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-24 15:06:38 +00:00
Catalin Nicutar
6e6637bdb4 cmd/vet: add a check for tests with malformed names
According to golang.org/pkg/testing the first character after Test has
to be non-lowercase. Functions that don't conform to this are not
considered tests and are not loaded which can cause surprises.

This change adds a check to warn about Test-like functions in a _test
file that are not actually run by go test.

Moved over from https://go-review.googlesource.com/#/c/19466/

Change-Id: I2f89676058b27a0e35f721bdabc9fa8a9d34430d
Reviewed-on: https://go-review.googlesource.com/19724
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-02-24 10:40:34 +00:00
Alexandru Moșoi
d337e55672 [dev.ssa] cmd/compile/internal/ssa: simplify convert in more cases
Saves about 2k for binaries in pkg/tool/linux_amd64.
Also useful when opt runs after cse (as in 12960) which reorders
arguments for commutative operations such as Add64.

Change-Id: I49ad53afa53db9736bd35c425f4fb35fb511fd63
Reviewed-on: https://go-review.googlesource.com/19827
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-24 07:39:01 +00:00
Shenghou Ma
c3ecded729 cmd/dist: introduce list subcommand to list all supported platforms
Fixes #12270.

Change-Id: Ie3dcbd0403d270b4b7f5c39049e12315eee159ed
Reviewed-on: https://go-review.googlesource.com/19837
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-24 06:41:08 +00:00
Robert Griesemer
539aa05a64 cmd/compile: towards simpler and faster lexing: always use getr
Always reading runes (rather than bytes) has negligible overhead
(a simple if at the moment - it can be eliminated eventually) but
simplifies the lexer logic and opens up the door for speedups.
In the process remove many int conversions that are now not needed
anymore.

Also, because identifiers are now more easily recognized, remove
talph label and move identifier lexing "in place".

Also, instead of accepting all chars < 0x80 and then check for
"frogs", only permit valid characters in the first place. Removes
an extra call for common simple tokens and leads to simpler logic.

`time go build -a net/http` (best of 5 runs) seems 1% faster.
Assuming this is in the noise, there is no noticeable performance
degradation with this change.

Change-Id: I3454c9bf8b91808188cf7a5f559341749da9a1eb
Reviewed-on: https://go-review.googlesource.com/19847
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-24 04:36:25 +00:00
Mikio Hara
08f1a778c9 net: rename test files
This change renames {ipraw,tcp,udp,unix}_test.go to
{ipraw,tcp,udp,unix}sock_test.go for clarification. Also moves
NSS-related system configuration test helpers into main_conf_test.go and
main_noconf_test.go.

Change-Id: I28ba1e8ceda7b182ee3aa85f0ca3321388ba45e2
Reviewed-on: https://go-review.googlesource.com/19787
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-24 03:07:58 +00:00
Shenghou Ma
1439158120 runtime, syscall: switch linux/386 to use int 0x80
Like bionic, musl also doesn't provide vsyscall helper in %gs:0x10,
and as int $0x80 is as fast as calling %gs:0x10, just use int $0x80
always.

Because we're no longer using vsyscall in VDSO, get rid of VDSO code
for linux/386 too.

Fixes #14476.

Change-Id: I00ec8652060700e0a3c9b524bfe3c16a810263f6
Reviewed-on: https://go-review.googlesource.com/19833
Run-TryBot: Minux Ma <minux@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-24 02:07:17 +00:00
Ian Lance Taylor
5c096cc092 runtime: deflake TestCgoCheckBytes
Bump up the multiplier to 20.  Also run the fast version first, so that
the slow version is likely to start up faster.

Change-Id: Ia0654cc1212ab03a45da1904d3e4b57d6a8d02a0
Reviewed-on: https://go-review.googlesource.com/19835
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2016-02-24 01:49:05 +00:00
Shenghou Ma
7606e4a032 cmd/compile/internal/gc: update comment after c2go
Change-Id: I02c60f6c767e917a8ed3772c2773fe266f781e44
Reviewed-on: https://go-review.googlesource.com/19834
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-24 01:46:27 +00:00
Shenghou Ma
733cae6acd cmd/dist, go/build: make cmd/dist generate cgoEnabled map for go/build
This reduces the amount of duplication. Now there is only one list
of platforms supporting cgo.

Update #12270.

Change-Id: I5dcd55cb6be7c5bb6ce560383c71d90ab1189dc9
Reviewed-on: https://go-review.googlesource.com/14278
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-24 01:45:28 +00:00
Matthew Dempsky
1e4e09612c cmd/compile: remove parser lineno hack for issue #13267
After golang.org/cl/19652 removed the bizarre lexlineno{++,--}
statements for parsing canned imports, this hack for #13267 is no
longer necessary:

    $ echo -n 0 > /tmp/0.go
    $ go tool compile /tmp/0.go
    /tmp/0.go:1: syntax error: package statement must be first

Apparently setting lexlineno to 2 while parsing the canned imports
caused prevlineno and lineno to also be set to 2.  After we finished
parsing imports and restored lexlineno to 1, since "package" is the
first token in a source file, we'll have fixed lineno = 1, but
prevlineno was still set to 2.

Change-Id: Ibcc49fe3402264819b9abb53505631f7a0ad4a36
Reviewed-on: https://go-review.googlesource.com/19859
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-24 00:19:46 +00:00
Keith Randall
e360f7c4db cmd/compile: keep JMPs around with -N
When -N, make sure we don't drop every instruction from
a block, even ones which would otherwise be empty.
Helps keep line numbers around for debugging, particularly
for break and continue statements (which often compile
down to nothing).

Fixes #14379

Change-Id: I33722c4f0dcd502f146fa48af262ba3a477c959a
Reviewed-on: https://go-review.googlesource.com/19854
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2016-02-24 00:16:23 +00:00
Prashant Varanasi
c4cb365ea2 net: fix for DialTimeout errors with large timeout
The existing implementation converts the deadline time to an int64,
but does not handle overflow. If the calculated deadline is negative
but the user specified deadline is in the future, then we can assume
the calculation overflowed, and set the deadline to math.MaxInt64.

Fixes #14431

Change-Id: I54dbb4f02bc7ffb9cae8cf62e4e967e9c6541ec6
Reviewed-on: https://go-review.googlesource.com/19758
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2016-02-23 22:48:04 +00:00
Keith Randall
80bc512449 [dev.ssa] Merge remote-tracking branch 'origin/master' into mergebranch
Semi-regular merge from tip to dev.ssa.

Change-Id: If7d2269f267bcbc0ecd3a483d349951044470e3f
2016-02-23 14:42:20 -08:00
Robert Griesemer
d1cc7f70cd cmd/compile: give informative error instead of "stupid shift"
Fixes #13940.

Change-Id: I00fe377c949e5be4cbc035f6ca18e547e326bfba
Reviewed-on: https://go-review.googlesource.com/19856
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-23 22:31:35 +00:00
Robert Griesemer
ef3c45adfc text/tabwriter: clarify documentation
More clearly distinguish between tab-terminated cells
which are part of an (aligned) column, and non-tab terminated
cells which are not part of a column. Added additional examples.

For #14412.

Change-Id: If72607385752e221eaa2518238b11f48fbcb8a90
Reviewed-on: https://go-review.googlesource.com/19855
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-02-23 22:09:32 +00:00
Alberto Donizetti
7786f97905 unicode/utf16: speed up and clean up Decode
name                        old time/op  new time/op  delta
DecodeValidASCII-4          94.7ns ± 1%  87.4ns ± 1%  -7.71%  (p=0.000 n=10+9)
DecodeValidJapaneseChars-4  91.0ns ± 2%  84.8ns ± 0%  -6.77%  (p=0.000 n=9+10)
DecodeRune-4                16.5ns ± 0%  16.6ns ± 2%    ~     (p=0.108 n=9+10)

For #6957

Change-Id: I618c15c2a42ef7ec6a5cd163b7c3f1a65ca4ad01
Reviewed-on: https://go-review.googlesource.com/19826
Reviewed-by: Rob Pike <r@golang.org>
2016-02-23 21:09:07 +00:00
Matthew Dempsky
9877900c8c Revert "cmd/compile: move hiter, hmap, and scase definitions into builtin.go"
This reverts commit f28bbb776a.

Change-Id: I82fb81dcff3ddcaefef72949f1ef3a41bcd22301
Reviewed-on: https://go-review.googlesource.com/19849
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-23 19:42:52 +00:00
Paul Marks
676550d040 net: use dialTCP cancelation for DualStack dialing.
The previous Happy Eyeballs implementation would intentionally leak
connections, because dialTCP could not be reliably terminated upon
losing the race.

Now that dialTCP supports cancelation (plan9 excluded), dialParallel can
wait for responses from both the primary and fallback racers, strictly
before returning control to the caller.

In dial_test.go, we no longer need Sleep to avoid leaks.
Also, fix a typo in the Benchmark IPv4 address.

Updates #11225
Fixes #14279

Change-Id: Ibf3fe5c7ac2f7a438c1ab2cdb57032beb8bc27b5
Reviewed-on: https://go-review.googlesource.com/19390
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-23 19:26:34 +00:00
Alexandru Moșoi
40f2b57e0b [dev.ssa] cmd/compile/internal/ssa: eliminate phis during deadcode removal
While investigating the differences between 19710 (remove
tautological controls) and 12960 (bounds and nil propagation)
I observed that part of the wins of 19710 come from missed
opportunities for deadcode elimination due to phis.
See for example runtime.stackcacherelease. 19710 happens much
later than 12960 and has more chances to eliminate bounds.

Size of pkg/tool/linux_amd64/* excluding compile:

-this -12960 95882248
+this -12960 95880120
-this +12960 95581512
+this +12960 95555224

This change saves about 25k.

Change-Id: Id2f4e55fc92b71595842ce493c3ed527d424fe0e
Reviewed-on: https://go-review.googlesource.com/19728
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-23 18:52:15 +00:00
David Crawshaw
735e5a483c cmd/compile: stop aligning string data
Makes godoc 10KB smaller.
For #6853.

Change-Id: Id54bd8c82cb2a1ba11d2d724e3107f73024b19d9
Reviewed-on: https://go-review.googlesource.com/19696
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-23 17:15:39 +00:00
Alberto Donizetti
cd41db34bc regexp: remove unreachable code
Found running go vet on the package. It barks that
	regexp/backtrack.go:257: unreachable code
	regexp/backtrack.go:302: unreachable code

For #11041

Change-Id: I0f5ba0d6183108fba3d144991b826273db0ffb09
Reviewed-on: https://go-review.googlesource.com/19824
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-23 15:16:50 +00:00
Harshavardhana
4ded58bd5a net/http/httputil: Keep response headers when response ContentLength is 0.
Current code does not print any response headers from httputil.DumpResponse().

   PUT /miniocloud/new-file HTTP/1.1
   Host: s3.amazonaws.com
   User-Agent: Go-http-client/1.1
   Content-Length: 11
   Accept-Encoding: gzip

   HTTP/1.1 200 OK

With this fix we get an appropriate output for httputil.DumpResponse().

   PUT /miniocloud/new-file HTTP/1.1
   Host: s3.amazonaws.com
   User-Agent: Go-http-client/1.1
   Content-Length: 11
   Accept-Encoding: gzip

   HTTP/1.1 200 OK
   Content-Length: 0
   Date: Thu, 14 Jan 2016 03:04:42 GMT
   Etag: "3e25960a79dbc69b674cd4ec67a72c62"
   Server: AmazonS3
   X-Amz-Id-2: qnXyH6sknlovV0Myy3emFAXTNtI/sQIcu1ZXNq/6wd17K32tQ7WNGB1qb3nzCpW2DhfeZ/MbWfw=
   X-Amz-Request-Id: 8422EACB0CC492BD

Fixes #13942

Change-Id: Ida063cc3524a96170d8a837893f7c9f49b6cf98e
Reviewed-on: https://go-review.googlesource.com/18624
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-23 15:16:39 +00:00
Shawn Smith
58ec5839cd all: fix typos
Change-Id: I6035941df8b0de6aeaf6c05df7257bcf6e9191fe
Reviewed-on: https://go-review.googlesource.com/19320
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-23 13:58:47 +00:00
Alberto Donizetti
abf4696ede unicode/utf16: add benchmarks
For #6957

Change-Id: Ic497c12f33efc933e9fe81f6cd1b2a0a01abbabf
Reviewed-on: https://go-review.googlesource.com/19820
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-23 13:58:26 +00:00
Matthew Dempsky
3ec0651539 cmd/compile: add copyright notice to util.go
util.go was originally added in golang.org/cl/4851, and later moved to
its current location in golang.org/cl/10287.

Change-Id: I10b4941d42ae1ff2e78990c497c1347bbbae4e3d
Reviewed-on: https://go-review.googlesource.com/19851
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-02-23 10:49:47 +00:00
Matthew Dempsky
e34295e647 cmd/compile: use path.Join in importfile
Change-Id: Ib413b0cb16405965455d7764a8c4a22bf431389b
Reviewed-on: https://go-review.googlesource.com/19850
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-02-23 10:49:39 +00:00
Todd Neal
c17b6b488c [dev.ssa] cmd/compile: truncate auxint when constructing Prog
The upper bits of 8/16/32 bit constants are undefined.  We need to
truncate in order to prevent x86.oclass misidentifying the size of the
constant.

Fixes #14389

Change-Id: I3e5ff79cd904376572a93f489ba7e152a5cb6e60
Reviewed-on: https://go-review.googlesource.com/19740
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-23 03:52:08 +00:00
Robert Griesemer
e7524d51fd cmd/compile: move Io state into lexer and remove Io type
Pass lexer around so state is accessible and dependency is explicit.
In the process remove EOF -> '\n' conversion that has to be corrected
for when reporting errors.

Change-Id: If95564b70e7484dedc1f5348e585cd19acbc1243
Reviewed-on: https://go-review.googlesource.com/19819
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-02-23 03:42:38 +00:00
Robert Griesemer
0784e6918e net/http: fix typo in doc string
Fixes #14475.

Change-Id: I1b5b0a9793a417572ec55f313185d03ad5ae9d01
Reviewed-on: https://go-review.googlesource.com/19846
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-23 03:42:24 +00:00
Todd Neal
9dc1334cc7 [dev.ssa] cmd/compile : replace load of store with a copy
Loads of stores from the same pointer with compatible types
can be replaced with a copy.

Change-Id: I514b3ed8e5b6a9c432946880eac67a51b1607932
Reviewed-on: https://go-review.googlesource.com/19743
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-23 01:18:31 +00:00
Keith Randall
bd70bd9cb2 runtime: unify memeq and memequal
They do the same thing, except memequal also has the short-circuit
check if the two pointers are equal.

A) We might as well always do the short-circuit check, it is only 2 instructions.
B) The extra function call (memequal->memeq) is expensive.

benchmark                 old ns/op     new ns/op     delta
BenchmarkArrayEqual-8     8.56          5.31          -37.97%

No noticeable affect on the former memeq user (maps).

Fixes #14302

Change-Id: I85d1ada59ed11e64dd6c54667f79d32cc5f81948
Reviewed-on: https://go-review.googlesource.com/19843
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-23 00:15:38 +00:00
Brady Sullivan
1e00cc1647 crypto/tls: Improve ambiguous comment in cipher_suites.go
A comment existed referencing RC4 coming before AES because of it's
vulnerability to the Lucky 13 attack. This clarifies that the Lucky 13 attack
only effects AES-CBC, and not AES-GCM.

Fixes #14474

Change-Id: Idcb07b5e0cdb0f9257cf75abea60129ba495b5f5
Reviewed-on: https://go-review.googlesource.com/19845
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-22 23:56:37 +00:00
Rob Pike
108218453a cmd/doc: handle embedded fields properly
The structure of the code meant that an embedded field was never
checked for export status. We need to check the name of the type,
which is either of type T or type *T, and T might be unexported.

Fixes #14356.

Change-Id: I56f468e9b8ae67e9ed7509ed0b91d860507baed2
Reviewed-on: https://go-review.googlesource.com/19701
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-22 23:40:02 +00:00
Matthew Dempsky
a4b833940d runtime: move machport into darwin's mOS
It's not needed on other OSes.

Change-Id: Ia6b13510585392a7062374806527d33876beba2a
Reviewed-on: https://go-review.googlesource.com/19818
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-22 21:15:50 +00:00
Matthew Dempsky
756ea30eb0 runtime: simplify stack copying in ThreadCreateProfile
Change-Id: I7414d2fab18ae6e7e7c50f8697ec64d38290f409
Reviewed-on: https://go-review.googlesource.com/19817
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-22 21:15:46 +00:00
Josh Bleecher Snyder
36694064e5 cmd/compile: disable checknils during alg eq generation
Cuts 20k off cmd/go and 32k off golang.org/x/tools/cmd/godoc, approx 0.15% each.

For #6853 and #9930

Change-Id: Ic510b76b80a9153b1ede7b3533d2dbc16caa5c63
Reviewed-on: https://go-review.googlesource.com/19768
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-02-22 21:10:55 +00:00
Caio Marcelo de Oliveira Filho
e7f6d8b2d7 cmd/cover: don't overskip children nodes when adding counters
When visiting the AST to add counters, there are special cases in which
the code calls cuts the walking short by returning nil. In some cases
certain nodes are ignored, e.g. Init and Cond inside IfStmt.

The fix is to explicitly walk all the children nodes (not only
Body and Else) when cutting the current walk. Similar approach
was taken with SwitchStmt and TypeSwitchStmt.

While the existing test code doesn't handle different counters in the
same line, the generated HTML report does it correctly (because it takes
column into account).

The previous behavior caused lines in function literals to not be
tracked when those literals were inside Init or Cond of an IfStmt for
example.

Fixes #14039.

Change-Id: Iad591363330843ad833bd79a0388d709c8d0c8aa
Reviewed-on: https://go-review.googlesource.com/19775
Reviewed-by: Rob Pike <r@golang.org>
2016-02-22 21:06:57 +00:00
Robert Griesemer
f39cca94af cmd/compile: bring vendored copy of math/big up-to-date
These files were not added to the repo. They contain conversion
routines and corresponding tests not used by the compiler and
thus are technically not needed.

However, future changes to math/big (and corresponding updates
of this vendored version) may require these files to exist.
Add them to avoid unnecessary confusion.

Change-Id: Ie390fb54f499463b2bba2fdc084967539afbeeb3
Reviewed-on: https://go-review.googlesource.com/19730
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-02-22 20:50:00 +00:00
Josh Bleecher Snyder
028247d2cd cmd/compile: reuse []Flow
Benchmarked using compilebench on a quiet
but rather old OS X laptop.

Benchmarks from others would be welcome,
since the numbers look too good to be true.

name      old time/op    new time/op    delta
Template     331ms ± 9%     303ms ± 4%   -8.25%  (p=0.000 n=24+24)
GoTypes      946ms ± 4%     888ms ± 3%   -6.17%  (p=0.000 n=24+25)
Compiler     3.20s ± 1%     3.10s ± 2%   -3.07%  (p=0.000 n=24+25)

name      old alloc/op   new alloc/op   delta
Template    72.5MB ± 0%    61.8MB ± 0%  -14.76%  (p=0.000 n=25+24)
GoTypes      224MB ± 0%     189MB ± 0%  -15.65%  (p=0.000 n=25+25)
Compiler     695MB ± 0%     561MB ± 0%  -19.26%  (p=0.000 n=25+25)

name      old allocs/op  new allocs/op  delta
Template      498k ± 0%      497k ± 0%   -0.21%  (p=0.000 n=25+23)
GoTypes      1.47M ± 0%     1.47M ± 0%   -0.25%  (p=0.000 n=25+25)
Compiler     4.09M ± 0%     4.08M ± 0%   -0.18%  (p=0.000 n=25+23)

Change-Id: I2394bc748128d721863453257fa5756c410f7898
Reviewed-on: https://go-review.googlesource.com/19771
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-22 18:22:48 +00:00
David Chase
c3db6c95b6 [dev.ssa] cmd/compile: double speed of CSE phase
Replaced comparison based on (*Type).String() with an
allocation-free structural comparison.  Roughly doubles
speed of CSE, also reduces allocations.

Checked that roughly the same number of CSEs were detected
during make.bash (about a million) and that "new" CSEs
were caused by the effect described above.

Change-Id: Id205a9f6986efd518043e12d651f0b01206aeb1b
Reviewed-on: https://go-review.googlesource.com/19471
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-22 17:15:41 +00:00
Alexandru Moșoi
88c1ef5b45 [dev.ssa] cmd/compile/internal/ssa: handle commutative operations in cse
* If a operation is commutative order the parameters
in a canonical way.

Size of pkg/tool/linux_amd64/* excluding compile:
before: 95882288
 after: 95868152
change: 14136 ~0.015%

I tried something similar with Leq and Geq, but the results were
not great because it confuses the 'lowered cse' pass too much
which can no longer remove redundant comparisons from IsInBounds.

Change-Id: I2f928663a11320bfc51c7fa47e384b7411c420ba
Reviewed-on: https://go-review.googlesource.com/19727
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-22 16:52:05 +00:00
David Chase
b86cafc7dc [dev.ssa] cmd/compile: memory allocation tweaks to regalloc and dom
Spotted a minor source of excess allocation in the register
allocator.  Rearranged the dominator tree code to pull its
scratch memory from a reused buffer attached to Config.

Change-Id: I6da6e7b112f7d3eb1fd00c58faa8214cdea44e38
Reviewed-on: https://go-review.googlesource.com/19450
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-22 15:32:58 +00:00
Todd Neal
94f0245114 [dev.ssa] cmd/compile: add a zero arg cse pass
Add an initial cse pass that only operates on zero argument
values.  This removes the need for a special case in cse for removing
OpSB and speeds up arithConst_ssa.go compilation by 9% while slowing
"test -c net/http" by 1.5%.

Change-Id: Id1500482485426f66c6c2eba75eeaf4f19c8a889
Reviewed-on: https://go-review.googlesource.com/19454
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-22 13:06:18 +00:00
Matthew Dempsky
f28bbb776a cmd/compile: move hiter, hmap, and scase definitions into builtin.go
Also eliminates per-maptype hiter and hmap types, since they're not
really needed anyway.  Update packages reflect and runtime
accordingly.

Reduces golang.org/x/tools/cmd/godoc's text segment by ~170kB:

   text	   data	    bss	    dec	    hex	filename
13085702	 140640	 151520	13377862	 cc2146	godoc.before
12915382	 140640	 151520	13207542	 c987f6	godoc.after

Updates #6853.

Change-Id: I948b2bc1f22d477c1756204996b4e3e1fb568d81
Reviewed-on: https://go-review.googlesource.com/16610
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-22 07:42:37 +00:00
Keith Randall
d0c11577b9 cmd/compile: inline {i,e}facethash
These functions are really simple, the overhead of calling
them (in both time and code size) is larger than the inlined versions.

Reorganize how the nil case in a type switch is handled, as we have
to check for nil explicitly now anyway.

Saves about 0.8% in the binary size of the go tool.

Change-Id: I8501b62d72fde43650b79f52b5f699f1fbd0e7e7
Reviewed-on: https://go-review.googlesource.com/19814
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-02-22 05:09:25 +00:00
Todd Neal
4827c6d077 [dev.ssa] test: add test of pointer aliasing
This adds a test case with aliased pointers to ensure modifications to
dse don't remove valid stores.

Change-Id: I143653250f46a403835218ec685bcd336d5087ef
Reviewed-on: https://go-review.googlesource.com/19795
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-22 03:40:16 +00:00
Matthew Dempsky
5609a48931 cmd/compile: make cmpstackvarlt properly asymmetric
Previously, given two Nodes n1 and n2 of different non-PAUTO classes
(e.g., PPARAM and PPARAMOUT), cmpstackvarlt(n1, n2) and
cmpstackvarlt(n2, n1) both returned true, which is nonsense.

This doesn't seem to cause any visible miscompilation problems, but
notably fixing it does cause toolstash/buildall to fail.

Change-Id: I33b2c66e902c5eced875d8fbf18b7cfdc81e8aed
Reviewed-on: https://go-review.googlesource.com/19778
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-22 00:09:36 +00:00
Austin Clements
8847a5913a runtime: remove unused parfor code
Change-Id: Ibbfae20cab48163f22d661604ef730705f2b97ba
Reviewed-on: https://go-review.googlesource.com/19661
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-21 23:22:11 +00:00
Matthew Dempsky
89cfdda44d cmd/compile: replace Order's use of NodeLists with slices
Order's "temp" and "free" fields use NodeLists in a rather
non-idiomatic way.  Instead of using the "list" or "concat" functions,
it manipulates them directly and without the normal invariants (e.g.,
it doesn't maintain the "End" field).

Rather than convert it to more typical usage, just replace with a
slice, which ends up much simpler anyway.

Passes toolstash/buildall.

Change-Id: Ibd0f24324bd674c0d5bb1bc40d073b01e7824ad5
Reviewed-on: https://go-review.googlesource.com/19776
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-21 23:20:43 +00:00
Shenghou Ma
d70c04cf08 runtime: fix missing word in comment
Change-Id: I6cb8ac7b59812e82111ab3b0f8303ab8194a5129
Reviewed-on: https://go-review.googlesource.com/19791
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-21 22:40:25 +00:00
Shenghou Ma
a4b143bc22 go/types: skip $GOROOT/src/*.go in TestStdlib
Change-Id: I4a75d98a48675e2beb5b4843fb2c6ff5d4c8d2a2
Reviewed-on: https://go-review.googlesource.com/14769
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-21 22:39:44 +00:00
Matthew Dempsky
8caf19c46f net: fix TestUpdateResolvConf after CL 18860
When writing a fake dnsConfig to conf.dnsConfig, set lastChecked to an
hour into the future.  This causes dnsclient_unix.go's
tryUpdate("/etc/resolv.conf") calls to short-circuit and ignore that
/etc/resolv.conf's mtime differs from the test's fake resolv.conf
file.  We only need to zero out lastChecked in teardown.

While here, this makes two other tryUpdate(conf.path) test calls
pointless, since they'll now short circuit too.

Fixes #14437.

Change-Id: Ieb520388e319b9826dfa49f134907f4927608a53
Reviewed-on: https://go-review.googlesource.com/19777
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2016-02-21 20:59:45 +00:00
Matthew Dempsky
8ffe496ae7 cmd/compile, runtime: eliminate unnecessary algorithm types
There's no need for 8 different ways to represent that a type is
non-comparable.

While here, move AMEM out of the runtime-known algorithm values since
it's not needed at run-time, and get rid of the unused AUNK constant.

Change-Id: Ie23972b692c6f27fc5f1a908561b3e26ef5a50e9
Reviewed-on: https://go-review.googlesource.com/19779
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-02-21 20:59:36 +00:00
Shenghou Ma
e960302410 runtime: when crash with panic, call user Error/String methods before freezing the world
Fixes #14432.

Change-Id: I0a92ef86de95de39217df9a664d8034ef685a906
Reviewed-on: https://go-review.googlesource.com/19792
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-21 20:18:51 +00:00
Josh Bleecher Snyder
bc8458ab02 cmd/compile: use && in generated eq algs
This allows the compiler to generate better code
containing fewer jumps and only a single return value.

Cuts 12k off cmd/go and 16k off golang.org/x/tools/cmd/godoc, approx 0.1% each.

For #6853 and #9930

Change-Id: I009616df797760b01e09f06357a2d6fd6ebcf307
Reviewed-on: https://go-review.googlesource.com/19767
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-21 18:17:39 +00:00
Josh Bleecher Snyder
4cef0e980a cmd/compile: don't generate algs for [0]T and [1]T
All [0]T values are equal.
[1]T values are equal iff their sole components are.

This types show up most frequently as a by-product of variadic
function calls, such as fmt.Printf("abc") or fmt.Printf("%v", x).

Cuts 12k off cmd/go and 22k off golang.org/x/tools/cmd/godoc, approx 0.1% each.

For #6853 and #9930

Change-Id: Ic9b7aeb8cc945804246340f6f5e67bbf6008773e
Reviewed-on: https://go-review.googlesource.com/19766
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-21 18:13:55 +00:00
Suharsh Sivakumar
9ad41f6243 net: ensure lookupStatic* returns copy of slice to disallow cache corruption.
Fixes #14212

Change-Id: I74325dfaa1fb48f4b281c2d42157b563f1e42a94
Reviewed-on: https://go-review.googlesource.com/19201
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2016-02-21 16:36:56 +00:00
Josh Bleecher Snyder
e43c74a0d8 all: use cannot instead of can not
You can not use cannot, but you cannot spell cannot can not.

Change-Id: I2f0971481a460804de96fd8c9e46a9cc62a3fc5b
Reviewed-on: https://go-review.googlesource.com/19772
Reviewed-by: Rob Pike <r@golang.org>
2016-02-21 15:35:50 +00:00
Martin Möhrmann
5dc053b9de fmt: fix zero padding for NaN
Makes zero padding of NaN and infinities consistent
by using spaces instead of zeroes to pad NaN.
Adds more tests for NaN formatting.

Fixes #14421

Change-Id: Ia20f8e878cc81ac72a744ec10d65e84b94e09c6a
Reviewed-on: https://go-review.googlesource.com/19723
Reviewed-by: Rob Pike <r@golang.org>
2016-02-21 12:04:21 +00:00
Robert Griesemer
aa5b44aeab cmd/compile: set lexer nlsemi state directly
The old code used an extra function call and switch to inspect the
current token and determine the new state of curio.nlsemi. However,
the lexer knows the token w/o the need of an extra test and thus
can set curio.nlsemi directly:

- removed need for extra function call in next
- renamed _yylex to next
- set nlsemi at the point a token is identified
- moved nlsemi from curio to lexer - it's really part of the lexer state

This change makes the lexer call sequence less convoluted and should
also speed up the lexing a bit.

Change-Id: Iaf2683081f04231cb62c94e1400d455f98f6f82a
Reviewed-on: https://go-review.googlesource.com/19765
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-02-21 05:13:58 +00:00
Robert Griesemer
20ee67acc9 cmd/compile: test for lower-case letters first in isAlpha
Lower-case letters are more common in identifiers.

Change-Id: I49c39e3ac810eea57d15c1433608daec212c9792
Reviewed-on: https://go-review.googlesource.com/19760
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-02-21 05:12:38 +00:00
Robert Griesemer
11e51ed4bc cmd/compile: remove gratuituous copying of lexer token data
Rename yySymType to lexer; should eventually capture all lexer state.
Embed lexer in parser and access lexer token data directly.

Change-Id: I246194705d594f80426f3ba77d8580af9185daf7
Reviewed-on: https://go-review.googlesource.com/19759
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-02-21 05:12:14 +00:00
Matthew Dempsky
5621b09dad cmd/compile: simplify import path handling
Change-Id: I64c9b4c4978520a9bc989b7fd7d5708d364dc88a
Reviewed-on: https://go-review.googlesource.com/19755
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-21 05:05:08 +00:00
Josh Bleecher Snyder
5fc43c94bf net/url: simplify value lookup
Change-Id: Ic998c189003d4dee758fca3b5ac954d5b54d3d36
Reviewed-on: https://go-review.googlesource.com/19764
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-21 04:00:01 +00:00
Josh Bleecher Snyder
1dbba1a2b7 encoding/hex: minor cleanup
Change-Id: I404fd946dd0607fa41e2abe0d1d8081d4433ff0a
Reviewed-on: https://go-review.googlesource.com/19762
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-21 03:59:22 +00:00
Josh Bleecher Snyder
de6a5881bb bytes: make Buffer comment more accurate
Change-Id: Ief22b3dbba9616dd40bf3ea8e2633d3c5e7d1886
Reviewed-on: https://go-review.googlesource.com/19761
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-21 03:57:24 +00:00
Mikio Hara
92b74d0940 net: add missing aborted connection handling on accept test
This change adds TestAcceptIgnoreAbortedConnRequest to test accepting
aborted connection requests on all supported platforms except Plan 9.

Change-Id: I5936b04085184ff348539962289b1167ec4ac619
Reviewed-on: https://go-review.googlesource.com/19707
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-21 03:32:36 +00:00
Mikio Hara
64d2a88105 net/internal/socktest: add missing support for AcceptEx
Change-Id: I37faedc6fa316fffac80093b01e15429995b0f5b
Reviewed-on: https://go-review.googlesource.com/19705
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-21 03:09:25 +00:00
Mikio Hara
6716a54e36 net: make newLocalListener handle network argument correcly
Change-Id: I8987e705af069846e6668e2f2104e0254e695139
Reviewed-on: https://go-review.googlesource.com/19706
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-21 02:55:23 +00:00
Mikio Hara
9194421eed net: deflake TestDialerDualStackFDLeak
We need to stop the mock listener certainly for preventing it from
pulling up pending connections during measurement.

Fixes #14223.

Change-Id: Ia40db01d1262963697b83ca867563dec77d772e3
Reviewed-on: https://go-review.googlesource.com/19246
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-21 02:54:12 +00:00
David Crawshaw
e6d6ad47f5 cmd/compile: update some type names in comments
Change-Id: I741a1205bc6256c08b36efed43652bfbb75e4401
Reviewed-on: https://go-review.googlesource.com/19691
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-20 20:16:27 +00:00
David Crawshaw
41eb5ca089 cmd/link: typo in error message
Change-Id: Ideeef320d6a01a10c89524b6d895a64210a60f64
Reviewed-on: https://go-review.googlesource.com/19693
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-20 20:16:17 +00:00
Matthew Dempsky
3a11c8d319 cmd/compile: simplify if statement parsing
Somewhat notably, this means long if statement chains are now parsed
recursively, rather than iteratively.  This shouldn't be a concern
though, as several other functions (e.g., gen, typecheck, walk)
already use recursion to process the parsed if statement Node trees.

Change-Id: Ic8c12ace9021c870d60c06f5db86a48c4ec57084
Reviewed-on: https://go-review.googlesource.com/19756
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-20 18:59:57 +00:00
Matthew Dempsky
5efbdd9d10 net: fix race in (*resolverConfig).tryUpdate
Fixes #14072.

Change-Id: Ie31caa06690ac621906fc5acd34da2efa4e2049f
Reviewed-on: https://go-review.googlesource.com/18860
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
2016-02-20 10:03:47 +00:00
Shenghou Ma
315f4c70f1 runtime: use correct psABI SP alignment before calling libc mmap
Fixes #14384.

Change-Id: Ib025cf2d20754b4c2db52f0a8a4717fd303371d6
Reviewed-on: https://go-review.googlesource.com/19660
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2016-02-20 06:10:01 +00:00
Matthew Dempsky
3e40f13cf3 cmd/compile: eliminate global fileparser
Change-Id: I9b8b13731ccc2ba33d21642b12cc614dde0804b1
Reviewed-on: https://go-review.googlesource.com/19752
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2016-02-20 05:41:53 +00:00
Matthew Dempsky
338a891e79 cmd/compile: eliminate pushedio and savedstate
While here, get drop the lexlineno{++,--} hacks for canned imports.
They were added in commit d3237f9, but don't seem to serve any
purpose.

Change-Id: I00f9e6be0ae9f217f2fa113b85e041dfd0303757
Reviewed-on: https://go-review.googlesource.com/19652
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2016-02-20 05:14:32 +00:00
Matthew Dempsky
4e6e8e8c58 cmd/compile: change two pushedio.bin tests to use importpkg instead
pushedio.bin and importpkg are both non-nil iff we're parsing an
package's export data, so "pushedio.bin == nil" and "importpkg == nil"
are equivalent tests.

Change-Id: I571ee908fef867117ef72c5da1eb24fe9b3fd12d
Reviewed-on: https://go-review.googlesource.com/19751
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-20 04:40:29 +00:00
Matthew Dempsky
f8e41f6f59 cmd/compile: eliminate Io.infile and Io.cp
infile is never read and cp is never written.  Both are unneeded.

Change-Id: I0a90bb772a53a580ea4be8e5f0f770da7c1acf3a
Reviewed-on: https://go-review.googlesource.com/19651
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-20 04:39:09 +00:00
Matthew Dempsky
699a2ba137 cmd/compile: switch cannedimports to use a Biobuf
Allows eliminating the separate lexer code paths for reading from cp
in the next CL.

Change-Id: I49098ecef32b735c4a01374443c2f847235ff964
Reviewed-on: https://go-review.googlesource.com/19750
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-20 04:37:50 +00:00
Matthew Dempsky
7d3a40978a cmd/compile: refactor export data parsing
Merge push_parser and pop_parser into a single parse_import function
and inline unimportfile. Shake out function boundaries a little bit so
that the symmetry is readily visible.

Move the import_package call into parse_import (and inline
import_there into import_package).  This means importfile no longer
needs to provide fake import data to be needlessly lexed/parsed every
time it's called.

Also, instead of indicating import success/failure by whether the next
token is "package", import_spec can just check whether importpkg is
non-nil.

Tangentially, this somehow alters the diagnostics produced for
test/fixedbugs/issue11610.go.  However, the new diagnostics are more
consistent with those produced when the empty import statement is
absent, which seems more desirable than maintaining the previous
errors.

Change-Id: I5cd1c22aa14da8a743ef569ff084711d137279d5
Reviewed-on: https://go-review.googlesource.com/19650
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-20 04:31:42 +00:00
Ian Lance Taylor
0d5e6a3f07 cmd/api: fix benchmark to ignore internal packages
Change-Id: I8ee46287ae0744efa83ad343997ad6835520fa5c
Reviewed-on: https://go-review.googlesource.com/19688
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-20 01:58:38 +00:00
Martin Möhrmann
5a9c128a03 fmt: remove math package dependency and avoid float operations
Remove floating point comparisons and rely only on the information
directly provided by appendFloat.
Make restoring the zero padding flag explicit instead of using a defer.
Rearrange some case distinctions to remove duplicated code.
Add more test cases for zero padded floating point numbers with sign.

benchmark                   old ns/op     new ns/op     delta
BenchmarkSprintfFloat-4     187           180           -3.74%

Change-Id: Ifa2ae85257909f40b1b18118c92b516933271729
Reviewed-on: https://go-review.googlesource.com/19721
Reviewed-by: Rob Pike <r@golang.org>
2016-02-19 22:55:30 +00:00
Matthew Dempsky
113c4d2581 cmd/compile: refactor import statement parsing
Combine parser's import_stmt and import_here methods as a single new
importdcl method, and cleanup conditional logic slightly to make the
code easier to follow.

Also, eliminate importfile's unused line parameter, and get rid of all
of its duplicate type assertions.

Change-Id: Ic37ae8490afedc533f98ead9feef383e3599bc01
Reviewed-on: https://go-review.googlesource.com/19629
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-19 22:54:15 +00:00
Alexandru Moșoi
5949524fc4 [dev.ssa] cmd/compile/internal/ssa: handle phis in fuse.
Change-Id: Idd880cc6c1e5dc34dddbdea0841a7a718d2fa836
Reviewed-on: https://go-review.googlesource.com/19544
Reviewed-by: David Chase <drchase@google.com>
2016-02-19 22:44:29 +00:00
Alexandru Moșoi
e4bee4be92 [dev.ssa] cmd/compile/internal/ssa: constant fold truncates and bool comparisons
Change-Id: I731722eb77f373ff7d6101f93830ab0a50497e2c
Reviewed-on: https://go-review.googlesource.com/19542
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-19 21:56:26 +00:00
Matthew Dempsky
d930d69fd9 cmd/compile: make -A and -newexport compatible
Packages compiled with -A may reference the builtin "any" type, so it
needs to be included in the list of predeclared types for binary
import/export.

Also, when -A is used, mark all symbols as SymExport instead of
SymPackage in importsym.  This parallels the logic in autoexport and
is necessary to prevent a "export/package mismatch" errors in
exportsym during dumpexport's verifyExport pass.

Change-Id: Iff5ec5fbfe2219525ec9d1a975307fa8936af9b9
Reviewed-on: https://go-review.googlesource.com/19627
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-19 21:42:04 +00:00
Matthew Dempsky
1402e522c6 cmd/compile: load builtin export data only once
Previously, the builtin runtime export data was reparsed before every
Go source file, and the unsafe export data was reparsed for every
import of package unsafe.  Now, we parse both of them just once ahead
of time.

This does mean package unsafe's export data will be loaded even when
compiling packages that don't import it, but it's tiny anyway.

Change-Id: Ic6931bc58f6d62f664348bfa932f92d4ccacc3ef
Reviewed-on: https://go-review.googlesource.com/19626
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-19 19:56:32 +00:00
David Chase
fb2af2b35b cmd/compile: don't walk field-name syntax in esc.go
Walking the field name as if it were an expression
caused a called to haspointers with a TFIELD, which panics.
Trigger was a field at a large offset within a large struct,
combined with a struct literal expression mentioning that
field.

Fixes #14405

Change-Id: I4589badae27cf3d7cf365f3a66c13447512f41f9
Reviewed-on: https://go-review.googlesource.com/19699
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-19 19:40:49 +00:00
Damien Neil
0e34737c9a cmd/go: don't assume cc supports -gno-record-gcc-switches
NetBSD's C compiler appears to support -fdebug-prefix-map but
not -gno-record-gcc-switches. Remove assumption that support
for the former implies the latter.

Change-Id: Iecad9e4f497ea4edc1ce440010e6fe19dc3e0566
Reviewed-on: https://go-review.googlesource.com/19686
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-19 19:12:56 +00:00
Matthew Dempsky
9a184b22ee cmd/compile: refresh builtin.go
The export data format was augmented with a new "unsafe-uintptr" tag
in https://golang.org/cl/18584, but builtin.go was not regenerated.

While here, add a test to make sure builtin.go stays up to date in the
future.

Change-Id: I4ae17da29f0855bef6ec0fcc10e7082c8427d39c
Reviewed-on: https://go-review.googlesource.com/19681
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-19 19:08:47 +00:00
Tal Shprecher
5c5e8d4105 cmd/compile: avoid leak of dottype expression if type does not contain pointers.
Fixes #13805

Change-Id: Ica9aae2e054b74f67d28ab27f72c52a3f03eeb59
Reviewed-on: https://go-review.googlesource.com/19489
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-19 16:10:14 +00:00
Ian Lance Taylor
c8e7b34b59 runtime: skip cgo check for non-pointer slice elements
Fixes #14387.

Change-Id: Icc98be80f549c5e1f55c5e693bfea97b456a6c41
Reviewed-on: https://go-review.googlesource.com/19621
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-19 16:07:27 +00:00
Mohit Agarwal
277024bd6f cmd/go: don't set GO15VENDOREXPERIMENT in TestSymlinksVendor
Change-Id: I14947b64bdafd975bf3915eceb07f98897304a85
Reviewed-on: https://go-review.googlesource.com/19708
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-19 15:54:12 +00:00
Russ Cox
9aa630faa8 cmd/dist: accept "//+build" with no spaces, like go/build
The go/build parser accepts "//+build", with no spaces.
Make the cmd/dist bootstrap parser do the same.
While in theory we should always use the space form,
I copied some code that did not into the standard tree,
and I was very confused that 'go test' had had no problem
but then make.bash died.

(As a reminder, cmd/dist does not use go/build because
cmd/dist must build against earlier versions of Go.)

Change-Id: I90a18014bd878247b8811487e5c1a7589260cbfc
Reviewed-on: https://go-review.googlesource.com/19618
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-19 01:37:51 +00:00
Russ Cox
fe5eac63c4 cmd/internal/obj: hoist fieldtrack code out of x86 back end
Change-Id: I38e59088c37426d914ce2b4dfc79f3d476e06f49
Reviewed-on: https://go-review.googlesource.com/19617
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-19 01:37:46 +00:00
Russ Cox
53ebde225e cmd/cgo: do not use gcc -xc - to compile standard input
We have private reports of compilers that mishandle that.
Write to a temporary file instead.

Change-Id: I92e3cf4274b1a8048741e07fb52b8900c93b915e
Reviewed-on: https://go-review.googlesource.com/19616
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-19 01:37:41 +00:00
Russ Cox
3e23442518 cmd/go: remove GO15VENDOREXPERIMENT variable
The Go 1.6 release notes say that Go 1.7 will remove support
for the GO15VENDOREXPERIMENT environment variable,
making vendoring always on. Do that.

Change-Id: Iba8b79532455828869c1a8076a82edce84259468
Reviewed-on: https://go-review.googlesource.com/19615
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-19 01:35:53 +00:00
Russ Cox
51b624e6a2 cmd/link: remove alternate -X flag spelling
The Go 1.6 release notes say we'll remove the “-X name value” form
(in favor of the “-X name=value” form) in Go 1.7.
Do that.

Also establish the doc/go1.7.txt file.

Change-Id: Ie4565a6bc5dbcf155181754d8d92bfbb23c75338
Reviewed-on: https://go-review.googlesource.com/19614
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-19 01:35:25 +00:00
Russ Cox
0b4f578266 cmd/asm: remove nonexistent amd64 instructions
These have no accepted input syntax and,
as far as I can tell, do not actually exist.

Change-Id: Iafdfb71adccad76230191d922eb7ddf78b7d5898
Reviewed-on: https://go-review.googlesource.com/19612
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-19 01:35:18 +00:00
Russ Cox
76f272d717 cmd/asm: remove support for amd64 3DNow! instructions
3DNotAnymore!

These only ever existed on AMD (not Intel) processors,
and AMD cancelled support for them in August 2010.

Change-Id: Ia362259add9d4f5788fd151fb373f91288677407
Reviewed-on: https://go-review.googlesource.com/19611
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-19 01:35:13 +00:00
Nathan VanBenschoten
b04f3b06ec all: replace strings.Index with strings.Contains where possible
Change-Id: Ia613f1c37bfce800ece0533a5326fca91d99a66a
Reviewed-on: https://go-review.googlesource.com/18120
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
2016-02-19 01:06:05 +00:00
Ian Gudger
952c2fd606 net: fix packDomainName encoding of root and invalid names
Fixes #14372

Change-Id: I40d594582639e87ef2574d37ac868e37ffaa17dc
Reviewed-on: https://go-review.googlesource.com/19623
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-02-19 00:55:47 +00:00
Benoit Sigoure
3ddfaa5653 cmd/gofmt: Ignore file not found errors.
gofmt prints an error to stderr when a file is deleted during its
`filepath.Walk()', which can happen in builds that change the tree
concurrently with gofmt running.

Change-Id: Ia1aa4804f6bc2172baf061c093e16fe56a3ee50c
Reviewed-on: https://go-review.googlesource.com/19301
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-19 00:13:18 +00:00
Brad Fitzpatrick
2eeaaaae75 net/http: fix bug where http2 wasn't enabled on DefaultTransport
I had accidentally disabled a headline feature at the last second. :(

Fixes #14391

Change-Id: I1992c9b801072b7538b95c55242be174075ff932
Reviewed-on: https://go-review.googlesource.com/19672
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-18 23:58:00 +00:00
David Chase
ae276d8c23 [dev.ssa] cmd/compile: reenable TestStackBarrierProfiling
Tested it 1000x on OS X and Linux amd64, no failures.
Updated TODO.

Change-Id: Ia60c8d90962f6e5f7c3ed1ded6ba1b25eee983e1
Reviewed-on: https://go-review.googlesource.com/19662
Reviewed-by: Todd Neal <todd@tneal.org>
2016-02-18 23:21:14 +00:00
Rhys Hiltner
98cc8b4cf2 cmd/link/internal/ld: remove unused call to os.Getwd
This call to os.Getwd (or getwd) has been part of the linker since the C
implementation in 7d507dc6e6. It stopped being used in 26438d4d80, and
survived the conversion to Go in 1f9dbb60ef.

Its return value goes unused (the linker gets the value for AT_comp_dir in
dwarf.go), remove it.

Change-Id: I3d4594813bb4ee0a6af31a36e19d99ec4b863677
Reviewed-on: https://go-review.googlesource.com/19655
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-18 22:34:29 +00:00
Matthew Dempsky
7555f7f2bf cmd/compile: cleanup mkbuiltin.go
Changes largely in preparation for eventually switching the builtin
export data to use the new binary format.

Replace fancy incremental line-by-line scanning with simply reading
the entire object file into memory, finding the export data section,
and processing it that way.

Just use "package runtime" and "package unsafe" in the builtin Go
source files so we don't need to rewrite references to "PACKAGE".

Stop looking for init_PACKAGE_function; it doesn't exist anyway.

Compile package runtime with -u so that its export data marks it as a
"safe" package.

Eliminate requirement to pass "runtime" and "unsafe" as command-line
arguments so that just "go run mkbuiltin.go" works.

Only rewrite builtin.go when successful.

Change-Id: I4addfde9e0cfb30607c7a83de686bde0ad1f035a
Reviewed-on: https://go-review.googlesource.com/19624
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-18 21:41:51 +00:00
Matthew Dempsky
7d80291c4c cmd/compile: eliminate Io.importsafe
It was only really necessary for ensuring that package runtime should
be treated as safe even without a "safe" marker, but mkbuiltin.go now
compiles it with -u.

Change-Id: Ifbcc62436ce40ab732ece667141afd82c1d3b64b
Reviewed-on: https://go-review.googlesource.com/19625
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-18 21:28:57 +00:00
Damien Neil
5bbb98df09 cmd/go, cmd/link: make builds deterministic
Add the following flags when supported by the compiler:
  -gno-record-gcc-switches
  -fdebug-prefix-map=$WORK=/tmp/go-build

Add an empty NAME symbol to the ELF .symtab. GNU ld will add a NAME
symbol when one is not present; including one of our own prevents it
from adding a reference to the link tempdir.

Fixes #13247 for compilers that support -fdebug-prefix-map. (gcc, clang
in the near future.)

Change-Id: I221c71fc59cd23ee8c99bcc038793ff4623c9ffc
Reviewed-on: https://go-review.googlesource.com/19363
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
2016-02-18 20:56:29 +00:00
Matthew Dempsky
1a94431a78 cmd/cgo: support multiple-value special form in VarDecl
Fixes #13930.

Change-Id: I124b7d31d1f2be05b7f23dafd1e52d9f3f02f3f0
Reviewed-on: https://go-review.googlesource.com/18623
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-18 20:12:20 +00:00
Robert Griesemer
a576e9883c text/scanner: mention package when reporting errors to stderr
Fixes #14166.

Change-Id: I325b283a1d53e73a6d862611c446820ab94a161c
Reviewed-on: https://go-review.googlesource.com/19622
Reviewed-by: Damien Neil <dneil@google.com>
2016-02-18 19:46:51 +00:00
Matt Bostock
8fd1634f44 sort: Fix typo in stable sort comment
Fix `reverences`, which I believe should read as `references`.

Change-Id: I450efcbeee0f8861a84b209f2e6636764034232a
Reviewed-on: https://go-review.googlesource.com/19469
Reviewed-by: Russ Cox <rsc@golang.org>
2016-02-18 19:20:41 +00:00
Alberto Donizetti
3e91e8aa35 go/internal/gcimporter: add missing argument to error message
Change-Id: I3071f0e876506c6dc283e97bc15f157bf2ff011e
Reviewed-on: https://go-review.googlesource.com/19641
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-18 19:12:46 +00:00
Robert Griesemer
c51f9173ad go/constant: fix doc strings
Fixes #14357.

Change-Id: I91acff0b0cc7be2bcbad68925a19a437dbd4c83d
Reviewed-on: https://go-review.googlesource.com/19620
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-02-18 17:44:29 +00:00
Russ Cox
c4f902bef4 net/http: update bundle command
This is the bundle command's new usage and new output header,
after CL 19428.

Actually running this command would work but would bring in
a newer x/net/http2 that we don't want yet.

Change-Id: Ic6082ca00102a2df1f7632eebf9aca41fdcdb444
Reviewed-on: https://go-review.googlesource.com/19551
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2016-02-17 18:23:46 +00:00
Alexandru Moșoi
bc1fb32e9d [dev.ssa] cmd/compile/internal/ssa: fix the type of constant shift folding.
Also throw in a few more shift constant folding.

Change-Id: Iabe00596987f594e0686fbac3d76376d94612340
Reviewed-on: https://go-review.googlesource.com/19543
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-17 16:31:44 +00:00
Alexandru Moșoi
c67cac0703 [dev.ssa] cmd/compile/internal/ssa: transform degenerate control blocks
* In cases where we end up with empty branches like in
if a then jmp b else jmp b;
the flow can be replaced by a; jmp b.

The following functions is optimized as follows:
func f(a bool, x int) int {
        v := 0
        if a {
                v = -1
        } else {
                v = -1
        }
        return x | v
}

Before this change:
02819 (arith_ssa.go:362)  VARDEF "".~r2+16(FP)
02820 (arith_ssa.go:362)  MOVQ  $0, "".~r2+16(FP)
02821 (arith_ssa.go:362)  MOVB  "".a(FP), AX
02822 (arith_ssa.go:362)  TESTB AX, AX
02823 (arith_ssa.go:364)  JEQ 2824
02824 (arith_ssa.go:369)  VARDEF "".~r2+16(FP)
02825 (arith_ssa.go:369)  MOVQ  $-1, "".~r2+16(FP)
02826 (arith_ssa.go:369)  RET

After this change:
02819 (arith_ssa.go:362)  VARDEF "".~r2+16(FP)
02820 (arith_ssa.go:369)  VARDEF "".~r2+16(FP)
02821 (arith_ssa.go:369)  MOVQ  $-1, "".~r2+16(FP)
02822 (arith_ssa.go:369)  RET

Updates #14277

Change-Id: Ibe7d284f43406c704903632a4fcf2a4a64059686
Reviewed-on: https://go-review.googlesource.com/19464
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-17 10:43:48 +00:00
Ian Lance Taylor
aa22c42d70 cmd/go: avoid race on test environment
Fixes #14337.

Change-Id: I58aef7e08d936b0712da577dd1ce5c9ed5d8bfd2
Reviewed-on: https://go-review.googlesource.com/19513
Reviewed-by: Russ Cox <rsc@golang.org>
2016-02-16 22:02:56 +00:00
Alexandru Moșoi
65855cf640 [dev.ssa] cmd/compile/internal/ssa: factor out copyelimValue and phielimValue
* Merge copyelim into phielim.
* Add phielimValue to rewrite. cgoIsGoPointer is, for example, 2
instructions smaller now.

Change-Id: I8baeb206d1b3ef8aba4a6e3bcdc432959bcae2d5
Reviewed-on: https://go-review.googlesource.com/19462
Reviewed-by: David Chase <drchase@google.com>
2016-02-16 21:02:56 +00:00
Austin Clements
7c22af830a runtime: fix deadlock in TestCrashDumpsAllThreads
TestCrashDumpsAllThreads carefully sets the number of Ps to one
greater than the number of non-preemptible loops it starts so that the
main goroutine can continue to run (necessary because of #10958).
However, if GC starts, it can take over that one spare P and lock up
the system while waiting for the non-preemptible loops, causing the
test to eventually time out. This deadlock is easily reproducible if
you run the runtime test with GOGC=1.

Fix this by forcing GOGC=off when running this test.

Change-Id: Ifb22da5ce33f9a61700a326ea92fcf4b049721d1
Reviewed-on: https://go-review.googlesource.com/19516
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-02-16 20:18:40 +00:00
Russ Cox
feb2a5d610 cmd/compile: print struct tags in var decl in inlined func body
This bug was introduced in golang.org/cl/18217,
while trying to fix #13777.

Originally I wanted to just disable inlining for the case
being handled incorrectly, but it's fairly difficult to detect
and much easier just to fix. Since the case being handled
incorrectly was inlined correctly in Go 1.5, not inlining it
would also be somewhat of a regression.
So just fix it.

Test case copied from Ian's CL 19520.

The mistake to worry about in this CL would be relaxing
the condition too much (we now print the note more often
than we did yesterday). To confirm that we'd catch this mistake,
I checked that changing (!fmtbody || !t.Funarg) to (true) does
cause fixedbugs/issue13777.go to fail. And putting it back
to what is written in this CL makes that test pass again
as well as the new fixedbugs/issue14331.go.
So I believe that the new condition is correct for both constraints.

Fixes #14331.

Change-Id: I91f75a4d5d07c53af5caea1855c780d9874b8df6
Reviewed-on: https://go-review.googlesource.com/19514
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-16 19:39:10 +00:00
Alex Brainman
e136cac48c net: make TestInterfaceAddrsWithNetsh more robust
TestInterfaceAddrsWithNetsh invokes Windows netsh command passing
it a particular interface name. This approach somehow does not work
on some computers (see issue for details). Change that to call netsh
without specifying any interface name. This provides output for all
interfaces available. So we can achieve same goal parsing this output.
Also makes test faster because we only need to invoke netsh once.

Fixes #14130.

Change-Id: I7911692ca64e372af1e1f9d6acb718c67071de67
Reviewed-on: https://go-review.googlesource.com/19441
Reviewed-by: Volker Dobler <dr.volker.dobler@gmail.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-02-16 17:16:00 +00:00
Austin Clements
0c02bc009a runtime: show panics in traceback
We used to include panic calls in tracebacks; however, when
runtime.panic was renamed to runtime.gopanic in the conversion of the
runtime to Go, we missed the special case in showframe that includes
panic calls even though they're in package runtime.

Fix the function name check in showframe (and, while we're here, fix
the other check for "runtime.panic" in runtime/pprof). Since the
"runtime.gopanic" name doesn't match what users call panic and hence
isn't very user-friendly, make traceback rewrite it to just "panic".

Updates #5832, #13857. Fixes #14315.

Change-Id: I8059621b41ec043e63d5cfb4cbee479f47f64973
Reviewed-on: https://go-review.googlesource.com/19492
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-02-16 16:58:43 +00:00
Todd Neal
adc8d491c2 [dev.ssa] cmd/compiler: rewrite AND x const as a shift if possible
ANDs of constants whose only set bits are leading or trailing can be
rewritten as two shifts instead.  This is slightly faster for 32 or
64 bit operands.

Change-Id: Id5c1ff27e5a4df22fac67b03b9bddb944871145d
Reviewed-on: https://go-review.googlesource.com/19485
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-16 16:53:16 +00:00
Ian Lance Taylor
387d5b8cfb runtime: remove debugging print in cgoCheckTypedBlock
Change-Id: I83639fcde88e7d9747b54728a9481ee2e1b23a64
Reviewed-on: https://go-review.googlesource.com/19486
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-13 17:33:22 +00:00
Brad Fitzpatrick
76cb265f28 net/http: update bundled http2 to fix gzip crash on Read after NewReader error
Updates x/net/http2 to git rev 62685c2 for https://golang.org/cl/19483

Change-Id: Id01331cdba03934a6e55e55ad9c2ae27461ba149
Reviewed-on: https://go-review.googlesource.com/19484
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-13 06:46:47 +00:00
Keith Randall
e3033fc535 cmd/compile: add write barrier to type switch
Type switches need write barriers if the written-to
variable is heap allocated.

For the added needwritebarrier call, the right arg doesn't
really matter, I just pass something that will never disqualify
the write barrier.  The left arg is the one that matters.

Fixes #14306

Change-Id: Ic2754167cce062064ea2eeac2944ea4f77cc9c3b
Reviewed-on: https://go-review.googlesource.com/19481
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-12 21:07:21 +00:00
Ian Lance Taylor
c93193aec0 runtime: return errno value from Solaris mmap as expected
The code in mem_bsd.go expects that when mmap fails it will return a
positive errno value.  This fixes the Solaris implementation of mmap to
work as expected.

Change-Id: Id1c34a9b916e8dc955ced90ea2f4af8321d92265
Reviewed-on: https://go-review.googlesource.com/19477
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-02-12 19:20:19 +00:00
Ryan Brown
68aa7fb636 cmd/link: fix padding for dwarf aranges on 32 bit platforms.
Fixes #14278

Change-Id: I6a0c1370d595f0573ff0eb933450b1eea41f4bb3
Reviewed-on: https://go-review.googlesource.com/19452
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-02-12 19:13:11 +00:00
Todd Neal
e49c910900 [dev.ssa] cmd/compile: print aux value also
When printing a value with just an aux, print the aux as well. Debugging
cse is easier when the aux values are visible.

Change-Id: Ifaf96bdb25462c9df7ba01fdfdbf0d379631f555
Reviewed-on: https://go-review.googlesource.com/19476
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-12 00:44:36 +00:00
Ian Lance Taylor
cc0a04d351 runtime: fix errno sign for some mmap and mincore cases
The caller of mmap expects it to return a positive errno value, but the
linux-arm64 and nacl-386 system calls returned a negative errno value.
Correct them to negate the errno value.

The caller of mincore expects it to return a negative errno value (yes,
this is inconsistent), but the linux-mips64x and linux-ppc64x system
call returned a positive errno value.  Correct them to negate the errno
value.

Add a test that mmap returns errno with the correct sign.  Brad added a
test for mincore's errno value in https://golang.org/cl/19457.

Fixes #14297.

Change-Id: I2b93f32e679bd1eae1c9aef9ae7bcf0ba39521b5
Reviewed-on: https://go-review.googlesource.com/19455
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-12 00:07:29 +00:00
Gerrit Code Review
d509788d97 Merge "[dev.ssa] Merge remote-tracking branch 'origin/master' into mergebranch" into dev.ssa 2016-02-11 21:32:48 +00:00
Keith Randall
6d40c62732 [dev.ssa] cmd/compile: remove redundant compare ops
Flagalloc was recalculating flags is some situations
when it didn't need to.  Fixed by using the same name
for the original flag calculation instruction throughout.

Change-Id: Ic0bf58f728a8d87748434dd25a67b0708755e1f8
Reviewed-on: https://go-review.googlesource.com/19237
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-11 21:01:17 +00:00
Brad Fitzpatrick
70418eb819 runtime: add test for mincore's return value sign on Linux
Updates #14297

Change-Id: I6b5f5020af5efaaa71280bdeb2ff99785ee9b959
Reviewed-on: https://go-review.googlesource.com/19457
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-11 19:09:50 +00:00
Brad Fitzpatrick
53b6661673 net/http/httptest: make Server.CloseClientConnections wait for conns to close
httptest.Server was rewritten during Go 1.6, but
CloseClientConnections was accidentally made async in the rewrite and
not caught due to lack of tests.

Restore the Go 1.5 behavior and add tests.

Fixes #14290
Updates #14291

Change-Id: I14f01849066785053ccca2373931bc82d78c0a13
Reviewed-on: https://go-review.googlesource.com/19432
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-02-10 21:30:13 +00:00
Keith Randall
eb0cff9a76 [dev.ssa] Merge remote-tracking branch 'origin/master' into mergebranch
Semi-regular merge from tip to dev.ssa.

Two fixes:
1) Mark selectgo as not returning.  This caused problems
   because there are no VARKILL ops on the selectgo path,
   causing things to be marked live that shouldn't be.
2) Tell the amd64 assembler that addressing modes like
   name(SP)(AX*4) are ok.

Change-Id: I9ca81c76391b1a65cc47edc8610c70ff1a621913
2016-02-10 09:31:41 -08:00
Robert Griesemer
7ebf653fcc go/internal/gcimporter: interpret relative srcDir relative to cwd
1) go/types.dir: Correctly return "." if there is no path.
2) go/internal/gcimporter.FindPkg: work-around for build.Import
   (build.Import doesn't produce expected result if srcDir is
   relative). See also issue 14282.

Fixes #14215.

Change-Id: Ia3721f9ad8a1115d2595fe99b04baaf30d5765f2
Reviewed-on: https://go-review.googlesource.com/19393
Reviewed-by: Russ Cox <rsc@golang.org>
2016-02-10 16:46:50 +00:00
Volker Dobler
811b785193 net: make getmac based tests on windows more robust
The Windows 7 getmac command may report the physical address of an adapter
as "Disabled" or "N/A". Handle these two cases to make the tests more
robust when building on Windows with manually disabled adapters or turned
off hardware.

Addresses issue #14130.

Change-Id: I0c2f8554b4b6810568e4e60ed53857599401f296
Reviewed-on: https://go-review.googlesource.com/19411
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-02-10 14:42:30 +00:00
Alexandru Moșoi
fd458ba499 [dev.ssa] cmd/compile/internal/ssa: more simplifications and normalization
Found by inspecting random generated code.

Change-Id: I57d0fed7c3a8dc91fd13cdccb4819101f9976ec9
Reviewed-on: https://go-review.googlesource.com/19413
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-09 22:14:02 +00:00
Brad Fitzpatrick
79d9f48c73 net/http: be more conservative about enabling http2 on Transports
For now, don't enable http2 when Transport.TLSConfig != nil.
See background in #14275.

Also don't enable http2 when ExpectContinueTimeout is specified for
now, in case somebody depends on that functionality. (It is not yet
implemented in http2, and was only just added to net/http too in Go
1.6, so nobody would be setting it yet).

Updates #14275
Updates #13851

Change-Id: I192d555f5fb0a567bd89b6ad87175bbdd7891ae3
Reviewed-on: https://go-review.googlesource.com/19424
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-09 21:12:32 +00:00
Alexandru Moșoi
d0d04d2d6c [dev.ssa] cmd/compile/internal/ssa: handle rewrite of Phis.
* Phis can have variable number of arguments, but rulegen assumed that
each operation has fixed number of arguments.
* Rewriting Phis is necessary to handle the following case:

func f1_ssa(a bool, x int) int {
        v := 0
        if a {
                v = -1
        } else {
                v = -1
        }
        return x|v
}

Change-Id: Iff6bd411b854f3d1d6d3ce21934bf566757094f2
Reviewed-on: https://go-review.googlesource.com/19412
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-09 20:46:16 +00:00
Russ Cox
ee451770a7 cmd/go: use GOPATH order for compile -I and link -L options
Given GOPATH=p1:p2 and source code of just the right form,
the go command could previously end up invoking the compiler
with -I p2 -I p1 or the linker with -L p2 -L p1, so that
compiled packages in p2 incorrectly shadowed packages in p1.
If foo were in both p1 and p2 and the compilation of bar
were such that the -I and -L options were inverted in this way,
then

	GOPATH=p2 go install foo
	GOPATH=p1:p2 go install bar

would get the p2 copy of foo instead of the (expected) p1 copy of foo.

This manifested in real usage in a few different ways, but in all
the root cause was that the -I or -L option sequence did not
match GOPATH.

Make it match GOPATH.

Fixes #14176 (second report).
Fixes #14192.
Related but less common issue #14271 not fixed.

Change-Id: I9c0f69042bb2bf92c9fc370535da2c60a1187d30
Reviewed-on: https://go-review.googlesource.com/19385
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2016-02-09 20:36:10 +00:00
Russ Cox
558a213d55 build: mv cmd/vendor cmd/internal/unvendor
And update two imports in cmd/internal/objfile/disasm.go.
This makes GO15VENDOREXPERIMENT=0 ./make.bash work.
For Go 1.7 we will move it back.

Fixes #14236.

Change-Id: I429c9af4baff8496f83d113b1b03b90e309f4f48
Reviewed-on: https://go-review.googlesource.com/19384
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-09 20:36:08 +00:00
Russ Cox
97572d5552 cmd/go: silence standard imports non-standard error for non-existent import target
This error only affects the compilation of the standard library,
but I discovered that if you import "notexist" from the standard
library then you get both an error about notexist not existing
and an error about notexist being a non-standard package
(because the non-existant package is in fact not a standard package).
Silence the second error.

Change-Id: Ib4c1523e89844260fde90de3459ec1e752df8f25
Reviewed-on: https://go-review.googlesource.com/19383
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-09 20:36:06 +00:00
Keith Randall
7f7f7cddec [dev.ssa] cmd/compile: split decompose pass in two
A first pass to decompose user types (structs, maybe
arrays someday), and a second pass to decompose builtin
types (strings, interfaces, slices, complex).  David wants
this for value range analysis so he can have structs decomposed
but slices and friends will still be intact and he can deduce
things like the length of a slice is >= 0.

Change-Id: Ia2300d07663329b51ed6270cfed21d31980daa7c
Reviewed-on: https://go-review.googlesource.com/19340
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: David Chase <drchase@google.com>
2016-02-09 02:18:31 +00:00
Todd Neal
9763f6f8cf [dev.ssa] cmd/compile: add test to detect cse bug
Adds a test to detect the bug that slipped in earlier when partioning
by the Aux value, but not sorting by it.

Change-Id: I56d0ba76383bbc1514b3dabd295e369771c26645
Reviewed-on: https://go-review.googlesource.com/19382
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-09 02:06:25 +00:00
Brad Fitzpatrick
6a208efbdf net/http: make ListenAndServeTLS treat GetCertificate as a set cert too
ListenAndServeTLS doesn't require cert and key file names if the
server's TLSConfig has a cert configured. This code was never updated
when the GetCertificate hook was added to *tls.Config, however.

Fixes #14268

Change-Id: Ib282ebb05697edd37ed8ff105972cbd1176d900b
Reviewed-on: https://go-review.googlesource.com/19381
Reviewed-by: Russ Cox <rsc@golang.org>
2016-02-09 00:17:25 +00:00
Robert Griesemer
41191e192c go/constant: fix String() implementation
Fixes #14262.

Change-Id: Id590995dd4460e81f6b91bcfb3f02515a97650fe
Reviewed-on: https://go-review.googlesource.com/19361
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-08 23:10:00 +00:00
Brad Fitzpatrick
77b4c8d9af runtime: fix comment
Fixes #14259

Change-Id: I23fedec0eb85ae28e56bc24539bc864674856130
Reviewed-on: https://go-review.googlesource.com/19318
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-08 22:12:42 +00:00
Ilya Tocar
e93410d3e5 [dev.ssa] cmd/compile: use INC/DEC instead of add when we can
INC/DEC produces slightly faster and smaller code.

Change-Id: I329d9bdb01b90041be45e053d9df640818bf0c2d
Reviewed-on: https://go-review.googlesource.com/19238
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-08 22:02:58 +00:00
Alexandru Moșoi
964dda9bf1 [dev.ssa] cmd/compile/internal/ssa/gen: constant fold Neg*.
Change-Id: Id51e5c97e9653b764b809bf3424f1a6d31b6ffea
Reviewed-on: https://go-review.googlesource.com/19338
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: David Chase <drchase@google.com>
2016-02-08 22:01:13 +00:00
David Chase
58cfa40419 [dev.ssa] cmd/compile: fix for bug in cse speed improvements
Problem was caused by use of Args[].Aux differences
in early partitioning.  This artificially separated
two equivalent expressions because sort ignores the
Aux field, hence things can end with equal things
separated by unequal things and thus the equal things
are split into more than one partition.  For example:
SliceLen(a), SliceLen(b), SliceLen(a).

Fix: don't use Args[].Aux in initial partitioning.

Left in a debugging flag and some debugging Fprintf's;
not sure if that is house style or not.  We'll probably
want to be more systematic in our naming conventions,
e.g. ssa.cse, ssa.scc, etc.

Change-Id: Ib1412539cc30d91ea542c0ac7b2f9b504108ca7f
Reviewed-on: https://go-review.googlesource.com/19316
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-08 18:44:03 +00:00
Robert Griesemer
33a9a98e4d go/types: make sure constants valid in integer operations are in integer form
The operation where this manifested in a crash was % (only defined on integers).
However, the existing code was sloppy in that it didn't retain the integer form
after a value (e.g., 3.0) was accepted as representable in integer form (3 for
the example). We would have seen a crash in such cases for / as well except
that there was code to fix it for just that case.

Remove the special code for / and fix more generally by retaining the integer
form for all operations if applicable.

Fixes #14229.

Change-Id: I8bef769e6299839fade27c6e8b5ff29ad6521d0d
Reviewed-on: https://go-review.googlesource.com/19300
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-02-08 18:05:04 +00:00
Todd Neal
bc07922843 [dev.ssa] cmd/compile: speed up cse
Examine both Aux and AuxInt to form more precise initial partitions.
Restructure loop to avoid repeated type.Equal() call.  Speeds up
compilation of testdata/gen/arithConst_ssa by 25%.

Change-Id: I3cfb1d254adf0601ee69239e1885b0cf2a23575b
Reviewed-on: https://go-review.googlesource.com/19313
Run-TryBot: Todd Neal <todd@tneal.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-08 02:43:19 +00:00
Keith Randall
faf1bdb42b [dev.ssa] cmd/compile: panic doesn't return
Panic doesn't return, so record that we immediately exit after a panic
call.  This will help code analysis.

Change-Id: I4d1f67494f97b6aee130c43ff4e44307b2b0f149
Reviewed-on: https://go-review.googlesource.com/19303
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-07 13:25:33 +00:00
Mikio Hara
fa5e5478c8 runtime: don't call testing.Fatal from worker goroutines
Change-Id: I630d4d2d8a914d6c07f22351a56d5e44a937123e
Reviewed-on: https://go-review.googlesource.com/19245
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-07 03:18:28 +00:00
Ian Lance Taylor
54b4b946b6 net/http: deflake TestCloseNotifierPipelined
The test sends two HTTP/1.1 pipelined requests.  The first is
completedly by the second, and as such triggers an immediate call to the
CloseNotify channel.  The second calls the CloseNotify channel after the
overall connection is closed.

The test was passing fine on gc because the code would enter the select
loop before running the handler, so the send on gotReq would always be
seen first.  On gccgo the code would sometimes enter the select loop
after the handler had already finished, meaning that the select could
choose between gotReq and sawClose.  If it picked sawClose, it would
never close the overall connection, and the httptest server would hang.
The same hang could be induced with gc by adding a time.Sleep
immediately before the select loop.

Deflake the test by 1) don't close the overall connection until both
requests have been seen; 2) don't exit the loop until both closes have
been seen.

Fixes #14231.

Change-Id: I9d20c309125422ce60ac545f78bcfa337aec1c7d
Reviewed-on: https://go-review.googlesource.com/19281
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-06 23:33:23 +00:00
Keith Randall
a3055af45e [dev.ssa] cmd/compile: strength-reduce 64-bit constant divides
The frontend does this for 32 bits and below, but SSA needs
to do it for 64 bits.  The algorithms are all copied from
cgen.go:cgen_div.

Speeds up TimeFormat substantially: ~40% slower to ~10% slower.

Change-Id: I023ea2eb6040df98ccd9105e15ca6ea695610a7a
Reviewed-on: https://go-review.googlesource.com/19302
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2016-02-06 16:52:57 +00:00
Brad Fitzpatrick
fd9fd4c39d net/http: fix doc typo
Change-Id: I93201fa4152f2d60b3eedb8d321a152819033121
Reviewed-on: https://go-review.googlesource.com/19270
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-05 17:06:51 +00:00