Peter Kleiweg [Tue, 29 May 2012 20:30:06 +0000 (16:30 -0400)]
Emacs go-mode: don't indent the inside of strings.
Two fixes for indentation problems:
1. Properly recognize multi-line strings. These start with `, not ".
2. Don't indent a line if the beginning of the line is the end of a multi-line string. This happened for instance when inserting a closing bracket after a multi-line string.
Brad Fitzpatrick [Tue, 29 May 2012 18:09:09 +0000 (11:09 -0700)]
database/sql: use driver.ColumnConverter everywhere consistently
It was only being used for (*Stmt).Exec, not Query, and not for
the same two methods on *DB.
This unifies (*Stmt).Exec's old inline code into the old
subsetArgs function, renaming it in the process (changing the
old word "subset" to "driver", mostly converted earlier)
Russ Cox [Tue, 29 May 2012 18:02:29 +0000 (14:02 -0400)]
runtime: replace runtime·rnd function with ROUND macro
It's sad to introduce a new macro, but rnd shows up consistently
in profiles, and the function call overwhelms the two arithmetic
instructions it performs.
Rob Pike [Tue, 29 May 2012 18:01:50 +0000 (11:01 -0700)]
test/bench/shootout/timing.log: update after recent compiler changes
Moving panic out of line speeds up fannkuch almost a factor of two.
Changes to bitwhacking code affect mandelbrot badly.
R=golang-dev, bradfitz, rsc, r
CC=golang-dev
https://golang.org/cl/6258056
Akshat Kumar [Tue, 29 May 2012 16:32:42 +0000 (12:32 -0400)]
cmd/6l: Fixes for 64-bit Plan 9
Plan 9 versions for amd64 have 2 megabyte pages.
This also fixes the logic for 32-bit vs 64-bit Plan 9,
making 64-bit the default, and adds logic to generate
a symbols table.
R=golang-dev, rsc, rminnich, ality, 0intro
CC=golang-dev, john
https://golang.org/cl/6218046
Russ Cox [Tue, 29 May 2012 16:09:27 +0000 (12:09 -0400)]
cmd/6g, cmd/8g: move panicindex calls out of line
The old code generated for a bounds check was
CMP
JLT ok
CALL panicindex
ok:
...
The new code is (once the linker finishes with it):
CMP
JGE panic
...
panic:
CALL panicindex
which moves the calls out of line, putting more useful
code in each cache line. This matters especially in tight
loops, such as in Fannkuch. The benefit is more modest
elsewhere, but real.
JLT target // same as always
JLT $0, target // branch expected not taken
JLT $1, target // branch expected taken
The linker could also emit the prediction prefixes, but it
does not: expected taken branches are reversed so that the
expected case is not taken (as in example above), and
the default expectaton for such a jump is not taken
already.
R=golang-dev, gri, r, dave
CC=golang-dev
https://golang.org/cl/6248049
Brad Fitzpatrick [Mon, 28 May 2012 18:07:24 +0000 (11:07 -0700)]
net/http: avoid a bunch of unnecessary CanonicalHeaderKey calls
CanonicalHeaderKey didn't allocate, but it did use unnecessary
CPU in the hot path, deciding it didn't need to allocate.
I considered using constants for all these common header keys
but I didn't think it would be prettier. "Content-Length" looks
better than contentLength or hdrContentLength, etc.
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/6255053
Alexey Borzenkov [Mon, 28 May 2012 17:46:51 +0000 (10:46 -0700)]
net/http: reuse http proxy connections for different http requests
Comment on cache keys above connectMethod says "http to proxy, http
anywhere after that", however in reality target address was always
included, which prevented http requests to different target
addresses to reuse the same http proxy connection.
Wall time for Denis Cheremisov's PNG-decoding program given in
https://groups.google.com/group/golang-nuts/browse_thread/thread/22aa8a05040fdd49
Before: 2.25s
After: 2.27s
Delta: +1%
The same program, but with a different PNG input file
(http://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png)
and only 100 iterations instead of 1000
Before: 4.78s
After: 4.42s
Delta: -8%
Russ Cox [Fri, 25 May 2012 03:05:36 +0000 (23:05 -0400)]
cmd/gc: fix parallel assignment in range
for expr1, expr2 = range slice
was assigning to expr1 and expr2 in sequence
instead of in parallel. Now it assigns in parallel,
as it should. This matters for things like
for i, x[i] = range slice.
Russ Cox [Fri, 25 May 2012 02:41:07 +0000 (22:41 -0400)]
runtime: handle and test large map values
This is from CL 5451105 but was dropped from that CL.
See also CL 6137051.
The only change compared to 5451105 is to check for
h != nil in reflect·mapiterinit; allowing use of nil maps
must have happened after that original CL.
Fixes #3573.
R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/6215078
Wall time for Denis Cheremisov's PNG-decoding program given in
https://groups.google.com/group/golang-nuts/browse_thread/thread/22aa8a05040fdd49
Before: 2.44s
After: 2.26s
Delta: -7%
Alexey Borzenkov [Thu, 24 May 2012 23:07:08 +0000 (16:07 -0700)]
net/rpc: fix race condition when request write partially fails
When client fails to write a request is sends caller that error,
however server might have failed to read that request in the mean
time and replied with that error. When client then reads the
response the call would no longer be pending, so call will be nil
Handle this gracefully by discarding such server responses
R=golang-dev, r
CC=golang-dev, rsc
https://golang.org/cl/5956051
Russ Cox [Thu, 24 May 2012 21:20:07 +0000 (17:20 -0400)]
cmd/gc: faster code, mainly for rotate
* Eliminate bounds check on known small shifts.
* Rewrite x<<s | x>>(32-s) as a rotate (constant s).
* More aggressive (but still minimal) range analysis.
Rob Pike [Thu, 24 May 2012 21:15:43 +0000 (14:15 -0700)]
runtime: fix docs for Caller and Callers
The previous attempt to explain this got it backwards (all the more reason to be
sad we couldn't make the two functions behave the same).
Russ Cox [Thu, 24 May 2012 18:50:36 +0000 (14:50 -0400)]
exp/locale/collate: avoid 16-bit math
There's no need for the 16-bit arithmetic here,
and it tickles a long-standing compiler bug.
Fix the exp code not to use 16-bit math and
create an explicit test for the compiler bug.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6256048
Robert Griesemer [Thu, 24 May 2012 17:49:38 +0000 (10:49 -0700)]
math/big: make Rat.Denom() always return a reference
The documentation says so, but in the case of a normalized
integral Rat, the denominator was a new value. Changed the
internal representation to use an Int to represent the
denominator (with the sign ignored), so a reference to it
can always be returned.
Russ Cox [Thu, 24 May 2012 16:11:32 +0000 (12:11 -0400)]
cmd/6g: peephole fixes/additions
* Shift/rotate by constant doesn't have to stop subprop. (also in 8g)
* Remove redundant MOVLQZX instructions.
* An attempt at issuing loads early.
Good for 0.5% on a good day, might not be worth keeping.
Need to understand more about whether the x86
looks ahead to what loads might be coming up.
R=ken2, ken
CC=golang-dev
https://golang.org/cl/6203091
Shenghou Ma [Wed, 23 May 2012 03:36:24 +0000 (11:36 +0800)]
cmd/ld: fix Linux/ARM build
CL 5823055 removed a line introduced in Linux/ARM cgo support.
Because readsym() now returns nil for "$a", "$d" mapping symbols,
no matter the settings of `needSym', we still have to guard against
them in ldelf().
Ugorji Nwoke [Tue, 22 May 2012 22:21:35 +0000 (15:21 -0700)]
text/template: exec should accept interface value as valid.
Currently, if you pass some data to a template as an interface (e.g. interface{})
and extract that value that value as a parameter for a function, it fails, saying
wrong type.
This is because it is only looking at the interface type, not the interface content.
This CL uses the underlying content as the parameter to the func.
Fixes #3642.
R=golang-dev, r, r
CC=golang-dev
https://golang.org/cl/6218052
Shenghou Ma [Tue, 22 May 2012 18:32:27 +0000 (02:32 +0800)]
cmd/ld, cmd/6l, cmd/8l, cmd/5l: fix hidden/local symbol import for ELF systems
Introduce a newsym() to cmd/lib.c to add a symbol but don't add
them to hash table.
Introduce a new bit flag SHIDDEN and bit mask SMASK to handle hidden
and/or local symbols in ELF symbol tables. Though we still need to order
the symbol table entries correctly.
Fix for issue 3261 comment #9.
For CL 5822049.
Shenghou Ma [Tue, 22 May 2012 18:27:44 +0000 (02:27 +0800)]
cmd/ld: take section symbols' value into account for PE
ld -r could generate multiple section symbols for the same section,
but with different values, we have to take that into account.
Fixes #3322.
Part of issue 3261.
For CL 5822049.
Russ Cox [Tue, 22 May 2012 17:53:57 +0000 (13:53 -0400)]
unicode: fix comment about variable types
In both the web and command line tool,
the comment is shown after the declaration.
But in the code the comment is obviously before.
Make the text not refer to a specific order.
Comparing Go 1.0.1 and the complete unroll (this CL):
benchmark old MB/s new MB/s speedup
md5.BenchmarkHash1K 142.64 419.18 2.94x
md5.BenchmarkHash8K 144.14 432.13 3.00x
On the same machine, 'openssl speed md5' reports 441 MB/s
and 531 MB/s for our two cases, so this CL is at 90% and 80% of
those speeds, which is at least in the right ballpark.
OpenSSL is using carefully engineered assembly, so we are
unlikely to catch up completely.
There is also visible improvement in consumed CPU time:
tree2 -heapsize=8000000000 -cpus=12
before: 248.74user 6.36system 0:52.74elapsed 483%CPU
after: 229.86user 6.33system 0:51.08elapsed 462%CPU
-1.66s of real time, but -18.91s of consumed CPU time
Robert Griesemer [Tue, 22 May 2012 17:04:34 +0000 (10:04 -0700)]
go/parser: fix comment grouping (day 1 bug)
Comment groups must end at the end of a line (or the
next non-comment token) if the group started on a line
with non-comment tokens.
This is important for correct computation of "lead"
and "line" comments (Doc and Comment fields in AST nodes).
Without this fix, the "line" comment for F1 in the
following example:
type T struct {
F1 int // comment1
// comment2
F2 int
}
is "// comment1// comment2" rather than just "// comment1".
This bug was present from Day 1 but only visible when
looking at export-filtered ASTs where only comments
associated with AST nodes are printed, and only in rare
cases (e.g, in the case above, if F2 where not exported,
godoc would show "// comment2" anyway because it was
considered part of the "line" comment for F1).
The bug fix is very small (parser.go). The bulk of the
changes are additional test cases (parser_test.go).
The fix exposed a caching bug in go/printer via one of the
existing tests, hence the changes to printer.go.
As an aside, the fix removes the the need for empty lines
before an "// Output" comment for some special cases of
code examples (e.g.: src/pkg/strings/example_test.go, Count
example).
Russ Cox [Mon, 21 May 2012 18:10:16 +0000 (14:10 -0400)]
crypto/rsa: add SHA-224 hash prefix
http://www.rsa.com/rsalabs/node.asp?id=2125:
NOTE: A new OID has been defined for the combination
of the v1.5 signature scheme and the SHA-224 hash function:
sha224WithRSAEncryption OBJECT IDENTIFIER ::=
Like the other sha*WithRSAEncryption OIDs in PKCS #1 v2.1,
this OID has NULL parameters.
The DigestInfo encoding for SHA-224 (see Section 9.2, Note 1) is:
(0x)30 2d 30 0d 06 09 60 86 48 01 65 03 04 02 04 05 00 04 1c || H
Volker Dobler [Mon, 21 May 2012 17:57:15 +0000 (10:57 -0700)]
net/http: add cookies from jar to POST request.
The main content of this CL is a test case checking the reported
issue 3511 and a tiny fix for it. A subsequent CL will refactor
the fix as proposed issue 3511.
Brad Fitzpatrick [Mon, 21 May 2012 17:39:31 +0000 (10:39 -0700)]
net/http: fix regression and mute known test failure for now
Two tests added in 820ffde8c are expected to fail until the fix
for Issue 3540 goes back in (pending Windows net fixes), so
make those tests just Logf for now, with a TODO to re-enable.
Add a new client test.
Rearrange the transport code to be more readable, and fix the
bug from 820ffde8c where the persistConn was being closed before
the body was fully ready.
Fixes #3644
Updates #1967 (not yet fixed, but should be after Issue 3540)