]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
9 years agoREADME: emphasize that we don't accept pull requests
Robert Griesemer [Thu, 8 Jan 2015 18:35:44 +0000 (10:35 -0800)]
README: emphasize that we don't accept pull requests

Change-Id: Ie31f957f6b60b0a9405147c7a0af789df01a4b02
Reviewed-on: https://go-review.googlesource.com/2550
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agoruntime: improve GC times printing
Austin Clements [Wed, 7 Jan 2015 20:34:02 +0000 (15:34 -0500)]
runtime: improve GC times printing

This improves the printing of GC times to be both more human-friendly
and to provide enough information for the construction of MMU curves
and other statistics.  The new times look like:

GC: #8 72413852ns @143036695895725 pause=622900 maxpause=427037 goroutines=11 gomaxprocs=4
GC:     sweep term: 190584ns    max=190584 total=275001 procs=4
GC:     scan:       260397ns    max=260397 total=902666 procs=1
GC:     install wb: 5279ns    max=5279 total=18642 procs=4
GC:     mark:       71530555ns    max=71530555 total=186694660 procs=1
GC:     mark term:  427037ns    max=427037 total=1691184 procs=4

This prints gomaxprocs and the number of procs used in each phase for
the benefit of analyzing mutator utilization during concurrent phases.
This also means the analysis doesn't have to hard-code which phases
are STW.

This prints the absolute start time only for the GC cycle.  The other
start times can be derived from the phase durations.  This declutters
the view for humans readers and doesn't pose any additional complexity
for machine readers.

This removes the confusing "cycle" terminology.  Instead, this places
the phase duration after the phase name and adds a "ns" unit, which
both makes it implicitly clear that this is the duration of that phase
and indicates the units of the times.

This adds a "GC:" prefix to all lines for easier identification.

Finally, this generally cleans up the code as well as the placement of
spaces in the output and adds print locking so the statistics blocks
are never interrupted by other prints.

Change-Id: Ifd056db83ed1b888de7dfa9a8fc5732b01ccc631
Reviewed-on: https://go-review.googlesource.com/2542
Reviewed-by: Rick Hudson <rlh@golang.org>
9 years agomath/big: faster "pure Go" addition/subtraction for long vectors
Robert Griesemer [Wed, 7 Jan 2015 19:11:57 +0000 (11:11 -0800)]
math/big: faster "pure Go" addition/subtraction for long vectors
          (platforms w/o corresponding assembly kernels)

For short vector adds there's some erradic slow-down, but overall
these routines have become significantly faster. This only matters
for platforms w/o native (assembly) versions of these kernels, so
we are not concerned about the minor slow-down for short vectors.

This code was already reviewed under Mercurial (golang.org/cl/172810043)
but wasn't submitted before the switch to git.

Benchmarks run on 2.3GHz Intel Core i7, running OS X 10.9.5,
with the respective AddVV and AddVW assembly routines disabled.

benchmark              old ns/op     new ns/op     delta
BenchmarkAddVV_1       6.59          7.09          +7.59%
BenchmarkAddVV_2       10.3          10.1          -1.94%
BenchmarkAddVV_3       10.9          12.6          +15.60%
BenchmarkAddVV_4       13.9          15.6          +12.23%
BenchmarkAddVV_5       16.8          17.3          +2.98%
BenchmarkAddVV_1e1     29.5          29.9          +1.36%
BenchmarkAddVV_1e2     246           232           -5.69%
BenchmarkAddVV_1e3     2374          2185          -7.96%
BenchmarkAddVV_1e4     58942         22292         -62.18%
BenchmarkAddVV_1e5     668622        225279        -66.31%
BenchmarkAddVW_1       6.81          5.58          -18.06%
BenchmarkAddVW_2       7.69          6.86          -10.79%
BenchmarkAddVW_3       9.56          8.32          -12.97%
BenchmarkAddVW_4       12.1          9.53          -21.24%
BenchmarkAddVW_5       13.2          10.9          -17.42%
BenchmarkAddVW_1e1     23.4          18.0          -23.08%
BenchmarkAddVW_1e2     175           141           -19.43%
BenchmarkAddVW_1e3     1568          1266          -19.26%
BenchmarkAddVW_1e4     15425         12596         -18.34%
BenchmarkAddVW_1e5     156737        133539        -14.80%
BenchmarkFibo          381678466     132958666     -65.16%

benchmark              old MB/s     new MB/s     speedup
BenchmarkAddVV_1       9715.25      9028.30      0.93x
BenchmarkAddVV_2       12461.72     12622.60     1.01x
BenchmarkAddVV_3       17549.64     15243.82     0.87x
BenchmarkAddVV_4       18392.54     16398.29     0.89x
BenchmarkAddVV_5       18995.23     18496.57     0.97x
BenchmarkAddVV_1e1     21708.98     21438.28     0.99x
BenchmarkAddVV_1e2     25956.53     27506.88     1.06x
BenchmarkAddVV_1e3     26947.93     29286.66     1.09x
BenchmarkAddVV_1e4     10857.96     28709.46     2.64x
BenchmarkAddVV_1e5     9571.91      28409.21     2.97x
BenchmarkAddVW_1       1175.28      1433.98      1.22x
BenchmarkAddVW_2       2080.01      2332.54      1.12x
BenchmarkAddVW_3       2509.28      2883.97      1.15x
BenchmarkAddVW_4       2646.09      3356.83      1.27x
BenchmarkAddVW_5       3020.69      3671.07      1.22x
BenchmarkAddVW_1e1     3425.76      4441.40      1.30x
BenchmarkAddVW_1e2     4553.17      5642.96      1.24x
BenchmarkAddVW_1e3     5100.14      6318.72      1.24x
BenchmarkAddVW_1e4     5186.15      6350.96      1.22x
BenchmarkAddVW_1e5     5104.07      5990.74      1.17x

Change-Id: I7a62023b1105248a0e85e5b9819d3fd4266123d4
Reviewed-on: https://go-review.googlesource.com/2480
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
9 years agomath/big: faster assembly kernels for AddVx/SubVx for amd64.
Robert Griesemer [Thu, 8 Jan 2015 01:16:59 +0000 (17:16 -0800)]
math/big: faster assembly kernels for AddVx/SubVx for amd64.

Replaced use of rotate instructions (RCRQ, RCLQ) with ADDQ/SBBQ
for restoring/saving the carry flag per suggestion from Torbjörn
Granlund (author of GMP bignum libs for C).
The rotate instructions tend to be slower on todays machines.

benchmark              old ns/op     new ns/op     delta
BenchmarkAddVV_1       5.69          5.51          -3.16%
BenchmarkAddVV_2       7.15          6.87          -3.92%
BenchmarkAddVV_3       8.69          8.06          -7.25%
BenchmarkAddVV_4       8.10          8.13          +0.37%
BenchmarkAddVV_5       8.37          8.47          +1.19%
BenchmarkAddVV_1e1     13.1          12.0          -8.40%
BenchmarkAddVV_1e2     78.1          69.4          -11.14%
BenchmarkAddVV_1e3     815           656           -19.51%
BenchmarkAddVV_1e4     8137          7345          -9.73%
BenchmarkAddVV_1e5     100127        93909         -6.21%
BenchmarkAddVW_1       4.86          4.71          -3.09%
BenchmarkAddVW_2       5.67          5.50          -3.00%
BenchmarkAddVW_3       6.51          6.34          -2.61%
BenchmarkAddVW_4       6.69          6.66          -0.45%
BenchmarkAddVW_5       7.20          7.21          +0.14%
BenchmarkAddVW_1e1     10.0          9.34          -6.60%
BenchmarkAddVW_1e2     45.4          52.3          +15.20%
BenchmarkAddVW_1e3     417           491           +17.75%
BenchmarkAddVW_1e4     4760          4852          +1.93%
BenchmarkAddVW_1e5     69107         67717         -2.01%

benchmark              old MB/s      new MB/s      speedup
BenchmarkAddVV_1       11241.82      11610.28      1.03x
BenchmarkAddVV_2       17902.68      18631.82      1.04x
BenchmarkAddVV_3       22082.43      23835.64      1.08x
BenchmarkAddVV_4       31588.18      31492.06      1.00x
BenchmarkAddVV_5       38229.90      37783.17      0.99x
BenchmarkAddVV_1e1     48891.67      53340.91      1.09x
BenchmarkAddVV_1e2     81940.61      92191.86      1.13x
BenchmarkAddVV_1e3     78443.09      97480.44      1.24x
BenchmarkAddVV_1e4     78644.18      87129.50      1.11x
BenchmarkAddVV_1e5     63918.48      68150.84      1.07x
BenchmarkAddVW_1       13165.09      13581.00      1.03x
BenchmarkAddVW_2       22588.04      23275.41      1.03x
BenchmarkAddVW_3       29483.82      30303.96      1.03x
BenchmarkAddVW_4       38286.54      38453.21      1.00x
BenchmarkAddVW_5       44414.57      44370.59      1.00x
BenchmarkAddVW_1e1     63816.84      68494.08      1.07x
BenchmarkAddVW_1e2     140885.41     122427.16     0.87x
BenchmarkAddVW_1e3     153258.31     130325.28     0.85x
BenchmarkAddVW_1e4     134447.63     131904.02     0.98x
BenchmarkAddVW_1e5     92609.41      94509.88      1.02x

Change-Id: Ia473e9ab9c63a955c252426684176bca566645ae
Reviewed-on: https://go-review.googlesource.com/2503
Reviewed-by: Keith Randall <khr@golang.org>
9 years agostrconv: add atoi tests for uncommon bases and syntax errors
Martin Möhrmann [Thu, 8 Jan 2015 01:18:16 +0000 (02:18 +0100)]
strconv: add atoi tests for uncommon bases and syntax errors

Edge cases like base 2 and 36 conversions are now covered.
Many tests are mirrored from the itoa tests.

Added more test cases for syntax errors.

Change-Id: Iad8b2fb4854f898c2bfa18cdeb0cb4a758fcfc2e
Reviewed-on: https://go-review.googlesource.com/2463
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
9 years agosyscall: use go generate to build zsyscall_windows.go
Alex Brainman [Mon, 22 Dec 2014 05:54:07 +0000 (16:54 +1100)]
syscall: use go generate to build zsyscall_windows.go

I would like to create new syscalls in src/internal/syscall,
and I prefer not to add new shell scripts for that.

Replacement for CL 136000043.

Change-Id: I840116b5914a2324f516cdb8603c78973d28aeb4
Reviewed-on: https://go-review.googlesource.com/1940
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agotest: shorten test runtime
Keith Randall [Thu, 8 Jan 2015 00:46:29 +0000 (16:46 -0800)]
test: shorten test runtime

This test was taking a long time, reduce its zealousness.

Change-Id: Ib824247b84b0039a9ec690f72336bef3738d4c44
Reviewed-on: https://go-review.googlesource.com/2502
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Minux Ma <minux@golang.org>
9 years agobuild: add GOTESTONLY environment test for Plan 9's run.rc
Brad Fitzpatrick [Thu, 8 Jan 2015 04:10:32 +0000 (20:10 -0800)]
build: add GOTESTONLY environment test for Plan 9's run.rc

$GOTESTONLY controls which set of tests gets run. Only "std" is
supported. This should bring the time of plan9 builder down
from 90 minutes to a maybe 10-15 minutes when running on GCE.

(Plan 9 has performance problems when running on GCE, and/or with the
os/exec package)

This is a temporary workaround for one builder. The other Plan 9
builders will continue to do full builds. The plan9 buidler will be
renamed plan9-386-gcepartial or something to indicate it's not running
the 'test/*' directory, or API tests. Go on Plan 9 has bigger problems
for now. This lets us get trybots going sooner including Plan 9,
without waiting 90+ minutes.

Update #9491

Change-Id: Ic505e9169c6b304ed4029b7bdfb77bb5c8fa8daa
Reviewed-on: https://go-review.googlesource.com/2522
Reviewed-by: Rob Pike <r@golang.org>
9 years agobuild: increase Plan 9 timeout for runtime multi-CPU test, add temporary -v
Brad Fitzpatrick [Thu, 8 Jan 2015 01:05:51 +0000 (17:05 -0800)]
build: increase Plan 9 timeout for runtime multi-CPU test, add temporary -v

This isn't the final answer, but it will give us a clue about what's
going on.

Update #9491

Change-Id: I997f6004eb97e86a4a89a8caabaf58cfdf92a8f0
Reviewed-on: https://go-review.googlesource.com/2510
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agocmd/cgo, go/build: finish a cleanup TODO
Matthew Dempsky [Thu, 8 Jan 2015 00:30:24 +0000 (16:30 -0800)]
cmd/cgo, go/build: finish a cleanup TODO

Removing #cgo directive parsing from cmd/cgo was done in
https://golang.org/cl/8610044.

Change-Id: Id1bec58c6ec1f932df0ce0ee84ff253655bb73ff
Reviewed-on: https://go-review.googlesource.com/2501
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agomisc/swig/stdio: fix broken nil pointer test
Shenghou Ma [Wed, 7 Jan 2015 06:23:45 +0000 (01:23 -0500)]
misc/swig/stdio: fix broken nil pointer test

SWIG has always returned a typed interface value for a C++ class,
so the interface value will never be nil even if the pointer itself
is NULL. ptr == NULL in C/C++ should be ptr.Swigcptr() == 0 in Go.

Fixes #9514.

Change-Id: I3778b91acf54d2ff22d7427fbf2b6ec9b9ce3b43
Reviewed-on: https://go-review.googlesource.com/2440
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agobuild: increase timeout in run.rc
David du Colombier [Wed, 7 Jan 2015 22:32:34 +0000 (23:32 +0100)]
build: increase timeout in run.rc

Increasing the timeout prevents the runtime test
to time out on the Plan 9 instances running on GCE.

Update golang/go#9491

Change-Id: Id9c2b0c4e59b103608565168655799b353afcd77
Reviewed-on: https://go-review.googlesource.com/2462
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agocmd/cgo: remove obsolete -cdefs flag
Matthew Dempsky [Wed, 7 Jan 2015 21:23:45 +0000 (13:23 -0800)]
cmd/cgo: remove obsolete -cdefs flag

Now that there's no 6c compiler anymore, there's no need for cgo to
generate C headers that are compatible with it.

Fixes #9528

Change-Id: I43f53869719eb9a6065f1b39f66f060e604cbee0
Reviewed-on: https://go-review.googlesource.com/2482
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agoruntime: remove stray commas in assembly
Josh Bleecher Snyder [Wed, 7 Jan 2015 22:24:18 +0000 (14:24 -0800)]
runtime: remove stray commas in assembly

Change-Id: I4dc97ff8111bdc5ca6e4e3af06aaf4f768031c68
Reviewed-on: https://go-review.googlesource.com/2473
Reviewed-by: Minux Ma <minux@golang.org>
9 years agocmd/gc: optimize existence-only map lookups
Josh Bleecher Snyder [Mon, 22 Dec 2014 19:33:47 +0000 (11:33 -0800)]
cmd/gc: optimize existence-only map lookups

The compiler converts 'val, ok = m[key]' to

        tmp, ok = <runtime call>
        val = *tmp

For lookups of the form '_, ok = m[key]',
the second statement is unnecessary.
By not generating it we save a nil check.

Change-Id: I21346cc195cb3c62e041af8b18770c0940358695
Reviewed-on: https://go-review.googlesource.com/1975
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/6g, cmd/8g, liblink: improve handling of float constants
Josh Bleecher Snyder [Mon, 22 Dec 2014 23:12:28 +0000 (15:12 -0800)]
cmd/6g, cmd/8g, liblink: improve handling of float constants

* Enable basic constant propagation for floats.
  The constant propagation is still not as aggressive as it could be.
* Implement MOVSS $(0), Xx and MOVSD $(0), Xx as XORPS Xx, Xx.

Sample code:

func f32() float32 {
var f float32
return f
}

func f64() float64 {
var f float64
return f
}

Before:

"".f32 t=1 size=32 value=0 args=0x8 locals=0x0
0x0000 00000 (demo.go:3) TEXT "".f32+0(SB),4,$0-8
0x0000 00000 (demo.go:3) FUNCDATA $0,gclocals·a7a3692b8e27e823add69ec4239ba55f+0(SB)
0x0000 00000 (demo.go:3) FUNCDATA $1,gclocals·3280bececceccd33cb74587feedb1f9f+0(SB)
0x0000 00000 (demo.go:3) MOVSS $f32.00000000+0(SB),X0
0x0008 00008 (demo.go:4) MOVSS $f32.00000000+0(SB),X0
0x0010 00016 (demo.go:5) MOVSS X0,"".~r0+8(FP)
0x0016 00022 (demo.go:5) RET ,
"".f64 t=1 size=32 value=0 args=0x8 locals=0x0
0x0000 00000 (demo.go:8) TEXT "".f64+0(SB),4,$0-8
0x0000 00000 (demo.go:8) FUNCDATA $0,gclocals·a7a3692b8e27e823add69ec4239ba55f+0(SB)
0x0000 00000 (demo.go:8) FUNCDATA $1,gclocals·3280bececceccd33cb74587feedb1f9f+0(SB)
0x0000 00000 (demo.go:8) MOVSD $f64.0000000000000000+0(SB),X0
0x0008 00008 (demo.go:9) MOVSD $f64.0000000000000000+0(SB),X0
0x0010 00016 (demo.go:10) MOVSD X0,"".~r0+8(FP)
0x0016 00022 (demo.go:10) RET ,

After:

"".f32 t=1 size=16 value=0 args=0x8 locals=0x0
0x0000 00000 (demo.go:3) TEXT "".f32+0(SB),4,$0-8
0x0000 00000 (demo.go:3) FUNCDATA $0,gclocals·a7a3692b8e27e823add69ec4239ba55f+0(SB)
0x0000 00000 (demo.go:3) FUNCDATA $1,gclocals·3280bececceccd33cb74587feedb1f9f+0(SB)
0x0000 00000 (demo.go:3) XORPS X0,X0
0x0003 00003 (demo.go:5) MOVSS X0,"".~r0+8(FP)
0x0009 00009 (demo.go:5) RET ,
"".f64 t=1 size=16 value=0 args=0x8 locals=0x0
0x0000 00000 (demo.go:8) TEXT "".f64+0(SB),4,$0-8
0x0000 00000 (demo.go:8) FUNCDATA $0,gclocals·a7a3692b8e27e823add69ec4239ba55f+0(SB)
0x0000 00000 (demo.go:8) FUNCDATA $1,gclocals·3280bececceccd33cb74587feedb1f9f+0(SB)
0x0000 00000 (demo.go:8) XORPS X0,X0
0x0003 00003 (demo.go:10) MOVSD X0,"".~r0+8(FP)
0x0009 00009 (demo.go:10) RET ,

Change-Id: Ie9eb65e324af4f664153d0a7cd22bb16b0fba16d
Reviewed-on: https://go-review.googlesource.com/2053
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: remove size argument from hash and equal algorithms
Keith Randall [Wed, 7 Jan 2015 00:42:48 +0000 (16:42 -0800)]
runtime: remove size argument from hash and equal algorithms

The equal algorithm used to take the size
   equal(p, q *T, size uintptr) bool
With this change, it does not
   equal(p, q *T) bool
Similarly for the hash algorithm.

The size is rarely used, as most equal functions know the size
of the thing they are comparing.  For instance f32equal already
knows its inputs are 4 bytes in size.

For cases where the size is not known, we allocate a closure
(one for each size needed) that points to an assembly stub that
reads the size out of the closure and calls generic code that
has a size argument.

Reduces the size of the go binary by 0.07%.  Performance impact
is not measurable.

Change-Id: I6e00adf3dde7ad2974adbcff0ee91e86d2194fec
Reviewed-on: https://go-review.googlesource.com/2392
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agotest: delete testlib
Josh Bleecher Snyder [Tue, 23 Dec 2014 21:19:59 +0000 (13:19 -0800)]
test: delete testlib

It is unused as of e7173dfd.

Change-Id: I3e4ea3fc66cf0a768ff28172a151b244952eefc9
Reviewed-on: https://go-review.googlesource.com/2093
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agoruntime: faster version of findfunc
Keith Randall [Sun, 28 Dec 2014 03:26:40 +0000 (19:26 -0800)]
runtime: faster version of findfunc

Use a lookup table to find the function which contains a pc.  It is
faster than the old binary search.  findfunc is used primarily for
stack copying and garbage collection.

benchmark              old ns/op     new ns/op     delta
BenchmarkStackCopy     294746596     255400980     -13.35%

(findfunc is one of several tasks done by stack copy, the findfunc
time itself is about 2.5x faster.)

The lookup table is built at link time.  The table grows the binary
size by about 0.5% of the text segment.

We impose a lower limit of 16 bytes on any function, which should not
have much of an impact.  (The real constraint required is <=256
functions in every 4096 bytes, but 16 bytes/function is easier to
implement.)

Change-Id: Ic315b7a2c83e1f7203cd2a50e5d21a822e18fdca
Reviewed-on: https://go-review.googlesource.com/2097
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/cgo, runtime/cgo: support ppc64
Austin Clements [Tue, 16 Dec 2014 23:34:55 +0000 (18:34 -0500)]
cmd/cgo, runtime/cgo: support ppc64

This implements support for calls to and from C in the ppc64 C ABI, as
well as supporting functionality such as an entry point from the
dynamic linker.

Change-Id: I68da6df50d5638cb1a3d3fef773fb412d7bf631a
Reviewed-on: https://go-review.googlesource.com/2009
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: set up C TLS and save g to it on ppc64
Austin Clements [Tue, 16 Dec 2014 22:14:00 +0000 (17:14 -0500)]
runtime: set up C TLS and save g to it on ppc64

Cgo will need this for calls from C to Go and for handling signals
that may occur in C code.

Change-Id: I50cc4caf17cd142bff501e7180a1e27721463ada
Reviewed-on: https://go-review.googlesource.com/2008
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/9g: don't use R13
Austin Clements [Tue, 16 Dec 2014 18:52:09 +0000 (13:52 -0500)]
cmd/9g: don't use R13

R13 is the C TLS pointer.  Once we're calling to and from C code, if
we clobber R13 in our code, sigtramp won't know whether to get the
current g from REGG or from C TLS.  The simplest solution is for Go
code to preserve the C TLS pointer.  This is equivalent to what other
platforms do, except that on other platforms the TLS pointer is in a
special register.

Change-Id: I076e9cb83fd78843eb68cb07c748c4705c9a4c82
Reviewed-on: https://go-review.googlesource.com/2007
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/9l: support internal linking
Austin Clements [Tue, 16 Dec 2014 19:59:59 +0000 (14:59 -0500)]
cmd/9l: support internal linking

This implements the ELF relocations and dynamic linking tables
necessary to support internal linking on ppc64.  It also marks ppc64le
ELF files as ABI v2; failing to do this doesn't seem to confuse the
loader, but it does confuse libbfd (and hence gdb, objdump, etc).

Change-Id: I559dddf89b39052e1b6288a4dd5e72693b5355e4
Reviewed-on: https://go-review.googlesource.com/2006
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/ld: support for relocation variants
Austin Clements [Mon, 22 Dec 2014 19:42:37 +0000 (14:42 -0500)]
cmd/ld: support for relocation variants

Most ppc64 relocations come in six or more variants where the basic
relocation formula is the same, but which bits of the computed value
are installed where changes.  Introduce the concept of "variants" for
internal relocations to support this.  Since this applies to
architecture-independent relocation types like R_PCREL, we do this in
relocsym.

Currently there is only an identity variant.  A later CL that adds
support for ppc64 ELF relocations will introduce more.

Change-Id: I0c5f0e7dbe5beece79cd24fe36267d37c52f1a0c
Reviewed-on: https://go-review.googlesource.com/2005
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/ld: support 2 byte relocations
Austin Clements [Tue, 16 Dec 2014 19:12:01 +0000 (14:12 -0500)]
cmd/ld: support 2 byte relocations

ppc64 has a bunch of these.

Change-Id: I3b93ed2bae378322a8dec036b1681e520b56ff53
Reviewed-on: https://go-review.googlesource.com/2003
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
9 years agocmd/ld: decode local entry offset from ppc64 symbols
Austin Clements [Tue, 16 Dec 2014 19:01:08 +0000 (14:01 -0500)]
cmd/ld: decode local entry offset from ppc64 symbols

ppc64 function symbols have both a global entry point and a local
entry point, where the difference is stashed in sym.other.  We'll need
this information to generate calls to ELF ABI functions.

Change-Id: Ibe343923f56801de7ebec29946c79690a9ffde57
Reviewed-on: https://go-review.googlesource.com/2002
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
9 years agoruntime: add comment about channels already handling zero-sized objects correctly.
Keith Randall [Tue, 6 Jan 2015 16:41:55 +0000 (08:41 -0800)]
runtime: add comment about channels already handling zero-sized objects correctly.

update #9401

Change-Id: I634a772814e7cd066f631a68342e7c3dc9d27e72
Reviewed-on: https://go-review.googlesource.com/2370
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: increase number of stack orders to 4
Keith Randall [Sat, 27 Dec 2014 02:10:59 +0000 (18:10 -0800)]
runtime: increase number of stack orders to 4

Cache 2KB, 4KB, 8KB, and 16KB stacks.  Larger stacks
will be allocated directly.  There is no point in cacheing
32KB+ stacks as we ask for and return 32KB at a time
from the allocator.

Note that the minimum stack is 8K on windows/64bit and 4K on
windows/32bit and plan9.  For these os/arch combinations,
the number of stack orders is less so that we have the same
maximum cached size.

Fixes #9045

Change-Id: Ia4195dd1858fb79fc0e6a91ae29c374d28839e44
Reviewed-on: https://go-review.googlesource.com/2098
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agodoc/contribute: add necessary <code> tags, remove an extra close parenthesis.
Oling Cat [Sun, 14 Dec 2014 06:32:56 +0000 (14:32 +0800)]
doc/contribute: add necessary <code> tags, remove an extra close parenthesis.

Change-Id: I7238ae84d637534a345e5d077b8c63466148bd75
Reviewed-on: https://go-review.googlesource.com/1521
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: remove trailing empty arrays in structs
Keith Randall [Wed, 7 Jan 2015 04:38:44 +0000 (20:38 -0800)]
runtime: remove trailing empty arrays in structs

The ones at the end of M and G are just used to compute
their size for use in assembly.  Generate the size explicitly.
The one at the end of itab is variable-sized, and at least one.
The ones at the end of interfacetype and uncommontype are not
needed, as the preceding slice references them (the slice was
originally added for use by reflect?).
The one at the end of stackmap is already accessed correctly,
and the runtime never allocates one.

Update #9401

Change-Id: Ia75e3aaee38425f038c506868a17105bd64c712f
Reviewed-on: https://go-review.googlesource.com/2420
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: use some startup randomness in the fallback hashes
Keith Randall [Tue, 6 Jan 2015 17:06:44 +0000 (09:06 -0800)]
runtime: use some startup randomness in the fallback hashes

Fold in some startup randomness to make the hash vary across
different runs.  This helps prevent attackers from choosing
keys that all map to the same bucket.

Also, reorganize the hash a bit.  Move the *m1 multiply to after
the xor of the current hash and the message.  For hash quality
it doesn't really matter, but for DDOS resistance it helps a lot
(any processing done to the message before it is merged with the
random seed is useless, as it is easily inverted by an attacker).

Update #9365

Change-Id: Ib19968168e1bbc541d1d28be2701bb83e53f1e24
Reviewed-on: https://go-review.googlesource.com/2344
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/cgo: update code and docs to reflect post-6c world
Matthew Dempsky [Tue, 6 Jan 2015 23:08:02 +0000 (15:08 -0800)]
cmd/cgo: update code and docs to reflect post-6c world

The gc toolchain no longer includes a C compiler, so mentions of "6c"
can be removed or replaced by 6g as appropriate.  Similarly, some cgo
functions that previously generated C source output no longer need to.

Change-Id: I1ae6b02630cff9eaadeae6f3176c0c7824e8fbe5
Reviewed-on: https://go-review.googlesource.com/2391
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agodoc: add bufio.Reader.Discard to go1.5.txt
Brad Fitzpatrick [Wed, 7 Jan 2015 06:40:22 +0000 (22:40 -0800)]
doc: add bufio.Reader.Discard to go1.5.txt

Change-Id: I315b338968cb1d9298664d181de44a691b325bb8
Reviewed-on: https://go-review.googlesource.com/2450
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agobufio: add Reader.Discard
Brad Fitzpatrick [Fri, 2 Jan 2015 18:02:15 +0000 (10:02 -0800)]
bufio: add Reader.Discard

Reader.Discard is the complement to Peek. It discards the next n bytes
of input.

We already have Reader.Buffered to see how many bytes of data are
sitting available in memory, and Reader.Peek to get that that buffer
directly. But once you're done with the Peek'd data, you can't get rid
of it, other than Reading it.
Both Read and io.CopyN(ioutil.Discard, bufReader, N) are relatively
slow. People instead resort to multiple blind ReadByte calls, just to
advance the internal b.r variable.

I've wanted this previously, several people have asked for it in the
past on golang-nuts/dev, and somebody just asked me for it again in a
private email. There are a few places in the standard library we'd use
it too.

Change-Id: I85dfad47704a58bd42f6867adbc9e4e1792bc3b0
Reviewed-on: https://go-review.googlesource.com/2260
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: fix build for race detector
Shenghou Ma [Wed, 7 Jan 2015 01:40:16 +0000 (20:40 -0500)]
runtime: fix build for race detector

This CL only fixes the build, there are two failing tests:
RaceMapBigValAccess1 and RaceMapBigValAccess2
in runtime/race tests. I haven't investigated why yet.

Updates #9516.

Change-Id: If5bd2f0bee1ee45b1977990ab71e2917aada505f
Reviewed-on: https://go-review.googlesource.com/2401
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agosort: optimize symMerge performance for blocks with one element
Martin Möhrmann [Thu, 1 Jan 2015 23:18:10 +0000 (00:18 +0100)]
sort: optimize symMerge performance for blocks with one element

Use direct binary insertion instead of recursive calls to symMerge
when one of the blocks has only one element.

benchmark                   old ns/op      new ns/op      delta
BenchmarkStableString1K     421999         397629         -5.77%
BenchmarkStableInt1K        123422         120592         -2.29%
BenchmarkStableInt64K       9629094        9620200        -0.09%
BenchmarkStable1e2          123089         120209         -2.34%
BenchmarkStable1e4          39505228       36870029       -6.67%
BenchmarkStable1e6          8196612367     7630840157     -6.90%

Change-Id: I49905a909e8595cfa05920ccf9aa00a8f3036110
Reviewed-on: https://go-review.googlesource.com/2219
Reviewed-by: Robert Griesemer <gri@golang.org>
9 years agoruntime: allocate wbshadow at high address
Russ Cox [Wed, 31 Dec 2014 03:39:48 +0000 (22:39 -0500)]
runtime: allocate wbshadow at high address

sysReserve doesn't actually reserve the full amount requested on
64-bit systems, because of problems with ulimit. Instead it checks
that it can get the first 64 kB and assumes it can grab the rest as
needed. This doesn't work well with the "let the kernel pick an address"
mode, so don't do that. Pick a high address instead.

Change-Id: I4de143a0e6fdeb467fa6ecf63dcd0c1c1618a31c
Reviewed-on: https://go-review.googlesource.com/2345
Reviewed-by: Rick Hudson <rlh@golang.org>
9 years agoruntime: adjust dropm for write barriers
Russ Cox [Tue, 6 Jan 2015 18:56:21 +0000 (13:56 -0500)]
runtime: adjust dropm for write barriers

The line 'mp.schedlink = mnext' has an implicit write barrier call,
which needs a valid g. Move it above the setg(nil).

Change-Id: If3e86c948e856e10032ad89f038bf569659300e0
Reviewed-on: https://go-review.googlesource.com/2347
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
9 years agomisc/cgo: disable TestAllocateFromC in wbshadow mode
Russ Cox [Tue, 6 Jan 2015 18:46:13 +0000 (13:46 -0500)]
misc/cgo: disable TestAllocateFromC in wbshadow mode

This test is doing pointer graph manipulation from C, and we
cannot support that with concurrent GC. The wbshadow mode
correctly diagnoses missing write barriers.

Disable the test in that mode for now. There is a bigger issue
behind it, namely SWIG, but for now we are focused on making
all.bash pass with wbshadow enabled.

Change-Id: I55891596d4c763e39b74082191d4a5fac7161642
Reviewed-on: https://go-review.googlesource.com/2346
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
9 years agocmd/go: buffer output for go usage
Brad Fitzpatrick [Tue, 6 Jan 2015 17:15:13 +0000 (09:15 -0800)]
cmd/go: buffer output for go usage

It did tons of write syscalls before:
    https://www.youtube.com/watch?v=t60fhjAqBdw

This is the worst offender. It's not worth fixing all the cases of two
consecutive prints.

Change-Id: I95860ef6a844d89b149528195182b191aad8731b
Reviewed-on: https://go-review.googlesource.com/2371
Reviewed-by: Rob Pike <r@golang.org>
9 years agocrypto/tls: fix renegotiation extension.
Adam Langley [Fri, 19 Dec 2014 23:14:03 +0000 (15:14 -0800)]
crypto/tls: fix renegotiation extension.

There are two methods by which TLS clients signal the renegotiation
extension: either a special cipher suite value or a TLS extension.

It appears that I left debugging code in when I landed support for the
extension because there's a "+ 1" in the switch statement that shouldn't
be there.

The effect of this is very small, but it will break Firefox if
security.ssl.require_safe_negotiation is enabled in about:config.
(Although almost nobody does this.)

This change fixes the original bug and adds a test. Sadly the test is a
little complex because there's no OpenSSL s_client option that mirrors
that behaviour of require_safe_negotiation.

Change-Id: Ia6925c7d9bbc0713e7104228a57d2d61d537c07a
Reviewed-on: https://go-review.googlesource.com/1900
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agocrypto/rsa: rsa.SignPSS with opts=nil shouldn't crash.
Adam Langley [Mon, 5 Jan 2015 22:29:42 +0000 (14:29 -0800)]
crypto/rsa: rsa.SignPSS with opts=nil shouldn't crash.

SignPSS is documented as allowing opts to be nil, but actually
crashes in that case. This change fixes that.

Change-Id: Ic48ff5f698c010a336e2bf720e0f44be1aecafa0
Reviewed-on: https://go-review.googlesource.com/2330
Reviewed-by: Minux Ma <minux@golang.org>
9 years agoruntime: fix two garbage collector bugs
Russ Cox [Mon, 5 Jan 2015 20:02:09 +0000 (15:02 -0500)]
runtime: fix two garbage collector bugs

First, call clearcheckmarks immediately after changing checkmark,
so that there is less time when the checkmark flag and the bitmap
are inconsistent. The tiny gap between the two lines is fine, because
the world is stopped. Before, the gap was much larger and included
such code as "go bgsweep()", which allocated.

Second, modify gcphase only when the world is stopped.
As written, gcscan_m was changing gcphase from 0 to GCscan
and back to 0 while other goroutines were running.
Another goroutine running at the same time might decide to
sleep, see GCscan, call gcphasework, and start "helping" by
scanning its stack. That's fine, except that if gcphase flips back
to 0 as the goroutine calls scanblock, it will start draining the
work buffers prematurely.

Both of these were found wbshadow=2 (and a lot of hard work).
Eventually that will run automatically, but right now it still
doesn't quite work for all.bash, due to mmap conflicts with
pthread-created threads.

Change-Id: I99aa8210cff9c6e7d0a1b62c75be32a23321897b
Reviewed-on: https://go-review.googlesource.com/2340
Reviewed-by: Rick Hudson <rlh@golang.org>
9 years agocmd/gc: add write barrier for append(slice, slice...)
Russ Cox [Mon, 29 Dec 2014 21:26:25 +0000 (16:26 -0500)]
cmd/gc: add write barrier for append(slice, slice...)

Found with GODEBUG=wbshadow=2 mode.
Eventually that will run automatically, but right now
it still detects other missing write barriers.

Change-Id: I5624b509a36650bce6834cf394b9da163abbf8c0
Reviewed-on: https://go-review.googlesource.com/2310
Reviewed-by: Rick Hudson <rlh@golang.org>
9 years agoruntime: do not display Windows Error Reporting dialogue
Alex Brainman [Wed, 31 Dec 2014 02:46:58 +0000 (13:46 +1100)]
runtime: do not display Windows Error Reporting dialogue

Fixes #9121

Change-Id: Id6ca9f259260310c4c6cbdabbc8f2fead8414e6a
Reviewed-on: https://go-review.googlesource.com/2202
Reviewed-by: Minux Ma <minux@golang.org>
9 years agoruntime: fix build for ARM
Shenghou Ma [Tue, 6 Jan 2015 01:16:10 +0000 (20:16 -0500)]
runtime: fix build for ARM

Change-Id: Ia18b8411bebc47ea71ac1acd9ff9dc570ec15dea
Reviewed-on: https://go-review.googlesource.com/2341
Reviewed-by: Dave Cheney <dave@cheney.net>
9 years agoreflect: add write barriers
Russ Cox [Tue, 30 Dec 2014 18:59:55 +0000 (13:59 -0500)]
reflect: add write barriers

Use typedmemmove, typedslicecopy, and adjust reflect.call
to execute the necessary write barriers.

Found with GODEBUG=wbshadow=2 mode.
Eventually that will run automatically, but right now
it still detects other missing write barriers.

Change-Id: Iec5b5b0c1be5589295e28e5228e37f1a92e07742
Reviewed-on: https://go-review.googlesource.com/2312
Reviewed-by: Keith Randall <khr@golang.org>
9 years agosync/atomic: remove atomic pointer hammer tests
Russ Cox [Tue, 30 Dec 2014 18:06:52 +0000 (13:06 -0500)]
sync/atomic: remove atomic pointer hammer tests

These depend on storing arbitrary integer values using
pointer atomics, and we can't support that anymore.

Change-Id: I8cadd6d462c3eebdbe7078f43fe7c779fa8f52b3
Reviewed-on: https://go-review.googlesource.com/2311
Reviewed-by: Rick Hudson <rlh@golang.org>
9 years agocmd/gc, runtime: make assertI2T and variants not variadic
Russ Cox [Mon, 29 Dec 2014 21:15:05 +0000 (16:15 -0500)]
cmd/gc, runtime: make assertI2T and variants not variadic

A side effect of this change is that when assertI2T writes to the
memory for the T being extracted, it can use typedmemmove
for write barriers.

There are other ways we could have done this, but this one
finishes a TODO in package runtime.

Found with GODEBUG=wbshadow=2 mode.
Eventually that will run automatically, but right now
it still detects other missing write barriers.

Change-Id: Icbc8aabfd8a9b1f00be2e421af0e3b29fa54d01e
Reviewed-on: https://go-review.googlesource.com/2279
Reviewed-by: Keith Randall <khr@golang.org>
9 years agocmd/gc: add write barrier in copy of function parameters to heap
Russ Cox [Mon, 29 Dec 2014 16:47:04 +0000 (11:47 -0500)]
cmd/gc: add write barrier in copy of function parameters to heap

Found with GODEBUG=wbshadow=2 mode.
Eventually that will run automatically, but right now
it still detects other missing write barriers.

Change-Id: I1320d5340a9e421c779f24f3b170e33974e56e4f
Reviewed-on: https://go-review.googlesource.com/2278
Reviewed-by: Rick Hudson <rlh@golang.org>
9 years agoruntime: use typed memmove (write barriers) for chan, map, interface content
Russ Cox [Mon, 29 Dec 2014 15:07:47 +0000 (10:07 -0500)]
runtime: use typed memmove (write barriers) for chan, map, interface content

Found with GODEBUG=wbshadow=2 mode.
Eventually that will run automatically, but right now
it still detects other missing write barriers.

Change-Id: Iea83d693480c2f3008b4e80d55821acff65970a6
Reviewed-on: https://go-review.googlesource.com/2277
Reviewed-by: Keith Randall <khr@golang.org>
9 years agocmd/gc, runtime: rename writebarrierfat to typedmemmove
Russ Cox [Mon, 29 Dec 2014 15:05:57 +0000 (10:05 -0500)]
cmd/gc, runtime: rename writebarrierfat to typedmemmove

Preparation for replacing many memmove calls in runtime
with typedmemmove, which is a clearer description of what
the routine is doing.

For the same reason, rename writebarriercopy to typedslicecopy.

Change-Id: I6f23bef2c2215509fefba175b16908f76dc7538c
Reviewed-on: https://go-review.googlesource.com/2276
Reviewed-by: Rick Hudson <rlh@golang.org>
9 years agoruntime, sync/atomic: add write barrier for atomic write of pointer
Russ Cox [Tue, 23 Dec 2014 03:50:42 +0000 (22:50 -0500)]
runtime, sync/atomic: add write barrier for atomic write of pointer

Add write barrier to atomic operations manipulating pointers.

In general an atomic write of a pointer word may indicate racy accesses,
so there is no strictly safe way to attempt to keep the shadow copy
in sync with the real one. Instead, mark the shadow copy as not used.

Redirect sync/atomic pointer routines back to the runtime ones,
so that there is only one copy of the write barrier and shadow logic.
In time we might consider doing this for most of the sync/atomic
functions, but for now only the pointer routines need that treatment.

Found with GODEBUG=wbshadow=1 mode.
Eventually that will run automatically, but right now
it still detects other missing write barriers.

Change-Id: I852936b9a111a6cb9079cfaf6bd78b43016c0242
Reviewed-on: https://go-review.googlesource.com/2066
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
9 years agoruntime: change Gobuf.g to uintptr, not pointer
Russ Cox [Tue, 23 Dec 2014 03:43:49 +0000 (22:43 -0500)]
runtime: change Gobuf.g to uintptr, not pointer

The Gobuf.g goroutine pointer is almost always updated by assembly code.
In one of the few places it is updated by Go code - func save - it must be
treated as a uintptr to avoid a write barrier being emitted at a bad time.
Instead of figuring out how to emit the write barriers missing in the
assembly manipulation, change the type of the field to uintptr, so that
it does not require write barriers at all.

Goroutine structs are published in the allg list and never freed.
That will keep the goroutine structs from being collected.
There is never a time that Gobuf.g's contain the only references
to a goroutine: the publishing of the goroutine in allg comes first.

Goroutine pointers are also kept in non-GC-visible places like TLS,
so I can't see them ever moving. If we did want to start moving data
in the GC, we'd need to allocate the goroutine structs from an
alternate arena. This CL doesn't make that problem any worse.

Found with GODEBUG=wbshadow=1 mode.
Eventually that will run automatically, but right now
it still detects other missing write barriers.

Change-Id: I85f91312ec3e0ef69ead0fff1a560b0cfb095e1a
Reviewed-on: https://go-review.googlesource.com/2065
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
9 years agoruntime: add missing write barriers in append's copy of slice data
Russ Cox [Tue, 23 Dec 2014 03:42:05 +0000 (22:42 -0500)]
runtime: add missing write barriers in append's copy of slice data

Found with GODEBUG=wbshadow=1 mode.
Eventually that will run automatically, but right now
it still detects other missing write barriers.

Change-Id: Ic8624401d7c8225a935f719f96f2675c6f5c0d7c
Reviewed-on: https://go-review.googlesource.com/2064
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
9 years agoruntime: add GODEBUG wbshadow for finding missing write barriers
Russ Cox [Mon, 22 Dec 2014 15:53:51 +0000 (10:53 -0500)]
runtime: add GODEBUG wbshadow for finding missing write barriers

This is the detection code. It works well enough that I know of
a handful of missing write barriers. However, those are subtle
enough that I'll address them in separate followup CLs.

GODEBUG=wbshadow=1 checks for a write that bypassed the
write barrier at the next write barrier of the same word.
If a bug can be detected in this mode it is typically easy to
understand, since the crash says quite clearly what kind of
word has missed a write barrier.

GODEBUG=wbshadow=2 adds a check of the write barrier
shadow copy during garbage collection. Bugs detected at
garbage collection can be difficult to understand, because
there is no context for what the found word means.
Typically you have to reproduce the problem with allocfreetrace=1
in order to understand the type of the badly updated word.

Change-Id: If863837308e7c50d96b5bdc7d65af4969bf53a6e
Reviewed-on: https://go-review.googlesource.com/2061
Reviewed-by: Austin Clements <austin@google.com>
9 years agogo/doc: propagate types from unexported constants
Josh Bleecher Snyder [Tue, 23 Dec 2014 20:10:36 +0000 (12:10 -0800)]
go/doc: propagate types from unexported constants

When constants were declared using unexported constants,
the type information was lost when those constants were filtered out.
This CL propagates the type information of unexported constants
so that it is available for display.

This is a follow-up to CL 144110044, which fixed this problem
specifically for _ constants.

Updates #5397.

Change-Id: I3f0c767a4007d88169a5634ab2870deea4e6a740
Reviewed-on: https://go-review.googlesource.com/2091
Reviewed-by: Robert Griesemer <gri@golang.org>
9 years agomath/big: panic if n <= 0 for ProbablyPrime
Shenghou Ma [Mon, 5 Jan 2015 21:39:34 +0000 (16:39 -0500)]
math/big: panic if n <= 0 for ProbablyPrime

Fixes #9509

Change-Id: I3b86745d38e09093fe2f4b918d774bd6608727d7
Reviewed-on: https://go-review.googlesource.com/2313
Reviewed-by: Robert Griesemer <gri@golang.org>
9 years agoruntime: only check whether the runtime is stale once during tests
Brad Fitzpatrick [Mon, 5 Jan 2015 21:14:08 +0000 (13:14 -0800)]
runtime: only check whether the runtime is stale once during tests

Noticed while investigating the speed of the runtime tests, as part
of debugging while Plan 9's runtime tests are timing out on GCE.

Change-Id: I95f5a3d967a0b45ec1ebf10067e193f51db84e26
Reviewed-on: https://go-review.googlesource.com/2283
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agodoc: Added link to 'go help gopath'
Christopher Guiney [Sat, 3 Jan 2015 18:46:45 +0000 (10:46 -0800)]
doc: Added link to 'go help gopath'

The existing go code document did not link to the GOPATH documentation.
This will link to it, in hopes of making it more discoverable.

Change-Id: Ie4ded2fdce08f412e4acbcc93acdd76f5791b84a
Reviewed-on: https://go-review.googlesource.com/2265
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agomath: be consistent in how we document special cases
Fazlul Shahriar [Fri, 2 Jan 2015 03:16:38 +0000 (22:16 -0500)]
math: be consistent in how we document special cases

Change-Id: Ic6bc4af7bcc89b2881b2b9e7290aeb6fd54804e2
Reviewed-on: https://go-review.googlesource.com/2239
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agoRevert "liblink, cmd/ld, runtime: remove stackguard1"
Russ Cox [Mon, 5 Jan 2015 16:29:21 +0000 (16:29 +0000)]
Revert "liblink, cmd/ld, runtime: remove stackguard1"

This reverts commit ab0535ae3fb45ba734d47542cc4845f27f708d1b.

I think it will remain useful to distinguish code that must
run on a system stack from code that can run on either stack,
even if that distinction is no
longer based on the implementation language.

That is, I expect to add a //go:systemstack comment that,
in terms of the old implementation, tells the compiler,
to pretend this function was written in C.

Change-Id: I33d2ebb2f99ae12496484c6ec8ed07233d693275
Reviewed-on: https://go-review.googlesource.com/2275
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoreflect: document that Values can't be compared directly
Shenghou Ma [Mon, 5 Jan 2015 05:20:45 +0000 (00:20 -0500)]
reflect: document that Values can't be compared directly

Fixes #9504.

Change-Id: I148f407ace3d1b4db3f19fbb8561d1ee6c4c13b3
Reviewed-on: https://go-review.googlesource.com/2273
Reviewed-by: Rob Pike <r@golang.org>
9 years agocrypto/x509: add missing copyright
Mikio Hara [Mon, 5 Jan 2015 06:29:10 +0000 (15:29 +0900)]
crypto/x509: add missing copyright

Change-Id: Ida3b431a06527f6cd604ab4af5ce517959c8619b
Reviewed-on: https://go-review.googlesource.com/2306
Reviewed-by: Dave Cheney <dave@cheney.net>
9 years agocrypto/x509: fix nacl build
Mikio Hara [Mon, 5 Jan 2015 06:27:20 +0000 (15:27 +0900)]
crypto/x509: fix nacl build

Change-Id: Ie47c6460c1749aef3cf6d7c6ba44d43305d7ca7b
Reviewed-on: https://go-review.googlesource.com/2305
Reviewed-by: Minux Ma <minux@golang.org>
9 years agocrypto/x509: split certFiles definition by GOOS
Dave Cheney [Mon, 5 Jan 2015 02:14:04 +0000 (13:14 +1100)]
crypto/x509: split certFiles definition by GOOS

This CL splits the (ever growing) list of ca cert locations by major unix
platforms (darwin, windows and plan9 are already handled seperately).
Although it is clear the unix variants cannot manage to agree on some standard
locations, we can avoid to some extent an artificial ranking of priority
amongst the supported GOOSs.

* Split certFiles definition by GOOS
* Include NetBSD ca cert location

Fixes #9285

Change-Id: I6df2a3fddf3866e71033e01fce43c31e51b48a9e
Reviewed-on: https://go-review.googlesource.com/2208
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agoimage: use three-index slice for NewYCbCr.
Nigel Tao [Mon, 5 Jan 2015 02:50:09 +0000 (13:50 +1100)]
image: use three-index slice for NewYCbCr.

This ensures that changing an image.YCbCr's Y values can't change its
chroma values, even after re-slicing up to capacity.

Change-Id: Icb626561522e336a3220e10f456c95330ae7db9e
Reviewed-on: https://go-review.googlesource.com/2209
Reviewed-by: Rob Pike <r@golang.org>
9 years agolog: update doc comment
Andrew Gerrand [Tue, 30 Dec 2014 01:37:54 +0000 (12:37 +1100)]
log: update doc comment

Fixes #9448.

Change-Id: I8e1d676688d9e9b2fa3519ebc530905f574a1b3e
Reviewed-on: https://go-review.googlesource.com/2088
Reviewed-by: Rob Pike <r@golang.org>
9 years agofmt: fix two typos
Shenghou Ma [Sun, 4 Jan 2015 22:58:13 +0000 (17:58 -0500)]
fmt: fix two typos

Change-Id: I7b65cf3b67bef8950115066d6d12b25cd0a5edfc
Reviewed-on: https://go-review.googlesource.com/2272
Reviewed-by: Rob Pike <r@golang.org>
9 years agocmd/go: be more careful when linking a test exe with gccgo
Michael Hudson-Doyle [Thu, 18 Dec 2014 09:27:26 +0000 (22:27 +1300)]
cmd/go: be more careful when linking a test exe with gccgo

Previously, we ended up passing two compiled objects for the package
being tested when linking the test executable.  Somewhat by luck, this
worked most of the time but occasionally it did not.  This changes the
linking code to not pass two objects for the same ImportPath and to
always pass the object for the test version of the package and removes
some unecessary nil checks.

Change-Id: I7bbd3fc708f14672ee2cc6aed3397421fceb8a38
Reviewed-on: https://go-review.googlesource.com/1840
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agoliblink: fix encoding of SETcc for amd64
Shenghou Ma [Fri, 2 Jan 2015 21:30:08 +0000 (16:30 -0500)]
liblink: fix encoding of SETcc for amd64

liblink used to encode both SETEQ BP and SETEQ CH as 0f 94 c5,
however, SETEQ BP should have used a REX prefix.

Fixes #8545.

Change-Id: Ie59c990cdd0ec506cffe4318e9ad1b48db5e57dd
Reviewed-on: https://go-review.googlesource.com/2270
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
9 years agoreflect: set dir when creating a channel via ChanOf
Michael Fraenkel [Fri, 2 Jan 2015 02:38:12 +0000 (21:38 -0500)]
reflect: set dir when creating a channel via ChanOf

Fixes #9135

Change-Id: I4d0e4eb52a3d64262f107eb7eae4096a6e47ac08
Reviewed-on: https://go-review.googlesource.com/2238
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agoruntime: remove unnecessary GOOS switch
Ian Lance Taylor [Sun, 4 Jan 2015 19:36:54 +0000 (11:36 -0800)]
runtime: remove unnecessary GOOS switch

Change-Id: I8f518e273c02110042b08f7c50c3d38a648c8b6e
Reviewed-on: https://go-review.googlesource.com/2281
Reviewed-by: Minux Ma <minux@golang.org>
9 years agonet: add test cases for parsing ipv4-mapped ipv6 address
Mikio Hara [Wed, 31 Dec 2014 07:46:19 +0000 (16:46 +0900)]
net: add test cases for parsing ipv4-mapped ipv6 address

This CL adds missing ipv4-mapped ipv6 address test cases to TestParseIP.

Change-Id: I3144d2a88d409bd515cf52f8711d407bfa81ed68
Reviewed-on: https://go-review.googlesource.com/2205
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agoruntime: fix slicecopy return value for zero-width elements
Matthew Dempsky [Tue, 30 Dec 2014 20:31:17 +0000 (12:31 -0800)]
runtime: fix slicecopy return value for zero-width elements

Fixes #8620

Change-Id: Idb49e586919d21d07e94a39ed9ebb0562f403460
Reviewed-on: https://go-review.googlesource.com/2221
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agoruntime: fix TestCgoExternalThreadSIGPROF again
Shenghou Ma [Sat, 3 Jan 2015 05:12:34 +0000 (00:12 -0500)]
runtime: fix TestCgoExternalThreadSIGPROF again

Shell out to `uname -r` this time, so that the test will compile
even if the platform doesn't have syscall.Sysctl.

Change-Id: I3a19ab5d820bdb94586a97f4507b3837d7040525
Reviewed-on: https://go-review.googlesource.com/2271
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agoruntime: skip TestCgoExternalThreadSIGPROF on OS X 10.6
Shenghou Ma [Thu, 1 Jan 2015 06:10:39 +0000 (01:10 -0500)]
runtime: skip TestCgoExternalThreadSIGPROF on OS X 10.6

The test program requires static constructor, which in turn needs
external linking to work, but external linking never works on 10.6.

This should fix the darwin-{386,amd64} builders.

Change-Id: I714fdd3e35f9a7e5f5659cf26367feec9412444f
Reviewed-on: https://go-review.googlesource.com/2235
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agodoc: add a section for performance improvements in go1.5.txt
Brad Fitzpatrick [Fri, 2 Jan 2015 22:35:55 +0000 (14:35 -0800)]
doc: add a section for performance improvements in go1.5.txt

Mostly I need to tickle the builders, since I'm working on the
dashboard builders right now.

Change-Id: I833fc22bc942758a58791ed038634cdd812f5411
Reviewed-on: https://go-review.googlesource.com/2261
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agoruntime: use SETEQ instead of JZ for cas
Josh Bleecher Snyder [Thu, 1 Jan 2015 01:31:32 +0000 (17:31 -0800)]
runtime: use SETEQ instead of JZ for cas

Change-Id: Ibabbca3988d39bdce584924173a912d45f50f0dd
Reviewed-on: https://go-review.googlesource.com/2243
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Minux Ma <minux@golang.org>
9 years agocmd/go: put user ldflags at the end of the linker invocation
Josh Bleecher Snyder [Wed, 31 Dec 2014 21:25:52 +0000 (13:25 -0800)]
cmd/go: put user ldflags at the end of the linker invocation

If the user provided a key but no value via -ldflag -X,
another linker flag was used as the value.

Placing the user's flags at the end avoids this problem.
It also provides the user the opportunity to
override existing linker flags.

Fixes #8810.

Change-Id: I96f4190713dc9a9c29142e56658446fba7fb6bc8
Reviewed-on: https://go-review.googlesource.com/2242
Reviewed-by: Minux Ma <minux@golang.org>
9 years agoos: replace itod on posix with general itoa and fix possible infinite recursion
Martin Möhrmann [Wed, 31 Dec 2014 20:18:59 +0000 (21:18 +0100)]
os: replace itod on posix with general itoa and fix possible infinite recursion

Remove use of itod on posix systems and replace with call to itoa.
Build and use same itoa function on all systems.
Fix infinite recursion in iota function for the case -1<<63.

Change-Id: I89d7e742383c5c4aeef8780501c78a3e1af87a6f
Reviewed-on: https://go-review.googlesource.com/2213
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agocmd/gc: update issue tracker link
Alberto Donizetti [Thu, 1 Jan 2015 21:40:11 +0000 (22:40 +0100)]
cmd/gc: update issue tracker link

Updated the issue tracker link the compiler prints out
when asking for a bug report after an internal error.

Change-Id: I092b118130f131c6344d9d058bea4ad6379032b8
Reviewed-on: https://go-review.googlesource.com/2218
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agoinclude: remove unnecessary stuff on windows
Shenghou Ma [Thu, 1 Jan 2015 07:23:55 +0000 (02:23 -0500)]
include: remove unnecessary stuff on windows

Our definition of struct timespec used to cause problems with
certain versions of mingw-rt. However, as it turns out, we don't
actually need those definitions and prototypes, so remove them.

Fixes #9472.

Change-Id: Ie0880f0d58be112625140f73d0bed71f98b7cf05
Reviewed-on: https://go-review.googlesource.com/2236
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
9 years agocmd/gc: give an error if only one argument is given to complex()
Shenghou Ma [Mon, 29 Dec 2014 00:18:54 +0000 (19:18 -0500)]
cmd/gc: give an error if only one argument is given to complex()

Fixes #8501

Change-Id: I0dbbdded7f7924351c3d1841d60cb5c934b295b7
Reviewed-on: https://go-review.googlesource.com/2143
Reviewed-by: Chris Manghane <cmang@golang.org>
9 years agoruntime: remove unused export_test declarations
David Crawshaw [Wed, 31 Dec 2014 19:08:54 +0000 (11:08 -0800)]
runtime: remove unused export_test declarations

Change-Id: Iac28c4bbe949af5628cef8ecafdd59ab5d71e6cc
Reviewed-on: https://go-review.googlesource.com/2240
Reviewed-by: Keith Randall <khr@golang.org>
9 years agonet: don't return io.EOF on reading data from datagram, raw sockets on windows
Mikio Hara [Wed, 31 Dec 2014 01:08:51 +0000 (10:08 +0900)]
net: don't return io.EOF on reading data from datagram, raw sockets on windows

Preventing returning io.EOF on non-connection oriented sockets is
already applied to Unix variants. This CL applies it to Windows.

Update #4856.

Change-Id: I82071d40f617e2962d0540b9d1d6a10ea4cdb2ec
Reviewed-on: https://go-review.googlesource.com/2203
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
9 years agonet: remove redundant test case for lookupIP with threadLimit
Mikio Hara [Wed, 31 Dec 2014 06:45:46 +0000 (15:45 +0900)]
net: remove redundant test case for lookupIP with threadLimit

There is no reason to have the redundant test case TestDNSThreadLimt
because TestLookupIPDeadline does cover what we need to test with
-dnsflood flag and more.

Also this CL moves TestLookupIPDeadline into lookup_test.go to avoid
abusing to control the order of test case execution by using file name.

Change-Id: Ib417d7d3411c59d9352c03c996704d584368dc62
Reviewed-on: https://go-review.googlesource.com/2204
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agoruntime: provide a dummy value of _SIGPROF on plan9 and windows
Shenghou Ma [Thu, 1 Jan 2015 01:55:47 +0000 (20:55 -0500)]
runtime: provide a dummy value of _SIGPROF on plan9 and windows

Fixes build on plan9 and windows.

Change-Id: Ic9b02c641ab84e4f6d8149de71b9eb495e3343b2
Reviewed-on: https://go-review.googlesource.com/2233
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
9 years agoruntime/cgo: remove unused variable
Shenghou Ma [Thu, 1 Jan 2015 02:58:02 +0000 (21:58 -0500)]
runtime/cgo: remove unused variable

I missed this one in golang.org/cl/2232 and only tested the patch
on openbsd/amd64.

Change-Id: I4ff437ae0bfc61c989896c01904b6d33f9bdf0ec
Reviewed-on: https://go-review.googlesource.com/2234
Reviewed-by: Minux Ma <minux@golang.org>
9 years agoruntime/cgo: initialize our pthread_create wrapper earlier on openbsd
Shenghou Ma [Thu, 1 Jan 2015 01:30:57 +0000 (20:30 -0500)]
runtime/cgo: initialize our pthread_create wrapper earlier on openbsd

This is a genuine bug exposed by our test for issue 9456: our wrapper
for pthread_create is not initialized until we initialize cgo itself,
but it is possible that a static constructor could call pthread_create,
and in that case, it will be calling a nil function pointer.

Fix that by also initializing the sys_pthread_create function pointer
inside our pthread_create wrapper function, and use a pthread_once to
make sure it is only initialized once.

Fix build for openbsd.

Change-Id: Ica4da2c21fcaec186fdd3379128ef46f0e767ed7
Reviewed-on: https://go-review.googlesource.com/2232
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years agocmd/gc: fix filename output format verb for -s
Shenghou Ma [Wed, 31 Dec 2014 00:48:26 +0000 (19:48 -0500)]
cmd/gc: fix filename output format verb for -s

%lL will prepend the current directory to the filename, which is not
what we want here (as the file name is already absolute).

Fixes #9150.

Change-Id: I4c9386be6baf421393b92d9401a264b4692986d0
Reviewed-on: https://go-review.googlesource.com/2231
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agoruntime: ignore SIGPROF to foreign threads before cgocallback is fully initialized
Shenghou Ma [Sun, 28 Dec 2014 00:15:38 +0000 (19:15 -0500)]
runtime: ignore SIGPROF to foreign threads before cgocallback is fully initialized

Some libraries, for example, OpenBLAS, create work threads in a global constructor.
If we're doing cpu profiling, it's possible that SIGPROF might come to some of the
worker threads before we make our first cgo call. Cgocallback used to terminate the
process when that happens, but it's better to miss a couple profiling signals than
to abort in this case.

Fixes #9456.

Change-Id: I112b8e1a6e10e6cc8ac695a4b518c0f577309b6b
Reviewed-on: https://go-review.googlesource.com/2141
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agodoc: 2015 will be the Year of the Gopher.
David Symonds [Wed, 31 Dec 2014 13:00:00 +0000 (00:00 +1100)]
doc: 2015 will be the Year of the Gopher.

Change-Id: Ic2e34f84596b56715d5f41c9a5250f7c9f8e671b
Reviewed-on: https://go-review.googlesource.com/2087
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
9 years agostrconv: optimize decimal to string conversion
Martin Möhrmann [Thu, 25 Dec 2014 18:30:53 +0000 (19:30 +0100)]
strconv: optimize decimal to string conversion

Avoid the decimal lookup in digits array and compute the decimal character value directly.
Reduce calls to 64bit division on 32bit plattforms by splitting conversion into smaller blocks.
Convert value to uintptr type when it can be represented by uintptr.

on darwin/386

benchmark               old ns/op     new ns/op     delta
BenchmarkFormatInt      8352          7466          -10.61%
BenchmarkAppendInt      4281          3401          -20.56%
BenchmarkFormatUint     2785          2251          -19.17%
BenchmarkAppendUint     1770          1223          -30.90%

on darwin/amd64

benchmark               old ns/op     new ns/op     delta
BenchmarkFormatInt      5531          5492          -0.71%
BenchmarkAppendInt      2435          2295          -5.75%
BenchmarkFormatUint     1628          1569          -3.62%
BenchmarkAppendUint     726           750           +3.31%

Change-Id: Ifca281cbdd62ab7d7bd4b077a96da99eb12cf209
Reviewed-on: https://go-review.googlesource.com/2105
Reviewed-by: Robert Griesemer <gri@golang.org>
9 years agogo/parser: add {map,chan,interface} to expression lookahead tokens
Alan Donovan [Tue, 30 Dec 2014 19:44:41 +0000 (14:44 -0500)]
go/parser: add {map,chan,interface} to expression lookahead tokens

+ tests that these parse:
  map[int]int{}[0]++
  interface{f()}(x).f()
  chan int(x) <- 0

Fixes #9474

Change-Id: If9fa57b3ab415ae7e93aa9935ec63edda8fe9d4f
Reviewed-on: https://go-review.googlesource.com/2178
Reviewed-by: Robert Griesemer <gri@golang.org>
9 years agoarchive/tar: document Reader.Next's behavior at the end
Brad Fitzpatrick [Tue, 30 Dec 2014 06:28:02 +0000 (22:28 -0800)]
archive/tar: document Reader.Next's behavior at the end

Change-Id: I72f6d0fc66dbee3f832d2d960b99a166a5bb10c3
Reviewed-on: https://go-review.googlesource.com/2191
Reviewed-by: David Symonds <dsymonds@golang.org>
9 years agodoc: add http server trailers support to go1.5.txt
Brad Fitzpatrick [Tue, 30 Dec 2014 18:01:49 +0000 (10:01 -0800)]
doc: add http server trailers support to go1.5.txt

Change-Id: Ic15e40bb1ae0bf3a4e8c43a44daf7cc35a18da87
Reviewed-on: https://go-review.googlesource.com/2192
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agoruntime: consolidate arch-specific signal handlers on Plan 9
Anthony Martin [Thu, 18 Dec 2014 13:05:44 +0000 (05:05 -0800)]
runtime: consolidate arch-specific signal handlers on Plan 9

Change-Id: I4379418853c523fc9aaeb5d6f37bc96117841418
Reviewed-on: https://go-review.googlesource.com/1786
Reviewed-by: David du Colombier <0intro@gmail.com>
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
9 years agodoc: update links in FAQ
Emil Hessman [Tue, 30 Dec 2014 05:45:24 +0000 (06:45 +0100)]
doc: update links in FAQ

Vitess and protobuf has moved to GitHub; update the links.

Change-Id: I2d90bde1a7f2b590c8b7b08ce73d6faa13b51da0
Reviewed-on: https://go-review.googlesource.com/2166
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agonet/http: support for setting trailers from a server Handler
Brad Fitzpatrick [Tue, 30 Dec 2014 03:32:07 +0000 (19:32 -0800)]
net/http: support for setting trailers from a server Handler

We already had client support for trailers, but no way for a server to
set them short of hijacking the connection.

Fixes #7759

Change-Id: Ic83976437739ec6c1acad5f209ed45e501dbb93a
Reviewed-on: https://go-review.googlesource.com/2157
Reviewed-by: Andrew Gerrand <adg@golang.org>