1
0
mirror of https://github.com/golang/go synced 2024-10-01 13:18:33 -06:00
Commit Graph

21485 Commits

Author SHA1 Message Date
Martin Möhrmann
878fa886a6 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>
2015-01-08 16:51:47 +00:00
Alex Brainman
d00024bd60 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>
2015-01-08 06:07:56 +00:00
Keith Randall
fcfbeb3adf 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>
2015-01-08 04:49:43 +00:00
Brad Fitzpatrick
abb2aa2085 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>
2015-01-08 04:35:23 +00:00
Brad Fitzpatrick
e16ab38dc9 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>
2015-01-08 01:11:43 +00:00
Matthew Dempsky
ee94cd1dff 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>
2015-01-08 00:59:37 +00:00
Shenghou Ma
583293349b 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>
2015-01-07 23:24:23 +00:00
David du Colombier
8c69ce0b90 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>
2015-01-07 22:58:38 +00:00
Matthew Dempsky
b2aab72d9a 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>
2015-01-07 22:49:59 +00:00
Josh Bleecher Snyder
f7e43f14d3 runtime: remove stray commas in assembly
Change-Id: I4dc97ff8111bdc5ca6e4e3af06aaf4f768031c68
Reviewed-on: https://go-review.googlesource.com/2473
Reviewed-by: Minux Ma <minux@golang.org>
2015-01-07 22:41:54 +00:00
Josh Bleecher Snyder
43e6923131 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>
2015-01-07 22:36:06 +00:00
Josh Bleecher Snyder
43c87aa481 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>
2015-01-07 22:26:55 +00:00
Keith Randall
d5e4c4061b 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>
2015-01-07 21:57:01 +00:00
Josh Bleecher Snyder
60801c4853 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>
2015-01-07 21:48:48 +00:00
Keith Randall
63116de558 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>
2015-01-07 21:24:21 +00:00
Austin Clements
af7ca8dce4 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>
2015-01-07 20:36:27 +00:00
Austin Clements
f1c4444dfc 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>
2015-01-07 20:36:19 +00:00
Austin Clements
bbd2127909 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>
2015-01-07 20:36:08 +00:00
Austin Clements
db923390a0 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>
2015-01-07 20:35:54 +00:00
Austin Clements
ac5a1ac318 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>
2015-01-07 20:35:37 +00:00
Austin Clements
fcdffb3f33 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>
2015-01-07 20:35:13 +00:00
Austin Clements
e32fe2049d 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>
2015-01-07 20:34:55 +00:00
Keith Randall
ec767c10b3 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>
2015-01-07 20:25:06 +00:00
Keith Randall
5aae246f1e 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>
2015-01-07 20:13:06 +00:00
Oling Cat
ce36552083 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>
2015-01-07 17:26:50 +00:00
Keith Randall
1dd0163ce3 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>
2015-01-07 16:05:16 +00:00
Keith Randall
ce5cb037d1 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>
2015-01-07 16:02:05 +00:00
Matthew Dempsky
31775c5a95 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>
2015-01-07 15:14:07 +00:00
Brad Fitzpatrick
3ef39472a8 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>
2015-01-07 06:41:35 +00:00
Brad Fitzpatrick
ee2ecc4552 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>
2015-01-07 06:37:57 +00:00
Shenghou Ma
5f179c7cef 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>
2015-01-07 03:20:42 +00:00
Martin Möhrmann
e5864cd939 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>
2015-01-06 23:30:46 +00:00
Russ Cox
bc2601a1df 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>
2015-01-06 22:28:52 +00:00
Russ Cox
9b638bf1bf 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>
2015-01-06 22:23:14 +00:00
Russ Cox
949dd10222 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>
2015-01-06 22:22:59 +00:00
Brad Fitzpatrick
f5f69bba3b 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>
2015-01-06 20:31:35 +00:00
Adam Langley
ea64e5785d 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>
2015-01-06 19:50:07 +00:00
Adam Langley
b1370742ee 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>
2015-01-06 19:18:28 +00:00
Russ Cox
02f89331c2 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>
2015-01-06 15:10:13 +00:00
Russ Cox
ff979626fc 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>
2015-01-06 14:41:45 +00:00
Alex Brainman
03d6637dbb 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>
2015-01-06 05:31:40 +00:00
Shenghou Ma
a6a30fefd9 runtime: fix build for ARM
Change-Id: Ia18b8411bebc47ea71ac1acd9ff9dc570ec15dea
Reviewed-on: https://go-review.googlesource.com/2341
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-01-06 01:29:42 +00:00
Russ Cox
df027aceb9 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>
2015-01-06 00:28:31 +00:00
Russ Cox
813386f200 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>
2015-01-06 00:28:22 +00:00
Russ Cox
ccdb50931f 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>
2015-01-06 00:28:03 +00:00
Russ Cox
e5ef657264 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>
2015-01-06 00:27:49 +00:00
Russ Cox
54bb4dc390 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>
2015-01-06 00:27:29 +00:00
Russ Cox
bcadab9349 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>
2015-01-06 00:27:20 +00:00
Russ Cox
7b4df8f018 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>
2015-01-06 00:27:06 +00:00
Russ Cox
eafc482d4f 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>
2015-01-06 00:26:54 +00:00