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

15279 Commits

Author SHA1 Message Date
Dmitriy Vyukov
5dab2da954 runtime: mark global var as NOPTR
LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/119300043
2014-07-29 14:45:07 +04:00
Mikio Hara
c0325f5083 net: prevent spurious on-connect events via epoll on linux
On Linux, adding a socket descriptor to epoll instance before getting
the EINPROGRESS return value from connect system call could be a root
cause of spurious on-connect events.

See golang.org/issue/8276, golang.org/issue/8426 for further information.

All credit to Jason Eggleston <jason@eggnet.com>

Fixes #8276.
Fixes #8426.

LGTM=dvyukov
R=dvyukov, golang-codereviews, adg, dave, iant, alex.brainman
CC=golang-codereviews
https://golang.org/cl/120820043
2014-07-29 16:48:11 +09:00
Dmitriy Vyukov
9333fe8e92 cmd/ld: better diagnostics on unaligned symbols
Want to see why builders are failing.
Then decide whether to rollback or fix.

TBR=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/114510043
2014-07-29 11:22:57 +04:00
Dmitriy Vyukov
cd17a717f9 runtime: simpler and faster GC
Implement the design described in:
https://docs.google.com/document/d/1v4Oqa0WwHunqlb8C3ObL_uNQw3DfSY-ztoA-4wWbKcg/pub

Summary of the changes:
GC uses "2-bits per word" pointer type info embed directly into bitmap.
Scanning of stacks/data/heap is unified.
The old spans types go away.
Compiler generates "sparse" 4-bits type info for GC (directly for GC bitmap).
Linker generates "dense" 2-bits type info for data/bss (the same as stacks use).

Summary of results:
-1680 lines of code total (-1000+ in mgc0.c only)
-25% memory consumption
-3-7% binary size
-15% GC pause reduction
-7% run time reduction

LGTM=khr
R=golang-codereviews, rsc, christoph, khr
CC=golang-codereviews, rlh
https://golang.org/cl/106260045
2014-07-29 11:01:02 +04:00
Rui Ueyama
0100afbdcc image/png: use branch-free abs function
benchmark                        old ns/op     new ns/op     delta
BenchmarkPaeth                   5.06          6.02          +18.97%
BenchmarkDecodeGray              1010551       956911        -5.31%
BenchmarkDecodeNRGBAGradient     3877813       3754160       -3.19%
BenchmarkDecodeNRGBAOpaque       3194058       3079094       -3.60%
BenchmarkDecodePaletted          699243        700211        +0.14%
BenchmarkDecodeRGB               2835733       2692120       -5.06%
BenchmarkDecodeInterlacing       3651805       3563124       -2.43%
BenchmarkEncodeGray              4399183       4404113       +0.11%
BenchmarkEncodeNRGBOpaque        13323627      13306485      -0.13%
BenchmarkEncodeNRGBA             15840092      15751188      -0.56%
BenchmarkEncodePaletted          4396622       4404373       +0.18%
BenchmarkEncodeRGBOpaque         13320475      13279189      -0.31%
BenchmarkEncodeRGBA              36898392      36781002      -0.32%

LGTM=nigeltao
R=nigeltao
CC=golang-codereviews
https://golang.org/cl/117290043
2014-07-29 14:29:14 +10:00
Rob Pike
d3fb02b5c5 time: make it clearer that the reference time is the reference time.
Because the reference time is the reference time but beginners seem
to think otherwise, make it clearer you can't choose the reference time.

LGTM=josharian, dave
R=golang-codereviews, josharian, dave
CC=golang-codereviews
https://golang.org/cl/117250044
2014-07-28 17:24:39 -07:00
Adam Langley
30fbcc7576 crypto/tls: check curve equation in ECDHE.
This change causes a TLS client and server to verify that received
elliptic curve points are on the expected curve. This isn't actually
necessary in the Go TLS stack, but Watson Ladd has convinced me that
it's worthwhile because it's pretty cheap and it removes the
possibility that some change in the future (e.g. tls-unique) will
depend on it without the author checking that precondition.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/115290046
2014-07-28 15:46:27 -07:00
Adam Langley
8332112d0a encoding/asn1: only omit optional elements matching default value.
ASN.1 elements can be optional, and can have a default value.
Traditionally, Go has omitted elements that are optional and that have
the zero value. I believe that's a bug (see [1]).

This change causes an optional element with a default value to only be
omitted when it has that default value. The previous behaviour of
omitting optional, zero elements with no default is retained because
it's used quite a lot and will break things if changed.

[1] https://groups.google.com/d/msg/Golang-nuts/9Ss6o9CW-Yo/KL_V7hFlyOAJ

Fixes #7780.

R=bradfitz

LGTM=bradfitz
R=golang-codereviews, bradfitz, rsc
CC=golang-codereviews, r
https://golang.org/cl/86960045
2014-07-28 14:47:37 -07:00
Asim Shankar
42d0785bbd crypto/tls: Support ECDSA keys in generate_cert.go
R=golang-codereviews, bradfitz, agl
CC=golang-codereviews
https://golang.org/cl/117180043
2014-07-28 14:46:34 -07:00
Brad Fitzpatrick
f5037ee127 net/http: make ServeContent support dates in If-Range headers
Fixes #8367

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/116300044
2014-07-27 23:30:53 -07:00
Shenghou Ma
20a5de9eb6 liblink: warn about TLS base MRC instruction that does not write into R0.
While we're here, make it lookup the tlsfallback symbol only once.

LGTM=crawshaw
R=golang-codereviews, crawshaw, dave
CC=golang-codereviews
https://golang.org/cl/107430044
2014-07-26 17:46:51 -04:00
Shenghou Ma
faa223459a cmd/ld: remove duplicated nuxiinit() call.
It is already called by linknew().

LGTM=dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/120760043
2014-07-26 17:45:45 -04:00
Shenghou Ma
a57dda74d9 cmd/5g: remove dead code.
LGTM=bradfitz, dave
R=rsc, bradfitz, dave
CC=golang-codereviews
https://golang.org/cl/115070043
2014-07-26 17:45:24 -04:00
Shenghou Ma
61864c09fc cmd/5l: remove unused noop.c
LGTM=dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/116330043
2014-07-26 17:44:47 -04:00
Shenghou Ma
595dcef80a cmd/5l, cmd/6l, cmd/8l: remove mkenam.
Unused. cmd/dist will generate enams as liblink/anames[568].c.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/119940043
2014-07-26 17:43:10 -04:00
Keith Randall
c403af83a6 runtime: convert complex128div to go.
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/116320043
2014-07-25 15:12:45 -07:00
Bobby Powers
0f2cde8bdc cmd/gc: don't mark select descriptor as EscNone
selv is created with temp() which calls tempname, which marks
the new n with EscNever, so there is no need to explicitly set
EscNone on the select descriptor.

Fixes #8396.

LGTM=dvyukov
R=golang-codereviews, dave, dvyukov
CC=golang-codereviews
https://golang.org/cl/112520043
2014-07-25 11:22:58 +04:00
Alex Brainman
5e805aff4a syscall: fix handling of bool return values in mksyscall_windows.go
LGTM=chines
R=chines
CC=golang-codereviews
https://golang.org/cl/118160044
2014-07-25 15:13:59 +10:00
Mathieu Lonjaret
cf35f5b742 time: minor typo in doc
LGTM=minux
R=golang-codereviews, minux
CC=golang-codereviews
https://golang.org/cl/120150043
2014-07-24 18:18:41 -04:00
Keith Randall
3590d9ce69 runtime: set sweepgen atomically before updating span state
Sweepone may be running while a new span is allocating.  It
must not see the state updated while the sweepgen is unset.

Fixes #8399

LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews
https://golang.org/cl/118050043
2014-07-24 14:37:34 -07:00
Brad Fitzpatrick
c4807f6a84 net/http: don't ignore errors in Request.Write
LGTM=josharian, adg
R=golang-codereviews, josharian, adg
CC=golang-codereviews
https://golang.org/cl/119110043
2014-07-23 18:38:13 -07:00
Dmitriy Vyukov
e91704af27 runtime: don't lock mheap on user goroutine
This is bad for 2 reasons:
1. if the code under lock ever grows stack,
it will deadlock as stack growing acquires mheap lock.
2. It currently deadlocks with SetCPUProfileRate:
scavenger locks mheap, receives prof signal and tries to lock prof lock;
meanwhile SetCPUProfileRate locks prof lock and tries to grow stack
(presumably in runtime.unlock->futexwakeup). Boom.
Let's assume that it
Fixes #8407.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews, khr
https://golang.org/cl/112640043
2014-07-23 18:52:25 +04:00
Dmitriy Vyukov
0603fbb01c runtime: fix unexpected return pc for runtime.newstackcall
With cl/112640043 TestCgoDeadlockCrash episodically print:
unexpected return pc for runtime.newstackcall
After adding debug output I see the following trace:

runtime: unexpected return pc for runtime.newstackcall called from 0xc208011b00
runtime.throw(0x414da86)
        src/pkg/runtime/panic.c:523 +0x77
runtime.gentraceback(0x40165fc, 0xba440c28, 0x0, 0xc208d15200, 0xc200000000, 0xc208ddfd20, 0x20, 0x0, 0x0, 0x300)
	src/pkg/runtime/traceback_x86.c:185 +0xca4
runtime.callers(0x1, 0xc208ddfd20, 0x20)
	src/pkg/runtime/traceback_x86.c:438 +0x98
mcommoninit(0xc208ddfc00)
	src/pkg/runtime/proc.c:369 +0x5c
runtime.allocm(0xc208052000)
	src/pkg/runtime/proc.c:686 +0xa6
newm(0x4017850, 0xc208052000)
	src/pkg/runtime/proc.c:933 +0x27
startm(0xc208052000, 0x100000001)
	src/pkg/runtime/proc.c:1011 +0xba
wakep()
	src/pkg/runtime/proc.c:1071 +0x57
resetspinning()
	src/pkg/runtime/proc.c:1297 +0xa1
schedule()
	src/pkg/runtime/proc.c:1366 +0x14b
runtime.gosched0(0xc20808e240)
	src/pkg/runtime/proc.c:1465 +0x5b
runtime.newstack()
	src/pkg/runtime/stack.c:891 +0x44d
runtime: unexpected return pc for runtime.newstackcall called from 0xc208011b00
runtime.newstackcall(0x4000cbd, 0x4000b80)
	src/pkg/runtime/asm_amd64.s:278 +0x6f

I suspect that it can happen on any stack split.
So don't unwind g0 stack.
Also, that comment is lying -- we can traceback w/o mcache,
CPU profiler does that.

LGTM=rsc
R=golang-codereviews
CC=golang-codereviews, khr, rsc
https://golang.org/cl/120040043
2014-07-23 18:51:34 +04:00
Russ Cox
b916dc1992 liblink: more precise literal word comparison on arm
There are fields in the Addr that do not matter for the
purpose of deciding that the same word is already
in the current literal pool. Copy only the fields that
do matter.

This came up when comparing against the Go version
because the way it is invoked doesn't copy a few fields
(like node) that are never directly used by liblink itself.

Also remove a stray print that is not well-defined in
the new liblink. (Cannot use %D outside of %P, because
%D needs the outer Prog*.)

LGTM=minux
R=minux
CC=golang-codereviews
https://golang.org/cl/119000043
2014-07-23 10:17:59 -04:00
Russ Cox
d4d50b5f01 lib9: format %#04x, 0 as 0x0000 not 000000.
This matches Go's fmt.Printf instead of ANSI C's dumb rules.
It makes the -S output from C liblink match Go's liblink.

LGTM=minux
R=minux
CC=golang-codereviews
https://golang.org/cl/112600043
2014-07-23 10:17:47 -04:00
Dmitriy Vyukov
8b20e7bb7e cmd/gc: mark auxiliary symbols as containing no pointers
They do not, but pretend that they do.
The immediate need is that it breaks the new GC because
these are weird symbols as if with pointers but not necessary
pointer aligned.

LGTM=rsc
R=golang-codereviews, dave, josharian, khr, rsc
CC=golang-codereviews, iant, khr, rlh
https://golang.org/cl/116060043
2014-07-23 17:36:10 +04:00
Russ Cox
d2d7187d31 testing: add Coverage function
I've found this very useful for generating
good test case lists for -short mode for
the disassemblers.

Fixes #7959.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/98150043
2014-07-22 22:56:35 -04:00
Alex Brainman
0403181a88 syscall: allow for mksyscall_windows.go to be used outside of syscall
Fixes #8398.

LGTM=chines
R=golang-codereviews, chines, josharian
CC=golang-codereviews
https://golang.org/cl/114140043
2014-07-23 12:36:34 +10:00
Dave Cheney
355c38d86a runtime: rename throwgo to gothrow
As pointed out by Elias Naur, the convention for Go runtime functions means this function should be named gothrow.

Discussion: https://golang.org/cl/115860045/#msg6

LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews
https://golang.org/cl/118120043
2014-07-23 07:08:52 +10:00
Dmitriy Vyukov
65e2b6f847 cmd/ld: mark hostobj sections as containing no pointers
Currently they are scanned conservatively.
But there is no reason to scan them. C world must not contain
pointers into Go heap. Moreover, we don't have enough information
to emit write barriers nor update pointers there in future.
The immediate need is that it breaks the new GC because
these are weird symbols as if with pointers but not necessary
pointer aligned.

LGTM=rsc
R=golang-codereviews, rlh, rsc
CC=golang-codereviews, iant, khr
https://golang.org/cl/117000043
2014-07-22 12:10:18 +04:00
Keith Randall
722764b75a runtime: make go vet happy
CL 117950044 updates vet to fix LEA* issue.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/112440043
2014-07-21 21:35:48 -07:00
Keith Randall
064acace5b cmd/gc: in the runtime package, don't promote any decls to the heap.
In the runtime, we want to control where allocations happen.
In particular, we don't want the code implementing malloc to
itself trigger a malloc.  This change prevents the compiler
from inserting mallocs on our behalf (due to escaping declarations).

This check does not trigger on the current runtime code.

Note: Composite literals are still allowed.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/105280047
2014-07-21 20:56:44 -07:00
Keith Randall
76f1b901db runtime: keep build version around in binaries
So we can tell from a binary which version of
Go built it.

LGTM=minux, rsc
R=golang-codereviews, minux, khr, rsc, dave
CC=golang-codereviews
https://golang.org/cl/117040043
2014-07-21 20:52:11 -07:00
David Symonds
d9079cc883 syscall: fix typo in namei doc comment.
LGTM=dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/112420044
2014-07-22 10:09:32 +10:00
David Symonds
446bfffcd6 crypto/subtle: make ConstantTimeCompare return zero for args of different length.
This is more useful than panicking, since otherwise every caller needs
to do the length check before calling; some will forget, and have a
potential submarine crasher as a result. Other implementations of this
functionality do a length check.

This is backward compatible, except if someone has written code that
relies on this panicking with different length args. However, that was
not the case before Go 1.3 either.

Updates #7304.

LGTM=agl
R=agl, minux, hanwen
CC=golang-codereviews
https://golang.org/cl/118750043
2014-07-22 10:08:23 +10:00
Dmitriy Vyukov
7bcbdbd904 runtime: pass correct size to malloc
In both cases we lie to malloc about the actual size that we need.
In panic we ask for less memory than we are going to use.
In slice we ask for more memory than we are going to use
(potentially asking for a fractional number of elements).
This breaks the new GC.

LGTM=khr
R=golang-codereviews, dave, khr
CC=golang-codereviews, rsc
https://golang.org/cl/116940043
2014-07-22 01:56:19 +04:00
Dmitriy Vyukov
92c54e4a73 runtime: simplify code
LGTM=khr
R=golang-codereviews, dave, khr
CC=golang-codereviews, rsc
https://golang.org/cl/116950043
2014-07-22 01:56:01 +04:00
Russ Cox
8e0e09ae7d liblink: remove some gotos + other fixes
Rewrite gotos that violate Go's stricter rules.
Use uchar* instead of char* in a few places that aren't strings.
Remove dead opcross code from asm5.c.
Declare regstr (in both list6 and list8) static.

LGTM=minux, dave
R=minux, dave
CC=golang-codereviews
https://golang.org/cl/113230043
2014-07-21 17:38:48 -04:00
Russ Cox
34655223ef runtime: round gohash stack frame to multiple of 8 on amd64p32
Even though pointers are 4 bytes the stack frame should be kept
a multiple of 8 bytes so that return addresses pushed on the stack
are properly aligned.

Fixes #8379.

LGTM=dvyukov, minux
R=minux, bradfitz, dvyukov, dave
CC=golang-codereviews
https://golang.org/cl/115840048
2014-07-21 17:38:30 -04:00
Brad Fitzpatrick
783bc895ae net/http: create internal pkg, unify two chunked.go files
LGTM=rsc
R=rsc, dan.kortschak
CC=golang-codereviews, r
https://golang.org/cl/115840046
2014-07-21 12:18:14 -07:00
Brad Fitzpatrick
4676e260e3 cmd/api: ignore internal packages
We might want to add a go/build.IsInternal(pkg string) bool
later, but this works for now.

LGTM=dave, rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/113300044
2014-07-21 12:06:30 -07:00
Josh Bleecher Snyder
2ac289c4a0 runtime: add Benchmark[Clear|Copy]Fat[8|12]
These correspond to 2 and 3 word fat copies/clears on 8g, which dominate usage in the stdlib. (70% of copies and 46% of clears are for 2 or 3 words.) I missed these in CL 111350043, which added 2 and 3 word benchmarks for 6g. A follow-up CL will optimize these cases.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/115160043
2014-07-21 11:23:29 -07:00
Alex Brainman
ebfc7e862e make.bat: do not exit builder on successful completion of make.bat (fixes build)
LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews
https://golang.org/cl/118020043
2014-07-21 16:29:38 +10:00
Dmitriy Vyukov
88b78b41c5 cmd/gc: do not mark PC as pointer on stack
GC thinks that it's an invalid pointer on plan9:
http://build.golang.org/log/f7da638a20544ef7f45e81f23fdbc4875044c296

LGTM=0intro
R=golang-codereviews, 0intro
CC=aram, golang-codereviews
https://golang.org/cl/113350043
2014-07-20 18:52:46 +04:00
Dmitriy Vyukov
40d7d5a656 cmd/gc: allocate select descriptor on stack
benchmark                      old ns/op     new ns/op     delta
BenchmarkSelectUncontended     220           165           -25.00%
BenchmarkSelectContended       209           161           -22.97%
BenchmarkSelectProdCons        1042          904           -13.24%

But more importantly this change will allow
to get rid of free function in runtime.

Fixes #6494.

LGTM=rsc, khr
R=golang-codereviews, rsc, dominik.honnef, khr
CC=golang-codereviews, remyoudompheng
https://golang.org/cl/107670043
2014-07-20 15:07:10 +04:00
Dmitriy Vyukov
1a116c76ae sync/atomic: fix data races in tests
Fixes #8389.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/111320044
2014-07-20 14:59:19 +04:00
Anthony Martin
a7fe1f1612 build: be verbose when running tests on Plan 9
This is a temporary change to see how far the
builder gets when it times out.

LGTM=aram, 0intro
R=0intro, aram
CC=golang-codereviews, mischief
https://golang.org/cl/111400043
2014-07-20 13:14:53 +03:00
Keith Randall
01a7d39df1 runtime: fix stacks_sys accounting
subtract freed count before span gets merged during free.

LGTM=dvyukov
R=dmitry, dvyukov
CC=golang-codereviews
https://golang.org/cl/112450045
2014-07-19 10:29:57 -07:00
David du Colombier
a91c1f5c83 cmd/addr2line, cmd/objdump: fix on amd64 Plan 9
Fix virtual address of the start of the text segment
on amd64 Plan 9.

This issue has been partially fixed in cmd/add2line,
as part of CL 106460044, but we forgot to report the
change to cmd/objdump.

In the meantime, we also fixed the textStart address
in both cmd/add2line and cmd/objdump.

LGTM=aram, ality, mischief
R=rsc, mischief, aram, ality
CC=golang-codereviews, jas
https://golang.org/cl/117920043
2014-07-19 12:16:16 +03:00
Josh Bleecher Snyder
d2f322e9be runtime: use uint32 arrays in BenchmarkClearFat*
The CopyFat benchmarks were changed in CL 92760044. See CL 111350043 for discussion.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/116000043
2014-07-18 12:41:20 -07:00
Josh Bleecher Snyder
3ee391cc83 runtime: add Benchmark[Clear|Copy]Fat[16|24]
These benchmarks are important for performance. When compiling the stdlib:

* 77.1% of the calls to sgen (copyfat) are for 16 bytes; another 8.7% are for 24 bytes. (The next most common is 32 bytes, at 5.7%.)
* Over half the calls to clearfat are for 16 or 24 bytes.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews
https://golang.org/cl/111350043
2014-07-18 12:18:36 -07:00
Nicolas Owens
e45c384b73 os: broaden the range of errors understood by IsNotExist on Plan 9
Ken's standalone file server and its derivatives, like cwfs, return
error strings different from fossil when the user opens non-existent
files.

LGTM=aram, 0intro, r
R=0intro, aram, r
CC=golang-codereviews, ken
https://golang.org/cl/112420045
2014-07-18 11:04:29 -07:00
Josh Bleecher Snyder
6089fc767c go/ast: fix typo in comment
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/111330043
2014-07-18 09:58:54 -07:00
Egon Elbre
0b2da60fb8 bufio: fix UnreadSlice followed by UnreadRune
Also, fix a write check in writeBuf and make some bounds checks simpler.

LGTM=gri
R=golang-codereviews, adg, gri, r, minux
CC=golang-codereviews
https://golang.org/cl/113060043
2014-07-18 09:25:59 -07:00
Keith Randall
2425a2e32f runtime: fix gctrace=1
updatememstats is called on both the m and g stacks.
Call into flushallmcaches correctly.  flushallmcaches
can only run on the M stack.

This is somewhat temporary.  once ReadMemStats is in
Go we can have all of this code M-only.

LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews
https://golang.org/cl/116880043
2014-07-18 13:05:21 +04:00
Dmitriy Vyukov
5d58033682 go/printer: simplify test
Pre Go1?

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/115870043
2014-07-18 12:44:24 +04:00
Dmitriy Vyukov
4423222760 encoding/gob: remove unnecessary receivers
Encoder compilation must be enc-independent,
because the resulting program is reused across
different encoders.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/115860043
2014-07-18 12:39:00 +04:00
Shenghou Ma
040eeff71c undo CL 109640045 / f97fb06525e5
Breaks build for FreeBSD. Probably clang related?

««« original CL description
cmd/cgo: disable inappropriate warnings when the gcc struct is empty

package main
//#cgo CFLAGS: -Wall
//void test() {}
import "C"
func main() {
    C.test()
}

This code will cause gcc issuing warnings about unused variable.

This commit use offset of the second return value of
Packages.structType to detect whether the gcc struct is empty,
and if it's directly invoke the C function instead of writing an
unused code.

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

»»»

TBR=dfc
R=dave
CC=golang-codereviews
https://golang.org/cl/114990044
2014-07-18 02:59:54 -04:00
snyh
086df1dc77 cmd/cgo: disable inappropriate warnings when the gcc struct is empty
package main
//#cgo CFLAGS: -Wall
//void test() {}
import "C"
func main() {
    C.test()
}

This code will cause gcc issuing warnings about unused variable.

This commit use offset of the second return value of
Packages.structType to detect whether the gcc struct is empty,
and if it's directly invoke the C function instead of writing an
unused code.

LGTM=dave, minux
R=golang-codereviews, iant, minux, dave
CC=golang-codereviews
https://golang.org/cl/109640045
2014-07-18 02:47:21 -04:00
Dave Cheney
ec5d7ba95c runtime: add throwgo
Fixes #8380.

Also update hashmap.go to use throwgo rather than panic.

LGTM=khr
R=khr, rsc
CC=golang-codereviews
https://golang.org/cl/115860045
2014-07-18 16:30:38 +10:00
Keith Randall
f378f30034 undo CL 101570044 / 2c57aaea79c4
redo stack allocation.  This is mostly the same as
the original CL with a few bug fixes.

1. add racemalloc() for stack allocations
2. fix poolalloc/poolfree to terminate free lists correctly.
3. adjust span ref count correctly.
4. don't use cache for sizes >= StackCacheSize.

Should fix bugs and memory leaks in original changelist.

««« original CL description
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
»»»

LGTM=dvyukov
R=dvyukov, dave, khr, alex.brainman
CC=golang-codereviews
https://golang.org/cl/112240044
2014-07-17 14:41:46 -07:00
Josh Bleecher Snyder
6b2aabeecc sync: fix typo in benchmark name
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/118860043
2014-07-17 12:50:56 -07:00
Dmitriy Vyukov
92c1e72040 runtime: make NumGoroutines faster
Resolves TODO for not walking all goroutines in NumGoroutines.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, rsc
https://golang.org/cl/107290044
2014-07-17 21:51:03 +04:00
Dmitriy Vyukov
dc84eca75e runtime: improve select benchmarks
1. Add select on sync channels benchmark.
2. Make channels in BenchmarkSelectNonblock shared.
With GOMAXPROCS=1 it is the same, but with GOMAXPROCS>1
it becomes a more interesting benchmark.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews
https://golang.org/cl/115780043
2014-07-17 21:49:45 +04:00
Rui Ueyama
90870e61b7 strings: remove byteBitmap
Previously we had a bitmap to check whether or not a byte
appears in a string should be replaced. But we don't actually
need a separate bitmap for that purpose. Removing the bitmap
makes the code simpler.

LGTM=dave, iant, nigeltao
R=golang-codereviews, dave, gobot, nigeltao, iant, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/110100043
2014-07-17 09:55:12 -07:00
Robert Griesemer
8158b8b686 gofmt: -s flag simplifies "for _ = range x"
LGTM=adonovan, rsc
R=rsc, adonovan
CC=golang-codereviews
https://golang.org/cl/117800043
2014-07-17 09:40:27 -07:00
Michael Fraenkel
cf521ce64f os: Implement symlink support for Windows
Fixes #5750.

https://code.google.com/p/go/issues/detail?id=5750

os: Separate windows from posix. Implement windows support.
path/filepath: Use the same implementation as other platforms
syscall: Add/rework new APIs for Windows

LGTM=alex.brainman
R=golang-codereviews, alex.brainman, gobot, rsc, minux
CC=golang-codereviews
https://golang.org/cl/86160044
2014-07-17 17:02:46 +10:00
Keith Randall
5035750f23 runtime: align gomemeq return value correctly
Fixes #8378

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/114880043
2014-07-16 17:16:12 -07:00
Cristian Staretu
7a9e7c0afa archive/tar: fix writing of pax headers
"archive/tar: reuse temporary buffer in writeHeader" introduced a
change which was supposed to help lower the number of allocations from
512 bytes for every call to writeHeader. This change broke the writing
of PAX headers.

writeHeader calls writePAXHeader and writePAXHeader calls writeHeader
again. writeHeader will end up writing the PAX header twice.

example broken header:
PaxHeaders.4007/NetLock_Arany_=Class_Gold=_Ftanstvny.crt0000000000000000000000000000007112301216634021512 xustar0000000000000000
PaxHeaders.4007/NetLock_Arany_=Class_Gold=_Ftanstvny.crt0000000000000000000000000000007112301216634021512 xustar0000000000000000

example correct header:
PaxHeaders.4290/NetLock_Arany_=Class_Gold=_Ftanstvny.crt0000000000000000000000000000007112301216634021516 xustar0000000000000000
0100644000000000000000000000270412301216634007250 0ustar0000000000000000

This commit adds a dedicated buffer for pax headers to the Writer
struct. This change increases the size of the struct by 512 bytes, but
allows tar/writer to avoid allocating 512 bytes for all written
headers and it avoids allocating 512 more bytes for pax headers.

LGTM=dsymonds
R=dsymonds, dave, iant
CC=golang-codereviews
https://golang.org/cl/110480043
2014-07-17 10:00:29 +10:00
Robert Griesemer
8a23c0021e src, misc: applied gofmt -s -w
Pending CL 113120043.

LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/112290043
2014-07-16 16:29:51 -07:00
Russ Cox
8d504c4e97 cmd/gc: implement 'for range x {'
Fixes #6102.

LGTM=gri
R=ken, r, gri
CC=golang-codereviews
https://golang.org/cl/113120043
2014-07-16 19:27:10 -04:00
Russ Cox
26d0f75f2b time: change nsec back to int32
The garbage collector and stack scans are good enough now.

Fixes #7446.

LGTM=r
R=r, dvyukov
CC=golang-codereviews, mdempsky, mtj
https://golang.org/cl/112870046
2014-07-16 19:26:45 -04:00
Russ Cox
055dfc204c liblink: fix precedence bug in pcdata comparison
As written, the ! applies before the &1.
This would crash writing out missing pcdata tables
if we ever used non-contiguous IDs in a function.
We don't, but fix anyway.

LGTM=iant, minux
R=minux, iant
CC=golang-codereviews
https://golang.org/cl/117810047
2014-07-16 19:26:36 -04:00
Keith Randall
0c6b55e76b runtime: convert map implementation to Go.
It's a bit slower, but not painfully so.  There is still room for
improvement (saving space so we can use nosplit, and removing the
requirement for hash/eq stubs).

benchmark                              old ns/op     new ns/op     delta
BenchmarkMegMap                        23.5          24.2          +2.98%
BenchmarkMegOneMap                     14.9          15.7          +5.37%
BenchmarkMegEqMap                      71668         72234         +0.79%
BenchmarkMegEmptyMap                   4.05          4.93          +21.73%
BenchmarkSmallStrMap                   21.9          22.5          +2.74%
BenchmarkMapStringKeysEight_16         23.1          26.3          +13.85%
BenchmarkMapStringKeysEight_32         21.9          25.0          +14.16%
BenchmarkMapStringKeysEight_64         21.9          25.1          +14.61%
BenchmarkMapStringKeysEight_1M         21.9          25.0          +14.16%
BenchmarkIntMap                        21.8          12.5          -42.66%
BenchmarkRepeatedLookupStrMapKey32     39.3          30.2          -23.16%
BenchmarkRepeatedLookupStrMapKey1M     322353        322675        +0.10%
BenchmarkNewEmptyMap                   129           136           +5.43%
BenchmarkMapIter                       137           107           -21.90%
BenchmarkMapIterEmpty                  7.14          8.71          +21.99%
BenchmarkSameLengthMap                 5.24          6.82          +30.15%
BenchmarkBigKeyMap                     34.5          35.3          +2.32%
BenchmarkBigValMap                     36.1          36.1          +0.00%
BenchmarkSmallKeyMap                   26.9          26.7          -0.74%

LGTM=rsc
R=golang-codereviews, dave, dvyukov, rsc, gobot, khr
CC=golang-codereviews
https://golang.org/cl/99380043
2014-07-16 14:16:19 -07:00
Volker Dobler
3b1b840699 strconv: fix handling of BOMs in CanBackquote
A byte order mark  (BOM) cannot be backquoted.

LGTM=r
R=golang-codereviews, gobot, r
CC=golang-codereviews
https://golang.org/cl/112310043
2014-07-16 13:06:11 -07:00
Matthew Cottingham
a03900a12f flag: fix typo
LGTM=r
R=golang-codereviews, gobot, r
CC=golang-codereviews
https://golang.org/cl/114850043
2014-07-16 12:27:25 -07:00
Rob Pike
74c9cc8394 cmd/ld: use count, not upper bound, in type of array
DWARF says only one is necessary.
The count is preferable because it admits 0-length arrays.
Update debug/dwarf to handle either form.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/111230044
2014-07-16 18:26:50 +00:00
Yasuhiro Matsumoto
59af2c647b cmd/go/doc: Fix example domain
code.org exists

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/95500043
2014-07-16 20:48:57 +10:00
Dmitriy Vyukov
aa76377423 runtime: start goroutine ids at 1
LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews, khr
https://golang.org/cl/117810043
2014-07-16 12:19:33 +04:00
Adam Langley
c12c5dba9c compress/bzip2: fix panics on malformed input.
Fixes 8363.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/114810043
2014-07-15 18:44:33 -07:00
Rob Pike
cddad8affe cmd/ld: change DWARF encoding for array lengths
They can be large, so use a varint encoding rather than only one byte.

LGTM=iant, rsc
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/113180043
2014-07-15 21:18:18 +00:00
Matthew Dempsky
6012ac9b79 cmd/ld: consistently document flags that expect values
LGTM=minux, rsc
R=golang-codereviews, minux, rsc
CC=golang-codereviews
https://golang.org/cl/113970044
2014-07-15 17:05:35 -04:00
Matthew Dempsky
348a20548d objdump: remove out-of-date comment
LGTM=iant
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/112320043
2014-07-15 06:03:36 -07:00
Dmitriy Vyukov
387c1c661f runtime: make a test more robust
The issue is discovered during testing of a change to runtime.
Even if it is unlikely to happen, the comment can safe an hour
next person who hits it.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, rlh, rsc
https://golang.org/cl/116790043
2014-07-15 10:30:12 +04:00
Dmitriy Vyukov
8422d1ea65 runtime: zero dangling pointer
I don't see how it can lead to bad things today.
But it's better to kill it before it does.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, rsc
https://golang.org/cl/111130045
2014-07-15 10:27:36 +04:00
Jakob Borg
0a5cb7dc49 net: Don't read beyond end of slice when parsing resolv.conf options.
Fixes #8252.

LGTM=adg
R=ruiu, josharian, adg
CC=golang-codereviews
https://golang.org/cl/102470046
2014-07-15 14:49:26 +10:00
Dave Cheney
c213b8864f cmd/go: skip vcs tests on nacl and android
Fixes build failures on nacl/* and android/* platforms.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/113140043
2014-07-15 14:45:59 +10:00
Volker Dobler
c0a824aad6 strconv: fix CanBackquote for invalid UTF-8
Make CanBackquote(invalid UTF-8) return false.

Also add two test which show that CanBackquote reports
true for strings containing a BOM.

Fixes #7572.

LGTM=r
R=golang-codereviews, bradfitz, r
CC=golang-codereviews
https://golang.org/cl/111780045
2014-07-14 19:49:26 -07:00
Robert Griesemer
deae10e038 go/ast: fix walk to handle "for range x"
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/117790043
2014-07-14 19:14:27 -07:00
Rob Pike
79b106ec62 cmd/ld: generate correct upper bound value for array types.
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/115820043
2014-07-15 01:38:05 +00:00
Chris McGee
fd7b82b4e4 go get: Support for IBM DevOps Services (hub.jazz.net) git repos
LGTM=adg
R=golang-codereviews, adg, minux
CC=golang-codereviews
https://golang.org/cl/106740044
2014-07-15 11:27:04 +10:00
Russ Cox
64c2083ebc runtime: refactor routines for stopping, running goroutine from m
This CL adds 'dropg', which is called to drop the association
between m and its current goroutine, and it makes schedule
handle locked goroutines correctly, instead of requiring all
callers of schedule to do that.

The effect is that if you want to take over an m for, say,
garbage collection work while still allowing the current g
to run on some other m, you can do an mcall to a function
that is:

        // dissociate gp
        dropg();
        gp->status = Gwaiting; // for ready

        // put gp on run queue for others to find
        runtime·ready(gp);

        /* ... do other work here ... */

        // done with m, let it run goroutines again
        schedule();

Before this CL, the dropg() body had to be written explicitly,
and the check for lockedg before schedule had to be
written explicitly too, both of which make the code a bit
more fragile than it needs to be.

LGTM=iant
R=dvyukov, iant
CC=golang-codereviews, rlh
https://golang.org/cl/113110043
2014-07-14 20:56:37 -04:00
Robert Griesemer
d3a2f58700 go/*: permit "for range x"
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/112970044
2014-07-14 16:17:17 -07:00
Peter Collingbourne
8b836fa872 cmd/go: introduce support for $GCCGO env var
This variable allows users to select the compiler when using the
gccgo toolchain.

LGTM=rsc
R=rsc, iant, minux, aram
CC=axwalk, golang-codereviews
https://golang.org/cl/106700044
2014-07-14 09:51:20 -04:00
Alex Brainman
369a3ff3fd make.bat: return exit code to dashboard builder
Fixes #7806.

LGTM=minux
R=golang-codereviews, minux
CC=golang-codereviews
https://golang.org/cl/104690043
2014-07-12 15:18:36 +10:00
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