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

14989 Commits

Author SHA1 Message Date
Russ Cox
c40480ddd9 runtime: print up to 10 words of arguments
The old limit of 5 was chosen because we didn't actually know how
many bytes of arguments there were; 5 was a halfway point between
printing some useful information and looking ridiculous.

Now we know how many bytes of arguments there are, and we stop
the printing when we reach that point, so the "looking ridiculous" case
doesn't happen anymore: we only print actual argument words.
The cutoff now serves only to truncate very long (but real) argument lists.

In multiple debugging sessions recently (completely unrelated bugs)
I have been frustrated by not seeing more of the long argument lists:
5 words is only 2.5 interface values or strings, and not even 2 slices.
Double the max amount we'll show.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews, iant, r
https://golang.org/cl/83850043
2014-04-02 23:00:40 -04:00
Keith Randall
059c10b552 cmd/ld: get rid of map.bucket's data field from dwarf info.
The data field is the generic array that acts as a standin
for the keys and values arrays for the generic runtime code.
We want to substitute the keys and values arrays for the data
array, not just add keys and values in addition to it.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/81160044
2014-04-02 19:46:47 -07:00
Dave Cheney
9121e7e4df runtime: check that new slice cap doesn't overflow
Fixes #7550.

LGTM=iant
R=golang-codereviews, iant, josharian
CC=golang-codereviews
https://golang.org/cl/83520043
2014-04-03 13:44:44 +11:00
Dave Cheney
568f50e3fc cmd/gc: fix build
Darwin 10.6 (gcc 4.2) and some older versions of gcc default to C90 mode, not C99 mode. Silence the warning.

LGTM=aram, iant
R=golang-codereviews, aram, iant
CC=golang-codereviews
https://golang.org/cl/83090050
2014-04-03 11:34:31 +11:00
Ian Lance Taylor
7d299d031d net: don't export netFD readFrom, writeTo, readMsg, writeMsg methods
There is no way to call them from outside the net package.
They are used to implement UCPConn.ReadMsgUDP and similar.

LGTM=mikioh.mikioh
R=golang-codereviews, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/83730044
2014-04-02 17:06:51 -07:00
Dave Cheney
1aaea50c76 cmd/pack: fix format string error in log message
Fixes #7693.

pack.go:347: possible formatting directive in Fatal call

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/83310045
2014-04-03 09:58:10 +11:00
Brad Fitzpatrick
84db9e09d9 crypto/tls: deflake TestConnReadNonzeroAndEOF
Fixes #7683

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/83080048
2014-04-02 14:31:57 -07:00
Russ Cox
81bc9b3ffd runtime: revert change to PoisonPtr value
Submitted accidentally in CL 83630044.
Fixes various builds.

TBR=khr
CC=golang-codereviews
https://golang.org/cl/83100047
2014-04-02 16:55:30 -04:00
Russ Cox
4676fae525 cmd/gc, cmd/ld, runtime: compact liveness bitmaps
Reduce footprint of liveness bitmaps by about 5x.

1. Mark all liveness bitmap symbols as 4-byte aligned
(they were aligned to a larger size by default).

2. The bitmap data is a bitmap count n followed by n bitmaps.
Each bitmap begins with its own count m giving the number
of bits. All the m's are the same for the n bitmaps.
Emit this bitmap length once instead of n times.

3. Many bitmaps within a function have the same bit values,
but each call site was given a distinct bitmap. Merge duplicate
bitmaps so that no bitmap is written more than once.

4. Many functions end up with the same aggregate bitmap data.
We used to name the bitmap data funcname.gcargs and funcname.gclocals.
Instead, name it gclocals.<md5 of data> and mark it dupok so
that the linker coalesces duplicate sets. This cut the bitmap
data remaining after step 3 by 40%; I was not expecting it to
be quite so dramatic.

Applied to "go build -ldflags -w code.google.com/p/go.tools/cmd/godoc":

                bitmaps           pclntab           binary on disk
before this CL  1326600           1985854           12738268
4-byte align    1154288 (0.87x)   1985854 (1.00x)   12566236 (0.99x)
one bitmap len   782528 (0.54x)   1985854 (1.00x)   12193500 (0.96x)
dedup bitmap     414748 (0.31x)   1948478 (0.98x)   11787996 (0.93x)
dedup bitmap set 245580 (0.19x)   1948478 (0.98x)   11620060 (0.91x)

While here, remove various dead blocks of code from plive.c.

Fixes #6929.
Fixes #7568.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/83630044
2014-04-02 16:49:27 -04:00
David du Colombier
9f9c9abb7e cmd/8g, cmd/gc: fix warnings on Plan 9
warning: src/cmd/8g/ggen.c:35 non-interruptable temporary
warning: src/cmd/gc/walk.c:656 set and not used: l
warning: src/cmd/gc/walk.c:658 set and not used: l

LGTM=minux.ma
R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/83660043
2014-04-02 21:33:50 +02:00
Russ Cox
96d90d0981 cmd/gc: shorten even more temporary lifetimes
1. Use n->alloc, not n->left, to hold the allocated temp being
passed from orderstmt/orderexpr to walk.

2. Treat method values the same as closures.

3. Use killed temporary for composite literal passed to
non-escaping function argument.

4. Clean temporaries promptly in if and for statements.

5. Clean temporaries promptly in select statements.
As part of this, move all the temporary-generating logic
out of select.c into order.c, so that the temporaries can
be reclaimed.

With the new temporaries, can re-enable the 1-entry
select optimization. Fixes issue 7672.

While we're here, fix a 1-line bug in select processing
turned up by the new liveness test (but unrelated; select.c:72).
Fixes #7686.

6. Clean temporaries (but not particularly promptly) in switch
and range statements.

7. Clean temporary used during convT2E/convT2I.

8. Clean temporaries promptly during && and || expressions.

---

CL 81940043 reduced the number of ambiguously live temps
in the godoc binary from 860 to 711.

CL 83090046 reduced the number from 711 to 121.

This CL reduces the number from 121 to 23.

15 the 23 that remain are in fact ambiguously live.
The final 8 could be fixed but are not trivial and
not common enough to warrant work at this point
in the release cycle.

These numbers only count ambiguously live temps,
not ambiguously live user-declared variables.
There are 18 such variables in the godoc binary after this CL,
so a total of 41 ambiguously live temps or user-declared
variables.

The net effect is that zeroing anything on entry to a function
should now be a rare event, whereas earlier it was the
common case.

This is good enough for Go 1.3, and probably good
enough for future releases too.

Fixes #7345.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/83000048
2014-04-02 14:09:42 -04:00
Keith Randall
47acf16709 cmd/gc: Don't zero more than we need.
Don't merge with the zero range, we may
end up zeroing more than we need.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/83430044
2014-04-02 09:17:42 -07:00
Mikio Hara
e88e7ed6ba net: enable unixpacket test on available platforms
DragonFlyBSD, FreeBSD 9 and beyond, NetBSD 6 and beyond, and
Solaris (illumos) support AF_UNIX+SOCK_SEQPACKET socket.

LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/83390043
2014-04-02 19:43:39 +09:00
Mikio Hara
67a5181045 net: make WriteTo, WriteToUnix and WriteMsgUnix fail when connectionless-mode UnixConn is already connected
This CL tries to fill the gap between Linux and other Unix-like systems
in the same way UDPConn already did.

Fixes #7677.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/83330045
2014-04-02 19:42:05 +09:00
Dmitriy Vyukov
f4ef6977ff runtime: ignore pointers to global objects in SetFinalizer
Update #7656

LGTM=rsc
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/82560043
2014-04-02 10:19:28 +04:00
Keith Randall
383963b506 runtime: zero at start of frame more efficiently.
Use Duff's device for zeroing.  Combine adjacent regions.

Update #7680
Update #7624

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/83200045
2014-04-01 19:44:07 -07:00
Russ Cox
9c8f11ff96 cmd/5g, cmd/8g: fix build
Botched during CL 83090046.

TBR=khr
CC=golang-codereviews
https://golang.org/cl/83070046
2014-04-01 20:24:53 -04:00
Russ Cox
daca06f2e3 cmd/gc: shorten more temporary lifetimes
1. In functions with heap-allocated result variables or with
defer statements, the return sequence requires more than
just a single RET instruction. There is an optimization that
arranges for all returns to jump to a single copy of the return
epilogue in this case. Unfortunately, that optimization is
fundamentally incompatible with PC-based liveness information:
it takes PCs at many different points in the function and makes
them all land at one PC, making the combined liveness information
at that target PC a mess. Disable this optimization, so that each
return site gets its own copy of the 'call deferreturn' and the
copying of result variables back from the heap.
This removes quite a few spurious 'ambiguously live' variables.

2. Let orderexpr allocate temporaries that are passed by address
to a function call and then die on return, so that we can arrange
an appropriate VARKILL.

2a. Do this for ... slices.

2b. Do this for closure structs.

2c. Do this for runtime.concatstring, which is the implementation
of large string additions. Change representation of OADDSTR to
an explicit list in typecheck to avoid reconstructing list in both
walk and order.

3. Let orderexpr allocate the temporary variable copies used for
range loops, so that they can be killed when the loop is over.
Similarly, let it allocate the temporary holding the map iterator.

CL 81940043 reduced the number of ambiguously live temps
in the godoc binary from 860 to 711.

This CL reduces the number to 121. Still more to do, but another
good checkpoint.

Update #7345

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/83090046
2014-04-01 20:02:54 -04:00
Andrew Gerrand
2f3776ac27 time: increase timeout in negative sleep duration test
There's enough jitter in the scheduler on overloaded machines
that 25ms is not enough.

LGTM=dave
R=golang-codereviews, gobot, rsc, dave
CC=golang-codereviews
https://golang.org/cl/83300044
2014-04-02 08:23:35 +11:00
Keith Randall
6c7cbf086c runtime: get rid of most uses of REP for copying/zeroing.
REP MOVSQ and REP STOSQ have a really high startup overhead.
Use a Duff's device to do the repetition instead.

benchmark                 old ns/op     new ns/op     delta
BenchmarkClearFat32       7.20          1.60          -77.78%
BenchmarkCopyFat32        6.88          2.38          -65.41%
BenchmarkClearFat64       7.15          3.20          -55.24%
BenchmarkCopyFat64        6.88          3.44          -50.00%
BenchmarkClearFat128      9.53          5.34          -43.97%
BenchmarkCopyFat128       9.27          5.56          -40.02%
BenchmarkClearFat256      13.8          9.53          -30.94%
BenchmarkCopyFat256       13.5          10.3          -23.70%
BenchmarkClearFat512      22.3          18.0          -19.28%
BenchmarkCopyFat512       22.0          19.7          -10.45%
BenchmarkCopyFat1024      36.5          38.4          +5.21%
BenchmarkClearFat1024     35.1          35.0          -0.28%

TODO: use for stack frame zeroing
TODO: REP prefixes are still used for "reverse" copying when src/dst
regions overlap.  Might be worth fixing.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews, r
https://golang.org/cl/81370046
2014-04-01 12:51:02 -07:00
Russ Cox
cfb347fc0a runtime: use correct pc to obtain liveness info during stack copy
The old code was using the PC of the instruction after the CALL.
Variables live during the call but not live when it returns would
not be seen as live during the stack copy, which might lead to
corruption. The correct PC to use is the one just before the
return address. After this CL the lookup matches what mgc0.c does.

The only time this matters is if you have back to back CALL instructions:

        CALL f1 // x live here
        CALL f2 // x no longer live

If a stack copy occurs during the execution of f1, the old code will
use the liveness bitmap intended for the execution of f2 and will not
treat x as live.

The only way this situation can arise and cause a problem in a stack copy
is if x lives on the stack has had its address taken but the compiler knows
enough about the context to know that x is no longer needed once f1
returns. The compiler has never known that much, so using the f2 context
cannot currently cause incorrect execution. For the same reason, it is not
possible to write a test for this today.

CL 83090046 will make the compiler precise enough in some cases
that this distinction will start mattering. The existing stack growth tests
in package runtime will fail if that CL is submitted without this one.

While we're here, print the frame PC in debug mode and update the
bitmap interpretation strings.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/83250043
2014-04-01 14:57:58 -04:00
Russ Cox
b700cb4974 cmd/gc: shorten temporary lifetimes when possible
The new channel and map runtime routines take pointers
to values, typically temporaries. Without help, the compiler
cannot tell when those temporaries stop being needed,
because it isn't sure what happened to the pointer.
Arrange to insert explicit VARKILL instructions for these
temporaries so that the liveness analysis can avoid seeing
them as "ambiguously live".

The change is made in order.c, which was already in charge of
introducing temporaries to preserve the order-of-evaluation
guarantees. Now its job has expanded to include introducing
temporaries as needed by runtime routines, and then also
inserting the VARKILL annotations for all these temporaries,
so that their lifetimes can be shortened.

In order to do its job for the map runtime routines, order.c arranges
that all map lookups or map assignments have the form:

        x = m[k]
        x, y = m[k]
        m[k] = x

where x, y, and k are simple variables (often temporaries).
Likewise, receiving from a channel is now always:

        x = <-c

In order to provide the map guarantee, order.c is responsible for
rewriting x op= y into x = x op y, so that m[k] += z becomes

        t = m[k]
        t2 = t + z
        m[k] = t2

While here, fix a few bugs in order.c's traversal: it was failing to
walk into select and switch case bodies, so order of evaluation
guarantees were not preserved in those situations.
Added tests to test/reorder2.go.

Fixes #7671.

In gc/popt's temporary-merging optimization, allow merging
of temporaries with their address taken as long as the liveness
ranges do not intersect. (There is a good chance of that now
that we have VARKILL annotations to limit the liveness range.)

Explicitly killing temporaries cuts the number of ambiguously
live temporaries that must be zeroed in the godoc binary from
860 to 711, or -17%. There is more work to be done, but this
is a good checkpoint.

Update #7345

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/81940043
2014-04-01 13:31:38 -04:00
Russ Cox
1ec4d5e9e7 runtime: adjust GODEBUG=allocfreetrace=1 and GODEBUG=gcdead=1
GODEBUG=allocfreetrace=1:

The allocfreetrace=1 mode prints a stack trace for each block
allocated and freed, and also a stack trace for each garbage collection.

It was implemented by reusing the heap profiling support: if allocfreetrace=1
then the heap profile was effectively running at 1 sample per 1 byte allocated
(always sample). The stack being shown at allocation was the stack gathered
for profiling, meaning it was derived only from the program counters and
did not include information about function arguments or frame pointers.
The stack being shown at free was the allocation stack, not the free stack.
If you are generating this log, you can find the allocation stack yourself, but
it can be useful to see exactly the sequence that led to freeing the block:
was it the garbage collector or an explicit free? Now that the garbage collector
runs on an m0 stack, the stack trace for the garbage collector was never interesting.

Fix all these problems:

1. Decouple allocfreetrace=1 from heap profiling.
2. Print the standard goroutine stack traces instead of a custom format.
3. Print the stack trace at time of allocation for an allocation,
   and print the stack trace at time of free (not the allocation trace again)
   for a free.
4. Print all goroutine stacks at garbage collection. Having all the stacks
   means that you can see the exact point at which each goroutine was
   preempted, which is often useful for identifying liveness-related errors.

GODEBUG=gcdead=1:

This mode overwrites dead pointers with a poison value.
Detect the poison value as an invalid pointer during collection,
the same way that small integers are invalid pointers.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/81670043
2014-04-01 13:30:10 -04:00
Shenghou Ma
16b95507a5 html/template: fix broken links
Fixes #7562.

LGTM=nigeltao
R=nigeltao
CC=golang-codereviews
https://golang.org/cl/81190044
2014-04-01 02:57:51 -04:00
Shenghou Ma
15bc7ab957 cmd/gc: fix spurious "bad negated constant" for complex constants.
Fixes #7648.

LGTM=r, remyoudompheng
R=golang-codereviews, r, remyoudompheng, jscrockett01
CC=golang-codereviews
https://golang.org/cl/80560045
2014-04-01 02:55:38 -04:00
Shenghou Ma
1b42d25ae3 cmd/ld: pass -Qunused-arguments to clang during host linking.
LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/82140043
2014-03-29 17:10:25 -04:00
Mike Andrews
ece69f7c2b cmd/ld: don't delete output binary if not "ordinary" file.
e.g., don't delete /dev/null. this fix inspired by gnu libiberty,
unlink-if-ordinary.c.

Fixes #7563

LGTM=iant
R=golang-codereviews, iant, 0intro
CC=golang-codereviews, r
https://golang.org/cl/76810045
2014-03-29 09:50:49 -07:00
Jan Ziak
2ca99505f6 cmd/gc: suppress array index error caused by a previously reported error
Fixes #7153

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/82180043
2014-03-29 15:45:40 +01:00
Mikio Hara
83ac901fb9 net: tweak the ephemeral port range on dragonfly
On DragonFly BSD, we adjust the ephemeral port range because
unlike other BSD systems its default ephemeral port range
doesn't conform to IANA recommendation as described in RFC 6355
and is pretty narrow.

On DragonFly BSD 3.6: default range [1024, 5000], high range [49152, 65535]
On FreeBSD 10: default range [10000, 65535], high range [49152, 65535]
On Linux 3.11: default range [32768, 61000]

Fixes #7541.

LGTM=iant
R=jsing, gobot, iant
CC=golang-codereviews
https://golang.org/cl/80610044
2014-03-29 13:04:25 +09:00
Mikio Hara
a7858a40a5 syscall: add SendmsgN for BSD variants, Linux and Solaris
SendmsgN is an alternate version Sendmsg that also returns
the number of bytes transferred, instead of just the error.

Update #7645

LGTM=aram, iant
R=iant, aram, bradfitz
CC=golang-codereviews
https://golang.org/cl/81210043
2014-03-29 09:28:40 +09:00
Brad Fitzpatrick
f074565158 bytes, strings: allow Reader.Seek past 1<<31
Fixes #7654

LGTM=rsc
R=rsc, dan.kortschak
CC=golang-codereviews
https://golang.org/cl/81530043
2014-03-28 12:23:51 -07:00
Russ Cox
e150ca9c9a cmd/gc: never pass ptr to uninit temp to runtime
chanrecv now expects a pointer to the data to be filled in.
mapiterinit expects a pointer to the hash iterator to be filled in.
In both cases, the temporary being pointed at changes from
dead to alive during the call. In order to make sure it is
preserved if a garbage collection happens after that transition
but before the call returns, the temp must be marked as live
during the entire call.

But if it is live during the entire call, it needs to be safe for
the garbage collector to scan at the beginning of the call,
before the new data has been filled in. Therefore, it must be
zeroed by the caller, before the call. Do that.

My previous attempt waited to mark it live until after the
call returned, but that's unsafe (see first paragraph);
undo that change in plive.c.

This makes powser2 pass again reliably.

I looked at every call to temp in the compiler.
The vast majority are followed immediately by an
initialization of temp, so those are fine.
The only ones that needed changing were the ones
where the next operation is to pass the address of
the temp to a function call, and there aren't too many.

Maps are exempted from this because mapaccess
returns a pointer to the data and lets the caller make
the copy.

Fixes many builds.

TBR=khr
CC=golang-codereviews
https://golang.org/cl/80700046
2014-03-28 11:30:02 -04:00
Adam Langley
ea3353b64c crypto/x509: unbreak Windows build.
This change sets systemSkip on a test where Go and CAPI have different
chain building behaviour. CAPI is correct, but aligning the Go code is
probably too large a change prior to 1.3.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/81620043
2014-03-28 10:36:52 -04:00
Alex Brainman
2dc7552f57 runtime: ignore windows exception if not in Go binary
LGTM=minux.ma
R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/80400043
2014-03-28 17:35:00 +11:00
Mikio Hara
a05ffd85aa net: make IPv6 capability test more suitable for address family selection on the dual IP stack node
For now we strictly use IPV6_V6ONLY=1 for IPv6-only communications
and IPV6_V6ONLY=0 for both IPv4 and IPv6 communications. So let the
capability test do the same.

LGTM=iant
R=golang-codereviews, gobot, iant
CC=golang-codereviews
https://golang.org/cl/80140044
2014-03-28 13:27:51 +09:00
Mikio Hara
753bdc0f47 syscall: don't generate RTF_BITS constant on OS X Mavericks and beyond
LGTM=iant
R=iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/80700044
2014-03-28 13:27:14 +09:00
Alex Brainman
277a7b22f1 runtime: do not crash when GetQueuedCompletionStatusEx is missing
Fixes #7635

LGTM=minux.ma
R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/80390043
2014-03-28 12:37:14 +11:00
Adam Langley
0f272d1378 crypto/x509: update tests because Windows removed the Verisign root.
The root update on 3/11/2014 removed the Verisign root cert that the Go
tests use. This only affects the 'TestSystemVerify' test in
crypto/x509.

Fixes #7523.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/80000044
2014-03-27 17:56:02 -04:00
Daniel Morsing
0f82cfd3f0 cmd/cgo: enforce typing of 0-sized types
cgo represents all 0-sized and unsized types internally as [0]byte. This means that pointers to incomplete types would be interchangable, even if given a name by typedef.

Fixes #7409.

LGTM=iant
R=golang-codereviews, bradfitz, iant
CC=golang-codereviews
https://golang.org/cl/76450043
2014-03-27 20:23:16 +00:00
Russ Cox
5a23a7e52c runtime: enable 'bad pointer' check during garbage collection of Go stack frames
This is the same check we use during stack copying.
The check cannot be applied to C stack frames, even
though we do emit pointer bitmaps for the arguments,
because (1) the pointer bitmaps assume all arguments
are always live, not true of outputs during the prologue,
and (2) the pointer bitmaps encode interface values as
pointer pairs, not true of interfaces holding integers.

For the rest of the frames, however, we should hold ourselves
to the rule that a pointer marked live really is initialized.
The interface scanning already implicitly checks this
because it interprets the type word  as a valid type pointer.

This may slow things down a little because of the extra loads.
Or it may speed things up because we don't bother enqueuing
nil pointers anymore. Enough of the rest of the system is slow
right now that we can't measure it meaningfully.
Enable for now, even if it is slow, to shake out bugs in the
liveness bitmaps, and then decide whether to turn it off
for the Go 1.3 release (issue 7650 reminds us to do this).

The new m->traceback field lets us force printing of fp=
values on all goroutine stack traces when we detect a
bad pointer. This makes it easier to understand exactly
where in the frame the bad pointer is, so that we can trace
it back to a specific variable and determine what is wrong.

Update #7650

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/80860044
2014-03-27 14:06:15 -04:00
Russ Cox
6722d45631 cmd/gc: liveness-related bug fixes
1. On entry to a function, only zero the ambiguously live stack variables.
Before, we were zeroing all stack variables containing pointers.
The zeroing is pretty inefficient right now (issue 7624), but there are also
too many stack variables detected as ambiguously live (issue 7345),
and that must be addressed before deciding how to improve the zeroing code.
(Changes in 5g/ggen.c, 6g/ggen.c, 8g/ggen.c, gc/pgen.c)

Fixes #7647.

2. Make the regopt word-based liveness analysis preserve the
whole-variable liveness property expected by the garbage collection
bitmap liveness analysis. That is, if the regopt liveness decides that
one word in a struct needs to be preserved, make sure it preserves
the entire struct. This is particularly important for multiword values
such as strings, slices, and interfaces, in which all the words need
to be present in order to understand the meaning.
(Changes in 5g/reg.c, 6g/reg.c, 8g/reg.c.)

Fixes #7591.

3. Make the regopt word-based liveness analysis treat a variable
as having its address taken - which makes it preserved across
all future calls - whenever n->addrtaken is set, for consistency
with the gc bitmap liveness analysis, even if there is no machine
instruction actually taking the address. In this case n->addrtaken
is incorrect (a nicer way to put it is overconservative), and ideally
there would be no such cases, but they can happen and the two
analyses need to agree.
(Changes in 5g/reg.c, 6g/reg.c, 8g/reg.c; test in bug484.go.)

Fixes crashes found by turning off "zero everything" in step 1.

4. Remove spurious VARDEF annotations. As the comment in
gc/pgen.c explains, the VARDEF must immediately precede
the initialization. It cannot be too early, and it cannot be too late.
In particular, if a function call sits between the VARDEF and the
actual machine instructions doing the initialization, the variable
will be treated as live during that function call even though it is
uninitialized, leading to problems.
(Changes in gc/gen.c; test in live.go.)

Fixes crashes found by turning off "zero everything" in step 1.

5. Do not treat loading the address of a wide value as a signal
that the value must be initialized. Instead depend on the existence
of a VARDEF or the first actual read/write of a word in the value.
If the load is in order to pass the address to a function that does
the actual initialization, treating the load as an implicit VARDEF
causes the same problems as described in step 4.
The alternative is to arrange to zero every such value before
passing it to the real initialization function, but this is a much
easier and more efficient change.
(Changes in gc/plive.c.)

Fixes crashes found by turning off "zero everything" in step 1.

6. Treat wide input parameters with their address taken as
initialized on entry to the function. Otherwise they look
"ambiguously live" and we will try to emit code to zero them.
(Changes in gc/plive.c.)

Fixes crashes found by turning off "zero everything" in step 1.

7. An array of length 0 has no pointers, even if the element type does.
Without this change, the zeroing code complains when asked to
clear a 0-length array.
(Changes in gc/reflect.c.)

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/80160044
2014-03-27 14:05:57 -04:00
Russ Cox
f94bff7935 cmd/dist: zero output variables on entry to goc2c functions
Zeroing the outputs makes sure that during function calls
in those functions we do not let the garbage collector
treat uninitialized values as pointers.

The garbage collector may still see uninitialized values
if a preemption occurs during the function prologue,
before the zeroing has had a chance to run.

This reduces the number of 'bad pointer' messages when
that runtime check is enabled, but it doesn't fix all of them,
so the check is still disabled.

It will also avoid leaks, although I doubt any of these were
particularly serious.

LGTM=iant, khr
R=iant, khr
CC=golang-codereviews
https://golang.org/cl/80850044
2014-03-27 14:05:31 -04:00
Russ Cox
ef3c0e7e61 regexp/syntax: remove InstLast
This was added by the one-pass CL (post Go 1.2)
so it can still be removed.

Removing because surely there will be new operations
added later, and we can't change the constant value
once we define it, so "last" is a bad concept to expose.

Nothing uses it.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/81160043
2014-03-27 14:05:14 -04:00
Jan Ziak
21b2e16842 cmd/gc: fix spurious 'use of untyped nil' error
Fixes #6402

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/81340044
2014-03-27 18:47:00 +01:00
Russ Cox
fc6befba3c runtime: initialize complete Hiter during mapiterinit
The garbage collector will scan these pointers,
so make sure they are initialized.

LGTM=bradfitz, khr
R=khr, bradfitz
CC=golang-codereviews
https://golang.org/cl/80960047
2014-03-26 21:52:29 -04:00
Erik Westrup
881d693c86 cmd/go: Use exported CgoLDFlags when compiler=gccgo
If you compile a program that has cgo LDFLAGS directives, those are exported to an environment variable to be used by subsequent compiler tool invocations. The linking phase when using the gccgo toolchain did not consider the envvar CGO_LDFLAGS's linking directives resulting in undefined references when using cgo+gccgo.

Fixes #7573

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/80780043
2014-03-26 15:23:31 -07:00
Shenghou Ma
4271dd4550 cmd/dist: set -Wuninitialized only when -O is also set.
GCC on OS X 10.6 doesn't support -Wuninitialized without -O.
Fixes #7492.

LGTM=iant
R=golang-codereviews, dave, iant
CC=golang-codereviews
https://golang.org/cl/72360045
2014-03-26 14:20:18 -04:00
Dmitriy Vyukov
7c75a862b4 runtime: eliminate false retention due to m->moreargp/morebuf
m->moreargp/morebuf were not cleared in case of preemption and stack growing,
it can lead to persistent leaks of large memory blocks.

It seems to fix the sync.Pool finalizer failures. I've run the test 500'000 times
w/o a single failure; previously it would fail dozens of times.

Fixes #7633.
Fixes #7533.

LGTM=rsc
R=golang-codereviews
CC=golang-codereviews, khr, rsc
https://golang.org/cl/80480044
2014-03-26 19:06:15 +04:00
Dmitriy Vyukov
d89a738378 runtime: support channel-based mutex in race detector
Update channel race annotations to support change in
cl/75130045: doc: allow buffered channel as semaphore without initialization
The new annotations are added only for channels with capacity 1.
Strictly saying it's possible to construct a counter-example that
will produce a false positive with capacity > 1. But it's hardly can
lead to false positives in real programs, at least I would like to see such programs first.
Any additional annotations also increase probability of false negatives,
so I would prefer to add them lazily.

LGTM=rsc
R=golang-codereviews
CC=golang-codereviews, iant, khr, rsc
https://golang.org/cl/76970043
2014-03-26 19:05:48 +04:00
Dmitriy Vyukov
f8c350873c runtime: fix yet another race in bgsweep
Currently it's possible that bgsweep finishes before all spans
have been swept (we only know that sweeping of all spans has *started*).
In such case bgsweep may fail wake up runfinq goroutine when it needs to.
finq may still be nil at this point, but some finalizers may be queued later.
Make bgsweep to wait for sweeping to *complete*, then it can decide
whether it needs to wake up runfinq for sure.
Update #7533

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/75960043
2014-03-26 15:11:36 +04:00
Dmitriy Vyukov
40f5e67571 runtime: minor improvement of string scanning
If we set obj, then it will be enqueued for marking at the end of the scanning loop.
This is not necessary, since we've already marked it.
This can wait for 1.4 if you wish.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/80030043
2014-03-26 15:03:58 +04:00
Rob Pike
61f2fabd38 cmd/go: fix typo in help doc
Fixes #7519.

LGTM=adg, mikioh.mikioh
R=golang-codereviews, adg, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/80370043
2014-03-26 17:18:59 +11:00
Rob Pike
274fc7600d fmt: document order of application of %T, %p and the special interfaces
Their priority was not documented.

Fixes #7571.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/80360043
2014-03-26 17:18:24 +11:00
Dave Cheney
3ce1677ad9 cmd/go: ensure external test files are presented to the linker first
Fixes #7627.

CL 61970044 changed the order in which .a files are passed to gccgo's link phase. However by reversing the order it caused gccgo to complain if both internal (liba.a) and external (liba_test.a) versions of a package were presented as the former would not contain all the necessary symbols, and the latter would duplicate symbols already defined.

This change ensures that all 'fake' targets remain at the top of the final link order which should be fine as a package compiled as an external test is a superset of its internal sibling.

Looking at how gcToolchain links tests I think this change now accurately mirrors those actions which present $WORK/_test before $WORK in the link order.

LGTM=iant
R=rsc, iant
CC=golang-codereviews, michael.hudson
https://golang.org/cl/80300043
2014-03-26 15:30:55 +11:00
Shenghou Ma
aa1391949c cmd/gc: add missing entries to lexn and yytfix.
Makes gc -x better.

LGTM=r
R=golang-codereviews, bradfitz, r
CC=golang-codereviews
https://golang.org/cl/73090043
2014-03-25 23:21:57 -04:00
Mikio Hara
4f1aecf2c4 net: deflake TestTCPConcurrentAccept
Some platform that implements inp_localgroup-like shared internet
protocol control block group looks a bit sensitive about transport
layer protocol's address:port reuse. Sometimes it rejects a TCP SYN
packet using TCP RST, and sometimes silence.

For now, until test case refactoring, we admit few Dial failures on
TestTCPConcurrentAccept as a workaround.

Update #7400
Update #7541

LGTM=jsing
R=jsing
CC=golang-codereviews
https://golang.org/cl/75920043
2014-03-25 02:56:37 +09:00
Mikio Hara
d1e3ad8bc1 net: avoid multiple calling of syscall connect on Unix variants
The previous fix CL 69340044 still leaves a possibility of it.
This CL prevents the kernel, especially DragonFly BSD, from
performing unpredictable asynchronous connection establishment
on stream-based transport layer protocol sockets.

Update #7541
Update #7474

LGTM=jsing
R=jsing
CC=golang-codereviews
https://golang.org/cl/75930043
2014-03-25 02:56:10 +09:00
Mikio Hara
4ffa021965 runtime: slience warning on 32-bit platforms
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/80250043
2014-03-26 10:21:22 +09:00
Alex Brainman
a837347dd9 runtime: use VEH for windows/amd64 exception handling
Fixes windows/amd64 build.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/79470046
2014-03-26 11:13:50 +11:00
Brad Fitzpatrick
aa2d4dee60 net/http: disable recently-introduced flaky test on Windows
Disable it until it's debugged so it doesn't hide other real
problems on Windows. The test was known to be unreliable
anyway (which is why it only needed 1 of 20 runs to pass), but
apparently it never passes on Windows. Figure out why later.

Update #7634

LGTM=alex.brainman
R=adg, alex.brainman
CC=golang-codereviews
https://golang.org/cl/80110043
2014-03-25 15:19:58 -07:00
Keith Randall
fff63c2448 runtime: WriteHeapDump dumps the heap to a file.
See http://golang.org/s/go13heapdump for the file format.

LGTM=rsc
R=rsc, bradfitz, dvyukov, khr
CC=golang-codereviews
https://golang.org/cl/37540043
2014-03-25 15:09:49 -07:00
Ian Lance Taylor
bee3848f4e runtime: fix windows build (buggy commit in 19543:d68b79ccbfed)
TBR=rsc
CC=golang-codereviews
https://golang.org/cl/80090043
2014-03-25 14:17:00 -07:00
Keith Randall
1b45cc45e3 runtime: redo stack map entries to avoid false retention
Change two-bit stack map entries to encode:
0 = dead
1 = scalar
2 = pointer
3 = multiword

If multiword, the two-bit entry for the following word encodes:
0 = string
1 = slice
2 = iface
3 = eface

That way, during stack scanning we can check if a string
is zero length or a slice has zero capacity.  We can avoid
following the contained pointer in those cases.  It is safe
to do so because it can never be dereferenced, and it is
desirable to do so because it may cause false retention
of the following block in memory.

Slice feature turned off until issue 7564 is fixed.

Update #7549

LGTM=rsc
R=golang-codereviews, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/76380043
2014-03-25 14:11:34 -07:00
Ian Lance Taylor
4ebfa83199 runtime: accurately record whether heap memory is reserved
The existing code did not have a clear notion of whether
memory has been actually reserved.  It checked based on
whether in 32-bit mode or 64-bit mode and (on GNU/Linux) the
requested address, but it confused the requested address and
the returned address.

LGTM=rsc
R=rsc, dvyukov
CC=golang-codereviews, michael.hudson
https://golang.org/cl/79610043
2014-03-25 13:22:19 -07:00
Brad Fitzpatrick
cc2c5fc3d2 net/http: don't re-use Transport connections if we've seen an EOF
This the second part of making persistent HTTPS connections to
certain servers (notably Amazon) robust.

See the story in part 1: https://golang.org/cl/76400046/

This is the http Transport change that notes whether our
net.Conn.Read has ever seen an EOF. If it has, then we use
that as an additional signal to not re-use that connection (in
addition to the HTTP response headers)

Fixes #3514

LGTM=rsc
R=agl, rsc
CC=golang-codereviews
https://golang.org/cl/79240044
2014-03-25 10:59:09 -07:00
Brad Fitzpatrick
f61f18d694 crypto/tls: make Conn.Read return (n, io.EOF) when EOF is next in buffer
Update #3514

An io.Reader is permitted to return either (n, nil)
or (n, io.EOF) on EOF or other error.

The tls package previously always returned (n, nil) for a read
of size n if n bytes were available, not surfacing errors at
the same time.

Amazon's HTTPS frontends like to hang up on clients without
sending the appropriate HTTP headers. (In their defense,
they're allowed to hang up any time, but generally a server
hangs up after a bit of inactivity, not immediately.) In any
case, the Go HTTP client tries to re-use connections by
looking at whether the response headers say to keep the
connection open, and because the connection looks okay, under
heavy load it's possible we'll reuse it immediately, writing
the next request, just as the Transport's always-reading
goroutine returns from tls.Conn.Read and sees (0, io.EOF).

But because Amazon does send an AlertCloseNotify record before
it hangs up on us, and the tls package does its own internal
buffering (up to 1024 bytes) of pending data, we have the
AlertCloseNotify in an unread buffer when our Conn.Read (to
the HTTP Transport code) reads its final bit of data in the
HTTP response body.

This change makes that final Read return (n, io.EOF) when
an AlertCloseNotify record is buffered right after, if we'd
otherwise return (n, nil).

A dependent change in the HTTP code then notes whether a
client connection has seen an io.EOF and uses that as an
additional signal to not reuse a HTTPS connection. With both
changes, the majority of Amazon request failures go
away. Without either one, 10-20 goroutines hitting the S3 API
leads to such an error rate that empirically up to 5 retries
are needed to complete an API call.

LGTM=agl, rsc
R=agl, rsc
CC=golang-codereviews
https://golang.org/cl/76400046
2014-03-25 10:58:35 -07:00
Ian Lance Taylor
8de04c78b7 runtime: change nproc local variable to uint32
The nproc and ndone fields are uint32.  This makes the type
consistent.

LGTM=minux.ma
R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/79340044
2014-03-25 05:18:08 -07:00
Nigel Tao
50ca1a52ca database/sql: add "defer rows.Close()" to the example code.
Strictly speaking, it's not necessary in example_test.go, as the
Rows.Close docs say that "If Next returns false, the Rows are closed
automatically". However, if the for loop breaks or returns early, it's
not obvious that you'll leak unless you explicitly call Rows.Close.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews, rsc
https://golang.org/cl/79330043
2014-03-25 13:32:18 +11:00
Russ Cox
3750904a7e runtime: use VEH, not SEH, for windows/386 exception handling
Structured Exception Handling (SEH) was the first way to handle
exceptions (memory faults, divides by zero) on Windows.
The S might as well stand for "stack-based": the implementation
interprets stack addresses in a few different ways, and it gets
subtly confused by Go's management of stacks. It's also something
that requires active maintenance during cgo switches, and we've
had bugs in that maintenance in the past.

We have recently come to believe that SEH cannot work with
Go's stack usage. See http://golang.org/issue/7325 for details.

Vectored Exception Handling (VEH) is more like a Unix signal
handler: you set it once for the whole process and forget about it.

This CL drops all the SEH code and replaces it with VEH code.
Many special cases and 7 #ifdefs disappear.

VEH was introduced in Windows XP, so Go on windows/386 will
now require Windows XP or later. The previous requirement was
Windows 2000 or later. Windows 2000 immediately preceded
Windows XP, so Windows 2000 is the only affected version.
Microsoft stopped supporting Windows 2000 in 2010.
See http://golang.org/s/win2000-golang-nuts for details.

Fixes #7325.

LGTM=alex.brainman, r
R=golang-codereviews, alex.brainman, stephen.gutekanst, dave
CC=golang-codereviews, iant, r
https://golang.org/cl/74790043
2014-03-24 21:22:16 -04:00
Russ Cox
3b27343c14 time: add comment explaining rejection of years outside [0000,9999]
This has come up twice now. Redirect future questions
to the explanation in the issue tracker.

LGTM=iant, r
R=r, iant
CC=golang-codereviews
https://golang.org/cl/79550043
2014-03-24 20:34:17 -04:00
Rob Pike
a9014ba415 math/cmplx: define Pow(0, x) for problematic values of x.
Currently it's always zero, but that is inconsistent with math.Pow
and also plain wrong.
This is a proposal for how it should be defined.
Fixes #7583.

LGTM=rsc
R=golang-codereviews, iant, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/76940044
2014-03-25 11:25:20 +11:00
Rob Pike
929ee59fce regexp/syntax: document the upper limit of n in x{n}
Fixes #7252.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/77990044
2014-03-25 11:19:25 +11:00
Rob Pike
c790b029e6 regexp: document that it is linear in the input size.
Fixes #7488.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/78050043
2014-03-25 11:17:30 +11:00
Jan Ziak
833dae6d26 cmd/gc: fix spurious 'const initializer is not a constant' error
Fixes #6403

LGTM=rsc
R=iant, rsc
CC=golang-codereviews
https://golang.org/cl/72840044
2014-03-24 20:36:42 +01:00
Rui Ueyama
4ffc799295 bufio: fix bug that ReadFrom stops before EOF or error
ReadFrom should not return until it receives a non-nil error
or too many contiguous (0, nil)s from a given reader.
Currently it immediately returns if it receives one (0, nil).
Fixes #7611.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/76400048
2014-03-24 11:48:34 -07:00
Jan Ziak
a43673cf8a cmd/gc: round floats with a large negative exponent towards zero
Fixes #6902

LGTM=iant
R=iant, rsc
CC=golang-codereviews
https://golang.org/cl/78730049
2014-03-24 10:10:29 -07:00
Rui Ueyama
de1ea5de86 strings: minor cleanup
bi is a slice and not an array, so bi[:] does not make much sense.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/79280043
2014-03-23 18:58:35 -07:00
Rui Ueyama
446d90d727 unicode/utf8: minor code simplification
It's a little bit waste to check if r is not a surrogate
code point because RuneError is not a surrogate code point.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/79230043
2014-03-23 15:44:29 -07:00
Rui Ueyama
160649ff9a unicode/utf16: remove unnecessary type conversions
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/79080044
2014-03-23 15:07:26 -07:00
Rui Ueyama
fa445849d1 bufio: fix typo in test
LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/79120043
2014-03-22 17:40:17 -07:00
Rui Ueyama
ed97788af9 regexp: remove unused variables
"min" and "max" in "case '{'" clause are fresh variables.
The variables defined in the outer scope never get value
other than 0.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/78750044
2014-03-22 11:05:40 -07:00
Rui Ueyama
b89a9fff5e text/scanner: handle non-io.EOF errors
Currently Scan ignores an error returned from source if the number
of bytes source has read is 0.

Fixes #7594.

LGTM=gri
R=golang-codereviews, bradfitz, gri
CC=golang-codereviews
https://golang.org/cl/78120043
2014-03-21 17:05:57 -07:00
David du Colombier
dc008af94d cmd/ld: fix warnings on Plan 9
warning: src/cmd/ld/macho.c:595 sign-extended character constant
warning: src/cmd/ld/macho.c:595 sign-extended character constant
warning: src/cmd/ld/symtab.c:63 sign-extended character constant
warning: src/cmd/ld/symtab.c:63 sign-extended character constant

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/76580046
2014-03-21 19:26:47 +01:00
David du Colombier
f182a6eec8 runtime: skip stack growth test in short mode
LGTM=dvyukov
R=dvyukov
CC=golang-codereviews
https://golang.org/cl/78410043
2014-03-21 18:13:23 +01:00
Adam Langley
050b60a369 encoding/asn1: use GeneralizedTime for times outside the range of UTCTime.
Fixes issue #6976.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/72080044
2014-03-21 11:14:38 -04:00
Rémy Oudompheng
0285d2b96b cmd/6g, cmd/8g: skip CONVNOP nodes in bgen.
Revision 3ae4607a43ff introduced CONVNOP layers
to fix type checking issues arising from comparisons.
The added complexity made 8g run out of registers
when compiling an equality function in go.net/ipv6.

A similar issue occurred in test/sizeof.go on
amd64p32 with 6g.

Fixes #7405.

LGTM=khr
R=rsc, dave, iant, khr
CC=golang-codereviews
https://golang.org/cl/78100044
2014-03-20 22:22:37 +01:00
Rémy Oudompheng
ea7d801130 reflect: correct alignment of call arguments on amd64p32.
Changes adapted from original CL 15680044.

LGTM=iant
R=rsc, iant, dave
CC=golang-codereviews
https://golang.org/cl/76150044
2014-03-20 22:22:07 +01:00
Rémy Oudompheng
ceb346685d cmd/6g: make comment more consistent.
LGTM=dave, iant
R=iant, khr, rsc, dave
CC=golang-codereviews
https://golang.org/cl/77960044
2014-03-20 22:21:10 +01:00
Brad Fitzpatrick
ca2cb5190b crypto/tls: clarify concurrent use of Config
LGTM=r, agl
R=agl, r
CC=golang-codereviews
https://golang.org/cl/77530044
2014-03-20 08:32:06 -07:00
Rui Ueyama
a2770af447 base64: fix bug that decoder fails to detect corruption
Encoding.Decode() failed to detect trailing garbages if input contains "==" followed by garbage smaller than 3 bytes (for example, it failed to detect "x" in "AA==x"). This patch fixes the bug and adds a few tests.

LGTM=nigeltao
R=golang-codereviews, bradfitz, nigeltao
CC=golang-codereviews
https://golang.org/cl/75340044
2014-03-20 16:00:34 +11:00
Rui Ueyama
90a66fa6af base32: remove unnecessary "if" condition
This is a patch to apply the same change as CL 76610045.

LGTM=nigeltao
R=nigeltao
CC=golang-codereviews
https://golang.org/cl/77460044
2014-03-20 15:54:17 +11:00
Ian Lance Taylor
6ea340fd61 cmd/6g: remove unused stosptr variable
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/78030043
2014-03-19 17:18:25 -07:00
Keith Randall
14664050b9 cmd/6g: do small zeroings with straightline code.
Removes most uses of the REP prefix, which has a high startup cost.

LGTM=iant
R=golang-codereviews, iant, khr
CC=golang-codereviews
https://golang.org/cl/77920043
2014-03-19 15:41:34 -07:00
Rob Pike
b00d967706 fmt: make %F a synonym for %f
Rationale:
        It already is for scanning.
        It is accepted for complexes already, but doesn't work.
        It's analogous to %G and %E.
        C accepts it too, and we try to be roughly compatible.
Fixes #7518.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/77580044
2014-03-20 08:51:06 +11:00
Rui Ueyama
cc4bdf0226 strings, bytes: ReadAt should not mutate receiver
CL 77580046 caused a data race issue with tests that assumes ReadAt
does not mutate receiver. This patch partially revert CL 77580046
to fix it.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/77900043
2014-03-19 12:13:47 -07:00
Rui Ueyama
79b3daa977 unicode: minor cleanup
These test cases are redundant because TestSimpleFold tests
all possible rotations of test data, so no need to add
rotated strings.

Also updated the comment as it's guaranteed that SimpleFold
returns values in increasing order.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/77730043
2014-03-19 10:14:04 -07:00
Rui Ueyama
a509026ff0 strings, bytes: fix Reader.UnreadRune
UnreadRune should return an error if previous operation is not
ReadRune.

Fixes #7579.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/77580046
2014-03-19 09:00:58 -07:00
Dmitriy Vyukov
8a908efd74 runtime: add stack growth tests
Also move generated code into a separate file,
because it's difficult to work with the file otherwise.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews
https://golang.org/cl/76080044
2014-03-19 17:22:56 +04:00
Dmitriy Vyukov
1895014257 runtime: fix stack split detection around fork
If runtime_BeforeFork splits stack, it will unsplit it
with spoiled g->stackguard. It leads to check failure in oldstack:

fatal error: stackfree: bad fixed size

runtime stack:
runtime.throw(0xadf3cd)
runtime.stackfree(0xc208040480, 0xfffffffffffff9dd, 0x1b00fa8)
runtime.oldstack()
runtime.lessstack()

goroutine 311 [stack unsplit]:
syscall.forkAndExecInChild(0xc20802eea0, 0xc208192c00, 0x5, 0x5, 0xc208072a80, ...)
syscall.forkExec(0xc20802ed80, 0x54, 0xc2081ccb40, 0x4, 0x4, ...)

Fixes #7567.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, khr, rsc
https://golang.org/cl/77340045
2014-03-19 17:04:51 +04:00
Jan Ziak
cb50277510 cmd/gc: check exponent overflow and underflow in mparith
A too large float constant is an error.
A too small float constant is rounded to zero.

Fixes #7419
Update #6902

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/76730046
2014-03-19 05:48:00 +01:00
Rui Ueyama
1a21dbc572 bytes: fix panic in Map
utf8.RuneLen returns -1 for an invalid rune. In that case we
need to extend the internal buffer at least by 3 for \uFFFD.

Fixes #7577.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/77420044
2014-03-18 20:52:58 -07:00
Rob Pike
f34251a91c strconv: CanBackquote should reject \x7F
It's a control character.
Fixes #7565.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/77300043
2014-03-19 10:16:48 +11:00
Jan Ziak
f081e2b9f4 cmd/go: let build -x output describe CGO_LDFLAGS env variable
Fixes #7249

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/75820046
2014-03-18 21:47:21 +01:00
Brad Fitzpatrick
666f5b4a89 expvar: don't recursively acquire Map.RLock
Fixes #7575

LGTM=iant
R=dvyukov, iant
CC=golang-codereviews
https://golang.org/cl/77540044
2014-03-18 11:38:39 -07:00
Mikio Hara
d7039b71a9 net/http: make use of testing.Errorf instead of testing.Fatalf in non-test function goroutines
See testing.FailNow for further information.
Also avoid nil pointer derefernce in TestTransportMaxPerHostIdleConns.

LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/76470043
2014-03-18 21:12:00 +09:00
Rui Ueyama
41818f8fcc base64: refactor encoder.Write
"nn" can never be zero for any input "p", so no check is needed.
This change should improve readability a bit.

LGTM=nigeltao
R=golang-codereviews, bradfitz, nigeltao
CC=golang-codereviews
https://golang.org/cl/76610045
2014-03-18 16:26:23 +11:00
Rob Pike
108a4dcd75 cmd/go: make the default coverage mode -atomic if -race is set
Fixes #7013.

LGTM=adg
R=golang-codereviews, gobot, adg
CC=golang-codereviews
https://golang.org/cl/76370043
2014-03-18 14:38:40 +11:00
Rob Pike
0de0de0907 fmt: document GoStringer and explain application of formats to compound objects
%q quotes each element of a string slice; this was never explained in the docs.
Fixes #7015.

LGTM=josharian
R=golang-codereviews, josharian
CC=golang-codereviews
https://golang.org/cl/77140044
2014-03-18 11:25:04 +11:00
Luka Zakrajšek
2701dadbac net/http: Request Body error should not be ignored.
Fixes #7521.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/76320043
2014-03-17 15:52:52 -07:00
Catalin Patulea
a387f91553 net/http/fcgi: fix handling of request ID reuse
Request ID reuse is allowed by the FastCGI spec [1]. In particular nginx uses
the same request ID, 1, for all requests on a given connection. Because
serveRequest does not remove the request from conn.requests, this causes it to
treat the second request as a duplicate and drops the connection immediately
after beginRequest. This manifests with nginx option 'fastcgi_keep_conn on' as
the following message in nginx error log:

2014/03/17 01:39:13 [error] 730#0: *109 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: x.x.x.x, server: example.org, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "example.org"

Because handleRecord and serveRequest run in different goroutines, access to
conn.requests must now be synchronized.

[1] http://www.fastcgi.com/drupal/node/6?q=node/22#S3.3

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/76800043
2014-03-17 15:47:16 -07:00
Rui Ueyama
01d49dc2dd encoding/hex: add error check for write error.
I believe the original author of this code just forgot to check for error here.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/76760043
2014-03-17 12:07:30 -07:00
Ian Lance Taylor
e3609ca672 cmd/gc: fix comment about how GOEXPERIMENT works
LGTM=minux.ma
R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/76270043
2014-03-15 11:18:11 -07:00
Mikio Hara
f0433e422b net: make use of testing.Errorf instead of testing.Fatalf in non-test function goroutines
See testing.FailNow for further information.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/75900043
2014-03-15 13:43:02 +09:00
Rémy Oudompheng
6436df0d81 runtime: fix 386 assembly for syscall.naclWrite
It was using the wrong offset and returned random values
making "runoutput" compiler tests crash.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/76250043
2014-03-14 22:49:46 +01:00
Rémy Oudompheng
88f84b3e41 liblink, runtime: make nacl/386 binaries valid.
They were rejected by NaCl due to AES instructions and
accesses to %gs:0x8, caused by wrong tlsoffset value.

LGTM=iant
R=rsc, dave, iant
CC=golang-codereviews
https://golang.org/cl/76050044
2014-03-14 21:33:55 +01:00
Dmitriy Vyukov
fed5428c4a runtime: fix another race in bgsweep
It's possible that bgsweep constantly does not catch up for some reason,
in this case runfinq was not woken at all.

R=rsc
CC=golang-codereviews
https://golang.org/cl/75940043
2014-03-14 23:32:12 +04:00
Dmitriy Vyukov
8d321625fd runtime: fix spans corruption
The problem was that spans end up in wrong lists after split
(e.g. in h->busy instead of h->central->empty).
Also the span can be non-swept before split,
I don't know what it can cause, but it's safer to operate on swept spans.
Fixes #7544.

R=golang-codereviews, rsc
CC=golang-codereviews, khr
https://golang.org/cl/76160043
2014-03-14 23:25:48 +04:00
Rémy Oudompheng
f210fd1fa9 cmd/6g, runtime: alignment fixes for amd64p32.
LGTM=rsc
R=rsc, dave, iant, khr
CC=golang-codereviews
https://golang.org/cl/75820044
2014-03-14 19:37:39 +01:00
Dmitriy Vyukov
d8e6881166 runtime: report "out of memory" in efence mode
Currently processes crash with obscure message.
Say that it's "out of memory".

LGTM=rsc
R=golang-codereviews
CC=golang-codereviews, khr, rsc
https://golang.org/cl/75820045
2014-03-14 21:22:03 +04:00
Dmitriy Vyukov
0da73b9f07 runtime: fix a race in bgsweep
See the comment for description.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/75670044
2014-03-14 21:21:44 +04:00
Dmitriy Vyukov
b8d40172ce runtime: do not shrink stacks GOCOPYSTACK=0
LGTM=rsc
R=golang-codereviews
CC=golang-codereviews, khr, rsc
https://golang.org/cl/76070043
2014-03-14 21:11:04 +04:00
Jan Ziak
22aa54965e cmd/go: fix invalid go pack command line in the output of go build -x
Fixes #7262

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/76110043
2014-03-14 16:44:54 +01:00
Jan Ziak
1483747f3c cmd/gc: fix spurious 'not enough arguments to return' error
Fixes #6405

LGTM=rsc
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/72920046
2014-03-14 16:42:42 +01:00
Shenghou Ma
cbe777b2c7 cmd/gc: replace '·' as '.' in ELF/Mach-O symbol tables
Old versions of DTrace (as those shipped in OS X and FreeBSD)
don't support unicode characters in symbol names.  Replace '·'
to '.' to make DTrace happy.

Fixes #7493

LGTM=aram, rsc
R=aram, rsc, gobot, iant
CC=golang-codereviews
https://golang.org/cl/72280043
2014-03-14 10:07:51 -04:00
Aram Hăvărneanu
199e703083 runtime: fix use after close race in Solaris network poller
The Solaris network poller uses event ports, which are
level-triggered. As such, it has to re-arm itself after each
wakeup. The arming mechanism (which runs in its own thread) raced
with the closing of a file descriptor happening in a different
thread. When a network file descriptor is about to be closed,
the network poller is awaken to give it a chance to remove its
association with the file descriptor. Because the poller always
re-armed itself, it raced with code that closed the descriptor.

This change makes the network poller check before re-arming if
the file descriptor is about to be closed, in which case it will
ignore the re-arming request. It uses the per-PollDesc lock in
order to serialize access to the PollDesc.

This change also adds extensive documentation describing the
Solaris implementation of the network poller.

Fixes #7410.

LGTM=dvyukov, iant
R=golang-codereviews, bradfitz, iant, dvyukov, aram.h, gobot
CC=golang-codereviews
https://golang.org/cl/69190044
2014-03-14 17:53:05 +04:00
Keith Randall
4c6d2d6aa8 debug/macho: handle missing __debug_str section
debug/elf does the same thing, use []byte{} for
any missing sections.

Fixes #7510

LGTM=rsc
R=golang-codereviews, iant
CC=golang-codereviews, rsc
https://golang.org/cl/75230043
2014-03-13 14:04:29 -07:00
Anthony Martin
41aa887be5 runtime: fix signal handling on Plan 9
LGTM=rsc
R=rsc, 0intro, aram, jeremyjackins, iant
CC=golang-codereviews, lucio.dere, minux.ma, paurea, r
https://golang.org/cl/9796043
2014-03-13 09:00:12 -07:00
Dmitriy Vyukov
c115cda22c runtime: improve efence
Mark free memory blocks as unused.
On amd64 it allows the process to eat all 128 GB of heap
without killing the machine.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/74070043
2014-03-13 19:04:00 +04:00
Dmitriy Vyukov
e678ab4e37 runtime: detect stack split after fork
This check would allowed to easily prevent issue 7511.
Update #7511

LGTM=rsc
R=rsc, aram
CC=golang-codereviews
https://golang.org/cl/75260043
2014-03-13 17:41:08 +04:00
Dmitriy Vyukov
1569628725 runtime: harden conditions when runtime panics on crash
This is especially important for SetPanicOnCrash,
but also useful for e.g. nil deref in mallocgc.
Panics on such crashes can't lead to anything useful,
only to deadlocks, hangs and obscure crashes.
This is a copy of broken but already LGTMed
https://golang.org/cl/68540043/

TBR=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/75320043
2014-03-13 13:25:59 +04:00
Dmitriy Vyukov
5daffee17f runtime: fix stack size check
When we copy stack, we check only new size of the top segment.
This is incorrect, because we can have other segments below it.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, rsc
https://golang.org/cl/73980045
2014-03-13 13:16:02 +04:00
Aram Hăvărneanu
28792f5d83 runtime: avoid runtime·cgocall in functions called by forkAndExecInChild
Calling runtime·cgocall could trigger a GC in the child while
gclock was held by the parent.

Fixes #7511

LGTM=bradfitz, dvyukov, dave
R=golang-codereviews, bradfitz, dvyukov, dave
CC=golang-codereviews, rsc
https://golang.org/cl/75210044
2014-03-13 18:26:01 +11:00
Rémy Oudompheng
fcc10bc0f1 cmd/gc: fix spurious type errors in walkselect.
The lowering to runtime calls introduces hidden pointers to the
arguments of select clauses. When implicit conversions were
involved it could end up with incompatible pointers. Since the
pointed-to types have the same representation, we can introduce a
forced conversion.

Fixes #6847.

LGTM=rsc
R=rsc, iant, khr
CC=golang-codereviews
https://golang.org/cl/72380043
2014-03-13 08:14:05 +01:00
Rémy Oudompheng
741244e433 cmd/6g: fix stack zeroing preamble on amd64p32.
It was using a REP STOSQ but putting in CX the number of 32-bit
words to clear.

LGTM=dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/75240043
2014-03-13 08:12:38 +01:00
Mikio Hara
6a6224c88d net: fix TCP keepalive on dragonfly
Fixes #7528.

LGTM=jsing
R=jsing
CC=golang-codereviews
https://golang.org/cl/75140045
2014-03-13 14:45:50 +09:00
Michael Hudson-Doyle
12474d01c4 cmd/go: use correct libraries during gccgo link
Under some circumstances, gccgoToolchain's ld can pass the path of
build outputs that have been deleted to the link command.

Fixes #7303.

LGTM=rsc
R=golang-codereviews, dave, michael.hudson, rsc
CC=golang-codereviews
https://golang.org/cl/61970044
2014-03-12 23:05:54 -04:00
Anthony Martin
64e041652a runtime: call symtabinit earlier
Otherwise, we won't get a stack trace in some of the early init.

Here's one example:

        http://build.golang.org/log/a96d10f6aee1fa3e3ae51f41da46d414a7ab02de

After walking the stack by hand in acid, I was able to determine
that the stackalloc inside mpreinit was causing the throw.

LGTM=rsc
R=rsc, dvyukov
CC=golang-codereviews
https://golang.org/cl/72450044
2014-03-12 19:42:58 -07:00
Anthony Martin
b53d2f5ba7 cmd/gc: make the fpu handle all exceptions on Plan 9
The compilers expect to not be interrupted by floating
point exceptions. On Plan 9, every process starts with
interrupts enabled for invalid operation, stack overflow,
and divide by zero exceptions.

LGTM=rsc
R=rsc, 0intro
CC=golang-codereviews
https://golang.org/cl/72750043
2014-03-12 19:41:36 -07:00
Anthony Martin
189397df58 os: relax the way we kill processes on Plan 9
Previously, we wrote "kill" to the process control file
to kill a program. This is problematic because it doesn't
let the program gracefully exit.

This matters especially if the process we're killing is a
Go program. On Unix, sending SIGKILL to a Go program will
automatically kill all runtime threads. On Plan 9, there
are no threads so when the program wants to exit it has to
somehow signal all of the runtime processes. It can't do
this if we mercilessly kill it by writing to it's control
file.

Instead, we now send it a note to invoke it's note handler
and let it perform any cleanup before exiting.

LGTM=rsc
R=rsc, 0intro
CC=golang-codereviews
https://golang.org/cl/74440044
2014-03-12 18:12:56 -07:00
Anthony Martin
8303a13bb8 runtime: use unoptimized memmove and memclr on Plan 9
On Plan 9, the kernel disallows the use of floating point
instructions while handling a note. Previously, we worked
around this by using a simple loop in place of memmove.

When I added that work-around, I verified that all paths
from the note handler didn't end up calling memmove. Now
that memclr is using SSE instructions, the same process
will have to be done again.

Instead of doing that, however, this CL just punts and
uses unoptimized functions everywhere on Plan 9.

LGTM=rsc
R=rsc, 0intro
CC=golang-codereviews
https://golang.org/cl/73830044
2014-03-12 18:12:25 -07:00
Anthony Martin
b67979320a cmd/ld: give acid a fighting chance at unwinding the stack
Acid can't produce a stack trace without .frame symbols.

Of course, it can only unwind through linear stacks but
this is still better than nothing. (I wrote an acid func
to do the full unwind a long time ago but lost it and
haven't worked up the courage to write it again).

Note that these will only be present in the native symbol
table for Plan 9 binaries.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/72450045
2014-03-12 18:10:31 -07:00
Dave Cheney
f2037e1533 runtime: fix missing nacl/386 symbol
syscall.naclWrite was missing from sys_nacl_386.s

This gets ./make.bash passing, but doesn't pass validation. I'm not sure if this is the fault of this change, or validation was broken anyway.

LGTM=rsc
R=minux.ma, rsc
CC=golang-codereviews
https://golang.org/cl/74510043
2014-03-13 07:58:42 +11:00
Rob Pike
78992439f4 fmt: improve documentation for width and precision
Fixes #7048.

LGTM=dominik.honnef
R=golang-codereviews, dominik.honnef
CC=golang-codereviews
https://golang.org/cl/74280044
2014-03-12 22:00:48 +11:00
Dmitriy Vyukov
1f4d2e79b0 runtime: efence support for growable stacks
1. Fix the bug that shrinkstack returns memory to heap.
   This causes growslice to misbehave (it manually initialized
   blocks, and in efence mode shrinkstack's free leads to
   partially-initialized blocks coming out of growslice.
   Which in turn causes GC to crash while treating the garbage
   as Eface/Iface.
2. Enable efence for stack segments.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews, khr
https://golang.org/cl/74080043
2014-03-12 10:21:34 +04:00
Dmitriy Vyukov
00e6fc1e9e runtime: temporary weaken a check in test
Currently the test fails as:
$ go test -v -cpu 1,1,1,1 runtime -test.run=TestStack
stack_test.go:1584: Stack inuse: want 4194304, got 18446744073709547520

Update #7468

LGTM=rsc
R=golang-codereviews, bradfitz
CC=golang-codereviews, khr, rsc
https://golang.org/cl/74010043
2014-03-12 10:20:58 +04:00
Jan Ziak
b87c7729ba cmd/go: respect system CGO_CFLAGS and CGO_CXXFLAGS
Fixes #6882

LGTM=iant
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/72080043
2014-03-12 07:16:22 +01:00
Brad Fitzpatrick
d53251d4ab net/http/cgi: serve 500, not 200, on invalid responses from child processes
Per RFC 3875 section 6 rules.

Fixes #7198

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/68960049
2014-03-11 22:55:15 -07:00
Russ Cox
54c901cd08 runtime: fix empty string handling in garbage collector
The garbage collector uses type information to guide the
traversal of the heap. If it sees a field that should be a string,
it marks the object pointed at by the string data pointer as
visited but does not bother to look at the data, because
strings contain bytes, not pointers.

If you save s[len(s):] somewhere, though, the string data pointer
actually points just beyond the string data; if the string data
were exactly the size of an allocated block, the string data
pointer would actually point at the next block. It is incorrect
to mark that next block as visited and not bother to look at
the data, because the next block may be some other type
entirely.

The fix is to ignore strings with zero length during collection:
they are empty and can never become non-empty: the base
pointer will never be used again. The handling of slices already
does this (but using cap instead of len).

This was not a bug in Go 1.2, because until January all string
allocations included a trailing NUL byte not included in the
length, so s[len(s):] still pointed inside the string allocation
(at the NUL).

This bug was causing the crashes in test/run.go. Specifically,
the parsing of a regexp in package regexp/syntax allocated a
[]syntax.Inst with rounded size 1152 bytes. In fact it
allocated many such slices, because during the processing of
test/index2.go it creates thousands of regexps that are all
approximately the same complexity. That takes a long time, and
test/run works on other tests in other goroutines. One such
other test is chan/perm.go, which uses an 1152-byte source
file. test/run reads that file into a []byte and then calls
strings.Split(string(src), "\n"). The string(src) creates an
1152-byte string - and there's a very good chance of it
landing next to one of the many many regexp slices already
allocated - and then because the file ends in a \n,
strings.Split records the tail empty string as the final
element in the slice. A garbage collection happens at this
point, the collection finds that string before encountering
the []syntax.Inst data it now inadvertently points to, and the
[]syntax.Inst data is not scanned for the pointers that it
contains. Each syntax.Inst contains a []rune, those are
missed, and the backing rune arrays are freed for reuse. When
the regexp is later executed, the runes being searched for are
no longer runes at all, and there is no match, even on text
that should match.

On 64-bit machines the pointer in the []rune inside the
syntax.Inst is larger (along with a few other pointers),
pushing the []syntax.Inst backing array into a larger size
class, avoiding the collision with chan/perm.go's
inadvertently sized file.

I expect this was more prevalent on OS X than on Linux or
Windows because those managed to run faster or slower and
didn't overlap index2.go with chan/perm.go as often. On the
ARM systems, we only run one errorcheck test at a time, so
index2 and chan/perm would never overlap.

It is possible that this bug is the root cause of other crashes
as well. For now we only know it is the cause of the test/run crash.

Many thanks to Dmitriy for help debugging.

Fixes #7344.
Fixes #7455.

LGTM=r, dvyukov, dave, iant
R=golang-codereviews, dave, r, dvyukov, delpontej, iant
CC=golang-codereviews, khr
https://golang.org/cl/74250043
2014-03-11 23:58:39 -04:00
Russ Cox
ab844022ee cmd/gc: fix crash in -live mode
debuglive >= 1 is not the condition under which we
start recording messages (we avoid printing for
init functions even if debuglive is set).

LGTM=bradfitz, iant
R=golang-codereviews, bradfitz
CC=golang-codereviews, iant, khr
https://golang.org/cl/74390043
2014-03-11 23:58:11 -04:00
Dhiru Kholia
5b5c8f0576 dwarf: add extensions for multi-file compression (.dwz)
LGTM=iant
R=golang-codereviews, iant, bradfitz
CC=golang-codereviews, math-nuts
https://golang.org/cl/72820044
2014-03-11 18:49:50 -07:00
Mikio Hara
ae9b661fa8 runtime: make use of THREAD_SHARE userspace mutex on freebsd
For now Note, futexsleep and futexwakeup are designed for threads,
not for processes. The explicit use of UMTX_OP_WAIT_UINT_PRIVATE and
UMTX_OP_WAKE_PRIVATE can avoid unnecessary traversals of VM objects,
to hit undiscovered bugs related to VM system on SMP/SMT/NUMA
environment.

Update #7496

LGTM=iant
R=golang-codereviews, gobot, iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/72760043
2014-03-12 10:33:09 +09:00
Mikio Hara
ef6c21d0e9 syscall, net: clean up socket stub for solaris
Solaris doesn't have struct ip_mreqn, instead it uses struct ip_mreq
and struct group_req with struct sockaddr_storage.

Also fixes incorrect SockaddrDatalink.

Update #7399

LGTM=aram, iant
R=golang-codereviews, aram, gobot, iant
CC=golang-codereviews
https://golang.org/cl/73920043
2014-03-12 10:32:46 +09:00
Dave Cheney
42da29f474 runtime: disable Native Client fake time support
This CL is a reformulation of CL 73110043 containing only the minimum required to get the nacl builds compiling.

LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/74220043
2014-03-12 08:55:30 +11:00
Kay Zhu
07dc50b8f1 path/filepath: fixed misaligned comment.
The comment for 'Clean' function is prepended with spaces instead of
a single tab, resulting in visually misaligned comment in the generated
documentation.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/73840043
2014-03-11 14:34:07 -07:00
Dave Cheney
053127b12f runtime: fix nacl/amd64p32 signal handling
The change to signal_amd64.c from CL 15790043 was not merged correctly.

This CL reapplies the change, renaming the file to signal_amd64x.c and adds the appropriate build tags.

LGTM=iant, bradfitz
R=rsc, iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/72790043
2014-03-12 07:21:55 +11:00
Josh Bleecher Snyder
4e5f31a760 liblink: fix bad code generated for MOVFD/MOVDF when reg > 7
The byte that r is or'd into is already 0x7, so the failure to zero r only
impacts the generated machine code if the register is > 7.

Fixes #7044.

LGTM=dave, minux.ma, rsc
R=dave, minux.ma, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/73730043
2014-03-11 14:04:44 -04:00
Shenghou Ma
da291de5a2 crypto/rsa: fix docs for PrecomputedValues.Qinv
Fixes #7507.

LGTM=agl
R=agl
CC=golang-codereviews
https://golang.org/cl/74090043
2014-03-11 13:06:01 -04:00
Dmitriy Vyukov
3877f1d9c8 runtime: remove atomic CAS loop from marknogc
Spans are now private to threads, and the loop
is removed from all other functions.
Remove it from marknogc for consistency.

LGTM=khr, rsc
R=golang-codereviews, bradfitz, khr
CC=golang-codereviews, khr, rsc
https://golang.org/cl/72520043
2014-03-11 17:35:49 +04:00
Dmitriy Vyukov
38f6c3f59d runtime: wipe out bitSpecial from GC code
LGTM=khr, rsc
R=golang-codereviews, bradfitz, khr
CC=golang-codereviews, khr, rsc
https://golang.org/cl/72480044
2014-03-11 17:33:03 +04:00
Alex Brainman
c07ca77432 syscall: replace mksyscall_windows.pl with mksyscall_windows.go
Not many windows users have perl installed. They can just use
standard go tools instead. Also mkerrors_windows.sh script
removed - we don't add any new "unix" errors to windows
syscall package anymore.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/41060044
2014-03-11 16:36:14 +11:00
Dave Cheney
6431be3fe4 runtime: more Native Client fixes
Thanks to Ian for spotting these.

runtime.h: define uintreg correctly.
stack.c: address warning caused by the type of uintreg being 32 bits on amd64p32.

Commentary (mainly for my own use)

nacl/amd64p32 defines a machine with 64bit registers, but address space is limited to a 4gb window (the window is placed randomly inside the full 48 bit virtual address space of a process). To cope with this 6c defines _64BIT and _64BITREG.

_64BITREG is always defined by 6c, so both GOARCH=amd64 and GOARCH=amd64p32 use 64bit wide registers.

However _64BIT itself is only defined when 6c is compiling for amd64 targets. The definition is elided for amd64p32 environments causing int, uint and other arch specific types to revert to their 32bit definitions.

LGTM=iant
R=iant, rsc, remyoudompheng
CC=golang-codereviews
https://golang.org/cl/72860046
2014-03-11 14:43:10 +11:00
Alan Donovan
cf57cf17e7 net/http: eliminate defined-but-not-used var.
gc does not report this as an error, but go/types does.
(I suspect that constructing a closure counts as a reference
to &all in gc's implementation).

This is not a tool bug, since the spec doesn't require
implementations to implement this check, but it does
illustrate that dialect variations are always a nuisance.

LGTM=rsc, bradfitz
R=bradfitz
CC=golang-codereviews, gri, rsc
https://golang.org/cl/73850043
2014-03-10 22:22:51 -04:00
Keith Randall
1306279cd1 runtime: remove unused declarations.
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/73720044
2014-03-10 16:02:46 -07:00
Dave Cheney
9ab4d1d6b3 runtime: small Native Client fixes
mem_nacl.c: add SysFault
env_posix.c: add nacl to build tag, from CL 15790043

LGTM=remyoudompheng, iant
R=rsc, remyoudompheng, iant
CC=golang-codereviews
https://golang.org/cl/72780043
2014-03-11 06:57:46 +11:00
Adam Langley
4ca6e588e4 time: handle int64 overflow in ParseDuration.
Previously, passing a long duration to ParseDuration could result in
random, even negative, values.

LGTM=r
R=golang-codereviews, bradfitz, r
CC=golang-codereviews
https://golang.org/cl/72120043
2014-03-10 12:33:45 -04:00
Rémy Oudompheng
4bc632cead runtime: fix cgocallback stack size on amd64p32.
LGTM=dave
R=rsc, dave, iant
CC=golang-codereviews
https://golang.org/cl/73160043
2014-03-10 07:57:58 +01:00
Mikio Hara
4888781f24 runtime: fix flakiness on futexsleep test
Fixes #7496.

LGTM=jsing
R=golang-codereviews, jsing
CC=golang-codereviews
https://golang.org/cl/72840043
2014-03-10 12:20:16 +09:00
Dave Cheney
4c75cab678 syscall: add missing SO_ERROR constant for nacl/*
CL 69340044 requires that syscall.SO_ERROR be defined on all unix like platforms. Add SO_ERROR to the list of dummy constants in sycall/net_nacl.go.

LGTM=bradfitz
R=iant, rsc, mikioh.mikioh, bradfitz
CC=golang-codereviews
https://golang.org/cl/73100043
2014-03-09 13:18:12 +11:00
Brad Fitzpatrick
7718c62692 net/rpc/jsonrpc: set exactly one of result or error to non-null in response
Fixes #7442

LGTM=gri
R=golang-codereviews, gri
CC=golang-codereviews
https://golang.org/cl/72570044
2014-03-07 16:59:11 -08:00
Brad Fitzpatrick
a35b9e4960 os: document that Process.Wait only works on child processes
Fixes #7072

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/71900045
2014-03-07 14:44:31 -08:00
Mikio Hara
a594f7ddd7 runtime: fix futexsleep test on freebsd/386
Fixes #7194.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/72310043
2014-03-08 07:34:40 +09:00
Rémy Oudompheng
e09ac3cf2a cmd/gc: correct GOARCH in object files for amd64p32.
LGTM=dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/72260045
2014-03-07 23:18:07 +01:00
Rémy Oudompheng
849ee73f67 runtime: add missing nacl build tag for lock_sema.c
LGTM=dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/72240045
2014-03-07 23:17:44 +01:00
Russ Cox
e721778f3e sync: give finalizers more time in TestPoolGC
If we report a leak, make sure we've waited long enough to be sure.
The new sleep regimen waits 1.05 seconds before failing; the old
one waited 0.005 seconds.

(The single linux/amd64 failure in this test feels more like a
timing problem than a leak. I don't want to spend time on it unless
we're sure.)

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/72630043
2014-03-07 16:08:12 -05:00
Dave Cheney
3d869c6e0c crypto/md5, crypto/sha1: exclude amd64p32 from generic implementations.
We provide amd64p32 implementations for md5 and sha1 so we need to exclude amd64p32 from the generic implementations in those packages.

Fixes build once CL 72360044 lands.

LGTM=agl, remyoudompheng
R=rsc, bradfitz, agl, remyoudompheng
CC=golang-codereviews
https://golang.org/cl/72460043
2014-03-08 07:54:41 +11:00
David Covert
76236ef136 regexp: add one-pass optimization from RE2
This produces about a 2.3x speedup for patterns
that can be handled this way.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/13345046
2014-03-07 15:30:02 -05:00
Shenghou Ma
84570aa9a1 runtime: round stack size to power of 2.
Fixes build on windows/386 and plan9/386.
Fixes #7487.

LGTM=mattn.jp, dvyukov, rsc
R=golang-codereviews, mattn.jp, dvyukov, 0intro, rsc
CC=golang-codereviews
https://golang.org/cl/72360043
2014-03-07 15:11:16 -05:00
Rémy Oudompheng
3d5e219e02 cmd/gc: enforce register-width alignment for stack sizes.
This fixes the following amd64p32 issue:
    pkg/time/format.go:724: internal compiler error: twobitwalktype1: invalid initial alignment, Time

caused by the pointer zone ending on a 32-bit-aligned boundary.

LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/72270046
2014-03-07 20:28:18 +01:00
Russ Cox
b2fa6f41a4 runtime: comment out breakpoint in windows/386 sighandler
This code being buggy is the only explanation I can come up
with for issue 7325. It's probably not, but the only alternative
is a Windows kernel bug. Comment this out to see what breaks
or gets fixed.

Update #7325

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/72590044
2014-03-07 14:22:17 -05:00
Russ Cox
02903f8395 runtime: fix windows/386 build
From the trace it appears that stackalloc is being
called with 0x1800 which is 6k = 4k + (StackSystem=2k).
Make StackSystem 4k too, to make stackalloc happy.
It's already 4k on windows/amd64.

TBR=khr
CC=golang-codereviews
https://golang.org/cl/72600043
2014-03-07 14:19:05 -05:00
Rémy Oudompheng
9460cf7825 liblink: fix morestack handling on amd64p32.
It was using MOVL to pass a 64-bit argument
(concatenated framesize and argsize) to morestack11.

LGTM=dave, rsc
R=dave, rsc, iant
CC=golang-codereviews
https://golang.org/cl/72360044
2014-03-07 19:44:35 +01:00
Dmitriy Vyukov
1a89e6388c runtime: refactor and fix stack management code
There are at least 3 bugs:
1. g->stacksize accounting is broken during copystack/shrinkstack
2. stktop->free is not properly maintained during copystack/shrinkstack
3. stktop->free logic is broken:
        we can have stktop->free==FixedStack,
        and we will free it into stack cache,
        but it actually comes from heap as the result of non-copying segment shrink
This shows as at least spurious races on race builders (maybe something else as well I don't know).

The idea behind the refactoring is to consolidate stacksize and
segment origin logic in stackalloc/stackfree.

Fixes #7490.

LGTM=rsc, khr
R=golang-codereviews, rsc, khr
CC=golang-codereviews
https://golang.org/cl/72440043
2014-03-07 20:52:29 +04:00
Dmitriy Vyukov
f946a7ca09 runtime: fix memory corruption and leak in recursive panic handling
Recursive panics leave dangling Panic structs in g->panic stack.
At best it leads to a Defer leak and incorrect output on a subsequent panic.
At worst it arbitrary corrupts heap.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/72480043
2014-03-07 20:50:30 +04:00
Russ Cox
b08156cd87 runtime: fix memory leak in runfinq
One reason the sync.Pool finalizer test can fail is that
this function's ef1 contains uninitialized data that just
happens to point at some of the old pool. I've seen this cause
retention of a single pool cache line (32 elements) on arm.

Really we need liveness information for C functions, but
for now we can be more careful about data in long-lived
C functions that block.

LGTM=bradfitz, dvyukov
R=golang-codereviews, bradfitz, dvyukov
CC=golang-codereviews, iant, khr
https://golang.org/cl/72490043
2014-03-07 11:27:01 -05:00
Dave Cheney
e509bbc943 cmd/6a: add support for nacl/amd64p32
Replaces CL 70000043.

Switch to the amd64p32 linker model if we are building under nacl/amd64p32.

No need to introduce linkarchinit() as 6a contains its own main() function.

LGTM=rsc
R=rsc, minux.ma
CC=golang-codereviews
https://golang.org/cl/72020043
2014-03-07 16:02:25 +11:00
Dave Cheney
e31a1ce109 cmd/gc, cmd/5g, cmd/6g, cmd/8g: introduce linkarchinit and add amd64p32 support
Replaces CL 70000043.

Introduce linkarchinit() from cmd/ld.

For cmd/6g, switch to the amd64p32 linker model if we are building under nacl/amd64p32.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/71330045
2014-03-07 15:33:44 +11:00
Rob Pike
22c668a810 encoding/gob: document that Decode returns EOF at EOF
Just commentary describing existing behavior, no code changes.

Fixes #7033.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/71860043
2014-03-07 13:24:14 +11:00
Rob Pike
c0d4576593 strconv: document value returned by ParseInt when there is an error
Documenting existing behavior; new commentary only.
Fixes #7105.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/68840044
2014-03-07 13:23:50 +11:00
Keith Randall
f4359afa7f runtime: shrink bigger stacks without any copying.
Instead, split the underlying storage in half and
free just half of it.

Shrinking without copying lets us reclaim storage used
by a previously profligate Go routine that has now blocked
inside some C code.

To shrink in place, we need all stacks to be a power of 2 in size.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/69580044
2014-03-06 16:03:43 -08:00
Russ Cox
9abcd53eda cmd/go: add test case for cgo coverage
This is a test case for CL 34680044.

Fixes #6333.

LGTM=bradfitz
R=golang-codereviews, bradfitz, minux.ma
CC=golang-codereviews
https://golang.org/cl/71230049
2014-03-06 18:36:32 -05:00
Russ Cox
da1bea0ef0 runtime: fix malloc page alignment + efence
Two memory allocator bug fixes.

- efence is not maintaining the proper heap metadata
  to make eventual memory reuse safe, so use SysFault.

- now that our heap PageSize is 8k but most hardware
  uses 4k pages, SysAlloc and SysReserve results must be
  explicitly aligned. Do that in a few more call sites and
  document this fact in malloc.h.

Fixes #7448.

LGTM=iant
R=golang-codereviews, josharian, iant
CC=dvyukov, golang-codereviews
https://golang.org/cl/71750048
2014-03-06 18:34:29 -05:00
Dave Cheney
1d2b7171d5 cmd/5c: fix arm build
cmd/5c/txt.c was missing from CL 72010043.

LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/72220043
2014-03-07 10:13:00 +11:00
Dave Cheney
d4896fb876 cmd/cc, cmd/5c, cmd/6c, cmd/8c: introduce linkarchinit and add amd64p32 support
Replaces CL 70000043.

Introduce linkarchinit() from cmd/ld.

For cmd/6c, switch to the amd64p32 linker model if we are building under nacl/amd64p32.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/72010043
2014-03-07 09:55:59 +11:00
Dmitriy Vyukov
2fb87ddb59 runtime: print goroutine header on fault
I've just needed the G status on fault to debug runtime bug.
For some reason we print everything except header here.
Make it more informative and consistent.

R=rsc
CC=golang-codereviews
https://golang.org/cl/67870056
2014-03-07 00:01:24 +04:00
David du Colombier
fb5e1e1fa1 runtime: fix warnings on Plan 9
warning: pkg/runtime/mgc0.c:2352 format mismatch p UVLONG, arg 2
warning: pkg/runtime/mgc0.c:2352 format mismatch p UVLONG, arg 3

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/71950044
2014-03-06 20:56:22 +01:00
Dmitriy Vyukov
a1695d2ea3 runtime: use custom thunks for race calls instead of cgo
Implement custom assembly thunks for hot race calls (memory accesses and function entry/exit).
The thunks extract caller pc, verify that the address is in heap or global and switch to g0 stack.

Before:
ok  	regexp	3.692s
ok  	compress/bzip2	9.461s
ok  	encoding/json	6.380s
After:
ok  	regexp	2.229s (-40%)
ok  	compress/bzip2	4.703s (-50%)
ok  	encoding/json	3.629s (-43%)

For comparison, normal non-race build:
ok  	regexp	0.348s
ok  	compress/bzip2	0.304s
ok  	encoding/json	0.661s
Race build:
ok  	regexp	2.229s (+540%)
ok  	compress/bzip2	4.703s (+1447%)
ok  	encoding/json	3.629s (+449%)

Also removes some race-related special cases from cgocall and scheduler.
In long-term it will allow to remove cyclic runtime/race dependency on cmd/cgo.

Fixes #4249.
Fixes #7460.
Update #6508
Update #6688

R=iant, rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/55100044
2014-03-06 23:48:30 +04:00
Brad Fitzpatrick
5db255fa3c net/http/cgi: kill child CGI process on copy error
Fixes #7196

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews, iant
https://golang.org/cl/69970052
2014-03-06 11:24:28 -08:00
Dmitriy Vyukov
8ca3372d7b runtime: fix bad g status after copystack
LGTM=khr
R=khr
CC=golang-codereviews, rsc
https://golang.org/cl/69870054
2014-03-06 21:33:19 +04:00
Dmitriy Vyukov
aea99eda0f runtime: fix runaway memory usage
It was caused by mstats.heap_alloc skew.
Fixes #7430.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, rsc
https://golang.org/cl/69870055
2014-03-06 21:33:00 +04:00
Dmitriy Vyukov
fd7ff20495 net/http: make TestUseProxy repeatable
Currently it fails on second and subsequent runs (when using -cpu=1,2,4) as:
--- FAIL: TestUseProxy-4 (0.00 seconds)
proxy_test.go:109: useProxy(barbaz.net) = true, want false
proxy_test.go:109: useProxy(foobar.com) = true, want false
proxy_test.go:109: useProxy(www.foobar.com) = true, want false

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/71940044
2014-03-06 18:44:14 +04:00
Dmitriy Vyukov
130458470a run.bash: explain why we set GOMAXPROCS for runtime test
Fixes #7459.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/71060044
2014-03-06 13:16:14 +04:00
Shenghou Ma
56e261ef2f cmd/dist: enable GOARM>5 on NetBSD/ARM.
Tested GOARM=6 on Raspberry Pi, and I found only a few tests that
use sub-normal numbers fails. I have a patch to NetBSD kernel pending
that fixes this issue (NetBSD kernel doesn't allow us to disable the
Flush-to-Zero feature).

LGTM=jsing
R=golang-codereviews, jsing
CC=golang-codereviews
https://golang.org/cl/70730043
2014-03-06 00:57:23 -05:00
Shenghou Ma
30d60936d9 syscall: update NetBSD/ARM port to EABI.
LGTM=jsing
R=golang-codereviews, jsing
CC=golang-codereviews
https://golang.org/cl/70720043
2014-03-06 00:55:57 -05:00
Brad Fitzpatrick
31731b27cd net/rpc/jsonrpc: add temporarily-disabled failing test
To be enabled by https://golang.org/cl/71230045/

Update #7442

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/69860056
2014-03-05 16:01:37 -08:00
Brad Fitzpatrick
3b961ba3d2 net/http: deflake a test
I missed this one in codereview.appspot.com/70010050
Same thing, but different test.

Fixes windows-amd64-race and likely other Windows
machines failing like:
http://build.golang.org/log/0382bf0048bf5835a51a8a902df5c6fc73cd7ff5

LGTM=adg
R=rsc, adg
CC=golang-codereviews
https://golang.org/cl/71770043
2014-03-05 14:56:50 -08:00
Brad Fitzpatrick
6433bff205 net/http: minor fixes and optimization for Response.TLS
Also add it to doc/go1.3.txt.

Update #7289

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/71740043
2014-03-05 12:40:13 -08:00
Paul A Querna
4816986ff5 net/http: Add TLS Connection State to Responses.
Fixes #7289.

LGTM=bradfitz
R=golang-codereviews, r, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/52660047
2014-03-05 12:25:55 -08:00
Shenghou Ma
fd4b001a0f syscall: add mmap constants for NetBSD/ARM.
Fixes the syscall test.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/71470043
2014-03-05 15:18:36 -05:00
Shenghou Ma
c887193382 cmd/dist: support building pkg/runtime/*.
Essentialy for running tests without a working cmd/go.
While we're at it, also fix a typo.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/70640043
2014-03-05 14:57:17 -05:00
Kelsey Hightower
13e359bdca encoding/gob: improve interface assignment error message
During the glob decoding process interface values are set to concrete
values after a test for assignability. If the assignability test fails
a slightly vague error message is produced. While technically accurate
the error message does not clearly describe the problem.

Rewrite the error message to include the usage of the word assignable,
which makes it clear the concrete value type is not assignable to the
interface value type.

Fixes #6467.

LGTM=r
R=golang-codereviews, rsc, r
CC=golang-codereviews
https://golang.org/cl/71590043
2014-03-06 06:52:18 +11:00
Shawn Smith
58980821c7 encoding/xml: add test for EncodeToken
LGTM=rsc
R=golang-codereviews, josharian, dave, iant, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/47870043
2014-03-05 14:49:33 -05:00
Shenghou Ma
37e195cf72 cmd/ld: don't include padding length in size of the note section
Recently NetBSD starts to enforce this, and refuses to execute
the program if n is larger than the sum of entry sizes.

Before:
$ readelf -n ../bin/go.old
Notes at offset 0x00000bd0 with length 0x00000019:
  Owner         Data size       Description
  NetBSD                0x00000004      NT_VERSION (version)
readelf: Warning: corrupt note found at offset 18 into core notes
readelf: Warning:  type: 0, namesize: 00000000, descsize: 00000000
$ readelf -n ../bin/go
Notes at offset 0x00000bd0 with length 0x00000018:
Owner         Data size       Description
NetBSD                0x00000004      NT_VERSION (version)

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/70710043
2014-03-05 14:40:55 -05:00
Alberto García Hierro
22705d0995 cmd/go: add support for coverage in CgoFiles
Add CgoFiles to the covered files when building
with cover support.

LGTM=rsc
R=golang-codereviews, gobot, r, rsc
CC=golang-codereviews
https://golang.org/cl/34680044
2014-03-05 14:28:11 -05:00
Russ Cox
3f1374fcf8 cmd/dist: use vfprintf on Windows, same as on Unix
Apparently, the Windows routines sometimes fail to generate output.
Copy the Unix stdio-based implementations instead.

Suggested by Pietro Gagliardi in CL 65280043 but that CL
seems to have been abandoned.

Fixes #7242.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/71550044
2014-03-05 14:16:30 -05:00
Chris Manghane
671cc6efba cmd/gc: allow append and complex builtins to accept 2-result call expression as first argument.
Fixes #5793.

LGTM=rsc
R=rsc, adonovan, dave
CC=golang-codereviews
https://golang.org/cl/13367051
2014-03-05 14:16:21 -05:00
Jan Ziak
202e6153f5 cmd/dist: respect system CFLAGS/LDFLAGS
Update #6882.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/69860055
2014-03-05 14:10:22 -05:00
Russ Cox
1249d3a518 runtime: handle Go calls C calls Go panic correctly on windows/386
32-bit Windows uses "structured exception handling" (SEH) to
handle hardware faults: that there is a per-thread linked list
of fault handlers maintained in user space instead of
something like Unix's signal handlers. The structures in the
linked list are required to live on the OS stack, and the
usual discipline is that the function that pushes a record
(allocated from the current stack frame) onto the list pops
that record before returning. Not to pop the entry before
returning creates a dangling pointer error: the list head
points to a stack frame that no longer exists.

Go pushes an SEH record in the top frame of every OS thread,
and that record suffices for all Go execution on that thread,
at least until cgo gets involved.

If we call into C using cgo, that called C code may push its
own SEH records, but by the convention it must pop them before
returning back to the Go code. We assume it does, and that's
fine.

If the C code calls back into Go, we want the Go SEH handler
to become active again, not whatever C has set up. So
runtime.callbackasm1, which handles a call from C back into
Go, pushes a new SEH record before calling the Go code and
pops it when the Go code returns. That's also fine.

It can happen that when Go calls C calls Go like this, the
inner Go code panics. We allow a defer in the outer Go to
recover the panic, effectively wiping not only the inner Go
frames but also the C calls. This sequence was not popping the
SEH stack up to what it was before the cgo calls, so it was
creating the dangling pointer warned about above. When
eventually the m stack was used enough to overwrite the
dangling SEH records, the SEH chain was lost, and any future
panic would not end up in Go's handler.

The bug in TestCallbackPanic and friends was thus creating a
situation where TestSetPanicOnFault - which causes a hardware
fault - would not find the Go fault handler and instead crash
the binary.

Add checks to TestCallbackPanicLocked to diagnose the mistake
in that test instead of leaving a bad state for another test
case to stumble over.

Fix bug by restoring SEH chain during deferred "endcgo"
cleanup.

This bug is likely present in Go 1.2.1, but since it depends
on Go calling C calling Go, with the inner Go panicking and
the outer Go recovering the panic, it seems not important
enough to bother fixing before Go 1.3. Certainly no one has
complained.

Fixes #7470.

LGTM=alex.brainman
R=golang-codereviews, alex.brainman
CC=golang-codereviews, iant, khr
https://golang.org/cl/71440043
2014-03-05 11:10:40 -05:00
Joel Sing
4e7049bb84 syscall: regenerate z-files for dragonfly
Regenerate z-files for DragonFly BSD 3.6.

F_DUP_FD_CLOEXEC is now supported, so remove the zero value constant
from types_dragonfly.go so that we use the generated value from the
z-files.

LGTM=mikioh.mikioh
R=golang-codereviews, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/70080047
2014-03-06 00:09:09 +11:00
Joel Sing
b586f56e76 syscall: fix mksysnum_dragonfly.pl
The format of the DragonFly BSD syscalls.master file has changed
slightly - update mksysnum_dragonfly.pl to match.

LGTM=mikioh.mikioh
R=golang-codereviews, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/71460044
2014-03-06 00:08:34 +11:00
Joel Sing
18019dffd2 net: disable "udp" to IPv6 unicast address loopback test on dragonfly
Disable the "udp" to IPv6 unicast address on the loopback interface
test under DragonFly BSD. This currently returns a local address of
0.0.0.1, rather than an IPv6 address with zone identifier.

Update #7473

LGTM=mikioh.mikioh
R=golang-codereviews, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/71500044
2014-03-06 00:08:03 +11:00
Joel Sing
734d4637c5 net: fix non-blocking connect handling on dragonfly
Performing multiple connect system calls on a non-blocking socket
under DragonFly BSD does not necessarily result in errors from earlier
connect calls being returned, particularly if we are connecting to
localhost. Instead, once netpoll tells us that the socket is ready,
get the SO_ERROR socket option to see if the connection succeeded
or failed.

Fixes #7474

LGTM=mikioh.mikioh
R=mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/69340044
2014-03-06 00:07:16 +11:00
Patrick Mézard
9a7cd11bc8 os: try openFile before openDir in windows os.OpenFile
Logging calls when running "go install -a std" turns:

  547  openDir succeeded
  3593 openDir failed and fell back to openFile
  3592 openFile succeeded
  1    both failed

into:

  3592 openFile succeeded
  548  openFile failed and fell back
  547  openDir succeeded
  1    both failed

Here the change trades 3593 failed openDir for 548 failed openFile.

Fix issue 7426.

LGTM=alex.brainman
R=golang-codereviews, alex.brainman, bradfitz
CC=golang-codereviews
https://golang.org/cl/70480044
2014-03-05 12:19:56 +11:00
Robert Griesemer
1624c73c9d go/parser: better error position for non-invoked gp/defer functions
Added test cases and expanded test harness to handle token end
positions.

Also: Make sure token end positions are never outside the valid
      position range, as was possible in case of parse errors.

Fixes #7458.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/70190046
2014-03-04 14:10:30 -08:00
Mike Andrews
a18bfb8c67 net/smtp: set ServerName in StartTLS, as now required by crypto/tls
the crypto/tls revision d3d43f270632 (CL 67010043, requiring ServerName or InsecureSkipVerify) breaks net/smtp,
since it seems impossible to do SMTP via TLS anymore. i've tried to fix this by simply using a tls.Config with
ServerName, instead of a nil *tls.Config. without this fix, doing SMTP with TLS results in error "tls: either
ServerName or InsecureSkipVerify must be specified in the tls.Config".

testing: the new method TestTlsClient(...) sets up a skeletal smtp server with tls capability, and test client
injects a "fake" certificate allowing tls to work on localhost; thus, the modification to SendMail(...) enabling
this.

Fixes #7437.

LGTM=bradfitz
R=golang-codereviews, josharian, bradfitz
CC=golang-codereviews
https://golang.org/cl/70380043
2014-03-04 13:43:26 -08:00
Brad Fitzpatrick
3b015616f7 net/http: improve Client.Timeout docs, quiet test
LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/70930043
2014-03-04 13:41:05 -08:00
Russ Cox
77720904a8 liblink: fix arm build
The arm puts the text flags in a different place
than the other architectures. This needs to be
cleaned up.

TBR=minux
CC=golang-codereviews
https://golang.org/cl/71260043
2014-03-04 14:59:08 -05:00
Matt Aimonetti
b38320bffb net/http: make Request.ParseForm parse form-urlencoded for method PATCH too
Fixes #7454

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/70990044
2014-03-04 11:58:21 -08:00
Brad Fitzpatrick
a5166a9512 net/http: fix test failure on some Windows machines
The network connection dies differently from the server's
perspective on (some) Windows when the client goes away. Match
on the common prefix (common to Unix and Windows) instead of
the network error part.

Fixes #7456

LGTM=josharian
R=golang-codereviews, josharian
CC=alex.brainman, golang-codereviews, iant
https://golang.org/cl/70010050
2014-03-04 11:55:35 -08:00
Russ Cox
f884e15aab runtime: fix arm build (B not JMP)
TBR=dvyukov
CC=golang-codereviews
https://golang.org/cl/71060046
2014-03-04 14:03:39 -05:00
Russ Cox
c2dd33a46f cmd/ld: clear unused ctxt before morestack
For non-closure functions, the context register is uninitialized
on entry and will not be used, but morestack saves it and then the
garbage collector treats it as live. This can be a source of memory
leaks if the context register points at otherwise dead memory.
Avoid this by introducing a parallel set of morestack functions
that clear the context register, and use those for the non-closure functions.

I hope this will help with some of the finalizer flakiness, but it probably won't.

Fixes #7244.

LGTM=dvyukov
R=khr, dvyukov
CC=golang-codereviews
https://golang.org/cl/71030044
2014-03-04 13:53:08 -05:00
Brad Fitzpatrick
542415c9df net/http: deflake another alloc test
I have one machine where this 25 test run is flaky
and fails ("21 >= 21"), but 50 works everywhere.

LGTM=josharian
R=josharian
CC=golang-codereviews
https://golang.org/cl/67870053
2014-03-04 09:59:07 -08:00
Brad Fitzpatrick
c7157bf449 crypto/cipher: fix AEAD.Open documentation nit
It mentioned true and false for error values. Instead, just
don't mention the error semantics, as they match normal Go
conventions (if error is non-nil, the other value is
meaningless). We generally only document error values when
they're interesting (where non-nil, non-nil is valid, or the
error value can be certain known values or types).

Fixes #7464

LGTM=agl
R=agl
CC=golang-codereviews
https://golang.org/cl/68440044
2014-03-04 09:58:54 -08:00
Kelsey Hightower
96c373f9e1 path/filepath: ensure Glob does not ignore broken symlinks
Fixes #6463.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/69870050
2014-03-04 09:00:45 -08:00
Brad Fitzpatrick
5f1e0fa538 net/http: disable an alloc test under the race detector
LGTM=dvyukov
R=dvyukov
CC=golang-codereviews
https://golang.org/cl/70200052
2014-03-04 08:56:52 -08:00
Russ Cox
241f63debd runtime: fix finalizer flakiness
The flakiness appears to be just in tests, not in the actual code.
Specifically, the many tests call runtime.GC once and expect that
the finalizers will be running in the background when GC returns.
Now that the sweep phase is concurrent with execution, however,
the finalizers will not be run until sweep finishes, which might
be quite a bit later. To force sweep to finish, implement runtime.GC
by calling the actual collection twice. The second will complete the
sweep from the first.

This was reliably broken after a few runs before the CL and now
passes tens of runs:

while GOMAXPROCS=2 ./runtime.test -test.run=Finalizer -test.short \
        -test.timeout=300s -test.cpu=$(perl -e 'print ("1,2,4," x 100) . "1"')
do true; done

Fixes #7328.

LGTM=dvyukov
R=dvyukov, dave
CC=golang-codereviews
https://golang.org/cl/71080043
2014-03-04 09:46:40 -05:00
Dmitriy Vyukov
d1c6c6004b cmd/go: fix data race on buildLdflags
Fixes #7438.

LGTM=rsc
R=golang-codereviews
CC=bradfitz, golang-codereviews, iant, rsc
https://golang.org/cl/70420044
2014-03-04 11:42:02 +04:00
Rémy Oudompheng
52e6d7c622 cmd/gc: use a register to checknil constants.
Fixes #7346.

LGTM=rsc
R=rsc, iant, khr
CC=golang-codereviews
https://golang.org/cl/69050044
2014-03-04 08:18:17 +01:00
Russ Cox
0a3bd045f5 runtime: fix traceback on Windows
The exception handler runs on the ordinary g stack,
and the stack copier is now trying to do a traceback
across it. That's never been needed before, so it was
unimplemented. Implement it, in all its ugliness.

Fixes windows/amd64 build.

TBR=khr
CC=golang-codereviews
https://golang.org/cl/71030043
2014-03-03 23:33:27 -05:00
Brad Fitzpatrick
709b12ffe6 net/http: fix location of StateHijacked and StateActive
1) Move StateHijacked callback earlier, to make it
panic-proof.  A Hijack followed by a panic didn't previously
result in ConnState getting fired for StateHijacked.  Move it
earlier, to the time of hijack.

2) Don't fire StateActive unless any bytes were read off the
wire while waiting for a request. This means we don't
transition from New or Idle to Active if the client
disconnects or times out. This was documented before, but not
implemented properly.

This CL is required for an pending fix for Issue 7264

LGTM=josharian
R=josharian
CC=golang-codereviews
https://golang.org/cl/69860049
2014-03-03 18:58:28 -08:00
Russ Cox
1a936ebcfa math/rand: speed up Float32, Float64
Actually, speed up Int31n and Int63n by avoiding retry loop.

benchmark           old ns/op    new ns/op    delta
BenchmarkFloat32           32           26  -19.45%
BenchmarkFloat64           46           23  -49.47%

Fixes #7267.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/69980047
2014-03-03 20:43:23 -05:00
Russ Cox
56b983c112 cmd/gc: fix internal crash
TBR=ken2
CC=golang-codereviews
https://golang.org/cl/70200053
2014-03-03 19:55:40 -05:00
Mikio Hara
1d086e39b0 net: enable fast socket creation with close-on-exec flag on freebsd
Also makes variable names explicit.

Fixes #7186.

LGTM=iant
R=golang-codereviews, gobot, iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/69100043
2014-03-04 09:28:09 +09:00
Mikio Hara
a918c2c6d8 syscall: add Accept4 for freebsd
Update #7186
Update #7428

LGTM=r, bradfitz
R=golang-codereviews, rsc, minux.ma, r, bradfitz
CC=golang-codereviews
https://golang.org/cl/68880043
2014-03-04 09:27:48 +09:00
Mikio Hara
be8aa4b073 os: handle file creation with close-on-exec flag correctly on darwin, freebsd
Fixes #7187.
Update #7193

LGTM=bradfitz
R=golang-codereviews, dave, rsc, minux.ma, bradfitz
CC=golang-codereviews
https://golang.org/cl/64510043
2014-03-04 09:27:29 +09:00
Mikio Hara
25668b9b34 syscall: add support for FreeBSD 10
This CL tweaks syscall.InterfaceMessage to support FreeBSD 10 and
prior to 10.

See http://svnweb.freebsd.org/base?view=revision&revision=254804.

Fixes #7193.

LGTM=iant
R=golang-codereviews, rsc, minux.ma, gobot, iant
CC=golang-codereviews
https://golang.org/cl/56980043
2014-03-04 09:26:56 +09:00
Mikio Hara
737efeb5b8 syscall: regenerate z-files on FreeBSD 10
Unfortunately FreeBSD 10 has changed its syscall arguments for
some reasons but as per request at golang-dev this CL does not
generate some structures, syscall numbers and constants as
compatible to FreeBSD 10 as follows:

Structure: Stat_t, IfData, IfMsghdr are based on 8-STABLE
Syscall number: Capsicum API is based on 9-STABLE
Constant: IFT_CARP, SIOCAIFADDR, SIOCSIFPHYADDR are based on 9-STABLE

Update #7193

FreeBSD 10 breaking changes:

r205792: Rename st_*timespec fields to st_*tim for POSIX 2008
compliance.
http://svnweb.freebsd.org/base?view=revision&revision=205792

r254804: Restructure the mbuf pkthdr to make it fit for upcoming
capabilities and features.
http://svnweb.freebsd.org/base?view=revision&revision=254804

r255219: Change the cap_rights_t type from uint64_t to a structure
that we can extend in the future in a backward compatible (API and
ABI) way.
http://svnweb.freebsd.org/base?view=revision&revision=255219

LGTM=iant
R=golang-codereviews, rsc, minux.ma, gobot, iant
CC=golang-codereviews
https://golang.org/cl/56770044
2014-03-04 09:26:01 +09:00
Dave Cheney
13ab78fdd9 runtime: update CBARGS macro for nacl/amd64p32
CBARGS is unused on amd64p32 so make this explicit.

LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/70940043
2014-03-04 10:36:04 +11:00
Brad Fitzpatrick
76cc0a2712 net/http: in Client, consume small redirect bodies before making next request
In Go 1.2, closing a request body without reading to EOF
causes the underlying TCP connection to not be reused. This
client code following redirects was never updated when that
happened.

This was part of a previous CL but moved to its own CL at
Josh's request.  Now with test too.

LGTM=josharian
R=josharian
CC=golang-codereviews
https://golang.org/cl/70800043
2014-03-03 11:25:57 -08:00
Graham King
ebe1eb6537 cmd/ld: DWARF opcode base to 10
DWARF 2 has 9 standard opcodes, so dwarfdump expects us to use an
opcode base of at least 10. Previously we used 5.

Discussion:
https://groups.google.com/forum/#!topic/golang-dev/d-BqpPgalzc

LGTM=josharian, rsc
R=golang-codereviews, gobot, rsc, josharian, iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/69320043
2014-03-03 11:11:04 -08:00
Adam Langley
3656c2db96 crypto/tls: split connErr to avoid read/write races.
Currently a write error will cause future reads to return that same error.
However, there may have been extra information from a peer pending on
the read direction that is now unavailable.

This change splits the single connErr into errors for the read, write and
handshake. (Splitting off the handshake error is needed because both read
and write paths check the handshake error.)

Fixes #7414.

LGTM=bradfitz, r
R=golang-codereviews, r, bradfitz
CC=golang-codereviews
https://golang.org/cl/69090044
2014-03-03 09:01:44 -05:00
David du Colombier
f608806092 cmd/ld: fix warning on Plan 9
warning: src/cmd/ld/pcln.c:184 more arguments than format INT

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/69870047
2014-03-03 08:14:27 +01:00
Brad Fitzpatrick
2ad72ecf34 net/http: add Client.Timeout for end-to-end timeouts
Fixes #3362

LGTM=josharian
R=golang-codereviews, josharian
CC=adg, dsymonds, golang-codereviews, n13m3y3r
https://golang.org/cl/70120045
2014-03-02 20:39:20 -08:00
Mikio Hara
f706d707b7 net: remove the dreg of solaris merge
Also enables netgo test on solaris.

LGTM=aram, jsing
R=golang-codereviews, dave, aram, jsing
CC=golang-codereviews
https://golang.org/cl/70300043
2014-03-03 07:09:28 +09:00
Mikio Hara
d9fc789df2 runtime: make SIGSYS notifiable on FreeBSD
Update #7186

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/70490043
2014-03-03 07:08:44 +09:00
Richard Crowley
7124ee59d1 net/http: ensure ConnState for StateNew fires before Server.Serve returns
The addition of Server.ConnState provides all the necessary
hooks to stop a Server gracefully, but StateNew previously
could fire concurrently with Serve exiting (as it does when
its net.Listener is closed). This previously meant one
couldn't use a WaitGroup incremented in the StateNew hook
along with calling Wait after Serve. Now you can.

Update #4674

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/70410044
2014-03-01 20:32:42 -08:00
Shenghou Ma
5fbd6044bc syscall: workaround Dragonfly BSD kernel exec bug
See also CL 4259056 for FreeBSD.

Test program:
// exec.go
package main
import (
        "log"
        "os"
        "os/exec"
        "runtime"
)
func main() {
        path := runtime.GOROOT() + "/src/pkg/net/http/cgi/testdata"
        cmd := &exec.Cmd{
                Path:   "test.cgi",
                Args:   []string{path + "/test.cgi"},
                Dir:    path
                Stdout: os.Stdout}
        if err := cmd.Start(); err != nil {
                log.Fatal(err)
        }
        if err := cmd.Wait(); err != nil {
                log.Fatal(err)
        }
}

$ go run exec.go
2014/03/01 15:52:41 fork/exec test.cgi: argument list too long

LGTM=iant
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/69970044
2014-03-01 18:56:50 -05:00
Dave Cheney
5b456c7488 sync/atomic: skip broken tests on freebsd/arm and netbsd/arm
Update #7338

The nil deref tests are currently failing on the *bsd/arm platforms. In an effort to avoid the build deteriorating further I would like to skip these tests on freebsd/arm and netbsd/arm.

LGTM=bradfitz, minux.ma
R=golang-codereviews, bradfitz, minux.ma
CC=golang-codereviews
https://golang.org/cl/69870045
2014-03-02 08:30:45 +11:00
Dave Cheney
0c6e4b9660 runtime: small Native Client fixes
cgocall.c: define the CBARGS macro for GOARCH_amd64p32. I don't think the value of this macro will ever be used under nacl/amd64p32 but it is required to compile even if cgo is not used.

hashmap.goc: amd64p32 uses 32bit words.

LGTM=iant
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/69960044
2014-03-01 11:13:29 +11:00
Brad Fitzpatrick
1f0a1f4c8d net/http: de-flake ConnState test
LGTM=josharian
R=golang-codereviews, josharian
CC=golang-codereviews
https://golang.org/cl/70270043
2014-02-28 13:27:36 -08:00
Brad Fitzpatrick
281088b1f0 net/http: add Server.ErrorLog; log and test TLS handshake errors
Fixes #7291

LGTM=agl
R=golang-codereviews, agl
CC=agl, golang-codereviews
https://golang.org/cl/70250044
2014-02-28 12:12:51 -08:00
Josh Bleecher Snyder
91e3681105 cmd/ld: fix misgenerated pcln file numbers
The pcln file number was being encoded incorrectly. The recorded delta was always against -1, not against the previous value.

Update #7369

This CL fixes the bad DWARF file numbers. It does not, however, fix the gdb continue-to-end bug.

LGTM=iant
R=rsc, minux.ma, iant
CC=golang-codereviews, graham
https://golang.org/cl/68960046
2014-02-28 11:08:32 -08:00
Brad Fitzpatrick
07e2b4049b os: don't allow Process.Kill after Process.Release
This is a user error, but killing -1 kills everything, which
is a pretty bad failure mode.

Fixes #7434

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/70140043
2014-02-28 08:31:12 -08:00
Brad Fitzpatrick
916682ea36 net/http: add Server.SetKeepAlivesEnabled
Part of graceful shutdown.

Update #4674

LGTM=adg, josharian
R=adg, josharian, r
CC=golang-codereviews
https://golang.org/cl/69670043
2014-02-28 07:40:25 -08:00
Adam Langley
1f8b2a69ec crypto/tls: add DialWithDialer.
While reviewing uses of the lower-level Client API in code, I found
that in many cases, code was using Client only because it needed a
timeout on the connection. DialWithDialer allows a timeout (and
 other values) to be specified without resorting to the low-level API.

LGTM=r
R=golang-codereviews, r, bradfitz
CC=golang-codereviews
https://golang.org/cl/68920045
2014-02-28 09:40:12 -05:00
Dave Cheney
b3e0a8df24 cmd/dist: add missing Native Client bits
Some parts of CL 15400047 didn't survive the merge.

LGTM=rsc
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/69870044
2014-02-28 21:45:12 +11:00
Nigel Tao
c2013e8a35 image/jpeg: return a FormatError when hitting an unexpected io.EOF
inside Huffman-encoded data.

Fixes #6450.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/69830043
2014-02-28 15:18:35 +11:00
Robert Sesek
a9600502bb debug/macho: Define CPU constants for other common architectures for OS X/iOS.
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/69100045
2014-02-27 19:11:03 -08:00
Brad Fitzpatrick
67b8bf3e32 net/http: add optional Server.ConnState callback
Update #4674

This allows for all sorts of graceful shutdown policies,
without picking a policy (e.g. lameduck period) and without
adding lots of locking to the server core. That policy and
locking can be implemented outside of net/http now.

LGTM=adg
R=golang-codereviews, josharian, r, adg, dvyukov
CC=golang-codereviews
https://golang.org/cl/69260044
2014-02-27 18:29:00 -08:00
Russ Cox
d9c6ae6ae8 all: final merge of NaCl tree
This CL replays the following one CL from the rsc-go13nacl repo.
This is the last replay CL: after this CL the main repo will have
everything the rsc-go13nacl repo did. Changes made to the main
repo after the rsc-go13nacl repo branched off probably mean that
NaCl doesn't actually work after this CL, but all the code is now moved
over and just needs to be redebugged.

---
cmd/6l, cmd/8l, cmd/ld: support for Native Client

See golang.org/s/go13nacl for design overview.

This CL is publicly visible but not CC'ed to golang-dev,
to avoid distracting from the preparation of the Go 1.2
release.

This CL and the others will be checked into my rsc-go13nacl
clone repo for now, and I will send CLs against the main
repo early in the Go 1.3 development.

R≡khr
https://golang.org/cl/15750044
---

LGTM=bradfitz, dave, iant
R=dave, bradfitz, iant
CC=golang-codereviews
https://golang.org/cl/69040044
2014-02-27 20:37:00 -05:00
Nigel Tao
ea34ca768f image/jpeg: fix progressive decoding when the DC components are split
over multiple scans. Previously, the Go code assumed that DC was
synonymous with interleaved and AC with non-interleaved.

Fixes #6767.

The test files were generated with libjpeg's cjpeg program, version 9a,
with the following patch, since cjpeg is hard-coded to output
interleaved DC.

$ diff -u jpeg-9a*/jcparam.c
--- jpeg-9a-clean/jcparam.c	2013-07-01 21:13:28.000000000 +1000
+++ jpeg-9a/jcparam.c	2014-02-27 11:40:41.236889852 +1100
@@ -572,7 +572,7 @@
 {
   int ci;

-  if (ncomps <= MAX_COMPS_IN_SCAN) {
+  if (0) {
         /* Single interleaved DC scan */
         scanptr->comps_in_scan = ncomps;
         for (ci = 0; ci < ncomps; ci++)
@@ -610,7 +610,7 @@
           (cinfo->jpeg_color_space == JCS_YCbCr ||
                cinfo->jpeg_color_space == JCS_BG_YCC)) {
         /* Custom script for YCC color images. */
-    nscans = 10;
+    nscans = 14;
   } else {
         /* All-purpose script for other color spaces. */
         if (ncomps > MAX_COMPS_IN_SCAN)

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/69000046
2014-02-28 10:37:21 +11:00
Keith Randall
e9445547b6 runtime: move stack shrinking until after sweepgen is incremented.
Before GC, we flush all the per-P allocation caches.  Doing
stack shrinking mid-GC causes these caches to fill up.  At the
end of gc, the sweepgen is incremented which causes all of the
data in these caches to be in a bad state (cached but not yet
swept).

Move the stack shrinking until after sweepgen is incremented,
so any caching that happens as part of shrinking is done with
already-swept data.

Reenable stack copying.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/69620043
2014-02-27 14:20:15 -08:00
Brad Fitzpatrick
0399b971d9 syscall: add some paranoia in Linux's Accept4
Fixes #7428

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/69530044
2014-02-27 14:16:47 -08:00
Brad Fitzpatrick
dc6bf295b9 net/http: make Transport.CancelRequest work for requests blocked in a dial
Fixes #6951

LGTM=josharian
R=golang-codereviews, josharian
CC=golang-codereviews
https://golang.org/cl/69280043
2014-02-27 13:32:40 -08:00
Robert Griesemer
28cc8aa89e go/printer: measure lines/construct in generated output rather than incoming source
No change to $GOROOT/src, misc formatting.

Nice side-effect: almost 3% faster runs because it's much faster to compute
line number differences in the generated output than the incoming source.

Benchmark run, best of 5 runs, before and after:
BenchmarkPrint	     200	  12347587 ns/op
BenchmarkPrint	     200	  11999061 ns/op

Fixes #4504.

LGTM=adonovan
R=golang-codereviews, adonovan
CC=golang-codereviews
https://golang.org/cl/69260045
2014-02-27 11:35:53 -08:00
Brad Fitzpatrick
b00e4770d9 bufio: in Reader.WriteTo, try to use target's ReaderFrom
This is the simple half of https://golang.org/cl/53560043/ with
a new benchmark. pongad is in the C+A files already.

benchmark                         old ns/op     new ns/op     delta
BenchmarkReaderWriteToOptimal     2054          825           -59.83%

Update #6373

LGTM=iant, gri
R=golang-codereviews, iant, gri
CC=golang-codereviews
https://golang.org/cl/69220046
2014-02-27 10:48:36 -08:00
William Orr
08706f19b4 syscall: add mlock, munlock, mlockall, munlockall and mprotect to OSX
Fixes #7415

LGTM=bradfitz
R=bradfitz, iant
CC=golang-codereviews
https://golang.org/cl/68980043
2014-02-27 10:13:41 -08:00
Robert Griesemer
e9ee0bf63c cmd/gofmt: minor internal cleanups
Reflect changes of reflect API.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/69240044
2014-02-27 09:00:27 -08:00
Dmitriy Vyukov
7e0dac08c7 runtime: fix and improve comments
LGTM=r
R=golang-codereviews, r
CC=golang-codereviews, iant, khr, rsc
https://golang.org/cl/67460043
2014-02-27 20:27:55 +04:00
Joel Sing
0b0e209ffb runtime: disable TestSetPanicOnFault for dragonfly/386
This test currently deadlocks on dragonfly/386.

Update #7421

LGTM=minux.ma
R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/69380043
2014-02-28 03:26:26 +11:00
Keith Randall
f50a87058b runtime: disable stack copying
TBR=dvyukov

TBR=dvyukov
CC=golang-codereviews
https://golang.org/cl/69080045
2014-02-27 01:45:22 -08:00
David du Colombier
092dd4bed2 runtime: fix build on Plan 9
warning: src/pkg/runtime/mem_plan9.c:72 param declared and not used: n
src/pkg/runtime/mem_plan9.c:73 name not declared: nbytes
src/pkg/runtime/mem_plan9.c:73 bad in naddr: NAME nbytes<>+0(SB)

LGTM=minux.ma, bradfitz
R=khr, minux.ma, bradfitz
CC=golang-codereviews
https://golang.org/cl/69360043
2014-02-27 09:22:02 +01:00
Keith Randall
1665b006a5 runtime: grow stack by copying
On stack overflow, if all frames on the stack are
copyable, we copy the frames to a new stack twice
as large as the old one.  During GC, if a G is using
less than 1/4 of its stack, copy the stack to a stack
half its size.

TODO
- Do something about C frames.  When a C frame is in the
  stack segment, it isn't copyable.  We allocate a new segment
  in this case.
  - For idempotent C code, we can abort it, copy the stack,
    then retry.  I'm working on a separate CL for this.
  - For other C code, we can raise the stackguard
    to the lowest Go frame so the next call that Go frame
    makes triggers a copy, which will then succeed.
- Pick a starting stack size?

The plan is that eventually we reach a point where the
stack contains only copyable frames.

LGTM=rsc
R=dvyukov, rsc
CC=golang-codereviews
https://golang.org/cl/54650044
2014-02-26 23:28:44 -08:00
Rémy Oudompheng
e5f01aee04 cmd/gc: do not nop-convert equivalent but different interface types.
The cached computed interface tables are indexed by the interface
types, not by the unnamed underlying interfaces

To preserve the invariants expected by interface comparison, an
itab generated for an interface type must not be used for a value
of a different interface type even if the representation is identical.

Fixes #7207.

LGTM=rsc
R=rsc, iant, khr
CC=golang-codereviews
https://golang.org/cl/69210044
2014-02-27 08:07:50 +01:00
Shenghou Ma
b4dc91e386 runtime: use monotonic clock for timers on dragonfly.
Update #6007

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/69040045
2014-02-26 23:15:34 -05:00
Keith Randall
3b5278fca6 runtime: get rid of the settype buffer and lock.
MCaches	now hold a MSpan for each sizeclass which they have
exclusive access to allocate from, so no lock is needed.

Modifying the heap bitmaps also no longer requires a cas.

runtime.free gets more expensive.  But we don't use it
much any more.

It's not much faster on 1 processor, but it's a lot
faster on multiple processors.

benchmark                 old ns/op    new ns/op    delta
BenchmarkSetTypeNoPtr1           24           23   -0.42%
BenchmarkSetTypeNoPtr2           33           34   +0.89%
BenchmarkSetTypePtr1             51           49   -3.72%
BenchmarkSetTypePtr2             55           54   -1.98%

benchmark                old ns/op    new ns/op    delta
BenchmarkAllocation          52739        50770   -3.73%
BenchmarkAllocation-2        33957        34141   +0.54%
BenchmarkAllocation-3        33326        29015  -12.94%
BenchmarkAllocation-4        38105        25795  -32.31%
BenchmarkAllocation-5        68055        24409  -64.13%
BenchmarkAllocation-6        71544        23488  -67.17%
BenchmarkAllocation-7        68374        23041  -66.30%
BenchmarkAllocation-8        70117        20758  -70.40%

LGTM=rsc, dvyukov
R=dvyukov, bradfitz, khr, rsc
CC=golang-codereviews
https://golang.org/cl/46810043
2014-02-26 15:52:58 -08:00
Robert Griesemer
3d4c12d9d0 go/printer: refine handling of one-line functions
Functions that "fit" on one line and were on one
line in the original source are not broken up into
two lines anymore simply because they contain a comment.

- Fine-tuned use of separating blanks after /*-style comments, so:

( /* extra blank after this comment */ )
(a int /* no extra blank after this comment*/)

- Factored out comment state (from printer state) into commentInfo.
- No impact on $GOROOT/src, misc formatting.

Fixes #5543.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/68630043
2014-02-26 13:39:49 -08:00
Josh Bleecher Snyder
3081261b58 cmd/gc: fix bad checknil with ints on 32 bit compilers
Fixes #7413.

LGTM=rsc
R=remyoudompheng
CC=golang-codereviews, r, rsc
https://golang.org/cl/69180044
2014-02-26 12:25:13 -08:00
Dave Cheney
7954b2b90b cmd/5a, cmd/5c, cmd/6a, cmd/6c, cmd/8a, cmd/8c, cmd/cc: support for Native Client
From the original description in CL 15770043

The main change here is to consult $GOARCH.

In 6c, when GOOS=nacl, some of the more complex addressing modes must be disabled, and the BP and R15 registers must not be used.

See golang.org/s/go13nacl for design overview.

LGTM=rsc
R=golang-codereviews, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/69020044
2014-02-27 06:57:06 +11:00
Ian Lance Taylor
77ac8ecbeb cmd/gc: minor code simplification
LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/68980044
2014-02-26 10:51:00 -08:00
Robert Griesemer
85f59b3429 go/parser: report error if ParseExpr argument contains extra tokens
This partly addresses issue 6099 where a gofmt rewrite is behaving
unexpectedly because the provided rewrite term is not a valid expression
but is silently consumed anyway.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/68920044
2014-02-26 09:54:01 -08:00
Russ Cox
e8fe1cce66 runtime, net: fixes from CL 68490043 review
These are mistakes in the first big NaCl CL.

LGTM=minux.ma, iant
R=golang-codereviews, minux.ma, iant
CC=golang-codereviews
https://golang.org/cl/69200043
2014-02-26 12:21:31 -05:00
Ian Lance Taylor
deaf89b8f1 runtime: remove unnecessary cast in alg.goc
LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/68650045
2014-02-26 08:28:26 -08:00
Ian Lance Taylor
fa6375ea47 cmd/6g, cmd/8g: simplify calls to gvardef
The gvardef function does nothing if n->class == PEXTERN, so
we don't need to test for that before calling it.  This makes
the 6g/8g code more like the 5g code and clarifies that the
cases that do not test for n->class != PEXTERN are not buggy.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/68900044
2014-02-26 07:37:10 -08:00
Joel Sing
3734663805 runtime: use monotonic clock for openbsd/386 and openbsd/amd64 timers
Switch nanotime to a monotonic clock on openbsd/386 and openbsd/amd64.
Also use a monotonic clock when for thrsleep, since the sleep duration
is based on the value returned from nanotime.

Update #6007

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/68460044
2014-02-26 13:20:36 +11:00
Andrew Gerrand
66562b9698 cmd/go: remove 'go tool benchcmp' and corresponding special case
See the discussion on the original CL for context:
        https://golang.org/cl/60100043/

LGTM=josharian
R=r, josharian
CC=golang-codereviews
https://golang.org/cl/68890043
2014-02-26 13:04:39 +11:00
Rob Pike
29d7bbcb16 lib9/utf: bring C environment up to Unicode 6.3.0
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/68820043
2014-02-25 17:49:32 -08:00
Mikio Hara
1b135172df net: clean the dregs of NaCL merge
LGTM=iant, aram, dave
R=golang-codereviews, iant, aram, dave
CC=golang-codereviews
https://golang.org/cl/68770044
2014-02-26 10:20:49 +09:00
Mikio Hara
36013e4a22 runtime: use monotonic clock for timers on freebsd/amd64,386,arm
For now we don't use CLOCK_MONOTONIC_FAST instead because
it's not supported on prior to 9-STABLE.

Update #6007

LGTM=minux.ma
R=golang-codereviews, minux.ma, bradfitz
CC=golang-codereviews
https://golang.org/cl/68690043
2014-02-26 10:19:51 +09:00
Josh Bleecher Snyder
d97d37188a 5g, 8g: remove dead code
maxstksize is superfluous and appears to be vestigial. 6g does not use it.

c >= 4 cannot occur; c = w % 4.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/68750043
2014-02-25 14:43:53 -08:00
Russ Cox
4a000b9d51 all: nacl import round 2
These previously reviewed CLs are present in this CL.

---
changeset:   18445:436bb084caed
user:        Russ Cox <rsc@golang.org>
date:        Mon Nov 11 09:50:34 2013 -0500
description:
runtime: assembly and system calls for Native Client x86-64

See golang.org/s/go13nacl for design overview.

This CL is publicly visible but not CC'ed to golang-dev,
to avoid distracting from the preparation of the Go 1.2
release.

This CL and the others will be checked into my rsc-go13nacl
clone repo for now, and I will send CLs against the main
repo early in the Go 1.3 development.

R≡adg
https://golang.org/cl/15760044

---
changeset:   18448:90bd871b5994
user:        Russ Cox <rsc@golang.org>
date:        Mon Nov 11 09:51:36 2013 -0500
description:
runtime: amd64p32 and Native Client assembly bootstrap

See golang.org/s/go13nacl for design overview.

This CL is publicly visible but not CC'ed to golang-dev,
to avoid distracting from the preparation of the Go 1.2
release.

This CL and the others will be checked into my rsc-go13nacl
clone repo for now, and I will send CLs against the main
repo early in the Go 1.3 development.

R≡khr
https://golang.org/cl/15820043

---
changeset:   18449:b011c3dc687e
user:        Russ Cox <rsc@golang.org>
date:        Mon Nov 11 09:51:58 2013 -0500
description:
math: amd64p32 assembly routines

These routines only manipulate float64 values,
so the amd64 and amd64p32 can share assembly.

The large number of files is symptomatic of a problem
with package path: it is a Go package structured like a C library.
But that will need to wait for another day.

See golang.org/s/go13nacl for design overview.

This CL is publicly visible but not CC'ed to golang-dev,
to avoid distracting from the preparation of the Go 1.2
release.

This CL and the others will be checked into my rsc-go13nacl
clone repo for now, and I will send CLs against the main
repo early in the Go 1.3 development.

R≡bradfitz
https://golang.org/cl/15870043

---
changeset:   18450:43234f082eec
user:        Russ Cox <rsc@golang.org>
date:        Mon Nov 11 10:03:19 2013 -0500
description:
syscall: networking for Native Client

See golang.org/s/go13nacl for design overview.

This CL is publicly visible but not CC'ed to golang-dev,
to avoid distracting from the preparation of the Go 1.2
release.

This CL and the others will be checked into my rsc-go13nacl
clone repo for now, and I will send CLs against the main
repo early in the Go 1.3 development.

R≡rsc
https://golang.org/cl/15780043

---
changeset:   18451:9c8d1d890aaa
user:        Russ Cox <rsc@golang.org>
date:        Mon Nov 11 10:03:34 2013 -0500
description:
runtime: assembly and system calls for Native Client x86-32

See golang.org/s/go13nacl for design overview.

This CL is publicly visible but not CC'ed to golang-dev,
to avoid distracting from the preparation of the Go 1.2
release.

This CL and the others will be checked into my rsc-go13nacl
clone repo for now, and I will send CLs against the main
repo early in the Go 1.3 development.

R≡rsc
https://golang.org/cl/15800043

---
changeset:   18452:f90b1dd9228f
user:        Russ Cox <rsc@golang.org>
date:        Mon Nov 11 11:04:09 2013 -0500
description:
runtime: fix frame size for linux/amd64 runtime.raise

R≡rsc
https://golang.org/cl/24480043

---
changeset:   18445:436bb084caed
user:        Russ Cox <rsc@golang.org>
date:        Mon Nov 11 09:50:34 2013 -0500
description:
runtime: assembly and system calls for Native Client x86-64

See golang.org/s/go13nacl for design overview.

This CL is publicly visible but not CC'ed to golang-dev,
to avoid distracting from the preparation of the Go 1.2
release.

This CL and the others will be checked into my rsc-go13nacl
clone repo for now, and I will send CLs against the main
repo early in the Go 1.3 development.

R≡adg
https://golang.org/cl/15760044

---
changeset:   18455:53b06799a938
user:        Russ Cox <rsc@golang.org>
date:        Mon Nov 11 23:29:52 2013 -0500
description:
cmd/gc: add -nolocalimports flag

R≡dsymonds
https://golang.org/cl/24990043

---
changeset:   18456:24f64e1eaa8a
user:        Russ Cox <rsc@golang.org>
date:        Tue Nov 12 22:06:29 2013 -0500
description:
runtime: add comments for playback write

R≡adg
https://golang.org/cl/25190043

---
changeset:   18457:d1f615bbb6e4
user:        Russ Cox <rsc@golang.org>
date:        Wed Nov 13 17:03:52 2013 -0500
description:
runtime: write only to NaCl stdout, never to NaCl stderr

NaCl writes some other messages on standard error
that we would like to be able to squelch.

R≡adg
https://golang.org/cl/26240044

---
changeset:   18458:1f01be1a1dc2
tag:         tip
user:        Russ Cox <rsc@golang.org>
date:        Wed Nov 13 19:45:16 2013 -0500
description:
runtime: remove apparent debugging dreg

Setting timens to 0 turns off fake time.

TBR≡adg
https://golang.org/cl/26400043

LGTM=bradfitz
R=dave, bradfitz
CC=golang-codereviews
https://golang.org/cl/68730043
2014-02-25 17:00:08 -05:00
Dave Cheney
f9b384f554 syscall: fix solaris build
Solaris does not define syscall.{Mmap,Munmap}. Move the Mmap test to a new file and exclude solaris as discussed.

LGTM=aram
R=aram, mikioh.mikioh, iant
CC=golang-codereviews
https://golang.org/cl/68720043
2014-02-26 07:56:41 +11:00
Keith Randall
391002a82b runtime: add prototype for panicdivide
LGTM=bradfitz
R=golang-codereviews, bradfitz, khr
CC=golang-codereviews
https://golang.org/cl/68680043
2014-02-25 11:49:37 -08:00
Brad Fitzpatrick
8a8b5cba67 crypto/sha1: restore accidental removal of arm build tag
Regression from https://golang.org/cl/68490043/diff/60001/src/pkg/crypto/sha1/sha1block_decl.go

Fixes arm build.

TBR=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/68080046
2014-02-25 10:55:26 -08:00
Russ Cox
5b35dc0f6f runtime: fix 386, arm build
CL 68150047 lost runtime.panicdivide.

TBR=dfc
CC=golang-codereviews
https://golang.org/cl/68610043
2014-02-25 11:31:09 -05:00
Russ Cox
441c4bb939 cmd/go: fix bug in remote package discovery
The parser was assuming it would find <body> or </head>.
If the entire response is just <meta> tags, it finds EOF and
treats that as an error. It's not.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/68520044
2014-02-25 11:22:22 -05:00
Brad Fitzpatrick
fd4b4b56c4 net/http: add Transport.TLSHandshakeTimeout; set it by default
Update #3362

LGTM=agl
R=agl
CC=golang-codereviews
https://golang.org/cl/68150045
2014-02-25 08:08:15 -08:00
Russ Cox
280d46b03b cmd/go: document new -exec flag on run/test
The new flag was added by CL 68150047 (part of the NaCl replay),
but the change, like the original, omitted documentation of the
new behavior.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/68580043
2014-02-25 10:22:27 -05:00
Dave Cheney
7c8280c9ef all: merge NaCl branch (part 1)
See golang.org/s/go13nacl for design overview.

This CL is the mostly mechanical changes from rsc's Go 1.2 based NaCl branch, specifically 39cb35750369 to 500771b477cf from https://code.google.com/r/rsc-go13nacl. This CL does not include working NaCl support, there are probably two or three more large merges to come.

CL 15750044 is not included as it involves more invasive changes to the linker which will need to be merged separately.

The exact change lists included are

15050047: syscall: support for Native Client
15360044: syscall: unzip implementation for Native Client
15370044: syscall: Native Client SRPC implementation
15400047: cmd/dist, cmd/go, go/build, test: support for Native Client
15410048: runtime: support for Native Client
15410049: syscall: file descriptor table for Native Client
15410050: syscall: in-memory file system for Native Client
15440048: all: update +build lines for Native Client port
15540045: cmd/6g, cmd/8g, cmd/gc: support for Native Client
15570045: os: support for Native Client
15680044: crypto/..., hash/crc32, reflect, sync/atomic: support for amd64p32
15690044: net: support for Native Client
15690048: runtime: support for fake time like on Go Playground
15690051: build: disable various tests on Native Client

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/68150047
2014-02-25 09:47:42 -05:00
Mikio Hara
7206f50f71 runtime: use monotonic clock for timers on linux/arm
Update #6007

LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews
https://golang.org/cl/67730048
2014-02-25 23:03:01 +09:00
Mikio Hara
b05f3de56f syscall: add mmap test
This CL adds a test that calls Mmap and Munmap through Syscall9
as the canary that detects assembly fragment breakage. For now
there is no package test that uses Syscall9 in the standard
library across all Unix-like systems.

Note that the package runtime owns its assembly fragments, so
this canary never works for runtime breakage.

LGTM=iant, bradfitz
R=iant, minux.ma, bradfitz
CC=golang-codereviews
https://golang.org/cl/61520049
2014-02-25 23:02:19 +09:00
Dmitriy Vyukov
ec0c9f270e sync: use RunParallel in benchmarks
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/68050043
2014-02-25 14:39:12 +04:00
Aram Hăvărneanu
1c9861918b syscall: add support for GOOS=solaris
These are only the new files, autogenerated files are in a
different CL to keep the size down.

LGTM=dave, minux.ma, jsing
R=golang-codereviews, dave, jsing, gobot, minux.ma, rsc, iant, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/36000043
2014-02-25 21:12:10 +11:00
Aram Hăvărneanu
e5b5f9b39d syscall: generate zfiles for GOOS=solaris
LGTM=minux.ma, mikioh.mikioh
R=golang-codereviews, minux.ma, gobot, jsing, mikioh.mikioh, dave
CC=golang-codereviews
https://golang.org/cl/36010043
2014-02-25 17:12:19 +09:00
Aram Hăvărneanu
50df136483 runtime, net: add support for GOOS=solaris
LGTM=dave, rsc
R=golang-codereviews, minux.ma, mikioh.mikioh, dave, iant, rsc
CC=golang-codereviews
https://golang.org/cl/36030043
2014-02-24 22:31:01 -05:00
Robert Griesemer
c738591e7e go/printer: fix alignment of comments in labeled statements
Does not change src, misc formatting.

Fixes #5623.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/68400043
2014-02-24 19:18:16 -08:00
Brad Fitzpatrick
49beb23ba7 net/http: use TCP Keep-Alives on DefaultTransport's connections
Update #3362

Also set a 30 second timeout, instead of relying on the
operating system's timeout, which if often but not always 3
minutes.

LGTM=crawshaw
R=rsc, crawshaw
CC=golang-codereviews
https://golang.org/cl/68330046
2014-02-24 15:20:45 -08:00
Adam Langley
c7612f3426 crypto/tls: report TLS version in ConnectionState.
Fixes #7231.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/68250043
2014-02-24 18:01:28 -05:00
Adam Langley
db99a8faa8 crypto/tls: pick ECDHE curves based on server preference.
Currently an ECDHE handshake uses the client's curve preference. This
generally means that we use P-521. However, P-521's strength is
mismatched with the rest of the cipher suite in most cases and we have
a fast, constant-time implementation of P-256.

With this change, Go servers will use P-256 where the client supports
it although that can be overridden in the Config.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/66060043
2014-02-24 17:57:51 -05:00
Russ Cox
e6e8945001 build: comment possible ulimit failure in run.bash
Record what's going on in case someone is debugging a failure there.
It's not Go's fault.

Fixes #7381.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/68200043
2014-02-24 16:44:35 -05:00
Brad Fitzpatrick
fdfbb406d1 net: add Dialer.KeepAlive option
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/68380043
2014-02-24 13:14:48 -08:00
Shenghou Ma
e2fe968d5f cmd/ld: fix build for ARMv5.
Credit goes to Dave Cheney for debugging the issue.

LGTM=dave, rsc
R=dave, rsc
CC=golang-codereviews
https://golang.org/cl/67820043
2014-02-25 06:53:17 +11:00
Rémy Oudompheng
14b0af4272 cmd/gc: fix walkcompare bugs.
Revision c0e0467635ec (cmd/gc: return canonical Node* from temp)
exposed original nodes of temporaries, allowing callers to mutate
their types.

In walkcompare a temporary could be typed as ideal because of
this. Additionnally, assignment of a comparison result to
a custom boolean type was broken.

Fixes #7366.

LGTM=rsc
R=rsc, iant, khr
CC=golang-codereviews
https://golang.org/cl/66930044
2014-02-24 19:51:59 +01:00
Lucio De Re
ff15e5c00f cmd/go: Plan 9 compatible "env" output
Fixes the output of go env so that variables can be set
more accurately when using Plan 9's rc shell. Specifically,
GOPATH may have multiple components and the current
representation is plain wrong. In practice, we probably
ought to change os. Getenv to produce the right result, but
that requires considerably more thought.

LGTM=rsc
R=golang-codereviews, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/66600043
2014-02-24 19:48:06 +01:00
Rob Pike
c687be423c crypto/md5,sha1: add examples for Sum
LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/66900044
2014-02-24 10:40:55 -08:00
Dmitriy Vyukov
cd13a57b0a testing: fix bogus benchmark
Fatal must not be called from secondary goroutines.
Fixes #7401.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/67820047
2014-02-24 21:12:44 +04:00
Dmitriy Vyukov
5b6aaba1ce testing: improve diagnosis of a potential misuse of RunParallel
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/68230045
2014-02-24 21:08:37 +04:00
Dmitriy Vyukov
ea87501750 runtime: fix heap memory corruption
With concurrent sweeping finc if modified by runfinq and queuefinalizer concurrently.
Fixes crashes like this one:
http://build.golang.org/log/6ad7b59ef2e93e3c9347eabfb4c4bd66df58fd5a
Fixes #7324.
Update #7396

LGTM=rsc
R=golang-codereviews, minux.ma, rsc
CC=golang-codereviews, khr
https://golang.org/cl/67980043
2014-02-24 20:53:50 +04:00
Dmitriy Vyukov
6e612ae0f5 runtime: fix potential memory corruption
Reinforce the guarantee that MSpan_EnsureSwept actually ensures that the span is swept.
I have not observed crashes related to this, but I do not see why it can't crash as well.

LGTM=rsc
R=golang-codereviews
CC=golang-codereviews, khr, rsc
https://golang.org/cl/67990043
2014-02-24 20:53:20 +04:00
Dmitriy Vyukov
69257d17fe runtime: use RunParallel in more benchmarks
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/68020043
2014-02-24 20:50:12 +04:00
Dmitriy Vyukov
bb9531e11b time: use RunParallel in benchmarks
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/68060043
2014-02-24 20:47:17 +04:00
Dmitriy Vyukov
51b9879a90 math/big: use RunParallel in benchmarks
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/67830044
2014-02-24 20:46:56 +04:00
Dmitriy Vyukov
44cc8e5cc9 fmt: use RunParallel in benchmarks
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/67910046
2014-02-24 20:46:25 +04:00
Mikio Hara
2ff431189e syscall: regenerate Flock_t to make it compliant with EABI
Note that current z-files for linux/amd64,386,arm are based on 3.2 kernel.

LGTM=iant
R=golang-codereviews, dave, bradfitz, gobot, iant
CC=golang-codereviews
https://golang.org/cl/59160044
2014-02-24 08:36:56 -08:00
Dmitriy Vyukov
1163127def testing: diagnose a potential misuse of RunParallel
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/68030043
2014-02-24 20:32:28 +04:00
Dmitriy Vyukov
96d5229818 net/http: use RunParallel in benchmarks
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/68070043
2014-02-24 20:28:14 +04:00
Dmitriy Vyukov
b5705ed9ab net/rpc: use RunParallel in benchmarks
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/68040044
2014-02-24 20:23:35 +04:00
Dmitriy Vyukov
0ef0d6cd7b runtime: fix double symbol definition
runfinqv is already defined the same way on line 271.
There may also be something to fix in compiler/linker wrt diagnostics.
Fixes #7375.

LGTM=bradfitz
R=golang-codereviews, dave, bradfitz
CC=golang-codereviews
https://golang.org/cl/67850044
2014-02-24 20:23:03 +04:00
Dave Cheney
dd740343e0 runtime: stack allocate Panic structure during runtime.panic
Update #7347

When runtime.panic is called the *Panic is malloced from the heap. This can lead to a gc cycle while panicing which can make a bad situation worse.

It appears to be possible to stack allocate the Panic and avoid malloc'ing during a panic.

Ref: https://groups.google.com/d/topic/golang-dev/OfxqpklGkh0/discussion

LGTM=minux.ma, dvyukov, rsc
R=r, minux.ma, gobot, rsc, dvyukov
CC=golang-codereviews
https://golang.org/cl/66830043
2014-02-24 11:09:19 -05:00
Jay Weisskopf
86c976ffd0 runtime: use monotonic clock for timers (linux/386, linux/amd64)
This lays the groundwork for making Go robust when the system's
calendar time jumps around. All input values to the runtimeTimer
struct now use the runtime clock as a common reference point.
This affects net.Conn.Set[Read|Write]Deadline(), time.Sleep(),
time.Timer, etc. Under normal conditions, behavior is unchanged.

Each platform and architecture's implementation of runtime·nanotime()
should be modified to use a monotonic system clock when possible.

Platforms/architectures modified and tested with monotonic clock:
  linux/x86     - clock_gettime(CLOCK_MONOTONIC)

Update #6007

LGTM=dvyukov, rsc
R=golang-codereviews, dvyukov, alex.brainman, stephen.gutekanst, dave, rsc, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/53010043
2014-02-24 10:57:46 -05:00
Patrick Mézard
7403071ada time: explicitely mention Tickers have to be stopped
LGTM=rsc
R=golang-codereviews, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/64770043
2014-02-24 10:18:40 -05:00
Shane Hansen
f12a167ba2 gdb: Add partial python3 + go1.2 support to runtime-gdb.py
Update #6963 Fixes pretty printing maps and updates
functions for interacting with $len(). goroutine $n bt
remains not working. Tested on gdb using python 2 and 3.
Fixes #7052
Update #6963
Fixes #6698

LGTM=rsc
R=golang-codereviews, josharian, rsc
CC=golang-codereviews
https://golang.org/cl/53590043
2014-02-24 10:13:27 -05:00
Robert Daniel Kortschak
b1c5bafda3 net/http: don't pile up defers in b.N loop
One defer was not removed in CL61150043.

LGTM=dvyukov
R=bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/64600044
2014-02-24 18:17:07 +04:00
Dmitriy Vyukov
f6d18c5ee9 runtime/race: fix finalizer tests
After "runtime: combine small NoScan allocations" finalizers
for small objects run more non deterministically.
TestRaceFin episodically fails on my darwin/amd64.

LGTM=khr
R=golang-codereviews, khr, dave
CC=golang-codereviews
https://golang.org/cl/56970043
2014-02-24 18:12:46 +04:00
Mikio Hara
699aa37d03 syscall: add fcntl test
Also updates documentation.

LGTM=minux.ma
R=iant, bradfitz, nightlyone, minux.ma
CC=golang-codereviews
https://golang.org/cl/58660044
2014-02-24 20:35:01 +09:00
Mikio Hara
fe330cf5bb syscall: make mkerrors.sh work with clang
LGTM=iant
R=golang-codereviews, minux.ma, gobot, iant
CC=golang-codereviews
https://golang.org/cl/67170043
2014-02-24 16:34:51 +09:00
Mikio Hara
2dcf8593ac syscall: consolidate test cases for Unix-like systems
As per request from minux in CL 61520049, this CL consolidates
existing test cases for Unix-like systems into one file except
Linux-specific credential test.

LGTM=bradfitz
R=iant, minux.ma, bradfitz
CC=golang-codereviews
https://golang.org/cl/67800044
2014-02-24 14:41:10 +09:00
Anfernee Yongkun Gui
4228092b2c net/http: fix comment in connectMethod's key format
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/66990045
2014-02-23 21:18:41 -08:00
Shenghou Ma
e33e47e844 cmd/gc: diagnose "make([]T, non-integer)" correctly.
Fixes #7223.

LGTM=rsc
R=golang-codereviews, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/63040043
2014-02-23 16:31:48 -05:00
Shenghou Ma
d4a9bbef51 cmd/ld: don't emit unreachable dynimport symbols in ELF symtab.
Fix build for Dragonfly BSD.
Fixes #7318.
Fixes #7367.

LGTM=jsing, iant
R=jsing, iant, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/64340043
2014-02-23 16:20:40 -05:00
Patrick Mézard
d4b6a198b3 os/exec: explicitly mention Cmd.Wait() has to be called eventually
LGTM=minux.ma, r
R=golang-codereviews, minux.ma, r
CC=golang-codereviews
https://golang.org/cl/67280043
2014-02-23 12:53:02 -08:00
Rob Pike
f1e4184db6 testing: improve introduction to package comment
Fixes #7361.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/66910045
2014-02-21 14:35:54 -08:00
Adam Langley
fca335e91a crypto/tls: enforce that either ServerName or InsecureSkipVerify be given.
crypto/tls has two functions for creating a client connection: Dial,
which most users are expected to use, and Client, which is the
lower-level API.

Dial does what you expect: it gives you a secure connection to the host
that you specify and the majority of users of crypto/tls appear to work
fine with it.

Client gives more control but needs more care. Specifically, if it
wasn't given a server name in the tls.Config then it didn't check that
the server's certificates match any hostname - because it doesn't have
one to check against. It was assumed that users of the low-level API
call VerifyHostname on the certificate themselves if they didn't supply
a hostname.

A review of the uses of Client both within Google and in a couple of
external libraries has shown that nearly all of them got this wrong.

Thus, this change enforces that either a ServerName or
InsecureSkipVerify is given. This does not affect tls.Dial.

See discussion at https://groups.google.com/d/msg/golang-nuts/4vnt7NdLvVU/b1SJ4u0ikb0J.

Fixes #7342.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/67010043
2014-02-21 15:56:41 -05:00
Russ Cox
59847321a7 reflect: better error for walking through nil embedded struct pointer
The old error was "call of reflect.Value.Field on ptr Value".

http://play.golang.org/p/Zm-ZbQaPeR

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/67020043
2014-02-21 13:51:22 -05:00
Russ Cox
e56c6e7535 runtime/debug: add SetPanicOnFault
SetPanicOnFault allows recovery from unexpected memory faults.
This can be useful if you are using a memory-mapped file
or probing the address space of the current program.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/66590044
2014-02-20 16:18:05 -05:00
Russ Cox
67c83db60d runtime: use goc2c as much as possible
Package runtime's C functions written to be called from Go
started out written in C using carefully constructed argument
lists and the FLUSH macro to write a result back to memory.

For some functions, the appropriate parameter list ended up
being architecture-dependent due to differences in alignment,
so we added 'goc2c', which takes a .goc file containing Go func
declarations but C bodies, rewrites the Go func declaration to
equivalent C declarations for the target architecture, adds the
needed FLUSH statements, and writes out an equivalent C file.
That C file is compiled as part of package runtime.

Native Client's x86-64 support introduces the most complex
alignment rules yet, breaking many functions that could until
now be portably written in C. Using goc2c for those avoids the
breakage.

Separately, Keith's work on emitting stack information from
the C compiler would require the hand-written functions
to add #pragmas specifying how many arguments are result
parameters. Using goc2c for those avoids maintaining #pragmas.

For both reasons, use goc2c for as many Go-called C functions
as possible.

This CL is a replay of the bulk of CL 15400047 and CL 15790043,
both of which were reviewed as part of the NaCl port and are
checked in to the NaCl branch. This CL is part of bringing the
NaCl code into the main tree.

No new code here, just reformatting and occasional movement
into .h files.

LGTM=r
R=dave, alex.brainman, r
CC=golang-codereviews
https://golang.org/cl/65220044
2014-02-20 15:58:47 -05:00
Russ Cox
258c278e12 cmd/pack: fix match
Match used len(ar.files) == 0 to mean "match everything"
but it also deleted matched things from the list, so once you
had matched everything you asked for, match returned true
for whatever was left in the archive too.

Concretely, if you have an archive containing f1, f2, then
        pack t foo.a f1
would match f1 and then, because len(ar.files) == 0 after
deleting f1 from the match list, also match f2.

Avoid the problem by recording explicitly whether match
matches everything.

LGTM=r, dsymonds
R=r, dsymonds
CC=golang-codereviews
https://golang.org/cl/65630046
2014-02-20 15:50:30 -05:00
Russ Cox
574e0f9a48 cmd/gc: explain 'nointerface' method failure
The message used to say that there was a type
mismatch, which is not necessarily true.

TBR=ken2
CC=golang-codereviews
https://golang.org/cl/66600044
2014-02-20 15:42:08 -05:00
Chris Manghane
a8a7f18aea cmd/gc: make embedded, unexported fields read-only.
Fixes #7363.

LGTM=gri
R=gri, rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/66510044
2014-02-20 11:32:55 -08:00
Josh Bleecher Snyder
15ec569ba9 cmd/ld: fix off-by-one error in DWARF .debug_line transcription
The liblink refactor changed the DWARF .debug_line flow control. The mapping was off by one pcline entry. The fix here preserves pc until it can be compared to pcline.pc.

Sample dwarfdump .debug_line output for main.main from the program in issue 7351, before liblink (correct):

0x0000003c: 00 Extended: <9> 02 DW_LNE_set_address( 0x0000000000002000 )
0x00000047: 03 DW_LNS_advance_line( 6 )
0x00000049: 01 DW_LNS_copy
            0x0000000000002000      1      7      0 is_stmt

0x0000004a: 8b address += 21,  line += 1
            0x0000000000002021      1      8      0 is_stmt

0x0000004b: 02 DW_LNS_advance_pc( 153 )
0x0000004e: 03 DW_LNS_advance_line( 1 )
0x00000050: 01 DW_LNS_copy
            0x00000000000020ba      1      9      0 is_stmt

After liblink (off by one entry):

0x00001bbf: 00 Extended: <9> 02 DW_LNE_set_address( 0x0000000000002000 )
0x00001bca: 02 DW_LNS_advance_pc( 33 )
0x00001bcc: 03 DW_LNS_advance_line( 6 )
0x00001bce: 01 DW_LNS_copy
            0x0000000000002021      1      7      0 is_stmt

0x00001bcf: 02 DW_LNS_advance_pc( 153 )
0x00001bd2: 03 DW_LNS_advance_line( 1 )
0x00001bd4: 01 DW_LNS_copy
            0x00000000000020ba      1      8      0 is_stmt

0x00001bd5: 02 DW_LNS_advance_pc( 153 )
0x00001bd8: 03 DW_LNS_advance_line( 1 )
0x00001bda: 01 DW_LNS_copy
            0x0000000000002153      1      9      0 is_stmt

After this CL (the line 9 pc offset changed due to intervening compiler changes):

0x00001d07: 00 Extended: <9> 02 DW_LNE_set_address( 0x0000000000002000 )
0x00001d12: 03 DW_LNS_advance_line( 6 )
0x00001d14: 01 DW_LNS_copy
            0x0000000000002000      1      7      0 is_stmt

0x00001d15: 8b address += 21,  line += 1
            0x0000000000002021      1      8      0 is_stmt

0x00001d16: 02 DW_LNS_advance_pc( 189 )
0x00001d19: 03 DW_LNS_advance_line( 1 )
0x00001d1b: 01 DW_LNS_copy
            0x00000000000020de      1      9      0 is_stmt

Fixes #7351.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/66290043
2014-02-20 09:06:32 -08:00
David du Colombier
58a9268f26 os: fix Rename on Plan 9
Rename should fail when the directory doesn't match.
It will fix the newly introduced test from cmd/pack
on Plan 9.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/65270044
2014-02-20 07:59:38 +01:00
Alex Brainman
5a6af5fc94 net/http: remove tmp file created in TestMultipartReaderOrder
LGTM=minux.ma
R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/66470043
2014-02-20 17:24:25 +11:00
Rob Pike
3e37720bce syscall: terminate error string in exec package on Plan 9
Try to prevent messages like this:
        './pack' file does not exist����������������������������������������������������������������������������������������������������
TBR=adonovan

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/66270043
2014-02-19 17:17:36 -08:00
Alex Brainman
0d11cd1b6e cmd/pack: provide executable name in TestHello
otherwise go build command adds .exe suffix

Fixes #7362

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/66250043
2014-02-20 11:29:37 +11:00
Rob Pike
00b76713a7 cmd/pack: another attempt to fix the build for TestHello
Plan 9 uses single quotes, not double quotes. I should have known.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/66240043
2014-02-19 16:12:05 -08:00
Rob Pike
2037756fcc cmd/pack: don't look for " in output from go env
Windows at least doesn't emit one.
Maybe fix Windows build.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/66120046
2014-02-19 15:33:47 -08:00
Rob Pike
8ac499916e cmd/pack: dump output of command of "go env" command in test
Get more information to help understand build failure on Plan 9.
Also Windows.
(TestHello is failing because GOCHAR does not appear in output.
What does?)

Update #7362

LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/66070044
2014-02-19 15:01:50 -08:00
Russ Cox
53061193f1 cmd/gc, runtime: enable precisestack by default
[Repeat of CL 64100044, after 32-bit fix in CL 66170043.]

Precisestack makes stack collection completely precise,
in the sense that there are no "used and not set" errors
in the collection of stack frames, no times where the collector
reads a pointer from a stack word that has not actually been
initialized with a pointer (possibly a nil pointer) in that function.

The most important part is interfaces: precisestack means
that if reading an interface value, the interface value is guaranteed
to be initialized, meaning that the type word can be relied
upon to be either nil or a valid interface type word describing
the data word.

This requires additional zeroing of certain values on the stack
on entry, which right now costs about 5% overall execution
time in all.bash. That cost will come down before Go 1.3
(issue 7345).

There are at least two known garbage collector bugs right now,
issues 7343 and 7344. The first happens even without precisestack.
The second I have only seen with precisestack, but that does not
mean that precisestack is what causes it. In fact it is very difficult
to explain by what precisestack does directly. Precisestack may
be exacerbating an existing problem. Both of those issues are
marked for Go 1.3 as well.

The reasons for enabling precisestack now are to give it more
time to soak and because the copying stack work depends on it.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/65820044
2014-02-19 17:09:08 -05:00
Russ Cox
1ca1cbea65 cmd/5g, cmd/8g: zero ambiguously live values on entry
The code here is being restored after its deletion in CL 14430048.

I restored the copy in cmd/6g in CL 56430043 but neglected the
other two.

This is the reason that enabling precisestack only worked on amd64.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/66170043
2014-02-19 17:08:55 -05:00
Russ Cox
0649a73606 cmd/pack: add 'c' command to create archive
When Go 1.3 is released, this will keep existing
Go 1.2 build scripts that use 'go tool pack grc' working.
For efficiency, such scripts should be changed to
use 6g -pack instead, but keeping the old behavior
available enables a more graceful transition.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/66130043
2014-02-19 17:08:44 -05:00
Rob Pike
78404dfb84 cmd/gc: fix printf format in typecheck.c
There are probably more of these, but bound and len are 64 bits so use %lld
in message about array index out of bounds.
Fixes the 386 build.

LGTM=bradfitz, rsc
R=rsc, bradfitz
CC=golang-codereviews, rickarnoldjr
https://golang.org/cl/66110043
2014-02-19 15:50:50 -05:00
Rob Pike
e6f5debd0c cmd/pack: use log.SetPrefix to make log calls more compact and consistent
Taking my own advice from a review of addr2line.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/65950044
2014-02-19 11:42:34 -08:00
Russ Cox
8efb5e7d63 cmd/addr2line: reimplement in Go
We never updated libmach for the new object file format,
so it the existing 'go tool addr2line' is broken.
Reimplement in Go to fix.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/66020043
2014-02-19 14:33:11 -05:00
Rick Arnold
8eec4ebd7d cmd/gc: fix array index out of bounds error message
The error message was previously off by one in all cases.

Fixes #7150.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/65850043
2014-02-19 11:29:36 -08:00
Adam Langley
d4d77052b4 crypto/x509: add example of using a custom root list.
Fixes #6267.

LGTM=r, josharian
R=golang-codereviews, josharian, r
CC=golang-codereviews
https://golang.org/cl/61020043
2014-02-19 11:18:35 -05:00
Adam Langley
80692a3f81 crypto/tls: improve documentation for ServerName.
Users of the low-level, Client function are frequenctly missing the
fact that, unless they pass a ServerName to the TLS connection then it
cannot verify the certificates against any name.

This change makes it clear that at least one of InsecureSkipVerify and
ServerName should always be set.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/65440043
2014-02-19 11:17:09 -05:00
Russ Cox
ae38b03f6c cmd/go: skip writing dwarf debug info for ephemeral binaries
Update #6853

For an ephemeral binary - one created, run, and then deleted -
there is no need to write dwarf debug information, since the
binary will not be used with gdb. In this case, instruct the linker
not to spend time and disk space generating the debug information
by passing the -w flag to the linker.

Omitting dwarf information reduces the size of most binaries by 25%.
We may be more aggressive about this in the future.

LGTM=bradfitz, r
R=r, bradfitz
CC=golang-codereviews
https://golang.org/cl/65890043
2014-02-19 10:01:15 -05:00
Russ Cox
2541cc8197 cmd/ld: drop gcargs, gclocals symbols from symbol table
Update #6853

Every function now has a gcargs and gclocals symbol
holding associated garbage collection information.
Put them all in the same meta-symbol as the go.func data
and then drop individual entries from symbol table.

Removing gcargs and gclocals reduces the size of a
typical binary by 10%.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/65870044
2014-02-19 10:00:44 -05:00
Rémy Oudompheng
475e7d0372 cmd/gc: fix handling of append with -race.
Also re-enable race tests in run.bash.

Fixes #7334.

LGTM=rsc
R=rsc, dvyukov, iant, bradfitz, dave
CC=golang-codereviews
https://golang.org/cl/65740043
2014-02-19 08:19:27 +01:00
Rémy Oudompheng
96678f9dc0 cmd/gc: reject incorrect use of fallthrough.
Fixes #6500.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/14920053
2014-02-19 07:55:03 +01:00
Rob Pike
8b0b994c08 reflect: improve documentation of IsNil
IsNil isn't quite the same as == nil, as this snippet shows:

// http://play.golang.org/p/huomslDZgw
package main

import "fmt"
import "reflect"

func main() {
        var i interface{}
        v := reflect.ValueOf(i)
        fmt.Println(v.IsValid(), i == nil)
        fmt.Println(v.IsNil())
}

The fact that IsNil panics if you call it with an untyped nil
was not apparent. Verbiage added for clarity.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/65480043
2014-02-18 22:33:59 -08:00
Russ Cox
964f6d3ec4 cmd/ld: remove Plan 9 symbol table
Update #6853

Nothing reads the Plan 9 symbol table anymore.
The last holdout was 'go tool nm', but since being rewritten in Go
it uses the standard symbol table for the binary format
(ELF, Mach-O, PE) instead.

Removing the Plan 9 symbol table saves ~15% disk space
on most binaries.

Two supporting changes included in this CL:

debug/gosym: use Go 1.2 pclntab to synthesize func-only
symbol table when there is no Plan 9 symbol table

debug/elf, debug/macho, debug/pe: ignore final EOF from ReadAt

LGTM=r
R=r, bradfitz
CC=golang-codereviews
https://golang.org/cl/65740045
2014-02-18 23:41:15 -05:00
Rick Arnold
86ac618145 cmd/link: change cloneProg to return the cloned value
The code was returning the original value rather than the cloned value
resulting in the tests not being repeatable.

Fixes #7111.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/65720045
2014-02-18 17:59:44 -08:00
Brad Fitzpatrick
a7fb31833b crypto/rc4: test the portable version too
Prevent bitrot. (similar to the previous sha1 and md5 CLs)

Fixes #6642

LGTM=agl
R=agl, dave
CC=golang-codereviews
https://golang.org/cl/65690043
2014-02-18 15:16:07 -08:00
Marcel van Lohuizen
746d636859 unicode: upgrade to Unicode 6.3.0
This is a relatively minor change.

This does not result in changes to go.text/unicode/norm. The go.text
packages will therefore be relatively unaffected. It does make the
way for an upgrade to CLDR 24, though.

The tests of all.bash pass, as well as the tests in go.text after
this update.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/65400044
2014-02-18 20:12:59 +01:00
Alex Brainman
72f2b56a67 run.bat: use double-colon to comment text
LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/64980043
2014-02-18 16:48:34 +11:00
Andrew Gerrand
13d85668ac go/doc: document the conditions where examples are "playable"
LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/64910043
2014-02-18 15:53:22 +11:00
Russ Cox
aad23e708c undo CL 64100044 / 04d062c2e81c
broke 32-bit builds

««« original CL description
cmd/gc, runtime: enable precisestack by default

Precisestack makes stack collection completely precise,
in the sense that there are no "used and not set" errors
in the collection of stack frames, no times where the collector
reads a pointer from a stack word that has not actually been
initialized with a pointer (possibly a nil pointer) in that function.

The most important part is interfaces: precisestack means
that if reading an interface value, the interface value is guaranteed
to be initialized, meaning that the type word can be relied
upon to be either nil or a valid interface type word describing
the data word.

This requires additional zeroing of certain values on the stack
on entry, which right now costs about 5% overall execution
time in all.bash. That cost will come down before Go 1.3
(issue 7345).

There are at least two known garbage collector bugs right now,
issues 7343 and 7344. The first happens even without precisestack.
The second I have only seen with precisestack, but that does not
mean that precisestack is what causes it. In fact it is very difficult
to explain by what precisestack does directly. Precisestack may
be exacerbating an existing problem. Both of those issues are
marked for Go 1.3 as well.

The reasons for enabling precisestack now are to give it more
time to soak and because the copying stack work depends on it.

LGTM=r
R=r
CC=golang-codereviews, iant, khr
https://golang.org/cl/64100044
»»»

TBR=r
CC=golang-codereviews
https://golang.org/cl/65230043
2014-02-17 21:34:58 -05:00
Nigel Tao
d2f61cc660 cmd/link: fix comment typo.
LGTM=dsymonds
R=dsymonds
CC=golang-codereviews
https://golang.org/cl/64100045
2014-02-18 13:04:59 +11:00
Russ Cox
ecf700b5ee cmd/gc, runtime: enable precisestack by default
Precisestack makes stack collection completely precise,
in the sense that there are no "used and not set" errors
in the collection of stack frames, no times where the collector
reads a pointer from a stack word that has not actually been
initialized with a pointer (possibly a nil pointer) in that function.

The most important part is interfaces: precisestack means
that if reading an interface value, the interface value is guaranteed
to be initialized, meaning that the type word can be relied
upon to be either nil or a valid interface type word describing
the data word.

This requires additional zeroing of certain values on the stack
on entry, which right now costs about 5% overall execution
time in all.bash. That cost will come down before Go 1.3
(issue 7345).

There are at least two known garbage collector bugs right now,
issues 7343 and 7344. The first happens even without precisestack.
The second I have only seen with precisestack, but that does not
mean that precisestack is what causes it. In fact it is very difficult
to explain by what precisestack does directly. Precisestack may
be exacerbating an existing problem. Both of those issues are
marked for Go 1.3 as well.

The reasons for enabling precisestack now are to give it more
time to soak and because the copying stack work depends on it.

LGTM=r
R=r
CC=golang-codereviews, iant, khr
https://golang.org/cl/64100044
2014-02-17 20:12:40 -05:00
Russ Cox
be1c71ecb5 runtime: clear f, arg to avoid leak in timerproc
I have seen this cause leaks where not all objects in a sync.Pool
would be reclaimed during the sync package tests.
I found it while debugging the '0 of 100 finalized' failure we are
seeing on arm, but it seems not to be the root cause for that one.

LGTM=dave, dvyukov
R=golang-codereviews, dave, dvyukov
CC=golang-codereviews
https://golang.org/cl/64920044
2014-02-17 20:11:53 -05:00
Dave Cheney
5c604f844a undo CL 64820044 / 4f9dee8402af
Callers of md5.Sum should do so to avoid allocations, the example did not demonstate this property.

««« original CL description
crypto/md5: add example for Sum

LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/64820044

»»»

LGTM=minux.ma
R=r, minux.ma
CC=golang-codereviews
https://golang.org/cl/65180043
2014-02-18 08:04:01 +11:00
ChaiShushan
2be94b1ba6 crypto/md5: add example for Sum
LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/64820044
2014-02-17 14:33:00 +11:00
Ian Lance Taylor
637e1f7da0 cmd/gc: correct function name in internal error messages
LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/64090043
2014-02-16 19:14:06 -08:00
Dmitriy Vyukov
c3922f0a63 testing: ease writing parallel benchmarks
Add b.RunParallel function that captures parallel benchmark boilerplate:
creates worker goroutines, joins worker goroutines, distributes work
among them in an efficient way, auto-tunes grain size.
Fixes #7090.

R=bradfitz, iant, josharian, tracey.brendan, r, rsc, gobot
CC=golang-codereviews
https://golang.org/cl/57270043
2014-02-17 06:29:56 +04:00
Dmitriy Vyukov
a1aee55bd1 net/http: close body in benchmarks
Is it required? Why don't we do it?

R=bradfitz
CC=golang-codereviews
https://golang.org/cl/61150043
2014-02-17 06:04:31 +04:00
Dave Cheney
a50c5fe6c3 go/build: temporarily disable cgo for freebsd/arm
Update #7331

cgo is currently broken on freebsd/arm.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/63900043
2014-02-16 20:46:03 +11:00
Russ Cox
9ed095bc59 build: disable race detector test in run.bat on windows
CL 64170043 disabled it in run.bash for Unix systems.
I did not realize Windows systems also ran the race detector test.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/64480043
2014-02-15 20:03:41 -05:00
Russ Cox
1a3ee6794c cmd/gc: record &x[0] as taking address of x, if x is an array
Not recording the address being taken was causing
the liveness analysis not to preserve x in the absence
of direct references to x, which in turn was making the
net test fail with GOGC=0.

In addition to the test, this fixes a bug wherein
        GOGC=0 go test -short net
crashed if liveness analysis was in use (like at tip, not like Go 1.2).

TBR=ken2
CC=golang-codereviews
https://golang.org/cl/64470043
2014-02-15 20:01:15 -05:00
Russ Cox
8b6ef69e23 cmd/gc: avoid pointer beyond array in range loop
This problem was discovered by reading the code.
I have not seen it in practice, nor do I have any ideas
on how to trigger it reliably in a test. But it's still worth
fixing.

TBR=ken2
CC=golang-codereviews
https://golang.org/cl/64370046
2014-02-15 20:00:57 -05:00
Russ Cox
7056b05f7a debug/elf: correct test failure print
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/64380043
2014-02-15 20:00:15 -05:00
Russ Cox
7a7c0ffb47 cmd/gc: correct liveness for fat variables
The VARDEF placement must be before the initialization
but after any final use. If you have something like s = ... using s ...
the rhs must be evaluated, then the VARDEF, then the lhs
assigned.

There is a large comment in pgen.c on gvardef explaining
this in more detail.

This CL also includes Ian's suggestions from earlier CLs,
namely commenting the use of mode in link.h and fixing
the precedence of the ~r check in dcl.c.

This CL enables the check that if liveness analysis decides
a variable is live on entry to the function, that variable must
be a function parameter (not a result, and not a local variable).
If this check fails, it indicates a bug in the liveness analysis or
in the generated code being analyzed.

The race detector generates invalid code for append(x, y...).
The code declares a temporary t and then uses cap(t) before
initializing t. The new liveness check catches this bug and
stops the compiler from writing out the buggy code.
Consequently, this CL disables the race detector tests in
run.bash until the race detector bug can be fixed
(golang.org/issue/7334).

Except for the race detector bug, the liveness analysis check
does not detect any problems (this CL and the previous CLs
fixed all the detected problems).

The net test still fails with GOGC=0 but the rest of the tests
now pass or time out (because GOGC=0 is so slow).

TBR=iant
CC=golang-codereviews
https://golang.org/cl/64170043
2014-02-15 10:58:55 -05:00
Rémy Oudompheng
15d294991f cmd/gc: do not lower copy to a value node in go/defer.
The existing tests issue4463.go and issue4654.go had failures at
typechecking and did not test walking the AST.

Fixes #7272.

LGTM=khr
R=khr, rsc, iant
CC=golang-codereviews
https://golang.org/cl/60550044
2014-02-15 16:39:04 +01:00
Rob Pike
71575a97ab text/template: don't panic when function call evaluates a nil pointer
Catch the error instead and return it to the user. Before this fix,
the template package panicked. Now you get:
        template: bug11:1:14: executing "bug11" at <.PS>: dereference of nil pointer of type *string
Extended example at http://play.golang.org/p/uP6pCW3qKT

Fixes #7333.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/64150043
2014-02-14 16:26:47 -08:00
Adam Langley
9f0008bb93 compress/bzip2: support superfluous Huffman levels.
These should never be found in a bzip2 file but it does appear that
there's a buggy encoder that is producing them. Since the official
bzip2 handles this case, this change makes the Go code do likewise.

With this change, the code produces the same output as the official
bzip2 code on the invalid example given in the bug.

Fixes #7279.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/64010043
2014-02-14 17:17:19 -05:00
David du Colombier
56872f02f0 runtime: fix "invalid address in sys call" on Plan 9
Rfork is not splitting the stack when creating a new thread,
so the parent and child are executing on the same stack.
However, if the parent returns and keeps executing before
the child can read the arguments from the parent stack,
the child will not see the right arguments. The solution
is to load the needed pieces from the parent stack into
register before INT $64.

Thanks to Russ Cox for the explanation.

LGTM=rsc
R=rsc
CC=ality, golang-codereviews
https://golang.org/cl/64140043
2014-02-14 22:27:47 +01:00
Michael T. Jones
1dc82d2563 math/big: Add text marshaller interface to Int
Fixes #7329

LGTM=gri
R=gri, bradfitz, mtj
CC=golang-codereviews
https://golang.org/cl/63710043
2014-02-14 12:57:03 -08:00
Elias Naur
9b0736fc58 cmd/go: remove cross compiling restriction on cgo
A previous CL added support for cross compiling with cgo, but
missed the GOOS check in cmd/go. Remove it.

Update #4714

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/57210046
2014-02-14 11:36:52 -08:00
Ian Lance Taylor
92b4741728 runtime: if traceback sees a breakpoint, don't change the PC
Changing the PC confuses gdb, because execution does not
continue where gdb expects it.  Not changing the PC has the
potential to confuse a stack dump, but when running under gdb
it seems better to confuse a stack dump than to confuse gdb.

Fixes #6776.

LGTM=rsc
R=golang-codereviews, dvyukov, rsc
CC=golang-codereviews
https://golang.org/cl/49580044
2014-02-14 11:06:53 -08:00
Mikio Hara
8c0a52f28d net: handle IP interface stack correctly on linux
A configuration like the following:

7: tun6rd: <NOARP,UP,LOWER_UP> mtu 1280
        link/sit 10.11.12.13 brd 0.0.0.0
        inet 1.2.3.4/24 scope global tun6rd
        inet6 2014:1001:a0b:c0d::1/32 scope global
        inet6 ::10.11.12.13/128 scope global
9: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1496
        link/ppp
        inet 192.168.101.234 peer 192.168.102.234/32 scope global ppp0
        inet 10.20.30.40/24 scope global ppp0
        inet6 2014:1002::1/64 scope global
11: tun0@NONE: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1480
        link/ipip 192.168.202.34 peer 192.168.202.69
        inet 192.168.10.1/24 scope global tunnel0
        inet6 2014:1003::1/64 scope global

will be handled like below.

"tun6rd": flags "up", ifindex 7, mtu 1280
        hardware address ""
        interface address "1.2.3.4/24"
        interface address "2014:1001:a0b:c0d::1/32"
        interface address "::a0b:c0d/128"
"ppp0": flags "up|pointtopoint|multicast", ifindex 9, mtu 1496
        hardware address ""
        interface address "192.168.101.234/32"
        interface address "10.20.30.40/24"
        interface address "2014:1002::1/64"
"tun0": flags "up|pointtopoint", ifindex 11, mtu 1480
        hardware address ""
        interface address "192.168.10.1/24"
        interface address "2014:1003::1/64"

Fixes #6433.
Update #4839

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/57700043
2014-02-15 01:07:51 +09:00
Mikio Hara
be9c514f84 syscall: make use of include/linux when generating system constants
On Linux include/net directory is just to help porting applications
from BSDs and files under net keep less information than include/linux.
Making use of files under include/linux instead of include/net prevents
lack of information.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/63930043
2014-02-15 00:47:28 +09:00
Dmitriy Vyukov
47534ddc68 runtime: remove misleading message during crash
The following checkdead message is false positive:

$ go test -race -c runtime
$ ./runtime.test -test.cpu=2 -test.run=TestSmhasherWindowed -test.v
=== RUN TestSmhasherWindowed-2
checkdead: find g 18 in status 1
SIGABRT: abort
PC=0x42bff1

LGTM=rsc
R=golang-codereviews, gobot, rsc
CC=golang-codereviews, iant, khr
https://golang.org/cl/59490046
2014-02-14 13:24:48 +04:00
Dmitriy Vyukov
e71d147750 runtime: fix mem profile when both large and small objects are allocated at the same stack
Currently small and large (size>rate) objects are merged into a single entry.
But rate adjusting is required only for small objects.
As a result pprof either incorrectly adjusts large objects
or does not adjust small objects.
With this change objects of different sizes are stored in different buckets.

LGTM=rsc
R=golang-codereviews, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/59220049
2014-02-14 13:20:41 +04:00
Russ Cox
f0023cf1d5 cmd/gc: fix build for 'default unsigned char' compilers
TBR=iant
CC=golang-codereviews
https://golang.org/cl/63680045
2014-02-14 00:43:43 -05:00
Shenghou Ma
6a9b98888e cmd/go: hide the "TERM" environment variable from "go env"
It's implementation detail.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/63690043
2014-02-14 00:38:55 -05:00
Russ Cox
af545660d5 cmd/gc: correct liveness for various non-returning functions
When the liveness code doesn't know a function doesn't return
(but the generated code understands that), the liveness analysis
invents a control flow edge that is not really there, which can cause
variables to seem spuriously live. This is particularly bad when the
variables are uninitialized.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/63720043
2014-02-14 00:38:24 -05:00
Dmitriy Vyukov
eca55f5ac0 runtime: fix windows cpu profiler
Currently it periodically fails with the following message.
The immediate cause is the wrong base register when obtaining g
in sys_windows_amd64/386.s.
But there are several secondary problems as well.

runtime: unknown pc 0x0 after stack split
panic: invalid memory address or nil pointer dereference
fatal error: panic during malloc
[signal 0xc0000005 code=0x0 addr=0x60 pc=0x42267a]

runtime stack:
runtime.panic(0x7914c0, 0xc862af)
        c:/src/perfer/work/windows-amd64-a15f344a9efa/go/src/pkg/runtime/panic.c:217 +0x2c
runtime: unexpected return pc for runtime.externalthreadhandler called from 0x0

R=rsc, alex.brainman
CC=golang-codereviews
https://golang.org/cl/63310043
2014-02-14 09:20:51 +04:00
Russ Cox
ab9e8d068a cmd/gc: correct liveness for func ending in panic
The registerization code needs the function to end in a RET,
even if that RET is actually unreachable.

The liveness code needs to avoid such unreachable RETs.
It had a special case for final RET after JMP, but no case
for final RET after UNDEF. Instead of expanding the special
cases, let fixjmp - which already knows what is and is not
reachable definitively - mark the unreachable RET so that
the liveness code can identify it.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/63680043
2014-02-13 23:56:53 -05:00
Russ Cox
02ae91f342 cmd/gc: correct liveness for wrappers containing tail jumps
A normal RET is treated as using the return values,
but a tail jump RET does not - it is jumping to the
function that is going to fill in the return values.
If a tail jump RET is recorded as using the return values,
since nothing initializes them they will be marked as
live on entry to the function, which is clearly wrong.

Found and tested by the new code in plive.c that looks
for variables that are incorrectly live on entry.
That code is disabled for now because there are other
cases remaining to be fixed. But once it is enabled,
test/live1.go becomes a real test of this CL.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/63570045
2014-02-13 23:33:20 -05:00
Russ Cox
91b1f7cb15 cmd/gc: handle variable initialization by block move in liveness
Any initialization of a variable by a block copy or block zeroing
or by multiple assignments (componentwise copying or zeroing
of a multiword variable) needs to emit a VARDEF. These cases were not.

Fixes #7205.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/63650044
2014-02-13 22:45:16 -05:00
Russ Cox
7addda685d cmd/5g, cmd/8g: fix build
The test added in CL 63630043 fails on 5g and 8g because they
were not emitting the VARDEF instruction when clearing a fat
value by clearing the components. 6g had the call in the right place.

Hooray tests.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/63660043
2014-02-13 22:30:35 -05:00
Mikio Hara
b0db7e870c syscall: fix system calls with misaligned arguments on freebsd/arm
This CL enables the current tree to work with FreeBSD 10-STABLE
on ARM EABI platforms, though there are still a few test fails.

Also updates documentation.

LGTM=iant
R=iant, dave
CC=golang-codereviews
https://golang.org/cl/61060044
2014-02-14 12:22:13 +09:00
Mikio Hara
2277e8d3c9 net: disable TestDNSThreadLimit even in non-short mode by default
TestDNSThreadLimit creates tons of DNS queries and it occasionally
causes an unintentional traffic jam and/or crash of some virtual
machine software, especially its builtin networking stuff.

We can run TestDNSThreadLimit with -dnsflood flag instead.

LGTM=dave, rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/63600043
2014-02-14 12:20:21 +09:00
Russ Cox
801e40a0a4 cmd/gc: rename AFATVARDEF to AVARDEF
The "fat" referred to being used for multiword values only.
We're going to use it for non-fat values sometimes too.

No change other than the renaming.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/63650043
2014-02-13 22:17:22 -05:00
Russ Cox
824e918ca4 cmd/gc: fix liveness for addressed results
Was spuriously marking results live on entry to function.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/63640043
2014-02-13 21:11:50 -05:00
Shenghou Ma
656a402545 cmd/gc: rephrase the invalid indexing operation error message
Old:
prog.go:9: invalid operation: this[i] (index of type int)
New:
prog.go:9: invalid operation: this[i] (type int does not support indexing)

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/52540043
2014-02-13 21:01:33 -05:00
Russ Cox
a069cf048d cmd/gc: distinguish unnamed vs blank-named return variables better
Before, an unnamed return value turned into an ONAME node n with n->sym
named ~anon%d, and n->orig == n.

A blank-named return value turned into an ONAME node n with n->sym
named ~anon%d but n->orig == the original blank n. Code generation and
printing uses n->orig, so that this node formatted as _.

But some code does not use n->orig. In particular the liveness code does
not know about the n->orig convention and so mishandles blank identifiers.
It is possible to fix but seemed better to avoid the confusion entirely.

Now the first kind of node is named ~r%d and the second ~b%d; both have
n->orig == n, so that it doesn't matter whether code uses n or n->orig.

After this change the ->orig field is only used for other kinds of expressions,
not for ONAME nodes.

This requires distinguishing ~b from ~r names in a few places that care.
It fixes a liveness analysis bug without actually changing the liveness code.

TBR=ken2
CC=golang-codereviews
https://golang.org/cl/63630043
2014-02-13 20:59:39 -05:00
Russ Cox
e5d742fcad cmd/gc: relax address-of escape analysis
Make the loop nesting depth of &x depend on where x is declared,
not on where the &x appears. The latter is only a conservative
estimate of the former. Being more careful can avoid some
variables escaping, and it is easier to reason about.

It would have avoided issue 7313, although that was still a bug
worth fixing.

Not much effect in the tree: one variable in the whole tree
is saved from a heap allocation (something in x509 parsing).

LGTM=daniel.morsing
R=daniel.morsing
CC=golang-codereviews
https://golang.org/cl/62380043
2014-02-13 19:59:09 -05:00
Markus Zimmermann
e0bb5ba52c container/list: mark must be an element of the list
The methods MoveAfter and MoveBefore of the container/list package did silently corrupt the interal structure of the list if a mark element is used which is not an element of the list.

LGTM=gri
R=golang-codereviews, gobot, gri
CC=golang-codereviews
https://golang.org/cl/60980043
2014-02-13 16:43:52 -08:00
Nick Craig-Wood
eae09a59a0 math/big: Optimise ARM assembler
Tweak the ARM assembler to improve its performance.

  * Use TEQ instead of CMP which preserves the carry flag.  This means
    we can avoid saving and restoring CPSR which is very slow.

  * Use conditional instructions to read the value of the carry flag.

  * Use 3 argument ARM instructions to save instructions

  * Improve scheduling for MOVW instructions (LDR)

  * Use RSB constant to save an instruction in bitLen

Results of -test.bench 'VV|VW|VU|WW|Bit' -test.benchtime 3s on Samsung
Exynos5 Chromebook.

There are a few small regressions in the benchmarks which I believe to
be noise, perhaps due to different cacheline alignment.

The changes to bitLen are apparently no faster, however less
instructions means less I-cache usage which is a win. I suspect it
will be a win on older ARM processors.

benchmark                 old ns/op    new ns/op    delta
BenchmarkAddVV_1                 48           14  -70.84%
BenchmarkAddVV_2                 87           17  -80.25%
BenchmarkAddVV_3                126           20  -83.97%
BenchmarkAddVV_4                165           23  -86.00%
BenchmarkAddVV_5                204           26  -87.21%
BenchmarkAddVV_1e1              399           41  -89.72%
BenchmarkAddVV_1e2             3921          315  -91.97%
BenchmarkAddVV_1e3            39085         2972  -92.40%
BenchmarkAddVV_1e4           390330        29623  -92.41%
BenchmarkAddVV_1e5          3935366       343431  -91.27%
BenchmarkAddVW_1                 20           10  -49.04%
BenchmarkAddVW_2                 60           14  -76.53%
BenchmarkAddVW_3                 99           16  -83.38%
BenchmarkAddVW_4                140           18  -86.50%
BenchmarkAddVW_5                179           21  -88.04%
BenchmarkAddVW_1e1              376           33  -91.20%
BenchmarkAddVW_1e2             3933          256  -93.49%
BenchmarkAddVW_1e3            39630         2378  -94.00%
BenchmarkAddVW_1e4           396218        23623  -94.04%
BenchmarkAddVW_1e5          3972901       238403  -94.00%
BenchmarkAddMulVVW_1             11           11   -4.27%
BenchmarkAddMulVVW_2             15           15   +0.00%
BenchmarkAddMulVVW_3             18           19   +4.37%
BenchmarkAddMulVVW_4             21           21   +4.29%
BenchmarkAddMulVVW_5             24           24   -0.82%
BenchmarkAddMulVVW_1e1           40           39   -2.70%
BenchmarkAddMulVVW_1e2          329          326   -0.91%
BenchmarkAddMulVVW_1e3         3200         3098   -3.19%
BenchmarkAddMulVVW_1e4        38457        40013   +4.05%
BenchmarkAddMulVVW_1e5       461880       428580   -7.21%
BenchmarkBitLen0                  5            5   -0.19%
BenchmarkBitLen1                  5            5   +0.00%
BenchmarkBitLen2                  5            5   -0.56%
BenchmarkBitLen3                  5            5   +0.38%
BenchmarkBitLen4                  5            5   +0.19%
BenchmarkBitLen5                  5            5   +0.56%
BenchmarkBitLen8                  5            5   -0.19%
BenchmarkBitLen9                  5            5   -0.56%
BenchmarkBitLen16                 5            5   -0.19%
BenchmarkBitLen17                 5            5   -0.37%
BenchmarkBitLen31                 5            5   -1.30%
BenchmarkBitset                  72           70   -2.49%
BenchmarkBitsetNeg             1584          396  -75.00%
BenchmarkBitsetOrig            1990         1980   -0.50%
BenchmarkBitsetNegOrig         4031         2877  -28.63%

benchmark                  old MB/s     new MB/s  speedup
BenchmarkAddVV_1             657.71      2251.28    3.42x
BenchmarkAddVV_2             730.65      3700.37    5.06x
BenchmarkAddVV_3             757.29      4754.30    6.28x
BenchmarkAddVV_4             772.95      5541.58    7.17x
BenchmarkAddVV_5             781.30      6125.59    7.84x
BenchmarkAddVV_1e1           800.33      7814.14    9.76x
BenchmarkAddVV_1e2           815.98     10129.62   12.41x
BenchmarkAddVV_1e3           818.73     10767.07   13.15x
BenchmarkAddVV_1e4           819.82     10802.12   13.18x
BenchmarkAddVV_1e5           813.14      9317.73   11.46x
BenchmarkAddVW_1            1539.56      3006.13    1.95x
BenchmarkAddVW_2            1057.66      4502.20    4.26x
BenchmarkAddVW_3             960.67      5797.65    6.04x
BenchmarkAddVW_4             913.19      6776.86    7.42x
BenchmarkAddVW_5             891.72      7467.82    8.37x
BenchmarkAddVW_1e1           850.12      9681.85   11.39x
BenchmarkAddVW_1e2           813.48     12494.27   15.36x
BenchmarkAddVW_1e3           807.45     13451.80   16.66x
BenchmarkAddVW_1e4           807.64     13545.64   16.77x
BenchmarkAddVW_1e5           805.46     13422.64   16.66x
BenchmarkAddMulVVW_1        2727.29      2847.66    1.04x
BenchmarkAddMulVVW_2        4162.30      4158.69    1.00x
BenchmarkAddMulVVW_3        5236.91      5015.98    0.96x
BenchmarkAddMulVVW_4        6090.27      5837.52    0.96x
BenchmarkAddMulVVW_5        6549.86      6598.60    1.01x
BenchmarkAddMulVVW_1e1      7850.72      8068.00    1.03x
BenchmarkAddMulVVW_1e2      9724.38      9794.40    1.01x
BenchmarkAddMulVVW_1e3      9997.18     10328.58    1.03x
BenchmarkAddMulVVW_1e4      8320.88      7997.39    0.96x
BenchmarkAddMulVVW_1e5      6928.20      7466.50    1.08x

LGTM=gri
R=golang-codereviews, dave, gri
CC=golang-codereviews
https://golang.org/cl/61290043
2014-02-13 16:19:38 -08:00
David Symonds
645a341b7d net/http: increase panic stack trace buffer size from 4 KB to 64 KB.
4 KB is a bit too small in some situations (e.g. panic during a
template execution), and ends up with an unhelpfully-truncated trace.
64 KB should be much more likely to capture the useful information.
There's not a garbage generation issue, since this code should only
be triggered when there's something seriously wrong with the program.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/63520043
2014-02-14 10:15:38 +11:00
Shenghou Ma
9abe6d9dd0 crypto/rsa: explain random parameter for GenerateKey and GenerateMultiPrimeKey.
Fixes #6850.

LGTM=agl
R=golang-codereviews, agl
CC=golang-codereviews
https://golang.org/cl/60500046
2014-02-13 15:56:48 -05:00
Shenghou Ma
c36dd4abdc cmd/go: fix cgo error output rewrite
for example, we now rewrite *_Ctype_int to *C.int.
Fixes #6781.

LGTM=iant
R=golang-codereviews, rsc, iant
CC=golang-codereviews
https://golang.org/cl/36860043
2014-02-13 15:55:14 -05:00
Russ Cox
e8ecd9f67a runtime: update malloc comment for MSpan.needzero
Missed this suggestion in CL 57680046.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/63390043
2014-02-13 14:31:48 -05:00
David du Colombier
98a76029ea lib9: fix Solaris build
In file included from src/lib9/utf/utfecpy.c:17:0:
src/lib9/utf/utfdef.h:28:0: error: "nil" redefined [-Werror]
In file included from src/lib9/utf/utfrrune.c:17:0:
src/lib9/utf/utfdef.h:28:0: error: "nil" redefined [-Werror]

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/63410043
2014-02-13 20:30:42 +01:00
David du Colombier
174b8c95f5 lib9: enable on Plan 9
This change depends on CL 57170052.

LGTM=rsc
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/60840049
2014-02-13 20:06:41 +01:00
David du Colombier
705d7c164f lib9: fix inconsistencies and warnings on Plan 9
warning: src/lib9/fmt/dorfmt.c:64 unreachable code RETURN
warning: src/lib9/fmt/fltfmt.c:184 set and not used: p
warning: src/lib9/utf/utflen.c:35 unreachable code RETURN
warning: src/lib9/utf/utfrrune.c:45 unreachable code RETURN
warning: src/lib9/utf/utfrune.c:44 unreachable code RETURN

LGTM=rsc
R=rsc, iant, gobot
CC=golang-codereviews
https://golang.org/cl/57170052
2014-02-13 20:05:55 +01:00
Daniel Morsing
e0a55a6c98 cmd/gc: for loop init statement misanalyzed by escape analysis
Logically, the init statement is in the enclosing scopes loopdepth, not inside the for loop.

Fixes #7313.

LGTM=rsc
R=golang-codereviews, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/62430043
2014-02-13 19:04:43 +00:00
Carlos Castillo
7861cd6082 cmd/go, go/build: support .m files
go/build is changed to list the .m files in a package, and match them for build constraints, adding them to a new field: Package.MFiles.

The go tool is changed to support building .m files and linking in the results during CGO and SWIG builds. This means packages that create a C interface to calls Objective-C code from go are now go-gettable without producing and distributing .syso files. This change is analogous to the one in Go 1.2 made to support C++ built code.

This change doesn't support .mm files (Objective C++).

Also added support for these MFiles to go list's -json mode.

Fixes #6536.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/60590044
2014-02-13 10:11:44 -08:00
Kyle Isom
fc8e77ca65 crypto/x509: Add certificate signature request (CSR) support.
This change adds support for parsing and serialisation of PKCS #10,
certificate signature requests.

LGTM=agl
R=golang-codereviews, agl
CC=agl, golang-codereviews, nick
https://golang.org/cl/49830048
2014-02-13 12:54:04 -05:00
Michael T. Jones
eea28f6701 math/big: add support for general encoding interfaces
TextMarshaller and TextUnmarshaller to ease transport of
unlimited precision rational numbers.

Fixes #7287.

Consists of encode and decode functions and two test
functions, one using JSON and one using XML. Each
verifies round trips for integers (rationals with
denominator == 1) and for fractional vaues.

LGTM=gri
R=gri, cookieo9, bradfitz, mtj
CC=golang-codereviews
https://golang.org/cl/61180043
2014-02-13 08:42:19 -08:00
Dmitriy Vyukov
e0dee49688 cmd/gc: fix windows build
c:\src\go\pkg\obj\windows_amd64\libgc.a(lex.o): In function `catcher':
c:/src/go/src/cmd/gc/lex.c:181: undefined reference to `noted'

LGTM=0intro
R=0intro
CC=golang-codereviews
https://golang.org/cl/63270043
2014-02-13 20:15:19 +04:00
Russ Cox
86e3cb8da5 runtime: introduce MSpan.needzero instead of writing to span data
This cleans up the code significantly, and it avoids any
possible problems with madvise zeroing out some but
not all of the data.

Fixes #6400.

LGTM=dave
R=dvyukov, dave
CC=golang-codereviews
https://golang.org/cl/57680046
2014-02-13 11:10:31 -05:00
Dmitriy Vyukov
f8e4a2ef94 runtime: fix concurrent GC sweep
The issue was that one of the MSpan_Sweep callers
was doing sweep with preemption enabled.
Additional checks are added.

LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/62990043
2014-02-13 19:36:45 +04:00
David du Colombier
9c767b64ee cmd/gc: catch notes on Plan 9
LGTM=rsc
R=rsc, jas, gobot
CC=ality, golang-codereviews
https://golang.org/cl/51650051
2014-02-13 16:35:51 +01:00
Nicolas Owens
68bf5666cd net: only return unique hosts during hostname lookup on plan 9
TestLookupHost expects that no duplicate addresses are returned. when cs is consulted for a name, e.g net!localhost!1, it will possibly return multiple available paths, e.g. via il and tcp. this confuses the tests.

LGTM=aram
R=jas, 0intro, aram
CC=golang-codereviews
https://golang.org/cl/58120045
2014-02-13 10:26:16 -05:00
Alexander Larsson
87d58f44a1 archive/tar: support extended attributes
This adds support for archives with the SCHILY.xattr field in the
pax header. This is what gnu tar and star generate.
Fixes #7154.

LGTM=dsymonds
R=golang-codereviews, gobot, dsymonds
CC=golang-codereviews
https://golang.org/cl/54570043
2014-02-13 20:08:30 +11:00
Shenghou Ma
ca6186aa26 cmd/6c, cmd/8c, cmd/8g: fix print of pc (which is vlong).
While we're at it, fix a wrong for statement in cmd/8g.

LGTM=rsc
R=rsc, golang-codereviews
CC=golang-codereviews
https://golang.org/cl/62700044
2014-02-13 03:09:03 -05:00
David du Colombier
a3e3b8e9db cmd/gc: fix warnings on Plan 9
warning: src/cmd/gc/popt.c:700 format mismatch d VLONG, arg 4
warning: src/cmd/gc/popt.c:700 format mismatch d VLONG, arg 5

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/62910043
2014-02-13 07:28:22 +01:00
Russ Cox
39067c79f3 runtime/pprof: fix arm build after CL 61270043
TBR=dvyukov
CC=golang-codereviews
https://golang.org/cl/62960043
2014-02-13 01:16:20 -05:00
Russ Cox
684332f47c cmd/5g: fix regopt bug in copyprop
copyau1 was assuming that it could deduce the type of the
middle register p->reg from the type of the left or right
argument: in CMPF F1, F2, the p->reg==2 must be a D_FREG
because p->from is F1, and in CMP R1, R2, the p->reg==2 must
be a D_REG because p->from is R1.

This heuristic fails for CMP $0, R2, which was causing copyau1
not to recognize p->reg==2 as a reference to R2, which was
keeping it from properly renaming the register use when
substituting registers.

cmd/5c has the right approach: look at the opcode p->as to
decide the kind of register. It is unclear where 5g's copyau1
came from; perhaps it was an attempt to avoid expanding 5c's
a2type to include new instructions used only by 5g.

Copy a2type from cmd/5c, expand to include additional instructions,
and make it crash the compiler if asked about an instruction
it does not understand (avoid silent bugs in the future if new
instructions are added).

Should fix current arm build breakage.

While we're here, fix the print statements dumping the pred and
succ info in the asm listing to pass an int arg to %.4ud
(Prog.pc is a vlong now, due to the liblink merge).

TBR=ken2
CC=golang-codereviews
https://golang.org/cl/62730043
2014-02-13 03:54:55 +00:00
Anthony Martin
27cb59fdad cmd/5g: fix print format in peephole debugging
Fixes #7294.

LGTM=minux.ma, dave, bradfitz
R=golang-codereviews, minux.ma, dave, bradfitz
CC=golang-codereviews
https://golang.org/cl/61370043
2014-02-12 17:03:21 -08:00
Robert Sesek
5bf35df491 debug/macho: Add support for opening fat/universal binaries.
New testdata was created from existing using:
$ lipo gcc-386-darwin-exec gcc-amd64-darwin-exec -create -output fat-gcc-386-amd64-darwin-exec

Fixes #7250.

LGTM=dave
R=golang-codereviews, dave, josharian, bradfitz
CC=golang-codereviews
https://golang.org/cl/60190043
2014-02-13 11:04:13 +11:00
Dave Cheney
951508671d debug/macho: add test file for CL 60190043
From the description of CL 60190043

debug/macho: Add support for opening fat/universal binaries.

New testdata was created from existing using:
$ lipo gcc-386-darwin-exec gcc-amd64-darwin-exec -create -output
fat-gcc-386-amd64-darwin-exec

Update #7250

LGTM=iant
R=golang-codereviews, gobot, dsymonds, iant
CC=golang-codereviews
https://golang.org/cl/61720044
2014-02-13 10:58:23 +11:00
Brad Fitzpatrick
72f0ed42fa crypto/md5: always test the portable block function too
So it doesn't bitrot.

Like the sha1 version (https://golang.org/cl/62270043)

LGTM=agl
R=agl
CC=golang-codereviews
https://golang.org/cl/62420043
2014-02-12 13:31:05 -08:00
Russ Cox
73a304356b runtime: fix non-concurrent sweep
State of the world:

CL 46430043 introduced a new concurrent sweep but is broken.

CL 62360043 made the new sweep non-concurrent
to try to fix the world while we understand what's wrong with
the concurrent version.

This CL fixes the non-concurrent form to run finalizers.
This CL is just a band-aid to get the build green again.

Dmitriy is working on understanding and then fixing what's
wrong with the concurrent sweep.

TBR=dvyukov
CC=golang-codereviews
https://golang.org/cl/62370043
2014-02-12 15:54:21 -05:00
Dmitriy Vyukov
3cac829ff4 runtime: temporary disable concurrent GC sweep
We see failures on builders, e.g.:
http://build.golang.org/log/70bb28cd6bcf8c4f49810a011bb4337a61977bf4

LGTM=rsc, dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/62360043
2014-02-13 00:03:27 +04:00
Anthony Martin
2cae0591cd cmd/cc, cmd/gc, cmd/ld: consolidate print format routines
We now use the %A, %D, %P, and %R routines from liblink
across the board.

Fixes #7178.
Fixes #7055.

LGTM=iant
R=golang-codereviews, gobot, rsc, dave, iant, remyoudompheng
CC=golang-codereviews
https://golang.org/cl/49170043
2014-02-12 14:29:11 -05:00
Brad Fitzpatrick
14c5c8a93a crypto/sha1: always test the portable block function too
So it doesn't bitrot.

LGTM=agl
R=golang-codereviews, agl
CC=golang-codereviews
https://golang.org/cl/62270043
2014-02-12 11:27:36 -08:00
Dmitriy Vyukov
bf0d71af29 runtime: more precise mprof sampling
Better sampling of objects that are close in size to sampling rate.
See the comment for details.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/43830043
2014-02-12 22:36:45 +04:00
Dmitriy Vyukov
5e72fae9b2 runtime: improve cpu profiles for GC/syscalls/cgo
Current "System->etext" is not very informative.
Add parent "GC" frame.
Replace un-unwindable syscall/cgo frames with Go stack that leads to the call.

LGTM=rsc
R=rsc, alex.brainman, ality
CC=golang-codereviews
https://golang.org/cl/61270043
2014-02-12 22:31:36 +04:00
Nick Craig-Wood
44c252bda2 An ARM version of sha1block.go with a big improvement in throughput
(up to 2.8x).

This is a partially unrolled version which performs better for small
hashes and only sacrifices a small amount of ultimate speed to a fully
unrolled version which uses 5k of code.

Code size

  Before 1636 bytes
  After 1880 bytes
  15% larger

Benchmarks on Samsung Exynos 5 ARMv7 Chromebook

benchmark              old ns/op    new ns/op    delta
BenchmarkHash8Bytes         1907         1136  -40.43%
BenchmarkHash1K            20280         7547  -62.79%
BenchmarkHash8K           148469        52576  -64.59%

benchmark               old MB/s     new MB/s  speedup
BenchmarkHash8Bytes         4.19         7.04    1.68x
BenchmarkHash1K            50.49       135.68    2.69x
BenchmarkHash8K            55.18       155.81    2.82x

LGTM=dave, agl
R=dave, bradfitz, agl, adg, nick
CC=golang-codereviews
https://golang.org/cl/56990044
2014-02-12 13:24:52 -05:00
Dmitriy Vyukov
2ea859a779 runtime: refactor level-triggered IO support
Remove GOOS_solaris ifdef from netpoll code,
instead introduce runtime edge/level triggered IO flag.
Replace armread/armwrite with a single arm(mode) function,
that's how all other interfaces look like and these functions
will need to do roughly the same thing anyway.

LGTM=rsc
R=golang-codereviews, dave, rsc
CC=golang-codereviews
https://golang.org/cl/55500044
2014-02-12 22:24:29 +04:00
Dmitriy Vyukov
e1ee04828d runtime: refactor chan code
1. Make internal chan functions static.
2. Move selgen local variable instead of a member of G struct.
3. Change "bool *pres/selected" parameter of chansend/chanrecv to "bool block",
   which is simpler, faster and less code.
-37 lines total.

LGTM=rsc
R=golang-codereviews, dave, gobot, rsc
CC=bradfitz, golang-codereviews, iant, khr
https://golang.org/cl/58610043
2014-02-12 22:21:38 +04:00
Dmitriy Vyukov
3c3be62201 runtime: concurrent GC sweep
Moves sweep phase out of stoptheworld by adding
background sweeper goroutine and lazy on-demand sweeping.

It turned out to be somewhat trickier than I expected,
because there is no point in time when we know size of live heap
nor consistent number of mallocs and frees.
So everything related to next_gc, mprof, memstats, etc becomes trickier.

At the end of GC next_gc is conservatively set to heap_alloc*GOGC,
which is much larger than real value. But after every sweep
next_gc is decremented by freed*GOGC. So when everything is swept
next_gc becomes what it should be.

For mprof I had to introduce 3-generation scheme (allocs, revent_allocs, prev_allocs),
because by the end of GC we know number of frees for the *previous* GC.

Significant caution is required to not cross yet-unknown real value of next_gc.
This is achieved by 2 means:
1. Whenever I allocate a span from MCentral, I sweep a span in that MCentral.
2. Whenever I allocate N pages from MHeap, I sweep until at least N pages are
returned to heap.
This provides quite strong guarantees that heap does not grow when it should now.

http-1
allocated                    7036         7033      -0.04%
allocs                         60           60      +0.00%
cputime                     51050        46700      -8.52%
gc-pause-one             34060569      1777993     -94.78%
gc-pause-total               2554          133     -94.79%
latency-50                 178448       170926      -4.22%
latency-95                 284350       198294     -30.26%
latency-99                 345191       220652     -36.08%
rss                     101564416    101007360      -0.55%
sys-gc                    6606832      6541296      -0.99%
sys-heap                 88801280     87752704      -1.18%
sys-other                 7334208      7405928      +0.98%
sys-stack                  524288       524288      +0.00%
sys-total               103266608    102224216      -1.01%
time                        50339        46533      -7.56%
virtual-mem             292990976    293728256      +0.25%

garbage-1
allocated                 2983818      2990889      +0.24%
allocs                      62880        62902      +0.03%
cputime                  16480000     16190000      -1.76%
gc-pause-one            828462467    487875135     -41.11%
gc-pause-total            4142312      2439375     -41.11%
rss                    1151709184   1153712128      +0.17%
sys-gc                   66068352     66068352      +0.00%
sys-heap               1039728640   1039728640      +0.00%
sys-other                37776064     40770176      +7.93%
sys-stack                 8781824      8781824      +0.00%
sys-total              1152354880   1155348992      +0.26%
time                     16496998     16199876      -1.80%
virtual-mem            1409564672   1402281984      -0.52%

LGTM=rsc
R=golang-codereviews, sameer, rsc, iant, jeremyjackins, gobot
CC=golang-codereviews, khr
https://golang.org/cl/46430043
2014-02-12 22:16:42 +04:00
Dmitriy Vyukov
3b85f9b7e1 encoding/json: fix test failure
$ go test -cpu=1,1,1,1,1,1,1,1,1 encoding/json
--- FAIL: TestIndentBig (0.00 seconds)
        scanner_test.go:131: Indent(jsonBig) did not get bigger
On 4-th run initBig generates an empty array.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/49930051
2014-02-12 21:50:58 +04:00
Adam Langley
384f4380e8 crypto/subtle: panic if slices of different lengths are passed to ConstantTimeCompare.
ConstantTimeCompare has always been documented to take equal length
slices but perhaps this is too subtle, even for 'subtle'.

Fixes #7304.

LGTM=hanwen, bradfitz
R=golang-codereviews, hanwen, bradfitz
CC=golang-codereviews
https://golang.org/cl/62190043
2014-02-12 11:58:48 -05:00
Adam Langley
6b29f7bfbe crypto/tls: better error messages.
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/60580046
2014-02-12 11:20:01 -05:00
Rick Arnold
5e711b473c net/http: make responseAndError satisfy the net.Error interface
Allow clients to check for timeouts without relying on error substring
matching.

Fixes #6185.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/55470048
2014-02-12 07:59:58 -08:00
Robert Dinu
c507601102 debug/pe: delete unnecessary type conversions
Fixes #7104.

LGTM=iant
R=golang-dev, iant
CC=golang-codereviews
https://golang.org/cl/61480049
2014-02-12 07:35:54 -08:00
Robert Griesemer
947aaf275c go/parser: better error messages for if/switch/for conditions/expressions
Fixes #7102.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/56770045
2014-02-11 16:45:31 -08:00
Shenghou Ma
4687b54147 cmd/ld, cmd/6l: part 2 of solaris/amd64 linker changes.
Second part of the solaris/amd64 linker changes: relocation and symbol table.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/61330043
2014-02-11 18:43:05 -05:00
Robert Griesemer
13a5958db3 go/parser: check presence of 2nd and 3rd index in 3-index slice
Fixes #7305.

LGTM=adonovan
R=bradfitz, adonovan
CC=golang-codereviews
https://golang.org/cl/58950045
2014-02-11 13:40:37 -08:00
Daniel Morsing
85e4cb2f10 cmd/6g, cmd/8g, cmd/5g: make the undefined instruction have no successors
The UNDEF instruction was listed in the instruction data as having the next instruction in the stream as its successor. This confused the optimizer into adding a load where it wasn't needed, in turn confusing the liveness analysis pass for GC bitmaps into thinking that the variable was live.

Fixes #7229.

LGTM=iant, rsc
R=golang-codereviews, bradfitz, iant, dave, rsc
CC=golang-codereviews
https://golang.org/cl/56910045
2014-02-11 20:25:40 +00:00
Brad Fitzpatrick
517f4a9683 archive/zip: re-use flate.Writers when writing compressed files
Prevents a ton of garbage. (Noticed this when writing large
Camlistore zip archives to Amazon Glacier)

Note that the Closer part of the io.WriteCloser is never given
to users. It's an internal detail of the package.

benchmark                         old ns/op     new ns/op     delta
BenchmarkCompressedZipGarbage     42884123      40732373      -5.02%

benchmark                         old allocs     new allocs     delta
BenchmarkCompressedZipGarbage     204            149            -26.96%

benchmark                         old bytes     new bytes     delta
BenchmarkCompressedZipGarbage     4397576       66744         -98.48%

LGTM=adg, rsc
R=adg, rsc
CC=golang-codereviews
https://golang.org/cl/54300053
2014-02-11 11:41:25 -08:00
Dmitriy Vyukov
e5a4211b36 runtime: do not profile blocked netpoll on windows
There is frequently a thread hanging on GQCS,
currently it skews profiles towards netpoll,
but it is not bad and is not consuming any resources.

R=alex.brainman
CC=golang-codereviews
https://golang.org/cl/61560043
2014-02-11 13:41:46 +04:00
David du Colombier
120218afeb runtime: homogenize panic strings on Plan 9
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/61410046
2014-02-11 09:34:43 +01:00
Andrew Gerrand
c4b279ba5a archive/zip: use correct test, fix 32-bit build
LGTM=dsymonds
R=dsymonds
CC=golang-codereviews
https://golang.org/cl/61070047
2014-02-11 16:27:14 +11:00
Andrew Gerrand
413e28da0d archive/zip: actually test uncompressed size
Fixes #7292.

LGTM=dsymonds
R=dsymonds
CC=golang-codereviews
https://golang.org/cl/61650046
2014-02-11 16:09:42 +11:00
Brendan Daniel Tracey
d30949693c cmd/gc: change compile error to "use of package %S without selector"
At present, when a package identifier is used outside of a selector expression, gc gives the error "use of package %S outside selector". However, in the selector expression x.f, the spec defines f as the selector. This change makes the error clearer.

Fixes #7133.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/50060047
2014-02-10 20:27:31 -05:00
Robert Griesemer
4d1301949a container/heap: avoid and/or ambiguity in documentation
(per suggestion by Doug McIlroy)

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/50580046
2014-02-10 12:48:56 -08:00
David du Colombier
76dcb9b346 runtime: handle "sys: trap: divide error" note on Plan 9
Fixes #7286.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/61410044
2014-02-10 21:47:52 +01:00
Dmitriy Vyukov
db9fb7b9ab cmd/go: fix comment
R=r
CC=golang-codereviews
https://golang.org/cl/61650044
2014-02-10 21:48:43 +04:00
Dmitriy Vyukov
373e1e94d8 runtime: fix crash during cpu profiling
mp->mcache can be concurrently modified by runtime·helpgc.
In such case sigprof can remember mcache=nil, then helpgc sets it to non-nil,
then sigprof restores it back to nil, GC crashes with nil mcache.

R=rsc
CC=golang-codereviews
https://golang.org/cl/58860044
2014-02-10 20:24:47 +04:00
Dmitriy Vyukov
e56e4e0193 cmd/go: better advice for heap profiling
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/60760048
2014-02-10 18:59:07 +04:00
Dmitriy Vyukov
0229dc6dbe runtime: do not cpu profile idle threads on windows
Currently this leads to a significant skew towards 'etext' entry,
since all idle threads are profiled every tick.
Before:
Total: 66608 samples
   63188  94.9%  94.9%    63188  94.9% etext
     278   0.4%  95.3%      278   0.4% sweepspan
     216   0.3%  95.6%      448   0.7% runtime.mallocgc
     122   0.2%  95.8%      122   0.2% scanblock
     113   0.2%  96.0%      113   0.2% net/textproto.canonicalMIMEHeaderKey
After:
Total: 8008 samples
    3949  49.3%  49.3%     3949  49.3% etext
     231   2.9%  52.2%      231   2.9% scanblock
     211   2.6%  54.8%      211   2.6% runtime.cas64
     182   2.3%  57.1%      408   5.1% runtime.mallocgc
     178   2.2%  59.3%      178   2.2% runtime.atomicload64

LGTM=alex.brainman
R=golang-codereviews, alex.brainman
CC=golang-codereviews
https://golang.org/cl/61250043
2014-02-10 15:40:55 +04:00
Dave Cheney
ff5f9bbf6a cmd/go: skip $ORIGIN test on darwin systems
Fixes #7293.

Update #7261

The bsd ld(1) does not understand $ORIGIN and has restrictions on using -rpath when using clang(1), the default compiler on darwin.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/58480045
2014-02-10 13:35:39 +11:00
Dave Cheney
414b45d91a cmd/go: fix test.bash
Fixes #7260.

Fix three broken tests in test.bash

The test for issue 4568 was confused by go $ACTION . producing a package root of "", avoiding this mode fixes the test but weakens the test.

The test for issue 4773 was broken on linux because math/Rand would fail to resolve as a package causing the test for duplicates to be skipped.

Finally, the last breakage was a small change in the error message.

Also, add test for foldDup.

LGTM=iant
R=iant, rsc
CC=golang-codereviews
https://golang.org/cl/61070044
2014-02-10 10:41:47 +11:00
Brad Fitzpatrick
730f51ab58 archive/zip: add flate writing benchmark
LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/60530049
2014-02-09 13:56:47 -08:00
Shenghou Ma
6ebf59b953 include, linlink, cmd/6l, cmd/ld: part 1 of solaris/amd64 linker changes.
rsc suggested that we split the whole linker changes into three parts.
This is the first one, mostly dealing with adding Hsolaris.

LGTM=iant
R=golang-codereviews, iant, dave
CC=golang-codereviews
https://golang.org/cl/54210050
2014-02-09 16:45:38 -05:00
Mikio Hara
65675a3e24 syscall: add missing include statement to bootstrap error code and signal generator
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/54300054
2014-02-09 17:20:59 +09:00
Rémy Oudompheng
2b93c4dd06 cmd/6g: faster memmove/memset-like code using unaligned load/stores.
This changes makes sgen and clearfat use unaligned instructions for
the trailing bytes, like the runtime memmove does, resulting in faster
code when manipulating types whose size is not a multiple of 8.

LGTM=khr
R=khr, iant, rsc
CC=golang-codereviews
https://golang.org/cl/51740044
2014-02-07 23:58:21 +01:00
David du Colombier
d0591d5ebd cmd/gc: revert CL 60740044
LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/60590047
2014-02-07 17:05:16 +01:00
David du Colombier
f95a311c9b cmd/gc: fix nil pointer dereference
LGTM=iant
R=golang-codereviews, dave, iant
CC=golang-codereviews
https://golang.org/cl/60740044
2014-02-07 15:43:40 +01:00
Alex Brainman
a747adf798 net: remove superfluous type conversion
LGTM=minux.ma, dvyukov
R=golang-codereviews, minux.ma, dvyukov
CC=golang-codereviews
https://golang.org/cl/60900043
2014-02-07 16:58:45 +11:00
Keith Randall
da7cf0ba5d runtime: faster memclr on x86.
Use explicit SSE writes instead of REP STOSQ.

benchmark               old ns/op    new ns/op    delta
BenchmarkMemclr5               22            5  -73.62%
BenchmarkMemclr16              27            5  -78.49%
BenchmarkMemclr64              28            6  -76.43%
BenchmarkMemclr256             34            8  -74.94%
BenchmarkMemclr4096           112           84  -24.73%
BenchmarkMemclr65536         1902         1920   +0.95%

LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews
https://golang.org/cl/60090044
2014-02-06 17:43:22 -08:00
Alex Brainman
aac872e118 os/exec: use filepath.Base in Command
filepath.Base covers all scenarios
(for example paths like d:hello.txt)
on windows

LGTM=iant, bradfitz
R=golang-codereviews, iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/59740050
2014-02-07 12:30:30 +11:00
Mikio Hara
546081fd01 syscall: make use of signed char explicit in generating z-files on freebsd/arm
This CL is in preparation to make cgo work on freebsd/arm.

The signedness of C char might be a problem when we make bare syscall
APIs, Go structures, using built-in bootstrap scripts with cgo because
they do translate C stuff to Go stuff internally. For now almost all
the C compilers assume that the type of char will be unsigned on arm
by default but it makes a different view from amd64, 386.

This CL just passes -fsigned-char, let the type of char be signed,
option which is supported on both gcc and clang to the underlying C
compilers through cgo for avoiding such inconsistency on syscall API.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/59740051
2014-02-07 10:23:53 +09:00
Mikio Hara
5d871c7ef0 syscall: regenerate EABI call convention compliant syscalls for freebsd/arm
This CL is in preparation to make cgo work on freebsd/arm.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/59490051
2014-02-07 10:23:26 +09:00
Mikio Hara
aa29cd98dc syscall: fix build on freebsd/arm
This CL is in preparation to make cgo work on freebsd/arm.

It's just for fixing build fails on freebsd/arm, we still need to
update z-files later for fixing several package test fails.

How to generate z-files on freebsd/arm in the bootstrapping phase:
1. run freebsd on appropriate arm-eabi platforms
2. both syscall z-files and runtime def-files in the current tree are
   broken about EABI padding, fix them by hand
3. run make.bash again to build $GOTOOLDIR/cgo
4. use $GOTOOLDIR/cgo directly

LGTM=iant
R=iant, dave
CC=golang-codereviews
https://golang.org/cl/59490052
2014-02-07 10:23:02 +09:00
Mikio Hara
61fe7d8308 runtime/cgo: fix build on freebsd/arm
This CL is in preparation to make cgo work on freebsd/arm.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/60500044
2014-02-07 10:22:34 +09:00