Luuk van Dijk [Mon, 22 Oct 2012 08:01:14 +0000 (10:01 +0200)]
cmd/gc: fix strict tree property for AST for OAS2RECV nodes.
in typecheck and walk, conversion from OAS2RECV to OAS2
and to OSELRECV2 duplicated the ->rlist->n to ->right
thereby destroying the strict tree-ness of the AST (up to
ONAMES) of course. Several recursions in esc.c and inl.c
and probably elsewhere assume nodes of the tree aren't duplicated.
rather than defensively code around this, i'd rather assert
these cases away and fix their cause.
Roger Peppe [Mon, 22 Oct 2012 07:58:27 +0000 (08:58 +0100)]
cmd/go: add join template function.
It's common to use the go list command in shell scripts, but
currently it's awkward to print a string slice from the Package
type in a way that's easily parseable by the shell. For example:
go list -f '{{range .Deps}}{{.}}
{{end}}'
(and even that prints an unwanted new line at the end|).
To make this easier, this CL adds a "join" function to the
format template.
go list -f '{{join .Deps "\n"}}'
R=rsc, dsymonds, minux.ma, remyoudompheng, r
CC=golang-dev
https://golang.org/cl/6680044
Mikio Hara [Sun, 21 Oct 2012 21:17:51 +0000 (17:17 -0400)]
net: add test for Conn, PacketConn and Listener
I just realized that there is no good place for adding
exposed function or method tests because server, unicast
and multicast_test.go do test complicated multiple test
objects, platform behaviros, protocol behaviors and API,
at the same time. Perhaps splitting them into per test
object might be better, so this CL provides tests focused
on API.
Daniel Morsing [Sun, 21 Oct 2012 17:22:51 +0000 (19:22 +0200)]
cmd/gc: Friendlier errors on oversized arrays.
Someone new to the language may not know the connection between ints and arrays, which was the only thing that the previous error told you anything about.
Robert Griesemer [Fri, 19 Oct 2012 17:12:09 +0000 (10:12 -0700)]
go spec: constant divisors must not be zero
Both gc and gccgo always checked this for constant
expressions but the spec only mentions run-time
exceptions.
This CL also requires that constant divisors
must not be zero in non-constant integer expressions:
This is consistent with the spirit of the most
recent changes and it is consistent with constant
expressions. We don't want to specify the effect for
non-integer expressions (f/0.0 where f is a float or
complex number) because there the result f/g is not
further specified if a non-constant g is 0.
Robert Griesemer [Fri, 19 Oct 2012 17:11:06 +0000 (10:11 -0700)]
go spec: define make() restrictions as for index expressions
This is a language change: Until now, the spec required run-
time panics for some of these errors. Note that gc and gccgo
implemented this inconsistently, and that both compilers already
reported compile-time errors in some cases. This change makes
make() behave along the same vein as index expressions.
This addresses the spec aspect of issue 4085.
R=r, rsc, iant, ken
CC=golang-dev
https://golang.org/cl/6725053
Nigel Tao [Fri, 19 Oct 2012 05:32:00 +0000 (16:32 +1100)]
bufio: make Writer.ReadFrom not flush prematurely. For example,
many small writes to a network may be less efficient that a few
large writes.
This fixes net/http's TestClientWrites, broken by 6565056 that
introduced Writer.ReadFrom. That test implicitly assumed that
calling io.Copy on a *bufio.Writer wouldn't write to the
underlying network until the buffer was full.
Robert Griesemer [Wed, 17 Oct 2012 18:08:42 +0000 (11:08 -0700)]
go spec: restrictions for index and slice expressions
At the moment, gc and gccgo report compile-
time errors for certain constant indexes that
are out of bounds. The spec however requests
a run-time panic for out-of-bounds indexes
(http://tip.golang.org/ref/spec#Indexes).
Document the status quo.
Fixes #4231.
R=r, rsc, iant, ken
CC=golang-dev
https://golang.org/cl/6699048
Adam Langley [Wed, 17 Oct 2012 15:19:26 +0000 (11:19 -0400)]
math/big: add 4-bit, fixed window exponentiation.
A 4-bit window is convenient because 4 divides both 32 and 64,
therefore we never have a window spanning words of the exponent.
Additionaly, the benefit of a 5-bit window is only 2.6% at 1024-bits
and 3.3% at 2048-bits.
This code is still not constant time, however.
benchmark old ns/op new ns/op delta
BenchmarkRSA2048Decrypt 1710859011180370 -34.65%
Benchmark3PrimeRSA2048Decrypt 130037207680390 -40.94%
Rob Pike [Wed, 17 Oct 2012 05:00:09 +0000 (16:00 +1100)]
path/filepath: better documentation for WalkFunc
Define the properties of the arguments better. In particular,
explain that the path is (sort of) relative to the argument to
Walk.
Robert Griesemer [Tue, 16 Oct 2012 20:46:27 +0000 (13:46 -0700)]
math/big: fix big.Exp and document better
- always return 1 for y <= 0
- document that the sign of m is ignored
- protect against div-0 panics by treating
m == 0 the same way as m == nil
- added extra tests
Rob Pike [Tue, 16 Oct 2012 00:27:20 +0000 (11:27 +1100)]
spec: more clarification about deferred functions
Proposed new text to make matters clearer. The existing text was
unclear about the state of result parameters when panicking.
Nigel Tao [Mon, 15 Oct 2012 00:21:20 +0000 (11:21 +1100)]
image/jpeg: decode progressive JPEGs.
To be clear, this supports decoding the bytes on the wire into an
in-memory image. There is no API change: jpeg.Decode will still not
return until the entire image is decoded.
The code is obviously more complicated, and costs around 10% in
performance on baseline JPEGs. The processSOS code could be cleaned up a
bit, and maybe some of that loss can be reclaimed, but I'll leave that
for follow-up CLs, to keep the diff for this one as small as possible.
Shenghou Ma [Sat, 13 Oct 2012 11:05:22 +0000 (19:05 +0800)]
io/ioutil: use pathname instead of name in docs to avoid confusion
caller of ioutil.TempFile() can use f.Name() to get "pathname"
of the temporary file, instead of just the "name" of the file.
Also remove an out-of-date comment about random number state.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6649054
Shenghou Ma [Fri, 12 Oct 2012 10:50:41 +0000 (18:50 +0800)]
doc: remove ExpressivenessOfGo.pdf
It has been moved to go.talks/2010/ExpressivenessOfGo-2010.pdf
URL: http://talks.golang.org/2010/ExpressivenessOfGo-2010.pdf
Shenghou Ma [Fri, 12 Oct 2012 05:39:12 +0000 (13:39 +0800)]
cmd/5l: reorder some struct fields to reduce memory consumption
Valgrind Massif result when linking godoc:
On amd64:
old new -/+
mem_heap_B 185844612175358047 -5.7%
mem_heap_extra_B 773404 773137 -0.0%
On 386/ARM:
old new -/+
mem_heap_B 141775701131289941 -7.4%
mem_heap_extra_B 737011 736955 -0.0%
R=golang-dev, r, dave
CC=golang-dev
https://golang.org/cl/6655045
Shenghou Ma [Fri, 12 Oct 2012 05:35:05 +0000 (13:35 +0800)]
cmd/dist: fix superfluous and confusing "binaries ... to be copied or moved" message
Also, to aid debugging cmd/dist, make make.bat support --dist-tool flag.
Note that due to other improvements (faster assembly routines,
better code generation by compiler), these benchmarks now run
up to 37% faster than they used to at the last time measured (1/9/2012).
Minor performance impact for StringPiParallel running in parallel:
Current CL but with Lock/Unlock commented out (removed):
Adam Langley [Thu, 11 Oct 2012 22:25:23 +0000 (18:25 -0400)]
crypto/rsa: fix decryption benchmark.
I was an idiot and was thinking that a small base didn't matter
because the exponentiation would quickly make the number the same size
as the modulus. But, of course, the small base continues to make
multiplications unrealistically cheap throughout the computation.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6649048
Adam Langley [Thu, 11 Oct 2012 19:28:02 +0000 (15:28 -0400)]
crypto/hmac: add Equal function.
It was suggested that it's too easy to use crypto/hmac insecurely and
I think that has some merit. This change adds a Equal function to
make it obvious that MAC values should be compared in constant time.
R=rsc, max
CC=golang-dev
https://golang.org/cl/6632044
Shenghou Ma [Thu, 11 Oct 2012 15:33:57 +0000 (23:33 +0800)]
doc/contribute.html: assorted fixes
0. windows uses all.bat instead of ./all.bash
1. correct expected all.bash output
2. mention you need to use an application specific password
if you're using 2-step verification
3. note you can edit files included in CL by 'hg change NNNN'
or 'hg file'
R=golang-dev, adg, r
CC=golang-dev
https://golang.org/cl/6615060
Dmitriy Vyukov [Wed, 10 Oct 2012 16:49:18 +0000 (20:49 +0400)]
runtime/debug: fix the test
If source are not available, then the stack looks like:
stack_test.go:40: /tmp/gobuilder/linux-amd64-race-72b15c5d6f65/go/src/pkg/runtime/debug/bla-bla-bla/src/pkg/runtime/debug/stack_test.go:15 (0x43fb11)
stack_test.go:40: /tmp/gobuilder/linux-amd64-race-72b15c5d6f65/go/src/pkg/runtime/debug/bla-bla-bla/src/pkg/runtime/debug/stack_test.go:18 (0x43fb7a)
stack_test.go:40: /tmp/gobuilder/linux-amd64-race-72b15c5d6f65/go/src/pkg/runtime/debug/bla-bla-bla/src/pkg/runtime/debug/stack_test.go:37 (0x43fbf4)
stack_test.go:40: /tmp/gobuilder/linux-amd64-race-72b15c5d6f65/go/src/pkg/testing/bla-bla-bla/src/pkg/testing/testing.go:301 (0x43b5ba)
stack_test.go:40: /tmp/gobuilder/linux-amd64-race-72b15c5d6f65/go/src/pkg/runtime/bla-bla-bla/src/pkg/runtime/proc.c:276 (0x410670)
stack_test.go:40:
which is 6 lines.
Dmitriy Vyukov [Wed, 10 Oct 2012 14:09:23 +0000 (18:09 +0400)]
cmd/gc: fix compiler crash during race instrumentation
The compiler is crashing on the following code:
type TypeID int
func (t *TypeID) encodeType(x int) (tt TypeID, err error) {
switch x {
case 0:
return t.encodeType(x * x)
}
return 0, nil
}
The pass marks "return struct" {tt TypeID, err error} as used,
and this causes internal check failure.
I've added the test to:
https://golang.org/cl/6525052/diff/7020/src/pkg/runtime/race/regression_test.go
Rob Pike [Wed, 10 Oct 2012 02:29:50 +0000 (13:29 +1100)]
spec: clarify defer semantics
It's already there but only in the "for instance" and so not
clear enough: deferred functions run after
the result parameters are updated.
Robert Griesemer [Wed, 10 Oct 2012 00:08:09 +0000 (17:08 -0700)]
go/printer: idempotent comment formatting
Also:
- Refactored testing framework to permit easier
idempotency testing.
- Applied gofmt -w src misc
This CL depends on CL 6639044 being applied first.
Formatting is not idempotent for all files: In those
files the comment position has changed (due to missing
precise location information) and/or the comment formatting
cannot/is not aware of independent code re-formatting.
In general it is very hard to make format idempotent when
running it in one pass only. Leaving that aside for now.