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

14271 Commits

Author SHA1 Message Date
Dmitriy Vyukov
fc37eba149 syscall: mark arguments to Syscall as noescape
Heap arguments to "async" syscalls will break when/if we have moving GC anyway.
With this change is must not break until moving GC, because a user must
reference the object in Go to preserve liveness. Otherwise the code is broken already.
Reduces number of leaked params from 125 to 36 on linux.

R=golang-codereviews, mikioh.mikioh, bradfitz
CC=cshapiro, golang-codereviews, khr, rsc
https://golang.org/cl/45930043
2014-01-17 20:18:37 +04:00
Luke Curley
701982f173 crypto/cipher: improved cbc performance
decrypt: reduced the number of copy calls from 2n to 1.
encrypt: reduced the number of copy calls from n to 1.

Encryption is straight-forward: use dst instead of tmp when
xoring the block with the iv.

Decryption now loops backwards through the blocks abusing the
fact that the previous block's ciphertext (src) is the iv. This
means we don't need to copy the iv every time, in addition to
using dst instead of tmp like encryption.

R=golang-codereviews, agl, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/50900043
2014-01-17 11:07:04 -05:00
Aram Hăvărneanu
a46b434931 runtime: add support for GOOS=solaris
R=alex.brainman, dave, jsing, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/35990043
2014-01-17 17:58:10 +13:00
Rob Pike
f8225bdb35 net/rpc: fix inconsistency in documentation of Service.Register
Falsely claimed an old, no longer true condition that the first argument
must be a pointer.
Fixes #6697

R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/53480043
2014-01-16 15:57:32 -08:00
Dave Cheney
8bc32785b9 net: skip TestDualStackTCPListener in short mode
Update #5001

This test is flakey on linux servers and fails otherwise good builds. Mikio has some proposals to fix the test, but they require additional plumbing.

In the meantime, disable this test in -short mode so it will run during the full net test suite, but not during builder ci.

R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/53410043
2014-01-17 09:49:38 +11:00
Rob Pike
f8cd243669 time: break parse and formatting tests into a separate source file
No changes, just rearrangement. The tests were in need of a little
housekeeping.

R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/53400043
2014-01-16 14:30:01 -08:00
Brad Fitzpatrick
055b588e55 syscall: add Flock_t on Linux
Matches Darwin and the BSDs. This means leveldb-go, kv,
Camlistore, etc can stop defining these structs on Linux by
hand.

Update #7059

R=golang-codereviews, dave, iant
CC=golang-codereviews
https://golang.org/cl/53350043
2014-01-16 14:08:32 -08:00
Keith Randall
873aaa59b7 reflect: Remove imprecise techniques from channel/select operations.
Reflect used to communicate to the runtime using interface words,
which is bad for precise GC because sometimes iwords hold a pointer
and sometimes they don't.  This change rewrites channel and select
operations to always pass pointers to the runtime.

reflect.Select gets somewhat more expensive, as we now do an allocation
per receive case instead of one allocation whose size is the max of
all the received types.  This seems unavoidable to get preciseness
(unless we move the allocation into selectgo, which is a much bigger
change).

Fixes #6490

R=golang-codereviews, dvyukov, rsc
CC=golang-codereviews
https://golang.org/cl/52900043
2014-01-16 13:35:29 -08:00
Brad Fitzpatrick
36477291cc net/http: don't allow Content-Type or body on 204 and 1xx
Status codes 204, 304, and 1xx don't allow bodies. We already
had a function for this, but we were hard-coding just 304
(StatusNotModified) in a few places.  Use the function
instead, and flesh out tests for all codes.

Fixes #6685

R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/53290044
2014-01-16 11:43:52 -08:00
Kamil Kisiel
18d644111e net/smtp: add examples
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/8274046
2014-01-16 10:49:58 -08:00
Brad Fitzpatrick
4deead7645 net/http: cache transport environment lookup
Apparently this is expensive on Windows.

Fixes #7020

R=golang-codereviews, alex.brainman, mattn.jp, dvyukov
CC=golang-codereviews
https://golang.org/cl/52840043
2014-01-16 10:25:45 -08:00
Rob Pike
fc908a0298 fmt: fix bug printing large zero-padded hexadecimal
We forgot to include the width of "0x" when computing the crossover
from internal buffer to allocated buffer.
Also add a helper function to the test for formatting large zero-padded
test strings.

Fixes #6777.

R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/50820043
2014-01-16 09:48:23 -08:00
Russ Cox
ca9975a45e cmd/gc: handle non-escaping address-taken variables better
This CL makes the bitmaps a little more precise about variables
that have their address taken but for which the address does not
escape to the heap, so that the variables are kept in the stack frame
rather than allocated on the heap.

The code before this CL handled these variables by treating every
return statement as using every such variable and depending on
liveness analysis to essentially treat the variable as live during the
entire function. That approach has false positives and (worse) false
negatives. That is, it's both sloppy and buggy:

        func f(b1, b2 bool) {	// x live here! (sloppy)
                if b2 {
                        print(0) // x live here! (sloppy)
                        return
                }
                var z **int
                x := new(int)
                *x = 42
                z = &x
                print(**z) // x live here (conservative)
                if b2 {
                        print(1) // x live here (conservative)
                        return
                }
                for {
                        print(**z) // x not live here (buggy)
                }
        }

The first two liveness annotations (marked sloppy) are clearly
wrong: x cannot be live if it has not yet been declared.

The last liveness annotation (marked buggy) is also wrong:
x is live here as *z, but because there is no return statement
reachable from this point in the code, the analysis treats x as dead.

This CL changes the liveness calculation to mark such variables
live exactly at points in the code reachable from the variable
declaration. This keeps the conservative decisions but fixes
the sloppy and buggy ones.

The CL also detects ambiguously live variables, those that are
being marked live but may not actually have been initialized,
such as in this example:

        func f(b1 bool) {
                var z **int
                if b1 {
                        x := new(int)
                        *x = 42
                        z = &x
                } else {
                        y := new(int)
                        *y = 54
                        z = &y
                }
                print(**z) // x, y live here (conservative)
        }

Since the print statement is reachable from the declaration of x,
x must conservatively be marked live. The same goes for y.
Although both x and y are marked live at the print statement,
clearly only one of them has been initialized. They are both
"ambiguously live".

These ambiguously live variables cause problems for garbage
collection: the collector cannot ignore them but also cannot
depend on them to be initialized to valid pointer values.

Ambiguously live variables do not come up too often in real code,
but recent changes to the way map and interface runtime functions
are invoked has created a large number of ambiguously live
compiler-generated temporary variables. The next CL will adjust
the analysis to understand these temporaries better, to make
ambiguously live variables fairly rare.

Once ambiguously live variables are rare enough, another CL will
introduce code at the beginning of a function to zero those
slots on the stack. At that point the garbage collector and the
stack copying routines will be able to depend on the guarantee that
if a slot is marked as live in a liveness bitmap, it is initialized.

R=khr
CC=golang-codereviews, iant
https://golang.org/cl/51810043
2014-01-16 10:32:30 -05:00
Russ Cox
fbfb9430dc cmd/gc: fix race build
Missed this case in CL 51010045.

TBR=khr
CC=golang-codereviews
https://golang.org/cl/53200043
2014-01-16 10:11:06 -05:00
Dmitriy Vyukov
c0b9e6218c runtime: output how long goroutines are blocked
Example of output:

goroutine 4 [sleep for 3 min]:
time.Sleep(0x34630b8a000)
        src/pkg/runtime/time.goc:31 +0x31
main.func·002()
        block.go:16 +0x2c
created by main.main
        block.go:17 +0x33

Full program and output are here:
http://play.golang.org/p/NEZdADI3Td

Fixes #6809.

R=golang-codereviews, khr, kamil.kisiel, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/50420043
2014-01-16 12:54:46 +04:00
Dmitriy Vyukov
4722b1cbd3 runtime: use lock-free ring for work queues
Use lock-free fixed-size ring for work queues
instead of an unbounded mutex-protected array.
The ring has single producer and multiple consumers.
If the ring overflows, work is put onto global queue.

benchmark              old ns/op    new ns/op    delta
BenchmarkMatmult               7            5  -18.12%
BenchmarkMatmult-4             2            2  -18.98%
BenchmarkMatmult-16            1            0  -12.84%

BenchmarkCreateGoroutines                     105           88  -16.10%
BenchmarkCreateGoroutines-4                   376          219  -41.76%
BenchmarkCreateGoroutines-16                  241          174  -27.80%
BenchmarkCreateGoroutinesParallel             103           87  -14.66%
BenchmarkCreateGoroutinesParallel-4           169          143  -15.38%
BenchmarkCreateGoroutinesParallel-16          158          151   -4.43%

R=golang-codereviews, rsc
CC=ddetlefs, devon.odell, golang-codereviews
https://golang.org/cl/46170044
2014-01-16 12:17:00 +04:00
Keith Randall
2af7a26f1e reflect: add precise GC info for Call argument frame.
Give proper types to the argument/return areas
allocated for reflect calls.  Avoid use of iword to
manipulate receivers, which may or may not be pointers.

Update #6490

R=rsc
CC=golang-codereviews
https://golang.org/cl/52110044
2014-01-15 13:56:59 -08:00
Brad Fitzpatrick
35710eecd6 net/http: add disabled test for Body Read/Close lock granularity
Update #7121

R=golang-codereviews, gobot, dsymonds
CC=golang-codereviews
https://golang.org/cl/51750044
2014-01-15 13:12:32 -08:00
Robert Griesemer
fc80ce8194 go/scanner: report too short escape sequences
Generally improve error messages for escape sequences.

R=adonovan
CC=golang-codereviews
https://golang.org/cl/49430046
2014-01-15 09:50:55 -08:00
Rob Pike
fdbf3d901b cmd/pack: rewrite in Go
Replace the pack command, a C program, with a clean reimplementation in Go.
It does not need to reproduce the full feature set and it is no longer used by
the build chain, but has a role in looking inside archives created by the build
chain directly.

Since it's not in C, it is no longer build by dist, so remove it from cmd/dist and
make it a "tool" in cmd/go terminology.

Fixes #2705

R=rsc, dave, minux.ma, josharian
CC=golang-codereviews
https://golang.org/cl/52310044
2014-01-15 09:13:52 -08:00
Dmitriy Vyukov
b3a3afc9b7 runtime: fix data race in GC
Fixes #5139.
Update #7065.

R=golang-codereviews, bradfitz, minux.ma
CC=golang-codereviews
https://golang.org/cl/52090045
2014-01-15 19:38:08 +04:00
Brad Fitzpatrick
89c9d6b7f8 net/http: return UnexpectedEOF instead of EOF on truncated resposne
Fixes #6564

R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/52420043
2014-01-14 19:08:40 -08:00
Shenghou Ma
0db71338ed runtime/debug: force GC after setting of GCPercent to make it effective.
See also discussion in CL 51010045.

R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/52230043
2014-01-14 19:23:36 -05:00
Rob Pike
71377d3cd3 cmd/ld: document the -w flag, which disables DWARF generation
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/52360044
2014-01-14 15:34:27 -08:00
Rob Pike
591265fcb4 reflect: better document the tri-state for TryRecv
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/52360043
2014-01-14 15:04:16 -08:00
Keith Randall
8454e2c287 runtime: Change size of map iter offset so 32-bit version compiles cleanly.
R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/52310043
2014-01-14 13:46:22 -08:00
Michael Kelly
26cc10289f net/http: escape contents of the directory indexes generated by FileServer
Previously, filenames containing special characters could:
      1) Escape the <a> tag, with a file called something like: ">foo
      2) Break the links in the index by prematurely ending the path portion
      of the url, with a file called: foo?bar

      In order to avoid a forbidden dependency on the html package, I'm
      using htmlReplacer from net/http/server.go, which is equivalent to
      html.EscapeString.

      This change also expands fakeFile.Readdir to better emulate
os.File.Readdir.

R=golang-codereviews, rsc, gobot, bradfitz, josharian, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/37440043
2014-01-14 12:55:12 -08:00
Josh Bleecher Snyder
3be4d95731 runtime: change map iteration randomization to use intra-bucket offset
Map iteration previously started from a random bucket, but walked each
bucket from the beginning. Now, iteration always starts from the first
bucket and walks each bucket starting at a random offset. For
performance, the random offset is selected at the start of iteration
and reused for each bucket.

Iteration over a map with 8 or fewer elements--a single bucket--will
now be non-deterministic. There will now be only 8 different possible
map iterations.

Significant benchmark changes, on my OS X laptop (rough but consistent):

benchmark                              old ns/op     new ns/op     delta
BenchmarkMapIter                       128           121           -5.47%
BenchmarkMapIterEmpty                  4.26          4.45          +4.46%
BenchmarkNewEmptyMap                   114           111           -2.63%

Fixes #6719.

R=khr, bradfitz
CC=golang-codereviews
https://golang.org/cl/47370043
2014-01-14 12:54:05 -08:00
Brad Fitzpatrick
1e2b13355f undo CL 47560044 / 40a37153a550
Still work to do. See http://golang.org/issue/7125

««« original CL description
net/http/cookiejar: document format of domain in PublicSuffix

Document what values a PublicSuffixList must accept as
a domain in a call to PublicSuffix.

R=bradfitz, nigeltao
CC=golang-codereviews
https://golang.org/cl/47560044

»»»

R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/51770044
2014-01-14 12:53:21 -08:00
Brad Fitzpatrick
014f3dcc83 cmd/gofmt: remove -tabwidth and -tabs flags
Having these flags misleads people into thinking they're acceptable
for code that "must be gofmt'd".

If an organization wishes to use gofmt internally with
different settings, they can fork gofmt trivially. But "gofmt"
as used by the community with open source Go code should not
support these old knobs.

Also removes the -comments flag.

Fixes #7101

R=r, gri
CC=golang-codereviews
https://golang.org/cl/52170043
2014-01-14 11:10:56 -08:00
Brad Fitzpatrick
9b0560ea2f net/http: fix another data race when sharing Request.Body
Fix another issue (similar to Issue 6995) where there was a
data race when sharing a server handler's Request.Body with
another goroutine that out-lived the Handler's goroutine.

In some cases we were not closing the incoming Request.Body
(which would've required reading it until the end) if we
thought it we thought we were going to be forcibly closing the
underlying net.Conn later anyway. But that optimization
largely moved to the transfer.go *body later, and locking was
added to *body which then detected read-after-close, so now
calling the (*body).Close always is both cheap and correct.

No new test because TestTransportAndServerSharedBodyRace caught it,
albeit only sometimes. Running:

while ./http.test -test.cpu=8 -test.run=TestTransportAndServerSharedBodyRace; do true; done

... would reliably cause a race before, but not now.

Update #6995
Fixes #7092

R=golang-codereviews, khr
CC=golang-codereviews
https://golang.org/cl/51700043
2014-01-14 09:46:40 -08:00
Russ Cox
334056a7bc cmd/gc: return canonical Node* from temp
For historical reasons, temp was returning a copy
of the created Node*, not the original Node*.
This meant that if analysis recorded information in the
returned node (for example, n->addrtaken = 1), the
analysis would not show up on the original Node*, the
one kept in fn->dcl and consulted during liveness
bitmap creation.

Correct this, and watch for it when setting addrtaken.

Fixes #7083.

R=khr, dave, minux.ma
CC=golang-codereviews
https://golang.org/cl/51010045
2014-01-14 10:43:13 -05:00
Russ Cox
8bd8cede03 cmd/gc: add -live flag for debugging liveness maps
R=khr
CC=golang-codereviews
https://golang.org/cl/51820043
2014-01-14 10:40:16 -05:00
Russ Cox
3ec60c253d runtime: emit collection stacks in GODEBUG=allocfreetrace mode
R=khr, dvyukov
CC=golang-codereviews
https://golang.org/cl/51830043
2014-01-14 10:39:50 -05:00
Dmitriy Vyukov
e0dcf73d61 runtime: fix comment
Void function can not return false.

R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/52000043
2014-01-14 12:58:13 +04:00
Alex Brainman
fa6ffc6c9b cmd/api: ensure GOPATH always points to the correct go.tools
R=golang-codereviews, dave, bradfitz
CC=golang-codereviews
https://golang.org/cl/51000043
2014-01-14 16:56:22 +11:00
Keith Randall
cefe6ac9a1 runtime/pprof: fix flaky TestCPUProfileMultithreaded test
It's too sensitive.

Fixes bug 7095

R=golang-codereviews, iant, minux.ma, rsc
CC=golang-codereviews
https://golang.org/cl/50470043
2014-01-13 21:18:47 -08:00
Russ Cox
6e8b4920c1 cmd/link: fix build
The golden file for link.hello.darwin.amd64
was a little ahead of the checked-in code.

R=iant
TBR=iant
CC=golang-codereviews
https://golang.org/cl/51870043
2014-01-13 23:20:53 -05:00
Russ Cox
7dcc652f10 cmd/link: implement dead code removal
R=iant
CC=golang-codereviews
https://golang.org/cl/51470043
2014-01-13 23:08:10 -05:00
Russ Cox
7cecac3cbb cmd/link: implement and test automatic symbols
Related changes included in this CL:

 - Add explicit start symbol to Prog.
 - Add omitRuntime bool to Prog.
 - Introduce p.Packages[""] to hold automatic symbols
 - Add SymOrder to Prog to preserve symbol order.
 - Add layout test (and fix bug that was putting everything in text section).

R=iant
CC=golang-codereviews
https://golang.org/cl/51260045
2014-01-13 23:07:57 -05:00
Russ Cox
9c1aa658bf cmd/link: replace golden binary files with hex dumps
The hex dumps will diff better, and I hope they will avoid
a repeat of http://bugs.debian.org/716853.

The CL will probably show the testdata diffs as "binary",
but in fact the binary versions are being replaced by
textual hex dumps (output of hexdump -C).

R=iant
CC=golang-codereviews
https://golang.org/cl/51000044
2014-01-13 23:07:40 -05:00
Mikio Hara
47dc183136 net: fix incorrect internal IPv6 address representation in test
Also fixes a dialgoogle test glitch after issue 6628 fix.

R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/50660044
2014-01-14 07:36:38 +09:00
David du Colombier
1f0ca748c2 os/exec: disable fd check in TestHelperProcess on Plan 9
On Plan 9, we can observe the following open file descriptors:

  0 r  c    0 (000000000000000a   0 00)     0        0 /dev/null
  1 rw |    0 (0000000001df6742   0 00) 65536       54 #|/data1
  2 rw |    0 (0000000001df6782   0 00) 65536        0 #|/data1
  3 rw M 1956 (0000000000d66dd2   0 00)  8192       12 /tmp/333163398
  4 r  c    0 (0000000000000001   0 00)     0      528 /dev/bintime
  5 r  M 1956 (0000000000d66dd1 854 00)  8192        0 /tmp/go-build843954301/os/exec/_test/exec.test
  6 r  M 1956 (0000000000d66dd1 854 00)  8192        0 /tmp/go-build843954301/os/exec/_test/exec.test
  7 r  M 1956 (0000000000d66dd1 854 00)  8192        0 /tmp/go-build843954301/os/exec/_test/exec.test
  8 r  M 1956 (0000000000d66dd1 854 00)  8192        0 /tmp/go-build843954301/os/exec/_test/exec.test
  9 r  M 1956 (0000000000d66dd1 854 00)  8192        0 /tmp/go-build843954301/os/exec/_test/exec.test
 10 r  M 1956 (0000000000d66dd1 854 00)  8192        0 /tmp/go-build843954301/os/exec/_test/exec.test
 11 r  c    0 (000000000000000f   0 00)     0       32 /dev/random
 12 r  M 1956 (0000000000d66dd1 854 00)  8192        0 /tmp/go-build843954301/os/exec/_test/exec.test
 13 r  c    0 (000000000000000a   0 00)     0        0 /dev/null
 14 rw |    0 (0000000001df6801   0 00) 65536        0 #|/data
 15 rw |    0 (0000000001df6802   0 00) 65536     1275 #|/data1

R=rsc, bradfitz, aram
CC=golang-codereviews
https://golang.org/cl/51420044
2014-01-13 23:03:22 +01:00
Michael Gehring
5ce3e6a1ef syscall: add syscall.Termios on freebsd/{386,amd64}
R=golang-codereviews, bradfitz, mg
CC=golang-codereviews
https://golang.org/cl/51580044
2014-01-13 13:57:38 -08:00
Brad Fitzpatrick
9c43033977 net/http: clarify semantics of File methods
There were no docs explaining the meaning of Readdir's count
argument, for instance. Clarify that these mean the same as
the methods on *os.File.

R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/51630043
2014-01-13 13:52:06 -08:00
Robert Griesemer
11740e19a4 go/scanner: minimal non-terminated literals
Consume as little as possible input when encountering
non-terminated rune, string, and raw string literals.
The old code consumed at least one extra character
which could lead to worse error recovery when parsing
erroneous sources.

Also made error messages in those cases more consistent.

Fixes #7091.

R=adonovan
CC=golang-codereviews
https://golang.org/cl/50630043
2014-01-13 11:10:45 -08:00
Russ Cox
a2edc469a0 runtime: remove redundant 0x prefix in error print
%x already adds the prefix unconditionally

R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/51550043
2014-01-13 11:39:04 -05:00
David du Colombier
6f97ef28af os: disable TestReaddirStatFailures on Plan 9
R=rsc, dave, aram, jeremyjackins, lucio.dere
CC=golang-codereviews, jas
https://golang.org/cl/50980043
2014-01-13 13:24:59 +01:00
Joel Sing
f40dd8f1d9 syscall: include mmap constants in openbsd zerror* files
Include the <sys/mman.h> header for OpenBSD mkerrors.sh. This brings
in constants used with madvise(2), mmap(2), msync(2) and mlockall(2).

Fixes #4929

R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/50930043
2014-01-13 11:25:48 +11:00
Joel Sing
3233a12f61 syscall: remove getsockname workaround for openbsd
Remove the getsockname workaround for unix domain sockets on OpenBSD.
This was fixed in OpenBSD 5.2 and we now have a minimum requirement
for OpenBSD 5.4-current.

R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/50960043
2014-01-13 11:24:56 +11:00
Joel Sing
073bd0ba24 runtime/pprof: enable profiling test on openbsd
Profiling of multithreaded applications works correctly on OpenBSD
5.4-current, so enable the profiling test.

R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/50940043
2014-01-13 11:24:08 +11:00
Alex Brainman
c7ef348bad net: ignore some errors in windows Accept
Fixes #6987

R=golang-codereviews, dvyukov
CC=golang-codereviews
https://golang.org/cl/49490043
2014-01-12 12:20:16 +11:00
Jeff Sickel
830bb3797e net: add plan9 to TestDialTimeout
=== RUN TestDialTimeout
     --- PASS: TestDialTimeout (0.21 seconds)

R=golang-codereviews, bradfitz, 0intro
CC=golang-codereviews, rsc
https://golang.org/cl/49710050
2014-01-11 18:58:03 +01:00
Joel Sing
471763f657 runtime, syscall: update for openbsd system ABI break
Update Go so that it continues to work past the OpenBSD system ABI
break, with 64-bit time_t:

  http://www.openbsd.org/faq/current.html#20130813

Note: this makes OpenBSD 5.5 (currently 5.4-current) the minimum
supported release for Go.

Fixes #7049.

R=golang-codereviews, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/13368046
2014-01-11 19:00:32 +11:00
Brad Fitzpatrick
5f341df90d database/sql: fix test on 32-bit
R=golang-codereviews
TBR=golang-dev
CC=golang-codereviews
https://golang.org/cl/49920047
2014-01-10 12:30:23 -08:00
Brad Fitzpatrick
258ed3f226 database/sql: avoiding fmt.Sprintf while scanning, avoid allocs with RawBytes
A user reported heavy contention on fmt's printer cache. Avoid
fmt.Sprint. We have to do reflection anyway, and there was
already an asString function to use strconv, so use it.

This CL also eliminates a redundant allocation + copy when
scanning into *[]byte (avoiding the intermediate string)
and avoids an extra alloc when assigning to a caller's RawBytes
(trying to reuse the caller's memory).

Fixes #7086

R=golang-codereviews, nightlyone
CC=golang-codereviews
https://golang.org/cl/50240044
2014-01-10 12:19:36 -08:00
Dmitriy Vyukov
7f62d08777 fmt: make benchmarks parallel
This seems to be the best target to benchmark sync.Pool changes.

This is resend of cl/49910043 which was LGTMed by
TBR=bradfitz

R=golang-codereviews
CC=golang-codereviews
https://golang.org/cl/50140045
2014-01-10 13:51:11 +04:00
Keith Randall
bb7cd9659b liblink: fix comments. Someone was overzealous with search & replace.
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/49160045
2014-01-09 19:46:46 -08:00
Nicholas Katsaros
5277b90ec4 net: add SetKeepAlivePeriod for windows
R=golang-codereviews, alex.brainman, bradfitz, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/11393043
2014-01-10 14:33:54 +11:00
Anthony Martin
d155f6a309 liblink: adjust format verbs to avoid collisions
The %S and %N format verbs are used by cmd/gc to
represent Sym and Node structures, respectively.

In liblink, these two verbs are used only by the %D
format routine and never referenced externally.

This change will allow us to delete the duplicated
code for the %A, %D, %P, and %R format routines in
both the compiler and linker.

R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/49720043
2014-01-09 19:01:08 -08:00
Rémy Oudompheng
f739dae7db cmd/gc: mark OGOTO as a statement for formatters.
Nodes of goto statements were corrupted when written
to export data.

Fixes #7023.

R=rsc, dave, minux.ma
CC=golang-codereviews
https://golang.org/cl/46190043
2014-01-10 01:33:24 +01:00
Russ Cox
8449863d31 cmd/link: Mach-O (OS X) file formatter
See CL 48870044 for basic structure.

R=iant
CC=golang-codereviews
https://golang.org/cl/48910043
2014-01-09 19:29:29 -05:00
Russ Cox
146897b031 cmd/link: intial skeleton of linker written in Go
R=iant
CC=golang-codereviews
https://golang.org/cl/48870044
2014-01-09 19:29:10 -05:00
Brad Fitzpatrick
d6bce32a36 net/http: use TCP keep-alives for ListenAndServe and ListenAndServeTLS
Our default behavior for the common cases shouldn't lead to
leaked TCP connections (e.g. from people closing laptops) when
their Go servers are exposed to the open Internet without a
proxy in front.

Too many users on golang-nuts have learned this the hard way.

No API change. Only ListenAndServe and ListenAndServeTLS are
updated.

R=golang-codereviews, cespare, gobot, rsc, minux.ma
CC=golang-codereviews
https://golang.org/cl/48300043
2014-01-09 15:05:09 -08:00
Ian Lance Taylor
8da8b37674 runtime: fix 32-bit malloc for pointers >= 0x80000000
The spans array is allocated in runtime·mallocinit.  On a
32-bit system the number of entries in the spans array is
MaxArena32 / PageSize, which (2U << 30) / (1 << 12) == (1 << 19).
So we are allocating an array that can hold 19 bits for an
index that can hold 20 bits.  According to the comment in the
function, this is intentional: we only allocate enough spans
(and bitmaps) for a 2G arena, because allocating more would
probably be wasteful.

But since the span index is simply the upper 20 bits of the
memory address, this scheme only works if memory addresses are
limited to the low 2G of memory.  That would be OK if we were
careful to enforce it, but we're not.  What we are careful to
enforce, in functions like runtime·MHeap_SysAlloc, is that we
always return addresses between the heap's arena_start and
arena_start + MaxArena32.

We generally get away with it because we start allocating just
after the program end, so we only run into trouble with
programs that allocate a lot of memory, enough to get past
address 0x80000000.

This changes the code that computes a span index to subtract
arena_start on 32-bit systems just as we currently do on
64-bit systems.

R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/49460043
2014-01-09 15:00:00 -08:00
Robert Griesemer
8a089c07ec go/parser: slightly improved error message by adding hint
It's difficult to make this much better w/o much
more effort. This is a rare case and probably not
worth it.

Fixes #6052.

R=golang-codereviews, bradfitz, adonovan
CC=golang-codereviews
https://golang.org/cl/49740045
2014-01-09 14:51:23 -08:00
Shenghou Ma
9847c065f4 testing: document that ResetTimer also zeros the allocation counters.
Fixes #6998.

R=golang-codereviews, gobot, r
CC=golang-codereviews
https://golang.org/cl/44880044
2014-01-09 15:21:24 -05:00
Adam Langley
779ef7bd13 crypto/tls: support renegotiation extension.
The renegotiation extension was introduced[1] due to an attack by Ray in
which a client's handshake was spliced into a connection that was
renegotiating, thus giving an attacker the ability to inject an
arbitary prefix into the connection.

Go has never supported renegotiation as a server and so this attack
doesn't apply. As a client, it's possible that at some point in the
future the population of servers will be sufficiently updated that
it'll be possible to reject connections where the server hasn't
demonstrated that it has been updated to address this problem.

We're not at that point yet, but it's good for Go servers to support
the extension so that it might be possible to do in the future.

[1] https://tools.ietf.org/search/rfc5746

R=golang-codereviews, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/48580043
2014-01-09 13:38:11 -05:00
Rowan Worth
c4770b991b runtime: co-exist with NPTL's pthread_cancel.
NPTL uses SIGRTMIN (signal 32) to effect thread cancellation.
Go's runtime replaces NPTL's signal handler with its own, and
ends up aborting if a C library that ends up calling
pthread_cancel is used.

This patch prevents runtime from replacing NPTL's handler.

Fixes #6997.

R=golang-codereviews, iant, dvyukov
CC=golang-codereviews
https://golang.org/cl/47540043
2014-01-09 09:34:04 -08:00
Aram Hăvărneanu
6d0d08b849 os, os/exec, os/user: add support for GOOS=solaris
R=golang-codereviews, dave, minux.ma, gobot, jsing
CC=golang-codereviews
https://golang.org/cl/36020043
2014-01-10 02:49:37 +11:00
Ian Lance Taylor
7e639c0229 runtime: change errorCString to a struct
This prevents callers from using reflect to create a new
instance of errorCString with an arbitrary value and calling
the Error method to examine arbitrary memory.

Fixes #7084.

R=golang-codereviews, minux.ma, bradfitz
CC=golang-codereviews
https://golang.org/cl/49600043
2014-01-08 21:40:33 -08:00
Russ Cox
2d55fdb507 debug/goobj: add String methods for SymID and SymKind
R=iant
CC=golang-codereviews
https://golang.org/cl/48890044
2014-01-08 20:37:41 -05:00
Russ Cox
06c0280440 libmach: use different names for different Ureg types
Everything was doing this already with #defines.
Do it right.

R=golang-codereviews, jsing, 0intro, iant
CC=golang-codereviews
https://golang.org/cl/49090043
2014-01-08 20:37:27 -05:00
Rob Pike
fca453e062 cmd/nm: add -sort=size
When printing the size, we often want to sort on that key.
Because it's used when looking for large things, make the
sort go from largest to smallest.

Perfect recreation of CL 45150044, which was lost to some blunder.

R=golang-codereviews, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/48500044
2014-01-08 15:56:40 -08:00
Keith Randall
e7d010a6a7 runtime: deallocate specials before deallocating the underlying object.
R=dvyukov
CC=golang-codereviews
https://golang.org/cl/48840043
2014-01-08 12:41:26 -08:00
Ian Lance Taylor
89c5d17878 runtime: handle gdb breakpoint in x86 traceback
This lets stack splits work correctly when running under gdb
when gdb has inserted a breakpoint somewhere on the call
stack.

Fixes #6834.

R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/48650043
2014-01-08 12:36:31 -08:00
Jeff Sickel
a03e8a5be0 plan9: lookup query must seek to offset 0 before reading or
writing /net/dns or /net/cs (see nbd(8)).

R=golang-codereviews
CC=0intro, golang-codereviews, rsc
https://golang.org/cl/49060043
2014-01-08 21:22:18 +01:00
Brad Fitzpatrick
e7c21703a8 archive/zip: new test for earlier zip64 fix
Update #7069

R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/49180043
2014-01-08 11:28:40 -08:00
Aram Hăvărneanu
f952d45508 all: add solaris build tags
R=golang-codereviews, minux.ma, gobot, rsc, dave
CC=golang-codereviews
https://golang.org/cl/36040043
2014-01-07 23:53:30 -05:00
Michael Hudson-Doyle
7178c05d05 cmd/go: test: do not put object files where later steps will find them
When recompiling a package whose basename is the name of a standard
package for testing with gccgo, a .o file with the basename of the
package being tested was being placed in the _test/ directory where the
compilation of the test binary then found it when looking for the
standard library package.

This change puts the object files in a separate directory.

Fixes #6793

R=golang-codereviews, dave, gobot, rsc, iant
CC=golang-codereviews
https://golang.org/cl/27650045
2014-01-07 23:53:16 -05:00
Keith Randall
020b39c3f3 runtime: use special records hung off the MSpan to
record finalizers and heap profile info.  Enables
removing the special bit from the heap bitmap.  Also
provides a generic mechanism for annotating occasional
heap objects.

finalizers
        overhead      per obj
old	680 B	      80 B avg
new	16 B/span     48 B

profile
        overhead      per obj
old	32KB	      24 B + hash tables
new	16 B/span     24 B

R=cshapiro, khr, dvyukov, gobot
CC=golang-codereviews
https://golang.org/cl/13314053
2014-01-07 13:45:50 -08:00
Brad Fitzpatrick
affab3f312 net/http: fix data race when sharing request body between client and server
A server Handler (e.g. a proxy) can receive a Request, and
then turn around and give a copy of that Request.Body out to
the Transport. So then two goroutines own that Request.Body
(the server and the http client), and both think they can
close it on failure.  Therefore, all incoming server requests
bodies (always *http.body from transfer.go) need to be
thread-safe.

Fixes #6995

R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/46570043
2014-01-07 10:40:56 -08:00
Shawn Smith
39a396d2ba encoding/csv: test that carriage return is handled in Write
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/46310043
2014-01-07 09:32:15 -08:00
Rémy Oudompheng
095de8795a cmd/gc: add missing dupok flag for interface method wrappers.
R=rsc
CC=golang-codereviews
https://golang.org/cl/48420044
2014-01-07 18:25:11 +01:00
Joel Sing
9a7fb68359 crypto/sha512: avoid duplicate block declaration on 386
Unbreak the build - we do not have a sha512 block implementation in
386 assembly (yet).

R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/48520043
2014-01-07 23:50:31 +11:00
Rémy Oudompheng
f303921251 cmd/gc: do not omit wrapper for expression (interface{...}).F
Fixes #6723.

R=rsc
CC=golang-codereviews
https://golang.org/cl/41570047
2014-01-07 13:26:48 +01:00
Joel Sing
0a37002367 crypto/sha512: block implementation in amd64 assembly
Benchmark on Intel(R) Xeon(R) CPU X5650  @ 2.67GHz

benchmark              old ns/op    new ns/op    delta
BenchmarkHash8Bytes         1779         1114  -37.38%
BenchmarkHash1K             9848         4894  -50.30%
BenchmarkHash8K            68513        32187  -53.02%

benchmark               old MB/s     new MB/s  speedup
BenchmarkHash8Bytes         4.50         7.18    1.60x
BenchmarkHash1K           103.97       209.19    2.01x
BenchmarkHash8K           119.57       254.51    2.13x

R=agl
CC=golang-codereviews
https://golang.org/cl/37150044
2014-01-07 23:16:46 +11:00
Aram Hăvărneanu
901e7bfe53 lib9, libmach, cmd/dist, go/build: add support for GOOS=solaris
This change adds solaris to the list of supported operating
systems and allows cmd/dist to be built on Solaris.

This CL has to come first because we want the tools to ignore
solaris-specific files until the whole port is integrated.

R=golang-codereviews, jsing, rsc, minux.ma
CC=golang-codereviews
https://golang.org/cl/35900045
2014-01-07 23:12:12 +11:00
Joel Sing
8f9844348f syscall: include mmap constants in netbsd zerror* files
Include the <sys/mman.h> header for NetBSD mkerrors.sh. This brings
in constants used with mmap(2), msync(2) and mlockall(2).

The regeneration of the NetBSD zerror* files also picks clone(2)
related constants.

Update #4929.

R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/45510044
2014-01-07 23:04:17 +11:00
Russ Cox
d227d680ec cmd/gc: use 100x less memory for []byte("string")
[]byte("string") was simplifying to
[]byte{0: 0x73, 1: 0x74, 2: 0x72, 3: 0x69, 4: 0x6e, 5: 0x67},
but that latter form takes up much more memory in the compiler.
Preserve the string form and recognize it to turn global variables
initialized this way into linker-initialized data.

Reduces the compiler memory footprint for a large []byte initialized
this way from approximately 10 kB/B to under 100 B/B.

See also issue 6643.

R=golang-codereviews, r, iant, oleku.konko, dave, gobot, bradfitz
CC=golang-codereviews
https://golang.org/cl/15930045
2014-01-06 20:43:44 -05:00
Adam Langley
78c16c9b16 crypto/rsa: support unpadded signatures.
Usually when a message is signed it's first hashed because RSA has low
limits on the size of messages that it can sign. However, some
protocols sign short messages directly. This isn't a great idea because
the messages that can be signed suddenly depend on the size of the RSA
key, but several people on golang-nuts have requested support for
this and it's very easy to do.

R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/44400043
2014-01-06 16:11:58 -05:00
Brad Fitzpatrick
90e9669c50 undo CL 44150043 / 198bdc0984dd
See https://golang.org/cl/44150043/

««« original CL description
regexp: use sync.Pool

For machines, not threads.

Update #4720

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

TBR=golang-dev
CC=golang-codereviews
https://golang.org/cl/48190043
2014-01-06 12:38:04 -08:00
Brad Fitzpatrick
02a15e7165 archive/zip: fix bug reading zip64 files
ZIP64 Extra records are variably sized, but we weren't capping
our reading of the extra fields at its previously-declared
size.

No test because I don't know how to easily create such files
and don't feel like manually construction one.  But all
existing tests pass, and this is "obviously correct" (queue
laughter).

Fixes #7069

R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/48150043
2014-01-06 10:43:56 -08:00
Matthew Cottingham
991e9a8331 net/http: Add more call order tests for request form parsing.
Adds tests for branches handling call ordering which
were shown to be untested by the cover tool.

This is part of the refactoring of form parsing discussed
in CL 44040043. These tests may need to be changed later but
should help lock in the current behaviour.

R=golang-codereviews, dave, bradfitz
CC=golang-codereviews
https://golang.org/cl/46750043
2014-01-06 10:36:04 -08:00
Bill Thiede
6576757927 hash/fnv: fix overview link currently returning 404.
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/47570043
2014-01-06 10:34:24 -08:00
Shawn Smith
16134060de time: add tests for Tick, NewTicker with negative duration
R=golang-codereviews, gobot, r, bradfitz
CC=golang-codereviews
https://golang.org/cl/37660044
2014-01-06 10:32:07 -08:00
Joel Sing
232a4e89a4 crypto/sha256: block implementation in 386 assembly
Benchmark on Intel(R) Core(TM) i5-2500S CPU @ 2.70GHz (albeit in a VM)

benchmark              old ns/op    new ns/op    delta
BenchmarkHash8Bytes         1606          699  -56.48%
BenchmarkHash1K            21920         7268  -66.84%
BenchmarkHash8K           165696        53756  -67.56%

benchmark               old MB/s     new MB/s  speedup
BenchmarkHash8Bytes         4.98        11.44    2.30x
BenchmarkHash1K            46.72       140.88    3.02x
BenchmarkHash8K            49.44       152.39    3.08x

R=agl, cldorian
CC=golang-codereviews
https://golang.org/cl/44800044
2014-01-06 13:31:22 -05:00
Volker Dobler
939b3fa39e net/http: remove todos from cookie code
The Domain and Path field of a parsed cookie have been
the unprocessed wire data since Go 1.0; this seems to
be okay for most applications so let's keep it.

Returning the unprocessed wire data makes it easy to
handle nonstandard or even broken clients without
consulting Raw or Unparsed of a cookie.

The RFC 6265 parsing rules for domain and path are
currently buried in net/http/cookiejar but could be
exposed in net/http if necessary.

R=bradfitz, nigeltao
CC=golang-codereviews
https://golang.org/cl/48060043
2014-01-06 10:00:58 -08:00
Volker Dobler
eb93f86275 net/http/cookiejar: document format of domain in PublicSuffix
Document what values a PublicSuffixList must accept as
a domain in a call to PublicSuffix.

R=bradfitz, nigeltao
CC=golang-codereviews
https://golang.org/cl/47560044
2014-01-06 10:00:20 -08:00
Emil Hessman
aeeda707ff runtime: Fix panic when trying to stop CPU profiling with profiler turned off
Fixes #7063.

R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/47950043
2014-01-06 09:53:55 -08:00
Joel Sing
29fe067ba7 crypto/sha1, crypto/sha256, crypto/sha512: use copy for partial block
Use copy rather than a hand rolled loop when moving a partial input
block to the scratch area. This results in a reasonable performance
gain when partial blocks are written.

Benchmarks on Intel(R) Xeon(R) CPU X5650  @ 2.67GHz with Go amd64:

       benchmark               old MB/s     new MB/s  speedup
SHA1   BenchmarkHash8Bytes        18.37        22.80    1.24x
SHA256 BenchmarkHash8Bytes        11.86        13.78    1.16x
SHA512 BenchmarkHash8Bytes         4.51         5.24    1.16x

       benchmark              old ns/op    new ns/op    delta
SHA1   BenchmarkHash8Bytes          435          350  -19.54%
SHA256 BenchmarkHash8Bytes          674          580  -13.95%
SHA512 BenchmarkHash8Bytes         1772         1526  -13.88%

R=agl, dave, bradfitz
CC=golang-codereviews
https://golang.org/cl/35840044
2014-01-06 01:34:56 +11:00
Shawn Smith
48334e3e91 container/list: improve test coverage
R=golang-codereviews, dave, gobot, bradfitz, gri
CC=golang-codereviews
https://golang.org/cl/46640043
2014-01-05 07:48:32 +11:00
Jeff Sickel
c136197ca8 runtime: plan 9 does have /dev/random
R=golang-codereviews, r, aram
CC=0intro, golang-codereviews, rsc
https://golang.org/cl/43420045
2014-01-04 10:53:22 -08:00
Keith Randall
f59ea4e58b runtime: Fix race detector checks to ignore KindNoPointers bit
when comparing kinds.

R=dvyukov, dave, khr
CC=golang-codereviews
https://golang.org/cl/41660045
2014-01-04 08:43:17 -08:00
Dave Cheney
30ba286c61 os: add tests for operations on nil *File methods
R=shawn.p.smith, gobot, r
CC=golang-codereviews
https://golang.org/cl/46820043
2014-01-04 09:58:04 +11:00
Dave Cheney
f2e946f9ed os: return ErrInvalid if receiver is nil.
Fixes #7043.

Test coming in https://golang.org/cl/46820043

R=r, bradfitz
CC=golang-codereviews
https://golang.org/cl/38330045
2014-01-04 08:25:09 +11:00
Daniel Morsing
f2e94b58a0 cmd/gc: silence assignment errors to undefined symbols
Fixes #6406.

R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/46900043
2014-01-03 21:03:20 +01:00
Emil Hessman
880442f110 encoding/json: Fix missing error when trying to unmarshal null string into int, for successive ,string option
Fixes #7046.

R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/47260043
2014-01-03 10:13:28 -08:00
Joel Sing
d180579170 syscall: handle varied path lengths for unix sockets
Most BSDs include the trailing NUL character of the socket path in the
length, however some do not (such as NetBSD 6.99). Handle this by only
subtracting the family and length bytes from the returned length, then
scanning the path and removing any terminating NUL bytes.

Fixes #6627.

R=golang-codereviews, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/46420044
2014-01-04 00:29:20 +11:00
David Symonds
8778760a7e runtime: increase attempt count for map iteration order test.
Some builders broke on this test; I'm guessing that was because
this test didn't try hard enough to find a different iteration order.

Update #6719

R=dave
CC=golang-codereviews
https://golang.org/cl/47300043
2014-01-03 10:41:56 +11:00
David Symonds
d4c66a35ba runtime: add a test for randomised map iteration order.
Technically the spec does not guarantee that the iteration order is random,
but it is a property that we have consciously pursued, and so it seems
right to verify that our implementation does indeed randomise.

Update #6719.

R=khr, bradfitz
CC=golang-codereviews
https://golang.org/cl/47010043
2014-01-03 10:10:54 +11:00
Shawn Smith
eaff83b98e encoding/hex: add Decode error test case
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/46880043
2014-01-02 10:34:21 -08:00
Shawn Smith
b38da05ab1 time: add tests for Duration.Nanoseconds, Duration.Minutes, and Duration.Hours
R=golang-codereviews, rsc, dave
CC=golang-codereviews
https://golang.org/cl/42440043
2014-01-02 21:01:18 +11:00
Dave Cheney
66730120fa encoding/json: add tests for InvalidUnmarshalError
R=golang-codereviews, shawn.p.smith
CC=golang-codereviews
https://golang.org/cl/41960047
2014-01-02 09:49:55 +11:00
Shawn Smith
4d239bcea2 bufio: improve NewReaderSize, Peek, and UnreadByte test coverage
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/42990045
2014-01-01 22:26:22 +11:00
Shawn Smith
a39f3b29ec encoding/json: improve omitempty test coverage
R=golang-codereviews, dave, bradfitz
CC=golang-codereviews
https://golang.org/cl/46250043
2014-01-01 17:54:06 +11:00
Shawn Smith
3c7d2e6af9 os: improve Readdir and Readdirnames test coverage
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/46450043
2014-01-01 16:40:52 +11:00
Shawn Smith
873271378b encoding/hex: add Decode test case with uppercase hex characters
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/46270043
2014-01-01 16:32:05 +11:00
Michael Stapelberg
592416a387 debug/elf: add C source for testdata executables
This source file, when compiled with gcc 4.4.3 on Ubuntu lucid,
corresponds instruction for instruction to the binaries in the same
directory.

Shipping this source code file resolves http://bugs.debian.org/716853

R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/46780043
2013-12-31 14:36:13 -08:00
Shawn Smith
e3040e2bba crypto/sha256: add tests for Size() and BlockSize()
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/46470043
2014-01-01 07:46:00 +11:00
Shawn Smith
0333e80d63 crypto/sha1: add tests for Size() and BlockSize()
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/46400044
2013-12-31 23:13:05 +11:00
Shawn Smith
a1731ac078 container/ring: add test for Move with empty Ring
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/46630044
2013-12-31 21:18:40 +11:00
Mikio Hara
b4571bdfe8 net: fix typo
R=golang-codereviews, bradfitz, dave
CC=golang-codereviews
https://golang.org/cl/46600043
2013-12-31 18:52:37 +09:00
Shawn Smith
dcf562dfb6 crypto/sha512: add tests for Size() and BlockSize()
R=golang-codereviews, bradfitz, dave
CC=golang-codereviews
https://golang.org/cl/43550047
2013-12-31 19:29:09 +11:00
Josh Bleecher Snyder
ff006982c3 text/template: don't panic when using AddParseTree with an unparsed template
Fixes #7032.

R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/43960045
2013-12-30 17:17:19 -08:00
Keith Randall
0ea20bc981 cmd/6g: inline copies of up to 4 words in length.
This change fixes a serious performance regression
with reflect.Value growing to 4 words instead of 3.
The json benchmark was ~50% slower, with this change
it is ~5% slower (and the binary is 0.5% larger).

Longer term, we probably need to rethink our copy
generation.  Using REP is really expensive time-wise.
But inlining the copy grows the binary.

R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/44990043
2013-12-30 12:14:27 -08:00
Keith Randall
1cc2ff8fc7 runtime: use readrange instead of read to check for races
on map keys and values which are now passed by reference.

R=dvyukov, khr
CC=golang-codereviews
https://golang.org/cl/43490044
2013-12-30 12:03:56 -08:00
Richard Musiol
7ff57e2fa1 reflect: fixed method name in Slice3 error message
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/46500043
2013-12-30 11:41:01 -08:00
Shawn Smith
96ee10fb71 reflect: add DeepEqual slice of slice inequality test
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/46510043
2013-12-30 11:39:47 -08:00
Shawn Smith
c989a0b2f7 reflect: remove length check for arrays in deepValueEqual
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/39910044
2013-12-29 11:05:30 -08:00
Shawn Smith
36c8c5f063 io: add tests for SectionReader ReadAt and Size
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/39200045
2013-12-29 22:38:05 +11:00
Shawn Smith
351caa4b91 crypto/hmac: add tests for Size() and BlockSize()
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/41320044
2013-12-29 20:56:05 +11:00
Dave Cheney
d2fe44d568 runtime: load runtime.goarm as a byte, not a word
Fixes #6952.

runtime.asminit was incorrectly loading runtime.goarm as a word, not a uint8 which made it subject to alignment issues on arm5 platforms.

Alignment aside, this also meant that the top 3 bytes in R11 would have been garbage and could not be assumed to be setting up the FPU reliably.

R=iant, minux.ma
CC=golang-codereviews
https://golang.org/cl/46240043
2013-12-29 15:25:34 +11:00
Ian Lance Taylor
672525a56e net: work around Solaris connect issue when server closes socket
On Solaris, if you do a in-progress connect, and then the
server accepts and closes the socket, the client's later
attempt to complete the connect will fail with EINVAL.  Handle
this case by assuming that the connect succeeded.  This code
is weird enough that it is implemented as Solaris-only so that
it doesn't hide a real error on a different OS.

Update #6828

R=golang-codereviews, bradfitz, dave
CC=golang-codereviews
https://golang.org/cl/46160043
2013-12-28 09:37:54 -08:00
Shawn Smith
872f5ffa09 bytes: add test for Contains
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/46140043
2013-12-28 20:33:05 +11:00
Shawn Smith
42cea1a452 archive/tar: add test case for passing nil to FileInfoHeader
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/44710044
2013-12-28 16:14:49 +11:00
Martin Olsson
5499034a71 all: fix a few spelling errors in source comments
R=golang-codereviews, dave, iant
CC=golang-codereviews
https://golang.org/cl/45750044
2013-12-27 08:59:02 -08:00
Ian Lance Taylor
4aa521a77d net: use DialTimeout in TestSelfConnect
This avoids problems with systems that take a long time to
find out nothing is listening, while still testing for the
self-connect misfeature since a self-connect should be fast.
With this we may be able to remove the test for non-Linux
systems.

Tested (on GNU/Linux) by editing selfConnect in
tcpsock_posix.go to always return false and verifying that
TestSelfConnect then fails with and without this change.

Idea from Uros Bizjak.

R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/39200044
2013-12-27 08:49:47 -08:00
Shawn Smith
d1a9143669 strconv: add tests for FormatBool and AppendBool
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/42480043
2013-12-27 08:40:14 -08:00
Shawn Smith
f485e9859a strconv: remove unused atof32int function
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/44200044
2013-12-27 08:40:03 -08:00
Shawn Smith
4133407061 crypto/cipher: remove unused shift1 function
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/38990045
2013-12-27 08:39:54 -08:00
Brad Fitzpatrick
2ccc9a965b net/http: quiet distracting test spam
Capture log output (and test it while at it),
and quiet unnecessary t.Logf.

R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/45850043
2013-12-26 13:03:30 -08:00
Brad Fitzpatrick
1fa0206024 net/http: fix data race in benchmark
Fixes #7006

R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/44940044
2013-12-26 12:16:11 -08:00
John Newlin
92b5e16147 net/http: Release reference to chunkWriter's bufio.Writer on hijack
When a connection is hijacked, release the reference to the bufio.Writer
that is used with the chunkWriter.  The chunkWriter is not used after
the connection is hijacked.

Also add a test to check that double Hijack calls do something sensible.

benchmark                old ns/op    new ns/op    delta
BenchmarkServerHijack        24137        20629  -14.53%

benchmark               old allocs   new allocs    delta
BenchmarkServerHijack           21           19   -9.52%

benchmark                old bytes    new bytes    delta
BenchmarkServerHijack        11774         9667  -17.90%

R=bradfitz, dave, chris.cahoon
CC=golang-codereviews
https://golang.org/cl/39440044
2013-12-26 11:52:14 -08:00
Marko Tiikkaja
0d12e24ebb database/sql: Use all connections in pool
The last connection in the pool was not being handed out correctly.

R=golang-codereviews, gobot, bradfitz
CC=golang-codereviews
https://golang.org/cl/40410043
2013-12-26 11:27:18 -08:00
Ian Lance Taylor
59583b09f3 runtime/cgo: include <signal.h> to fix build
R=golang-codereviews
TBR=dfc
CC=golang-codereviews
https://golang.org/cl/43120044
2013-12-24 08:24:32 -08:00
Ian Lance Taylor
699dbb60b7 runtime/cgo: always set signal mask before calling pthread_create
This was done correctly for most targets but was missing from
FreeBSD/ARM and Linux/ARM.

R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/45180043
2013-12-24 08:08:15 -08:00
S.Çağlar Onur
41183d015d cgo/runtime: replace sigprocmask with pthread_sigmask.
sigprocmask use in a multithreaded environment is undefined so replace it with pthread_sigmask.

Fixes #6811.

R=jsing, iant
CC=golang-codereviews, golang-dev
https://golang.org/cl/30460043
2013-12-22 08:55:29 -08:00
Shawn Smith
7054890715 bytes, strings: improve Title test coverage by adding cases with underscore and unicode line separator
R=golang-codereviews, gobot, r
CC=golang-codereviews
https://golang.org/cl/42310045
2013-12-20 23:19:32 -08:00
David du Colombier
4237ffe5ea os: reimplement HasPrefix and LastIndex to not depend on strings
R=golang-codereviews, rsc
CC=golang-codereviews, jas
https://golang.org/cl/44790043
2013-12-21 01:22:10 +01:00
Russ Cox
145edc283f cmd/gc: do not compute dead value maps if they will not be used
Reduces 6g big.go memory usage from 251 MB to 242 MB.
Reduces 6g slow.go memory usage from 529 MB to 453 MB.

Mostly a memory savings; 6g slow.go is only about 5% faster.

The test programs are at
https://rsc.googlecode.com/hg/testdata/big.go (36k lines, 276kB)
https://rsc.googlecode.com/hg/testdata/slow.go (7k lines, 352kB)

R=golang-codereviews, bradfitz, iant
CC=golang-codereviews
https://golang.org/cl/42280045
2013-12-20 19:14:42 -05:00
Jakub Ryszard Czarnowicz
57e27a879e net/http: empty contenty-type treated as application/octet-stream
RFC 2616, section 7.2.1 - empty type SHOULD be treated as
application/octet-stream.
Fixes #6616.

R=golang-codereviews, gobot, bradfitz, josharian
CC=golang-codereviews
https://golang.org/cl/31810043
2013-12-20 11:49:42 -08:00
Russ Cox
0e97f4187e cmd/gc: address 1½ liveness bottlenecks
As much as 7x speedup on some programs, cuts all.bash time by 20%.

Change splicebefore function from O(n) to O(1).
The approach was suggested by Carl during the code's review
but apparently did not make it into the tree.
It makes a huge difference on huge programs.

Make twobitwalktype1 slightly faster by using & instead of %.
Really it needs to be cached; left a note to that effect.
(Not a complete fix, hence the ½.)

big.go (output of test/chan/select5.go)
 47.53u   0.50s  48.14r before this CL
  7.09u   0.47s   7.59r with splicebefore change (6.7x speedup)
  6.15u   0.42s   6.59r with twobitwalktype1 change (1.15x speedup; total 7.7x)

slow.go (variant of program in go.text, by mpvl)
 77.75u   2.11s  80.03r before this CL
 24.40u   1.97s  26.44r with splicebefore change (3.2x speedup)
 18.12u   2.19s  20.38r with twobitwalktype1 change (1.35x speedup; total 4.3x)

test/run
150.63u  49.57s  81.08r before this CL
 88.01u  45.60s  46.65r after this CL (1.7x speedup)

all.bash
369.70u 115.64s 256.21r before this CL
298.52u 110.35s 214.67r after this CL (1.24x speedup)

The test programs are at
https://rsc.googlecode.com/hg/testdata/big.go (36k lines, 276kB)
https://rsc.googlecode.com/hg/testdata/slow.go (7k lines, 352kB)

R=golang-codereviews, gobot, r
CC=cshapiro, golang-codereviews
https://golang.org/cl/43210045
2013-12-20 14:24:48 -05:00
Russ Cox
4acb70d377 cmd/gc: bypass DATA instruction for data initialized to integer constant
Eventually we will want to bypass DATA for everything,
but the relocations are not standardized well enough across
architectures to make that possible.

This did not help as much as I expected, but it is definitely better.
It shaves maybe 1-2% off all.bash depending on how much you
trust the timings of a single run:

Before: 241.139r 362.702u 112.967s
After:  234.339r 359.623u 111.045s

R=golang-codereviews, gobot, r, iant
CC=golang-codereviews
https://golang.org/cl/44650043
2013-12-20 14:24:39 -05:00
Rob Pike
dc8572c3fe sync: explain Pool's intentions
Expand the type's doc comment to make its purpose clear
and discourage misuse.

R=golang-codereviews, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/44680043
2013-12-20 11:15:50 -08:00
Brad Fitzpatrick
568a449bd1 io/ioutil: use sync.Pool in Discard
And merge the blackhole.go file back into ioutil,
where it once was. It was only in a separate file
because it used to have race-vs-!race versions.

R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/44060044
2013-12-20 09:38:35 -08:00
Russ Cox
1334b794b7 libmach: remove old object file readers
These no longer work; removing them makes other refactoring easier.
The code for pack P being deleted in this CL does not work either.
I created issue 6989 to track restoring this functionality (probably not
until pack is written in Go).

R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/44300043
2013-12-20 12:10:53 -05:00
Adam Langley
6f149492bf crypto/tls: rework reference tests.
The practice of storing reference connections for testing has worked
reasonably well, but the large blocks of literal data in the .go files
is ugly and updating the tests is a real problem because their number
has grown.

This CL changes the way that reference tests work. It's now possible to
automatically update the tests and the test data is now stored in
testdata/. This should make it easier to implement changes that affect
all connections, like implementing the renegotiation extension.

R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/42060044
2013-12-20 11:37:05 -05:00
Alex A Skinner
487dff1852 net: ParseIP should return nil if :: doesn't expand in an IPv6 address.
Per RFC 4291, 'The use of "::" indicates one or more groups of 16 bits of zeros.'
Fixes #6628

R=golang-dev, rsc, minux.ma, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/15990043
2013-12-20 21:29:28 +09:00
Shenghou Ma
eb7ed0d626 runtime: fix build for OpenBSD
R=golang-dev
CC=golang-dev
https://golang.org/cl/38030045
2013-12-19 21:12:18 -05:00
Shenghou Ma
0097d30c97 runtime: unblock signals when we try to core dump
Fixes #6988.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/44070046
2013-12-19 20:45:05 -05:00
Keith Randall
cbc565a801 reflect: rewrite Value to separate out pointer vs. nonpointer info.
Needed for precise gc and copying stacks.

reflect.Value now takes 4 words instead of 3.

Still to do:
 - un-iword-ify channel ops.
 - un-iword-ify method receivers.

R=golang-dev, iant, rsc, khr
CC=golang-dev
https://golang.org/cl/43040043
2013-12-19 15:15:24 -08:00
Russ Cox
c9f12d2289 liblink: allow either of a pair of conflicting symbols to say dupok
This makes the linker's -X flag work again.

R=iant
CC=bradfitz, golang-codereviews, golang-dev
https://golang.org/cl/44360043
2013-12-19 16:52:47 -05:00
Brad Fitzpatrick
cbf6ff3b90 net/http: add Hihack benchmark
Notably, to show allocs. Currently: 11766 B/op, 21 allocs/op,
at least one alloc of which is in the benchmark loop itself.

R=golang-dev, jnewlin
CC=golang-dev
https://golang.org/cl/40370057
2013-12-19 13:24:42 -08:00
Rémy Oudompheng
e6b023473e runtime: reduce delays in finalizer test.
The runtime tests are executed 4 times in all.bash
and there is currently a 5-second delay each time.

R=golang-dev, minux.ma, khr, bradfitz
CC=golang-dev
https://golang.org/cl/42450043
2013-12-19 21:37:44 +01:00
David du Colombier
16dcef80d4 os: rename only works as part of the same directory on Plan 9
R=golang-dev, lucio.dere, rsc
CC=golang-dev
https://golang.org/cl/44080046
2013-12-19 21:20:03 +01:00
Rob Pike
6f6ff95183 go/build: mention 'tag' as an alias for 'build constraint'
The code is all about tags, and the cmd/go documentation
said to look in the go/build documentation for information
about tags, but the documentation said nothing about tags,
only build constraints. Make things clearer.

R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/44100043
2013-12-19 11:43:34 -08:00
Adam Langley
9144ef3321 crypto/x509: import crypto/sha256
Since SHA-256 is now the default hash function, x509 should import it
otherwise some programs may fail because it hasn't been linked in.

R=golang-dev, dave, minux.ma
CC=golang-dev
https://golang.org/cl/44010047
2013-12-19 14:06:28 -05:00
ChaiShushan
0b26ba8af3 cmd/yacc: expr example support windows
1. expr append executable extension.
2. support '\r' character.

Fixes #6851.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/35330043
2013-12-19 12:14:07 -05:00
Joel Sing
0eaabf6452 cmd/ld: make hostobj work on newer openbsd
Make hostobj work on OpenBSD 5.3/5.4/-current - these have PIE
enabled by default and linking fails since the Go linker generates
objects that are neither PIC nor PIE.

Fixes #5067

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7572049
2013-12-20 03:58:27 +11:00
Mikio Hara
efd1d05023 net: rename TestReadConfig to TestDNSReadConfig
To make it possible to type "go test -run=DNS".
Also removes unnecessary parens.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/43470051
2013-12-19 13:02:06 +09:00
Alex Brainman
7f8a5057dd syscall: add NewCallbackCDecl again
Fixes #6338

R=golang-dev, kin.wilson.za, rsc
CC=golang-dev
https://golang.org/cl/36180044
2013-12-19 14:38:50 +11:00
Alex Brainman
f18e2a3271 runtime/pprof: skip tests that fail on windows-amd64-race builder
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/44180043
2013-12-19 14:15:57 +11:00
Brad Fitzpatrick
0594f89489 compress/flate: use io.ByteReader in docs
We did this elsewhere when io.ByteReader was added
but forgot this one.

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/43480052
2013-12-18 18:24:55 -08:00
Keith Randall
2d20c0d625 runtime: mark objects in free lists as allocated and unscannable.
On the plus side, we don't need to change the bits when mallocing
pointerless objects.  On the other hand, we need to mark objects in the
free lists during GC.  But the free lists are small at GC time, so it
should be a net win.

benchmark                    old ns/op    new ns/op    delta
BenchmarkMalloc8                    40           33  -17.65%
BenchmarkMalloc16                   45           38  -15.72%
BenchmarkMallocTypeInfo8            58           59   +0.85%
BenchmarkMallocTypeInfo16           63           64   +1.10%

R=golang-dev, rsc, dvyukov
CC=cshapiro, golang-dev
https://golang.org/cl/41040043
2013-12-18 17:13:59 -08:00
Mikio Hara
7eb45d3c4a net: don't return a nested error when happy eyeballs dialing
Also removes an unused variable.

Fixes #6795.

R=adg, dave, bradfitz, gobot
CC=golang-dev
https://golang.org/cl/29440043
2013-12-19 10:00:15 +09:00
Brad Fitzpatrick
b682f6de5a regexp: use sync.Pool
For machines, not threads.

Update #4720

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/44150043
2013-12-18 16:43:19 -08:00
Russ Cox
4890502af6 liblink: use explicit field for globl duplicate detection
Overloading size leads to problems if clients
try to set up an LSym by hand.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/44140043
2013-12-18 19:36:14 -05:00
Russ Cox
2404b7f168 debug/goobj: expand package prefix correctly
R=r, bradfitz
CC=golang-dev
https://golang.org/cl/43480049
2013-12-18 19:00:52 -05:00
David du Colombier
674606503e syscall: disallow slashes in file names on Plan 9
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/43480050
2013-12-19 00:58:23 +01:00
Brad Fitzpatrick
93e4a9d84c net/http: use sync.Pool
Update #4720

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/44080043
2013-12-18 15:52:20 -08:00
Brad Fitzpatrick
46b4ed2cf0 encoding/json: use sync.Pool
Benchmark is within the noise. I had to run this a dozen times
each before & after (on wall power, without a browser running)
before I could get halfway consistent numbers, and even then
they jumped all over the place, with the new one sometimes
being better. But these are the best of a dozen each.

Slowdown is expected anyway, since I imagine channels are
optimized more.

benchmark                 old ns/op    new ns/op    delta
BenchmarkCodeEncoder       26556987     27291072   +2.76%
BenchmarkEncoderEncode         1069         1071   +0.19%

benchmark                  old MB/s     new MB/s  speedup
BenchmarkCodeEncoder          73.07        71.10    0.97x

benchmark                old allocs   new allocs    delta
BenchmarkEncoderEncode            2            2    0.00%

benchmark                 old bytes    new bytes    delta
BenchmarkEncoderEncode          221          221    0.00%

Update #4720

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/37720047
2013-12-18 15:52:05 -08:00
Dave Cheney
3f6dbfc44c liblink, cmd/gc: resolve several shift warnings
Address several warnings generated by clang -fsanitize=undefined

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/43050043
2013-12-19 10:34:33 +11:00
Shenghou Ma
8606b97690 cmd/go: show testflag help for "go test -h"
Fixes #6576.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/14502065
2013-12-18 17:40:31 -05:00
Mikio Hara
2b3ad827a6 net: add test cases for the both of netgo, cgo DNS lookups
Update #4078

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/14638043
2013-12-19 07:40:10 +09:00
Jakob Borg
2b693b7c19 encoding/asn1: Fix parsing of non-printable strings in
sequences.

Use the same criteria for when to modify the tag type when
parsing a string in a sequence as when parsing a bare string
field.

Fixes #6726.

R=golang-dev, bradfitz, gobot, agl
CC=golang-dev
https://golang.org/cl/22460043
2013-12-18 17:06:17 -05:00
Jeff R. Allen
17dc712c18 math/rand: Float32/64 must only return values in [0,1)
Float32 and Float64 are now both created by taking the ratio
of two integers which are chosen to fit entirely into the
precision of the desired float type. The previous code
could cast a Float64 with more than 23 bits of ".99999"
into a Float32 of 1.0, which is not in [0,1).

Float32 went from 15 to 21 ns/op (but is now correct).

Fixes #6721.

R=golang-dev, iant, rsc
CC=golang-dev
https://golang.org/cl/22730043
2013-12-18 15:38:53 -05:00
ChaiShushan
3d2c4df983 cmd/yacc: gofmt y.go
R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/36950043
2013-12-18 15:17:08 -05:00
Nigel Tao
ff6b922361 image/gif: respect local color table transparency.
Fixes #6441.

R=r
CC=andybons, golang-dev
https://golang.org/cl/13829043
2013-12-18 15:10:40 -05:00
David du Colombier
9607255760 cmd/6g, cmd/gc, cmd/ld: fix Plan 9 amd64 warnings
warning: src/cmd/6g/reg.c:671 format mismatch d VLONG, arg 4
warning: src/cmd/gc/pgen.c:230 set and not used: oldstksize
warning: src/cmd/gc/plive.c:877 format mismatch lx UVLONG, arg 2
warning: src/cmd/gc/walk.c:2878 set and not used: cbv
warning: src/cmd/gc/walk.c:2885 set and not used: hbv
warning: src/cmd/ld/data.c:198 format mismatch s IND FUNC(IND CHAR) INT, arg 2
warning: src/cmd/ld/data.c:230 format mismatch s IND FUNC(IND CHAR) INT, arg 2
warning: src/cmd/ld/dwarf.c:1517 set and not used: pc
warning: src/cmd/ld/elf.c:1507 format mismatch d VLONG, arg 2
warning: src/cmd/ld/ldmacho.c:509 set and not used: dsymtab

R=golang-dev, gobot, rsc
CC=golang-dev
https://golang.org/cl/36740045
2013-12-18 20:20:46 +01:00
David du Colombier
ef0100c7d7 libmach, cmd/8l: fix Plan 9 warnings
warning: src/libmach/sym.c:1861 non-interruptable temporary
warning: src/cmd/8l/../ld/pcln.c:29 set and not used: p

R=golang-dev, gobot, rsc
CC=golang-dev
https://golang.org/cl/40500043
2013-12-18 20:19:59 +01:00
David du Colombier
6e97513012 liblink: fix Plan 9 warnings
warning: src/liblink/asm5.c:485 non-interruptable temporary
warning: src/liblink/asm5.c:565 set and not used: c
warning: src/liblink/asm5.c:622 format mismatch ux VLONG, arg 2
warning: src/liblink/asm5.c:1218 overspecified class: asmout GLOBL STATIC
warning: src/liblink/asm5.c:2088 overspecified class: oprrr GLOBL STATIC
warning: src/liblink/asm5.c:2202 overspecified class: opbra GLOBL STATIC
warning: src/liblink/asm5.c:2237 overspecified class: olr GLOBL STATIC
warning: src/liblink/asm5.c:2266 overspecified class: olhr GLOBL STATIC
warning: src/liblink/asm5.c:2291 overspecified class: osr GLOBL STATIC
warning: src/liblink/asm5.c:2302 overspecified class: oshr GLOBL STATIC
warning: src/liblink/asm5.c:2312 overspecified class: osrr GLOBL STATIC
warning: src/liblink/asm5.c:2319 overspecified class: oshrr GLOBL STATIC
warning: src/liblink/asm5.c:2325 overspecified class: olrr GLOBL STATIC
warning: src/liblink/asm5.c:2332 overspecified class: olhrr GLOBL STATIC
warning: src/liblink/asm5.c:2338 overspecified class: ofsr GLOBL STATIC
warning: src/liblink/asm5.c:2375 overspecified class: omvl GLOBL STATIC
warning: src/liblink/asm8.c:1261 format mismatch d VLONG, arg 3
warning: src/liblink/asm8.c:1274 format mismatch +d VLONG, arg 5
warning: src/liblink/list5.c:153 format mismatch d VLONG, arg 3
warning: src/liblink/list5.c:310 format mismatch d VLONG, arg 3
warning: src/liblink/obj6.c:665 set and not used: q
warning: src/liblink/pcln.c:32 set and not used: p

R=golang-dev, jas, gobot, rsc
CC=golang-dev
https://golang.org/cl/40370043
2013-12-18 20:19:29 +01:00
Brad Fitzpatrick
0f9311811c fmt: use sync.Pool
Update #4720

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/43990043
2013-12-18 11:09:07 -08:00
Brad Fitzpatrick
8c6ef061e3 sync: add Pool type
Adds the Pool type and docs, and use it in fmt.
This is a temporary implementation, until Dmitry
makes it fast.

Uses the API proposal from Russ in http://goo.gl/cCKeb2 but
adds an optional New field, as used in fmt and elsewhere.
Almost all callers want that.

Update #4720

R=golang-dev, rsc, cshapiro, iant, r, dvyukov, khr
CC=golang-dev
https://golang.org/cl/41860043
2013-12-18 11:08:34 -08:00
Ian Lance Taylor
0830f64bf0 liblink: don't search for an import file with an absolute path
This restores the old behaviour, and makes it possible to
continue to use 6g and 6l directly, rather than the go tool,
with dot imports.

R=rsc
CC=golang-dev
https://golang.org/cl/43710043
2013-12-18 10:33:47 -08:00
Russ Cox
f48120ef51 cmd/nm: minor cleanup from previous CL
I forgot to apply Ian's suggestions before submitting CL 40600043.

R=iant
CC=golang-dev
https://golang.org/cl/43560045
2013-12-18 13:29:40 -05:00
Shawn Smith
b758d8703a encoding/csv: remove unused unreadRune function
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/37720046
2013-12-18 13:29:27 -05:00
Shawn Smith
a025e1caac html: add tests for UnescapeString edge cases
R=golang-dev, gobot, bradfitz
CC=golang-dev
https://golang.org/cl/40810044
2013-12-18 10:20:25 -08:00
Shawn Smith
c22e79b37b encoding/asn1: add more test cases for BitString.At and TestUTCTime, add test for ObjectIdentifier.Equal
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/42740043
2013-12-18 10:19:07 -08:00
Shawn Smith
aa20d26292 encoding/json: add test for HTMLEscape
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/38220044
2013-12-18 10:18:35 -08:00
Robert Griesemer
108d35bd8e go/ast: added example illustrating CommentMap use.
R=bradfitz
CC=golang-dev
https://golang.org/cl/43930043
2013-12-18 10:10:40 -08:00
Shawn Smith
9d1832f227 encoding/ascii85: add empty string case for Encode test
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/36830046
2013-12-18 08:33:59 -08:00
Anfernee Yongkun Gui
b3f38b4630 net: test dnsconfig_unix with sample resolv.conf
R=golang-dev, adg, bradfitz, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/21580043
2013-12-18 08:26:36 -08:00
Adam Langley
ca3ff9251d crypto/x509: set default signature hash to SHA256 and allow override.
Previously the hash used when signing an X.509 certificate was fixed
and, for RSA, it was fixed to SHA1. Since Microsoft have announced the
deprecation of SHA1 in X.509 certificates, this change switches the
default to SHA256.

It also allows the hash function to be controlled by the caller by
setting the SignatureAlgorithm field of the template.

[1] http://blogs.technet.com/b/pki/archive/2013/11/12/sha1-deprecation-policy.aspx

Fixes #5302.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/40720047
2013-12-18 10:57:56 -05:00
Josh Bleecher Snyder
4f23481483 crypto/x509: add non-cgo darwin system anchor certs
The set of certs fetched via exec'ing `security` is not quite identical
to the certs fetched via the cgo call. The cgo fetch includes
any trusted root certs that the user may have added; exec does not.
The exec fetch includes an Apple-specific root cert; the cgo fetch
does not. Other than that, they appear to be the same.

Unfortunately, os/exec depends on crypto/x509, via net/http. Break the
circular dependency by moving the exec tests to their own package.

This will not work in iOS; we'll cross that bridge when we get to it.

R=golang-dev, minux.ma, agl
CC=golang-dev
https://golang.org/cl/22020045
2013-12-18 10:57:07 -05:00
Brad Fitzpatrick
626da8d737 encoding/json: speed up decoding
Don't make copies of keys while decoding, and don't use the
expensive strings.EqualFold when it's not necessary. Instead,
note in the existing field cache what algorithm to use to
check fold equality... most keys are just ASCII letters.

benchmark               old ns/op    new ns/op    delta
BenchmarkCodeDecoder    137074314    103974418  -24.15%

benchmark                old MB/s     new MB/s  speedup
BenchmarkCodeDecoder        14.16        18.66    1.32x

Update #6496

R=golang-dev, rsc, adg, r, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/13894045
2013-12-18 07:30:21 -08:00
Andrew Gerrand
9f2b2dfa86 log: fix example (fix build)
R=golang-dev
CC=golang-dev
https://golang.org/cl/43780043
2013-12-18 17:25:23 +11:00
ChaiShushan
8c530becaf log: add example
Fixes #6028.

R=golang-dev, bradfitz, adg, r
CC=golang-dev
https://golang.org/cl/43320043
2013-12-18 16:24:11 +11:00
ChaiShushan
8eb508dd08 flag: remove unused FlagSet.exitOnError field
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/14279043
2013-12-17 23:18:12 -05:00
Mikio Hara
f439e07b1b net: make TestDNSThreadLimit execute at the end of tests
Because TestDNSThreadLimit consumes tons of file descriptors and
makes other tests flaky when CGO_ENABLE=0 or being with netgo tag.

Fixes #6580.

R=golang-dev, bradfitz, adg, minux.ma
CC=golang-dev
https://golang.org/cl/14639044
2013-12-18 13:05:47 +09:00
Shenghou Ma
8ce584c2aa liblink: rewrite '\\' in paths to '/' on windows
At least three Go tests rely on that (log, runtime/{pprof,debug}).

Fixes #6972.
Fixes #6974.
Fixes #6975.

R=alex.brainman, mattn.jp, rsc
CC=golang-dev
https://golang.org/cl/43150043
2013-12-17 22:40:13 -05:00
Alex Brainman
ae9e4db07c runtime: skip broken TestRuntimeGogoBytes on windows
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/43730043
2013-12-18 14:17:47 +11:00
Russ Cox
c86fc68ac6 cmd/go: avoid use of 'go tool pack'
All packages now use the -pack option to the compiler.
For a pure Go package, that's enough.
For a package with additional C and assembly files, the extra
archive entries can be added directly (by concatenation)
instead of by invoking go tool pack.

These changes make it possible to rewrite cmd/pack in Go.

R=iant, r
CC=golang-dev
https://golang.org/cl/42910043
2013-12-17 21:44:36 -05:00
Russ Cox
b2d43caa7a cmd/dist: avoid use of 'go tool pack'
All packages now use the -pack option to the compiler.
For a pure Go package, that's enough.
For a package with additional C and assembly files, the extra
archive entries can be added directly (by concatenation)
instead of by invoking go tool pack.

These changes make it possible to rewrite cmd/pack in Go.

R=iant, r
CC=golang-dev
https://golang.org/cl/42890043
2013-12-17 21:44:18 -05:00
Russ Cox
b022334029 cmd/gc: implement -pack flag
The -pack flag causes 5g, 6g, 8g to write a Go archive directly,
instead of requiring the use of 'go tool pack' to convert the .5/.6/.8
to .a format.

Writing directly avoids the copy and also avoids having the
export data stored twice in the archive (once in __.PKGDEF,
once in .5/.6/.8).

A separate CL will enable the use of this flag by cmd/go.

Other build systems that do not know about -pack will be unaffected.

The changes to cmd/ld handle a minor simplification to the format:
an unused section is removed.

R=iant, r
CC=golang-dev
https://golang.org/cl/42880043
2013-12-17 21:43:33 -05:00
Keith Randall
deb554934c runtime, gc: call interface conversion routines by reference.
Part of getting rid of vararg C calls.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/23310043
2013-12-17 16:55:06 -08:00
David du Colombier
bccf029fc0 net: rewrite toLower more clearly
Rob suggested this change.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/43670044
2013-12-17 16:32:27 -08:00
Keith Randall
9aae6c1a8b runtime: don't store evacuate bit as low bit of hashtable overflow pointer.
Hash tables currently store an evacuated bit in the low bit
of the overflow pointer.  That's probably not sustainable in the
long term as GC wants correctly typed & aligned pointers.  It is
also a pain to move any of this code to Go in the current state.

This change moves the evacuated bit into the tophash entries.

Performance change is negligable.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/14412043
2013-12-17 15:23:31 -08:00
Marko Tiikkaja
ab05a855c6 database/sql: Fix inaccurate comment
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/40370051
2013-12-17 14:53:31 -08:00
Michael Hudson-Doyle
0a6ad46b4f reflect: Add tests for Call with functions taking and returning structs.
gccgo has problems using reflect.Call with functions that take and
return structs with no members.  Prior to fixing that problem there, I
thought it sensible to add some tests of this situation.

Update #6761

First contribution to Go, apologies in advance if I'm doing it wrong.

R=golang-dev, dave, minux.ma, iant, khr, bradfitz
CC=golang-dev
https://golang.org/cl/26570046
2013-12-17 14:49:51 -08:00
Caleb Spare
e9895d92e0 container/list: Add missing period to doc comment for Front
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/38540046
2013-12-17 14:21:11 -08:00
David du Colombier
e87b171013 net: reimplement toLower to not depend on strings
R=golang-dev, r, bradfitz
CC=golang-dev, jas
https://golang.org/cl/43610043
2013-12-17 14:19:11 -08:00
Brad Fitzpatrick
4b76a31c6d runtime: don't crash in SetFinalizer if sizeof *x is zero
And document it explicitly, even though it already said
it wasn't guaranteed.

Fixes #6857

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/43580043
2013-12-17 14:18:58 -08:00
Arne Hormann
a1a3d21355 database/sql: fix typo in comment
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/43300043
2013-12-18 08:17:43 +11:00
Brad Fitzpatrick
ff8e45828c os: avoid a string concat in readdir
R=golang-dev, crawshaw
CC=golang-dev
https://golang.org/cl/37690045
2013-12-17 12:25:32 -08:00
Brad Fitzpatrick
6a1a2170bc os, path/filepath: don't ignore Lstat errors in Readdir
os: don't ignore LStat errors in Readdir. If it's ENOENT,
on the second pass, just treat it as missing. If it's another
error, it's real.

path/filepath: use ReaddirNames instead of Readdir in Walk,
in order to obey the documented WalkFunc contract of returning
each walked item's LStat error, if any.

Fixes #6656
Fixes #6680

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/43530043
2013-12-17 12:19:01 -08:00
Julien Schmidt
762a9d934e database/sql: fix auto-reconnect in prepared statements
This also fixes several connection leaks.
Fixes #5718

R=bradfitz, adg
CC=alberto.garcia.hierro, golang-dev
https://golang.org/cl/14920046
2013-12-17 11:57:30 -08:00
Rob Pike
a075fdbaa6 image: roll back 13239051 (add RGB and RGB48)
They cause too much bloat in the internals as we find ourselves adding
special case code for all the cross-connections. It's better to use RGBA
and just max out the alpha. We lose a little memory but reduce the number
of special cases the encoders, decoders, and drawers need to provide.

R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/42910045
2013-12-17 10:49:45 -08:00
David du Colombier
2784a3ea85 ld: fix Plan 9 build
R=golang-dev, jas, bradfitz
CC=golang-dev
https://golang.org/cl/43420043
2013-12-17 08:46:07 -08:00
ChaiShushan
64379b854f all: add missing copyright
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/43290043
2013-12-17 06:52:32 -08:00
Shenghou Ma
d35b22d128 cmd/ld: maintain correct headstring needed by windows port.
Fixes build for go_bootstrap.
Fixes #6971.

R=alex.brainman, mattn.jp, rsc
CC=golang-dev
https://golang.org/cl/43130043
2013-12-17 07:36:01 -05:00
Dmitriy Vyukov
d24019f0fe race.bat: set exit status
R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/43340043
2013-12-17 15:09:42 +04:00
Dmitriy Vyukov
830f9ac030 race.bat: fix env setup
Currently it fails as:
go tool dist: $GOROOT is not set correctly or not exported
GOROOT=c:\go
c:\go\include\u.h does not exist
Fail.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/42550044
2013-12-17 12:59:13 +04:00
Shenghou Ma
98f16ad112 time: fix test error in Chinese edition of Windows
On the Chinese Windows XP system that I'm using, GetTimeZoneInformation returns a struct containing "中国标准时间" (China Standard Time in Chinese) in both StandardName and DaylightName (which is correct, because China does not use DST). However, in registry, under key HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\China Standard Time, the key Std and Dlt contain "中国标准时间" (China Standard Time in Chinese) and "中国夏季时间" (China Summer Time in Chinese) respectively. This means that time.toEnglishName() cannot determine the abbreviation for the local timezone (CST) and causes test failures (time.Local is empty)

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/43210043
2013-12-17 02:43:14 -05:00
Josh Bleecher Snyder
4a18e0edd9 math/rand: minor optimization to Perm
Instead of writing out 0..n and then reading it
back, just use i when it is needed.

Wikipedia calls this the "inside-out" implementation:
http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle

This yields identical values to the previous
implementation, given the same seed. (Note that the
output from Example_rand is unchanged.)

2.8 GHz Intel Core i7, results very stable:

benchmark          old ns/op    new ns/op    delta
BenchmarkPerm3           138          136   -1.45%
BenchmarkPerm30          825          803   -2.67%

Stock Raspberry Pi, minimum improvement out of three runs:

benchmark          old ns/op    new ns/op    delta
BenchmarkPerm3          5774         5664   -1.91%
BenchmarkPerm30        32582        29381   -9.82%

R=golang-dev, dave, mtj, adg
CC=golang-dev
https://golang.org/cl/21030043
2013-12-17 13:49:34 +11:00
Andrew Gerrand
1561230ca0 cmd/go: set GOROOT when testing "go install cmd/fix"
This particular test would never pass unless you had GOROOT set in your
environment. This changes makes the test use the baked-in GOROOT, as it
does with GOOS and GOARCH.

R=golang-dev, dave, iant
CC=golang-dev
https://golang.org/cl/43080043
2013-12-17 12:17:56 +11:00
Shenghou Ma
f85ba7d50a cmd/gc: fix comparison order of parameters in mpcmpfltc(a, b)
It should compare a - b to 0, not b - a to 0.
Fixes #6964.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/39020044
2013-12-16 16:54:10 -05:00
Marko Tiikkaja
1f20ab1116 database/sql: Check errors in QueryRow.Scan
The previous coding did not correctly check for errors from the driver's
Next() or Close(), which could mask genuine errors from the database, as
witnessed in issue #6651.

Even after this change errors from Close() will be ignored if the query
returned no rows (as Rows.Next will have closed the handle already), but it
is a lot easier for the drivers to guard against that.

Fixes #6651.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/41590043
2013-12-16 12:48:35 -08:00
David du Colombier
20dee338c3 net: lookup protocol in lower-case on Plan 9
Protocol keywords are case-insensitive,
but the Ndb database is case-sensitive.

Also use the generic net protocol instead
of tcp in lookupHost.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/40600047
2013-12-16 12:00:23 -08:00
Daniel Lidén
4e23b69314 strings: Add example function for IndexAny
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/42310044
2013-12-16 10:50:56 -08:00
Robin Eklind
ab9b2ae38c strings: Add IndexFunc example
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/42370043
2013-12-16 10:44:23 -08:00
Robin Eklind
7b53e32e0b strings: Update Trim example.
Use an input which better shows that behaviour of the function. Only leading
and trailing runes are trimed, not intermediate ones.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/42390043
2013-12-16 10:40:28 -08:00
Russ Cox
a392cf4fd3 runtime: fix test
Was supposed to be in the nm CL.

TBR=r
CC=golang-dev
https://golang.org/cl/42870043
2013-12-16 12:59:30 -05:00
Russ Cox
08b846b129 debug/goobj: add package for reading new Go object files
R=golang-dev, r, iant
CC=golang-dev
https://golang.org/cl/40610043
2013-12-16 12:52:21 -05:00
Russ Cox
500547f28b cmd/nm: reimplement in Go
The immediate goal is to support the new object file format,
which libmach (nm's support library) does not understand.
Rather than add code to libmach or reengineer liblink to
support this new use, just write it in Go.

The C version of nm reads the Plan 9 symbol table stored in
Go binaries, now otherwise unused.

This reimplementation uses the standard symbol table for
the corresponding file format instead, bringing us one step
closer to removing the Plan 9 symbol table from Go binaries.

Tell cmd/dist not to build cmd/nm anymore.
Tell cmd/go to install cmd/nm in the tool directory.

R=golang-dev, r, iant, alex.brainman
CC=golang-dev
https://golang.org/cl/40600043
2013-12-16 12:52:11 -05:00
Russ Cox
a9f6db58ce cmd/ld: move instruction selection + layout into compilers, assemblers
- new object file reader/writer (liblink/objfile.c)
- remove old object file writing routines
- add pcdata iterator
- remove all trace of "line number stack" and "path fragments" from
  object files, linker (!!!)
- dwarf now writes a single "compilation unit" instead of one per package

This CL disables the check for chains of no-split functions that
could overflow the stack red zone. A future CL will attack the problem
of reenabling that check (issue 6931).

This CL is just the liblink and cmd/ld changes.
There are minor associated adjustments in CL 37030045.
Each depends on the other.

R=golang-dev, dave, iant
CC=golang-dev
https://golang.org/cl/39680043
2013-12-16 12:51:58 -05:00
Russ Cox
870e821ded cmd/cc, cmd/gc: update compilers, assemblers for liblink changes
- add buffered stdout to all tools and provide to link ctxt.
- avoid extra \n before ! in .6 files written by assemblers
  (makes them match the C compilers).
- use linkwriteobj instead of linkouthist+linkwritefuncs.
- in assemblers and C compilers, record pc explicitly in Prog,
  for use by liblink.
- in C compilers, preserve jump target links.
- in Go compilers (gsubr.c) attach gotype directly to
  corresponding LSym* instead of rederiving from instruction stream.
- in Go compilers, emit just one definition for runtime.zerovalue
  from each compilation.

This CL consists entirely of small adjustments.
The heavy lifting is in CL 39680043.
Each depends on the other.

R=golang-dev, dave, iant
CC=golang-dev
https://golang.org/cl/37030045
2013-12-16 12:51:38 -05:00
Robin Eklind
a6ebc88bac strings: Add FieldsFunc example.
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/42360043
2013-12-16 09:43:03 -08:00
Dave Cheney
62baae6e57 unicode/utf16: add explicit test for decoding invalid runes.
The EncodeRune test exercises DecodeRune, but only for runes that it can encode. Add an explicit test for invalid utf16 surrogate pairs.

Bonus: coverage is now 100%

unicode/utf16/utf16.go: IsSurrogate     100.0%
unicode/utf16/utf16.go: DecodeRune      100.0%
unicode/utf16/utf16.go: EncodeRune      100.0%
unicode/utf16/utf16.go: Encode          100.0%
unicode/utf16/utf16.go: Decode          100.0%
total:                  (statements)    100.0%

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/39150044
2013-12-16 12:35:25 +11:00
Dave Cheney
fb31a0b1d0 unicode/utf16: add explicit tests for IsSurrogate
Update #6956

Add tests for IsSurrogate.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/42570043
2013-12-16 11:15:23 +11:00
Adam Langley
1dabd71666 crypto/tls: generate random serial numbers.
NSS (used in Firefox and Chrome) won't accept two certificates with the same
issuer and serial. But this causes problems with self-signed certificates
with a fixed serial number.

This change randomises the serial numbers in the certificates generated by
generate_cert.go.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/38290044
2013-12-15 12:57:57 -05:00
Adam Langley
1d546005af crypto/cipher: fix CFB mode.
a073d65e6f8c had a couple of bugs in the CFB mode that I missed in code review:
        1) The loop condition wasn't updated from the old version.
        2) It wasn't safe when src and dst aliased.

Fixes #6950.

R=golang-dev, hanwen
CC=golang-dev
https://golang.org/cl/42110043
2013-12-15 12:55:59 -05:00
Russ Cox
bc135f6492 runtime: fix crash in runtime.GoroutineProfile
This is a possible Go 1.2.1 candidate.

Fixes #6946.

R=iant, r
CC=golang-dev
https://golang.org/cl/41640043
2013-12-13 15:44:57 -05:00
Shenghou Ma
c134ce272f bytes: fix description of FieldsFunc
Similar to CL 3814041 that fixed the same issue in strings.
Fixes #6941.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/41490045
2013-12-12 22:13:19 -05:00
Ian Lance Taylor
52ecd2ce96 debug/dwarf: remove unused field addrsize from Data
The addrsize field is not a constant for an entire executable
file, and is now handled by the dataFormat interface when
reading the data.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/41620043
2013-12-12 18:55:05 -08:00
Ian Lance Taylor
c0946afb9c reflect: correct function name in panic string
R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/36840045
2013-12-12 18:54:48 -08:00
Richard Musiol
9394629b89 crypto/rc4: fix type errors in pure Go implementation
R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/40540049
2013-12-12 14:32:31 -05:00
Nick Craig-Wood
107d18299c crypto/sha1: Optimise FUNC1 with alternate formulation
According to Wikipedia: http://en.wikipedia.org/wiki/SHA-1
there is an alternate formulation for the FUNC1 transform,
namely

f1 = d xor (b and (c xor d))

instead of

f1 = (b and c) or ((not b) and d)

This reduces the instruction count of FUNC1 from 6 to 4 and
makes about 5% speed improvement on amd64 and suprisingly 17%
on 386.

amd64 Intel(R) Core(TM) i7 CPU Q 820 @ 1.73GHz:

benchmark              old ns/op    new ns/op    delta
BenchmarkHash8Bytes          506          499   -1.38%
BenchmarkHash1K             3099         2961   -4.45%
BenchmarkHash8K            22292        21243   -4.71%

benchmark               old MB/s     new MB/s  speedup
BenchmarkHash8Bytes        15.80        16.00    1.01x
BenchmarkHash1K           330.40       345.82    1.05x
BenchmarkHash8K           367.48       385.63    1.05x

i386 Intel(R) Core(TM) i7 CPU Q 820 @ 1.73GHz:

benchmark              old ns/op    new ns/op    delta
BenchmarkHash8Bytes          647          615   -4.95%
BenchmarkHash1K             3673         3161  -13.94%
BenchmarkHash8K            26141        22374  -14.41%

benchmark               old MB/s     new MB/s  speedup
BenchmarkHash8Bytes        12.35        13.01    1.05x
BenchmarkHash1K           278.74       323.94    1.16x
BenchmarkHash8K           313.37       366.13    1.17x

The improvements on an Intel(R) Core(TM) i7-4770K CPU @
3.50GHz were almost identical.

R=golang-dev, r, hanwen
CC=golang-dev, rsc
https://golang.org/cl/19910043
2013-12-12 11:26:36 -08:00
ChaiShushan
e5902fc70f image: add RGB and RGB48
R=golang-dev, r, nigeltao
CC=golang-dev
https://golang.org/cl/13239051
2013-12-12 11:24:27 -08:00
Han-Wen Nienhuys
b2a198ce39 crypto/cipher: speed up gcmInc32.
The counter is not secret, so the code does not need to be
constant time.

benchmark                    old MB/s     new MB/s  speedup
BenchmarkAESGCMSeal1K           89.90        92.84    1.03x
BenchmarkAESGCMOpen1K           89.16        92.30    1.04x

R=agl
CC=golang-dev
https://golang.org/cl/40690046
2013-12-12 11:25:17 -05:00
Felix Geisendörfer
5ad5b7a551 fmt: Fix signed zero-padding for positive floats
Space padding still has the same issue, I will send a separate patch for that
if this one gets accepted.
Fixes #6856.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/35660043
2013-12-12 06:40:16 -08:00
Josh Bleecher Snyder
563d0b62b8 net, text/tabwriter: use cap arg to make
Changes generated by:

gofmt -w -r 'make(a, b)[0:0] -> make(a, 0, b)' src/pkg

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/24820045
2013-12-12 10:13:17 +04:00
Josh Bleecher Snyder
cf51702bba net: don't leave hostsPath unrestored on error in TestLookupStaticHost
If the return was reached, then hostsPath would not be properly restored
to its original value. See the (lengthy) discussion at
https://golang.org/cl/15960047/

I assume that this is not for Go 1.2; mailing now since I promised to do so.
I will plan to ping once Go 1.2 is out.

R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/16200043
2013-12-12 10:12:06 +04:00
Adam Langley
2f43ce7fb0 crypto/x509: fix typo in comment.
Fixes #6633.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/40720046
2013-12-11 17:27:29 -05:00
Han-Wen Nienhuys
5744be9fe4 crypto/cipher: speed up xor operations in CBC, CFB, OBF, CTR
and GCM on 386 and amd64

Intel(R) Core(TM) i5-2540M CPU @ 2.60GHz:

benchmark                    old MB/s     new MB/s  speedup
BenchmarkAESGCMSeal1K           82.39        92.05    1.12x
BenchmarkAESGCMOpen1K           82.28        91.88    1.12x
BenchmarkAESCFBEncrypt1K       141.54       277.59    1.96x
BenchmarkAESCFBDecrypt1K       133.06       278.07    2.09x
BenchmarkAESOFB1K              160.51       380.24    2.37x
BenchmarkAESCTR1K              164.07       429.25    2.62x
BenchmarkAESCBCEncrypt1K       170.99       263.74    1.54x
BenchmarkAESCBCDecrypt1K       124.96       249.14    1.99x

Fixes #6741.

R=agl, dave, agl
CC=golang-dev
https://golang.org/cl/24250044
2013-12-11 16:05:02 -05:00
Russ Cox
426b48a775 cmd/5a, cmd/6a, cmd/8a: fix .y files to match y.tab.[ch]
When I renamed LAddr back to Addr (before sending the
original linker CLs), I missed the .y files in my global substitute.
Since the .y files are only processed when running make in
one of those directories (not during all.bash), they were
behind the generated files.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/40770044
2013-12-11 12:11:37 -05:00
Joel Sing
75800a9a28 crypto/sha256: block implementation in amd64 assembly
Benchmark on Intel(R) Xeon(R) CPU X5650  @ 2.67GHz

benchmark              old ns/op    new ns/op    delta
BenchmarkHash8Bytes         1259          677  -46.23%
BenchmarkHash1K            14387         6749  -53.09%
BenchmarkHash8K           106006        50107  -52.73%

benchmark               old MB/s     new MB/s  speedup
BenchmarkHash8Bytes         6.35        11.81    1.86x
BenchmarkHash1K            71.17       151.72    2.13x
BenchmarkHash8K            77.28       163.49    2.12x

R=agl
CC=golang-dev
https://golang.org/cl/28460043
2013-12-11 11:41:30 -05:00
Shenghou Ma
77fe6befb7 net/http: document that body is closed after (*Request).Write.
Fixes #6911.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/38690043
2013-12-10 23:35:50 -05:00
Carl Shapiro
c69402d82b runtime: remove outdated comment and related indentation
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/39810043
2013-12-10 11:17:43 -08:00
Adam Langley
ddbad5ef20 crypto/x509: fix behaviour of KeyUsageAny.
(Reporter wasn't able to provide a certificate chain that uses this
feature for testing.)

Fixes #6831

R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/40340043
2013-12-10 14:06:26 -05:00
David du Colombier
4321beba85 liblink, cmd/gc: fix incompatible type signatures on Plan 9
R=ality, golang-dev, r, rsc
CC=golang-dev
https://golang.org/cl/39640043
2013-12-10 08:42:41 -05:00
Joel Sing
517e49eb29 syscall: skip routing messages with mismatched version
Skip routing messages with a mismatched version, rather than failing
and returning EINVAL. Only return EINVAL if we were unable to parse
any of the routing messages (presumably due to a version mismatch).

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/30340043
2013-12-11 00:03:46 +11:00
Alberto García Hierro
c8869e9caf database/sql: Remove redundant condition in if
The final condition (db.maxIdleConnsLocked() > db.freeConn.Len()) can
only be true iff db.maxIdleConnsLocked() is greater than 0, so previously
checking if it's greater than 0 is a waste, specially when that involves
a method call which (ATM) can't be inlined and includes a switch.

Dissasembly follows (test for err == nil has been omitted for clarity):

Before:
43c357: cmp    $0x0,%bl
43c35a: jne    43c3ce <database/sql.(*DB).putConnDBLocked+0x1ce>
43c35c: mov    %rax,(%rsp)
43c360: callq  43aec0 <database/sql.(*DB).maxIdleConnsLocked>
43c365: mov    0x8(%rsp),%rbx
43c36a: cmp    $0x0,%rbx
43c36e: jle    43c3ce <database/sql.(*DB).putConnDBLocked+0x1ce>
43c370: mov    0x30(%rsp),%rbx
43c375: mov    %rbx,(%rsp)
43c379: callq  43aec0 <database/sql.(*DB).maxIdleConnsLocked>
43c37e: mov    0x30(%rsp),%rdx
43c383: mov    0x8(%rsp),%rcx
43c388: mov    0x28(%rdx),%rbp
43c38c: mov    0x28(%rbp),%rbx
43c390: cmp    %rcx,%rbx
43c393: jge    43c3ce <database/sql.(*DB).putConnDBLocked+0x1ce>
43c395: mov    0x28(%rdx),%rbp
43c399: mov    %rbp,(%rsp)
43c39d: mov    0x38(%rsp),%rcx
43c3a2: mov    $0x556c60,%eax
43c3a7: mov    %rax,0x8(%rsp)
43c3ac: mov    %rcx,0x10(%rsp)
43c3b1: callq  4db5b0 <container/list.(*List).PushFront>

After:
43c357: cmp    $0x0,%bl
43c35a: jne    43c3b5 <database/sql.(*DB).putConnDBLocked+0x1b5>
43c35c: mov    %rax,(%rsp)
43c360: callq  43aec0 <database/sql.(*DB).maxIdleConnsLocked>
43c365: mov    0x30(%rsp),%rdx
43c36a: mov    0x8(%rsp),%rcx
43c36f: mov    0x28(%rdx),%rbp
43c373: mov    0x28(%rbp),%rbx
43c377: cmp    %rcx,%rbx
43c37a: jge    43c3b5 <database/sql.(*DB).putConnDBLocked+0x1b5>
43c37c: mov    0x28(%rdx),%rbp
43c380: mov    %rbp,(%rsp)
43c384: mov    0x38(%rsp),%rcx
43c389: mov    $0x556c60,%eax
43c38e: mov    %rax,0x8(%rsp)
43c393: mov    %rcx,0x10(%rsp)
43c398: callq  4db590 <container/list.(*List).PushFront>

R=golang-dev, bradfitz, iant
CC=golang-dev
https://golang.org/cl/14656044
2013-12-10 16:10:09 +04:00
Mikio Hara
e5a7ab8550 net: fix nits found by go tool vet
R=golang-dev, dave, adg
CC=golang-dev
https://golang.org/cl/27430043
2013-12-10 14:30:52 +09:00
Shenghou Ma
a4b66b7703 os: fix build.
CL 36800043 and CL 36930044 have a merge conflict that I overlooked.

R=golang-dev
CC=golang-dev
https://golang.org/cl/39850043
2013-12-09 23:46:21 -05:00
Shenghou Ma
4f2cfdc7f4 crypto/rand: support generation of 2-5 bit primes, also document the error return for Prime
Fixes #6849.
Fixes #6867.

R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/35870043
2013-12-09 23:25:49 -05:00
Shenghou Ma
aa0ae7554c os: clarify docs for Rename.
Three changes:
1. mention "move" to clarify things up.
2. use {old,new}path instead of {old,new}name, which makes it clear what
   relative path would do here.
3. mention "OS-specific restrictions might apply".

Fixes #6887.

R=golang-dev, alex.brainman, iant, r
CC=golang-dev
https://golang.org/cl/36930044
2013-12-09 23:25:13 -05:00
Shenghou Ma
46d1461ab7 strconv: add example for Unquote.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/38920043
2013-12-09 23:24:58 -05:00
Carl Shapiro
f574726f16 runtime: check for signed zero in printfloat
Fixes #6899

R=golang-dev, r, cshapiro, iant, rsc
CC=golang-dev
https://golang.org/cl/38120043
2013-12-09 17:51:30 -08:00
Russ Cox
4c01a23cf1 cmd/pack: stop parsing object files to generate __.SYMDEF
Nothing looks at __.SYMDEF, and the object file format is changing.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/39580044
2013-12-09 19:35:17 -05:00
Russ Cox
4230044bb8 runtime: remove non-extern decls of runtime.goarm
The linker is in charge of providing the one true declaration.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/39560043
2013-12-09 19:35:07 -05:00
Alex Brainman
6795687427 cmd/cgo: use __gcc_struct__ for go exported functions
Fixes #6833

R=minux.ma, iant
CC=golang-dev
https://golang.org/cl/35790045
2013-12-10 11:30:12 +11:00
Anthony Martin
52ee63f544 liblink: fix extern register accesses on Plan 9 (386)
R=golang-dev, 0intro, rsc
CC=golang-dev
https://golang.org/cl/39680044
2013-12-09 18:48:44 -05:00
David du Colombier
58005207d2 cmd/8c, cmd/8g, cmd/8l: fix Plan 9 warnings
warning: src/cmd/8c/list.c:124 format mismatch d VLONG, arg 3
warning: src/cmd/8c/list.c:134 format mismatch d VLONG, arg 3
warning: src/cmd/8c/list.c:142 format mismatch d VLONG, arg 3
warning: src/cmd/8c/list.c:152 format mismatch d VLONG, arg 3
warning: src/cmd/8c/list.c:156 format mismatch d VLONG, arg 4
warning: src/cmd/8c/list.c:160 format mismatch d VLONG, arg 4
warning: src/cmd/8c/list.c:165 format mismatch d VLONG, arg 4
warning: src/cmd/8c/list.c:167 format mismatch d VLONG, arg 3
warning: src/cmd/8c/list.c:172 format mismatch d VLONG, arg 4
warning: src/cmd/8c/list.c:174 format mismatch d VLONG, arg 3
warning: src/cmd/8c/list.c:178 format mismatch d VLONG, arg 3
warning: src/cmd/8c/list.c:184 format mismatch d VLONG, arg 3

warning: src/cmd/8g/list.c:91 format mismatch d VLONG, arg 4
warning: src/cmd/8g/list.c:100 format mismatch d VLONG, arg 4
warning: src/cmd/8g/list.c:114 format mismatch d VLONG, arg 5
warning: src/cmd/8g/list.c:118 format mismatch d VLONG, arg 5
warning: src/cmd/8g/list.c:122 format mismatch d VLONG, arg 5
warning: src/cmd/8g/list.c:126 format mismatch d VLONG, arg 5
warning: src/cmd/8g/list.c:136 format mismatch d VLONG, arg 4

warning: src/cmd/8l/list.c:107 format mismatch d VLONG, arg 4
warning: src/cmd/8l/list.c:125 format mismatch ux VLONG, arg 4
warning: src/cmd/8l/list.c:128 format mismatch ux VLONG, arg 4
warning: src/cmd/8l/list.c:130 format mismatch d VLONG, arg 4
warning: src/cmd/8l/list.c:134 format mismatch d VLONG, arg 5
warning: src/cmd/8l/list.c:138 format mismatch d VLONG, arg 6
warning: src/cmd/8l/list.c:143 format mismatch d VLONG, arg 5
warning: src/cmd/8l/list.c:148 format mismatch d VLONG, arg 5
warning: src/cmd/8l/list.c:150 format mismatch d VLONG, arg 4
warning: src/cmd/8l/list.c:154 format mismatch d VLONG, arg 4
warning: src/cmd/8l/list.c:158 format mismatch d VLONG, arg 4
warning: src/cmd/8l/obj.c:132 format mismatch ux VLONG, arg 2

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/39710043
2013-12-09 18:47:22 -05:00
Anthony Martin
274a8e3f56 runtime: do not use memmove in the Plan 9 signal handler
Fixes a regression introduced in revision 4cb93e2900d0.

That revision changed runtime·memmove to use SSE MOVOU
instructions for sizes between 17 and 256 bytes. We were
using memmove to save a copy of the note string during
the note handler. The Plan 9 kernel does not allow the
use of floating point in note handlers (which includes
MOVOU since it touches the XMM registers).

Arguably, runtime·memmove should not be using MOVOU when
GO386=387 but that wouldn't help us on amd64. It's very
important that we guard against any future changes so we
use a simple copy loop instead.

This change is extracted from CL 9796043 (since that CL
is still being ironed out).

R=rsc
CC=golang-dev
https://golang.org/cl/34640045
2013-12-09 18:41:48 -05:00
Anthony Martin
66c32384dd build: do not use the host's libbio on Plan 9
R=jas, lucio.dere, rsc
CC=golang-dev
https://golang.org/cl/14604047
2013-12-09 18:39:58 -05:00
Carl Shapiro
bc9691c465 cmd/gc, runtime: correct a misnomer regarding dead value maps
The funcdata symbol incorrectly named the dead value map the
dead pointer map.  The dead value map identifies all dead
values, including pointers and non-pointers, in a stack frame.
The purpose of this map is to allow the runtime to poison
locations of dead data to catch lost invariants.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/38670043
2013-12-09 14:45:10 -08:00
Russ Cox
9a53fb571d cmd/gc: fix windows build, probably
TBR=iant
CC=golang-dev
https://golang.org/cl/39540043
2013-12-09 13:02:56 -05:00
Russ Cox
1eac128d64 cmd/6l: fix linux/amd64
TBR=iant
CC=golang-dev
https://golang.org/cl/39530043
2013-12-09 09:58:35 -08:00
Russ Cox
65a643ba47 cmd/dist, cmd/go: pass -fmessage-length always
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/36300044
2013-12-09 12:56:23 -05:00
Russ Cox
295e73e13f cmd/gc: print more information for windows failure
TBR=iant
CC=golang-dev
https://golang.org/cl/39510043
2013-12-09 12:55:25 -05:00
Russ Cox
0c0589ec42 cmd/ld: fix linux/386 build
TBR=iant
CC=golang-dev
https://golang.org/cl/39400044
2013-12-09 07:42:55 -08:00
Russ Cox
79479ac486 cmd/dist, cmd/go: pass -fmessage-length=0 when using clang
That option turns off word wrapping of individual
error messages generated by clang. The wrapping
makes the errors harder to read and conflicts with the
idea of a terminal window that can be resized.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/35810043
2013-12-09 10:33:27 -05:00
David du Colombier
b9bed39714 liblink: fix Plan 9 build
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/39280043
2013-12-09 07:55:53 -05:00
Russ Cox
7c17982f72 runtime: remove cross-function jump in vlop_arm.s
The new linker will disallow this on arm
(it is already disallowed on amd64 and 386)
in order to be able to lay out each function
separately.

The restriction is only for jumps into the middle
of a function; jumps to the beginning of a function
remain fine.

Prereq for linker cleanup (golang.org/s/go13linker).

R=iant, r, minux.ma
CC=golang-dev
https://golang.org/cl/35800043
2013-12-08 22:52:08 -05:00
Russ Cox
f606c1be80 cmd/5g, cmd/6g, cmd/8g: use liblink
Preparation for golang.org/s/go13linker work.

This CL does not build by itself. It depends on 35740044
and 35790044 and will be submitted at the same time.

R=iant
CC=golang-dev
https://golang.org/cl/34590045
2013-12-08 22:51:55 -05:00
Russ Cox
76a8c873cf cmd/5c, cmd/6c, cmd/8c: use liblink
Preparation for golang.org/s/go13linker work.

This CL does not build by itself. It depends on 35740044
and 35790044 and will be submitted at the same time.

R=iant
CC=golang-dev
https://golang.org/cl/34580044
2013-12-08 22:51:31 -05:00
Russ Cox
f7aaa553da cmd/5a, cmd/6a, cmd/8a: use liblink
Preparation for golang.org/s/go13linker work.

This CL does not build by itself. It depends on 35740044
and 35790044 and will be submitted at the same time.

R=iant
CC=golang-dev
https://golang.org/cl/35830043
2013-12-08 22:49:56 -05:00
Russ Cox
7d507dc6e6 liblink: create new library based on linker code
There is an enormous amount of code moving around in this CL,
but the code is the same, and it is invoked in the same ways.
This CL is preparation for the new linker structure, not the new
structure itself.

The new library's definition is in include/link.h.

The main change is the use of a Link structure to hold all the
linker-relevant state, replacing the smattering of global variables.
The Link structure should both make it clearer which state must
be carried around and make it possible to parallelize more easily
later.

The main body of the linker has moved into the architecture-independent
cmd/ld directory. That includes the list of known header types, so the
distinction between Hplan9x32 and Hplan9x64 is removed (no other
header type distinguished 32- and 64-bit formats), and code for unused
formats such as ipaq kernels has been deleted.

The code being deleted from 5l, 6l, and 8l reappears in liblink or in ld.
Because multiple files are being merged in the liblink directory,
it is not possible to show the diffs nicely in hg.

The Prog and Addr structures have been unified into an
architecture-independent form and moved to link.h, where they will
be shared by all tools: the assemblers, the compilers, and the linkers.
The unification makes it possible to write architecture-independent
traversal of Prog lists, among other benefits.

The Sym structures cannot be unified: they are too fundamentally
different between the linker and the compilers. Instead, liblink defines
an LSym - a linker Sym - to be used in the Prog and Addr structures,
and the linker now refers exclusively to LSyms. The compilers will
keep using their own syms but will fill out the corresponding LSyms in
the Prog and Addr structures.

Although code from 5l, 6l, and 8l is now in a single library, the
code has been arranged so that only one architecture needs to
be linked into a particular program: 5l will not contain the code
needed for x86 instruction layout, for example.

The object file writing code in liblink/obj.c is from cmd/gc/obj.c.

Preparation for golang.org/s/go13linker work.

This CL does not build by itself. It depends on 35740044
and will be submitted at the same time.

R=iant
CC=golang-dev
https://golang.org/cl/35790044
2013-12-08 22:49:37 -05:00
Russ Cox
8642cbd660 cmd/dist: add liblink build information
In addition to adding the library, change the way the anames array is created.
Previously, it was written to src/cmd/6l/enam.c (and similarly for 5l and 8l)
and each of the other tools (6g, 6c, 6a) compiled the 6l/enam.c file in addition
to their own sources.

Now that there is a library shared by all these programs, move the anames
array into that library. To eliminate name conflicts, name the array after
the architecture letter: anames5, anames6, anames8.

First step to linker cleanup (golang.org/s/go13linker).

This CL does not build by itself. It depends on the CLs introducing
liblink and changing commands to use it.

R=iant
CC=golang-dev
https://golang.org/cl/35740044
2013-12-08 22:48:11 -05:00
Carl Shapiro
6965a752a7 cmd/gc: do not generate dead value maps yet
We are not clearing dead values in the garbage collector so it
is not worth the RSS cost to materialize the data and write it
out to the binary.

R=golang-dev, iant, cshapiro
CC=golang-dev
https://golang.org/cl/38650043
2013-12-06 15:49:47 -08:00
Carl Shapiro
d4f68f2892 cmd/gc: clarify a TODO regarding variables used in liveness analysis
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/38640043
2013-12-06 15:36:54 -08:00
Carl Shapiro
76c54c1193 runtime: add GODEBUG option for an electric fence like heap mode
When enabled this new debugging mode will allocate objects on
their own page and never recycle memory addresses.  This is an
essential tool to root cause a broad class of heap corruption.

R=golang-dev, dave, daniel.morsing, dvyukov, rsc, iant, cshapiro
CC=golang-dev
https://golang.org/cl/22060046
2013-12-06 14:40:45 -08:00
Carl Shapiro
f1e726e311 cmd/dist: revert an accidental change to the optimization setting
R=golang-dev
CC=golang-dev
https://golang.org/cl/38130043
2013-12-05 17:49:34 -08:00
Carl Shapiro
f056daf075 cmd/5g, cmd/5l, cmd/6g, cmd/6l, cmd/8g, cmd/8l, cmd/gc, runtime: generate pointer maps by liveness analysis
This change allows the garbage collector to examine stack
slots that are determined as live and containing a pointer
value by the garbage collector.  This results in a mean
reduction of 65% in the number of stack slots scanned during
an invocation of "GOGC=1 all.bash".

Unfortunately, this does not yet allow garbage collection to
be precise for the stack slots computed as live.  Pointers
confound the determination of what definitions reach a given
instruction.  In general, this problem is not solvable without
runtime cost but some advanced cooperation from the compiler
might mitigate common cases.

R=golang-dev, rsc, cshapiro
CC=golang-dev
https://golang.org/cl/14430048
2013-12-05 17:35:22 -08:00
Carl Shapiro
77913e9aab encoding/gob: do not hide an unsafe.Pointer in a uintptr
R=golang-dev, r, rsc
CC=golang-dev
https://golang.org/cl/23320044
2013-12-03 15:24:27 -08:00
Carl Shapiro
48279bd567 runtime: add an allocation and free tracing for gc debugging
Output for an allocation and free (sweep) follows

MProf_Malloc(p=0xc2100210a0, size=0x50, type=0x0 <single object>)
        #0 0x46ee15 runtime.mallocgc /usr/local/google/home/cshapiro/go/src/pkg/runtime/malloc.goc:141
        #1 0x47004f runtime.settype_flush /usr/local/google/home/cshapiro/go/src/pkg/runtime/malloc.goc:612
        #2 0x45f92c gc /usr/local/google/home/cshapiro/go/src/pkg/runtime/mgc0.c:2071
        #3 0x45f89e mgc /usr/local/google/home/cshapiro/go/src/pkg/runtime/mgc0.c:2050
        #4 0x45258b runtime.mcall /usr/local/google/home/cshapiro/go/src/pkg/runtime/asm_amd64.s:179

MProf_Free(p=0xc2100210a0, size=0x50)
        #0 0x46ee15 runtime.mallocgc /usr/local/google/home/cshapiro/go/src/pkg/runtime/malloc.goc:141
        #1 0x47004f runtime.settype_flush /usr/local/google/home/cshapiro/go/src/pkg/runtime/malloc.goc:612
        #2 0x45f92c gc /usr/local/google/home/cshapiro/go/src/pkg/runtime/mgc0.c:2071
        #3 0x45f89e mgc /usr/local/google/home/cshapiro/go/src/pkg/runtime/mgc0.c:2050
        #4 0x45258b runtime.mcall /usr/local/google/home/cshapiro/go/src/pkg/runtime/asm_amd64.s:179

R=golang-dev, dvyukov, rsc, cshapiro
CC=golang-dev
https://golang.org/cl/21990045
2013-12-03 14:42:38 -08:00
Keith Randall
f238049a00 cmd/gc: fix special-casing of the printed names of map internal structures.
Shaves 1% off of binary size.

update #6853

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/35940047
2013-12-03 14:27:08 -08:00
Carl Shapiro
0368a7ceb6 runtime: move stack scanning into the parallel mark phase
This change reduces the cost of the stack scanning by frames.
It moves the stack scanning from the serial root enumeration
phase to the parallel tracing phase.  The output that follows
are timings for the issue 6482 benchmark

Baseline

BenchmarkGoroutineSelect	      50	 108027405 ns/op
BenchmarkGoroutineBlocking	      50	  89573332 ns/op
BenchmarkGoroutineForRange	      20	  95614116 ns/op
BenchmarkGoroutineIdle		      20	 122809512 ns/op

Stack scan by frames, non-parallel

BenchmarkGoroutineSelect	      20	 297138929 ns/op
BenchmarkGoroutineBlocking	      20	 301137599 ns/op
BenchmarkGoroutineForRange	      10	 312499469 ns/op
BenchmarkGoroutineIdle		      10	 209428876 ns/op

Stack scan by frames, parallel

BenchmarkGoroutineSelect	      20	 183938431 ns/op
BenchmarkGoroutineBlocking	      20	 170109999 ns/op
BenchmarkGoroutineForRange	      20	 179628882 ns/op
BenchmarkGoroutineIdle		      20	 157541498 ns/op

The remaining performance disparity is due to inefficiencies
in gentraceback and its callees.  The effect was isolated by
using a parallel stack scan where scanstack was modified to do
a conservative scan of the stack segments without gentraceback
followed by a call of gentrackback with a no-op callback.

The output that follows are the top-10 most frequent tops of
stacks as determined by the Linux perf record facility.

Baseline

+  25.19%  gc.test  gc.test            [.] runtime.xchg
+  19.00%  gc.test  gc.test            [.] scanblock
+   8.53%  gc.test  gc.test            [.] scanstack
+   8.46%  gc.test  gc.test            [.] flushptrbuf
+   5.08%  gc.test  gc.test            [.] procresize
+   3.57%  gc.test  gc.test            [.] runtime.chanrecv
+   2.94%  gc.test  gc.test            [.] dequeue
+   2.74%  gc.test  gc.test            [.] addroots
+   2.25%  gc.test  gc.test            [.] runtime.ready
+   1.33%  gc.test  gc.test            [.] runtime.cas64

Gentraceback

+  18.12%  gc.test  gc.test             [.] runtime.xchg
+  14.68%  gc.test  gc.test             [.] scanblock
+   8.20%  gc.test  gc.test             [.] runtime.gentraceback
+   7.38%  gc.test  gc.test             [.] flushptrbuf
+   6.84%  gc.test  gc.test             [.] scanstack
+   5.92%  gc.test  gc.test             [.] runtime.findfunc
+   3.62%  gc.test  gc.test             [.] procresize
+   3.15%  gc.test  gc.test             [.] readvarint
+   1.92%  gc.test  gc.test             [.] addroots
+   1.87%  gc.test  gc.test             [.] runtime.chanrecv

R=golang-dev, dvyukov, rsc
CC=golang-dev
https://golang.org/cl/17410043
2013-12-03 14:12:55 -08:00
Keith Randall
24699fb05c runtime: get rid of concatstring's vararg C argument.
Pass as a slice of strings instead.  For 2-5 strings, implement
dedicated routines so no slices are needed.

static call counts in the go binary:
 2 strings: 342 occurrences
 3 strings:  98
 4 strings:  30
 5 strings:  13
6+ strings:  14

Why?  C varags, bad for stack scanning and copying.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/36380043
2013-12-03 10:39:19 -08:00
Keith Randall
c0f2294577 runtime: fix race detector when map keys/values are passed by pointer.
Now that the map implementation is reading the keys and values from
arbitrary memory (instead of from stack slots), it needs to tell the
race detector when it does so.

Fixes #6875.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/36360043
2013-12-02 18:03:25 -08:00
Keith Randall
742f755a29 reflect: test to make sure big Zero()-obtained objects are really zero.
Update #6876.

R=dave, bradfitz
CC=golang-dev
https://golang.org/cl/36370043
2013-12-02 17:58:19 -08:00
Keith Randall
e7d899cba5 reflect: fix Zero() implementation - not every type has a
zero object allocated, so we still need to allocate a new
zero area every time.

Fixes #6876.

R=golang-dev
CC=golang-dev
https://golang.org/cl/36320043
2013-12-02 16:54:29 -08:00
Keith Randall
85138da832 reflect: prevent the callXX routines from calling makeFuncStub
and methodValueCall directly.  Instead, we inline their behavior
inside of reflect.call.

This change is required because otherwise we have a situation where
reflect.callXX calls makeFuncStub, neither of which knows the
layout of the args passed between them.  That's bad for
precise gc & stack copying.

Fixes #6619.

R=golang-dev, dvyukov, rsc, iant, khr
CC=golang-dev
https://golang.org/cl/26970044
2013-12-02 13:36:50 -08:00
Keith Randall
c792bde9ef runtime: don't use ... formal argument to deferreturn.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/28860043
2013-12-02 13:07:15 -08:00
Keith Randall
3278dc158e runtime: pass key/value to map accessors by reference, not by value.
This change is part of the plan to get rid of all vararg C calls
which are a pain for getting exact stack scanning.

We allocate a chunk of zero memory to return a pointer to when a
map access doesn't find the key.  This is simpler than returning nil
and fixing things up in the caller.  Linker magic allocates a single
zero memory area that is shared by all (non-reflect-generated) map
types.

Passing things by reference gets rid of some copies, so it speeds
up code with big keys/values.

benchmark             old ns/op    new ns/op    delta
BenchmarkBigKeyMap           34           31   -8.48%
BenchmarkBigValMap           37           30  -18.62%
BenchmarkSmallKeyMap         26           23  -11.28%

R=golang-dev, dvyukov, khr, rsc
CC=golang-dev
https://golang.org/cl/14794043
2013-12-02 13:05:04 -08:00
Russ Cox
a664b49457 doc/asm: more about SP, ARM R11
Also rename URL to /doc/asm.

R=golang-dev, minux.ma, r
CC=golang-dev
https://golang.org/cl/26170043
2013-11-13 21:29:34 -05:00
Russ Cox
7dd086e52d encoding/gob: do not use MarshalText, UnmarshalText
This seems to be the best of a long list of bad ways to fix this issue.

Fixes #6760.

R=r
CC=golang-dev
https://golang.org/cl/22770044
2013-11-13 21:29:19 -05:00
Andrew Gerrand
b6c7cc3241 encoding/gob: expose encode/decode example
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/26220045
2013-11-14 09:20:29 +11:00
Rob Pike
0bdd90bc0a src/cmd/?a: link to new assembler document
Blocked on 20930043, the CL the new text references.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/18430044
2013-11-12 20:07:08 -08:00
Olivier Duperray
8f10c76471 cmd/godoc: document package-level examples
Fixes  issue  5807 .

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/23940043
2013-11-11 12:09:24 +11:00
Russ Cox
6be1cb8c7a cmd/cgo: fix handling of array of pointers when using clang
Clang does not record the "size" field for pointer types,
so we must insert the size ourselves. We were already
doing this, but only for the case of pointer types.
For an array of pointer types, the setting of the size for
the nested pointer type was happening after the computation
of the size of the array type, meaning that the array type
was always computed as 0 bytes. Delay the size computation.

This bug happens on all Clang systems, not just FreeBSD.
Our test checked that cgo wrote something, not that it was correct.
FreeBSD's default clang rejects array[0] as a C struct field,
so it noticed the incorrect sizes. But the sizes were incorrect
everywhere.

Update testcdefs to check the output has the right semantics.

Fixes #6292.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/22840043
2013-11-07 15:24:51 -05:00
Ato Araki
df03aeb67c go/doc: add full stop of Japanese, Chinese and Korean.
This fix will show a good synopsis on package listings in that languages.

R=adg, r
CC=golang-dev
https://golang.org/cl/21130043
2013-11-05 15:13:50 +11:00
Brad Fitzpatrick
692a14787f net/textproto: fix CanonicalMIMEHeaderKey panic
Fixes #6712

R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/21450043
2013-11-04 12:35:11 -05:00
Russ Cox
2c98a3bc2e cmd/5l, runtime: fix divide for profiling tracebacks on ARM
Two bugs:
1. The first iteration of the traceback always uses LR when provided,
which it is (only) during a profiling signal, but in fact LR is correct
only if the stack frame has not been allocated yet. Otherwise an
intervening call may have changed LR, and the saved copy in the stack
frame should be used. Fix in traceback_arm.c.

2. The division runtime call adds 8 bytes to the stack. In order to
keep the traceback routines happy, it must copy the saved LR into
the new 0(SP). Change

        SUB $8, SP

into

        MOVW    0(SP), R11 // r11 is temporary, for use by linker
        MOVW.W  R11, -8(SP)

to update SP and 0(SP) atomically, so that the traceback always
sees a saved LR at 0(SP).

Fixes #6681.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/19910044
2013-10-31 18:15:55 +00:00
Russ Cox
b88148b9a0 undo CL 19810043 / 352f3b7c9664
The CL causes misc/cgo/test to fail randomly.
I suspect that the problem is the use of a division instruction
in usleep, which can be called while trying to acquire an m
and therefore cannot store the denominator in m.
The solution to that would be to rewrite the code to use a
magic multiply instead of a divide, but now we're getting
pretty far off the original code.

Go back to the original in preparation for a different,
less efficient but simpler fix.

««« original CL description
cmd/5l, runtime: make ARM integer division profiler-friendly

The implementation of division constructed non-standard
stack frames that could not be handled by the traceback
routines.

CL 13239052 left the frames non-standard but fixed them
for the specific case of a divide-by-zero panic.
A profiling signal can arrive at any time, so that fix
is not sufficient.

Change the division to store the extra argument in the M struct
instead of in a new stack slot. That keeps the frames bog standard
at all times.

Also fix a related bug in the traceback code: when starting
a traceback, the LR register should be ignored if the current
function has already allocated its stack frame and saved the
original LR on the stack. The stack copy should be used, as the
LR register may have been modified.

Combined, these make the torture test from issue 6681 pass.

Fixes #6681.

R=golang-dev, r, josharian
CC=golang-dev
https://golang.org/cl/19810043
»»»

TBR=r
CC=golang-dev
https://golang.org/cl/20350043
2013-10-31 17:18:57 +00:00
Russ Cox
b0db472ea2 cmd/5l, runtime: make ARM integer division profiler-friendly
The implementation of division constructed non-standard
stack frames that could not be handled by the traceback
routines.

CL 13239052 left the frames non-standard but fixed them
for the specific case of a divide-by-zero panic.
A profiling signal can arrive at any time, so that fix
is not sufficient.

Change the division to store the extra argument in the M struct
instead of in a new stack slot. That keeps the frames bog standard
at all times.

Also fix a related bug in the traceback code: when starting
a traceback, the LR register should be ignored if the current
function has already allocated its stack frame and saved the
original LR on the stack. The stack copy should be used, as the
LR register may have been modified.

Combined, these make the torture test from issue 6681 pass.

Fixes #6681.

R=golang-dev, r, josharian
CC=golang-dev
https://golang.org/cl/19810043
2013-10-30 18:50:34 +00:00
Russ Cox
797d1bac0d cmd/cgo: accept extra leading _ on __cgodebug_data for all object formats
The current Windows build breakage appears to be because
the Windows code should be looking for __cgodebug_data
not ___cgodebug_data. Dodge the question everywhere by
accepting both.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/19780043
2013-10-30 10:24:42 -04:00
Brad Fitzpatrick
7307ffa7cd database/sql: document Result methods
Fixes #5110

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/19280046
2013-10-29 17:38:43 -07:00
Julien Schmidt
e6c4fa58b5 database/sql: Fix typos in doc
R=golang-dev
CC=bradfitz, golang-dev
https://golang.org/cl/17590043
2013-10-29 16:03:13 -07:00
Russ Cox
a508381e89 time: correct path to time zone zip file on Unix
Most Unix systems have their own time zone data,
so we almost never get far enough in the list to
discover that we cannot fall back to the zip file.
Adjust testing to exercise the final fallback.

Plan 9 and Windows were already correct
(and are the main users of the zip file).

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/19280043
2013-10-29 17:11:51 -04:00
Russ Cox
2e984c2180 encoding/xml: fix doc comment
The tag is ",chardata" not "chardata".

Fixes #6631.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/19300046
2013-10-29 17:11:25 -04:00
Brad Fitzpatrick
1428045469 net/http/httputil: fix DumpRequestOut with ContentLength & false body param
Fixes #6471

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/14920050
2013-10-29 14:06:11 -07:00
Russ Cox
ef805fe3a0 os: do not return Lstat errors from Readdir
This CL restores the Go 1.1.2 semantics for os.File's Readdir method.

The code in Go 1.1.2 was rewritten mainly because it looked buggy.
This new version attempts to be clearer but still provide the 1.1.2 results.

The important diff is not this CL's version against tip but this CL's version
against Go 1.1.2.

Go 1.1.2:

        names, err := f.Readdirnames(n)
        fi = make([]FileInfo, len(names))
        for i, filename := range names {
                fip, err := Lstat(dirname + filename)
                if err == nil {
                        fi[i] = fip
                } else {
                        fi[i] = &fileStat{name: filename}
                }
        }
        return fi, err

This CL:

        names, err := f.Readdirnames(n)
        fi = make([]FileInfo, len(names))
        for i, filename := range names {
                fip, lerr := lstat(dirname + filename)
                if lerr != nil {
                        fi[i] = &fileStat{name: filename}
                        continue
                }
                fi[i] = fip
        }
        return fi, err

The changes from Go 1.1.2 are stylistic, not semantic:
1. Use lstat instead of Lstat, for testing (done before this CL).
2. Make error handling in loop body look more like an error case.
3. Use separate error variable name in loop body, to be clear
   we are not trying to influence the final return result.

Fixes #6656.
Fixes #6680.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/18870043
2013-10-29 11:50:40 -04:00
Russ Cox
b8be100d35 cmd/gc: silence clang warning
This code is only built when you run 'make' in cmd/gc,
not in all.bash.

R=golang-dev, jsing, iant
CC=golang-dev
https://golang.org/cl/19160043
2013-10-29 11:50:18 -04:00
Russ Cox
7dbbb53f37 debug/dwarf: add DWARF 4 form constants
Some versions of clang generate DWARF 4-format attributes
even when using -gdwarf-2. We don't care much about the
values, but we do need to be able to parse past them.

This fixes a bug in Go 1.2 rc2 reported via private mail using
a near-tip version of clang.

R=golang-dev, iant, dvyukov
CC=golang-dev
https://golang.org/cl/18460043
2013-10-29 10:36:51 -04:00
Russ Cox
adda33483d cmd/cgo: stop using -fno-eliminate-unused-debug-types
This flag was added in January 2010, in CL 181102, to fix issue 497.
(Numbers were just shorter back then.) The fix was for OS X machines
and the llvm-gcc frontend.

In July 2011 we had to change the way we get enum values, because
there were no flags available to force Xcode's llvm-gcc to include the
enum names and values in DWARF debug output.

We now use clang, not llvm-gcc, on OS X machines.
Earlier versions of clang printed a warning about not knowing the flag.
Newer versions of clang now make that an error.

That is:
 - The flag was added for OS X machines.
 - The flag is no longer necessary on OS X machines.
 - The flag now breaks some OS X machines.

Remove it.

I have run the original program from issue 497 successfully
without the flag on both OS X and Linux machines.

Fixes #6678.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/18850043
2013-10-28 22:21:26 -04:00
Russ Cox
00a757fb74 runtime: relax preemption assertion during stack split
The case can happen when starttheworld is calling acquirep
to get things moving again and acquirep gets preempted.
The stack trace is in golang.org/issue/6644.

It is difficult to build a short test case for this, but
the person who reported issue 6644 confirms that this
solves the problem.

Fixes #6644.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/18740044
2013-10-28 19:40:40 -04:00
Josh Bleecher Snyder
5644774ea5 net: handle single-line non-\n-terminated files correctly in readLine
Fixes #6646.

R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/15960047
2013-10-28 19:31:25 -04:00
Andrew Gerrand
6ea5687b46 net/url: fix Encode doc comment
Encoded query strings are always sorted by key; the example wasn't.

R=golang-dev, dsymonds, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/16430043
2013-10-25 23:00:22 +03:00
Brad Fitzpatrick
2d6a13997a strings: fix Replacer bug with prefix matches
singleStringReplacer had a bug where if a string was replaced
at the beginning and no output had yet been produced into the
temp buffer before matching ended, an invalid nil check (used
as a proxy for having matched anything) meant it always
returned its input.

Fixes #6659

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/16880043
2013-10-24 15:51:19 -07:00
Matthew Cottingham
17a03d8650 database/sql: link to wiki in package docs
Update #5886

R=golang-dev, kamil.kisiel, adg, r, rsc, dave, arnehormann, bradfitz
CC=golang-dev
https://golang.org/cl/14087043
2013-10-24 10:13:23 -07:00
Russ Cox
c8ddfd9ad1 cmd/cgo: use __typeof__, -w instead of typeof, -Wno-all
Suggested by iant in earlier CL.

R=golang-dev, bradfitz, iant
CC=golang-dev
https://golang.org/cl/14920052
2013-10-22 18:33:23 -04:00
Shenghou Ma
d220c9957c time: fix ParseDuration overflow when given more than 9 digits on 32-bit arch
Fixes #6617.

R=golang-dev, rsc, r
CC=golang-dev
https://golang.org/cl/15080043
2013-10-22 18:33:05 -04:00
Russ Cox
089bc25ae2 math: remove unnecessary source file
The routines in this file are dregs from a very early copy of the math API.
There are no Go prototypes and no non-amd64 implementations.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/15750046
2013-10-22 10:37:33 -04:00
Bill Neubauer
72d40a4bd9 go/build: document the go1.2 build tag
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/14930046
2013-10-22 16:43:32 +04:00
Adam Langley
7d9acff751 crypto/x509: name constraints should be a disjunction.
The code was requiring that all constraints be met, but it should be
satisfied by meeting *any* of them.

R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/15570044
2013-10-21 19:01:24 -04:00
Adam Langley
efed6f99d2 crypto/tls: advertise support for RSA+SHA1 in TLS 1.2 handshake.
Despite SHA256 support being required for TLS 1.2 handshakes, some
servers are aborting handshakes that don't offer SHA1 support.

This change adds support for signing TLS 1.2 ServerKeyExchange messages
with SHA1. It does not add support for signing TLS 1.2 client
certificates with SHA1 as that would require the handshake to be
buffered.

Fixes #6618.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/15650043
2013-10-21 16:35:09 -04:00
David Symonds
fae4553a9d net/mail: fix minor doc typo.
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/15510043
2013-10-21 17:32:45 +11:00
Shenghou Ma
be1a94b401 cmd/yacc: fix stderr on Windows.
Fixes #6620.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/15330043
2013-10-19 23:07:20 -04:00
Russ Cox
dbe2eacf04 cmd/cgo: fix line number in an error message
Fixes #6563.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14870046
2013-10-18 16:52:44 -04:00
Russ Cox
06ad3b2de1 cmd/cgo: stop using compiler error message text to analyze C names
The old approach to determining whether "name" was a type, constant,
or expression was to compile the C program

        name;

and scan the errors and warnings generated by the compiler.
This requires looking for specific substrings in the errors and warnings,
which ties the implementation to specific compiler versions.
As compilers change their errors or drop warnings, cgo breaks.
This happens slowly but it does happen.
Clang in particular (now required on OS X) has a significant churn rate.

The new approach compiles a slightly more complex program
that is either valid C or not valid C depending on what kind of
thing "name" is. It uses only the presence or absence of an error
message on a particular line, not the error text itself. The program is:

        // error if and only if name is undeclared
        void f1(void) { typeof(name) *x; }

        // error if and only if name is not a type
        void f2(void) { name *x; }

        // error if and only if name is not an integer constant
        void f3(void) { enum { x = (name)*1 }; }

I had not been planning to do this until Go 1.3, because it is a
non-trivial change, but it fixes a real Xcode 5 problem in Go 1.2,
and the new code is easier to understand than the old code.
It should be significantly more robust.

Fixes #6596.
Fixes #6612.

R=golang-dev, r, james, iant
CC=golang-dev
https://golang.org/cl/15070043
2013-10-18 15:56:25 -04:00
Russ Cox
20f99ffa3e cmd/gc: shorten name used for map bucket type
Before:
type.struct { buckets *struct { overflow *struct { overflow *struct { overflow *struct { overflow *struct { overflow *<...>; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable }; oldbuckets *struct { overflow *struct { overflow *struct { overflow *struct { overflow *struct { overflow *<...>; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable } }

After:
type.map.bucket[string]*"".RangeTable

This makes debugging maps a little nicer, and it takes up less space in the binary.

R=golang-dev, r
CC=golang-dev, khr
https://golang.org/cl/15110044
2013-10-18 15:56:07 -04:00
Russ Cox
66f49f78a5 net: make sure failed Dial returns nil Conn
Fixes #6614.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/14950045
2013-10-18 15:35:45 -04:00
Dmitriy Vyukov
f6329700ae runtime: remove nomemprof
Nomemprof seems to be unneeded now, there is no recursion.
If the recursion will be re-introduced, it will break loudly by deadlocking.
Fixes #6566.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/14695044
2013-10-18 10:45:19 +04:00
Andrew Gerrand
04e95a1a56 api: add go1.2.txt, use in tests
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14860043
2013-10-18 13:36:59 +09:00
Brad Fitzpatrick
f41b43a024 net/url: fix regression when serializing relative URLs
Only add a slash to path if it's a separator between
a host and path.

Fixes #6609

R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/14815043
2013-10-17 16:06:40 -07:00
Ian Lance Taylor
88c448ba40 runtime: correct test for when to poll network
Fixes #6610.

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/14793043
2013-10-17 11:57:48 -07:00
Ian Lance Taylor
667303f158 runtime: correct parameter name in MCentral_AllocList comment
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/14792043
2013-10-17 11:57:00 -07:00
Russ Cox
4dce7f8575 encoding/xml: accept chains of interfaces and pointers
Fixes #6556.

R=golang-dev, iant, adg
CC=golang-dev
https://golang.org/cl/14747043
2013-10-17 12:13:33 -04:00
Alberto García Hierro
e39eda1366 database/sql: make tests repeatable with -cpu=n,n
New test added in CL 14611045 causes a deadlock when
running the tests with -cpu=n,n because the fakedb
driver always waits when opening a new connection after
running TestConnectionLeak.  Reset its state after.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/14780043
2013-10-17 09:02:32 -07:00
Brad Fitzpatrick
e5babeff8a database/sql: fix some test fmt verbs
Found by vet.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14762044
2013-10-16 16:30:39 -07:00
Alberto García Hierro
37db880469 database/sql: Fix connection leak and potential deadlock
CL 10726044 introduced a race condition which causes connections
to be leaked under certain circumstances. If SetMaxOpenConns is
used, the application eventually deadlocks. Otherwise, the number
of open connections just keep growing indefinitely.

Fixes #6593

R=golang-dev, bradfitz, tad.glines, bketelsen
CC=golang-dev
https://golang.org/cl/14611045
2013-10-16 09:22:57 -07:00
Alberto García Hierro
478f4b6754 database/sql: fix double decrement of numOpen count; test for connection leaks
Add a check at the end of every test to make sure
there are no leaked connections after running a test.

Avoid incorrectly decrementing the number of open connections
when the driver connection ends up it a bad state (numOpen was
decremented twice).

Prevent leaking a Rows struct (which ends up leaking a
connection) in Row.Scan() when a *RawBytes destination is
improperly used.

Close the Rows struct in TestRowsColumns.

Update #6593

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/14642044
2013-10-16 09:17:25 -07:00
Shenghou Ma
4d38d1260e cmd/cgo: simpler fix for issue 6506.
Replaces CL 14682044.
Fixes #6506.

R=rsc, iant, dave
CC=golang-dev
https://golang.org/cl/14717043
2013-10-15 21:35:52 -04:00
Russ Cox
5feb15508e cmd/cgo: print the builtin prolog after the per-file preamble
The preamble may want to #define some special symbols
and then #include <sys/types.h> itself. The builtin prolog
also #includes <sys/types.h>, which would break such a
preamble (because the second #include will be a no-op).

The use of sys/types.h in the builtin prolog is new since Go 1.1,
so this should preserve the semantics of more existing cgo
code than we would otherwise.

It also fixes src/pkg/syscall/mkall.sh's use of go tool cgo -godefs
on some Linux systems.

Thanks to fullung@ for identifying the problem.

Fixes #6558.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14684044
2013-10-15 15:00:48 -04:00
Alex Brainman
9aee98def8 undo CL 14231047 / 2f4c2dde2756
undone because the change slows down profile collection
significantly and unpredictable at times (see comments
at https://golang.org/cl/14231047 for details)

««« original CL description
runtime: collect profiles even while on g0 stack

Fixes #6417

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

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/14535046
2013-10-15 14:37:43 -04:00
Russ Cox
043ace1213 cmd/cgo: fix Xcode 5 incompatibility for #defined expressions
Ensure that clang always exits with a non-zero status by
giving it something that it always warns about (the statement "1;").

Fixes #6128.

R=golang-dev, iant, minux.ma
CC=golang-dev
https://golang.org/cl/14702043
2013-10-15 14:34:46 -04:00
Russ Cox
56aeec31c6 cmd/cgo: work around bug in clang debug info for builtins like memset
Fixes #6506.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14682044
2013-10-15 12:46:14 -04:00
Alex Brainman
9a420b79d7 runtime/pprof: disable flaky TestGoroutineSwitch on windows
Update #6417

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/14604043
2013-10-15 13:00:06 +11:00
Keith Randall
2acb80b5e5 cmd/gc: fix comment about performing indexing at compile time.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14441070
2013-10-14 14:26:52 -07:00
Michael Piatek
21e6b90d36 net/http: skip content-type sniffing if the header is explicitly unset.
Fixes #5953

R=dsymonds, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/14434044
2013-10-15 08:22:04 +11:00
Ian Lance Taylor
c78d67fb86 debug/dwarf: report the value of an unrecognized attribute format
R=golang-dev, r, minux.ma
CC=golang-dev
https://golang.org/cl/14669045
2013-10-14 10:53:55 -07:00
Shenghou Ma
89ebc28b58 cmd/api: make it work even when cgo is disabled
make use of $USER or %USERNAME% to determine the current user.
Fixes #6578.

R=golang-dev, bradfitz, alex.brainman
CC=golang-dev
https://golang.org/cl/14649043
2013-10-14 00:18:46 -04:00
Ian Lance Taylor
5b2f626159 go/build: add GOOS and GOARCH to name of gccgo pkg directory
This matches the behaviour of builder.includeArgs in
cmd/go/build.go.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/14535048
2013-10-11 16:17:45 -07:00
Ian Lance Taylor
96648e0195 go/build: fix test if built with CGO_ENABLED=0
Fixes #6567.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/14502060
2013-10-11 15:55:50 -07:00
Shenghou Ma
7dba510c7b cmd/gc: re-word some error messages
Fixes #6557.

R=golang-dev, rsc, tracey.brendan
CC=golang-dev
https://golang.org/cl/14432053
2013-10-10 22:43:34 -04:00
Ian Lance Taylor
649fc255a9 net: fix TestDialFailPDLeak to work when GOMAXPROCS is large
Fixes #6553.

R=golang-dev, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/14526048
2013-10-09 13:52:29 -07:00
Keith Randall
139cc96a57 runtime: markfreed's error reports should be prefixed with "markfreed", not "markallocated".
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14441055
2013-10-09 13:28:47 -07:00
Ian Lance Taylor
c774e90208 cmd/go: add any .c/.cc files to the SWIG shared library
Also add the action's object directory to the list of
directories we use to find SWIG shared libraries.

Fixes #6521.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/14369043
2013-10-09 10:35:46 -07:00
Ian Lance Taylor
cb30917387 runtime/cgo: mark callback functions as NOSPLIT
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/14448044
2013-10-09 08:44:47 -07:00
Russ Cox
0965459bd9 debug/dwarf: handle surprising clang encoding
Fixes a bug in cgo on OS X using clang.
See golang.org/issue/6472 for details.

Fixes #6472.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14575043
2013-10-09 11:08:22 -04:00
Ian Lance Taylor
7bbe0163c7 net: fix typo in failure message in test
R=golang-dev, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/14582043
2013-10-09 06:44:11 -07:00
Russ Cox
8ba6deb1ec compress/flate: fix infinite loop on malformed data
Test using compress/gzip, because that's how the
data arrived.

Fixes #6550.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14441051
2013-10-09 08:37:06 -04:00
Rob Pike
daa61d1eb3 encoding/gob: add examples
Also tweak the package document, putting in section headings and
adding a sentence about intended use.

Fixes #4925.

R=golang-dev, iant, adg, ugorji
CC=golang-dev
https://golang.org/cl/14519044
2013-10-08 13:13:40 -07:00
Carl Shapiro
254dc5fdbe cmd/go, runtime: express armv5t architecture constraint differently
Instead of adding an -march=armv5t flag to the gcc command
line, the same effect is obtained with an ".arch armv5t"
pseudo op in the assembly file that uses armv5t instructions.

R=golang-dev, iant, dave
CC=golang-dev
https://golang.org/cl/14511044
2013-10-08 10:40:51 -07:00
Rob Pike
9795882704 math: the trig functions work in radians; document that
Fixes #6543
6543 is also a fine NGC object.

R=golang-dev, dsymonds, kamil.kisiel, minux.ma
CC=golang-dev
https://golang.org/cl/14515044
2013-10-07 16:32:47 -07:00
Joel Sing
fc1bea321d os/user: fix user lookups on dragonfly
Like FreeBSD, DragonFly does not provide a sysconf value for
_SC_GETPW_R_SIZE_MAX.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14469043
2013-10-07 09:21:33 -07:00
Joel Sing
fba015ecb4 os/user: enable tests on all supported platforms
All of the currently supported platforms have a working user
implementation and do not use stubs. As a result, enable the tests
on all platforms rather than whitelisting.

R=golang-dev, dave, iant
CC=golang-dev
https://golang.org/cl/14454044
2013-10-07 09:12:17 -07:00
Joel Sing
932428a1ed os/signal: make test logs reflect reality
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14470043
2013-10-07 09:04:20 -07:00
Keith Randall
869368a528 runtime: fix bug in maps at the intersection of iterators, growing, and NaN keys
If an iterator is started while a map is in the middle of a grow,
and the map has NaN keys, then those keys might get returned by
the iterator more than once.  This fix makes the evacuation decision
deterministic and repeatable for NaN keys so each one gets returned
only once.

R=golang-dev, r, khr, iant
CC=golang-dev
https://golang.org/cl/14367043
2013-10-04 13:54:03 -07:00
Keith Randall
15baf6b4ac runtime: remove 3 unused declarations.
R=golang-dev, cshapiro, iant
CC=golang-dev
https://golang.org/cl/14405043
2013-10-04 13:22:20 -07:00
Ian Lance Taylor
ef4e12a4ba reflect: test using a MakeFunc value in a couple of different ways
The gccgo implementation mishandled calling Interface on a
value created by MakeFunc.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14401043
2013-10-04 13:12:50 -07:00
Alex Brainman
4207897dcc runtime: collect profiles even while on g0 stack
Fixes #6417

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/14231047
2013-10-04 13:53:34 +10:00
Ian Lance Taylor
e59db90bfb reflect: add a test that gccgo mishandled
Failure occurred when using reflect.Call to pass a func value
following a non-pointer value.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14186043
2013-10-03 13:23:02 -07:00
Robert Hencke
a51b8cf870 gofmt: explain why lower bounds aren't automatically simplified
Full credit goes to gri and rsc for their explanations.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14229043
2013-10-03 10:55:17 -07:00
Rob Pike
c4579635cf sync/atomic: explain how to subtract an unsigned constant
Explain for those unfamiliar with twos-complement arithmetic how to
implement negation of signed positive constant.
Fixes #6408.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/14267044
2013-10-03 10:40:42 -07:00
Russ Cox
01479b6c4a go/doc: update ToHTML doc comment
Update #5429

R=golang-dev, r, dan.kortschak
CC=golang-dev
https://golang.org/cl/14293043
2013-10-03 09:49:12 -04:00
Russ Cox
408238e20b runtime: change default stack segment size to 8 kB
Changing from 4 kB to 8 kB brings significant improvement
on a variety of the Go 1 benchmarks, on both amd64
and 386 systems.

Significant runtime reductions:

          amd64  386
GoParse    -14%  -1%
GobDecode  -12% -20%
GobEncode  -64%  -1%
JSONDecode  -9%  -4%
JSONEncode -15%  -5%
Template   -17% -14%

In the longer term, khr's new stacks will avoid needing to
make this decision at all, but for Go 1.2 this is a reasonable
stopgap that makes performance significantly better.

Demand paging should mean that if the second 4 kB is not
used, it will not be brought into memory, so the change
should not adversely affect resident set size.
The same argument could justify bumping as high as 64 kB
on 64-bit machines, but there are diminishing returns
after 8 kB, and using 8 kB limits the possible unintended
memory overheads we are not aware of.

Benchmark graphs at
http://swtch.com/~rsc/gostackamd64.html
http://swtch.com/~rsc/gostack386.html

Full data at
http://swtch.com/~rsc/gostack.zip

R=golang-dev, khr, dave, bradfitz, dvyukov
CC=golang-dev
https://golang.org/cl/14317043
2013-10-03 09:19:10 -04:00
Dave Day
0a033a18ad cmd/gc: support -installsuffix in the compiler and builder
Add the -installsuffix flag to gc and {5,6,8}l, which overrides -race
for the suffix if both are supplied.
Pass this flag from the go tool for build and install.

R=rsc
CC=golang-dev
https://golang.org/cl/14246044
2013-10-03 13:48:47 +10:00