]> Cypherpunks repositories - gostls13.git/log
gostls13.git
10 years agohtml/template: fix build after encoding/js escaping change
Andrew Gerrand [Mon, 27 Oct 2014 23:18:44 +0000 (10:18 +1100)]
html/template: fix build after encoding/js escaping change

TBR=rsc
R=golang-codereviews
CC=golang-codereviews
https://golang.org/cl/159590043

10 years agotest: make maplinear more robust
Russ Cox [Mon, 27 Oct 2014 22:59:02 +0000 (18:59 -0400)]
test: make maplinear more robust

The test just doubled a certain number of times
and then gave up. On a mostly fast but occasionally
slow machine this may never make the test run
long enough to see the linear growth.

Change test to keep doubling until the first round
takes at least a full second, to reduce the effect of
occasional scheduling or other jitter.

The failure we saw had a time for the first round
of around 100ms.

Note that this test still passes once it sees a linear
effect, even with a very small total time.
The timeout here only applies to how long the execution
must be to support a reported failure.

LGTM=khr
R=khr
CC=golang-codereviews, rlh
https://golang.org/cl/164070043

10 years agoencoding/json: encode \t as \t instead of \u0009
Russ Cox [Mon, 27 Oct 2014 22:58:25 +0000 (18:58 -0400)]
encoding/json: encode \t as \t instead of \u0009

Shorter and easier to read form for a common character.

LGTM=bradfitz
R=adg, bradfitz
CC=golang-codereviews, zimmski
https://golang.org/cl/162340043

10 years agodoc/go1.4.html: first pieces of release notes
Rob Pike [Mon, 27 Oct 2014 21:23:24 +0000 (14:23 -0700)]
doc/go1.4.html: first pieces of release notes
Move the release notes into an HTML file.
Start writing the text.

LGTM=rsc
R=golang-codereviews, bradfitz, kamil.kisiel, tracey.brendan, rsc
CC=golang-codereviews
https://golang.org/cl/161350043

10 years agoruntime: fix endianness assumption when decoding ftab
Austin Clements [Mon, 27 Oct 2014 21:12:48 +0000 (17:12 -0400)]
runtime: fix endianness assumption when decoding ftab

The ftab ends with a half functab record consisting only of
the 'entry' field followed by a uint32 giving the offset of
the next table.  Previously, symtabinit assumed it could read
this uint32 as a uintptr.  Since this is unsafe on big endian,
explicitly read the offset as a uint32.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/157660043

10 years agonet: if a DNS lookup times out, forget that it is in flight
Ian Lance Taylor [Mon, 27 Oct 2014 15:46:18 +0000 (08:46 -0700)]
net: if a DNS lookup times out, forget that it is in flight

Before this CL, if the system resolver does a very slow DNS
lookup for a particular host, all subsequent requests for that
host will hang waiting for that lookup to complete.  That is
more or less expected when Dial is called with no deadline.
When Dial has a deadline, though, we can accumulate a large
number of goroutines waiting for that slow DNS lookup.  Try to
avoid this problem by restarting the DNS lookup when it is
redone after a deadline is passed.

This CL also avoids creating an extra goroutine purely to
handle the deadline.

No test because we would have to simulate a slow DNS lookup
followed by a fast DNS lookup.

Fixes #8602.

LGTM=bradfitz
R=bradfitz, mikioh.mikioh
CC=golang-codereviews, r, rsc
https://golang.org/cl/154610044

10 years agomisc/makerelease/windows: fix 404 help URL in installer
Emil Hessman [Mon, 27 Oct 2014 01:43:14 +0000 (12:43 +1100)]
misc/makerelease/windows: fix 404 help URL in installer

ARPHELPLINK yields 404; update the URL.

While here, also prefix the ARPREADME and ARPURLINFOABOUT URL's with the HTTP scheme to make 'em clickable links in the Add or Remove Programs listing.

LGTM=adg
R=golang-codereviews
CC=adg, golang-codereviews
https://golang.org/cl/154580045

10 years agodoc/go_faq.html: fix a couple of nits
Rob Pike [Sun, 26 Oct 2014 18:27:55 +0000 (11:27 -0700)]
doc/go_faq.html: fix a couple of nits
Wrong article, one stylistic point that bothers someone (but not me).

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/156680043

10 years agocmd/go: pass $CGO_LDFLAGS to linker with the "gccgo" toolchain.
Peter Collingbourne [Sat, 25 Oct 2014 17:30:14 +0000 (10:30 -0700)]
cmd/go: pass $CGO_LDFLAGS to linker with the "gccgo" toolchain.

LGTM=iant
R=iant, minux
CC=golang-codereviews, golang-dev
https://golang.org/cl/157460043

10 years agocmd/go: add bzr support for vcs root checking
Gustavo Niemeyer [Fri, 24 Oct 2014 17:49:17 +0000 (15:49 -0200)]
cmd/go: add bzr support for vcs root checking

Complements the logic introduced in CL 147170043.

LGTM=rsc
R=rsc, gustavo
CC=golang-codereviews
https://golang.org/cl/147240043

10 years agodoc/go1.4.txt: unsafe is outside go1 compatibility guarantees
Rob Pike [Fri, 24 Oct 2014 16:52:11 +0000 (09:52 -0700)]
doc/go1.4.txt: unsafe is outside go1 compatibility guarantees

CC=golang-codereviews
https://golang.org/cl/164770043

10 years agounsafe: document that unsafe programs are not protected
Rob Pike [Fri, 24 Oct 2014 16:37:25 +0000 (09:37 -0700)]
unsafe: document that unsafe programs are not protected
The compatibility guideline needs to be clear about this even
though it means adding a clause that was not there from the
beginning. It has always been understood, so this isn't really
a change in policy, just in its expression.

LGTM=bradfitz, gri, rsc
R=golang-codereviews, bradfitz, gri, rsc
CC=golang-codereviews
https://golang.org/cl/162060043

10 years agonet/http/pprof: run GC for /debug/pprof/heap?gc=1
Russ Cox [Fri, 24 Oct 2014 14:58:13 +0000 (10:58 -0400)]
net/http/pprof: run GC for /debug/pprof/heap?gc=1

We force runtime.GC before WriteHeapProfile with -test.heapprofile.
Make it possible to do the same with the HTTP interface.

Some servers only run a GC every few minutes.
On such servers, the heap profile will be a few minutes stale,
which may be too old to be useful.

Requested by private mail.

LGTM=dvyukov
R=dvyukov
CC=golang-codereviews
https://golang.org/cl/161990043

10 years agocmd/gc: synthesize zeroed value for non-assignment context
Russ Cox [Fri, 24 Oct 2014 14:27:39 +0000 (10:27 -0400)]
cmd/gc: synthesize zeroed value for non-assignment context

CL 157910047 introduced code to turn a node representing
a zeroed composite literal into N, the nil Node* pointer
(which represents any zero, not the Go literal nil).

That's great for assignments like x = T{}, but it doesn't work
when T{} is used in a value context like T{}.v or x == T{}.
Fix those.

Should have no effect on performance; confirmed.
The deltas below are noise (compare ns/op):

benchmark                          old ns/op      new ns/op      delta
BenchmarkBinaryTree17              2902919192     2915228424     +0.42%
BenchmarkFannkuch11                2597417605     2630363685     +1.27%
BenchmarkFmtFprintfEmpty           73.7           74.8           +1.49%
BenchmarkFmtFprintfString          196            199            +1.53%
BenchmarkFmtFprintfInt             213            217            +1.88%
BenchmarkFmtFprintfIntInt          336            356            +5.95%
BenchmarkFmtFprintfPrefixedInt     289            294            +1.73%
BenchmarkFmtFprintfFloat           415            416            +0.24%
BenchmarkFmtManyArgs               1281           1271           -0.78%
BenchmarkGobDecode                 10271734       10307978       +0.35%
BenchmarkGobEncode                 8985021        9079442        +1.05%
BenchmarkGzip                      410233227      412266944      +0.50%
BenchmarkGunzip                    102114554      103272443      +1.13%
BenchmarkHTTPClientServer          45297          44993          -0.67%
BenchmarkJSONEncode                19499741       19498489       -0.01%
BenchmarkJSONDecode                76436733       74247497       -2.86%
BenchmarkMandelbrot200             4273814        4307292        +0.78%
BenchmarkGoParse                   4024594        4028937        +0.11%
BenchmarkRegexpMatchEasy0_32       131            135            +3.05%
BenchmarkRegexpMatchEasy0_1K       328            333            +1.52%
BenchmarkRegexpMatchEasy1_32       115            117            +1.74%
BenchmarkRegexpMatchEasy1_1K       931            948            +1.83%
BenchmarkRegexpMatchMedium_32      216            217            +0.46%
BenchmarkRegexpMatchMedium_1K      72669          72857          +0.26%
BenchmarkRegexpMatchHard_32        3818           3809           -0.24%
BenchmarkRegexpMatchHard_1K        121398         121945         +0.45%
BenchmarkRevcomp                   613996550      615145436      +0.19%
BenchmarkTemplate                  93678525       93267391       -0.44%
BenchmarkTimeParse                 414            411            -0.72%
BenchmarkTimeFormat                396            399            +0.76%

Fixes #8947.

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

10 years agodoc/go1.4: encoding/csv
Russ Cox [Fri, 24 Oct 2014 04:48:34 +0000 (00:48 -0400)]
doc/go1.4: encoding/csv

CC=golang-codereviews
https://golang.org/cl/162140043

10 years agoencoding/csv: for Postgres, unquote empty strings, quote \.
Russ Cox [Fri, 24 Oct 2014 03:44:47 +0000 (23:44 -0400)]
encoding/csv: for Postgres, unquote empty strings, quote \.

In theory both of these lines encode the same three fields:

        a,,c
        a,"",c

However, Postgres defines that when importing CSV, the unquoted
version is treated as NULL (missing), while the quoted version is
treated as a string value (empty string). If the middle field is supposed to
be an integer value, the first line can be imported (NULL is okay), but
the second line cannot (empty string is not).

Postgres's import command (COPY FROM) has an option to force
the unquoted empty to be interpreted as a string but it does not
have an option to force the quoted empty to be interpreted as a NULL.

From http://www.postgresql.org/docs/9.0/static/sql-copy.html:

        The CSV format has no standard way to distinguish a NULL
        value from an empty string. PostgreSQL's COPY handles this
        by quoting. A NULL is output as the NULL parameter string
        and is not quoted, while a non-NULL value matching the NULL
        parameter string is quoted. For example, with the default
        settings, a NULL is written as an unquoted empty string,
        while an empty string data value is written with double
        quotes (""). Reading values follows similar rules. You can
        use FORCE_NOT_NULL to prevent NULL input comparisons for
        specific columns.

Therefore printing the unquoted empty is more flexible for
imports into Postgres than printing the quoted empty.

In addition to making the output more useful with Postgres, not
quoting empty strings makes the output smaller and easier to read.
It also matches the behavior of Microsoft Excel and Google Drive.

Since we are here and making concessions for Postgres, handle this
case too (again quoting the Postgres docs):

        Because backslash is not a special character in the CSV
        format, \., the end-of-data marker, could also appear as a
        data value. To avoid any misinterpretation, a \. data value
        appearing as a lone entry on a line is automatically quoted
        on output, and on input, if quoted, is not interpreted as
        the end-of-data marker. If you are loading a file created by
        another application that has a single unquoted column and
        might have a value of \., you might need to quote that value
        in the input file.

Fixes #7586.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/164760043

10 years agospec: minimal documention of unsafe.Pointer conversions
Robert Griesemer [Thu, 23 Oct 2014 16:45:11 +0000 (09:45 -0700)]
spec: minimal documention of unsafe.Pointer conversions

Per suggestion from rsc as a result of the dicussion of
(abandoned) CL 153110044.

Fixes #7192.

LGTM=r, rsc, iant
R=r, rsc, iant, ken
CC=golang-codereviews
https://golang.org/cl/163050043

10 years agogccgo_install.html: the 4.9 release series supports Go 1.2
Ian Lance Taylor [Thu, 23 Oct 2014 03:41:13 +0000 (20:41 -0700)]
gccgo_install.html: the 4.9 release series supports Go 1.2

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/163760043

10 years agosync: release Pool memory during second and later GCs
Dmitriy Vyukov [Wed, 22 Oct 2014 16:23:49 +0000 (20:23 +0400)]
sync: release Pool memory during second and later GCs

Pool memory was only being released during the first GC after the first Put.

Put assumes that p.local != nil means p is on the allPools list.
poolCleanup (called during each GC) removed each pool from allPools
but did not clear p.local, so each pool was cleared by exactly one GC
and then never cleared again.

This bug was introduced late in the Go 1.3 release cycle.

Fixes #8979.

LGTM=rsc
R=golang-codereviews, bradfitz, r, rsc
CC=golang-codereviews, khr
https://golang.org/cl/162980043

10 years agotest: add more cases to recover.go
Ian Lance Taylor [Wed, 22 Oct 2014 15:06:15 +0000 (08:06 -0700)]
test: add more cases to recover.go

test16 used to fail with gccgo.  The withoutRecoverRecursive
test would have failed in some possible implementations.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/151630043

10 years agoCONTRIBUTORS: add Austin Clements's google.com email (Google CLA)
Russ Cox [Wed, 22 Oct 2014 14:51:30 +0000 (10:51 -0400)]
CONTRIBUTORS: add Austin Clements's google.com email (Google CLA)

LGTM=bradfitz, austin
R=austin
CC=bradfitz, golang-codereviews
https://golang.org/cl/158330045

10 years agoruntime/cgo: encode BLX directly, fixes one clang build error on arm
Dave Cheney [Wed, 22 Oct 2014 01:30:15 +0000 (12:30 +1100)]
runtime/cgo: encode BLX directly, fixes one clang build error on arm

Fixes #8348.

Trying to work around clang's dodgy support for .arch by reverting to the external assembler didn't work out so well. Minux had a much better solution to encode the instructions we need as .word directives which avoids .arch altogether.

I've confirmed with gdb that this form produces the expected machine code

Dump of assembler code for function crosscall_arm1:
   0x00000000 <+0>: push {r4, r5, r6, r7, r8, r9, r10, r11, r12, lr}
   0x00000004 <+4>: mov r4, r0
   0x00000008 <+8>: mov r5, r1
   0x0000000c <+12>: mov r0, r2
   0x00000010 <+16>: blx r5
   0x00000014 <+20>: blx r4
   0x00000018 <+24>: pop {r4, r5, r6, r7, r8, r9, r10, r11, r12, pc}

There is another compilation failure that blocks building Go with clang on arm

# ../misc/cgo/test
# _/home/dfc/go/misc/cgo/test
/tmp/--407b12.s: Assembler messages:
/tmp/--407b12.s:59: Error: selected processor does not support ARM mode `blx r0'
clang: error: assembler command failed with exit code 1 (use -v to see invocation)
FAIL _/home/dfc/go/misc/cgo/test [build failed]

I'll open a new issue for that

LGTM=iant
R=iant, minux
CC=golang-codereviews
https://golang.org/cl/158180047

10 years agomisc/makerelease: set version number in Windows installer
Jens Frederich [Tue, 21 Oct 2014 23:56:26 +0000 (10:56 +1100)]
misc/makerelease: set version number in Windows installer

Set correct version number at Windows installer based on
Go's Mercurial tag.

Name                                     | Version
------------------------------------------------
Go Programming Language amd64 go1.3.3    | 1.3.3
Go Programming Language amd64 go1.2rc3   | 1.2
Go Programming Language amd64 go1.2beta1 | 1.2

Fixes #8239.

LGTM=adg
R=adg, c.emil.hessman, alex.brainman
CC=golang-codereviews
https://golang.org/cl/160950044

10 years agoundo CL 156430044 / 5d69cad4faaf
Dave Cheney [Tue, 21 Oct 2014 23:42:13 +0000 (23:42 +0000)]
undo CL 156430044 / 5d69cad4faaf

Partial undo, changes to ldelf.c retained.

Some platforms are still not working even with the integrated assembler disabled, will have to find another solution.

««« original CL description
cmd/cgo: disable clang's integrated assembler

Fixes #8348.

Clang's internal assembler (introduced by default in clang 3.4) understands the .arch directive, but doesn't change the default value of -march. This causes the build to fail when we use BLX (armv5 and above) when clang is compiled for the default armv4t architecture (which appears to be the default on all the distros I've used).

This is probably a clang bug, so work around it for the time being by disabling the integrated assembler when compiling the cgo assembly shim.

This CL also includes a small change to ldelf.c which was required as clang 3.4 and above generate more weird symtab entries.

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

LGTM=minux
R=iant, minux
CC=golang-codereviews
https://golang.org/cl/162880044

10 years agoruntime: warn that cputicks() might not be monotonic.
Keith Randall [Tue, 21 Oct 2014 21:46:07 +0000 (14:46 -0700)]
runtime: warn that cputicks() might not be monotonic.

Get rid of gocputicks(), it is no longer used.

LGTM=bradfitz, dave
R=golang-codereviews, bradfitz, dave, minux
CC=golang-codereviews
https://golang.org/cl/161110044

10 years agocmd/ld: fix addstrdata for big-endian systems
Ian Lance Taylor [Tue, 21 Oct 2014 17:10:11 +0000 (10:10 -0700)]
cmd/ld: fix addstrdata for big-endian systems

LGTM=rsc
R=minux, rsc
CC=golang-codereviews
https://golang.org/cl/158280043

10 years agotime: panic with a more helpful error on use of invalid Timer
Brad Fitzpatrick [Tue, 21 Oct 2014 11:26:40 +0000 (13:26 +0200)]
time: panic with a more helpful error on use of invalid Timer

Fixes #8721

LGTM=rsc
R=r, rsc
CC=golang-codereviews
https://golang.org/cl/155620045

10 years agocmd/gc: disallow call of *T method using **T variable
Russ Cox [Tue, 21 Oct 2014 02:04:12 +0000 (22:04 -0400)]
cmd/gc: disallow call of *T method using **T variable

This brings cmd/gc in line with the spec on this question.
It might break existing code, but that code was not conformant
with the spec.

Credit to Rémy for finding the broken code.

Fixes #6366.

LGTM=r
R=golang-codereviews, r
CC=adonovan, golang-codereviews, gri
https://golang.org/cl/129550043

10 years agocompress/gzip: allow stopping at end of first stream
Russ Cox [Tue, 21 Oct 2014 02:03:46 +0000 (22:03 -0400)]
compress/gzip: allow stopping at end of first stream

Allows parsing some file formats that assign special
meaning to which stream data is found in.

Will do the same for compress/bzip2 once this is
reviewed and submitted.

Fixes #6486.

LGTM=nigeltao
R=nigeltao, dan.kortschak
CC=adg, bradfitz, golang-codereviews, r
https://golang.org/cl/159120044

10 years agocmd/cgo: disable clang's integrated assembler
Dave Cheney [Mon, 20 Oct 2014 23:28:39 +0000 (23:28 +0000)]
cmd/cgo: disable clang's integrated assembler

Fixes #8348.

Clang's internal assembler (introduced by default in clang 3.4) understands the .arch directive, but doesn't change the default value of -march. This causes the build to fail when we use BLX (armv5 and above) when clang is compiled for the default armv4t architecture (which appears to be the default on all the distros I've used).

This is probably a clang bug, so work around it for the time being by disabling the integrated assembler when compiling the cgo assembly shim.

This CL also includes a small change to ldelf.c which was required as clang 3.4 and above generate more weird symtab entries.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/156430044

10 years agodebug/pe: use appropriate type for sizeofOptionalHeader32
Alex Brainman [Mon, 20 Oct 2014 23:02:33 +0000 (10:02 +1100)]
debug/pe: use appropriate type for sizeofOptionalHeader32

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/157220043

10 years agoruntime: fix flaky TestBlockProfile test
Keith Randall [Mon, 20 Oct 2014 22:48:42 +0000 (15:48 -0700)]
runtime: fix flaky TestBlockProfile test

It has been failing periodically on Solaris/x64.
Change blockevent so it always records an event if we called
SetBlockProfileRate(1), even if the time delta is negative or zero.

Hopefully this will fix the test on Solaris.
Caveat: I don't actually know what the Solaris problem is, this
is just an educated guess.

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

10 years agoruntime: handle non-nil-terminated environment strings on Plan 9
David du Colombier [Mon, 20 Oct 2014 21:03:03 +0000 (23:03 +0200)]
runtime: handle non-nil-terminated environment strings on Plan 9

Russ Cox pointed out that environment strings are not
required to be nil-terminated on Plan 9.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/159130044

10 years agoos/exec: fix number of expected file descriptors on Plan 9
David du Colombier [Mon, 20 Oct 2014 21:01:32 +0000 (23:01 +0200)]
os/exec: fix number of expected file descriptors on Plan 9

Since CL 104570043 and 112720043, we are using the
nsec system call instead of /dev/bintime on Plan 9.

LGTM=rsc
R=rsc
CC=aram, golang-codereviews
https://golang.org/cl/155590043

10 years agoflag: roll back 156390043 (flag setting)
Rob Pike [Mon, 20 Oct 2014 20:28:00 +0000 (13:28 -0700)]
flag: roll back 156390043 (flag setting)
Shell scripts depend on the old behavior too often.
It's too late to make this change.

LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/161890044

10 years agocmd/go: set exit status for failing "go generate" run.
Rob Pike [Mon, 20 Oct 2014 20:27:41 +0000 (13:27 -0700)]
cmd/go: set exit status for failing "go generate" run.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/154360048

10 years agoreflect: fix TestAllocations now that interfaces hold only pointers
Ian Lance Taylor [Mon, 20 Oct 2014 18:10:03 +0000 (11:10 -0700)]
reflect: fix TestAllocations now that interfaces hold only pointers

This test was failing but did not break the build because it
was not run when -test.short was used.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/157150043

10 years agoreflect: allocate correct type in assignTo and cvtT2I
Ian Lance Taylor [Mon, 20 Oct 2014 17:43:43 +0000 (10:43 -0700)]
reflect: allocate correct type in assignTo and cvtT2I

I came across this while debugging a GC problem in gccgo.
There is code in assignTo and cvtT2I that handles assignment
to all interface values.  It allocates an empty interface even
if the real type is a non-empty interface.  The fields are
then set for a non-empty interface, but the memory is recorded
as holding an empty interface.  This means that the GC has
incorrect information.

This is extremely unlikely to fail, because the code in the GC
that handles empty interfaces looks like this:

obj = nil;
typ = eface->type;
if(typ != nil) {
        if(!(typ->kind&KindDirectIface) || !(typ->kind&KindNoPointers))
                obj = eface->data;

In the current runtime the condition is always true--if
KindDirectIface is set, then KindNoPointers is clear--and we
always want to set obj = eface->data.  So the question is what
happens when we incorrectly store a non-empty interface value
in memory marked as an empty interface.  In that case
eface->type will not be a *rtype as we expect, but will
instead be a pointer to an Itab.  We are going to use this
pointer to look at a *rtype kind field.  The *rtype struct
starts out like this:

type rtype struct {
        size          uintptr
        hash          uint32            // hash of type; avoids computation in hash tables
        _             uint8             // unused/padding
        align         uint8             // alignment of variable with this type
        fieldAlign    uint8             // alignment of struct field with this type
        kind          uint8             // enumeration for C

An Itab always has at least two pointers, so on a
little-endian 64-bit system the kind field will be the high
byte of the second pointer.  This will normally be zero, so
the test of typ->kind will succeed, which is what we want.

On a 32-bit system it might be possible to construct a failing
case by somehow getting the Itab for an interface with one
method to be immediately followed by a word that is all ones.
The effect would be that the test would sometimes fail and the
GC would not mark obj, leading to an invalid dangling
pointer.  I have not tried to construct this test.

I noticed this in gccgo, where this error is much more likely
to cause trouble for a rather random reason: gccgo uses a
different layout of rtype, and in gccgo the kind field happens
to be the low byte of a pointer, not the high byte.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/155450044

10 years agoregexp: fix TestOnePassCutoff
Russ Cox [Mon, 20 Oct 2014 16:16:46 +0000 (12:16 -0400)]
regexp: fix TestOnePassCutoff

The stack blowout can no longer happen,
but we can still test that too-complex regexps
are rejected.

Replacement for CL 162770043.

LGTM=iant, r
R=r, iant
CC=bradfitz, golang-codereviews
https://golang.org/cl/162860043

10 years agoregexp/syntax: fix validity testing of zero repeats
Ian Lance Taylor [Mon, 20 Oct 2014 15:12:45 +0000 (08:12 -0700)]
regexp/syntax: fix validity testing of zero repeats

This is already tested by TestRE2Exhaustive, but the build has
not broken because that test is not run when using -test.short.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/155580043

10 years agodebug/pe: remove use of unsafe
Russ Cox [Mon, 20 Oct 2014 15:10:00 +0000 (11:10 -0400)]
debug/pe: remove use of unsafe

Helps in environments with restricted support for unsafe.

LGTM=bradfitz
R=r, bradfitz
CC=dsymonds, golang-codereviews
https://golang.org/cl/156410044

10 years agocmd/gc: emit code for extern = <N>
Daniel Morsing [Mon, 20 Oct 2014 14:59:10 +0000 (15:59 +0100)]
cmd/gc: emit code for extern = <N>

https://golang.org/cl/152700045/ made it possible for struct literals assigned to globals to use <N> as the RHS. Normally, this is to zero out variables on first use. Because globals are already zero (or their linker initialized value), we just ignored this.

Now that <N> can occur from non-initialization code, we need to emit this code. We don't use <N> for initialization of globals any more, so this shouldn't cause any excessive zeroing.

Fixes #8961.

LGTM=rsc
R=golang-codereviews, rsc
CC=bradfitz, golang-codereviews
https://golang.org/cl/154540044

10 years agoencoding/gob: add custom decoder buffer for performance
Rob Pike [Mon, 20 Oct 2014 14:33:08 +0000 (07:33 -0700)]
encoding/gob: add custom decoder buffer for performance
As we did with encoding, provide a trivial byte reader for
faster decoding. We can also reduce some of the copying
by doing the allocation all at once using a slightly different
interface from byte buffers.

benchmark                            old ns/op     new ns/op     delta
BenchmarkEndToEndPipe                13368         12902         -3.49%
BenchmarkEndToEndByteBuffer          5969          5642          -5.48%
BenchmarkEndToEndSliceByteBuffer     479485        470798        -1.81%
BenchmarkEncodeComplex128Slice       92367         92201         -0.18%
BenchmarkEncodeFloat64Slice          39990         38960         -2.58%
BenchmarkEncodeInt32Slice            30510         27938         -8.43%
BenchmarkEncodeStringSlice           33753         33365         -1.15%
BenchmarkDecodeComplex128Slice       232278        196704        -15.32%
BenchmarkDecodeFloat64Slice          150258        128191        -14.69%
BenchmarkDecodeInt32Slice            133806        115748        -13.50%
BenchmarkDecodeStringSlice           335117        300534        -10.32%

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/154360049

10 years agodoc/go1.4.txt: add compress/* Reset note
Brad Fitzpatrick [Mon, 20 Oct 2014 08:02:25 +0000 (10:02 +0200)]
doc/go1.4.txt: add compress/* Reset note

CC=golang-codereviews
https://golang.org/cl/156430043

10 years agocompress/flate: add Reset() to allow reusing large buffers to compress multiple buffers
James Robinson [Mon, 20 Oct 2014 01:58:02 +0000 (12:58 +1100)]
compress/flate: add Reset() to allow reusing large buffers to compress multiple buffers

This adds a Reset() to compress/flate's decompressor and plumbs that through
to compress/zlib and compress/gzip's Readers so callers can avoid large
allocations when performing many inflate operations. In particular this
preserves the allocation of the decompressor.hist buffer, which is 32kb and
overwritten as needed while inflating.

On the benchmark described in issue 6317, produces the following speedup on
my 2.3ghz Intel Core i7 MBP with go version devel +6b696a34e0af Sun Aug 03
15:14:59 2014 -0700 darwin/amd64:

blocked.text w/out patch vs blocked.text w/ patch:
benchmark           old ns/op      new ns/op      delta
BenchmarkGunzip     8371577533     7927917687     -5.30%

benchmark           old allocs     new allocs     delta
BenchmarkGunzip     176818         148519         -16.00%

benchmark           old bytes     new bytes     delta
BenchmarkGunzip     292184936     12739528      -95.64%

flat.text vs blocked.text w/patch:
benchmark           old ns/op      new ns/op      delta
BenchmarkGunzip     7939447827     7927917687     -0.15%

benchmark           old allocs     new allocs     delta
BenchmarkGunzip     90702          148519         +63.74%

benchmark           old bytes     new bytes     delta
BenchmarkGunzip     9959528       12739528      +27.91%

Similar speedups to those bradfitz saw in  https://golang.org/cl/13416045.

Fixes #6317.
Fixes #7950.

LGTM=nigeltao
R=golang-codereviews, bradfitz, dan.kortschak, adg, nigeltao, jamesr
CC=golang-codereviews
https://golang.org/cl/97140043

10 years agodoc/go1.4.txt: flags can now be set at most once
Rob Pike [Sun, 19 Oct 2014 17:33:50 +0000 (10:33 -0700)]
doc/go1.4.txt: flags can now be set at most once

CC=golang-codereviews
https://golang.org/cl/161820043

10 years agoflag: disallow setting flags multiple times
Rob Pike [Sun, 19 Oct 2014 17:33:22 +0000 (10:33 -0700)]
flag: disallow setting flags multiple times
This is a day 1 error in the flag package: It did not check
that a flag was set at most once on the command line.
Because user-defined flags may have more general
properties, the check applies only to the standard flag
types in this package: bool, string, etc.

Fixes #8960.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/156390043

10 years agoregexp: correct doc comment for ReplaceAllLiteralString
Ian Lance Taylor [Sun, 19 Oct 2014 17:28:27 +0000 (10:28 -0700)]
regexp: correct doc comment for ReplaceAllLiteralString

Fixes #8959.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/161790043

10 years agoencoding/gob: fix print format in generated decoder helpers
Rob Pike [Sun, 19 Oct 2014 13:44:50 +0000 (06:44 -0700)]
encoding/gob: fix print format in generated decoder helpers
Needed a %% to quote a percent in the format.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/156330043

10 years agoruntime: dequeue the correct SudoG
Keith Randall [Sun, 19 Oct 2014 04:02:49 +0000 (21:02 -0700)]
runtime: dequeue the correct SudoG

select {
       case <- c:
       case <- c:
}

In this case, c.recvq lists two SudoGs which have the same G.
So we can't use the G as the key to dequeue the correct SudoG,
as that key is ambiguous.  Dequeueing the wrong SudoG ends up
freeing a SudoG that is still in c.recvq.

The fix is to use the actual SudoG pointer as the key.

LGTM=dvyukov
R=rsc, bradfitz, dvyukov, khr
CC=austin, golang-codereviews
https://golang.org/cl/159040043

10 years agotext/template: fix bug in pipelined variadics
Rob Pike [Sat, 18 Oct 2014 18:22:05 +0000 (11:22 -0700)]
text/template: fix bug in pipelined variadics
Simple bug in argument processing: The final arg may
be the pipeline value, in which case it gets bound to the
fixed argument section. The code got that wrong. Easy
to fix.

Fixes #8950.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/161750043

10 years agoencoding/gob: use simple append-only buffer for encoding
Rob Pike [Sat, 18 Oct 2014 03:51:15 +0000 (20:51 -0700)]
encoding/gob: use simple append-only buffer for encoding
Bytes buffers have more API and are a little slower. Since appending
is a key part of the path in encode, using a faster implementation
speeds things up measurably.
The couple of positive swings are likely garbage-collection related
since memory allocation looks different in the benchmark now.
I am not concerned by them.

benchmark                            old ns/op     new ns/op     delta
BenchmarkEndToEndPipe                6620          6388          -3.50%
BenchmarkEndToEndByteBuffer          3548          3600          +1.47%
BenchmarkEndToEndSliceByteBuffer     336678        367980        +9.30%
BenchmarkEncodeComplex128Slice       78199         71297         -8.83%
BenchmarkEncodeFloat64Slice          37731         32258         -14.51%
BenchmarkEncodeInt32Slice            26780         22977         -14.20%
BenchmarkEncodeStringSlice           35882         26492         -26.17%
BenchmarkDecodeComplex128Slice       194819        185126        -4.98%
BenchmarkDecodeFloat64Slice          120538        120102        -0.36%
BenchmarkDecodeInt32Slice            106442        107275        +0.78%
BenchmarkDecodeStringSlice           272902        269866        -1.11%

LGTM=ruiu
R=golang-codereviews, ruiu
CC=golang-codereviews
https://golang.org/cl/160990043

10 years agoencoding/gob: custom array/slice decoders
Rob Pike [Fri, 17 Oct 2014 19:37:41 +0000 (12:37 -0700)]
encoding/gob: custom array/slice decoders
Use go generate to write better loops for decoding arrays,
just as we did for encoding. It doesn't help as much,
relatively speaking, but it's still noticeable.

benchmark                          old ns/op     new ns/op     delta
BenchmarkDecodeComplex128Slice     202348        184529        -8.81%
BenchmarkDecodeFloat64Slice        135800        120979        -10.91%
BenchmarkDecodeInt32Slice          121200        105149        -13.24%
BenchmarkDecodeStringSlice         288129        278214        -3.44%

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/154420044

10 years agoruntime/pprof: fix memory profiler test
Dmitriy Vyukov [Fri, 17 Oct 2014 17:28:47 +0000 (21:28 +0400)]
runtime/pprof: fix memory profiler test
Don't use cmd/pprof as it is not necessary installed
and does not work on nacl and plan9.
Instead just look at the raw profile.

LGTM=crawshaw, rsc
R=golang-codereviews, crawshaw, 0intro, rsc
CC=golang-codereviews
https://golang.org/cl/159010043

10 years agocmd/gc: don't use static init to initialize small structs, fields
Russ Cox [Fri, 17 Oct 2014 17:10:42 +0000 (13:10 -0400)]
cmd/gc: don't use static init to initialize small structs, fields

Better to avoid the memory loads and just use immediate constants.
This especially applies to zeroing, which was being done by
copying zeros from elsewhere in the binary, even if the value
was going to be completely initialized with non-zero values.
The zero writes were optimized away but the zero loads from
the data segment were not.

LGTM=r
R=r, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/152700045

10 years agoreflect: a few microoptimizations
Russ Cox [Fri, 17 Oct 2014 16:54:31 +0000 (12:54 -0400)]
reflect: a few microoptimizations

Replace i < 0 || i >= x with uint(i) >= uint(x).
Shorten a few other code sequences.
Move the kind bits to the bottom of the flag word, to avoid shifts.

LGTM=r
R=r, bradfitz
CC=golang-codereviews
https://golang.org/cl/159020043

10 years agoencoding/gob: speed up encoding of arrays and slices
Rob Pike [Fri, 17 Oct 2014 16:00:07 +0000 (09:00 -0700)]
encoding/gob: speed up encoding of arrays and slices

We borrow a trick from the fmt package and avoid reflection
to walk the elements when possible. We could push further with
unsafe (and we may) but this is a good start.
Decode can benefit similarly; it will be done separately.

Use go generate (engen.go) to produce the helper functions
(enc_helpers.go).

benchmark                            old ns/op     new ns/op     delta
BenchmarkEndToEndPipe                6593          6482          -1.68%
BenchmarkEndToEndByteBuffer          3662          3684          +0.60%
BenchmarkEndToEndSliceByteBuffer     350306        351693        +0.40%
BenchmarkComplex128Slice             96347         80045         -16.92%
BenchmarkInt32Slice                  42484         26008         -38.78%
BenchmarkFloat64Slice                51143         36265         -29.09%
BenchmarkStringSlice                 53402         35077         -34.32%

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/156310043

10 years agoruntime/pprof: fix test
Russ Cox [Fri, 17 Oct 2014 15:23:15 +0000 (11:23 -0400)]
runtime/pprof: fix test

gogo called from GC is okay
for the same reasons that
gogo called from System or ExternalCode is okay.
All three are fake stack traces.

Fixes #8408.

LGTM=dvyukov, r
R=r, dvyukov
CC=golang-codereviews
https://golang.org/cl/152580043

10 years agoruntime: remove comment that leaked into CL 153710043
Russ Cox [Fri, 17 Oct 2014 15:03:55 +0000 (11:03 -0400)]
runtime: remove comment that leaked into CL 153710043

This doesn't actually do anything. Maybe it will some day,
but maybe not.

TBR=r
CC=golang-codereviews
https://golang.org/cl/155490043

10 years agoCONTRIBUTORS: add James Robinson (Google CLA)
Brad Fitzpatrick [Fri, 17 Oct 2014 14:39:42 +0000 (16:39 +0200)]
CONTRIBUTORS: add James Robinson (Google CLA)

LGTM=iant
R=golang-codereviews, iant
CC=dvyukov, golang-codereviews, jamesr, nigeltao
https://golang.org/cl/155530043

10 years agoundo CL 159990043 / 421fadcef39a
Russ Cox [Fri, 17 Oct 2014 14:11:03 +0000 (10:11 -0400)]
undo CL 159990043 / 421fadcef39a

Dmitriy believes this broke Windows.
It looks like build.golang.org stopped before that,
but it's worth a shot.

««« original CL description
runtime: make pprof a little nicer

Update #8942

This does not fully address issue 8942 but it does make
the profiles much more useful, until that issue can be
fixed completely.

LGTM=dvyukov
R=r, dvyukov
CC=golang-codereviews
https://golang.org/cl/159990043
»»»

TBR=dvyukov
CC=golang-codereviews
https://golang.org/cl/160030043

10 years agospec: define "variable"
Robert Griesemer [Thu, 16 Oct 2014 22:08:49 +0000 (15:08 -0700)]
spec: define "variable"

Fixes #8496.

LGTM=rsc, r, iant
R=r, rsc, iant, ken
CC=golang-codereviews
https://golang.org/cl/148580043

10 years agoreflect: fix struct size calculation to include terminal padding
Damien Neil [Thu, 16 Oct 2014 20:58:32 +0000 (13:58 -0700)]
reflect: fix struct size calculation to include terminal padding

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/160920045

10 years agoCONTRIBUTORS: add Damien Neil
Damien Neil [Thu, 16 Oct 2014 20:55:32 +0000 (13:55 -0700)]
CONTRIBUTORS: add Damien Neil

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/159920044

10 years agosyscall: don't cache environment variables on Plan 9
David du Colombier [Thu, 16 Oct 2014 20:30:14 +0000 (22:30 +0200)]
syscall: don't cache environment variables on Plan 9

Fixes #8849.

LGTM=bradfitz, aram
R=bradfitz, rsc, aram
CC=golang-codereviews
https://golang.org/cl/158970045

10 years agoruntime/pprof: disable new memory test
Russ Cox [Thu, 16 Oct 2014 18:58:11 +0000 (14:58 -0400)]
runtime/pprof: disable new memory test

It cannot run 'go tool pprof'. There is no guarantee that's installed.
It needs to build a temporary pprof binary and run that.
It also needs to skip the test on systems that can't build and
run binaries, namely android and nacl.

See src/cmd/nm/nm_test.go's TestNM for a template.

Update #8867
Status: Accepted

TBR=dvyukov
CC=golang-codereviews
https://golang.org/cl/153710043

10 years agoruntime: make pprof a little nicer
Russ Cox [Thu, 16 Oct 2014 18:44:55 +0000 (14:44 -0400)]
runtime: make pprof a little nicer

Update #8942

This does not fully address issue 8942 but it does make
the profiles much more useful, until that issue can be
fixed completely.

LGTM=dvyukov
R=r, dvyukov
CC=golang-codereviews
https://golang.org/cl/159990043

10 years agoruntime: fix memory profiler
Dmitriy Vyukov [Thu, 16 Oct 2014 18:11:26 +0000 (22:11 +0400)]
runtime: fix memory profiler
There are 3 issues:
1. Skip argument of callers is off by 3,
so that all allocations are deep inside of memory profiler.
2. Memory profiling statistics are not updated after runtime.GC.
3. Testing package does not update memory profiling statistics
before capturing the profile.
Also add an end-to-end test.
Fixes #8867.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/148710043

10 years agocmd/gc: elide write barrier for x = x[0:y] and x = append(x, ...)
Russ Cox [Thu, 16 Oct 2014 16:43:17 +0000 (12:43 -0400)]
cmd/gc: elide write barrier for x = x[0:y] and x = append(x, ...)

Both of these forms can avoid writing to the base pointer in x
(in the slice, always, and in the append, most of the time).

For Go 1.5, will need to change the compilation of x = x[0:y]
to avoid writing to the base pointer, so that the elision is safe,
and will need to change the compilation of x = append(x, ...)
to write to the base pointer (through a barrier) only when
growing the underlying array, so that the general elision is safe.

For Go 1.4, elide the write barrier always, a change that should
have equivalent performance characteristics but is much
simpler and therefore safer.

benchmark                       old ns/op   new ns/op   delta
BenchmarkBinaryTree17           3910526122  3918802545  +0.21%
BenchmarkFannkuch11             3747650699  3732600693  -0.40%
BenchmarkFmtFprintfEmpty        106         98.7        -6.89%
BenchmarkFmtFprintfString       280         269         -3.93%
BenchmarkFmtFprintfInt          296         282         -4.73%
BenchmarkFmtFprintfIntInt       467         470         +0.64%
BenchmarkFmtFprintfPrefixedInt  418         398         -4.78%
BenchmarkFmtFprintfFloat        574         535         -6.79%
BenchmarkFmtManyArgs            1768        1818        +2.83%
BenchmarkGobDecode              14916799    14925182    +0.06%
BenchmarkGobEncode              14110076    13358298    -5.33%
BenchmarkGzip                   546609795   542630402   -0.73%
BenchmarkGunzip                 136270657   136496277   +0.17%
BenchmarkHTTPClientServer       126574      125245      -1.05%
BenchmarkJSONEncode             30006238    27862354    -7.14%
BenchmarkJSONDecode             106020889   102664600   -3.17%
BenchmarkMandelbrot200          5793550     5818320     +0.43%
BenchmarkGoParse                5437608     5463962     +0.48%
BenchmarkRegexpMatchEasy0_32    192         179         -6.77%
BenchmarkRegexpMatchEasy0_1K    462         460         -0.43%
BenchmarkRegexpMatchEasy1_32    168         153         -8.93%
BenchmarkRegexpMatchEasy1_1K    1420        1280        -9.86%
BenchmarkRegexpMatchMedium_32   338         286         -15.38%
BenchmarkRegexpMatchMedium_1K   107435      98027       -8.76%
BenchmarkRegexpMatchHard_32     5941        4846        -18.43%
BenchmarkRegexpMatchHard_1K     185965      153830      -17.28%
BenchmarkRevcomp                795497458   798447829   +0.37%
BenchmarkTemplate               132091559   134938425   +2.16%
BenchmarkTimeParse              604         608         +0.66%
BenchmarkTimeFormat             551         548         -0.54%

LGTM=r
R=r, dave
CC=golang-codereviews, iant, khr, rlh
https://golang.org/cl/159960043

10 years agocrypto/tls: support TLS_FALLBACK_SCSV as a server.
Adam Langley [Thu, 16 Oct 2014 00:54:04 +0000 (17:54 -0700)]
crypto/tls: support TLS_FALLBACK_SCSV as a server.

A new attack on CBC padding in SSLv3 was released yesterday[1]. Go only
supports SSLv3 as a server, not as a client. An easy fix is to change
the default minimum version to TLS 1.0 but that seems a little much
this late in the 1.4 process as it may break some things.

Thus this patch adds server support for TLS_FALLBACK_SCSV[2] -- a
mechanism for solving the fallback problem overall. Chrome has
implemented this since February and Google has urged others to do so in
light of yesterday's news.

With this change, clients can indicate that they are doing a fallback
connection and Go servers will be able to correctly reject them.

[1] http://googleonlinesecurity.blogspot.com/2014/10/this-poodle-bites-exploiting-ssl-30.html
[2] https://tools.ietf.org/html/draft-ietf-tls-downgrade-scsv-00

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/157090043

10 years agocmd/gc: simplify compiled code for explicit zeroing
Russ Cox [Wed, 15 Oct 2014 23:33:15 +0000 (19:33 -0400)]
cmd/gc: simplify compiled code for explicit zeroing

Among other things, *x = T{} does not need a write barrier.
The changes here avoid an unnecessary copy even when
no pointers are involved, so it may have larger effects.

In 6g and 8g, avoid manually repeated STOSQ in favor of
writing explicit MOVs, under the theory that the MOVs
should have fewer dependencies and pipeline better.

Benchmarks compare best of 5 on a 2012 MacBook Pro Core i5
with TurboBoost disabled. Most improvements can be explained
by the changes in this CL.

The effect in Revcomp is real but harder to explain: none of
the instructions in the inner loop changed. I suspect loop
alignment but really have no idea.

benchmark                       old         new         delta
BenchmarkBinaryTree17           3809027371  3819907076  +0.29%
BenchmarkFannkuch11             3607547556  3686983012  +2.20%
BenchmarkFmtFprintfEmpty        118         103         -12.71%
BenchmarkFmtFprintfString       289         277         -4.15%
BenchmarkFmtFprintfInt          304         290         -4.61%
BenchmarkFmtFprintfIntInt       507         458         -9.66%
BenchmarkFmtFprintfPrefixedInt  425         408         -4.00%
BenchmarkFmtFprintfFloat        555         555         +0.00%
BenchmarkFmtManyArgs            1835        1733        -5.56%
BenchmarkGobDecode              14738209    14639331    -0.67%
BenchmarkGobEncode              14239039    13703571    -3.76%
BenchmarkGzip                   538211054   538701315   +0.09%
BenchmarkGunzip                 135430877   134818459   -0.45%
BenchmarkHTTPClientServer       116488      116618      +0.11%
BenchmarkJSONEncode             28923406    29294334    +1.28%
BenchmarkJSONDecode             105779820   104289543   -1.41%
BenchmarkMandelbrot200          5791758     5771964     -0.34%
BenchmarkGoParse                5376642     5310943     -1.22%
BenchmarkRegexpMatchEasy0_32    195         190         -2.56%
BenchmarkRegexpMatchEasy0_1K    477         455         -4.61%
BenchmarkRegexpMatchEasy1_32    170         165         -2.94%
BenchmarkRegexpMatchEasy1_1K    1410        1394        -1.13%
BenchmarkRegexpMatchMedium_32   336         329         -2.08%
BenchmarkRegexpMatchMedium_1K   108979      106328      -2.43%
BenchmarkRegexpMatchHard_32     5854        5821        -0.56%
BenchmarkRegexpMatchHard_1K     185089      182838      -1.22%
BenchmarkRevcomp                834920364   780202624   -6.55%
BenchmarkTemplate               137046937   129728756   -5.34%
BenchmarkTimeParse              600         594         -1.00%
BenchmarkTimeFormat             559         539         -3.58%

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

10 years agounicode/utf8: fix docs for DecodeRune(empty) and friends.
Nigel Tao [Wed, 15 Oct 2014 22:13:50 +0000 (09:13 +1100)]
unicode/utf8: fix docs for DecodeRune(empty) and friends.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/157080043

10 years agocmd/go: add '_go_' suffix to go files compiled by gccgo to avoid naming conflicts
Chris Manghane [Wed, 15 Oct 2014 20:13:37 +0000 (13:13 -0700)]
cmd/go: add '_go_' suffix to go files compiled by gccgo to avoid naming conflicts

Fixes #8828.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/154410043

10 years agocmd/gc: do not copy via temporary for writebarrierfat{2,3,4}
Russ Cox [Wed, 15 Oct 2014 18:33:52 +0000 (14:33 -0400)]
cmd/gc: do not copy via temporary for writebarrierfat{2,3,4}

The general writebarrierfat needs a temporary for src,
because we need to pass the address of the temporary
to the writebarrierfat routine. But the new fixed-size
ones pass the value directly and don't need to introduce
the temporary.

Magnifies some of the effect of the custom write barrier change.

Comparing best of 5 with TurboBoost turned off,
on a 2012 Retina MacBook Pro Core i5.
Still not completely confident in these numbers,
but the fmt, regexp, and revcomp improvements seem real.

benchmark                      old ns/op  new ns/op  delta
BenchmarkBinaryTree17          3942965521 3929654940 -0.34%
BenchmarkFannkuch11            3707543350 3699566011 -0.22%
BenchmarkFmtFprintfEmpty       119        119        +0.00%
BenchmarkFmtFprintfString      295        296        +0.34%
BenchmarkFmtFprintfInt         313        314        +0.32%
BenchmarkFmtFprintfIntInt      517        484        -6.38%
BenchmarkFmtFprintfPrefixedInt 439        429        -2.28%
BenchmarkFmtFprintfFloat       571        569        -0.35%
BenchmarkFmtManyArgs           1899       1820       -4.16%
BenchmarkGobDecode             15507208   15325649   -1.17%
BenchmarkGobEncode             14811710   14715434   -0.65%
BenchmarkGzip                  561144467  549624323  -2.05%
BenchmarkGunzip                137377667  137691087  +0.23%
BenchmarkHTTPClientServer      126632     124717     -1.51%
BenchmarkJSONEncode            29944112   29526629   -1.39%
BenchmarkJSONDecode            108954913  107339551  -1.48%
BenchmarkMandelbrot200         5828755    5821659    -0.12%
BenchmarkGoParse               5577437    5521895    -1.00%
BenchmarkRegexpMatchEasy0_32   198        193        -2.53%
BenchmarkRegexpMatchEasy0_1K   486        469        -3.50%
BenchmarkRegexpMatchEasy1_32   175        167        -4.57%
BenchmarkRegexpMatchEasy1_1K   1450       1419       -2.14%
BenchmarkRegexpMatchMedium_32  344        338        -1.74%
BenchmarkRegexpMatchMedium_1K  112088     109855     -1.99%
BenchmarkRegexpMatchHard_32    6078       6003       -1.23%
BenchmarkRegexpMatchHard_1K    191166     187499     -1.92%
BenchmarkRevcomp               854870445  799012851  -6.53%
BenchmarkTemplate              141572691  141508105  -0.05%
BenchmarkTimeParse             604        603        -0.17%
BenchmarkTimeFormat            579        560        -3.28%

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/155450043

10 years agoreflect: shorten value to 3 words
Russ Cox [Wed, 15 Oct 2014 18:24:18 +0000 (14:24 -0400)]
reflect: shorten value to 3 words

scalar is no longer needed, now that
interfaces always hold pointers.

Comparing best of 5 with TurboBoost turned off,
on a 2012 Retina MacBook Pro Core i5.
Still not completely confident in these numbers,
but the gob and template improvements seem real.

benchmark                       old ns/op   new ns/op   delta
BenchmarkBinaryTree17           3819892491  3803008185  -0.44%
BenchmarkFannkuch11             3623876405  3611776426  -0.33%
BenchmarkFmtFprintfEmpty        119         118         -0.84%
BenchmarkFmtFprintfString       294         292         -0.68%
BenchmarkFmtFprintfInt          310         304         -1.94%
BenchmarkFmtFprintfIntInt       513         507         -1.17%
BenchmarkFmtFprintfPrefixedInt  427         426         -0.23%
BenchmarkFmtFprintfFloat        562         554         -1.42%
BenchmarkFmtManyArgs            1873        1832        -2.19%
BenchmarkGobDecode              15824504    14746565    -6.81%
BenchmarkGobEncode              14347378    14208743    -0.97%
BenchmarkGzip                   537229271   537973492   +0.14%
BenchmarkGunzip                 134996775   135406149   +0.30%
BenchmarkHTTPClientServer       119065      116937      -1.79%
BenchmarkJSONEncode             29134359    28928099    -0.71%
BenchmarkJSONDecode             106867289   105770161   -1.03%
BenchmarkMandelbrot200          5798475     5791433     -0.12%
BenchmarkGoParse                5299169     5379201     +1.51%
BenchmarkRegexpMatchEasy0_32    195         195         +0.00%
BenchmarkRegexpMatchEasy0_1K    477         477         +0.00%
BenchmarkRegexpMatchEasy1_32    170         170         +0.00%
BenchmarkRegexpMatchEasy1_1K    1412        1397        -1.06%
BenchmarkRegexpMatchMedium_32   336         337         +0.30%
BenchmarkRegexpMatchMedium_1K   109025      108977      -0.04%
BenchmarkRegexpMatchHard_32     5854        5856        +0.03%
BenchmarkRegexpMatchHard_1K     184914      184748      -0.09%
BenchmarkRevcomp                829233526   836598734   +0.89%
BenchmarkTemplate               142055312   137016166   -3.55%
BenchmarkTimeParse              598         597         -0.17%
BenchmarkTimeFormat             564         568         +0.71%

Fixes #7425.

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

10 years agoreflect: add fast path for FieldByIndex with len(index) = 1
Russ Cox [Wed, 15 Oct 2014 17:33:00 +0000 (13:33 -0400)]
reflect: add fast path for FieldByIndex with len(index) = 1

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/152640043

10 years agoruntime: remove hand-generated ptr bitmaps for reflectcall
Russ Cox [Wed, 15 Oct 2014 17:12:16 +0000 (13:12 -0400)]
runtime: remove hand-generated ptr bitmaps for reflectcall

A Go prototype can be used instead now, and the compiler
will do a better job than we will doing it by hand.
(We got it wrong in amd64p32, causing the current build
breakage.)

The auto-prototype-matching only applies to functions
without an explicit package path, so the TEXT lines for
reflectcall and callXX are s/runtime·/·/.

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

10 years agodatabase/sql: add Drivers, returning list of registered drivers
Russ Cox [Wed, 15 Oct 2014 17:10:14 +0000 (13:10 -0400)]
database/sql: add Drivers, returning list of registered drivers

Fixes #7969.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/158950043

10 years agoos/exec: document that Stdin goroutine must finish in Wait
Russ Cox [Wed, 15 Oct 2014 17:09:59 +0000 (13:09 -0400)]
os/exec: document that Stdin goroutine must finish in Wait

Fixes #7990.

LGTM=iant, bradfitz
R=bradfitz, iant, robryk
CC=golang-codereviews
https://golang.org/cl/156220043

10 years agocmd/gc: blank methods are not permitted in interface types
Chris Manghane [Wed, 15 Oct 2014 16:55:13 +0000 (09:55 -0700)]
cmd/gc: blank methods are not permitted in interface types

Fixes #6606.

LGTM=rsc
R=rsc
CC=golang-codereviews, gri
https://golang.org/cl/156210044

10 years agonet/http: don't send implicit gzip Accept-Encoding on Range requests
Brad Fitzpatrick [Wed, 15 Oct 2014 15:51:30 +0000 (17:51 +0200)]
net/http: don't send implicit gzip Accept-Encoding on Range requests

The http package by default adds "Accept-Encoding: gzip" to outgoing
requests, unless it's a bad idea, or the user requested otherwise.
Only when the http package adds its own implicit Accept-Encoding header
does the http package also transparently un-gzip the response.

If the user requested part of a document (e.g. bytes 40 to 50), it appears
that Github/Varnish send:
        range(gzip(content), 40, 50)

And not:
        gzip(range(content, 40, 50))

The RFC 2616 set of replacements (with the purpose of
clarifying ambiguities since 1999) has an RFC about Range
requests (http://tools.ietf.org/html/rfc7233) but does not
mention the interaction with encodings.

Regardless of whether range(gzip(content)) or gzip(range(content)) is
correct, this change prevents the Go package from asking for gzip
in requests if we're also asking for Range, avoiding the issue.
If the user cared, they can do it themselves. But Go transparently
un-gzipping a fragment of gzip is never useful.

Fixes #8923

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/155420044

10 years agonet/http: don't reuse a server connection after any Write errors
Brad Fitzpatrick [Wed, 15 Oct 2014 15:51:12 +0000 (17:51 +0200)]
net/http: don't reuse a server connection after any Write errors

Fixes #8534

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/149340044

10 years agocrypto/x509: correct field name in comment
Ian Lance Taylor [Wed, 15 Oct 2014 13:20:55 +0000 (06:20 -0700)]
crypto/x509: correct field name in comment

Fixes #8936.

LGTM=bradfitz
R=agl, bradfitz
CC=golang-codereviews
https://golang.org/cl/152590043

10 years agoliblink: require DATA lines to be ordered by offset, with no overlap
Russ Cox [Wed, 15 Oct 2014 03:25:12 +0000 (23:25 -0400)]
liblink: require DATA lines to be ordered by offset, with no overlap

The assembler could give a better error, but this one
is good enough for now.

Fixes #8880.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/153610043

10 years agogo/build: Return MultiplePackageError on importing a dir containing multiple packages
Jens Frederich [Wed, 15 Oct 2014 03:24:58 +0000 (23:24 -0400)]
go/build: Return MultiplePackageError on importing a dir containing multiple packages

When the Import function in go/build encounters a directory
without any buildable Go source files, it returns a handy
NoGoError. Now if, instead it encounters multiple Go source files
from multiple packages, it returns a handy MultiplePackageError.

A new test for NoGoError and MultiplePackageError is also provided.

Fixes #8286.

LGTM=adg, rsc
R=bradfitz, rsc, adg
CC=golang-codereviews
https://golang.org/cl/155050043

10 years agocmd/gc, runtime: fix race, nacl for writebarrier changes
Russ Cox [Wed, 15 Oct 2014 03:24:32 +0000 (23:24 -0400)]
cmd/gc, runtime: fix race, nacl for writebarrier changes

The racewalk code was not updated for the new write barriers.
Make it more future-proof.

The new write barrier code assumed that +1 pointer would
be aligned properly for any type that might follow, but that's
not true on 32-bit systems where some types are 64-bit aligned.
The only system like that today is nacl/amd64p32.
Insert a dummy pointer so that the ambiguously typed
value is at +2 pointers, which is always max-aligned.

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

10 years agoencoding/gob: make encoding structs a little faster
Rob Pike [Wed, 15 Oct 2014 03:03:35 +0000 (20:03 -0700)]
encoding/gob: make encoding structs a little faster
FieldByIndex never returns an invalid Value, so the validity
test can be avoided if the field is not indirect.

BenchmarkGobEncode     12768642      12424022      -2.70%
BenchmarkGobEncode     60.11        61.78        1.03x

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/158890045

10 years agocmd/gc: check for initialization cycles in method values
Chris Manghane [Wed, 15 Oct 2014 02:12:10 +0000 (19:12 -0700)]
cmd/gc: check for initialization cycles in method values

Fixes #7960.

LGTM=rsc
R=rsc
CC=golang-codereviews, gri
https://golang.org/cl/159800045

10 years agoruntime: handle all windows exception (second attempt)
Alex Brainman [Wed, 15 Oct 2014 00:11:11 +0000 (11:11 +1100)]
runtime: handle all windows exception (second attempt)

includes undo of 22318cd31d7d and also:
- always use SetUnhandledExceptionFilter on windows-386;
- crash when receive EXCEPTION_BREAKPOINT in exception handler.

Fixes #8006.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/155360043

10 years agomath/big: Allow non-prime modulus for ModInverse
Keith Randall [Tue, 14 Oct 2014 21:09:56 +0000 (14:09 -0700)]
math/big: Allow non-prime modulus for ModInverse

The inverse is defined whenever the element and the
modulus are relatively prime.  The code already handles
this situation, but the spec does not.

Test that it does indeed work.

Fixes #8875

LGTM=agl
R=agl
CC=golang-codereviews
https://golang.org/cl/155010043

10 years agocmd/gc: add 2-, 3-, 4-word write barrier specializations
Russ Cox [Tue, 14 Oct 2014 20:31:09 +0000 (16:31 -0400)]
cmd/gc: add 2-, 3-, 4-word write barrier specializations

Assignments of 2-, 3-, and 4-word values were handled
by individual MOV instructions (and for scalars still are).
But if there are pointers involved, those assignments now
go through the write barrier routine. Before this CL, they
went to writebarrierfat, which calls memmove.
Memmove is too much overhead for these small
amounts of data.

Instead, call writebarrierfat{2,3,4}, which are specialized
for the specific amount of data being copied.
Today the write barrier does not care which words are
pointers, so size alone is enough to distinguish the cases.
If we keep these distinctions in Go 1.5 we will need to
expand them for all the pointer-vs-scalar possibilities,
so the current 3 functions will become 3+7+15 = 25,
still not a large burden (we deleted more morestack
functions than that when we dropped segmented stacks).

BenchmarkBinaryTree17           3250972583  3123910344  -3.91%
BenchmarkFannkuch11             3067605223  2964737839  -3.35%
BenchmarkFmtFprintfEmpty        101         96.0        -4.95%
BenchmarkFmtFprintfString       267         235         -11.99%
BenchmarkFmtFprintfInt          261         253         -3.07%
BenchmarkFmtFprintfIntInt       444         402         -9.46%
BenchmarkFmtFprintfPrefixedInt  374         346         -7.49%
BenchmarkFmtFprintfFloat        472         449         -4.87%
BenchmarkFmtManyArgs            1537        1476        -3.97%
BenchmarkGobDecode              13986528    12432985    -11.11%
BenchmarkGobEncode              13120323    12537420    -4.44%
BenchmarkGzip                   451925758   437500578   -3.19%
BenchmarkGunzip                 113267612   110053644   -2.84%
BenchmarkHTTPClientServer       103151      77100       -25.26%
BenchmarkJSONEncode             25002733    23435278    -6.27%
BenchmarkJSONDecode             94213717    82568789    -12.36%
BenchmarkMandelbrot200          4804246     4713070     -1.90%
BenchmarkGoParse                4646114     4379456     -5.74%
BenchmarkRegexpMatchEasy0_32    163         158         -3.07%
BenchmarkRegexpMatchEasy0_1K    433         391         -9.70%
BenchmarkRegexpMatchEasy1_32    154         138         -10.39%
BenchmarkRegexpMatchEasy1_1K    1481        1132        -23.57%
BenchmarkRegexpMatchMedium_32   282         270         -4.26%
BenchmarkRegexpMatchMedium_1K   92421       86149       -6.79%
BenchmarkRegexpMatchHard_32     5209        4718        -9.43%
BenchmarkRegexpMatchHard_1K     158141      147921      -6.46%
BenchmarkRevcomp                699818791   642222464   -8.23%
BenchmarkTemplate               132402383   108269713   -18.23%
BenchmarkTimeParse              509         478         -6.09%
BenchmarkTimeFormat             462         456         -1.30%

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/156200043

10 years agocmd/gc: fix 'make' in cmd/gc directory
Russ Cox [Tue, 14 Oct 2014 18:58:25 +0000 (14:58 -0400)]
cmd/gc: fix 'make' in cmd/gc directory

Right now, go tool 6g -A fails complaining about 'any' type.

TBR=r
CC=golang-codereviews
https://golang.org/cl/156200044

10 years agoruntime: a few optimizations of scanblock.
Keith Randall [Tue, 14 Oct 2014 16:22:47 +0000 (09:22 -0700)]
runtime: a few optimizations of scanblock.

Lowers gc pause time by 5-10% on test/bench/garbage

LGTM=rsc, dvyukov
R=rsc, dvyukov
CC=golang-codereviews
https://golang.org/cl/157810043

10 years agocrypto/x509: continue to recognise MaxPathLen of zero as "no value".
Adam Langley [Tue, 14 Oct 2014 01:35:53 +0000 (18:35 -0700)]
crypto/x509: continue to recognise MaxPathLen of zero as "no value".

In [1] the behaviour of encoding/asn1 with respect to marshaling
optional integers was changed. Previously, a zero valued integer would
be omitted when marshaling. After the change, if a default value was
set then the integer would only be omitted if it was the default value.

This changed the behaviour of crypto/x509 because
Certificate.MaxPathLen has a default value of -1 and thus zero valued
MaxPathLens would no longer be omitted when marshaling. This is
arguably a bug-fix -- a value of zero for MaxPathLen is valid and
meaningful and now could be expressed. However it broke users
(including Docker) who were not setting MaxPathLen at all.

This change again causes a zero-valued MaxPathLen to be omitted and
introduces a ZeroMathPathLen member that indicates that, yes, one
really does want a zero. This is ugly, but we value not breaking users.

[1] https://code.google.com/p/go/source/detail?r=4218b3544610e8d9771b89126553177e32687adf

LGTM=rsc
R=rsc
CC=golang-codereviews, golang-dev
https://golang.org/cl/153420045

10 years agomath/big: Fixes issue 8920
Casey Marshall [Mon, 13 Oct 2014 19:41:14 +0000 (12:41 -0700)]
math/big: Fixes issue 8920

(*Rat).SetString checks for denominator.

LGTM=gri
R=golang-codereviews, gri
CC=golang-codereviews
https://golang.org/cl/159760043

10 years agotest: add test for gccgo-specific issue 8079
Chris Manghane [Mon, 13 Oct 2014 19:33:45 +0000 (12:33 -0700)]
test: add test for gccgo-specific issue 8079

LGTM=gri
R=gri
CC=golang-codereviews, iant
https://golang.org/cl/159850044

10 years agoos: handle 'no parent' error as IsNotExist on Plan 9
David du Colombier [Mon, 13 Oct 2014 18:39:46 +0000 (20:39 +0200)]
os: handle 'no parent' error as IsNotExist on Plan 9

This error is returned by lib9p when removing a file
without parent. It should fix TestRemoveAllRace
when running on ramfs.

LGTM=bradfitz, aram
R=rsc, bradfitz, aram
CC=golang-codereviews, mischief
https://golang.org/cl/153410044

10 years agonet/rpc: fix mutex comment
Rob Pike [Mon, 13 Oct 2014 17:27:51 +0000 (10:27 -0700)]
net/rpc: fix mutex comment
Fixes #8086.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/153420044

10 years agoreflect: generated unrolled GC bitmask directly
Ian Lance Taylor [Mon, 13 Oct 2014 17:01:34 +0000 (10:01 -0700)]
reflect: generated unrolled GC bitmask directly

The code for a generated type is already generating an
unrolled GC bitmask.  Rather than unrolling the the source
type bitmasks and copying them, just generate the required
bitmask directly.  Don't mark it as an unrolled GC program,
since there is no need to do so.

Fixes #8917.

LGTM=rsc
R=dvyukov, rsc
CC=golang-codereviews
https://golang.org/cl/156930044

10 years agogo1.4: add note about change to bufio.SplitFunc at EOF
Ian Lance Taylor [Sun, 12 Oct 2014 18:41:55 +0000 (11:41 -0700)]
go1.4: add note about change to bufio.SplitFunc at EOF

CC=golang-codereviews
https://golang.org/cl/159800044