]> Cypherpunks repositories - gostls13.git/log
gostls13.git
10 years agocmd/cc, runtime: convert C compilers to use Go calling convention
Russ Cox [Wed, 27 Aug 2014 15:32:17 +0000 (11:32 -0400)]
cmd/cc, runtime: convert C compilers to use Go calling convention

To date, the C compilers and Go compilers differed only in how
values were returned from functions. This made it difficult to call
Go from C or C from Go if return values were involved. It also made
assembly called from Go and assembly called from C different.

This CL changes the C compiler to use the Go conventions, passing
results on the stack, after the arguments.
[Exception: this does not apply to C ... functions, because you can't
know where on the stack the arguments end.]

By doing this, the CL makes it possible to rewrite C functions into Go
one at a time, without worrying about which languages call that
function or which languages it calls.

This CL also updates all the assembly files in package runtime to use
the new conventions. Argument references of the form 40(SP) have
been rewritten to the form name+10(FP) instead, and there are now
Go func prototypes for every assembly function called from C or Go.
This means that 'go vet runtime' checks effectively every assembly
function, and go vet's output was used to automate the bulk of the
conversion.

Some functions, like seek and nsec on Plan 9, needed to be rewritten.

Many assembly routines called from C were reading arguments
incorrectly, using MOVL instead of MOVQ or vice versa, especially on
the less used systems like openbsd.
These were found by go vet and have been corrected too.
If we're lucky, this may reduce flakiness on those systems.

Tested on:
        darwin/386
        darwin/amd64
        linux/arm
        linux/386
        linux/amd64
If this breaks another system, the bug is almost certainly in the
sys_$GOOS_$GOARCH.s file, since the rest of the CL is tested
by the combination of the above systems.

LGTM=dvyukov, iant
R=golang-codereviews, 0intro, dave, alex.brainman, dvyukov, iant
CC=golang-codereviews, josharian, r
https://golang.org/cl/135830043

10 years agoruntime: changes to g->atomicstatus (nee status) to support concurrent GC
Rick Hudson [Wed, 27 Aug 2014 15:15:47 +0000 (11:15 -0400)]
runtime: changes to g->atomicstatus (nee status) to support concurrent GC

Every change to g->atomicstatus is now done atomically so that we can
ensure that all gs pass through a gc safepoint on demand. This allows
the GC to move from one phase to the next safely. In some phases the
stack will be scanned. This CL only deals with the infrastructure that
allows g->atomicstatus to go from one state to another. Future CLs
will deal with scanning and monitoring what phase the GC is in.

The major change was to moving to using a Gscan bit to indicate that
the status is in a scan state. The only bug fix was in oldstack where
I wasn't moving to a Gcopystack state in order to block scanning until
the new stack was in place. The proc.go file is waiting for an atomic
load instruction.

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

10 years agoCONTRIBUTORS: add Rick Hudson (Google CLA)
Russ Cox [Wed, 27 Aug 2014 15:10:01 +0000 (11:10 -0400)]
CONTRIBUTORS: add Rick Hudson (Google CLA)

TBR=rlh
CC=golang-codereviews
https://golang.org/cl/131410043

10 years agocmd/gc: fix undefined behaviour warnings in mparith3.c
Dave Cheney [Wed, 27 Aug 2014 05:23:38 +0000 (15:23 +1000)]
cmd/gc: fix undefined behaviour warnings in mparith3.c

Update #8527

Fixes two warnings:

src/cmd/gc/mparith3.c:255:10: runtime error: shift exponent 52 is too large for 32-bit type 'int'
src/cmd/gc/mparith3.c:254:14: runtime error: shift exponent 52 is too large for 32-bit type 'int'

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

10 years agotime: use go generate rather than Makefile (windows only)
Rob Pike [Tue, 26 Aug 2014 21:45:53 +0000 (14:45 -0700)]
time: use go generate rather than Makefile (windows only)
Also make genzabbrs.go more self-contained.
Also run it (on Linux; does that matter?) to update the table.

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

10 years agounicode: use go generate instead of make to create tables.go
Rob Pike [Tue, 26 Aug 2014 21:43:03 +0000 (14:43 -0700)]
unicode: use go generate instead of make to create tables.go

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

10 years agoA+C: Joe Shaw (individual CLA)
Brad Fitzpatrick [Tue, 26 Aug 2014 21:24:04 +0000 (14:24 -0700)]
A+C: Joe Shaw (individual CLA)

Generated by a+c.

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

10 years agoruntime: name hi and lo parts of ret in assembly
Josh Bleecher Snyder [Tue, 26 Aug 2014 19:38:18 +0000 (12:38 -0700)]
runtime: name hi and lo parts of ret in assembly

Makes vet happy.

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

10 years agodoc/cmd.html: close a tag.
Oling Cat [Tue, 26 Aug 2014 12:26:48 +0000 (05:26 -0700)]
doc/cmd.html: close a tag.

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

10 years agoruntime: convert Stack to Go.
Rémy Oudompheng [Tue, 26 Aug 2014 06:34:46 +0000 (08:34 +0200)]
runtime: convert Stack to Go.

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

10 years agoruntime: convert int64tofloat64, uint64tofloat64 to Go
Dave Cheney [Tue, 26 Aug 2014 05:39:04 +0000 (05:39 +0000)]
runtime: convert int64tofloat64, uint64tofloat64 to Go

I noticed that 5g doesn't flush the float64 result back to the stack, hence the change in the function signature. I'm wondering if I should also change the signature for the other two functions.

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

10 years agoruntime,sync: Convert procPin and procUnpin functions to Go.
Sanjay Menakuru [Tue, 26 Aug 2014 05:01:52 +0000 (09:01 +0400)]
runtime,sync: Convert procPin and procUnpin functions to Go.

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

10 years agonet/http: fix data race in test
Brad Fitzpatrick [Tue, 26 Aug 2014 04:50:42 +0000 (21:50 -0700)]
net/http: fix data race in test

I can't reproduce the race, but this should fix it.

Fixes #8483

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

10 years agoio: document that Readers and Writers must not retain buffers
Brad Fitzpatrick [Tue, 26 Aug 2014 04:38:39 +0000 (21:38 -0700)]
io: document that Readers and Writers must not retain buffers

There are both many callers and many implementations of these
interfaces, so make the contract explicit. Callers generally
assume this, and at least the standard library and other
implementations obey this, but it's never stated explicitly,
making it somewhat risky to assume.

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

10 years agocmd/go: add missing doc for GOOS and GOARCH
ChaiShushan [Tue, 26 Aug 2014 03:01:43 +0000 (20:01 -0700)]
cmd/go: add missing doc for GOOS and GOARCH

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

10 years agoregexp: fix imports in the middle of the license header
Caleb Spare [Mon, 25 Aug 2014 23:42:15 +0000 (16:42 -0700)]
regexp: fix imports in the middle of the license header

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

10 years agoliblink: introduce way to avoid pc-relative addressing
Russ Cox [Mon, 25 Aug 2014 22:45:29 +0000 (18:45 -0400)]
liblink: introduce way to avoid pc-relative addressing

For Solaris. Sigh.

LGTM=dave
R=aram, iant, dave
CC=golang-codereviews
https://golang.org/cl/129540043

10 years agocmd/gofmt: don't permit -w with stdin
Robert Griesemer [Mon, 25 Aug 2014 22:29:47 +0000 (15:29 -0700)]
cmd/gofmt: don't permit -w with stdin

Also: use 0x644 file permission if a new file
is created (should not happen anymore, though).

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

10 years agounicode/maketables: add -output flag, buffer output, use gofmt
Rob Pike [Mon, 25 Aug 2014 21:56:35 +0000 (14:56 -0700)]
unicode/maketables: add -output flag, buffer output, use gofmt
Simplify the invocation (and speed it up substantially) in preparation
for move to go generate.

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

10 years agostrings, bytes: document behavior of Replace when old is empty
Caleb Spare [Mon, 25 Aug 2014 21:42:27 +0000 (14:42 -0700)]
strings, bytes: document behavior of Replace when old is empty

Fixes #8143.

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

10 years agocmd/go: clean up a couple of inconsequential nits in generate
Rob Pike [Mon, 25 Aug 2014 20:47:38 +0000 (13:47 -0700)]
cmd/go: clean up a couple of inconsequential nits in generate
Post-submit glitches caught by reviewers.

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

10 years agoruntime: restore scavenger constants
Dmitriy Vyukov [Mon, 25 Aug 2014 19:30:39 +0000 (23:30 +0400)]
runtime: restore scavenger constants
Once and for all.
Broken in cl/108640043.
I've messed it before. To test scavenger-related changes
one needs to alter the constants during final testing.
And then it's very easy to submit with the altered constants.

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

10 years agoruntime: restore nacl timens
Dmitriy Vyukov [Mon, 25 Aug 2014 19:24:18 +0000 (23:24 +0400)]
runtime: restore nacl timens
Deleted in cl/123700044.
I am not sure whether I need to restore it,
or delete rest of the uses...

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

10 years agonet/http: populate Request.Close in ReadRequest
Brad Fitzpatrick [Mon, 25 Aug 2014 18:44:08 +0000 (11:44 -0700)]
net/http: populate Request.Close in ReadRequest

Fixes #8261

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

10 years agocrypto/cipher: add CFB test vectors.
Adam Langley [Mon, 25 Aug 2014 18:40:10 +0000 (11:40 -0700)]
crypto/cipher: add CFB test vectors.

Fixes #8576.

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

10 years agocmd/gc, runtime: treat slices and strings like pointers in garbage collection
Russ Cox [Mon, 25 Aug 2014 18:38:19 +0000 (14:38 -0400)]
cmd/gc, runtime: treat slices and strings like pointers in garbage collection

Before, a slice with cap=0 or a string with len=0 might have its
base pointer pointing beyond the actual slice/string data into
the next block. The collector had to ignore slices and strings with
cap=0 in order to avoid misinterpreting the base pointer.

Now, a slice with cap=0 or a string with len=0 still has a base
pointer pointing into the actual slice/string data, no matter what.
The collector can now always scan the pointer, which means
strings and slices are no longer special.

Fixes #8404.

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

10 years agocmd/go: add GOOS and GOARCH to generate
Rob Pike [Mon, 25 Aug 2014 18:35:55 +0000 (11:35 -0700)]
cmd/go: add GOOS and GOARCH to generate
Fixes test failure in build, probably a good idea anyway.

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

10 years agocmd/go: add simple test for generate's line parser
Rob Pike [Mon, 25 Aug 2014 18:07:08 +0000 (11:07 -0700)]
cmd/go: add simple test for generate's line parser

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

10 years agoencoding/json: make ,string work when encoding pointer fields
Brad Fitzpatrick [Mon, 25 Aug 2014 17:32:46 +0000 (10:32 -0700)]
encoding/json: make ,string work when encoding pointer fields

It was respected by unmarshal, but not marshal, so they didn't
round-trip.

Fixes #8582

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

10 years agoruntime: round channel size in allocation instead of using system-specific pad field
Russ Cox [Mon, 25 Aug 2014 17:31:55 +0000 (13:31 -0400)]
runtime: round channel size in allocation instead of using system-specific pad field

Followup to CL 128700043.

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

10 years agoruntime: remove dedicated scavenger thread
Dmitriy Vyukov [Mon, 25 Aug 2014 16:59:52 +0000 (20:59 +0400)]
runtime: remove dedicated scavenger thread
A whole thread is too much for background scavenger that sleeps all the time anyway.
We already have sysmon thread that can do this work.
Also remove g->isbackground and simplify enter/exitsyscall.

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

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