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

8697 Commits

Author SHA1 Message Date
Keith Randall
12e46e42ec runtime: don't mark the new call trampolines as NOSPLIT.
They may call other NOSPLIT routines, and that might
overflow the stack.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12563043
2013-08-06 14:33:55 -07:00
Mikio Hara
b29d035fe6 net: add dial, listenStream and listenDatagram methods to netFD
This CL refactors the existing listenerSockaddr function into several
methods on netFD.

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

Update #5199

R=golang-dev, dave, alex.brainman, dvyukov, remyoudompheng
CC=golang-dev
https://golang.org/cl/12023043
2013-08-07 06:15:50 +09:00
Rob Pike
98a80b95b4 runtime: use correct types for maxstring and concatstring
Updates #6046.
This CL just does maxstring and concatstring. There are other functions
to fix but doing them a few at a time will help isolate any (unlikely)
breakages these changes bring up in architectures I can't test
myself.

R=golang-dev, dave, iant
CC=golang-dev
https://golang.org/cl/12519044
2013-08-07 06:49:11 +10:00
Brad Fitzpatrick
ad119b9c4d os: fix plan9 build
I broke it with the darwin getwd attrlist stuff (0583e9d36dd).
plan9 doesn't have syscall.ENOTSUP.

It's in api/go1.txt as a symbol always available (not context-specific):

pkg syscall, const ENOTSUP Errno

... but plan9 isn't considered by cmd/api, so it only looks
universally available.  Alternatively, we could add a fake ENOTSUP
to plan9, but they were making efforts earlier to clean their
syscall package, so I'd prefer not to dump more in it.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12509044
2013-08-06 12:04:08 -07:00
Dustin Sallings
9115345925 archive/zip: allow user-extensible compression methods
This change replaces the hard-coded switch on compression method
in zipfile reader and writer with a map into which users can
register compressors and decompressors in their init()s.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/12421043
2013-08-06 12:03:38 -07:00
Russ Cox
8dc7a31d77 runtime/pprof: adjust test
NetBSD and OpenBSD are broken like OS X is. Good to know.

Drop required count from avg/2 to avg/3, because the
Plan 9 builder just barely missed avg/2 in one of its runs.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/12548043
2013-08-06 14:49:55 -04:00
Dmitriy Vyukov
905f296552 net: test that Read/Write do 0 allocations
It turned out that change 12413043 did not break
any builders. So let's lock this in.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12545043
2013-08-06 21:29:35 +04:00
Mikio Hara
262d6f58c7 syscall: fix IPv6 wrong network mask on latest FreeBSD
Looks like latest FreeBSD doesn't set address family identifer
for RTAX_NETMASK stuff; probably RTAX_GENMASK too, not confirmed.
This CL tries to identify address families by using the length of
each socket address if possible.

The issue is confirmed on FreeBSD 9.1.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12332043
2013-08-07 00:25:23 +09:00
Mikio Hara
6a76bca362 net: separate pollster initialization from network file descriptor allocation
Unlike the existing net package own pollster, runtime-integrated
network pollster on BSD variants, actually kqueue, requires a socket
that has beed passed to syscall.Listen previously for a stream
listener.

This CL separates pollDesc.Init (actually runtime_pollOpen) from newFD
to allow control of each state of sockets and adds init method to netFD
instead. Upcoming CLs will rearrange the call order of runtime-integrated
pollster and syscall functions like the following;

- For dialers that open active connections, runtime_pollOpen will be
  called in between syscall.Bind and syscall.Connect.

- For stream listeners that open passive stream connections,
  runtime_pollOpen will be called just after syscall.Listen.

- For datagram listeners that open datagram connections,
  runtime_pollOpen will be called just after syscall.Bind.

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

Update #5199

R=dvyukov, alex.brainman, minux.ma
CC=golang-dev
https://golang.org/cl/8608044
2013-08-06 23:42:33 +09:00
David du Colombier
33bd9694cd runtime: fix Plan 9 build
The current failures were:

fatal error: runtime: stack split during syscall
goroutine 1 [stack split]:
runtime.findnull(0x105a9080)
        /usr/go/src/pkg/runtime/string.goc:14 fp=0x305aefb8
runtime: unexpected return pc for runtime.errstr called from 0x80
runtime.errstr()
        /usr/go/src/pkg/runtime/sys_plan9_386.s:196 +0x2f fp=0x305aefc8

fatal error: runtime: stack split during syscall
goroutine 2 [stack split]:
runtime.nanotime(0x305bff3c)
        /usr/go/src/pkg/runtime/time_plan9_386.c:9 fp=0x305bff34
notetsleep(0x305bff9c, 0xf8475800, 0xd, 0x0, 0x0, ...)
        /usr/go/src/pkg/runtime/lock_sema.c:195 +0x87 fp=0x305bff48
runtime.notetsleepg(0x305bff9c, 0xf8475800, 0xd)
        /usr/go/src/pkg/runtime/lock_sema.c:266 +0xa4 fp=0x305bff68
runtime.MHeap_Scavenger()
        /usr/go/src/pkg/runtime/mheap.c:463 +0xc2 fp=0x305bffd0
runtime.goexit()
        /usr/go/src/pkg/runtime/proc.c:1332 fp=0x305bffd4
created by runtime.main
        /usr/go/src/pkg/runtime/proc.c:168

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12128043
2013-08-06 07:37:26 -07:00
Brad Fitzpatrick
b2fcdfa5fd net: detect bad F_DUPFD_CLOEXEC on OS X 10.6
On 10.6, OS X's fcntl returns EBADF instead of EINVAL.

R=golang-dev, iant, dave
CC=golang-dev
https://golang.org/cl/12493043
2013-08-06 07:18:06 -07:00
Rob Pike
82f5ca1ef0 runtime: change int32 to intgo in findnull and findnullw
Update #6046.
This CL just does findnull and findnullw. There are other functions
to fix but doing them a few at a time will help isolate any (unlikely)
breakages these changes bring up in architectures I can't test
myself.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12520043
2013-08-06 21:49:03 +10:00
Dmitriy Vyukov
429a67e300 net: fix intentional build breakage introduced in 12413043
R=alex.brainman
CC=golang-dev
https://golang.org/cl/12502044
2013-08-06 14:43:36 +04:00
Dmitriy Vyukov
04b1cfa946 net: reduce number of memory allocations during IO operations
Embed all data necessary for read/write operations directly into netFD.

benchmark                    old ns/op    new ns/op    delta
BenchmarkTCP4Persistent          27669        23341  -15.64%
BenchmarkTCP4Persistent-2        18173        12558  -30.90%
BenchmarkTCP4Persistent-4        10390         7319  -29.56%

This change will intentionally break all builders to see
how many allocations they do per read/write.
This will be fixed soon afterwards.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/12413043
2013-08-06 14:40:10 +04:00
Dmitriy Vyukov
9c0500b466 runtime: use gcpc/gcsp during traceback of goroutines in syscalls
gcpc/gcsp are used by GC in similar situation.
gcpc/gcsp are also more stable than gp->sched,
because gp->sched is mutated by entersyscall/exitsyscall
in morestack and mcall. So it has higher chances of being inconsistent.
Also, rename gcpc/gcsp to syscallpc/syscallsp.

This is the same as reverted change 12250043
with save marked as textflag 7.
The problem was that if save calls morestack,
then subsequent lessstack spoils g->sched.pc/sp.
And that bad values were remembered in g->syscallpc/sp.
Entersyscallblock had the same problem,
but it was never triggered to date.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12478043
2013-08-06 13:38:44 +04:00
Kyle Lemons
321ede78e3 flag: document the zero value of FlagSet
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12403043
2013-08-06 16:48:19 +10:00
Keith Randall
034d5fcc30 runtime: Use old reflect.call implementation from cgo.
Basically a partial rollback of 12053043 until I can
figure out what is really going on.
Fixes bug 6051.

R=golang-dev
CC=golang-dev
https://golang.org/cl/12496043
2013-08-05 17:53:08 -07:00
Russ Cox
d3066e47b1 runtime/pprof: test multithreaded profile, remove OS X workarounds
This means that pprof will no longer report profiles on OS X.
That's unfortunate, but the profiles were often wrong and, worse,
it was difficult to tell whether the profile was wrong or not.

The workarounds were making the scheduler more complex,
possibly caused a deadlock (see issue 5519), and did not actually
deliver reliable results.

It may be possible for adventurous users to apply a patch to
their kernels to get working results, or perhaps having no results
will encourage someone to do the work of creating a profiling
thread like on Windows. Issue 6047 has details.

Fixes #5519.
Fixes #6047.

R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/12429045
2013-08-05 19:49:02 -04:00
Brad Fitzpatrick
d8e27db395 undo CL 12486043 / ab644299d124
Uglier.

««« original CL description
all: use strings.IndexByte instead of Index where possible

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/12486043
»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/12485044
2013-08-05 16:27:24 -07:00
Brad Fitzpatrick
4c772cda54 all: use strings.IndexByte instead of Index where possible
R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/12486043
2013-08-05 15:46:06 -07:00
Pieter Droogendijk
dd6f49ddca container/heap: add Fix and document the min is element 0.
Fixes #5372.
Fixes #5577.

R=gri, rsc, bradfitz, r
CC=golang-dev
https://golang.org/cl/12265043
2013-08-05 15:45:39 -07:00
Brad Fitzpatrick
37feacf623 net: use F_DUPFD_CLOEXEC when duping fds
This means that in the common case (modern kernel), we only
make 1 system call to dup instead of two, and we also avoid
grabbing the syscall.ForkLock.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/12476043
2013-08-05 15:43:45 -07:00
Keith Randall
f7910128e7 reflect: Get rid of the test for the error message when
you do reflect.call with too big an argument list.
Not worth the hassle.

Fixes #6023
Fixes #6033

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/12485043
2013-08-05 15:08:37 -07:00
Brad Fitzpatrick
598c78967f strings: use runtime assembly for IndexByte
Fixes #3751

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/12483043
2013-08-05 15:04:05 -07:00
Dave Cheney
8ce8adbe7a runtime: tune append crossover on amd64 and 386
Fixes #4963.

Sets the append crossover to 0 on intel platforms.

Results for linux/amd64 Core i5 SNB

benchmark                     old ns/op    new ns/op    delta
BenchmarkAppend                     102          104   +1.96%
BenchmarkAppend1Byte                 10           11   +0.92%
BenchmarkAppend4Bytes                15           11  -28.10%
BenchmarkAppend7Bytes                17           12  -32.58%
BenchmarkAppend8Bytes                18           12  -36.17%
BenchmarkAppend15Bytes               24           11  -55.02%
BenchmarkAppend16Bytes               25           11  -56.03%
BenchmarkAppend32Bytes               11           12   +4.31%
BenchmarkAppendStr1Byte               8            9  +13.99%
BenchmarkAppendStr4Bytes             11            9  -17.52%
BenchmarkAppendStr8Bytes             14            9  -35.70%
BenchmarkAppendStr16Bytes            21            9  -55.19%
BenchmarkAppendStr32Bytes            10           10   -5.66%
BenchmarkAppendSpecialCase           49           52   +7.96%

Results for linux/386 Atom(TM) CPU 330 @ 1.60GHz

benchmark                     old ns/op    new ns/op    delta
BenchmarkAppend                     219          218   -0.46%
BenchmarkAppend1Byte                 75           72   -3.44%
BenchmarkAppend4Bytes                92           73  -19.87%
BenchmarkAppend7Bytes               108           74  -31.20%
BenchmarkAppend8Bytes               116           74  -35.95%
BenchmarkAppend15Bytes              162           77  -52.22%
BenchmarkAppend16Bytes              169           77  -54.20%
BenchmarkAppend32Bytes               88           86   -2.38%
BenchmarkAppendStr1Byte              57           59   +3.32%
BenchmarkAppendStr4Bytes             72           59  -17.40%
BenchmarkAppendStr8Bytes             92           60  -34.70%
BenchmarkAppendStr16Bytes           141           63  -54.89%
BenchmarkAppendStr32Bytes            75           73   -2.64%
BenchmarkAppendSpecialCase          270          270   +0.00%

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12440044
2013-08-06 07:51:37 +10:00
Russ Cox
8a0779f9b9 compress/bzip2: support concatenated files
While we're here, add a test for the same functionality in gzip,
which was already implemented, and add bzip2 CRC checks.

Fixes #5772.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12387044
2013-08-05 16:08:08 -04:00
Russ Cox
10ebb84d48 runtime: remove debugging knob to turn off preemption
It's still easy to turn off, but the builders are happy.
Also document.

R=golang-dev, iant, dvyukov
CC=golang-dev
https://golang.org/cl/12371043
2013-08-05 16:06:24 -04:00
Dmitriy Vyukov
f38ff9e5ea undo CL 12250043 / e911f94c4902
Break all 386 builders.

««« original CL description
runtime: use gcpc/gcsp during traceback of goroutines in syscalls
gcpc/gcsp are used by GC in similar situation.
gcpc/gcsp are also more stable than gp->sched,
because gp->sched is mutated by entersyscall/exitsyscall
in morestack and mcall. So it has higher chances of being inconsistent.
Also, rename gcpc/gcsp to syscallpc/syscallsp.

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

R=rsc
CC=golang-dev
https://golang.org/cl/12424045
2013-08-05 23:33:50 +04:00
Brad Fitzpatrick
7963ba6a4a os, syscall: implement Getwd on darwin using getattrlist
Fixes #4807

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12349044
2013-08-05 12:26:05 -07:00
Dmitriy Vyukov
d5ab784611 runtime: remove singleproc var
It was needed for the old scheduler,
because there temporary could be more threads than gomaxprocs.
In the new scheduler gomaxprocs is always respected.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12438043
2013-08-05 22:58:02 +04:00
Dmitriy Vyukov
f73972fa33 runtime: use gcpc/gcsp during traceback of goroutines in syscalls
gcpc/gcsp are used by GC in similar situation.
gcpc/gcsp are also more stable than gp->sched,
because gp->sched is mutated by entersyscall/exitsyscall
in morestack and mcall. So it has higher chances of being inconsistent.
Also, rename gcpc/gcsp to syscallpc/syscallsp.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12250043
2013-08-05 22:55:54 +04:00
Adam Langley
20a2b96089 crypto/cipher: add GCM mode.
GCM is Galois Counter Mode, an authenticated encryption mode that is,
nearly always, used with AES.

R=rsc
CC=golang-dev
https://golang.org/cl/12375043
2013-08-05 14:31:58 -04:00
Adam Langley
5e36877d2a crypto: include hash number in panic message.
In the event that code tries to use a hash function that isn't compiled
in and panics, give the developer a fighting chance of figuring out
which hash function it needed.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12420045
2013-08-05 14:23:32 -04:00
ChaiShushan
6ab49fbc6e net: fix some test bug
Fixes #5785.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/10587043
2013-08-05 11:59:59 +10:00
Rob Pike
af8426eebe time: match month and day names only when not followed immediately by a lower-case letter
Avoids seeing "Janet" as "Januaryet".

Fixes #6020.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12448044
2013-08-05 10:53:46 +10:00
Dmitriy Vyukov
49217cf5fd runtime: remove unused scheduler knob
Blockingsyscall was used in net package on windows,
it's not used anymore.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12436043
2013-08-04 23:32:40 +04:00
Dmitriy Vyukov
0a904a3f2e runtime: remove dead code
Remove dead code related to allocation of type metadata with SysAlloc.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12311045
2013-08-04 23:32:06 +04:00
Dmitriy Vyukov
77f21eea59 net: fix concurrent Accept on windows
Runtime netpoll supports at most one read waiter
and at most one write waiter. It's responsibility
of net package to ensure that. Currently windows
implementation allows more than one waiter in Accept.
It leads to "fatal error: netpollblock: double wait".

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12400045
2013-08-04 23:31:23 +04:00
Josh Bleecher Snyder
910caf9345 net/http: fix Response.Header documentation for multiple headers with same key
Whether the keys are concatenated or separate (or a mixture) depends on the server.

Fixes #5979.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12433043
2013-08-04 11:23:17 -07:00
Dmitriy Vyukov
a574822f80 runtime: disable dynamic priority boosting on windows
Windows dynamic priority boosting assumes that a process has different types
of dedicated threads -- GUI, IO, computational, etc. Go processes use
equivalent threads that all do a mix of GUI, IO, computations, etc.
In such context dynamic priority boosting does nothing but harm, so turn it off.
In particular, if 2 goroutines do heavy IO on a server uniprocessor machine,
windows rejects to schedule timer thread for 2+ seconds when priority boosting is enabled.
Fixes #5971.

R=alex.brainman
CC=golang-dev
https://golang.org/cl/12406043
2013-08-04 14:08:13 +04:00
Rob Pike
7d4ea6cc9e html/template: delete panic recovery code from test
The test isn't checking deliberate panics so catching them just makes the code longer.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12420043
2013-08-04 09:06:14 +10:00
Josh Bleecher Snyder
53d9b6fcf3 html/template: handle nils during indirection
Fixes #5982.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12387043
2013-08-04 08:41:19 +10:00
Rob Pike
16c9d3616a various: deleted unused items
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12396043
2013-08-03 16:01:04 +10:00
Mikio Hara
8a7def2b3b net: reduce unnecessary syscall.Sockaddr conversions
This CL makes IPAddr, UDPAddr and TCPAddr implement sockaddr
interface, UnixAddr is already sockaddr interface compliant, and
reduces unnecessary conversions between net.Addr, net.sockaddr and
syscall.Sockaddr.

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

Update #5199

R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/12010043
2013-08-03 13:32:22 +09:00
Mikio Hara
f0291a8e10 net: make IP address selection work correctly on IPv6-only kernel
Update #3610
Update #5267
Update #5707

R=golang-dev, bradfitz, dave, fvbommel
CC=golang-dev
https://golang.org/cl/11958043
2013-08-03 12:17:01 +09:00
Keith Randall
9cd570680b runtime: reimplement reflect.call to not use stack splitting.
R=golang-dev, r, khr, rsc
CC=golang-dev
https://golang.org/cl/12053043
2013-08-02 13:03:14 -07:00
Russ Cox
337407d847 testing: make parsing of -cpu more lenient
Also add \n to error message.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12261044
2013-08-02 13:51:45 -04:00
Russ Cox
ebc5513be6 runtime: in newstack, double-check calling goroutine
Checking this condition helped me find the arm problem last night.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12267043
2013-08-02 13:51:28 -04:00
Nigel Tao
97863bb8af image/draw: fix typos found by "go vet".
R=r, adg, bradfitz
CC=golang-dev
https://golang.org/cl/12312043
2013-08-02 13:29:45 +10:00
Rob Pike
fba7b04dcb fmt: clean up some errors found by vet
Includes deleting some unused items.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/12305043
2013-08-02 11:38:19 +10:00
Russ Cox
e03dd07981 runtime: disable preemption during software fp routines
It's okay to preempt at ordinary function calls because
compilers arrange that there are no live registers to save
on entry to the function call.

The software floating point routines are function calls
masquerading as individual machine instructions. They are
expected to keep all the registers intact. In particular,
they are expected not to clobber all the floating point
registers.

The floating point registers are kept per-M, because they
are not live at non-preemptive goroutine scheduling events,
and so keeping them per-M reduces the number of 132-byte
register blocks we are keeping in memory.

Because they are per-M, allowing the goroutine to be
rescheduled during software floating point simulation
would mean some other goroutine could overwrite the registers
or perhaps the goroutine would continue running on a different
M entirely.

Disallow preemption during the software floating point
routines to make sure that a function full of floating point
instructions has the same floating point registers throughout
its execution.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/12298043
2013-08-01 20:07:01 -04:00
Brad Fitzpatrick
e2a1bd68b3 bytes: move IndexByte assembly to pkg runtime
Per suggestion from Russ in February. Then strings.IndexByte
can be implemented in terms of the shared code in pkg runtime.

Update #3751

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12289043
2013-08-01 16:11:19 -07:00
Scott Ferguson
39679ca88f net/url: prepend slash to path in String()
Previously if a path was set manually without a leading /, String()
would not insert the slash when writing its output. This would lead
to situations where a URL that should be http://www.google.com/search
is output as http://www.google.comsearch

Fixes #5927.

R=golang-dev, bradfitz, rsc, 0xjnml
CC=golang-dev
https://golang.org/cl/11698045
2013-08-01 15:52:56 -07:00
Russ Cox
13507e0697 runtime: fix traceback across morestack
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12287043
2013-08-01 18:51:55 -04:00
Pieter Droogendijk
df1eeeba4a compress/flate: Fixed two panics on bad data
I used just enough of the data provided by Matt in Issue 5915 to trigger
issue 5915. As luck would have it, using slightly less of it triggered
issue 5962.

Fixes #5915.
Fixes #5962.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12288043
2013-08-01 15:20:01 -07:00
Brad Fitzpatrick
17d803d251 net/http: don't write out invalid cookie lines
Fixes #3033

R=golang-dev, fvbommel, rsc
CC=golang-dev
https://golang.org/cl/12204043
2013-08-01 12:16:37 -07:00
Andrew Balholm
334761a666 net/http: document that Error is to be used with plain text
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12276043
2013-08-01 12:05:05 -07:00
Brad Fitzpatrick
9742003ffc strings: add IndexByte, for consistency with bytes package
I always forget which package has it.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12214044
2013-08-01 11:17:26 -07:00
Russ Cox
c24e60eebb strconv: fix doc comment for IntSize
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12258043
2013-08-01 11:34:25 -04:00
Dmitriy Vyukov
c33d490020 runtime: print "created by" for running goroutines in traceback
This allows to at least determine goroutine "identity".
Now it looks like:
goroutine 12 [running]:
        goroutine running on other thread; stack unavailable
created by testing.RunTests
        src/pkg/testing/testing.go:440 +0x88e

R=golang-dev, r, rsc
CC=golang-dev
https://golang.org/cl/12248043
2013-08-01 19:28:38 +04:00
Dmitriy Vyukov
3cbc2716a9 runtime: remove unused var
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12249043
2013-08-01 18:26:21 +04:00
Dmitriy Vyukov
d8bbbd2537 runtime: make new tests shorter in short mode
We see timeouts in these tests on some platforms,
but not on the others.  The hypothesis is that
the problematic platforms are slow uniprocessors.
Stack traces do not suggest that the process
is completely hang, and it is able to schedule
the alarm goroutine. And if it actually hangs,
we still will be able to detect that.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12253043
2013-08-01 18:25:36 +04:00
Dmitriy Vyukov
bd0a14fe40 testing: say what was the timeout if it fires
It looks reasonable here and may be useful.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12252043
2013-08-01 17:24:24 +04:00
Dmitriy Vyukov
21315c3428 runtime: fix netbsd/arm build
Currently fails with:
fatal error: runtime: stack split during syscall
goroutine 2 [stack split]:
_vasop(0x3ac4a0, 0x505f8f00, 0x7a5a8, 0x7, 0x1ed3797f, ...)
        src/pkg/runtime/vlrt_arm.c:513 fp=0x505f8ecc
runtime.semasleep(0xf8475800, 0xd)
        src/pkg/runtime/os_netbsd.c:97 +0x178 fp=0x505f8efc

R=rsc
CC=golang-dev
https://golang.org/cl/12246043
2013-08-01 15:19:45 +04:00
Brad Fitzpatrick
c8d49cf56f syscall: add Dup3 on Linux
With dup3, we can avoid an extra system call on some machines
while holding syscall.ForkLock. Currently we have to
syscall.Dup + syscall.CloseOnExec.

On machines with Linux and a new enough kernel, this can just
be dup3.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12170045
2013-07-31 23:38:53 -07:00
Brad Fitzpatrick
252c107f2f net/http: don't MIME sniff if handler set an empty string Content-Type
Fixes #5953

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12117043
2013-07-31 23:38:32 -07:00
Rémy Oudompheng
184b02ea9f runtime: fix arm build.
More functions needs to be marked as no stack split.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11963044
2013-08-01 07:48:21 +02:00
Russ Cox
f4f2cf16b0 runtime: mark arm _lsvh nosplit (may fix arm build)
Mark the 386 one too for consistency,
although most of that code is no longer used.

TBR=dvyukov
CC=golang-dev
https://golang.org/cl/12227043
2013-08-01 00:23:30 -04:00
Russ Cox
cba880e04a runtime: fix arm preemption
Preemption during the software floating point code
could cause m (R9) to change, so that when the
original registers were restored at the end of the
floating point handler, the changed and correct m
would be replaced by the old and incorrect m.

TBR=dvyukov
CC=golang-dev
https://golang.org/cl/11883045
2013-08-01 00:16:31 -04:00
Rémy Oudompheng
a05237f20a runtime: save 8 stack bytes in timediv on arm.
Operations on int64 are very stack consuming with 5c.
Fixes netbsd/arm build.

Before: TEXT    runtime.timediv+0(SB),7,$52-16
After:  TEXT    runtime.timediv+0(SB),7,$44-16

The stack usage is unchanged on 386:
        TEXT    runtime.timediv+0(SB),7,$8-16

R=golang-dev, dvyukov, bradfitz
CC=golang-dev
https://golang.org/cl/12182044
2013-07-31 23:37:23 +02:00
Pieter Droogendijk
fbcc24bb9d container/list: added MoveBefore and MoveAfter
Fixes #4940.

R=golang-dev, bradfitz, gri
CC=golang-dev
https://golang.org/cl/12021044
2013-07-31 14:11:25 -07:00
Rémy Oudompheng
441ef7978d crypto/des: faster permutation.
This patch introduces specialized functions for initial
and final permutations, and precomputes the output of the
third permutation on the S-box elements.

benchmark           old ns/op    new ns/op    delta
BenchmarkEncrypt         3581         1226  -65.76%
BenchmarkDecrypt         3590         1224  -65.91%

benchmark            old MB/s     new MB/s  speedup
BenchmarkEncrypt         2.23         6.52    2.92x
BenchmarkDecrypt         2.23         6.53    2.93x

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12072045
2013-07-31 22:06:48 +02:00
Dmitriy Vyukov
98d94b589c runtime: better debug output for inconsistent Note
Update #5139.
Double wakeup on Note was reported several times,
but no reliable reproducer.
There also was a strange report about weird value of epoll fd.
Maybe it's corruption of global data...

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12182043
2013-07-31 22:03:59 +04:00
Dmitriy Vyukov
658d19a53f runtime: do not park sysmon thread if any goroutines are running
Sysmon thread parks if no goroutines are running (runtime.sched.npidle ==
runtime.gomaxprocs).
Currently it's unparked when a goroutine enters syscall, it was enough
to retake P's from blocking syscalls.
But it's not enough for reliable goroutine preemption. We need to ensure that
sysmon runs if any goroutines are running.

R=rsc
CC=golang-dev
https://golang.org/cl/12176043
2013-07-31 20:09:03 +04:00
Dmitriy Vyukov
6ee69a9726 undo CL 12167043 / 475e11851fc1
Submitted with some unrelated changes that were not intended to go in.

««« original CL description
runtime: do not park sysmon thread if any goroutines are running
Sysmon thread parks if no goroutines are running (runtime.sched.npidle == runtime.gomaxprocs).
Currently it's unparked when a goroutine enters syscall, it was enough
to retake P's from blocking syscalls.
But it's not enough for reliable goroutine preemption. We need to ensure that
sysmon runs if any goroutines are running.

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

R=rsc
CC=golang-dev
https://golang.org/cl/12171044
2013-07-31 20:03:05 +04:00
Dmitriy Vyukov
8679d5f2b5 cmd/gc: record argument size for all indirect function calls
This is required to properly unwind reflect.methodValueCall/makeFuncStub.
Fixes #5954.
Stats for 'go install std':
61849 total INSTCALL
24655 currently have ArgSize metadata
27278 have ArgSize metadata with this change
godoc size before: 11351888, after: 11364288

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12163043
2013-07-31 20:00:33 +04:00
Dmitriy Vyukov
156e8b306d runtime: do not park sysmon thread if any goroutines are running
Sysmon thread parks if no goroutines are running (runtime.sched.npidle == runtime.gomaxprocs).
Currently it's unparked when a goroutine enters syscall, it was enough
to retake P's from blocking syscalls.
But it's not enough for reliable goroutine preemption. We need to ensure that
sysmon runs if any goroutines are running.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12167043
2013-07-31 19:59:27 +04:00
Russ Cox
e8018fbebe runtime: rewrite map size test
I don't know why the memstats code is flaky.

TBR=bradfitz
CC=golang-dev
https://golang.org/cl/12160043
2013-07-31 08:35:43 -04:00
Pieter Droogendijk
27032fddee path/filepath: Panic in Match when parsing invalid character range.
Fixes #5668.

R=golang-dev, rsc, r
CC=golang-dev
https://golang.org/cl/12001056
2013-07-31 16:58:28 +10:00
Robert Daniel Kortschak
53b61057b2 fmt: make all errors begin with the string "%!", always.
Fixes #5730.

R=dsymonds, r, kamil.kisiel
CC=golang-dev
https://golang.org/cl/11998044
2013-07-31 16:11:12 +10:00
Ulf Holm Nielsen
aa38aeaeaf time: Allow Parse and Format to handle time zone offsets with seconds
Adds layout cases with seconds for stdISO8601 and stdNumTZ with and without colons. Update time.Format to append seconds for those cases.

Fixes #4934.

R=golang-dev, r, bradfitz
CC=golang-dev
https://golang.org/cl/8132044
2013-07-31 16:11:02 +10:00
Rob Pike
df4de948a5 text/template/parse: print TextNodes using %s not %q
This means that printing a Node will produce output that can be used as valid input.
It won't be exactly the same - some spacing may be different - but it will mean the same.

Fixes #4593.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12006047
2013-07-31 15:09:13 +10:00
Rob Pike
221af5c12f fmt: treat \r\n as \n in Scan
When scanning input and "white space" is permitted, a carriage return
followed immediately by a newline (\r\n) is treated exactly the same
as a plain newline (\n). I hope this makes it work better on Windows.

We do it everywhere, not just on Windows, since why not?

Fixes #5391.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12142043
2013-07-31 15:00:08 +10:00
Keith Randall
a696ae56db runtime: optimize some hash lookups.
When comparing strings, check these (in order):
- length mismatch => not equal
- string pointer equal => equal
- if length is short:
  - memeq on body
- if length is long:
  - compare first&last few bytes, if different => not equal
  - save entry as a possible match
  - after checking every entry, if there is only one possible
    match, use memeq on that entry.  Otherwise, fallback to hash.

benchmark                 old ns/op    new ns/op    delta
BenchmarkSameLengthMap           43            4  -89.77%

Fixes #5194.
Update #3885.

R=golang-dev, bradfitz, khr, rsc
CC=golang-dev
https://golang.org/cl/12128044
2013-07-30 21:39:57 -07:00
Rob Pike
609d742e79 fmt: remove "Scan:" prefix from error messages
The prefix was not uniformly applied and is probably better left off anyway.

Fixes #4944.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12140043
2013-07-31 14:09:19 +10:00
Rob Pike
02ad82fe15 fmt: put a ! in all error output generated by Printf-like functions
Fixes #5730.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12141043
2013-07-31 14:08:47 +10:00
Mikio Hara
fa673bd872 net: add simple SetKeepAlivePeriod call test
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/12090043
2013-07-31 12:34:14 +09:00
Russ Cox
1794880299 runtime: fix build on FreeBSD
This is what I get for being talked into a test.

TBR=bradfitz
CC=golang-dev
https://golang.org/cl/12045044
2013-07-30 23:21:07 -04:00
Rob Pike
5fea8c030b text/template: fix type of ComplexZero in test
Was stupidly float64; should be complex128.
The tests still pass.

Fixes #5649.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12107044
2013-07-31 13:04:57 +10:00
Russ Cox
6a13897bc6 runtime: ARM _sfloat has no arguments
Fixes one build failure.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/12139043
2013-07-30 22:58:38 -04:00
Russ Cox
4042b77776 runtime: cut struct Hmap back to 48-byte allocation
struct Hmap is the header for a map value.

CL 8377046 made flags a uint32 so that it could be updated atomically,
but that bumped the struct to 56 bytes, which allocates as 64 bytes (on amd64).

hash0 is initialized from runtime.fastrand1, which returns a uint32,
so the top 32 bits were always zero anyway. Declare it as a uint32
to reclaim 4 bytes and bring the Hmap size back down to a 48-byte allocation.

Fixes #5237.

R=golang-dev, khr, khr
CC=bradfitz, dvyukov, golang-dev
https://golang.org/cl/12034047
2013-07-30 22:48:03 -04:00
Shivakumar GN
3abaf5cae0 net/http: skip TestDirJoin on Windows, even if /etc/hosts exists
Fixes #5460.

R=golang-dev, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/12123043
2013-07-30 18:25:08 -07:00
Robert Griesemer
12a38d5b95 container/list: document complexity of Len
Fixes #5972.

R=golang-dev, adonovan
CC=golang-dev
https://golang.org/cl/12125043
2013-07-30 13:35:14 -07:00
Dmitriy Vyukov
3d6bce411c runtime: fix code formatting
This is mainly to force another build
with goroutine preemption.

R=rsc
CC=golang-dev
https://golang.org/cl/12006045
2013-07-30 23:48:18 +04:00
Dmitriy Vyukov
a20784bdaf runtime: enable goroutine preemption
All known issues with preemption have beed fixed.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12008044
2013-07-30 22:17:38 +04:00
Dmitriy Vyukov
5c8ad2e13d runtime: fix race builders
Do not run Syscall benchmarks under race detector,
they split stack in syscall status.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12093045
2013-07-30 22:13:51 +04:00
Dmitriy Vyukov
3b6de5e847 net: fix memory leak on unix
If netFD is closed by finalizer, runtime netpoll descriptor is not freed.

R=golang-dev, dave, alex.brainman
CC=golang-dev
https://golang.org/cl/12037043
2013-07-30 19:47:16 +04:00
Mikio Hara
28138f1364 net: fix comment on SetKeepAlivePeriod
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/12091043
2013-07-30 16:31:57 +09:00
Mikio Hara
8f32df5455 net: add missing SetKeepAlivePeriod for Plan 9
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/12082045
2013-07-30 16:29:51 +09:00
Alex A Skinner
789e1c351e encoding/xml: Do not pass through invalid utf8 bytes
EscapeText now escapes 0xFFFD returned from DecodeRune as 0xFFFD, rather than passing through the original byte.
Fixes #5880.

R=golang-dev, r, bradfitz, adg
CC=golang-dev
https://golang.org/cl/11975043
2013-07-30 14:11:47 +10:00
Robert Griesemer
3eb9adeeb8 go/parser: don't report name errors if DeclarationErrors is not set
R=adonovan
CC=golang-dev
https://golang.org/cl/12072043
2013-07-29 16:00:28 -07:00
Robert Griesemer
340918a8a3 go/parser: selectors may be method expressions
R=adonovan
CC=golang-dev
https://golang.org/cl/12062043
2013-07-29 13:52:15 -07:00
Russ Cox
c7d5c438a2 runtime: adjust timediv to avoid _vasop; mark _subv okay
R=dvyukov
CC=golang-dev
https://golang.org/cl/12028046
2013-07-29 16:42:07 -04:00
Russ Cox
98cc58e2c7 runtime: fix timediv calls on NetBSD, OpenBSD
Document endian-ness assumption.

R=dvyukov
CC=golang-dev
https://golang.org/cl/12056044
2013-07-29 16:31:42 -04:00
Dmitriy Vyukov
14e3540430 runtime: fix arm build
The current failure is:
fatal error: runtime: stack split during syscall
goroutine 2 [stack split]:
_si2v(0xb6ebaebc, 0x3b9aca00)
        /usr/local/go/src/pkg/runtime/vlrt_arm.c:628 fp=0xb6ebae9c
runtime.timediv(0xf8475800, 0xd, 0x3b9aca00, 0xb6ebaef4)
        /usr/local/go/src/pkg/runtime/runtime.c:424 +0x1c fp=0xb6ebaed4

Just adding textflag 7 causes the following error:
notetsleep: nosplit stack overflow
        128	assumed on entry to notetsleep
        96	after notetsleep uses 32
        60	after runtime.futexsleep uses 36
        4	after runtime.timediv uses 56
        -4	after _si2v uses 8

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12001045
2013-07-30 00:08:30 +04:00
Robert Griesemer
5bd61e0603 math/big: better documentation for Rat.Float64
R=adonovan, r
CC=golang-dev
https://golang.org/cl/11961043
2013-07-29 13:06:34 -07:00
Dmitriy Vyukov
64db2ec915 runtime: fix arm build
The current failure is:
fatal error: runtime: stack split during syscall
goroutine 2 [stack split]:
_addv(0xb6fa0f28, 0xd0a5112e, 0x13156d6e, 0xf8475800, 0xd)
        /usr/local/go/src/pkg/runtime/vlrt_arm.c:66 fp=0xb6fa0ef8
notetsleep(0xb6fa0f9c, 0xf8475800, 0xd, 0x0, 0x0, ...)
        /usr/local/go/src/pkg/runtime/lock_futex.c:156 +0xd0 fp=0xb6fa0f18
runtime.notetsleepg(0xb6fa0f9c, 0xf8475800, 0xd)
        /usr/local/go/src/pkg/runtime/lock_futex.c:197 +0x74 fp=0xb6fa0f3c

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12052043
2013-07-29 23:41:12 +04:00
Dmitriy Vyukov
d91219e458 runtime: fix linux/arm build
notetsleep: nosplit stack overflow
        128	assumed on entry to notetsleep
        80	after notetsleep uses 48
        44	after runtime.futexsleep uses 36
        -12	after runtime.timediv uses 56

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12049043
2013-07-29 22:59:30 +04:00
Dmitriy Vyukov
ddc01d5b06 runtime: fix openbsd build
notetsleep: nosplit stack overflow
        120	assumed on entry to notetsleep
        96	after notetsleep uses 24
        88	on entry to runtime.semasleep
        32	after runtime.semasleep uses 56
        24	on entry to runtime.nanotime
        -8	after runtime.nanotime uses 32

Nanotime seems to be using only 24 bytes of stack space.
Unless I am missing something.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12041044
2013-07-29 22:58:58 +04:00
Dmitriy Vyukov
d83688165a runtime: fix freebsd build
notetsleep: nosplit stack overflow
        120	assumed on entry to notetsleep
        80	after notetsleep uses 40
        72	on entry to runtime.futexsleep
        16	after runtime.futexsleep uses 56
        8	on entry to runtime.printf
        -16	after runtime.printf uses 24

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12047043
2013-07-29 22:58:26 +04:00
Dmitriy Vyukov
e84d9e1fb3 runtime: do not split stacks in syscall status
Split stack checks (morestack) corrupt g->sched,
but g->sched must be preserved consistent for GC/traceback.
The change implements runtime.notetsleepg function,
which does entersyscall/exitsyscall and is carefully arranged
to not call any split functions in between.

R=rsc
CC=golang-dev
https://golang.org/cl/11575044
2013-07-29 22:22:34 +04:00
Dmitriy Vyukov
b8734748b6 net: fix memory leaks on windows
Close netpoll descriptor along with socket.
Ensure that error paths close the descriptor as well.

R=golang-dev, mikioh.mikioh, alex.brainman
CC=golang-dev
https://golang.org/cl/11987043
2013-07-29 20:01:13 +04:00
Pieter Droogendijk
6350e45892 runtime: allow SetFinalizer with a func(interface{})
Fixes #5368.

R=golang-dev, dvyukov
CC=golang-dev, rsc
https://golang.org/cl/11858043
2013-07-29 19:43:08 +04:00
Mikio Hara
3398322d5e net: remove redundant comment on isWildcard
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/11985043
2013-07-29 23:26:11 +09:00
Mikio Hara
442e614cab net: document sockaddr interface
This is in preparation for runtime-integrated network pollster for BSD
variants.

Update #5199

R=golang-dev, fvbommel, dave
CC=golang-dev
https://golang.org/cl/11984043
2013-07-29 23:25:39 +09:00
Rémy Oudompheng
b7c3d06a1f all: move examples into package *_test.
Fixes #5677.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/11992043
2013-07-29 01:25:51 +02:00
Rémy Oudompheng
05026c4ebd compress/flate: reduce tiny allocs done by encoder.
benchmark                          old allocs   new allocs    delta
BenchmarkEncodeDigitsSpeed1e4             942           91  -90.34%
BenchmarkEncodeDigitsSpeed1e5            1919          178  -90.72%
BenchmarkEncodeDigitsSpeed1e6           18539         1517  -91.82%
BenchmarkEncodeDigitsDefault1e4           734          100  -86.38%
BenchmarkEncodeDigitsDefault1e5          1958          193  -90.14%
BenchmarkEncodeDigitsDefault1e6         17338         1426  -91.78%
BenchmarkEncodeDigitsCompress1e4          734          100  -86.38%
BenchmarkEncodeDigitsCompress1e5         1958          193  -90.14%
BenchmarkEncodeDigitsCompress1e6        17338         1426  -91.78%
BenchmarkEncodeTwainSpeed1e4             1865          109  -94.16%
BenchmarkEncodeTwainSpeed1e5             3943          211  -94.65%
BenchmarkEncodeTwainSpeed1e6            31279         1595  -94.90%
BenchmarkEncodeTwainDefault1e4           1811          103  -94.31%
BenchmarkEncodeTwainDefault1e5           3708          199  -94.63%
BenchmarkEncodeTwainDefault1e6          26738         1330  -95.03%
BenchmarkEncodeTwainCompress1e4          1811          103  -94.31%
BenchmarkEncodeTwainCompress1e5          3693          190  -94.86%
BenchmarkEncodeTwainCompress1e6         26902         1333  -95.04%

benchmark                           old bytes    new bytes    delta
BenchmarkEncodeDigitsSpeed1e4         1469438      1453920   -1.06%
BenchmarkEncodeDigitsSpeed1e5         1490898      1458961   -2.14%
BenchmarkEncodeDigitsSpeed1e6         1858819      1542407  -17.02%
BenchmarkEncodeDigitsDefault1e4       1465903      1454160   -0.80%
BenchmarkEncodeDigitsDefault1e5       1491841      1459361   -2.18%
BenchmarkEncodeDigitsDefault1e6       1825424      1531545  -16.10%
BenchmarkEncodeDigitsCompress1e4      1465903      1454160   -0.80%
BenchmarkEncodeDigitsCompress1e5      1491681      1459361   -2.17%
BenchmarkEncodeDigitsCompress1e6      1825424      1531545  -16.10%
BenchmarkEncodeTwainSpeed1e4          1485308      1454400   -2.08%
BenchmarkEncodeTwainSpeed1e5          1526065      1459878   -4.34%
BenchmarkEncodeTwainSpeed1e6          2066627      1536296  -25.66%
BenchmarkEncodeTwainDefault1e4        1484380      1454240   -2.03%
BenchmarkEncodeTwainDefault1e5        1521793      1459558   -4.09%
BenchmarkEncodeTwainDefault1e6        1977504      1523388  -22.96%
BenchmarkEncodeTwainCompress1e4       1484380      1454240   -2.03%
BenchmarkEncodeTwainCompress1e5       1521457      1459318   -4.08%
BenchmarkEncodeTwainCompress1e6       1980000      1523609  -23.05%

benchmark                           old ns/op    new ns/op    delta
BenchmarkEncodeDigitsSpeed1e4         1472128      1384343   -5.96%
BenchmarkEncodeDigitsSpeed1e5         8283663      8112304   -2.07%
BenchmarkEncodeDigitsSpeed1e6        77459311     76364216   -1.41%
BenchmarkEncodeDigitsDefault1e4       1813090      1746552   -3.67%
BenchmarkEncodeDigitsDefault1e5      26221292     26052516   -0.64%
BenchmarkEncodeDigitsDefault1e6     286512472    286099039   -0.14%
BenchmarkEncodeDigitsCompress1e4      1809373      1747230   -3.43%
BenchmarkEncodeDigitsCompress1e5     26231580     26038456   -0.74%
BenchmarkEncodeDigitsCompress1e6    286140002    286025372   -0.04%
BenchmarkEncodeTwainSpeed1e4          1594094      1438600   -9.75%
BenchmarkEncodeTwainSpeed1e5          7669724      7316288   -4.61%
BenchmarkEncodeTwainSpeed1e6         68731353     65938994   -4.06%
BenchmarkEncodeTwainDefault1e4        2063497      1866488   -9.55%
BenchmarkEncodeTwainDefault1e5       22602689     22221377   -1.69%
BenchmarkEncodeTwainDefault1e6      233376842    232114297   -0.54%
BenchmarkEncodeTwainCompress1e4       2062441      1949676   -5.47%
BenchmarkEncodeTwainCompress1e5      28264344     27930627   -1.18%
BenchmarkEncodeTwainCompress1e6     304369641    303704330   -0.22%

benchmark                            old MB/s     new MB/s  speedup
BenchmarkEncodeDigitsSpeed1e4            6.79         7.22    1.06x
BenchmarkEncodeDigitsSpeed1e5           12.07        12.33    1.02x
BenchmarkEncodeDigitsSpeed1e6           12.91        13.10    1.01x
BenchmarkEncodeDigitsDefault1e4          5.52         5.73    1.04x
BenchmarkEncodeDigitsDefault1e5          3.81         3.84    1.01x
BenchmarkEncodeDigitsDefault1e6          3.49         3.50    1.00x
BenchmarkEncodeDigitsCompress1e4         5.53         5.72    1.03x
BenchmarkEncodeDigitsCompress1e5         3.81         3.84    1.01x
BenchmarkEncodeDigitsCompress1e6         3.49         3.50    1.00x
BenchmarkEncodeTwainSpeed1e4             6.27         6.95    1.11x
BenchmarkEncodeTwainSpeed1e5            13.04        13.67    1.05x
BenchmarkEncodeTwainSpeed1e6            14.55        15.17    1.04x
BenchmarkEncodeTwainDefault1e4           4.85         5.36    1.11x
BenchmarkEncodeTwainDefault1e5           4.42         4.50    1.02x
BenchmarkEncodeTwainDefault1e6           4.28         4.31    1.01x
BenchmarkEncodeTwainCompress1e4          4.85         5.13    1.06x
BenchmarkEncodeTwainCompress1e5          3.54         3.58    1.01x
BenchmarkEncodeTwainCompress1e6          3.29         3.29    1.00x

R=imkrasin, golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/10006043
2013-07-28 09:42:40 +02:00
Mikio Hara
a64bea5c99 net: make UnixAddr implement sockaddr interface
This is in preparation for runtime-integrated network pollster for BSD
variants.

Update #5199

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/11932044
2013-07-28 16:15:07 +09:00
Mikio Hara
e257cd8aae net: extend sockaddr interface to the all address families
This CL extends existing sockaddr interface to accommodate not only
internet protocol family endpoint addressess but unix network family
endpoint addresses.

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

Update #5199

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/11979043
2013-07-28 12:52:30 +09:00
Mikio Hara
bf61a97f24 net: simplify socket option helpers
Also consolidates syscall.IPPROTO_TCP level option helper files.

R=golang-dev, dave, alex.brainman
CC=golang-dev
https://golang.org/cl/8637049
2013-07-28 11:18:06 +09:00
Dmitriy Vyukov
91d35ad1b8 runtime: fix potential deadlock in netpoll on windows
If netpoll has been told to block, it must not return with nil,
otherwise scheduler assumes that netpoll is disabled.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/11920044
2013-07-27 13:46:40 +04:00
Dmitriy Vyukov
29f17fb01c net: temporary skip hanging test on windows
Update #5971.

R=alex.brainman
CC=golang-dev
https://golang.org/cl/11938046
2013-07-27 13:36:27 +04:00
Russ Cox
14062efb16 runtime: handle runtime.Goexit during init
Fixes #5963.

R=golang-dev, dsymonds, dvyukov
CC=golang-dev
https://golang.org/cl/11879045
2013-07-26 13:54:44 -04:00
Dmitriy Vyukov
f8a850b250 runtime: refactor mallocgc
Make it accept type, combine flags.
Several reasons for the change:
1. mallocgc and settype must be atomic wrt GC
2. settype is called from only one place now
3. it will help performance (eventually settype
functionality must be combined with markallocated)
4. flags are easier to read now (no mallocgc(sz, 0, 1, 0) anymore)

R=golang-dev, iant, nightlyone, rsc, dave, khr, bradfitz, r
CC=golang-dev
https://golang.org/cl/10136043
2013-07-26 21:17:24 +04:00
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Dmitriy Vyukov
07cb48c31f sync: fix race instrumentation of WaitGroup
Currently more than 1 gorutine can execute raceWrite() in Wait()
in the following scenario:
1. goroutine 1 executes first check of wg.counter, sees that it's == 0
2. goroutine 2 executes first check of wg.counter, sees that it's == 0
3. goroutine 2 locks the mutex, sees that he is the first waiter and executes raceWrite()
4. goroutine 2 block on the semaphore
5. goroutine 3 executes Done() and unblocks goroutine 2
6. goroutine 1 lock the mutex, sees that he is the first waiter and executes raceWrite()

It produces the following false report:
WARNING: DATA RACE
Write by goroutine 35:
  sync.raceWrite()
      src/pkg/sync/race.go:41 +0x33
  sync.(*WaitGroup).Wait()
      src/pkg/sync/waitgroup.go:103 +0xae
  command-line-arguments_test.TestNoRaceWaitGroupMultipleWait2()
      src/pkg/runtime/race/testdata/waitgroup_test.go:156 +0x19a
  testing.tRunner()
      src/pkg/testing/testing.go:361 +0x108

Previous write by goroutine 36:
  sync.raceWrite()
      src/pkg/sync/race.go:41 +0x33
  sync.(*WaitGroup).Wait()
      src/pkg/sync/waitgroup.go:103 +0xae
  command-line-arguments_test.func·012()
      src/pkg/runtime/race/testdata/waitgroup_test.go:148 +0x4d

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10424043
2013-06-25 20:27:19 +04:00
Alex Brainman
3d513faa6f runtime: do not mark os memory as executable on windows
Resubmit 3c2cddfbdaec now that windows callbacks
are not generated during runtime.

Fixes #5494

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/10487043
2013-06-25 17:20:14 +10:00
Alex Brainman
8486d96a27 runtime: change netpoll in preparation for windows implementation
- change runtime_pollWait so it does not return
  closed or timeout if IO is ready - windows must
  know if IO has completed or not even after
  interruption;
- add (*pollDesc).Prepare(mode int) that can be
  used for both read and write, same for Wait;
- introduce runtime_pollWaitCanceled and expose
  it in net as (*pollDesc).WaitCanceled(mode int);

Full windows netpoll changes are
here https://golang.org/cl/8670044/.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/10485043
2013-06-25 12:29:00 +10:00
Rob Pike
793bb6cce7 crypto/sha1: mark block as non-escaping
The compiler still gets the escape analysis wrong, but the annotation here is correct.

R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/10514046
2013-06-24 17:48:31 -07:00
Dave Cheney
3b76d70e11 syscall: reduce duplication between *bsd and linux
Part 2 of several.

R=rsc, mikioh.mikioh, r
CC=golang-dev
https://golang.org/cl/10462043
2013-06-25 10:14:40 +10:00
Rob Pike
feab3f4986 hash: tweak the package docs
No semantic change.
I found the wording distracting in a couple of instances and was moved to improve it.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/10478048
2013-06-24 16:53:13 -07:00
Brad Fitzpatrick
a054028471 net/http: Transport should return an error when response body ends early
If a server response contains a Content-Length and the body is short,
the Transport should end in io.ErrUnexpectedEOF, not io.EOF.

Fixes #5738

R=golang-dev, kevlar, r
CC=golang-dev
https://golang.org/cl/10237050
2013-06-24 13:27:56 -07:00
ChaiShushan
3eaaed5030 net/rpc: fix RegisterName rejects "." character.
Fixes #5617.

R=r, rsc
CC=gobot, golang-dev
https://golang.org/cl/10370043
2013-06-24 13:23:02 -07:00
ChaiShushan
b78aaec22f net/rpc: call client.Close() when test exit
Fixes #5768.

R=golang-dev
CC=golang-dev
https://golang.org/cl/10503043
2013-06-24 13:18:50 -07:00
Dmitriy Vyukov
bd105b2bca runtime/pprof: disable testing under race detector
until we decide what to do with issues 5659/5736.
Profiling with race detector is not very useful in general,
and now it makes race builders red.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10523043
2013-06-24 23:51:00 +04:00
Russ Cox
f21bc7920d time: avoid garbage collector aliasing bug
Time is a tiny struct, so the compiler copies a Time by
copying each of the three fields.

The layout of a time on amd64 is [ptr int32 gap32 ptr].
Copying a Time onto a location that formerly held a pointer in the
second word changes only the low 32 bits, creating a different
but still plausible pointer. This confuses the garbage collector
when it appears in argument or result frames.

To avoid this problem, declare nsec as uintptr, so that there is
no gap on amd64 anymore, and therefore no partial pointers.

Note that rearranging the fields to put the int32 last still leaves
a gap - [ptr ptr int32 gap32] - because Time must have a total
size that is ptr-width aligned.

Update #5749

This CL is enough to fix the problem, but we should still do
the other actions listed in the initial report. We're not too far
from completely precise collection.

R=golang-dev, dvyukov, r
CC=golang-dev
https://golang.org/cl/10504043
2013-06-24 14:49:35 -04:00
Adam Langley
ce5d91baa5 compress/bzip2: don't panic on invalid input.
Fixes 5747.

R=golang-dev, r, bradfitz
CC=golang-dev
https://golang.org/cl/10401050
2013-06-24 10:59:41 -04:00
Alex Brainman
05a5de30f0 runtime: do not generate code during runtime in windows NewCallback
Update #5494

R=golang-dev, minux.ma, rsc, iant
CC=golang-dev
https://golang.org/cl/10368043
2013-06-24 17:17:45 +10:00
Dave Cheney
28a55111b2 os: rename error_posix.go to error_unix.go
The tradition is to use _posix when the platform extends beyond unix variants. As windows has its own file, rename to the more usual _unix.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10320043
2013-06-24 11:23:37 +10:00
Rick Arnold
fc0b5ef0fd time: handle integer overflow in Sub
If time.Sub results in a value that won't fit in a Duration (int64),
return either the min or max int64 value as appropriate.

Fixes #5011.

R=golang-dev, bradfitz, r, rsc
CC=golang-dev
https://golang.org/cl/10328043
2013-06-21 18:07:57 -07:00
Dave Cheney
dd3a3cfa49 syscall: reduce duplication between *bsd and linux
See discussion: https://groups.google.com/forum/#!topic/golang-dev/zSmH0lQxKAs

Part 1 of several.

Move identical types and functions to syscall_unix.go.

R=rsc, mikioh.mikioh, r
CC=golang-dev
https://golang.org/cl/10392048
2013-06-22 11:03:40 +10:00
Robert Griesemer
fc1e298ba1 go/parser: always provide a non-nil path for imports
The go/ast ImportSpec always requires a non-nil path.

R=adonovan
CC=golang-dev
https://golang.org/cl/10402047
2013-06-21 15:09:04 -07:00
Rob Pike
279c48444a testing: include cover mode in cover profile
R=adg, rsc
CC=golang-dev
https://golang.org/cl/10392049
2013-06-21 14:19:08 -07:00
Robert Griesemer
f243584d29 go/*: support for slices with cap: s[:j:k] and s[i:j:k]
Experimental, per rsc's proposal.

R=rsc
CC=golang-dev
https://golang.org/cl/10204043
2013-06-21 13:14:06 -07:00
Dave Cheney
a00958aac6 all: avoid leaking fds during tests
trivial: it is not a serious problem to leak a fd in a short lived process, but it was obscuring my investigation of issue 5593.

R=golang-dev, iant, bradfitz
CC=golang-dev
https://golang.org/cl/10391043
2013-06-21 11:13:14 +10:00
Rob Pike
0bc7e79afd all: excise some warts found by vet -shadow
These are not erroneous, just poor or confusing.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/10448043
2013-06-20 16:14:40 -07:00
Brad Fitzpatrick
5b0bf9db8e net/http: fix confusing shadowing in ProxyFromEnvironment
The old code worked, somewhat on accident, but was confusing,
and had a useless assignment to the inner err. It worked
because url.Parse parses just about anything, so the outer err
was always nil, so it always fell through to the bottom return
statement, even without the "err = nil" line.

Instead, just have two return statements, and add a comment.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10448044
2013-06-20 11:58:24 -07:00
Rob Pike
3e710c0ba5 all: fix shadowing bugs found by go tool vet -shadow
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/10328044
2013-06-20 11:50:44 -07:00
Adam Langley
9035297266 crypto/x509: add function to marshal EC private keys.
This complements the parsing function that we already have.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10426043
2013-06-20 12:14:16 -04:00
Adam Langley
966e889687 crypto/tls: change advertised ciphersuite order.
TLS clients send ciphersuites in preference order (most prefereable
first). This change alters the order so that ECDHE comes before plain
RSA, and RC4 comes before AES (because of the Lucky13 attack).

This is unlikely to have much effect: as a server, the code uses the
client's ciphersuite order by default and, as a client, the non-Go
server probably imposes its order.

R=golang-dev, r, raggi, jsing
CC=golang-dev
https://golang.org/cl/10372045
2013-06-19 16:46:53 -04:00
Rob Pike
27cca31ee1 cmd/go: simplify flags for coverage
The single flag -cover provides the default simplest behavior.
The other flags, -covermode and -coverprofile, provide more
control. The three flags interconnect to work well.

R=rsc, adg
CC=golang-dev
https://golang.org/cl/10364044
2013-06-18 17:15:26 -07:00
Rob Pike
8e8b8b85c2 cmd/go: write coverage to file, add percentage statistic
Move the data dumper to the testing package, where it has access
to file I/O.
Print a percentage value at the end of the run.

R=rsc, adg
CC=golang-dev
https://golang.org/cl/10264045
2013-06-18 14:18:25 -07:00
Robert Griesemer
6154ae8e24 math/big: fix Errorf verb
Pointed out by go vet.

R=r
CC=golang-dev
https://golang.org/cl/10368048
2013-06-18 14:16:40 -07:00
Cosmos Nicolaou
f882bc8708 os/exec: make exec_test.go:TestExtraFilesFDShuffle portable.
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/9103045
2013-06-18 08:55:32 -07:00
Alex Jin
83db738786 net/smtp: close conn in SendMail; add Client.Close method
R=rsc, dave, bradfitz
CC=golang-dev
https://golang.org/cl/10082044
2013-06-17 16:53:27 -07:00
Paul van Brouwershaven
4bd79e742a crypto/x509: Added RFC 5280, section 4.2.1.14 to parseCertificate and buildExtensions
Support for CRL Distribution Points

R=golang-dev, agl, bradfitz
CC=golang-dev
https://golang.org/cl/10258043
2013-06-17 14:56:45 -07:00
Nicolas Owens
2af974777d net: fix LookupNS on Plan 9
use correct field count when resolving nameservers via /net/dns on Plan 9.

we incorrectly check for 4 fields instead of 3 when parsing the result of /net/dns, and get no results

R=golang-dev, ality
CC=golang-dev
https://golang.org/cl/10182044
2013-06-17 11:38:07 -07:00
Dan Peterson
563d09cd14 testing: use -bench flag and fix flags doc link
R=golang-dev, r, kr
CC=golang-dev
https://golang.org/cl/10263043
2013-06-17 07:32:28 -07:00
Brad Fitzpatrick
14e52c74bc crypto/cipher: StreamWriter.Closer docs + behavior change
Don't panic when the underlying Writer isn't a Closer. And
document what Close does and clarify that it's not a Flush.

R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/10310043
2013-06-17 07:30:04 -07:00
Dmitriy Vyukov
d660688f14 runtime/race: add tests for method thunks
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/10257043
2013-06-17 17:59:53 +04:00
Dmitriy Vyukov
f84cbd0950 runtime: fix test for new closure representation
I've hit it several times already.
Currently it crashes with nil deref.

R=golang-dev, daniel.morsing, r
CC=golang-dev
https://golang.org/cl/10317045
2013-06-17 15:41:17 +04:00
Dmitriy Vyukov
94dc963b55 runtime: fix race condition between GC and setGCPercent
If first GC runs concurrently with setGCPercent,
it can overwrite gcpercent value with default.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/10242047
2013-06-15 16:07:06 +04:00
Dmitriy Vyukov
4bb491b12e runtime: improve scheduler fairness
Currently global runqueue is starved if a group of goroutines
constantly respawn each other (local runqueue never becomes empty).
Fixes #5639.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/10042044
2013-06-15 16:06:28 +04:00
Dmitriy Vyukov
5caf762457 runtime: remove unused moreframesize_minalloc field
It was used to request large stack segment for GC
when it was running not on g0.
Now GC is running on g0 with large stack,
and it is not needed anymore.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/10242045
2013-06-15 16:02:39 +04:00
Keith Randall
de316388a7 runtime: garbage collector runs on g0 now.
No need to change to Grunnable state.
Add some more checks for Grunning state.

R=golang-dev, rsc, khr, dvyukov
CC=golang-dev
https://golang.org/cl/10186045
2013-06-14 11:42:51 -07:00
Brad Fitzpatrick
61d3b2db62 net: coalesce duplicate in-flight DNS lookups
In Issue 5625, Russ says: "We should at least have a cache of
inflight lookups, so that 100 simultaneous dials of one host
name don't do the work 100x. That's easy and (assume we forget
the answer once they all get it) doesn't pose any consistency
problems. It just merges simultaneous work."

This brings in singleflight (unexported) from Google /
Camlistore, but without its tests. Maybe we should put it
somewhere in the standard library. But not now.

Update #5625

R=golang-dev, iant, cespare, rsc, dave, rogpeppe, remyoudompheng
CC=golang-dev
https://golang.org/cl/10079043
2013-06-14 08:59:43 -07:00
Rémy Oudompheng
3be794cdc2 cmd/gc: instrument arrays properly in race detector.
The previous implementation would only record access to
the address of the array but the memory access to the whole
memory range must be recorded instead.

R=golang-dev, dvyukov, r
CC=golang-dev
https://golang.org/cl/8053044
2013-06-14 11:14:45 +02:00
Caleb Spare
bc08124866 strconv: corrected several bad references to err.Error in doc comments.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10253051
2013-06-13 17:04:47 -07:00
Alan Donovan
568c4617ec go/ast: add {L,R}paren token.Pos field to ast.TypeAssertExpr.
These are required to correctly determine the End() of the node.

Also set these fields in go/parser and use them in go/printer.

This is a backward-compatible API change.

R=gri, r
CC=golang-dev
https://golang.org/cl/10189043
2013-06-13 14:41:44 -04:00
Dmitriy Vyukov
b9ddb0d8b3 runtime: fix bug introduced in cl/10256043
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/10260043
2013-06-13 16:40:10 +04:00
Dmitriy Vyukov
e2d95c1f24 runtime/race: remove now unused step parameter from range access functions
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/10259043
2013-06-13 16:38:44 +04:00
Dmitriy Vyukov
591d58a3bb cmd/gc: properly race-instrument for loops
Instrumentation of ntest expression should go to ntest->init.
Same for nincr.
Fixes #5340.

R=golang-dev, daniel.morsing
CC=golang-dev
https://golang.org/cl/10026046
2013-06-13 16:03:58 +04:00
Dmitriy Vyukov
2ffaefd161 runtime: use ROUND macro for rounding
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/10256043
2013-06-13 16:02:50 +04:00
Dmitriy Vyukov
cc99e6e949 runtime/race: update runtime to r183644
This revision properly handles memory range accesses.
Fixes #4453.
Fixes #5654.

R=golang-dev, iant, remyoudompheng
CC=golang-dev
https://golang.org/cl/10082043
2013-06-13 14:32:05 +04:00
Rob Pike
28a1c36d62 testing: add -outputdir flag so "go test" controls where the files are written
Obscure misfeature now fixed: When run from "go test", profiles were always
written in the package's source directory. This change puts them in the directory
where "go test" is run.
Also fix a couple of problems causing errors in testing.after to go unreported
unless -v was set.

R=rsc, minux.ma, iant, alex.brainman
CC=golang-dev
https://golang.org/cl/10234044
2013-06-12 18:13:34 -07:00
Ian Lance Taylor
0627248a1f runtime: update runtime·gogo comment in asm files
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/10244043
2013-06-12 15:05:10 -07:00
Russ Cox
d67e7e3acf runtime: add lr, ctxt, ret to Gobuf
Add gostartcall and gostartcallfn.
The old gogocall = gostartcall + gogo.
The old gogocallfn = gostartcallfn + gogo.

R=dvyukov, minux.ma
CC=golang-dev
https://golang.org/cl/10036044
2013-06-12 15:22:26 -04:00
Dmitriy Vyukov
a8ad859c30 runtime: more flexible heap memory mapping on 64-bits
Fixes #5641.

R=golang-dev, dave, daniel.morsing, iant
CC=golang-dev, kcc
https://golang.org/cl/10126044
2013-06-12 18:47:16 +04:00
Dmitriy Vyukov
dbcfed93e7 runtime: fix scheduler race condition
In starttheworld() we assume that P's with local work
are situated in the beginning of idle P list.
However, once we start the first M, it can execute all local G's
and steal G's from other P's.
That breaks the assumption above. Thus starttheworld() will fail
to start some P's with local work.
It seems that it can not lead to very bad things, but still
it's wrong and breaks other assumtions
(e.g. we can have a spinning M with local work).
The fix is to collect all P's with local work first,
and only then start them.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10051045
2013-06-12 18:46:35 +04:00
Russ Cox
e5cbebc1ad runtime: fix plan9, windows builds
TBR=dvyukov
CC=golang-dev
https://golang.org/cl/10229043
2013-06-12 09:41:29 -04:00
Russ Cox
80efeff20a runtime: fix build
TBR=dvyukov
CC=golang-dev
https://golang.org/cl/10227044
2013-06-12 09:06:28 -04:00
Russ Cox
e58f798c0c runtime: adjust traceback / garbage collector boundary
The garbage collection routine addframeroots is duplicating
logic in the traceback routine that calls it, sometimes correctly,
sometimes incorrectly, sometimes incompletely.
Pass necessary information to addframeroots instead of
deriving it anew.

Should make addframeroots significantly more robust.
It's certainly smaller.

Also try to standardize on uintptr for saved pc, sp values.

Will make CL 10036044 trivial.

R=golang-dev, dave, dvyukov
CC=golang-dev
https://golang.org/cl/10169045
2013-06-12 08:49:38 -04:00
Shenghou Ma
ccd1d07cc4 runtime: round spans_size up to page boundary
in case we have weird (not page aligned) memory limit.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10199043
2013-06-12 05:22:49 +08:00
Russ Cox
6120ef0799 runtime: rename _rt0_$GOARCH to _rt0_go
There's no reason to use a different name on each architecture,
and doing so makes it impossible for portable code to refer to
the original Go runtime entry point. Rename it _rt0_go everywhere.

This is a global search and replace only.

R=golang-dev, bradfitz, minux.ma
CC=golang-dev
https://golang.org/cl/10196043
2013-06-11 16:49:24 -04:00
Daniel Morsing
e7657de717 cmd/gc: avoid creating circular lists when compiling with race detector.
Fixes #5431.

R=dvyukov, remyoudompheng, rsc
CC=gobot, golang-dev
https://golang.org/cl/9910043
2013-06-11 21:19:29 +02:00
Alex Brainman
9b2561ef16 os: request appropriate access rights before calling windows TerminateProcess
Fixes #5615.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/9651047
2013-06-11 13:06:38 +10:00
Gerasimos Dimitriadis
02a891b30b asn1: Improved encoding/decoding for OID types
The first identifier in an Object Identifer must be between 0 and 2
inclusive. The range of values that the second one can take depends
on the value of the first one.
The two first identifiers are not necessarily encoded in a single octet,
but in a varint.

R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/10140046
2013-06-10 18:14:47 -04:00
Dmitriy Vyukov
fd41926347 runtime: fix one-time memory leak on linux
Update #5641.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/10144043
2013-06-10 22:59:39 +04:00
Dmitriy Vyukov
62747bde6c runtime: catch races between channel close and channel send in select
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/10137043
2013-06-10 22:58:04 +04:00
Shenghou Ma
06f55f5009 net: introduce netgo build tag to build a pure Go net package.
Fixes #4078.

R=golang-dev, bradfitz, rsc, iant
CC=golang-dev
https://golang.org/cl/7100050
2013-06-11 02:55:16 +08:00
Shenghou Ma
46e30c7d70 syscall: add {Set,Get}priority for Linux, and consistency tests
R=golang-dev, iant, bradfitz, dave
CC=golang-dev
https://golang.org/cl/7430044
2013-06-11 02:47:04 +08:00
Dmitriy Vyukov
fc80764792 runtime/race: tell race detector what memory Read/Write syscalls touch
Fixes #5567.

R=golang-dev, dave, iant
CC=golang-dev
https://golang.org/cl/10085043
2013-06-10 22:40:35 +04:00
Dmitriy Vyukov
0f4897ae1a sync: improve race instrumentation of WaitGroup
Do not synchronize Add(1) with Wait().
Imitate read on first Add(1) and write on Wait(),
it allows to catch common misuses of WaitGroup:
- Add() called in the additional goroutine itself
- incorrect reuse of WaitGroup with multiple waiters

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/10093044
2013-06-10 22:38:58 +04:00
Alex Brainman
bb6e265fed os: return io.EOF from windows ReadAt as documented
Fixes #5619.

R=golang-dev, r, peter.armitage, go.peter.90
CC=golang-dev
https://golang.org/cl/9952044
2013-06-10 19:14:41 +10:00
Dmitriy Vyukov
4f514e8691 runtime: use persistentalloc instead of SysAlloc in FixAlloc
Also reduce FixAlloc allocation granulatiry from 128k to 16k,
small programs do not need that much memory for MCache's and MSpan's.

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/10140044
2013-06-10 09:20:27 +04:00
Dmitriy Vyukov
83445fdcc3 runtime: use persistentalloc instead of mallocgc in symtab
Reduces heap size.

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/10140043
2013-06-10 09:17:46 +04:00
Dmitriy Vyukov
99922aba8b runtime: use persistentalloc instead of SysAlloc in GC
Especially important for Windows because it reserves VM
only in multiple of 64k.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/10082048
2013-06-10 09:16:06 +04:00
Dmitriy Vyukov
b36f2db12a runtime: use persistentalloc instead of mallocgc for itab
Reduces heap size.

R=golang-dev, remyoudompheng, bradfitz
CC=golang-dev
https://golang.org/cl/10139043
2013-06-09 21:58:35 +04:00
Dmitriy Vyukov
5290e55164 runtime: use persistentalloc instead of SysAlloc in netpoll
Especially important for Windows because it reserves VM
only in multiple of 64k.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/10138043
2013-06-09 21:39:47 +04:00
Dmitriy Vyukov
8cf7044983 runtime: use persistentalloc instead of custom malloc in memory profiler
Removes code duplication.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/9874055
2013-06-09 21:38:37 +04:00
Shenghou Ma
e880ab112e runtime: remove unused file mkversion.c
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/10107044
2013-06-09 22:04:17 +08:00
Ian Lance Taylor
b6e52ecffa runtime: remove unused mid function
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10036047
2013-06-06 18:10:42 -07:00
Dmitriy Vyukov
8bf57c3dcb runtime: remove unused field from Hchan
Remove alignment logic as well, it's not respected by chanbuf() anyway.

R=golang-dev, dave, minux.ma, r, iant, rsc
CC=golang-dev
https://golang.org/cl/9678046
2013-06-06 23:06:12 +04:00
Dmitriy Vyukov
5d637b83a9 runtime: speedup malloc stats collection
Count only number of frees, everything else is derivable
and does not need to be counted on every malloc.
benchmark                    old ns/op    new ns/op    delta
BenchmarkMalloc8                    68           66   -3.07%
BenchmarkMalloc16                   75           70   -6.48%
BenchmarkMallocTypeInfo8           102           97   -4.80%
BenchmarkMallocTypeInfo16          108          105   -2.78%

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/9776043
2013-06-06 14:56:50 +04:00
Alex Brainman
07ea243d50 time: provide timezone abbreviations on windows
Use http://unicode.org/cldr/data/common/supplemental/windowsZones.xml
to generate the map.

Fixes #4838.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/9997043
2013-06-06 16:30:25 +10:00
Robert Obryk
9614119007 io/ioutil: make WriteFile notice errors from Close()
WriteFile should not successfully return if the file's
Close call failed.

Fixes #5644.

R=golang-dev, kr, r
CC=golang-dev
https://golang.org/cl/10067043
2013-06-05 21:16:44 -07:00
Russ Cox
528534c1d4 runtime: fix comments (g->gobuf became g->sched long ago)
Should reduce size of CL 9868044.

R=golang-dev, ality
CC=golang-dev
https://golang.org/cl/10045043
2013-06-05 07:16:53 -04:00
Russ Cox
f032eefdb0 cmd/cgo, cmd/go, go/build: sort flag lists
CFLAGS comes before CPPFLAGS.
Also fix one typo CPPCFLAGS.

Cleanup for CL 8248043.

R=golang-dev, iant, alberto.garcia.hierro
CC=golang-dev
https://golang.org/cl/9965045
2013-06-05 07:14:05 -04:00
Anthony Martin
5567592c07 mime: add support for Plan 9
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/10028043
2013-06-04 17:30:45 -07:00
Nigel Tao
427bec62b5 image/jpeg: avoid documentation argument over whether it's luma
subsampling or chroma subsampling.

Fixes #5569.

R=r
CC=golang-dev
https://golang.org/cl/9900044
2013-06-05 10:18:06 +10:00
Anthony Martin
cdfbe00d91 runtime: fix description of SysAlloc
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/10010046
2013-06-04 17:12:29 -07:00
Adam Langley
2112fed743 crypto/tls: support TLS 1.1.
The significant change between TLS 1.0 and 1.1 is the addition of an explicit IV in the case of CBC encrypted records. Support for TLS 1.1 is needed in order to support TLS 1.2.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7880043
2013-06-04 20:02:22 -04:00
Adam Langley
eec014de66 encoding/asn1: harmonise error prefixes.
This change ensures that error messages always start with "asn1: ".

R=golang-dev, gedimitr
CC=golang-dev
https://golang.org/cl/9751043
2013-06-04 19:51:26 -04:00
Ian Lance Taylor
941db1ed39 encoding/gob: consistently use unsafe.Pointer for pointer values
Fixes #5621.

R=golang-dev, cshapiro, r, fullung
CC=golang-dev
https://golang.org/cl/9988043
2013-06-04 06:20:57 -07:00
Alex Brainman
9bc0eaf60e runtime: update defs_windows_*.h files
New version of cmd/cgo from
https://golang.org/cl/9574043/
is used to regenerate these.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/9679046
2013-06-04 12:50:40 +10:00
Russ Cox
fa4a9ff764 cmd/ld, runtime: clean up CL 9666047
Remove unnecessary ( ) around == in && clause.
Add { } around multiline if body, even though it's one statement.

Add runtime: prefix to printed errors.

R=cshapiro, iant
CC=golang-dev
https://golang.org/cl/9685047
2013-06-03 16:44:35 -04:00
Rémy Oudompheng
394706b646 compress/bzip2: faster decoding.
benchmark                old ns/op    new ns/op    delta
BenchmarkDecodeDigits     19451173     14347829  -26.24%
BenchmarkDecodeTwain      57516800     42619978  -25.90%

benchmark                 old MB/s     new MB/s  speedup
BenchmarkDecodeDigits         2.22         3.01    1.36x
BenchmarkDecodeTwain          2.17         2.93    1.35x

R=golang-dev, dave, bradfitz, agl
CC=golang-dev
https://golang.org/cl/9915043
2013-06-03 20:38:00 +02:00
Dmitriy Vyukov
4a8ef1f65d runtime: disable preemption in several scheduler functions
Required for preemptive scheduler, see the comments for details.

R=golang-dev, khr, iant, khr
CC=golang-dev
https://golang.org/cl/9740051
2013-06-03 14:40:38 +04:00
Dmitriy Vyukov
354ec51666 runtime: introduce preemption function (not used for now)
This is part of preemptive scheduler.

R=golang-dev, cshapiro, iant
CC=golang-dev
https://golang.org/cl/9843046
2013-06-03 13:20:17 +04:00
Dmitriy Vyukov
f5becf4233 runtime: add stackguard0 to G
This is part of preemptive scheduler.
stackguard0 is checked in split stack checks and can be set to StackPreempt.
stackguard is not set to StackPreempt (holds the original value).

R=golang-dev, daniel.morsing, iant
CC=golang-dev
https://golang.org/cl/9875043
2013-06-03 12:28:24 +04:00
Dave Cheney
a28609d66f testing: fix rounding error in roundDown10
Fixes #5599.

Thanks to minux.ma for the suggested fix.

As we now have a harness to test testing internal functions I added some coverage for testing.roundUp, as it is the main consumer of roundDown10.

R=minux.ma, kr, r
CC=golang-dev
https://golang.org/cl/9926043
2013-06-02 09:13:12 +10:00
Dmitriy Vyukov
83d4cd758c runtime: minor code style improvements (followup to change 9778049)
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9693044
2013-06-02 01:45:26 +04:00
Keith Randall
7f0ee023ba runtime: revert of CL 8852047: do hashmap grow work during reads.
seems to break freebsd-386.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/9915047
2013-05-31 21:44:32 -07:00
Keith Randall
07b6add0ca runtime: do hashmap grow work during reads.
Before this change, grow work was done only
during map writes to ensure multithreaded safety.
This can lead to maps remaining in a partially
grown state for a long time, potentially forever.
This change allows grow work to happen during reads,
which will lead to grow work finishing sooner, making
the resulting map smaller and faster.

Grow work is not done in parallel.  Reads can
happen in parallel while grow work is happening.

R=golang-dev, dvyukov, khr, iant
CC=golang-dev
https://golang.org/cl/8852047
2013-05-31 20:58:31 -07:00
Keith Randall
71f061043d runtime/gc: Run garbage collector on g0 stack
instead of regular g stack. We do this so that the g stack
we're currently running on is no longer changing.  Cuts
the root set down a bit (g0 stacks are not scanned, and
we don't need to scan gc's internal state).  Also an
enabler for copyable stacks.

R=golang-dev, cshapiro, khr, 0xe2.0x9a.0x9b, dvyukov, rsc, iant
CC=golang-dev
https://golang.org/cl/9754044
2013-05-31 20:43:33 -07:00
Alberto García Hierro
84485361f9 cmd/go: Add support for including C++ files in packages
* Add a CXXFiles field to Package, which includes .cc, .cpp and .cxx  files.
* CXXFiles are compiled using g++, which can be overridden using the CXX environment variable.
* Include .hh, .hpp and .hxx files in HFiles.
* Add support for CPPFLAGS (used for both C and C++) and CXXFLAGS (used only for C++) in cgo directive.
* Changed pkg-config cgo directive to modify CPPFLAGS rather than CFLAGS, so both C and C++ files get any flag returned by pkg-config --cflags.

Fixes #1476.

R=iant, r
CC=bradfitz, gobot, golang-dev, iant, minux.ma, remyoudompheng, seb.binet
https://golang.org/cl/8248043
2013-05-31 11:33:36 -07:00
Dave Cheney
787976c739 testing: add test for issue 5599
Update #5599

R=golang-dev, r, minux.ma
CC=golang-dev
https://golang.org/cl/9738052
2013-05-31 23:03:22 +10:00
Dmitriy Vyukov
9ba551bb87 runtime: fix heap coalescing bug introduced in cl/9802043
mheap.map become a pointer, so nelem(h->map) returns 1 rather than the map size.
As the result coalescing with subsequent spans does not happen.

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/9649046
2013-05-31 10:58:50 +04:00
Dmitriy Vyukov
86da989ee5 runtime: introduce helper persistentalloc() function
It is a caching wrapper around SysAlloc() that can allocate small chunks.
Use it for symtab allocations. Reduces number of symtab walks from 4 to 3
(reduces buildfuncs time from 10ms to 7.5ms on a large binary,
reduces initial heap size by 680K on the same binary).
Also can be used for type info allocation, itab allocation.
There are also several places in GC where we do the same thing,
they can be changed to use persistentalloc().
Also can be used in FixAlloc, because each instance of FixAlloc allocates
in 128K regions, which is too eager.
Reincarnation of committed and rolled back https://golang.org/cl/9805043
The latent bugs that it revealed are fixed:
https://golang.org/cl/9837049
https://golang.org/cl/9778048

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/9778049
2013-05-31 10:42:30 +04:00
Keith Randall
d6f89d735e runtime: set MSpan.limit properly for large spans.
Then use the limit to make sure MHeap_LookupMaybe & inlined
copies don't return a span if the pointer is beyond the limit.
Use this fact to optimize all call sites.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/9869045
2013-05-30 21:32:20 -07:00
Rob Pike
cf5dd6ad64 testing: quantize AllocsPerRun
As the code now says:

We are forced to return a float64 because the API is silly, but do
the division as integers so we can ask if AllocsPerRun()==1
instead of AllocsPerRun()<2.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/9837049
2013-05-30 11:28:08 -04:00
Dmitriy Vyukov
e17281b397 runtime: rename mheap.maps to mheap.spans
as was dicussed in cl/9791044

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9853046
2013-05-30 17:09:58 +04:00
Dmitriy Vyukov
573d25a423 runtime: mark runtime.goexit as nosplit
Required for preemptive scheduler, see the comment.

R=golang-dev, daniel.morsing
CC=golang-dev
https://golang.org/cl/9841047
2013-05-30 14:11:49 +04:00
Carl Shapiro
037a1a9f31 cmd/ld, runtime: emit pointer maps for nosplits identified by the linker
A nosplits was assumed to have no argument information and no
pointer map.  However, nosplits created by the linker often
have both.  This change uses the pointer map size as an
alternate source of argument size when processing a nosplit.

In addition, the symbol table construction pointer map size
and argument size consistency check is strengthened.  If a
nptrs is greater than 0 it must be equal to the number of
argument words.

R=golang-dev, khr, khr
CC=golang-dev
https://golang.org/cl/9666047
2013-05-29 17:16:57 -07:00
Shenghou Ma
5d081792b6 cmd/5a, cmd/dist, runtime: support m/g in the assembler, drop support for R9/R10
to avoid unintentionally clobber R9/R10.
Thanks Lucio for the suggestion.

PS: yes, this could be considered a big change (but not an API change), but
as it turns out even temporarily changes R9/R10 in user code is unsafe and
leads to very hard to diagnose problems later, better to disable using R9/R10
when the user first uses it.
See CL 6300043 and CL 6305100 for two problems caused by misusing R9/R10.

R=golang-dev, khr, rsc
CC=golang-dev
https://golang.org/cl/9840043
2013-05-30 03:03:52 +08:00
Jan Ziak
a3e0002e6a runtime: remove all badcallback() functions
R=iant
CC=golang-dev
https://golang.org/cl/9738046
2013-05-29 17:51:17 +02:00
Rob Pike
d84132cce7 fmt: change evalutation of indexed arg to match docs
The old code put the index before the period in the precision;
it should be after so it's always before the star, as documented.
A little trickier to do in one pass but compensated for by more
tests and catching a couple of other error cases.

R=rsc
CC=golang-dev
https://golang.org/cl/9751044
2013-05-29 11:29:29 -04:00
John Shahid
ca986a2c81 crypto/tls: Check all certificates in the path.
Currently we only check the leaf node's issuer against the list of
distinguished names in the server's CertificateRequest message. This
will fail if the client certiciate has more than one certificate in
the path and the leaf node issuer isn't in the list of distinguished
names, but the issuer's issuer was in the distinguished names.

R=agl, agl
CC=gobot, golang-dev
https://golang.org/cl/9795043
2013-05-29 11:21:32 -04:00
Dmitriy Vyukov
e932c2035f runtime: make notetsleep() return false if timeout happens
This is needed for preemptive scheduler, because during
stoptheworld we want to wait with timeout and re-preempt
M's on timeout.

R=golang-dev, remyoudompheng, iant
CC=golang-dev
https://golang.org/cl/9375043
2013-05-29 11:49:45 +04:00
Carl Shapiro
4e0a51c210 cmd/5l, cmd/6l, cmd/8l, cmd/gc, runtime: generate and use bitmaps of argument pointer locations
With this change the compiler emits a bitmap for each function
covering its stack frame arguments area.  If an argument word
is known to contain a pointer, a bit is set.  The garbage
collector reads this information when scanning the stack by
frames and uses it to ignores locations known to not contain a
pointer.

R=golang-dev, bradfitz, daniel.morsing, dvyukov, khr, khr, iant, cshapiro
CC=golang-dev
https://golang.org/cl/9223046
2013-05-28 17:59:10 -07:00
Dmitriy Vyukov
8bbb08533d runtime: make mheap statically allocated again
This depends on: 9791044: runtime: allocate page table lazily
Once page table is moved out of heap, the heap becomes small.
This removes unnecessary dereferences during heap access.
No logical changes.

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/9802043
2013-05-28 22:14:47 +04:00
Dmitriy Vyukov
671814b904 runtime: allocate page table lazily
This removes the 256MB memory allocation at startup,
which conflicts with ulimit.
Also will allow to eliminate an unnecessary memory dereference in GC,
because the page table is usually mapped at known address.
Update #5049.
Update #5236.

R=golang-dev, khr, r, khr, rsc
CC=golang-dev
https://golang.org/cl/9791044
2013-05-28 22:04:34 +04:00
Dmitriy Vyukov
081129e286 runtime: allocate internal symbol table eagerly
we need it for GC anyway.

R=golang-dev, khr, dave, khr
CC=golang-dev
https://golang.org/cl/9728044
2013-05-28 21:10:10 +04:00
Dmitriy Vyukov
4d6bfcf245 os/exec: fix test hang
Currently the test closes random files descriptors,
which leads to hang (in particular if netpoll fd is closed).
Try to open only fd 3, since the parent process expects it to be fd 3 anyway.
Fixes #5571.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9778048
2013-05-28 21:09:27 +04:00
Dmitriy Vyukov
2f5825d427 runtime: fix heap corruption during GC
The 'n' variable is used during rescan initiation in GC_END case,
but it's overwritten with chan capacity in GC_CHAN case.
As the result rescan is done with the wrong object size.
Fixes #5554.

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/9831043
2013-05-28 19:17:47 +04:00
Shenghou Ma
d8fd8d89ea runtime: use m and g, instead of R9 and R10, in ARM assembly files
also don't clobber R9 if it is about to crash.

In response to https://golang.org/cl/9251043/#msg2.

R=golang-dev, khr, khr, dave
CC=golang-dev
https://golang.org/cl/9778046
2013-05-28 20:13:02 +08:00
Dmitriy Vyukov
828c68f8d8 undo CL 9805043 / 776aba85ece8
multiple failures on amd64

««« original CL description
runtime: introduce helper persistentalloc() function
It is a caching wrapper around SysAlloc() that can allocate small chunks.
Use it for symtab allocations. Reduces number of symtab walks from 4 to 3
(reduces buildfuncs time from 10ms to 7.5ms on a large binary,
reduces initial heap size by 680K on the same binary).
Also can be used for type info allocation, itab allocation.
There are also several places in GC where we do the same thing,
they can be changed to use persistentalloc().
Also can be used in FixAlloc, because each instance of FixAlloc allocates
in 128K regions, which is too eager.

R=golang-dev, daniel.morsing, khr
CC=golang-dev
https://golang.org/cl/9805043
»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/9822043
2013-05-28 11:14:39 +04:00
Dmitriy Vyukov
5166013f75 runtime: inline MCache_Alloc() into mallocgc()
benchmark                    old ns/op    new ns/op    delta
BenchmarkMalloc8                    68           62   -8.63%
BenchmarkMalloc16                   75           69   -7.94%
BenchmarkMallocTypeInfo8           102           98   -3.73%
BenchmarkMallocTypeInfo16          108          103   -4.63%

R=golang-dev, dave, khr
CC=golang-dev
https://golang.org/cl/9790043
2013-05-28 11:05:55 +04:00
Dmitriy Vyukov
47e0a3d7b1 runtime: introduce helper persistentalloc() function
It is a caching wrapper around SysAlloc() that can allocate small chunks.
Use it for symtab allocations. Reduces number of symtab walks from 4 to 3
(reduces buildfuncs time from 10ms to 7.5ms on a large binary,
reduces initial heap size by 680K on the same binary).
Also can be used for type info allocation, itab allocation.
There are also several places in GC where we do the same thing,
they can be changed to use persistentalloc().
Also can be used in FixAlloc, because each instance of FixAlloc allocates
in 128K regions, which is too eager.

R=golang-dev, daniel.morsing, khr
CC=golang-dev
https://golang.org/cl/9805043
2013-05-28 10:47:35 +04:00
Bill Neubauer
82ef961af5 runtime: fix runtime·netpoll() to call runtime·netpollready() only once per event.
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/9808043
2013-05-28 05:03:10 +08:00
Shenghou Ma
ae73b90369 runtime: make arm signal handler call runtime.badsignal
In preparation for CL 9249043 (already submitted).

Fixes #5553.

R=golang-dev, iant, capnm9, dave
CC=golang-dev
https://golang.org/cl/9251043
2013-05-27 20:46:53 +08:00
Dmitriy Vyukov
5782f4117d runtime: introduce cnewarray() to simplify allocation of typed arrays
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/9648044
2013-05-27 11:29:11 +04:00
Jan Ziak
e017e0cb24 runtime: flag static variables as no-pointers
Variables in data sections of 32-bit executables interfere with
garbage collector's ability to free objects and/or unnecessarily
slow down the garbage collector.

This changeset moves some static variables to .noptr sections.
'files' in symtab.c is now allocated dynamically.

R=golang-dev, dvyukov, minux.ma
CC=golang-dev
https://golang.org/cl/9786044
2013-05-27 08:11:59 +02:00
Dmitriy Vyukov
46137f227b runtime: update comment on stack allocator
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9665046
2013-05-25 22:47:36 +04:00
Rob Pike
7472ce0e58 fmt.Printf: introduce notation for random access to arguments.
This text is added to doc.go:

        Explicit argument indexes:

        In Printf, Sprintf, and Fprintf, the default behavior is for each
        formatting verb to format successive arguments passed in the call.
        However, the notation [n] immediately before the verb indicates that the
        nth one-indexed argument is to be formatted instead. The same notation
        before a '*' for a width or precision selects the argument index holding
        the value. After processing a bracketed expression [n], arguments n+1,
        n+2, etc. will be processed unless otherwise directed.

        For example,
                fmt.Sprintf("%[2]d %[1]d\n", 11, 22)
        will yield "22, 11", while
                fmt.Sprintf("%[3]*[2].*[1]f", 12.0, 2, 6),
        equivalent to
                fmt.Sprintf("%6.2f", 12.0),
        will yield " 12.00". Because an explicit index affects subsequent verbs,
        this notation can be used to print the same values multiple times
        by resetting the index for the first argument to be repeated:
                fmt.Sprintf("%d %d %#[1]x %#x", 16, 17)
        will yield "16 17 0x10 0x11".

The notation chosen differs from that in C, but I believe it's easier to read
and to remember (we're indexing the arguments), and compatibility with
C's printf was never a strong goal anyway.

While we're here, change the word "field" to "arg" or "argument" in the
code; it was being misused and was confusing.

R=rsc, bradfitz, rogpeppe, minux.ma, peter.armitage
CC=golang-dev
https://golang.org/cl/9680043
2013-05-24 15:49:26 -07:00
Adam Langley
ddc8679128 crypto/x509: harmonise error prefixes.
crypto/x509 has ended up with a variety of error formats. This change makes them all start with "x509: ".

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9736043
2013-05-24 16:23:13 -04:00
Christopher Nielsen
ee78a707c0 path/filepath: Skip TestEvalSymlinks. Plan 9 doesn't have symlinks.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9713044
2013-05-24 11:01:04 -07:00
Gerasimos Dimitriadis
af48543c54 asn1: Stricter checks for DER encoded booleans
According to X.690, only 0 and 255 are allowed as values
for encoded booleans. Also added some test for parsing
booleans

R=golang-dev, agl, r
CC=golang-dev
https://golang.org/cl/9692043
2013-05-24 12:37:42 -04:00
Dmitriy Vyukov
0806c97209 log/syslog: fix deadlock in test
The problem was that server handlers block on done<-,
the goroutine that reads from done blocks on count<-,
and the main goroutine that is supposed to read from count
waits for server handlers to exit.
Fixes #5547.

R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/9722043
2013-05-24 18:35:48 +04:00
Frederick Kelly Mayle III
7b9df09261 runtime: faster range on empty map
benchmark                old ns/op    new ns/op    delta
BenchmarkMapIter               191          190   -0.52%
BenchmarkMapIterEmpty           22            4  -78.96%

R=golang-dev, minux.ma, dvyukov, iant, khr
CC=golang-dev
https://golang.org/cl/9637043
2013-05-23 14:17:52 -07:00
Daniel Morsing
fdc4ce6ec7 io: Prioritize WriterTos over ReaderFroms in Copy.
This only affects calls where both ReaderFrom and WriterTo are implemented. WriterTo can issue one large write, while ReaderFrom must Read until EOF, potentially reallocating when out of memory. With one large Write, the Writer only needs to allocate once.

This also helps in ioutil.Discard since we can avoid copying memory when the Reader implements WriterTo.

R=golang-dev, dsymonds, remyoudompheng, bradfitz
CC=golang-dev, minux.ma
https://golang.org/cl/9462044
2013-05-23 18:29:19 +02:00
Nan Deng
876455f3ba crypto/rsa: implement PSS signatures.
This change contains an implementation of the RSASSA-PSS signature
algorithm described in RFC 3447.

R=agl, agl
CC=gobot, golang-dev, r
https://golang.org/cl/9438043
2013-05-23 11:10:41 -04:00
Mikio Hara
adbe59e332 syscall: add IPv6 socket options for Unix variants
This CL adds missing IPv6 socket options which are required
to control IPv6 as described in RFC 3493, RFC 3542.

Update #5538

R=golang-dev, dave, iant
CC=golang-dev
https://golang.org/cl/9373046
2013-05-23 16:22:05 +09:00
Robert Griesemer
e3a72b05f8 go/doc: fix build
1) go/doc:
   - create correct ast.FuncType
   - use more commonly used variable names in a test case

2) make ast.FuncType.Pos robust in case of incorrect ASTs

R=golang-dev
CC=golang-dev
https://golang.org/cl/9651044
2013-05-22 14:22:50 -07:00
Shenghou Ma
cb8782e8b3 bufio: fix SplitFunc docs
Fixes #5532.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/9672044
2013-05-23 04:38:32 +08:00
Robert Griesemer
75b62e367b go/ast: fix FuncType.Pos() impl. and FuncType.Params documentation
As pointed out by adonovan.

R=golang-dev, adonovan
CC=golang-dev
https://golang.org/cl/9662045
2013-05-22 13:36:43 -07:00
Rob Pike
e17a6d4b9d log/syslog: report errors from write
Fixes #5541.
This time for sure.

R=golang-dev, minux.ma, iant
CC=golang-dev
https://golang.org/cl/9668043
2013-05-22 12:45:52 -07:00
Dmitriy Vyukov
72c4ee1a9d runtime: properly synchronize GC and finalizer goroutine
This is needed for preemptive scheduler, because the goroutine
can be preempted at surprising points.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/9376043
2013-05-22 23:04:46 +04:00
Dmitriy Vyukov
34c67eb24e runtime: detect deadlocks in programs using cgo
When cgo is used, runtime creates an additional M to handle callbacks on threads not created by Go.
This effectively disabled deadlock detection, which is a right thing, because Go program can be blocked
and only serve callbacks on external threads.
This also disables deadlock detection under race detector, because it happens to use cgo.
With this change the additional M is created lazily on first cgo call. So deadlock detector
works for programs that import "C", "net" or "net/http/pprof" but do not use them in fact.
Also fixes deadlock detector under race detector.
It should be fine to create the M later, because C code can not call into Go before first cgo call,
because C code does not know when Go initialization has completed. So a Go program need to call into C
first either to create an external thread, or notify a thread created in global ctor that Go
initialization has completed.
Fixes #4973.
Fixes #5475.

R=golang-dev, minux.ma, iant
CC=golang-dev
https://golang.org/cl/9303046
2013-05-22 22:57:47 +04:00
Rob Pike
f6c7b339a6 undo CL 9658043 / ac7877558dce
The original code was correct. The count returned must be the length
of the input slice, not the length of the formatted message.

««« original CL description
log/syslog: report errors from Fprintf
Thanks to chiparus for identifying this.

Fixes #5541.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/9658043
»»»

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/9644044
2013-05-22 11:42:04 -07:00
Dmitriy Vyukov
c075d82cca runtime: fix and speedup malloc stats
Currently per-sizeclass stats are lost for destroyed MCache's. This patch fixes this.
Also, only update mstats.heap_alloc on heap operations, because that's the only
stat that needs to be promptly updated. Everything else needs to be up-to-date only in ReadMemStats().

R=golang-dev, remyoudompheng, dave, iant
CC=golang-dev
https://golang.org/cl/9207047
2013-05-22 22:22:57 +04:00
Rob Pike
4c2df76b7d log/syslog: report errors from Fprintf
Thanks to chiparus for identifying this.

Fixes #5541.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/9658043
2013-05-22 11:03:10 -07:00
Dmitriy Vyukov
c4cfef075e runtime: simplify MCache
The nlistmin/size thresholds are copied from tcmalloc,
but are unnecesary for Go malloc. We do not do explicit
frees into MCache. For sparse cases when we do (mainly hashmap),
simpler logic will do.

R=rsc, dave, iant
CC=gobot, golang-dev, r, remyoudompheng
https://golang.org/cl/9373043
2013-05-22 13:29:17 +04:00
Brad Fitzpatrick
950fa93531 net/http: add another Hijacker test
R=dsymonds
CC=gobot, golang-dev
https://golang.org/cl/9570043
2013-05-21 18:43:28 -07:00
Brad Fitzpatrick
99f6722860 bufio: reuse Writer buffers after Flush
A bufio.Writer.Flush marks the usual end of a Writer's
life. Recycle its internal buffer on those explicit flushes,
but not on normal, as-needed internal flushes.

benchmark               old ns/op    new ns/op    delta
BenchmarkWriterEmpty         1959          727  -62.89%

benchmark              old allocs   new allocs    delta
BenchmarkWriterEmpty            2            1  -50.00%

benchmark               old bytes    new bytes    delta
BenchmarkWriterEmpty         4215           83  -98.03%

R=gri, iant
CC=gobot, golang-dev, voidlogic7
https://golang.org/cl/9459044
2013-05-21 15:51:49 -07:00
Brad Fitzpatrick
ddda7980c5 net/http: don't send Accept-Encoding on HEAD requests
Works around a bug in nginx: http://trac.nginx.org/nginx/ticket/358

Fixes #5522

R=iant
CC=gobot, golang-dev
https://golang.org/cl/9627043
2013-05-21 15:21:30 -07:00
Brad Fitzpatrick
0e10196982 database/sql: remove extra RemoveDep call
This should have been removed in 45c12efb4635. Not a correctness
issue, but unnecessary work.

This CL also adds paranoia checks in removeDep so this doesn't
happen again.

Fixes #5502

R=adg
CC=gobot, golang-dev, google
https://golang.org/cl/9543043
2013-05-21 14:58:08 -07:00
Brad Fitzpatrick
509a1173a3 time: remove Time.FormatAppend
undo CL 8478044 / 0d28fd55e721

Lack of consensus.

««« original CL description
time: add Time.FormatAppend

This is a version of Time.Format that doesn't require allocation.

Fixes #5192
Update #5195

R=r
CC=gobot, golang-dev
https://golang.org/cl/8478044
»»»

R=r
CC=golang-dev
https://golang.org/cl/9462049
2013-05-21 14:32:09 -07:00
Adam Langley
8590e1bd3c crypto/tls: don't send NPN extension if NextProtos is not set.
This isn't clearly a bug on Go's part, but it triggers a bug in Firefox
which means that crypto/tls and net/http cannot be wired up together
unless NextProtos includes "http/1.1". When net/http sets up the
tls.Config, it does this and so works fine. But anyone setting up the
tls.Config themselves will hit the Firefox bug.

Fixes #5445.

R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/9539045
2013-05-21 10:47:31 -04:00
Brad Fitzpatrick
c6c439d7a0 net/http: use WriteString directly when possible
Several places used io.WriteString unnecessarily when the
static type already implemented WriteString. No need to
check for it at runtime.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9608043
2013-05-20 19:26:26 -07:00
Rémy Oudompheng
fc3bec386e cmd/gc: clear n->list of OFOR range loop after walk.
It contains the LHS of the range clause and gets
instrumented by racewalk, but it doesn't have any meaning.

Fixes #5446.

R=golang-dev, dvyukov, daniel.morsing, r
CC=golang-dev
https://golang.org/cl/9560044
2013-05-20 23:45:22 +02:00
Adam Langley
b419e2b57c crypto/x509: provide better error messages for X.509 verify failures.
Failures caused by errors like invalid signatures or missing hash
functions cause rather generic, unhelpful error messages because no
trust chain can be constructed: "x509: certificate signed by unknown
authority."

With this change, authority errors may contain the reason why an
arbitary candidate step in the chain was rejected. For example, in the
event of a missing hash function the error looks like:

x509: certificate signed by unknown authority (possibly because of
"crypto/x509: cannot verify signature: algorithm unimplemented" while
trying to verify candidate authority certificate 'Thawte SGC CA')

Fixes 5058.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9104051
2013-05-20 14:20:26 -04:00
Brad Fitzpatrick
27f7427995 net/http: simplify transfer body; reduces allocations too
benchmark                                   old ns/op    new ns/op    delta
BenchmarkServerFakeConnNoKeepAlive              14431        14247   -1.28%
BenchmarkServerFakeConnWithKeepAlive            11618        11357   -2.25%
BenchmarkServerFakeConnWithKeepAliveLite         6735         6427   -4.57%
BenchmarkServerHandlerTypeLen                    8842         8740   -1.15%
BenchmarkServerHandlerNoLen                      8001         7828   -2.16%
BenchmarkServerHandlerNoType                     8270         8227   -0.52%
BenchmarkServerHandlerNoHeader                   6148         5920   -3.71%

benchmark                                  old allocs   new allocs    delta
BenchmarkServerFakeConnNoKeepAlive                 30           29   -3.33%
BenchmarkServerFakeConnWithKeepAlive               25           24   -4.00%
BenchmarkServerFakeConnWithKeepAliveLite           10            9  -10.00%
BenchmarkServerHandlerTypeLen                      18           17   -5.56%
BenchmarkServerHandlerNoLen                        15           14   -6.67%
BenchmarkServerHandlerNoType                       16           15   -6.25%
BenchmarkServerHandlerNoHeader                     10            9  -10.00%

benchmark                                   old bytes    new bytes    delta
BenchmarkServerFakeConnNoKeepAlive               2557         2492   -2.54%
BenchmarkServerFakeConnWithKeepAlive             2260         2194   -2.92%
BenchmarkServerFakeConnWithKeepAliveLite         1092         1026   -6.04%
BenchmarkServerHandlerTypeLen                    1941         1875   -3.40%
BenchmarkServerHandlerNoLen                      1898         1832   -3.48%
BenchmarkServerHandlerNoType                     1906         1840   -3.46%
BenchmarkServerHandlerNoHeader                   1092         1026   -6.04%

Update #5195

R=golang-dev, daniel.morsing
CC=golang-dev
https://golang.org/cl/9492044
2013-05-20 07:23:59 -07:00
Mikio Hara
b98a4d1a10 syscall: prefer PATH environment variable in bootstrap scripts
R=golang-dev, dave, iant
CC=golang-dev
https://golang.org/cl/9575043
2013-05-20 23:18:52 +09:00
Mikio Hara
c5732c8526 runtime: integrated network poller for freebsd/amd64,386, openbsd/amd64,386
Update #5199

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/8825043
2013-05-20 19:25:32 +09:00
Alex Brainman
1a948950f7 net: move system common global variables into fd_unix.go
R=golang-dev, bradfitz
CC=dvyukov, golang-dev, mikioh.mikioh
https://golang.org/cl/9495044
2013-05-20 15:23:45 +10:00
Dmitriy Vyukov
1308194204 runtime: zeroize g->fnstart to not prevent GC of the closure
Fixes #5493.

R=golang-dev, minux.ma, iant
CC=golang-dev
https://golang.org/cl/9557043
2013-05-20 08:17:21 +04:00
Brad Fitzpatrick
d4cbc80d10 net/http: fewer allocations in the server path
Don't allocate for the Date or Content-Length headers.
A custom Date header formatter replaces use of time.Format.

benchmark                                   old ns/op    new ns/op    delta
BenchmarkClientServer                           67791        64424   -4.97%
BenchmarkClientServerParallel4                  62956        58533   -7.03%
BenchmarkClientServerParallel64                 62043        54789  -11.69%
BenchmarkServer                                254609       229060  -10.03%
BenchmarkServerFakeConnNoKeepAlive              17038        16316   -4.24%
BenchmarkServerFakeConnWithKeepAlive            14184        13226   -6.75%
BenchmarkServerFakeConnWithKeepAliveLite         8591         7532  -12.33%
BenchmarkServerHandlerTypeLen                   10750         9961   -7.34%
BenchmarkServerHandlerNoLen                      9535         8935   -6.29%
BenchmarkServerHandlerNoType                     9858         9362   -5.03%
BenchmarkServerHandlerNoHeader                   7754         6856  -11.58%

benchmark                                  old allocs   new allocs    delta
BenchmarkClientServer                              68           66   -2.94%
BenchmarkClientServerParallel4                     68           66   -2.94%
BenchmarkClientServerParallel64                    68           66   -2.94%
BenchmarkServer                                    21           19   -9.52%
BenchmarkServerFakeConnNoKeepAlive                 32           30   -6.25%
BenchmarkServerFakeConnWithKeepAlive               27           25   -7.41%
BenchmarkServerFakeConnWithKeepAliveLite           12           10  -16.67%
BenchmarkServerHandlerTypeLen                      19           18   -5.26%
BenchmarkServerHandlerNoLen                        17           15  -11.76%
BenchmarkServerHandlerNoType                       17           16   -5.88%
BenchmarkServerHandlerNoHeader                     12           10  -16.67%

Update #5195

R=nigeltao
CC=golang-dev
https://golang.org/cl/9432046
2013-05-19 20:15:40 -07:00
Alex Brainman
38abb09a2e runtime: change PollDesc.fd from int32 to uintptr
This is in preparation for netpoll windows version.

R=golang-dev, bradfitz
CC=dvyukov, golang-dev, mikioh.mikioh
https://golang.org/cl/9569043
2013-05-20 12:55:50 +10:00
Dmitriy Vyukov
fee1d1cda0 runtime: properly set G status after syscall
R=golang-dev, r, dave
CC=golang-dev
https://golang.org/cl/9307045
2013-05-19 19:35:09 +04:00
Anthony Martin
2dc751ac21 runtime, cmd/gc: clean up function protoypes
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/8652043
2013-05-18 15:49:23 -07:00
Anthony Martin
8b85a3d480 runtime: mark usleep as NOSPLIT on Plan 9
Usleep is called from lockextra, also marked NOSPLIT.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9258043
2013-05-18 15:47:49 -07:00
Anthony Martin
b65271d008 runtime: fix newproc debugging print
R=golang-dev, remyoudompheng, r
CC=golang-dev
https://golang.org/cl/9249044
2013-05-18 15:47:15 -07:00
Keith Randall
28882bbd33 compress/flate: faster version of forwardCopy
benchmark                           old ns/op    new ns/op    delta
BenchmarkDecodeDigitsSpeed1e4          197767       203490   +2.89%
BenchmarkDecodeDigitsSpeed1e5         1873969      1912761   +2.07%
BenchmarkDecodeDigitsSpeed1e6        18922760     19021056   +0.52%
BenchmarkDecodeDigitsDefault1e4        194975       197054   +1.07%
BenchmarkDecodeDigitsDefault1e5       1704262      1719988   +0.92%
BenchmarkDecodeDigitsDefault1e6      16618354     16351957   -1.60%
BenchmarkDecodeDigitsCompress1e4       195281       194626   -0.34%
BenchmarkDecodeDigitsCompress1e5      1694364      1702372   +0.47%
BenchmarkDecodeDigitsCompress1e6     16463347     16492126   +0.17%
BenchmarkDecodeTwainSpeed1e4           200653       200127   -0.26%
BenchmarkDecodeTwainSpeed1e5          1861385      1759632   -5.47%
BenchmarkDecodeTwainSpeed1e6         18255769     17186679   -5.86%
BenchmarkDecodeTwainDefault1e4         189080       185157   -2.07%
BenchmarkDecodeTwainDefault1e5        1559222      1461465   -6.27%
BenchmarkDecodeTwainDefault1e6       14792125     13879051   -6.17%
BenchmarkDecodeTwainCompress1e4        188881       185151   -1.97%
BenchmarkDecodeTwainCompress1e5       1537031      1456945   -5.21%
BenchmarkDecodeTwainCompress1e6      14805972     13405094   -9.46%
BenchmarkPaeth                          4            4   -0.89%
BenchmarkDecodeGray                964679       937244   -2.84%
BenchmarkDecodeNRGBAGradient      3753769      3646416   -2.86%
BenchmarkDecodeNRGBAOpaque        3165856      2981300   -5.83%
BenchmarkDecodePaletted            713950       691984   -3.08%
BenchmarkDecodeRGB                3051718      2924260   -4.18%

R=nigeltao, bradfitz
CC=golang-dev, raph
https://golang.org/cl/9425046
2013-05-18 15:28:27 -07:00
Brad Fitzpatrick
b25a53acd7 bufio: make Reader buffer transient
Share garbage between different bufio Readers. When a Reader
has zero buffered data, put its buffer into a pool.

This acknowledges that most bufio.Readers eventually get
read to completion, and their buffers are then no longer
needed.

benchmark               old ns/op    new ns/op    delta
BenchmarkReaderEmpty         2993         1058  -64.65%

benchmark              old allocs   new allocs    delta
BenchmarkReaderEmpty            3            2  -33.33%

benchmark               old bytes    new bytes    delta
BenchmarkReaderEmpty         4278          133  -96.89%

Update #5100

R=r
CC=adg, dvyukov, gobot, golang-dev, rogpeppe
https://golang.org/cl/8819049
2013-05-17 15:16:06 -07:00
Keith Randall
6021449236 runtime: faster x86 memmove (a.k.a. built-in copy())
REP instructions have a high startup cost, so we handle small
sizes with some straightline code.  The REP MOVSx instructions
are really fast for large sizes.  The cutover is approximately
1K.  We implement up to 128/256 because that is the maximum
SSE register load (loading all data into registers before any
stores lets us ignore copy direction).

(on a Sandy Bridge E5-1650 @ 3.20GHz)
benchmark               old ns/op    new ns/op    delta
BenchmarkMemmove0               3            3   +0.86%
BenchmarkMemmove1               5            5   +5.40%
BenchmarkMemmove2              18            8  -56.84%
BenchmarkMemmove3              18            7  -58.45%
BenchmarkMemmove4              36            7  -78.63%
BenchmarkMemmove5              36            8  -77.91%
BenchmarkMemmove6              36            8  -77.76%
BenchmarkMemmove7              36            8  -77.82%
BenchmarkMemmove8              18            8  -56.33%
BenchmarkMemmove9              18            7  -58.34%
BenchmarkMemmove10             18            7  -58.34%
BenchmarkMemmove11             18            7  -58.45%
BenchmarkMemmove12             36            7  -78.51%
BenchmarkMemmove13             36            7  -78.48%
BenchmarkMemmove14             36            7  -78.56%
BenchmarkMemmove15             36            7  -78.56%
BenchmarkMemmove16             18            7  -58.24%
BenchmarkMemmove32             18            8  -54.33%
BenchmarkMemmove64             18            8  -53.37%
BenchmarkMemmove128            20            9  -55.93%
BenchmarkMemmove256            25           11  -55.16%
BenchmarkMemmove512            33           33   -1.19%
BenchmarkMemmove1024           43           44   +2.06%
BenchmarkMemmove2048           61           61   +0.16%
BenchmarkMemmove4096           95           95   +0.00%

R=golang-dev, bradfitz, remyoudompheng, khr, iant, dominik.honnef
CC=golang-dev
https://golang.org/cl/9038048
2013-05-17 12:53:49 -07:00
Alex Brainman
fad27ec5d4 os: clarify windows read console code
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9458043
2013-05-17 17:26:44 +10:00
Alex Brainman
c15ca825ad runtime: revert 3c2cddfbdaec
It appears, syscall.NewCallback still
uses heap to store executable code.

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/9060046
2013-05-17 14:23:29 +10:00
Alex Brainman
28f74608b5 runtime: do not mark os memory as executable on windows
R=golang-dev, bradfitz, khr
CC=golang-dev
https://golang.org/cl/9235046
2013-05-17 13:37:30 +10:00
Carl Shapiro
50ba6e13b4 runtime: fix scanning of not started goroutines
The stack scanner for not started goroutines ignored the arguments
area when its size was unknown.  With this change, the distance
between the stack pointer and the stack base will be used instead.

Fixes #5486

R=golang-dev, bradfitz, iant, dvyukov
CC=golang-dev
https://golang.org/cl/9440043
2013-05-16 10:42:39 -07:00
Adam Langley
21cf646bfc crypto/tls: fix flakey test.
A test added in b37d2fdcc4d9 didn't work with some values of GOMAXPROCS
because the defer statements were in the wrong order: the Pipe could be
closed before the TLS Client was.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/9187047
2013-05-16 12:29:23 -04:00
Alex Brainman
a65f861bfa os: use small buffer when reading from windows console
Fixes #5481.

R=golang-dev, dominik.honnef, bradfitz
CC=golang-dev
https://golang.org/cl/9437044
2013-05-16 17:20:13 +10:00
Brad Fitzpatrick
0af302f507 time: add Time.FormatAppend
This is a version of Time.Format that doesn't require allocation.

Fixes #5192
Update #5195

R=r
CC=gobot, golang-dev
https://golang.org/cl/8478044
2013-05-15 17:23:40 -07:00
Robert Hencke
f7b5a01999 reflect: use visit structure for map key in DeepEqual
R=golang-dev, bradfitz, jonathan, r
CC=golang-dev
https://golang.org/cl/8730044
2013-05-15 14:50:57 -07:00
Dmitriy Vyukov
c6293d2106 runtime: fix GC scanning of slices
If a slice points to an array embedded in a struct,
the whole struct can be incorrectly scanned as the slice buffer.
Fixes #5443.

R=cshapiro, iant, r, cshapiro, minux.ma
CC=bradfitz, gobot, golang-dev
https://golang.org/cl/9372044
2013-05-15 23:50:32 +04:00
Dmitriy Vyukov
915784e11a runtime: add simple malloc benchmarks
Allocs of size 16 can bypass atomic set of the allocated bit, while allocs of size 8 can not.
Allocs with and w/o type info hit different paths inside of malloc.
Current results on linux/amd64:
BenchmarkMalloc8	50000000	        43.6 ns/op
BenchmarkMalloc16	50000000	        46.7 ns/op
BenchmarkMallocTypeInfo8	50000000	        61.3 ns/op
BenchmarkMallocTypeInfo16	50000000	        63.5 ns/op

R=golang-dev, remyoudompheng, minux.ma, bradfitz, iant
CC=golang-dev
https://golang.org/cl/9090045
2013-05-15 21:22:32 +04:00
Keith Randall
ee66972dce runtime: Optimize aeshash a bit. Use a better predicted branch
for checking for page boundary.  Also avoid boundary check
when >=16 bytes are hashed.

benchmark                        old ns/op    new ns/op    delta
BenchmarkHashStringSpeed                23           22   -0.43%
BenchmarkHashBytesSpeed                 44           42   -3.61%
BenchmarkHashStringArraySpeed           71           68   -4.05%

R=iant, khr
CC=gobot, golang-dev, google
https://golang.org/cl/9123046
2013-05-15 09:40:14 -07:00
Dmitriy Vyukov
23ad563119 runtime: transfer whole span from MCentral to MCache
Finer-grained transfers were relevant with per-M caches,
with per-P caches they are not relevant and harmful for performance.
For few small size classes where it makes difference,
it's fine to grab the whole span (4K).

benchmark          old ns/op    new ns/op    delta
BenchmarkMalloc           42           40   -4.45%

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/9374043
2013-05-15 18:35:05 +04:00
Adam Langley
e85e678899 crypto/rsa: check for minimal PKCS#1 v1.5 padding.
The PKCS#1 spec requires that the PS padding in an RSA message be at
least 8 bytes long. We were not previously checking this. This isn't
important in the most common situation (session key encryption), but
the impact is unclear in other cases.

This change enforces the specified minimum size.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/9222045
2013-05-15 10:27:34 -04:00
Adam Langley
a1dbfee15b crypto/tls: ignore empty TLS records.
OpenSSL can be configured to send empty records in order to randomise
the CBC IV. This is an early version of 1/n-1 record splitting (that Go
does) and is quite reasonable, but it results in tls.Conn.Read
returning (0, nil).

This change ignores up to 100 consecutive, empty records to avoid
returning (0, nil) to callers.

Fixes 5309.

R=golang-dev, r, minux.ma
CC=golang-dev
https://golang.org/cl/8852044
2013-05-15 10:25:54 -04:00
Adam Langley
133cdb6707 math/big: save some copies in binaryGCD.
This patch resulted from a bit of quick optimisation in response to a
golang-nuts post. It looks like one could save a couple other copies in
this function, but this addresses the inner loop and is fairly simple.

benchmark                    old ns/op    new ns/op    delta
BenchmarkGCD10x10                 1964         1711  -12.88%
BenchmarkGCD10x100                2019         1736  -14.02%
BenchmarkGCD10x1000               2471         2171  -12.14%
BenchmarkGCD10x10000              6040         5778   -4.34%
BenchmarkGCD10x100000            43204        43025   -0.41%
BenchmarkGCD100x100              11004         8520  -22.57%
BenchmarkGCD100x1000             11820         9446  -20.08%
BenchmarkGCD100x10000            23846        21382  -10.33%
BenchmarkGCD100x100000          133691       131505   -1.64%
BenchmarkGCD1000x1000           120041        95591  -20.37%
BenchmarkGCD1000x10000          136887       113600  -17.01%
BenchmarkGCD1000x100000         295370       273912   -7.26%
BenchmarkGCD10000x10000        2556126      2205198  -13.73%
BenchmarkGCD10000x100000       3159512      2808038  -11.12%
BenchmarkGCD100000x100000    150543094    139986045   -7.01%

R=gri, remyoudompheng
CC=bradfitz, gobot, golang-dev, gri
https://golang.org/cl/9424043
2013-05-15 10:03:22 -04:00
Dmitriy Vyukov
764bb36ea2 runtime: unset m->locks after actual lock unlock
This is needed for preemptive scheduler,
it will preempt only when m->locks==0,
and we do not want to be preempted while
we have not completely unlocked the lock.

R=golang-dev, khr, iant
CC=golang-dev
https://golang.org/cl/9196047
2013-05-15 16:48:41 +04:00
Dmitriy Vyukov
e69012ce2a runtime: use enums instead static vars for debugging
Compiler can detect and delete dead code with enums,
but can not with static vars.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/9377043
2013-05-15 11:10:26 +04:00
Dmitriy Vyukov
5a89b35bca runtime: inline size to class conversion in malloc()
Also change table type from int32[] to int8[] to save space in L1$.

benchmark          old ns/op    new ns/op    delta
BenchmarkMalloc           42           40   -4.68%

R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/9199044
2013-05-15 11:02:33 +04:00
Alexey Borzenkov
fae362e97e os/user: faster user lookup on Windows
Trying to lookup user's display name with directory services can
take several seconds when user's computer is not in a domain.
As a workaround, check if computer is joined in a domain first,
and don't use directory services if it is not.
Additionally, don't leak tokens in user.Current().
Fixes #5298.

R=golang-dev, bradfitz, alex.brainman, lucio.dere
CC=golang-dev
https://golang.org/cl/8541047
2013-05-15 13:24:54 +10:00
Jonathan Hseu
c691ae6764 testing/quick: fix for aliased types, delete duplicate uint8 test, and fix randFloat64() to give random numbers from (-math.MaxFloat64, math.MaxFloat64).
R=r, agl
CC=agl, bradfitz, golang-dev
https://golang.org/cl/9296046
2013-05-14 17:14:59 -07:00
Carl Shapiro
0e6007e4f9 runtime: enable stack scanning by frames
Update #5134

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/9406046
2013-05-14 16:38:12 -07:00
Brad Fitzpatrick
0bbf0ec0ed database/sql: use method values instead of generating closures
Reduces garbage.

R=adg, r
CC=dsymonds, gobot, golang-dev
https://golang.org/cl/9088045
2013-05-14 16:35:31 -07:00
Rémy Oudompheng
6c4943cb51 cmd/gc: fix race instrumentation of selectors T(v).Field
Fixes #5424.

R=golang-dev, daniel.morsing, dvyukov, r
CC=golang-dev
https://golang.org/cl/9033048
2013-05-15 01:25:20 +02:00
Keith Randall
b3946dc119 runtime/bytes: fast Compare for byte arrays and strings.
Uses SSE instructions to process 16 bytes at a time.

fixes #5354

R=bradfitz, google
CC=golang-dev
https://golang.org/cl/8853048
2013-05-14 16:05:51 -07:00
Brad Fitzpatrick
f1583bb956 encoding/json: allocate less in NewEncoder
The *Encoder is almost always garbage. It doesn't need an
encodeState inside of it (and its bytes.Buffer), since it's
only needed locally inside of Encode.

benchmark                 old ns/op    new ns/op    delta
BenchmarkEncoderEncode         2562         2553   -0.35%

benchmark                 old bytes    new bytes    delta
BenchmarkEncoderEncode          283          102  -63.96%

R=r
CC=gobot, golang-dev
https://golang.org/cl/9365044
2013-05-14 15:50:46 -07:00
Alberto García Hierro
d535bc7af3 net/http: Fix basic authentication with empty password
The encoded string must include the : separating the username
        and the password, even when the latter is empty. See
        http://www.ietf.org/rfc/rfc2617.txt for more information.

R=golang-dev, bradfitz, adg
CC=golang-dev
https://golang.org/cl/8475043
2013-05-14 15:33:46 -07:00
Shenghou Ma
9c94580921 archive/tar: skip NUL-filled unused octal fields
Fixes #5290.

R=golang-dev, dave, bradfitz, r
CC=golang-dev
https://golang.org/cl/8763044
2013-05-15 04:40:42 +08:00
Robin Eklind
392cebea5d image: minor update of comments.
R=golang-dev, iant, bradfitz, nigeltao
CC=golang-dev
https://golang.org/cl/9408044
2013-05-14 13:28:16 -07:00
Brad Fitzpatrick
67acff0b09 go/token: let FileSet.AddFile take a negative base
Negative base now means "automatic". Fixes a higher
level race.

Fixes #5418

R=gri
CC=golang-dev
https://golang.org/cl/9269043
2013-05-14 09:30:13 -07:00
Dmitriy Vyukov
5a7e14c143 runtime/race: improve public documentation
Move the documentation from race.go to doc.go, because
race.go uses +build race, so it's not normally parsed by go doc.
Rephrase the documentation for end users, provide link to race
detector manual.
Fixes #5444.

R=golang-dev, minux.ma, adg, r
CC=golang-dev
https://golang.org/cl/9144050
2013-05-13 10:28:12 +04:00
Ian Lance Taylor
26d95d8027 runtime: fix crash in select
runtime.park() can access freed select descriptor
due to a racing free in another thread.
See the comment for details.

Slightly modified version of dvyukov's CL 9259045.

No test yet.  Before this CL, the test described in issue 5422
would fail about every 40 times for me.  With this CL, I ran
the test 5900 times with no failures.

Fixes #5422.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9311043
2013-05-08 14:58:34 -07:00
Alex Brainman
e1922febbe net: fix dial race on plan9 and windows
Fixes #5349.

R=golang-dev, lucio.dere, dsymonds, bradfitz, iant, adg, dave, r
CC=golang-dev
https://golang.org/cl/9159043
2013-05-08 16:19:02 +10:00
Dmitriy Vyukov
f322c78692 runtime: fix crash in badsignal()
The linker can generate split stack prolog when a textflag 7 function
makes an indirect function call.  If it happens, badsignal() crashes
trying to dereference g.
Fixes #5337.

R=bradfitz, dave, adg, iant, r, minux.ma
CC=adonovan, golang-dev
https://golang.org/cl/9226043
2013-05-06 16:15:03 -07:00
Shenghou Ma
b3b1efd882 runtime: reduce max arena size on windows/amd64 to 32 GiB
Update #5236
Update #5402
This CL reduces gofmt's committed memory from 545864 KiB to 139568 KiB.
Note: Go 1.0.3 uses about 70MiB.

R=golang-dev, r, iant, nightlyone
CC=golang-dev
https://golang.org/cl/9245043
2013-05-07 06:53:02 +08:00
Brad Fitzpatrick
e85016f81f database/sql: remove an unused field from Rows
Found while debugging memory usage. Nobody accesses this field
anymore.

R=golang-dev, i.caught.air, adg, r
CC=golang-dev
https://golang.org/cl/9108043
2013-05-06 15:16:47 -07:00
Shenghou Ma
6de184b385 syscall: fix prototype of Fchflags (API change)
API change, but the old API is obviously wrong.

R=golang-dev, iant, r, rsc
CC=golang-dev
https://golang.org/cl/9157044
2013-05-07 05:20:00 +08:00
Jeremiah Harmsen
a228e733b9 go/doc/example: Fix bug causing false negatives for Example playability.
Allows Examples with KeyValue expressions to be playable in godoc.

During the traversal of the abstract syntax tree any KeyValueExpr Key.Name was incorrectly being added as an unresolved identifier.
Since this identifier could not be provided the Example was marked as unplayable.
This updates the AST traversal to skip Keys (but continue traversing the Values).

Example of problematic AST now fixed (see L99 where "UpperBound" was being added as a missing identifier):

 81  .  .  .  .  .  .  .  .  .  Values: []ast.Expr (len = 1) {
 82  .  .  .  .  .  .  .  .  .  .  0: *ast.UnaryExpr {
 83  .  .  .  .  .  .  .  .  .  .  .  OpPos: 12:19
 84  .  .  .  .  .  .  .  .  .  .  .  Op: &
 85  .  .  .  .  .  .  .  .  .  .  .  X: *ast.CompositeLit {
 86  .  .  .  .  .  .  .  .  .  .  .  .  Type: *ast.SelectorExpr {
 87  .  .  .  .  .  .  .  .  .  .  .  .  .  X: *ast.Ident {
 88  .  .  .  .  .  .  .  .  .  .  .  .  .  .  NamePos: 12:20
 89  .  .  .  .  .  .  .  .  .  .  .  .  .  .  Name: "t_proto"
 90  .  .  .  .  .  .  .  .  .  .  .  .  .  }
 91  .  .  .  .  .  .  .  .  .  .  .  .  .  Sel: *ast.Ident {
 92  .  .  .  .  .  .  .  .  .  .  .  .  .  .  NamePos: 12:41
 93  .  .  .  .  .  .  .  .  .  .  .  .  .  .  Name: "BConfig"
 94  .  .  .  .  .  .  .  .  .  .  .  .  .  }
 95  .  .  .  .  .  .  .  .  .  .  .  .  }
 96  .  .  .  .  .  .  .  .  .  .  .  .  Lbrace: 12:79
 97  .  .  .  .  .  .  .  .  .  .  .  .  Elts: []ast.Expr (len = 2) {
 98  .  .  .  .  .  .  .  .  .  .  .  .  .  0: *ast.KeyValueExpr {
 99  .  .  .  .  .  .  .  .  .  .  .  .  .  .  Key: *ast.Ident {
100  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  NamePos: 13:3
101  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  Name: "UpperBound"
102  .  .  .  .  .  .  .  .  .  .  .  .  .  .  }
103  .  .  .  .  .  .  .  .  .  .  .  .  .  .  Colon: 13:13
104  .  .  .  .  .  .  .  .  .  .  .  .  .  .  Value: *ast.CallExpr {
105  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  Fun: *ast.SelectorExpr {
106  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  X: *ast.Ident {
107  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  NamePos: 13:15
108  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  Name: "proto"
109  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  }
110  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  Sel: *ast.Ident {
111  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  NamePos: 13:21
112  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  Name: "Float32"
113  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  }

R=adg
CC=gobot, golang-dev, gri
https://golang.org/cl/8569045
2013-05-06 10:15:16 -07:00
Brad Fitzpatrick
1294f14f1f image/png: fix error message to not return width twice
Fixes #5413

R=golang-dev, dave, adg
CC=golang-dev
https://golang.org/cl/9153045
2013-05-06 09:59:33 -07:00
Shenghou Ma
a21b36da1c go/build: document GOOS.go also has implicit GOOS build constraint
R=golang-dev, i.caught.air, alexb, r
CC=golang-dev
https://golang.org/cl/9064044
2013-05-05 02:23:19 +08:00
Keith Randall
4ff48c7f45 text/template: comment fix
R=golang-dev, minux.ma, r
CC=golang-dev
https://golang.org/cl/9086043
2013-05-03 14:22:34 -07:00
Shenghou Ma
988236ba86 runtime/cgo: fix build for ARM
TBR=iant
CC=golang-dev
https://golang.org/cl/9048048
2013-05-03 17:15:43 +08:00
Shenghou Ma
e0db7fae87 cmd/ld: add .note.GNU-stack section for external linking
Fixes #5392.

R=iant, r
CC=golang-dev
https://golang.org/cl/9119043
2013-05-03 16:33:21 +08:00
Brad Fitzpatrick
7cc0581f86 regexp: doc fix
This must have been from when "error" was a good variable
name for an "os.Error". But we use "err" these days.

R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/9132045
2013-05-02 18:59:39 -07:00
Ian Lance Taylor
9de38d6788 runtime/cgo: export symbols in both internal and external link mode
R=rsc, r
CC=golang-dev
https://golang.org/cl/9060045
2013-05-01 14:30:51 -07:00
Alex Brainman
ca6b1f3eeb net: do not call syscall.Bind twice on windows
Fixes #5355.

R=golang-dev, mikioh.mikioh, bradfitz, r
CC=golang-dev
https://golang.org/cl/8966046
2013-04-30 17:47:39 -07:00
Rob Pike
b461c94cfa os/exec: disable TestExtraFilesFDShuffle
It's too hard to make portable just now.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/9057043
2013-04-30 13:17:37 -07:00
Cosmos Nicolaou
b493f0a868 syscall: fix a bug in the shuffling of file descriptors in StartProcess on Linux.
R=iant, iant, r, bradfitz
CC=golang-dev
https://golang.org/cl/8334044
2013-04-30 11:52:23 -07:00
Rob Pike
479b1241b5 syscall: fix exec_bsd.go to accompany exec_linux.go changes
exec_plan9.go too.
Those are in CL 8334044

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/9055043
2013-04-30 11:52:15 -07:00
Shenghou Ma
5c20a4f260 encoding/json: document that marshaling invalid utf-8 sequence will return error
Also added docs for InvalidUTF8Error.
Fixes #5360.

R=golang-dev, adg, r
CC=golang-dev
https://golang.org/cl/8926046
2013-04-30 11:21:48 +08:00
Rob Pike
b42c8294eb fmt: fix crash for Printf("%.", 3)
Fixes #5311

R=golang-dev, bradfitz, iant
CC=golang-dev
https://golang.org/cl/8961050
2013-04-29 13:52:07 -07:00
Shenghou Ma
5b78cee376 runtime: fix stack pointer corruption in runtime.cgocallback_gofunc()
runtime.setmg() calls another function (cgo_save_gm), so it must save
LR onto stack.
Re-enabled TestCthread test in misc/cgo/test.

Fixes #4863.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9019043
2013-04-30 04:13:32 +08:00
Ian Lance Taylor
806dea82d4 fmt: document that if String or Error panics, that value is printed
Fixes #5350.

R=r, minux.ma
CC=golang-dev
https://golang.org/cl/8950043
2013-04-29 12:01:32 -07:00
Andrew Gerrand
13721cf688 net/http/httptest: fix incorrectly-named ResponseRecorder example
R=golang-dev, minux.ma, r
CC=golang-dev
https://golang.org/cl/8545047
2013-04-29 17:34:47 +02:00
Brad Fitzpatrick
e9546a01dc math/rand: fix typo and add better crash message
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9000043
2013-04-27 18:50:38 -07:00
Dave Cheney
d09f34cc55 runtime: tune appendCrossover for arm
Turns out the optimal value is 8 on cortex-A9 systems (pandaboard)

benchmark                     old ns/op    new ns/op    delta
BenchmarkAppend                     907          908   +0.11%
BenchmarkAppend1Byte                101          101   +0.00%
BenchmarkAppend4Bytes               116          116   +0.00%
BenchmarkAppend8Bytes               139          138   -0.72%
BenchmarkAppend16Bytes              185          158  -14.59%
BenchmarkAppend32Bytes              131          131   +0.00%
BenchmarkAppendStr1Byte              72           72   +0.00%
BenchmarkAppendStr4Bytes             93           93   -0.21%
BenchmarkAppendStr8Bytes            116          116   +0.00%
BenchmarkAppendStr16Bytes           161          125  -22.36%
BenchmarkAppendStr32Bytes           102          102   +0.00%
BenchmarkAppendSpecialCase          613          613   +0.00%

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/8863045
2013-04-28 00:18:11 +10:00
Brad Fitzpatrick
3cef6979ee database/sql/driver: try to unstutter Value docs
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/8981043
2013-04-26 11:42:58 -07:00
Dmitriy Vyukov
489addd250 time: stop 1ns timer in test
R=golang-dev, adg, r
CC=golang-dev
https://golang.org/cl/8819046
2013-04-26 11:08:50 +04:00
Brad Fitzpatrick
277047f52a database/sql: fix driver Conn refcounting with prepared statements
The refcounting of driver Conns was completedly busted and
would leak (be held open forever) with any reasonable
load. This was a significant regression from Go 1.0.

The core of this patch is removing one line:

     s.db.addDep(dc, s)

A database conn (dc) is a resource that be re-created any time
(but cached for speed) should not be held open forever with a
dependency refcount just because the Stmt (s) is alive (which
typically last for long periods of time, like forever).

The meat of the patch is new tests. In fixing the real issue,
a lot of tests then failed due to the fakedb_test.go's paranoia
about closing a fakeConn while it has open fakeStmts on it. I
could've ignored that, but that's been a problem in the past for
other bugs.

Instead, I now track per-Conn open statements and close them
when the the conn closes.  The proper way to do this would've
been making *driverStmt a finalCloser and using the dep mechanism,
but it was much more invasive. Added a TODO instead.

I'd like to give a way for drivers to opt-out of caring about
driver.Stmt closes before a driver.Conn close, but that's a TODO
for the future, and that TODO is added in this CL.

I know this is very late for Go 1.1, but database/sql is
currently nearly useless without this.

I'd like to believe all these database/sql bugs in the past
release cycle are the result of increased usage, number of
drivers, and good feedback from increasingly-capable Go
developers, and not the result of me sucking.  It's also hard
with all the real drivers being out-of-tree, so I'm having to
add more and more hooks to fakedb_test.go to simulate things
which real drivers end up doing.

Fixes #5323

R=golang-dev, snaury, gwenn.kahz, google, r
CC=golang-dev
https://golang.org/cl/8836045
2013-04-25 14:45:56 -07:00
Jan Ziak
db1c218d4f undo CL 8954044 / ad3c2ffb16d7
It works on i386, but fails on amd64 and arm.

««« original CL description
runtime: prevent the GC from seeing the content of a frame in runfinq()

Fixes #5348.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/8954044
»»»

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/8695051
2013-04-25 18:12:09 +02:00
Jan Ziak
e9bbe3a8da runtime: prevent the GC from seeing the content of a frame in runfinq()
Fixes #5348.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/8954044
2013-04-25 13:39:09 +02:00
Mikio Hara
2bd17bca07 net: deflake raw IP protocol entry test on Windows
Update #5344

R=golang-dev, dave, r, alex.brainman
CC=golang-dev
https://golang.org/cl/8934043
2013-04-25 13:23:24 +09:00
Mikio Hara
73417e4098 net: add missing File method document
R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/8698049
2013-04-24 08:32:11 +09:00
Shenghou Ma
7bec1a6033 all: fix typos
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/8896045
2013-04-24 04:46:14 +08:00