]> Cypherpunks repositories - gostls13.git/log
gostls13.git
9 years ago[dev.ssa] cmd/compile: detect rewrite loops of length > 1
Josh Bleecher Snyder [Mon, 10 Aug 2015 21:01:04 +0000 (14:01 -0700)]
[dev.ssa] cmd/compile: detect rewrite loops of length > 1

Use a version of Floyd's cycle finding algorithm,
but advance by 1 and 1/2 steps per cycle rather
than by 1 and 2. It is simpler and should be cheaper
in the normal, acyclic case.

This should fix the 386 and arm builds,
which are currently hung.

Change-Id: If8bd443011b28a5ecb004a549239991d3dfc862b
Reviewed-on: https://go-review.googlesource.com/13473
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/ssa: enforce load-store ordering in scheduler
Keith Randall [Mon, 10 Aug 2015 18:10:53 +0000 (11:10 -0700)]
[dev.ssa] cmd/compile/internal/ssa: enforce load-store ordering in scheduler

We must make sure that all loads that use a store are scheduled
before the next store.  Add additional dependency edges to the
value graph to enforce this constraint.

Change-Id: Iab83644f68bc4c30637085b82ca7467b9d5513a5
Reviewed-on: https://go-review.googlesource.com/13470
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
9 years ago[dev.ssa] cmd/compile: add simplifying block rewrite rules
Josh Bleecher Snyder [Fri, 7 Aug 2015 17:24:57 +0000 (10:24 -0700)]
[dev.ssa] cmd/compile: add simplifying block rewrite rules

Change-Id: Ia946c259628f84dc7031171456563975d2ad5ea9
Reviewed-on: https://go-review.googlesource.com/13381
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/ssa: don't perform nilcheck on OpAddr/OpAddPtr values
Todd Neal [Mon, 3 Aug 2015 23:08:22 +0000 (18:08 -0500)]
[dev.ssa] cmd/compile/ssa: don't perform nilcheck on OpAddr/OpAddPtr values

Don't nilcheck values that were constructed as a result of OpAddr or
OpAddPtr.

Change-Id: I38053e905d1b76a2a64e77f84e444d38a5217108
Reviewed-on: https://go-review.googlesource.com/13256
Reviewed-by: David Chase <drchase@google.com>
9 years ago[dev.ssa] cmd/compile: copy values during rewrites
Josh Bleecher Snyder [Wed, 5 Aug 2015 17:33:09 +0000 (10:33 -0700)]
[dev.ssa] cmd/compile: copy values during rewrites

Rather than require an explicit Copy on the RHS of rewrite rules,
use rulegen magic to add it.

The advantages to handling this in rulegen are:

* simpler rules
* harder to accidentally miss a Copy

Change-Id: I46853bade83bdf517eee9495bf5a553175277b53
Reviewed-on: https://go-review.googlesource.com/13242
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/ssa/gen: generate better code when right-shifting...
Alexandru Moșoi [Thu, 6 Aug 2015 16:33:49 +0000 (18:33 +0200)]
[dev.ssa] cmd/compile/internal/ssa/gen: generate better code when right-shifting with a constant.

The lowering rules were missing the non-64 bit case.

SBBLcarrymask can be folded to a int32 integer whose
type has a smaller bit size. Without the new AND rules
the following would be generated:

    v19 = MOVLconst <uint8> [-1] : SI
    v20 = ANDB <uint8> v18 v19 : DI

which is obviously a NOP.

Fixes #12022

Change-Id: I5f4209f78edc0f118e5b9b2908739f09cefebca4
Reviewed-on: https://go-review.googlesource.com/13301
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile: handle phi control values
Josh Bleecher Snyder [Wed, 5 Aug 2015 22:56:31 +0000 (15:56 -0700)]
[dev.ssa] cmd/compile: handle phi control values

Tests courtesy of Todd Neal.

Change-Id: If657c7c7d3cd1ce01e9d9ad79eb6b2110230c0f9
Reviewed-on: https://go-review.googlesource.com/13267
Reviewed-by: Todd Neal <todd@tneal.org>
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/ssa: more checks on ssa structure
Keith Randall [Wed, 5 Aug 2015 04:59:15 +0000 (21:59 -0700)]
[dev.ssa] cmd/compile/internal/ssa: more checks on ssa structure

Make sure all referenced Blocks and Values are really there.
Fix deadcode to generate SSA graphs that pass this new test.

Change-Id: Ib002ce20e33490eb8c919bd189d209f769d61517
Reviewed-on: https://go-review.googlesource.com/13147
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
9 years ago[dev.ssa] cmd/compile: enforce that all phis are first during regalloc
Josh Bleecher Snyder [Wed, 5 Aug 2015 18:01:59 +0000 (11:01 -0700)]
[dev.ssa] cmd/compile: enforce that all phis are first during regalloc

Change-Id: I035708f5d0659b3deef00808d35e1cc8a80215e0
Reviewed-on: https://go-review.googlesource.com/13243
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile: schedule phi control values first
Josh Bleecher Snyder [Wed, 5 Aug 2015 23:07:13 +0000 (16:07 -0700)]
[dev.ssa] cmd/compile: schedule phi control values first

Change-Id: I684440dc316625d5572cc12179adbc206e306429
Reviewed-on: https://go-review.googlesource.com/13263
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile: tidy up register setup
Josh Bleecher Snyder [Thu, 6 Aug 2015 16:34:54 +0000 (09:34 -0700)]
[dev.ssa] cmd/compile: tidy up register setup

No functional changes.
The intent is just to make this
easier to read and maintain.

Change-Id: Iec207546482cd62bcb22eaae8efe5be6c4f15378
Reviewed-on: https://go-review.googlesource.com/13284
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile: improve error message for phi location mismatch
Josh Bleecher Snyder [Wed, 5 Aug 2015 23:43:49 +0000 (16:43 -0700)]
[dev.ssa] cmd/compile: improve error message for phi location mismatch

Change-Id: I402841743fcdc287631646039eb149f5cfdf886c
Reviewed-on: https://go-review.googlesource.com/13269
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile: don't move OpSP and OpSB values
Josh Bleecher Snyder [Wed, 5 Aug 2015 23:11:57 +0000 (16:11 -0700)]
[dev.ssa] cmd/compile: don't move OpSP and OpSB values

regalloc expects to find all OpSP and OpSB values
in the entry block.

There is no value to moving them; don't.

Change-Id: I775198f03ce7420348721ffc5e7d2bab065465b1
Reviewed-on: https://go-review.googlesource.com/13266
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile: provide better errors for regnum and localOffset failures
Josh Bleecher Snyder [Wed, 5 Aug 2015 23:06:39 +0000 (16:06 -0700)]
[dev.ssa] cmd/compile: provide better errors for regnum and localOffset failures

Change-Id: I2667b0923e17df7cbf08e34ebec1b69a0f2f02b2
Reviewed-on: https://go-review.googlesource.com/13265
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile: respect phi values in tighten
Josh Bleecher Snyder [Wed, 5 Aug 2015 22:51:05 +0000 (15:51 -0700)]
[dev.ssa] cmd/compile: respect phi values in tighten

Given (say)

b1: <- b2 b3
  v1 = Phi <t> v2 v3
b2:
  v2 = ...
b3:
  ...

tighten will move v2 to b1, since it is only used in b1.

This is wrong; v2 needs to be evaluated before entering b1.
Fix it.

Change-Id: I2cc3b30e3ffd221cf594e36cec534dfd9cf3c6a7
Reviewed-on: https://go-review.googlesource.com/13264
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile: add SSA pass to move values closer to uses
Josh Bleecher Snyder [Tue, 4 Aug 2015 21:55:35 +0000 (14:55 -0700)]
[dev.ssa] cmd/compile: add SSA pass to move values closer to uses

Even this very simple, restricted initial implementation helps.

While running make.bash, it moves 84437 values
to new, closer homes.

As a concrete example:

func f_ssa(i, j int, b bool) int {
if !b {
return 0
}
return i + j
}

It cuts off one stack slot and two instructions:

Before:

"".f_ssa t=1 size=96 value=0 args=0x20 locals=0x18
0x0000 00000 (x.go:3) TEXT "".f_ssa(SB), $24-32
0x0000 00000 (x.go:3) SUBQ $24, SP
0x0004 00004 (x.go:3) FUNCDATA $0, "".gcargs·0(SB)
0x0004 00004 (x.go:3) FUNCDATA $1, "".gclocals·1(SB)
0x0004 00004 (x.go:5) MOVQ $0, AX
0x0006 00006 (x.go:3) MOVQ 32(SP), CX
0x000b 00011 (x.go:3) MOVQ 40(SP), DX
0x0010 00016 (x.go:3) LEAQ 48(SP), BX
0x0015 00021 (x.go:3) MOVB (BX), BPB
0x0018 00024 (x.go:3) MOVQ $0, SI
0x001a 00026 (x.go:3) MOVQ SI, 56(SP)
0x001f 00031 (x.go:3) TESTB BPB, BPB
0x0022 00034 (x.go:5) MOVQ AX, (SP)
0x0026 00038 (x.go:3) MOVQ CX, 8(SP)
0x002b 00043 (x.go:3) MOVQ DX, 16(SP)
0x0030 00048 (x.go:4) JEQ 74
0x0032 00050 (x.go:3) MOVQ 8(SP), AX
0x0037 00055 (x.go:3) MOVQ 16(SP), CX
0x003c 00060 (x.go:7) LEAQ (AX)(CX*1), DX
0x0040 00064 (x.go:7) MOVQ DX, 56(SP)
0x0045 00069 (x.go:3) ADDQ $24, SP
0x0049 00073 (x.go:3) RET
0x004a 00074 (x.go:5) MOVQ (SP), AX
0x004e 00078 (x.go:5) MOVQ AX, 56(SP)
0x0053 00083 (x.go:3) JMP 69

After:

"".f_ssa t=1 size=80 value=0 args=0x20 locals=0x10
0x0000 00000 (x.go:3) TEXT "".f_ssa(SB), $16-32
0x0000 00000 (x.go:3) SUBQ $16, SP
0x0004 00004 (x.go:3) FUNCDATA $0, "".gcargs·0(SB)
0x0004 00004 (x.go:3) FUNCDATA $1, "".gclocals·1(SB)
0x0004 00004 (x.go:3) MOVQ 32(SP), AX
0x0009 00009 (x.go:3) MOVQ 24(SP), CX
0x000e 00014 (x.go:3) LEAQ 40(SP), DX
0x0013 00019 (x.go:3) MOVB (DX), BL
0x0015 00021 (x.go:3) MOVQ $0, BP
0x0017 00023 (x.go:3) MOVQ BP, 48(SP)
0x001c 00028 (x.go:3) TESTB BL, BL
0x001e 00030 (x.go:3) MOVQ AX, (SP)
0x0022 00034 (x.go:3) MOVQ CX, 8(SP)
0x0027 00039 (x.go:4) JEQ 64
0x0029 00041 (x.go:3) MOVQ 8(SP), AX
0x002e 00046 (x.go:3) MOVQ (SP), CX
0x0032 00050 (x.go:7) LEAQ (AX)(CX*1), DX
0x0036 00054 (x.go:7) MOVQ DX, 48(SP)
0x003b 00059 (x.go:3) ADDQ $16, SP
0x003f 00063 (x.go:3) RET
0x0040 00064 (x.go:5) MOVQ $0, AX
0x0042 00066 (x.go:5) MOVQ AX, 48(SP)
0x0047 00071 (x.go:3) JMP 59

Of course, the old backend is still well ahead:

"".f_ssa t=1 size=48 value=0 args=0x20 locals=0x0
0x0000 00000 (x.go:3) TEXT "".f_ssa(SB), $0-32
0x0000 00000 (x.go:3) NOP
0x0000 00000 (x.go:3) NOP
0x0000 00000 (x.go:3) FUNCDATA $0, gclocals·a8eabfc4a4514ed6b3b0c61e9680e440(SB)
0x0000 00000 (x.go:3) FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
0x0000 00000 (x.go:4) CMPB "".b+24(FP), $0
0x0005 00005 (x.go:4) JNE 17
0x0007 00007 (x.go:5) MOVQ $0, "".~r3+32(FP)
0x0010 00016 (x.go:5) RET
0x0011 00017 (x.go:7) MOVQ "".i+8(FP), BX
0x0016 00022 (x.go:7) MOVQ "".j+16(FP), BP
0x001b 00027 (x.go:7) ADDQ BP, BX
0x001e 00030 (x.go:7) MOVQ BX, "".~r3+32(FP)
0x0023 00035 (x.go:7) RET

Some regalloc improvements should help considerably.

Change-Id: I95bb5dd83e56afd70ae4e983f1d32dffd0c3d46a
Reviewed-on: https://go-review.googlesource.com/13142
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/ssa: implement ITAB
Keith Randall [Tue, 4 Aug 2015 22:47:22 +0000 (15:47 -0700)]
[dev.ssa] cmd/compile/internal/ssa: implement ITAB

Implement ITAB, selecting the itable field of an interface.

Soften the lowering check to allow lowerings that leave
generic but dead ops behind.  (The ITAB lowering does this.)

Change-Id: Icc84961dd4060d143602f001311aa1d8be0d7fc0
Reviewed-on: https://go-review.googlesource.com/13144
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
9 years ago[dev.ssa] cmd/compile: make GOSSAFUNC trigger logging
Josh Bleecher Snyder [Tue, 4 Aug 2015 18:13:56 +0000 (11:13 -0700)]
[dev.ssa] cmd/compile: make GOSSAFUNC trigger logging

I find myself always adding this in temporarily.
Make it permanent.

Change-Id: I1646b3930a07d0ea01840736ccd449b7fd24f06e
Reviewed-on: https://go-review.googlesource.com/13141
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile: treat control ops as live at end of block
Josh Bleecher Snyder [Tue, 4 Aug 2015 21:22:29 +0000 (14:22 -0700)]
[dev.ssa] cmd/compile: treat control ops as live at end of block

Failure to treat control ops as live can lead
to them being eliminated when they live in
other blocks.

Change-Id: I604a1977a3d3884b1f4516bea4e15885ce38272d
Reviewed-on: https://go-review.googlesource.com/13138
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile: always print block control values
Josh Bleecher Snyder [Tue, 4 Aug 2015 19:53:05 +0000 (12:53 -0700)]
[dev.ssa] cmd/compile: always print block control values

They were being omitted after scheduling.

Change-Id: Ia20e2dcb61fde9ec854918b958c3897bafd282a6
Reviewed-on: https://go-review.googlesource.com/13140
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/ssa: put new values for block rewrites in rewritten...
Keith Randall [Tue, 4 Aug 2015 19:24:23 +0000 (12:24 -0700)]
[dev.ssa] cmd/compile/internal/ssa: put new values for block rewrites in rewritten block

Don't put them in the control value's block.
That may be many blocks up the dominator tree.

Change-Id: Iab3ea36a890ffe0e355dadec7aeb676901c4f070
Reviewed-on: https://go-review.googlesource.com/13134
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
9 years ago[dev.ssa] cmd/compile: log progs during ssa codegen
Josh Bleecher Snyder [Fri, 31 Jul 2015 21:37:15 +0000 (14:37 -0700)]
[dev.ssa] cmd/compile: log progs during ssa codegen

This is helpful when debugging generated code.

Change-Id: I268efa3593a03bb2c4e9f07d9034c004cd40df41
Reviewed-on: https://go-review.googlesource.com/13099
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile: simplify repeated OCOM
Todd Neal [Thu, 30 Jul 2015 20:02:24 +0000 (16:02 -0400)]
[dev.ssa] cmd/compile: simplify repeated OCOM

Rewrite ^{n}x to be ^{n % 2}x.  This will eventually resolve a fuzz
issue that breaks v1.5.

Updates #11352

Change-Id: I1b3f93872d06222f9ff5f6fd5580178ebaf4c003
Reviewed-on: https://go-review.googlesource.com/13110
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/ssa : fix typo in error message
Todd Neal [Tue, 4 Aug 2015 00:28:48 +0000 (19:28 -0500)]
[dev.ssa] cmd/compile/ssa : fix typo in error message

Change-Id: Ibb5169aade15190773ff7dd11b303c1f1345a0c2
Reviewed-on: https://go-review.googlesource.com/13100
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/ssa: Fix scheduler
Keith Randall [Mon, 3 Aug 2015 19:33:03 +0000 (12:33 -0700)]
[dev.ssa] cmd/compile/internal/ssa: Fix scheduler

The DFS scheduler doesn't do the right thing.  If a Value x is used by
more than one other Value, then x is put into the DFS queue when
its first user (call it y) is visited.  It is not removed and reinserted
when the second user of x (call it z) is visited, so the dependency
between x and z is not respected.  There is no easy way to fix this with
the DFS queue because we'd have to rip values out of the middle of the
DFS queue.

The new scheduler works from the end of the block backwards, scheduling
instructions which have had all of their uses already scheduled.
A simple priority scheme breaks ties between multiple instructions that
are ready to schedule simultaneously.

Keep track of whether we've scheduled or not, and make print() use
the scheduled order if we have.

Fix some shift tests that this change tickles.  Add unsigned right shift tests.

Change-Id: I44164c10bb92ae8ab8f76d7a5180cbafab826ea1
Reviewed-on: https://go-review.googlesource.com/13069
Reviewed-by: Todd Neal <todd@tneal.org>
9 years ago[dev.ssa] cmd/compile/ssa: speed up nilcheck
Todd Neal [Tue, 14 Jul 2015 21:26:38 +0000 (16:26 -0500)]
[dev.ssa] cmd/compile/ssa: speed up nilcheck

Reworks nilcheck to be performed by a depth first traversal of the
dominator tree, keeping an updated map of the values that have been
nil-checked during the traversal.

benchmark                           old ns/op     new ns/op     delta
BenchmarkNilCheckDeep1-8            1242          1825          +46.94%
BenchmarkNilCheckDeep10-8           2397          3942          +64.46%
BenchmarkNilCheckDeep100-8          29105         24873         -14.54%
BenchmarkNilCheckDeep1000-8         2742563       265760        -90.31%
BenchmarkNilCheckDeep10000-8        335690119     3157995       -99.06%

benchmark                           old MB/s     new MB/s     speedup
BenchmarkNilCheckDeep1-8            0.81         0.55         0.68x
BenchmarkNilCheckDeep10-8           4.17         2.54         0.61x
BenchmarkNilCheckDeep100-8          3.44         4.02         1.17x
BenchmarkNilCheckDeep1000-8         0.36         3.76         10.44x
BenchmarkNilCheckDeep10000-8        0.03         3.17         105.67x

benchmark                        old allocs     new allocs     delta
BenchmarkNilCheckDeep1-8         9              14             +55.56%
BenchmarkNilCheckDeep10-8        9              23             +155.56%
BenchmarkNilCheckDeep100-8       9              113            +1155.56%
BenchmarkNilCheckDeep1000-8      9              1015
+11177.78%
BenchmarkNilCheckDeep10000-8     9              10024
+111277.78%

benchmark                        old bytes     new bytes     delta
BenchmarkNilCheckDeep1-8         432           608           +40.74%
BenchmarkNilCheckDeep10-8        1008          1496          +48.41%
BenchmarkNilCheckDeep100-8       8064          11656         +44.54%
BenchmarkNilCheckDeep1000-8      73728         145240        +96.99%
BenchmarkNilCheckDeep10000-8     737280        2144411       +190.85%

Change-Id: I0f86010e9823aec04aac744fdb589b65ec8acefc
Reviewed-on: https://go-review.googlesource.com/12332
Reviewed-by: David Chase <drchase@google.com>
9 years ago[dev.ssa] cmd/compile/ssa: test against known values
Todd Neal [Mon, 3 Aug 2015 01:28:31 +0000 (20:28 -0500)]
[dev.ssa] cmd/compile/ssa: test against known values

Modify tests to use a known value instead of comparing the backends
directly.

Change-Id: I32e804e12515885bd94c4f83644cbca03b018fea
Reviewed-on: https://go-review.googlesource.com/13042
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/ssa/gen: add more simplifications rules
Alexandru Moșoi [Fri, 31 Jul 2015 10:32:22 +0000 (12:32 +0200)]
[dev.ssa] cmd/compile/internal/ssa/gen: add more simplifications rules

This is a follow up on https://go-review.googlesource.com/#/c/12420/
with some rules moved to AMD64 closer to the existing rules.

Change-Id: Id346bb0fc4459b3c49b826a59cc74308a590310e
Reviewed-on: https://go-review.googlesource.com/12906
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile: handle non-in-place NEG and NOT
Josh Bleecher Snyder [Fri, 31 Jul 2015 00:15:16 +0000 (17:15 -0700)]
[dev.ssa] cmd/compile: handle non-in-place NEG and NOT

This fixes the crypto/subtle tests.

Change-Id: Ie6e721eec3481f67f13de1bfbd7988e227793148
Reviewed-on: https://go-review.googlesource.com/13000
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile: move most types outside SSA
Josh Bleecher Snyder [Thu, 30 Jul 2015 18:03:05 +0000 (11:03 -0700)]
[dev.ssa] cmd/compile: move most types outside SSA

The only types that remain in the ssa package
are special compiler-only types.

Change-Id: If957abf128ec0778910d67666c297f97f183b7ee
Reviewed-on: https://go-review.googlesource.com/12933
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile: provide stack trace for caught panics
Josh Bleecher Snyder [Thu, 30 Jul 2015 17:28:57 +0000 (10:28 -0700)]
[dev.ssa] cmd/compile: provide stack trace for caught panics

Change-Id: I9cbb6d53a8c2302222b13d2f33b081b704208b8a
Reviewed-on: https://go-review.googlesource.com/12932
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
9 years ago[dev.ssa] cmd/compile/internal/ssa/gen: implement OXOR.
Alexandru Moșoi [Thu, 30 Jul 2015 10:33:36 +0000 (12:33 +0200)]
[dev.ssa] cmd/compile/internal/ssa/gen: implement OXOR.

From compiling go there were 260 functions where XOR was needed.

Much of the required changes for implementing XOR were already
done in 12813.

Change-Id: I5a68aa028f5ed597bc1d62cedbef3620753dfe82
Reviewed-on: https://go-review.googlesource.com/12901
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile: use Copy instead of ConvNop
Josh Bleecher Snyder [Tue, 28 Jul 2015 21:31:25 +0000 (14:31 -0700)]
[dev.ssa] cmd/compile: use Copy instead of ConvNop

The existing backend simply elides OCONVNOP.
There's no reason for us to do any differently.
Rather than insert ConvNops and then rewrite them
away, stop creating them in the first place.

Change-Id: I4bcbe2229fcebd189ae18df24f2c612feb6e215e
Reviewed-on: https://go-review.googlesource.com/12810
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile: fix SUBQ generation error
Todd Neal [Thu, 30 Jul 2015 17:57:43 +0000 (13:57 -0400)]
[dev.ssa] cmd/compile: fix SUBQ generation error

Fix code generation error that resulted in a multi-argument NEGQ

doasm: notfound ft=13 tt=13 00134 NEGQ AX, AX 13 13

Change-Id: I8b712d21a5523eccbae1f33ccea417844c27073e
Reviewed-on: https://go-review.googlesource.com/12869
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
9 years ago[dev.ssa] Merge remote-tracking branch 'origin/master' into mergebranch
Keith Randall [Thu, 30 Jul 2015 19:22:02 +0000 (12:22 -0700)]
[dev.ssa] Merge remote-tracking branch 'origin/master' into mergebranch

Semi-regular merge from tip into ssa branch

Change-Id: Ida553b5c504058347c0bdcb1a987727bdcea456b

9 years agoruntime/cgo: fix darwin/amd64 signal handling setup
Russ Cox [Thu, 30 Jul 2015 18:53:44 +0000 (14:53 -0400)]
runtime/cgo: fix darwin/amd64 signal handling setup

Was not allocating space for the frame above sigpanic,
nor was it pushing the LR into the right place.
Because traceback past sigpanic only needs the
LR for faulting leaves, this was not noticed too much.
But it did break the sync/atomic nil deref tests.

Change-Id: Icba53fffa193423aab744c37f21ee893ce2ee3ac
Reviewed-on: https://go-review.googlesource.com/12926
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/ssa: fix shift operations
Keith Randall [Thu, 30 Jul 2015 00:07:09 +0000 (17:07 -0700)]
[dev.ssa] cmd/compile/internal/ssa: fix shift operations

Convert shift ops to also encode the size of the shift amount.

Change signed right shift from using CMOV to using bit twiddles.
It is a little bit better (5 instructions instead of 4, but fewer
bytes and slightly faster code).  It's also a bit faster than
the 4-instruction branch version, even with a very predictable
branch.  As tested on my machine, YMMV.

Implement OCOM while we are here.

Change-Id: I8ca12dd62fae5d626dc0e6da5d4bbd34fd9640d2
Reviewed-on: https://go-review.googlesource.com/12867
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
9 years agocmd/compile: add case for ODOTTYPE to escwalk
David Chase [Thu, 30 Jul 2015 16:31:18 +0000 (12:31 -0400)]
cmd/compile: add case for ODOTTYPE to escwalk

ODOTTYPE should be treated a whole lot like ODOT,
but it was missing completely from the switch in
escwalk and thus escape status did not propagate
to fields.

Since interfaces are required to trigger this bug,
the test was added to escape_iface.go.

Fixes #11931.

Change-Id: Id0383981cc4b1a160f6ad447192a112eed084538
Reviewed-on: https://go-review.googlesource.com/12921
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/ssa: update generated code
Keith Randall [Thu, 30 Jul 2015 17:36:37 +0000 (10:36 -0700)]
[dev.ssa] cmd/compile/internal/ssa: update generated code

Missed somehow in #12813

Change-Id: I28f2789e33822a4ff884d8a3f474522747f61c73
Reviewed-on: https://go-review.googlesource.com/12868
Reviewed-by: Keith Randall <khr@golang.org>
9 years agosync/atomic: reenable TestNilDeref everywhere
Russ Cox [Thu, 30 Jul 2015 16:37:05 +0000 (12:37 -0400)]
sync/atomic: reenable TestNilDeref everywhere

There is absolutely no information about how this was failing.
If we reenable the test then at least we can get a build log from
darwin/arm.

There are not even freebsd/arm or netbsd/arm builders,
so not too worried about those. (That is another problem.)

Change-Id: I0e739a4dd2897adbe110aa400d720d8fa02ae65f
Reviewed-on: https://go-review.googlesource.com/12920
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: change arm software div/mod call sequence not to modify stack
Russ Cox [Thu, 30 Jul 2015 14:45:01 +0000 (10:45 -0400)]
runtime: change arm software div/mod call sequence not to modify stack

Instead of pushing the denominator argument on the stack,
the denominator is now passed in m.

This fixes a variety of bugs related to trying to take stack traces
backwards from the middle of the software div/mod routines.
Some of those bugs have been kludged around in the past,
but others have not. Instead of trying to patch up after breaking
the stack, this CL stops breaking the stack.

This is an update of https://golang.org/cl/19810043,
which was rolled back in https://golang.org/cl/20350043.

The problem in the original CL was that there were divisions
at bad times, when m was not available. These were divisions
by constant denominators, either in C code or in assembly.
The Go compiler knows how to generate division by multiplication
for constant denominators, but the C compiler did not.
There is no longer any C code, so that's taken care of.
There was one problematic DIV in runtime.usleep (assembly)
but https://golang.org/cl/12898 took care of that one.
So now this approach is safe.

Reject DIV/MOD in NOSPLIT functions to keep them from
coming back.

Fixes #6681.
Fixes #6699.
Fixes #10486.

Change-Id: I09a13c76ad08ba75b3bd5d46a3eb78e66a84ab38
Reviewed-on: https://go-review.googlesource.com/12899
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/cgo: discard trailing zero-sized fields in a non-empty C struct
Ian Lance Taylor [Thu, 30 Jul 2015 05:04:09 +0000 (22:04 -0700)]
cmd/cgo: discard trailing zero-sized fields in a non-empty C struct

In order to fix issue #9401 the compiler was changed to add a padding
byte to any non-empty Go struct that ends in a zero-sized field.  That
causes the Go version of such a C struct to have a different size than
the C struct, which can considerable confusion.  Change cgo so that it
discards any such zero-sized fields, so that the Go and C structs are
the same size.

This is a change from previous releases, in that it used to be
possible to refer to a zero-sized trailing field (by taking its
address), and with this change it no longer is.  That is unfortunate,
but something has to change.  It seems better to visibly break
programs that do this rather than to silently break programs that rely
on the struct sizes being the same.

Update #9401.
Fixes #11925.

Change-Id: I3fba3f02f11265b3c41d68616f79dedb05b81225
Reviewed-on: https://go-review.googlesource.com/12864
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: replace divide with multiply in runtime.usleep on arm
Russ Cox [Thu, 30 Jul 2015 14:54:53 +0000 (10:54 -0400)]
runtime: replace divide with multiply in runtime.usleep on arm

We want to adjust the DIV calling convention to use m,
and usleep can be called without an m, so switch to a
multiplication by the reciprocal (and test).

Step toward a fix for #6699 and #10486.

Change-Id: Iccf76a18432d835e48ec64a2fa34a0e4d6d4b955
Reviewed-on: https://go-review.googlesource.com/12898
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/internal/obj/arm: fix line numbers after constant pool
Russ Cox [Thu, 30 Jul 2015 14:28:44 +0000 (10:28 -0400)]
cmd/internal/obj/arm: fix line numbers after constant pool

If a function is large enough to need to flush the constant pool
mid-function, the line number assignment code was forcing the
line numbers not just for the constant pool but for all the instructions
that follow it. This made the line number information completely
wrong for all but the beginning of large functions on arm.

Same problem in code copied into arm64.

This broke runtime/trace's TestTraceSymbolize.

Fixes arm build.

Change-Id: I84d9fb2c798c4085f69b68dc766ab4800c7a6ca4
Reviewed-on: https://go-review.googlesource.com/12894
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

9 years agocrypto/x509: mark root_darwin_armx.go as cgo-only
Russ Cox [Thu, 30 Jul 2015 15:08:15 +0000 (11:08 -0400)]
crypto/x509: mark root_darwin_armx.go as cgo-only

This allows running a cross-compile like
GOOS=darwin GOARCH=arm go build std
to check that everything builds.

Otherwise there is a redefinition error because both
root_nocgo_darwin.go and root_darwin_armx.go
supply initSystemRoots.

Change-Id: Ic95976b2b698d28c629bfc93d8dac0048b023578
Reviewed-on: https://go-review.googlesource.com/12897
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agonet: allow longer timeout in dialClosedPort test on windows
Russ Cox [Thu, 30 Jul 2015 14:39:07 +0000 (10:39 -0400)]
net: allow longer timeout in dialClosedPort test on windows

The test expects the dial to take 1.0 seconds
on Windows and allows it to go to 1.095 seconds.
That's far too optimistic.
Recent failures are reporting roughly 1.2 seconds.
Let it have 1.5.

Change-Id: Id69811ccb65bf4b4c159301a2b4767deb6ee8d28
Reviewed-on: https://go-review.googlesource.com/12895
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agomath/rand: warn against using package for security-sensitive work
Andrey Petrov [Thu, 30 Jul 2015 09:47:01 +0000 (11:47 +0200)]
math/rand: warn against using package for security-sensitive work

Urge users of math/rand to consider using crypto/rand when doing
security-sensitive work.

Related to issue #11871. While we haven't reached consensus on how
to make the package inherently safer, everyone agrees that the docs
for math/rand can be improved.

Change-Id: I576a312e51b2a3445691da6b277c7b4717173197
Reviewed-on: https://go-review.googlesource.com/12900
Reviewed-by: Rob Pike <r@golang.org>
9 years agoruntime/trace: test requires 'go tool addr2line'
David Crawshaw [Wed, 29 Jul 2015 23:56:10 +0000 (19:56 -0400)]
runtime/trace: test requires 'go tool addr2line'

For the android/arm builder.

Change-Id: Iad4881689223cd6479870da9541524a8cc458cce
Reviewed-on: https://go-review.googlesource.com/12859
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>

9 years agocmd/compile: fix uninitialized memory during type switch assertE2I2
Russ Cox [Thu, 30 Jul 2015 04:46:42 +0000 (00:46 -0400)]
cmd/compile: fix uninitialized memory during type switch assertE2I2

Fixes arm64 builder crash.

The bug is possible on all architectures; you just have to get lucky
and hit a preemption or a stack growth on entry to assertE2I2.
The test stacks the deck.

Change-Id: I8419da909b06249b1ad15830cbb64e386b6aa5f6
Reviewed-on: https://go-review.googlesource.com/12890
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
9 years agoruntime: enable TestEmptySlice
Russ Cox [Wed, 29 Jul 2015 23:05:07 +0000 (19:05 -0400)]
runtime: enable TestEmptySlice

It says to disable until #7564 is fixed. It was fixed in April 2014.

Change-Id: I9bebfe96802bafdd2d1a0a47591df346d91b000c
Reviewed-on: https://go-review.googlesource.com/12858
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agoruntime: set invalidptr=1 by default, as documented go1.5beta3
Russ Cox [Wed, 29 Jul 2015 23:04:35 +0000 (19:04 -0400)]
runtime: set invalidptr=1 by default, as documented

Also make invalidptr control the recently added GC pointer check,
as documented.

Change-Id: Iccfdf49480219d12be8b33b8f03d8312d8ceabed
Reviewed-on: https://go-review.googlesource.com/12857
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
9 years agodoc: remove non-answer from FAQ
Andrew Gerrand [Wed, 29 Jul 2015 22:27:56 +0000 (08:27 +1000)]
doc: remove non-answer from FAQ

Change-Id: Ie43986d016e5a9fb17ca1393263932bbb56e81ff
Reviewed-on: https://go-review.googlesource.com/12836
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime/trace: remove existing Skips
Russ Cox [Tue, 28 Jul 2015 17:37:13 +0000 (13:37 -0400)]
runtime/trace: remove existing Skips

The skips added in CL 12579, based on incorrect time stamps,
should be sufficient to identify and exclude all the time-related
flakiness on these systems.

If there is other flakiness, we want to find out.

For #10512.

Change-Id: I5b588ac1585b2e9d1d18143520d2d51686b563e3
Reviewed-on: https://go-review.googlesource.com/12746
Reviewed-by: Austin Clements <austin@google.com>
9 years agoruntime/trace: record event sequence numbers explicitly
Russ Cox [Thu, 23 Jul 2015 18:01:03 +0000 (14:01 -0400)]
runtime/trace: record event sequence numbers explicitly

Nearly all the flaky failures we've seen in trace tests have been
due to the use of time stamps to determine relative event ordering.
This is tricky for many reasons, including:
 - different cores might not have exactly synchronized clocks
 - VMs are worse than real hardware
 - non-x86 chips have different timer resolution than x86 chips
 - on fast systems two events can end up with the same time stamp

Stop trying to make time reliable. It's clearly not going to be for Go 1.5.
Instead, record an explicit event sequence number for ordering.
Using our own counter solves all of the above problems.

The trace still contains time stamps, of course. The sequence number
is just used for ordering.

Should alleviate #10554 somewhat. Then tickDiv can be chosen to
be a useful time unit instead of having to be exact for ordering.

Separating ordering and time stamps lets the trace parser diagnose
systems where the time stamp order and actual order do not match
for one reason or another. This CL adds that check to the end of
trace.Parse, after all other sequence order-based checking.
If that error is found, we skip the test instead of failing it.
Putting the check in trace.Parse means that cmd/trace will pick
up the same check, refusing to display a trace where the time stamps
do not match actual ordering.

Using net/http's BenchmarkClientServerParallel4 on various CPU counts,
not tracing vs tracing:

name                      old time/op    new time/op    delta
ClientServerParallel4       50.4µs ± 4%    80.2µs ± 4%  +59.06%        (p=0.000 n=10+10)
ClientServerParallel4-2     33.1µs ± 7%    57.8µs ± 5%  +74.53%        (p=0.000 n=10+10)
ClientServerParallel4-4     18.5µs ± 4%    32.6µs ± 3%  +75.77%        (p=0.000 n=10+10)
ClientServerParallel4-6     12.9µs ± 5%    24.4µs ± 2%  +89.33%        (p=0.000 n=10+10)
ClientServerParallel4-8     11.4µs ± 6%    21.0µs ± 3%  +83.40%        (p=0.000 n=10+10)
ClientServerParallel4-12    14.4µs ± 4%    23.8µs ± 4%  +65.67%        (p=0.000 n=10+10)

Fixes #10512.

Change-Id: I173eecf8191e86feefd728a5aad25bf1bc094b12
Reviewed-on: https://go-review.googlesource.com/12579
Reviewed-by: Austin Clements <austin@google.com>
9 years agoruntime: ignore arguments in cgocallback_gofunc frame
Russ Cox [Wed, 29 Jul 2015 20:16:13 +0000 (16:16 -0400)]
runtime: ignore arguments in cgocallback_gofunc frame

Otherwise the GC may see uninitialized memory there,
which might be old pointers that are retained, or it might
trigger the invalid pointer check.

Fixes #11907.

Change-Id: I67e306384a68468eef45da1a8eb5c9df216a77c0
Reviewed-on: https://go-review.googlesource.com/12852
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
9 years agoruntime: fix darwin/amd64 assembly frame sizes
Russ Cox [Wed, 29 Jul 2015 22:25:30 +0000 (18:25 -0400)]
runtime: fix darwin/amd64 assembly frame sizes

Change-Id: I2f0ecdc02ce275feadf07e402b54f988513e9b49
Reviewed-on: https://go-review.googlesource.com/12855
Reviewed-by: Russ Cox <rsc@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/ssa: implement lots of small (<8byte) ops.
Keith Randall [Tue, 28 Jul 2015 23:04:50 +0000 (16:04 -0700)]
[dev.ssa] cmd/compile/internal/ssa: implement lots of small (<8byte) ops.

Lots and lots of ops!
Also XOR for good measure.

Add a pass to the compiler generator to check that all of the
architecture-specific opcodes are handled by genValue.  We will
catch any missing ones if we come across them during compilation,
but probably better to catch them statically.

Change-Id: Ic4adfbec55c8257f88117bc732fa664486262868
Reviewed-on: https://go-review.googlesource.com/12813
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
9 years agocmd/internal/obj/arm64: fix build
Russ Cox [Wed, 29 Jul 2015 21:42:58 +0000 (17:42 -0400)]
cmd/internal/obj/arm64: fix build

Change-Id: I3088e17aff72096e3ec2ced49c70564627c982a6
Reviewed-on: https://go-review.googlesource.com/12854
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: reenable bad pointer check in GC
Russ Cox [Wed, 29 Jul 2015 19:18:56 +0000 (15:18 -0400)]
runtime: reenable bad pointer check in GC

The last time we tried this, linux/arm64 broke.
The series of CLs leading to this one fixes that problem.
Let's try again.

Fixes #9880.

Change-Id: I67bc1d959175ec972d4dcbe4aa6f153790f74251
Reviewed-on: https://go-review.googlesource.com/12849
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
9 years agocmd/internal/obj/arm64: reject misaligned stack frames, except empty frames
Russ Cox [Wed, 29 Jul 2015 19:15:03 +0000 (15:15 -0400)]
cmd/internal/obj/arm64: reject misaligned stack frames, except empty frames

The layout code has to date insisted on stack frames that are 16-aligned
including the saved LR, and it ensured this by growing the frame itself.
This breaks code that refers to values near the top of the frame by positive
offset from SP, and in general it's too magical: if you see TEXT xxx, $N,
you expect that the frame size is actually N, not sometimes N and sometimes N+8.

This led to a serious bug in the compiler where ambiguously live values
were not being zeroed correctly, which in turn triggered an assertion
in the GC about finding only valid pointers. The compiler has been
fixed to always emit aligned frames, and the hand-written assembly
has also been fixed.

Now that everything is aligned, make unaligned an error instead of
something to "fix" silently.

For #9880.

Change-Id: I05f01a9df174d64b37fa19b36a6b6c5f18d5ba2d
Reviewed-on: https://go-review.googlesource.com/12848
Reviewed-by: Austin Clements <austin@google.com>
9 years agocmd/link: fix nosplit stack overflow checks
Russ Cox [Wed, 29 Jul 2015 19:07:35 +0000 (15:07 -0400)]
cmd/link: fix nosplit stack overflow checks

The nosplit stack overflow checks were confused about morestack.
The comment about not having correct SP information at the call
to morestack was true, but that was a real bug, not something to
work around. I fixed that problem in CL 12144. With that fixed,
no need to special-case morestack in the way done here.

This cleanup and simplification of the code was the first step
to fixing a bug that happened when I started working on the
arm64 frame size adjustments, but the cleanup was sufficient
to make the bug go away.

For #9880.

Change-Id: I16b69a5c16b6b8cb4090295d3029c42d606e3b9b
Reviewed-on: https://go-review.googlesource.com/12846
Reviewed-by: Austin Clements <austin@google.com>
9 years agoruntime, reflect: use correctly aligned stack frame sizes on arm64
Russ Cox [Wed, 29 Jul 2015 19:04:30 +0000 (15:04 -0400)]
runtime, reflect: use correctly aligned stack frame sizes on arm64

arm64 requires either no stack frame or a frame with a size that is 8 mod 16
(adding the saved LR will make it 16-aligned).

The cmd/internal/obj/arm64 has been silently aligning frames, but it led to
a terrible bug when the compiler and obj disagreed on the frame size,
and it's just generally confusing, so we're going to make misaligned frames
an error instead of something that is silently changed.

This CL prepares by updating assembly files.
Note that the changes in this CL are already being done silently by
cmd/internal/obj/arm64, so there is no semantic effect here,
just a clarity effect.

For #9880.

Change-Id: Ibd6928dc5fdcd896c2bacd0291bf26b364591e28
Reviewed-on: https://go-review.googlesource.com/12845
Reviewed-by: Austin Clements <austin@google.com>
9 years agocmd/compile: align arm64 stack frames correctly
Russ Cox [Wed, 29 Jul 2015 19:11:42 +0000 (15:11 -0400)]
cmd/compile: align arm64 stack frames correctly

If the compiler doesn't do it, cmd/internal/obj/arm64 will,
and that will break the zeroing of ambiguously live values
done in zerorange, which in turn produces uninitialized
pointer cells that the GC trips over.

For #9880.

Change-Id: Ice97c30bc8b36d06b7b88d778d87fab8e1827fdc
Reviewed-on: https://go-review.googlesource.com/12847
Reviewed-by: Austin Clements <austin@google.com>
9 years ago[dev.ssa] cmd/compile/internal/ssa/gen: implement OOR.
Alexandru Moșoi [Wed, 29 Jul 2015 15:52:25 +0000 (17:52 +0200)]
[dev.ssa] cmd/compile/internal/ssa/gen: implement OOR.

From compiling go there were 761 functions where OR was needed.

Change-Id: Ied8bf59cec50a3175273387bc7416bd042def6d8
Reviewed-on: https://go-review.googlesource.com/12766
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
9 years agoruntime: report GC CPU utilization in MemStats
Austin Clements [Wed, 29 Jul 2015 18:02:34 +0000 (14:02 -0400)]
runtime: report GC CPU utilization in MemStats

This adds a GCCPUFraction field to MemStats that reports the
cumulative fraction of the program's execution time spent in the
garbage collector. This is equivalent to the utilization percent shown
in the gctrace output and makes this available programmatically.

This does make one small effect on the gctrace output: we now report
the duration of mark termination up to just before the final
start-the-world, rather than up to just after. However, unlike
stop-the-world, I don't believe there's any way that start-the-world
can block, so it should take negligible time.

While there are many statistics one might want to expose via MemStats,
this is one of the few that will undoubtedly remain meaningful
regardless of future changes to the memory system.

The diff for this change is larger than the actual change. Mostly it
lifts the code for computing the GC CPU utilization out of the
debug.gctrace path.

Updates #10323.

Change-Id: I0f7dc3fdcafe95e8d1233ceb79de606b48acd989
Reviewed-on: https://go-review.googlesource.com/12844
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: always capture GC phase transition times
Austin Clements [Wed, 29 Jul 2015 16:48:33 +0000 (12:48 -0400)]
runtime: always capture GC phase transition times

Currently we only capture GC phase transition times if
debug.gctrace>0, but we're about to compute GC CPU utilization
regardless of whether debug.gctrace is set, so we need these
regardless of debug.gctrace.

Change-Id: If3acf16505a43d416e9a99753206f03287180660
Reviewed-on: https://go-review.googlesource.com/12843
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
9 years agoruntime: avoid race between SIGPROF traceback and stack barriers
Austin Clements [Tue, 28 Jul 2015 18:33:39 +0000 (14:33 -0400)]
runtime: avoid race between SIGPROF traceback and stack barriers

The following sequence of events can lead to the runtime attempting an
out-of-bounds access on a stack barrier slice:

1. A SIGPROF comes in on a thread while the G on that thread is in
   _Gsyscall. The sigprof handler calls gentraceback, which saves a
   local copy of the G's stkbar slice. Currently the G has no stack
   barriers, so this slice is empty.

2. On another thread, the GC concurrently scans the stack of the
   goroutine being profiled (it considers it stopped because it's in
   _Gsyscall) and installs stack barriers.

3. Back on the sigprof thread, gentraceback comes across a stack
   barrier in the stack and attempts to look it up in its (zero
   length) copy of G's old stkbar slice, which causes an out-of-bounds
   access.

This commit fixes this by adding a simple cas spin to synchronize the
SIGPROF handler with stack barrier insertion.

In general I would prefer that this synchronization be done through
the G status, since that's how stack scans are otherwise synchronized,
but adding a new lock is a much smaller change and G statuses are full
of subtlety.

Fixes #11863.

Change-Id: Ie89614a6238bb9c6a5b1190499b0b48ec759eaf7
Reviewed-on: https://go-review.googlesource.com/12748
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: force mutator to give work buffer to GC
Rick Hudson [Wed, 29 Jul 2015 16:03:54 +0000 (12:03 -0400)]
runtime: force mutator to give work buffer to GC

The scheduler, work buffer's dispose, and write barriers
can conspire to hide the a pointer from the GC's concurent
mark phase. If this pointer is the only path to a large
amount of marking the STW mark termination phase may take
a lot of time.

Consider the following:
1) dispose places a work buffer on the partial queue
2) the GC is busy so it does not immediately remove and
   process the work buffer
3) the scheduler runs a mutator whose write barrier dequeues the
   work buffer from the partial queue so the GC won't see it
This repeats until the GC reaches the mark termination
phase where the GC finally discovers the pointer along
with a lot of work to do.

This CL fixes the problem by having the mutator
dispose of the buffer to the full queue instead of
the partial queue. Since the write buffer never asks for full
buffers the conspiracy described above is not possible.

Updates #11694.

Change-Id: I2ce832f9657a7570f800e8ce4459cd9e304ef43b
Reviewed-on: https://go-review.googlesource.com/12840
Reviewed-by: Austin Clements <austin@google.com>
9 years agodoc: add json tokenizer to go1.5.html
Rob Pike [Tue, 28 Jul 2015 23:43:32 +0000 (09:43 +1000)]
doc: add json tokenizer to go1.5.html

Change-Id: I45d92fed757fa1866d5b80e53ed1af6712fa6741
Reviewed-on: https://go-review.googlesource.com/12782
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/internal/asm: delete
Mikio Hara [Wed, 29 Jul 2015 03:55:19 +0000 (12:55 +0900)]
cmd/internal/asm: delete

Updates #10510.

Change-Id: Ib4d39943969d18517b373292b83d87650d5df12a
Reviewed-on: https://go-review.googlesource.com/12787
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agocmd: delete old[5689]a
Rob Pike [Wed, 29 Jul 2015 03:06:28 +0000 (13:06 +1000)]
cmd: delete old[5689]a

These are the old assemblers written in C, and now they are
not needed.

Fixes #10510.

Change-Id: Id9337ffc8eccfd93c84b2e23f427fb1a576b543d
Reviewed-on: https://go-review.googlesource.com/12784
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agocmd/dist: cleanup message about building go_bootstrap
Matthew Dempsky [Tue, 28 Jul 2015 17:58:27 +0000 (10:58 -0700)]
cmd/dist: cleanup message about building go_bootstrap

At this stage, dist is only building go_bootstrap as cmd/compile and
the rest of the Go toolchain has already been built.

Change-Id: I6f99fa00ff1d3585e215f4ce84d49344c4fcb8a5
Reviewed-on: https://go-review.googlesource.com/12779
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/go: fix go get -u with vendoring
Russ Cox [Tue, 28 Jul 2015 19:50:51 +0000 (15:50 -0400)]
cmd/go: fix go get -u with vendoring

Fixes #11864.

Change-Id: Ib9d5bd79f3b73ebd32f6585b354aaad556e0fc71
Reviewed-on: https://go-review.googlesource.com/12749
Reviewed-by: Rob Pike <r@golang.org>
9 years ago[dev.ssa] cmd/compile: lower all integer comparisons
Josh Bleecher Snyder [Tue, 28 Jul 2015 21:36:14 +0000 (14:36 -0700)]
[dev.ssa] cmd/compile: lower all integer comparisons

Change-Id: I683281e1293d3df3c39772e7b08f0b55a3b61404
Reviewed-on: https://go-review.googlesource.com/12811
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile: add a few more binary ops
Josh Bleecher Snyder [Tue, 28 Jul 2015 21:14:25 +0000 (14:14 -0700)]
[dev.ssa] cmd/compile: add a few more binary ops

With this, all non-float, non-complex
binary ops found in the standard library
are implemented.

Change-Id: I6087f115229888c0dce10ab35db3fd36a0e0a8b1
Reviewed-on: https://go-review.googlesource.com/12799
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/ssa: Split OpConst into an OpConst8, OpConst16, ...
Keith Randall [Tue, 28 Jul 2015 21:19:20 +0000 (14:19 -0700)]
[dev.ssa] cmd/compile/internal/ssa: Split OpConst into an OpConst8, OpConst16, ...

Convert the polymorphic OpConst into monomorphic variants.

Change-Id: I90bb8894fbac04ca5e5484ea260c131ef8b506fb
Reviewed-on: https://go-review.googlesource.com/12798
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
9 years ago[dev.ssa] cmd/compile: implement OINDREG in expr context
Josh Bleecher Snyder [Tue, 28 Jul 2015 19:37:46 +0000 (12:37 -0700)]
[dev.ssa] cmd/compile: implement OINDREG in expr context

Change-Id: I1922656c99773255e5bc15b5a2bd79f19a2fe82c
Reviewed-on: https://go-review.googlesource.com/12796
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile: finish InvertFlags rewrites
Josh Bleecher Snyder [Mon, 27 Jul 2015 23:37:22 +0000 (16:37 -0700)]
[dev.ssa] cmd/compile: finish InvertFlags rewrites

Change-Id: I61b2d2be18f905a17e8ee765a4494b763a425c55
Reviewed-on: https://go-review.googlesource.com/12794
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile: implement genValue for MOVQstoreidx8
Josh Bleecher Snyder [Mon, 27 Jul 2015 23:36:36 +0000 (16:36 -0700)]
[dev.ssa] cmd/compile: implement genValue for MOVQstoreidx8

Change-Id: I6b13a26e01ef8739ed60e6fd5f5c1ea045bea581
Reviewed-on: https://go-review.googlesource.com/12793
Reviewed-by: Keith Randall <khr@golang.org>
9 years agoruntime: fix out-of-bounds in stack debugging
Dmitry Vyukov [Tue, 28 Jul 2015 18:50:00 +0000 (20:50 +0200)]
runtime: fix out-of-bounds in stack debugging

Currently stackDebug=4 crashes as:

panic: runtime error: index out of range
fatal error: panic on system stack
runtime stack:
runtime.throw(0x607470, 0x15)
src/runtime/panic.go:527 +0x96
runtime.gopanic(0x5ada00, 0xc82000a1d0)
src/runtime/panic.go:354 +0xb9
runtime.panicindex()
src/runtime/panic.go:12 +0x49
runtime.adjustpointers(0xc820065ac8, 0x7ffe58b56100, 0x7ffe58b56318, 0x0)
src/runtime/stack1.go:428 +0x5fb
runtime.adjustframe(0x7ffe58b56200, 0x7ffe58b56318, 0x1)
src/runtime/stack1.go:542 +0x780
runtime.gentraceback(0x487760, 0xc820065ac0, 0x0, 0xc820001080, 0x0, 0x0, 0x7fffffff, 0x6341b8, 0x7ffe58b56318, 0x0, ...)
src/runtime/traceback.go:336 +0xa7e
runtime.copystack(0xc820001080, 0x1000)
src/runtime/stack1.go:616 +0x3b1
runtime.newstack()
src/runtime/stack1.go:801 +0xdde

Change-Id: If2d60960231480a9dbe545d87385fe650d6db808
Reviewed-on: https://go-review.googlesource.com/12763
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: use 64k page rounding on arm64
Russ Cox [Tue, 28 Jul 2015 17:41:16 +0000 (13:41 -0400)]
runtime: use 64k page rounding on arm64

Fixes #11886.

Change-Id: I9392fd2ef5951173ae275b3ab42db4f8bd2e1d7a
Reviewed-on: https://go-review.googlesource.com/12747
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years ago[dev.ssa] cmd/compile: respect Xoffset of static data
Josh Bleecher Snyder [Tue, 28 Jul 2015 18:08:44 +0000 (11:08 -0700)]
[dev.ssa] cmd/compile: respect Xoffset of static data

Together with teaching SSA to generate static data,
this fixes the encoding/pem and hash/adler32 tests.

Change-Id: I75f81f6c995dcb9c6d99bd3acda94a4feea8b87b
Reviewed-on: https://go-review.googlesource.com/12791
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile: implement static data generation
Josh Bleecher Snyder [Tue, 28 Jul 2015 17:56:39 +0000 (10:56 -0700)]
[dev.ssa] cmd/compile: implement static data generation

The existing backend recognizes special
assignment statements as being implementable
with static data rather than code.
Unfortunately, it assumes that it is in the middle
of codegen; it emits data and modifies the AST.

This does not play well with SSA's two-phase
bootstrapping approach, in which we attempt to
compile code but fall back to the existing backend
if something goes wrong.

To work around this:

* Add the ability to inquire about static data
without side-effects.
* Save the static data required for a function.
* Emit that static data during SSA codegen.

Change-Id: I2e8a506c866ea3e27dffb597095833c87f62d87e
Reviewed-on: https://go-review.googlesource.com/12790
Reviewed-by: Keith Randall <khr@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/ssa: redo how sign extension is handled
Keith Randall [Thu, 23 Jul 2015 21:35:02 +0000 (14:35 -0700)]
[dev.ssa] cmd/compile/internal/ssa: redo how sign extension is handled

For integer types less than a machine register, we have to decide
what the invariants are for the high bits of the register.  We used
to set the high bits to the correct extension (sign or zero, as
determined by the type) of the low bits.

This CL makes the compiler ignore the high bits of the register
altogether (they are junk).

On this plus side, this means ops that generate subword results don't
have to worry about correctly extending them.  On the minus side,
ops that consume subword arguments have to deal with the input
registers not being correctly extended.

For x86, this tradeoff is probably worth it.  Almost all opcodes
have versions that use only the correct subword piece of their
inputs.  (The one big exception is array indexing.)  Not many opcodes
can correctly sign extend on output.

For other architectures, the tradeoff is probably not so clear, as
they don't have many subword-safe opcodes (e.g. 16-bit compare,
ignoring the high 16/48 bits).  Fortunately we can decide whether
we do this per-architecture.

For the machine-independent opcodes, we pretend that the "register"
size is equal to the type width, so sign extension is immaterial.
Opcodes that care about the signedness of the input (e.g. compare,
right shift) have two different variants.

Change-Id: I465484c5734545ee697afe83bc8bf4b53bd9df8d
Reviewed-on: https://go-review.googlesource.com/12600
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
9 years agoruntime: fix x86 stack trace for call to heap memory on Plan 9
David du Colombier [Tue, 28 Jul 2015 18:48:10 +0000 (20:48 +0200)]
runtime: fix x86 stack trace for call to heap memory on Plan 9

Russ Cox fixed this issue for other systems
in CL 12026, but the Plan 9 part was forgotten.

Fixes #11656.

Change-Id: I91c033687987ba43d13ad8f42e3fe4c7a78e6075
Reviewed-on: https://go-review.googlesource.com/12762
Reviewed-by: Russ Cox <rsc@golang.org>
9 years ago[dev.ssa] cmd/compile: implement non-numeric comparisons
Josh Bleecher Snyder [Mon, 27 Jul 2015 20:17:45 +0000 (13:17 -0700)]
[dev.ssa] cmd/compile: implement non-numeric comparisons

The only slice/interface comparisons that reach
the backend are comparisons to nil.

Funcs, maps, and channels are references types,
so pointer equality is enough.

Change-Id: I60a71da46a36202e9bd62ed370ab7d7f2e2800e7
Reviewed-on: https://go-review.googlesource.com/12715
Reviewed-by: Keith Randall <khr@golang.org>
9 years agocmd/doc: extend darwin/arm64 test TODO to arm
David Crawshaw [Tue, 28 Jul 2015 16:59:34 +0000 (12:59 -0400)]
cmd/doc: extend darwin/arm64 test TODO to arm

Change-Id: Iee0f3890d66b4117aa5d9f486e5775b1cf31996c
Reviewed-on: https://go-review.googlesource.com/12745
Reviewed-by: Russ Cox <rsc@golang.org>
9 years ago[dev.ssa] cmd/compile/internal/ssa/gen: implement OAND.
Alexandru Moșoi [Tue, 28 Jul 2015 12:58:49 +0000 (14:58 +0200)]
[dev.ssa] cmd/compile/internal/ssa/gen: implement OAND.

Before this patch there was only partial support for ANDQconst
which was not lowered. This patch added support for AND operations
for all bit sizes and signs.

Change-Id: I3a6b2cddfac5361b27e85fcd97f7f3537ebfbcb6
Reviewed-on: https://go-review.googlesource.com/12761
Reviewed-by: Keith Randall <khr@golang.org>
9 years agotest: don't run fixedbugs/issue11656.go on netbsd/386
Ian Lance Taylor [Tue, 28 Jul 2015 15:33:24 +0000 (08:33 -0700)]
test: don't run fixedbugs/issue11656.go on netbsd/386

The netbsd/386 builder reports a failure at
http://build.golang.org/log/c21c45a4fc6f4845868aa3ebde0f5bb3f167f3a3

I'm assuming that this is similar to the unknown openbsd failure.

Update #11910.

Change-Id: I9cdfefa23dc7cda3849f14814b3ce531f1d39e93
Reviewed-on: https://go-review.googlesource.com/12777
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years agotest: don't run issue10607.go on ppc64
Ian Lance Taylor [Tue, 28 Jul 2015 14:42:09 +0000 (07:42 -0700)]
test: don't run issue10607.go on ppc64

This is a reprise of https://golang.org/cl/12623.  In that a CL I made
a suggestion which forgot that the +build constraints in the test
directory are not the same as those supported by the go tool: in the
test directory, if a single +build line fails, the test is skipped.
(In my defense, the code I was commenting on was also wrong.)

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

9 years agocmd/asm: fix and test CALL, JMP aliases on arm, arm64, ppc64
Russ Cox [Tue, 28 Jul 2015 03:26:26 +0000 (23:26 -0400)]
cmd/asm: fix and test CALL, JMP aliases on arm, arm64, ppc64

Fixes #11900.

Change-Id: Idfc54e1fac833c8d646266128efe46214a82dfed
Reviewed-on: https://go-review.googlesource.com/12741
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
9 years agoruntime: don't define libc_getpid in os3_solaris.go
Ian Lance Taylor [Tue, 28 Jul 2015 06:29:09 +0000 (23:29 -0700)]
runtime: don't define libc_getpid in os3_solaris.go

The function is already defined between syscall_solaris.go and
syscall2_solaris.go.

Change-Id: I034baf7c8531566bebfdbc5a4061352cbcc31449
Reviewed-on: https://go-review.googlesource.com/12773
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agonet: make spuriousENOTAVAIL to be able to parse EADDRNOTAVAIL correctly
Mikio Hara [Tue, 28 Jul 2015 03:28:09 +0000 (12:28 +0900)]
net: make spuriousENOTAVAIL to be able to parse EADDRNOTAVAIL correctly

Change-Id: I82e3aadbd18fccb98a76d1c36876510f5e1c3089
Reviewed-on: https://go-review.googlesource.com/12750
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agocmd/go: avoid long lines in help messages
Jeff R. Allen [Thu, 23 Jul 2015 12:56:13 +0000 (14:56 +0200)]
cmd/go: avoid long lines in help messages

Reformat some help messages to stay within 80 characters.

Fixes #11840.

Change-Id: Iebafcb616f202ac44405e5897097492a79a51722
Reviewed-on: https://go-review.googlesource.com/12514
Reviewed-by: Rob Pike <r@golang.org>
9 years agonet: don't return DNS query results including the second best records unconditionally
Mikio Hara [Tue, 9 Jun 2015 08:30:00 +0000 (17:30 +0900)]
net: don't return DNS query results including the second best records unconditionally

This change prevents DNS query results using domain search list
overtaking results not using the list unconditionally, which only
happens when using builtin DNS stub resolver.

The previous internal lookup function lookup is split into lookup and
goLookupIPOrder for iteration over a set of names: FQDN or absolute
FQDN, with domain label suffixes in search list, without domain label
suffixes, and for concurrent A and AAAA record queries.

Fixes #11081.

Change-Id: I9ff0640f69276e372d97e709b149ed5b153e8601
Reviewed-on: https://go-review.googlesource.com/10836
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoencoding/json: test style tweaks
Brad Fitzpatrick [Tue, 28 Jul 2015 05:53:37 +0000 (07:53 +0200)]
encoding/json: test style tweaks

Rename test name from Http to HTTP, and fix some style nits.

Change-Id: I00fe1cecd69ca2f50be86a76ec90031c2f921707
Reviewed-on: https://go-review.googlesource.com/12760
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agoruntime: fix definitions of getpid and kill on Solaris
Ian Lance Taylor [Tue, 28 Jul 2015 06:09:16 +0000 (23:09 -0700)]
runtime: fix definitions of getpid and kill on Solaris

A further attempt to fix raiseproc on Solaris.

Change-Id: I8d8000d6ccd0cd9f029ebe1f211b76ecee230cd0
Reviewed-on: https://go-review.googlesource.com/12771
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agoruntime: correct implementation of raiseproc on Solaris
Ian Lance Taylor [Mon, 27 Jul 2015 17:41:41 +0000 (10:41 -0700)]
runtime: correct implementation of raiseproc on Solaris

I forgot that the libc raise function only sends the signal to the
current thread.  We need to actually use kill and getpid here, as we
do on other systems.

Change-Id: Iac34af822c93468bf68cab8879db3ee20891caaf
Reviewed-on: https://go-review.googlesource.com/12704
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agonet/http: disable new flaky TestTransportCancelBeforeResponseHeaders test
Brad Fitzpatrick [Mon, 27 Jul 2015 22:01:16 +0000 (00:01 +0200)]
net/http: disable new flaky TestTransportCancelBeforeResponseHeaders test

I'll rewrite this later. It's apparently dependent on scheduling order.
The earlier fix in git rev 9d56c181 seems fine, though.

Update #11894

Change-Id: I7c150918af4be079c262a5f2933ef4639cc535ef
Reviewed-on: https://go-review.googlesource.com/12731
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agonet: Set finalDeadline from TestDialParallel to avoid leaked sockets.
Paul Marks [Mon, 27 Jul 2015 21:39:32 +0000 (14:39 -0700)]
net: Set finalDeadline from TestDialParallel to avoid leaked sockets.

I've also changed TestDialSerialAsyncSpuriousConnection for consistency,
although it always computes a finalDeadline of zero.

Note that #11225 is the root cause of the socket leak; this just hides
it from the unit test by restoring the shorter timeout.

Fixes #11878

Change-Id: Ie0037dd3bce6cc81d196765375489f8c61be74c2
Reviewed-on: https://go-review.googlesource.com/12712
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Paul Marks <pmarks@google.com>