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

15134 Commits

Author SHA1 Message Date
Russ Cox
e1821692ca cmd/ld: add go-specific dwarf type information
LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/116720043
2014-07-11 23:10:00 -04:00
David du Colombier
90c146f390 liblink: fix warnings on Plan 9
warning: /usr/go/src/liblink/asm5.c:720 set and not used: m
warning: /usr/go/src/liblink/asm5.c:807 set and not used: c

LGTM=minux
R=minux
CC=golang-codereviews
https://golang.org/cl/108570043
2014-07-11 22:24:45 +02:00
Rob Pike
125d1e9269 ld: change DWARF output for structs
The debug/dwarf package cannot parse the format generated here,
but the format can be changed so it does.
After this edit, tweaking the expression defining the offset
of a struct field, the dwarf package can parse the tables (again?).

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/105710043
2014-07-11 15:16:00 +00:00
Dustin Long
5c2f01f392 image/png: interlacing support for png.
Fixes #6293.

Image "testdata/benchRGB-interlace.png" was generated by opening "testdata/benchRGB.png" in the editor Gimp and saving it with interlacing enabled.

Benchmark:
BenchmarkDecodeRGB        	     500	   7014194 ns/op	  37.37 MB/s
ok  	pkg/image/png	4.657s

BenchmarkDecodeInterlacing	     100	  10623241 ns/op	  24.68 MB/s
ok  	pkg/image/png	1.339s

LGTM=nigeltao
R=nigeltao, andybons, matrixik
CC=golang-codereviews
https://golang.org/cl/102130044
2014-07-11 11:02:02 +10:00
Benny Siegert
0e694298e9 cmd/go: do not fail if libgcc does not exist
(This is a patch from the pkgsrc Go package.)

LGTM=iant
R=golang-codereviews, iant, joerg.sonnenberger, dave
CC=golang-codereviews, joerg
https://golang.org/cl/108340043
2014-07-10 14:35:04 -07:00
Pietro Gagliardi
f5b600f70c debug/elf: add (*File).DynamicSymbols, ErrNoSymbols, and tests for (*File).Symbols and (*File).DynamicSymbols, and formalize symbol order.
Added a complement to (*File).Symbols for the dynamic symbol table.
Would be useful, for instance, if seraching for certain shared objects
compatible with certain libraries (for instance, LADSPA requires an
exported symbol "ladspa_descriptor").

Added a variable ErrNoSymbols that canonicalizes a return from
(*File).Symbols and (*File).DyanmicSymbols if the file has no symbols.

Added tests for both (*File).Symbols and (*File).DynamicSymbols;
there was never a test for (*File).Symbols at all. A small C program using
libelf, included in the test data, was used to produce the golden
symbols to compare against.

As part of the requirements for testing, (*File).Symbols and (*File).DynamicSymbols now document the order in which the symbol tables are returned (in the order the symbols appear in the file).

All tests currently pass.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/107530043
2014-07-10 12:44:40 -07:00
Shenghou Ma
54d0b5ab6a nacltest.bash: set GOROOT before invoking cmd/go
The builder builds with GOROOT_FINAL=/usr/local/go set.

TBR=rsc
R=golang-codereviews
CC=golang-codereviews
https://golang.org/cl/112100043
2014-07-10 15:36:48 -04:00
Shenghou Ma
99e2a56786 nacltest.bash: nacl/arm support.
Also detect GOARCH automatically based on `uname -m`.

LGTM=crawshaw, dave, rsc
R=rsc, iant, crawshaw, dave
CC=golang-codereviews
https://golang.org/cl/111780043
2014-07-10 15:15:41 -04:00
Shenghou Ma
366f88f3e4 cmd/dist: always use GOARM=7 for nacl/arm
LGTM=dave, rsc
R=rsc, iant, dave
CC=golang-codereviews
https://golang.org/cl/101590044
2014-07-10 15:15:24 -04:00
Shenghou Ma
d1fee626f6 crypto/rc4: disable assembly implementation for nacl/arm.
It uses an unsupported addressing mode.

LGTM=iant, rsc
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/106370043
2014-07-10 15:15:16 -04:00
Shenghou Ma
837bc4e502 syscall: nacl/arm support.
LGTM=dave, rsc
R=rsc, iant, dave
CC=golang-codereviews
https://golang.org/cl/101620043
2014-07-10 15:15:06 -04:00
Shenghou Ma
62af04c0bc sync/atomic: nacl/arm support.
LGTM=dave, rsc
R=rsc, iant, dave
CC=golang-codereviews
https://golang.org/cl/110330044
2014-07-10 15:14:58 -04:00
Shenghou Ma
d1177ed40d runtime: nacl/arm support.
LGTM=rsc
R=rsc, iant, dave
CC=golang-codereviews
https://golang.org/cl/103680046
2014-07-10 15:14:49 -04:00
Shenghou Ma
783bcba84d cmd/5c, cmd/5g, cmd/5l, liblink: nacl/arm support
LGTM=dave, rsc
R=rsc, iant, dave
CC=golang-codereviews
https://golang.org/cl/108360043
2014-07-10 15:14:37 -04:00
Alex Brainman
418b39d436 runtime: align stack before calling windows in usleep2
Fixes #8174.

LGTM=minux
R=golang-codereviews, minux
CC=golang-codereviews
https://golang.org/cl/102360043
2014-07-10 14:23:50 +10:00
Shenghou Ma
a1778ec146 runtime: ignore exceptions from foreign threads.
Fixes #8224.

LGTM=alex.brainman, rsc
R=alex.brainman, rsc, dave
CC=golang-codereviews
https://golang.org/cl/104200046
2014-07-09 23:55:35 -04:00
Josh Bleecher Snyder
76ce843afe net/rpc: use html/template to render html
Found using the vet check in CL 106370045.

This is a second attempt at CL 101670044, which omitted the deps_test change.

This adds dependencies to net/rpc:

        encoding
        encoding/base64
        encoding/json
        html
        unicode/utf16

The obvious correctness and security warrants the additional dependencies.

LGTM=rsc
R=r, minux, rsc, adg
CC=golang-codereviews
https://golang.org/cl/110890043
2014-07-09 19:33:45 -07:00
David Crawshaw
fe71b387b3 androidtest.bash: missing !
LGTM=iant
R=bradfitz, iant
CC=golang-codereviews
https://golang.org/cl/112010045
2014-07-09 14:54:11 -04:00
David Crawshaw
c4b714d3fe os: no /tmp on android
LGTM=minux, bradfitz
R=golang-codereviews, minux, bradfitz
CC=golang-codereviews
https://golang.org/cl/104650043
2014-07-09 14:12:30 -04:00
Peter Collingbourne
5512f6f3b3 cmd/go: use $CC to build _cgo_defun.c
LGTM=dave, iant
R=iant, dave
CC=golang-codereviews
https://golang.org/cl/112000043
2014-07-09 10:04:38 -07:00
Dmitriy Vyukov
0622e13b4d runtime: grow heap by 64K instead of 128K
When we've switched to 8K pages,
heap started to grow by 128K instead of 64K,
because it was implicitly assuming that pages are 4K.
Fix that and make the code more robust.

LGTM=khr
R=golang-codereviews, dave, khr
CC=golang-codereviews, rsc
https://golang.org/cl/106450044
2014-07-09 17:00:54 +04:00
David Crawshaw
a5f8e8f99c androidtest.bash, misc/android: build scripts for android
LGTM=minux
R=minux
CC=golang-codereviews
https://golang.org/cl/107640044
2014-07-09 06:56:49 -04:00
Aram Hăvărneanu
29aac3d91b debug/plan9obj: fix test build
LGTM=0intro, dave
R=dave, 0intro
CC=golang-codereviews
https://golang.org/cl/106560044
2014-07-09 12:48:55 +02:00
Aram Hăvărneanu
9c3141145a syscall: use the nsec system call instead of /dev/bintime on Plan 9
Also remove arch-specific Go files in the Plan 9 syscall package

LGTM=0intro
R=0intro, dave
CC=ality, golang-codereviews, jas, mischief, rsc
https://golang.org/cl/112720043
2014-07-09 12:34:06 +02:00
Aram Hăvărneanu
a84e3ad198 runtime: use the nsec system call instead of /dev/bintime on Plan 9
LGTM=0intro
R=0intro
CC=ality, dave, golang-codereviews, jas, mischief, rsc
https://golang.org/cl/104570043
2014-07-09 12:33:42 +02:00
Aram Hăvărneanu
0a2083edd7 debug/plan9obj, cmd/addr2line: on Plan 9 use a.out header
size instead of abusing text symbol

cmd/addr2line needs to know the virtual address of the start
of the text segment (load address plus header size). For
this, it used the text symbol added by the linker. This is
wrong on amd64. Header size is 40 bytes, not 32 like on 386
and arm. Function alignment is 16 bytes causing text to be
at 0x200030.

debug/plan9obj now exports both the load address and the
header size; cmd/addr2line uses this new information and
doesn't rely on text anymore.

LGTM=0intro
R=0intro, gobot, ality
CC=ality, golang-codereviews, jas, mischief
https://golang.org/cl/106460044
2014-07-09 12:33:13 +02:00
Aram Hăvărneanu
fa113cf767 cmd/objdump: set goarch properly on non-386 Plan 9 systems
LGTM=0intro, r
R=0intro, r
CC=ality, golang-codereviews, jas, mischief
https://golang.org/cl/108420043
2014-07-09 12:32:49 +02:00
Aram Hăvărneanu
38e75f9d0e syscall: remove more NxM assumptions on Plan 9
LGTM=0intro, r
R=0intro, r
CC=ality, dave, golang-codereviews, jas, mischief, rsc
https://golang.org/cl/111910043
2014-07-09 12:32:18 +02:00
Aram Hăvărneanu
a6cc634766 os: fix failing test on Plan 9
LGTM=0intro, r
R=0intro, r
CC=ality, dave, golang-codereviews, jas, mischief, rsc
https://golang.org/cl/105580044
2014-07-09 12:31:20 +02:00
Cristian Staretu
8aea9a00a8 syscall: NetlinkRIB, avoid allocation in loop
NetlinkRIB is currently allocating a page sized slice of bytes in a
for loop and it's also calling Getpagesize() in the same for loop.

This CL changes NetlinkRIB to preallocate the page sized slice of
bytes before reaching the for loop. This reduces memory allocations
and lowers the number of calls to Getpagesize() to 1 per NetlinkRIB
call.

This CL reduces the allocated memory from 141.5 MB down to 52 MB in
a test.

LGTM=crawshaw, dave
R=dave, dsymonds, crawshaw
CC=bradfitz, dsymonds, golang-codereviews
https://golang.org/cl/110920043
2014-07-09 18:50:38 +10:00
Dmitri Shuralyov
3e801416ce cmd/go: fix build -o panic when import path pattern matches 0 pkgs
Fixes #8165.

After this change, the panic is replaced by a message:

        $ go build -o out ...doesntexist
        warning: "...doesntexist" matched no packages
        no packages to build

The motivation to return 1 exit error code is to allow -o flag
to be used to guarantee that the output binary is written to
when exit status is 0. If someone uses an import path pattern
to specify a single package and suddenly that matches no packages,
it's better to return exit code 1 instead of silently doing nothing.
This is consistent with the case when -o flag is given and multiple
packages are matched.
It's also somewhat consistent with the current behavior with the
panic, except that gave return code 2. But it's similar in
that it's also non-zero (indicating failure).
I've changed the language to be similar to output of go test
when an import path pattern matches no packages (it also has a return status of
1):

        $ go test ...doesntexist
        warning: "...doesntexist" matched no packages
        no packages to test

LGTM=adg
R=golang-codereviews, josharian, gobot, adg
CC=golang-codereviews
https://golang.org/cl/107140043
2014-07-09 13:17:27 +10:00
David Crawshaw
107b8fc9e4 run.bash: disable tests that don't (yet) like running off the host
LGTM=bradfitz, minux
R=bradfitz, golang-codereviews, minux
CC=golang-codereviews
https://golang.org/cl/110940043
2014-07-08 18:41:07 -04:00
David Crawshaw
b0589864dc go/build: add android to the flock
LGTM=minux
R=golang-codereviews, minux
CC=golang-codereviews
https://golang.org/cl/108450044
2014-07-08 17:04:18 -04:00
David Crawshaw
1648df6728 runtime: skip crash test on android
LGTM=bradfitz
R=golang-codereviews, bradfitz, minux
CC=golang-codereviews
https://golang.org/cl/110400043
2014-07-08 14:47:52 -04:00
Dmitriy Vyukov
97c8b24d01 runtime: fix spurious "[string too long]" error
Maxstring is not updated in the new string routines,
this makes runtime think that long strings are bogus.
Fixes #8339.

LGTM=crawshaw, iant
R=golang-codereviews, crawshaw, iant
CC=golang-codereviews, khr, rsc
https://golang.org/cl/110930043
2014-07-08 22:37:18 +04:00
David Crawshaw
331bf64d17 cmd/addr2line: skip test on android
LGTM=minux
R=golang-codereviews, minux
CC=golang-codereviews
https://golang.org/cl/104600043
2014-07-08 13:45:31 -04:00
David Crawshaw
4e0214eb8e cmd/pack: skip test on android (no Go tool)
LGTM=minux
R=golang-codereviews, minux
CC=golang-codereviews
https://golang.org/cl/107600043
2014-07-08 13:45:06 -04:00
David Crawshaw
b157077e34 cmd/nm: skip test on android (no Go tool)
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/107590043
2014-07-08 13:44:41 -04:00
David Crawshaw
cb2355bbb3 os: adjust tests for android file system
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/108460043
2014-07-08 13:44:06 -04:00
David Crawshaw
8543ed3df5 cmd/objdump: skip test on android (no Go tool)
LGTM=minux, iant
R=golang-codereviews, minux, iant
CC=golang-codereviews
https://golang.org/cl/109570043
2014-07-08 13:43:22 -04:00
David Crawshaw
e50d059862 crypto/x509: skip test on android (no Go tool)
LGTM=minux
R=golang-codereviews, minux
CC=golang-codereviews
https://golang.org/cl/111970043
2014-07-08 13:43:02 -04:00
David Crawshaw
9416fb8c81 net: no AI_ALL on android
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/112800043
2014-07-08 13:42:14 -04:00
David Crawshaw
8b6dafa80e net: treat android like linux in tests
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/112810043
2014-07-08 13:41:18 -04:00
Josh Bleecher Snyder
a31eeef7ff undo CL 101670044 / 49a6cbd80cf2
Broke build; missing deps_test change. Will re-send the original with the appropriate fix.

««« original CL description
net/rpc: use html/template to render html

Found using the vet check in CL 106370045.

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

TBR=r
CC=golang-codereviews
https://golang.org/cl/110880044
2014-07-07 17:10:33 -07:00
Josh Bleecher Snyder
ccb99122b1 net/rpc: use html/template to render html
Found using the vet check in CL 106370045.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/101670044
2014-07-07 16:57:07 -07:00
Rob Pike
7b0ee53429 cmd/ld: fix off-by-one in DWARF frame tables
The code generating the .debug_frame section emits pairs of "advance PC",
"set SP offset" pseudo-instructions. Before the fix, the PC advance comes
out before the SP setting, which means the emitted offset for a block is
actually the value at the end of the block, which is incorrect for the
block itself.

The easiest way to fix this problem is to emit the SP offset before the
PC advance.

One delicate point: the last instruction to come out is now an
"advance PC", which means that if there are padding intsructions after
the final RET, they will appear to have a non-zero offset. This is odd
but harmless because there is no legal way to have a PC in that range,
or to put it another way, if you get here the SP is certainly screwed up
so getting the wrong (virtual) frame pointer is the least of your worries.

LGTM=iant
R=rsc, iant, lvd
CC=golang-codereviews
https://golang.org/cl/112750043
2014-07-07 16:07:24 -07:00
David Crawshaw
c1c8c3c8c4 runtime: export _rt0 for android
LGTM=iant, minux
R=golang-codereviews, minux, iant
CC=golang-codereviews
https://golang.org/cl/109470043
2014-07-07 07:35:39 -04:00
Dmitriy Vyukov
735e38cace debug/elf: fix nil deref in test
LGTM=crawshaw
R=golang-codereviews, crawshaw
CC=golang-codereviews
https://golang.org/cl/109470044
2014-07-05 08:48:46 +04:00
Dmitriy Vyukov
67afeac2ab image/gif: fix nil deref in test
LGTM=crawshaw, dave
R=golang-codereviews, crawshaw, dave
CC=golang-codereviews
https://golang.org/cl/104520044
2014-07-05 08:48:04 +04:00
David Crawshaw
72faffbc70 runtime/cgo: replace fprintf(stderr, ...) with fatalf(...) for linux/android
Both stdout and stderr are sent to /dev/null in android
apps. Introducing fatalf allows android to implement its
own copy that sends fatal errors to __android_log_print.

LGTM=minux, dave
R=minux, dave
CC=golang-codereviews
https://golang.org/cl/108400045
2014-07-03 21:04:48 -04:00
David Crawshaw
b2c75ae2be runtime/cgo: revert use of undefined logging function
It snuck into cl/106380043. Too many active clients.

LGTM=ruiu
R=golang-codereviews, ruiu
CC=golang-codereviews
https://golang.org/cl/110830045
2014-07-03 16:52:34 -04:00
David Crawshaw
12b990ba7d cmd/go, cmd/ld, runtime, os/user: TLS emulation for android
Based on cl/69170045 by Elias Naur.

There are currently several schemes for acquiring a TLS
slot to save the g register. None of them appear to work
for android. The closest are linux and darwin.

Linux uses a linker TLS relocation. This is not supported
by the android linker.

Darwin uses a fixed offset, and calls pthread_key_create
until it gets the slot it wants. As the runtime loads
late in the android process lifecycle, after an
arbitrary number of other libraries, we cannot rely on
any particular slot being available.

So we call pthread_key_create, take the first slot we are
given, and put it in runtime.tlsg, which we turn into a
regular variable in cmd/ld.

Makes android/arm cgo binaries work.

LGTM=minux
R=elias.naur, minux, dave, josharian
CC=golang-codereviews
https://golang.org/cl/106380043
2014-07-03 16:14:34 -04:00
Dmitriy Vyukov
d3be3daafe runtime: delete unnecessary confusing code
The code in GC that handles gp->gobuf.ctxt is wrong,
because it does not mark the ctxt object itself,
if just queues the ctxt object for scanning.
So the ctxt object can be collected as garbage.
However, Gobuf.ctxt is void*, so it's always marked and
scanned through G.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, khr, rsc
https://golang.org/cl/105490044
2014-07-03 22:58:42 +04:00
Dmitriy Vyukov
2ec3a0a72f crypto/x509: fix format strings in test
Currently it says:
--- PASS: TestDecrypt-2 (0.11s)
pem_decrypt_test.go:17: test 0. %!s(x509.PEMCipher=1)
--- PASS: TestEncrypt-2 (0.00s)
pem_decrypt_test.go:42: test 0. %!s(x509.PEMCipher=1)

LGTM=alex.brainman
R=golang-codereviews, alex.brainman
CC=golang-codereviews
https://golang.org/cl/108400044
2014-07-03 12:08:24 +04:00
Aram Hăvărneanu
df75f082d3 runtime: make runtime·usleep and runtime·osyield callable from cgo callback
runtime·usleep and runtime·osyield fall back to calling an
assembly wrapper for the libc functions in the absence of a m,
so they can be called in cgo callback context.

LGTM=rsc
R=minux.ma, rsc
CC=dave, golang-codereviews
https://golang.org/cl/102620044
2014-07-03 11:36:05 +10:00
Cristian Staretu
61ccc1f05f archive/tar: reuse temporary buffer in readHeader
A temporary 512 bytes buffer is allocated for every call to
readHeader. This buffer isn't returned to the caller and it could
be reused to lower the number of memory allocations.

This CL improves it by using a pool and zeroing out the buffer before
putting it back into the pool.

benchmark                  old ns/op     new ns/op     delta
BenchmarkListFiles100k     545249903     538832687     -1.18%

benchmark                  old allocs    new allocs    delta
BenchmarkListFiles100k     2105167       2005692       -4.73%

benchmark                  old bytes     new bytes     delta
BenchmarkListFiles100k     105903472     54831527      -48.22%

This improvement is very important if your code has to deal with a lot
of tarballs which contain a lot of files.

LGTM=dsymonds
R=golang-codereviews, dave, dsymonds, bradfitz
CC=golang-codereviews
https://golang.org/cl/108240044
2014-07-03 09:41:19 +10:00
Cristian Staretu
fe5a358aae archive/tar: reuse temporary buffer in writeHeader
A temporary 512 bytes buffer is allocated for every call to
writeHeader. This buffer could be reused the lower the number
of memory allocations.

benchmark                   old ns/op     new ns/op     delta
BenchmarkWriteFiles100k     634622051     583810847     -8.01%

benchmark                   old allocs     new allocs     delta
BenchmarkWriteFiles100k     2701920        2602621        -3.68%

benchmark                   old bytes     new bytes     delta
BenchmarkWriteFiles100k     115383884     64349922      -44.23%

This change is very important if your code has to write a lot of
tarballs with a lot of files.

LGTM=dsymonds
R=golang-codereviews, dave, dsymonds
CC=golang-codereviews
https://golang.org/cl/107440043
2014-07-03 09:40:53 +10:00
Adam Langley
372f399e00 crypto/rsa: fix out-of-bound access with short session keys.
Thanks to Cedric Staub for noting that a short session key would lead
to an out-of-bounds access when conditionally copying the too short
buffer over the random session key.

LGTM=davidben, bradfitz
R=davidben, bradfitz
CC=golang-codereviews
https://golang.org/cl/102670044
2014-07-02 15:28:57 -07:00
Russ Cox
ebce79446d build: annotations and modifications for c2go
The main changes fall into a few patterns:

1. Replace #define with enum.

2. Add /*c2go */ comment giving effect of #define.
This is necessary for function-like #defines and
non-enum-able #defined constants.
(Not all compilers handle negative or large enums.)

3. Add extra braces in struct initializer.
(c2go does not implement the full rules.)

This is enough to let c2go typecheck the source tree.
There may be more changes once it is doing
other semantic analyses.

LGTM=minux, iant
R=minux, dave, iant
CC=golang-codereviews
https://golang.org/cl/106860045
2014-07-02 15:41:29 -04:00
Preetam Jinka
4fedb59aec crypto/cipher: fix typo in example comment
LGTM=josharian
R=golang-codereviews, josharian
CC=golang-codereviews
https://golang.org/cl/110330043
2014-07-02 10:46:54 -07:00
Timo Truyts
22c3f67cd6 bufio: Fixed call to Fatal, should be Fatalf.
LGTM=iant
R=golang-codereviews, iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/107390044
2014-07-02 07:04:01 -07:00
Aram Hăvărneanu
decd810945 liblink, runtime: preliminary support for plan9/amd64
A TLS slot is reserved by _rt0_.*_plan9 as an automatic and
its address (which is static on Plan 9) is saved in the
global _privates symbol. The startup linkage now is exactly
like that from Plan 9 libc, and the way we access g is
exactly as if we'd have used privalloc(2).

Aside from making the code more standard, this change
drastically simplifies it, both for 386 and for amd64, and
makes the Plan 9 code in liblink common for both 386 and
amd64.

The amd64 runtime code was cleared of nxm assumptions, and
now runs on the standard Plan 9 kernel.

Note handling fixes will follow in a separate CL.

LGTM=rsc
R=golang-codereviews, rsc, bradfitz, dave
CC=0intro, ality, golang-codereviews, jas, minux.ma, mischief
https://golang.org/cl/101510049
2014-07-02 21:04:10 +10:00
Aram Hăvărneanu
d7b678b2ca runtime: properly restore registers in Solaris runtime·sigtramp
We restored registers correctly in the usual case where the thread
is a Go-managed thread and called runtime·sighandler, but we
failed to do so when runtime·sigtramp was called on a cgo-created
thread. In that case, runtime·sigtramp called runtime·badsignal,
a Go function, and did not restore registers after it returned

LGTM=rsc, dave
R=rsc, dave
CC=golang-codereviews, minux.ma
https://golang.org/cl/105280050
2014-07-02 09:34:06 +10:00
Shenghou Ma
bbe5c93e93 misc/nacl, syscall: lazily initialize fs on nacl.
On amd64, the real time is reduced from 176.76s to 140.26s.
On ARM, the real time is reduced from 921.61s to 726.30s.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/101580043
2014-07-01 18:24:43 -04:00
David Crawshaw
a36348008c all: add GOOS=android
As android and linux have significant overlap, and
because build tags are a poor way to represent an
OS target, this CL introduces an exception into
go/build: linux is treated as a synonym for android
when matching files.

http://golang.org/s/go14android
https://groups.google.com/forum/#!topic/golang-dev/P1ATVp1mun0

LGTM=rsc, minux
R=golang-codereviews, mikioh.mikioh, dave, aram, minux, gobot, rsc, aram.h, elias.naur, iant
CC=golang-codereviews, rsc
https://golang.org/cl/105270043
2014-07-01 17:21:50 -04:00
Russ Cox
e4bc3c462b encoding/gob: fewer decAlloc calls
Move decAlloc calls a bit higher in the call tree.
Cleans code marginally, improves speed marginally.
The benchmarks are noisy but the median time from
20 consective 1-second runs improves by about 2%.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/105530043
2014-07-01 14:19:27 -04:00
Robert Griesemer
dddc8b193f cmd/gofmt: fix gofmt -s for 3-index slices
3-index slices of the form s[:len(s):len(s)]
cannot be simplified to s[::len(s)].

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/108330043
2014-07-01 10:40:27 -07:00
Robert Griesemer
b39e2a0ca3 src, misc: applied gofmt -w -s
TBR=rsc
R=golang-codereviews
CC=golang-codereviews
https://golang.org/cl/111770043
2014-07-01 10:28:10 -07:00
Simon Whitehead
138099ae96 gofmt/main: Added removal of empty declaration groups.
Fixes #7631.

LGTM=gri
R=golang-codereviews, bradfitz, gri
CC=golang-codereviews
https://golang.org/cl/101410046
2014-07-01 09:32:03 -07:00
Rémy Oudompheng
1ec56062ef cmd/8g: don't allocate a register early for cap(CHAN).
There is no reason to generate different code for cap and len.

Fixes #8025.
Fixes #8026.

LGTM=rsc
R=rsc, iant, khr
CC=golang-codereviews
https://golang.org/cl/93570044
2014-07-01 09:20:51 +02:00
Keith Randall
3cf83c182a undo CL 104200047 / 318b04f28372
Breaks windows and race detector.
TBR=rsc

««« original CL description
runtime: stack allocator, separate from mallocgc

In order to move malloc to Go, we need to have a
separate stack allocator.  If we run out of stack
during malloc, malloc will not be available
to allocate a new stack.

Stacks are the last remaining FlagNoGC objects in the
GC heap.  Once they are out, we can get rid of the
distinction between the allocated/blockboundary bits.
(This will be in a separate change.)

Fixes #7468
Fixes #7424

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

TBR=rsc
CC=golang-codereviews
https://golang.org/cl/101570044
2014-06-30 19:48:08 -07:00
Keith Randall
7c13860cd0 runtime: stack allocator, separate from mallocgc
In order to move malloc to Go, we need to have a
separate stack allocator.  If we run out of stack
during malloc, malloc will not be available
to allocate a new stack.

Stacks are the last remaining FlagNoGC objects in the
GC heap.  Once they are out, we can get rid of the
distinction between the allocated/blockboundary bits.
(This will be in a separate change.)

Fixes #7468
Fixes #7424

LGTM=rsc, dvyukov
R=golang-codereviews, dvyukov, khr, dave, rsc
CC=golang-codereviews
https://golang.org/cl/104200047
2014-06-30 18:59:24 -07:00
David Crawshaw
54951023cb runtime: update arm comments now register m is gone
LGTM=minux
R=golang-codereviews, minux
CC=golang-codereviews
https://golang.org/cl/109220046
2014-06-30 19:10:41 -04:00
Rob Pike
ce5bbfdde4 encoding/gob: simplify allocation in decode.
The old code's structure needed to track indirections because of the
use of unsafe. That is no longer necessary, so we can remove all
that tracking. The code cleans up considerably but is a little slower.
We may be able to recover that performance drop. I believe the
code quality improvement is worthwhile regardless.

BenchmarkEndToEndPipe           5610          5780          +3.03%
BenchmarkEndToEndByteBuffer     3156          3222          +2.09%

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/103700043
2014-06-30 15:47:11 -07:00
Robert Griesemer
6a22823939 gofmt: remove redundant check in rewriter
If the actual types of two reflect values are
the same and the values are structs, they must
have the same number of fields.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/108280043
2014-06-30 14:40:12 -07:00
Rob Pike
3050a0a7d2 encoding/gob: remove unsafe, use reflection.
This removes a major unsafe thorn in our side, a perennial obstacle
to clean garbage collection.
Not coincidentally: In cleaning this up, several bugs were found,
including code that reached inside by-value interfaces to create
pointers for pointer-receiver methods. Unsafe code is just as
advertised.

Performance of course suffers, but not too badly. The Pipe number
is more indicative, since it's doing I/O that simulates a network
connection. Plus these are end-to-end, so each end suffers
only half of this pain.

The edit is pretty much a line-by-line conversion, with a few
simplifications and a couple of new tests. There may be more
performance to gain.

BenchmarkEndToEndByteBuffer     2493          3033          +21.66%
BenchmarkEndToEndPipe           4953          5597          +13.00%

Fixes #5159.

LGTM=rsc
R=rsc
CC=golang-codereviews, khr
https://golang.org/cl/102680045
2014-06-30 11:06:47 -07:00
Dmitriy Vyukov
5bfe8adee5 runtime: fix GC bitmap corruption
Fixes #8299.

R=golang-codereviews
CC=golang-codereviews, khr, rsc
https://golang.org/cl/103640044
2014-06-28 19:20:46 -07:00
Evan Shaw
94935cb5c1 strings: Replacer is safe for concurrent use
LGTM=r
R=golang-codereviews, bradfitz, r
CC=golang-codereviews
https://golang.org/cl/109220044
2014-06-28 15:53:07 -07:00
Preetam Jinka
873ceeff54 crypto/cipher: Fix typo in example comment
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/101510047
2014-06-28 10:11:26 -07:00
David Symonds
dd3856e1b0 flag: add a little more doc comment to Duration.
The only text that describes the accepted format is in the package doc,
which is far away from these functions. The other flag types don't need
this explicitness because they are more obvious.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/101550043
2014-06-28 20:47:06 +10:00
Dmitriy Vyukov
8c8bf3cc76 net/http: add TLS benchmark
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/110080045
2014-06-27 18:30:09 -07:00
Dmitriy Vyukov
03f2189a1b runtime: make garbage collector faster by deleting code again
Remove GC bitmap backward scanning.
This was already done once in https://golang.org/cl/5530074/
Still makes GC a bit faster.
On the garbage benchmark, before:
        gc-pause-one=237345195
        gc-pause-total=4746903
        cputime=32427775
        time=32458208
after:
        gc-pause-one=235484019
        gc-pause-total=4709680
        cputime=31861965
        time=31877772
Also prepares mgc0.c for future changes.

R=golang-codereviews, khr, khr
CC=golang-codereviews, rsc
https://golang.org/cl/105380043
2014-06-27 18:19:02 -07:00
Russ Cox
84a36434d9 runtime: fix nacl amd64p32 flakiness
newproc takes two extra pointers, not two extra registers.
On amd64p32 (nacl) they are different.

We diagnosed this before the 1.3 cut but the tree was frozen.
I believe this is causing the random problems on the builder.

Fixes #8199.

TBR=r
CC=golang-codereviews
https://golang.org/cl/102710043
2014-06-27 20:13:16 -04:00
Andrew Gerrand
ea0fb5d8e2 cmd/go: build non-runnable examples in xtests
Include these files in the build,
even though they don't get executed.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/108180043
2014-06-28 07:15:22 +10:00
Evan Shaw
128eed2749 net/http: [Post]FormValue ignores parse errors
LGTM=r
R=golang-codereviews, bradfitz, r
CC=golang-codereviews
https://golang.org/cl/102640046
2014-06-27 11:21:57 -07:00
Anthony Martin
a6999c8845 runtime: fix Plan 9 build
LGTM=0intro, aram
R=rsc, 0intro, aram
CC=golang-codereviews
https://golang.org/cl/109240044
2014-06-27 15:36:41 +02:00
Dmitriy Vyukov
a7186dc303 runtime: improve scheduler trace
Output number of spinning threads,
this is useful to understanding whether the scheduler
is in a steady state or not.

R=golang-codereviews, khr
CC=golang-codereviews, rsc
https://golang.org/cl/103540045
2014-06-26 17:16:43 -07:00
Josh Bleecher Snyder
548dece8f3 strings: avoid pointless slice growth in makeBenchInputHard
LGTM=ruiu
R=golang-codereviews, ruiu
CC=golang-codereviews
https://golang.org/cl/108150043
2014-06-26 13:00:47 -07:00
Dmitriy Vyukov
07f6f313a9 runtime: say when a goroutine is locked to OS thread
Say when a goroutine is locked to OS thread in crash reports
and goroutine profiles.
It can be useful to understand what goroutines consume OS threads
(syscall and locked), e.g. if you forget to call UnlockOSThread
or leak locked goroutines.

R=golang-codereviews
CC=golang-codereviews, rsc
https://golang.org/cl/94170043
2014-06-26 11:40:48 -07:00
Evan Kroske
9e04ff7953 cmd/gc: moved usefield to correct section of go.h, from "reflect.c" to "walk.c".
LGTM=iant
R=golang-codereviews, gobot, iant, dave
CC=golang-codereviews
https://golang.org/cl/108990044
2014-06-26 10:02:16 -07:00
Robert Griesemer
ef639b0936 go/parser: permit parentheses in receiver types
Pending acceptance of CL 101500044
and adjustment of test/fixedbugs/bug299.go.

LGTM=adonovan
R=golang-codereviews, adonovan
CC=golang-codereviews
https://golang.org/cl/110160043
2014-06-26 09:45:11 -07:00
Russ Cox
89f185fe8a all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).

This CL removes the extern register m; code now uses g->m.

On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.

The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:

BenchmarkBinaryTree17              5491374955     5471024381     -0.37%
BenchmarkFannkuch11                4357101311     4275174828     -1.88%
BenchmarkGobDecode                 11029957       11364184       +3.03%
BenchmarkGobEncode                 6852205        6784822        -0.98%
BenchmarkGzip                      650795967      650152275      -0.10%
BenchmarkGunzip                    140962363      141041670      +0.06%
BenchmarkHTTPClientServer          71581          73081          +2.10%
BenchmarkJSONEncode                31928079       31913356       -0.05%
BenchmarkJSONDecode                117470065      113689916      -3.22%
BenchmarkMandelbrot200             6008923        5998712        -0.17%
BenchmarkGoParse                   6310917        6327487        +0.26%
BenchmarkRegexpMatchMedium_1K      114568         114763         +0.17%
BenchmarkRegexpMatchHard_1K        168977         169244         +0.16%
BenchmarkRevcomp                   935294971      914060918      -2.27%
BenchmarkTemplate                  145917123      148186096      +1.55%

Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.

Actual code changes by Minux.
I only did the docs and the benchmarking.

LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 11:54:39 -04:00
Russ Cox
2565b5c060 cmd/gc: drop parenthesization restriction for receiver types
Matches CL 101500044.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/110160044
2014-06-25 09:57:48 -04:00
Dmitriy Vyukov
b0c586a821 index/suffixarray: reduce size of a benchmark
A single iteration of BenchmarkSaveRestore runs for 5 seconds
on my freebsd machine. 5 seconds looks like too long for a single
iteration.
This is the only benchmark that times out on freebsd-amd64-race builder.

R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/107340044
2014-06-24 20:37:28 -07:00
Andrew Gerrand
da1c2b182a undo CL 107320046 / 97cd07dcb9d8
Breaks the build

««« original CL description
cmd/go: build test files containing non-runnable examples

Even if we can't run them, we should at least check that they compile.

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

TBR=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/110140044
2014-06-25 12:04:36 +10:00
Dmitriy Vyukov
280eb703a2 regexp: skip TestOnePassCutoff in short mode
Runs for 4 seconds on my mac.
Also this is the only test that times out on freebsd in -race mode.

R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/110150045
2014-06-24 17:19:10 -07:00
Mihai Borobocea
92d58c7e46 fmt: fix typo in help doc
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/110110045
2014-06-24 16:59:33 -07:00
Dmitriy Vyukov
de2feeafdc race.bash: support freebsd
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/110150044
2014-06-24 15:47:22 -07:00
Andrew Gerrand
eb4c3455de cmd/go: build test files containing non-runnable examples
Even if we can't run them, we should at least check that they compile.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/107320046
2014-06-25 08:22:22 +10:00
William Orr
63e3763af8 syscall: implement setresuid(2) and setresgid(2) on OpenBSD/FreeBSD/DragonflyBSD
Fixes #8218.

LGTM=iant
R=golang-codereviews, iant, minux
CC=golang-codereviews
https://golang.org/cl/107150043
2014-06-24 13:30:30 -07:00