1
0
mirror of https://github.com/golang/go synced 2024-10-03 00:21:22 -06:00
Commit Graph

15554 Commits

Author SHA1 Message Date
Russ Cox
c548cc2ec8 runtime: fix windows signal handlers
Windows needs the return result in AX, but runtime.sighandler
no longer stores it in AX. Load it back during the assembly trampoline.

TBR=brainman
CC=golang-codereviews
https://golang.org/cl/133980043
2014-08-27 14:43:07 -04:00
Russ Cox
fe91006a02 runtime: give nosplit functions 32 more bytes of headroom
The Go calling convention uses more stack space than C.
On 64-bit systems we've been right up against the limit
(128 bytes, so only 16 words) and doing awful things to
our source code to work around it. Instead of continuing
to do awful things, raise the limit to 160 bytes.
I am prepared to raise the limit to 192 bytes if necessary,
but I think this will be enough.

Should fix current link-time stack overflow errors on
        - nacl/arm
        - netbsd/amd64
        - openbsd/amd64
        - solaris/amd64
        - windows/amd64

TBR=r
CC=golang-codereviews, iant
https://golang.org/cl/131450043
2014-08-27 14:08:26 -04:00
Brad Fitzpatrick
9a5654abef runtime: restore header to first goroutine in Stack
It appears to have been accidentally lost when converting
Stack from C to Go in https://golang.org/cl/129510043

LGTM=rsc
R=golang-codereviews
CC=golang-codereviews, josharian, khr, remyoudompheng, rsc
https://golang.org/cl/136870043
2014-08-27 09:31:32 -07:00
Russ Cox
25f6b02ab0 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
2014-08-27 11:32:17 -04:00
Rick Hudson
0a7c7ac80e 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
2014-08-27 11:15:47 -04:00
Dave Cheney
9c504696f4 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
2014-08-27 15:23:38 +10:00
Rob Pike
1660ece769 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
2014-08-26 14:45:53 -07:00
Rob Pike
62be54a8c0 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
2014-08-26 14:43:03 -07:00
Josh Bleecher Snyder
e5a06ccd37 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
2014-08-26 12:38:18 -07:00
Rémy Oudompheng
39ffa8be78 runtime: convert Stack to Go.
LGTM=khr
R=khr, josharian
CC=golang-codereviews
https://golang.org/cl/129510043
2014-08-26 08:34:46 +02:00
Dave Cheney
0eaea6010a 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
2014-08-26 05:39:04 +00:00
Sanjay Menakuru
90653d7864 runtime,sync: Convert procPin and procUnpin functions to Go.
LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews, khr
https://golang.org/cl/132880043
2014-08-26 09:01:52 +04:00
Brad Fitzpatrick
32c0dce00e 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
2014-08-25 21:50:42 -07:00
Brad Fitzpatrick
87b452537a 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
2014-08-25 21:38:39 -07:00
ChaiShushan
3c466dfea4 cmd/go: add missing doc for GOOS and GOARCH
LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/133900043
2014-08-25 20:01:43 -07:00
Caleb Spare
56916feea3 regexp: fix imports in the middle of the license header
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/129620043
2014-08-25 16:42:15 -07:00
Russ Cox
4516a60062 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
2014-08-25 18:45:29 -04:00
Robert Griesemer
236cf308c2 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
2014-08-25 15:29:47 -07:00
Rob Pike
dff17f4617 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
2014-08-25 14:56:35 -07:00
Caleb Spare
2c121b68b1 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
2014-08-25 14:42:27 -07:00
Rob Pike
958a6101eb 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
2014-08-25 13:47:38 -07:00
Dmitriy Vyukov
b2c43438d2 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
2014-08-25 23:30:39 +04:00
Dmitriy Vyukov
21a4bdef2f 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
2014-08-25 23:24:18 +04:00
Brad Fitzpatrick
6bddb13bc4 net/http: populate Request.Close in ReadRequest
Fixes #8261

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/126620043
2014-08-25 11:44:08 -07:00
Adam Langley
a6cd733450 crypto/cipher: add CFB test vectors.
Fixes #8576.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/136720043
2014-08-25 11:40:10 -07:00
Russ Cox
613383c765 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
2014-08-25 14:38:19 -04:00
Rob Pike
c6f7c176a3 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
2014-08-25 11:35:55 -07:00
Rob Pike
ba8ddc25ca cmd/go: add simple test for generate's line parser
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/128710043
2014-08-25 11:07:08 -07:00
Brad Fitzpatrick
df52d2ebd1 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
2014-08-25 10:32:46 -07:00
Russ Cox
1d2955a2af 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
2014-08-25 13:31:55 -04:00
Dmitriy Vyukov
b83d8bd0b8 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
2014-08-25 20:59:52 +04:00
Dmitriy Vyukov
4064d5e9a3 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
2014-08-25 20:26:32 +04:00
Dmitriy Vyukov
9601abaf8b runtime: convert timers to Go
LGTM=rsc
R=golang-codereviews, ruiu, rsc, daniel.morsing
CC=golang-codereviews, khr
https://golang.org/cl/123700044
2014-08-25 20:25:22 +04:00
Dmitriy Vyukov
ebac0e6f30 runtime: convert async semaphores to Go
LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews, khr
https://golang.org/cl/126210046
2014-08-25 20:12:26 +04:00
Dmitriy Vyukov
846db08936 runtime: fix plan9 HeapSys accounting
LGTM=0intro
R=0intro
CC=golang-codereviews
https://golang.org/cl/131190043
2014-08-25 18:02:30 +04:00
Dmitriy Vyukov
99080c4b6f runtime: fix chan alignment on 32 bits
LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews, khr, rsc
https://golang.org/cl/128700043
2014-08-25 17:19:56 +04:00
Russ Cox
20e97677fd 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
2014-08-25 07:05:45 -04:00
Dmitriy Vyukov
f595f834be 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
2014-08-25 12:10:24 +04:00
Dmitriy Vyukov
7b3677bf3c 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
2014-08-25 12:09:42 +04:00
Dmitriy Vyukov
8ca564fb3f 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
2014-08-25 11:56:25 +04:00
Dmitriy Vyukov
f6ceefa2bf 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
2014-08-25 11:55:42 +04:00
Sanjay Menakuru
639dc6c794 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
2014-08-25 11:29:53 +04:00
Alex Brainman
38ce599494 runtime: convert NewCallback and NewCallbackCDecl to Go
LGTM=khr
R=khr, remyoudompheng
CC=golang-codereviews
https://golang.org/cl/132820043
2014-08-25 15:59:13 +10:00
Sanjay Menakuru
ef50462378 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
2014-08-24 20:27:00 -07:00
Josh Bleecher Snyder
be2ad1d7f5 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
2014-08-24 19:07:27 -07:00
Russ Cox
4af79b6376 cmd/gc: fix build
TBR=dfc
CC=golang-codereviews
https://golang.org/cl/126210047
2014-08-24 21:26:07 -04:00
Russ Cox
527ae57e65 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
2014-08-24 21:16:24 -04:00
Russ Cox
75b72b1b27 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
2014-08-24 20:31:45 -04:00
Matthew Dempsky
2a679f8e3a cmd/link: fix testdata generation
Fixes #8494.

LGTM=rsc
R=golang-codereviews, gobot, rsc, evankroske
CC=golang-codereviews
https://golang.org/cl/123040043
2014-08-24 20:31:16 -04:00
Russ Cox
6c67dd90f7 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
2014-08-24 20:28:29 -04:00
Rob Pike
7dc25960b4 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
2014-08-24 11:34:45 -07:00
Rob Pike
41fc05d023 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
2014-08-24 11:34:12 -07:00
Russ Cox
22af2b8ee0 runtime: fix arm build
TBR=dvyukov
CC=golang-codereviews
https://golang.org/cl/131150043
2014-08-24 14:04:10 -04:00
Dmitriy Vyukov
a6950fe0f9 runtime: convert synchronous semaphores to Go
LGTM=rsc
R=golang-codereviews, khr, rsc
CC=golang-codereviews, rlh
https://golang.org/cl/130340043
2014-08-24 12:41:23 +04:00
Keith Randall
9a1e142bbc runtime: convert channel operations to Go, part 1 (chansend1).
LGTM=dvyukov
R=dvyukov, khr
CC=golang-codereviews
https://golang.org/cl/127460044
2014-08-24 12:31:03 +04:00
Dmitriy Vyukov
7f223e3b3b 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
2014-08-24 12:05:07 +04:00
Dmitriy Vyukov
b91223edd1 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
2014-08-24 12:04:51 +04:00
Dmitriy Vyukov
651d0cf204 runtime: convert sigqueue to Go
LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews, khr
https://golang.org/cl/132090043
2014-08-24 11:50:37 +04:00
Dmitriy Vyukov
98bebcc90a runtime: convert parfor to Go
LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews, khr
https://golang.org/cl/132100043
2014-08-24 11:47:06 +04:00
Russ Cox
48452a276d 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
2014-08-23 23:01:59 -04:00
Dave Cheney
5b70b71219 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
2014-08-23 21:52:17 -04:00
Dave Cheney
32b3a48ea8 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
2014-08-23 23:38:31 +00:00
Russ Cox
950ad4fa2b 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
2014-08-23 19:24:44 -04:00
Dmitriy Vyukov
71ecd16bf5 runtime: remove unused var
LGTM=bradfitz
R=daniel.morsing, bradfitz
CC=golang-codereviews
https://golang.org/cl/130500044
2014-08-23 21:11:57 +04:00
Daniel Morsing
6ed58c2962 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
2014-08-23 15:42:30 +01:00
Dmitriy Vyukov
d2165672ca runtime: fix futex notes
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/126540043
2014-08-22 22:22:16 +04:00
Dmitriy Vyukov
afb2260491 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
2014-08-22 22:13:01 +04:00
Dmitriy Vyukov
f4485784f0 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
2014-08-22 21:27:25 +04:00
Dmitri Shuralyov
9368d6ccbf 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
2014-08-22 10:18:00 -07:00
Josh Bleecher Snyder
0be59730fd runtime: add Go symtab implementation
LGTM=khr
R=khr, dvyukov, dave
CC=golang-codereviews, rsc
https://golang.org/cl/124300044
2014-08-22 08:41:32 -07:00
Dave Cheney
3d3d539083 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
2014-08-22 22:21:41 +10:00
Dmitriy Vyukov
0065cbe5d0 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
2014-08-22 11:46:10 +04:00
Alex Brainman
e6f0b74667 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
2014-08-22 17:14:42 +10:00
Robert Griesemer
67812a7cd9 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
2014-08-21 17:25:13 -07:00
Andrew Gerrand
bc64c07825 sync: be more explicit in WaitGroup docs
Fixes #8543.

LGTM=dvyukov, r
R=rsc, r
CC=dvyukov, golang-codereviews
https://golang.org/cl/123580043
2014-08-22 09:53:44 +10:00
Dave Cheney
f129370b3e 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
2014-08-22 09:10:33 +10:00
Robert Griesemer
32a092a885 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
2014-08-21 14:54:27 -07:00
Rémy Oudompheng
a9cef4952f 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
2014-08-21 22:34:00 +02:00
Alberto Donizetti
5e70140521 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
2014-08-21 10:35:43 -07:00
Josh Bleecher Snyder
d27dfd2152 cmd/api: reduce stutter in runtime type stubs
LGTM=khr
R=khr
CC=dvyukov, golang-codereviews
https://golang.org/cl/132770044
2014-08-21 10:16:49 -07:00
Mark Theunissen
1a1d43239e 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
2014-08-21 10:16:34 -07:00
Dmitriy Vyukov
ae875e040c 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
2014-08-21 21:10:45 +04:00
Dmitriy Vyukov
31e4ad5846 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
2014-08-21 21:10:30 +04:00
Dmitriy Vyukov
684de04118 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
2014-08-21 20:41:09 +04:00
Mikio Hara
6b112c24db net: fix typo
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/128500043
2014-08-21 17:53:45 +09:00
Dmitriy Vyukov
1f5800673b 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
2014-08-21 12:34:26 +04:00
Dmitriy Vyukov
99e9bac8c4 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
2014-08-21 11:55:05 +04:00
Dmitriy Vyukov
a0dbbeae67 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
2014-08-21 11:46:53 +04:00
Dmitriy Vyukov
e249b0ffee cmd/api: add missing runtime struct
Fixes build.

TBR=khr
R=golang-codereviews
CC=golang-codereviews, khr
https://golang.org/cl/130390044
2014-08-21 11:43:58 +04:00
Rémy Oudompheng
04487d5612 runtime: convert MemProfile, BlockProfile, ThreadCreateProfile to Go.
LGTM=khr
R=golang-codereviews, bradfitz, khr
CC=golang-codereviews
https://golang.org/cl/123680043
2014-08-21 08:07:42 +02:00
Josh Bleecher Snyder
cccd66c6c4 runtime: remove unused variable
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/128230047
2014-08-20 14:36:28 -07:00
Josh Bleecher Snyder
68f91aea57 runtime: convert memclrBytes to Go
LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/131980043
2014-08-20 14:02:11 -07:00
Dmitriy Vyukov
ddce7c35f4 runtime: add atomicor8 for amd64p32
LGTM=khr
R=golang-codereviews, daniel.morsing, khr, rsc
CC=golang-codereviews, khr, rlh
https://golang.org/cl/131950043
2014-08-20 12:58:01 +04:00
Alex Brainman
b95ed83480 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
2014-08-20 13:17:45 +10:00
Brad Fitzpatrick
e38fa91648 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
2014-08-19 18:45:05 -07:00
Josh Bleecher Snyder
339a24da66 runtime: fix typo in comment
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/125500043
2014-08-19 08:50:35 -07:00
Dmitriy Vyukov
8c25e08fbd 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
2014-08-19 19:32:27 +04:00
Josh Bleecher Snyder
c6442c994a cmd/6a, cmd/8a: document AJxx condition codes
LGTM=ruiu, rsc
R=rsc, ruiu
CC=golang-codereviews
https://golang.org/cl/130870043
2014-08-19 08:07:58 -07:00
Dmitriy Vyukov
ff3fa1b32d 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
2014-08-19 17:38:00 +04:00
Dmitriy Vyukov
fb44fb6cb7 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
2014-08-19 15:59:42 +04:00
Dmitriy Vyukov
9198ed4bd6 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
2014-08-19 14:24:03 +04:00
Dmitriy Vyukov
266d350f5e 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
2014-08-19 11:53:20 +04:00
Dmitriy Vyukov
5d40742728 runtime: convert Gosched to Go
LGTM=rlh, khr
R=golang-codereviews, rlh, bradfitz, khr
CC=golang-codereviews, rsc
https://golang.org/cl/127490043
2014-08-19 11:49:59 +04:00
Dmitriy Vyukov
53056c37c2 cmd/gc: fix heap buffer overflow
Fixes #8528.

LGTM=rsc
R=rsc, r, iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/128230045
2014-08-19 11:49:36 +04:00
Dmitriy Vyukov
b3d5a695a6 runtime: improve diagnostics of non-copyable frames
LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, rlh, rsc
https://golang.org/cl/124560043
2014-08-19 11:46:19 +04:00
Dmitriy Vyukov
30ef2c7deb 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
2014-08-19 11:46:05 +04:00
Alex Brainman
2de65cad54 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
2014-08-19 14:59:56 +10:00
Alex Brainman
e4f3db3852 runtime: apply KindMask before comparison
Fixes windows build.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/127510043
2014-08-19 14:41:52 +10:00
Andrew Gerrand
0fee63351d 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
2014-08-19 14:24:14 +10:00
Evan Kroske
bdb2f976d3 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
2014-08-18 20:40:12 -07:00
Russ Cox
3e9c7a8a1d runtime: fix windows/amd64 build after pc-relative 6l change
TBR=iant
CC=golang-codereviews
https://golang.org/cl/131900043
2014-08-18 22:12:51 -04:00
Josh Bleecher Snyder
a6feaf3aff 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
2014-08-18 18:14:54 -07:00
Russ Cox
1806a5732b 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
2014-08-18 21:13:11 -04:00
Russ Cox
ca85d572d6 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
2014-08-18 21:06:56 -04:00
Russ Cox
d89cd24857 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
2014-08-18 21:06:42 -04:00
Dave Cheney
afb6221bf7 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
2014-08-19 10:52:50 +10:00
Andrew Gerrand
326f48eb9c 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
2014-08-19 08:52:52 +10:00
Jeff R. Allen
6d248cec56 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
2014-08-18 14:41:28 -07:00
Keith Randall
523aa93288 runtime: move panicindex/panicslice to Go.
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/130210043
2014-08-18 13:26:28 -07:00
Marcel van Lohuizen
65d8cb985f unicode: strconv: regexp: Upgrade to Unicode 7.0.0.
LGTM=r, bradfitz
R=r, bradfitz
CC=golang-codereviews
https://golang.org/cl/127470043
2014-08-18 20:26:10 +02:00
Dmitriy Vyukov
159926236c 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
2014-08-18 22:21:55 +04:00
Brad Fitzpatrick
1a8c00ea21 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
2014-08-18 11:19:05 -07:00
Dmitriy Vyukov
e0df11d57e 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
2014-08-18 16:52:31 +04:00
Dmitriy Vyukov
101c00a44f runtime: fix dump of data/bss
Fixes #8530.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, rsc
https://golang.org/cl/124440043
2014-08-18 16:42:24 +04:00
Dmitriy Vyukov
30940cfad6 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
2014-08-18 16:33:39 +04:00
Dmitriy Vyukov
c6fe53a230 runtime: mark with non-atomic operations when GOMAXPROCS=1
Perf builders show 3-5% GC pause increase with GOMAXPROCS=1 when marking with atomic ops:
http://goperfd.appspot.com/perfdetail?commit=a8a6e765d6a87f7ccb71fd85a60eb5a821151f85&commit0=3b864e02b987171e05e2e9d0840b85b5b6476386&kind=builder&builder=linux-amd64&benchmark=http

LGTM=rlh
R=golang-codereviews, rlh
CC=dave, golang-codereviews, khr, rsc
https://golang.org/cl/128340043
2014-08-16 09:07:55 +04:00
Dave Cheney
78cc89ce67 cmd/ld: fix operator precedence
Fixes #8480.

This CL reapplies CL 114420043. This attempt doesn't blow up when encountering hidden symbols.

LGTM=minux
R=minux
CC=golang-codereviews
https://golang.org/cl/128310043
2014-08-16 14:10:35 +10:00
Shenghou Ma
41d75933d7 cmd/ld: fix operator precedence
LGTM=rsc
R=gobot, dave
CC=golang-codereviews, iant, rsc
https://golang.org/cl/114420043
2014-08-16 14:04:15 +10:00
Brad Fitzpatrick
a729552333 crypto/x509: SystemRootsError style tweaks, document in Verify
In retrospect this should've been a variable instead of a type,
but oh well.

LGTM=agl
R=agl
CC=golang-codereviews
https://golang.org/cl/129250044
2014-08-15 17:47:02 -07:00
Henning Schmiedehausen
7eba885ba5 cmd/dist: goc2c ignores GOROOT_FINAL
When building golang, the environment variable GOROOT_FINAL can be set
to indicate a different installation location from the build
location. This works fine, except that the goc2c build step embeds
line numbers in the resulting c source files that refer to the build
location, no the install location.

This would not be a big deal, except that in turn the linker uses the
location of runtime/string.goc to embed the gdb script in the
resulting binary and as a net result, the debugger now complains that
the script is outside its load path (it has the install location
configured).

See https://code.google.com/p/go/issues/detail?id=8524 for the full
description.

Fixes #8524.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/128230046
2014-08-15 15:19:02 -07:00
Rob Pike
ab0b0d9031 cmd/go: fix a couple of errors found by "go vet"
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/127410043
2014-08-15 12:35:01 -07:00
Rob Pike
4edcbe0d40 fmt: fix size returned on fast path of ReadRune
Fixes #8512.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/130090043
2014-08-15 11:41:12 -07:00
Dmitriy Vyukov
c5e648d684 runtime: fix getgcmask
bv.data is an array of uint32s but the code was using
offsets computed for an array of bytes.
Add a test for stack GC info.
Fixes #8531.

LGTM=rsc
R=golang-codereviews
CC=golang-codereviews, khr, rsc
https://golang.org/cl/124450043
2014-08-15 22:36:12 +04:00
Matthew Dempsky
7f40e5e6e5 cmd/gc: disallow pointer constants
Fixes #7760.

LGTM=iant
R=iant, remyoudompheng
CC=golang-codereviews
https://golang.org/cl/130720043
2014-08-15 11:33:31 -07:00
Egon Elbre
a18a360379 net: fix CNAME resolving on Windows
Fixes #8492

LGTM=alex.brainman
R=golang-codereviews, alex.brainman
CC=golang-codereviews
https://golang.org/cl/122200043
2014-08-15 16:37:19 +10:00
Dmitriy Vyukov
0c32bd6262 runtime: mark objects with non-atomic operations
On the go.benchmarks/garbage benchmark with GOMAXPROCS=16:
                   old ns/op     new ns/op     delta
time               1392254       1353170       -2.81%
cputime            21995751      21373999      -2.83%
gc-pause-one       15044812      13050524      -13.26%
gc-pause-total     213636        185317        -13.26%

LGTM=rlh
R=golang-codereviews, rlh
CC=golang-codereviews, khr, rsc
https://golang.org/cl/123380043
2014-08-14 21:38:24 +04:00
Matthew Dempsky
ba30c082c0 cmd/cgo: check for compiler errors in the C preamble
E.g., here's the new "go build" output:

$ go build misc/cgo/errors/issue8442.go
# command-line-arguments
could not determine kind of name for C.issue8442foo

gcc errors for preamble:
misc/cgo/errors/issue8442.go:11:19: error: unknown type name 'UNDEF'

Fixes #8442.

LGTM=iant
R=iant, alex.brainman
CC=golang-codereviews
https://golang.org/cl/129160043
2014-08-14 09:21:58 -07:00
Robert Griesemer
e9bbcea81d text/scanner: improve documentation
LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/123390043
2014-08-13 12:53:50 -07:00
Matthew Dempsky
078a9cbc6c cmd/cgo, debug/dwarf: fix translation of zero-size arrays
In cgo, now that recursive calls to typeConv.Type() always work,
we can more robustly calculate the array sizes based on the size
of our element type.

Also, in debug/dwarf, the decision to call zeroType is made
based on a type's usage	within a particular struct, but dwarf.Type
values are cached in typeCache, so the modification might affect
uses of the type in other structs.  Current compilers don't appear
to share DWARF type entries for "[]foo" and "[0]foo", but they also
don't consistently share type entries in other cases.  Arguably
modifying the types is an improvement in some cases, but varying
translated types according to compiler whims seems like a bad idea.

Lastly, also in debug/dwarf, zeroType only needs to rewrite the
top-level dimension, and only if the rest of the array size is
non-zero.

Fixes #8428.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/127980043
2014-08-13 11:16:30 -07:00
Dmitriy Vyukov
187d0f6720 runtime: keep objects in free lists marked as allocated.
Restore https://golang.org/cl/41040043 after GC rewrite.
Original description:
On the plus side, we don't need to change the bits on malloc and free.
On the downside, we need to mark objects in the free lists during GC.
But the free lists are small at GC time, so it should be a net win.

benchmark             old ns/op     new ns/op     delta
BenchmarkMalloc8      21.9          20.4          -6.85%
BenchmarkMalloc16     31.1          29.6          -4.82%

LGTM=khr
R=khr
CC=golang-codereviews, rlh, rsc
https://golang.org/cl/122280043
2014-08-13 20:42:55 +04:00
Thiago Fransosi Farina
aa549ce449 cmd/dist: Reuse streq whenever possible.
Basically this cleanup replaces all the usage usages of strcmp() == 0,
found by the following command line:

$ grep -R strcmp cmd/dist | grep "0"

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/123330043
2014-08-13 06:47:30 -07:00
Rob Pike
8bca148a3e all: copy cmd/ld/textflag.h into pkg/GOOS_GOARCH
The file is used by assembly code to define symbols like NOSPLIT.
Having it hidden inside the cmd directory makes it hard to access
outside the standard repository.
Solution: As with a couple of other files used by cgo, copy the
file into the pkg directory and add a -I argument to the assembler
to access it. Thus one can write just
        #include "textflag.h"
in .s files.

The names in runtime are not updated because in the boot sequence the
file has not been copied yet when runtime is built. All other .s files
in the repository are updated.

Changes to doc/asm.html, src/cmd/dist/build.c, and src/cmd/go/build.go
are hand-made. The rest are just the renaming done by a global
substitution. (Yay sam).

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/128050043
2014-08-12 17:04:45 -07:00
Russ Cox
ce35994d4e cmd/6c, cmd/6g: avoid address-as-constant in amd64 instructions
This allows implementing address-of-global
as a pc-relative address instead of as a
32-bit integer constant.

LGTM=rminnich, iant
R=golang-codereviews, rminnich, iant
CC=golang-codereviews
https://golang.org/cl/128070045
2014-08-12 19:53:11 -04:00
Russ Cox
3763a395b2 cmd/go: adjust import comment error
Fixes #7453.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/127210043
2014-08-12 19:52:04 -04:00
Russ Cox
9aa1e9afda runtime: avoid using address as constant in amd64 assembly
This allows changing the addressing mode for constant
global addresses to use pc-relative addressing.

LGTM=rminnich, iant
R=golang-codereviews, rminnich, iant
CC=golang-codereviews
https://golang.org/cl/129830043
2014-08-12 19:51:20 -04:00
Rob Pike
160b2461b6 syscall: freeze the package
Add a clause to the doc comment for the package and a
paragraph in the compatibility document explaining the
situation.

LGTM=bradfitz, adg, rsc
R=golang-codereviews, adg, bradfitz, minux, rsc
CC=golang-codereviews
https://golang.org/cl/129820043
2014-08-12 15:28:45 -07:00
Russ Cox
9abf0b6e9f cmd/ld: handle large link base addresses
codeblk and datblk were truncating their
arguments to int32. Don't do that.

LGTM=dvyukov, rminnich
R=iant, dvyukov, rminnich
CC=golang-codereviews
https://golang.org/cl/126050043
2014-08-12 17:41:16 -04:00
Russ Cox
0c6146711c cmd/go, go/build: implement import comment checking
See golang.org/s/go14customimport for design.

Added case to deps_test to allow go/build to import regexp.
Not a new dependency, because go/build already imports go/doc
which imports regexp.

Fixes #7453.

LGTM=r
R=r, josharian
CC=golang-codereviews
https://golang.org/cl/124940043
2014-08-12 17:41:03 -04:00
Brad Fitzpatrick
67e1d40031 crypto/rand: use getrandom system call on Linux
Adds internal/syscall package.

Fixes #8520

LGTM=r, agl
R=agl, rsc, r
CC=golang-codereviews, iant
https://golang.org/cl/123260044
2014-08-12 14:35:27 -07:00
Dmitriy Vyukov
1837419f30 runtime: remove FlagNoProfile
Turns out to be unused as well.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews, khr
https://golang.org/cl/127170044
2014-08-13 01:03:32 +04:00