1
0
mirror of https://github.com/golang/go synced 2024-10-02 14:38:33 -06:00
Commit Graph

12994 Commits

Author SHA1 Message Date
Rémy Oudompheng
a0f74093b2 crypto/des: faster block expansion.
On amd64:

benchmark           old ns/op    new ns/op    delta
BenchmarkEncrypt         6170         3593  -41.77%
BenchmarkDecrypt         6209         3564  -42.60%

benchmark            old MB/s     new MB/s  speedup
BenchmarkEncrypt         1.30         2.23    1.72x
BenchmarkDecrypt         1.29         2.24    1.74x

Update #4299.

R=golang-dev, agl, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/11874043
2013-07-26 09:10:29 +02:00
Alex Brainman
a79e125b2f cmd/pack: support removing of leading file prefix on windows
Fixes #5550

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11904043
2013-07-26 16:56:24 +10:00
Alex Brainman
32a3ce6799 gc: fix line directive processing on windows
This change should have been part of 5671737303a0.

Fixes #5904

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11894043
2013-07-26 13:38:24 +10:00
Keith Randall
ad5cd931d8 undo CL 11788043 / 62d06cccc261
Reason for breakage fixed with CL 11888043.

««« original CL description
undo CL 11683043 / bb75d03e6ccb

Broke arm build.
R=dave

««« original CL description
cc: generate argument pointer maps for C functions.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11683043
»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/11788043
»»»

TBR=dave
CC=golang-dev
https://golang.org/cl/11789043
2013-07-25 17:51:33 -07:00
Keith Randall
de6da4a8bd 5c: fix pc recalculation in the presence of AFUNCDATA
This makes CL 11683043 not break arm anymore.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/11888043
2013-07-25 17:40:29 -07:00
Robert Griesemer
4a695d2c18 go/parser: restrict ParseDir to files with suffix ".go"
Fixes #5956.

R=rsc, r
CC=golang-dev
https://golang.org/cl/11813043
2013-07-25 09:36:22 -07:00
Mikio Hara
cdd3598334 net: give more detail when test panics
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/11811043
2013-07-26 00:21:37 +09:00
Peter Mundy
5852760088 syscall: prlimit argument error for Getrlimit and Setrlimit on Linux 32-bit
The rlimit arguments for prlimit are reversed for linux 32-bit (386 and arm).
Getrlimit becomes Setrlimit and vice versa.
Fixes #5949.

R=iant, mikioh.mikioh, rsc
CC=golang-dev
https://golang.org/cl/11803043
2013-07-25 09:56:06 -04:00
Ian Lance Taylor
d9d3debee5 cmd/cgo: gccgo fixes
Don't require a full-scale callback for calls to the special
prologue functions.

Always use a simple wrapper function for C functions, so that
we can handle static functions defined in the import "C"
comment.

Disable a test that relies on gc-specific function names.

Fixes #5905.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11406047
2013-07-25 09:53:57 -04:00
Rémy Oudompheng
d7c99cdf9f cmd/gc: avoid passing unevaluated constant expressions to backends.
Backends do not exactly expect receiving binary operators with
constant operands or use workarounds to move them to
register/stack in order to handle them.

Fixes #5841.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/11107044
2013-07-25 09:42:05 -04:00
Mikio Hara
c0a4ce52c6 net: simplify probeIPv6Stack
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/11807043
2013-07-25 19:29:20 +09:00
Nick Craig-Wood
085159da26 crypto/md5: native arm assembler version
An ARM version of md5block.go with a big improvement in
throughput (up to 2.5x) and a reduction in object size (21%).

Code size

  Before 3100 bytes
  After 2424 bytes
  21% smaller

Benchmarks on Rasperry Pi

benchmark                       old ns/op    new ns/op    delta
BenchmarkHash8Bytes                 11703         6636  -43.30%
BenchmarkHash1K                     38057        21881  -42.50%
BenchmarkHash8K                    208131       142735  -31.42%
BenchmarkHash8BytesUnaligned        11457         6570  -42.66%
BenchmarkHash1KUnaligned            69334        26841  -61.29%
BenchmarkHash8KUnaligned           455120       182223  -59.96%

benchmark                        old MB/s     new MB/s  speedup
BenchmarkHash8Bytes                  0.68         1.21    1.78x
BenchmarkHash1K                     26.91        46.80    1.74x
BenchmarkHash8K                     39.36        57.39    1.46x
BenchmarkHash8BytesUnaligned         0.70         1.22    1.74x
BenchmarkHash1KUnaligned            14.77        38.15    2.58x
BenchmarkHash8KUnaligned            18.00        44.96    2.50x

benchmark                      old allocs   new allocs    delta
BenchmarkHash8Bytes                     1            0  -100.00%
BenchmarkHash1K                         2            0  -100.00%
BenchmarkHash8K                         2            0  -100.00%
BenchmarkHash8BytesUnaligned            1            0  -100.00%
BenchmarkHash1KUnaligned                2            0  -100.00%
BenchmarkHash8KUnaligned                2            0  -100.00%

benchmark                       old bytes    new bytes    delta
BenchmarkHash8Bytes                    64            0  -100.00%
BenchmarkHash1K                       128            0  -100.00%
BenchmarkHash8K                       128            0  -100.00%
BenchmarkHash8BytesUnaligned           64            0  -100.00%
BenchmarkHash1KUnaligned              128            0  -100.00%
BenchmarkHash8KUnaligned              128            0  -100.00%

This also adds another test which makes sure that the sums
over larger blocks work properly. I wrote this test when I was
worried about memory corruption.

R=golang-dev, dave, bradfitz, rsc, ajstarks
CC=golang-dev, minux.ma, remyoudompheng
https://golang.org/cl/11648043
2013-07-25 13:28:27 +10:00
Andrew Gerrand
93c6d0ef8f bufio: check buffer availability before reading in ReadFrom
Fixes #5947.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/11801043
2013-07-25 11:29:13 +10:00
Kevin Klues
f7dfeea90f cmd/cgo: Fix issue with cgo cdefs
The problem is that the cdecl() function in cmd/cgo/godefs.go isn't
properly translating the Go array type to a C array type when an
asterisk follows the [] in the array type declaration (it is perfectly
legal to put the asterisk on either side of the [] in go syntax,
depending on how you set up your pointers).

That said, the cdefs tool is only designed to translate from Go types
generated using the cgo *godefs* tool -- where the godefs tool is
designed to translate gcc-style C types into Go types. In essence, the
cdefs tool translates from gcc-style C types to Go types (via the godefs
tool), then back to kenc-style C types. Because of this, cdefs does not
need to know how to translate arbitraty Go types into C, just the ones
produced by godefs.

The problem is that during this translation process, the logic is
slightly wrong when going from (e.g.):

char *array[10];
to:
array [10]*int8;
back to:
int8 *array[10];

In the current implementation of cdecl(), the translation from the Go
type declaration back to the kenc-style declaration looks for Go
types of the form:

name *[]type;
rather than the actual generated Go type declaration of:
name []*type;

Both are valid Go syntax, with slightly different semantics, but the
latter is the only one that can ever be generated by the godefs tools.
(The semantics of the former are not directly expressible in a
single C statement -- you would have to have to first typedef the array
type, then declare a pointer to that typedef'd type in a separate
statement).

This commit changes the logic of cdecl() to look properly for, and
translate, Go type declarations of the form:
name []*type;

Additionally, the original implementation only allowed for a single
asterisk and a single sized aray (i.e. only a single level of pointer
indirection, and only one set of []) on the type, whereas the patched
version allows for an arbitrary number of both.

Tests are included in misc/cgo/testcdefs and the all.bash script has been
updated to account for these.

R=golang-dev, bradfitz, dave, iant
CC=golang-dev
https://golang.org/cl/11377043
2013-07-24 17:27:42 -07:00
Keith Randall
b3defa2e8e undo CL 11683043 / bb75d03e6ccb
Broke arm build.
R=dave

««« original CL description
cc: generate argument pointer maps for C functions.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11683043
»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/11788043
2013-07-24 15:04:10 -07:00
Ian Lance Taylor
0738c7e977 log/syslog: restore use of serverConn interface
Revision 15629 (8d71734a0cb0) removed the serverConn interface
that was introduce in revision 7718 (ee5e80c62862).  The
serverConn interface was there for use by gccgo on Solaris,
and it is still needed there.  Solaris does not support
connecting to the syslog daemon over TCP, and gccgo simply
calls the C library function.  This CL restores the
interface.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/11737043
2013-07-24 10:28:57 -07:00
Keith Randall
3453a2204b runtime: only define SEH when we need it.
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/11769043
2013-07-24 09:59:47 -07:00
Keith Randall
9b1f1833de cc: generate argument pointer maps for C functions.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11683043
2013-07-24 09:41:06 -07:00
Mikio Hara
8f746af65d runtime: drop EV_RECEIPT support from network pollster on kqueue
Currently Darwin and FreeBSD support and NetBSD and OpenBSD do not
support EV_RECEIPT flag. We will drop use of EV_RECEIPT for now.

Also enables to build runtime-integrated network pollster on
freebsd/amd64,386 and openbsd/amd64,386. It just does build but never
runs pollster stuff.

This is in preparation for runtime-integrated network pollster for BSD
variants.

Update #5199

R=dvyukov, minux.ma
CC=golang-dev
https://golang.org/cl/11759044
2013-07-25 00:24:17 +09:00
Russ Cox
f011282578 runtime: more cgocallback_gofunc work
Debugging the Windows breakage I noticed that SEH
only exists on 386, so we can balance the two stacks
a little more on amd64 and reclaim another word.

Now we're down to just one word consumed by
cgocallback_gofunc, having reclaimed 25% of the
overall budget (4 words out of 16).

Separately, fix windows/386 - the SEH must be on the
m0 stack, as must the saved SP, so we are forced to have
a three-word frame for 386. It matters much less for
386, because there 128 bytes gives 32 words to use.

R=dvyukov, alex.brainman
CC=golang-dev
https://golang.org/cl/11551044
2013-07-24 09:01:57 -04:00
Mikio Hara
a0935cc979 runtime: fix throw message in netpoll
R=dvyukov, r
CC=golang-dev
https://golang.org/cl/11761043
2013-07-24 17:48:13 +09:00
Russ Cox
cefdb9c286 runtime: fix windows build
TBR=golang-dev
CC=golang-dev
https://golang.org/cl/11595045
2013-07-23 22:59:32 -04:00
Rob Pike
6a801539c5 unicode: add "In" function to test membership of a rune
The existing function, IsOneOf, is hard to use. Since the slice comes
before the rune, in parallelism with the other Is functions, the slice
is clumsy to build. This CL adds a nicer-signatured In function of
equivalent functionality (its implementation is identical) that's much
easier to use. Compare:
        unicode.IsOneOf([]*unicode.RangeTable{unicode.Letter, unicode.Number}, r)
        unicode.In(r, unicode.Letter, unicode.Number)

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/11672044
2013-07-24 10:27:58 +10:00
Mikio Hara
a0a45bbb71 net: consolidate listenerBacklog declaration
Also adds maxListenerBacklog placeholder for Plan 9.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/11674044
2013-07-24 08:43:08 +09:00
Russ Cox
dba623b1c7 runtime: reduce frame size for runtime.cgocallback_gofunc
Tying preemption to stack splits means that we have to able to
complete the call to exitsyscall (inside cgocallbackg at least for now)
without any stack split checks, meaning that the whole sequence
has to work within 128 bytes of stack, unless we increase the size
of the red zone. This CL frees up 24 bytes along that critical path
on amd64. (The 32-bit systems have plenty of space because all
their words are smaller.)

R=dvyukov
CC=golang-dev
https://golang.org/cl/11676043
2013-07-23 18:40:02 -04:00
Andrew Gerrand
e97c870692 math/rand: mention that the default Source is thread-safe
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11709043
2013-07-24 08:27:20 +10:00
Andrew Gerrand
6efb6b9e38 math/rand: mention Seed in overview, add another top-level example
Fixes #5937.

R=golang-dev, mirtchovski, r
CC=golang-dev
https://golang.org/cl/11705043
2013-07-23 16:07:28 +10:00
Brad Fitzpatrick
baa9ca032b net/http: respect tls.Config.ServerName in Transport
When making an HTTPS client request, respect the
ServerName field in the tls.Config.

Fixes #5829

R=golang-dev, agl, adg
CC=golang-dev
https://golang.org/cl/11691043
2013-07-22 22:39:09 -07:00
Alex Brainman
a293065a39 database/sql: close statement before connection
Fixes #5936

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/11620046
2013-07-23 14:09:53 +10:00
Rob Pike
abe384f68a all: be more idiomatic when documenting boolean return values.
Phrases like "returns whether or not the image is opaque" could be
describing what the function does (it always returns, regardless of
the opacity) or what it returns (a boolean indicating the opacity).
Even when the "or not" is missing, the phrasing is bizarre.

Go with "reports whether", which is still clunky but at least makes
it clear we're talking about the return value.

These were edited by hand. A few were cleaned up in other ways.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/11699043
2013-07-23 11:59:49 +10:00
Mikio Hara
7d9a8fb8a9 net: make use of noDeadline instead of time.Time{}
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/11691044
2013-07-23 10:13:58 +09:00
Nick Craig-Wood
f8fd77baa9 runtime: Stop arm memmove corrupting its parameters
Change use of x+(SP) to access the stack frame into x-(SP)

Fixes #5925.

R=golang-dev, bradfitz, dave, remyoudompheng, nick, rsc
CC=dave cheney <dave, golang-dev
https://golang.org/cl/11647043
2013-07-23 09:29:25 +10:00
Brad Fitzpatrick
48b9be2b19 all: change "true iff" to "whether" in public docs
For consistency with Go documentation style.

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/11697043
2013-07-22 16:20:30 -07:00
David du Colombier
b015af4117 cmd/ld: fix warnings on Plan 9
src/cmd/ld/lib.c:1379 set and not used: p
src/cmd/ld/lib.c:1426 format mismatch 6llux INT, arg 3
src/cmd/ld/lib.c:1437 format mismatch 6llux INT, arg 3
src/cmd/ld/lib.c:1456 format mismatch 6llux INT, arg 3
src/cmd/ld/lib.c:1477 format mismatch 6llux INT, arg 3
src/cmd/ld/lib.c:1459 set and not used: started

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11615044
2013-07-22 17:33:41 -04:00
Dmitriy Vyukov
e97d677b4e runtime: introduce notetsleepg function
notetsleepg is the same as notetsleep, but is called on user g.
It includes entersyscall/exitsyscall and will help to avoid
split stack functions in syscall status.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11681043
2013-07-22 23:02:27 +04:00
Dmitriy Vyukov
10d1e55103 runtime: allow stack split in body of closechan
This gives more space during the call to runtime.lock.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11679043
2013-07-22 20:47:39 +04:00
Dmitriy Vyukov
27134567fa runtime: clarify comment for m->locked
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11671043
2013-07-22 16:37:31 +04:00
Mikio Hara
5d14b89933 net: remove unnecessary bit masking
R=dave
CC=golang-dev
https://golang.org/cl/11537044
2013-07-22 20:08:58 +09:00
Alex Brainman
6ea7bf253c net: implement netpoll for windows
Moves the network poller from net package into runtime.

benchmark                           old ns/op    new ns/op    delta
BenchmarkTCP4OneShot                   316386       287061   -9.27%
BenchmarkTCP4OneShot-2                 339822       313424   -7.77%
BenchmarkTCP4OneShot-3                 330057       306589   -7.11%
BenchmarkTCP4OneShotTimeout            341775       287061  -16.01%
BenchmarkTCP4OneShotTimeout-2          380835       295849  -22.32%
BenchmarkTCP4OneShotTimeout-3          398412       328070  -17.66%
BenchmarkTCP4Persistent                 40622        33392  -17.80%
BenchmarkTCP4Persistent-2               44528        35736  -19.74%
BenchmarkTCP4Persistent-3               44919        36907  -17.84%
BenchmarkTCP4PersistentTimeout          45309        33588  -25.87%
BenchmarkTCP4PersistentTimeout-2        50289        38079  -24.28%
BenchmarkTCP4PersistentTimeout-3        51559        37103  -28.04%
BenchmarkTCP6OneShot                   361305       345645   -4.33%
BenchmarkTCP6OneShot-2                 361305       331976   -8.12%
BenchmarkTCP6OneShot-3                 376929       347598   -7.78%
BenchmarkTCP6OneShotTimeout            361305       322212  -10.82%
BenchmarkTCP6OneShotTimeout-2          378882       333928  -11.86%
BenchmarkTCP6OneShotTimeout-3          388647       335881  -13.58%
BenchmarkTCP6Persistent                 47653        35345  -25.83%
BenchmarkTCP6Persistent-2               49215        35736  -27.39%
BenchmarkTCP6Persistent-3               38474        37493   -2.55%
BenchmarkTCP6PersistentTimeout          56637        34369  -39.32%
BenchmarkTCP6PersistentTimeout-2        42575        38079  -10.56%
BenchmarkTCP6PersistentTimeout-3        44137        37689  -14.61%

R=dvyukov
CC=golang-dev
https://golang.org/cl/8670044
2013-07-22 12:49:57 +10:00
David Symonds
ae5991695c runtime: add a missing newline in a debug printf.
Trivial, but annoying while debugging this code.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/11656043
2013-07-22 12:42:42 +10:00
Rémy Oudompheng
21b9d14738 regexp: use a very fast random generator for benchmarks.
Calls into math/rand are very slow, especially under race
detector because of heap accesses.

go test -bench . -run none -benchtime .1s
Before: 23.0s
After:  17.4s

Fixes #5837.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/11564044
2013-07-20 23:31:51 +02:00
Anthony Martin
87976e72a8 libmach: support more 386/amd64 instructions
R=golang-dev, dave, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/10030043
2013-07-20 00:38:26 -07:00
Alex Brainman
cae5213b91 libmach,lib9: override unused parameter warnings (fixes netbsd and openbsd builds)
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/11623043
2013-07-20 16:09:30 +10:00
Alex Brainman
dfbe467eda libmach,lib9: override unused parameter warnings (fixes windows build)
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/11620044
2013-07-20 12:43:50 +10:00
Russ Cox
c485b58912 cmd/dist, cmd/go: enable more warnings, make clang errors legible
This does not change the default compiler on OS X to clang.
It appears that for now we can keep using gcc as long as we
enable a few more warning settings that are on-by-default
elsewhere.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/11610044
2013-07-19 19:36:15 -04:00
Russ Cox
c758841853 cmd/ld, runtime: remove unused fields from Func
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11604043
2013-07-19 18:52:35 -04:00
Ian Lance Taylor
7666f24a84 cmd/gc, cmd/ld: fix build: remove unused var, use correct var in printf
Fixes #5924.

R=golang-dev, khr, rsc
CC=golang-dev
https://golang.org/cl/11606043
2013-07-19 15:04:53 -07:00
Russ Cox
48769bf546 runtime: use funcdata to supply garbage collection information
This CL introduces a FUNCDATA number for runtime-specific
garbage collection metadata, changes the C and Go compilers
to emit that metadata, and changes the runtime to expect it.

The old pseudo-instructions that carried this information
are gone, as is the linker code to process them.

R=golang-dev, dvyukov, cshapiro
CC=golang-dev
https://golang.org/cl/11406044
2013-07-19 16:04:09 -04:00
Russ Cox
5d340de1f6 cmd/dist: generate offsets for P structure
So far no checked-in assembly needs these,
but it matches having them for M and G.
I needed these for some manual testing.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/11595043
2013-07-19 15:40:32 -04:00
Keith Randall
c38173bcbd debug/gosym: put pclinetest file in temporary directory
where it belongs.

R=rsc
CC=golang-dev
https://golang.org/cl/11596043
2013-07-19 12:31:42 -07:00
Keith Randall
6fc49c1854 runtime: cleanup: use ArgsSizeUnknown to mark all functions
whose argument size is unknown (C vararg functions, and
assembly code without an explicit specification).

We used to use 0 to mean "unknown" and 1 to mean "zero".
Now we use ArgsSizeUnknown (0x80000000) to mean "unknown".

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11590043
2013-07-19 11:19:18 -07:00
Dmitriy Vyukov
eb04df75cd runtime: prevent GC from seeing the contents of a frame in runfinq
This holds the last finalized object and arguments to its finalizer.
Fixes #5348.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/11454044
2013-07-19 18:01:33 +04:00
Dmitriy Vyukov
2a6520c2d3 runtime: hide mheap from GC
It contains pointers to first blocks of lots of spans.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/11416046
2013-07-19 17:47:40 +04:00
Dmitriy Vyukov
6857264457 runtime: prevent sysmon from polling network excessivly
If the network is not polled for 10ms, sysmon starts polling network
on every iteration (every 20us) until another thread blocks in netpoll.
Fixes #5922.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/11569043
2013-07-19 17:45:34 +04:00
David Symonds
9bfb69187f regexp: exclude exhaustive RE2 test from running under race detector.
It is an expensive test to run, and even more so with -race,
and causes timeouts on builders. It is doubtful that it would
find a race that other tests in this package wouldn't, so there
is little loss in excluding it.

Update #5837.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/11568043
2013-07-19 23:44:22 +10:00
Russ Cox
df3e6ce4b1 runtime: disable preemption during runtime.settype
It assumes that the m will not change, and the m may
change if the goroutine is preempted.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11560043
2013-07-18 22:58:49 -04:00
Brad Fitzpatrick
b2b15d1230 net/http: document and test Client.Post treating Reader body as ReadCloser
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11542044
2013-07-19 12:02:54 +10:00
Dmitriy Vyukov
bc31bcccd3 runtime: preempt long-running goroutines
If a goroutine runs for more than 10ms, preempt it.
Update #543.

R=rsc
CC=golang-dev
https://golang.org/cl/10796043
2013-07-19 01:22:26 +04:00
Russ Cox
58f12ffd79 runtime: handle morestack/lessstack in stack trace
If we start a garbage collection on g0 during a
stack split or unsplit, we'll see morestack or lessstack
at the top of the stack. Record an argument frame size
for those, and record that they terminate the stack.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/11533043
2013-07-18 16:53:45 -04:00
Russ Cox
8c741c97f7 cmd/6a, cmd/6l: make FUNCDATA work
R=ken2
CC=golang-dev
https://golang.org/cl/11397043
2013-07-18 15:38:19 -04:00
Daniel Morsing
b6f841733b regexp/syntax: update documentation for Parse.
Syntax description was moved to the top level comment of this package.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11536043
2013-07-18 21:28:00 +02:00
Russ Cox
ef12bbfc9d runtime: disable preemption during deferreturn
Deferreturn is synthesizing a new call frame.
It must not be interrupted between copying the args there
and fixing up the program counter, or else the stack will
be in an inconsistent state, one that will confuse the
garbage collector.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/11522043
2013-07-18 12:26:47 -04:00
Russ Cox
8166b2da19 runtime: record full frame size for arm _sfloat2
With preemption, _sfloat2 can show up in stack traces.
Write the function prototype in a way that accurately
shows the frame size and the fact that it might contain
pointers.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/11523043
2013-07-18 12:23:38 -04:00
Russ Cox
249f807c39 runtime: mark concatstring as variadic (fixes 386 build)
Windows was the only one seeing this bug reliably in the builder,
but it was easy to reproduce using 'GOGC=1 go test strconv'.
concatstring looked like it took only one string, but in fact it
takes a long list of strings. Add an explicit ... so that the traceback
will not use the "fixed" frame size and instead look at the
frame size metadata recorded by the caller.

R=golang-dev
TBR=golang-dev
CC=golang-dev
https://golang.org/cl/11531043
2013-07-18 12:19:38 -04:00
Russ Cox
ff52cadc01 cmd/ld: refine test for history stack pop (fix Windows build)
This should fix the Windows build, or at least
what's breaking it at the moment.

Fixes #5904.

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/11519044
2013-07-18 11:40:59 -04:00
Russ Cox
72bd1a7e36 debug/gosym: avoid test failure on Windows
Would fix build if build hadn't already been broken with something else.

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/11525043
2013-07-18 11:01:58 -04:00
Russ Cox
c3de91bb15 cmd/ld, runtime: use new contiguous pcln table
R=golang-dev, r, dave
CC=golang-dev
https://golang.org/cl/11494043
2013-07-18 10:43:22 -04:00
Russ Cox
08ce3c3133 libmach: update for Go 1.2 pcln table
The change to addr2line makes it easy to test by hand.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11485044
2013-07-18 10:12:28 -04:00
Russ Cox
d7b4a09ca8 debug/gosym: update for Go 1.2 pcln table
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11495043
2013-07-18 10:12:14 -04:00
Brad Fitzpatrick
39100543ff io: let SectionReader seek past the end; document Seeker semantics more
Be consistent with os.File, strings.Reader, bytes.Reader, etc,
which all allow seeks past the end.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11403043
2013-07-18 13:03:26 +10:00
Andrew Bonventre
a6f95ad34e image/gif: don't write superfluous global color table
R=r, nigeltao
CC=golang-dev
https://golang.org/cl/11446043
2013-07-18 11:11:23 +10:00
Ian Lance Taylor
c5c52f072b cmd/cgo: don't emit #pragma declarations when using gccgo
Update #5905

Don't emit #pragma cgo_ldflag and cgo_import_static
declarations that gccgo doesn't understand and can't use.

R=golang-dev, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/11490043
2013-07-17 18:02:21 -07:00
Dave Cheney
9094941a40 cmd/ld: trivial: fix unused parameter pedantry
R=golang-dev, r, rsc
CC=golang-dev
https://golang.org/cl/11436043
2013-07-18 10:11:43 +10:00
Brad Fitzpatrick
4aa6d35306 net/http: document NewRequest treating Reader as ReadCloser
R=golang-dev, dsymonds, rogpeppe
CC=golang-dev
https://golang.org/cl/11432044
2013-07-18 10:10:10 +10:00
Ian Lance Taylor
1da96a3039 runtime: disable preemption again to fix linux build
Otherwise the tests in pkg/runtime fail:

runtime: unknown argument frame size for runtime.deferreturn called from 0x48657b [runtime_test.func·022]
fatal error: invalid stack
...

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/11483043
2013-07-17 16:15:46 -07:00
Russ Cox
b913cf84dc runtime: re-enable preemption
Update #543

I believe the runtime is strong enough now to reenable
preemption during the function prologue.
Assuming this is or can be made stable, it will be in Go 1.2.
More aggressive preemption is not planned for Go 1.2.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/11433045
2013-07-17 14:03:27 -04:00
Dmitriy Vyukov
5887f142a3 runtime: more reliable preemption
Currently preemption signal g->stackguard0==StackPreempt
can be lost if it is received when preemption is disabled
(e.g. m->lock!=0). This change duplicates the preemption
signal in g->preempt and restores g->stackguard0
when preemption is enabled.
Update #543.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10792043
2013-07-17 12:52:37 -04:00
Russ Cox
a83748596c runtime: use new frame argument size information
With this CL, I believe the runtime always knows
the frame size during the gc walk. There is no fallback
to "assume entire stack frame of caller" anymore.

R=golang-dev, khr, cshapiro, dvyukov
CC=golang-dev
https://golang.org/cl/11374044
2013-07-17 12:47:18 -04:00
Joel Sing
7b7dac5e23 crypto/tls: Add support for ECDHE-ECDSA
Add support for ECDHE-ECDSA (RFC4492), which uses an ephemeral server
key pair to perform ECDH with ECDSA signatures. Like ECDHE-RSA,
ECDHE-ECDSA also provides PFS.

R=agl
CC=golang-dev
https://golang.org/cl/7006047
2013-07-17 12:33:16 -04:00
Daniel Morsing
85a7c090c4 cmd/8g: Make clearfat non-interleaved with pointer calculations.
clearfat (used to zero initialize structures) will use AX for x86 block ops. If we write to AX while calculating the dest pointer, we will fill the structure with incorrect values.
Since 64-bit arithmetic uses AX to synthesize a 64-bit register, getting an adress by indexing with 64-bit ops can clobber the register.

Fixes #5820.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11383043
2013-07-17 11:04:34 +02:00
Keith Randall
cc84176108 runtime: print g0 stack if we throw on it and GOTRACEBACK>=2.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11385045
2013-07-16 16:44:24 -07:00
Adam Langley
ad477e4e20 crypto/rsa: remove obsolete TODO.
(PSS support is complete.)

Thanks to Frithjof Schulze for noting this.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10871046
2013-07-16 19:34:21 -04:00
Russ Cox
7b3c8b7ac8 cmd/5g, cmd/6g, cmd/8g: insert arg size annotations on runtime calls
If calling a function in package runtime, emit argument size
information around the call in case the call is to a variadic C function.

R=ken2
CC=golang-dev
https://golang.org/cl/11371043
2013-07-16 16:25:10 -04:00
Russ Cox
4e141145b7 cmd/5c, cmd/6c, cmd/8c: record arg size for every call
R=ken2
CC=golang-dev
https://golang.org/cl/11364043
2013-07-16 16:24:43 -04:00
Russ Cox
9ddfb64365 runtime: record argument size in assembly functions
I have not done the system call stubs in sys_*.s.
I hope to avoid that, because those do not block, so those
frames will not appear in stack traces during garbage
collection.

R=golang-dev, dvyukov, khr
CC=golang-dev
https://golang.org/cl/11360043
2013-07-16 16:24:09 -04:00
Russ Cox
e69082ffdb syscall: record argument size for all assembly functions
While we're here, fix Syscall9 on NetBSD and OpenBSD:
it was storing the results into the wrong memory locations.
I guess no one uses that function's results on those systems.

Part of cleaning up stack traces and argument frame information.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/11355044
2013-07-16 16:23:53 -04:00
Russ Cox
47b89a37d9 cmd/5a, cmd/6a, cmd/8a: parse PCDATA
In cmd/5a, also add support for argument size in TEXT instruction.

R=ken2
CC=golang-dev
https://golang.org/cl/11357044
2013-07-16 16:23:28 -04:00
Russ Cox
567818224e cmd/5l, cmd/6l, cmd/8l: accept PCDATA instruction in input
The portable code in cmd/ld already knows how to process it,
we just have to ignore it during code generation.

R=ken2
CC=golang-dev
https://golang.org/cl/11363043
2013-07-16 16:23:11 -04:00
Dmitriy Vyukov
1d55685e26 runtime: minor cleanup of hashmap code
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/11357043
2013-07-16 19:51:18 +04:00
Joel Sing
9bd32b48ca net: fix setsockopt for openbsd
s/TCP_KEEPALIVE/SO_KEEPALIVE/ to unbreak build on OpenBSD.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/11345044
2013-07-16 08:35:06 -07:00
Russ Cox
5d363c6357 cmd/ld, runtime: new in-memory symbol table format
Design at http://golang.org/s/go12symtab.

This enables some cleanup of the garbage collector metadata
that will be done in future CLs.

This CL does not move the old symtab and pclntab back into
an unmapped section of the file. That's a bit tricky and will be
done separately.

Fixes #4020.

R=golang-dev, dave, cshapiro, iant, r
CC=golang-dev, nigeltao
https://golang.org/cl/11085043
2013-07-16 09:41:38 -04:00
Dmitriy Vyukov
63e0ddc7bf cmd/gc: do not race instrument syscall.forkAndExecInChild
Race instrumentation can allocate, switch stacks, preempt, etc.
All that is not allowed in between fork and exec.
Fixes #4840.

R=golang-dev, daniel.morsing, dave
CC=golang-dev
https://golang.org/cl/11324044
2013-07-16 15:35:03 +04:00
Daniel Morsing
7e270cf6c4 cmd/gc: fix incorrect error when using f(g()) form on ... args
Fixes #5358.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11282044
2013-07-16 11:43:11 +02:00
Evan Shaw
4949dcb211 cmd/gc: complex types don't contain pointers
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11334043
2013-07-16 17:41:31 +10:00
Rémy Oudompheng
a15074c4dc cmd/gc: fix race detector instrumentation of type switches.
A type switch on a value with map index expressions,
could get a spurious instrumentation from a OTYPESW node.
These nodes do not need instrumentation because after
walk the type switch has been turned into a sequence
of ifs.

Fixes #5890.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/11308043
2013-07-16 09:04:20 +02:00
Alex Brainman
45cff65502 runtime: switch to os stack in windows osyield and usleep
Fixes #5831

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11266043
2013-07-16 12:36:05 +10:00
Russ Cox
2254785c3e cmd/gc: tweak interface satisfaction error message
"M requires pointer receiver" can be misinterpreted to
mean that method M should have a pointer receiver but
does not. In fact the message means "M has a pointer
receiver" (and you don't have a pointer).

Fixes #5891.

R=ken2
CC=golang-dev
https://golang.org/cl/11313043
2013-07-15 20:39:07 -04:00
David Presotto
918922cf85 net: add SetKeepAlivePeriod
Sets both the duration from the last data packet to the first
keep alive packet and the duration between keep alive packets to be
the passed duration.

I've tested the function on both Darwin (10.8.4) and 4.2 Linux.
I've compiled (make.bash) for all the OS's and tested (all.bash)
on Darwin and Linux.

R=golang-dev, dave, rsc, dvyukov, presotto+facebook, nick
CC=golang-dev, veyron-team
https://golang.org/cl/11130044
2013-07-15 18:40:55 -04:00
Dmitriy Vyukov
0a86b4dab8 runtime: minor test cleanup
R=golang-dev, khr, rsc
CC=golang-dev
https://golang.org/cl/11280043
2013-07-16 01:02:42 +04:00
Andrew Bonventre
9ebc5be39c image/gif: add writer implementation
R=r, nigeltao
CC=golang-dev
https://golang.org/cl/10896043
2013-07-15 10:57:01 +10:00
Joseph Holsten
69c924204b log/syslog: fix typo: change Wanring to Warning
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11220044
2013-07-14 12:56:11 +10:00
Russ Cox
aad4720b51 cmd/6l, cmd/8l: use one-byte XCHG forms when possible
Pointed out by khr.

R=ken2
CC=golang-dev
https://golang.org/cl/11145044
2013-07-12 20:58:38 -04:00
Russ Cox
4274d074dc encoding/json: add more tests for UTF-8 coercion
Suggested by Rob in CL 11211045, but the mail arrived
moments after hg submit completed.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11138045
2013-07-12 20:40:50 -04:00
Russ Cox
ccc4553491 cmd/go, testing: streamline direct use of test binaries
Before:

        $ go test -c -cover fmt
        $ ./fmt.test -test.covermode=set
        PASS
        coverage: 65.1% of statements in strconv
        $

After:

        $ go test -c -cover fmt
        $ ./fmt.test
        PASS
        coverage: 65.1% of statements in strconv
        $

In addition to being cumbersome, the old flag didn't make sense:
the cover mode cannot be changed after the binary has been built.

Another useful effect of this CL is that if you happen to do

        $ go test -c -covermode=atomic fmt

and then forget you did that and run benchmarks,
the final line of the output (the coverage summary) reminds you
that you are benchmarking with coverage enabled, which might
not be what you want.

        $ ./fmt.test -test.bench .
        PASS
        BenchmarkSprintfEmpty	10000000	       217 ns/op
        BenchmarkSprintfString	 2000000	       755 ns/op
        BenchmarkSprintfInt	 2000000	       774 ns/op
        BenchmarkSprintfIntInt	 1000000	      1363 ns/op
        BenchmarkSprintfPrefixedInt	 1000000	      1501 ns/op
        BenchmarkSprintfFloat	 1000000	      1257 ns/op
        BenchmarkManyArgs	  500000	      5346 ns/op
        BenchmarkScanInts	    1000	   2562402 ns/op
        BenchmarkScanRecursiveInt	     500	   3189457 ns/op
        coverage: 91.4% of statements
        $

As part of passing the new mode setting in via _testmain.go, merge
the two registration mechanisms into one extensible mechanism
(a struct).

R=r
CC=golang-dev
https://golang.org/cl/11219043
2013-07-12 20:40:30 -04:00
Russ Cox
4419d7e53c undo CL 11161044 / ba455262a9db
I want to think more carefully about this.

We put this in because Marshal encoded named []byte but Unmarshal rejected them.
And we noticed that Marshal's behavior was undocumented so we documented it.
But I am starting to think the docs and Unmarshal were correct and Marshal's
behavior was the problem.

Rolling back to give us more time to think.

««« original CL description
json: unmarshal types that are byte slices.

The json package cheerfully would marshal

        type S struct {
                IP net.IP
        }

but would give an error when unmarshalling.  This change allows any
type whose concrete type is a byte slice to be unmarshalled from a
string.

Fixes #5086.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11161044

»»»

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11042046
2013-07-12 17:42:01 -04:00
Russ Cox
64054a40ad encoding/json: coerce invalid UTF-8 to valid UTF-8 during Marshal
In practice, rejecting an entire structure due to a single invalid byte
in a string is just too picky, and too hard to track down.
Be consistent with the bulk of the standard library by converting
invalid UTF-8 into UTF-8 with replacement runes.

R=golang-dev, crawshaw
CC=golang-dev
https://golang.org/cl/11211045
2013-07-12 17:37:10 -04:00
Keith Randall
cfefe6a763 cmd/dist: allow assembly code to use enumerated constants.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11056044
2013-07-12 12:24:57 -07:00
Russ Cox
8124a02cb2 cmd/5a, cmd/6a, cmd/8a: fix flag parsing
go tool 6a -$(unicode fffd) was crashing.

Fixes #5878.

R=ken2
CC=golang-dev
https://golang.org/cl/11208045
2013-07-12 14:23:36 -04:00
Shenghou Ma
0ce56e60b8 run.bash: enlarge timeout of runtime tests
Recently addition to runtime test makes it take very close to 720s
of timeout limit on the netbsd-arm-qemu builder.

R=golang-dev, go.peter.90, rsc
CC=golang-dev
https://golang.org/cl/10935043
2013-07-13 02:00:07 +08:00
Russ Cox
7e97d39879 cmd/5g, cmd/6g, cmd/8g: fix line number of caller of deferred func
Deferred functions are not run by a call instruction. They are run by
the runtime editing registers to make the call start with a caller PC
returning to a
        CALL deferreturn
instruction.

That instruction has always had the line number of the function's
closing brace, but that instruction's line number is irrelevant.
Stack traces show the line number of the instruction before the
return PC, because normally that's what started the call. Not so here.
The instruction before the CALL deferreturn could be almost anywhere
in the function; it's unrelated and its line number is incorrect to show.

Fix the line number by inserting a true hardware no-op with the right
line number before the returned-to CALL instruction. That is, the deferred
calls now appear to start with a caller PC returning to the second instruction
in this sequence:
        NOP
        CALL deferreturn

The traceback will show the line number of the NOP, which we've set
to be the line number of the function's closing brace.

The NOP here is not the usual pseudo-instruction, which would be
elided by the linker. Instead it is the real hardware instruction:
XCHG AX, AX on 386 and amd64, and AND.EQ R0, R0, R0 on ARM.

Fixes #5856.

R=ken2, ken
CC=golang-dev
https://golang.org/cl/11223043
2013-07-12 13:47:55 -04:00
Russ Cox
031c107cad cmd/ld: fix large stack split for preempt check
If the stack frame size is larger than the known-unmapped region at the
bottom of the address space, then the stack split prologue cannot use the usual
condition:

        SP - size >= stackguard

because SP - size may wrap around to a very large number.
Instead, if the stack frame is large, the prologue tests:

        SP - stackguard >= size

(This ends up being a few instructions more expensive, so we don't do it always.)

Preemption requests register by setting stackguard to a very large value, so
that the first test (SP - size >= stackguard) cannot possibly succeed.
Unfortunately, that same very large value causes a wraparound in the
second test (SP - stackguard >= size), making it succeed incorrectly.

To avoid *that* wraparound, we have to amend the test:

        stackguard != StackPreempt && SP - stackguard >= size

This test is only used for functions with large frames, which essentially
always split the stack, so the cost of the few instructions is noise.

This CL and CL 11085043 together fix the known issues with preemption,
at the beginning of a function, so we will be able to try turning it on again.

R=ken2
CC=golang-dev
https://golang.org/cl/11205043
2013-07-12 12:12:56 -04:00
Russ Cox
56cd47b295 cmd/go, testing: remove redundant "for pkg" in coverage message
This is a transcript before this change. I've capitalized the text being removed.
Note that it is always near another line that already says fmt, marked with <<<

$ cd $GOROOT/src/pkg/fmt

$ go test -cover
PASS
coverage FOR FMT: 91.3% of statements
ok  	fmt	0.040s <<<

$ go test -coverpkg strconv
PASS
coverage FOR FMT: 64.9% of statements in strconv
ok  	fmt	0.039s <<<

$ go test -cover -c
$ ./fmt.test -test.covermode=set <<<
PASS
coverage FOR FMT: 91.3% of statements

$ go test -coverpkg strconv -c
$ ./fmt.test -test.covermode=set <<<
PASS
coverage FOR FMT: 64.9% of statements in strconv

That the summary printed by 'go test [options] fmt' is unchanged:

$ go test -cover fmt
ok  	fmt	0.040s	coverage: 91.3% of statements

$ go test -coverpkg strconv fmt
ok  	fmt	0.038s	coverage: 64.9% of statements in strconv

R=r
CC=gobot, golang-dev
https://golang.org/cl/10932045
2013-07-12 07:34:16 -04:00
Russ Cox
f70a19f085 runtime: fix 386 build after cas64 change
Missed this in CL 10909045.

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/10803045
2013-07-12 00:42:46 -04:00
David Symonds
d754647963 encoding/json: escape U+2028 and U+2029.
Fixes #5836.

R=golang-dev, bradfitz, r, rsc
CC=golang-dev
https://golang.org/cl/10883045
2013-07-12 14:35:55 +10:00
Russ Cox
fb63e4fefb runtime: make cas64 like cas32 and casp
The current cas64 definition hard-codes the x86 behavior
of updating *old with the new value when the cas fails.
This is inconsistent with cas32 and casp.
Make it consistent.

This means that the cas64 uses will be epsilon less efficient
than they might be, because they have to do an unnecessary
memory load on x86. But so be it. Code clarity and consistency
is more important.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/10909045
2013-07-12 00:03:32 -04:00
Russ Cox
3a8845b525 run.bash: actually stop on cgo failures
I hate bash.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/11200043
2013-07-11 23:24:57 -04:00
Russ Cox
d6d83c918c cmd/ld: place read-only data in non-executable segment
R=golang-dev, dave, r
CC=golang-dev, nigeltao
https://golang.org/cl/10713043
2013-07-11 22:52:48 -04:00
Russ Cox
6c99b5c0d3 cmd/5l, cmd/6l, cmd/8l: increase error buffer size
STRINGSZ (200) is fine for lines generated by things like
instruction dumps, but an error containing a couple file
names can easily exceed that, especially on Macs with
the ridiculous default $TMPDIR.

R=ken2
CC=golang-dev
https://golang.org/cl/11199043
2013-07-11 22:49:15 -04:00
Russ Cox
1d4ed0c86b cmd/gc: fix error message for import as 'init'
Fixes #5853.

R=ken2
CC=golang-dev
https://golang.org/cl/11104044
2013-07-11 22:40:21 -04:00
Paul Borman
5930649306 json: unmarshal types that are byte slices.
The json package cheerfully would marshal

        type S struct {
                IP net.IP
        }

but would give an error when unmarshalling.  This change allows any
type whose concrete type is a byte slice to be unmarshalled from a
string.

Fixes #5086.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11161044
2013-07-11 22:34:09 -04:00
Alex Brainman
09e72f5670 make.bat: incease runtime test timeout to 300s (fixes build)
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11064044
2013-07-12 12:30:18 +10:00
Shenghou Ma
4a4d48328b runtime: fix build for windows.
R=golang-dev
CC=golang-dev
https://golang.org/cl/11188043
2013-07-12 05:06:43 +08:00
Shenghou Ma
2f1ead7095 runtime: correctly handle signals received on foreign threads
Fixes #3250.

R=rsc
CC=golang-dev
https://golang.org/cl/10757044
2013-07-12 04:39:39 +08:00
Shenghou Ma
2a983aa311 cmd/cgo: silence two gcc warnings for *.cgo2.c
1. "int e;" is unused, generating "unused variable" error.
2. a->e was typed void *[2], but was accessed with *(int *)(a->e), this
generated "dereferencing type-punned pointer will break strict-aliasing rules" error.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11009043
2013-07-12 04:35:53 +08:00
Shenghou Ma
72faa4bc51 syscall: implement Sendfile for Darwin.
Update #5847
Summary: syscall: implement Sendfile for OpenBSD and NetBSD

R=golang-dev, rsc, dave
CC=golang-dev
https://golang.org/cl/10980043
2013-07-12 04:34:54 +08:00
Shenghou Ma
555e51f27b cmd/cgo: clarify the underscore prefix rule and C union representation in Go.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10981043
2013-07-12 04:34:04 +08:00
Dmitriy Vyukov
32fef9908a runtime: fix CPU underutilization
runtime.newproc/ready are deliberately sloppy about waking new M's,
they only ensure that there is at least 1 spinning M.
Currently to compensate for that, schedule() checks if the current P
has local work and there are no spinning M's, it wakes up another one.
It does not work if goroutines do not call schedule.
With this change a spinning M wakes up another M when it finds work to do.
It's also not ideal, but it fixes the underutilization.
A proper check would require to know the exact number of runnable G's,
but it's too expensive to maintain.
Fixes #5586.
This is reincarnation of cl/9776044 with the bug fixed.
The bug was due to code added after cl/9776044 was created:
if(tick - (((uint64)tick*0x4325c53fu)>>36)*61 == 0 && runtime·sched.runqsize > 0) {
        runtime·lock(&runtime·sched);
        gp = globrunqget(m->p, 1);
        runtime·unlock(&runtime·sched);
}
If M gets gp from global runq here, it does not reset m->spinning.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10743044
2013-07-11 15:57:36 -04:00
ChaiShushan
735cf52983 net/rpc: fix a test bug
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10855043
2013-07-11 15:55:08 -04:00
Dmitriy Vyukov
01e1b0cb53 runtime: adjust traceback for new preemptive reality
Currently it crashes as follows:
fatal error: unknown pc
...
goroutine 71698 [runnable]:
runtime.racegoend()
        src/pkg/runtime/race.c:171
runtime.goexit()
        src/pkg/runtime/proc.c:1276 +0x9
created by runtime_test.testConcurrentReadsAfterGrowth
        src/pkg/runtime/map_test.go:264 +0x332

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10674047
2013-07-11 13:52:20 -04:00
Nigel Tao
c77baac560 image/draw: add the Quantizer type.
R=r
CC=andybons, golang-dev
https://golang.org/cl/11148043
2013-07-11 15:17:32 +10:00
Russ Cox
a2c30fe648 cmd/ld: correct assignment of sizes to mach-o symbols
If you compute the size by subtraction from the address
of the next symbol, it helps to wait until the symbols have
been sorted by address.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11143043
2013-07-10 22:06:52 -04:00
Nigel Tao
e430eb8bd7 image/draw: add Drawer, FloydSteinberg and the op.Draw method.
R=r, andybons
CC=andybons, golang-dev
https://golang.org/cl/10977043
2013-07-11 08:47:29 +10:00
Robert Griesemer
dff0c19446 go/format: fix failing test (fix build)
R=khr
CC=golang-dev
https://golang.org/cl/11131043
2013-07-10 14:19:35 -07:00
Robert Griesemer
4fdc81d001 go/parser: more tolerant parsing of const and var decls
Instead, rely on the type checker.

R=adonovan
CC=golang-dev
https://golang.org/cl/10826044
2013-07-10 12:01:07 -07:00
Andrew Gerrand
4ca346795e html: add escaping tests
R=golang-dev, dsymonds, bradfitz
CC=golang-dev
https://golang.org/cl/11095043
2013-07-10 17:31:46 +10:00
Alex Brainman
231dfd9049 time: find correct zone abbreviations even on non-English windows systems
Fixes #5783

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10956043
2013-07-10 15:34:24 +10:00
Brad Fitzpatrick
d178c016c2 net/http: in ServeContent, don't seek on content until necessary
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/11080043
2013-07-10 13:29:52 +10:00
Andrew Gerrand
825373e4f0 encoding/xml: fix typo in docs
Fixes #5843.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/11073043
2013-07-10 10:14:31 +10:00
Rob Pike
6d86c14efa cmd/go: fix a couple of bugs in coverage tooling
Merging a couple of CLs into one, since they collided in my client
and I'm lazy.

1) Fix up output in "go test -cover" case.
We need to tell the testing package the name of the package being tested
and the name of the package being covered. It can then sort out the report.

2) Filter out the _test.go files from coverage processing. We want to measure
what the tests cover, not what's covered in the tests,
The coverage for encoding/gob goes from 82.2% to 88.4%.
There may be a cleaner way to do this - suggestions welcome - but ça suffit.

Fixes #5810.

R=rsc
CC=golang-dev
https://golang.org/cl/10868047
2013-07-10 09:52:36 +10:00
Robert Griesemer
c7065e927d builtin: document print and println
Fixes #5787.

R=r
CC=golang-dev
https://golang.org/cl/11057043
2013-07-09 16:20:19 -07:00
Nigel Tao
5e37154077 image/color: add Plan9Palette and WebSafePalette.
R=r, rsc, andybons
CC=andybons, golang-dev
https://golang.org/cl/10890045
2013-07-09 19:17:17 +10:00
Dave Cheney
328ec95878 cmd/ld: trivial: fix unhandled switch case
Fix warning found by clang 3.3.

R=rsc, r
CC=golang-dev
https://golang.org/cl/11022043
2013-07-08 21:14:32 -05:00
ChaiShushan
e23d19e235 net/rpc: use log.Print and return error instead log.Fatal
R=r
CC=golang-dev
https://golang.org/cl/10758044
2013-07-09 11:12:05 +10:00
Shenghou Ma
8b16a8bbc1 cmd/go: fix "go get -u" for git repositories.
CL 10869046 changed cmd/go to checkout master branch, so
for "go get -u" to work, it must "git pull" instead of
"git fetch". Added "--ff-only" so that it won't accidentally
overwrite user changes.

R=dsymonds
CC=golang-dev
https://golang.org/cl/10907043
2013-07-07 23:06:30 +08:00
Daniel Morsing
3c3ce8e7fb cmd/6g, cmd/8g: prevent constant propagation of non-constant LEA.
Fixes #5809.

R=golang-dev, dave, rsc, nigeltao
CC=golang-dev
https://golang.org/cl/10785043
2013-07-05 16:11:22 +02:00
Oliver Hookins
daf81ae78e encoding/json: Correct description of stateNeg function.
R=golang-dev, dave, adg
CC=golang-dev
https://golang.org/cl/10862045
2013-07-05 14:26:09 +10:00
Dave Cheney
2a730f8b16 syscall: reduce duplication between *bsd and linux
Part 3 of several.

* Linux has grown a SetsockoptByte.
* SetsockoptIPMreqn is handled directly by syscall_linux.go and syscall_freebsd.go.

R=golang-dev, mikioh.mikioh, r, bradfitz
CC=golang-dev
https://golang.org/cl/10775043
2013-07-05 13:25:23 +10:00
Nigel Tao
48936e46a1 image/gif: close the lzw.Reader we create.
The lzw.NewReader doc comment says, "It is the caller's responsibility
to call Close on the ReadCloser when finished reading."

Thanks to Andrew Bonventre for noticing this.

R=r, dsymonds, adg
CC=andybons, golang-dev
https://golang.org/cl/10821043
2013-07-05 10:12:13 +10:00
Robert Griesemer
dd1fe82cec go/parser: accept optional indices for all parts of an index expression
Instead, leave the error testing to the type checker, eventually.

Fixes #5827.

R=adonovan
CC=golang-dev
https://golang.org/cl/10917043
2013-07-03 10:43:24 -07:00
Brad Fitzpatrick
16c3f82ed4 net/textproto: reduce allocations in ReadMIMEHeader
ReadMIMEHeader is used by net/http, net/mail, and
mime/multipart.

Don't do so many small allocations. Calculate up front
how much we'll probably need.

benchmark                  old ns/op    new ns/op    delta
BenchmarkReadMIMEHeader         8433         7467  -11.45%

benchmark                 old allocs   new allocs    delta
BenchmarkReadMIMEHeader           23           14  -39.13%

benchmark                  old bytes    new bytes    delta
BenchmarkReadMIMEHeader         1705         1343  -21.23%

R=golang-dev, r, iant, adg
CC=golang-dev
https://golang.org/cl/8179043
2013-07-02 22:37:19 -07:00
David Symonds
a44009ca78 cmd/go: git checkout the correct default branch.
origin/master is always a remote branch, and it doesn't make sense to
switch to a remote branch. master is the default branch that tracks it.

R=adg
CC=golang-dev, matt.jibson
https://golang.org/cl/10869046
2013-07-03 11:56:02 +10:00
ChaiShushan
456f6df96a net/rpc: remove unnecessary code
Fixes #5760.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/10871043
2013-07-02 17:29:21 -07:00
Adam Langley
7e767791b9 crypto/tls: implement TLS 1.2.
This does not include AES-GCM yet. Also, it assumes that the handshake and
certificate signature hash are always SHA-256, which is true of the ciphersuites
that we currently support.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10762044
2013-07-02 19:58:56 -04:00
David Symonds
1f954e5c45 go/ast: improve doc for FuncDecl's Type field.
R=gri, r
CC=golang-dev
https://golang.org/cl/10679047
2013-07-03 08:16:08 +10:00
Shenghou Ma
e555172592 runtime: fix runtime.sigreturn_tramp for NetBSD/ARM
using m->tls[0] to save ucontext pointer is not re-entry safe, and
the old code didn't set it before the early return when signal is
received on non-Go threads.

so misc/cgo/test used to hang when testing issue 5337.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/10076045
2013-07-03 00:33:38 +08:00
Daniel Morsing
7cfa8310c7 cmd/gc: fix issue with method wrappers not having escape analysis run on them.
Escape analysis needs the right curfn value on a dclfunc node, otherwise it will not analyze the function.
When generating method value wrappers, we forgot to set the curfn correctly.

Fixes #5753.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10383048
2013-07-02 17:12:08 +02:00
Rémy Oudompheng
428ea6865c cmd/gc: fix computation of equality class of types.
A struct with a single field was considered as equivalent to the
field type, which is incorrect is the field is blank.

Fields with padding could make the compiler think some
types are comparable when they are not.

Fixes #5698.

R=rsc, golang-dev, daniel.morsing, bradfitz, gri, r
CC=golang-dev
https://golang.org/cl/10271046
2013-07-02 09:08:43 +02:00
Russ Cox
6d2d4ba94f sort: fix 32-bit build
TBR=golang-dev
CC=golang-dev
https://golang.org/cl/10856043
2013-07-01 21:44:14 -04:00
Jeff R. Allen
0286b4738e time: prevent a panic from leaving the timer mutex held
When deleting a timer, a panic due to nil deref
would leave a lock held, possibly leading to a deadlock
in a defer. Instead return false on a nil timer.

Fixes #5745.

R=golang-dev, daniel.morsing, dvyukov, rsc, iant
CC=golang-dev
https://golang.org/cl/10373047
2013-07-01 21:42:29 -04:00
ChaiShushan
b86f6c9224 net/rpc/jsonrpc: remove unused serverCodec.resp field
R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/10458045
2013-07-01 21:20:42 -04:00
Volker Dobler
1135ef153f sort: implement stable sorting
This CL provides stable in-place sorting by use of
bottom up merge sort with in-place merging done by
the SymMerge algorithm from P.-S. Kim and A. Kutzner.

The additional space needed for stable sorting (in the form of
stack space) is logarithmic in the inputs size n.
Number of calls to Less and Swap grow like O(n * log n) and
O(n * log n * log n):
Stable sorting random data uses significantly more calls
to Swap than the unstable quicksort implementation (5 times more
on n=100, 10 times more on n=1e4 and 23 times more on n=1e8).
The number of calls to Less is practically the same for Sort and
Stable.

Stable sorting 1 million random integers takes 5 times longer
than using Sort.

BenchmarkSortString1K      50000       328662 ns/op
BenchmarkStableString1K    50000       380231 ns/op  1.15 slower
BenchmarkSortInt1K         50000       157336 ns/op
BenchmarkStableInt1K       50000       191167 ns/op  1.22 slower
BenchmarkSortInt64K         1000     14466297 ns/op
BenchmarkStableInt64K        500     16190266 ns/op  1.12 slower

BenchmarkSort1e2          200000        64923 ns/op
BenchmarkStable1e2         50000       167128 ns/op  2.57 slower
BenchmarkSort1e4            1000     14540613 ns/op
BenchmarkStable1e4           100     58117289 ns/op  4.00 slower
BenchmarkSort1e6               5   2429631508 ns/op
BenchmarkStable1e6             1  12077036952 ns/op  4.97 slower

R=golang-dev, bradfitz, iant, 0xjnml, rsc
CC=golang-dev
https://golang.org/cl/9612044
2013-07-01 21:20:33 -04:00
Russ Cox
4d8aefde47 reflect: add Value.Slice3 and Value.SetCap methods, to match x[i:j:k]
Design doc at golang.org/s/go12slice.

R=golang-dev, r, nightlyone
CC=golang-dev
https://golang.org/cl/10761045
2013-07-01 20:32:53 -04:00
Russ Cox
b4e92cee97 cmd/gc: support x[i:j:k]
Design doc at golang.org/s/go12slice.
This is an experimental feature and may not be included in the release.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10743046
2013-07-01 20:32:36 -04:00
Russ Cox
1184407f2a runtime: disable preemption test (fix build)
TBR=golang-dev
CC=golang-dev
https://golang.org/cl/10849043
2013-07-01 18:10:03 -04:00
Russ Cox
08e064135d runtime: disable preemption
There are various problems, and both Dmitriy and I
will be away for the next week. Make the runtime a bit
more stable while we're gone.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/10848043
2013-07-01 17:57:09 -04:00
Dmitriy Vyukov
fd23958f49 runtime: fix memory leaks due to defers
fn can clearly hold a closure in memory.
argp/pc point into stack and so can hold
in memory a block that was previously
a large stack serment.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/10784043
2013-07-01 17:36:08 -04:00
Russ Cox
20498ed772 sync/atomic: remove test dependency on net/http
Depending on net/http means depending on cgo.
When the tree is in a shaky state it's nice to see sync/atomic
pass even if cgo or net causes broken binaries.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/10753044
2013-07-01 17:27:19 -04:00
Jeff R. Allen
8192017e14 image/gif: do not allow pixels outside the current palette
After loading a frame of a GIF, check that each pixel
is inside the frame's palette.

Fixes #5401.

R=nigeltao, r
CC=golang-dev
https://golang.org/cl/10597043
2013-07-01 14:11:45 +10:00
Russ Cox
0a4fc122de lib9: restore printing of signed integers
A casualty of https://golang.org/cl/10195044.

If x is an 32-bit int and u is a 64-bit ulong,
        u = (uint)x // converts to uint before extension, so zero fills
        u = (ulong)x // sign-extends

TBR=iant, r
CC=golang-dev
https://golang.org/cl/10814043
2013-06-30 19:53:36 -04:00
Rémy Oudompheng
c1fc8d5296 cmd/gc: fix missing export data for inlining in a few other cases.
Exported inlined functions that perform a string conversion
using a non-exported named type may miss it in export data.

Fixes #5755.

R=rsc, golang-dev, ality, r
CC=golang-dev
https://golang.org/cl/10464043
2013-06-28 23:29:13 +02:00
Russ Cox
a3f842a4c1 runtime: shorten hash lookup stack frames
On amd64 the frames are very close to the limit for a
nosplit (textflag 7) function, in part because the C compiler
does not make any attempt to reclaim space allocated for
completely registerized variables. Avoid a few short-lived
variables to reclaim two words.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10758043
2013-06-28 13:37:07 -07:00
Brad Fitzpatrick
46161cd079 net/http: fix memory leak in Transport
Fixes #5794

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10747044
2013-06-28 12:57:54 -07:00
Rick Arnold
64441d6d66 net/smtp: preserve Auth errors
If authentication failed, the initial error was being thrown away.

Fixes #5700.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/10744043
2013-06-28 12:24:45 -07:00
Russ Cox
0713293374 cmd/5g, cmd/6g, cmd/8g: fix comment
Keeping the string "compactframe" because that's what
I always search for to find this code. But point to the real place too.

TBR=iant
CC=golang-dev
https://golang.org/cl/10676047
2013-06-28 12:06:25 -07:00
Dmitriy Vyukov
4b536a550f runtime: introduce GODEBUG env var
Currently it replaces GOGCTRACE env var (GODEBUG=gctrace=1).
The plan is to extend it with other type of debug tracing,
e.g. GODEBUG=gctrace=1,schedtrace=100.

R=rsc
CC=bradfitz, daniel.morsing, gobot, golang-dev
https://golang.org/cl/10026045
2013-06-28 18:37:06 +04:00
Dmitriy Vyukov
1e112cd59f runtime: preempt goroutines for GC
The last patch for preemptive scheduler,
with this change stoptheworld issues preemption
requests every 100us.
Update #543.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/10264044
2013-06-28 17:52:17 +04:00
Ian Lance Taylor
ab1270bcfc runtime: remove declaration of function that does not exist
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/10730045
2013-06-27 22:43:30 -07:00
Rick Arnold
49b3301f4c flag: add Getter interface; implement for all Value types
Fixes #5383.

R=golang-dev, 0xjnml, r, rsc
CC=golang-dev
https://golang.org/cl/10472043
2013-06-27 15:30:45 -07:00
Paul van Brouwershaven
f99158c8ad crypto/x509: Added RFC 5280, section 4.2.2.1 Authority Information Access
R=agl, agl
CC=gobot, golang-dev
https://golang.org/cl/10245048
2013-06-27 17:16:25 -04:00
Russ Cox
97c19f0f72 cmd/go: add -coverpkg
The new -coverpkg flag allows computing coverage in
one set of packages while running the tests of a different set.

Also clean up some of the previous CL's recompileForTest,
using packageList to avoid the clumsy recursion.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10705043
2013-06-27 17:04:39 -04:00
Russ Cox
f0d73fbc7c runtime: use gp->sched.sp for stack overflow check
On x86 it is a few words lower on the stack than m->morebuf.sp
so it is a more precise check. Enabling the check requires recording
a valid gp->sched in reflect.call too. This is a good thing in general,
since it will make stack traces during reflect.call work better, and it
may be useful for preemption too.

R=dvyukov
CC=golang-dev
https://golang.org/cl/10709043
2013-06-27 16:51:06 -04:00
Dmitriy Vyukov
4eb17ecd1f runtime: fix goroutine status corruption
runtime.entersyscall() sets g->status = Gsyscall,
then calls runtime.lock() which causes stack split.
runtime.newstack() resets g->status to Grunning.
This will lead to crash during GC (world is not stopped) or GC will scan stack incorrectly.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10696043
2013-06-28 00:49:53 +04:00
Frithjof Schulze
b92b09300a crypto/tls: Change TLS version to 1.1 in the package comment.
Also use 2048-bit RSA keys as default in generate_cert.go,
as recommended by the NIST.

R=golang-dev, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/10676043
2013-06-27 11:23:55 -07:00
Adam Langley
d2a19e9fd1 crypto/elliptic: add constant-time, P-256 implementation.
On my 64-bit machine, despite being 32-bit code, fixed-base
multiplications are 7.1x faster and arbitary multiplications are 2.6x
faster.

It is difficult to review this change. However, the code is essentially
the same as code that has been open-sourced in Chromium. There it has
been successfully performing P-256 operations for several months on
many machines so the arithmetic of the code should be sound.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10551044
2013-06-27 13:31:05 -04:00
Dmitriy Vyukov
7ebb187e8e undo CL 9776044 / 1e280889f997
Failure on bot:
http://build.golang.org/log/f4c648906e1289ec2237c1d0880fb1a8b1852a08

««« original CL description
runtime: fix CPU underutilization
runtime.newproc/ready are deliberately sloppy about waking new M's,
they only ensure that there is at least 1 spinning M.
Currently to compensate for that, schedule() checks if the current P
has local work and there are no spinning M's, it wakes up another one.
It does not work if goroutines do not call schedule.
With this change a spinning M wakes up another M when it finds work to do.
It's also not ideal, but it fixes the underutilization.
A proper check would require to know the exact number of runnable G's,
but it's too expensive to maintain.
Fixes #5586.

R=rsc
TBR=rsc
CC=gobot, golang-dev
https://golang.org/cl/9776044
»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/10692043
2013-06-27 21:03:35 +04:00
Dmitriy Vyukov
15a1c3d1e4 runtime: fix CPU underutilization
runtime.newproc/ready are deliberately sloppy about waking new M's,
they only ensure that there is at least 1 spinning M.
Currently to compensate for that, schedule() checks if the current P
has local work and there are no spinning M's, it wakes up another one.
It does not work if goroutines do not call schedule.
With this change a spinning M wakes up another M when it finds work to do.
It's also not ideal, but it fixes the underutilization.
A proper check would require to know the exact number of runnable G's,
but it's too expensive to maintain.
Fixes #5586.

R=rsc
CC=gobot, golang-dev
https://golang.org/cl/9776044
2013-06-27 20:52:12 +04:00
Dmitriy Vyukov
eac6bee7c1 runtime: fix argument printing during traceback
Current code can print more arguments than necessary
and also incorrectly prints "...".
Update #5723.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10689043
2013-06-27 20:43:43 +04:00
Russ Cox
6fa3c89b77 runtime: record proper goroutine state during stack split
Until now, the goroutine state has been scattered during the
execution of newstack and oldstack. It's all there, and those routines
know how to get back to a working goroutine, but other pieces of
the system, like stack traces, do not. If something does interrupt
the newstack or oldstack execution, the rest of the system can't
understand the goroutine. For example, if newstack decides there
is an overflow and calls throw, the stack tracer wouldn't dump the
goroutine correctly.

For newstack to save a useful state snapshot, it needs to be able
to rewind the PC in the function that triggered the split back to
the beginning of the function. (The PC is a few instructions in, just
after the call to morestack.) To make that possible, we change the
prologues to insert a jmp back to the beginning of the function
after the call to morestack. That is, the prologue used to be roughly:

        TEXT myfunc
                check for split
                jmpcond nosplit
                call morestack
        nosplit:
                sub $xxx, sp

Now an extra instruction is inserted after the call:

        TEXT myfunc
        start:
                check for split
                jmpcond nosplit
                call morestack
                jmp start
        nosplit:
                sub $xxx, sp

The jmp is not executed directly. It is decoded and simulated by
runtime.rewindmorestack to discover the beginning of the function,
and then the call to morestack returns directly to the start label
instead of to the jump instruction. So logically the jmp is still
executed, just not by the cpu.

The prologue thus repeats in the case of a function that needs a
stack split, but against the cost of the split itself, the extra few
instructions are noise. The repeated prologue has the nice effect of
making a stack split double-check that the new stack is big enough:
if morestack happens to return on a too-small stack, we'll now notice
before corruption happens.

The ability for newstack to rewind to the beginning of the function
should help preemption too. If newstack decides that it was called
for preemption instead of a stack split, it now has the goroutine state
correctly paused if rescheduling is needed, and when the goroutine
can run again, it can return to the start label on its original stack
and re-execute the split check.

Here is an example of a split stack overflow showing the full
trace, without any special cases in the stack printer.
(This one was triggered by making the split check incorrect.)

runtime: newstack framesize=0x0 argsize=0x18 sp=0x6aebd0 stack=[0x6b0000, 0x6b0fa0]
        morebuf={pc:0x69f5b sp:0x6aebd8 lr:0x0}
        sched={pc:0x68880 sp:0x6aebd0 lr:0x0 ctxt:0x34e700}
runtime: split stack overflow: 0x6aebd0 < 0x6b0000
fatal error: runtime: split stack overflow

goroutine 1 [stack split]:
runtime.mallocgc(0x290, 0x100000000, 0x1)
        /Users/rsc/g/go/src/pkg/runtime/zmalloc_darwin_amd64.c:21 fp=0x6aebd8
runtime.new()
        /Users/rsc/g/go/src/pkg/runtime/zmalloc_darwin_amd64.c:682 +0x5b fp=0x6aec08
go/build.(*Context).Import(0x5ae340, 0xc210030c71, 0xa, 0xc2100b4380, 0x1b, ...)
        /Users/rsc/g/go/src/pkg/go/build/build.go:424 +0x3a fp=0x6b00a0
main.loadImport(0xc210030c71, 0xa, 0xc2100b4380, 0x1b, 0xc2100b42c0, ...)
        /Users/rsc/g/go/src/cmd/go/pkg.go:249 +0x371 fp=0x6b01a8
main.(*Package).load(0xc21017c800, 0xc2100b42c0, 0xc2101828c0, 0x0, 0x0, ...)
        /Users/rsc/g/go/src/cmd/go/pkg.go:431 +0x2801 fp=0x6b0c98
main.loadPackage(0x369040, 0x7, 0xc2100b42c0, 0x0)
        /Users/rsc/g/go/src/cmd/go/pkg.go:709 +0x857 fp=0x6b0f80
----- stack segment boundary -----
main.(*builder).action(0xc2100902a0, 0x0, 0x0, 0xc2100e6c00, 0xc2100e5750, ...)
        /Users/rsc/g/go/src/cmd/go/build.go:539 +0x437 fp=0x6b14a0
main.(*builder).action(0xc2100902a0, 0x0, 0x0, 0xc21015b400, 0x2, ...)
        /Users/rsc/g/go/src/cmd/go/build.go:528 +0x1d2 fp=0x6b1658
main.(*builder).test(0xc2100902a0, 0xc210092000, 0x0, 0x0, 0xc21008ff60, ...)
        /Users/rsc/g/go/src/cmd/go/test.go:622 +0x1b53 fp=0x6b1f68
----- stack segment boundary -----
main.runTest(0x5a6b20, 0xc21000a020, 0x2, 0x2)
        /Users/rsc/g/go/src/cmd/go/test.go:366 +0xd09 fp=0x6a5cf0
main.main()
        /Users/rsc/g/go/src/cmd/go/main.go:161 +0x4f9 fp=0x6a5f78
runtime.main()
        /Users/rsc/g/go/src/pkg/runtime/proc.c:183 +0x92 fp=0x6a5fa0
runtime.goexit()
        /Users/rsc/g/go/src/pkg/runtime/proc.c:1266 fp=0x6a5fa8

And here is a seg fault during oldstack:

SIGSEGV: segmentation violation
PC=0x1b2a6

runtime.oldstack()
        /Users/rsc/g/go/src/pkg/runtime/stack.c:159 +0x76
runtime.lessstack()
        /Users/rsc/g/go/src/pkg/runtime/asm_amd64.s:270 +0x22

goroutine 1 [stack unsplit]:
fmt.(*pp).printArg(0x2102e64e0, 0xe5c80, 0x2102c9220, 0x73, 0x0, ...)
        /Users/rsc/g/go/src/pkg/fmt/print.go:818 +0x3d3 fp=0x221031e6f8
fmt.(*pp).doPrintf(0x2102e64e0, 0x12fb20, 0x2, 0x221031eb98, 0x1, ...)
        /Users/rsc/g/go/src/pkg/fmt/print.go:1183 +0x15cb fp=0x221031eaf0
fmt.Sprintf(0x12fb20, 0x2, 0x221031eb98, 0x1, 0x1, ...)
        /Users/rsc/g/go/src/pkg/fmt/print.go:234 +0x67 fp=0x221031eb40
flag.(*stringValue).String(0x2102c9210, 0x1, 0x0)
        /Users/rsc/g/go/src/pkg/flag/flag.go:180 +0xb3 fp=0x221031ebb0
flag.(*FlagSet).Var(0x2102f6000, 0x293d38, 0x2102c9210, 0x143490, 0xa, ...)
        /Users/rsc/g/go/src/pkg/flag/flag.go:633 +0x40 fp=0x221031eca0
flag.(*FlagSet).StringVar(0x2102f6000, 0x2102c9210, 0x143490, 0xa, 0x12fa60, ...)
        /Users/rsc/g/go/src/pkg/flag/flag.go:550 +0x91 fp=0x221031ece8
flag.(*FlagSet).String(0x2102f6000, 0x143490, 0xa, 0x12fa60, 0x0, ...)
        /Users/rsc/g/go/src/pkg/flag/flag.go:563 +0x87 fp=0x221031ed38
flag.String(0x143490, 0xa, 0x12fa60, 0x0, 0x161950, ...)
        /Users/rsc/g/go/src/pkg/flag/flag.go:570 +0x6b fp=0x221031ed80
testing.init()
        /Users/rsc/g/go/src/pkg/testing/testing.go:-531 +0xbb fp=0x221031edc0
strings_test.init()
        /Users/rsc/g/go/src/pkg/strings/strings_test.go:1115 +0x62 fp=0x221031ef70
main.init()
        strings/_test/_testmain.go:90 +0x3d fp=0x221031ef78
runtime.main()
        /Users/rsc/g/go/src/pkg/runtime/proc.c:180 +0x8a fp=0x221031efa0
runtime.goexit()
        /Users/rsc/g/go/src/pkg/runtime/proc.c:1269 fp=0x221031efa8

goroutine 2 [runnable]:
runtime.MHeap_Scavenger()
        /Users/rsc/g/go/src/pkg/runtime/mheap.c:438
runtime.goexit()
        /Users/rsc/g/go/src/pkg/runtime/proc.c:1269
created by runtime.main
        /Users/rsc/g/go/src/pkg/runtime/proc.c:166

rax     0x23ccc0
rbx     0x23ccc0
rcx     0x0
rdx     0x38
rdi     0x2102c0170
rsi     0x221032cfe0
rbp     0x221032cfa0
rsp     0x7fff5fbff5b0
r8      0x2102c0120
r9      0x221032cfa0
r10     0x221032c000
r11     0x104ce8
r12     0xe5c80
r13     0x1be82baac718
r14     0x13091135f7d69200
r15     0x0
rip     0x1b2a6
rflags  0x10246
cs      0x2b
fs      0x0
gs      0x0

Fixes #5723.

R=r, dvyukov, go.peter.90, dave, iant
CC=golang-dev
https://golang.org/cl/10360048
2013-06-27 11:32:01 -04:00
Robin Eklind
2546a54148 crypto/sha512: update comment for the Sum512 function.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10660043
2013-06-27 20:51:46 +10:00
Ian Lance Taylor
8cd0689a63 runtime: remove unused typedef
R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/10660044
2013-06-26 22:02:32 -07:00
Alex Brainman
04b405c7fc syscall: handle empty environment variable values properly on windows
Setenv("AN_ENV_VAR", "") deletes AN_ENV_VAR instead of setting it
to "" at this moment. Also Getenv("AN_ENV_VAR") returns "not found",
if AN_ENV_VAR is "". Change it, so they behave like unix.

Fixes #5610

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/10594043
2013-06-27 10:11:30 +10:00
Rob Pike
fa7e46c884 crypto/sha512: provide top-level Sum512 and Sum384 functions
Makes it easy to ask the simple question, what is the hash of this data?
Also fix the commentary and prints in Sum256.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10630043
2013-06-26 13:14:11 -07:00
Rob Pike
5cd5d88954 crypto/sha256: provide top-level Sum and Sum224 functions
Makes it easy to ask the simple question, what is the hash of this data?

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10629043
2013-06-26 11:36:18 -07:00
Russ Cox
8b9c1a224b cmd/go: proper rebuild of affected packages during go test
With this CL, go test -short -cover std successfully builds and
runs all the standard package tests. The tests that look a file
line numbers (log and runtime/debug) fail, because cover is
not inserting //line directives. Everything else passes.

ok  	cmd/api	0.038s	coverage: 66.6% of statements
?   	cmd/cgo	[no test files]
ok  	cmd/fix	0.043s	coverage: 27.2% of statements
ok  	cmd/go	0.063s	coverage: 2.4% of statements
?   	cmd/godoc	[no test files]
ok  	cmd/gofmt	0.085s	coverage: 61.3% of statements
?   	cmd/yacc	[no test files]
ok  	archive/tar	0.023s	coverage: 74.2% of statements
ok  	archive/zip	0.075s	coverage: 71.8% of statements
ok  	bufio	0.149s	coverage: 88.2% of statements
ok  	bytes	0.135s	coverage: 90.4% of statements
ok  	compress/bzip2	0.087s	coverage: 85.1% of statements
ok  	compress/flate	0.632s	coverage: 79.3% of statements
ok  	compress/gzip	0.027s	coverage: 76.7% of statements
ok  	compress/lzw	0.141s	coverage: 71.2% of statements
ok  	compress/zlib	1.123s	coverage: 77.2% of statements
ok  	container/heap	0.020s	coverage: 85.8% of statements
ok  	container/list	0.021s	coverage: 92.5% of statements
ok  	container/ring	0.030s	coverage: 86.5% of statements
?   	crypto	[no test files]
ok  	crypto/aes	0.054s	coverage: 54.3% of statements
ok  	crypto/cipher	0.027s	coverage: 68.8% of statements
ok  	crypto/des	0.041s	coverage: 83.8% of statements
ok  	crypto/dsa	0.027s	coverage: 33.1% of statements
ok  	crypto/ecdsa	0.048s	coverage: 48.7% of statements
ok  	crypto/elliptic	0.030s	coverage: 91.6% of statements
ok  	crypto/hmac	0.019s	coverage: 83.3% of statements
ok  	crypto/md5	0.020s	coverage: 78.7% of statements
ok  	crypto/rand	0.057s	coverage: 20.8% of statements
ok  	crypto/rc4	0.092s	coverage: 70.8% of statements
ok  	crypto/rsa	0.261s	coverage: 80.8% of statements
ok  	crypto/sha1	0.019s	coverage: 83.9% of statements
ok  	crypto/sha256	0.021s	coverage: 89.0% of statements
ok  	crypto/sha512	0.023s	coverage: 88.7% of statements
ok  	crypto/subtle	0.027s	coverage: 83.9% of statements
ok  	crypto/tls	0.833s	coverage: 79.7% of statements
ok  	crypto/x509	0.961s	coverage: 74.9% of statements
?   	crypto/x509/pkix	[no test files]
ok  	database/sql	0.033s	coverage: 75.0% of statements
ok  	database/sql/driver	0.020s	coverage: 46.2% of statements
ok  	debug/dwarf	0.023s	coverage: 71.5% of statements
ok  	debug/elf	0.035s	coverage: 58.2% of statements
ok  	debug/gosym	0.022s	coverage: 1.8% of statements
ok  	debug/macho	0.023s	coverage: 63.7% of statements
ok  	debug/pe	0.024s	coverage: 50.5% of statements
ok  	encoding/ascii85	0.021s	coverage: 89.7% of statements
ok  	encoding/asn1	0.022s	coverage: 77.9% of statements
ok  	encoding/base32	0.022s	coverage: 91.4% of statements
ok  	encoding/base64	0.020s	coverage: 90.7% of statements
ok  	encoding/binary	0.022s	coverage: 66.2% of statements
ok  	encoding/csv	0.022s	coverage: 88.5% of statements
ok  	encoding/gob	0.064s	coverage: 82.2% of statements
ok  	encoding/hex	0.019s	coverage: 86.3% of statements
ok  	encoding/json	0.047s	coverage: 77.3% of statements
ok  	encoding/pem	0.026s	coverage: 80.5% of statements
ok  	encoding/xml	0.039s	coverage: 85.0% of statements
ok  	errors	0.022s	coverage: 100.0% of statements
ok  	expvar	0.048s	coverage: 72.0% of statements
ok  	flag	0.019s	coverage: 86.9% of statements
ok  	fmt	0.062s	coverage: 91.2% of statements
ok  	go/ast	0.028s	coverage: 46.3% of statements
ok  	go/build	0.190s	coverage: 75.4% of statements
ok  	go/doc	0.095s	coverage: 76.7% of statements
ok  	go/format	0.036s	coverage: 79.8% of statements
ok  	go/parser	0.075s	coverage: 82.0% of statements
ok  	go/printer	0.733s	coverage: 88.6% of statements
ok  	go/scanner	0.031s	coverage: 86.5% of statements
ok  	go/token	0.062s	coverage: 79.7% of statements
?   	hash	[no test files]
ok  	hash/adler32	0.029s	coverage: 49.0% of statements
ok  	hash/crc32	0.020s	coverage: 64.2% of statements
ok  	hash/crc64	0.021s	coverage: 53.5% of statements
ok  	hash/fnv	0.018s	coverage: 75.5% of statements
ok  	html	0.022s	coverage: 4.5% of statements
ok  	html/template	0.087s	coverage: 83.9% of statements
ok  	image	0.108s	coverage: 67.1% of statements
ok  	image/color	0.026s	coverage: 20.1% of statements
ok  	image/draw	0.049s	coverage: 69.6% of statements
ok  	image/gif	0.019s	coverage: 65.2% of statements
ok  	image/jpeg	0.197s	coverage: 78.6% of statements
ok  	image/png	0.055s	coverage: 56.5% of statements
ok  	index/suffixarray	0.027s	coverage: 82.4% of statements
ok  	io	0.037s	coverage: 83.4% of statements
ok  	io/ioutil	0.022s	coverage: 70.1% of statements
FAIL	log	0.020s
ok  	log/syslog	2.063s	coverage: 71.1% of statements
ok  	math	0.023s	coverage: 76.5% of statements
ok  	math/big	0.235s	coverage: 79.2% of statements
ok  	math/cmplx	0.020s	coverage: 66.5% of statements
ok  	math/rand	0.031s	coverage: 69.9% of statements
ok  	mime	0.022s	coverage: 83.0% of statements
ok  	mime/multipart	0.389s	coverage: 76.1% of statements
ok  	net	2.219s	coverage: 58.0% of statements
ok  	net/http	4.744s	coverage: 82.9% of statements
ok  	net/http/cgi	0.593s	coverage: 68.5% of statements
ok  	net/http/cookiejar	0.038s	coverage: 90.3% of statements
ok  	net/http/fcgi	0.047s	coverage: 37.6% of statements
ok  	net/http/httptest	0.068s	coverage: 68.9% of statements
ok  	net/http/httputil	0.058s	coverage: 52.8% of statements
?   	net/http/pprof	[no test files]
ok  	net/mail	0.025s	coverage: 80.3% of statements
ok  	net/rpc	0.063s	coverage: 71.5% of statements
ok  	net/rpc/jsonrpc	0.047s	coverage: 81.3% of statements
ok  	net/smtp	0.032s	coverage: 74.1% of statements
ok  	net/textproto	0.023s	coverage: 66.0% of statements
ok  	net/url	0.020s	coverage: 78.2% of statements
ok  	os	4.729s	coverage: 73.3% of statements
ok  	os/exec	39.620s	coverage: 65.1% of statements
ok  	os/signal	0.541s	coverage: 89.9% of statements
ok  	os/user	0.022s	coverage: 62.2% of statements
ok  	path	0.018s	coverage: 90.8% of statements
ok  	path/filepath	10.834s	coverage: 88.4% of statements
ok  	reflect	0.055s	coverage: 83.2% of statements
ok  	regexp	0.084s	coverage: 75.5% of statements
ok  	regexp/syntax	0.547s	coverage: 85.2% of statements
ok  	runtime	4.755s	coverage: 75.9% of statements
?   	runtime/cgo	[no test files]
FAIL	runtime/debug	0.018s
ok  	runtime/pprof	0.368s	coverage: 8.5% of statements
?   	runtime/race	[no test files]
ok  	sort	0.059s	coverage: 97.7% of statements
ok  	strconv	0.315s	coverage: 95.6% of statements
ok  	strings	0.147s	coverage: 96.1% of statements
ok  	sync	0.083s	coverage: 56.7% of statements
ok  	sync/atomic	0.035s	coverage: 0.0% of statements
ok  	syscall	0.043s	coverage: 24.0% of statements
ok  	testing	0.018s	coverage: 24.0% of statements
?   	testing/iotest	[no test files]
ok  	testing/quick	0.062s	coverage: 83.2% of statements
ok  	text/scanner	0.020s	coverage: 91.5% of statements
ok  	text/tabwriter	0.021s	coverage: 90.4% of statements
ok  	text/template	0.052s	coverage: 81.1% of statements
ok  	text/template/parse	0.024s	coverage: 86.1% of statements
ok  	time	2.431s	coverage: 88.8% of statements
ok  	unicode	0.024s	coverage: 92.1% of statements
ok  	unicode/utf16	0.017s	coverage: 97.3% of statements
ok  	unicode/utf8	0.019s	coverage: 97.4% of statements
?   	unsafe	[no test files]

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10586043
2013-06-26 14:31:12 -04:00
Rob Pike
4850f5d5ea crypto/md5: provide a top-level Sum function
Makes it easy to ask the simple question, what is the hash of this data?
Also mark block as non-escaping.

R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/10624044
2013-06-26 11:29:30 -07:00
Rob Pike
53a00e2812 cmd/go: log compilation errors when scanning directories and packages
Before, some packages disappear silently if the package cannot be imported,
such as if the import statement is unparseable.
Before:
        % ls src
        foo   issue
        % go list ./...
        _/home/r/bug/src/foo
        %
After:
        % go list ./...
        src/issue/issue.go:3:5: expected 'STRING', found newline
        _/home/r/bug/src/foo
        %

R=rsc
CC=golang-dev
https://golang.org/cl/10568043
2013-06-26 10:48:04 -07:00
Rob Pike
4cf73890a2 crypto/sha1: provide a top-level Sum function
Makes it easy to ask the simple question, what is the hash of this data?

R=golang-dev, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/10571043
2013-06-25 17:04:18 -07:00
Russ Cox
148fac79a3 cmd/gc: fix escape analysis ordering
Functions without bodies were excluded from the ordering logic,
because when I wrote the ordering logic there was no reason to
analyze them.

But then we added //go:noescape tags that need analysis, and we
didn't update the ordering logic.

So in the absence of good ordering, //go:noescape only worked
if it appeared before the use in the source code.

Fixes #5773.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10570043
2013-06-25 17:28:49 -04:00
Russ Cox
a14e143c21 cmd/ld: fix line numbers when using fieldtrack
USEFIELD is a special kind of NOP, so treat it like a NOP
when generating the pc-ln table.

There are more invasive fixes that could be applied here.
I am going for minimum number of lines changed.

The smallest test case we know of is five distinct Go files
in four packages, and the bug only happens with
GOEXPERIMENT=fieldtrack enabled, which we don't
normally build with, so the test would never run
meaningfully anyway.

Fixes #5762.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/10495044
2013-06-25 17:23:33 -04:00
Ian Lance Taylor
7590e28d24 lib9: avoid all -Wconversion warnings
Built after adding -Wconversion to the list of compiler
arguments used when building.  I believe these are all OK
assuming we will not change the API.  There is no effort to
detect overflow due to very long strings.

R=golang-dev, dave, rsc, r
CC=golang-dev
https://golang.org/cl/10195044
2013-06-25 10:44:25 -07:00