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

8939 Commits

Author SHA1 Message Date
Russ Cox
382738af51 net: defend against broken getaddrinfo on Linux
getaddrinfo is supposed to set errno when it returns
EAI_SYSTEM, but sometimes it does not.

Fixes #6232.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13532045
2013-09-11 11:38:56 -04:00
Russ Cox
397ba2cb4a cmd/cgo: replace C.malloc with our own wrapper
This allows us to make two changes:

1. Force the argument type to be size_t, even on broken
   systems that declare malloc to take a ulong.

2. Call runtime.throw if malloc fails.
   (That is, the program crashes; it does not panic.)

Fixes #3403.
Fixes #5926.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13413047
2013-09-11 11:30:08 -04:00
Mikio Hara
89b26760d7 net: implement TCP connection setup with fast failover
This CL adds minimal support of Happy Eyeballs-like TCP connection
setup to Dialer API. Happy Eyeballs and derivation techniques are
described in the following:

- Happy Eyeballs: Success with Dual-Stack Hosts
  http://tools.ietf.org/html/rfc6555

- Analysing Dual Stack Behaviour and IPv6 Quality
  http://www.potaroo.net/presentations/2012-04-17-dual-stack-quality.pdf

Usually, the techniques consist of three components below.

- DNS query racers, that run A and AAAA queries in parallel or series
- A short list of destination addresses
- TCP SYN racers, that run IPv4 and IPv6 transport in parallel or series

This CL implements only the latter two. The existing DNS query
component gathers together A and AAAA records in series, so we don't
touch it here. This CL just uses extended resolveInternetAddr and makes
it possible to run multiple Dial racers in parallel.

For example, when the given destination is a DNS name and the name has
multiple address family A and AAAA records, and it happens on the TCP
wildcard network "tcp" with DualStack=true like the following:

(&net.Dialer{DualStack: true}).Dial("tcp", "www.example.com:80")

The function will return a first established connection either TCP over
IPv4 or TCP over IPv6, and close the other connection internally.

Fixes #3610.
Fixes #5267.

Benchmark results on freebsd/amd64 virtual machine, tip vs. tip+12416043:

benchmark                           old ns/op    new ns/op    delta
BenchmarkTCP4OneShot                    50696        52141   +2.85%
BenchmarkTCP4OneShotTimeout             65775        66426   +0.99%
BenchmarkTCP4Persistent                 10986        10457   -4.82%
BenchmarkTCP4PersistentTimeout          11207        10445   -6.80%
BenchmarkTCP6OneShot                    62009        63718   +2.76%
BenchmarkTCP6OneShotTimeout             78351        79138   +1.00%
BenchmarkTCP6Persistent                 14695        14659   -0.24%
BenchmarkTCP6PersistentTimeout          15032        14646   -2.57%
BenchmarkTCP4ConcurrentReadWrite         7215         6217  -13.83%
BenchmarkTCP6ConcurrentReadWrite         7528         7493   -0.46%

benchmark                          old allocs   new allocs    delta
BenchmarkTCP4OneShot                       36           36    0.00%
BenchmarkTCP4OneShotTimeout                36           36    0.00%
BenchmarkTCP4Persistent                     0            0     n/a%
BenchmarkTCP4PersistentTimeout              0            0     n/a%
BenchmarkTCP6OneShot                       37           37    0.00%
BenchmarkTCP6OneShotTimeout                37           37    0.00%
BenchmarkTCP6Persistent                     0            0     n/a%
BenchmarkTCP6PersistentTimeout              0            0     n/a%
BenchmarkTCP4ConcurrentReadWrite            0            0     n/a%
BenchmarkTCP6ConcurrentReadWrite            0            0     n/a%

benchmark                           old bytes    new bytes    delta
BenchmarkTCP4OneShot                     2500         2503    0.12%
BenchmarkTCP4OneShotTimeout              2508         2505   -0.12%
BenchmarkTCP4Persistent                     0            0     n/a%
BenchmarkTCP4PersistentTimeout              0            0     n/a%
BenchmarkTCP6OneShot                     2713         2707   -0.22%
BenchmarkTCP6OneShotTimeout              2722         2720   -0.07%
BenchmarkTCP6Persistent                     0            0     n/a%
BenchmarkTCP6PersistentTimeout              0            0     n/a%
BenchmarkTCP4ConcurrentReadWrite            0            0     n/a%
BenchmarkTCP6ConcurrentReadWrite            0            0     n/a%

R=golang-dev, bradfitz, nightlyone, rsc
CC=golang-dev
https://golang.org/cl/12416043
2013-09-11 10:48:53 -04:00
Dave Cheney
3ee0744c06 bytes: additional test coverage
Add coverage for some uncovered bytes methods. The increase in actual coverage is disapointing small.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13651044
2013-09-11 21:20:15 +10:00
Russ Cox
6706931a71 go/doc: restore handling of multi-paragraph BUG comments
It was lost when the generic "Notes" support went in.

Had to change the test setup, because it precluded even
being able test multi-line comments, much less multi-paragraph
comments.

Now 'godoc sync/atomic' works correctly again.

Fixes #6135.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13427045
2013-09-10 14:41:20 -04:00
Russ Cox
d5fbad0de8 cmd/go: better error for shadowed directories in GOPATH
Fixes #5774.

R=golang-dev, adg, r, bradfitz
CC=golang-dev
https://golang.org/cl/9164043
2013-09-10 13:17:21 -04:00
Alexis Imperial-Legrand
927b7ac327 runtime: explicit init of runtime-gdb helpers
If using other gdb python scripts loaded before Go's gdb-runtime.py
and that have a different init prototype:
Traceback (most recent call last):
  File "/usr/lib/go/src/pkg/runtime/runtime-gdb.py", line 446, in <module>
    k()
TypeError: __init__() takes exactly 3 arguments (1 given)

The problem is that gdb keeps all python scripts in the same namespace,
so vars() contains them. To avoid that, load helpers one by one.

R=iant, rsc
CC=gobot, golang-dev
https://golang.org/cl/9752044
2013-09-10 13:00:08 -04:00
Russ Cox
c971f95c10 go/build: allow $ in cgo LDFLAGS
Fixes #6038.

R=iant
CC=golang-dev
https://golang.org/cl/13649043
2013-09-10 12:47:43 -04:00
Keith Randall
4487054751 runtime: clean up / align comment tabbing
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13336046
2013-09-10 09:02:22 -07:00
Mikio Hara
02faa939d3 net: remove dreg of obsoleted network poller
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/13396051
2013-09-10 20:00:21 +09:00
Alex Brainman
a6149da08a os/exec: change windows LookPath so it works like cmd.exe
Fixes #6224

R=golang-dev, hcwfrichter, bradfitz
CC=golang-dev
https://golang.org/cl/13410045
2013-09-10 14:50:29 +10:00
Russ Cox
5d2c3a687c encoding/json: document actual behavior for Unmarshal into interface{}
Fixes #4900.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13400044
2013-09-09 19:11:05 -04:00
Richard Eric Gavaletz
7adb42eee4 container/list: unexpected panic if Next/Prev called outside of list.
Before CL 7065067 calling Next on an element returned either the
next/prev element or nil was returned.  After the CL if an element
was not part of a list e.Next() and e.Prev() will panic.  This CL
returns to the documented behavior, that Next/Prev returns the
next/prev list element or nil.

Fixes #6349.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/13234051
2013-09-09 15:41:36 -07:00
Russ Cox
5dc8c4dbfb path/filepath: fix race with other tests
Bug3486 tried to walk the entire file tree, but other tests might
be creating and removing files in that tree. In particular, package os
creates and removes files in the os directory, and issue 5863
reports failures due to seeing those files appear and then disappear.

Change the test to walk just the test tree, which should not be
changing.

Fixes #5863.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13467045
2013-09-09 16:42:18 -04:00
Russ Cox
10c36fbc9d encoding/xml: fix panic in Marshal
Fixes #6341.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13512048
2013-09-09 16:42:07 -04:00
Russ Cox
1b651556c3 syslog: fix data race on 'crashy' in test function
Fixes #5894.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13303051
2013-09-09 16:17:59 -04:00
Russ Cox
87a6d75012 log/syslog: use alternate format for logging to local syslog daemon
Fixes #5803.
Is it correct behavior? Who knows.

R=golang-dev, bradfitz, jgc
CC=golang-dev, jgc
https://golang.org/cl/13248048
2013-09-09 16:17:44 -04:00
Russ Cox
6252b41981 runtime: remove OABI check from ARM startup
The code in question is trying to print a nice error message
when a Go EABI binary runs on an OABI machine.
Unfortunately, the only way to do that is to use
ARM Thumb instructions, which we otherwise don't use.

There exist ARM EABI machines that do not support Thumb.
We could run on them if not for this OABI check, so disable it.

Fixes #5685.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/13234050
2013-09-09 15:06:05 -04:00
Joel Sing
3b089179c4 runtime: unbreak build on dragonfly
Update dragonfly memory functions to work with new memory statistics.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13615043
2013-09-09 08:48:06 -07:00
Alex Brainman
5f75314e18 time: allow more time for TestOverflowRuntimeTimer to succeed
Attempting to fix windows gobuilders

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13507044
2013-09-09 15:50:11 +10:00
Dominik Honnef
a789ae9e8e compress/flate: small documentation fix
R=golang-dev, adg
CC=bradfitz, golang-dev, remyoudompheng
https://golang.org/cl/13568045
2013-09-09 09:37:05 +10:00
Robert Daniel Kortschak
c01945afc9 sort: fix up example expected output formatting
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13426046
2013-09-08 13:21:03 +10:00
Andriy Lytvynov
467122ce0b sort: add a simpler sort.Interface example
Existing example renamed to Example_sortWrapper.
Fixes #6335.

R=golang-dev, rsc, taj.khattra, r
CC=golang-dev
https://golang.org/cl/13586043
2013-09-08 11:17:23 +10:00
Keith Randall
78338d8c66 runtime: Smhasher tests of our map hash function.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13436045
2013-09-06 16:23:46 -07:00
Brad Fitzpatrick
da7a51d16b net: don't error when marshalling nil IP addresses
See https://code.google.com/p/go/issues/detail?id=6339#c3

Fixes #6339

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13553044
2013-09-06 15:29:09 -07:00
Ehren Kret
3b6b53f493 compress/flate: prevent panic when reinitializing huffmanDecoder with bad input
The huffmanDecoder struct appears to be intented for reuse by calling init a
second time with a second sequence of code lengths. Unfortunately, it can
currently panic if the second sequence of code lengths has a minimum value
greater than 10 due to failure to reinitialize the links table.

This change prevents the panic by resetting the huffmanDecoder struct back to
the struct's zero value at the beginning of the init method if the
huffmanDecoder is being reused (determined by checking if min has been set to a
non-zero value).

Fixes #6255.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13230043
2013-09-06 15:09:42 -07:00
Dmitriy Vyukov
a33ef8d11b runtime: account for all sys memory in MemStats
Currently lots of sys allocations are not accounted in any of XxxSys,
including GC bitmap, spans table, GC roots blocks, GC finalizer blocks,
iface table, netpoll descriptors and more. Up to ~20% can unaccounted.
This change introduces 2 new stats: GCSys and OtherSys for GC metadata
and all other misc allocations, respectively.
Also ensures that all XxxSys indeed sum up to Sys. All sys memory allocation
functions require the stat for accounting, so that it's impossible to miss something.
Also fix updating of mcache_sys/inuse, they were not updated after deallocation.

test/bench/garbage/parser before:
Sys		670064344
HeapSys		610271232
StackSys	65536
MSpanSys	14204928
MCacheSys	16384
BuckHashSys	1439992

after:
Sys		670064344
HeapSys		610271232
StackSys	65536
MSpanSys	14188544
MCacheSys	16384
BuckHashSys	3194304
GCSys		39198688
OtherSys	3129656

Fixes #5799.

R=rsc, dave, alex.brainman
CC=golang-dev
https://golang.org/cl/12946043
2013-09-06 16:55:40 -04:00
Marco Hennings
4e998d71c9 archive/tar: fix a case where USTAR-split is not working correctly.
For some long filenames the USTAR-split code does not work
correctly. It is wrongly assumed that the path would not be too long,
but it is.

The user visible result was that a filename was split, but it still
caused an error.

The cause was a wrongly calculated nlen. In addition I noticed that
at this place it is also seems necessary to check if the prefix will
fit in the 155 chars available for the prefix.

R=dsymonds, rsc
CC=golang-dev
https://golang.org/cl/13300046
2013-09-06 16:49:38 -04:00
Andriy Lytvynov
fb25a61872 sort: fix Example_sortMultiKeys
Old example referenced global var from multiSorter.Sort and ignored it's argument.
Changed one of example calls to actually pass slice to sort.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13551044
2013-09-06 16:49:34 -04:00
Josh Bleecher Snyder
08925ce6ee cmd/gofmt: sort more, remove some duplicate imports
* Sort imports by import path, then import name, then comment. Currently, gofmt sorts only by import path.
* If two imports have the same import path and import name, and one of them has no comment, remove the import with no comment. (See the discussion at issue 4414.)

Based on @rsc's https://golang.org/cl/7231070/

Fixes #4414.

R=gri, rsc
CC=golang-dev
https://golang.org/cl/12837044
2013-09-06 16:25:15 -04:00
Anthony Martin
3548ab5ebb runtime: handle timer overflow in tsleep
Make sure we never pass a timer into timerproc with
a negative duration since it will cause other timers
to never expire.

Fixes #5321.

R=golang-dev, minux.ma, remyoudompheng, mikioh.mikioh, r, bradfitz, rsc, dvyukov
CC=golang-dev
https://golang.org/cl/9035047
2013-09-06 15:47:39 -04:00
Brad Fitzpatrick
da50221e8e reflect: unexport BUCKETSIZE, MAXKEYSIZE, MAXVALSIZE
But keep their case for ease of searching.

They were added recently. We don't want them part of go1.2's API.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13569044
2013-09-06 12:00:42 -07:00
Brad Fitzpatrick
c327e82ddb crypto/rand: make Read use io.ReadFull
Fixes #6084

R=golang-dev, rsc, dave
CC=golang-dev
https://golang.org/cl/13523044
2013-09-06 12:00:27 -07:00
Kamil Kisiel
a3834a2e8a net: Fix inaccurate docs for AcceptTCP and AcceptUnix.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13592043
2013-09-06 12:00:03 -07:00
Rob Pike
46f96079df undo CL 13004046 / 5db14b33d6ef
Flushing after every token negates the point of buffering. A different approach is required.

««« original CL description
encoding/xml: flush buffer after encoding token

R=rsc, bradfitz, adg
CC=golang-dev
https://golang.org/cl/13004046

»»»

R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/13515043
2013-09-06 07:54:43 +10:00
Rémy Oudompheng
86c0cf10cb compress/zlib: add Reset method to Writer.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13171046
2013-09-05 21:50:47 +02:00
Rémy Oudompheng
780f5b714d reflect: do not cache trivial values in DeepEqual.
DeepEqual caches addresses of compared values
each time it visits addressable values. This is
more expensive than actually comparing them in
the common case of large slices of bytes or integers.

Also add a fast path for slices with identical
underlying array.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13000044
2013-09-05 21:37:07 +02:00
Brad Fitzpatrick
fca660892d compress/flate: use bytes.NewReader instead of NewBuffer in test
Also, report allocations in benchmark.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13410044
2013-09-04 15:31:46 -07:00
Rob Pike
80f39f7b73 html/template: export the parse.Tree for the escaped template
The underlying parse tree is visible in text/template, so it should be visible here.
Done by copying the underlying *parse.Tree up to the top level of the struct, and then making sure it's kept up to date.
Fixes #6318.

R=mikesamuel
CC=golang-dev
https://golang.org/cl/13479044
2013-09-05 08:23:11 +10:00
Aulus Egnatius Varialus
2b44b36487 cgo: enable cgo on dragonfly
Enable cgo for dragonfly/386 and dragonfly/amd64.

R=golang-dev, jsing, iant, bradfitz
CC=golang-dev
https://golang.org/cl/13247046
2013-09-04 15:19:21 -07:00
Rob Pike
0ba7ffe289 text/template: allow eq to take more than two arguments
Based on an old suggestion by rsc, it compares the second
and following arguments to the first.

Unfortunately the code cannot be as pretty as rsc's original
because it doesn't require identical types.

R=golang-dev, dsymonds, adg
CC=golang-dev
https://golang.org/cl/13509046
2013-09-04 13:42:22 +10:00
Mikio Hara
54b2a83d9a net/http: remove dreg of obsoleted network poller
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13261049
2013-09-04 10:04:12 +09:00
Brad Fitzpatrick
8272c14f7e net/http: sniff less
We were reading 1024 bytes but only using 512.

Fixes #6311

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13289047
2013-09-03 09:11:25 -07:00
Mikio Hara
c576bcbad5 net: fix TestFirstFavoriteAddr failure on single IP stack kernel
Update #3610
Update #5267
Update #5707

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/13465043
2013-09-02 16:44:51 +09:00
Keith Randall
23f9751e83 runtime: clean up map code. Remove hashmap.h.
Use cnew/cnewarray instead of mallocgc.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/13396045
2013-08-31 14:09:34 -07:00
Joel Sing
465ba6b78c runtime, syscall: add support for dragonfly/386
Add runtime and syscall support for dragonfly/386.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13237051
2013-08-31 09:32:07 -07:00
Joel Sing
f6f02a69ae syscall: z* files for dragonfly/386
Add generated z* files for dragonfly/386.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13303046
2013-08-31 09:29:38 -07:00
Keith Randall
fb376021be runtime: record type information for hashtable internal structures.
Remove all hashtable-specific GC code.

Fixes bug 6119.

R=cshapiro, dvyukov, khr
CC=golang-dev
https://golang.org/cl/13078044
2013-08-31 09:09:50 -07:00
Mikio Hara
29de03adf3 net: keep lookup IP stuff close
Also flattens import declaration.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/13373046
2013-08-31 16:29:50 +09:00
Mikio Hara
7c59c8bdee net: make resolveInternetAddr return a list of addresses
This CL makes resolveInternetAddr return a list of addresses that
contain a pair of different address family IP addresses if possible,
but doesn't contain any API behavioral changes yet. A simple IP
address selection mechanism for Resolve{TCP,UDP,IP}Addr and Dial API
still prefers IPv4.

This is in preparation for TCP connection setup with fast failover on
dual IP stack node as described in RFC 6555.

Update #3610
Update #5267

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13374043
2013-08-31 10:28:49 +09:00
Brad Fitzpatrick
db12f9d4e4 compress/gzip: add Writer.Reset
compress/flate is https://golang.org/cl/12953048
compress/zlib is https://golang.org/cl/13171046

Update #6138

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13435043
2013-08-30 11:41:12 -07:00
Tad Glines
41c5d8d85f database/sql: add SetMaxOpenConns
Update #4805

Add the ability to set an open connection limit.
Fixed case where the Conn finalCloser was being called with db.mu locked.
Added separate benchmarks for each path for Exec and Query.
Replaced slice based idle pool with list based idle pool.

R=bradfitz
CC=golang-dev
https://golang.org/cl/10726044
2013-08-30 09:27:33 -07:00
Adam Langley
87404c9887 crypto/x509: expose arbitary X.509 extensions.
This change allows people who want to parse or set odd X.509 extensions
to do so without having to add support for them all to the package.

I tried to make it so that only a single member: Extensions would be
needed. However, that would mean detecting when the caller had altered
the contents of it so that parsing and marshaling a certificate
wouldn't ignore all changes to the other members. This ended up being
messy, thus the current design where there are two members: one for
reading and another for writing.

As crypto/x509 adds support for more extensions in the future, the raw
extensions will still be in Extensions for older code that expects it
there. Also, future extensions will be overridden by any raw extensions
added to ExtraExtensions by code that was written before support was
added.

R=golang-dev, r
CC=golang-dev, jpsugar
https://golang.org/cl/12056043
2013-08-30 10:14:45 -04:00
Nigel Tao
2df3d80037 go/build: fix deps_test for Plan 9's os/user dependencies and to
include the new image/color/palette package.

R=r
CC=golang-dev
https://golang.org/cl/13314044
2013-08-30 17:12:42 +10:00
Nigel Tao
aeb8b45866 image/color/palette: move Plan9Palette and WebSafePalette out of the
image/color package into their own package. They require some non-
trivial init-time code (interface conversions, currently 40KiB of text)
that would otherwise burden any Go program that imported image/color.

R=r
CC=golang-dev
https://golang.org/cl/13256046
2013-08-30 16:03:16 +10:00
Mikio Hara
20692c22d7 net: add addrList
This CL adds a new type addrList that will carry a short list of IP
addresses to dial helper functions in the upcoming CLs.

This is in preparation for TCP connection setup with fast failover on
dual IP stack node as described in RFC 6555.

Update #3610
Update #5267

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13241046
2013-08-30 09:28:26 +09:00
Brad Fitzpatrick
9456adb36b undo CL 10726044 / c9bea548fb6f
Breaks build, and has a race.

««« original CL description
database/sql: add SetMaxOpenConns

Update #4805

Add the ability to set an open connection limit.
Fixed case where the Conn finalCloser was being called with db.mu locked.
Added seperate benchmarks for each path for Exec and Query.
Replaced slice based idle pool with list based idle pool.

R=bradfitz
CC=golang-dev
https://golang.org/cl/10726044

»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/13252046
2013-08-29 17:26:00 -07:00
Tad Glines
4572e48483 database/sql: add SetMaxOpenConns
Update #4805

Add the ability to set an open connection limit.
Fixed case where the Conn finalCloser was being called with db.mu locked.
Added seperate benchmarks for each path for Exec and Query.
Replaced slice based idle pool with list based idle pool.

R=bradfitz
CC=golang-dev
https://golang.org/cl/10726044
2013-08-29 17:20:39 -07:00
Mikio Hara
3c6558ad90 net: add netaddr interface
This CL adds the netaddr interface that will carry a single network
endpoint address or a short list of IP addresses to dial helper
functions in the upcoming CLs.

This is in preparation for TCP connection setup with fast failover on
dual IP stack node as described in RFC 6555.

Update #3610
Update #5267

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13368044
2013-08-30 09:09:45 +09:00
Keith Randall
32b770b2c0 runtime: jump to badmcall instead of calling it.
This replaces the mcall frame with the badmcall frame instead of
leaving the mcall frame on the stack and adding the badmcall frame.
Because mcall is no longer on the stack, traceback will now report what
called mcall, which is what we would like to see in this situation.

R=golang-dev, cshapiro
CC=golang-dev
https://golang.org/cl/13012044
2013-08-29 15:53:34 -07:00
Brad Fitzpatrick
90351506d4 regexp/syntax: optimize EmptyOpContext
Minor. Saw this in a profile at few percent of CPU and was
curious what it was. Improves overall regexp benchmarks
anywhere from 0 to 3%, but they're a pain to run. You need to
run them in isolation for long runs to get stable numbers.

benchmark                  old ns/op    new ns/op    delta
BenchmarkEmptyOpContext          537          473  -11.92%

R=golang-dev, crawshaw
CC=golang-dev
https://golang.org/cl/13407043
2013-08-29 14:31:10 -07:00
Adam Langley
2fe9a5a3e8 crypto/tls: support AES-GCM.
AES-GCM is the only current TLS ciphersuite that doesn't have
cryptographic weaknesses (RC4), nor major construction issues (CBC mode
ciphers) and has some deployment (i.e. not-CCM).

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13249044
2013-08-29 17:18:59 -04:00
Brad Fitzpatrick
c4aa9c5c4e regexp: fix a benchmark case
I noticed that this one benchmark in particular was very
noisy.  Looking into it, I saw that the table was wrong
and inconsistent with the lines above and below.

R=golang-dev, crawshaw
CC=golang-dev
https://golang.org/cl/13393045
2013-08-29 13:55:30 -07:00
Shenghou Ma
716a409b90 net/http: redirect handlers from mux.Handler() shouldn't clear the query string
R=bradfitz, alberto.garcia.hierro, rsc, adg
CC=golang-dev
https://golang.org/cl/7099045
2013-08-29 13:55:12 -07:00
Carl Shapiro
c51152f438 runtime: check bitmap word for allocated bit in markonly
When searching for an allocated bit, flushptrbuf would search
backward in the bitmap word containing the bit of pointer
being looked-up before searching the span.  This extra check
was not replicated in markonly which, instead, after not
finding an allocated bit for a pointer would directly look in
the span.

Using statistics generated from godoc, before this change span
lookups were, on average, more common than word lookups.  It
was common for markonly to consult spans for one third of its
pointer lookups.  With this change in place, what were
previously span lookups are overwhelmingly become by the word
lookups making the total number of span lookups a relatively
small fraction of the whole.

This change also introduces some statistics gathering about
lookups guarded by the CollectStats enum.

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/13311043
2013-08-29 13:52:38 -07:00
Keith Randall
ed467db6d8 cmd/cc,runtime: change preprocessor to expand macros inside of
#pragma textflag and #pragma dataflag directives.
Update dataflag directives to use symbols instead of integer constants.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13310043
2013-08-29 12:36:59 -07:00
Rémy Oudompheng
f5f0e40e80 compress/flate: implement Reset method on Writer.
Fixes #6138.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12953048
2013-08-29 21:09:23 +02:00
Robert Daniel Kortschak
b3fd434ae0 net: make channel-based semaphore depend on receive, not send
R=r, dvyukov
CC=golang-dev
https://golang.org/cl/13348045
2013-08-29 17:14:57 +10:00
Andrew Gerrand
27f4166e37 undo CL 13180043 / 318540e7857f
Accidentally submitted.

««« original CL description
encoding/json: add "overflow" struct tag option

Fixes #6213.

R=golang-dev, dsymonds, bradfitz
CC=golang-dev
https://golang.org/cl/13180043
»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/13234045
2013-08-29 14:45:59 +10:00
Andrew Gerrand
10e2ffdf2c os/exec: return idempotent Closer from StdinPipe
Before this fix, it was always an error to use the Close method on the
io.WriteCloser obtained from Cmd.StdinPipe, as it would race with the
Close performed by Cmd.Wait.

Fixes #6270.

R=golang-dev, r, remyoudompheng, bradfitz, dsymonds
CC=golang-dev
https://golang.org/cl/13329043
2013-08-29 14:41:44 +10:00
Andrew Gerrand
466001d05d encoding/json: add "overflow" struct tag option
Fixes #6213.

R=golang-dev, dsymonds, bradfitz
CC=golang-dev
https://golang.org/cl/13180043
2013-08-29 14:39:55 +10:00
Dave Cheney
9169372749 sort: use a very fast random generator for benchmarks
Adapted from https://golang.org/cl/11564044.

Fixes breakage of darwin-amd64-race builder.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13352045
2013-08-29 13:21:21 +10:00
Rob Pike
7c7d22ac5f runtime: re-enable TestParForParallel
See how it flies. We'll disable it again if the underlying issue is not resolved.
See issue 4155 for details.

Fixes #4155.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13368045
2013-08-29 11:42:18 +10:00
Mikio Hara
e4bb139e75 net: make protocol-specific Dial and Listen return consistent error value
Update #4856

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/12916046
2013-08-28 19:51:02 +09:00
Mikio Hara
a8b4a1e63a net: BUG section for ReadFrom, ReadFromIP methods of IPConn on "ip4" network
Fixes #3944.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13263043
2013-08-28 19:49:17 +09:00
Robin Eklind
cfb02f7b74 fmt: Remove some unnecessary conversions.
R=golang-dev, remyoudompheng
CC=golang-dev
https://golang.org/cl/12795052
2013-08-28 11:55:39 -07:00
Brad Fitzpatrick
8159b6901f time: add more docs on Sleep
Merge the comment from runtime/time.goc ("at least")
and also note that negative is okay and won't crash.
I see people going out of their way to avoid passing
a negative value to Sleep.

R=golang-dev, adg, r, alex.brainman
CC=golang-dev
https://golang.org/cl/13271045
2013-08-28 11:16:55 -07:00
Rob Pike
37cee77ac6 text/template: allow {{else if ... }} to simplify if chains
The method is simple: the parser just parses

        {{if A}}a{{else if B}}b{{end}}

to the same tree that would be produced by

        {{if A}}a{{else}}{{if B}}b{{end}}{{end}}

Thus no changes are required in text/template itself
or in html/template, only in text/template/parse.

Fixes #6085

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13327043
2013-08-28 14:43:56 +10:00
Josh Bleecher Snyder
cbea724378 sync: improve once.Do documentation readability
The previous wording, though accurate, was hard to parse.
In particular, it was tempting to interpret "the method"
as referring to "the function f" instead of "Do", and
required effort to find the correct antecedent for
"this receiver".

R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/13307043
2013-08-28 12:53:59 +10:00
Brad Fitzpatrick
2ede818ae0 net/http: document Request.Body more
Fixes #6221

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13289043
2013-08-27 16:13:21 -07:00
Brad Fitzpatrick
c7c1a1bbaa net/smtp: clarify that SendMail's auth param is optional
It wasn't obvious that the Auth could be nil.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13060048
2013-08-27 16:12:11 -07:00
Caleb Spare
8b047893a0 go/ast: fix comment formatting
A bullet list was getting mangled in godoc.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13060047
2013-08-27 09:03:38 -07:00
Volker Dobler
2f81dfd53f sort: harden limit in stable test
Reduce the number of allowed swap operations during stable sort. 

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12907045
2013-08-27 08:41:43 -07:00
Mathieu Lonjaret
d5c806d581 encoding/binary: use bytes.Reader in read example
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/13274043
2013-08-27 06:32:24 -07:00
Alex Brainman
11320fa500 net: have separate read and write processing threads on windows
Fixes #4195

R=golang-dev, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/12960046
2013-08-27 14:53:57 +10:00
Rob Pike
1f661fc205 text/template: make the escapers for HTML etc. handle pointers correctly
Apply the same rules for argument evaluation and indirection that are
used by the regular evaluator.

Fixes #5802

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/13257043
2013-08-27 13:29:07 +10:00
Mikio Hara
519a9e8e9b net: enable PacketConn test for raw IP network on Windows
Just forgot to include this in CL 12843043.
Also consolidates the code dealing with test environment.

Update #6122

R=alex.brainman
CC=golang-dev
https://golang.org/cl/13184043
2013-08-26 18:36:58 +09:00
Evan Shaw
f033d988b1 bytes, strings: use copy in Repeat
R=golang-dev, dave, bradfitz, adg
CC=golang-dev
https://golang.org/cl/13249043
2013-08-27 09:21:08 +10:00
Volker Dobler
f1d61b959f net/http: do not send leading dot in cookie domain attribute
RFC 6265 allows a leading dot in a cookie domain attribute
but is clear (see section 4.1.1) that a Set-Cookie header
should be sent without these dots.

R=bradfitz
CC=golang-dev
https://golang.org/cl/13111043
2013-08-26 07:41:37 -05:00
Mikio Hara
9a7947288b syscall: update routing socket parser for NetBSD 6 and beyond
NetBSD 6 kernel and beyond require 64-bit aligned access to routing
facilities.

Fixes #6226.

R=golang-dev, bsiegert, bradfitz
CC=golang-dev
https://golang.org/cl/13170043
2013-08-25 08:44:31 +09:00
Brad Fitzpatrick
9ec0f30a25 bytes: clarify Equal docs
== isn't defined on slices, so don't use it in docs.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/12983045
2013-08-24 17:05:27 -05:00
Mikio Hara
33f3dffa7c net: allow TestDialFailPDLeak run in long-mode test
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/12917050
2013-08-24 22:05:14 +09:00
Nicolas Owens
de8de8912e os/user: Current support on Plan 9
Current for Plan 9 is implemented with /dev/user for
Uid/Gid/Username/Name, and $home environment variable for
HomeDir.

Implementing Lookup/LookupId is not done, which would
require parsing /adm/users. It is unclear of how much benefit
this would be.

R=golang-dev
CC=bradfitz, golang-dev, r
https://golang.org/cl/13203043
2013-08-23 21:05:49 -05:00
Rémy Oudompheng
534c67abc4 syscall: add Cloneflags to Linux SysProcAttr.
Also use clone(2) syscall instead of fork().

Fixes #6214.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/13159044
2013-08-24 03:34:07 +02:00
Keith Randall
d0dd420a24 runtime: rename FlagNoPointers to FlagNoScan. Better represents
the use of the flag, especially for objects which actually do have
pointers but we don't want the GC to scan them.

R=golang-dev, cshapiro
CC=golang-dev
https://golang.org/cl/13181045
2013-08-23 17:28:47 -07:00
Carl Shapiro
221eef6808 os/exec: remove flaky TestExtraFilesFDShuffle test
Update #5780

R=golang-dev, cshapiro, dave, bradfitz
CC=golang-dev
https://golang.org/cl/12869049
2013-08-23 16:53:32 -07:00
Rémy Oudompheng
d4f719ee13 syscall: define CLONE_* constants on Linux.
Update #6214

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13160043
2013-08-23 22:26:49 +02:00
Joel Sing
4186e9d313 all: dragonfly support
Enable remaining packages (crypto, mime, path, time) to build on dragonfly.

R=bradfitz
CC=golang-dev
https://golang.org/cl/13190043
2013-08-24 02:22:52 +10:00
Joel Sing
fce0608561 net: dragonfly support
Make the net package build and work on dragonfly.

R=bradfitz
CC=golang-dev
https://golang.org/cl/13173044
2013-08-24 02:18:22 +10:00
Joel Sing
6939061d47 os: dragonfly support
Make the os package build and work on dragonfly.

R=bradfitz
CC=golang-dev
https://golang.org/cl/13183044
2013-08-24 02:15:50 +10:00
Joel Sing
f3442a80c3 syscall: dragonfly/amd64 z-files
Add generated z-files for dragonfly/amd64.

R=bradfitz
CC=golang-dev
https://golang.org/cl/13056045
2013-08-24 01:52:33 +10:00
Joel Sing
8f3f4c96a3 syscall: dragonfly/amd64 support
Add syscall support for dragonfly/amd64.

Also add support for generating syscall z* files for dragonfly.

R=bradfitz
CC=golang-dev
https://golang.org/cl/13188043
2013-08-24 01:51:25 +10:00
Joel Sing
ac00524beb runtime: add dragonfly/amd64 port
Go runtime support for dragonfly/amd64, largely based of the existing
FreeBSD runtime (with some clues from the varialus/godfly work).

R=bradfitz
CC=golang-dev
https://golang.org/cl/13088044
2013-08-24 01:50:24 +10:00
Joel Sing
71dc91db0f all: compiler/bootstrap for dragonfly/amd64
Add dragonfly/amd64 support to the Go compiler, bootstrap and GOOS list.

R=devon.odell, bradfitz
CC=golang-dev
https://golang.org/cl/12796050
2013-08-24 01:18:04 +10:00
Mikio Hara
180da80e90 net: fix dial to raw IP networks on Windows
Also avoids platform-dependent datagram truncation in raw IP tests.
At least it's different between Windows and others.

Fixes #6122.

R=alex.brainman
CC=golang-dev
https://golang.org/cl/12843043
2013-08-23 19:31:24 +09:00
Mikio Hara
910a6faa93 net: fix race in TestDNSThreadLimit
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13141045
2013-08-23 14:26:52 +09:00
Alex Brainman
ec9e3e62a1 net: wait longer before failing TestVariousDeadlines4Proc on windows
This is an attempt to make our slow
windows-386 builder more reliable.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/12798045
2013-08-23 15:07:42 +10:00
Mikio Hara
6383896fee net: update doc on socket
Also makes variable names a bit cleaner.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/12808047
2013-08-23 13:13:43 +09:00
Mikio Hara
d3043b7b4a net: add test for protocol numbers lookup using internal information base
Update #5344

R=alex.brainman
CC=golang-dev
https://golang.org/cl/12966046
2013-08-22 12:13:54 +09:00
Alex Brainman
e541c861a3 net: fix misspelled variable name (fixes windows build)
R=golang-dev, adg
CC=golang-dev, mikioh.mikioh
https://golang.org/cl/12848047
2013-08-22 12:34:05 +10:00
Mikio Hara
fd58320f32 net: add minimal internet protocol number information base
This CL adds minimal information for supporting platforms that don't
have a complete list of internet protocol numbers.

Fixes #5344.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12898045
2013-08-22 10:33:37 +09:00
Mikio Hara
3b961bf88b net: remove redundant argument check from Dial on udp, unix networks
The net package consists of thin three layers like the follwoing;

- Exposed API, that contains net.Dial, net.DialUDP, net.DialUnix
- Socket and network file descriptor, that contains net.netFD and
  its methods, helper functions such as dialUDP, dialUnix
- Network pollster, that contains net.pollDesc and its methods

This CL removes redundant argument check which is already done by
API layer.

R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/13092043
2013-08-22 10:33:06 +09:00
Rémy Oudompheng
4a7a72b8c1 syscall: fix stale URL for linux/arm unistd.h
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13105047
2013-08-22 00:59:48 +02:00
Dmitriy Vyukov
dfdd1ba028 runtime: do not trigger GC on g0
GC acquires worldsema, which is a goroutine-level semaphore
which parks goroutines. g0 can not be parked.
Fixes #6193.

R=khr, khr
CC=golang-dev
https://golang.org/cl/12880045
2013-08-22 02:17:45 +04:00
Carl Shapiro
87fdb8fb9a undo CL 13010045 / 04f8101b46dd
Update the original change but do not read interface types in
the arguments area.  Once the arguments area is zeroed as the
locals area is we can safely read interface type values there
too.

««« original CL description
undo CL 12785045 / 71ce80dc4195

This has broken the 32-bit builds.

««« original CL description
cmd/gc, runtime: use type information to scan interface values

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

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

R=khr, khr
CC=golang-dev
https://golang.org/cl/13073045
2013-08-21 13:51:00 -07:00
Sokolov Yura
fcf6a7e5ce time: make timers heap 4-ary
This slightly improves performance when a lot of timers are present

$ misc/benchcmp ../old_timers_m.txt ../new_timers_m.txt
benchmark                           old ns/op    new ns/op    delta
BenchmarkAfterFunc                       6884         6605   -4.05%
BenchmarkAfterFunc-2                     4473         4144   -7.36%
BenchmarkAfterFunc-3                     8601         6185  -28.09%
BenchmarkAfterFunc-4                     9378         8773   -6.45%
BenchmarkAfter                           7237         7278   +0.57%
BenchmarkAfter-2                         4638         3923  -15.42%
BenchmarkAfter-3                         8751         6239  -28.71%
BenchmarkAfter-4                         9223         8737   -5.27%
BenchmarkStop                             603          496  -17.74%
BenchmarkStop-2                           795          577  -27.42%
BenchmarkStop-3                           982          680  -30.75%
BenchmarkStop-4                          1164          739  -36.51%
BenchmarkSimultaneousAfterFunc            657          593   -9.74%
BenchmarkSimultaneousAfterFunc-2          816          757   -7.23%
BenchmarkSimultaneousAfterFunc-3          844          830   -1.66%
BenchmarkSimultaneousAfterFunc-4          785          771   -1.78%
BenchmarkStartStop                        238          239   +0.42%
BenchmarkStartStop-2                      249          234   -6.02%
BenchmarkStartStop-3                      271          268   -1.11%
BenchmarkStartStop-4                      293          295   +0.68%

R=golang-dev, dvyukov, bradfitz, r
CC=golang-dev
https://golang.org/cl/13094043
2013-08-21 18:51:37 +04:00
Dmitriy Vyukov
2f2d4c6bc3 net: ensure that Read/Write on all platforms do 0 mallocs
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12780045
2013-08-21 14:21:02 +04:00
Todd Wang
0e73497a4b reflect: Fix Convert to add indir bit when the value is actually a
pointer.  An example that triggers the bad behavior on a 64bit
machine http://play.golang.org/p/GrNFakAYLN
        rv1 := reflect.ValueOf(complex128(0))
        rt := rv1.Type()
        rv2 := rv1.Convert(rt)
        rv3 := reflect.New(rt).Elem()
        rv3.Set(rv2)

Running the code fails with the following:
        panic: reflect: internal error: storeIword of 16-byte value

I've tested on a 64bit machine and verified this fixes the panic.  I
haven't tested on a 32bit machine so I haven't verified the other
cases, but they follow logically.

R=golang-dev, r, iant
CC=golang-dev
https://golang.org/cl/12805045
2013-08-21 14:41:55 +10:00
Rob Pike
f578726de1 all: protect alloc count tests by -testing.short
Update #5000
Should reduce the flakiness a little. Malloc counting is important
to general testing but not to the build dashboard, which uses -short.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12866047
2013-08-21 14:00:45 +10:00
Rob Pike
7bbe320679 text/template: implement comparison of basic types
Add eq, lt, etc. to allow one to do simple comparisons.
It's basic types only (booleans, integers, unsigned integers,
floats, complex, string) because that's easy, easy to define,
and covers the great majority of useful cases, while leaving
open the possibility of a more sweeping definition later.

{{if eq .X .Y}}X and Y are equal{{else}}X and Y are unequal{{end}}

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13091045
2013-08-21 11:27:27 +10:00
Rob Pike
9364868a07 archive/tar,zip: implement the os.FileInfo interface correctly.
This is potentially an API-breaking change, but it is an important bug fix.

The CL https://golang.org/cl/7305072/ added stuff to make
the tar file look more like a file system internally, including providing an
implementation of os.FileInfo for the file headers within the archive.
But the code is incorrect because FileInfo.Name is supposed to return
the base name only; this implementation returns the full path. A round
trip test added in the same shows this in action, as the slashes are
preserved as we create a header using the local implementation of
FileInfo.

The CL here changes the behavior of the tar (and zip) FileInfo to honor
the Go spec for that interface. It also clarifies that the FileInfoHeader
function, which takes a FileInfo as an argument, will therefore create
a header with only the base name of the file recorded, and that
subsequent adjustment may be necessary.

There may be code out there that depends on the broken behavior.
We can call out the risk in the release notes.

Fixes #6180.

R=golang-dev, dsymonds, adg, bradfitz
CC=golang-dev
https://golang.org/cl/13118043
2013-08-21 08:29:41 +10:00
Mikio Hara
ed738ad354 net: remove obsolete builtin network pollster
Update #5199
Update #6146

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/13112044
2013-08-20 17:32:55 +09:00
Mikio Hara
9b65dac494 net: enable runtime-integrated network pollster on freebsd/arm
Fixes #6146.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12927048
2013-08-20 17:02:42 +09:00
Mikio Hara
e82614e5be runtime: integrated network pollster for freebsd/arm
Update #6146

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12927047
2013-08-20 16:57:30 +09:00
Brad Fitzpatrick
33d531dfa4 net/http: support WriteString on the ResponseWriter
Fixes #5377

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12991046
2013-08-19 22:56:54 -07:00
Rob Pike
94b42fb14a os: fix windows build
The os windows source uses file as the receiver, not f.
TBR=golang-dev@googlegroups.com

R=adg
CC=golang-dev
https://golang.org/cl/12922044
2013-08-20 14:45:46 +10:00
Rob Pike
4cb086b838 os: be consistent about File methods with nil receivers
Some crashed, some didn't. Make a nil receiver always
return ErrInvalid rather than crash.
Fixes #5824.
The program in the bug listing is silent now, at least on my Mac.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13108044
2013-08-20 14:33:03 +10:00
Carl Shapiro
ca2d32b46d undo CL 12785045 / 71ce80dc4195
This has broken the 32-bit builds.

««« original CL description
cmd/gc, runtime: use type information to scan interface values

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

R=khr, golang-dev, khr
CC=golang-dev
https://golang.org/cl/13010045
2013-08-19 14:16:55 -07:00
Keith Randall
6401e0f83f runtime: don't run finalizers if we're still on the g0 stack.
R=golang-dev, rsc, dvyukov, khr
CC=golang-dev
https://golang.org/cl/11386044
2013-08-19 12:20:50 -07:00
Dmitriy Vyukov
88ee849a8a net: annotate Read/Write for race detector
Fixes #6167.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13052043
2013-08-19 23:09:24 +04:00
Dmitriy Vyukov
d017f578d0 runtime: do not preempt race calls
In the crash stack trace race cgocall() calls endcgo(),
this means that m->racecall is wrong.
Indeed this can happen is a goroutine is rescheduled to another M
during race call.
Disable preemption for race calls.
Fixes #6155.

R=golang-dev, rsc, cshapiro
CC=golang-dev
https://golang.org/cl/12866045
2013-08-19 23:06:46 +04:00
Carl Shapiro
21ea5103a4 cmd/gc, runtime: use type information to scan interface values
R=golang-dev, rsc, dvyukov
CC=golang-dev
https://golang.org/cl/12785045
2013-08-19 10:19:59 -07:00
Rob Pike
bc6bb3efb4 math/big: fix nil bug in GobEncode
Update #5305.
This handles the case where the nil pointers are inside a slice.
A top-level nil pointer is harder, maybe fundamentally broken by gob's model.
Thinking required.
However, a slice is the important case since people don't expect to be sending
top-level nils much, but they can arise easily in slices.

R=golang-dev, josharian, adg
CC=golang-dev
https://golang.org/cl/13042044
2013-08-19 11:22:09 +10:00
Marco Hennings
a07c95a53c archive/tar: Fix support for long links and improve PAX support.
The tar/archive code from golang has a problem with linknames with length >
100. A pax header is added but the original header still written with a too
long field length.

As it is clear that pax support is incomplete I have added missing
implementation parts.

This commit contains code from the golang project in the folder tar/archiv.

The following pax header records are now automatically written:

- gname)
- linkpath
- path
- uname

The following fields can be written with PAX, but the default is to use the
star binary extension.

- gid  (value > 2097151)
- size (value > 8589934591)
- uid (value > 2097151)

The string fields are written when the value is longer as the field or if the
string contains a char that is not encodable as 7-bit ASCII value.

The change was tested against a current ubuntu-cloud image tarball comparing
the compressed result.

+ added some automated tests for the new functionality.

Fixes #6056.

R=dsymonds
CC=golang-dev
https://golang.org/cl/12561043
2013-08-19 10:45:44 +10:00
Rob Pike
6fb9cc1f63 testing: don't start timing a Parallel test until it's actually starting
Fixes #5285.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/13045044
2013-08-19 10:15:30 +10:00
Dominik Honnef
43a39bfd7f encoding/xml: flush buffer after encoding token
R=rsc, bradfitz, adg
CC=golang-dev
https://golang.org/cl/13004046
2013-08-19 10:14:10 +10:00
Mikio Hara
7917b88a06 net: make protocol-specific WriteTo, WriteMsg methods return error instead of crash
R=golang-dev, dave, rsc, adg, bradfitz
CC=golang-dev
https://golang.org/cl/11809043
2013-08-18 19:19:36 +09:00
Emil Hessman
df7b93c175 net/textproto: use ReadDotBytes instead of non-existent ReadDotAll.
Fixes #5893.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13086043
2013-08-18 08:11:34 +10:00
Emil Hessman
20eb4cba37 net/textproto: replace '3-digit' with 'three-digit'
A matter on form in documentation.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13087043
2013-08-18 08:10:00 +10:00
Mikio Hara
ca01ab39ef net: fix garbage connection close in dual stack tests
This may possibly be the root cause of flaky dual stack tests.

Update #4176
Update #5001

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13050043
2013-08-17 13:40:55 +09:00
Mikio Hara
96d7997f03 net: enable runtime-integrated network pollster on netbsd
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13080043
2013-08-17 13:40:14 +09:00
Mikio Hara
c4cdd35e6e runtime: integrated network pollster for netbsd/amd64,386,arm
Original CL by minux (9545044).

Update #6146

R=golang-dev, rsc
CC=golang-dev, minux.ma
https://golang.org/cl/12949045
2013-08-17 12:11:29 +09:00
Russ Cox
1d3efd6533 net: limit number of concurrent cgo calls
The limit is 500. There is no way to change it.
This primarily affects name resolution.
If a million goroutines try to resolve DNS names,
only 500 will get to execute cgo calls at a time.
But in return the operating system will not crash.

Fixes #5625.

R=golang-dev, dan.kortschak, r, dvyukov
CC=bradfitz, golang-dev
https://golang.org/cl/13038043
2013-08-16 22:43:05 -04:00
Russ Cox
665feeedcb runtime: impose thread count limit
Actually working to stay within the limit could cause subtle deadlocks.
Crashing avoids the subtlety.

Fixes #4056.

R=golang-dev, r, dvyukov
CC=golang-dev
https://golang.org/cl/13037043
2013-08-16 22:25:26 -04:00
Dmitriy Vyukov
18f5ce8561 runtime/race: add output tests for different GORACE params
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13065043
2013-08-16 21:54:04 +04:00
Dmitriy Vyukov
187b9c695f runtime: fix goroutine stack accounting
Fixes #6166.
Fixes #6168.

R=golang-dev, bradfitz, remyoudompheng
CC=golang-dev
https://golang.org/cl/12927045
2013-08-16 21:04:05 +04:00
Dmitriy Vyukov
fbf5fd5f1e runtime/race: update runtime to rev 188542
Fixes #6107.
race: output goroutine 1 as main goroutine

Fixes #6130.
race: option to abort program on first detected error

R=golang-dev, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/12968044
2013-08-16 17:51:09 +04:00
Dmitriy Vyukov
727dd08cdf net: fix bug in fdMutex
Fixes #6165.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12984044
2013-08-16 16:02:55 +04:00
Rob Pike
4c855f3830 time: fix time zones yet again.
This time we're going for 5!
http://goo.gl/3ETYH7

Fixes #3790
Yeah, right.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13002044
2013-08-16 14:57:49 +10:00
David Symonds
ea6cfc57b3 undo CL 12822043 / 96fefaa02ae3
Fixes #6160.

««« original CL description
go/doc: permit a package synopsis to end with ":\n".

R=gri, r
CC=golang-dev
https://golang.org/cl/12822043
»»»

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13040043
2013-08-16 14:36:06 +10:00
Russ Cox
757e0de89f runtime: impose stack size limit
The goal is to stop only those programs that would keep
going and run the machine out of memory, but before they do that.
1 GB on 64-bit, 250 MB on 32-bit.
That seems implausibly large, and it can be adjusted.

Fixes #2556.
Fixes #4494.
Fixes #5173.

R=khr, r, dvyukov
CC=golang-dev
https://golang.org/cl/12541052
2013-08-15 22:34:06 -04:00
Dimitri Tcaciuc
205329aaf2 image: Inline example image data to make it runnable on playground.
Use more compressed image to reduce source clutter.

Fixes #5983.

R=nigeltao, adg
CC=golang-dev
https://golang.org/cl/12513044
2013-08-16 11:43:43 +10:00
Nigel Tao
bc21265074 database/sql: make Rows.Next returning false always implicitly call
Rows.Close.

Previously, callers that followed the example code (but not call
rows.Close after "for rows.Next() { ... }") could leak statements if
the driver returned an error other than io.EOF.

R=bradfitz, alex.brainman
CC=golang-dev, rsc
https://golang.org/cl/12677050
2013-08-16 11:23:35 +10:00
Brad Fitzpatrick
67a69bce6b net/http: don't send an automatic Content-Length on a 304 Not Modified
Also start of some test helper unification, long overdue.
I refrained from cleaning up the rest in this CL.

Fixes #6157

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13030043
2013-08-15 17:40:05 -07:00
Brad Fitzpatrick
95e0a8c277 net/http: unify the confusingly-named serve_test and server_test
One was tiny. One was gigantic. Now one is gone and one is giganticer.

No code changes.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13025043
2013-08-15 16:47:31 -07:00
Russ Cox
08fdf00906 tests: remove two misuses of nil pointers
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12858044
2013-08-15 11:51:04 -04:00
Mikio Hara
ff86d222be runtime: fix wrong syscall numbers on freebsd/386, openbsd/386
R=golang-dev, jsing
CC=golang-dev
https://golang.org/cl/12876044
2013-08-15 23:22:55 +09:00
Mikio Hara
cb3b292201 net: enable runtime-integrated network pollster on freebsd, openbsd
Fixes #5199.

Benchmark results on freebsd/amd64 (virtual machine):

benchmark                             old ns/op    new ns/op    delta
BenchmarkTCP4OneShot-2                   184566       187164   +1.41%
BenchmarkTCP4OneShotTimeout-2            215558       187722  -12.91%
BenchmarkTCP4Persistent-2                 59686        41294  -30.81%
BenchmarkTCP4PersistentTimeout-2          60692        39974  -34.14%
BenchmarkTCP6OneShot-2                   226595       223688   -1.28%
BenchmarkTCP6OneShotTimeout-2            253144       225161  -11.05%
BenchmarkTCP6Persistent-2                 69157        55605  -19.60%
BenchmarkTCP6PersistentTimeout-2          70426        53805  -23.60%
BenchmarkTCP4ConcurrentReadWrite-2        53878        56087   +4.10%
BenchmarkTCP6ConcurrentReadWrite-2        66538        68190   +2.48%

benchmark                            old allocs   new allocs    delta
BenchmarkTCP4OneShot-2                       39           36   -7.69%
BenchmarkTCP4OneShotTimeout-2                42           36  -14.29%
BenchmarkTCP4Persistent-2                     1            0  -100.00%
BenchmarkTCP4PersistentTimeout-2              1            0  -100.00%
BenchmarkTCP6OneShot-2                       41           36  -12.20%
BenchmarkTCP6OneShotTimeout-2                43           36  -16.28%
BenchmarkTCP6Persistent-2                     1            0  -100.00%
BenchmarkTCP6PersistentTimeout-2              1            0  -100.00%
BenchmarkTCP4ConcurrentReadWrite-2            0            0     n/a%
BenchmarkTCP6ConcurrentReadWrite-2            0            0     n/a%

benchmark                             old bytes    new bytes    delta
BenchmarkTCP4OneShot-2                     3084         2544  -17.51%
BenchmarkTCP4OneShotTimeout-2              3129         2519  -19.50%
BenchmarkTCP4Persistent-2                    30            0  -100.00%
BenchmarkTCP4PersistentTimeout-2             31            0  -100.00%
BenchmarkTCP6OneShot-2                     3297         2660  -19.32%
BenchmarkTCP6OneShotTimeout-2              3306         2655  -19.69%
BenchmarkTCP6Persistent-2                    31            0  -100.00%
BenchmarkTCP6PersistentTimeout-2             29            0  -100.00%
BenchmarkTCP4ConcurrentReadWrite-2            2            0  -100.00%
BenchmarkTCP6ConcurrentReadWrite-2            7            0  -100.00%

R=dvyukov, minux.ma, dave, bradfitz, alex.brainman
CC=golang-dev
https://golang.org/cl/8264043
2013-08-15 21:10:03 +09:00
Dmitriy Vyukov
f195ae94ca runtime: remove old preemption checks
runtime.gcwaiting checks are not needed anymore

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/12934043
2013-08-15 14:32:10 +04:00
Dmitriy Vyukov
67c79da857 runtime: fix plan9 build
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12986043
2013-08-15 14:24:28 +04:00
Mikio Hara
5d5defc77f net: rearrange the call order of runtime-integrated network pollster and syscall functions
This CL rearranges the call order for raw networking primitives like
the following;

- For dialers that open active connections, pollDesc.Init will be
  called before syscall.Connect.

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

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

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

Update #5199

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/12730043
2013-08-15 16:40:33 +09:00
Rob Pike
a454d2fd2e time: expand acceptance of time zones when parsing
I tried to make it absolutely correct but there are too many
conflicting definitions for the official list of time zones.
Since when we're parsing we know when to expect
a time zone and we know what they look like if not exactly
what the definitive set is, we compromise. We accept any
three-character sequence of upper case letters, possibly
followed by a capital T (all four-letter zones end in T).

There is one crazy special case (ChST) and the possibility
of a signed hour offset for GMT.

Fixes #3790
I hope forever, but I doubt that very much.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/12969043
2013-08-15 16:42:54 +10:00
Brad Fitzpatrick
ec837ad73c archive/zip: speed up Zip64 test
Took 76 seconds or so before. By avoiding flate and crc32 on
4GB of data, it's now only 12 seconds.  Still a slow test, but
not painful to run anymore when you forget -short.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/12950043
2013-08-14 23:21:57 -07:00
Brad Fitzpatrick
35d8bb39bd testing: add TB, an interface common to T and B
R=golang-dev, kevlar, rsc, adg, r
CC=golang-dev
https://golang.org/cl/12962043
2013-08-14 23:21:32 -07:00
Rob Pike
a41a5bb207 os/exec: document that LookPath's result may be a relative path
Fixes #3622

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/12971043
2013-08-15 14:29:04 +10:00
Rob Pike
727b2b6f7d time: handle GMT possibly with offset
Update #3790
Handle time zones like GMT-8.
The more general time zone-matching problem is not yet resolved.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12922043
2013-08-15 10:10:49 +10:00
Russ Cox
904e113615 encoding/xml: support generic encoding interfaces
Remove custom support for time.Time.
No new tests: the tests for the time.Time special case
now test the general case.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12751045
2013-08-14 18:52:09 -04:00
Carl Shapiro
3ec0427a07 cmd/go, runtime/cgo: explicitly target ARMv5T
The baseline architecture had been left to the GCC configured
default which can be more accomodating than the rest of the Go
toolchain.  This prevented instructions used by the 5g compiler,
like BLX, from being used in GCC compiled assembler code.

R=golang-dev, dave, rsc, elias.naur, cshapiro
CC=golang-dev
https://golang.org/cl/12954043
2013-08-14 15:21:53 -07:00
Mikio Hara
88411547d4 net: simplify dial
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12884044
2013-08-15 05:53:53 +09:00
Dmitriy Vyukov
3bd0b0a80d runtime: fix SetBlockProfileRate
It doughtily misses all possible corner cases.
In particular on machines with <1GHz processors,
SetBlockProfileRate(1) disables profiling.
Fixes #6114.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/12936043
2013-08-15 00:20:36 +04:00
Mikio Hara
2eb7c6ec8a net: simplify non-cgo DNS exchange
Also does less buffer allocation in case of TCP fallback.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12925043
2013-08-15 05:08:08 +09:00
Mikio Hara
3a93626b49 net: fix TestTCPLookup
R=golang-dev, dvyukov, dave
CC=golang-dev
https://golang.org/cl/12766044
2013-08-15 05:07:35 +09:00
Russ Cox
54bdfc007f encoding/xml: add, support Marshaler interface
See golang.org/s/go12xml for design.

Repeat of CL 12603044, which was submitted accidentally
and then rolled back.

Fixes #2771.
Fixes #4169.
Fixes #5975.
Fixes #6125.

R=golang-dev
CC=golang-dev
https://golang.org/cl/12919043
2013-08-14 14:58:28 -04:00
Russ Cox
84b0842a59 encoding/xml: add, support Unmarshaler interface
See golang.org/s/go12xml for design.

R=golang-dev, dominik.honnef, dan.kortschak
CC=golang-dev
https://golang.org/cl/12556043
2013-08-14 14:57:45 -04:00
Russ Cox
7e886740d1 encoding/json: support encoding.TextMarshaler, encoding.TextUnmarshaler
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12703043
2013-08-14 14:56:07 -04:00
Russ Cox
5822e7848a runtime: make SetFinalizer(x, f) accept any f for which f(x) is valid
Originally the requirement was f(x) where f's argument is
exactly x's type.

CL 11858043 relaxed the requirement in a non-standard
way: f's argument must be exactly x's type or interface{}.

If we're going to relax the requirement, it should be done
in a way consistent with the rest of Go. This CL allows f's
argument to have any type for which x is assignable;
that's the same requirement the compiler would impose
if compiling f(x) directly.

Fixes #5368.

R=dvyukov, bradfitz, pieter
CC=golang-dev
https://golang.org/cl/12895043
2013-08-14 14:54:31 -04:00
Russ Cox
2560f8fe22 runtime/cgo: use old-style indirect call on arm
TBR=elias.naur
CC=golang-dev
https://golang.org/cl/12943043
2013-08-14 14:54:08 -04:00
Dmitriy Vyukov
dd50dac56c runtime: fix windows build
R=golang-dev
CC=golang-dev
https://golang.org/cl/12941043
2013-08-14 22:18:49 +04:00
Dmitriy Vyukov
4e76abbc60 runtime: implement SysUnused on windows
Fixes #5584.

R=golang-dev, chaishushan, alex.brainman
CC=golang-dev
https://golang.org/cl/12720043
2013-08-14 21:54:07 +04:00
Dmitriy Vyukov
f8ca13c3e5 net: make TCPStress test shorter
It timeouts on freebsd builders:
http://build.golang.org/log/3d8169e13bff912bebf6fd3c54b34ad2d29a7221
but there are always runnable goroutines,
which suggests that it's slowly progressing.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12939043
2013-08-14 21:53:27 +04:00
Elias Naur
dc48e9516c runtime: Fix build on older ARM
The ARM external linking CL used BLX instructions in gcc assembler. Replace with BL to retain support on older ARM processors.

R=rsc
CC=golang-dev
https://golang.org/cl/12938043
2013-08-14 13:50:12 -04:00
Dmitriy Vyukov
9bbf1e1b72 net: make TestDeadlineRace shorter
1. Do less iterations in short mode
2. Bound number of times SetDeadline is executed

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12937043
2013-08-14 21:20:11 +04:00
Elias Naur
48c0d8b6e2 runtime: Fix netbsd/arm and freebsd/arm build
The ARM external linking CL left missed changes to sys_freebsd_arm.s and sys_netbsd_arm.s already done to sys_linux_arm.s.

R=rsc
CC=golang-dev
https://golang.org/cl/12842044
2013-08-14 13:18:32 -04:00
Matt Joiner
13c7896fb6 database/sql: fix accumulation of bad conns on prepared statements
Fixes an issue where prepared statements that outlive many
connections become expensive to invoke.

Fixes #6081

R=golang-dev
CC=bradfitz, golang-dev
https://golang.org/cl/12646044
2013-08-14 09:27:30 -07:00
Elias Naur
45233734e2 runtime.cmd/ld: Add ARM external linking and implement -shared in terms of external linking
This CL is an aggregate of 10271047, 10499043, 9733044. Descriptions of each follow:

10499043
runtime,cmd/ld: Merge TLS symbols and teach 5l about ARM TLS

This CL prepares for external linking support to ARM.

The pseudo-symbols runtime.g and runtime.m are merged into a single
runtime.tlsgm symbol. When external linking, the offset of a thread local
variable is stored at a memory location instead of being embedded into a offset
of a ldr instruction. With a single runtime.tlsgm symbol for both g and m, only
one such offset is needed.

The larger part of this CL moves TLS code from gcc compiled to internally
compiled. The TLS code now uses the modern MRC instruction, and 5l is taught
about TLS fallbacks in case the instruction is not available or appropriate.

10271047
This CL adds support for -linkmode external to 5l.

For 5l itself, use addrel to allow for D_CALL relocations to be handled by the
host linker. Of the cases listed in rsc's comment in issue 4069, only case 5 and
63 needed an update. One of the TODO: addrel cases was since replaced, and the
rest of the cases are either covered by indirection through addpool (cases with
LTO or LFROM flags) or stubs (case 74). The addpool cases are covered because
addpool emits AWORD instructions, which in turn are handled by case 11.

In the runtime, change the argv argument in the rt0* functions slightly to be a
pointer to the argv list, instead of relying on a particular location of argv.

9733044
The -shared flag to 6l outputs a shared library, implemented in Go
and callable from non-Go programs such as C.

The main part of this CL change the thread local storage model.
Go uses the fastest and least general mode, local exec. TLS data in shared
libraries normally requires at least the local dynamic mode, however, this CL
instead opts for using the initial exec mode. Initial exec mode is faster than
local dynamic mode and can be used in linux since the linker has reserved a
limited amount of TLS space for performance sensitive TLS code.

Initial exec mode requires an extra load from the GOT table to determine the
TLS offset. This penalty will not be paid if ld is not in -shared mode, since
TLS accesses will be reduced to local exec.

The elf sections .init_array and .rela.init_array are added to register the Go
runtime entry with cgo at library load time.

The "hidden" attribute is added to Cgo functions called from Go, since Go
does not generate call through the GOT table, and adding non-GOT relocations for
a global function is not supported by gcc. Cgo symbols don't need to be global
and avoiding the GOT table is also faster.

The changes to 8l are only removes code relevant to the old -shared mode where
internal linking was used.

This CL only address the low level linker work. It can be submitted by itself,
but to be useful, the runtime changes in CL 9738047 is also needed.

Design discussion at
https://groups.google.com/forum/?fromgroups#!topic/golang-nuts/zmjXkGrEx6Q

Fixes #5590.

R=rsc
CC=golang-dev
https://golang.org/cl/12871044
2013-08-14 15:38:54 +00:00
Dmitriy Vyukov
c92287686d runtime: improve block profiler support for channels
1. Handle select statements.
2. Handle chan close.
3. Show top frame in debug mode (chansend/chanrecv/selectgo).
Fixes #6049.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/12694050
2013-08-14 13:56:01 +04:00
Russ Cox
883530c019 sync/atomic: fix new swap on arm linux
TBR=dvyukov
CC=golang-dev
https://golang.org/cl/12920043
2013-08-14 00:50:47 -04:00
Russ Cox
071e44e4e4 time: make Time implement encoding interfaces
See golang.org/s/go12encoding for design.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12706043
2013-08-14 00:34:00 -04:00
Russ Cox
413d4c6c11 net: make IP implement encoding.MarshalerText, encoding.UnmarshalerText
See golang.org/s/go12encoding for design.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/12705043
2013-08-14 00:33:20 -04:00
Russ Cox
56ce83f7ba undo CL 12603044 / 2ca230b93195
fat fingers - did not intend to submit.
depends on the Unmarshaler CL anyway.

««« original CL description
encoding/xml: add, support Marshaler interface

See golang.org/s/go12xml for design.

Fixes #2771.
Fixes #4169.
Fixes #5975.
Fixes #6125.

R=golang-dev, iant, dan.kortschak
CC=golang-dev
https://golang.org/cl/12603044
»»»

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/12918043
2013-08-14 00:20:55 -04:00
Russ Cox
ce3ba126a0 encoding/gob: support new generic interfaces in package encoding
R=r
CC=golang-dev
https://golang.org/cl/12681044
2013-08-14 00:18:48 -04:00
Russ Cox
48b90bbc55 encoding: new package
See golang.org/s/go12encoding for design.

R=r
CC=golang-dev
https://golang.org/cl/12541051
2013-08-14 00:18:20 -04:00
Russ Cox
85f3acd788 encoding/xml: add, support Marshaler interface
See golang.org/s/go12xml for design.

Fixes #2771.
Fixes #4169.
Fixes #5975.
Fixes #6125.

R=golang-dev, iant, dan.kortschak
CC=golang-dev
https://golang.org/cl/12603044
2013-08-14 00:17:42 -04:00
Russ Cox
1a09d70e23 runtime: fix build on arm
Do not use ? :
I cannot say this enough.

TBR=dvyukov
CC=golang-dev
https://golang.org/cl/12903043
2013-08-13 19:37:54 -04:00
Brad Fitzpatrick
a2599cf50e archive/zip: add File.DataOffset
Accessor to find where the bytes of a file start.

R=golang-dev, rsc, dsymonds, adg
CC=golang-dev
https://golang.org/cl/12784045
2013-08-13 16:29:51 -07:00
Mikio Hara
45cb2e1b70 net: make Dial, Listen and ListenPacket return consistent error value
Update #4856

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12763044
2013-08-14 07:04:39 +09:00
Brad Fitzpatrick
ca3ed9f352 database/sql: add a disabled broken test
Update #6081

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/12810043
2013-08-13 14:56:40 -07:00
Brad Fitzpatrick
c7d352c941 archive/zip: remove an allocation, speed up a test
Update #6138

TestOver65kFiles spends all its time garbage collecting.
Removing the 1.4 MB of allocations per each of the 65k
files brings this from 34 seconds to 0.23 seconds.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12894043
2013-08-13 14:48:08 -07:00
Rob Pike
c18af467fd encoding/binary: make Write work like Read
Use the fast path calculation to shorten the code.
No effect on benchmarks.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12696046
2013-08-14 07:03:56 +10:00
Dmitriy Vyukov
992374f8fb net: fix build fix
Now builders say:
pkg/net/dnsclient_unix_test.go:10: imported and not used: "runtime"

R=golang-dev
CC=golang-dev
https://golang.org/cl/12890043
2013-08-14 00:55:18 +04:00
Dmitriy Vyukov
d90a81c39f net: fix windows build
Windows builders say:
pkg\net\dnsclient_unix_test.go:24: undefined: dnsConfig
pkg\net\dnsclient_unix_test.go:25: undefined: exchange

R=golang-dev
CC=golang-dev
https://golang.org/cl/12889043
2013-08-14 00:44:57 +04:00
Dmitriy Vyukov
4f2e382c9f runtime: dump scheduler state if GODEBUG=schedtrace is set
The schedtrace value sets dump period in milliseconds.
In default mode the trace looks as follows:
SCHED 0ms: gomaxprocs=4 idleprocs=0 threads=3 idlethreads=0 runqueue=0 [1 0 0 0]
SCHED 1001ms: gomaxprocs=4 idleprocs=3 threads=6 idlethreads=3 runqueue=0 [0 0 0 0]
SCHED 2008ms: gomaxprocs=4 idleprocs=1 threads=6 idlethreads=1 runqueue=0 [0 1 0 0]
If GODEBUG=scheddetail=1 is set as well, then the detailed trace is printed:
SCHED 0ms: gomaxprocs=4 idleprocs=0 threads=3 idlethreads=0 runqueue=0 singleproc=0 gcwaiting=1 mlocked=0 nmspinning=0 stopwait=0 sysmonwait=0
  P0: status=3 tick=1 m=0 runqsize=1/128 gfreecnt=0
  P1: status=3 tick=0 m=-1 runqsize=0/128 gfreecnt=0
  P2: status=3 tick=0 m=-1 runqsize=0/128 gfreecnt=0
  P3: status=3 tick=0 m=-1 runqsize=0/128 gfreecnt=0
  M2: p=-1 curg=-1 mallocing=0 throwing=0 gcing=0 locks=1 dying=0 helpgc=0 spinning=0 lockedg=-1
  M1: p=-1 curg=-1 mallocing=0 throwing=0 gcing=0 locks=1 dying=0 helpgc=0 spinning=0 lockedg=-1
  M0: p=0 curg=1 mallocing=0 throwing=0 gcing=0 locks=1 dying=0 helpgc=0 spinning=0 lockedg=1
  G1: status=2() m=0 lockedm=0
  G2: status=1() m=-1 lockedm=-1

R=golang-dev, raggi, rsc
CC=golang-dev
https://golang.org/cl/11435044
2013-08-14 00:30:55 +04:00
Russ Cox
2642c6e24d sync/atomic: update comment for ARM 64-bit atomics
They don't work on older chips, just like the x86-32 64-bit atomics.

Update #6134

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12880043
2013-08-13 16:16:05 -04:00
Keith Randall
74e78df107 undo CL 12840043 / 3b9f54db72a1
Breaks the build.  Old bucket arrays kept by iterators
still need to be scanned.

««« original CL description
runtime: tell GC not to scan internal hashmap structures.
We'll do it ourselves via hash_gciter, thanks.
Fixes bug 6119.

R=golang-dev, dvyukov, cookieo9, rsc
CC=golang-dev
https://golang.org/cl/12840043
»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/12884043
2013-08-13 12:59:39 -07:00
Keith Randall
0df438c683 runtime: tell GC not to scan internal hashmap structures.
We'll do it ourselves via hash_gciter, thanks.
Fixes bug 6119.

R=golang-dev, dvyukov, cookieo9, rsc
CC=golang-dev
https://golang.org/cl/12840043
2013-08-13 12:36:03 -07:00
Russ Cox
ba14974e07 undo CL 12787044 / ed695cdf962b
The NetBSD and OpenBSD failures are apparently real,
not due to the test bug fixed in 100b9fc0c46f.

««« original CL description
runtime/pprof: test netbsd and openbsd again

Maybe these will work now.

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

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12873043
2013-08-13 23:33:49 +04:00
Dmitriy Vyukov
4961483e7d runtime: fix LockOSThread
Fixes #6100.

R=golang-dev, dave, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/12703045
2013-08-13 22:37:04 +04:00
Dmitriy Vyukov
f9066fe1c0 runtime: more reliable preemption
Currently it's possible that a goroutine
that periodically executes non-blocking
cgo/syscalls is never preempted.
This change splits scheduler and syscall
ticks to prevent such situation.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12658045
2013-08-13 22:14:04 +04:00
Dmitriy Vyukov
cc4e6aad8e runtime: do no lose CPU profiling signals
Currently we lose lots of profiling signals.
Most notably, GC is not accounted at all.
But stack splits, scheduler, syscalls, etc are lost as well.
This creates seriously misleading profile.
With this change all profiling signals are accounted.
Now I see these additional entries that were previously absent:
161  29.7%  29.7%      164  30.3% syscall.Syscall
 12   2.2%  50.9%       12   2.2% scanblock
 11   2.0%  55.0%       11   2.0% markonly
 10   1.8%  58.9%       10   1.8% sweepspan
  2   0.4%  85.8%        2   0.4% runtime.newstack
It is still impossible to understand what causes stack splits,
but at least it's clear how many time is spent on them.
Update #2197.
Update #5659.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12179043
2013-08-13 22:12:02 +04:00
Dmitriy Vyukov
1da1030b5d runtime: fix false deadlock crash
Fixes #6070.
Update #6055.

R=golang-dev, nightlyone, rsc
CC=golang-dev
https://golang.org/cl/12602043
2013-08-13 22:07:42 +04:00
Dmitriy Vyukov
7eb6a6f46d sync/atomic: fix ARM nomenclature in comments
R=cshapiro
CC=golang-dev
https://golang.org/cl/12877043
2013-08-13 22:07:21 +04:00
Rick Arnold
4be93851c3 io: prevent write to PipeWriter after Close
Return an ErrClosedPipe rather than allowing the write to proceed.

Fixes #5330.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12541053
2013-08-13 11:04:09 -07:00
Dmitriy Vyukov
d3f36dbfc7 sync/atomic: add Swap to nil deref test
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12870043
2013-08-13 21:18:33 +04:00
Dmitriy Vyukov
66c58cea67 sync/atomic: trigger paging fault early on linux/arm
so that we don't need to traceback through __kuser_cmpxchg

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12869043
2013-08-13 21:15:47 +04:00
Alex A Skinner
0a3cb7ece3 net: implement DNS TCP fallback query if UDP response is truncated
Fixes #5686.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/12458043
2013-08-13 09:44:12 -07:00
Russ Cox
469250fb77 runtime/pprof: test netbsd and openbsd again
Maybe these will work now.

R=golang-dev, dvyukov, bradfitz
CC=golang-dev
https://golang.org/cl/12787044
2013-08-13 12:35:37 -04:00
Dmitriy Vyukov
71c6da39ce runtime/pprof: fix test
R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/12790043
2013-08-13 12:18:29 -04:00
Dmitriy Vyukov
aaab946943 runtime: fix handling of network deadlines
Ensure that deadlines affect already issued IO.

R=golang-dev, mikioh.mikioh, bradfitz
CC=golang-dev
https://golang.org/cl/12847043
2013-08-13 19:11:42 +04:00
Dmitriy Vyukov
0e15b03f93 sync/atomic: add Swap functions
Fixes #5722.

R=golang-dev, khr, cshapiro, rsc, r
CC=golang-dev
https://golang.org/cl/12670045
2013-08-13 15:26:48 +04:00
Mikio Hara
39a7017c26 net: make deadline helpers join to netFD as its methods
Just for readability reasons; to prevent overlooking deadline stuff
across over platforms.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/8656044
2013-08-13 20:00:58 +09:00
Dmitriy Vyukov
5a20b4a6a9 sync: faster Cond
The new version does not require any memory allocations and is 30-50% faster.
Also detect and painc if Cond is copied after first.

benchmark            old ns/op    new ns/op    delta
BenchmarkCond1             317          195  -38.49%
BenchmarkCond1-2           875          607  -30.63%
BenchmarkCond1-4          1116          548  -50.90%
BenchmarkCond1-8          1013          613  -39.49%
BenchmarkCond1-16          983          450  -54.22%
BenchmarkCond2             559          352  -37.03%
BenchmarkCond2-2          1916         1378  -28.08%
BenchmarkCond2-4          1518         1322  -12.91%
BenchmarkCond2-8          2313         1291  -44.19%
BenchmarkCond2-16         1885         1078  -42.81%
BenchmarkCond4            1070          614  -42.62%
BenchmarkCond4-2          4899         3047  -37.80%
BenchmarkCond4-4          3813         3006  -21.16%
BenchmarkCond4-8          3605         3045  -15.53%
BenchmarkCond4-16         4148         2637  -36.43%
BenchmarkCond8            2086         1264  -39.41%
BenchmarkCond8-2          9961         6736  -32.38%
BenchmarkCond8-4          8135         7689   -5.48%
BenchmarkCond8-8          9623         7517  -21.89%
BenchmarkCond8-16        11661         8093  -30.60%

R=sougou, rsc, bradfitz, r
CC=golang-dev
https://golang.org/cl/11573043
2013-08-13 14:45:36 +04:00
Dmitriy Vyukov
d1b66439f9 runtime: eliminate excessive notewakeup calls in timers
If the timer goroutine is wakeup by timeout,
other goroutines will still notewakeup because sleeping is still set.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12763043
2013-08-13 14:14:24 +04:00
Dmitriy Vyukov
e33e476e07 syscall: disable cpu profiling around fork
Fixes #5517.
Fixes #5659.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12183044
2013-08-13 13:01:30 +04:00
Dmitriy Vyukov
9707f269c1 runtime: fix network timers related crash
Fixes #6103.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/12686045
2013-08-13 12:55:57 +04:00
David Symonds
c272fd14a8 go/doc: permit a package synopsis to end with ":\n".
R=gri, r
CC=golang-dev
https://golang.org/cl/12822043
2013-08-13 16:20:17 +10:00
Rob Pike
954d14741d go/build: change the wording of NoGoError and comment it better
Out of context, it can be very confusing because there can be lots of Go
files in the directory, but the error message says there aren't.

R=golang-dev, dsymonds, rsc
CC=golang-dev
https://golang.org/cl/12823043
2013-08-13 11:32:32 +10:00
Elias Naur
83348a13fb text/template: Make function call builtin handle nil errors correctly
The call builtin unconditionally tries to convert a second return value from a function to the error type. This fails in case nil is returned, effectively making call useless for functions returning two values.

This CL adds a nil check for the second return value, and adds a test.

Note that for regular function and method calls the nil error case is handled correctly and is verified by a test.

R=r
CC=golang-dev
https://golang.org/cl/12804043
2013-08-13 11:11:05 +10:00
Volker Dobler
4f86a96ac9 net/http: do not send malformed cookie domain attribute
Malformed domain attributes are not sent in a Set-Cookie header.
Instead the domain attribute is dropped which turns the cookie
into a host-only cookie. This is much safer than dropping characters
from domain attribute.

Domain attributes with a leading dot '.' are still allowed, even
if discouraged by RFC 6265 section 4.1.1.

Fixes #6013

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12745043
2013-08-12 15:14:34 -07:00
Keith Randall
e838334beb runtime: change textflags from numbers to symbols
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12798043
2013-08-12 13:47:18 -07:00
Dmitriy Vyukov
2791ef0b67 runtime/race: add end-to-end test
Fixes #5933.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12699051
2013-08-12 22:04:10 +04:00
Dmitriy Vyukov
fa4628346b runtime: remove unused m->racepc
The original plan was to collect allocation stacks
for all memory blocks. But it was never implemented
and it's not in near plans and it's unclear how to do it at all.

R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/12724044
2013-08-12 21:48:19 +04:00
Dmitriy Vyukov
f3c1070fa4 sync/atomic: specify argsize for asm routines
Fixes #6098.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12717043
2013-08-12 21:46:33 +04:00
Dmitriy Vyukov
92254d4463 runtime: fix ARM assembly formatting
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12702048
2013-08-12 21:36:33 +04:00
Keith Randall
8b789e1738 all: change textflags from numbers to symbols.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12774043
2013-08-12 10:25:36 -07:00
Keith Randall
1f7966346e math: convert textflags from numbers to symbols
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12773044
2013-08-12 10:25:18 -07:00
Keith Randall
db324ccd72 syscall: Convert textflags from numbers to symbols.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12773043
2013-08-12 10:24:30 -07:00
Andrew Gerrand
8eb8ad2454 bufio: add Writer example
Update #5530

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12504044
2013-08-12 13:03:50 +10:00
Rob Pike
6b706cf50d bufio: make it clear that the client must call Writer.Flush
Fixes #5530.

R=golang-dev, iant, com.liigo
CC=golang-dev
https://golang.org/cl/12688044
2013-08-12 12:55:33 +10:00
Rob Pike
ce00562607 crypto/rand: simplify example to exploit properties of ReadFull
No need for the complex condition.
Fixes #6089

R=golang-dev, mischief, adg
CC=golang-dev
https://golang.org/cl/12731043
2013-08-12 12:52:23 +10:00
Dmitriy Vyukov
2758101b9d runtime/pprof: add block profile test
Fixes #5993.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12665046
2013-08-11 13:05:51 +04:00
Brad Fitzpatrick
3e38b7f246 net/http: simplify server, use bufio Reader.Reset and Writer.Reset
Update #5100
Update #6086

Remove switchReader, switchWriter, switchReaderPair,
switchWriterPair, etc.

Now it only maintains pools of bufio Readers and Writers, but
uses Reset instead of working around all their
previously-associated state.

Compared to before the bufio Reset change, it's the same number of
allocations, and also faster:

benchmark                                   old ns/op    new ns/op    delta
BenchmarkClientServer                          111218       109828   -1.25%
BenchmarkClientServerParallel4                  70580        70013   -0.80%
BenchmarkClientServerParallel64                 72636        68919   -5.12%
BenchmarkServer                                139858       137068   -1.99%
BenchmarkServerFakeConnNoKeepAlive              14619        14314   -2.09%
BenchmarkServerFakeConnWithKeepAlive            12390        11361   -8.31%
BenchmarkServerFakeConnWithKeepAliveLite         7630         7306   -4.25%
BenchmarkServerHandlerTypeLen                    9688         9342   -3.57%
BenchmarkServerHandlerNoLen                      8700         8470   -2.64%
BenchmarkServerHandlerNoType                     9255         8949   -3.31%
BenchmarkServerHandlerNoHeader                   7058         6806   -3.57%

benchmark                                  old allocs   new allocs    delta
BenchmarkClientServer                              61           61    0.00%
BenchmarkClientServerParallel4                     61           61    0.00%
BenchmarkClientServerParallel64                    61           61    0.00%
BenchmarkServer                                    16           16    0.00%
BenchmarkServerFakeConnNoKeepAlive                 24           24    0.00%
BenchmarkServerFakeConnWithKeepAlive               19           19    0.00%
BenchmarkServerFakeConnWithKeepAliveLite            9            9    0.00%
BenchmarkServerHandlerTypeLen                      17           17    0.00%
BenchmarkServerHandlerNoLen                        14           14    0.00%
BenchmarkServerHandlerNoType                       15           15    0.00%
BenchmarkServerHandlerNoHeader                      9            9    0.00%

benchmark                                   old bytes    new bytes    delta
BenchmarkClientServer                            6988         6985   -0.04%
BenchmarkClientServerParallel4                   6979         6985    0.09%
BenchmarkClientServerParallel64                  7002         7019    0.24%
BenchmarkServer                                  1846         1848    0.11%
BenchmarkServerFakeConnNoKeepAlive               2420         2412   -0.33%
BenchmarkServerFakeConnWithKeepAlive             2126         2129    0.14%
BenchmarkServerFakeConnWithKeepAliveLite          989          990    0.10%
BenchmarkServerHandlerTypeLen                    1818         1819    0.06%
BenchmarkServerHandlerNoLen                      1775         1777    0.11%
BenchmarkServerHandlerNoType                     1783         1785    0.11%
BenchmarkServerHandlerNoHeader                    989          990    0.10%

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12708046
2013-08-10 19:22:44 -07:00
Brad Fitzpatrick
ede9aa9e02 bufio: drop buffer recycling, add Reader.Reset and Writer.Reset
Fixes #6086

R=golang-dev, pieter, r, rsc
CC=golang-dev
https://golang.org/cl/12603049
2013-08-10 19:22:19 -07:00
ChaiShushan
418e2f6aae strconv: fix typo in docs
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12709044
2013-08-10 11:38:42 +10:00
Mikio Hara
db84a450d7 net: move InvalidAddrError type into net.go
Probably we should remove this type before Go 1 contract has settled,
but too late. Instead, keep InvalidAddrError close to package generic
error types.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12670044
2013-08-10 09:46:22 +09:00
Carl Shapiro
abc516e420 cmd/cc, cmd/gc, runtime: Uniquely encode iface and eface pointers in the pointer map.
Prior to this change, pointer maps encoded the disposition of
a word using a single bit.  A zero signaled a non-pointer
value and a one signaled a pointer value.  Interface values,
which are a effectively a union type, were conservatively
labeled as a pointer.

This change widens the logical element size of the pointer map
to two bits per word.  As before, zero signals a non-pointer
value and one signals a pointer value.  Additionally, a two
signals an iface pointer and a three signals an eface pointer.

Following other changes to the runtime, values two and three
will allow a type information to drive interpretation of the
subsequent word so only those interface values containing a
pointer value will be scanned.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12689046
2013-08-09 16:48:12 -07:00
Rob Pike
556b337ece encoding/binary: better description for intReadSize
It used to be called intDestSize; the new name is better too.

R=bradfitz
CC=golang-dev
https://golang.org/cl/12713043
2013-08-10 09:11:58 +10:00
Rob Pike
1f25f5ad48 encoding/binary: fast path for reading slices
Again, it still allocates but the code is simple.

benchmark                       old ns/op    new ns/op    delta
BenchmarkReadSlice1000Int32s        35580        11465  -67.78%

benchmark                        old MB/s     new MB/s  speedup
BenchmarkReadSlice1000Int32s       112.42       348.86    3.10x

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12694048
2013-08-10 08:40:32 +10:00
Russ Cox
d9f93b0e0b go/build: add AllTags to Package
AllTags lists all the tags that can affect the decision
about which files to include. Tools scanning packages
can use this to decide how many variants there are
and what they are.

R=bradfitz
CC=golang-dev
https://golang.org/cl/12703044
2013-08-09 18:34:08 -04:00
Russ Cox
080e00d55d encoding/json: escape & always
There are a few different places in the code that escape
possibly-problematic characters like < > and &.
This one was the only one missing &, so add it.

This means that if you Marshal a string, you get the
same answer you do if you Marshal a string and
pass it through the compactor. (Ironically, the
compaction makes the string longer.)

Because html/template invokes json.Marshal to
prepare escaped strings for JavaScript, this changes
the form of some of the escaped strings, but not
their meaning.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12708044
2013-08-09 18:33:57 -04:00
Taru Karttunen
e3dbb1a310 net/http: Make ReadResponse work with a nil Request parameter
Fixes #5583

R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/9821043
2013-08-09 15:11:03 -07:00
Nicolas Owens
3319db4c94 net: fix LookupSRV ordering on plan 9
lookup_plan9.go's lookupSRV is using the wrong order for srv results. order should be weight, priority, port, following the response from /net/dns:

  chi Aug  9 20:31:13 Rread tag 20 count 61 '_xmpp-client._tcp.offblast.org srv 5 0 5222 iota.offblast.org' 72

R=golang-dev, bradfitz
CC=ality, golang-dev, r, rsc
https://golang.org/cl/12708043
2013-08-09 14:16:43 -07:00
Pieter Droogendijk
b990c40d5e mime: escape backslash in attribute values
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12689045
2013-08-09 13:10:53 -07:00
Pieter Droogendijk
14903f6598 strings: add test for Count
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12541050
2013-08-09 12:51:21 -07:00
Brad Fitzpatrick
ecf3274143 io/ioutil: add WriteString to Discard
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/12580045
2013-08-09 11:27:29 -07:00
Dmitriy Vyukov
cc0a005c9d runtime: fix netbsd build
I've placed net.runtime_Semacquire into netpoll.goc,
but netbsd does not yet use netpoll.goc.

R=golang-dev, bradfitz, iant
CC=golang-dev
https://golang.org/cl/12699045
2013-08-09 22:17:12 +04:00
Dmitriy Vyukov
23e15f7253 net: add special netFD mutex
The mutex, fdMutex, handles locking and lifetime of sysfd,
and serializes Read and Write methods.
This allows to strip 2 sync.Mutex.Lock calls,
2 sync.Mutex.Unlock calls, 1 defer and some amount
of misc overhead from every network operation.

On linux/amd64, Intel E5-2690:
benchmark                             old ns/op    new ns/op    delta
BenchmarkTCP4Persistent                    9595         9454   -1.47%
BenchmarkTCP4Persistent-2                  8978         8772   -2.29%
BenchmarkTCP4ConcurrentReadWrite           4900         4625   -5.61%
BenchmarkTCP4ConcurrentReadWrite-2         2603         2500   -3.96%

In general it strips 70-500 ns from every network operation depending
on processor model. On my relatively new E5-2690 it accounts to ~5%
of network op cost.

Fixes #6074.

R=golang-dev, bradfitz, alex.brainman, iant, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/12418043
2013-08-09 21:43:00 +04:00
Brad Fitzpatrick
89b5c6c0af encoding/json: faster encoding
The old code was caching per-type struct field info. Instead,
cache type-specific encoding funcs, tailored for that
particular type to avoid unnecessary reflection at runtime.
Once the machine is built once, future encodings of that type
just run the func.

benchmark               old ns/op    new ns/op    delta
BenchmarkCodeEncoder     48424939     36975320  -23.64%

benchmark                old MB/s     new MB/s  speedup
BenchmarkCodeEncoder        40.07        52.48    1.31x

Additionally, the numbers seem stable now at ~52 MB/s, whereas
the numbers for the old code were all over the place: 11 MB/s,
40 MB/s, 13 MB/s, 39 MB/s, etc.  In the benchmark above I compared
against the best I saw the old code do.

R=rsc, adg
CC=gobot, golang-dev, r
https://golang.org/cl/9129044
2013-08-09 09:46:47 -07:00
Ian Lance Taylor
ba6cf63cba net: give C.getaddrinfo a hint that we only want SOCK_STREAM answers
This should be more efficient everywhere, and appears to be
required on Solaris.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12583046
2013-08-09 09:23:27 -07:00
Rob Pike
ef86beb445 encoding/binary: fix 32-bit build
Sigh.

R=golang-dev
CC=golang-dev
https://golang.org/cl/12491045
2013-08-09 23:23:34 +10:00
Rob Pike
c0465d0326 encoding/binary: speed up writing slices of integers
Simple approach. Still generates garbage, but not as much.

benchmark                        old ns/op    new ns/op    delta
BenchmarkWriteSlice1000Int32s        40260        18791  -53.33%

benchmark                         old MB/s     new MB/s  speedup
BenchmarkWriteSlice1000Int32s        99.35       212.87    2.14x

Fixes #2634.

R=golang-dev, crawshaw
CC=golang-dev
https://golang.org/cl/12680046
2013-08-09 23:15:08 +10:00
Dmitriy Vyukov
01f1e3da48 runtime: traceback running goroutines
Introduce freezetheworld function that is a best-effort attempt to stop any concurrently running goroutines. Call it during crash.
Fixes #5873.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12054044
2013-08-09 12:53:35 +04:00
Rob Pike
e0405b7318 encoding/binary: document its goals better
It's a modest package with modest goals and limitations.
Make that clear.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12694043
2013-08-09 17:08:02 +10:00
Pieter Droogendijk
f2bc275525 encoding/csv: always allow trailing commas
Original CL by rsc (11916045):

The motivation for disallowing them was RFC 4180 saying
"The last field in the record must not be followed by a comma."
I believe this is an admonition to CSV generators, not readers.
When reading, anything followed by a comma is not the last field.

Fixes #5892.

R=golang-dev, rsc, r
CC=golang-dev
https://golang.org/cl/12294043
2013-08-09 15:46:01 +10:00
Rob Pike
b7eb0e5990 text/template/parse: nicer error when comment ends before final delimiter
By separating finding the end of the comment from the end of the action,
we can diagnose malformed comments better.
Also tweak the documentation to make the comment syntax clearer.

Fixes #6022.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12570044
2013-08-09 12:57:21 +10:00
Rob Pike
94179d61ab reflect: avoid allocation when interface's contents are not addressable
See issue 4949 for a full explanation.

Allocs go from 1 to zero in the non-addressable case.
Fixes #4949.

BenchmarkInterfaceBig             90           14  -84.01%
BenchmarkInterfaceSmall           14           14   +0.00%

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12646043
2013-08-09 10:49:01 +10:00
David Symonds
d2bff757f6 net/mail: comment our divergence from RFC 5322.
R=golang-dev, bradfitz
CC=golang-dev, ryanslade
https://golang.org/cl/12588044
2013-08-09 10:17:57 +10:00
Mikio Hara
554d47ecb5 net: separate unix 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 of Unix network pollster from newFD
to avoid any breakages in the transition from Unix network pollster
to runtime-integrated pollster. Upcoming CLs will rearrange the call
order of pollster and syscall functions like the following;

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

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

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

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

Update #5199

R=dvyukov, bradfitz
CC=golang-dev
https://golang.org/cl/12663043
2013-08-09 09:02:27 +09:00
Volker Dobler
654f35865f net: avoid string operation and make valid domain names explicit
Having a trailing dot in the string doesn't really simplify
the checking loop in isDomainName. Avoid this unnecessary allocation.
Also make the valid domain names more explicit by adding some more
test cases.

benchmark            old ns/op    new ns/op    delta
BenchmarkDNSNames       2420.0        983.0  -59.38%

benchmark           old allocs   new allocs    delta
BenchmarkDNSNames           12            0  -100.00%

benchmark            old bytes    new bytes    delta
BenchmarkDNSNames          336            0  -100.00%

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12662043
2013-08-08 16:33:57 -07:00
Brad Fitzpatrick
de04bf24e5 net/http: fix early side effects in the ResponseWriter's ReadFrom
The ResponseWriter's ReadFrom method was causing side effects on
the output before any data was read.

Now, bail out early and do a normal copy (which does a read
before writing) when our input and output are known to not to
be the pair of types we need for sendfile.

Fixes #5660

R=golang-dev, rsc, nightlyone
CC=golang-dev
https://golang.org/cl/12632043
2013-08-08 14:02:54 -07:00
Brad Fitzpatrick
8378804640 os: fix windows and plan9 builds
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12519046
2013-08-08 11:13:00 -07:00
Dmitriy Vyukov
9f46efce52 runtime: print scavenger details when forced with debug.FreeOSMemory
Fixes #5900.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12669043
2013-08-08 21:55:04 +04:00
Pieter Droogendijk
bdbd5418f4 os: make Readdir work as documented
Readdir's result should never contain a nil.

Fixes #5960.

R=golang-dev, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/12261043
2013-08-08 10:44:01 -07:00
Dmitriy Shelenin
547f1a6fe7 encoding/xml: allow attributes stored in pointers to be marshaled.
Fixes #5334.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/8653047
2013-08-08 10:40:51 -07:00
Ryan Slade
73b8baa1bd net/mail: AddressList fails to parse addresses with a dot
Fixes #4938.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12657044
2013-08-08 10:00:24 -07:00
Dmitriy Vyukov
65834685d3 runtime: use GetQueuedCompletionStatusEx on windows if available
GetQueuedCompletionStatusEx allows to dequeue a batch of completion
notifications, which is more efficient than dequeueing one by one.

benchmark                           old ns/op    new ns/op    delta
BenchmarkClientServerParallel4         100605        90945   -9.60%
BenchmarkClientServerParallel4-2        90225        74504  -17.42%

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/12436044
2013-08-08 17:41:57 +04:00
Dmitriy Vyukov
ed8c5501c7 net: use SetFileCompletionNotificationModes on windows if available
This allows to skip GetQueuedCompletionStatus if an IO operation completes synchronously.
benchmark                    old ns/op    new ns/op    delta
BenchmarkTCP4Persistent          27669        25863   -6.53%
BenchmarkTCP4Persistent-2        18173        15908  -12.46%
BenchmarkTCP4Persistent-4        10390         9766   -6.01%

R=golang-dev, mikioh.mikioh, alex.brainman
CC=golang-dev
https://golang.org/cl/12409044
2013-08-08 17:36:43 +04:00
Rob Pike
b4f370ca57 regexp/syntax: make it clearer that \b and \B are ASCII-defined
Fixes #5896.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12645043
2013-08-08 13:26:39 +10:00
Rob Pike
077989cf94 container/list: fix typo in comment
Fixes #6058.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12643043
2013-08-08 12:41:19 +10:00
Rob Pike
6ac93e2ac8 flag: export commandLine, the previously internal default FlagSet
s/commandLine/CommandLine/g

Fixes #4209.

R=golang-dev, dsymonds, bradfitz
CC=golang-dev
https://golang.org/cl/12587043
2013-08-08 11:50:58 +10:00
Keith Randall
a97a91de06 runtime: Record jmpdefer's argument size.
Fixes bug 6055.

R=golang-dev, bradfitz, dvyukov, khr
CC=golang-dev
https://golang.org/cl/12536045
2013-08-07 14:03:50 -07:00
Dmitriy Vyukov
326ae8d14e runtime: fix traceback in cgo programs
Fixes #6061.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12609043
2013-08-08 00:31:52 +04:00
Dmitriy Vyukov
1590abef03 runtime: do not run TestCgoSignalDeadlock on windows in short mode
The test takes up to 64 seconds on windows builders.
I've tried to reduce number of iterations in the test,
but it does not affect run time.
Fixes #6054.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/12531043
2013-08-08 00:04:28 +04:00
Carl Shapiro
73c93a404c cmd/cc, cmd/gc, runtime: emit bitmaps for scanning locals.
Previously, all word aligned locations in the local variables
area were scanned as conservative roots.  With this change, a
bitmap is generated describing the locations of pointer values
in local variables.

With this change the argument bitmap information has been
changed to only store information about arguments.  The locals
member, has been removed.  In its place, the bitmap data for
local variables is now used to store the size of locals.  If
the size is negative, the magnitude indicates the size of the
local variables area.

R=rsc
CC=golang-dev
https://golang.org/cl/12328044
2013-08-07 12:47:01 -07:00
Keith Randall
0273dc131e runtime: convert .s textflags from numbers to symbolic constants.
Remove NOPROF/DUPOK from everything.

Edits done with a script, except pclinetest.asm which depended
on the DUPOK flag on main().

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12613044
2013-08-07 12:20:05 -07:00
Pieter Droogendijk
a08b1d13ea net/http: Various fixes to Basic authentication
There were some issues with the code sometimes using base64.StdEncoding,
and sometimes base64.URLEncoding.
Encoding basic authentication is now always done by the same code.

Fixes #5970.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12397043
2013-08-07 11:58:59 -07:00
Keith Randall
5a54696d78 cmd/ld: Put the textflag constants in a separate file.
We can then include this file in assembly to replace
cryptic constants like "7" with meaningful constants
like "(NOPROF|DUPOK|NOSPLIT)".

Converting just pkg/runtime/asm*.s for now.  Dropping NOPROF
and DUPOK from lots of places where they aren't needed.
More .s files to come in a subsequent changelist.

A nonzero number in the textflag field now means
"has not been converted yet".

R=golang-dev, daniel.morsing, rsc, khr
CC=golang-dev
https://golang.org/cl/12568043
2013-08-07 10:23:24 -07:00
Alex Brainman
60aa48c127 net: fix small bug introduced by 48f7c4dd87fe
Fixes #6063

R=golang-dev, r, dave
CC=dvyukov, golang-dev
https://golang.org/cl/12586043
2013-08-07 13:36:41 +10:00
Josh Bleecher Snyder
1535727e57 net/http: do not send redundant Connection: close header in HTTP/1.0 responses
HTTP/1.0 connections are closed implicitly, unless otherwise specified.

Note that this change does not test or fix "request too large" responses.
Reasoning: (a) it complicates tests and fixes, (b) they should be rare,
and (c) this is just a minor wire optimization, and thus not really worth worrying
about in this context.

Fixes #5955.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12435043
2013-08-06 18:37:34 -07:00
Brad Fitzpatrick
ebe91d1105 net/http: treat HEAD requests like GET requests
A response to a HEAD request is supposed to look the same as a
response to a GET request, just without a body.

HEAD requests are incredibly rare in the wild.

The Go net/http package has so far treated HEAD requests
specially: a Write on our default ResponseWriter returned
ErrBodyNotAllowed, telling handlers that something was wrong.
This was to optimize the fast path for HEAD requests, but:

1) because HEAD requests are incredibly rare, they're not
   worth having a fast path for.

2) Letting the http.Handler handle but do nop Writes is still
   very fast.

3) this forces ugly error handling into the application.
   e.g. https://code.google.com/p/go/source/detail?r=6f596be7a31e
   and related.

4) The net/http package nowadays does Content-Type sniffing,
   but you don't get that for HEAD.

5) The net/http package nowadays does Content-Length counting
   for small (few KB) responses, but not for HEAD.

6) ErrBodyNotAllowed was useless. By the time you received it,
   you had probably already done all your heavy computation
   and I/O to calculate what to write.

So, this change makes HEAD requests like GET requests.

We now count content-length and sniff content-type for HEAD
requests. If you Write, it doesn't return an error.

If you want a fast-path in your code for HEAD, you have to do
it early and set all the response headers yourself. Just like
before. If you choose not to Write in HEAD requests, be sure
to set Content-Length if you know it. We won't write
"Content-Length: 0" because you might've just chosen to not
write (or you don't know your Content-Length in advance).

Fixes #5454

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12583043
2013-08-06 18:33:03 -07:00
Rob Pike
a4ebad79b4 all: fix up language in a couple of comments
Leftovers from 11699043

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12558046
2013-08-07 09:35:06 +10:00
Rob Pike
f59064de80 fmt: fix up zero padding
If the padding is huge, we crashed by blowing the buffer. That's easy: make sure
we have a big enough buffer by allocating in problematic cases.
Zero padding floats was just wrong in general: the space would appear in the
middle.

Fixes #6044.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12498043
2013-08-07 08:38:46 +10:00
Brad Fitzpatrick
1104a2afb1 strings: add IndexByte benchmark
Like existing Index, IndexRune, IndexHardN, etc.

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/12486044
2013-08-06 14:41:07 -07:00
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