]> Cypherpunks repositories - gostls13.git/log
gostls13.git
10 years agoliblink, cmd/5a: fix reglist parsing/printing after changing REG_R0 to 32
Shenghou Ma [Thu, 5 Feb 2015 02:30:22 +0000 (21:30 -0500)]
liblink, cmd/5a: fix reglist parsing/printing after changing REG_R0 to 32

Fixes #9759.

Change-Id: I263f1251b9401371231374551c4f71c70cb6e359
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/3931
Reviewed-by: Dave Cheney <dave@cheney.net>
10 years agocmd/pack: simplify the testing logic slightly
Rob Pike [Wed, 4 Feb 2015 21:50:08 +0000 (13:50 -0800)]
cmd/pack: simplify the testing logic slightly

Followup to https://go-review.googlesource.com/3910

We only need 1000 iteratinons.

Change-Id: Ib63ae53105176abec77bad9609d638aeda7bcd61
Reviewed-on: https://go-review.googlesource.com/3901
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agomath/big: first version of Float %e, %f, %g, %G formatting working
Robert Griesemer [Wed, 4 Feb 2015 01:37:01 +0000 (17:37 -0800)]
math/big: first version of Float %e, %f, %g, %G formatting working

Change-Id: I10efa3bc8bc7f41100feabe17837f805a42d7eb6
Reviewed-on: https://go-review.googlesource.com/3842
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agomath/big: fix %b format so it matches strconf %b format for non-zero values
Robert Griesemer [Tue, 3 Feb 2015 23:13:26 +0000 (15:13 -0800)]
math/big: fix %b format so it matches strconf %b format for non-zero values

(For zero values the strconv %b format prints the bias-adjusted exponent;
there's no bias in Float.)

Change-Id: I6f4dda9c3a50d02eac375cfe2c927c1540aae865
Reviewed-on: https://go-review.googlesource.com/3841
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agomath/big: implemented decimal rounding for Float-to-string conversion
Robert Griesemer [Tue, 3 Feb 2015 22:29:03 +0000 (14:29 -0800)]
math/big: implemented decimal rounding for Float-to-string conversion

Change-Id: Id508ca2f6c087861e8c6bc536bc39e54dce09825
Reviewed-on: https://go-review.googlesource.com/3840
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agoruntime: support panic/print logging in android-L.
Hyang-Ah Hana Kim [Sat, 24 Jan 2015 22:51:42 +0000 (17:51 -0500)]
runtime: support panic/print logging in android-L.

In android-L, logging is done through the logd daemon.
If logd daemon is available, send logging to logd.
Otherwise, fallback to the legacy mechanism (/dev/log files).

This change adds access/socket/connect calls to interact with the logd.

Fixes golang/go#9398.

Change-Id: I3c52b81b451f5862107d7c675f799fc85548486d
Reviewed-on: https://go-review.googlesource.com/3350
Reviewed-by: David Crawshaw <crawshaw@golang.org>
10 years agogo1.5.txt: array generation support in testing/quick
Josh Bleecher Snyder [Wed, 4 Feb 2015 17:32:44 +0000 (09:32 -0800)]
go1.5.txt: array generation support in testing/quick

Change-Id: I00f18a8c62a8d63822d7e07fee1ac5f088cc9587
Reviewed-on: https://go-review.googlesource.com/3866
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
10 years agoRevert "runtime: bound defer pools"
Russ Cox [Wed, 4 Feb 2015 16:56:34 +0000 (11:56 -0500)]
Revert "runtime: bound defer pools"

This reverts commit 805907115352801a54f987fc9079251b478cce3f.

Conflicts:
src/runtime/proc1.go (resolved by hand)

Change-Id: Ic62e3e802f0007ff9012b37bc5fd41fcafc153d0
Reviewed-on: https://go-review.googlesource.com/3885
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
10 years agoliblink: require use of TYPE_ADDR, not TYPE_CONST
Russ Cox [Fri, 30 Jan 2015 04:35:14 +0000 (23:35 -0500)]
liblink: require use of TYPE_ADDR, not TYPE_CONST

Add Addr-checking for all Progs on input to liblink, in liblink/pass.c,
including requiring use of TYPE_ADDR, not TYPE_CONST.
Update compilers and assemblers to satisfy checks.

Change-Id: Idac36b9f6805f0451cb541d2338992ca5eaf3963
Reviewed-on: https://go-review.googlesource.com/3801
Reviewed-by: Austin Clements <austin@google.com>
10 years agotesting/quick: support generation of array types in Value
Chris Kastorff [Wed, 4 Feb 2015 12:43:00 +0000 (04:43 -0800)]
testing/quick: support generation of array types in Value

Generating array types like [4]int would fail even though the int type
is generatable. Allow generating values of array types when the inner
type is generatable.

Change-Id: I7d71b3c18edb3737e2fec1ddf5e36c9dc8401971
Reviewed-on: https://go-review.googlesource.com/3865
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
10 years agocmd/go, make: remove ccflags
Josh Bleecher Snyder [Wed, 4 Feb 2015 00:17:08 +0000 (16:17 -0800)]
cmd/go, make: remove ccflags

cc is no more.

Change-Id: I8d1bc0d2e471cd9357274204c9bc1fa67cbc272d
Reviewed-on: https://go-review.googlesource.com/3833
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
10 years agocmd/go: add 9g and 9l to documentation
Josh Bleecher Snyder [Wed, 4 Feb 2015 00:19:05 +0000 (16:19 -0800)]
cmd/go: add 9g and 9l to documentation

Change-Id: I274c438ab168278dfbb34ada3ed9a7f7c66b66ef
Reviewed-on: https://go-review.googlesource.com/3834
Reviewed-by: Minux Ma <minux@golang.org>
10 years agonet: remove the dregs of old built-in poll server
Mikio Hara [Wed, 4 Feb 2015 09:00:52 +0000 (18:00 +0900)]
net: remove the dregs of old built-in poll server

We don't need placeholders for the old built-in poll server any more.

Change-Id: I3a510aec6a30bc2ac97676c400177cdfe557b8dc
Reviewed-on: https://go-review.googlesource.com/3863
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
10 years agoruntime: cleanup some left-overs of the C past
Dmitry Vyukov [Tue, 3 Feb 2015 08:20:58 +0000 (11:20 +0300)]
runtime: cleanup some left-overs of the C past

Change-Id: I3e280ca7d922f6ab14b2477361327ed076a95779
Reviewed-on: https://go-review.googlesource.com/3743
Reviewed-by: Keith Randall <khr@golang.org>
10 years agonet: update TDDO
Mikio Hara [Wed, 4 Feb 2015 02:27:08 +0000 (11:27 +0900)]
net: update TDDO

The issue #8432 has been marked as an issue for golang.org/x/net.

Change-Id: Ia39abd99b685c820ea6169ee6505b16028e7e77f
Reviewed-on: https://go-review.googlesource.com/3836
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agoruntime: bound defer pools
Dmitry Vyukov [Tue, 3 Feb 2015 05:58:04 +0000 (08:58 +0300)]
runtime: bound defer pools

The unbounded list-based defer pool can grow infinitely.
This can happen if a goroutine routinely allocates a defer;
then blocks on one P; and then unblocked, scheduled and
frees the defer on another P.
The scenario was reported on golang-nuts list.

We've been here several times. Any unbounded local caches
are bad and grow to infinite size. This change introduces
central defer pool; local pools become fixed-size
with the only purpose of amortizing accesses to the
central pool.

Change-Id: Iadcfb113ccecf912e1b64afc07926f0de9de2248
Reviewed-on: https://go-review.googlesource.com/3741
Reviewed-by: Keith Randall <khr@golang.org>
10 years agocmd/gc: don't copy string in range []byte(str)
Dmitry Vyukov [Tue, 3 Feb 2015 17:50:58 +0000 (20:50 +0300)]
cmd/gc: don't copy string in range []byte(str)

Using benchmark from the issue:

benchmark                    old ns/op     new ns/op     delta
BenchmarkRangeStringCast     2162          1152          -46.72%

benchmark                    old allocs     new allocs     delta
BenchmarkRangeStringCast     1              0              -100.00%

Fixes #2204

Change-Id: I92c5edd2adca4a7b6fba00713a581bf49dc59afe
Reviewed-on: https://go-review.googlesource.com/3790
Reviewed-by: Keith Randall <khr@golang.org>
10 years agoruntime: fix RuntimeGogoBytes on windows/amd64
Austin Clements [Wed, 4 Feb 2015 02:14:47 +0000 (21:14 -0500)]
runtime: fix RuntimeGogoBytes on windows/amd64

Before 3c0fee1, runtime.gogo was just long enough to align to 64 bytes
on OSs with short get_tls implementations and 80 bytes on OSs with
longer get_tls implementations (Windows, Solaris, and Plan 9).
3c0fee1 added a few instructions, which pushed it to 80 on most OSs,
including Windows and Plan 9, and 96 on Solaris.

Fixes #9770.

Change-Id: Ie84810657c14ab16dce9f0e0a932955251b0bf33
Reviewed-on: https://go-review.googlesource.com/3850
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
10 years agogo/doc: don't treat _ consts as exported
Josh Bleecher Snyder [Tue, 3 Feb 2015 23:12:26 +0000 (15:12 -0800)]
go/doc: don't treat _ consts as exported

golang.org/cl/144110044 made _ consts treated
as exported as a small, safe fix for #5397.
It also introduced issue #9615.

golang.org/cl/2091 then fixed the underlying issue,
which was missing type information when the type
was specified only for _.

This cl reverts the original fix.

Fixes #9615.

Change-Id: I4815ad8292bb5bec18beb8c131b48949d9af8876
Reviewed-on: https://go-review.googlesource.com/3832
Reviewed-by: Robert Griesemer <gri@golang.org>
10 years agocrypto/tls: add support for AES_256_GCM_SHA384 cipher suites specified in RFC5289
Jacob H. Haven [Wed, 4 Feb 2015 00:15:18 +0000 (16:15 -0800)]
crypto/tls: add support for AES_256_GCM_SHA384 cipher suites specified in RFC5289

Generalizes PRF calculation for TLS 1.2 to support arbitrary hashes (SHA-384 instead of SHA-256).
Testdata were all updated to correspond with the new cipher suites in the handshake.

Change-Id: I3d9fc48c19d1043899e38255a53c80dc952ee08f
Reviewed-on: https://go-review.googlesource.com/3265
Reviewed-by: Adam Langley <agl@golang.org>
10 years agocmd/dist: fix whitespace and comment typo in arm vfp detection
Josh Bleecher Snyder [Tue, 3 Feb 2015 22:09:53 +0000 (14:09 -0800)]
cmd/dist: fix whitespace and comment typo in arm vfp detection

Follow-up to cl 2682.

Change-Id: I06a589e782af821e4fa46a7c34d9a549de47fa60
Reviewed-on: https://go-review.googlesource.com/3830
Reviewed-by: Dave Cheney <dave@cheney.net>
10 years agonet/http: remove unused switchReader type
Blake Gentry [Tue, 3 Feb 2015 20:01:29 +0000 (12:01 -0800)]
net/http: remove unused switchReader type

Change-Id: Ic8a01d06ffc6c80beaf6dee9e7242dcbb7425e71
Reviewed-on: https://go-review.googlesource.com/3822
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoinclude: restore use of signal.h on windows (fixes build)
Alex Brainman [Tue, 3 Feb 2015 23:07:16 +0000 (10:07 +1100)]
include: restore use of signal.h on windows (fixes build)

Change-Id: Ifd983cf50b1ccbe64a45d3b3ad171ef67f608033
Reviewed-on: https://go-review.googlesource.com/3831
Reviewed-by: Dave Cheney <dave@cheney.net>
10 years agocrypto/x509/pkix: Parse and add additional elements in a DN
Paul van Brouwershaven [Mon, 5 Jan 2015 11:15:18 +0000 (11:15 +0000)]
crypto/x509/pkix: Parse and add additional elements in a DN

Additional elements in a DN can be added in via ExtraNames. This
option can also be used for sorting DN elements in a custom order.

Change-Id: Ie408d332de913dc2a33bdd86433be38abb7b55be
Reviewed-on: https://go-review.googlesource.com/2257
Reviewed-by: Adam Langley <agl@golang.org>
10 years agoruntime: Change memprofrate to memprofilerate
Lynn Boger [Tue, 3 Feb 2015 18:13:31 +0000 (12:13 -0600)]
runtime:  Change memprofrate to memprofilerate

Use memprofilerate in GODEBUG instead of memprofrate to be
consistent with other uses.

Change-Id: Iaf6bd3b378b1fc45d36ecde32f3ad4e63ca1e86b
Reviewed-on: https://go-review.googlesource.com/3800
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agomath/big: implement precise Float to decimal conversion (core functionality)
Robert Griesemer [Tue, 3 Feb 2015 00:31:13 +0000 (16:31 -0800)]
math/big: implement precise Float to decimal conversion (core functionality)

Change-Id: Ic0153397922ded28a5cb362e86ecdfec42e92163
Reviewed-on: https://go-review.googlesource.com/3752
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agomath/big: fix typos
Robert Griesemer [Sat, 31 Jan 2015 00:33:31 +0000 (16:33 -0800)]
math/big: fix typos

Change-Id: Icb1490f97584d61823339ae809b88d423b185e64
Reviewed-on: https://go-review.googlesource.com/3751
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agomath/big: build Float.Format on top of Float.Append
Robert Griesemer [Fri, 30 Jan 2015 23:57:38 +0000 (15:57 -0800)]
math/big: build Float.Format on top of Float.Append

Change-Id: I444eec24467f827caa5c88a1c5ae5bce92508b98
Reviewed-on: https://go-review.googlesource.com/3750
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agoliblink: define fixed A-numbers for common instructions
Russ Cox [Fri, 30 Jan 2015 01:19:07 +0000 (20:19 -0500)]
liblink: define fixed A-numbers for common instructions

This makes names like ANOP, ATEXT, AGLOBL, ACALL, AJMP, ARET
available for use by architecture-independent processing passes.

On arm and ppc64, the alternate names are now aliases for the
official ones (ABL for ACALL, AB or ABR for AJMP, ARETURN for ARET).

Change-Id: Id027771243795af2b3745199c645b6e1bedd7d18
Reviewed-on: https://go-review.googlesource.com/3577
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Austin Clements <austin@google.com>
10 years agoliblink: place DATA size in from3.offset always
Russ Cox [Fri, 30 Jan 2015 00:42:01 +0000 (19:42 -0500)]
liblink: place DATA size in from3.offset always

Like the TEXT/GLOBL flags, this was split between from.scale and reg,
neither of which is appropriate.

Change-Id: I2a16ef066a53b6edb7afb16cce108c0d1d26389c
Reviewed-on: https://go-review.googlesource.com/3576
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Austin Clements <austin@google.com>
10 years agoliblink: the zero Prog is now valid and ready for use
Russ Cox [Thu, 29 Jan 2015 21:16:24 +0000 (16:16 -0500)]
liblink: the zero Prog is now valid and ready for use

Use AXXX instead of AGOK (neither is a valid instruction but AXXX is zero)
for the initial setting of Prog.as, and now there are no non-zero default
field settings.

Remove the arch-specific zprog/zprg in favor of a single global zprog.
Remove the arch-specific prg constructor in favor of emallocz(sizeof(Prog)).

Change-Id: Ia73078726768333d7cdba296f548170c1bea9498
Reviewed-on: https://go-review.googlesource.com/3575
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Austin Clements <austin@google.com>
10 years agoliblink: remove dead computation of p->back in span6/span8
Russ Cox [Thu, 29 Jan 2015 20:35:56 +0000 (15:35 -0500)]
liblink: remove dead computation of p->back in span6/span8

Originally, when this code was part of 6l/8l, every new
Prog was constructed starting with zprg, which set back=2,
and then this code walked over the list setting back=1 for
backward branches, back=0 otherwise. The initial back=2
setting was used to identify forward branches (the branched-to
instruction had back == 2 since it hadn't yet been set to 0 or 1).

When the code was extracted into liblink and linked directly
with 6a/6g/8a/8g, those programs created the Prog struct
and did not set back=2, breaking this backward branch detection.

No one noticed, because the next loop recomputes the information.
The only requirement for the next loop is that p->back == 0 or 1 for
each of the Progs in the list.

The initialization of the zprg with back=2 would cause problems
in this second loop, for the few liblink-internally-generated instructions
that are created by copying zprg, except that the first loop was
making sure that back == 0 or 1.

The first loop's manipulation of p->back can thus be deleted,
provided we also delete the zprg.back = 2 initializations.

This is awful and my fault. I apologize.

While we're here, remove the .scale = 1 from the zprg init too.
Anything that sets up a scaled index should set the scale itself.
(And mostly those come from outside liblink anyway.)

Tested by checking that all generated code is bit-for-bit
identical to before this CL.

Change-Id: I7f6e0b33ce9ccd5b7dc25e0f00429fedd0957c8c
Reviewed-on: https://go-review.googlesource.com/3574
Reviewed-by: Austin Clements <austin@google.com>
10 years agoliblink: renumber ARM conditions to make C_SCOND_NONE == 0
Russ Cox [Thu, 29 Jan 2015 20:18:22 +0000 (15:18 -0500)]
liblink: renumber ARM conditions to make C_SCOND_NONE == 0

A step toward making the zero Prog useful.

Change-Id: I427b98b1ce9bd8f093da825aa4bb83244fc01903
Reviewed-on: https://go-review.googlesource.com/3573
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Austin Clements <austin@google.com>
10 years agoliblink: place TEXT/GLOBL flags in p->from3 always
Russ Cox [Thu, 29 Jan 2015 19:58:54 +0000 (14:58 -0500)]
liblink: place TEXT/GLOBL flags in p->from3 always

Before, amd64 and 386 stored the flags in p->from.scale
and arm and ppc64 stored the flags in p->reg.
Both caused special cases in printing and in handling of the
addresses.

To avoid possible conflicts with the real meaning of p->from
and to avoid storing a non-register value in a reg field,
use from3 to hold a TYPE_CONST value giving the flags.

There is still a special case for printing, because the flags
are specified without a $, and normally a TYPE_CONST prints
with a $. But that's much less special than what came before.

This allows us to remove the textflag and settextflag methods
from LinkArch. They are no longer architecture-specific.

Change-Id: I931da8e1ecd92e127cd9aa44ef5a73c42e730110
Reviewed-on: https://go-review.googlesource.com/3572
Reviewed-by: Austin Clements <austin@google.com>
10 years agoliblink: use same TEXT $frame-arg encoding for all architectures
Russ Cox [Thu, 29 Jan 2015 17:26:21 +0000 (12:26 -0500)]
liblink: use same TEXT $frame-arg encoding for all architectures

Change-Id: I3417a8c5ddd7f405939edc9fdef086e4741495a1
Reviewed-on: https://go-review.googlesource.com/3571
Reviewed-by: Austin Clements <austin@google.com>
10 years agocmd/9a: fix GLOBL instruction
Russ Cox [Thu, 29 Jan 2015 18:50:19 +0000 (13:50 -0500)]
cmd/9a: fix GLOBL instruction

Because it was lumped in with the TEXT instruction,
the high 32 bits of the 64-bit constant holding the size
were always set to 0x80000000 (ArgsSizeUnknown).
This only worked because cmd/9l was reading the 64-bit
value into an int32.

While we're here, fix 5a.
It wasn't as much of a problem there because
the two values were being stored in two different fields.
But it was still wrong.

Change-Id: I69a2214c7be939530d499e29cfdc3b26720ac05a
Reviewed-on: https://go-review.googlesource.com/3570
Reviewed-by: Austin Clements <austin@google.com>
10 years agocmd/gc: fix capturing by value for range statements
Dmitry Vyukov [Thu, 29 Jan 2015 15:33:19 +0000 (18:33 +0300)]
cmd/gc: fix capturing by value for range statements

Kindly detected by race builders by failing TestRaceRange.
ORANGE typecheck does not increment decldepth around body.

Change-Id: I0df5f310cb3370a904c94d9647a9cf0f15729075
Reviewed-on: https://go-review.googlesource.com/3507
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/gc: typecheck type switch variables
Dmitry Vyukov [Fri, 30 Jan 2015 08:23:22 +0000 (11:23 +0300)]
cmd/gc: typecheck type switch variables

Type switch variables was not typechecked.
Previously it lead only to a minor consequence:

switch unsafe.Sizeof = x.(type) {

generated an inconsistent error message.
But capturing by value functionality now requries typechecking of all ONAMEs.

Fixes #9731

Change-Id: If037883cba53d85028fb97b1328696091b3b7ddd
Reviewed-on: https://go-review.googlesource.com/3600
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime: fix nosplit stack overflow
Dmitry Vyukov [Thu, 29 Jan 2015 09:47:30 +0000 (12:47 +0300)]
runtime: fix nosplit stack overflow

The overflow happens only with -gcflags="-N -l"
and can be reproduced with:

$ go test -gcflags="-N -l" -a -run=none net

runtime.cgocall: nosplit stack overflow
504 assumed on entry to runtime.cgocall
480 after runtime.cgocall uses 24
472 on entry to runtime.cgocall_errno
408 after runtime.cgocall_errno uses 64
400 on entry to runtime.exitsyscall
288 after runtime.exitsyscall uses 112
280 on entry to runtime.exitsyscallfast
152 after runtime.exitsyscallfast uses 128
144 on entry to runtime.writebarrierptr
88 after runtime.writebarrierptr uses 56
80 on entry to runtime.writebarrierptr_nostore1
24 after runtime.writebarrierptr_nostore1 uses 56
16 on entry to runtime.acquirem
-24 after runtime.acquirem uses 40

Move closure creation into separate function so that
frames of writebarrierptr_shadow and writebarrierptr_nostore1
are overlapped.

Fixes #9721

Change-Id: I40851f0786763ee964af34814edbc3e3d73cf4e7
Reviewed-on: https://go-review.googlesource.com/3418
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime: fix false race report during tracing
Dmitry Vyukov [Tue, 3 Feb 2015 10:01:09 +0000 (13:01 +0300)]
runtime: fix false race report during tracing

Currently race detector produces the following reports on pprof tests:

WARNING: DATA RACE
Read by goroutine 4:
  runtime/pprof_test.TestTraceStartStop()
      src/runtime/pprof/trace_test.go:38 +0x1da
  testing.tRunner()
      src/testing/testing.go:448 +0x13a

Previous write by goroutine 5:
  bytes.(*Buffer).grow()
      src/bytes/buffer.go:102 +0x190
  bytes.(*Buffer).Write()
      src/bytes/buffer.go:127 +0x75
  runtime/pprof.func·002()
      src/runtime/pprof/pprof.go:633 +0xae

Trace writer goroutine synchronizes with StopTrace
using trace.shutdownSema runtime semaphore.
But race detector does not see that synchronization
and so produces false reports.
Teach race detector about the synchronization.

Change-Id: I1219817325d4e16b423f29a0cbee94c929793881
Reviewed-on: https://go-review.googlesource.com/3746
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime: rearrange framepointer check condition
Austin Clements [Tue, 3 Feb 2015 14:18:15 +0000 (09:18 -0500)]
runtime: rearrange framepointer check condition

The test for the framepointer experiment flag is cheaper and more
branch-predictable than the other parts of this conditional, so move
it first.  This is also more readable.

(Originally, the flag check required parsing the experiments string,
which is why it was done last.  Now that flag is cached.)

Change-Id: I84e00fa7e939e9064f0fa0a4a6fe00576dd61457
Reviewed-on: https://go-review.googlesource.com/3782
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoruntime: use 2*regSize for saved frame pointer check
Austin Clements [Tue, 3 Feb 2015 14:09:56 +0000 (09:09 -0500)]
runtime: use 2*regSize for saved frame pointer check

Previously, we checked for a saved frame pointer by looking for a
2*ptrSize gap between the argument pointer and the locals pointer.
The intent of this check was to look for a two stack slot gap (caller
IP and saved frame pointer), but stack slots are regSize, not ptrSize.

Correct this by checking instead for a 2*regSize gap.

On most platforms, this made no difference because ptrSize==regSize.
However, on amd64p32 (nacl), the saved frame pointer check incorrectly
fired when there was no saved frame pointer because the one stack slot
for the caller IP left an 8 byte gap, which is 2*ptrSize (but not
2*regSize) on amd64p32.

Fixes #9760.

Change-Id: I6eedcf681fe5bf2bf924dde8a8f2d9860a4d758e
Reviewed-on: https://go-review.googlesource.com/3781
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoruntime: add missing \n to error message
Austin Clements [Tue, 3 Feb 2015 13:35:38 +0000 (08:35 -0500)]
runtime: add missing \n to error message

Change-Id: Ife7d30f4191e6a8aaf3a442340d277989f7a062d
Reviewed-on: https://go-review.googlesource.com/3780
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agonet: case insensitivity of DNS labels in built-in stub resolver
Mikio Hara [Mon, 2 Feb 2015 12:09:23 +0000 (21:09 +0900)]
net: case insensitivity of DNS labels in built-in stub resolver

This change adds support for case insensitivity of DNS labels to
built-in DNS stub resolver as described in RFC 4343.

Fixes #9215.

Change-Id: Ia752fe71866a3bfa3ea08371985b799d419ddea3
Reviewed-on: https://go-review.googlesource.com/3685
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agonet/http: remove redundant strings.TrimPrefix
Erik Aigner [Mon, 2 Feb 2015 07:52:41 +0000 (08:52 +0100)]
net/http: remove redundant strings.TrimPrefix

We already checked for the prefix with strings.HasPrefix

Change-Id: I33852fd19ffa92aa33b75b94b4bb505f4043a54a
Reviewed-on: https://go-review.googlesource.com/3691
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoinclude: fix arm build one more time
Dave Cheney [Fri, 30 Jan 2015 15:19:50 +0000 (02:19 +1100)]
include: fix arm build one more time

Fourth time's the charm.

Actually this doesn't fix the build, there is a
crash after go_bootstrap is compiled which looks
like it is related to auxv parsing.

Change-Id: Id00e2dfbe7bae42856f996065d3fb90b820e29a8
Reviewed-on: https://go-review.googlesource.com/3610
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoruntime: Add memprofrate value to GODEBUG
Lynn Boger [Wed, 28 Jan 2015 18:28:59 +0000 (12:28 -0600)]
runtime: Add memprofrate value to GODEBUG

Add memprofrate as a value recognized in GODEBUG.  The
value provided is used as the new setting for
runtime.MemProfileRate, allowing the user to
adjust memory profiling.

Change-Id: If129a247683263b11e2dd42473cf9b31280543d5
Reviewed-on: https://go-review.googlesource.com/3450
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agocmd/6g, liblink, runtime: support saving base pointers
Austin Clements [Wed, 14 Jan 2015 16:09:50 +0000 (11:09 -0500)]
cmd/6g, liblink, runtime: support saving base pointers

This adds a "framepointer" GOEXPERIMENT that that makes the amd64
toolchain maintain base pointer chains in the same way that gcc
-fno-omit-frame-pointer does.  Go doesn't use these saved base
pointers, but this does enable external tools like Linux perf and
VTune to unwind Go stacks when collecting system-wide profiles.

This requires support in the compilers to not clobber BP, support in
liblink for generating the BP-saving function prologue and unwinding
epilogue, and support in the runtime to save BPs across preemption, to
skip saved BPs during stack unwinding and, and to adjust saved BPs
during stack moving.

As with other GOEXPERIMENTs, everything from the toolchain to the
runtime must be compiled with this experiment enabled.  To do this,
run make.bash (or all.bash) with GOEXPERIMENT=framepointer.

Change-Id: I4024853beefb9539949e5ca381adfdd9cfada544
Reviewed-on: https://go-review.googlesource.com/2992
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime: eliminate uses of BP on amd64
Austin Clements [Tue, 27 Jan 2015 23:29:02 +0000 (18:29 -0500)]
runtime: eliminate uses of BP on amd64

Any place that clobbers BP in the runtime can potentially interfere
with frame pointer unwinding with GOEXPERIMENT=framepointer.  This
change eliminates uses of BP in the runtime to address this problem.
We have spare registers everywhere this occurs, so there's no downside
to eliminating BP.  Where possible, this uses the same new register as
the amd64p32 runtime, which doesn't use BP due to restrictions placed
on it by NaCL.

One nice side effect of this is that it will let perf/VTune unwind the
call stack even through a call to systemstack, which will let us get
really good call graphs from the garbage collector.

Change-Id: I0ffa14cb4dd2b613a7049b8ec59df37c52286212
Reviewed-on: https://go-review.googlesource.com/3390
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime: rename m.gcing to m.preemptoff and make it a string
Austin Clements [Fri, 30 Jan 2015 20:30:41 +0000 (15:30 -0500)]
runtime: rename m.gcing to m.preemptoff and make it a string

m.gcing has become overloaded to mean "don't preempt this g" in
general.  Once the garbage collector is preemptible, the one thing it
*won't* mean is that we're in the garbage collector.

So, rename gcing to "preemptoff" and make it a string giving a reason
that preemption is disabled.  gcing was never set to anything but 0 or
1, so we don't have to worry about there being a stack of reasons.

Change-Id: I4337c29e8e942e7aa4f106fc29597e1b5de4ef46
Reviewed-on: https://go-review.googlesource.com/3660
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime: update a few "onM"s in comments to say "systemstack"
Austin Clements [Wed, 28 Jan 2015 16:51:04 +0000 (11:51 -0500)]
runtime: update a few "onM"s in comments to say "systemstack"

Commit 656be31 replaced onM with systemstack, but missed updating a
few comments that still referred to onM.  Update these.

Change-Id: I0efb017e9a66ea0adebb6e1da6e518ee11263f69
Reviewed-on: https://go-review.googlesource.com/3664
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/9g: note suboptimal copy code
Austin Clements [Fri, 30 Jan 2015 16:18:24 +0000 (11:18 -0500)]
cmd/9g: note suboptimal copy code

9g generates needlessly complex code for small copies.  There are a
few other things that need to be improved about the copy code, so for
now just note the problem.

Change-Id: I0f1de4b2f9197a2635e27cc4b91ecf7a6c11f457
Reviewed-on: https://go-review.googlesource.com/3665
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agogo/printer: clearer logic (clenaup)
Robert Griesemer [Mon, 2 Feb 2015 19:02:09 +0000 (11:02 -0800)]
go/printer: clearer logic (clenaup)

Change-Id: I278ce47b38ec5732d981aec06b71f9ee5747c3bb
Reviewed-on: https://go-review.googlesource.com/3730
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agogo/printer: set prefix correctly when all comment lines blank
Dmitri Shuralyov [Mon, 2 Feb 2015 09:28:10 +0000 (01:28 -0800)]
go/printer: set prefix correctly when all comment lines blank

In stripCommonPrefix, the prefix was correctly calculated in all cases,
except one. That unhandled case is when there are more than 2 lines,
but all lines are blank (other than the first and last lines,
which contain /* and */ respectively).
This change detects that case and correctly sets the prefix calculated
from the last line. This is consistent with the (correct) behavior
that happens when there's at least one non-blank line.
That fixes issue #9751 that occurs for problematic input,
where cmd/gofmt and go/source would insert extra indentation on
every format operation. It also allows go/printer itself to print
such parsed files in an expected way.

Fixes #9751.

Change-Id: Id3dfb945beb59ffad3705085a3c285fca30a5f87
Reviewed-on: https://go-review.googlesource.com/3684
Reviewed-by: Robert Griesemer <gri@golang.org>
10 years agoos: fix TestMkdirAllAtSlash on Plan 9
David du Colombier [Mon, 2 Feb 2015 16:40:47 +0000 (17:40 +0100)]
os: fix TestMkdirAllAtSlash on Plan 9

Since CL 3676, the TestMkdirAllAtSlash test
depends on syscall.EROFS, which isn't defined
on Plan 9.

This change works around this issue by
defining a system dependent isReadonlyError
function.

Change-Id: If972fd2fe4828ee3bcb8537ea7f4ba29f7a87619
Reviewed-on: https://go-review.googlesource.com/3696
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agocmd/gc: always treat the output parameters as having been assigned in capturevars.
Shenghou Ma [Sat, 31 Jan 2015 07:50:56 +0000 (02:50 -0500)]
cmd/gc: always treat the output parameters as having been assigned in capturevars.

Fixes #9738.

Change-Id: Iab75de2d78335d4e31c3dce6a0e1826d8cddf5f3
Reviewed-on: https://go-review.googlesource.com/3690
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
10 years agonet: failed not faild
David Crawshaw [Mon, 2 Feb 2015 11:33:06 +0000 (11:33 +0000)]
net: failed not faild

Change-Id: Iea4221186325783db2029b07af1409015ddeda99
Reviewed-on: https://go-review.googlesource.com/3695
Reviewed-by: Dave Cheney <dave@cheney.net>
10 years agoos: don't silently skip test
Dave Cheney [Sat, 31 Jan 2015 03:48:14 +0000 (14:48 +1100)]
os: don't silently skip test

This is a followup to CL 3676.

Rather than silently returning from the test, a pass,
use the Skip facility to mark the test as skipped.

Change-Id: I90d237e770150bf8d69f14fb09874e70894a7f86
Reviewed-on: https://go-review.googlesource.com/3682
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoos: allow EROFS in TestMkdirAllAtSlash
Rahul Chaudhry [Fri, 30 Jan 2015 23:07:11 +0000 (15:07 -0800)]
os: allow EROFS in TestMkdirAllAtSlash

On some systems (e.g. ChromeOS), / is mounted read-only.
This results in error code syscall.EROFS, which I guess
is just as valid as syscall.EACCES for this test.

Change-Id: I9188d5437a1b5ac1daa9c68b95b8dcb447666ca3
Reviewed-on: https://go-review.googlesource.com/3676
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agomath/big: split float conversion routines and tests into separate files
Robert Griesemer [Fri, 30 Jan 2015 22:53:53 +0000 (14:53 -0800)]
math/big: split float conversion routines and tests into separate files

No other functional changes.

Change-Id: I7e0bb7452c6a265535297ec7ce6a629f1aff695c
Reviewed-on: https://go-review.googlesource.com/3674
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agomath/big: split rat conversion routines and tests into separate files
Robert Griesemer [Fri, 30 Jan 2015 22:20:04 +0000 (14:20 -0800)]
math/big: split rat conversion routines and tests into separate files

No other functional changes.

Change-Id: I8be1fc488caa4f3d4c00afcb8c00475bfcd10709
Reviewed-on: https://go-review.googlesource.com/3673
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agomath/big: split int conversion routines and tests into separate files
Robert Griesemer [Fri, 30 Jan 2015 22:25:55 +0000 (14:25 -0800)]
math/big: split int conversion routines and tests into separate files

No other functional changes.

Change-Id: If0d9e6208d53478e70d991b6926ea196b2cccf2e
Reviewed-on: https://go-review.googlesource.com/3672
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agomath/big: split nat conversion routines and tests into separate files
Robert Griesemer [Fri, 30 Jan 2015 22:12:21 +0000 (14:12 -0800)]
math/big: split nat conversion routines and tests into separate files

No functional changes.

Change-Id: Ibbb705b167603d30467f3ebb83a3bb39845306a5
Reviewed-on: https://go-review.googlesource.com/3671
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agomath/big: parsing of fractions and floats in mantissa bases other than 10
Robert Griesemer [Thu, 29 Jan 2015 01:11:15 +0000 (17:11 -0800)]
math/big: parsing of fractions and floats in mantissa bases other than 10

Change-Id: I1eaebf956a69e0958201cc5e0a9beefa062c71e1
Reviewed-on: https://go-review.googlesource.com/3454
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agodoc: add log.SetOutput to go1.5.txt
Andrew Gerrand [Fri, 30 Jan 2015 16:01:14 +0000 (16:01 +0000)]
doc: add log.SetOutput to go1.5.txt

Change-Id: I257211f10b334eb4828be96cd434d588bfb1a378
Reviewed-on: https://go-review.googlesource.com/3605
Reviewed-by: Rob Pike <r@golang.org>
10 years agolog: add SetOutput method on Logger
Andrew Gerrand [Mon, 19 Jan 2015 03:54:53 +0000 (14:54 +1100)]
log: add SetOutput method on Logger

Fixes #9629

Change-Id: I66091003b97742ca6d857fe51d609833ab727216
Reviewed-on: https://go-review.googlesource.com/3023
Reviewed-by: Rob Pike <r@golang.org>
10 years agocmd/pack: make a test less disk-intensive in short mode
Brad Fitzpatrick [Thu, 29 Jan 2015 12:45:56 +0000 (13:45 +0100)]
cmd/pack: make a test less disk-intensive in short mode

Fixes #9656

Change-Id: I1158636683492ef12eeafb12e257d205026adc3f
Reviewed-on: https://go-review.googlesource.com/3175
Reviewed-by: Minux Ma <minux@golang.org>
10 years agodoc: remove redundant images
Andrew Gerrand [Tue, 27 Jan 2015 08:50:00 +0000 (19:50 +1100)]
doc: remove redundant images

These are no longer used by anything.

Change-Id: I50c971418b07cafc983242833a196ba2028a2723
Reviewed-on: https://go-review.googlesource.com/3603
Reviewed-by: Rob Pike <r@golang.org>
10 years agoliblink: fix arm build again
Dave Cheney [Fri, 30 Jan 2015 05:20:46 +0000 (16:20 +1100)]
liblink: fix arm build again

Another attempt to fix the arm build by moving the include of signal.h
to cmd/lex.c, unless we are building on plan9.

Obviously if we had a plan9/arm builder this would probably not work, but
this is only a temporary measure until the c2go transition is complete.

Change-Id: I7f8ae27349b2e7a09c55db03e02a01939159a268
Reviewed-on: https://go-review.googlesource.com/3566
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime: fix system memory allocator on plan9
Dmitry Vyukov [Fri, 30 Jan 2015 11:36:12 +0000 (14:36 +0300)]
runtime: fix system memory allocator on plan9

The following line in sysFree:
n += (n + memRound) &^ memRound
doubles value of n (n += n).
Which is wrong and can lead to memory corruption.

Fixes #9712

Change-Id: I3c141b71da11e38837c09408cf4f1d22e8f7f36e
Reviewed-on: https://go-review.googlesource.com/3602
Reviewed-by: David du Colombier <0intro@gmail.com>
10 years agoruntime: fix trace ticks frequency on windows
Dmitry Vyukov [Thu, 29 Jan 2015 12:26:15 +0000 (15:26 +0300)]
runtime: fix trace ticks frequency on windows

Change-Id: I8c7fcc7705070bc9979e39d08a4c9b2870087a08
Reviewed-on: https://go-review.googlesource.com/3500
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
10 years agocmd/5l, cmd/9l: more ucontext.h fixes
Russ Cox [Fri, 30 Jan 2015 04:57:48 +0000 (23:57 -0500)]
cmd/5l, cmd/9l: more ucontext.h fixes

Change-Id: I32cad7358f5bfd8e107179653bdc55a69fbe772a
Reviewed-on: https://go-review.googlesource.com/3579
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/5l, cmd/8g: fix build failures
Russ Cox [Fri, 30 Jan 2015 04:49:27 +0000 (23:49 -0500)]
cmd/5l, cmd/8g: fix build failures

REG_R0 etc are defined in <ucontext.h> on ARM systems.
Possible use of uninitialized n in 8g/reg.c.

Change-Id: I6e8ce83a6515ca2b779ed8a344a25432db629cc2
Reviewed-on: https://go-review.googlesource.com/3578
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/dist: update for portable Prog, Addr
Russ Cox [Mon, 26 Jan 2015 20:16:24 +0000 (15:16 -0500)]
cmd/dist: update for portable Prog, Addr

There are no D_ names anymore.

Change-Id: Id3f1ce5efafb93818e5fd16c47ff48bbf61b5339
Reviewed-on: https://go-review.googlesource.com/3520
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
10 years agocmd/9a, cmd/9g, cmd/9l, liblink: update for portable Prog, Addr
Russ Cox [Mon, 26 Jan 2015 20:16:03 +0000 (15:16 -0500)]
cmd/9a, cmd/9g, cmd/9l, liblink: update for portable Prog, Addr

Change-Id: I55afed0eabf3c38e72ff105294782ac36446b66b
Reviewed-on: https://go-review.googlesource.com/3519
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
10 years agocmd/8a, cmd/8g, cmd/8l, liblink: update for portable Prog, Addr
Russ Cox [Mon, 26 Jan 2015 20:15:43 +0000 (15:15 -0500)]
cmd/8a, cmd/8g, cmd/8l, liblink: update for portable Prog, Addr

Change-Id: I19ed283962aa0221cf806307bde9ea0773a1bfd4
Reviewed-on: https://go-review.googlesource.com/3518
Reviewed-by: Austin Clements <austin@google.com>
10 years agocmd/6a, cmd/6g, cmd/6l, liblink: update for portable Prog, Addr
Russ Cox [Mon, 26 Jan 2015 20:15:25 +0000 (15:15 -0500)]
cmd/6a, cmd/6g, cmd/6l, liblink: update for portable Prog, Addr

Change-Id: I5535582660da3504663c6cba2637da132c65a400
Reviewed-on: https://go-review.googlesource.com/3517
Reviewed-by: Austin Clements <austin@google.com>
10 years agocmd/5a, cmd/5g, cmd/5l, liblink: update for portable Prog, Addr
Russ Cox [Mon, 26 Jan 2015 20:15:05 +0000 (15:15 -0500)]
cmd/5a, cmd/5g, cmd/5l, liblink: update for portable Prog, Addr

Change-Id: I06762d4fb3bb2616087339b6ae1eb5267a39c46a
Reviewed-on: https://go-review.googlesource.com/3516
Reviewed-by: Austin Clements <austin@google.com>
10 years agocmd/gc, cmd/ld, liblink: update for portable Prog, Addr changes
Russ Cox [Mon, 26 Jan 2015 20:14:23 +0000 (15:14 -0500)]
cmd/gc, cmd/ld, liblink: update for portable Prog, Addr changes

Change-Id: Ia6f8badca56565b9df80c8dbe28c47f6cf7e653f
Reviewed-on: https://go-review.googlesource.com/3515
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
10 years agoliblink: make Prog, Addr more portable and document
Russ Cox [Mon, 26 Jan 2015 20:13:05 +0000 (15:13 -0500)]
liblink: make Prog, Addr more portable and document

Change-Id: Idda476b71ae23f7b73fe63f062cf3531c1268eb3
Reviewed-on: https://go-review.googlesource.com/3514
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Dave Cheney <dave@cheney.net>
10 years agoliblink: fix error message on linux for unknown TLS base
Russ Cox [Thu, 29 Jan 2015 03:39:57 +0000 (22:39 -0500)]
liblink: fix error message on linux for unknown TLS base

headstr(Hlinux) was reporting "android",
making for some confusing error messages.

Change-Id: I437095bee7cb2143aa37c91cf786f3a3581ae7b9
Reviewed-on: https://go-review.googlesource.com/3513
Reviewed-by: Austin Clements <austin@google.com>
10 years agocmd/9g: use nopout in excise
Russ Cox [Thu, 29 Jan 2015 01:44:55 +0000 (20:44 -0500)]
cmd/9g: use nopout in excise

In addition to duplicating the logic, the old code was
clearing the line number, which led to missing source line
information in the -S output.

Also fix nopout, which was incomplete.

Change-Id: Ic2b596a2f9ec2fe85642ebe125cca8ef38c83085
Reviewed-on: https://go-review.googlesource.com/3512
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
10 years agoliblink: bug fixes for ppc64 %P format
Russ Cox [Wed, 28 Jan 2015 02:07:35 +0000 (21:07 -0500)]
liblink: bug fixes for ppc64 %P format

- certain code paths were appending to the string without first clearing it.
- some prints were using spaces instead of tabs

Change-Id: I7a3d38289c8206682baf8942abf5a9950a56b449
Reviewed-on: https://go-review.googlesource.com/3511
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
10 years agotest/closure2.go: correctly "use" tmp
Robert Griesemer [Thu, 29 Jan 2015 22:18:52 +0000 (14:18 -0800)]
test/closure2.go: correctly "use" tmp

cmd/go doesn't complain (this is an open issue), but go/types does

Change-Id: I2caec1f7aec991a9500d2c3504c29e4ab718c138
Reviewed-on: https://go-review.googlesource.com/3541
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agoruntime: scanvalid race Fixes #9727
Rick Hudson [Thu, 29 Jan 2015 15:37:32 +0000 (10:37 -0500)]
runtime: scanvalid race Fixes #9727

Set gcscanvalid=false after you have cased to _Grunning.
If you do it before the cas and the atomicstatus races to a scan state,
the scan will set gcscanvalid=true and we will be _Grunning
with gcscanvalid==true which is not a good thing.

Change-Id: Ie53ea744a5600392b47da91159d985fe6fe75961
Reviewed-on: https://go-review.googlesource.com/3510
Reviewed-by: Austin Clements <austin@google.com>
10 years agoruntime: use func value for parfor body
Austin Clements [Wed, 28 Jan 2015 20:55:23 +0000 (15:55 -0500)]
runtime: use func value for parfor body

Yet another leftover from C: parfor took a func value for the
callback, casted it to an unsafe.Pointer for storage, and then casted
it back to a func value to call it.  This is unnecessary, so just
store the body as a func value.  Beyond general cleanup, this also
eliminates the last use of unsafe in parfor.

Change-Id: Ia904af7c6c443ba75e2699835aee8e9a39b26dd8
Reviewed-on: https://go-review.googlesource.com/3396
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
10 years agoruntime: eliminate parfor ctx field
Austin Clements [Wed, 28 Jan 2015 20:49:26 +0000 (15:49 -0500)]
runtime: eliminate parfor ctx field

Prior to the conversion of the runtime to Go, this void* was
necessary to get closure information in to C callbacks.  There
are no more C callbacks and parfor is perfectly capable of
invoking a Go closure now, so eliminate ctx and all of its
unsafe-ness.  (Plus, the runtime currently doesn't use ctx for
anything.)

Change-Id: I39fc53b7dd3d7f660710abc76b0d831bfc6296d8
Reviewed-on: https://go-review.googlesource.com/3395
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
10 years agoruntime: use threads slice in parfor instead of unsafe pointer math
Austin Clements [Wed, 28 Jan 2015 20:25:05 +0000 (15:25 -0500)]
runtime: use threads slice in parfor instead of unsafe pointer math

parfor originally used a tail array for its thread array.  This got
replaced with a slice allocation in the conversion to Go, but many of
its gnarlier effects remained.  Instead of keeping track of the
pointer to the first element of the slice and using unsafe pointer
math to get at the ith element, just keep the slice around and use
regular slice indexing.  There is no longer any need for padding to
64-bit align the tail array (there hasn't been since the Go
conversion), so remove this unnecessary padding from the parfor
struct.  Finally, since the slice tracks its own length, replace the
nthrmax field with len(thr).

Change-Id: I0020a1815849bca53e3613a8fa46ae4fbae67576
Reviewed-on: https://go-review.googlesource.com/3394
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime: move all parfor-related code to parfor.go
Austin Clements [Wed, 28 Jan 2015 19:51:49 +0000 (14:51 -0500)]
runtime: move all parfor-related code to parfor.go

This cleanup was slated for after the conversion of the runtime to Go.
Also improve type and function documentation.

Change-Id: I55a16b09e00cf701f246deb69e7ce7e3e04b26e7
Reviewed-on: https://go-review.googlesource.com/3393
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
10 years agoruntime: check alignment of 8-byte atomic loads and stores on 386
Austin Clements [Thu, 29 Jan 2015 16:54:45 +0000 (11:54 -0500)]
runtime: check alignment of 8-byte atomic loads and stores on 386

Currently, if we do an atomic{load,store}64 of an unaligned address on
386, we'll simply get a non-atomic load/store.  This has been the
source of myriad bugs, so add alignment checks to these two
operations.  These checks parallel the equivalent checks in
sync/atomic.

The alignment check is not necessary in cas64 because it uses a locked
instruction.  The CPU will either execute this atomically or raise an
alignment fault (#AC)---depending on the alignment check flag---either
of which is fine.

This also fixes the two places in the runtime that trip the new
checks.  One is in the runtime self-test and shouldn't have caused
real problems.  The other is in tickspersecond and could, in
principle, have caused a misread of the ticks per second during
initialization.

Change-Id: If1796667012a6154f64f5e71d043c7f5fb3dd050
Reviewed-on: https://go-review.googlesource.com/3521
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/go: add build flag -toolexec
Russ Cox [Tue, 27 Jan 2015 01:58:17 +0000 (20:58 -0500)]
cmd/go: add build flag -toolexec

Like the -exec flag, which specifies a program to use to run a built executable,
the -toolexec flag specifies a program to use to run a tool like 5a, 5g, or 5l.

This flag enables running the toolchain under common testing environments,
such as valgrind.

This flag also enables the use of custom testing environments or the substitution
of alternate tools. See https://godoc.org/rsc.io/toolstash for one possibility.

Change-Id: I256aa7af2d96a4bc7911dc58151cc2155dbd4121
Reviewed-on: https://go-review.googlesource.com/3351
Reviewed-by: Rob Pike <r@golang.org>
10 years agocmd/gc: capture variables by value
Dmitry Vyukov [Mon, 19 Jan 2015 19:59:58 +0000 (22:59 +0300)]
cmd/gc: capture variables by value

Language specification says that variables are captured by reference.
And that is what gc compiler does. However, in lots of cases it is
possible to capture variables by value under the hood without
affecting visible behavior of programs. For example, consider
the following typical pattern:

func (o *Obj) requestMany(urls []string) []Result {
wg := new(sync.WaitGroup)
wg.Add(len(urls))
res := make([]Result, len(urls))
for i := range urls {
i := i
go func() {
res[i] = o.requestOne(urls[i])
wg.Done()
}()
}
wg.Wait()
return res
}

Currently o, wg, res, and i are captured by reference causing 3+len(urls)
allocations (e.g. PPARAM o is promoted to PPARAMREF and moved to heap).
But all of them can be captured by value without changing behavior.

This change implements simple strategy for capturing by value:
if a captured variable is not addrtaken and never assigned to,
then it is captured by value (it is effectively const).
This simple strategy turned out to be very effective:
~80% of all captures in std lib are turned into value captures.
The remaining 20% are mostly in defers and non-escaping closures,
that is, they do not cause allocations anyway.

benchmark                                    old allocs     new allocs     delta
BenchmarkCompressedZipGarbage                153            126            -17.65%
BenchmarkEncodeDigitsSpeed1e4                91             69             -24.18%
BenchmarkEncodeDigitsSpeed1e5                178            129            -27.53%
BenchmarkEncodeDigitsSpeed1e6                1510           1051           -30.40%
BenchmarkEncodeDigitsDefault1e4              100            75             -25.00%
BenchmarkEncodeDigitsDefault1e5              193            139            -27.98%
BenchmarkEncodeDigitsDefault1e6              1420           985            -30.63%
BenchmarkEncodeDigitsCompress1e4             100            75             -25.00%
BenchmarkEncodeDigitsCompress1e5             193            139            -27.98%
BenchmarkEncodeDigitsCompress1e6             1420           985            -30.63%
BenchmarkEncodeTwainSpeed1e4                 109            81             -25.69%
BenchmarkEncodeTwainSpeed1e5                 211            151            -28.44%
BenchmarkEncodeTwainSpeed1e6                 1588           1097           -30.92%
BenchmarkEncodeTwainDefault1e4               103            77             -25.24%
BenchmarkEncodeTwainDefault1e5               199            143            -28.14%
BenchmarkEncodeTwainDefault1e6               1324           917            -30.74%
BenchmarkEncodeTwainCompress1e4              103            77             -25.24%
BenchmarkEncodeTwainCompress1e5              190            137            -27.89%
BenchmarkEncodeTwainCompress1e6              1327           919            -30.75%
BenchmarkConcurrentDBExec                    16223          16220          -0.02%
BenchmarkConcurrentStmtQuery                 17687          16182          -8.51%
BenchmarkConcurrentStmtExec                  5191           5186           -0.10%
BenchmarkConcurrentTxQuery                   17665          17661          -0.02%
BenchmarkConcurrentTxExec                    15154          15150          -0.03%
BenchmarkConcurrentTxStmtQuery               17661          16157          -8.52%
BenchmarkConcurrentTxStmtExec                3677           3673           -0.11%
BenchmarkConcurrentRandom                    14000          13614          -2.76%
BenchmarkManyConcurrentQueries               25             22             -12.00%
BenchmarkDecodeComplex128Slice               318            252            -20.75%
BenchmarkDecodeFloat64Slice                  318            252            -20.75%
BenchmarkDecodeInt32Slice                    318            252            -20.75%
BenchmarkDecodeStringSlice                   2318           2252           -2.85%
BenchmarkDecode                              11             8              -27.27%
BenchmarkEncodeGray                          64             56             -12.50%
BenchmarkEncodeNRGBOpaque                    64             56             -12.50%
BenchmarkEncodeNRGBA                         67             58             -13.43%
BenchmarkEncodePaletted                      68             60             -11.76%
BenchmarkEncodeRGBOpaque                     64             56             -12.50%
BenchmarkGoLookupIP                          153            139            -9.15%
BenchmarkGoLookupIPNoSuchHost                508            466            -8.27%
BenchmarkGoLookupIPWithBrokenNameServer      245            226            -7.76%
BenchmarkClientServer                        62             59             -4.84%
BenchmarkClientServerParallel4               62             59             -4.84%
BenchmarkClientServerParallel64              62             59             -4.84%
BenchmarkClientServerParallelTLS4            79             76             -3.80%
BenchmarkClientServerParallelTLS64           112            109            -2.68%
BenchmarkCreateGoroutinesCapture             10             6              -40.00%
BenchmarkAfterFunc                           1006           1005           -0.10%

Fixes #6632.

Change-Id: I0cd51e4d356331d7f3c5f447669080cd19b0d2ca
Reviewed-on: https://go-review.googlesource.com/3166
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agonet: remove full stack test cases for IPConn
Mikio Hara [Wed, 28 Jan 2015 02:38:05 +0000 (11:38 +0900)]
net: remove full stack test cases for IPConn

A few packages that handle net.IPConn in golang.org/x/net sub repository
already implement full stack test cases with more coverage than the net
package. There is no need to keep duplicate code around here.

This change removes full stack test cases for IPConn that require
knowing how to speak with each of protocol stack implementation of
supported platforms.

Change-Id: I871119a9746fc6a2b997b69cfd733463558f5816
Reviewed-on: https://go-review.googlesource.com/3404
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agonet: remove solaris tag from cgo
Mikio Hara [Mon, 26 Jan 2015 11:52:02 +0000 (20:52 +0900)]
net: remove solaris tag from cgo

For now solaris port does not support cgo. Moreover, its system calls
and library interfaces are different from BSD.

Change-Id: Idb4fed889973368b35d38b361b23581abacfdeab
Reviewed-on: https://go-review.googlesource.com/3306
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
10 years agoencoding/json: add UnmarshalTypeError.Offset
Alex Plugaru [Mon, 26 Jan 2015 10:51:43 +0000 (11:51 +0100)]
encoding/json: add UnmarshalTypeError.Offset

Fixes #9693

Change-Id: Ibf07199729bfc883b2a7e051cafd98185f912acd
Reviewed-on: https://go-review.googlesource.com/3283
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoexpvar: Use sync/atomic to manipulate Int for better perf
Evan Phoenix [Wed, 28 Jan 2015 17:16:44 +0000 (09:16 -0800)]
expvar: Use sync/atomic to manipulate Int for better perf

Using a mutex to protect a single int operation is quite heavyweight.
Using sync/atomic provides much better performance. This change was
benchmarked as such:

BenchmarkSync   10000000       139 ns/op
BenchmarkAtomic 200000000      9.90 ns/op

package blah

import (
        "sync"
        "sync/atomic"
        "testing"
)

type Int struct {
        mu sync.RWMutex
        i  int64
}

func (v *Int) Add(delta int64) {
        v.mu.Lock()
        defer v.mu.Unlock()
        v.i += delta
}

type AtomicInt struct {
        i int64
}

func (v *AtomicInt) Add(delta int64) {
        atomic.AddInt64(&v.i, delta)
}

func BenchmarkSync(b *testing.B) {
        s := new(Int)

        for i := 0; i < b.N; i++ {
                s.Add(1)
        }
}

func BenchmarkAtomic(b *testing.B) {
        s := new(AtomicInt)

        for i := 0; i < b.N; i++ {
                s.Add(1)
        }
}

Change-Id: I6998239c785967647351bbfe8533c38e4894543b
Reviewed-on: https://go-review.googlesource.com/3430
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
10 years agocmd/cgo: add support for s390 and s390x
Dominik Vogt [Tue, 13 Jan 2015 11:36:44 +0000 (12:36 +0100)]
cmd/cgo: add support for s390 and s390x

This patch was previously sent for review using hg:
golang.org/cl/173930043

Change-Id: I559a2f2ee07990d0c23d2580381e32f8e23077a5
Reviewed-on: https://go-review.googlesource.com/3033
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agomath/big: sketched out complete set of Float/string conversion functions
Robert Griesemer [Wed, 28 Jan 2015 00:51:59 +0000 (16:51 -0800)]
math/big: sketched out complete set of Float/string conversion functions

Also:
- use io.ByteScanner rather than io.RuneScanner internally
- minor simplifications in Float.Add/Sub

Change-Id: Iae0e99384128dba9eccf68592c4fd389e2bd3b4f
Reviewed-on: https://go-review.googlesource.com/3380
Reviewed-by: Rob Pike <r@golang.org>
10 years agoruntime: set minimum heap size to 4Mbytes
Rick Hudson [Wed, 28 Jan 2015 20:57:46 +0000 (15:57 -0500)]
runtime: set minimum heap size to 4Mbytes

Set the minimum heap size to 4Mbytes except when the hash
table code wants to force a GC. In an unrelated change when a
mutator is asked to assist the GC by marking pointer workbufs
it will keep working until the requested number of pointers
are processed even if it means asking for additional workbufs.

Change-Id: I661cfc0a7f2efcf6286b5d37d73e593d9ecd04d5
Reviewed-on: https://go-review.googlesource.com/3392
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
10 years agocmd/gc: allocate stack buffer for ORUNESTR
Dmitry Vyukov [Wed, 28 Jan 2015 05:42:20 +0000 (08:42 +0300)]
cmd/gc: allocate stack buffer for ORUNESTR

If result of string(i) does not escape,
allocate a [4]byte temp on stack for it.

Change-Id: If31ce9447982929d5b3b963fd0830efae4247c37
Reviewed-on: https://go-review.googlesource.com/3411
Reviewed-by: Russ Cox <rsc@golang.org>