]> Cypherpunks repositories - gostls13.git/log
gostls13.git
9 years ago[dev.ssa] cmd/compile: implement genValue for AMD64SETxx
Josh Bleecher Snyder [Mon, 20 Jul 2015 22:21:49 +0000 (15:21 -0700)]
[dev.ssa] cmd/compile: implement genValue for AMD64SETxx

Change-Id: I591f2c0465263dcdeef46920aabf1bbb8e7ac5c0
Reviewed-on: https://go-review.googlesource.com/12436
Reviewed-by: Keith Randall <khr@golang.org>
9 years agoRevert "[dev.ssa] cmd/compile: don't Compile if Unimplemented"
Josh Bleecher Snyder [Fri, 17 Jul 2015 16:47:43 +0000 (16:47 +0000)]
Revert "[dev.ssa] cmd/compile: don't Compile if Unimplemented"

This reverts commit 766bcc92a5b693f336deffc347be52fe68af884a.

Change-Id: I55413c1aa80d82c856a3ea89b4ffccf80fb58013
Reviewed-on: https://go-review.googlesource.com/12361
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/ssa: use width and sign specific opcodes
Keith Randall [Sun, 19 Jul 2015 22:48:20 +0000 (15:48 -0700)]
[dev.ssa] cmd/compile/internal/ssa: use width and sign specific opcodes

Bake the bit width and signedness into opcodes.
Pro: Rewrite rules become easier.  Less chance for confusion.
Con: Lots more opcodes.

Let me know what you think.  I'm leaning towards this, but I could be
convinced otherwise if people think this is too ugly.

Update #11467

Change-Id: Icf1b894268cdf73515877bb123839800d97b9df9
Reviewed-on: https://go-review.googlesource.com/12362
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
9 years ago[dev.ssa] cmd/compile: fix test verb
Josh Bleecher Snyder [Mon, 20 Jul 2015 22:24:03 +0000 (15:24 -0700)]
[dev.ssa] cmd/compile: fix test verb

The verb doesn't do anything, but if/when we move
these to the test directory, having it be right
will be one fewer thing to remember.

Change-Id: Ibf0280d7cc14bf48927e25215de6b91c111983d9
Reviewed-on: https://go-review.googlesource.com/12438
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years ago[dev.ssa] cmd/compile: refactor out zero value creation
Josh Bleecher Snyder [Mon, 20 Jul 2015 22:30:52 +0000 (15:30 -0700)]
[dev.ssa] cmd/compile: refactor out zero value creation

This will be used in a subsequent commit.

Change-Id: I43eca21f4692d99e164c9f6be0760597c46e6a26
Reviewed-on: https://go-review.googlesource.com/12440
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years ago[dev.ssa] test: gofmt {goto,label,label1}.go
Josh Bleecher Snyder [Mon, 20 Jul 2015 20:00:28 +0000 (13:00 -0700)]
[dev.ssa] test: gofmt {goto,label,label1}.go

Change-Id: I971d0c93632e39aad4e2ba1862f085df820baf8b
Reviewed-on: https://go-review.googlesource.com/12431
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years ago[dev.ssa] cmd/compile: handle OpCopy loops in rewrite
Josh Bleecher Snyder [Fri, 17 Jul 2015 16:45:48 +0000 (10:45 -0600)]
[dev.ssa] cmd/compile: handle OpCopy loops in rewrite

Change-Id: Icbaad6e5cbfc5430a651538fe90c0a9ee664faf4
Reviewed-on: https://go-review.googlesource.com/12360
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/ssa/gen: Fix *64 strength reduction
Keith Randall [Thu, 16 Jul 2015 21:20:40 +0000 (14:20 -0700)]
[dev.ssa] cmd/compile/internal/ssa/gen: Fix *64 strength reduction

*64 is <<6, not <<5.

Change-Id: I2eb7e113d5003b2c77fbd3abc3defc4d98976a5e
Reviewed-on: https://go-review.googlesource.com/12323
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/ssa: compute outarg size correctly
Keith Randall [Tue, 14 Jul 2015 20:20:08 +0000 (13:20 -0700)]
[dev.ssa] cmd/compile/internal/ssa: compute outarg size correctly

Keep track of the outargs size needed at each call.
Compute the size of the outargs section of the stack frame.  It's just
the max of the outargs size at all the callsites in the function.

Change-Id: I3d0640f654f01307633b1a5f75bab16e211ea6c0
Reviewed-on: https://go-review.googlesource.com/12178
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
9 years ago[dev.ssa] cmd/compile: implement lowering of constant bools
Josh Bleecher Snyder [Thu, 16 Jul 2015 19:12:57 +0000 (13:12 -0600)]
[dev.ssa] cmd/compile: implement lowering of constant bools

Change-Id: Ia56ee9798eefe123d4da04138a6a559d2c25ddf3
Reviewed-on: https://go-review.googlesource.com/12312
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years ago[dev.ssa] cmd/compile: don't Compile if Unimplemented
Josh Bleecher Snyder [Thu, 16 Jul 2015 18:45:22 +0000 (12:45 -0600)]
[dev.ssa] cmd/compile: don't Compile if Unimplemented

If we've already hit an Unimplemented, there may be important
SSA invariants that do not hold and which could cause
ssa.Compile to hang or spin.

While we're here, make detected dependency cycles stop execution.

Change-Id: Ic7d4eea659e1fe3f2c9b3e8a4eee5567494f46ad
Reviewed-on: https://go-review.googlesource.com/12310
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/ssa: implement ODOT
Keith Randall [Thu, 16 Jul 2015 04:33:49 +0000 (21:33 -0700)]
[dev.ssa] cmd/compile/internal/ssa: implement ODOT

Implement ODOT.  Similar to ArrayIndex, StructSelect selects a field
out of a larger Value.

We may need more ways to rewrite StructSelect, but StructSelect/Load
is the typical way it is used.

Change-Id: Ida7b8aab3298f4754eaf9fee733974cf8736e45d
Reviewed-on: https://go-review.googlesource.com/12265
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years ago[dev.ssa] cmd/compile/internal : Implement Lengauer-Tarjan for dominators
Todd Neal [Sun, 5 Jul 2015 23:23:25 +0000 (18:23 -0500)]
[dev.ssa] cmd/compile/internal : Implement Lengauer-Tarjan for dominators

Implements the simple Lengauer-Tarjan algorithm for dominator
and post-dominator calculation.

benchmark                           old ns/op     new ns/op     delta
BenchmarkDominatorsLinear-8         1403862       1292741       -7.92%
BenchmarkDominatorsFwdBack-8        1270633       1428285       +12.41%
BenchmarkDominatorsManyPred-8       225932354     1530886       -99.32%
BenchmarkDominatorsMaxPred-8        445994225     1393612       -99.69%
BenchmarkDominatorsMaxPredVal-8     447235248     1246899       -99.72%
BenchmarkNilCheckDeep1-8            829           1259          +51.87%
BenchmarkNilCheckDeep10-8           2199          2397          +9.00%
BenchmarkNilCheckDeep100-8          57325         29405         -48.70%
BenchmarkNilCheckDeep1000-8         6625837       2933151       -55.73%
BenchmarkNilCheckDeep10000-8        763559787     319105541     -58.21%

benchmark                           old MB/s     new MB/s     speedup
BenchmarkDominatorsLinear-8         7.12         7.74         1.09x
BenchmarkDominatorsFwdBack-8        7.87         7.00         0.89x
BenchmarkDominatorsManyPred-8       0.04         6.53         163.25x
BenchmarkDominatorsMaxPred-8        0.02         7.18         359.00x
BenchmarkDominatorsMaxPredVal-8     0.02         8.02         401.00x
BenchmarkNilCheckDeep1-8            1.21         0.79         0.65x
BenchmarkNilCheckDeep10-8           4.55         4.17         0.92x
BenchmarkNilCheckDeep100-8          1.74         3.40         1.95x
BenchmarkNilCheckDeep1000-8         0.15         0.34         2.27x
BenchmarkNilCheckDeep10000-8        0.01         0.03         3.00x

Change-Id: Icec3d774422a9bc64914779804c8c0ab73aa72bf
Reviewed-on: https://go-review.googlesource.com/11971
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile: implement OIND
Todd Neal [Tue, 14 Jul 2015 02:22:16 +0000 (21:22 -0500)]
[dev.ssa] cmd/compile: implement OIND

Change-Id: I15aee8095e6388822e2222f1995fe2278ac956ca
Reviewed-on: https://go-review.googlesource.com/12129
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
9 years ago[dev.ssa] cmd/compile/internal/ssa: ensure Phi ops are scheduled first
Keith Randall [Tue, 14 Jul 2015 06:52:59 +0000 (23:52 -0700)]
[dev.ssa] cmd/compile/internal/ssa: ensure Phi ops are scheduled first

Phi ops should always be scheduled first.  They have the semantics
of all happening simultaneously at the start of the block.  The regalloc
phase assumes all the phis will appear first.

Change-Id: I30291e1fa384a0819205218f1d1ec3aef6d538dd
Reviewed-on: https://go-review.googlesource.com/12154
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
9 years ago[dev.ssa] cmd/compile: handle OLITERAL nil expressions
Brad Fitzpatrick [Mon, 13 Jul 2015 23:30:42 +0000 (17:30 -0600)]
[dev.ssa] cmd/compile: handle OLITERAL nil expressions

Change-Id: I02b8fb277b486eaf0916ddcd8f28c062d4022d4b
Reviewed-on: https://go-review.googlesource.com/12150
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/gc: Implement ODOT and ODOTPTR in addr.
Keith Randall [Mon, 13 Jul 2015 22:55:37 +0000 (15:55 -0700)]
[dev.ssa] cmd/compile/internal/gc: Implement ODOT and ODOTPTR in addr.

Change-Id: If8a9d5901fa2141d16b1c8d001761ea62bc23207
Reviewed-on: https://go-review.googlesource.com/12141
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years ago[dev.ssa] cmd/compile: treat unsafe.Pointer as a pointer
Brad Fitzpatrick [Mon, 13 Jul 2015 21:46:53 +0000 (15:46 -0600)]
[dev.ssa] cmd/compile: treat unsafe.Pointer as a pointer

Change-Id: I3f3ac3055c93858894b8852603d79592bbc1696b
Reviewed-on: https://go-review.googlesource.com/12140
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile: support zero type for *T
Brad Fitzpatrick [Mon, 13 Jul 2015 20:01:08 +0000 (14:01 -0600)]
[dev.ssa] cmd/compile: support zero type for *T

Change-Id: I4c9bcea01e2c4333c2a3592b66f1da9f424747a4
Reviewed-on: https://go-review.googlesource.com/12130
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/gc: fix tests on non-amd64
Brad Fitzpatrick [Mon, 13 Jul 2015 20:57:16 +0000 (14:57 -0600)]
[dev.ssa] cmd/compile/internal/gc: fix tests on non-amd64

Change-Id: Ibd6a59db2d5feea41a21fbea5c1a7fdd49238aa8
Reviewed-on: https://go-review.googlesource.com/12131
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>

9 years ago[dev.ssa] cmd/compile: OANDAND, OOROR
Brad Fitzpatrick [Fri, 10 Jul 2015 18:58:53 +0000 (12:58 -0600)]
[dev.ssa] cmd/compile: OANDAND, OOROR

Joint hacking with josharian. Hints from matloob and Todd Neal.

Now with tests, and OROR.

Change-Id: Iff8826fde475691fb72a3eea7396a640b6274af9
Reviewed-on: https://go-review.googlesource.com/12041
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/gc: handle _ label correctly
Keith Randall [Sun, 12 Jul 2015 18:52:09 +0000 (11:52 -0700)]
[dev.ssa] cmd/compile/internal/gc: handle _ label correctly

An empty label statement can just be ignored, as it cannot
be the target of any gotos.

Tests are already in test/fixedbugs/issue7538*.go

Fixes #11589
Fixes #11593

Change-Id: Iadcd639e7200ce16aa40fd7fa3eaf82522513e82
Reviewed-on: https://go-review.googlesource.com/12093
Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/gc: implement more no-op statements
Daniel Morsing [Sun, 12 Jul 2015 13:37:01 +0000 (14:37 +0100)]
[dev.ssa] cmd/compile/internal/gc: implement more no-op statements

Change-Id: I26c268f46dcffe39912b8c92ce9abb875310934f
Reviewed-on: https://go-review.googlesource.com/12100
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/ssa: comment why replacing phi with copy is ok
Keith Randall [Sat, 11 Jul 2015 22:43:35 +0000 (15:43 -0700)]
[dev.ssa] cmd/compile/internal/ssa: comment why replacing phi with copy is ok

Change-Id: I3e2e8862f2fde4349923016b97e8330b0d494e0e
Reviewed-on: https://go-review.googlesource.com/12092
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
9 years ago[dev.ssa] cmd/compile: implement ONOT
Brad Fitzpatrick [Fri, 10 Jul 2015 17:25:48 +0000 (11:25 -0600)]
[dev.ssa] cmd/compile: implement ONOT

Co-hacking with josharian at Gophercon.

Change-Id: Ia59dfab676c6ed598c2c25483439cd1395a4ea87
Reviewed-on: https://go-review.googlesource.com/12029
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>

9 years ago[dev.ssa] cmd/compile: implement OCAP
Brad Fitzpatrick [Fri, 10 Jul 2015 16:47:28 +0000 (10:47 -0600)]
[dev.ssa] cmd/compile: implement OCAP

And dependent fixes and misc cleanup.

Co-hacking with josharian at Gophercon.

Change-Id: Ib85dc13b303929017eb0a4d2fc2f603485f7479b
Reviewed-on: https://go-review.googlesource.com/12027
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>

9 years ago[dev.ssa] cmd/compile/internal/ssa: Phi inputs from dead blocks are not live
Keith Randall [Sat, 11 Jul 2015 21:41:22 +0000 (14:41 -0700)]
[dev.ssa] cmd/compile/internal/ssa: Phi inputs from dead blocks are not live

Fixes #11676

Change-Id: I941f951633c89bb1454ce6d1d1b4124d46a7d9dd
Reviewed-on: https://go-review.googlesource.com/12091
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years ago[dev.ssa] cmd/compile/ssa: Replace less-or-equal with equal in len comparison with...
ALTree [Sat, 11 Jul 2015 14:30:24 +0000 (16:30 +0200)]
[dev.ssa] cmd/compile/ssa: Replace less-or-equal with equal in len comparison with zero

Since the spec guarantees than 0 <= len always:

https://golang.org/ref/spec#Length_and_capacity

replace len(...) <= 0 check with len(...) == 0 check

Change-Id: I5517a9cb6b190f0b1ee314a67487477435f3b409
Reviewed-on: https://go-review.googlesource.com/12034
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/ssa: Use Ninit from expressions
Keith Randall [Sat, 11 Jul 2015 18:39:12 +0000 (11:39 -0700)]
[dev.ssa] cmd/compile/internal/ssa: Use Ninit from expressions

If an expression has an Ninit list, generate code for it.
Required for (at least) OANDAND.

Change-Id: I94c9e22e2a76955736f4a8e574d92711419c5e5c
Reviewed-on: https://go-review.googlesource.com/12072
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years ago[dev.ssa] cmd/compile/ssa: handle nested dead blocks
Josh Bleecher Snyder [Fri, 10 Jul 2015 03:24:12 +0000 (21:24 -0600)]
[dev.ssa] cmd/compile/ssa: handle nested dead blocks

removePredecessor can change which blocks are live.
However, it cannot remove dead blocks from the function's
slice of blocks because removePredecessor may have been
called from within a function doing a walk of the blocks.

CL 11879 did not handle this correctly and broke the build.

To fix this, mark the block as dead but leave its actual
removal for a deadcode pass. Blocks that are dead must have
no successors, predecessors, values, or control values,
so they will generally be ignored by other passes.
To be safe, we add a deadcode pass after the opt pass,
which is the only other pass that calls removePredecessor.

Two alternatives that I considered and discarded:

(1) Make all call sites aware of the fact that removePrecessor
might make arbitrary changes to the list of blocks. This
will needlessly complicate callers.

(2) Handle the things that can go wrong in practice when
we encounter a dead-but-not-removed block. CL 11930 takes
this approach (and the tests are stolen from that CL).
However, this is just patching over the problem.

Change-Id: Icf0687b0a8148ce5e96b2988b668804411b05bd8
Reviewed-on: https://go-review.googlesource.com/12004
Reviewed-by: Todd Neal <todd@tneal.org>
Reviewed-by: Michael Matloob <michaelmatloob@gmail.com>
9 years ago[dev.ssa] cmd/compile/ssa: print lazily
Josh Bleecher Snyder [Fri, 10 Jul 2015 15:31:28 +0000 (09:31 -0600)]
[dev.ssa] cmd/compile/ssa: print lazily

Reduces 'go run run.go 64bit.go' from 23s to 8s on my machine.

Change-Id: Ie5b642d0abb56e8eb3899d69472bc88a85a1c985
Reviewed-on: https://go-review.googlesource.com/12023
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years ago[dev.ssa] cmd/compile/ssa: place for loop incr in a separate block
Josh Bleecher Snyder [Mon, 6 Jul 2015 22:29:39 +0000 (15:29 -0700)]
[dev.ssa] cmd/compile/ssa: place for loop incr in a separate block

This is a prerequisite for implementing break and continue;
blocks ending in break or continue need to have
the increment block as a successor.

While we're here, implement for loops with no condition.

Change-Id: I85d8ba020628d805bfd0bd583dfd16e1be6f6fae
Reviewed-on: https://go-review.googlesource.com/11941
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/ssa: dominator tests and benchmarks
Todd Neal [Fri, 26 Jun 2015 04:13:57 +0000 (23:13 -0500)]
[dev.ssa] cmd/compile/ssa: dominator tests and benchmarks

This change has some tests verifying functionality and an assortment of
benchmarks of various block lists. It modifies NewBlock to allocate in
contiguous blocks improving the performance of intersect() for extremely
large graphs by 30-40%.

benchmark                           old ns/op      new ns/op     delta
BenchmarkDominatorsLinear-8         1185619        901154        -23.99%
BenchmarkDominatorsFwdBack-8        1302138        863537        -33.68%
BenchmarkDominatorsManyPred-8       404670521      247450911     -38.85%
BenchmarkDominatorsMaxPred-8        455809002      471675119     +3.48%
BenchmarkDominatorsMaxPredVal-8     819315864      468257300     -42.85%

BenchmarkNilCheckDeep1-8            766            706           -7.83%
BenchmarkNilCheckDeep10-8           2553           2209          -13.47%
BenchmarkNilCheckDeep100-8          58606          57545         -1.81%
BenchmarkNilCheckDeep1000-8         7753012        8025750       +3.52%
BenchmarkNilCheckDeep10000-8        1224165946     789995184     -35.47%

Change-Id: Id3d6bc9cb1138e8177934441073ac7873ddf7ade
Reviewed-on: https://go-review.googlesource.com/11716
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/ssa: implement constant booleans
Josh Bleecher Snyder [Mon, 6 Jul 2015 21:13:17 +0000 (14:13 -0700)]
[dev.ssa] cmd/compile/ssa: implement constant booleans

The removal of if false { ... } blocks in the opt
pass exposed that removePredecessor needed
to do more cleaning, on pain of failing later
consistency checks.

Change-Id: I45d4ff7e1f7f1486fdd99f867867ce6ea006a288
Reviewed-on: https://go-review.googlesource.com/11879
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/ssa: implement OLEN
Josh Bleecher Snyder [Sat, 4 Jul 2015 01:41:28 +0000 (18:41 -0700)]
[dev.ssa] cmd/compile/ssa: implement OLEN

Change-Id: Ie23b13142fd820d7071a348a8370175e58b76d64
Reviewed-on: https://go-review.googlesource.com/11878
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/ssa: handle loops that don't loop
Josh Bleecher Snyder [Sat, 4 Jul 2015 16:07:54 +0000 (09:07 -0700)]
[dev.ssa] cmd/compile/ssa: handle loops that don't loop

Loops such as

func f(c chan int) int {
for x := range c {
return x
}
return 0
}

don't loop. Remove the assumption that they must.

Partly fixes the build.

Change-Id: I766cebeec8e36d14512bea26f54c06c8eaf95e23
Reviewed-on: https://go-review.googlesource.com/11876
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/ssa: stop compilation immediately on leading goto
Josh Bleecher Snyder [Sat, 4 Jul 2015 20:01:04 +0000 (13:01 -0700)]
[dev.ssa] cmd/compile/ssa: stop compilation immediately on leading goto

There is clearly work to do to fix labels and gotos.
The compiler currently hangs on ken/label.go.

For the moment, stop the bleeding.

Fixes the build.

Change-Id: Ib68360d583cf53e1a8ca4acff50644b570382728
Reviewed-on: https://go-review.googlesource.com/11877
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/ssa: mark race/nodfp as unimplemented
Josh Bleecher Snyder [Sat, 4 Jul 2015 03:28:56 +0000 (20:28 -0700)]
[dev.ssa] cmd/compile/ssa: mark race/nodfp as unimplemented

Partly fixes the build, by punting.
Other things have broken in the meantime.

Change-Id: I1e2b8310057cbbbd9ffc501ef51e744690e00726
Reviewed-on: https://go-review.googlesource.com/11875
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/ssa: add Logf state helper
Josh Bleecher Snyder [Sat, 4 Jul 2015 03:29:11 +0000 (20:29 -0700)]
[dev.ssa] cmd/compile/ssa: add Logf state helper

Change-Id: I4e4200b0fa847a1ff8a8b7d1e318bbc1c5e26b5b
Reviewed-on: https://go-review.googlesource.com/11874
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/gc: mark unimplemented variable classes as such
Daniel Morsing [Wed, 1 Jul 2015 19:37:25 +0000 (20:37 +0100)]
[dev.ssa] cmd/compile/internal/gc: mark unimplemented variable classes as such

Doesn't fix the build entirely, but does make it get to the race
detector tests.

Change-Id: Ie986d52374936855b7ee975dc68742306527eb15
Reviewed-on: https://go-review.googlesource.com/11835
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/ssa: add checks for nil args in values
Josh Bleecher Snyder [Mon, 29 Jun 2015 18:56:28 +0000 (11:56 -0700)]
[dev.ssa] cmd/compile/ssa: add checks for nil args in values

These additional checks were useful in
tracking down the broken build (CL 11238).

This CL does not fix the build, sadly.

Change-Id: I34de3bed223f450aaa97c1cadaba2e4e5850050b
Reviewed-on: https://go-review.googlesource.com/11681
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/ssa: Initial implementation of memory zeroing
Daniel Morsing [Sat, 27 Jun 2015 14:45:20 +0000 (15:45 +0100)]
[dev.ssa] cmd/compile/internal/ssa: Initial implementation of memory zeroing

This will make it possible for us to start implementing interfaces
and other stack allocated types which are more than one machine word.

Change-Id: I52b187a791cf1919cb70ed6dabdc9f57b317ea83
Reviewed-on: https://go-review.googlesource.com/11631
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/gc: fix stringsym call
Keith Randall [Wed, 1 Jul 2015 04:16:51 +0000 (21:16 -0700)]
[dev.ssa] cmd/compile/internal/gc: fix stringsym call

Forgot to add this in the tip merge.

Change-Id: I0e5a2681133f4ae7a7c360ae2c2d71d46420c693
Reviewed-on: https://go-review.googlesource.com/11793
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] Merge remote-tracking branch 'origin/master' into ssamerge
Keith Randall [Wed, 1 Jul 2015 03:51:17 +0000 (20:51 -0700)]
[dev.ssa] Merge remote-tracking branch 'origin/master' into ssamerge

Semi-regular merge from tip into ssa branch.

Change-Id: I9cbe23f566410496d4ceb97c1435e2df7f2b56ec

9 years agodoc: more library in go1.5.html
Rob Pike [Tue, 30 Jun 2015 22:48:19 +0000 (08:48 +1000)]
doc: more library in go1.5.html

Everything in the library but crypto and net.

Change-Id: I89b21b9621e6d338fa1891da0eabba5d7d2fe349
Reviewed-on: https://go-review.googlesource.com/11820
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agodatabase/sql: make Register safe for concurrent use
Brad Fitzpatrick [Tue, 30 Jun 2015 00:56:20 +0000 (17:56 -0700)]
database/sql: make Register safe for concurrent use

Adding a mutex was easier than documenting it, and is consistent with
gob.

Fixes #9847

Change-Id: Ifa94c17e7c11643add81b35431ef840b794d78b1
Reviewed-on: https://go-review.googlesource.com/11682
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agonet/http: harden Server against request smuggling
Brad Fitzpatrick [Tue, 30 Jun 2015 21:21:15 +0000 (14:21 -0700)]
net/http: harden Server against request smuggling

See RFC 7230.

Thanks to Régis Leroy for the report.

Change-Id: Ic1779bc2180900430d4d7a4938cac04ed73c304c
Reviewed-on: https://go-review.googlesource.com/11810
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>

9 years agointernal/singleflight: deflake test
Brad Fitzpatrick [Tue, 30 Jun 2015 15:32:02 +0000 (08:32 -0700)]
internal/singleflight: deflake test

Fixes #11475

Change-Id: Ibaedbb732bb1b9f062bd5af7b866ec4758c724a7
Reviewed-on: https://go-review.googlesource.com/11770
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>

9 years agogo/types: change {Type,Object,Selection}String to accept a Qualifier function
Alan Donovan [Tue, 30 Jun 2015 19:07:20 +0000 (15:07 -0400)]
go/types: change {Type,Object,Selection}String to accept a Qualifier function

The optional Qualifier function determines what prefix to attach to
package-level names, enabling clients to qualify packages in different
ways, for example, using only the package name instead of its complete
path, or using the locally appropriate name for package given a set of
(possibly renaming) imports.

Prior to this change, clients wanting this behavior had to copy
hundreds of lines of complex printing logic.

Fun fact: (*types.Package).Path and (*types.Package).Name are valid
Qualifier functions.

We provide the RelativeTo helper function to create Qualifiers so that
the old behavior remains a one-liner.

Fixes golang/go#11133

This CL is a copy of https://go-review.googlesource.com/#/c/11692/
to the golang.org/x/tools repository.

Change-Id: I26d0f3644d077a26bfe350989f9c545f018eefbf
Reviewed-on: https://go-review.googlesource.com/11790
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>

9 years agocmd/link: reject data size > 2 GB
Russ Cox [Mon, 29 Jun 2015 20:44:45 +0000 (16:44 -0400)]
cmd/link: reject data size > 2 GB

We can't address more than this on amd64 anyway.

Fixes #9862.

Change-Id: Ifb1abae558e2e1ee2dc953a76995f3f08c60b1df
Reviewed-on: https://go-review.googlesource.com/11715
Reviewed-by: Austin Clements <austin@google.com>
9 years agocmd/compile: allow linker to drop string headers when not needed
Russ Cox [Mon, 29 Jun 2015 17:50:30 +0000 (13:50 -0400)]
cmd/compile: allow linker to drop string headers when not needed

Compiling a simple file containing a slice of 100,000 strings,
the size of the resulting binary dropped from 5,896,224 bytes
to 3,495,968 bytes, which is the expected 2,400,000 bytes,
give or take.

Fixes #7384.

Change-Id: I3e551b5a1395b523a41b33518d81a1bf28da0906
Reviewed-on: https://go-review.googlesource.com/11698
Reviewed-by: Austin Clements <austin@google.com>
9 years agocmd/compile: fix race detector handling of OBLOCK nodes
Russ Cox [Mon, 29 Jun 2015 19:17:14 +0000 (15:17 -0400)]
cmd/compile: fix race detector handling of OBLOCK nodes

Fixes #7561 correctly.
Fixes #9137.

Change-Id: I7f27e199d7101b785a7645f789e8fe41a405a86f
Reviewed-on: https://go-review.googlesource.com/11713
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
9 years agonet/textproto: don't treat spaces as hyphens in header keys
Brad Fitzpatrick [Tue, 30 Jun 2015 16:22:41 +0000 (09:22 -0700)]
net/textproto: don't treat spaces as hyphens in header keys

This was originally done in https://codereview.appspot.com/5690059
(Feb 2012) to deal with bad response headers coming back from webcams,
but it presents a potential security problem with HTTP request
smuggling for request headers containing "Content Length" instead of
"Content-Length".

Part of overall HTTP hardening for request smuggling. See RFC 7230.

Thanks to Régis Leroy for the report.

Change-Id: I92b17fb637c9171c5774ea1437979ae2c17ca88a
Reviewed-on: https://go-review.googlesource.com/11772
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agocmd/trace: sort procs
Dmitry Vyukov [Tue, 30 Jun 2015 12:09:41 +0000 (14:09 +0200)]
cmd/trace: sort procs

If you have more than 10 procs, then currently they are sorted alphabetically as
0, 10, 11, ..., 19, 2, 20, ...
Assign explicit order to procs so that they are sorted numerically.

Change-Id: I6d978d2cd439aa2fcbcf147842a643f9073eef75
Reviewed-on: https://go-review.googlesource.com/11750
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agonet/http: harden, document func SetCookie and type Cookie
Brad Fitzpatrick [Tue, 30 Jun 2015 01:10:43 +0000 (18:10 -0700)]
net/http: harden, document func SetCookie and type Cookie

Fixes #9758

Change-Id: I3089ec06cddd74b547d8b10834d7478a04b02069
Reviewed-on: https://go-review.googlesource.com/11701
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agonet/url: only record RawPath when it is needed
Russ Cox [Tue, 30 Jun 2015 15:28:29 +0000 (11:28 -0400)]
net/url: only record RawPath when it is needed

RawPath is a hint to the desired encoding of Path.
It is ignored when it is not a valid encoding of Path,
such as when Path has been changed but RawPath has not.
It is not ignored but also not useful when it matches
the url package's natural choice of encoding.
In this latter case, set it to the empty string.
This should help drive home the point that clients
cannot in general depend on it being present and
that they should use the EncodedPath method instead.

This also reduces the impact of the change on tests,
especially tests that use reflect.DeepEqual on parsed URLs.

Change-Id: I437c51a33b85439a31c307caf1436118508ea196
Reviewed-on: https://go-review.googlesource.com/11760
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agocmd/compile/internal/gc: give OASWB name
Dmitry Vyukov [Tue, 30 Jun 2015 11:58:54 +0000 (13:58 +0200)]
cmd/compile/internal/gc: give OASWB name

Change-Id: Iacb84421215ca80c7add2818118b2af1a650fd58
Reviewed-on: https://go-review.googlesource.com/11639
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agoencoding/xml: fix xmlns= behavior
Roger Peppe [Mon, 29 Jun 2015 11:36:48 +0000 (12:36 +0100)]
encoding/xml: fix xmlns= behavior

When an xmlns="..." attribute was explicitly generated,
it was being ignored because the name space on the
attribute was assumed to have been explicitly set (to the empty
name space) and it's not possible to have an element in the
empty name space when there is a non-empty name space set.

We fix this by recording when a default name space has been
explicitly set and setting the name space of the element to that
so printer.defineNS can do its work correctly.

We do not attempt to add our own xmlns="..." attribute
when one is explicitly set.

We also add tests for EncodeElement, as that's the only way
to attain coverage of some of the changed behaviour.
Some other test coverage is also increased, although
more work remains to be done in this area.

This change was jointly developed with Martin Hilton (mhilton on github).

Fixes #11431.

Change-Id: I7b85e06eea5b18b2c15ec16dcbd92a8e1d6a9a4e
Reviewed-on: https://go-review.googlesource.com/11635
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/go: use GOOS and GOARCH from build context for "go generate"
Andrew Gerrand [Tue, 30 Jun 2015 05:35:01 +0000 (15:35 +1000)]
cmd/go: use GOOS and GOARCH from build context for "go generate"

Fixes #11438

Change-Id: Iedd31918aa5187fc3fdaed71c8dad82075559084
Reviewed-on: https://go-review.googlesource.com/11667
Reviewed-by: Rob Pike <r@golang.org>
9 years agoimage/gif: accept LZW encodings that do not have an explicit end marker.
Nigel Tao [Mon, 29 Jun 2015 06:43:25 +0000 (16:43 +1000)]
image/gif: accept LZW encodings that do not have an explicit end marker.

The spec says this is invalid, but it matches giflib's behavior.

Fixes #9856 (together with https://go-review.googlesource.com/11661).

Change-Id: I05701f62a9e5e724a2d85c6b87ae4111e537146b
Reviewed-on: https://go-review.googlesource.com/11663
Reviewed-by: Rob Pike <r@golang.org>
9 years agocompress/lzw: return the partial decoding for a truncated input.
Nigel Tao [Mon, 29 Jun 2015 06:22:54 +0000 (16:22 +1000)]
compress/lzw: return the partial decoding for a truncated input.

This is needed by issue #9856.

Change-Id: Idad570a7e55ad903aab55372d390bc746c4e19cf
Reviewed-on: https://go-review.googlesource.com/11661
Reviewed-by: Rob Pike <r@golang.org>
9 years agoarchive/tar: move round-trip reading into common os file
Alex Brainman [Mon, 29 Jun 2015 06:42:28 +0000 (16:42 +1000)]
archive/tar: move round-trip reading into common os file

Fixes #11426

Change-Id: I77368b0e852149ed4533e139cc43887508ac7f78
Reviewed-on: https://go-review.googlesource.com/11662
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agonet/http: add a Request.Cancel channel.
Aaron Jacobs [Mon, 29 Jun 2015 00:07:31 +0000 (10:07 +1000)]
net/http: add a Request.Cancel channel.

This allows for "race free" cancellation, in the sense discussed in
issue #11013: in contrast to Transport.CancelRequest, the cancellation
will not be lost if the user cancels before the request is put into the
transport's internal map.

Fixes #11013.

Change-Id: I0b5e7181231bdd65d900e343f764b4d1d7c422cd
Reviewed-on: https://go-review.googlesource.com/11601
Run-TryBot: David Symonds <dsymonds@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agocmd/compile: reject large floating point exponents without math/big
Russ Cox [Mon, 29 Jun 2015 03:25:38 +0000 (23:25 -0400)]
cmd/compile: reject large floating point exponents without math/big

For #11326 (but not a fix).

Change-Id: Ic51814f5cd7357427c3fd990a5522775d05e7987
Reviewed-on: https://go-review.googlesource.com/11673
Reviewed-by: Robert Griesemer <gri@golang.org>
9 years agoio: tweak Reader comment
Russ Cox [Mon, 29 Jun 2015 14:58:54 +0000 (10:58 -0400)]
io: tweak Reader comment

I think this has the same meaning as before,
but the text is tighter, and it makes some people happy.

Fixes #10182.

Change-Id: I7ee1eae4bcd6ee4a5898ea948648939e6bde5f01
Reviewed-on: https://go-review.googlesource.com/11674
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
9 years agopath/filepath: document and test behavior of SkipDir on files
Russ Cox [Mon, 29 Jun 2015 15:53:51 +0000 (11:53 -0400)]
path/filepath: document and test behavior of SkipDir on files

This behavior is not what we might have designed from the start,
but it has been present since Go 1. Rather than make a visible
behavioral change that might cause programs to work differently
in Go ≤1.4 vs Go ≥1.5, document what SkipDir on a non-directory
has always meant. If code doesn't want this meaning, it is easy
enough not to return SkipDir on non-directories.

Fixes #10533.

Change-Id: Ic0612f032044bc7c69bf62583a02037e4b47530b
Reviewed-on: https://go-review.googlesource.com/11690
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
9 years agocmd/link: detect -X setting non-string variable
Russ Cox [Mon, 29 Jun 2015 17:03:11 +0000 (13:03 -0400)]
cmd/link: detect -X setting non-string variable

Fixes #9621.

Change-Id: Ib9c6001378364af899f57fd4b89fb23af2042923
Reviewed-on: https://go-review.googlesource.com/11694
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>

9 years agodoc: finish listing the non-crypto non-net small API changes
Rob Pike [Mon, 29 Jun 2015 09:51:56 +0000 (19:51 +1000)]
doc: finish listing the non-crypto non-net small API changes

Change-Id: I5791639e71874ce13fac836a0c6014e20ee7417e
Reviewed-on: https://go-review.googlesource.com/11664
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agogo/types: go/types: add an API test of the Scope type
Alan Donovan [Mon, 29 Jun 2015 20:13:09 +0000 (16:13 -0400)]
go/types: go/types: add an API test of the Scope type

Also: make (*Scope).Innermost work for Package scopes.

This change is identical to http://go-review.googlesource.com/#/c/11691/,
except for minor changes required by the use of testImporter.

Change-Id: Id07e66f78987f7242c2e642dfd6ee613676e10e5
Reviewed-on: https://go-review.googlesource.com/11714
Reviewed-by: Robert Griesemer <gri@golang.org>
9 years agocmd/link: fix -s with external linking
Russ Cox [Mon, 29 Jun 2015 17:12:10 +0000 (13:12 -0400)]
cmd/link: fix -s with external linking

This code used to only be run for ELF, with the predictable
result that using -s with external linking broke on Windows and OS X.
Moving it here should fix Windows and does fix OS X.

CL 10835 also claims to fix the crash on Windows.
I don't know whether it does so correctly, but regardless,
this CL should make that one a no-op.

Fixes #10254.

Change-Id: I2e7b45ab0c28568ddbb1b50581dcc157ae0e7ffe
Reviewed-on: https://go-review.googlesource.com/11695
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years agocmd/compile: enable PAUTO capture variables on arch != 6
Russ Cox [Mon, 29 Jun 2015 17:56:27 +0000 (13:56 -0400)]
cmd/compile: enable PAUTO capture variables on arch != 6

Fixes #9865.

Change-Id: I8ce5b1708ed938910c59899706e470271c2e7e9d
Reviewed-on: https://go-review.googlesource.com/11699
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agocrypto/rsa: check for primes ≤ 1 in Validate
Adam Langley [Sat, 27 Jun 2015 21:50:39 +0000 (14:50 -0700)]
crypto/rsa: check for primes ≤ 1 in Validate

Change 7c7126cfeb82894229b9c3d5109e4b04e6cfde0c removed the primality
checking in Validate to save CPU time. That check happened to be
filtering out private keys with primes that were zero or one. Without
that filtering, such primes cause a panic when trying to use such a
private key.

This change specifically checks for and rejects primes ≤ 1 in Validate.

Fixes #11233.

Change-Id: Ie6537edb8250c07a45aaf50dab43227002ee7386
Reviewed-on: https://go-review.googlesource.com/11611
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agonet/http/httptest: increase test Server's key size
Brad Fitzpatrick [Mon, 29 Jun 2015 18:37:13 +0000 (11:37 -0700)]
net/http/httptest: increase test Server's key size

Fixes #10725

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

9 years agocmd/go: 'go env' print GO15VENDOREXPERIMENT in Go1.5
Tom Heng [Mon, 29 Jun 2015 13:55:13 +0000 (21:55 +0800)]
cmd/go: 'go env' print GO15VENDOREXPERIMENT in Go1.5

Fixes #11410

Change-Id: I9d01be3e01f74f4b12a516aba8a5d20d9b277ec6
Reviewed-on: https://go-review.googlesource.com/11539
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agosync: disable flaky WaitGroup misuse test in short mode
Brad Fitzpatrick [Mon, 29 Jun 2015 18:40:13 +0000 (11:40 -0700)]
sync: disable flaky WaitGroup misuse test in short mode

Update #11443

Change-Id: Icb7ea291a837dcf2799a791a2ba780fd2a5e712b
Reviewed-on: https://go-review.googlesource.com/11721
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
9 years agocmd/go: disable TestIssue10952 without external network
Russ Cox [Mon, 29 Jun 2015 17:58:18 +0000 (13:58 -0400)]
cmd/go: disable TestIssue10952 without external network

Should fix arm64 build failure.

Change-Id: Ib35e4a69a1082e461a1eddf3265544a1d2ff98e5
Reviewed-on: https://go-review.googlesource.com/11710
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years agocmd/compile: allow unnamed constants to set line number
Russ Cox [Mon, 29 Jun 2015 03:12:21 +0000 (23:12 -0400)]
cmd/compile: allow unnamed constants to set line number

Fixes #8836.

Change-Id: Idda9f4a987e03b3bdf5e8fdb984fe56d6f84aa59
Reviewed-on: https://go-review.googlesource.com/11672
Reviewed-by: David Chase <drchase@google.com>
9 years agoruntime: fix broken arm builds
Russ Cox [Mon, 29 Jun 2015 17:32:09 +0000 (13:32 -0400)]
runtime: fix broken arm builds

Change-Id: I08de33aacb3fc932722286d69b1dd70ffe787c89
Reviewed-on: https://go-review.googlesource.com/11697
Reviewed-by: Russ Cox <rsc@golang.org>
9 years ago[dev.ssa] cmd/compile/ssa: add comparison ops
Josh Bleecher Snyder [Thu, 25 Jun 2015 00:48:22 +0000 (17:48 -0700)]
[dev.ssa] cmd/compile/ssa: add comparison ops

Increase SSA coverage of functions in the
standard library from 20.79% to 27.81%.

The most significant unimplemented items are now:

 10.16%  2597 SSA unimplemented: zero for type error not implemented
  8.44%  2157 SSA unimplemented: addr: bad op DOTPTR
  7.98%  2039 SSA unimplemented: unhandled OLITERAL 7
  6.29%  1607 SSA unimplemented: unhandled expr OROR
  4.73%  1209 SSA unimplemented: unhandled expr LEN
  4.55%  1163 SSA unimplemented: unhandled expr LROT
  3.42%   874 SSA unimplemented: unhandled OLITERAL 6
  2.46%   629 SSA unimplemented: unhandled expr DOT
  2.41%   615 SSA unimplemented: zero for type []byte not implemented
  2.02%   516 SSA unimplemented: unhandled stmt CALLMETH
  1.90%   486 SSA unimplemented: unhandled expr ANDAND
  1.79%   458 SSA unimplemented: unhandled expr CALLINTER
  1.69%   433 SSA unimplemented: unhandled stmt SWITCH
  1.67%   428 SSA unimplemented: unhandled expr CALLMETH
  1.67%   426 SSA unimplemented: unhandled expr CLOSUREVAR

Change-Id: I40959b22993c4f70784b4eca472cae752347879c
Reviewed-on: https://go-review.googlesource.com/11452
Reviewed-by: Keith Randall <khr@golang.org>
9 years agocmd/link: record missing pcdata tables correctly
Russ Cox [Mon, 29 Jun 2015 02:26:35 +0000 (22:26 -0400)]
cmd/link: record missing pcdata tables correctly

The old code was recording the current table output offset,
so the table from the next function would be used instead of
the runtime realizing that there was no table at all.

Add debug constant in runtime to check this for every function
at startup. It's too expensive to do that by default, but we can
do the last five functions. The end of the table is usually where
the C symbols end up, so that's where the problems typically are.

Fixes #10747.
Fixes #11396.

Change-Id: I13592e78017969fc22979fa902e19e1b151d41b1
Reviewed-on: https://go-review.googlesource.com/11657
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>

9 years agoruntime: reset mark state before checkmark and gctrace=2 mark
Austin Clements [Fri, 26 Jun 2015 17:56:58 +0000 (13:56 -0400)]
runtime: reset mark state before checkmark and gctrace=2 mark

Currently we fail to reset the live heap accounting state before the
checkmark mark and before the gctrace=2 extra mark. As a result, if
either are enabled, at the end of GC it thinks there are 0 bytes of
live heap, which causes the GC controller to initiate a new GC
immediately, regardless of the true heap size.

Fix this by factoring this state reset into a function and calling it
before all three possible marks.

This function should be merged with gcResetGState, but doing so
requires some additional cleanup, so it will wait for after the
freeze. Filed #11427 for this cleanup.

Fixes #10492.

Change-Id: Ibe46348916fc8368fac6f086e142815c970a6f4d
Reviewed-on: https://go-review.googlesource.com/11561
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: don't free stack spans during GC
Austin Clements [Mon, 22 Jun 2015 14:24:50 +0000 (10:24 -0400)]
runtime: don't free stack spans during GC

Memory for stacks is manually managed by the runtime and, currently
(with one exception) we free stack spans immediately when the last
stack on a span is freed. However, the garbage collector assumes that
spans can never transition from non-free to free during scan or mark.
This disagreement makes it possible for the garbage collector to mark
uninitialized objects and is blocking us from re-enabling the bad
pointer test in the garbage collector (issue #9880).

For example, the following sequence will result in marking an
uninitialized object:

1. scanobject loads a pointer slot out of the object it's scanning.
   This happens to be one of the special pointers from the heap into a
   stack. Call the pointer p and suppose it points into X's stack.

2. X, running on another thread, grows its stack and frees its old
   stack.

3. The old stack happens to be large or was the last stack in its
   span, so X frees this span, setting it to state _MSpanFree.

4. The span gets reused as a heap span.

5. scanobject calls heapBitsForObject, which loads the span containing
   p, which is now in state _MSpanInUse, but doesn't necessarily have
   an object at p. The not-object at p gets marked, and at this point
   all sorts of things can go wrong.

We already have a partial solution to this. When shrinking a stack, we
put the old stack on a queue to be freed at the end of garbage
collection. This was done to address exactly this problem, but wasn't
a complete solution.

This commit generalizes this solution to both shrinking and growing
stacks. For stacks that fit in the stack pool, we simply don't free
the span, even if its reference count reaches zero. It's fine to reuse
the span for other stacks, and this enables that. At the end of GC, we
sweep for cached stack spans with a zero reference count and free
them. For larger stacks, we simply queue the stack span to be freed at
the end of GC. Ideally, we would reuse these large stack spans the way
we can small stack spans, but that's a more invasive change that will
have to wait until after the freeze.

Fixes #11267.

Change-Id: Ib7f2c5da4845cc0268e8dc098b08465116972a71
Reviewed-on: https://go-review.googlesource.com/11502
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: remove unused _GCsweep state
Austin Clements [Thu, 25 Jun 2015 16:24:44 +0000 (12:24 -0400)]
runtime: remove unused _GCsweep state

We don't use this state. _GCoff means we're sweeping in the
background. This makes it clear in the next commit that _GCoff and
only _GCoff means sweeping.

Change-Id: I416324a829ba0be3794a6cf3cf1655114cb6e47c
Reviewed-on: https://go-review.googlesource.com/11501
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/cgo: fix a problem with 'go build -compiler gccgo'
Russ Cox [Mon, 29 Jun 2015 03:04:05 +0000 (23:04 -0400)]
cmd/cgo: fix a problem with 'go build -compiler gccgo'

Port of https://golang.org/cl/154360045 to Git.
Original author is Xia Bin <snyh@snyh.org> (already a contributor).

Fixes #8945.

Change-Id: I28bcaf3348794202ca59fbc3466bd7b9670030e4
Reviewed-on: https://go-review.googlesource.com/11658
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agoruntime: always clear stack barriers on G exit
Austin Clements [Wed, 24 Jun 2015 21:13:24 +0000 (17:13 -0400)]
runtime: always clear stack barriers on G exit

Currently the runtime fails to clear a G's stack barriers in gfput if
the G's stack allocation is _FixedStack bytes. This causes the runtime
to panic if the following sequence of events happens:

1) The runtime installs stack barriers on a G.

2) The G exits by calling runtime.Goexit. Since this does not
   necessarily return through the stack barriers installed on the G,
   there may still be untriggered stack barriers left on the G's stack
   in recorded in g.stkbar.

3) The runtime calls gfput to add the exiting G to the free pool. If
   the G's stack allocation is _FixedStack bytes, we fail to clear
   g.stkbar.

4) A new G starts and allocates the G that was just added to the free
   pool.

5) The new G begins to execute and overwrites the stack slots that had
   stack barriers in them.

6) The garbage collector enters mark termination, attempts to remove
   stack barriers from the new G, and finds that they've been
   overwritten.

Fix this by clearing the stack barriers in gfput in the case where it
reuses the stack.

Fixes #11256.

Change-Id: I377c44258900e6bcc2d4b3451845814a8eeb2bcf
Reviewed-on: https://go-review.googlesource.com/11461
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoencoding/binary: update protobuf documentation link
Dmitry Savintsev [Mon, 29 Jun 2015 11:09:06 +0000 (13:09 +0200)]
encoding/binary: update protobuf documentation link

Updated the protobuf documentation URL (code.google.com deprecated)
to avoid a redirect.

Change-Id: I134f6e4a2bf2bba699942883bf6347bc61700bcb
Reviewed-on: https://go-review.googlesource.com/11634
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agofmt: restore padding for %x on byte slices and strings
Rob Pike [Sat, 27 Jun 2015 01:07:30 +0000 (11:07 +1000)]
fmt: restore padding for %x on byte slices and strings

Also improve the documentation. A prior fix in this release
changed the properties for empty strings and slices, incorrectly.
Previous behavior is now restored and better documented.

Add lots of tests.

The behavior is that when using a string-like format (%s %q %x %X)
a byte slice is equivalent to a string, and printed as a unit. The padding
applies to the entire object. (The space and sharp flags apply
elementwise.)

Fixes #11422.
Fixes #10430.

Change-Id: I758f0521caf71630437e43990ec6d6c9a92655e3
Reviewed-on: https://go-review.googlesource.com/11600
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agodoc: fix typo in faq
Rob Pike [Mon, 29 Jun 2015 05:43:42 +0000 (15:43 +1000)]
doc: fix typo in faq

Change-Id: Id2cfa63d4c749503f729097654d7cbd2b252f192
Reviewed-on: https://go-review.googlesource.com/11660
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agodoc: update FAQ for Go 1.5
Rob Pike [Mon, 29 Jun 2015 03:27:41 +0000 (13:27 +1000)]
doc: update FAQ for Go 1.5

Change-Id: I4befb21d0811819ce0a5721421a2f6df7a9b62fa
Reviewed-on: https://go-review.googlesource.com/11605
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agonet/http: fix now-flaky TransportAndServerSharedBodyRace test
Brad Fitzpatrick [Sat, 27 Jun 2015 03:51:13 +0000 (20:51 -0700)]
net/http: fix now-flaky TransportAndServerSharedBodyRace test

TestTransportAndServerSharedBodyRace got flaky after
issue #9662 was fixed by https://golang.org/cl/11412, which made
servers hang up on clients when a Handler stopped reading its body
early.

This test was affected by a race between the the two goroutines in the
test both only reading part of the request, which was an unnecessary
detail for what the test was trying to test (concurrent Read/Close
races on an *http.body)

Also remove an unused remnant from an old test from which this one was
derived. And make the test not deadlock when it fails. (which was why
the test was showing up as 2m timeouts on the dashboard)

Fixes #11418

Change-Id: Ic83d18aef7e09a9cd56ac15e22ebed75713026cb
Reviewed-on: https://go-review.googlesource.com/11610
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years ago[dev.ssa] cmd/compile/ssa: add nilcheckelim benchmarks
Josh Bleecher Snyder [Thu, 25 Jun 2015 21:04:55 +0000 (14:04 -0700)]
[dev.ssa] cmd/compile/ssa: add nilcheckelim benchmarks

These benchmarks demonstrate that
the nilcheckelim pass is roughly O(n^2):

BenchmarkNilCheckDeep1      2000000        741 ns/op    1.35 MB/s
BenchmarkNilCheckDeep10     1000000       2237 ns/op    4.47 MB/s
BenchmarkNilCheckDeep100      20000      60713 ns/op    1.65 MB/s
BenchmarkNilCheckDeep1000       200    7925198 ns/op    0.13 MB/s
BenchmarkNilCheckDeep10000        1 1220104252 ns/op    0.01 MB/s

Profiling suggests that building the
dominator tree is also O(n^2),
and before size factors take over,
considerably more expensive than nilcheckelim.

Change-Id: If966b38ec52243a25f355dab871300d29db02e16
Reviewed-on: https://go-review.googlesource.com/11520
Reviewed-by: Keith Randall <khr@golang.org>
9 years agosyscall: return error instead of panicking in windows StartProcess
Alex Brainman [Mon, 29 Jun 2015 01:19:33 +0000 (11:19 +1000)]
syscall: return error instead of panicking in windows StartProcess

Fixes #11417

Change-Id: Iacea829a48b39df0a4f751b06b19e918fbb713d0
Reviewed-on: https://go-review.googlesource.com/11604
Reviewed-by: Rob Pike <r@golang.org>
9 years ago[dev.ssa] cmd/compile/ssa: refine type equality in cse
Josh Bleecher Snyder [Wed, 24 Jun 2015 21:34:28 +0000 (14:34 -0700)]
[dev.ssa] cmd/compile/ssa: refine type equality in cse

The correct way to compare gc.Types is Eqtype,
rather than pointer equality.
Introduce an Equal method for ssa.Type to allow
us to use it.

In the cse pass, use a type's string to build
the coarse partition, and then use Type.Equal
during refinement.

This lets the cse pass do a better job.
In the ~20% of the standard library that SSA
can compile, the number of common subexpressions
recognized by the cse pass increases from
27,550 to 32,199 (+17%). The number of nil checks
eliminated increases from 75 to 115 (+50%).

Change-Id: I0bdbfcf613ca6bc2ec987eb19b6b1217b51f3008
Reviewed-on: https://go-review.googlesource.com/11451
Reviewed-by: Keith Randall <khr@golang.org>
9 years agocmd/link/internal/ld: exclude only real container symbols from symtab
Keith Randall [Sat, 27 Jun 2015 19:57:06 +0000 (12:57 -0700)]
cmd/link/internal/ld: exclude only real container symbols from symtab

It looks like the test for whether symbols contain subsymbols is wrong.
In particular, symbols in C libraries are mistakenly considered container
symbols.

Fix the test so only symbols which actually have a subsymbol
are excluded from the symtab.  When linking cgo programs the list
of containers is small, something like:

container _/home/khr/sandbox/symtab/misc/cgo/test(.text)<74>
container _/home/khr/sandbox/symtab/misc/cgo/test/issue8828(.text)<75>
container _/home/khr/sandbox/symtab/misc/cgo/test/issue9026(.text)<76>
container runtime/cgo(.text)<77>

I'm not sure this is the right fix.  In particular I can't reproduce
the original problem.  Anyone have a repro they can try and see if
this fix works?

Fixes #10747
Fixes #11396

Change-Id: Id8b016389d33348b4a791fdcba0f9db8ae71ebf3
Reviewed-on: https://go-review.googlesource.com/11652
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoencoding/asn1: don't parse invalid UTF-8.
Adam Langley [Sat, 13 Jun 2015 20:50:02 +0000 (13:50 -0700)]
encoding/asn1: don't parse invalid UTF-8.

Invalid UTF-8 triggers an error when marshaling but, previously, not
when unmarshaling. This means that ASN.1 structures were not
round-tripping.

This change makes invalid UTF-8 in a string marked as UTF-8 to be an
error when Unmarshaling.

Fixes #11126.

Change-Id: Ic37be84d21dc5c03983525e244d955a8b1e1ff14
Reviewed-on: https://go-review.googlesource.com/11056
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoencoding/asn1: be stricter by reserialising parsed times.
Adam Langley [Sun, 14 Jun 2015 17:48:13 +0000 (10:48 -0700)]
encoding/asn1: be stricter by reserialising parsed times.

The time package does normalisation of times: for example day zero is
converted to the last day of the previous month and the 31st of February
is moved into March etc. This makes the ASN.1 parsing a little
worryingly lax.

This change causes the parser to reserialise parsed times to ensure that
they round-trip correctly and thus were not normalised.

Fixes #11134.

Change-Id: I3988bb95153a7b33d64ab861fbe51b1a34a359e9
Reviewed-on: https://go-review.googlesource.com/11094
Run-TryBot: Adam Langley <agl@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: store syscall parameters in m not on stack
Alex Brainman [Fri, 22 May 2015 00:58:57 +0000 (10:58 +1000)]
runtime: store syscall parameters in m not on stack

Stack can move during callback, so libcall struct cannot be stored on stack.
asmstdcall updates return values and errno in libcall struct parameter, but
these could be at different location when callback returns.
Store these in m, so they are not affected by GC.

Fixes #10406

Change-Id: Id01c9d2b4b44530494e6d9e9e1c875261ce477cd
Reviewed-on: https://go-review.googlesource.com/10370
Reviewed-by: Russ Cox <rsc@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/gc: Fix constant shift generation
Keith Randall [Sun, 28 Jun 2015 13:08:50 +0000 (06:08 -0700)]
[dev.ssa] cmd/compile/internal/gc: Fix constant shift generation

Change-Id: Ib142185de3f6e4d2f4983511c063492529d8fb8a
Reviewed-on: https://go-review.googlesource.com/11656
Reviewed-by: Michael Matloob <michaelmatloob@gmail.com>
9 years agocmd/go: reset read-only flag during TestIssue10952
Alex Brainman [Mon, 29 Jun 2015 00:14:24 +0000 (10:14 +1000)]
cmd/go: reset read-only flag during TestIssue10952

git sets read-only flag on all its repo files on Windows.
os.Remove cannot delete these files.

Fixes windows build

Change-Id: Icaf72470456b88a1c26295caecd4e0d3dc22a1b6
Reviewed-on: https://go-review.googlesource.com/11602
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
9 years agobuiltin: remove errant space in hyphenated adjective phrase
Brad Fitzpatrick [Sun, 28 Jun 2015 19:21:42 +0000 (12:21 -0700)]
builtin: remove errant space in hyphenated adjective phrase

Change-Id: I67947e0e3189093e830120941ee49f9f32086f0e
Reviewed-on: https://go-review.googlesource.com/11615
Reviewed-by: Rob Pike <r@golang.org>