]> Cypherpunks repositories - gostls13.git/log
gostls13.git
10 years agoruntime: add comment
Dmitriy Vyukov [Mon, 25 Aug 2014 16:26:32 +0000 (20:26 +0400)]
runtime: add comment
Explain why it's safe to allocate chans with flagNoScan.

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

10 years agoruntime: convert timers to Go
Dmitriy Vyukov [Mon, 25 Aug 2014 16:25:22 +0000 (20:25 +0400)]
runtime: convert timers to Go

LGTM=rsc
R=golang-codereviews, ruiu, rsc, daniel.morsing
CC=golang-codereviews, khr
https://golang.org/cl/123700044

10 years agoruntime: convert async semaphores to Go
Dmitriy Vyukov [Mon, 25 Aug 2014 16:12:26 +0000 (20:12 +0400)]
runtime: convert async semaphores to Go

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

10 years agoruntime: fix plan9 HeapSys accounting
Dmitriy Vyukov [Mon, 25 Aug 2014 14:02:30 +0000 (18:02 +0400)]
runtime: fix plan9 HeapSys accounting

LGTM=0intro
R=0intro
CC=golang-codereviews
https://golang.org/cl/131190043

10 years agoruntime: fix chan alignment on 32 bits
Dmitriy Vyukov [Mon, 25 Aug 2014 13:19:56 +0000 (17:19 +0400)]
runtime: fix chan alignment on 32 bits

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

10 years agocmd/gc: fix order of channel evaluation of receive channels
Russ Cox [Mon, 25 Aug 2014 11:05:45 +0000 (07:05 -0400)]
cmd/gc: fix order of channel evaluation of receive channels

Normally, an expression of the form x.f or *y can be reordered
with function calls and communications.

Select is stricter than normal: each channel expression is evaluated
in source order. If you have case <-x.f and case <-foo(), then if the
evaluation of x.f causes a panic, foo must not have been called.
(This is in contrast to an expression like x.f + foo().)

Enforce this stricter ordering.

Fixes #8336.

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

10 years agoruntime: refactor CPU profiling
Dmitriy Vyukov [Mon, 25 Aug 2014 08:10:24 +0000 (12:10 +0400)]
runtime: refactor CPU profiling
Reduce duration of critical section,
make pcbuf local to function.

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

10 years agoruntime: fix block profile for sync semaphores
Dmitriy Vyukov [Mon, 25 Aug 2014 08:09:42 +0000 (12:09 +0400)]
runtime: fix block profile for sync semaphores
Part of cl/128670043 that got lost during submit.

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

10 years agoruntime: fix block profile for sync semaphores
Dmitriy Vyukov [Mon, 25 Aug 2014 07:56:25 +0000 (11:56 +0400)]
runtime: fix block profile for sync semaphores
And add a test.

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

10 years agoruntime: add fast paths to non-blocking channel operations
Dmitriy Vyukov [Mon, 25 Aug 2014 07:55:42 +0000 (11:55 +0400)]
runtime: add fast paths to non-blocking channel operations
benchmark                      old ns/op     new ns/op     delta
BenchmarkChanNonblocking       27.8          7.80          -71.94%
BenchmarkChanNonblocking-2     79.1          3.94          -95.02%
BenchmarkChanNonblocking-4     71.2          2.04          -97.13%

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

10 years agoruntime: Loosen conditions in TestMemstat in an attempt to fix the nacl/arm build.
Sanjay Menakuru [Mon, 25 Aug 2014 07:29:53 +0000 (11:29 +0400)]
runtime: Loosen conditions in TestMemstat in an attempt to fix the nacl/arm build.

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

10 years agoruntime: convert NewCallback and NewCallbackCDecl to Go
Alex Brainman [Mon, 25 Aug 2014 05:59:13 +0000 (15:59 +1000)]
runtime: convert NewCallback and NewCallbackCDecl to Go

LGTM=khr
R=khr, remyoudompheng
CC=golang-codereviews
https://golang.org/cl/132820043

10 years agoruntime,runtime/debug: Converted some functions from goc to Go.
Sanjay Menakuru [Mon, 25 Aug 2014 03:27:00 +0000 (20:27 -0700)]
runtime,runtime/debug: Converted some functions from goc to Go.

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

10 years agocmd/5g, cmd/6g, cmd/8g: clear Addr node when registerizing
Josh Bleecher Snyder [Mon, 25 Aug 2014 02:07:27 +0000 (19:07 -0700)]
cmd/5g, cmd/6g, cmd/8g: clear Addr node when registerizing

Update #8525

Some temporary variables that were fully registerized nevertheless had stack space allocated for them because the Addrs were still marked as having associated nodes.

Distribution of stack space reserved for temporary variables while running make.bash (6g):

BEFORE

40.89%  7026 allocauto: 0 to 0
 7.83%  1346 allocauto: 0 to 24
 7.22%  1241 allocauto: 0 to 8
 6.30%  1082 allocauto: 0 to 16
 4.96%   853 allocauto: 0 to 56
 4.59%   789 allocauto: 0 to 32
 2.97%   510 allocauto: 0 to 40
 2.32%   399 allocauto: 0 to 48
 2.10%   360 allocauto: 0 to 64
 1.91%   328 allocauto: 0 to 72

AFTER

48.49%  8332 allocauto: 0 to 0
 9.52%  1635 allocauto: 0 to 16
 5.28%   908 allocauto: 0 to 48
 4.80%   824 allocauto: 0 to 32
 4.73%   812 allocauto: 0 to 8
 3.38%   581 allocauto: 0 to 24
 2.35%   404 allocauto: 0 to 40
 2.32%   399 allocauto: 0 to 64
 1.65%   284 allocauto: 0 to 56
 1.34%   230 allocauto: 0 to 72

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

10 years agocmd/gc: fix build
Russ Cox [Mon, 25 Aug 2014 01:26:07 +0000 (21:26 -0400)]
cmd/gc: fix build

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

10 years agocmd/5g, cmd/8g: registerize small structs and arrays
Russ Cox [Mon, 25 Aug 2014 01:16:24 +0000 (21:16 -0400)]
cmd/5g, cmd/8g: registerize small structs and arrays

cmd/6g has been doing this for a long time.

Arrays are still problematic on 5g because the addressing
for t[0] where local var t has type [3]uintptr takes the address of t.
That's issue 8125.

Fixes #8123.

LGTM=josharian
R=josharian, dave
CC=golang-codereviews
https://golang.org/cl/102890046

10 years agocmd/gc: re-enable IfacePointerOnly
Russ Cox [Mon, 25 Aug 2014 00:31:45 +0000 (20:31 -0400)]
cmd/gc: re-enable IfacePointerOnly

CL 130240043 did this but broke ARM, because
it made newErrorCString start allocating, so we rolled
it back in CL 133810043.

CL 133820043 removed that allocation.

Try again.

Fixes #8405.

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

10 years agocmd/link: fix testdata generation
Matthew Dempsky [Mon, 25 Aug 2014 00:31:16 +0000 (20:31 -0400)]
cmd/link: fix testdata generation

Fixes #8494.

LGTM=rsc
R=golang-codereviews, gobot, rsc, evankroske
CC=golang-codereviews
https://golang.org/cl/123040043

10 years agoruntime: remove some overuse of uintptr/unsafe.Pointer
Russ Cox [Mon, 25 Aug 2014 00:28:29 +0000 (20:28 -0400)]
runtime: remove some overuse of uintptr/unsafe.Pointer

Now 'go vet runtime' only shows:

        malloc.go:200: possible misuse of unsafe.Pointer
        malloc.go:214: possible misuse of unsafe.Pointer
        malloc.go:250: possible misuse of unsafe.Pointer
        stubs.go:167: possible misuse of unsafe.Pointer

Those are all unavoidable.

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

10 years agocmd/yacc: remove Makefile and build expr using go generate
Rob Pike [Sun, 24 Aug 2014 18:34:45 +0000 (11:34 -0700)]
cmd/yacc: remove Makefile and build expr using go generate
It now serves as an example for go generate as well as for yacc.

NOTE: Depends on go generate, which is not yet checked in.
This is a proof of concept of the approach.
That is https://golang.org/cl/125580044.

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

10 years agocmd/go: add go generate
Rob Pike [Sun, 24 Aug 2014 18:34:12 +0000 (11:34 -0700)]
cmd/go: add go generate
First cut.

Works well enough to support yacc via
        https://golang.org/cl/125620044.

LGTM=alex.brainman, rsc
R=rsc, alex.brainman
CC=golang-codereviews
https://golang.org/cl/125580044

10 years agodoc/go1.4.txt: go generate
Rob Pike [Sun, 24 Aug 2014 18:33:32 +0000 (11:33 -0700)]
doc/go1.4.txt: go generate

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

10 years agoruntime: fix arm build
Russ Cox [Sun, 24 Aug 2014 18:04:10 +0000 (14:04 -0400)]
runtime: fix arm build

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

10 years agoruntime: convert synchronous semaphores to Go
Dmitriy Vyukov [Sun, 24 Aug 2014 08:41:23 +0000 (12:41 +0400)]
runtime: convert synchronous semaphores to Go

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

10 years agoruntime: convert channel operations to Go, part 1 (chansend1).
Keith Randall [Sun, 24 Aug 2014 08:31:03 +0000 (12:31 +0400)]
runtime: convert channel operations to Go, part 1 (chansend1).

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

10 years agoruntime: fix races on mheap.allspans
Dmitriy Vyukov [Sun, 24 Aug 2014 08:05:07 +0000 (12:05 +0400)]
runtime: fix races on mheap.allspans

This is based on the crash dump provided by Alan
and on mental experiments:

sweep 0 74
fatal error: gc: unswept span
runtime stack:
runtime.throw(0x9df60d)
markroot(0xc208002000, 0x3)
runtime.parfordo(0xc208002000)
runtime.gchelper()

I think that when we moved all stacks into heap,
we introduced a bunch of bad data races. This was later
worsened by parallel stack shrinking.

Observation 1: exitsyscall can allocate a stack from heap at any time (including during STW).
Observation 2: parallel stack shrinking can (surprisingly) grow heap during marking.
Consider that we steadily grow stacks of a number of goroutines from 8K to 16K.
And during GC they all can be shrunk back to 8K. Shrinking will allocate lots of 8K
stacks, and we do not necessary have that many in heap at this moment. So shrinking
can grow heap as well.

Consequence: any access to mheap.allspans in GC (and otherwise) must take heap lock.
This is not true in several places.

Fix this by protecting accesses to mheap.allspans and introducing allspans cache for marking,
similar to what we use for sweeping.

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

10 years agoruntime: cache unrolled GC bitmask
Dmitriy Vyukov [Sun, 24 Aug 2014 08:04:51 +0000 (12:04 +0400)]
runtime: cache unrolled GC bitmask
Cache unrolled GC bitmask for types up to 64/32K on 64/32-bit systems,
this corresponds to up to 4K cached bitmask.
Perf builders say that 2% of time is spent in unrollgcproginplace_m/unrollgcprog1
on http benchmark:
http://goperfd.appspot.com/log/f42045f45bf61a0da53b724a7c8567824a0ad6c9

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

10 years agoruntime: convert sigqueue to Go
Dmitriy Vyukov [Sun, 24 Aug 2014 07:50:37 +0000 (11:50 +0400)]
runtime: convert sigqueue to Go

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

10 years agoruntime: convert parfor to Go
Dmitriy Vyukov [Sun, 24 Aug 2014 07:47:06 +0000 (11:47 +0400)]
runtime: convert parfor to Go

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

10 years agoruntime: adjust errorCString definition to avoid allocation
Russ Cox [Sun, 24 Aug 2014 03:01:59 +0000 (23:01 -0400)]
runtime: adjust errorCString definition to avoid allocation

The low-level implementation of divide on ARM assumes that
it can panic with an error created by newErrorCString without
allocating. If we make interface data words require pointer values,
the current definition would require an allocation when stored
in an interface. Changing the definition to use unsafe.Pointer
instead of uintptr avoids the allocation. This change is okay
because the field really is a pointer (to a C string in rodata).

Update #8405.

This should make CL 133830043 safe to try again.

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

10 years agoundo CL 130240043 / b09f70c301a5
Dave Cheney [Sun, 24 Aug 2014 01:52:17 +0000 (21:52 -0400)]
undo CL 130240043 / b09f70c301a5

This change broke divmod.go on all arm platforms.

««« original CL description
cmd/gc: change interface representation: only pointers in data word

Note that there are various cleanups that can be made if we keep
this change, but I do not want to start making changes that
depend on this one until the 1.4 cycle closes.

Fixes #8405.

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

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

10 years agoruntime: convert float64toint64, float64touint64 to Go
Dave Cheney [Sat, 23 Aug 2014 23:38:31 +0000 (23:38 +0000)]
runtime: convert float64toint64, float64touint64 to Go

This is a very dumb translation to keep the code as close to the original C as possible.

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

10 years agocmd/gc: change interface representation: only pointers in data word
Russ Cox [Sat, 23 Aug 2014 23:24:44 +0000 (19:24 -0400)]
cmd/gc: change interface representation: only pointers in data word

Note that there are various cleanups that can be made if we keep
this change, but I do not want to start making changes that
depend on this one until the 1.4 cycle closes.

Fixes #8405.

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

10 years agoruntime: remove unused var
Dmitriy Vyukov [Sat, 23 Aug 2014 17:11:57 +0000 (21:11 +0400)]
runtime: remove unused var

LGTM=bradfitz
R=daniel.morsing, bradfitz
CC=golang-codereviews
https://golang.org/cl/130500044

10 years agoruntime: run newproc1 on M stack.
Daniel Morsing [Sat, 23 Aug 2014 14:42:30 +0000 (15:42 +0100)]
runtime: run newproc1 on M stack.

This makes newproc invisible to the GC. This is a pretty simple change since parts of newproc already depends on being run on the M stack.

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

10 years agoruntime: fix futex notes
Dmitriy Vyukov [Fri, 22 Aug 2014 18:22:16 +0000 (22:22 +0400)]
runtime: fix futex notes

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

10 years agoruntime: convert note to Go
Dmitriy Vyukov [Fri, 22 Aug 2014 18:13:01 +0000 (22:13 +0400)]
runtime: convert note to Go
Note is required for timers and heap scavenger.

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

10 years agoruntime: please vet
Dmitriy Vyukov [Fri, 22 Aug 2014 17:27:25 +0000 (21:27 +0400)]
runtime: please vet
The current code is correct, but vet does not understand it:
asm_amd64.s:963: [amd64] invalid MOVL of ret+0(FP); int64 is 8-byte value
asm_amd64.s:964: [amd64] invalid offset ret+4(FP); expected ret+0(FP)

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

10 years agocmd/gofmt: fix error on partial Go code ending with line comment.
Dmitri Shuralyov [Fri, 22 Aug 2014 17:18:00 +0000 (10:18 -0700)]
cmd/gofmt: fix error on partial Go code ending with line comment.

Fix issue by always appending newline after user input, before
the closing curly bracket. The adjust func is modified to remove
this new newline.

Add test case (it fails before CL, passes after).

Fixes #8411.

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

10 years agoruntime: add Go symtab implementation
Josh Bleecher Snyder [Fri, 22 Aug 2014 15:41:32 +0000 (08:41 -0700)]
runtime: add Go symtab implementation

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

10 years agopath, path/filepath: remove dead code
Dave Cheney [Fri, 22 Aug 2014 12:21:41 +0000 (22:21 +1000)]
path, path/filepath: remove dead code

Fixes #8503.

Thanks to no.smile.face for the original report.

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

10 years agomisc/nacl: fix build
Dave Cheney [Fri, 22 Aug 2014 08:36:01 +0000 (18:36 +1000)]
misc/nacl: fix build

Add gofmt.go and gofmt_test.go as they are part of the test data set.

See CL 130440043.

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

10 years agosyscall: fix nacl build
Dmitriy Vyukov [Fri, 22 Aug 2014 07:46:10 +0000 (11:46 +0400)]
syscall: fix nacl build
Timer callback does not accept now as first arg anymore.

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

10 years agopath/filepath: make Abs handle paths like c:a.txt properly
Alex Brainman [Fri, 22 Aug 2014 07:14:42 +0000 (17:14 +1000)]
path/filepath: make Abs handle paths like c:a.txt properly

Fixes #8145.

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

10 years agocmd/gofmt: make test files self-describing
Robert Griesemer [Fri, 22 Aug 2014 00:25:13 +0000 (17:25 -0700)]
cmd/gofmt: make test files self-describing

1) Interpret a comment of the form

//gofmt <flags>

in test files to drive the respective
gofmt command. Eliminates the need to
enumerate all test files in the test
harness.

2) Added -update flag to make it easier
to update test cases.

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

10 years agosync: be more explicit in WaitGroup docs
Andrew Gerrand [Thu, 21 Aug 2014 23:53:44 +0000 (09:53 +1000)]
sync: be more explicit in WaitGroup docs

Fixes #8543.

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

10 years agocmd/ld: fix undefined behaviour in pcln.c
Dave Cheney [Thu, 21 Aug 2014 23:10:33 +0000 (09:10 +1000)]
cmd/ld: fix undefined behaviour in pcln.c

Update #8527

Fixes, src/cmd/6l/../ld/pcln.c:93:18: runtime error: left shift of negative value -2

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

10 years agoA+C: Fatih Arslan (individual CLA)
Rob Pike [Thu, 21 Aug 2014 22:44:03 +0000 (15:44 -0700)]
A+C: Fatih Arslan (individual CLA)

Generated by a+c.

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

10 years agocmd/gofmt: remove testdata/*.gofmt files
Robert Griesemer [Thu, 21 Aug 2014 21:54:27 +0000 (14:54 -0700)]
cmd/gofmt: remove testdata/*.gofmt files

This files were added accidentally and are
not required for running the tests (they
are produced by failing tests for easier
debugging).

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

10 years agoruntime: give an explicit name to profiling Bucket sub-structs.
Rémy Oudompheng [Thu, 21 Aug 2014 20:34:00 +0000 (22:34 +0200)]
runtime: give an explicit name to profiling Bucket sub-structs.

Fixes compilation of runtime on Solaris where the inner struct
was not called "_4_".

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

10 years agotime: removed from tests now obsolete assumption about Australian tz abbreviations
Alberto Donizetti [Thu, 21 Aug 2014 17:35:43 +0000 (10:35 -0700)]
time: removed from tests now obsolete assumption about Australian tz abbreviations

Australian timezones abbreviation for standard and daylight saving time were recently
changed from EST for both to AEST and AEDT in the icann tz database (see changelog
on www.iana.org/time-zones).

A test in the time package was written to check that the ParseInLocation function
understand that Feb EST and Aug EST are different time zones, even though they are
both called EST. This is no longer the case, and the Date function now returns
AEST or AEDT for australian tz on every Linux system with an up to date tz database
(and this makes the test fail).

Since I wasn't able to find another country that 1) uses daylight saving and 2) has
the same abbreviation for both on tzdata, I changed the test to make sure that
ParseInLocation does not get confused when it parses, in different locations, two
dates with the same abbreviation (this was suggested in the mailing list).

Fixes #8547.

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

10 years agoA+C: Alberto Donizetti (individual CLA)
Brad Fitzpatrick [Thu, 21 Aug 2014 17:34:02 +0000 (10:34 -0700)]
A+C: Alberto Donizetti (individual CLA)

Generated by a+c.

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

10 years agocmd/api: reduce stutter in runtime type stubs
Josh Bleecher Snyder [Thu, 21 Aug 2014 17:16:49 +0000 (10:16 -0700)]
cmd/api: reduce stutter in runtime type stubs

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

10 years agonet/http/httputil: Pass a Logger to ReverseProxy, allowing the user to control logging.
Mark Theunissen [Thu, 21 Aug 2014 17:16:34 +0000 (10:16 -0700)]
net/http/httputil: Pass a Logger to ReverseProxy, allowing the user to control logging.

Fixes #8553.

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

10 years agoA+C: Mark Theunissen (individual CLA)
Brad Fitzpatrick [Thu, 21 Aug 2014 17:15:19 +0000 (10:15 -0700)]
A+C: Mark Theunissen (individual CLA)

Generated by a+c.

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

10 years agoruntime: convert lfstack to Go
Dmitriy Vyukov [Thu, 21 Aug 2014 17:10:45 +0000 (21:10 +0400)]
runtime: convert lfstack to Go
It is called from Go only in tests.

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

10 years agoruntime: remove now arg from timer callback
Dmitriy Vyukov [Thu, 21 Aug 2014 17:10:30 +0000 (21:10 +0400)]
runtime: remove now arg from timer callback
Cleanup before converting to Go.
Fortunately nobody using it, because it is incorrect:
monotonic runtime time instead of claimed real time.

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

10 years agoruntime: convert common scheduler functions to Go
Dmitriy Vyukov [Thu, 21 Aug 2014 16:41:09 +0000 (20:41 +0400)]
runtime: convert common scheduler functions to Go
These are required for chans, semaphores, timers, etc.

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

10 years agonet: fix typo
Mikio Hara [Thu, 21 Aug 2014 08:53:45 +0000 (17:53 +0900)]
net: fix typo

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

10 years agocmd/gc: fix undefined behavior
Dmitriy Vyukov [Thu, 21 Aug 2014 08:34:26 +0000 (12:34 +0400)]
cmd/gc: fix undefined behavior
UndefinedBehaviorSanitizer claims it is UB in C:
src/cmd/gc/racewalk.c:422:37: runtime error: member access within null pointer of type 'Node' (aka 'struct Node')
src/cmd/gc/racewalk.c:423:37: runtime error: member access within null pointer of type 'Node' (aka 'struct Node')

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

10 years agoruntime: init GC later
Dmitriy Vyukov [Thu, 21 Aug 2014 07:55:05 +0000 (11:55 +0400)]
runtime: init GC later
Init GC later as it needs to read GOGC env var.
Fixes #8562.

LGTM=daniel.morsing, rsc
R=golang-codereviews, daniel.morsing, rsc
CC=golang-codereviews, khr, rlh
https://golang.org/cl/130990043

10 years agoruntime: fix deadlock when gctrace
Dmitriy Vyukov [Thu, 21 Aug 2014 07:46:53 +0000 (11:46 +0400)]
runtime: fix deadlock when gctrace
Calling ReadMemStats which does stoptheworld on m0 holding locks
was not a good idea.
Stoptheworld holding locks is a recipe for deadlocks (added check for this).
Stoptheworld on g0 may or may not work (added check for this as well).
As far as I understand scavenger will print incorrect numbers now,
as stack usage is not subtracted from heap. But it's better than deadlocking.

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

10 years agocmd/api: add missing runtime struct
Dmitriy Vyukov [Thu, 21 Aug 2014 07:43:58 +0000 (11:43 +0400)]
cmd/api: add missing runtime struct
Fixes build.

TBR=khr
R=golang-codereviews
CC=golang-codereviews, khr
https://golang.org/cl/130390044

10 years agoruntime: convert MemProfile, BlockProfile, ThreadCreateProfile to Go.
Rémy Oudompheng [Thu, 21 Aug 2014 06:07:42 +0000 (08:07 +0200)]
runtime: convert MemProfile, BlockProfile, ThreadCreateProfile to Go.

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

10 years agoruntime: remove unused variable
Josh Bleecher Snyder [Wed, 20 Aug 2014 21:36:28 +0000 (14:36 -0700)]
runtime: remove unused variable

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

10 years agoruntime: convert memclrBytes to Go
Josh Bleecher Snyder [Wed, 20 Aug 2014 21:02:11 +0000 (14:02 -0700)]
runtime: convert memclrBytes to Go

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/131980043

10 years agoruntime: add atomicor8 for amd64p32
Dmitriy Vyukov [Wed, 20 Aug 2014 08:58:01 +0000 (12:58 +0400)]
runtime: add atomicor8 for amd64p32

LGTM=khr
R=golang-codereviews, daniel.morsing, khr, rsc
CC=golang-codereviews, khr, rlh
https://golang.org/cl/131950043

10 years agosyscall: replace zsyscall_windows_*.go files with a single file
Alex Brainman [Wed, 20 Aug 2014 03:17:45 +0000 (13:17 +1000)]
syscall: replace zsyscall_windows_*.go files with a single file

zsyscall_windows_386.go and zsyscall_windows_amd64.go contain same bytes

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

10 years agonet/http: fix TimeoutHandler data races; hold lock longer
Brad Fitzpatrick [Wed, 20 Aug 2014 01:45:05 +0000 (18:45 -0700)]
net/http: fix TimeoutHandler data races; hold lock longer

The existing lock needed to be held longer. If a timeout occured
while writing (but after the guarded timeout check), the writes
would clobber a future connection's buffer.

Also remove a harmless warning by making Write also set the
flag that headers were sent (implicitly), so we don't try to
write headers later (a no-op + warning) on timeout after we've
started writing.

Fixes #8414
Fixes #8209

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

10 years agoruntime: fix typo in comment
Josh Bleecher Snyder [Tue, 19 Aug 2014 15:50:35 +0000 (08:50 -0700)]
runtime: fix typo in comment

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

10 years agoruntime: fix TestGcLastTime on windows
Dmitriy Vyukov [Tue, 19 Aug 2014 15:32:27 +0000 (19:32 +0400)]
runtime: fix TestGcLastTime on windows
Intended to fix:
http://build.golang.org/log/d6718ea67541b8c6be2bb14bcbc4e1c4261f67d7

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

10 years agocmd/6a, cmd/8a: document AJxx condition codes
Josh Bleecher Snyder [Tue, 19 Aug 2014 15:07:58 +0000 (08:07 -0700)]
cmd/6a, cmd/8a: document AJxx condition codes

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

10 years agoruntime: make the GC bitmap a byte array
Dmitriy Vyukov [Tue, 19 Aug 2014 13:38:00 +0000 (17:38 +0400)]
runtime: make the GC bitmap a byte array
Half the code in the garbage collector accesses the bitmap
as an array of bytes instead of as an array of uintptrs.
This is tricky to do correctly in a portable fashion,
it breaks on big-endian systems.
Make the bitmap a byte array.
Simplifies markallocated, scanblock and span sweep along the way,
as we don't need to recalculate bitmap position for each word.

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

10 years agoruntime: always pass type to mallocgc when allocating scannable memory
Dmitriy Vyukov [Tue, 19 Aug 2014 11:59:42 +0000 (15:59 +0400)]
runtime: always pass type to mallocgc when allocating scannable memory
We allocate scannable memory w/o type only in few places in runtime.
All these cases are not-performance critical (e.g. G or finq args buffer),
and in long term they all need to go away.
It's not worth it to have special code for this case in mallocgc.
So use special fake "notype" type for such allocations.

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

10 years agoruntime: allow copying of onM frame
Dmitriy Vyukov [Tue, 19 Aug 2014 10:24:03 +0000 (14:24 +0400)]
runtime: allow copying of onM frame
Currently goroutines in onM can't be copied/shrunk
(including the very goroutine that triggers GC).
Special case onM to allow copying.

LGTM=daniel.morsing, khr
R=golang-codereviews, daniel.morsing, khr, rsc
CC=golang-codereviews, rlh
https://golang.org/cl/124550043

10 years agoruntime: fix MemStats on 32-bits
Dmitriy Vyukov [Tue, 19 Aug 2014 07:53:20 +0000 (11:53 +0400)]
runtime: fix MemStats on 32-bits
Int64's do not fit into uintptr's.

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

10 years agoruntime: convert Gosched to Go
Dmitriy Vyukov [Tue, 19 Aug 2014 07:49:59 +0000 (11:49 +0400)]
runtime: convert Gosched to Go

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

10 years agocmd/gc: fix heap buffer overflow
Dmitriy Vyukov [Tue, 19 Aug 2014 07:49:36 +0000 (11:49 +0400)]
cmd/gc: fix heap buffer overflow
Fixes #8528.

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

10 years agoruntime: improve diagnostics of non-copyable frames
Dmitriy Vyukov [Tue, 19 Aug 2014 07:46:19 +0000 (11:46 +0400)]
runtime: improve diagnostics of non-copyable frames

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

10 years agoruntime: fix memstats
Dmitriy Vyukov [Tue, 19 Aug 2014 07:46:05 +0000 (11:46 +0400)]
runtime: fix memstats
Newly allocated memory is subtracted from inuse, while it was never added to inuse.
Span leftovers are subtracted from both inuse and idle,
while they were never added.
Fixes #8544.
Fixes #8430.

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

10 years agoos: make SameFile handle paths like c:a.txt properly
Alex Brainman [Tue, 19 Aug 2014 04:59:56 +0000 (14:59 +1000)]
os: make SameFile handle paths like c:a.txt properly

Fixes #8490.

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

10 years agoruntime: apply KindMask before comparison
Alex Brainman [Tue, 19 Aug 2014 04:41:52 +0000 (14:41 +1000)]
runtime: apply KindMask before comparison

Fixes windows build.

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

10 years agohtml/template: don't panic on second execution of unescapable template
Andrew Gerrand [Tue, 19 Aug 2014 04:24:14 +0000 (14:24 +1000)]
html/template: don't panic on second execution of unescapable template

Fixes #8431.

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

10 years agonet/http: correct error message for incorrect Body length
Evan Kroske [Tue, 19 Aug 2014 03:40:12 +0000 (20:40 -0700)]
net/http: correct error message for incorrect Body length

Fixes #8140.

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

10 years agoruntime: fix windows/amd64 build after pc-relative 6l change
Russ Cox [Tue, 19 Aug 2014 02:12:51 +0000 (22:12 -0400)]
runtime: fix windows/amd64 build after pc-relative 6l change

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

10 years agoliblink: fix encoding of ASETPC in 6a, 8a
Josh Bleecher Snyder [Tue, 19 Aug 2014 01:14:54 +0000 (18:14 -0700)]
liblink: fix encoding of ASETPC in 6a, 8a

It was incorrectly encoded as ASETLS.

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

10 years agocmd/gc, runtime: refactor interface inlining decision into compiler
Russ Cox [Tue, 19 Aug 2014 01:13:11 +0000 (21:13 -0400)]
cmd/gc, runtime: refactor interface inlining decision into compiler

We need to change the interface value representation for
concurrent garbage collection, so that there is no ambiguity
about whether the data word holds a pointer or scalar.

This CL does NOT make any representation changes.

Instead, it removes representation assumptions from
various pieces of code throughout the tree.
The isdirectiface function in cmd/gc/subr.c is now
the only place that decides that policy.
The policy propagates out from there in the reflect
metadata, as a new flag in the internal kind value.

A follow-up CL will change the representation by
changing the isdirectiface function. If that CL causes
problems, it will be easy to roll back.

Update #8405.

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

10 years agodoc/go1.4: mention pc-relative addressing on amd64
Russ Cox [Tue, 19 Aug 2014 01:07:11 +0000 (21:07 -0400)]
doc/go1.4: mention pc-relative addressing on amd64

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

10 years agoliblink: use pc-relative addressing for all memory references in amd64 code
Russ Cox [Tue, 19 Aug 2014 01:06:56 +0000 (21:06 -0400)]
liblink: use pc-relative addressing for all memory references in amd64 code

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

10 years agoruntime: avoid $sym(SB) as constant
Russ Cox [Tue, 19 Aug 2014 01:06:42 +0000 (21:06 -0400)]
runtime: avoid $sym(SB) as constant

The change to pc-relative addressing will make this illegal.

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

10 years agocmd/6g: fix undefined behavior in reg.c
Dave Cheney [Tue, 19 Aug 2014 00:52:50 +0000 (10:52 +1000)]
cmd/6g: fix undefined behavior in reg.c

Update #8527

Fixes, cmd/6g/reg.c:847:24: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

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

10 years agofmt: print byte stringers correctly
Andrew Gerrand [Mon, 18 Aug 2014 22:52:52 +0000 (08:52 +1000)]
fmt: print byte stringers correctly

type T byte
func (T) String() string { return "X" }

fmt.Sprintf("%s", []T{97, 98, 99, 100}) == "abcd"
fmt.Sprintf("%x", []T{97, 98, 99, 100}) == "61626364"
fmt.Sprintf("%v", []T{97, 98, 99, 100}) == "[X X X X]"

This change makes the last case print correctly.
Before, it would have been "[97 98 99 100]".

Fixes #8360.

LGTM=r
R=r, dan.kortschak
CC=golang-codereviews
https://golang.org/cl/129330043

10 years agobzip2: improve performance
Jeff R. Allen [Mon, 18 Aug 2014 21:41:28 +0000 (14:41 -0700)]
bzip2: improve performance

Improve performance of move-to-front by using cache-friendly
copies instead of doubly-linked list. Simplify so that the
underlying slice is the object. Remove the n=0 special case,
      which was actually slower with the copy approach.

benchmark                 old ns/op     new ns/op     delta
BenchmarkDecodeDigits     26429714      23859699      -9.72%
BenchmarkDecodeTwain      76684510      67591946      -11.86%

benchmark                 old MB/s     new MB/s     speedup
BenchmarkDecodeDigits     1.63         1.81         1.11x
BenchmarkDecodeTwain      1.63         1.85         1.13x

Updates #6754.

LGTM=adg, agl, josharian
R=adg, agl, josharian
CC=golang-codereviews
https://golang.org/cl/131840043

10 years agoruntime: move panicindex/panicslice to Go.
Keith Randall [Mon, 18 Aug 2014 20:26:28 +0000 (13:26 -0700)]
runtime: move panicindex/panicslice to Go.

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

10 years agounicode: strconv: regexp: Upgrade to Unicode 7.0.0.
Marcel van Lohuizen [Mon, 18 Aug 2014 18:26:10 +0000 (20:26 +0200)]
unicode: strconv: regexp: Upgrade to Unicode 7.0.0.

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

10 years agoruntime: add more cases to GC info test
Dmitriy Vyukov [Mon, 18 Aug 2014 18:21:55 +0000 (22:21 +0400)]
runtime: add more cases to GC info test

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

10 years agointernal/syscall: add support for getrandom on arm
Brad Fitzpatrick [Mon, 18 Aug 2014 18:19:05 +0000 (11:19 -0700)]
internal/syscall: add support for getrandom on arm

Added in linux commit eb6452537b28

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

10 years agoruntime: implement transfer cache
Dmitriy Vyukov [Mon, 18 Aug 2014 12:52:31 +0000 (16:52 +0400)]
runtime: implement transfer cache
Currently we do the following dance after sweeping a span:
1. lock mcentral
2. remove the span from a list
3. unlock mcentral
4. unmark span
5. lock mheap
6. insert the span into heap
7. unlock mheap
8. lock mcentral
9. observe empty list
10. unlock mcentral
11. lock mheap
12. grab the span
13. unlock mheap
14. mark span
15. lock mcentral
16. insert the span into empty list
17. unlock mcentral

This change short-circuits this sequence to nothing,
that is, we just cache and use the span after sweeping.

This gives us functionality similar (even better) to tcmalloc's transfer cache.

benchmark            old ns/op     new ns/op     delta
BenchmarkMalloc8     22.2          19.5          -12.16%
BenchmarkMalloc16    31.0          26.6          -14.19%

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

10 years agoruntime: fix dump of data/bss
Dmitriy Vyukov [Mon, 18 Aug 2014 12:42:24 +0000 (16:42 +0400)]
runtime: fix dump of data/bss
Fixes #8530.

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

10 years agoruntime: don't acquirem on malloc fast path
Dmitriy Vyukov [Mon, 18 Aug 2014 12:33:39 +0000 (16:33 +0400)]
runtime: don't acquirem on malloc fast path
Mallocgc must be atomic wrt GC, but for performance reasons
don't acquirem/releasem on fast path. The code does not have
split stack checks, so it can't be preempted by GC.
Functions like roundup/add are inlined. And onM/racemalloc are nosplit.
Also add debug code that checks these assumptions.

benchmark                     old ns/op     new ns/op     delta
BenchmarkMalloc8              20.5          17.2          -16.10%
BenchmarkMalloc16             29.5          27.0          -8.47%
BenchmarkMallocTypeInfo8      31.5          27.6          -12.38%
BenchmarkMallocTypeInfo16     34.7          30.9          -10.95%

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