]> Cypherpunks repositories - gostls13.git/log
gostls13.git
10 years agonet/http: close HTTP response bodies in benchmark
Brad Fitzpatrick [Wed, 28 Jan 2015 18:44:54 +0000 (12:44 -0600)]
net/http: close HTTP response bodies in benchmark

This should fix the race builders.

Change-Id: I9c9e7393d5e29d64ab797e346b34b1fa1dfe6d96
Reviewed-on: https://go-review.googlesource.com/3441
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
10 years agonet/http/pprof: add tracing support
Dmitry Vyukov [Fri, 12 Dec 2014 17:58:09 +0000 (18:58 +0100)]
net/http/pprof: add tracing support

net/http/pprof part of tracing functionality:
https://docs.google.com/document/u/1/d/1FP5apqzBgr7ahCCgFO-yoVhk4YZrNIDNf9RybngBc14/pub
Full change:
https://codereview.appspot.com/146920043

Change-Id: I9092028fcbd5e8f97a56f2c155889ccdfb494afb
Reviewed-on: https://go-review.googlesource.com/1453
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/gc: don't copy []byte during string comparison
Dmitry Vyukov [Tue, 27 Jan 2015 20:57:12 +0000 (23:57 +0300)]
cmd/gc: don't copy []byte during string comparison

Currently we allocate a new string during []byte->string conversion
in string comparison expressions. String allocation is unnecessary in
this case, because comparison does memorize the strings for later use.
This change uses slicebytetostringtmp to construct temp string directly
from []byte buffer and passes it to runtime.eqstring.

Change-Id: If00f1faaee2076baa6f6724d245d5b5e0f59b563
Reviewed-on: https://go-review.googlesource.com/3410
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime/pprof: skip trace tests on solaris and windows
Dmitry Vyukov [Wed, 28 Jan 2015 17:08:54 +0000 (20:08 +0300)]
runtime/pprof: skip trace tests on solaris and windows

Coarse-grained test skips to fix bots.
Need to look closer at windows and nacl failures.

Change-Id: I767ef1707232918636b33f715459ee3c0349b45e
Reviewed-on: https://go-review.googlesource.com/3416
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agocmd/gc: ignore re-slicing in escape analysis
Dmitry Vyukov [Fri, 16 Jan 2015 20:30:35 +0000 (23:30 +0300)]
cmd/gc: ignore re-slicing in escape analysis

Escape analysis treats everything assigned to OIND/ODOTPTR as escaping.
As the result b escapes in the following code:

func (b *Buffer) Foo() {
n, m := ...
b.buf = b.buf[n:m]
}

This change recognizes such assignments and ignores them.

Update issue #9043.
Update issue #7921.

There are two similar cases in std lib that benefit from this optimization.
First is in archive/zip:

type readBuf []byte
func (b *readBuf) uint32() uint32 {
v := binary.LittleEndian.Uint32(*b)
*b = (*b)[4:]
return v
}

Second is in time:

type data struct {
p     []byte
error bool
}

func (d *data) read(n int) []byte {
if len(d.p) < n {
d.p = nil
d.error = true
return nil
}
p := d.p[0:n]
d.p = d.p[n:]
return p
}

benchmark                         old ns/op     new ns/op     delta
BenchmarkCompressedZipGarbage     32431724      32217851      -0.66%

benchmark                         old allocs     new allocs     delta
BenchmarkCompressedZipGarbage     153            143            -6.54%

Change-Id: Ia6cd32744e02e36d6d8c19f402f8451101711626
Reviewed-on: https://go-review.googlesource.com/3162
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/gc: improve escape analysis for &T{...}
Dmitry Vyukov [Mon, 19 Jan 2015 20:46:22 +0000 (23:46 +0300)]
cmd/gc: improve escape analysis for &T{...}

Currently all PTRLIT element initializers escape. There is no reason for that.
This change links STRUCTLIT to PTRLIT; STRUCTLIT element initializers are
already linked to the STRUCTLIT. As the result, PTRLIT element initializers
escape when PTRLIT itself escapes.

Change-Id: I89ecd8677cbf81addcfd469cd2fd461c0e9bf7dd
Reviewed-on: https://go-review.googlesource.com/3031
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime/pprof: add tests for tracer
Dmitry Vyukov [Tue, 23 Dec 2014 19:22:56 +0000 (22:22 +0300)]
runtime/pprof: add tests for tracer

Change-Id: I832a433f0f2fc10b0a2fea0bfb003a988fc2c81b
Reviewed-on: https://go-review.googlesource.com/2039
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/go: add tracing support
Dmitry Vyukov [Fri, 12 Dec 2014 18:41:18 +0000 (19:41 +0100)]
cmd/go: add tracing support

cmd/go part of tracing functionality:
https://docs.google.com/document/u/1/d/1FP5apqzBgr7ahCCgFO-yoVhk4YZrNIDNf9RybngBc14/pub
Full change:
https://codereview.appspot.com/146920043

Change-Id: If346e11b8029c475b01fbf7172ce1c88171fb1b2
Reviewed-on: https://go-review.googlesource.com/1460
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agotesting: add tracing support
Dmitry Vyukov [Fri, 12 Dec 2014 18:43:23 +0000 (19:43 +0100)]
testing: add tracing support

testing part of tracing functionality:
https://docs.google.com/document/u/1/d/1FP5apqzBgr7ahCCgFO-yoVhk4YZrNIDNf9RybngBc14/pub
Full change:
https://codereview.appspot.com/146920043

Change-Id: Ia3c2c4417106937d5775b0e7064db92c1fc36679
Reviewed-on: https://go-review.googlesource.com/1461
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime/pprof: add tracing support
Dmitry Vyukov [Fri, 12 Dec 2014 17:56:36 +0000 (18:56 +0100)]
runtime/pprof: add tracing support

runtime/pprof part of tracing functionality:
https://docs.google.com/document/u/1/d/1FP5apqzBgr7ahCCgFO-yoVhk4YZrNIDNf9RybngBc14/pub
Full change:
https://codereview.appspot.com/146920043

Change-Id: I3143a569cbd33576f19ca47308d1ff5200d8c955
Reviewed-on: https://go-review.googlesource.com/1452
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime: add tracing of runtime events
Dmitry Vyukov [Fri, 12 Dec 2014 17:41:57 +0000 (18:41 +0100)]
runtime: add tracing of runtime events

Add actual tracing of interesting runtime events.
Part of a larger tracing functionality:
https://docs.google.com/document/u/1/d/1FP5apqzBgr7ahCCgFO-yoVhk4YZrNIDNf9RybngBc14/pub
Full change:
https://codereview.appspot.com/146920043

Change-Id: Icccf54aea54e09350bb698ba6bf11532f9fbe6d3
Reviewed-on: https://go-review.googlesource.com/1451
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime: add execution tracing functionality
Dmitry Vyukov [Fri, 12 Dec 2014 17:11:27 +0000 (18:11 +0100)]
runtime: add execution tracing functionality

This is first patch of series of patches that implement tracing functionality.
Design doc:
https://docs.google.com/document/u/1/d/1FP5apqzBgr7ahCCgFO-yoVhk4YZrNIDNf9RybngBc14/pub
Full change:
https://codereview.appspot.com/146920043

Change-Id: I84588348bb05a6f6a102c230f3bca6380a3419fe
Reviewed-on: https://go-review.googlesource.com/1450
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/gc: fix condition for fast pathed interface conversions
Dmitry Vyukov [Wed, 28 Jan 2015 14:28:50 +0000 (17:28 +0300)]
cmd/gc: fix condition for fast pathed interface conversions

For some reason the current conditions require the type to be "uintptr-shaped".
This cuts off structs and arrays with a pointer.
isdirectiface and width==widthptr is sufficient condition to enable the fast paths.

Change-Id: I11842531e7941365413606cfd6c34c202aa14786
Reviewed-on: https://go-review.googlesource.com/3414
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/gc: allow map index expressions in for range statements
Dmitry Vyukov [Mon, 26 Jan 2015 08:26:55 +0000 (11:26 +0300)]
cmd/gc: allow map index expressions in for range statements

Fixes #9691.

Change-Id: I22bfc82e05497e91a7b18a668913aed6c723365d
Reviewed-on: https://go-review.googlesource.com/3282
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agonet/http: fix goroutine leak in benchmark
Dmitry Vyukov [Wed, 28 Jan 2015 13:17:36 +0000 (16:17 +0300)]
net/http: fix goroutine leak in benchmark

Race builders report goroutine leaks after addition of this benchmark:
http://build.golang.org/log/18e47f4cbc18ee8db125e1f1157573dd1e333c41
Close idle connection in default transport.

Change-Id: I86ff7b2e0972ed47c5ebcb9fce19e7f39d3ff530
Reviewed-on: https://go-review.googlesource.com/3412
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoreflect: cache call frames
Dmitry Vyukov [Mon, 22 Dec 2014 19:31:55 +0000 (22:31 +0300)]
reflect: cache call frames

Call frame allocations can account for significant portion
of all allocations in a program, if call is executed
in an inner loop (e.g. to process every line in a log).
On the other hand, the allocation is easy to remove
using sync.Pool since the allocation is strictly scoped.

benchmark           old ns/op     new ns/op     delta
BenchmarkCall       634           338           -46.69%
BenchmarkCall-4     496           167           -66.33%

benchmark           old allocs     new allocs     delta
BenchmarkCall       1              0              -100.00%
BenchmarkCall-4     1              0              -100.00%

Update #7818

Change-Id: Icf60cce0a9be82e6171f0c0bd80dee2393db54a7
Reviewed-on: https://go-review.googlesource.com/1954
Reviewed-by: Keith Randall <khr@golang.org>
10 years agonet: update test cases for network interface API
Mikio Hara [Mon, 26 Jan 2015 09:04:44 +0000 (18:04 +0900)]
net: update test cases for network interface API

This change extends existing test case to Windows for helping to fix
golang.org/issue/5395.

Change-Id: Iff077fa98ede511981df513f48d84c19375b3e04
Reviewed-on: https://go-review.googlesource.com/3304
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
10 years agoliblink: do not print pointers in debug output
Russ Cox [Tue, 27 Jan 2015 19:53:14 +0000 (14:53 -0500)]
liblink: do not print pointers in debug output

Pointers change from run to run, making it hard to use
the debug output to identify the reason for a changed
object file.

Change-Id: I0c954da0943092c48686afc99ecf75eba516de6a
Reviewed-on: https://go-review.googlesource.com/3352
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Rob Pike <r@golang.org>
10 years agocrypto/ecdsa: make Sign safe with broken entropy sources
David Leon Gil [Tue, 27 Jan 2015 07:00:21 +0000 (23:00 -0800)]
crypto/ecdsa: make Sign safe with broken entropy sources

ECDSA is unsafe to use if an entropy source produces predictable
output for the ephemeral nonces. E.g., [Nguyen]. A simple
countermeasure is to hash the secret key, the message, and
entropy together to seed a CSPRNG, from which the ephemeral key
is derived.

Fixes #9452

--

This is a minimalist (in terms of patch size) solution, though
not the most parsimonious in its use of primitives:

   - csprng_key = ChopMD-256(SHA2-512(priv.D||entropy||hash))
   - reader = AES-256-CTR(k=csprng_key)

This, however, provides at most 128-bit collision-resistance,
so that Adv will have a term related to the number of messages
signed that is significantly worse than plain ECDSA. This does
not seem to be of any practical importance.

ChopMD-256(SHA2-512(x)) is used, rather than SHA2-256(x), for
two sets of reasons:

*Practical:* SHA2-512 has a larger state and 16 more rounds; it
is likely non-generically stronger than SHA2-256. And, AFAIK,
cryptanalysis backs this up. (E.g., [Biryukov] gives a
distinguisher on 47-round SHA2-256 with cost < 2^85.) This is
well below a reasonable security-strength target.

*Theoretical:* [Coron] and [Chang] show that Chop-MD(F(x)) is
indifferentiable from a random oracle for slightly beyond the
birthday barrier. It seems likely that this makes a generic
security proof that this construction remains UF-CMA is
possible in the indifferentiability framework.

--

Many thanks to Payman Mohassel for reviewing this construction;
any mistakes are mine, however. And, as he notes, reusing the
private key in this way means that the generic-group (non-RO)
proof of ECDSA's security given in [Brown] no longer directly
applies.

--

[Brown]: http://www.cacr.math.uwaterloo.ca/techreports/2000/corr2000-54.ps
"Brown. The exact security of ECDSA. 2000"

[Coron]: https://www.cs.nyu.edu/~puniya/papers/merkle.pdf
"Coron et al. Merkle-Damgard revisited. 2005"

[Chang]: https://www.iacr.org/archive/fse2008/50860436/50860436.pdf
"Chang and Nandi. Improved indifferentiability security analysis
of chopMD hash function. 2008"

[Biryukov]: http://www.iacr.org/archive/asiacrypt2011/70730269/70730269.pdf
"Biryukov et al. Second-order differential collisions for reduced
SHA-256. 2011"

[Nguyen]: ftp://ftp.di.ens.fr/pub/users/pnguyen/PubECDSA.ps
"Nguyen and Shparlinski. The insecurity of the elliptic curve
digital signature algorithm with partially known nonces. 2003"

New tests:

  TestNonceSafety: Check that signatures are safe even with a
    broken entropy source.

  TestINDCCA: Check that signatures remain non-deterministic
    with a functional entropy source.

Updated "golden" KATs in crypto/tls/testdata that use ECDSA suites.

Change-Id: I55337a2fbec2e42a36ce719bd2184793682d678a
Reviewed-on: https://go-review.googlesource.com/3340
Reviewed-by: Adam Langley <agl@golang.org>
10 years agomath/big: various fixes, enable tests for 32bit platforms
Robert Griesemer [Tue, 27 Jan 2015 00:08:51 +0000 (16:08 -0800)]
math/big: various fixes, enable tests for 32bit platforms

- fixed Float.Add, Float.Sub
- fixed Float.PString to be platform independent
- fixed Float.Uint64
- fixed various test outputs

TBR: adonovan

Change-Id: I9d273b344d4786f1fed18862198b23285c358a39
Reviewed-on: https://go-review.googlesource.com/3321
Reviewed-by: Robert Griesemer <gri@golang.org>
10 years agoruntime: simplify code
Dmitry Vyukov [Tue, 27 Jan 2015 19:55:03 +0000 (22:55 +0300)]
runtime: simplify code

The %61 hack was added when runtime was is in C.
Now the Go compiler does the optimization.

Change-Id: I79c3302ec4b931eaaaaffe75e7101c92bf287fc7
Reviewed-on: https://go-review.googlesource.com/3289
Reviewed-by: Keith Randall <khr@golang.org>
10 years agonet/http: add client benchmark
Dmitry Vyukov [Thu, 22 Jan 2015 19:54:18 +0000 (22:54 +0300)]
net/http: add client benchmark

BenchmarkClient is intended for profiling
the client without the HTTP server code.
The server code runs in a subprocess.

Change-Id: I9aa128604d0d4e94dc5c0372dc86f962282ed6e8
Reviewed-on: https://go-review.googlesource.com/3164
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agounsafe: fix doc strings
Robert Griesemer [Tue, 27 Jan 2015 17:57:48 +0000 (09:57 -0800)]
unsafe: fix doc strings

Change-Id: I73a416291a2374dbb8ce8586f24059f8dce56529
Reviewed-on: https://go-review.googlesource.com/3360
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agocmd/gc: don't copy []byte during string concatenation
Dmitry Vyukov [Thu, 22 Jan 2015 14:56:12 +0000 (17:56 +0300)]
cmd/gc: don't copy []byte during string concatenation

Consider the following code:

s := "(" + string(byteSlice) + ")"

Currently we allocate a new string during []byte->string conversion,
and pass it to concatstrings. String allocation is unnecessary in
this case, because concatstrings does memorize the strings for later use.
This change uses slicebytetostringtmp to construct temp string directly
from []byte buffer and passes it to concatstrings.

I've found few such cases in std lib:

s += string(msg[off:off+c]) + "."
buf.WriteString("Sec-WebSocket-Accept: " + string(c.accept) + "\r\n")
bw.WriteString("Sec-WebSocket-Key: " + string(nonce) + "\r\n")
err = xml.Unmarshal([]byte("<Top>"+string(data)+"</Top>"), &logStruct)
d.err = d.syntaxError("invalid XML name: " + string(b))
return m, ProtocolError("malformed MIME header line: " + string(kv))

But there are much more in our internal code base.

Change-Id: I42f401f317131237ddd0cb9786b0940213af16fb
Reviewed-on: https://go-review.googlesource.com/3163
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/gc: don't emit write barriers for *tmp if tmp=&PAUTO
Dmitry Vyukov [Mon, 26 Jan 2015 14:19:00 +0000 (17:19 +0300)]
cmd/gc: don't emit write barriers for *tmp if tmp=&PAUTO

This is another case where we can say that the address refers to stack.
We create such temps for OSTRUCTLIT initialization.

This eliminates a handful of write barriers today.
But this come up a prerequisite for another change (capturing vars by value),
otherwise we emit writebarriers in writebarrier itself when
capture writebarrier arguments by value.

Change-Id: Ibba93acd0f5431c5a4c3d90ef1e622cb9a7ff50e
Reviewed-on: https://go-review.googlesource.com/3285
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/gc: fix range typecheck order
Dmitry Vyukov [Mon, 26 Jan 2015 13:43:20 +0000 (16:43 +0300)]
cmd/gc: fix range typecheck order

Typecheck for range variables before typechecking for range body.
Body can refer to new vars declared in for range,
so it is preferable to typecheck them before the body.
Makes typecheck order consistent between ORANGE and OFOR.

This come up during another change that computes some predicates
on variables during typechecking.

Change-Id: Ic975db61b1fd5b7f9ee78896d4cc7d93c593c532
Reviewed-on: https://go-review.googlesource.com/3284
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime: fix wbshadow mode
Dmitry Vyukov [Mon, 26 Jan 2015 14:28:54 +0000 (17:28 +0300)]
runtime: fix wbshadow mode

Half of tests currently crash with GODEBUG=wbshadow.
_PageSize is set to 8192. So data can be extended outside
of actually mapped region during rounding. Which leads to crash
during initial copying to shadow.
Use _PhysPageSize instead.

Change-Id: Iaa89992bd57f86dafa16b092b53fdc0606213acb
Reviewed-on: https://go-review.googlesource.com/3286
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime: do not scan maps when k/v do not contain pointers
Dmitry Vyukov [Mon, 26 Jan 2015 18:04:41 +0000 (21:04 +0300)]
runtime: do not scan maps when k/v do not contain pointers

Currently we scan maps even if k/v does not contain pointers.
This is required because overflow buckets are hanging off the main table.
This change introduces a separate array that contains pointers to all
overflow buckets and keeps them alive. Buckets themselves are marked
as containing no pointers and are not scanned by GC (if k/v does not
contain pointers).

This brings maps in line with slices and chans -- GC does not scan
their contents if elements do not contain pointers.

Currently scanning of a map[int]int with 2e8 entries (~8GB heap)
takes ~8 seconds. With this change scanning takes negligible time.

Update #9477.

Change-Id: Id8a04066a53d2f743474cad406afb9f30f00eaae
Reviewed-on: https://go-review.googlesource.com/3288
Reviewed-by: Keith Randall <khr@golang.org>
10 years agoruntime: fix crash during heapdump
Dmitry Vyukov [Mon, 26 Jan 2015 18:44:06 +0000 (21:44 +0300)]
runtime: fix crash during heapdump

runtime/debug test crashes with GOMAXPROCS>1:

fatal error: unexpected signal during runtime execution
[signal 0xb code=0x1 addr=0x0 pc=0x80521b8]
runtime stack:
runtime.throw(0x8195028, 0x2a)
src/runtime/panic.go:508 +0x71 fp=0x18427f24 sp=0x18427f18
runtime.sigpanic()
src/runtime/sigpanic_unix.go:12 +0x53 fp=0x18427f4c sp=0x18427f24
runtime.finq_callback(0x0, 0x0, 0x0, 0x8129140, 0x0)
src/runtime/heapdump.go:410 +0x58 fp=0x18427f58 sp=0x18427f4c
runtime.iterate_finq(0x81a6860)
src/runtime/mfinal.go:89 +0x73 fp=0x18427f78 sp=0x18427f58
runtime.dumproots()
src/runtime/heapdump.go:448 +0x17a fp=0x18427fa4 sp=0x18427f78
runtime.mdump()
src/runtime/heapdump.go:652 +0xbc fp=0x18427fb4 sp=0x18427fa4
runtime.writeheapdump_m(0x3)

This happens because runfinq goroutine nils some elements in allfin after
execution of finalizers:

// drop finalizer queue references to finalized object
f.fn = nil
f.arg = nil
f.ot = nil

Then heapdump crashes trying to dereference fn.fn here:

func finq_callback(fn *funcval, obj unsafe.Pointer, nret uintptr, fint *_type, ot *ptrtype) {
dumpint(tagQueuedFinalizer)
dumpint(uint64(uintptr(obj)))
dumpint(uint64(uintptr(unsafe.Pointer(fn))))
dumpint(uint64(uintptr(unsafe.Pointer(fn.fn))))
dumpint(uint64(uintptr(unsafe.Pointer(fint))))
dumpint(uint64(uintptr(unsafe.Pointer(ot))))
}

Change-Id: I372433c964180d782967be63d4355e568666980d
Reviewed-on: https://go-review.googlesource.com/3287
Reviewed-by: Keith Randall <khr@golang.org>
10 years agoRevert "crypto/ecdsa: make Sign safe with broken entropy sources"
Adam Langley [Mon, 26 Jan 2015 22:31:25 +0000 (22:31 +0000)]
Revert "crypto/ecdsa: make Sign safe with broken entropy sources"

This reverts commit 8d7bf2291b095d3a2ecaa2609e1101be46d80deb.

Change-Id: Iad2c74a504d64bcf7ca707b00bda29bc796a2ae9
Reviewed-on: https://go-review.googlesource.com/3320
Reviewed-by: Adam Langley <agl@golang.org>
10 years agocrypto/ecdsa: make Sign safe with broken entropy sources
David Leon Gil [Wed, 7 Jan 2015 06:10:24 +0000 (22:10 -0800)]
crypto/ecdsa: make Sign safe with broken entropy sources

ECDSA is unsafe to use if an entropy source produces predictable
output for the ephemeral nonces. E.g., [Nguyen]. A simple
countermeasure is to hash the secret key, the message, and
entropy together to seed a CSPRNG, from which the ephemeral key
is derived.

--

This is a minimalist (in terms of patch size) solution, though
not the most parsimonious in its use of primitives:

   - csprng_key = ChopMD-256(SHA2-512(priv.D||entropy||hash))
   - reader = AES-256-CTR(k=csprng_key)

This, however, provides at most 128-bit collision-resistance,
so that Adv will have a term related to the number of messages
signed that is significantly worse than plain ECDSA. This does
not seem to be of any practical importance.

ChopMD-256(SHA2-512(x)) is used, rather than SHA2-256(x), for
two sets of reasons:

*Practical:* SHA2-512 has a larger state and 16 more rounds; it
is likely non-generically stronger than SHA2-256. And, AFAIK,
cryptanalysis backs this up. (E.g., [Biryukov] gives a
distinguisher on 47-round SHA2-256 with cost < 2^85.) This is
well below a reasonable security-strength target.

*Theoretical:* [Coron] and [Chang] show that Chop-MD(F(x)) is
indifferentiable from a random oracle for slightly beyond the
birthday barrier. It seems likely that this makes a generic
security proof that this construction remains UF-CMA is
possible in the indifferentiability framework.

--

Many thanks to Payman Mohassel for reviewing this construction;
any mistakes are mine, however. And, as he notes, reusing the
private key in this way means that the generic-group (non-RO)
proof of ECDSA's security given in [Brown] no longer directly
applies.

--

[Brown]: http://www.cacr.math.uwaterloo.ca/techreports/2000/corr2000-54.ps
"Brown. The exact security of ECDSA. 2000"

[Coron]: https://www.cs.nyu.edu/~puniya/papers/merkle.pdf
"Coron et al. Merkle-Damgard revisited. 2005"

[Chang]: https://www.iacr.org/archive/fse2008/50860436/50860436.pdf
"Chang and Nandi. Improved indifferentiability security analysis
of chopMD hash function. 2008"

[Biryukov]: http://www.iacr.org/archive/asiacrypt2011/70730269/70730269.pdf
"Biryukov et al. Second-order differential collisions for reduced
SHA-256. 2011"

[Nguyen]: ftp://ftp.di.ens.fr/pub/users/pnguyen/PubECDSA.ps
"Nguyen and Shparlinski. The insecurity of the elliptic curve
digital signature algorithm with partially known nonces. 2003"

Fixes #9452

Tests:

  TestNonceSafety: Check that signatures are safe even with a
    broken entropy source.

  TestINDCCA: Check that signatures remain non-deterministic
    with a functional entropy source.

Change-Id: Ie7e04057a3a26e6becb80e845ecb5004bb482745
Reviewed-on: https://go-review.googlesource.com/2422
Reviewed-by: Adam Langley <agl@golang.org>
10 years agoliblink: arrange for Prog* argument in vaddr
Russ Cox [Mon, 19 Jan 2015 21:26:14 +0000 (16:26 -0500)]
liblink: arrange for Prog* argument in vaddr

The argument is unused in the C code but will be used in the Go translation,
because the Prog holds information needed to invoke the right meaning
of %A in the ctxt->diag calls in vaddr.

Change-Id: I501830f8ea0e909aafd8ec9ef5d7338e109d9548
Reviewed-on: https://go-review.googlesource.com/3041
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-on: https://go-review.googlesource.com/3310
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/go: on arm, all binaries depend on math
Russ Cox [Fri, 23 Jan 2015 16:08:32 +0000 (11:08 -0500)]
cmd/go: on arm, all binaries depend on math

Change-Id: I10b781927245a3e9822f9cffe254f226a5b93213
Reviewed-on: https://go-review.googlesource.com/3279
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/gc: simplify code for c2go (more)
Russ Cox [Thu, 22 Jan 2015 17:10:59 +0000 (12:10 -0500)]
cmd/gc: simplify code for c2go (more)

- Remove more ? : expressions.
- Use uint32 **hash instead of uint32 *hash[] in function argument.
- Change array.c API to use int, not int32, to match Go's slices.
- Rename strlit to newstrlit, to avoid case-insensitive collision with Strlit.
- Fix a few incorrect printf formats.
- Rename a few variables from 'len' to n or length.
- Eliminate direct string editing building up names like convI2T.

Change-Id: I754cf553402ccdd4963e51b7039f589286219c29
Reviewed-on: https://go-review.googlesource.com/3278
Reviewed-by: Rob Pike <r@golang.org>
10 years agocmd/gc: make cmd/gc a real library
Russ Cox [Thu, 22 Jan 2015 05:52:01 +0000 (00:52 -0500)]
cmd/gc: make cmd/gc a real library

cmd/gc contains symbol references into the back end dirs like 6g.
It also contains a few files that include the back end header files and
are compiled separately for each back end, despite being in cmd/gc.
cmd/gc also defines main, which makes at least one reverse symbol
reference unavoidable. (Otherwise you can't get into back-end code.)

This was all expedient, but it's too tightly coupled, especially for a
program written Go.

Make cmd/gc into a true library, letting the back end define main and
call into cmd/gc after making the necessary references available.
cmd/gc being a real library will ease the transition to Go.

Change-Id: I4fb9a0e2b11a32f1d024b3c56fc3bd9ee458842c
Reviewed-on: https://go-review.googlesource.com/3277
Reviewed-by: Rob Pike <r@golang.org>
10 years agocmd/gc: simplify code for c2go
Russ Cox [Thu, 22 Jan 2015 03:19:15 +0000 (22:19 -0500)]
cmd/gc: simplify code for c2go

- Change forward reference to struct Node* to void* in liblink.
- Use explicit (Node*) casts in cmd/gc to get at that field.
- Define struct Array in go.h instead of hiding it in array.c.
- Remove some sizeof(uint32), sizeof(uint64) uses.
- Remove some ? : expressions.
- Rewrite some problematic mid-expression assignments.

Change-Id: I308c70140238a0cfffd90e133f86f442cd0e17d4
Reviewed-on: https://go-review.googlesource.com/3276
Reviewed-by: Rob Pike <r@golang.org>
10 years agoos: emulate plan 9 libc in stat
David du Colombier [Sun, 25 Jan 2015 01:19:39 +0000 (02:19 +0100)]
os: emulate plan 9 libc in stat

This change is a recreation of the CL written
by Nick Owens on http://golang.org/cl/150730043.

If the stat buffer is too short, the kernel
informs us by putting the 2-byte size in the
buffer, so we read that and try again.

This follows the same algorithm as /sys/src/libc/9sys/dirfstat.c.

Fixes #8781.

Change-Id: I01b4ad3a5e705dd4cab6673c7a119f8bef9bbd7c
Reviewed-on: https://go-review.googlesource.com/3281
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoregexp: update URLs in tests
Shenghou Ma [Mon, 26 Jan 2015 00:08:59 +0000 (19:08 -0500)]
regexp: update URLs in tests

Change-Id: I06035d949272157bbb7255563b37ac93cbf07f15
Reviewed-on: https://go-review.googlesource.com/3272
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoarchive/tar: set Header.Mode in example
Shenghou Ma [Mon, 26 Jan 2015 00:01:58 +0000 (19:01 -0500)]
archive/tar: set Header.Mode in example

Creating a tar containing files with 0000 permission bits is
not going to be useful.

Change-Id: Ie489c2891c335d32270b18f37b0e32ecdca536a6
Reviewed-on: https://go-review.googlesource.com/3271
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoimage: fix typo in Alpha16 doc comment
Andrew Ekstedt [Sat, 24 Jan 2015 22:57:01 +0000 (14:57 -0800)]
image: fix typo in Alpha16 doc comment

Change-Id: Ie7031ae37f52ea1f229bfb769daf306d537b3d3e
Reviewed-on: https://go-review.googlesource.com/3300
Reviewed-by: Minux Ma <minux@golang.org>
10 years agodatabase/sql: reduce lock contention in Stmt.connStmt
INADA Naoki [Fri, 23 Jan 2015 11:02:37 +0000 (20:02 +0900)]
database/sql: reduce lock contention in Stmt.connStmt

Previouslly, Stmt.connStmt calls DB.connIfFree on each Stmt.css.
Since Stmt.connStmt locks Stmt.mu, a concurrent use of Stmt causes lock
contention on Stmt.mu.
Additionally, DB.connIfFree locks DB.mu which is shared by DB.addDep and
DB.removeDep.

This change removes DB.connIfFree and makes use of a first unused
connection in idle connection pool to reduce lock contention
without making it complicated.

Fixes #9484

On EC2 c3.8xlarge (E5-2680 v2 @ 2.80GHz * 32 vCPU):

benchmark                           old ns/op     new ns/op     delta
BenchmarkManyConcurrentQuery-8      40249         34721         -13.73%
BenchmarkManyConcurrentQuery-16     45610         40176         -11.91%
BenchmarkManyConcurrentQuery-32     109831        43179         -60.69%

benchmark                           old allocs     new allocs     delta
BenchmarkManyConcurrentQuery-8      25             25             +0.00%
BenchmarkManyConcurrentQuery-16     25             25             +0.00%
BenchmarkManyConcurrentQuery-32     25             25             +0.00%

benchmark                           old bytes     new bytes     delta
BenchmarkManyConcurrentQuery-8      3980          3969          -0.28%
BenchmarkManyConcurrentQuery-16     3980          3982          +0.05%
BenchmarkManyConcurrentQuery-32     3993          3990          -0.08%

Change-Id: Ic96296922c465bac38a260018c58324dae1531d9
Reviewed-on: https://go-review.googlesource.com/2207
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
10 years agomath/big: disable some tests on 32bit platforms (fix build)
Robert Griesemer [Sat, 24 Jan 2015 05:40:35 +0000 (21:40 -0800)]
math/big: disable some tests on 32bit platforms (fix build)

TBR: adonovan

Change-Id: I59757b5b46a2c533fc5f888423c99d550d3c7648
Reviewed-on: https://go-review.googlesource.com/3264
Reviewed-by: Robert Griesemer <gri@golang.org>
10 years agomath/big: multi-precision Floats (starting point)
Robert Griesemer [Mon, 8 Dec 2014 22:36:39 +0000 (14:36 -0800)]
math/big: multi-precision Floats (starting point)

Implemented:
- +, -, *, /, and some unary ops
- all rounding modes
- basic conversions
- string to float conversion
- tests

Missing:
- float to string conversion, formatting
- handling of +/-0 and +/-inf (under- and overflow)
- various TODOs and cleanups

With precision set to 24 or 53, the results match
float32 or float64 operations exactly (excluding
NaNs and denormalized numbers which will not be
supported).

Change-Id: I3121e90fc4b1528e40bb6ff526008da18b3c6520
Reviewed-on: https://go-review.googlesource.com/1218
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agogo/ast: document that ast.FilterFile always filters imports
Robert Griesemer [Fri, 23 Jan 2015 19:45:00 +0000 (11:45 -0800)]
go/ast: document that ast.FilterFile always filters imports

Fixes #9248.

Change-Id: Id1c50af5eb35d7720b8f0a4d4881414baf061d56
Reviewed-on: https://go-review.googlesource.com/3241
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agogo/printer: update golden file (fix build)
Robert Griesemer [Fri, 23 Jan 2015 19:21:19 +0000 (11:21 -0800)]
go/printer: update golden file (fix build)

Change-Id: I897a09a1c54f6d68c5dc68e189cb25dc72bb7590
Reviewed-on: https://go-review.googlesource.com/3240
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agogo/printer, cmd/gofmt: print import paths in double quotes
Robert Griesemer [Thu, 22 Jan 2015 18:43:16 +0000 (10:43 -0800)]
go/printer, cmd/gofmt: print import paths in double quotes

Fixes #9644.

Change-Id: Ia2e42befa20233107ac5409e79f9dce794983a3f
Reviewed-on: https://go-review.googlesource.com/3200
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agogo/parser: report error for var/const decls with missing init exprs
Robert Griesemer [Fri, 23 Jan 2015 05:54:26 +0000 (21:54 -0800)]
go/parser: report error for var/const decls with missing init exprs

Fixes #9639.

Change-Id: I311045d3df26b29b9380c159ef4727e85650d13b
Reviewed-on: https://go-review.googlesource.com/3211
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agoruntime: fix incorrectly replaced "_type" in comments
Shenghou Ma [Thu, 22 Jan 2015 06:31:49 +0000 (01:31 -0500)]
runtime: fix incorrectly replaced "_type" in comments

Change-Id: I9d0b1bb68604c5a153bd5c05c7008db045c38d2a
Reviewed-on: https://go-review.googlesource.com/3180
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agobytes, strings: improve documentation for Count functions
Robert Griesemer [Thu, 22 Jan 2015 17:16:20 +0000 (09:16 -0800)]
bytes, strings: improve documentation for Count functions

Fixes #9659.

Change-Id: If364d5984a0c9a48858ae524b1560f633e621826
Reviewed-on: https://go-review.googlesource.com/3181
Reviewed-by: Rob Pike <r@golang.org>
10 years agonet: simplify itoa conversions
Martin Möhrmann [Wed, 31 Dec 2014 17:45:05 +0000 (18:45 +0100)]
net: simplify itoa conversions

Rename itod to uitoa to have consistent naming with other itoa functions.
Reduce redundant code by calling uitoa from itoa.
Reduce buffer to maximally needed size for conversion of 64bit integers.
Adjust calls to itoa functions in package net to use new name for itod.
Avoid calls to itoa if uitoa suffices.

Change-Id: I79deaede4d4b0c076a99a4f4dd6f644ba1daec53
Reviewed-on: https://go-review.googlesource.com/2212
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
10 years agocmd/ld: s/specificaly/specifically/ in comment
Michael Matloob [Thu, 22 Jan 2015 07:05:42 +0000 (23:05 -0800)]
cmd/ld: s/specificaly/specifically/ in comment

Change-Id: I849b8046daaec97ae631d59f1870cd5f1cd72f22
Reviewed-on: https://go-review.googlesource.com/3176
Reviewed-by: Minux Ma <minux@golang.org>
10 years agocmd/gc: treat non-local vars inlined into wrapper as escaping
Ian Lance Taylor [Wed, 21 Jan 2015 05:32:22 +0000 (21:32 -0800)]
cmd/gc: treat non-local vars inlined into wrapper as escaping

The compiler has a phase ordering problem.  Escape analysis runs
before wrapper generation.  When a generated wrapper calls a method
defined in a different package, if that call is inlined, there will be
no escape information for the variables defined in the inlined call.
Those variables will be placed on the stack, which fails if they
actually do escape.

There are probably various complex ways to fix this.  This is a simple
way to avoid it: when a generated wrapper calls a method defined in a
different package, treat all local variables as escaping.

Fixes #9537.

Change-Id: I530f39346de16ad173371c6c3f69cc189351a4e9
Reviewed-on: https://go-review.googlesource.com/3092
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agolib9: build tokenize on Plan 9
David du Colombier [Wed, 21 Jan 2015 23:25:08 +0000 (00:25 +0100)]
lib9: build tokenize on Plan 9

The build was broken on Plan 9 after the
CL 2994, because of the use of getfields
in src/liblink/go.c.

This happened when building 8l, because
getfield was part of lib9 and tokenize
was part of the Plan 9 libc. However,
both getfields and tokenize depend on
utfrune, causing an incompatibility.

This change enables the build of tokenize
as part of lib9, so it doesn't use
tokenize from the Plan 9 libc anymore.

Change-Id: I2a76903b508bd92771c4754cd53dfc64df350892
Reviewed-on: https://go-review.googlesource.com/3121
Reviewed-by: Minux Ma <minux@golang.org>
10 years agoruntime: fix trigger for concurrent GC
Rick Hudson [Tue, 13 Jan 2015 20:36:42 +0000 (15:36 -0500)]
runtime: fix trigger for concurrent GC

Adjust triggergc so that we trigger when we have used 7/8
of the available heap memory. Do first collection when we
exceed 4Mbytes.

Change-Id: I467b4335e16dc9cd1521d687fc1f99a51cc7e54b
Reviewed-on: https://go-review.googlesource.com/3149
Reviewed-by: Austin Clements <austin@google.com>
10 years agocrypto/x509: implement crypto.Signer
Paul van Brouwershaven [Mon, 5 Jan 2015 10:07:05 +0000 (10:07 +0000)]
crypto/x509: implement crypto.Signer

Signer is an interface to support opaque private keys.
These keys typically result from being kept in special hardware
(i.e. a TPM) although sometimes operating systems provide a
similar interface using process isolation for security rather
than hardware boundaries.

This changes provides updates implements crypto.Signer in
CreateCRL and CreateCertificate so that they can be used with
opaque keys.

This CL has been discussed at: http://golang.org/cl/145910043

Change-Id: Id7857fb9a3b4c957c7050b519552ef1c8e55461e
Reviewed-on: https://go-review.googlesource.com/3126
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
10 years agosyscall: use name+(NN)FP on linux/amd64
David Crawshaw [Wed, 14 Jan 2015 19:41:04 +0000 (14:41 -0500)]
syscall: use name+(NN)FP on linux/amd64

Generated from a modified go vet.

Change-Id: Ibe82941283da9bd4dbc7fa624a33ffb12424daa2
Reviewed-on: https://go-review.googlesource.com/2817
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agosyscall: use name+(NN)FP on linux/386
David Crawshaw [Wed, 14 Jan 2015 19:39:41 +0000 (14:39 -0500)]
syscall: use name+(NN)FP on linux/386

Generated from go vet.

Change-Id: I8fee4095e43034b868bfd2b07e21ac13d5beabbb
Reviewed-on: https://go-review.googlesource.com/2816
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agoRevert "runtime: fix trigger for concurrent GC"
Austin Clements [Wed, 21 Jan 2015 16:20:14 +0000 (16:20 +0000)]
Revert "runtime: fix trigger for concurrent GC"

This reverts commit 44529d939192c3034a04e2eff865d04ee51ae532.

Change-Id: I7671e2cd6f6a476efffa16e8110500a98258c0c1
Reviewed-on: https://go-review.googlesource.com/3130
Reviewed-by: Austin Clements <austin@google.com>
10 years agoruntime: fix trigger for concurrent GC
Rick Hudson [Tue, 13 Jan 2015 20:36:42 +0000 (15:36 -0500)]
runtime: fix trigger for concurrent GC

Adujst triggergc so that we trigger when we have used 7/8
of the available memory.

Change-Id: I7ca02546d3084e6a04d60b09479e04a9a9837ae2
Reviewed-on: https://go-review.googlesource.com/3061
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agointernal/syscall: add getrandom syscall number for ppc64/ppc64le
Shenghou Ma [Mon, 19 Jan 2015 17:34:56 +0000 (12:34 -0500)]
internal/syscall: add getrandom syscall number for ppc64/ppc64le

Change-Id: I04c1b8f2a9ac4efba227d6c0a20459420cd3dc05
Reviewed-on: https://go-review.googlesource.com/3014
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agohtml/template: fix example code
Andrew Gerrand [Wed, 21 Jan 2015 02:33:37 +0000 (13:33 +1100)]
html/template: fix example code

Fixes #9651

Change-Id: I987833b6263482a402e58fcd9eeb0e42401599b5
Reviewed-on: https://go-review.googlesource.com/3073
Reviewed-by: Robert Griesemer <gri@golang.org>
10 years agomath/big: use new nat.scan for Rat.SetString
Robert Griesemer [Wed, 21 Jan 2015 00:41:31 +0000 (16:41 -0800)]
math/big: use new nat.scan for Rat.SetString

Change-Id: Ida20bf95e8f0fdadb459c2daa6d22edae9c3ad16
Reviewed-on: https://go-review.googlesource.com/3091
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agobuild: implement GOEXPERIMENT again in runtime, and add to liblink
Russ Cox [Sat, 17 Jan 2015 00:22:58 +0000 (19:22 -0500)]
build: implement GOEXPERIMENT again in runtime, and add to liblink

For Austin's framepointer experiment.

Change-Id: I81b6f414943b3578924f853300b9193684f79bf4
Reviewed-on: https://go-review.googlesource.com/2994
Reviewed-by: Austin Clements <austin@google.com>
10 years agoRevert "crypto/x509: implement crypto.Signer"
Adam Langley [Wed, 21 Jan 2015 00:39:53 +0000 (00:39 +0000)]
Revert "crypto/x509: implement crypto.Signer"

This reverts commit cef15faafe5d15ba6242bad3504a52d287f78b88.

Change-Id: I6df3e9ea48cd58893892587dd5cd28c1eb759c48
Reviewed-on: https://go-review.googlesource.com/3090
Reviewed-by: Adam Langley <agl@golang.org>
10 years agocrypto/x509: Authority Key Identifier must be included in all CRLs issued
Paul van Brouwershaven [Mon, 5 Jan 2015 11:19:50 +0000 (11:19 +0000)]
crypto/x509: Authority Key Identifier must be included in all CRLs issued

According to RFC5280 the authority key identifier extension MUST included in all
CRLs issued. This patch includes the authority key identifier extension when the
Subject Key Identifier is present in the signing certificate.

RFC5280 states:

"The authority key identifier extension provides a means of identifying the
public key corresponding to the private key used to sign a CRL.  The
identification can be based on either the key identifier (the subject key
identifier in the CRL signer's certificate) or the issuer name and serial
number.  This extension is especially useful where an issuer has more than one
signing key, either due to multiple concurrent key pairs or due to changeover."

Conforming CRL issuers MUST use the key identifier method, and MUST include this
extension in all CRLs issued."

This CL has been discussed at: http://golang.org/cl/177760043

Change-Id: I9bf50521908bfe777ea2398f154c13e8c90d14ad
Reviewed-on: https://go-review.googlesource.com/2258
Reviewed-by: Adam Langley <agl@golang.org>
10 years agocrypto/x509: implement crypto.Signer
Paul van Brouwershaven [Mon, 5 Jan 2015 10:07:05 +0000 (10:07 +0000)]
crypto/x509: implement crypto.Signer

Signer is an interface to support opaque private keys.
These keys typically result from being kept in special hardware
(i.e. a TPM) although sometimes operating systems provide a
similar interface using process isolation for security rather
than hardware boundaries.

This changes provides updates implements crypto.Signer in
CreateCRL and CreateCertificate so that they can be used with
opaque keys.

This CL has been discussed at: http://golang.org/cl/145910043

Change-Id: Ie4a4a583fb120ff484a5ccf267ecd2a9c5a3902b
Reviewed-on: https://go-review.googlesource.com/2254
Reviewed-by: Adam Langley <agl@golang.org>
10 years agopath/filepath: make Join handle UNC paths on Windows
Emil Hessman [Wed, 31 Dec 2014 05:27:31 +0000 (06:27 +0100)]
path/filepath: make Join handle UNC paths on Windows

Unless the first element is a Universal Naming Convention (UNC)[0]
path, Join shouldn't create a UNC path on Windows.

For example, Join inadvertently creates a UNC path on Windows when
told to join at least three non-empty path elements, where the first
element is `\` or `/`.

This CL prevents creation of a UNC path prefix when the first path
element isn't a UNC path.

Since this introduces some amount of Windows-specific logic, Join is
moved to a per GOOS implementation.

Fixes #9167.

[0]: http://msdn.microsoft.com/en-us/library/gg465305.aspx

Change-Id: Ib6eda597106cb025137673b33c4828df1367f75b
Reviewed-on: https://go-review.googlesource.com/2211
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
10 years agomath/big: permit internal nat.scan to accept decimal point
Robert Griesemer [Fri, 16 Jan 2015 02:38:25 +0000 (18:38 -0800)]
math/big: permit internal nat.scan to accept decimal point

This will simplify parsing of rational and (eventually) floating point numbers.

Also streamlined inner loop. As a result, scan runs faster for all but short
(<= 10 digit) numbers. For short numbers it is < 10% slower (cause is known
and could be addressed in a future CL).

Minor unrelated cleanups. Added additional tests.

benchmark                     old ns/op     new ns/op     delta
BenchmarkScanPi               134465        125122        -6.95%
BenchmarkScan10Base2          493           540           +9.53%
BenchmarkScan100Base2         3608          3244          -10.09%
BenchmarkScan1000Base2        35376         32377         -8.48%
BenchmarkScan10000Base2       481504        450028        -6.54%
BenchmarkScan100000Base2      17936774      17648080      -1.61%
BenchmarkScan10Base8          258           280           +8.53%
BenchmarkScan100Base8         1389          1323          -4.75%
BenchmarkScan1000Base8        14221         13036         -8.33%
BenchmarkScan10000Base8       271298        258993        -4.54%
BenchmarkScan100000Base8      15715465      15672580      -0.27%
BenchmarkScan10Base10         249           268           +7.63%
BenchmarkScan100Base10        1324          1220          -7.85%
BenchmarkScan1000Base10       13398         12234         -8.69%
BenchmarkScan10000Base10      259157        249342        -3.79%
BenchmarkScan100000Base10     15670613      15582409      -0.56%
BenchmarkScan10Base16         231           251           +8.66%
BenchmarkScan100Base16        1093          1065          -2.56%
BenchmarkScan1000Base16       12687         12196         -3.87%
BenchmarkScan10000Base16      282349        271443        -3.86%
BenchmarkScan100000Base16     16742669      16552917      -1.13%

Change-Id: I4b9b078792788aef872b307399f00ffd34903127
Reviewed-on: https://go-review.googlesource.com/2960
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agocmd/gc: don't unpack struct arguments to append
Chris Manghane [Tue, 20 Jan 2015 22:35:33 +0000 (14:35 -0800)]
cmd/gc: don't unpack struct arguments to append

Fixes #9634.

Change-Id: I7b18f26c2fb812978fc7adc5bfd39ebfffe48701
Reviewed-on: https://go-review.googlesource.com/3080
Reviewed-by: Minux Ma <minux@golang.org>
10 years agoruntime: Add some diagnostic messages printing source of unmarked object
Rick Hudson [Tue, 13 Jan 2015 20:36:42 +0000 (15:36 -0500)]
runtime: Add some diagnostic messages printing source of unmarked object

Print out the object holding the reference to the object
that checkmark detects as not being properly marked.

Change-Id: Ieedbb6fddfaa65714504af9e7230bd9424cd0ae0
Reviewed-on: https://go-review.googlesource.com/2744
Reviewed-by: Austin Clements <austin@google.com>
10 years agomath/big: better test coverage, misc. cleanups
Robert Griesemer [Fri, 16 Jan 2015 23:11:26 +0000 (15:11 -0800)]
math/big: better test coverage, misc. cleanups

Change-Id: I4ce5cee63093d917095bf90f4e11123f7ec0f93c
Reviewed-on: https://go-review.googlesource.com/2964
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agoruntime/pprof: ignore CPU profile test failures in QEMU
Burcu Dogan [Sat, 17 Jan 2015 00:53:13 +0000 (16:53 -0800)]
runtime/pprof: ignore CPU profile test failures in QEMU

Fixes #9605

Change-Id: Iafafa4c1362bbd1940f8e4fb979f72feae3ec3ad
Reviewed-on: https://go-review.googlesource.com/3000
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agomisc/makerelease: send file size when uploading
Andrew Gerrand [Tue, 20 Jan 2015 04:03:16 +0000 (15:03 +1100)]
misc/makerelease: send file size when uploading

Change-Id: I1a1ed1e23067268a2bac08fc4c99c594fb723837
Reviewed-on: https://go-review.googlesource.com/3050
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agonet/http/fcgi: Fix resource leaks
Evan Kroske [Sun, 21 Dec 2014 17:25:12 +0000 (09:25 -0800)]
net/http/fcgi: Fix resource leaks

Close the pipe for the body of a request when it is aborted and close
all pipes when child.serve terminates.

Fixes #6934

Change-Id: I1c5e7d2116e1ff106f11a1ef8e99bf70cf04162a
Reviewed-on: https://go-review.googlesource.com/1923
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agocmd/go: make use of Runnable method
Mikio Hara [Mon, 19 Jan 2015 08:19:46 +0000 (17:19 +0900)]
cmd/go: make use of Runnable method

Reported via unsupported Github pull request: #9299

Change-Id: I0e98dd68cbc68fcc6bcec15c5b33f20b6a861ec6
Reviewed-on: https://go-review.googlesource.com/3025
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agomisc/dashboard/codereview: delete
Andrew Gerrand [Mon, 19 Jan 2015 22:12:24 +0000 (09:12 +1100)]
misc/dashboard/codereview: delete

This dashboard is no longer in use, and doesn't work with Gerrit.

Change-Id: Ib7c367dcad97322566610157b15e23db5bec58ff
Reviewed-on: https://go-review.googlesource.com/3028
Reviewed-by: David Symonds <dsymonds@golang.org>
10 years agocmd/dist: fix deadlock when compilation command fails
Russ Cox [Sat, 17 Jan 2015 03:12:41 +0000 (22:12 -0500)]
cmd/dist: fix deadlock when compilation command fails

Can't use bgwait, both because it can only be used from
one goroutine at a time and because it ends up queued
behind all the other pending commands. Use a separate
signaling mechanism so that we can notice we're dying
sooner.

Change-Id: I8652bfa2f9bb5725fa5968d2dd6a745869d01c01
Reviewed-on: https://go-review.googlesource.com/3010
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agoruntime: factor out bitmap, finalizer code from malloc/mgc
Russ Cox [Fri, 16 Jan 2015 19:43:38 +0000 (14:43 -0500)]
runtime: factor out bitmap, finalizer code from malloc/mgc

The code in mfinal.go is moved from malloc*.go and mgc*.go
and substantially unchanged.

The code in mbitmap.go is also moved from those files, but
cleaned up so that it can be called from those files (in most cases
the code being moved was not already a standalone function).
I also renamed the constants and wrote comments describing
the format. The result is a significant cleanup and isolation of
the bitmap code, but, roughly speaking, it should be treated
and reviewed as new code.

The other files changed only as much as necessary to support
this code movement.

This CL does NOT change the semantics of the heap or type
bitmaps at all, although there are now some obvious opportunities
to do so in followup CLs.

Change-Id: I41b8d5de87ad1d3cd322709931ab25e659dbb21d
Reviewed-on: https://go-review.googlesource.com/2991
Reviewed-by: Keith Randall <khr@golang.org>
10 years agonet/http: remove unused test type
Jongmin Kim [Mon, 19 Jan 2015 12:13:13 +0000 (21:13 +0900)]
net/http: remove unused test type

Change-Id: Ia8d4459a39425583027f00410fe17b9686b768db
Reviewed-on: https://go-review.googlesource.com/3026
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoruntime: move write barrier code into mbarrier.go
Russ Cox [Thu, 15 Jan 2015 02:47:49 +0000 (21:47 -0500)]
runtime: move write barrier code into mbarrier.go

I also added new comments at the top of mbarrier.go,
but the rest of the code is just copy-and-paste.

Change-Id: Iaeb2b12f8b1eaa33dbff5c2de676ca902bfddf2e
Reviewed-on: https://go-review.googlesource.com/2990
Reviewed-by: Austin Clements <austin@google.com>
10 years agoruntime: rename float64 constants to avoid name space pollution
Russ Cox [Fri, 16 Jan 2015 19:33:27 +0000 (14:33 -0500)]
runtime: rename float64 constants to avoid name space pollution

Otherwise, if you mistakenly refer to an undeclared 'shift' variable, you get 52.

Change-Id: I845fb29f23baee1d8e17b37bde0239872eb54316
Reviewed-on: https://go-review.googlesource.com/2909
Reviewed-by: Austin Clements <austin@google.com>
10 years agofmt: reword the document for [n].
Shenghou Ma [Mon, 19 Jan 2015 01:05:44 +0000 (20:05 -0500)]
fmt: reword the document for [n].

Fixes #9632.

Change-Id: Ic4d7cad8ff62023c1beecd2d62e48eb9258f5306
Reviewed-on: https://go-review.googlesource.com/3013
Reviewed-by: Rob Pike <r@golang.org>
10 years agonet: more accurate parsing of IPv4 header on IPConn
Mikio Hara [Sun, 18 Jan 2015 07:28:15 +0000 (16:28 +0900)]
net: more accurate parsing of IPv4 header on IPConn

As shown in #9395, inaccurate implementation would be a cause of parsing
IPv4 header twice and corrupted upper-layer message issues.

Change-Id: Ia1a042e7ca58ee4fcb38fe9ec753c2ab100592ca
Reviewed-on: https://go-review.googlesource.com/3001
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agostrings: remove overengineered Compare implementation
Russ Cox [Sun, 18 Jan 2015 17:50:22 +0000 (12:50 -0500)]
strings: remove overengineered Compare implementation

The function is here ONLY for symmetry with package bytes.
This function should be used ONLY if it makes code clearer.
It is not here for performance. Remove any performance benefit.

If performance becomes an issue, the compiler should be fixed to
recognize the three-way compare (for all comparable types)
rather than encourage people to micro-optimize by using this function.

Change-Id: I71f4130bce853f7aef724c6044d15def7987b457
Reviewed-on: https://go-review.googlesource.com/3012
Reviewed-by: Rob Pike <r@golang.org>
10 years agocmd/go: set $GOROOT during 'go tool' invocations
Russ Cox [Sat, 17 Jan 2015 03:15:01 +0000 (22:15 -0500)]
cmd/go: set $GOROOT during 'go tool' invocations

cmd/dist now requires $GOROOT to be set explicitly.
Set it when invoking via 'go tool dist' so that users are unaffected.

Also, change go tool -n to drop trailing space in output
for 'go tool -n <anything>'.

Change-Id: I9b2c020e0a2f3fa7c9c339fadcc22cc5b6cb7cac
Reviewed-on: https://go-review.googlesource.com/3011
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agocmd/dist: do not leave go-tool-dist-* temporary directories behind
Shenghou Ma [Sat, 17 Jan 2015 03:08:22 +0000 (22:08 -0500)]
cmd/dist: do not leave go-tool-dist-* temporary directories behind

Change-Id: I3f6ba5591130b2c4762d33bd4553220765ad9fc5
Reviewed-on: https://go-review.googlesource.com/2996
Reviewed-by: Andrew Gerrand <adg@golang.org>
10 years agocmd/dist: produce a properly formatted zversion.go
Michael Matloob [Mon, 19 Jan 2015 00:04:47 +0000 (16:04 -0800)]
cmd/dist: produce a properly formatted zversion.go

gofmt inserts a blank line line between const and var declarations

Change-Id: I3f2ddbd9e66a74eb3f37a2fe641b93820b02229e
Reviewed-on: https://go-review.googlesource.com/3022
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agodoc: update go1.5.txt
Brad Fitzpatrick [Mon, 19 Jan 2015 00:00:10 +0000 (16:00 -0800)]
doc: update go1.5.txt

Change-Id: I58d66a7fc25b172baf0df6b634e9e2cc792967d5
Reviewed-on: https://go-review.googlesource.com/3021
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoruntime, syscall: use SYSCALL instruction on FreeBSD.
Bill Thiede [Sun, 18 Jan 2015 05:09:15 +0000 (21:09 -0800)]
runtime, syscall: use SYSCALL instruction on FreeBSD.

This manually reverts 555da73 from #6372 which implies a
minimum FreeBSD version of 8-STABLE.
Updates docs to mention new minimum requirement.

Fixes #9627

Change-Id: I40ae64be3682d79dd55024e32581e3e5e2be8aa7
Reviewed-on: https://go-review.googlesource.com/3020
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agomisc/makerelease: workaround the go install -a restriction on release branches
Shenghou Ma [Sat, 17 Jan 2015 02:07:23 +0000 (21:07 -0500)]
misc/makerelease: workaround the go install -a restriction on release branches

Fixes #9619.

Change-Id: I71931b0d546163e5451d7d72e552b08540e3c2a7
Reviewed-on: https://go-review.googlesource.com/2995
Reviewed-by: Andrew Gerrand <adg@golang.org>
10 years agodoc: direct people to the mailing list
Brad Fitzpatrick [Sun, 18 Jan 2015 18:56:00 +0000 (10:56 -0800)]
doc: direct people to the mailing list

Since the move to Github, we've started to receive lots of
introductory questions to the bug tracker. I posit this is because
most projects on Github don't have mailing lists, so the culture on
Github is to use the Issue Tracker as a discussion forum.

The Go project doesn't use the Issue Tracker as our first point of
communication. This CL updates CONTRIBUTING.md (which is linked when
you file a bug or send a pull request), to mention that we have a
mailing list.

It certainly won't stop all the errant bug reports, but it should
help.

Change-Id: Id8fbfd35b73f5117617dff53b1e72d5b5276388b
Reviewed-on: https://go-review.googlesource.com/3002
Reviewed-by: Rob Pike <r@golang.org>
10 years agonet/http/cgi: correctly handle pathnames for cygwin perl on windows
Martin Möhrmann [Sat, 17 Jan 2015 12:37:04 +0000 (13:37 +0100)]
net/http/cgi: correctly handle pathnames for cygwin perl on windows

Cygwin perl uses unix pathnames in windows. Include cygwin perl in the
list of special cases for unix pathname handling in test.cgi.

Change-Id: I30445a9cc79d62d022ecc232c35aa5015b7418dc
Reviewed-on: https://go-review.googlesource.com/2973
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
10 years agotest: generate tests for arithmetic on narrow types
Keith Randall [Fri, 16 Jan 2015 05:02:51 +0000 (21:02 -0800)]
test: generate tests for arithmetic on narrow types

Fixes #9607
Related to #9604
Inadvertently found #9609

Change-Id: I8a8ddf84ac72d3e18986fd8e9288734459f3f174
Reviewed-on: https://go-review.googlesource.com/2962
Reviewed-by: Minux Ma <minux@golang.org>
10 years agoall: merge dev.cc (929f321) into master
Russ Cox [Fri, 16 Jan 2015 23:52:30 +0000 (18:52 -0500)]
all: merge dev.cc (929f321) into master

This brings in cmd/dist written in Go, which is working on the primary builders.

If this breaks your build, you need to get Go 1.4 and put it in $HOME/go1.4
(or, if you want to use some other directory, set $GOROOT_BOOTSTRAP
to that directory).

To build Go 1.4 from source:

git clone -b release-branch.go1.4 $GOROOT $HOME/go1.4
cd $HOME/go1.4/src
./make.bash

Or use a binary release: https://golang.org/dl/.

See https://golang.org/s/go15bootstrap for more information.

Change-Id: Ie4ae834c76ea35e39cc54e9878819a9e51b284d9

10 years agomisc/android: choose the right subdirectory for bin under GOPATH.
Hyang-Ah Hana Kim [Thu, 15 Jan 2015 21:47:41 +0000 (16:47 -0500)]
misc/android: choose the right subdirectory for bin under GOPATH.

This change includes the cleanup of temporary files created during
the binary execution as well.

Change-Id: Ic01a0a537d1daafcaa3acda1ec344aff5dcddfc2
Reviewed-on: https://go-review.googlesource.com/2903
Reviewed-by: David Crawshaw <crawshaw@golang.org>
10 years agomisc/cgo: skip testso on ppc64
Austin Clements [Fri, 16 Jan 2015 15:34:07 +0000 (10:34 -0500)]
misc/cgo: skip testso on ppc64

This test requires external linking, but we don't yet implement
external linking on ppc64 (tracked in issue #8912).  Disable the test
on ppc64 until external linking is implemented.

This makes all.bash pass on ppc64le.

Change-Id: I741498d4d9321607e7a65792a33faf8187bd18e4
Reviewed-on: https://go-review.googlesource.com/2908
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agomath/big: bug in AndNot(x,y) for x>0,y<0.
Keith Randall [Fri, 16 Jan 2015 04:45:07 +0000 (20:45 -0800)]
math/big: bug in AndNot(x,y) for x>0,y<0.

The comment says to use (y-1), but then we did add(y.abs, natOne).  We meant sub.

Fixes #9609

Change-Id: I4fe4783326ca082c05588310a0af7895a48fc779
Reviewed-on: https://go-review.googlesource.com/2961
Reviewed-by: Robert Griesemer <gri@golang.org>
10 years agosyscall: use name+(NN)FP on linux/arm
David Crawshaw [Wed, 14 Jan 2015 19:36:17 +0000 (14:36 -0500)]
syscall: use name+(NN)FP on linux/arm

Generated with a modified version of go vet and tested on android.

Change-Id: I1ff20135c5ab9de5a6dbf76ea2991167271ee70d
Reviewed-on: https://go-review.googlesource.com/2815
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agomisc/makerelease: a couple of small fixes
Andrew Gerrand [Fri, 16 Jan 2015 02:49:06 +0000 (13:49 +1100)]
misc/makerelease: a couple of small fixes

Change-Id: Iec19d6152b95ba67daac366b32d42f69e1dba9a4
Reviewed-on: https://go-review.googlesource.com/2951
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agocmd/5g: make sure we normalize after unary ops on small types
Keith Randall [Thu, 15 Jan 2015 22:39:58 +0000 (14:39 -0800)]
cmd/5g: make sure we normalize after unary ops on small types

We were failing ^uint16(0xffff) == 0, as we computed 0xffff0000 instead.

I could only trigger a failure for the above case, the other two tests
^uint16(0xfffe) == 1 and -uint16(0xffff) == 1 didn't seem to fail
previously.  Somehow they get MOVHUs inserted for other reasons (used
by CMP instead of TST?).  I fixed OMINUS anyway, better safe than
sorry.

Fixes #9604

Change-Id: I4c2d5bdc667742873ac029fdbe3db0cf12893c27
Reviewed-on: https://go-review.googlesource.com/2940
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>