]> Cypherpunks repositories - gostls13.git/log
gostls13.git
10 years agocmd/dist: another attempt at textflag.h
Russ Cox [Fri, 5 Sep 2014 01:56:11 +0000 (21:56 -0400)]
cmd/dist: another attempt at textflag.h

The old change worked fine in my client, but my client
must not have been in a completely clean state.

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

10 years agocmd/dist: make textflag.h available in runtime, avoid android/linux conflicts
Russ Cox [Fri, 5 Sep 2014 01:22:18 +0000 (21:22 -0400)]
cmd/dist: make textflag.h available in runtime, avoid android/linux conflicts

1) cmd/dist was copying textflag.h to the build include directory,
but only after compiling package runtime. So other packages could
use it, just not runtime. Copy earlier, so that runtime can use it too.

2) We decided for android that anything marked linux is also included
in the build. The generated linux-specific files in cmd/dist must therefore
have explicit +build !android tags, or else you can't have simultaneous
linux/arm and android/arm builds in a single client. The tag was already
there for at least one file, but it was missing from many others.

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

10 years agoruntime: mark sysAlloc nosplit
Russ Cox [Fri, 5 Sep 2014 01:12:48 +0000 (21:12 -0400)]
runtime: mark sysAlloc nosplit

sysAlloc is the only mem function called from Go.

LGTM=iant, khr
R=golang-codereviews, khr, 0intro, iant
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139210043

10 years agoruntime: more C to Go conversion adjustments
Russ Cox [Fri, 5 Sep 2014 01:12:31 +0000 (21:12 -0400)]
runtime: more C to Go conversion adjustments

Mostly NOSPLIT additions.
Had to rewrite atomic_arm.c in Go because it calls lock,
and lock is too complex.

With this CL, I find no Go -> C calls that can split the stack
on any system except Solaris and Windows.

Solaris and Windows need more work and will be done separately.

LGTM=iant, dave
R=golang-codereviews, bradfitz, iant, dave
CC=dvyukov, golang-codereviews, khr, r
https://golang.org/cl/137160043

10 years agocmd/api: don't depend on os/user or USER to check api
Brad Fitzpatrick [Fri, 5 Sep 2014 00:13:22 +0000 (17:13 -0700)]
cmd/api: don't depend on os/user or USER to check api

The -nocgo builder failed because it has cgo disabled
as well as no USER environment variable:
http://build.golang.org/log/2250abb82f5022b72a12997b8ff89fcdeff094c9

# Checking API compatibility.
Error getting current user: user: Current not implemented on linux/amd64
exit status 1

Don't require the environment variable here.

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

10 years agogo/parser: fix "zero day" parse error
Robert Griesemer [Thu, 4 Sep 2014 22:18:32 +0000 (15:18 -0700)]
go/parser: fix "zero day" parse error

(a b string, ok bool) is not a valid signature

Fixes #8656.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/137140043

10 years agoruntime: make more functions safe for Go
Russ Cox [Thu, 4 Sep 2014 19:53:45 +0000 (15:53 -0400)]
runtime: make more functions safe for Go

Convert no-op race functions.
Everything else is tiny and gets NOSPLITs.

After this, all that is left on darwin is sysAlloc, panic, and gothrow (all pending).
There may be system-specific calls in other builds.

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

10 years agoruntime: convert cgocall to Go
Dmitriy Vyukov [Thu, 4 Sep 2014 18:40:40 +0000 (14:40 -0400)]
runtime: convert cgocall to Go

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

10 years agoruntime: use C for readgstatus, goroutine status values
Russ Cox [Thu, 4 Sep 2014 18:19:50 +0000 (14:19 -0400)]
runtime: use C for readgstatus, goroutine status values

When this code was written, there was no way for Go to
reuse the C function and enum values. Now there is.

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

10 years agoruntime: reconvert sigqueue.goc from C to Go
Russ Cox [Thu, 4 Sep 2014 17:51:12 +0000 (13:51 -0400)]
runtime: reconvert sigqueue.goc from C to Go

The original conversion in CL 132090043 cut up
the function in an attempt to avoid converting most
of the code to Go. This contorts the control flow.

While debugging the onM signal stack bug,
I reconverted sigqueue.goc in its entirety.
This restores the original control flow, which is
much easier to understand.

The current conversion is correct, it's just complex
and will be hard to maintain. The new one is as
readable as the original code.

I uploaded sigqueue.goc as the initial copy of
sigqueue.go in the CL, so if you view the diffs
of sigqueue.go comparing against patch set 2 [sic]
it will show the actual starting point.

For example:
https://golang.org/cl/136160043/diff2/20001:60001/src/pkg/runtime/sigqueue.go

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

10 years agogo/parser: initialize file set even in only some tests are run
Robert Griesemer [Thu, 4 Sep 2014 17:43:03 +0000 (10:43 -0700)]
go/parser: initialize file set even in only some tests are run

Without this fix, some tests crashed (e.g. go test -run Invalid).

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/133580043

10 years agoandroidtest.bash: drop noisy adb sync output
David Crawshaw [Thu, 4 Sep 2014 17:39:51 +0000 (13:39 -0400)]
androidtest.bash: drop noisy adb sync output

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

10 years agoruntime: fix solaris netpoll
Dmitriy Vyukov [Thu, 4 Sep 2014 07:34:01 +0000 (11:34 +0400)]
runtime: fix solaris netpoll

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

10 years agoruntime: fix netbsd build
Dmitriy Vyukov [Thu, 4 Sep 2014 07:31:39 +0000 (11:31 +0400)]
runtime: fix netbsd build

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

10 years agoruntime: fix typos
Mikio Hara [Thu, 4 Sep 2014 07:23:37 +0000 (16:23 +0900)]
runtime: fix typos

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

10 years agoruntime: fix Plan 9 build
David du Colombier [Thu, 4 Sep 2014 06:36:18 +0000 (08:36 +0200)]
runtime: fix Plan 9 build

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

10 years agoruntime: fix arm build
Dmitriy Vyukov [Thu, 4 Sep 2014 06:16:57 +0000 (10:16 +0400)]
runtime: fix arm build

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

10 years agoruntime: convert netpoll to Go
Dmitriy Vyukov [Thu, 4 Sep 2014 06:04:04 +0000 (10:04 +0400)]
runtime: convert netpoll to Go
The common code is converted, epoll and kqueue are converted.
Windows and solaris are still C.

LGTM=rsc
R=golang-codereviews, rsc, dave
CC=golang-codereviews, iant, khr, rsc
https://golang.org/cl/132910043

10 years agoruntime: fix nacl/amd64p32 build
Russ Cox [Thu, 4 Sep 2014 05:58:31 +0000 (01:58 -0400)]
runtime: fix nacl/amd64p32 build

BP is not a legal register on nacl.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/140980043

10 years agoruntime: fix int64 reconstruction in semasleep
Russ Cox [Thu, 4 Sep 2014 05:38:49 +0000 (01:38 -0400)]
runtime: fix int64 reconstruction in semasleep

I had this right in one of my clients, but apparently not the one I submitted from.

Fixes 386 builds.

TBR=dfc
CC=golang-codereviews
https://golang.org/cl/138000045

10 years agoruntime: fix onM test for curg on arm
Russ Cox [Thu, 4 Sep 2014 05:05:32 +0000 (01:05 -0400)]
runtime: fix onM test for curg on arm

TBR=iant
CC=golang-codereviews
https://golang.org/cl/137130043

10 years agoruntime: fix sigtrampPC on Windows
Russ Cox [Thu, 4 Sep 2014 04:54:37 +0000 (00:54 -0400)]
runtime: fix sigtrampPC on Windows

The arm5 build breakage at CL 139110043 was caused by
calling funcPC on a lessstack defined as a struct{}.
That symbol ended up with a non-4-aligned address,
which caused the memory fault that broke the builders.
The definition of lessstack was fixed in CL 140880043.

Tracking that down suggested that it would be worth
looking for the same bug elsewhere in the directory.
This is the only one I found.

LGTM=bradfitz
R=golang-codereviews, dave, bradfitz
CC=dvyukov, golang-codereviews, iant, khr, r
https://golang.org/cl/134410043

10 years agoruntime: correct various Go -> C function calls
Russ Cox [Thu, 4 Sep 2014 04:54:06 +0000 (00:54 -0400)]
runtime: correct various Go -> C function calls

Some things get converted.
Other things (too complex or too many C deps) get onM calls.
Other things (too simple) get #pragma textflag NOSPLIT.

After this CL, the offending function list is basically:
        - panic.c
        - netpoll.goc
        - mem*.c
        - race stuff
        - readgstatus
        - entersyscall/exitsyscall

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

10 years agoruntime: reject onM calls from gsignal stack
Russ Cox [Thu, 4 Sep 2014 04:10:10 +0000 (00:10 -0400)]
runtime: reject onM calls from gsignal stack

The implementation and use patterns of onM assume
that they run on either the m->curg or m->g0 stack.

Calling onM from m->gsignal has two problems:

(1) When not on g0, onM switches to g0 and then "back" to curg.
If we didn't start at curg, bad things happen.

(2) The use of scalararg/ptrarg to pass C arguments and results
assumes that there is only one onM call at a time.
If a gsignal starts running, it may have interrupted the
setup/teardown of the args for an onM on the curg or g0 stack.
Using scalararg/ptrarg itself would smash those.

We can fix (1) by remembering what g was running before the switch.

We can fix (2) by requiring that uses of onM that might happen
on a signal handling stack must save the old scalararg/ptrarg
and restore them after the call, instead of zeroing them.
The only sane way to do this is to introduce a separate
onM_signalsafe that omits the signal check, and then if you
see a call to onM_signalsafe you know the surrounding code
must preserve the old scalararg/ptrarg values.
(The implementation would be that onM_signalsafe just calls
fn if on the signal stack or else jumps to onM. It's not necessary
to have two whole copies of the function.)

(2) is not a problem if the caller and callee are both Go and
a closure is used instead of the scalararg/ptrarg slots.

For now, I think we can avoid calling onM from code executing
on gsignal stacks, so just reject it.

In the long term, (2) goes away (as do the scalararg/ptrarg slots)
once everything is in Go, and at that point fixing (1) would be
trivial and maybe worth doing just for regularity.

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

10 years agoruntime: refactor/fix asmcgocall/asmcgocall_errno
Russ Cox [Thu, 4 Sep 2014 04:01:55 +0000 (00:01 -0400)]
runtime: refactor/fix asmcgocall/asmcgocall_errno

Instead of making asmcgocall call asmcgocall_errno,
make both load args into registers and call a shared
assembly function.

On amd64, this costs 1 word in the asmcgocall_errno path
but saves 3 words in the asmcgocall path, and the latter
is what happens on critical nosplit paths on Windows.

On arm, this fixes build failures: asmcgocall was writing
the arguments for asmcgocall_errno into the wrong
place on the stack. Passing them in registers avoids the
decision entirely.

On 386, this isn't really needed, since the nosplit paths
have twice as many words to work with, but do it for consistency.

Update #8635
Fixes arm build (except GOARM=5).

TBR=iant
CC=golang-codereviews
https://golang.org/cl/134390043

10 years agonet: fix parsing literal IPv6 address with zone identifier in builtin dns stub resolver
Mikio Hara [Thu, 4 Sep 2014 03:53:51 +0000 (12:53 +0900)]
net: fix parsing literal IPv6 address with zone identifier in builtin dns stub resolver

Fixes #8619.

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

10 years agoruntime: give 2 words back in notetsleep_internal
Russ Cox [Thu, 4 Sep 2014 03:10:15 +0000 (23:10 -0400)]
runtime: give 2 words back in notetsleep_internal

I really hoped we could avoid this nonsense, but it appears not.

Should fix windows/amd64 build breakage.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/137120043

10 years agonet: fix parsing literal IP address in builtin dns stub resolver
Mikio Hara [Thu, 4 Sep 2014 01:00:30 +0000 (10:00 +0900)]
net: fix parsing literal IP address in builtin dns stub resolver

This CL fixes a bug introduced by CL 128820043 which is that
builtin dns stub resolver doesn't work well with literal IPv6
address namesever entries in /etc/resolv.conf.

Also simplifies resolv.conf parser and adds more test cases.

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

10 years agotext/template: 0xef is an integer, not a floating-point value.
Rob Pike [Wed, 3 Sep 2014 22:57:03 +0000 (15:57 -0700)]
text/template: 0xef is an integer, not a floating-point value.
The discriminator in the execution engine was stupid.
Add a test to the parse package too. The problem wasn't there
but the particular case ('e' in a hex integer) was not covered.

Fixes #8622.

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

10 years agoruntime: make entersyscall/exitsyscall safe for stack splits
Russ Cox [Wed, 3 Sep 2014 21:42:35 +0000 (17:42 -0400)]
runtime: make entersyscall/exitsyscall safe for stack splits

It is fundamentally unsafe to grow the stack once someone
has made a call to syscall.Syscall. That function takes 6 uintptr
arguments, but depending on the call some are pointers.
In fact, some might be pointers to stack values, and we don't know which.
That makes it impossible to copy the stack somewhere else.
Since we want to delete all the stack splitting code, relying only
on stack copying, make sure that Syscall never needs to split the stack.

The only thing Syscall does is:
        call entersyscall
        make the system call
        call exitsyscall

As long as we make sure that entersyscall and exitsyscall
can live in the nosplit region, they won't ask for more stack.

Do this by making entersyscall and exitsyscall set up the
stack guard so that any call to a function with a split check
will cause a crash. Then move non-essential slow-path
work onto the m stack using onM and mark the rest of the
work nosplit. The linker will verify that the chain of nosplits
fits in the total nosplit budget.

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

10 years agospec: Add link to rune literals from string literals when talking about escape sequences.
Robin Eklind [Wed, 3 Sep 2014 17:44:33 +0000 (10:44 -0700)]
spec: Add link to rune literals from string literals when talking about escape sequences.

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

10 years agoruntime: convert symtab.c into symtab.go
Russ Cox [Wed, 3 Sep 2014 17:02:48 +0000 (13:02 -0400)]
runtime: convert symtab.c into symtab.go

Because symtab.c was partially converted before,
the diffs are not terribly useful.

The earlier conversion was trying to refactor or
clean up the code in addition to doing the translation.
It also made a mistake by redefining Func to be something
users could overwrite.

I undid those changes, making symtab.go a more
literal line-for-line translation of symtab.c instead.

LGTM=josharian
R=golang-codereviews, dave, bradfitz, josharian
CC=golang-codereviews, iant, khr, r
https://golang.org/cl/140880043

10 years agoruntime: relax flaky GC pause test
Brad Fitzpatrick [Wed, 3 Sep 2014 16:54:53 +0000 (09:54 -0700)]
runtime: relax flaky GC pause test

We often saw GC pauses of 0 ns, not just on Windows.
Google Compute Engine timer granularity might suck
too.

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

10 years agoruntime: remove guard against uninitialized forcegc.g
Russ Cox [Wed, 3 Sep 2014 16:48:32 +0000 (12:48 -0400)]
runtime: remove guard against uninitialized forcegc.g

The race was in the old C code.
The new Go code does not have the race
and does not need the check.

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

10 years agoruntime: adopt race detector for runtime written in Go
Dmitriy Vyukov [Wed, 3 Sep 2014 16:47:30 +0000 (20:47 +0400)]
runtime: adopt race detector for runtime written in Go
Ignore memory access on g0/gsignal.
See the issue for context and explanation.
Fixes #8627.

LGTM=khr
R=golang-codereviews, mdempsky, khr
CC=golang-codereviews, rsc
https://golang.org/cl/137070043

10 years agoruntime: Start and stop individual goroutines at gc safepoints
Rick Hudson [Wed, 3 Sep 2014 16:06:36 +0000 (12:06 -0400)]
runtime: Start and stop individual goroutines at gc safepoints

Code to bring goroutines to a gc safepoint one at a time,
do some work such as scanning, and restart the
goroutine, and then move on to the next goroutine.
Currently this code does not do much useful work
but this infrastructure will be critical to future
concurrent GC work.

Fixed comments reviewers.

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

10 years agoruntime: deferproc/deferreturn in Go
Keith Randall [Wed, 3 Sep 2014 15:49:43 +0000 (08:49 -0700)]
runtime: deferproc/deferreturn in Go

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

10 years agocmd/cgo, runtime: write cgo stub wrappers in Go, not C
Russ Cox [Wed, 3 Sep 2014 15:36:14 +0000 (11:36 -0400)]
cmd/cgo, runtime: write cgo stub wrappers in Go, not C

LGTM=alex.brainman, iant
R=golang-codereviews, alex.brainman, iant
CC=dvyukov, golang-codereviews, khr, r
https://golang.org/cl/139070043

10 years agoruntime: make onM and mcall take Go func values
Russ Cox [Wed, 3 Sep 2014 15:35:22 +0000 (11:35 -0400)]
runtime: make onM and mcall take Go func values

This gives them correct types in Go and also makes it
possible to use them to run Go code on an m stack.

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

10 years agoruntime: convert a few traceback-related functions from proc.c to traceback.go
Russ Cox [Wed, 3 Sep 2014 15:11:16 +0000 (11:11 -0400)]
runtime: convert a few traceback-related functions from proc.c to traceback.go

They were in proc.c mainly because there was no portable
traceback source file. As part of converting them to Go,
move to traceback.go.

In order to get access to the PC of _rt0_go,
rename to runtime.rt0_go.

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

10 years agoruntime: introduce, use funcPC to convert Go func to PC
Russ Cox [Wed, 3 Sep 2014 15:10:38 +0000 (11:10 -0400)]
runtime: introduce, use funcPC to convert Go func to PC

This removes the ** unsafe hack.

Real bug fixed at chan.go:101.

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

10 years agoruntime: increase windows prof thread priority sooner
Alex Brainman [Wed, 3 Sep 2014 04:17:04 +0000 (14:17 +1000)]
runtime: increase windows prof thread priority sooner

If system is busy burning cpu, it takes long time (about 300ms on
windows builders) to adjust prof thread priority. Once adjusted, prof
thread runs ahead of everyone else, but due to initial slowness, it
does not capture prof snapshots until start-up period is completed.

Change prof thread priority sooner, so it can start captures straight
away.

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

10 years agoruntime: avoid race with forcegc helper
Russ Cox [Tue, 2 Sep 2014 23:18:46 +0000 (19:18 -0400)]
runtime: avoid race with forcegc helper

While we are here, give the gc helper a real function name
that will appear in stack traces.

LGTM=rlh
R=rlh
CC=dvyukov, golang-codereviews
https://golang.org/cl/133470043

10 years agoruntime: don't allocate a new string in snprintf
David du Colombier [Tue, 2 Sep 2014 22:56:50 +0000 (00:56 +0200)]
runtime: don't allocate a new string in snprintf

This fixes the Plan 9 build.

Fix issue 8621.

LGTM=iant
R=rsc, mattn.jp, iant
CC=golang-codereviews
https://golang.org/cl/135280043

10 years agoruntime: handle empty environment variables on Plan 9
David du Colombier [Tue, 2 Sep 2014 22:56:31 +0000 (00:56 +0200)]
runtime: handle empty environment variables on Plan 9

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

10 years agoruntime: unify fastrand1 and fastrand2
Keith Randall [Tue, 2 Sep 2014 21:33:33 +0000 (14:33 -0700)]
runtime: unify fastrand1 and fastrand2

C and Go calling conventions are now compatible, so we
don't need two versions of this function.

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

10 years agoruntime: convert select implementation to Go.
Keith Randall [Tue, 2 Sep 2014 21:13:29 +0000 (14:13 -0700)]
runtime: convert select implementation to Go.

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

10 years agocrypto: Add SHA3 functions in go.crypto/sha3 to the Hash enum.
David Leon Gil [Tue, 2 Sep 2014 19:23:49 +0000 (12:23 -0700)]
crypto: Add SHA3 functions in go.crypto/sha3 to the Hash enum.

Reverse dependency of https://golang.org/cl/130950043/

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

10 years agoA+C: David Leon Gil (individual CLA)
Adam Langley [Tue, 2 Sep 2014 19:22:57 +0000 (12:22 -0700)]
A+C: David Leon Gil (individual CLA)

Generated by a+c.

R=gobot
CC=golang-codereviews
https://golang.org/cl/134330043

10 years agoruntime: convert traceback*.c to Go
Russ Cox [Tue, 2 Sep 2014 19:12:53 +0000 (15:12 -0400)]
runtime: convert traceback*.c to Go

The two converted files were nearly identical.
Instead of continuing that duplication, I merged them
into a single traceback.go.

Tested on arm, amd64, amd64p32, and 386.

LGTM=r
R=golang-codereviews, remyoudompheng, dave, r
CC=dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/134200044

10 years agocmd/gc: fix runtime print(hex(x))
Russ Cox [Tue, 2 Sep 2014 18:36:25 +0000 (14:36 -0400)]
cmd/gc: fix runtime print(hex(x))

The code I wrote originally works for trivial functions
that are inlined at a call site in another package,
because that was how I wrote my local test.
Make hex(x) work for non-inlinable functions too.

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

10 years agoruntime: move reflect trampolines into thunk file.
Keith Randall [Tue, 2 Sep 2014 17:07:02 +0000 (10:07 -0700)]
runtime: move reflect trampolines into thunk file.

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

10 years agodatabase/sql: Avoid re-preparing statements when all connections are busy
Marko Tiikkaja [Tue, 2 Sep 2014 16:08:41 +0000 (09:08 -0700)]
database/sql: Avoid re-preparing statements when all connections are busy

Previously, if all connections were busy, we would always
re-prepare the statement on the connection we were assigned from
the pool.  That meant that if all connections were busy most of the
time, the number of prepared statements for each connection would
keep increasing over time.

Instead, after getting a free connection, check to see if the
statement has already been prepared on it, and reuse the statement
handle if so.

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

10 years agoruntime: convert clearpools/registerPoolCleanup to Go
Dmitriy Vyukov [Tue, 2 Sep 2014 16:03:48 +0000 (20:03 +0400)]
runtime: convert clearpools/registerPoolCleanup to Go

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

10 years agoruntime: convert cpuprof from C to Go
Matthew Dempsky [Tue, 2 Sep 2014 04:14:22 +0000 (00:14 -0400)]
runtime: convert cpuprof from C to Go

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

10 years agoruntime/pprof: adjust cpuHogger so that tests pass on windows builders
Alex Brainman [Tue, 2 Sep 2014 03:06:22 +0000 (23:06 -0400)]
runtime/pprof: adjust cpuHogger so that tests pass on windows builders

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

10 years agoruntime: fix gogetenv on Plan 9
David du Colombier [Tue, 2 Sep 2014 03:03:26 +0000 (23:03 -0400)]
runtime: fix gogetenv on Plan 9

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

10 years agoruntime: fix race detector running Go code on g0 of non-main thread
Russ Cox [Tue, 2 Sep 2014 01:55:57 +0000 (21:55 -0400)]
runtime: fix race detector running Go code on g0 of non-main thread

It looks like this has just always been broken:
the race detector handles running Go code on g0 of the main thread
and on g0 of any extra threads created by non-Go code, but it does
not handle running Go code on g0 of non-main threads created by Go.
Handle that.

Should fix the race build failures on the dashboard.

We're running into this now because we are running more
and more Go code on g0.

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

10 years agotime: update generated zoneinfo_abbrs_windows.go
Alex Brainman [Tue, 2 Sep 2014 01:54:24 +0000 (11:54 +1000)]
time: update generated zoneinfo_abbrs_windows.go

The file in repo has been updated recently, but all these changes
are gone off the web site now. It seems web site gets updated once
in a while, so we'll update our file occasionally.

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

10 years agoruntime: fix Stack
Russ Cox [Mon, 1 Sep 2014 23:42:22 +0000 (19:42 -0400)]
runtime: fix Stack

Fixes #8626.

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

10 years agoruntime: convert mprof.goc to mprof.go
Russ Cox [Mon, 1 Sep 2014 22:51:12 +0000 (18:51 -0400)]
runtime: convert mprof.goc to mprof.go

The exported Go definitions appearing in mprof.go are
copied verbatim from debug.go.

The unexported Go funcs and types are new.
The C Bucket type used a union and was not a line-for-line translation.

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

10 years agoruntime: fix windows build
Russ Cox [Mon, 1 Sep 2014 21:36:45 +0000 (17:36 -0400)]
runtime: fix windows build

#ifdef'ed out code wasn't updated for argp change.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/139040043

10 years agoruntime: change concatstring panic to gothrow
Russ Cox [Mon, 1 Sep 2014 21:25:26 +0000 (17:25 -0400)]
runtime: change concatstring panic to gothrow

It was a throw originally; it was converted incorrectly.

LGTM=dave
R=khr, dave
CC=golang-codereviews
https://golang.org/cl/139000043

10 years agoruntime: include os_*.h in the generated Go structs
Russ Cox [Mon, 1 Sep 2014 21:25:10 +0000 (17:25 -0400)]
runtime: include os_*.h in the generated Go structs

Adding the #include to defs.c makes it get processed
by cmd/dist, which writes out Go equivalent for all the
C data structures defined in defs.c.

This in turn makes it necessary to define the Plink type,
used in os_plan9.h, in os_plan9.go. Rename it to _Plink
to avoid being exported.

LGTM=0intro, iant
R=golang-codereviews, iant, 0intro
CC=golang-codereviews, r
https://golang.org/cl/132490043

10 years agoruntime: change PC, SP values in Stkframe, Panic, Defer from byte* to uintptr
Russ Cox [Mon, 1 Sep 2014 14:05:16 +0000 (10:05 -0400)]
runtime: change PC, SP values in Stkframe, Panic, Defer from byte* to uintptr

uintptr is better when translating to Go,
and in a few places it's better in C too.

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

10 years agoruntime/race: better handling of atomic operations
Dmitriy Vyukov [Mon, 1 Sep 2014 12:04:33 +0000 (08:04 -0400)]
runtime/race: better handling of atomic operations
This change fixes the last known false negative of the race detector --
detection of races between mutating atomic operations and non-atomic operations.
Race runtime already has functions for precise modelling of various atomic operations,
so this change just forwards all atomic ops to race runtime
instead of poor man modeling in sync/atomic package.
Performance is also improved -- full sync/atomic tests run in 60s instead of 85s now.

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

10 years agostrings: use Rabin-Karp algorithm for LastIndex.
Rui Ueyama [Mon, 1 Sep 2014 07:47:57 +0000 (17:47 +1000)]
strings: use Rabin-Karp algorithm for LastIndex.

benchmark                  old ns/op     new ns/op     delta
BenchmarkSingleMatch       49443         52275         +5.73%
BenchmarkIndex             28.8          27.4          -4.86%
BenchmarkLastIndex         14.5          14.0          -3.45%
BenchmarkLastIndexHard1    3982782       2309200       -42.02%
BenchmarkLastIndexHard2    3985562       2287715       -42.60%
BenchmarkLastIndexHard3    3555259       2282866       -35.79%

LGTM=josharian, nigeltao
R=golang-codereviews, ality, josharian, bradfitz, dave, nigeltao, gobot, nightlyone
CC=golang-codereviews
https://golang.org/cl/102560043

10 years agoruntime: remove old malloc test programs
Russ Cox [Mon, 1 Sep 2014 04:40:28 +0000 (00:40 -0400)]
runtime: remove old malloc test programs

These haven't been run in ages.

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

10 years agoarchive/zip: add Writer.Flush
Brad Fitzpatrick [Mon, 1 Sep 2014 04:32:13 +0000 (21:32 -0700)]
archive/zip: add Writer.Flush

This is needed for callers to be able to keep track of the
writing position within a zip file. Otherwise it's not
possible to compute the size of headers, and the TOC isn't
written until the very end.

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

10 years agoruntime: paste mprof.goc into mprof.go as comments
Russ Cox [Mon, 1 Sep 2014 04:06:26 +0000 (00:06 -0400)]
runtime: paste mprof.goc into mprof.go as comments

NO CODE CHANGES HERE

The first conversion was not complete.
This CL doesn't make any actual changes,
but it inserts the missing mprof.goc code
as comments so that the next CL will have
useful diffs.

To make the diffs a bit more useful, removed
all semicolons, ->, and runtime· prefixes as well.

Also corrected order of a few functions in mprof.go
to match original order in mprof.goc.

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

10 years agomisc/cgo/testcdefs: comment out test of packed structs
Ian Lance Taylor [Mon, 1 Sep 2014 02:59:43 +0000 (22:59 -0400)]
misc/cgo/testcdefs: comment out test of packed structs

The [568]c compilers no longer support packed structs, so
using them with -cdefs no longer works.  Just commenting out
the test, rather than removing it, in case this needs to be
handled.  It may be that -cdefs can go away entirely in the
future, in which case so can this directory.

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

10 years agocmd/ld: diagnose Go calling C
Russ Cox [Mon, 1 Sep 2014 02:49:14 +0000 (22:49 -0400)]
cmd/ld: diagnose Go calling C

For example:
go build -ldflags -C cmd/go 2>&1 | awk '{print $NF}' | sort | uniq -c | sort -nr

LGTM=khr
R=khr, josharian
CC=golang-codereviews
https://golang.org/cl/135170044

10 years agonet/http: fix typo in comment
Dmitri Shuralyov [Mon, 1 Sep 2014 02:03:23 +0000 (12:03 +1000)]
net/http: fix typo in comment

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

10 years agoimage/png: make the CompressionLevel constants negative, reserving
Nigel Tao [Mon, 1 Sep 2014 00:02:52 +0000 (10:02 +1000)]
image/png: make the CompressionLevel constants negative, reserving
positive numbers to mean a numeric zlib compression level.

LGTM=bradfitz, ruiu
R=bradfitz, ruiu
CC=golang-codereviews, jeff.allen
https://golang.org/cl/138860043

10 years agoruntime: fix Linux build
Ian Lance Taylor [Sun, 31 Aug 2014 01:15:55 +0000 (18:15 -0700)]
runtime: fix Linux build

Make the definition of the EpollEvent data field consistent
across architectures, adapt the other use of it in
netpoll_epoll for the new definition, and use uint64 rather
than uintptr.

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

10 years agocmd/cc: generate error if #pragma pack off does anything
Russ Cox [Sat, 30 Aug 2014 18:54:09 +0000 (14:54 -0400)]
cmd/cc: generate error if #pragma pack off does anything

We can't translate misaligned things to Go, so start rejecting them in C.

The only one in any build appears to be EpollEvent on linux/amd64.
Fix that.

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

10 years agoruntime: translate env*.c to Go
Russ Cox [Sat, 30 Aug 2014 18:53:47 +0000 (14:53 -0400)]
runtime: translate env*.c to Go

In an earlier CL I wrote a separate Go-only version, but that broke Plan 9,
because the Go-only version assumed a non-Plan 9 system.

Translate the real ones instead.

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

10 years agoruntime/pprof: make CPU profiling tests more robust
Dmitriy Vyukov [Sat, 30 Aug 2014 18:38:54 +0000 (22:38 +0400)]
runtime/pprof: make CPU profiling tests more robust
Under the race detector most of the samples go into race runtime,
because of that freebsd race builder constantly fails on this test.

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

10 years agoruntime: preallocate panic errors for index and slice
Russ Cox [Sat, 30 Aug 2014 18:18:41 +0000 (14:18 -0400)]
runtime: preallocate panic errors for index and slice

This avoids allocating at the panic sites.

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

10 years agoruntime: convert chanrecv to Go
Keith Randall [Sat, 30 Aug 2014 18:03:28 +0000 (11:03 -0700)]
runtime: convert chanrecv to Go

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

10 years agonet/url: make Userinfo.String() escape ? and add test for shouldEscape
Evan Kroske [Sat, 30 Aug 2014 17:34:51 +0000 (10:34 -0700)]
net/url: make Userinfo.String() escape ? and add test for shouldEscape

See RFC 3986 §3.2.1.
Fixes #6573.

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

10 years agogo/doc/headscan: update script to count headings with an ID attribute
Evan Kroske [Sat, 30 Aug 2014 17:27:36 +0000 (10:27 -0700)]
go/doc/headscan: update script to count headings with an ID attribute

Fixes script used to sanity-check the heading-detection heuristic of go/doc.
Fixes #8467.

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

10 years agospec: Fix indentation and remove trailing white space characters.
Robin Eklind [Sat, 30 Aug 2014 17:27:01 +0000 (10:27 -0700)]
spec: Fix indentation and remove trailing white space characters.

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

10 years agoruntime: retry fix openbsd build
Matthew Dempsky [Sat, 30 Aug 2014 06:13:17 +0000 (23:13 -0700)]
runtime: retry fix openbsd build

Tested on linux/amd64 too this time.

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

10 years agonet/http: add BasicAuth method to *http.Request
Kelsey Hightower [Sat, 30 Aug 2014 05:19:30 +0000 (22:19 -0700)]
net/http: add BasicAuth method to *http.Request

The net/http package supports setting the HTTP Authorization header
using the Basic Authentication Scheme as defined in RFC 2617, but does
not provide support for extracting the username and password from an
authenticated request using the Basic Authentication Scheme.

Add BasicAuth method to *http.Request that returns the username and
password from authenticated requests using the Basic Authentication
Scheme.

Fixes #6779.

LGTM=bradfitz
R=golang-codereviews, josharian, bradfitz, alberto.garcia.hierro, blakesgentry
CC=golang-codereviews
https://golang.org/cl/76540043

10 years agoruntime: increase nosplit area to 192
Russ Cox [Sat, 30 Aug 2014 04:56:52 +0000 (00:56 -0400)]
runtime: increase nosplit area to 192

In CL 131450043, which raised it to 160,
I'd raise it to 192 if necessary.
Apparently it is necessary on windows/amd64.

One note for those concerned about the growth:
in the old segmented stack world, we wasted this much
space at the bottom of every stack segment.
In the new contiguous stack world, each goroutine has
only one stack segment, so we only waste this much space
once per goroutine. So even raising the limit further might
still be a net savings.

Fixes windows/amd64 build.

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

10 years agoruntime: rename SysAlloc to sysAlloc for Go
Russ Cox [Sat, 30 Aug 2014 04:54:40 +0000 (00:54 -0400)]
runtime: rename SysAlloc to sysAlloc for Go

Renaming the C SysAlloc will let Go define a prototype without exporting it.
For use in cpuprof.goc's translation to Go.

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

10 years agoruntime: convert type algorithms to Go
Dmitriy Vyukov [Sat, 30 Aug 2014 04:40:56 +0000 (08:40 +0400)]
runtime: convert type algorithms to Go
Actually it mostly deletes code -- alg.print and alg.copy go away.
There was only one usage of alg.print for debug purposes.
Alg.copy is used in chan.goc, but Keith replaces them with
memcopy during conversion, so alg.copy is not needed as well.
Converting them would be significant amount of work
for no visible benefit.

LGTM=crawshaw, rsc, khr
R=golang-codereviews, crawshaw, khr
CC=golang-codereviews, rsc
https://golang.org/cl/139930044

10 years agoundo CL 135230043 / 60812bad3769
Russ Cox [Sat, 30 Aug 2014 04:16:07 +0000 (00:16 -0400)]
undo CL 135230043 / 60812bad3769

broke api check everywhere

««« original CL description
runtime: fix openbsd build

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

»»»

TBR=mdempsky
CC=golang-codereviews
https://golang.org/cl/137010043

10 years agonet: implement query-response fast failover in builtin dns stub resolver
Alex A Skinner [Sat, 30 Aug 2014 04:12:28 +0000 (13:12 +0900)]
net: implement query-response fast failover in builtin dns stub resolver

Speed improvements via code cleanup, and changes to make go dns behave more like glibc resolver.  See https://groups.google.com/forum/#!topic/golang-dev/lV-0aHqxVeo

Fixes #6579.

Benchmark results on linux/amd64

benchmark                                  old ns/op    new ns/op    delta
BenchmarkGoLookupIP                          4831903      2572937  -46.75%
BenchmarkGoLookupIPNoSuchHost               10114105      2419641  -76.08%
BenchmarkGoLookupIPWithBrokenNameServer  20007735624   5004490730  -74.99%

benchmark                                 old allocs   new allocs    delta
BenchmarkGoLookupIP                              287          288    0.35%
BenchmarkGoLookupIPNoSuchHost                    204          102  -50.00%
BenchmarkGoLookupIPWithBrokenNameServer          410          358  -12.68%

benchmark                                  old bytes    new bytes    delta
BenchmarkGoLookupIP                            13181        13271    0.68%
BenchmarkGoLookupIPNoSuchHost                  17260         8714  -49.51%
BenchmarkGoLookupIPWithBrokenNameServer        28160        22432  -20.34%

LGTM=mikioh.mikioh
R=golang-codereviews, mikioh.mikioh, bradfitz, josharian, abursavich
CC=golang-codereviews
https://golang.org/cl/128820043

10 years agoruntime: fix openbsd build
Matthew Dempsky [Sat, 30 Aug 2014 03:51:26 +0000 (20:51 -0700)]
runtime: fix openbsd build

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

10 years agoruntime: rename Sigaltstack to SigaltstackT
Ian Lance Taylor [Fri, 29 Aug 2014 23:11:05 +0000 (16:11 -0700)]
runtime: rename Sigaltstack to SigaltstackT

Avoids a conflict between the type and function sigaltstack.

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

10 years agoundo CL 107150043 / caa2646daa63
Mikio Hara [Fri, 29 Aug 2014 22:52:20 +0000 (07:52 +0900)]
undo CL 107150043 / caa2646daa63

preparing for the syscall package freeze.
the change for issue 8218 is only applied to go.sys/unix.

««« original CL description
syscall: implement setresuid(2) and setresgid(2) on OpenBSD/FreeBSD/DragonflyBSD

Fixes #8218.

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

»»»

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

10 years agonet: ensure identical queries are not sent multiple times in builtin stub resolver
Alex A Skinner [Fri, 29 Aug 2014 22:50:50 +0000 (07:50 +0900)]
net: ensure identical queries are not sent multiple times in builtin stub resolver

Prevents non-rooted queries with > ndots dots from being tried twice on error.
Fixes #8616.

Benchmark results on linux/amd64
benchmark                        old ns/op    new ns/op    delta
BenchmarkGoLookupIPNoSuchHost      8212394      4413293  -46.26%

benchmark                       old allocs   new allocs    delta
BenchmarkGoLookupIPNoSuchHost          216          108  -50.00%

benchmark                        old bytes    new bytes    delta
BenchmarkGoLookupIPNoSuchHost        17460         8726  -50.02%

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

10 years agoruntime: make allp a static array
Russ Cox [Fri, 29 Aug 2014 20:41:08 +0000 (16:41 -0400)]
runtime: make allp a static array

It is anyway, just an allocated one.
Giving it a sized type makes Go access nicer.

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

10 years agoruntime: convert lock*.c to Go
Russ Cox [Fri, 29 Aug 2014 20:20:48 +0000 (16:20 -0400)]
runtime: convert lock*.c to Go

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

10 years agoruntime: include constants and defs_*_*.h types in generated Go defs
Russ Cox [Fri, 29 Aug 2014 20:00:31 +0000 (16:00 -0400)]
runtime: include constants and defs_*_*.h types in generated Go defs

I had to rename Kevent and Sigaction to avoid the functions of the
same (lowercase) name.

LGTM=iant, r
R=golang-codereviews, r, iant, aram.h
CC=dvyukov, golang-codereviews, khr
https://golang.org/cl/140740043

10 years agocrypto: add Signer
Adam Langley [Fri, 29 Aug 2014 19:36:30 +0000 (12:36 -0700)]
crypto: add 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 interfaces for representing them and
alters crypto/tls so that client certificates can use
opaque keys.

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

10 years agotext/template/parse: restore pointer-only receivers for Type on Dot and Nil
Rob Pike [Fri, 29 Aug 2014 17:40:45 +0000 (10:40 -0700)]
text/template/parse: restore pointer-only receivers for Type on Dot and Nil
Needless except that the api tool complains. We could fix that issue instead.

TBR=bradfitz
R=golang-codereviews
CC=golang-codereviews
https://golang.org/cl/133290043

10 years agoruntime: run runtime.init
Russ Cox [Fri, 29 Aug 2014 17:22:31 +0000 (13:22 -0400)]
runtime: run runtime.init

Run it right before main.init.
There is still some runtime initialization that
happens before runtime.init, and some of that
may call into Go code (for example to acquire locks)
so this timing is not perfect, but I believe it is the
best we can do.

This came up because global variables intialized
to func values are done in the generated init code,
not in the linker.

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