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

16613 Commits

Author SHA1 Message Date
Russ Cox
7d516079de runtime: convert netbsd/arm to Go
This was the last src/runtime/*.c file.

LGTM=austin
R=austin
CC=golang-codereviews
https://golang.org/cl/187770043
2014-12-05 16:17:09 -05:00
Russ Cox
444839014b [dev.garbage] all: merge dev.cc (81884b89bd88) into dev.garbage
TBR=rlh
CC=golang-codereviews
https://golang.org/cl/181100044
2014-12-05 11:40:41 -05:00
Russ Cox
829b286f2c [dev.cc] all: merge default (8d42099cdc23) into dev.cc
TBR=austin
CC=golang-codereviews
https://golang.org/cl/178700044
2014-12-05 11:18:10 -05:00
Austin Clements
e04c8b063f [dev.cc] liblink: don't patch jumps to jumps to symbols
When liblink sees something like

       JMP x
       ...
    x: JMP y

it rewrites the first jump to jump directly to y.  This is
fine if y is a resolved label.  However, it *also* does this
if y is a function symbol, but fails to carry over the
relocation that would later patch in that symbol's value.  As
a result, the original jump becomes either a self-jump (if
relative) or a jump to PC 0 (if absolute).

Fix this by disabling this optimization if the jump being
patched in is a jump to a symbol.

LGTM=minux
R=rsc, minux
CC=golang-codereviews
https://golang.org/cl/185890044
2014-12-05 09:24:01 -05:00
Shenghou Ma
274976f45c [dev.cc] cmd/ld: finalize linkmode before determining whether to import runtime/cgo
Frankly, I don't understand how the current code could possibly work except
when every android program is using cgo. Discovered this while working on
the iOS port.

LGTM=crawshaw, rsc
R=rsc, crawshaw
CC=golang-codereviews
https://golang.org/cl/177470043
2014-12-05 02:22:20 -05:00
Rob Pike
41c6b84342 cmd/go: fix build
The new semantics of split require the newline be present.
The test was stale.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/182480043
2014-12-05 09:37:56 +09:00
Rob Pike
dd26fc3822 cmd/go: avoid use of bufio.Scanner in generate
Scanner can't handle stupid long lines and there are
reports of stupid long lines in production.

Note the issue isn't long "//go:generate" lines, but
any long line in any Go source file.

To be fair, if you're going to have a stupid long line
it's not a bad bet you'll want to run it through go
generate, because it's some embeddable asset that
has been machine generated. (One could ask why
that generation process didn't add a newline or two,
but we should cope anyway.)

Rewrite the file scanner in "go generate" so it can
handle arbitrarily long lines, and only stores in memory
those lines that start "//go:generate".

Also: Adjust the documentation to make clear that it
does not parse the file.

Fixes #9143.
Fixes #9196.

LGTM=rsc, dominik.honnef
R=rsc, cespare, minux, dominik.honnef
CC=golang-codereviews
https://golang.org/cl/182970043
2014-12-05 09:15:38 +09:00
Shenghou Ma
c9d0c81214 cmd/pprof/internal/commands: add command to open browser on windows
While we're at there, also add a message to prompt the user to install
Graphviz if "dot" command is not found.

Fixes #9178.

LGTM=adg, alex.brainman, cookieo9, rsc
R=rsc, adg, bradfitz, alex.brainman, cookieo9, smyrman
CC=golang-codereviews
https://golang.org/cl/180380043
2014-12-04 11:24:23 -05:00
Russ Cox
9f04a62a39 cmd/pprof: fix symbol resolution for remote profiles
Fixes #9199.

LGTM=iant
R=golang-codereviews, iant
CC=austin, golang-codereviews, minux
https://golang.org/cl/183080043
2014-12-03 14:14:00 -05:00
Dominik Honnef
14948481f6 cmd/go: regenerate doc.go
Move change from CL 170770043 to correct file and regenerate docs
for changes from CL 164120043.

LGTM=adg
R=golang-codereviews, adg, bradfitz
CC=golang-codereviews
https://golang.org/cl/183000043
2014-12-03 10:28:54 +11:00
Russ Cox
2b62e1eaec runtime: fix hang in GC due to shrinkstack vs netpoll race
During garbage collection, after scanning a stack, we think about
shrinking it to reclaim some memory. The shrinking code (called
while the world is stopped) checked that the status was Gwaiting
or Grunnable and then changed the state to Gcopystack, to essentially
lock the stack so that no other GC thread is scanning it.
The same locking happens for stack growth (and is more necessary there).

        oldstatus = runtime·readgstatus(gp);
        oldstatus &= ~Gscan;
        if(oldstatus == Gwaiting || oldstatus == Grunnable)
                runtime·casgstatus(gp, oldstatus, Gcopystack); // oldstatus is Gwaiting or Grunnable
        else
                runtime·throw("copystack: bad status, not Gwaiting or Grunnable");

Unfortunately, "stop the world" doesn't stop everything. It stops all
normal goroutine execution, but the network polling thread is still
blocked in epoll and may wake up. If it does, and it chooses a goroutine
to mark runnable, and that goroutine is the one whose stack is shrinking,
then it can happen that between readgstatus and casgstatus, the status
changes from Gwaiting to Grunnable.

casgstatus assumes that if the status is not what is expected, it is a
transient change (like from Gwaiting to Gscanwaiting and back, or like
from Gwaiting to Gcopystack and back), and it loops until the status
has been restored to the expected value. In this case, the status has
changed semi-permanently from Gwaiting to Grunnable - it won't
change again until the GC is done and the world can continue, but the
GC is waiting for the status to change back. This wedges the program.

To fix, call a special variant of casgstatus that accepts either Gwaiting
or Grunnable as valid statuses.

Without the fix bug with the extra check+throw in casgstatus, the
program below dies in a few seconds (2-10) with GOMAXPROCS=8
on a 2012 Retina MacBook Pro. With the fix, it runs for minutes
and minutes.

package main

import (
        "io"
        "log"
        "net"
        "runtime"
)

func main() {
        const N = 100
        for i := 0; i < N; i++ {
                l, err := net.Listen("tcp", "127.0.0.1:0")
                if err != nil {
                        log.Fatal(err)
                }
                ch := make(chan net.Conn, 1)
                go func() {
                        var err error
                        c1, err := net.Dial("tcp", l.Addr().String())
                        if err != nil {
                                log.Fatal(err)
                        }
                        ch <- c1
                }()
                c2, err := l.Accept()
                if err != nil {
                        log.Fatal(err)
                }
                c1 := <-ch
                l.Close()
                go netguy(c1, c2)
                go netguy(c2, c1)
                c1.Write(make([]byte, 100))
        }
        for {
                runtime.GC()
        }
}

func netguy(r, w net.Conn) {
        buf := make([]byte, 100)
        for {
                bigstack(1000)
                _, err := io.ReadFull(r, buf)
                if err != nil {
                        log.Fatal(err)
                }
                w.Write(buf)
        }
}

var g int

func bigstack(n int) {
        var buf [100]byte
        if n > 0 {
                bigstack(n - 1)
        }
        g = int(buf[0]) + int(buf[99])
}

Fixes #9186.

LGTM=rlh
R=austin, rlh
CC=dvyukov, golang-codereviews, iant, khr, r
https://golang.org/cl/179680043
2014-12-01 16:32:06 -05:00
Keith Randall
7c1e33033d reflect: Fix reflect.funcLayout. The GC bitmap has two bits per
pointer, not one.

Fixes #9179

LGTM=iant, rsc
R=golang-codereviews, iant, rsc
CC=golang-codereviews
https://golang.org/cl/182160043
2014-12-01 07:52:09 -08:00
Austin Clements
6f755f2f8f [dev.cc] 9l: make R_CALLPOWER like ELF's R_PPC64_REL24
These accomplished the same thing, but R_CALLPOWER expected
the whole instruction to be in the addend (and completely
overwrote what was in the text section), while R_PPC64_REL24
overwrites only bits 6 through 24 of whatever was in the text
section.  Make R_CALLPOWER work like R_PPC64_REL24 to ease the
implementation of dynamic linking.

LGTM=rsc
R=rsc
CC=golang-codereviews, minux
https://golang.org/cl/177430043
2014-11-25 16:00:25 -05:00
David du Colombier
c8af6de2e8 [dev.cc] cmd/5g,cmd/6g,cmd/9g: fix warnings on Plan 9
warning: src/cmd/5g/reg.c:461 format mismatch d VLONG, arg 5
warning: src/cmd/6g/reg.c:396 format mismatch d VLONG, arg 5
warning: src/cmd/9g/reg.c:440 format mismatch d VLONG, arg 5

LGTM=minux
R=rsc, minux
CC=golang-codereviews
https://golang.org/cl/179300043
2014-11-25 08:42:00 +01:00
Russ Cox
355f25305b go/build: build $GOOS_test.go always
We decided to build $GOOS.go always
but forgot to test $GOOS_test.go.

Fixes #9159.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/176290043
2014-11-24 20:18:44 -05:00
Russ Cox
b8540fc288 [dev.garbage] all: merge dev.cc (493ad916c3b1) into dev.garbage
TBR=austin
CC=golang-codereviews
https://golang.org/cl/179290043
2014-11-24 12:07:11 -05:00
Austin Clements
ed5488eece [dev.cc] 9g: peephole optimizer
This was based on the 9c peephole optimizer, modified to work
with code generated by gc and use the proginfo infrastructure
in gc.

LGTM=rsc
R=rsc, bradfitz, minux
CC=golang-codereviews
https://golang.org/cl/179190043
2014-11-24 11:42:15 -05:00
Austin Clements
e78777ebfe [dev.cc] 9g: fill progtable for CC, V, and VCC instruction variants
This adds some utilities for converting between the CC, V, and
VCC variants of operations and uses these to derive the
ProgInfo entries for these variants (which are identical to
the ProgInfo for the base operations).

The 9g peephole optimizer will also use these conversion
utilities.

LGTM=minux, rsc
R=rsc, dave, minux
CC=golang-codereviews
https://golang.org/cl/180110044
2014-11-24 11:40:36 -05:00
Joel Sing
6ddc2cb80c [dev.cc] runtime: convert dragonfly/386 port to Go
LGTM=rsc
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/178210043
2014-11-25 03:15:11 +11:00
Russ Cox
a236804c76 [dev.cc] all: merge default (95f5614b4648) into dev.cc
TBR=austin
CC=golang-codereviews
https://golang.org/cl/177220044
2014-11-23 15:13:48 -05:00
Russ Cox
04923042bd image/jpeg: handle Read returning n > 0, err != nil in d.fill
Fixes #9127.

LGTM=r
R=bradfitz, r
CC=golang-codereviews, nigeltao
https://golang.org/cl/178120043
2014-11-22 13:55:33 -05:00
Shenghou Ma
8cda58c25e cmd/go: fix running pprof on windows.
Fixes #9149.

LGTM=alex.brainman, rsc
R=rsc, dave, alex.brainman
CC=golang-codereviews
https://golang.org/cl/176170043
2014-11-22 13:37:46 -05:00
Joel Sing
0d76887433 [dev.cc] runtime: convert netbsd/386 port to Go
LGTM=minux
R=rsc, minux
CC=golang-codereviews
https://golang.org/cl/177170043
2014-11-22 22:09:11 +11:00
Joel Sing
cfc8099a9a [dev.cc] runtime: convert netbsd/amd64 port to Go
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/169620043
2014-11-22 16:05:31 +11:00
Shenghou Ma
d3526ea0f6 [dev.cc] runtime: migrate Android/ARM port to Go.
I tested building Go itself, but not any of go.mobile tests.

LGTM=crawshaw
R=crawshaw, rsc
CC=golang-codereviews
https://golang.org/cl/179110043
2014-11-21 18:15:30 -05:00
Shenghou Ma
adbca13cb3 [dev.cc] runtime: explicitly exclude android in zgoos_linux.go
Otherwise both zgoos_linux.go and zgoos_android.go will be compiled
for GOOS=android.

LGTM=crawshaw, rsc
R=rsc, crawshaw
CC=golang-codereviews
https://golang.org/cl/178110043
2014-11-21 18:13:59 -05:00
Rick Hudson
273507aa8f [dev.garbage] runtime: Stop running gs during the GCscan phase.
Ensure that all gs are in a scan state when their stacks are being scanned.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/179160044
2014-11-21 16:46:27 -05:00
Austin Clements
ee853dacf5 [dev.cc] 9g: correct bad proginfo for ADUFFZERO and ADUFFCOPY
LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/176130044
2014-11-21 15:58:01 -05:00
Russ Cox
8c3f64022a [dev.garbage] runtime: add prefetcht0, prefetcht1, prefetcht2, prefetcht3, prefetchnta for GC
We don't know what we need yet, so add them all.
Add them even on x86 architectures (as no-ops) so that
the GC can refer to them unconditionally.

Eventually we'll know what we want and probably
have just one 'prefetch' with an appropriate meaning
on each architecture.

LGTM=rlh
R=rlh
CC=golang-codereviews
https://golang.org/cl/179160043
2014-11-21 15:57:10 -05:00
David du Colombier
2f28916f02 [dev.cc] liblink: fix warnings on Plan 9
warning: src/liblink/list6.c:94 set and not used: s
warning: src/liblink/list6.c:157 format mismatch ld VLONG, arg 3
warning: src/liblink/list6.c:157 format mismatch E UINT, arg 4
warning: src/liblink/list6.c:157 format mismatch d VLONG, arg 5
warning: src/liblink/list6.c:163 set and not used: s
warning: src/liblink/list9.c:105 set and not used: s
warning: src/liblink/list9.c:185 format mismatch ld VLONG, arg 3
warning: src/liblink/list9.c:185 format mismatch E UINT, arg 4
warning: src/liblink/list9.c:185 format mismatch d VLONG, arg 5
warning: src/liblink/list9.c:193 set and not used: s

LGTM=rsc
R=rsc
CC=austin, golang-codereviews, minux
https://golang.org/cl/176130043
2014-11-21 20:56:33 +01:00
David du Colombier
213a6645ce [dev.cc] cmd/8g: fix warning on Plan 9
warning: /usr/go/src/cmd/8g/reg.c:365 format mismatch d VLONG, arg 5

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/177160043
2014-11-21 20:44:04 +01:00
David du Colombier
e9c57d8a2d [dev.cc] runtime: convert Plan 9 port to Go
Thanks to Aram Hăvărneanu, Nick Owens
and Russ Cox for the early reviews.

LGTM=aram, rsc
R=rsc, lucio.dere, aram, ality
CC=golang-codereviews, mischief
https://golang.org/cl/175370043
2014-11-21 19:39:01 +01:00
Russ Cox
ad8179281d [dev.cc] runtime: convert nacl support to Go
LGTM=dave
R=minux, dave
CC=golang-codereviews
https://golang.org/cl/181030043
2014-11-21 10:22:18 -05:00
Russ Cox
ce3e8e4edc [dev.cc] build: skip API checks on Windows too (not just Unix)
TBR=brainman
CC=golang-codereviews
https://golang.org/cl/175490043
2014-11-21 00:21:49 -05:00
Alex Brainman
841de809bb [dev.cc] runtime: windows does not use _cgo_setenv and _cgo_unsetenv
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/175480043
2014-11-21 15:59:22 +11:00
Alex Brainman
0a38b2cdaf [dev.cc] runtime: fix windows goenvs conversion mistake
uint16 occupies 2 bytes, not 1

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/178100043
2014-11-21 12:15:18 +11:00
Austin Clements
7b596457d1 [dev.cc] liblink: fix Solaris build some more
a->name and a->class are char, so Solaris doesn't like using
them as array indexes.  (This same problem was fixed for amd64
in CL 169630043.)

LGTM=aram, minux
R=rsc, minux, aram
CC=golang-codereviews
https://golang.org/cl/175430043
2014-11-20 14:28:54 -05:00
Rick Hudson
cc73a44f67 [dev.garbage] runtime: Fix constant overflow on 32 bit machines
LGTM=rsc
R=golang-codereviews
CC=golang-codereviews, rsc
https://golang.org/cl/180040043
2014-11-20 14:24:01 -05:00
Robert Griesemer
e538770d4b go/parser: Use test-specific filesets to avoid races.
Only affects test code.

Fixes #9025.
Fixes #9130.

LGTM=r, adonovan
R=adonovan, r
CC=golang-codereviews
https://golang.org/cl/180920043
2014-11-20 09:35:22 -08:00
Rick Hudson
8cfb084534 [dev.garbage] runtime: Turn concurrent GC on by default. Avoid write barriers for GC internal structures such as free lists.
LGTM=rsc
R=rsc
CC=golang-codereviews, rsc
https://golang.org/cl/179000043
2014-11-20 12:08:13 -05:00
Russ Cox
50e0749f87 [dev.cc] all: merge default (e4ab8f908aac) into dev.cc
TBR=austin
CC=golang-codereviews
https://golang.org/cl/179040044
2014-11-20 11:48:08 -05:00
Russ Cox
754de8d403 [dev.cc] all: merge dev.power64 (f57928630b36) into dev.cc
This will be the last dev.power64 merge; we'll finish on dev.cc.

TBR=austin
CC=golang-codereviews
https://golang.org/cl/175420043
2014-11-20 11:30:43 -05:00
Dmitriy Vyukov
2b3f379080 runtime: fix atomic operations on non-heap addresses
Race detector runtime does not tolerate operations on addresses
that was not previously declared with __tsan_map_shadow
(namely, data, bss and heap). The corresponding address
checks for atomic operations were removed in
https://golang.org/cl/111310044
Restore these checks.
It's tricker than just not calling into race runtime,
because it is the race runtime that makes the atomic
operations themselves (if we do not call into race runtime
we skip the atomic operation itself as well). So instead we call
__tsan_go_ignore_sync_start/end around the atomic operation.
This forces race runtime to skip all other processing
except than doing the atomic operation itself.
Fixes #9136.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/179030043
2014-11-20 09:51:02 -05:00
Russ Cox
361199749d build: disable race external linking test on OS X 10.6 and earlier
External linking doesn't work there at all.

LGTM=bradfitz
R=adg, bradfitz
CC=golang-codereviews
https://golang.org/cl/176070043
2014-11-19 20:52:58 -05:00
Alex Brainman
ab4578adef [dev.cc] runtime: convert remaining windows C code to Go
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/177090043
2014-11-20 12:24:03 +11:00
Russ Cox
378c2515ae runtime: remove assumption that noptrdata data bss noptrbss are ordered and contiguous
The assumption can be violated by external linkers reordering them or
inserting non-Go sections in between them. I looked briefly at trying
to write out the _go_.o in external linking mode in a way that forced
the ordering, but no matter what there's no way to force Go's data
and Go's bss to be next to each other. If there is any data or bss from
non-Go objects, it's very likely to get stuck in between them.

Instead, rewrite the two places we know about that make the assumption.
I grepped for noptrdata to look for more and didn't find any.

The added race test (os/exec in external linking mode) fails without
the changes in the runtime. It crashes with an invalid pointer dereference.

Fixes #9133.

LGTM=dneil
R=dneil
CC=dvyukov, golang-codereviews, iant
https://golang.org/cl/179980043
2014-11-19 15:25:33 -05:00
Austin Clements
f4a525452e [dev.cc] runtime: add explicit siginfo.si_addr field
struct siginfo_t's si_addr field is part of a union.
Previously, we represented this union in Go using an opaque
byte array and accessed the si_addr field using unsafe (and
wrong on 386 and arm!) pointer arithmetic.  Since si_addr is
the only field we use from this union, this replaces the
opaque byte array with an explicit declaration of the si_addr
field and accesses it directly.

LGTM=minux, rsc
R=rsc, minux
CC=golang-codereviews
https://golang.org/cl/179970044
2014-11-19 14:56:49 -05:00
Austin Clements
d11a425959 [dev.cc] runtime: decode power64 branch instructions the way the CPU does
Previously, this used the top 8 bits of an instruction as a
sort-of opcode and ignored the top two bits of the relative
PC.  This worked because these jumps are always negative and
never big enough for the top two bits of the relative PC (also
the bottom 2 bits of the sort-of opcode) to be anything other
than 0b11, but the code is confusing because it doesn't match
the actual structure of the instruction.

Instead, use the real 6 bit opcode and use all 24 bits of
relative PC.

LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/179960043
2014-11-19 14:24:41 -05:00
Russ Cox
2d53d6b5d5 undo CL 131750044 / 2d6d44ceb80e
Breaks reading from stdin in parent after exec with SysProcAttr{Setpgid: true}.

package main

import (
        "fmt"
        "os"
        "os/exec"
        "syscall"
)

func main() {
        cmd := exec.Command("true")
        cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
        cmd.Run()

        fmt.Printf("Hit enter:")
        os.Stdin.Read(make([]byte, 100))
        fmt.Printf("Bye\n")
}

In go1.3, I type enter at the prompt and the program exits.
With the CL being rolled back, the program wedges at the
prompt.

««« original CL description
syscall: SysProcAttr job control changes

Making the child's process group the foreground process group and
placing the child in a specific process group involves co-ordination
between the parent and child that must be done post-fork but pre-exec.

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

»»»

LGTM=minux, dneil
R=dneil, minux
CC=golang-codereviews, iant, michael.p.macinnis
https://golang.org/cl/174450043
2014-11-19 14:16:12 -05:00
Austin Clements
b76e836042 [dev.cc] runtime: allow more address bits in lfstack on Power64
Previously, lfstack assumed Linux limited user space addresses
to 43 bits on Power64 based on a paper from 2001.  It turns
out the limit is now 46 bits, so lfstack was truncating
pointers.

Raise the limit to 48 bits (for some future proofing and to
make it match amd64) and add a self-test that will fail in a
useful way if ever unpack(pack(x)) != x.

With this change, dev.cc passes all.bash on power64le.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/174430043
2014-11-19 11:30:58 -05:00
Alex Brainman
b27c0618eb [dev.cc] runtime: update sys_windows_386.s and sys_windows_amd64.s for Go conversion
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/176970043
2014-11-19 11:55:15 +11:00
Austin Clements
f4627d1b05 [dev.cc] runtime: merge power64 onM/onM_signalok into systemstack
This is the power64 component of CL 174950043.

With this, dev.cc compiles on power64 and power64le and passes
most tests if GOGC=off (but crashes in go_bootstrap if GC is
on).

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/175290043
2014-11-18 15:50:36 -05:00
Austin Clements
70f6769b60 [dev.cc] runtime: catch defs_linux_power64*.go up to other archs
Fix a constant conversion error.  Add set_{sec,nsec} for
timespec and set_usec for timeval.  Fix type of
sigaltstackt.ss_size.

LGTM=rsc
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/180840043
2014-11-18 15:19:48 -05:00
Austin Clements
0da27cb8b0 [dev.cc] runtime: convert power64-specific .c and .h files to Go
The power64 equivalent of CL 174860043

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/179890043
2014-11-18 15:19:37 -05:00
Austin Clements
3f27c3ae37 [dev.cc] runtime: convert power64 assembly files for C to Go transition
The power64 equivalent of CL 168510043

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/178940043
2014-11-18 15:19:26 -05:00
Austin Clements
54d731452d [dev.cc] runtime: convert power64 signal handlers from C to Go
The power64 equivalent of CL 168500044

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/175280043
2014-11-18 15:19:09 -05:00
Austin Clements
cf06ea68d5 [dev.cc] 9a: make RET a synonym for RETURN; use "g" instead of "R30"
Previously, 9a was the only assembler that had a different
name for RET, causing unnecessary friction in simple files
that otherwise assembled on all architectures.  Add RET so
these work on 9a.

This also renames "R30" to "g" to avoid unintentionally
clobbering g in assembly code.  This parallels a change made
to 5a.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/178030043
2014-11-18 15:18:52 -05:00
Austin Clements
1a68ac2538 [dev.cc] cmd/9c: remove
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/175940043
2014-11-18 15:18:42 -05:00
Russ Cox
0fe444d3e8 [dev.cc] runtime: generate GOOS- and GOARCH-specific files with go generate
Eventually I'd like almost everything cmd/dist generates
to be done with 'go generate' and checked in, to simplify
the bootstrap process. The only thing cmd/dist really needs
to do is write things like the current experiment info and
the current version.

This is a first step toward that. It replaces the _NaCl etc
constants with generated ones goos_nacl, goos_darwin,
goarch_386, and so on.

LGTM=dave, austin
R=austin, dave, bradfitz
CC=golang-codereviews, iant, r
https://golang.org/cl/174290043
2014-11-18 12:07:50 -05:00
Russ Cox
312a64ec4e [dev.cc] runtime: convert defs_linux_power64*.h to go
LGTM=austin
R=austin
CC=golang-codereviews
https://golang.org/cl/176990043
2014-11-18 11:38:23 -05:00
Austin Clements
0e8fed098c [dev.cc] runtime: two missed references to "M stack"
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/177940043
2014-11-18 09:54:50 -05:00
Alex Brainman
55f19ed866 runtime: fix getcallersp documentation
LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/180760043
2014-11-18 09:55:15 +11:00
David du Colombier
2c2a6df4e9 [dev.cc] cmd/gc: fix warning on Plan 9
warning: src/cmd/gc/walk.c:1769 set and not used: on

LGTM=rsc
R=rsc, minux
CC=golang-codereviews
https://golang.org/cl/175850043
2014-11-17 20:46:42 +01:00
Austin Clements
38fef031e1 cmd/pprof: fix EOF handling when getting function source
getFunctionSource gathers five lines of "margin" around every
requested sample line.  However, if this margin went past the
end of the source file, getFunctionSource would encounter an
io.EOF error and abort with this error, resulting in listings
like

    (pprof) list main.main
    ROUTINE ======================== main.main in ...
    0      8.33s (flat, cum) 99.17% of Total
    Error: EOF
    (pprof)

Modify the error handling in getFunctionSource so io.EOF is
always considered non-fatal.  If it reaches EOF, it simply
returns the lines it has.

LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/172600043
2014-11-17 14:44:41 -05:00
Alex Brainman
fc288681cf [dev.cc] runtime: replace deleted netpollfd function
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/169710043
2014-11-17 17:18:21 +11:00
Russ Cox
3e7d4f11c0 debug/goobj: move to cmd/internal/goobj
debug/goobj is not ready to be published but it is
needed for the various binary-reading commands.
Move to cmd/internal/goobj.

(The Go 1.3 release branch deleted it, but that's not
an option anymore due to the command dependencies.
The API is still not vetted nor terribly well designed.)

LGTM=adg, dsymonds
R=adg, dsymonds
CC=golang-codereviews
https://golang.org/cl/174250043
2014-11-16 20:52:45 -05:00
David du Colombier
7aa89ea798 [dev.cc] cmd/8g: work around "out of fixed registers" on Plan 9
This change works around the "out of fixed registers"
issue with the Plan 9 C compiler on 386, introduced by
the Bits change to uint64 in CL 169060043.

The purpose of this CL is to be able to properly
follow the conversion of the Plan 9 runtime to Go
on the Plan 9 builders.

This CL could be reverted once the Go compilers will
be converted to Go.

Thanks to Nick Owens for investigating this issue.

LGTM=rsc
R=rsc
CC=austin, golang-codereviews, mischief
https://golang.org/cl/177860043
2014-11-16 22:55:07 +01:00
Russ Cox
3034be60d8 [dev.garbage] all: merge dev.cc (723ca3789b88) into dev.garbage
Brings in Linux time signature fixes. Should fix build.

TBR=austin
CC=golang-codereviews
https://golang.org/cl/176870043
2014-11-16 16:53:53 -05:00
Russ Cox
b3932baba4 runtime: fix sudog leak
The SudoG used to sit on the stack, so it was cheap to allocated
and didn't need to be cleaned up when finished.

For the conversion to Go, we had to move sudog off the stack
for a few reasons, so we added a cache of recently used sudogs
to keep allocation cheap. But we didn't add any of the necessary
cleanup before adding a SudoG to the new cache, and so the cached
SudoGs had stale pointers inside them that have caused all sorts
of awful, hard to debug problems.

CL 155760043 made sure SudoG.elem is cleaned up.
CL 150520043 made sure SudoG.selectdone is cleaned up.

This CL makes sure SudoG.next, SudoG.prev, and SudoG.waitlink
are cleaned up. I should have done this when I did the other two
fields; instead I wasted a week tracking down a leak they caused.

A dangling SudoG.waitlink can point into a sudogcache list that
has been "forgotten" in order to let the GC collect it, but that
dangling .waitlink keeps the list from being collected.
And then the list holding the SudoG with the dangling waitlink
can find itself in the same situation, and so on. We end up
with lists of lists of unusable SudoGs that are still linked into
the object graph and never collected (given the right mix of
non-trivial selects and non-channel synchronization).

More details in golang.org/issue/9110.

Fixes #9110.

LGTM=r
R=r
CC=dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/177870043
2014-11-16 16:44:45 -05:00
Russ Cox
6150414cb8 runtime: update URL for heap dump format
I just created that redirect, so we can change
it once the wiki moves.

LGTM=bradfitz, khr
R=khr, bradfitz
CC=golang-codereviews
https://golang.org/cl/177780043
2014-11-16 14:25:33 -05:00
Russ Cox
0fcf54b3d2 [dev.garbage] all: merge dev.cc into dev.garbage
The garbage collector is now written in Go.
There is plenty to clean up (just like on dev.cc).

all.bash passes on darwin/amd64, darwin/386, linux/amd64, linux/386.

TBR=rlh
R=austin, rlh, bradfitz
CC=golang-codereviews
https://golang.org/cl/173250043
2014-11-15 08:00:38 -05:00
Dave Cheney
2ceca80e3f [dev.cc] runtime: fix _sfloat thunk
* _sfloat dispatches to runtime._sfloat2 with the Go calling convention, so the seecond argument is a [15]uint32, not a *[15]uint32.
* adjust _sfloat2 to return the new pc in 68(R13) as expected.

LGTM=rsc
R=minux, austin, rsc
CC=golang-codereviews
https://golang.org/cl/174160043
2014-11-15 13:27:05 +11:00
Dave Cheney
14d23bfd7b [dev.cc] runtime: fix bus error accessing auxv random data on arm5
It's rather unsporting of the kernel to give us a pointer to unaligned memory.

This fixes one crash, the next crash occurs in the soft float emulation.

LGTM=minux, rsc, austin
R=minux, rsc, austin
CC=golang-codereviews
https://golang.org/cl/177730043
2014-11-15 09:57:02 +11:00
David du Colombier
1f420c13bd [dev.cc] liblink: fix warnings on Plan 9
warning: src/liblink/asm9.c:501 set and not used: bflag
warning: src/liblink/list9.c:259 format mismatch .5lux INT, arg 4
warning: src/liblink/list9.c:261 format mismatch .5lux INT, arg 3
warning: src/liblink/list9.c:319 more arguments than format VLONG
warning: src/liblink/obj9.c:222 set and not used: autoffset

LGTM=bradfitz, austin
R=rsc, bradfitz
CC=austin, golang-codereviews
https://golang.org/cl/175070043
2014-11-14 22:57:33 +01:00
Austin Clements
7904e951d4 [dev.power64] liblink: fix Solaris build
a->class is a char.  Boo hoo.

LGTM=minux
R=rsc, minux
CC=golang-codereviews
https://golang.org/cl/169630043
2014-11-14 15:53:15 -05:00
Russ Cox
580cba42f4 [dev.cc] runtime: change set_sec to take int64
Fixes build.
Tested that all these systems can make.bash.

TBR=austin
CC=golang-codereviews
https://golang.org/cl/177770043
2014-11-14 14:50:00 -05:00
Austin Clements
1222cc4682 [dev.power64] 6g,9g: formatters for Prog and Addr details
The pretty printers for these make it hard to understand
what's actually in the fields of these structures.  These
"ugly printers" show exactly what's in each field, which can
be useful for understanding and debugging code.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/175780043
2014-11-14 13:58:31 -05:00
Russ Cox
5fce15a2a3 [dev.cc] runtime: fix lfstack for amd64 addresses in top half of addr space
While we are here, add the linux/power64 version.

LGTM=austin
R=austin
CC=aram, dvyukov, golang-codereviews
https://golang.org/cl/177750043
2014-11-14 12:55:23 -05:00
Russ Cox
a87e4a2d01 [dev.cc] runtime: fix linux build
TBR=austin
CC=golang-codereviews
https://golang.org/cl/176760044
2014-11-14 12:55:10 -05:00
Joel Sing
1d05d5880e [dev.cc] runtime: convert dragonfly/amd64 port to Go
LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/176750043
2014-11-15 04:47:20 +11:00
Russ Cox
3e804631d9 [dev.cc] all: merge dev.power64 (7667e41f3ced) into dev.cc
This is to reduce the delta between dev.cc and dev.garbage to just garbage collector changes.

These are the files that had merge conflicts and have been edited by hand:
        malloc.go
        mem_linux.go
        mgc.go
        os1_linux.go
        proc1.go
        panic1.go
        runtime1.go

LGTM=austin
R=austin
CC=golang-codereviews
https://golang.org/cl/174180043
2014-11-14 12:10:52 -05:00
Russ Cox
9ef4e56108 [dev.garbage] all: merge dev.power64 (7667e41f3ced) into dev.garbage
Now the only difference between dev.cc and dev.garbage
is the runtime conversion on the one side and the
garbage collection on the other. They both have the
same set of changes from default and dev.power64.

LGTM=austin
R=austin
CC=golang-codereviews
https://golang.org/cl/172570043
2014-11-14 12:09:42 -05:00
Austin Clements
a11f256436 [dev.power64] liblink: generate dnames[5689] for D_* constants
This is more complicated than the other enums because the D_*
enums are full of explicit initializers and repeated values.
This tries its best.  (This will get much cleaner once we
tease these constants apart better.)

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/166700043
2014-11-14 12:08:46 -05:00
Austin Clements
5b38501a4f [dev.power64] 5g,6g,8g,9g: debug prints for regopt pass 6 and paint2
Theses were very helpful in understanding the regions and
register selection when porting regopt to 9g.  Add them to the
other compilers (and improve 9g's successor debug print).

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/174130043
2014-11-14 11:56:31 -05:00
Joel Sing
9ad6b7e322 [dev.cc] runtime: convert openbsd/386 port to Go
LGTM=rsc
R=golang-codereviews, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/173200044
2014-11-15 03:55:14 +11:00
Russ Cox
3dcc62e1da [dev.garbage] all: merge default (f38460037b72) into dev.garbage
This is the revision that dev.cc is branched from.

LGTM=austin
R=austin
CC=golang-codereviews
https://golang.org/cl/169590043
2014-11-14 11:37:54 -05:00
Austin Clements
9e7bed88cd [dev.power64] 5g,6g,8g: synchronize documentation for regopt structures
I added several comments to the regopt-related structures when
porting it to 9g.  Synchronize those comments back in to the
other compilers.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/175720043
2014-11-14 11:07:33 -05:00
Aram Hăvărneanu
9d6825edee [dev.cc] runtime: fix nil pointer crash handler bug on Solaris
This change fixes the Solaris port.

LGTM=dave, rsc
R=rsc, dave
CC=brad, golang-codereviews
https://golang.org/cl/168600045
2014-11-14 14:25:49 +01:00
Alex Brainman
0438182c30 [dev.cc] runtime: convert netpoll_windows.c to Go
LGTM=rsc
R=rsc
CC=dvyukov, golang-codereviews
https://golang.org/cl/172530043
2014-11-14 14:07:28 +11:00
Joel Sing
ba603c3100 [dev.cc] runtime: convert openbsd/amd64 port to Go
LGTM=rsc
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/171660043
2014-11-14 13:01:12 +11:00
Nigel Tao
891abf9cc7 net/http: add comment to clarify whether Dir is '/' or '\'.
LGTM=bradfitz
R=bradfitz, alex.brainman
CC=golang-codereviews
https://golang.org/cl/168600044
2014-11-14 11:43:01 +11:00
Austin Clements
743bdf612a [dev.power64] 9g: implement regopt
This adds registerization support to 9g equivalent to what the
other compilers have.

LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/174980043
2014-11-13 13:51:44 -05:00
Austin Clements
231b8d61e9 [dev.power64] 9l: remove enum as's tag for c2go
None of the other compilers have a tag for this enum.
Cleaning all of this up to use proper types will happen after
the conversion.

LGTM=minux, rsc
R=rsc, minux
CC=golang-codereviews
https://golang.org/cl/166690043
2014-11-13 13:48:59 -05:00
Austin Clements
c3dadb3d19 [dev.power64] 6g,8g: remove unnecessary and incorrect reg use scanning
Previously, the 6g and 8g registerizers scanned for used
registers beyond the end of a region being considered for
registerization.  This ancient artifact was copied from the C
compilers, where it was probably necessary to track implicitly
used registers.  In the Go compilers it's harmless (because it
can only over-restrict the set of available registers), but no
longer necessary because the Go compilers correctly track
register use/set information.  The consequences of this extra
scan were (at least) that 1) we would not consider allocating
the AX register if there was a deferproc call in the future
because deferproc uses AX as a return register, so we see the
use of AX, but don't track that AX is set by the CALL, and 2)
we could not consider allocating the DX register if there was
a MUL in the future because MUL implicitly sets DX and (thanks
to an abuse of copyu in this code) we would also consider DX
used.

This commit fixes these problems by nuking this code.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/174110043
2014-11-13 13:34:20 -05:00
Joel Sing
b2ec4cf50c [dev.cc] runtime: make SIGSYS notifiable on freebsd (again)
This was originally done to the C port in rev 17d3b45534b5 and
seemingly got lost during the conversion.

LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/167700043
2014-11-14 04:29:03 +11:00
Aram Hăvărneanu
e088e16256 [dev.cc] runtime: convert Solaris port to Go
Memory management was consolitated with the BSD ports, since
it was almost identical.

Assembly thunks are gone, being replaced by the new //go:linkname
feature.

This change supersedes CL 138390043 (runtime: convert solaris
netpoll to Go), which was previously reviewed and tested.

This change is only the first step, the port now builds,
but doesn't run. Binaries fail to exec:

    ld.so.1: 6.out: fatal: 6.out: TLS requirement failure : TLS support is unavailable
    Killed

This seems to happen because binaries don't link with libc.so
anymore. We will have to solve that in a different CL.

Also this change is just a rough translation of the original
C code, cleanup will come in a different CL.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=rsc
R=rsc, dave
CC=golang-codereviews, iant, khr, minux, r, rlh
https://golang.org/cl/174960043
2014-11-13 16:07:10 +01:00
Alex Brainman
a0862a175d [dev.cc] runtime: convert mem_windows.c to Go
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/175000043
2014-11-13 14:53:13 +11:00
Alex Brainman
e5d01a5ffc [dev.cc] runtime: add missing cb_max const
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/169490043
2014-11-13 12:05:36 +11:00
Brad Fitzpatrick
38ea0ae05f net/url: add example of using URL.Opaque with http.Request
Per private thread soliciting help. I realized part of this is
documented in several places, but we lacked a unifying
example.

LGTM=rsc
R=golang-codereviews
CC=adg, golang-codereviews, iant, rsc
https://golang.org/cl/171620043
2014-11-12 14:27:27 -08:00
Joel Sing
37cae806cb [dev.cc] [dev.cc] runtime: fix freebsd cgo __progname export
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/174050043
2014-11-12 17:18:22 -05:00
Austin Clements
60f66aa817 [dev.power64] 9g: proginfo fixes
For D_OREG addresses, store the used registers in regindex
instead of reguse because they're really part of addressing.

Add implicit register use/set for DUFFZERO/DUFFCOPY.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/174050044
2014-11-12 14:58:43 -05:00
Russ Cox
656be317d0 [dev.cc] runtime: delete scalararg, ptrarg; rename onM to systemstack
Scalararg and ptrarg are not "signal safe".
Go code filling them out can be interrupted by a signal,
and then the signal handler runs, and if it also ends up
in Go code that uses scalararg or ptrarg, now the old
values have been smashed.
For the pieces of code that do need to run in a signal handler,
we introduced onM_signalok, which is really just onM
except that the _signalok is meant to convey that the caller
asserts that scalarg and ptrarg will be restored to their old
values after the call (instead of the usual behavior, zeroing them).

Scalararg and ptrarg are also untyped and therefore error-prone.

Go code can always pass a closure instead of using scalararg
and ptrarg; they were only really necessary for C code.
And there's no more C code.

For all these reasons, delete scalararg and ptrarg, converting
the few remaining references to use closures.

Once those are gone, there is no need for a distinction between
onM and onM_signalok, so replace both with a single function
equivalent to the current onM_signalok (that is, it can be called
on any of the curg, g0, and gsignal stacks).

The name onM and the phrase 'm stack' are misnomers,
because on most system an M has two system stacks:
the main thread stack and the signal handling stack.

Correct the misnomer by naming the replacement function systemstack.

Fix a few references to "M stack" in code.

The main motivation for this change is to eliminate scalararg/ptrarg.
Rick and I have already seen them cause problems because
the calling sequence m.ptrarg[0] = p is a heap pointer assignment,
so it gets a write barrier. The write barrier also uses onM, so it has
all the same problems as if it were being invoked by a signal handler.
We worked around this by saving and restoring the old values
and by calling onM_signalok, but there's no point in keeping this nice
home for bugs around any longer.

This CL also changes funcline to return the file name as a result
instead of filling in a passed-in *string. (The *string signature is
left over from when the code was written in and called from C.)
That's arguably an unrelated change, except that once I had done
the ptrarg/scalararg/onM cleanup I started getting false positives
about the *string argument escaping (not allowed in package runtime).
The compiler is wrong, but the easiest fix is to write the code like
Go code instead of like C code. I am a bit worried that the compiler
is wrong because of some use of uninitialized memory in the escape
analysis. If that's the reason, it will go away when we convert the
compiler to Go. (And if not, we'll debug it the next time.)

LGTM=khr
R=r, khr
CC=austin, golang-codereviews, iant, rlh
https://golang.org/cl/174950043
2014-11-12 14:54:31 -05:00
Russ Cox
e98f2d597e [dev.cc] runtime/cgo: add comment about import _ "unsafe"
LGTM=bradfitz, r
R=r, bradfitz
CC=golang-codereviews
https://golang.org/cl/167650043
2014-11-12 14:54:04 -05:00
Rick Hudson
18ed947ee1 [dev.garbage] runtime: Add write barriers to c code
Also improve missing GC mark diagnostics.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/169450043
2014-11-12 14:20:53 -05:00
Austin Clements
c1e8c57c3d [dev.power64] 9g: fix width check and width calculation for OADDR
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/174970043
2014-11-12 14:16:49 -05:00
Nigel Tao
de7d1c4094 hash/crc32: fix comment that the IEEE polynomial applies to MPEG-2.
LGTM=minux
R=adg, minux
CC=golang-codereviews
https://golang.org/cl/170520043
2014-11-12 18:48:00 +11:00
Russ Cox
a9695a5d38 [dev.cc] runtime/cgo: fix freebsd build?
Last try and then someone with a FreeBSD has to do it.

TBR=r
CC=golang-codereviews
https://golang.org/cl/171590043
2014-11-11 23:28:26 -05:00
Russ Cox
9e719ceefe [dev.cc] runtime: fix arm5 build
TBR=r
CC=golang-codereviews
https://golang.org/cl/168600043
2014-11-11 23:24:54 -05:00
Russ Cox
22293bb1a4 [dev.cc] runtime/cgo: add missing import _ "unsafe" for //go:linkname
Will prod freebsd build along.
Not claiming it will fix it.

TBR=r
CC=golang-codereviews
https://golang.org/cl/171580044
2014-11-11 23:19:59 -05:00
Russ Cox
aac17fd4e1 [dev.cc] runtime: convert freebsd to Go
It builds.
Don't know if it works, but it's a lot closer than having everything in C.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/168590043
2014-11-11 23:00:29 -05:00
Russ Cox
c81d248eca [dev.cc] runtime: convert softfloat_arm.c to Go + build fixes
Also include onM_signalok fix from issue 8995.

Fixes linux/arm build.
Fixes #8995.

LGTM=r
R=r, dave
CC=golang-codereviews
https://golang.org/cl/168580043
2014-11-11 22:30:02 -05:00
Robin Eklind
04c7b68b4a regexp/syntax: Clarify comment of OpAnyCharNotNL.
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/171560043
2014-11-11 18:52:07 -08:00
Russ Cox
8420df622a [dev.cc] runtime: bring back mgc0.h
This was recorded as an hg mv instead of an hg cp.
For now a C version is needed for the Go compiler.

TBR=r
CC=golang-codereviews
https://golang.org/cl/174020043
2014-11-11 18:50:02 -05:00
Russ Cox
9204821731 [dev.cc] runtime: convert arch-specific .c and .h files to Go
The conversion was done with an automated tool and then
modified only as necessary to make it compile and run.

vlrt.c was only called from C. Pure delete.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=r
R=r, austin
CC=dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/174860043
2014-11-11 17:09:09 -05:00
Russ Cox
e785e3acf8 [dev.cc] runtime: convert operating system support code from C to Go
The conversion was done with an automated tool and then
modified only as necessary to make it compile and run.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=r
R=r
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/174830044
2014-11-11 17:08:54 -05:00
Russ Cox
b2cdf30eb6 [dev.cc] runtime: convert scheduler from C to Go
The conversion was done with an automated tool and then
modified only as necessary to make it compile and run.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=r
R=r, daniel.morsing
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/172260043
2014-11-11 17:08:33 -05:00
Russ Cox
59e3e5354d [dev.cc] runtime: convert race implementation from C to Go
The conversion was done with an automated tool and then
modified only as necessary to make it compile and run.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=r
R=r
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/172250044
2014-11-11 17:08:14 -05:00
Russ Cox
ece09790af [dev.cc] runtime: convert parallel support code from C to Go
The conversion was done with an automated tool and then
modified only as necessary to make it compile and run.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=r
R=r, austin
CC=dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/172250043
2014-11-11 17:07:54 -05:00
Russ Cox
580ef3e4af [dev.cc] runtime: convert defs_$GOOS_$GOARCH.h to Go
The conversion was done with an automated tool and then
modified only as necessary to make it compile and run.

In a few cases, defs_$GOOS_$GOARCH.go already existed,
so the target here is defs1_$GOOS_$GOARCH.go.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=r
R=r
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/171490043
2014-11-11 17:07:37 -05:00
Russ Cox
0c3c2c1724 [dev.cc] runtime: convert basic library routines from C to Go
float.c held bit patterns for special float64 values,
hiding from the real uses. Rewrite Go code not to
refer to those values directly.

Convert library routines in runtime.c and string.c.

LGTM=r
R=r, dave
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/170330043
2014-11-11 17:07:06 -05:00
Russ Cox
7b3ebb131f [dev.cc] build: disable API check until all systems build
Otherwise no system will get an 'ok' until they all do.

LGTM=r, dave
R=r, dave
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/170320044
2014-11-11 17:06:41 -05:00
Russ Cox
15ced2d008 [dev.cc] runtime: convert assembly files for C to Go transition
The main change is that #include "zasm_GOOS_GOARCH.h"
is now #include "go_asm.h" and/or #include "go_tls.h".

Also, because C StackGuard is now Go _StackGuard,
the assembly name changes from const_StackGuard to
const__StackGuard.

In asm_$GOARCH.s, add new function getg, formerly
implemented in C.

The renamed atomics now have Go wrappers, to get
escape analysis annotations right. Those wrappers
are in CL 174860043.

LGTM=r, aram
R=r, aram
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/168510043
2014-11-11 17:06:22 -05:00
Russ Cox
2d917c0c26 [dev.cc] runtime: convert signal handlers from C to Go
This code overused macros and could not be
converted automatically. Instead a new sigctxt
type had to be defined for each os/arch combination,
with a common (implicit) interface used by the
arch-specific signal handler code.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=r
R=r
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/168500044
2014-11-11 17:05:55 -05:00
Russ Cox
9f99d531a0 [dev.cc] runtime/cgo: convert from C to Go
The conversion was done with an automated tool and then
modified only as necessary to make it compile and run.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=r
R=r
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/168500043
2014-11-11 17:05:37 -05:00
Russ Cox
fee9e47559 [dev.cc] runtime: convert header files to Go
The conversion was done with an automated tool and then
modified only as necessary to make it compile and run.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=r
R=r, austin
CC=dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/167550043
2014-11-11 17:05:19 -05:00
Russ Cox
1e2d2f0947 [dev.cc] runtime: convert memory allocator and garbage collector to Go
The conversion was done with an automated tool and then
modified only as necessary to make it compile and run.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=r
R=r
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/167540043
2014-11-11 17:05:02 -05:00
Russ Cox
d98553a727 [dev.cc] runtime: convert panic and stack code from C to Go
The conversion was done with an automated tool and then
modified only as necessary to make it compile and run.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=r
R=r, dave
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/166520043
2014-11-11 17:04:34 -05:00
Russ Cox
9eded54fa3 [dev.garbage] runtime: concurrent mark fixes
Add missing write barrier when initializing state
for newly created goroutine. Add write barrier for
same slot when preempting a goroutine.

Disable write barrier during goroutine death,
because dopanic does pointer writes.

With concurrent mark enabled (not in this CL), all.bash passed once.
The second time, TestGoexitCrash-2 failed.

LGTM=rlh
R=rlh
CC=golang-codereviews
https://golang.org/cl/167610043
2014-11-11 16:54:50 -05:00
Russ Cox
0d49f7b5fc [dev.cc] cmd/dist: adjust for build process without cmd/cc
[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

- Remove references to C compiler directories.
- Remove generation of special header files.
- Remove generation of Go source files from C declarations.

- Compile Go sources before rest of package (was after),
  so that Go compiler can write go_asm.h for use in assembly.

- Move TLS information from cmd/dist (was embedding in output)
  to src/runtime/go_tls.h, which it can be maintained directly.

LGTM=r
R=r, dave
CC=austin, golang-codereviews, iant, khr
https://golang.org/cl/172960043
2014-11-11 01:29:05 -05:00
Russ Cox
0185ba76ed [dev.cc] liblink: resolve bss vs other conflict regardless of order found
If the linker finds the same name given a BSS and a non-BSS
symbol, the assumption is that the non-BSS symbol is the
true one, and the BSS symbol is just the best Go can do toward
an "extern" declaration. This has always been the case,
as long as the object files were read in the right order.

The old code worked when the BSS symbol is found before
the non-BSS symbol. This CL adds equivalent logic for when
the non-BSS symbol is found before the BSS symbol.
This comes up when Go must refer to symbols defined in
host object files.

LGTM=r
R=r
CC=austin, golang-codereviews, iant, khr
https://golang.org/cl/171480043
2014-11-11 01:28:26 -05:00
Russ Cox
729847cf8a [dev.cc] cmd/go: adjust go, cgo builds & disable cc
[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

Make gcToolchain.cc return an error (no C compiler!).

Adjust expectations of cgo, now that cgo does not write any C files
(no C compiler!).

For packages with .s files, invoke Go compiler with -asmhdr go_asm.h
so that assembly files can use it. This applies to all packages but is only
needed today by package runtime.

LGTM=r
R=r
CC=austin, golang-codereviews, iant, khr
https://golang.org/cl/171470043
2014-11-11 01:27:55 -05:00
Russ Cox
fd2bc95d53 [dev.cc] cmd/gc: changes for removing runtime C code
[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

export.c, lex.c:
Add -asmhdr flag to write assembly header file with struct
field offsets and const values. cmd/dist used to construct this
file by interpreting output from the C compiler.
Generate it from the Go definitions instead.
Also, generate the form we need directly, instead of relying
on cmd/dist for reprocessing.

lex.c, obj.c:
If the C compiler accepted #pragma cgo_xxx, recognize
a directive //go:cgo_xxx instead. The effect is the same as
in the C compiler: accumulate text into a buffer and emit in the
output file, where the linker will find and use it.

lex.c, obj.c:
Accept //go:linkname to control the external symbol name
used for a particular top-level Go variable. This makes it
possible to refer to C symbol names but also symbols from
other packages. It has always been possible to do this from
C and assembly. To drive home the point that this should not
be done lightly, require import "unsafe" in any file containing
//go:linkname.

plive.c, reflect.c, subr.c:
Hard-code that interfaces contain only pointers.
This means code handling multiword values in the garbage
collector and the stack copier can be deleted instead of being
converted. This change is already present in the dev.garbage
branch.

LGTM=r
R=r
CC=austin, golang-codereviews, iant, khr
https://golang.org/cl/169360043
2014-11-11 01:27:30 -05:00
Russ Cox
25f9f5d082 [dev.cc] cmd/cgo: generate only Go source files
[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

We changed cgo to write the actual function wrappers in Go
for Go 1.4. The only code left in C output files was the definitions
for pointers to C data and the #pragma cgo directives.
Write both of those to Go outputs instead, using the new
compiler directives introduced in CL 169360043.

(Still generating C files in gccgo mode.)

LGTM=r
R=r
CC=austin, golang-codereviews, iant, khr
https://golang.org/cl/169330045
2014-11-11 01:23:19 -05:00
Russ Cox
33e910296e [dev.cc] reflect: interfaces contain only pointers
[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

Adjustments for changes made in CL 169360043.
This change is already present in the dev.garbage branch.

LGTM=r
R=r
CC=austin, golang-codereviews, iant, khr
https://golang.org/cl/167520044
2014-11-11 01:23:01 -05:00
Russ Cox
4a42fae2cd [dev.cc] cmd/5c, cmd/6c, cmd/8c, cmd/cc: remove
Let's just do this up front.
This will break the build (here on the dev.cc branch).
The CLs that follow will take care of fixing it.

Leave behind cmd/cc/lexbody and cmd/cc/macbody for the assemblers.
They'll go away later.

LGTM=dave, r
R=r, dave
CC=golang-codereviews
https://golang.org/cl/172170043
2014-11-10 22:40:44 -05:00
Russ Cox
37186d91fa [dev.garbage] runtime: add write barrier to casp
Also rewrite some casp that don't use real pointers
to use casuintptr instead.

LGTM=rlh
R=rlh
CC=golang-codereviews
https://golang.org/cl/166440044
2014-11-10 14:59:36 -05:00
Rick Hudson
28c5385965 [dev.garbage] runtime: Coarsen the write barrier to always grey the destination.
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/174820043
2014-11-10 14:32:02 -05:00
Rick Hudson
d3d60975b4 [dev.garbage] runtime: Code to implement write barriers
To turn concurrent gc on alter the if false in func gogc
currently at line 489 in malloc.go

LGTM=rsc
R=rsc
CC=golang-codereviews, rlh
https://golang.org/cl/172190043
2014-11-10 13:42:34 -05:00
Ian Lance Taylor
63fe9efb90 cmd/cgo: tweak doc to not show example of passing Go pointer
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/171360043
2014-11-10 08:12:43 -08:00
Ian Lance Taylor
cea69d6877 crypto/x509: add Solaris certificate file location
Fixes #9078.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/172920043
2014-11-09 20:57:44 -08:00
Ian Lance Taylor
f666167572 cmd/5g: fix bit mask for div/mod routines clobbering R12
This patch is based only on reading the code.  I have not
tried to construct a test case.

Fixes #9077.

LGTM=minux
R=minux
CC=golang-codereviews
https://golang.org/cl/172110043
2014-11-09 18:55:36 -08:00
Russ Cox
a697c4b439 cmd/internal/objfile: minor edits
Follow-up in response to comments on
TBR'ed CL 171260043.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/172080043
2014-11-09 20:21:37 -05:00
Russ Cox
2ad99f0960 runtime: fix sudog leak in syncsemrelease
Manifested as increased memory usage in a Google production system.

Not an unbounded leak, but can significantly increase the number
of sudogs allocated between garbage collections.

I checked all the other calls to acquireSudog.
This is the only one that was missing a releaseSudog.

LGTM=r, dneil
R=dneil, r
CC=golang-codereviews
https://golang.org/cl/169260043
2014-11-09 20:21:03 -05:00
Russ Cox
2cd05c3404 runtime/cgo: add +build tags to files named for $GOOS
These are being built into the runtime/cgo for every
operating system. It doesn't seem to matter, but
restore the Go 1.3 behavior anyway.

LGTM=r
R=r, dave
CC=golang-codereviews
https://golang.org/cl/171290043
2014-11-09 20:20:45 -05:00
Russ Cox
9bc842ca18 cmd/dist: remove old misc/pprof
LGTM=dave, bradfitz, r, alex.brainman
R=r, dave, bradfitz, alex.brainman
CC=golang-codereviews
https://golang.org/cl/167350043
2014-11-09 20:20:26 -05:00
Russ Cox
af3e02e404 cmd/pprof: install as go tool pprof
LGTM=bradfitz, r
R=r, bradfitz
CC=golang-codereviews
https://golang.org/cl/168320043
2014-11-09 20:20:06 -05:00
Andrew Gerrand
b53bdd496c undo CL 169000043 / 05b838013df9
This was a mistake. The cmd/api tool
depends on an old version of go/types.

««« original CL description
cmd/api: use golang.org/x/... import paths

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

TBR=rsc, bradfitz
R=bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/169320043
2014-11-10 09:46:27 +11:00
Andrew Gerrand
9a571deed6 undo CL 166380043 / 0b54a0927656
This was a mistake; the cmd/api tool
depends on an old version of go/types.

««« original CL description
cmd/api: bump go.tools golden CL hash

TBR=bradfitz
R=rsc
CC=golang-codereviews
https://golang.org/cl/166380043
»»»

TBR=bradfitz, rsc
R=bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/167430043
2014-11-10 09:39:17 +11:00
Andrew Gerrand
18b4f06b13 cmd/api: bump go.tools golden CL hash
TBR=bradfitz
R=rsc
CC=golang-codereviews
https://golang.org/cl/166380043
2014-11-10 09:30:57 +11:00
Andrew Gerrand
844889dfe2 cmd/go: use golang.org/x/... import paths
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/168170043
2014-11-10 09:27:25 +11:00
Andrew Gerrand
7f0be1f781 all: use golang.org/x/... import paths
LGTM=rsc, r
R=r, rsc
CC=golang-codereview, golang-codereviews
https://golang.org/cl/168050043
2014-11-10 09:15:57 +11:00
Andrew Gerrand
68e2dbe8b7 cmd/api: use golang.org/x/... import paths
LGTM=bradfitz, rsc
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/169000043
2014-11-10 09:13:04 +11:00
Brad Fitzpatrick
cf105e2fa0 net/http: fix benchmark goroutine leak
New detection because of net/http now using TestMain.

Fixes #9033

LGTM=iant
R=golang-codereviews, iant
CC=adg, golang-codereviews, rsc
https://golang.org/cl/170210043
2014-11-08 15:13:28 -03:00
Ian Lance Taylor
1340c6d593 cmd/go: disable warnings from cmd/cc when building for SWIG
Fixes #9065.

LGTM=rsc
R=rsc, misch
CC=golang-codereviews
https://golang.org/cl/171270043
2014-11-07 08:19:19 -08:00
Austin Clements
7739533f61 [dev.power64] 5g: fix mistaken bit-wise AND in regopt
Replace a bit-wise AND with a logical one.  This happened to
work before because bany returns 0 or 1, but the intent here
is clearly logical (and this makes 5g match with 6g and 8g).

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/172850043
2014-11-07 10:43:55 -05:00
Russ Cox
ec7f33300f cmd/internal/objfile: add Disasm
This was missing from CL 167320043.
Happy to apply comments in a followup.
TBR to fix build.

TBR=r
CC=golang-codereviews
https://golang.org/cl/171260043
2014-11-06 20:08:00 -05:00
Russ Cox
6bd0d0542e cmd/objdump, cmd/pprof: factor disassembly into cmd/internal/objfile
Moving so that new Go 1.4 pprof can use it.

The old 'GNU objdump workalike' mode for 'go tool objdump'
is now gone, as are the tests for that mode. It was used only
by pre-Go 1.4 pprof. You can still specify an address range on
the command line; you just get the same output format as
you do when dumping the entire binary (without an address
limitation).

LGTM=r
R=r
CC=golang-codereviews, iant
https://golang.org/cl/167320043
2014-11-06 19:56:55 -05:00
Austin Clements
e156f0e997 [dev.power64] 5g: fix etype and width of itable Addrs
For OITAB nodes, 5g's naddr was setting the wrong etype and
failing to set the width of the resulting Addr.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/171220043
2014-11-06 15:35:53 -05:00
Austin Clements
22c929f538 [dev.power64] 9g: fix addr width calculation; enable MOV* width check
9g's naddr was missing assignments to a->width in several
cases, so the optimizer was getting bogus width information.
Add them.

This correct width information also lets us enable the width
check in gins for MOV*.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/167310043
2014-11-06 14:41:44 -05:00
Austin Clements
f45fd5753c [dev.power64] gc: fix etype of strings
The etype of references to strings was being incorrectly set
to TINT32 on all platforms.  Change it to TSTRING.  It seems
this doesn't matter for compilation, since x86 uses LEA
instructions to load string addresses and arm and power64
disassemble the string into its constituent pieces (with the
correct types), but it helps when debugging.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/170100043
2014-11-06 14:37:39 -05:00
Keith Randall
5b110c7b08 runtime: don't stop bitmap dump at BitsDead
Stack bitmaps need to be scanned past any BitsDead entries.

Object bitmaps will not have any BitsDead in them (bitmap extraction stops at
the first BitsDead entry in makeheapobjbv).  data/bss bitmaps also have no BitsDead entries.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/168270043
2014-11-06 09:30:41 -08:00
Russ Cox
6ad16c4a48 runtime: fix initial gp->sched.pc in newextram
CL 170720043 missed this one when adding +PCQuantum.

LGTM=iant
R=r, iant
CC=golang-codereviews
https://golang.org/cl/168090043
2014-11-06 09:37:04 -05:00
Russ Cox
1cdd9b407d os: document that users of Fd should keep f alive
Fixes #9046.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/162680043
2014-11-06 09:36:51 -05:00
Keith Randall
23ecad07cd os/exec: tell lsof not to block
For some reason lsof is now hanging on my workstation
without the -b (avoid blocking in the kernel) option.
Adding -b makes the test pass and shouldn't hurt.

I don't know how recent the -b option is.  If the builders
are ok with it, it's probably ok.

LGTM=rsc
R=golang-codereviews, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/166220043
2014-11-05 20:25:20 -08:00
Andrew Gerrand
908dcab6f8 bufio: remove unused 'panicked' variable from test
LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/166230044
2014-11-06 15:22:29 +11:00
Russ Cox
39bcbb353c runtime: avoid gentraceback of self on user goroutine stack
Gentraceback may grow the stack.
One of the gentraceback wrappers may grow the stack.
One of the gentraceback callback calls may grow the stack.
Various stack pointers are stored in various stack locations
as type uintptr during the execution of these calls.
If the stack does grow, these stack pointers will not be
updated and will start trying to decode stack memory that
is no longer valid.

It may be possible to change the type of the stack pointer
variables to be unsafe.Pointer, but that's pretty subtle and
may still have problems, even if we catch every last one.
An easier, more obviously correct fix is to require that
gentraceback of the currently running goroutine must run
on the g0 stack, not on the goroutine's own stack.

Not doing this causes faults when you set
        StackFromSystem = 1
        StackFaultOnFree = 1

The new check in gentraceback will catch future lapses.

The more general problem is calling getcallersp but then
calling a function that might relocate the stack, which would
invalidate the result of getcallersp. Add note to stubs.go
declaration of getcallersp explaining the problem, and
check all existing calls to getcallersp. Most needed fixes.

This affects Callers, Stack, and nearly all the runtime
profiling routines. It does not affect stack copying directly
nor garbage collection.

LGTM=khr
R=khr, bradfitz
CC=golang-codereviews, r
https://golang.org/cl/167060043
2014-11-05 23:01:48 -05:00
Russ Cox
2d0db8e591 bufio: fix reading of many blank lines in a row
Fixes #9020.

LGTM=bradfitz, r
R=r, bradfitz
CC=golang-codereviews
https://golang.org/cl/170030043
2014-11-05 22:50:24 -05:00
Rob Pike
590f528376 bufio: don't loop generating empty tokens
The new rules for split functions mean that we are exposed
to the common bug of a function that loops forever at EOF.
Pick these off by shutting down the scanner if too many
consecutive empty tokens are delivered.

Fixes #9020.

LGTM=rsc, adg
R=golang-codereviews, rsc, adg, bradfitz
CC=golang-codereviews
https://golang.org/cl/169970043
2014-11-06 09:57:46 +11:00
Russ Cox
d8ee1c5a2c [dev.garbage] cmd/gc: emit pointer write barriers
This got lost in the change that added the writebarrierfat variants.

LGTM=rlh
R=rlh
CC=golang-codereviews
https://golang.org/cl/165510043
2014-11-05 15:43:41 -05:00
Austin Clements
4f81684f86 [dev.power64] 6g: don't create variables for indirect addresses
Previously, mkvar treated, for example, 0(AX) the same as AX.
As a result, a move to an indirect address would be marked as
*setting* the register, rather than just using it, resulting
in unnecessary register moves.  Fix this by not producing
variables for indirect addresses.

LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/164610043
2014-11-05 15:36:47 -05:00
Austin Clements
bb4a358af3 5g: don't generate reg variables for direct-called functions
The test intended to skip direct calls when creating
registerization variables was testing p->to.type instead of
p->to.name, so it always failed, causing regopt to create
unnecessary variables for these names.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/169110043
2014-11-05 15:14:47 -05:00
Russ Cox
75d3f62b3c [dev.garbage] cmd/gc, runtime: add locks around print statements
Now each C printf, Go print, or Go println is guaranteed
not to be interleaved with other calls of those functions.
This should help when debugging concurrent failures.

LGTM=rlh
R=rlh
CC=golang-codereviews
https://golang.org/cl/169120043
2014-11-05 14:42:54 -05:00
Russ Cox
91658f934d [dev.garbage] runtime: ignore objects in dead spans
We still don't know why this is happening.

LGTM=rlh
R=rlh
CC=golang-codereviews
https://golang.org/cl/169990043
2014-11-05 14:42:24 -05:00
Russ Cox
0584312e7d [dev.garbage] runtime: fix a few checkmark bugs
- Some sequencing issues with stopping the first gc_m round
at the right place to set up correctly for the second round.

- atomicxor8 is not idempotent; avoid xor.

- Maintain BitsDead type bits correctly; see long comment added.

- Enable checkmark phase by default for now.

LGTM=rlh
R=rlh
CC=golang-codereviews
https://golang.org/cl/171090043
2014-11-05 13:37:34 -05:00
Russ Cox
e1f7c3f82f [dev.garbage] runtime: fix 32-bit build
TBR=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/168860046
2014-11-05 11:09:08 -05:00
Austin Clements
fa32e922d5 [dev.power64] gc: convert Bits to a uint64 array
So far all of our architectures have had at most 32 registers,
so we've been able to use entry 0 in the Bits uint32 array
directly as a register mask.  Power64 has 64 registers, so
this converts Bits to a uint64 array so we can continue to use
entry 0 directly as a register mask on Power64.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/169060043
2014-11-04 16:34:56 -05:00
Rick Hudson
77db737ac3 [dev.garbage] runtime: Add gc mark verification pass.
This adds an independent mark phase to the GC that can be used to
verify the the default concurrent mark phase has found all reachable
objects. It uses the upper 2 bits of the boundary nibble to encode
the mark leaving the lower bits to encode the boundary and the
normal mark bit.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/167130043
2014-11-04 13:31:34 -05:00
Austin Clements
516d9ef53b gc: abort if given an unknown debug (-d) flag
The check for unknown command line debug flags in gc was
incorrect: the loop over debugtab terminates when it reaches a
nil entry, but it was only reporting an error if the parser
had passed the last entry of debugtab (which it never did).
Fix this by reporting the usage error if the loop reaches a
nil entry.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/166110043
2014-11-04 09:43:37 -05:00
Austin Clements
473bfae5ae [dev.power64] liblink: fix printing of branch targets
Print PC stored in target Prog* of branch instructions when
available instead of the offset stored in the branch
instruction.  The offset tends to be wrong after code
transformations, so previously this led to confusing listings.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/168980043
2014-11-03 17:24:13 -05:00
Austin Clements
810019286f [dev.power64] 9g: fix nilopt
Previously, nilopt was disabled on power64x because it threw
away "seemly random segments of code."  Indeed, excise on
power64x failed to preserve the link field, so it excised not
only the requested instruction but all following instructions
in the function.  Fix excise to retain the link field while
otherwise zeroing the instruction.

This makes nilopt safe on power64x.  It still fails
nilptr3.go's tests for removal of repeated nil checks because
those depend on also optimizing away repeated loads, which
doesn't currently happen on power64x.

LGTM=dave, rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/168120043
2014-11-03 15:48:51 -05:00
Austin Clements
489ff75ab8 runtime: make Go and C mallocgc signatures match
Previously, the flags argument to mallocgc was an int in Go,
but a uint32 in C.  Change the Go type to use uint32 so these
agree.  The largest flag value is 2 (and of course no flag
values are negative), so this won't change anything on little
endian architectures, but it matters on big endian.

LGTM=rsc
R=khr, rsc
CC=golang-codereviews
https://golang.org/cl/169920043
2014-11-03 13:26:46 -05:00
Austin Clements
31b1207fde [dev.power64] all: merge default into dev.power64
Trivial merge except for src/runtime/asm_power64x.s and
src/runtime/signal_power64x.c

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/168950044
2014-11-03 10:53:11 -05:00
Dave Cheney
84f7ac98f7 [dev.power64] cmd/objdump: disable tests on power64/power64le
LGTM=rsc, austin
R=austin, rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/164300043
2014-11-02 11:23:41 +11:00
Austin Clements
e1db508ffd [dev.power64] runtime: fix gcinfo_test on power64x
The GC info masks for slices and strings were changed in
commit caab29a25f68, but the reference masks used by
gcinfo_test for power64x hadn't caught up.  Now they're
identical to amd64, so this CL fixes this test by combining
the reference masks for these platforms.

LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/162620044
2014-10-31 16:58:12 -04:00
Austin Clements
700ab16daf [dev.power64] reflect: fix asm on power64x
reflect/asm_power64x.s was missing changes made to other
platforms for stack maps.  This CL ports those changes.  With
this fix, the reflect test passes on power64x.

LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/170870043
2014-10-31 15:29:03 -04:00
Austin Clements
40a5b3ecb1 [dev.power64] runtime: fix fastrand1 on power64x
fastrand1 depends on testing the high bit of its uint32 state.
For efficiency, all of the architectures implement this as a
sign bit test.  However, on power64, fastrand1 was using a
64-bit sign test on the zero-extended 32-bit state.  This
always failed, causing fastrand1 to have very short periods
and often decay to 0 and get stuck.

Fix this by using a 32-bit signed compare instead of a 64-bit
compare.  This fixes various tests for the randomization of
select of map iteration.

LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/166990043
2014-10-31 13:39:36 -04:00
Ian Lance Taylor
8985c091e4 net/http: add missing newline in list of leaked goroutines
LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/168860044
2014-10-31 10:20:36 -07:00
Brad Fitzpatrick
9dc1cce38d database/sql: make TestDrivers not crash on second run
Using -test.cpu=1,1 made it crash before.

Fixes #9024

LGTM=iant
R=adg, iant
CC=golang-codereviews
https://golang.org/cl/169860043
2014-10-31 09:49:42 -07:00
Gabriel Aszalos
2074046d00 cmd/go: fixed typo in doc and generator
LGTM=iant
R=golang-codereviews, iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/163690043
2014-10-31 09:38:41 -07:00
Austin Clements
6e86003651 [dev.power64] 9g: fix under-zeroing in clearfat
All three cases of clearfat were wrong on power64x.

The cases that handle 1032 bytes and up and 32 bytes and up
both use MOVDU (one directly generated in a loop and the other
via duffzero), which leaves the pointer register pointing at
the *last written* address.  The generated code was not
accounting for this, so the byte fill loop was re-zeroing the
last zeroed dword, rather than the bytes following the last
zeroed dword.  Fix this by simply adding an additional 8 byte
offset to the byte zeroing loop.

The case that handled under 32 bytes was also wrong.  It
didn't update the pointer register at all, so the byte zeroing
loop was simply re-zeroing the beginning of region.  Again,
the fix is to add an offset to the byte zeroing loop to
account for this.

LGTM=dave, bradfitz
R=rsc, dave, bradfitz
CC=golang-codereviews
https://golang.org/cl/168870043
2014-10-31 11:08:27 -04:00
Brad Fitzpatrick
baa5d26f62 sync/atomic: fix comment referencing Value.Store's argument name
Fixes #9029

LGTM=adg, r
R=r, adg
CC=golang-codereviews
https://golang.org/cl/161630044
2014-10-31 00:48:57 -03:00
Austin Clements
c24156bafe [dev.power64] runtime: fix a syntax error that slipped in to asm_power64x.s
Apparently I had already moved on to fixing another problem
when I submitted CL 169790043.

LGTM=dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/165210043
2014-10-30 16:44:42 -04:00
Nathan P Finch
692ad844b6 cmd/go: fix minor typo
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/170770043
2014-10-30 13:20:43 -07:00
Austin Clements
8a09639ae8 [dev.power64] runtime: make asm_power64x.s go vet-clean
No real problems found.  Just lots of argument names that
didn't quite match up.

LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/169790043
2014-10-30 15:58:30 -04:00
Alan Donovan
09f6f05c1f cmd/cgo: avoid worklist nondeterminism.
+ Regression test.

Fixes #9026.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/162490043
2014-10-30 14:01:14 -04:00
Austin Clements
4cf28a11e3 [dev.power64] runtime: fix out-of-date comment in panic
LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/162500043
2014-10-30 12:08:21 -04:00
Austin Clements
36d417c0e3 [dev.power64] runtime: test CAS on large unsigned 32-bit numbers
This adds a test to runtime·check to ensure CAS of large
unsigned 32-bit numbers does not accidentally sign-extend its
arguments.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/162490044
2014-10-30 11:17:26 -04:00
Austin Clements
097362fd2e [dev.power64] runtime: match argument/return type signedness in power64x assembly
Previously, the power64x runtime assembly was sloppy about
using sign-extending versus zero-extending moves of arguments
and return values.  I think all of the cases that actually
mattered have been fixed in recent CLs; this CL fixes up the
few remaining mismatches.

LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/162480043
2014-10-30 10:45:41 -04:00
Russ Cox
b035e97315 [dev.garbage] cmd/gc, runtime: implement write barriers in terms of writebarrierptr
This CL implements the many multiword write barriers by calling
writebarrierptr, so that only writebarrierptr needs the actual barrier.
In lieu of an actual barrier, writebarrierptr checks that the value
being copied is not a small non-zero integer. This is enough to
shake out bugs where the barrier is being called when it should not
(for non-pointer values). It also found a few tests in sync/atomic
that were being too clever.

This CL adds a write barrier for the memory moved during the
builtin copy function, which I forgot when inserting barriers for Go 1.4.

This CL re-enables some write barriers that were disabled for Go 1.4.
Those were disabled because it is possible to change the generated
code so that they are unnecessary most of the time, but we have not
changed the generated code yet. For safety they must be enabled.

None of this is terribly efficient. We are aiming for correct first.

LGTM=rlh
R=rlh
CC=golang-codereviews
https://golang.org/cl/168770043
2014-10-30 10:16:03 -04:00
Russ Cox
ca230d2d6f cmd/objdump: disable test failing on arm5
TBR=adg
CC=golang-codereviews
https://golang.org/cl/167890043
2014-10-29 21:02:58 -04:00
Russ Cox
a5a0733144 runtime: change top-most return PC from goexit to goexit+PCQuantum
If you get a stack of PCs from Callers, it would be expected
that every PC is immediately after a call instruction, so to find
the line of the call, you look up the line for PC-1.
CL 163550043 now explicitly documents that.

The most common exception to this is the top-most return PC
on the stack, which is the entry address of the runtime.goexit
function. Subtracting 1 from that PC will end up in a different
function entirely.

To remove this special case, make the top-most return PC
goexit+PCQuantum and then implement goexit in assembly
so that the first instruction can be skipped.

Fixes #7690.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/170720043
2014-10-29 20:37:44 -04:00
Alex Brainman
f9c4c16dce runtime: make TestCgoExternalThreadPanic run on windows
LGTM=rsc
R=golang-codereviews, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/163540043
2014-10-30 10:24:37 +11:00
Russ Cox
3eadbb02af cmd/objdump: use cmd/internal/objfile
This removes a bunch of ugly duplicate code.
The end goal is to factor the disassembly code
into cmd/internal/objfile too, so that pprof can use it,
but one step at a time.

LGTM=r, iant
R=r, alex.brainman, iant
CC=golang-codereviews
https://golang.org/cl/149400043
2014-10-29 18:07:24 -04:00
Russ Cox
a22c11b995 runtime: fix line number in first stack frame in printed stack trace
Originally traceback was only used for printing the stack
when an unexpected signal came in. In that case, the
initial PC is taken from the signal and should be used
unaltered. For the callers, the PC is the return address,
which might be on the line after the call; we subtract 1
to get to the CALL instruction.

Traceback is now used for a variety of things, and for
almost all of those the initial PC is a return address,
whether from getcallerpc, or gp->sched.pc, or gp->syscallpc.
In those cases, we need to subtract 1 from this initial PC,
but the traceback code had a hard rule "never subtract 1
from the initial PC", left over from the signal handling days.

Change gentraceback to take a flag that specifies whether
we are tracing a trap.

Change traceback to default to "starting with a return PC",
which is the overwhelmingly common case.

Add tracebacktrap, like traceback but starting with a trap PC.

Use tracebacktrap in signal handlers.

Fixes #7690.

LGTM=iant, r
R=r, iant
CC=golang-codereviews
https://golang.org/cl/167810044
2014-10-29 15:14:24 -04:00
Russ Cox
8db71d4ee8 runtime: update comment for Callers
Attempt to clear up confusion about how to turn
the PCs reported by Callers into the file and line
number people actually want.

Fixes #7690.

LGTM=r, chris.cs.guy
R=r, chris.cs.guy
CC=golang-codereviews
https://golang.org/cl/163550043
2014-10-29 15:14:04 -04:00
Russ Cox
d6f4e5020b [dev.garbage] all: merge dev.power64 (5ad5e85cfb99) into dev.garbage
The goal here is to get the big-endian fixes so that
in some upcoming code movement for write barriers
I don't make them unmergeable.

LGTM=rlh
R=rlh
CC=golang-codereviews
https://golang.org/cl/166890043
2014-10-29 12:25:24 -04:00
Russ Cox
8e171e1966 [dev.garbage] all: merge default (dd5014ed9b01) into dev.garbage
LGTM=rlh
R=rlh
CC=golang-codereviews
https://golang.org/cl/170730043
2014-10-29 11:54:48 -04:00
Russ Cox
599199fd9f [dev.power64] all: merge default (dd5014ed9b01) into dev.power64
Still passes on amd64.

LGTM=austin
R=austin
CC=golang-codereviews
https://golang.org/cl/165110043
2014-10-29 11:45:01 -04:00
Rob Pike
3bbc8638d5 fmt: fix one-letter typo in doc.go
Stupid mistake in previous CL.

TBR=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/166880043
2014-10-29 06:53:05 -07:00
Russ Cox
08b7805e45 cmd/objdump: skip extld test on plan9
TBR=iant
CC=golang-codereviews
https://golang.org/cl/164180043
2014-10-29 00:03:17 -04:00
Russ Cox
3ce6a4fb97 runtime: fix windows build
TBR=austin
CC=golang-codereviews
https://golang.org/cl/167820043
2014-10-29 00:02:29 -04:00
Russ Cox
260028fc0e cmd/gc: fix build - remove unused variables in walkprint
TBR=austin
CC=golang-codereviews
https://golang.org/cl/162420043
2014-10-28 23:45:01 -04:00
Ian Lance Taylor
324b293878 cmd/objdump: disassemble local text symbols
Fixes #8803.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/169720043
2014-10-28 23:25:55 -04:00
Russ Cox
6b54cc93d0 cmd/gc: fix internal compiler error in struct compare
Fixes #9006.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/167800043
2014-10-28 23:22:46 -04:00
Rob Pike
c88ba199e2 fmt: fix documentation for %g and %G
It now echoes what strconv.FormatFloat says.

Fixes #9012.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/169730043
2014-10-28 20:19:03 -07:00
Russ Cox
8fcdc70c5e runtime: add GODEBUG invalidptr setting
Fixes #8861.
Fixes #8911.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/165780043
2014-10-28 21:53:31 -04:00
Russ Cox
c4efaac15d runtime: fix unrecovered panic on external thread
Fixes #8588.

LGTM=austin
R=austin
CC=golang-codereviews, khr
https://golang.org/cl/159700044
2014-10-28 21:53:09 -04:00
Russ Cox
5e56854599 cmd/gc: avoid use of goprintf
goprintf is a printf-like print for Go.
It is used in the code generated by 'defer print(...)' and 'go print(...)'.

Normally print(1, 2, 3) turns into

        printint(1)
        printint(2)
        printint(3)

but defer and go need a single function call to give the runtime;
they give the runtime something like goprintf("%d%d%d", 1, 2, 3).

Variadic functions like goprintf cannot be described in the new
type information world, so we have to replace it.

Replace with a custom function, so that defer print(1, 2, 3) turns
into

        defer func(a1, a2, a3 int) {
                print(a1, a2, a3)
        }(1, 2, 3)

(and then the print becomes three different printints as usual).

Fixes #8614.

LGTM=austin
R=austin
CC=golang-codereviews, r
https://golang.org/cl/159700043
2014-10-28 21:52:53 -04:00
Russ Cox
b55791e200 [dev.power64] cmd/5a, cmd/6a, cmd/8a, cmd/9a: make labels function-scoped
I removed support for jumping between functions years ago,
as part of doing the instruction layout for each function separately.

Given that, it makes sense to treat labels as function-scoped.
This lets each function have its own 'loop' label, for example.

Makes the assembly much cleaner and removes the last
reason anyone would reach for the 123(PC) form instead.

Note that this is on the dev.power64 branch, but it changes all
the assemblers. The change will ship in Go 1.5 (perhaps after
being ported into the new assembler).

Came up as part of CL 167730043.

LGTM=r
R=r
CC=austin, dave, golang-codereviews, minux
https://golang.org/cl/159670043
2014-10-28 21:50:16 -04:00
David du Colombier
5f54f06a35 os: fix write on Plan 9
In CL 160670043 the write function was changed
so a zero-length write is now allowed. This leads
the ExampleWriter_Init test to fail.

The reason is that Plan 9 preserves message
boundaries, while the os library expects systems
that don't preserve them. We have to ignore
zero-length writes so they will never turn into EOF.

This issue was previously discussed in CL 7406046.

LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/163510043
2014-10-28 22:44:59 +01:00
Austin Clements
87b4149b22 [dev.power64] runtime: fix atomicor8 for power64x
Power64 servers do not currently support sub-word size atomic
memory access, so atomicor8 uses word size atomic access.
However, previously atomicor8 made no attempt to align this
access, resulting in errors.  Fix this by aligning the pointer
to a word boundary and shifting the value appropriately.
Since atomicor8 is used in GC, add a test to runtime·check to
make sure this doesn't break in the future.

This also fixes an incorrect branch label, an incorrectly
sized argument move, and adds argument names to help go vet.

LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/165820043
2014-10-28 15:57:33 -04:00
Russ Cox
202bf8d94d doc/asm: explain coordination with garbage collector
Also a few other minor changes.

Fixes #8712.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/164150043
2014-10-28 15:51:06 -04:00
Russ Cox
8a9c2c55bd os: fix build
TBR=crawshaw
CC=golang-codereviews
https://golang.org/cl/162390043
2014-10-28 15:34:50 -04:00
Austin Clements
c8f50b298c [dev.power64] 9a: correct generation of four argument ops
The "to" field was the penultimate argument to outgcode,
instead of the last argument, which swapped the third and
fourth operands.  The argument order was correct in a.y, so
just swap the meaning of the arguments in outgcode.  This
hadn't come up because we hadn't used these more obscure
operations in any hand-written assembly until now.

LGTM=rsc, dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/160690043
2014-10-28 15:08:09 -04:00
Russ Cox
a62da2027b os: do not assume syscall i/o funcs return n=0 on error
Fixes #9007.

LGTM=iant, r
R=r, iant
CC=golang-codereviews
https://golang.org/cl/160670043
2014-10-28 15:00:13 -04:00
Jens Frederich
46af78915a runtime: add PauseEnd array to MemStats and GCStats
Fixes #8787.

LGTM=rsc
R=rsc, dvyukov
CC=golang-codereviews
https://golang.org/cl/153670043
2014-10-28 12:35:25 -04:00
Russ Cox
96e9e81b5f syscall: fix ParseRoutingSockaddr with unexpected submessages
No easy way to test (would have to actually trigger some routing
events from kernel) but the code is clearly wrong as written.
If the header says there is a submessage, we need to at least
skip over its bytes, not just continue to the next iteration.

Fixes #8203.

LGTM=r
R=r
CC=golang-codereviews, mikioh.mikioh, p
https://golang.org/cl/164140044
2014-10-28 11:35:00 -04:00
Russ Cox
ea295a4cfb cmd/go: add get -f flag
get -u now checks that remote repo paths match the
ones predicted by the import paths: if you are get -u'ing
rsc.io/pdf, it has to be checked out from the right location.
This is important in case the rsc.io/pdf redirect changes.

In some cases, people have good reasons to use
non-standard remote repos. Add -f flag to allow that.
The f can stand for force or fork, as you see fit.

Fixes #8850.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/164120043
2014-10-28 11:14:25 -04:00
Austin Clements
c2364b58cc [dev.power64] liblink: emit wrapper code in correct place
The wrapper code was being emitted before the stack
reservation, rather than after.

LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/161540043
2014-10-28 10:14:19 -04:00
Mikio Hara
21a9141ab3 net: add test for lookupIPDeadline
Just to confirm the fix, by typing the follwing:
go test -run=TestLookupIPDeadline -dnsflood or
go test -run=TestLookupIPDeadline -dnsflood -tags netgo

Update #8602

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/166740043
2014-10-28 16:20:49 +09:00
Russ Cox
138b5ccd12 runtime: disable fake time on nacl
This leaked into the CL I submitted for Minux,
because I was testing it.

TBR=adg
CC=golang-codereviews
https://golang.org/cl/159600044
2014-10-27 20:47:15 -04:00
Russ Cox
1c534714e1 syscall: accept pre-existing directories in nacl zip file
NaCl creates /tmp. This lets the zip file populate it.

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/159600043
2014-10-27 20:45:16 -04:00
Shenghou Ma
2fe9482343 runtime: add fake time support back.
Revived from CL 15690048.

Fixes #5356.

LGTM=rsc
R=adg, dvyukov, rsc
CC=golang-codereviews
https://golang.org/cl/101400043
2014-10-27 20:35:15 -04:00
Dave Cheney
cb4f5e1970 [dev.power64] runtime: fix cas64 on power64x
cas64 was jumping to the wrong offset.

LGTM=minux, rsc
R=rsc, austin, minux
CC=golang-codereviews
https://golang.org/cl/158710043
2014-10-28 11:15:48 +11:00
Andrew Gerrand
e71c9cbe26 html/template: fix build after encoding/js escaping change
TBR=rsc
R=golang-codereviews
CC=golang-codereviews
https://golang.org/cl/159590043
2014-10-28 10:18:44 +11:00
Russ Cox
aec37e7cb1 encoding/json: encode \t as \t instead of \u0009
Shorter and easier to read form for a common character.

LGTM=bradfitz
R=adg, bradfitz
CC=golang-codereviews, zimmski
https://golang.org/cl/162340043
2014-10-27 18:58:25 -04:00
Dave Cheney
1b130a08d8 [dev.power64] runtime: fix power64le build
Brings defs_linux_power64le.h up to date with the big endian version.

LGTM=rsc
R=rsc, austin
CC=golang-codereviews
https://golang.org/cl/161470043
2014-10-28 09:56:33 +11:00
Austin Clements
062e354c84 [dev.power64] runtime: power64 fixes and ports of changes
Fix include paths that got moved in the great pkg/ rename.  Add
missing runtime/arch_* files for power64.  Port changes that
happened on default since branching to
runtime/{asm,atomic,sys_linux}_power64x.s (precise stacks,
calling convention change, various new and deleted functions.
Port struct renaming and fix some bugs in
runtime/defs_linux_power64.h.

LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/161450043
2014-10-27 17:27:03 -04:00
Austin Clements
6be0c8a566 [dev.power64] liblink: fix lost branch target
A recent commit lost the branch target in the really-big-stack
case of splitstack, causing an infinite loop stack preempt
case.  Revive the branch target.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/157790044
2014-10-27 17:19:41 -04:00
Austin Clements
5a653089ef [dev.power64] all: merge default into dev.power64
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/164110043
2014-10-27 17:17:06 -04:00
Austin Clements
3e62d2184a runtime: fix endianness assumption when decoding ftab
The ftab ends with a half functab record consisting only of
the 'entry' field followed by a uint32 giving the offset of
the next table.  Previously, symtabinit assumed it could read
this uint32 as a uintptr.  Since this is unsafe on big endian,
explicitly read the offset as a uint32.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/157660043
2014-10-27 17:12:48 -04:00
Rick Hudson
5550249ad3 [dev.garbage] runtime: Fix 386 compiler warnings.
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/163390043
2014-10-27 17:07:53 -04:00
Russ Cox
0f66d785cf [dev.garbage] runtime: fix TestLFStack on 386
LGTM=rlh
R=rlh, dvyukov
CC=golang-codereviews
https://golang.org/cl/157430044
2014-10-27 15:57:07 -04:00
Austin Clements
32c75a2d3d [dev.power64] liblink: power64 fixes and ports of changes
Ports of platform-specific changes that happened on default
after dev.power64 forked (fixes for c2go, wrapper math fixes,
moved stackguard field, stackguard1 support, precise stacks).
Bug fixes (missing AMOVW in instruction table, correct
unsigned 32-bit remainder).

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/164920044
2014-10-27 15:25:40 -04:00
Austin Clements
93341e8664 [dev.power64] cc: 8-byte align argument size on power64
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/163370043
2014-10-27 15:10:54 -04:00
Ian Lance Taylor
77595e462b net: if a DNS lookup times out, forget that it is in flight
Before this CL, if the system resolver does a very slow DNS
lookup for a particular host, all subsequent requests for that
host will hang waiting for that lookup to complete.  That is
more or less expected when Dial is called with no deadline.
When Dial has a deadline, though, we can accumulate a large
number of goroutines waiting for that slow DNS lookup.  Try to
avoid this problem by restarting the DNS lookup when it is
redone after a deadline is passed.

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

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

Fixes #8602.

LGTM=bradfitz
R=bradfitz, mikioh.mikioh
CC=golang-codereviews, r, rsc
https://golang.org/cl/154610044
2014-10-27 08:46:18 -07:00
Peter Collingbourne
ffa5e5f7fc cmd/go: pass $CGO_LDFLAGS to linker with the "gccgo" toolchain.
LGTM=iant
R=iant, minux
CC=golang-codereviews, golang-dev
https://golang.org/cl/157460043
2014-10-25 10:30:14 -07:00
Gustavo Niemeyer
fdf458436a cmd/go: add bzr support for vcs root checking
Complements the logic introduced in CL 147170043.

LGTM=rsc
R=rsc, gustavo
CC=golang-codereviews
https://golang.org/cl/147240043
2014-10-24 15:49:17 -02:00
Rob Pike
1415a53b75 unsafe: document that unsafe programs are not protected
The compatibility guideline needs to be clear about this even
though it means adding a clause that was not there from the
beginning. It has always been understood, so this isn't really
a change in policy, just in its expression.

LGTM=bradfitz, gri, rsc
R=golang-codereviews, bradfitz, gri, rsc
CC=golang-codereviews
https://golang.org/cl/162060043
2014-10-24 09:37:25 -07:00
Austin Clements
11ec8ab5cb [dev.power64] liblink: print line numbers in disassembly on power64
Matching other platforms.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/161320043
2014-10-24 11:39:01 -04:00
Rick Hudson
6184f46ea3 [dev.garbage] runtime: Concurrent scan code
Routines and logic to preform a concurrent stack scan of go-routines.
This CL excersizes most of the functionality needed. The
major exception being that it does not scan running goroutines.
After doing the scans it relies on a STW to finish the GC, including
rescanning the stacks. It is intended to achieve correctness,
performance will follow.

LGTM=rsc
R=golang-codereviews, rsc
CC=dvyukov, golang-codereviews
https://golang.org/cl/156580043
2014-10-24 11:07:16 -04:00
Russ Cox
c5943c668b net/http/pprof: run GC for /debug/pprof/heap?gc=1
We force runtime.GC before WriteHeapProfile with -test.heapprofile.
Make it possible to do the same with the HTTP interface.

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

Requested by private mail.

LGTM=dvyukov
R=dvyukov
CC=golang-codereviews
https://golang.org/cl/161990043
2014-10-24 10:58:13 -04:00
Russ Cox
5225854b74 cmd/gc: synthesize zeroed value for non-assignment context
CL 157910047 introduced code to turn a node representing
a zeroed composite literal into N, the nil Node* pointer
(which represents any zero, not the Go literal nil).

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

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

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

Fixes #8947.

LGTM=r
R=r, dave
CC=golang-codereviews
https://golang.org/cl/162130043
2014-10-24 10:27:39 -04:00
Russ Cox
6ad2749dcd encoding/csv: for Postgres, unquote empty strings, quote \.
In theory both of these lines encode the same three fields:

        a,,c
        a,"",c

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

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

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

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

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

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

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

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

Fixes #7586.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/164760043
2014-10-23 23:44:47 -04:00
Rick Hudson
62a4359e2e [dev.garbage] runtime: simplifiy lfstack.c due to undiagnosed buffer corruption.
The changes got rid of the problems we were seeing.
We suspect the pushcnt field has a race.

LGTM=rsc
R=dvyukov, rsc
CC=golang-codereviews
https://golang.org/cl/159330043
2014-10-23 15:51:17 -04:00
Dave Cheney
a08783f078 [dev.power64] runtime: fix SigaltstackT definition for power64le
Also updated defs3_linux.go but had to manually edit defs_linux_power64le.h. Will regenerate the file when cgo is working natively on ppc64.

LGTM=austin
R=rsc, austin
CC=golang-codereviews
https://golang.org/cl/158360043
2014-10-23 08:58:10 +11:00
Austin Clements
a9b9ecc9ef [dev.power64] runtime: fix early GC of Defer objects
go_bootstrap was panicking during runtime initialization
(under runtime.main) because Defer objects were being
prematurely GC'd.  This happened because of an incorrect
change to runtime·unrollgcprog_m to make it endian-agnostic
during the conversion of runtime bitmaps to byte arrays.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/161960044
2014-10-22 16:39:31 -04:00
Austin Clements
f0bd539c59 [dev.power64] all: merge default into dev.power64
This brings dev.power64 up-to-date with the current tip of
default.  go_bootstrap is still panicking with a bad defer
when initializing the runtime (even on amd64).

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/152570049
2014-10-22 15:51:54 -04:00
Austin Clements
977fba763a [dev.power64] runtime: Fix broken merge of noasm.go
The earlier dev.power64 merge missed the port of
runtime/noasm.goc to runtime/noasm_arm.go.  This CL fixes this
by moving noasm_arm.go to noasm.go and adding a +build to
share the file between arm and power64.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/158350043
2014-10-22 14:02:04 -04:00
Austin Clements
2bd616b1a7 build: merge the great pkg/ rename into dev.power64
This also removes pkg/runtime/traceback_lr.c, which was ported
to Go in an earlier commit and then moved to
runtime/traceback.go.

Reviewer: rsc@golang.org
          rsc: LGTM
2014-10-22 13:25:37 -04:00
Dmitriy Vyukov
af3868f187 sync: release Pool memory during second and later GCs
Pool memory was only being released during the first GC after the first Put.

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

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

Fixes #8979.

LGTM=rsc
R=golang-codereviews, bradfitz, r, rsc
CC=golang-codereviews, khr
https://golang.org/cl/162980043
2014-10-22 20:23:49 +04:00
Austin Clements
3208250185 [dev.power64] build: merge default into dev.power64
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/160200044
2014-10-22 11:21:16 -04:00
Dave Cheney
d1b2913710 runtime/cgo: encode BLX directly, fixes one clang build error on arm
Fixes #8348.

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

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

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

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

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

I'll open a new issue for that

LGTM=iant
R=iant, minux
CC=golang-codereviews
https://golang.org/cl/158180047
2014-10-22 12:30:15 +11:00
Dave Cheney
4073be88f4 undo CL 156430044 / 5d69cad4faaf
Partial undo, changes to ldelf.c retained.

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

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

Fixes #8348.

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

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

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

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

LGTM=minux
R=iant, minux
CC=golang-codereviews
https://golang.org/cl/162880044
2014-10-21 23:42:13 +00:00
Keith Randall
b60d5e12e9 runtime: warn that cputicks() might not be monotonic.
Get rid of gocputicks(), it is no longer used.

LGTM=bradfitz, dave
R=golang-codereviews, bradfitz, dave, minux
CC=golang-codereviews
https://golang.org/cl/161110044
2014-10-21 14:46:07 -07:00
Ian Lance Taylor
f29bd6c4a4 cmd/ld: fix addstrdata for big-endian systems
LGTM=rsc
R=minux, rsc
CC=golang-codereviews
https://golang.org/cl/158280043
2014-10-21 10:10:11 -07:00
Brad Fitzpatrick
ab4af52a9b time: panic with a more helpful error on use of invalid Timer
Fixes #8721

LGTM=rsc
R=r, rsc
CC=golang-codereviews
https://golang.org/cl/155620045
2014-10-21 13:26:40 +02:00
Russ Cox
93fcb92257 cmd/gc: disallow call of *T method using **T variable
This brings cmd/gc in line with the spec on this question.
It might break existing code, but that code was not conformant
with the spec.

Credit to Rémy for finding the broken code.

Fixes #6366.

LGTM=r
R=golang-codereviews, r
CC=adonovan, golang-codereviews, gri
https://golang.org/cl/129550043
2014-10-20 22:04:12 -04:00
Russ Cox
70f2f1b470 compress/gzip: allow stopping at end of first stream
Allows parsing some file formats that assign special
meaning to which stream data is found in.

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

Fixes #6486.

LGTM=nigeltao
R=nigeltao, dan.kortschak
CC=adg, bradfitz, golang-codereviews, r
https://golang.org/cl/159120044
2014-10-20 22:03:46 -04:00
Dave Cheney
cf9558c8ab cmd/cgo: disable clang's integrated assembler
Fixes #8348.

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

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

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

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/156430044
2014-10-20 23:28:39 +00:00
Alex Brainman
e5383c6854 debug/pe: use appropriate type for sizeofOptionalHeader32
LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/157220043
2014-10-21 10:02:33 +11:00
Keith Randall
3ec8fe45cf runtime: fix flaky TestBlockProfile test
It has been failing periodically on Solaris/x64.
Change blockevent so it always records an event if we called
SetBlockProfileRate(1), even if the time delta is negative or zero.

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

LGTM=dave
R=dvyukov, dave
CC=golang-codereviews
https://golang.org/cl/159150043
2014-10-20 15:48:42 -07:00
David du Colombier
9d06cfc810 runtime: handle non-nil-terminated environment strings on Plan 9
Russ Cox pointed out that environment strings are not
required to be nil-terminated on Plan 9.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/159130044
2014-10-20 23:03:03 +02:00
David du Colombier
1946afb662 os/exec: fix number of expected file descriptors on Plan 9
Since CL 104570043 and 112720043, we are using the
nsec system call instead of /dev/bintime on Plan 9.

LGTM=rsc
R=rsc
CC=aram, golang-codereviews
https://golang.org/cl/155590043
2014-10-20 23:01:32 +02:00
Rob Pike
9070afb359 flag: roll back 156390043 (flag setting)
Shell scripts depend on the old behavior too often.
It's too late to make this change.

LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/161890044
2014-10-20 13:28:00 -07:00
Rob Pike
c57cb7867e cmd/go: set exit status for failing "go generate" run.
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/154360048
2014-10-20 13:27:41 -07:00
Ian Lance Taylor
82a0188c88 reflect: fix TestAllocations now that interfaces hold only pointers
This test was failing but did not break the build because it
was not run when -test.short was used.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/157150043
2014-10-20 11:10:03 -07:00
Ian Lance Taylor
7b9c5ec24b reflect: allocate correct type in assignTo and cvtT2I
I came across this while debugging a GC problem in gccgo.
There is code in assignTo and cvtT2I that handles assignment
to all interface values.  It allocates an empty interface even
if the real type is a non-empty interface.  The fields are
then set for a non-empty interface, but the memory is recorded
as holding an empty interface.  This means that the GC has
incorrect information.

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

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

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

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

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

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

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

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/155450044
2014-10-20 10:43:43 -07:00
Russ Cox
22be4bfdbf regexp: fix TestOnePassCutoff
The stack blowout can no longer happen,
but we can still test that too-complex regexps
are rejected.

Replacement for CL 162770043.

LGTM=iant, r
R=r, iant
CC=bradfitz, golang-codereviews
https://golang.org/cl/162860043
2014-10-20 12:16:46 -04:00
Ian Lance Taylor
0f022fdd52 regexp/syntax: fix validity testing of zero repeats
This is already tested by TestRE2Exhaustive, but the build has
not broken because that test is not run when using -test.short.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/155580043
2014-10-20 08:12:45 -07:00
Russ Cox
3811c4d84a debug/pe: remove use of unsafe
Helps in environments with restricted support for unsafe.

LGTM=bradfitz
R=r, bradfitz
CC=dsymonds, golang-codereviews
https://golang.org/cl/156410044
2014-10-20 11:10:00 -04:00
Daniel Morsing
0edafefc36 cmd/gc: emit code for extern = <N>
https://golang.org/cl/152700045/ made it possible for struct literals assigned to globals to use <N> as the RHS. Normally, this is to zero out variables on first use. Because globals are already zero (or their linker initialized value), we just ignored this.

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

Fixes #8961.

LGTM=rsc
R=golang-codereviews, rsc
CC=bradfitz, golang-codereviews
https://golang.org/cl/154540044
2014-10-20 15:59:10 +01:00
Rob Pike
63acc48f87 encoding/gob: add custom decoder buffer for performance
As we did with encoding, provide a trivial byte reader for
faster decoding. We can also reduce some of the copying
by doing the allocation all at once using a slightly different
interface from byte buffers.

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

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/154360049
2014-10-20 07:33:08 -07:00
James Robinson
193d09a659 compress/flate: add Reset() to allow reusing large buffers to compress multiple buffers
This adds a Reset() to compress/flate's decompressor and plumbs that through
to compress/zlib and compress/gzip's Readers so callers can avoid large
allocations when performing many inflate operations. In particular this
preserves the allocation of the decompressor.hist buffer, which is 32kb and
overwritten as needed while inflating.

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

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

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

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

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

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

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

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

Fixes #6317.
Fixes #7950.

LGTM=nigeltao
R=golang-codereviews, bradfitz, dan.kortschak, adg, nigeltao, jamesr
CC=golang-codereviews
https://golang.org/cl/97140043
2014-10-20 12:58:02 +11:00
Rob Pike
8c29633368 flag: disallow setting flags multiple times
This is a day 1 error in the flag package: It did not check
that a flag was set at most once on the command line.
Because user-defined flags may have more general
properties, the check applies only to the standard flag
types in this package: bool, string, etc.

Fixes #8960.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/156390043
2014-10-19 10:33:22 -07:00
Ian Lance Taylor
3c5fd98918 regexp: correct doc comment for ReplaceAllLiteralString
Fixes #8959.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/161790043
2014-10-19 10:28:27 -07:00
Rob Pike
4c91b1371f encoding/gob: fix print format in generated decoder helpers
Needed a %% to quote a percent in the format.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/156330043
2014-10-19 06:44:50 -07:00
Keith Randall
e330cc16f4 runtime: dequeue the correct SudoG
select {
       case <- c:
       case <- c:
}

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

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

LGTM=dvyukov
R=rsc, bradfitz, dvyukov, khr
CC=austin, golang-codereviews
https://golang.org/cl/159040043
2014-10-18 21:02:49 -07:00
Rob Pike
1cd78eedd0 text/template: fix bug in pipelined variadics
Simple bug in argument processing: The final arg may
be the pipeline value, in which case it gets bound to the
fixed argument section. The code got that wrong. Easy
to fix.

Fixes #8950.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/161750043
2014-10-18 11:22:05 -07:00
Rob Pike
65dde1ed4b encoding/gob: use simple append-only buffer for encoding
Bytes buffers have more API and are a little slower. Since appending
is a key part of the path in encode, using a faster implementation
speeds things up measurably.
The couple of positive swings are likely garbage-collection related
since memory allocation looks different in the benchmark now.
I am not concerned by them.

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

LGTM=ruiu
R=golang-codereviews, ruiu
CC=golang-codereviews
https://golang.org/cl/160990043
2014-10-17 20:51:15 -07:00
Rob Pike
9965e40220 encoding/gob: custom array/slice decoders
Use go generate to write better loops for decoding arrays,
just as we did for encoding. It doesn't help as much,
relatively speaking, but it's still noticeable.

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

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/154420044
2014-10-17 12:37:41 -07:00
Dmitriy Vyukov
f4de59e234 runtime/pprof: fix memory profiler test
Don't use cmd/pprof as it is not necessary installed
and does not work on nacl and plan9.
Instead just look at the raw profile.

LGTM=crawshaw, rsc
R=golang-codereviews, crawshaw, 0intro, rsc
CC=golang-codereviews
https://golang.org/cl/159010043
2014-10-17 21:28:47 +04:00
Russ Cox
cfafa9f4cb cmd/gc: don't use static init to initialize small structs, fields
Better to avoid the memory loads and just use immediate constants.
This especially applies to zeroing, which was being done by
copying zeros from elsewhere in the binary, even if the value
was going to be completely initialized with non-zero values.
The zero writes were optimized away but the zero loads from
the data segment were not.

LGTM=r
R=r, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/152700045
2014-10-17 13:10:42 -04:00
Russ Cox
0d81b72e1b reflect: a few microoptimizations
Replace i < 0 || i >= x with uint(i) >= uint(x).
Shorten a few other code sequences.
Move the kind bits to the bottom of the flag word, to avoid shifts.

LGTM=r
R=r, bradfitz
CC=golang-codereviews
https://golang.org/cl/159020043
2014-10-17 12:54:31 -04:00
Rob Pike
5e713062b4 encoding/gob: speed up encoding of arrays and slices
We borrow a trick from the fmt package and avoid reflection
to walk the elements when possible. We could push further with
unsafe (and we may) but this is a good start.
Decode can benefit similarly; it will be done separately.

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

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

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/156310043
2014-10-17 09:00:07 -07:00
Russ Cox
fb173c4185 runtime/pprof: fix test
gogo called from GC is okay
for the same reasons that
gogo called from System or ExternalCode is okay.
All three are fake stack traces.

Fixes #8408.

LGTM=dvyukov, r
R=r, dvyukov
CC=golang-codereviews
https://golang.org/cl/152580043
2014-10-17 11:23:15 -04:00
Russ Cox
58e357ef16 runtime: remove comment that leaked into CL 153710043
This doesn't actually do anything. Maybe it will some day,
but maybe not.

TBR=r
CC=golang-codereviews
https://golang.org/cl/155490043
2014-10-17 11:03:55 -04:00
Russ Cox
1ba977ccca undo CL 159990043 / 421fadcef39a
Dmitriy believes this broke Windows.
It looks like build.golang.org stopped before that,
but it's worth a shot.

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

Update #8942

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

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

TBR=dvyukov
CC=golang-codereviews
https://golang.org/cl/160030043
2014-10-17 10:11:03 -04:00
Damien Neil
4e1d196543 reflect: fix struct size calculation to include terminal padding
LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/160920045
2014-10-16 13:58:32 -07:00
David du Colombier
70896a78fa syscall: don't cache environment variables on Plan 9
Fixes #8849.

LGTM=bradfitz, aram
R=bradfitz, rsc, aram
CC=golang-codereviews
https://golang.org/cl/158970045
2014-10-16 22:30:14 +02:00