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

19591 Commits

Author SHA1 Message Date
Austin Clements
572f08a064 runtime: split marking of span roots into 128 subtasks
Marking of span roots can represent a significant fraction of the time
spent in mark termination. Simply traversing the span list takes about
1ms per GB of heap and if there are a large number of finalizers (for
example, for network connections), it may take much longer.

Improve the situation by splitting the span scan into 128 subtasks
that can be executed in parallel and load balanced by the markroots
parallel for. This lets the GC balance this job across the Ps.

A better solution is to do this during concurrent mark, or to improve
it algorithmically, but this is a simple change with a lot of bang for
the buck.

This was suggested by Rhys Hiltner.

Updates #11485.

Change-Id: I8b281adf0ba827064e154a1b6cc32d4d8031c03c
Reviewed-on: https://go-review.googlesource.com/13112
Reviewed-by: Keith Randall <khr@golang.org>
2015-09-14 18:15:40 +00:00
Austin Clements
739f133837 runtime: fix hashing of trace stacks
The call to hash the trace stack reversed the "seed" and "size"
arguments to memhash and, hence, always called memhash with a 0 size,
which dutifully returned a hash value that depended only on the number
of PCs in the stack and not their values. As a result, all stacks were
put in to a very subset of the 8,192 buckets.

Fix this by passing these arguments in the correct order.

Change-Id: I67cd29312f5615c7ffa23e205008dd72c6b8af62
Reviewed-on: https://go-review.googlesource.com/13613
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-09-14 18:14:14 +00:00
Håvard Haugen
b9dbb030d5 cmd/compiler/internal/gc: make Type.Copyto a []*Node
Passes go build -a -toolexec 'toolstash -cmp' std cmd

Change-Id: Ief4613cfb341172a85e3a894f44fb2bb308c7b55
Reviewed-on: https://go-review.googlesource.com/14554
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-09-14 04:51:46 +00:00
Andrew Gerrand
b07a51b3d4 database/sql: fix typo
Fixes #12606

Change-Id: Ib68cb20108ad35c3dd96e606649c4c8f9c0f085c
Reviewed-on: https://go-review.googlesource.com/14571
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-14 00:20:55 +00:00
Håvard Haugen
4c96e7b79b cmd/compile/internal/gc: clean up errcmp
Change-Id: Id07811a25bf4aa3ff834e7254a3dfb04522b2926
Reviewed-on: https://go-review.googlesource.com/14174
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-09-13 23:50:25 +00:00
Dave Cheney
4f48507d90 runtime: reduce pthread stack size in TestCgoCallbackGC
Fixes #11959

This test runs 100 concurrent callbacks from C to Go consuming 100
operating system threads, which at 8mb a piece (the default on linux/arm)
would reserve over 800mb of address space. This would frequently
cause the test to fail on platforms with ~1gb of ram, such as the
raspberry pi.

This change reduces the thread stack allocation to 256kb, a number picked
at random, but at 1/32th the previous size, should allow the test to
pass successfully on all platforms.

Change-Id: I8b8bbab30ea7b2972b3269a6ff91e6fe5bc717af
Reviewed-on: https://go-review.googlesource.com/13731
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Capitanio <capnm9@gmail.com>
Reviewed-by: Minux Ma <minux@golang.org>
2015-09-13 23:46:55 +00:00
Shenghou Ma
0b5bcf53ee runtime/cgo: explicitly link msvcrt on windows
It's because runtime links to ntdll, and ntdll exports a couple
incompatible libc functions. We must link to msvcrt first and
then try ntdll.

Fixes #12030.

Change-Id: I0105417bada108da55f5ae4482c2423ac7a92957
Reviewed-on: https://go-review.googlesource.com/14472
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-12 08:34:52 +00:00
Dave Cheney
ea4e321d4d cmd/compile/internal/gc: avoid allocation in bnum
Although bnum was being called with a Bits value, a limitation
of the escape analyser (golang/go#12588) meant that taking the
address of the Bits.b array in the range statement caused the
formal parameter to escape to the heap.

Passing the a pointer to a Bits, as with all the other Bits helper
methods avoids the allocation.

Before:
BenchmarkBnum1-4        20000000                69.6 ns/op            32 B/op          1 allocs/op

After:
BenchmarkBnum1-4        100000000               10.1 ns/op             0 B/op          0 allocs/op

Change-Id: I673bd57ddc032ee67d09474156d795fb1ba72018
Reviewed-on: https://go-review.googlesource.com/14501
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-12 02:55:38 +00:00
Michal Bohuslávek
ab14797f21 go/printer: fix indentation of *ast.CallExpr parameters
The current version of go/printer formats the following code
like this:

	foo.Bar().
		Run(func() {
		do()
	}).
		Set(map[string]interface{}{
		"x": "three",
		"y": 4,
	}).
		Run(
		func() {
			do()
		},
	)

This CL changes the go/printer behaviour to make the code look
like this.

	foo.Bar().
		Run(func() {
			do()
		}).
		Set(map[string]interface{}{
			"x": "three",
			"y": 4,
		}).
		Run(
			func() {
				do()
			},
		)

Fixes #12066.

Change-Id: If0f525dae1a5d45f9ba40534dbb65715d7e8001b
Reviewed-on: https://go-review.googlesource.com/13928
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-09-11 23:36:34 +00:00
Rob Pike
67ddae87b9 all: use one 'l' when cancelling everywhere except Solaris
Fixes #11626.

Change-Id: I1b70c0844473c3b57a53d7cca747ea5cdc68d232
Reviewed-on: https://go-review.googlesource.com/14526
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-11 18:31:51 +00:00
Didier Spezia
f4f0344fe2 encoding/base64,xml: map/slice literals janitoring
Simplify slice/map literal expressions.
Caught with gofmt -d -s, fixed with gofmt -w -s

Change-Id: I639cfb02b1f57dea4087863df3995889c9371529
Reviewed-on: https://go-review.googlesource.com/13837
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-11 14:05:40 +00:00
Didier Spezia
41713b4d2b cmd/doc: slice/map literals janitoring
Simplify slice/map literal expression.
Caught with gofmt -d -s

Change-Id: I7f38ef9fb528e2fd284bd0f190fbdf4a91956e55
Reviewed-on: https://go-review.googlesource.com/13834
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-11 14:04:46 +00:00
Didier Spezia
400bb82678 crypto/x509: map/slice literals janitoring
Simplify slice/map literal expression.
Caught with gofmt -d -s, fixed with gofmt -w -s

Change-Id: I4472c6003cf66e65f6e69050872ff95c96f01253
Reviewed-on: https://go-review.googlesource.com/13836
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-11 14:04:11 +00:00
Didier Spezia
4f33436004 runtime,internal/trace: map/slice literals janitoring
Simplify slice/map literal expressions.
Caught with gofmt -d -s, fixed with gofmt -w -s
Checked that the result can still be compiled with Go 1.4.

Change-Id: I06bce110bb5f46ee2f45113681294475aa6968bc
Reviewed-on: https://go-review.googlesource.com/13839
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-11 14:03:43 +00:00
Didier Spezia
90f69259ec cmd/compile/internal/ppc64: map/slice literals janitoring
Simplify slice/map literal expressions.
Caught with gofmt -d -s, fixed with gofmt -w -s
Checked that the result can still be compiled with Go 1.4.

Change-Id: I201cd90fdfb8de2971c46ad7fce64111152b697e
Reviewed-on: https://go-review.googlesource.com/13832
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-11 12:59:18 +00:00
Rob Pike
5e89acb580 cmd/asm: fix some fuzz bugs
One (12466) was an actual logic error, backing up when there was
nothing there. The others were due to continuing to process an
instruction when it cannot work.

Methodically stop assembling an instruction when it's not going to
succeed.

Fixes #12466.
Fixes #12467.
Fixes #12468.

Change-Id: I88c568f2b9c1a8408043b2ac5a78f5e2ffd62abd
Reviewed-on: https://go-review.googlesource.com/14498
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-11 00:52:21 +00:00
alexander demakin
2b50e6b458 archive/zip: fixes unexpected EOF when reading archive
If comment of the archive contains data which looks like
a zip64 directory, the comment is parsed as an
actual directory header.
Commit adds some additional checks similar to the checks
in minizip library.

Fixes #12449

Change-Id: Ia0fc950e47b9c39f77d88401b9ca30100ca7c808
Reviewed-on: https://go-review.googlesource.com/14433
Run-TryBot: Andrew Gerrand <adg@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-11 00:32:59 +00:00
Shenghou Ma
3f2baa3e60 cmd/dist: re-enable GOARM auto-detection
cmd/dist will re-exec itself to detect VFP support at run-time.

Fixes #9732, #12548.

Change-Id: I9ad0c5c7fa3e97bd79a32da372e1a962565bb3af
Reviewed-on: https://go-review.googlesource.com/3973
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-10 22:43:07 +00:00
Robert Griesemer
a370fbaac6 math/big: use more direct formatting in ExampleRoundingMode, cosmetic changes
Change-Id: I3d37391af2089881a5bd4d8f3e5d434b279c272e
Reviewed-on: https://go-review.googlesource.com/14490
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-09-10 22:10:41 +00:00
Brad Fitzpatrick
3ed6e830b9 mime: fix docs for WordDecoder.Decode
It was correct for an early version of the CL which introduced the
type, but later versions of the CL changed the behavior without
updating the documentation.

Fixes #12568

Change-Id: Ia4090a02ba122e9f8317ed86c4c9839ae2c539e0
Reviewed-on: https://go-review.googlesource.com/14496
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-10 21:50:17 +00:00
Didier Spezia
7d48573d46 cmd/internal/obj: map/slice literals janitoring
Simplify slice/map literal expressions.
Caught with gofmt -d -s, fixed with gofmt -w -s
Checked that the result can still be compiled with Go 1.4.

Change-Id: I0a6773d12200a7b43491f25f914335069a1fa5e8
Reviewed-on: https://go-review.googlesource.com/13833
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-10 21:47:41 +00:00
Robert Griesemer
63ee321059 strconv: fix comment
Fixes #12531.

Change-Id: I66dc7ac1b71b8f72b4a8f3ec18befa2607ef358b
Reviewed-on: https://go-review.googlesource.com/14494
Reviewed-by: Rob Pike <r@golang.org>
2015-09-10 21:31:07 +00:00
Rob Pike
a00cec90ca fmt: allow any type in a format's width argument
The construction
	fmt.Printf("%*d", n, 4)
reads the argument n as a width specifier to use when printing 4.
Until now, only strict int type was accepted here and it couldn't
be fixed because the fix, using reflection, broke escape analysis
and added an extra allocation in every Printf call, even those that
do not use this feature.

The compiler has been fixed, although I am not sure when exactly,
so let's fix Printf and then write

Fixes #10732.

Change-Id: I79cf0c4fadd876265aa39d3cb62867247b36ab65
Reviewed-on: https://go-review.googlesource.com/14491
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-10 20:53:22 +00:00
Rob Pike
8b96be15f6 time: allow any one- or two-digit day of the month when parsing.
In Parse, one can now say Feb 31 or even Feb 99. This is easy
to explain, consistent with time.Date, and even maybe useful.

Fixes #12333.
Fixes #7268. (By disagreeing with it.)

Change-Id: I7b95c842528bed66933681c8b9cc00640fccfcb4
Reviewed-on: https://go-review.googlesource.com/14123
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-10 20:27:53 +00:00
Konstantin Shaposhnikov
e216735dfa math/big: add example for RoundingMode
Updates #11241

Change-Id: I0614c5a9a7a4c399ad5d664f36c70c3210911905
Reviewed-on: https://go-review.googlesource.com/14356
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-09-10 19:58:29 +00:00
Michael Hudson-Doyle
b0344e9fd5 cmd/internal/obj, cmd/link, runtime: a saner model for TLS on arm
this leaves lots of cruft behind, will delete that soon

Change-Id: I12d6b6192f89bcdd89b2b0873774bd3458373b8a
Reviewed-on: https://go-review.googlesource.com/14196
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-10 19:49:13 +00:00
Yao Zhang
b456aac388 cmd/objdump: skip TestDisasm* for mips64{,le}
Disassembler for mips64 is not supported yet.

Change-Id: Ie923dd1e37fed47fc395b9d1cd9194e55020bee5
Reviewed-on: https://go-review.googlesource.com/14459
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-10 18:27:09 +00:00
Yao Zhang
1153737e86 cmd/go: skip part of TestNoteReading for mips64{,le}
Because external linking is not supported for now.

Change-Id: Icdd8f3cb3bfb781a990e529fce9129d91e98a9ec
Reviewed-on: https://go-review.googlesource.com/14457
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-10 18:26:30 +00:00
Russ Cox
d8384e9a8f cmd/vet: diagnose plain assignment in copylock detector
It went out of its way to look for implicit assignments
but never checked explicit assignments.

This detects the root bug for #12099.

Change-Id: I6a6e774cc38749ea8be7cfd58ba6421247b67000
Reviewed-on: https://go-review.googlesource.com/13646
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
2015-09-10 16:55:51 +00:00
Dave Cheney
81a4bbffbf cmd/go: use RawToken to parse remote package metadata
CL 14315 broke the tests for parsing loosely formed remote package
metadata. Switch the parsing to use RawToken to recover the previous
behaviour that Token provided.

It could be argued that the parser should be stricter, but as remote
metadata has been readable with the parser for several years, it is
safer to change the parser to continue to accept the samples provided
in the test cases.

Change-Id: I2a3ba1757d3cff53b1a1c4386276955bb46cf8cd
Reviewed-on: https://go-review.googlesource.com/14482
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-10 07:30:43 +00:00
Dave Cheney
bab01a0b4b cmd/compile: convert typecheckdefstack to []*Node
This one of a set of changes to make the transition away from NodeList
easier by removing cases in which NodeList doesn't act semi-trivially like a
[]*Node.

This CL was originally prepared by Josh Bleecher Snyder <josharian@gmail.com>.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: Ie02d2cf35f1e8438c6e9dc1d5fba51e8adde1bc0
Reviewed-on: https://go-review.googlesource.com/14480
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-10 05:37:22 +00:00
Shenghou Ma
1cf05ee612 runtime: move arch1_$GOARCH.go into arch_$GOARCH.go
Update #12563.

Change-Id: Id87f8e53586accd662575c31961c39787268df7a
Reviewed-on: https://go-review.googlesource.com/14471
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-10 04:52:24 +00:00
Shenghou Ma
91ddc07f65 hash/*: document the byte order used by the Sum methods
Fixes #12350.

Change-Id: I3dcb0e2190c11f83f15fb07cc637fead54f734f7
Reviewed-on: https://go-review.googlesource.com/14275
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-10 03:34:23 +00:00
Robert Stepanek
bf2164390b encoding/xml: Return SyntaxError for unmatched root start elements.
Currently, the xml.Decoder's Token routine returns successfully for
XML input that does not properly close root start elements (and any
unclosed descendants). For example, all the following inputs

    <root>
    <root><foo>
    <root><foo></foo>

cause Token to return with nil and io.EOF, indicating a successful
parse.

This change fixes that. It leaves the semantics of RawToken intact.

Fixes #11405

Change-Id: I6f1328c410cf41e17de0a93cf357a69f12c2a9f7
Reviewed-on: https://go-review.googlesource.com/14315
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-09-10 01:18:30 +00:00
Nodir Turakulov
918c82308a html/template: preserve attr in stateBeforeValue
Context: #12149. The problem there is that contents of
<script type="text/template"> are treated as JS, and thus // is treated
as regexp.

Preserve context.attr while we are in the attribute, in particular in
stateBeforeValue, so we have attr when reading attr value.

Next CL will actually fix the bug.

Change-Id: I99add2237b0885ecdcc08b4f7c25d0af99173e53
Reviewed-on: https://go-review.googlesource.com/14335
Reviewed-by: Rob Pike <r@golang.org>
2015-09-09 23:31:06 +00:00
Nodir Turakulov
6599450016 text/template: perform value validity checks
Check reflect.Value.IsValid() before calling other reflect.Value methods
that panic on zero values.

Added tests for cases with untyped nils. They panicked without these fixes.

Removed a TODO.

Fixes #12356

Change-Id: I9b5cbed26db09a0a7c36d99a93f8b9729899d51e
Reviewed-on: https://go-review.googlesource.com/14340
Reviewed-by: Rob Pike <r@golang.org>
2015-09-09 23:25:44 +00:00
Keith Randall
00c638d243 runtime: on map update, don't overwrite key if we don't need to.
Keep track of which types of keys need an update and which don't.

Strings need an update because the new key might pin a smaller backing store.
Floats need an update because it might be +0/-0.
Interfaces need an update because they may contain strings or floats.

Fixes #11088

Change-Id: I9ade53c1dfb3c1a2870d68d07201bc8128e9f217
Reviewed-on: https://go-review.googlesource.com/10843
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-09 21:06:49 +00:00
Shawn Walker-Salas
af7c9a42c1 syscall: implement getwd on Solaris
In support of the changes required for #8609, it was suggested that
syscall.getwd() be updated to work on Solaris first since the runtime
uses it and today it's unimplemented.

Fixes #12507

Change-Id: Ifb58ac9db8540936d5685c2c58bdc465dbc836cb
Reviewed-on: https://go-review.googlesource.com/14420
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
2015-09-09 19:58:33 +00:00
Rob Pike
cf3134a017 cmd/doc: the builtin package should always show unexported symbols
Trivial fix: set unexported=true for builtin.
Godoc itself has a similar hack.

Fixes #12541

Change-Id: Ib701f867d117931eb6ec6de223941b52eb6cd4a7
Reviewed-on: https://go-review.googlesource.com/14441
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-09 19:46:08 +00:00
Marvin Stenger
c12e38aa04 time: fixed handling of "5" in Format's layout string
Fixes #12440

Change-Id: Iead77fe34d986cfd5c16bac671fe13c8d012a754
Reviewed-on: https://go-review.googlesource.com/14178
Reviewed-by: Rob Pike <r@golang.org>
2015-09-09 18:41:34 +00:00
Keith Randall
1ca7a64a0d cmd/compile/internal/gc: handle weird map literals in key dedup
We compute whether two keys k1 and k2 in a map literal are duplicates by
constructing the expression OEQ(k1, k2) and calling the constant
expression evaluator on that expression, then extracting the boolean
result.

Unfortunately, the constant expression evaluator can fail for various
reasons.  I'm not really sure why it is dying in the case of 12536, but
to be safe we should use the result only if we get a constant back (if
we get a constant back, it must be boolean).  This probably isn't a
permanent fix, but it should be good enough for 1.5.2.

A permanent fix would be to ensure that the constant expression
evaluator can always work for map literal keys, and if not the compiler
should generate an error saying that the key isn't a constant (or isn't
comparable to some specific other key).

This patch has the effect of allowing the map literal to compile when
constant eval of the OEQ fails.  If the keys are really equal (which the
map impl will notice at runtime), one will overwrite the other in the
resulting map.  Not great, but better than a compiler crash.

Fixes #12536

Change-Id: Ic151a5e3f131c2e8efa0c25c9218b431c55c1b30
Reviewed-on: https://go-review.googlesource.com/14400
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-09 17:50:52 +00:00
Marvin Stenger
05c35ac5d1 cmd/compile/internal/gc: convert fields of TempVar to bool
Convert two fields of struct TempVar in popt.go from uint8 to bool.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I1aa14313e0241a4e9cadd63c6c681ed4e965a9a3
Reviewed-on: https://go-review.googlesource.com/14377
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-09 17:03:02 +00:00
Marvin Stenger
a20fbe8e18 cmd/compile/internal/gc: convert fields of Symlink to bool
Convert two fields of struct Symlink in subr.go from uint8 to bool.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I913006f41605b17b0d82fe358ee773f6ecaa681c
Reviewed-on: https://go-review.googlesource.com/14378
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-09 16:07:51 +00:00
Rob Pike
e6ee26a03b text/template: provide a way to trim leading and trailing space between actions
Borrowing a suggestion from the issue listed below, we modify the lexer to
trim spaces at the beginning (end) of a block of text if the action immediately
before (after) is marked with a minus sign. To avoid parsing/lexing ambiguity,
we require an ASCII space between the minus sign and the rest of the action.
Thus:

	{{23 -}}
	<
	{{- 45}}

produces the output
	23<45

All the work is done in the lexer. The modification is invisible to the parser
or any outside package (except I guess for noticing some gaps in the input
if one tracks error positions). Thus it slips in without worry in text/template
and html/template both.

Fixes long-requested issue #9969.

Change-Id: I3774be650bfa6370cb993d0899aa669c211de7b2
Reviewed-on: https://go-review.googlesource.com/14391
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-09 05:28:11 +00:00
Konstantin Shaposhnikov
49fb8cc10c all: minor documentation tweaks for constants
Block comments appear after a block in the HTML documentation generated by
godoc. Words like "following" should be avoided.

Change-Id: Iedfad67f4b8b9c84f128b98b9b06fa76919af388
Reviewed-on: https://go-review.googlesource.com/14357
Reviewed-by: Rob Pike <r@golang.org>
2015-09-09 05:07:52 +00:00
Nigel Tao
0cf7331391 image/png: reject zero-width and zero-height images.
http://www.w3.org/TR/PNG/#11IHDR says that "Zero is an invalid value".

This change only affects the decoder. The encoder already checks
non-positive instead of negative.

Fixes #12545.

Change-Id: Iba40e1a2f4e0eec8b2fbcd3bbdae886311434da7
Reviewed-on: https://go-review.googlesource.com/14411
Reviewed-by: Rob Pike <r@golang.org>
2015-09-09 02:53:58 +00:00
Nigel Tao
e5d9cafbe8 compress/lzw: tidy up some flush calls.
Change-Id: Ie7368188ad4a970a82c140962cf97347d24f0331
Reviewed-on: https://go-review.googlesource.com/14410
Reviewed-by: David Symonds <dsymonds@golang.org>
2015-09-09 01:45:00 +00:00
Michael Hudson-Doyle
f7b66fffc5 cmd/dist, cmd/link: force external linking for shared libs on arm
Also run testcshared.

Fixes #12425

Change-Id: I5baea8d772d3462f945aab96260b4197dbb20c0a
Reviewed-on: https://go-review.googlesource.com/14143
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-09 01:42:22 +00:00
Austin Clements
e9089e4ab6 runtime: add high-level description of how stack barriers work
Change-Id: I6affe75b5fa9dbf513c16200bff4fd7aa5f3a985
Reviewed-on: https://go-review.googlesource.com/14051
Reviewed-by: Rick Hudson <rlh@golang.org>
2015-09-09 01:18:56 +00:00
Austin Clements
92e68c89f6 runtime: move stack barrier code to its own file
Currently the stack barrier code is mixed in with the mark and scan
code. Move all of the stack barrier related functions and variables to
a new dedicated source file. There are no code modifications.

Change-Id: I604603045465ef8573b9f88915d28ab6b5910903
Reviewed-on: https://go-review.googlesource.com/14050
Reviewed-by: Rick Hudson <rlh@golang.org>
2015-09-09 01:18:50 +00:00
Dave Cheney
fd50db2a66 cmd/internal/obj: remove unused code
Following on from CL 14350, remove the remaining dead code from data.go.

Also leave a TODO to be addressed later (with a unit test) to reduce
the overhead of SymGrow.

Change-Id: Iebad775b1280b54b89e87a3a073ca8af19a8bfba
Reviewed-on: https://go-review.googlesource.com/14359
Run-TryBot: Dave Cheney <dave@cheney.net>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-09 00:39:36 +00:00
Michael Hudson-Doyle
5cbca8d84b cmd/internal/ld: put read-only relocated data into .data.rel.ro when making a shared object
Currently Go produces shared libraries that cannot be shared between processes
because they have relocations against the text segment (not text section). This
fixes this by moving some data to sections with magic names recognized by the
static linker.

The change in genasmsym to add STYPELINK to the switch should fix things on
darwin/arm64.

Fixes #10914
Updates #9210

Change-Id: Iab4a6678dd04cec6114e683caac5cf31b1063309
Reviewed-on: https://go-review.googlesource.com/14306
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-08 23:34:16 +00:00
Shenghou Ma
14f919578d cmd/compile/internal/mips64: copy cmd/compile/internal/ppc64
Just a mechanical copy, no code changes.
This is to reduce code difference when adding the mips64 port.

Change-Id: Id06e975f414a7b09f4827167b30813b228a3bfaf
Reviewed-on: https://go-review.googlesource.com/14324
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-08 22:40:16 +00:00
Shenghou Ma
5cc86c6f55 cmd/internal/obj/mips: copy cmd/internal/obj/ppc64
Just a mechanical copy with filename renames, no code changes.
This is to reduce code difference when adding the mips64 port.

Change-Id: Id06e975f414a7b09f4827167b30813b228a3bfae
Reviewed-on: https://go-review.googlesource.com/14323
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-08 22:39:56 +00:00
Michael Hudson-Doyle
69a143e388 cmd/internal/obj: remove dead code and small cleanups
Change-Id: I88fa0cc245a2141af04acced8716e08b1133abd1
Reviewed-on: https://go-review.googlesource.com/14350
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-08 21:04:43 +00:00
Rob Pike
74288f09dc strconv: add QuoteToGraphic and friends
This version of quoting allows runes in category Zs, such as the
ideographic space characters, to be passed through unquoted.

Still to do (maybe): A way to access this from Printf.

Updates #11511.

Change-Id: I3bae84b1aa0bc1b885318d3f67c5f451099a2a5a
Reviewed-on: https://go-review.googlesource.com/14184
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
2015-09-08 17:33:17 +00:00
Marvin Stenger
9ac0fff70a cmd/compile/internal/gc: convert fields of Type to bool
Convert some fields of struct Type in go.go from uint8 to bool.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I0a6c53f8ee686839b5234010ee2de7ae3940d499
Reviewed-on: https://go-review.googlesource.com/14370
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-08 17:15:08 +00:00
Marvin Stenger
e03c7896a7 cmd/compile/internal/gc: convert fields of Pkg to bool
Convert Pkg.Imported, Pkg.Exported, Pkg.Direct from uint8/int8/int8 to bool.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I67a71f1186ff9737c03eca413f7d35d8a79ebc9b
Reviewed-on: https://go-review.googlesource.com/14371
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-08 15:53:06 +00:00
Håvard Haugen
259466452d cmd/compile/internal/gc: unexport and make Hasdefer a bool
Passes go build -a -toolexec 'toolstash -cmp' std cmd.

Change-Id: I804ee4252fa9be78cb277faf7f467e6c9cfdd4a6
Reviewed-on: https://go-review.googlesource.com/14319
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-08 05:45:29 +00:00
Marvin Stenger
704e05c6ec cmd/compile/internal/gc: remove unused field Type.Siggen
Remove unused field Type.Siggen in go.go.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: Ia61fe65a226c913fbf4a11a71d7453c56aa46c0e
Reviewed-on: https://go-review.googlesource.com/14372
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-09-08 05:28:37 +00:00
Håvard Haugen
391cc54da8 cmd/compile: make importlist a []*Node instead of *NodeList
Passes go build -a -toolexec 'toolstash -cmp' std.

Change-Id: Ica62765d3c1ef052afed34da1b3ac3f80646cc55
Reviewed-on: https://go-review.googlesource.com/14318
Reviewed-by: Dave Cheney <dave@cheney.net>
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-08 03:41:24 +00:00
Dave Cheney
8937780c8a cmd/compile/internal/gc: convert Type.Broke into a bool
Convert Type.Broke from a uint8 to a boolean

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I44e7548c71b00467e36576bdf62933c42555a21a
Reviewed-on: https://go-review.googlesource.com/14307
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Håvard Haugen <havard.haugen@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-08 03:17:10 +00:00
Dave Cheney
8712e1867b cmd/compile/internal/gc: convert Label.Used to bool
Convert Label.Used to a boolean. Also move the field to the
bottom of the struct to avoid padding.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: If09ee92f9d54dce807e7b862cf771005daed810d
Reviewed-on: https://go-review.googlesource.com/14308
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-07 21:35:06 +00:00
Michael Hudson-Doyle
0388d4303f runtime: remove unused FUNCDATA_DeadValueMaps
Change-Id: Iccb0221bd9aef062d20798b952eaa09d9e60b902
Reviewed-on: https://go-review.googlesource.com/14345
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-07 21:02:11 +00:00
Marvin Stenger
932c1e3dd3 cmd/compile/internal: some janitoring
Nicer swaps, loops (removed tmp variables). Use of bool instead of int.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I541904c74b57297848decc51a8a4913a8eca4af3
Reviewed-on: https://go-review.googlesource.com/14316
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-07 17:42:48 +00:00
Michael Hudson-Doyle
31322996fd runtime: add stub sigreturn on arm
When building a shared library, all functions that are declared must actually
be defined.

Change-Id: I1488690cecfb66e62d9fdb3b8d257a4dc31d202a
Reviewed-on: https://go-review.googlesource.com/14187
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-09-07 07:49:09 +00:00
Dave Cheney
60f0345667 cmd/dist: fix mkzversion to produce gofmt'd output
Fix mkzversion to produce correctly formatted runtime/zversion.go.

Change-Id: Ie6bcd361a2f2e390b7f6c4980fcae2c41bb7e52f
Reviewed-on: https://go-review.googlesource.com/14355
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-07 06:12:21 +00:00
Dave Cheney
dab0dac01a cmd/compile: convert typecheck_stack to []*Node
This one of a set of changes to make the transition away from NodeList
easier by removing cases in which NodeList doesn't act semi-trivially like a
[]*Node.

This CL was originally prepared by Josh Bleecher Snyder <josharian@gmail.com>.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I4d041b343952f4a31f3150fd70669e08fcaa74f8
Reviewed-on: https://go-review.googlesource.com/14305
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-06 23:50:51 +00:00
Didier Spezia
63e2bed0ab cmd/asm: fix another infinite loop in register list parser
The code parsing register lists involves an inner loop on
each range defined by the lo,hi bounds. The condition on
this loop (for lo<=hi) is fragile, because the bounds
are unsigned 16 bits numbers.

In some corner cases, the calculated upper bound is 2^16-1
leading to an infinite loop.

Parsing operand `[):[o-FP` results in:
- an infinite loop for non ARM architectures
- the generation of almost 2^16 errors for the ARM architecture
  (which are then ignored)

This CL improves the code in 3 ways:
- bail out early when parsing non R prefixed registers
- make sure the register index is never negative
- make sure the number of iterations is limited by the
  maximum size of the range (as a defensive measure).

Fixes #12469

Change-Id: Ib1e7e36fb8ad5a3a52c50fc6219d3cfe2b39cc34
Reviewed-on: https://go-review.googlesource.com/14314
Reviewed-by: Rob Pike <r@golang.org>
2015-09-05 18:57:11 +00:00
Dave Cheney
22452ac592 cmd/compile: use []*Node instead of NodeList in bottomUpVisitor
This one of a set of changes to make the transition away from NodeList
easier by removing cases in which NodeList doesn't act semi-trivially like a
[]*Node.

This CL was originally prepared by Josh Bleecher Snyder <josharian@gmail.com>.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I582ff8b077eb384b84721a1edb0c1efbc0c40059
Reviewed-on: https://go-review.googlesource.com/14304
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-05 04:34:55 +00:00
Paul Marks
5a3ff6c895 net: Make Listen(":port") use IPv6 when IPv4 is not supported.
When running an experimental kernel with IPv4 disabled, Listen(":port")
currently tries to create an AF_INET socket, and fails.  Instead, it
should see !supportsIPv4, and use an AF_INET6 socket.

This sort of environment is quite esoteric at the moment, but I can
force the tests to fail on regular Linux using the following tweaks:

- net/net.go: supportsIPv4, supportsIPv6, supportsIPv4map = false, true, false
- net/sockopt_linux.go: ipv6only=true
- net/ipsock_posix.go: Revert this fix
- ./make.bash && ../bin/go test net

Also, make the arrows in server_test.go point to the left, because
server<-client is easier to read.

Fixes #12510

Change-Id: I0cc3b6b08d5e6908d2fbf8594f652ba19815aa4b
Reviewed-on: https://go-review.googlesource.com/14334
Run-TryBot: Paul Marks <pmarks@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-05 02:31:22 +00:00
Dave Cheney
703bd83623 cmd/compile: use []*Node instead of NodeList in sinit
This is a first of a set of changes to make the transition away from NodeList
easier by removing cases in which NodeList doesn't act semi-trivially like a
[]*Node.

This CL was originally prepared by Josh Bleecher Snyder <josharian@gmail.com>.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: Iad10b75e42b5b24e1694407841282fa3bab2dc9f
Reviewed-on: https://go-review.googlesource.com/14232
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-05 02:25:01 +00:00
Russ Cox
928fe05a4f reflect: record unsafe.Pointer, not uintptr, during DeepEqual
This is more correct with respect to garbage collection.
I don't know of any specific failures it could cause today.

Change-Id: I7eed6a06d2f281051199e79e4a9913aa8360ded7
Reviewed-on: https://go-review.googlesource.com/14137
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-05 01:44:30 +00:00
Robert Griesemer
ace303297f cmd/compile/internal/gc: fix go.y (rename of Fatal -> Fatalf)
Also go generate to update generated files.

Change-Id: I049708db93455f0030ba5afc6f218fde6220958d
Reviewed-on: https://go-review.googlesource.com/14331
Reviewed-by: Damien Neil <dneil@google.com>
2015-09-05 00:01:33 +00:00
Shawn Walker-Salas
4f74de1e4d cmd/go: fix Go buildid reading on Solaris
TestNoteReading fails on Solaris with linkmode=external due to some
assumptions made about how ELF .note sections are written by some
linkers.

On current versions of Solaris and older derivatives, SHF_ALLOC is
intentionally ignored for .note sections unless the .note section is
assigned to the text segment via a mapfile.  Also, if .note sections
are assigned to the text segment, no PT_NOTE program header will be
created thwarting Go's attempts at attempting to quickly find the
.note.

Furthermore, Go assumes that the relevant note segment will be placed
early in the file while the Solaris linker currently places the note
segment last in the file, additionally thwarting Go's optimisation
attempts that read only the first 16KB of the file to find the
buildid.

The fix is to detect when the note section is outside of the first
16KB of the file and then fallback to additionally reading that
section of the file.  This way, in future versions of Solaris when
this linking behaviour is changed, the fast path will always succeed
and we'll only be slower if it fails; likewise, any other linker that
does this will also just work.

Fixes #12178

Change-Id: I61c1dc3f744ae3ad63938386d2ace8a432c0efe1
Reviewed-on: https://go-review.googlesource.com/14210
Run-TryBot: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
2015-09-04 20:01:09 +00:00
Dave Cheney
e49b2460a4 Revert "cmd/internal/ld: put read-only relocated data into .data.rel.ro when making a shared object"
This reverts commit 2c2cbb69c8.

Broke darwin/arm64

Change-Id: Ibd2dea475d6ce6a8b4b40e2da19a83fc0514025d
Reviewed-on: https://go-review.googlesource.com/14301
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-04 19:47:36 +00:00
Dan Peterson
ced0646fe5 net: make DNSError.Temporary return true on SERVFAIL
Fixes #8434

Change-Id: I323222b4160f3aba35cac1de7f6df93c524b72ec
Reviewed-on: https://go-review.googlesource.com/14169
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-04 17:53:54 +00:00
Artyom Pervukhin
6fd82d83d6 net/http: optimize some io.Copy calls by reusing buffers
Optimize two calls of io.Copy which cannot make use of neither
io.ReaderFrom nor io.WriterTo optimization tricks by replacing them with
io.CopyBuffer with reusable buffers.

First is fallback call to io.Copy when server misses the optimized case
of using sendfile to copy from a regular file to net.TCPConn; second is
use of io.Copy on piped reader/writer when handler implementation uses
http.CloseNotifier interface. One of the notable users of
http.CloseNotifier is httputil.ReverseProxy.

benchmark                    old ns/op     new ns/op     delta
BenchmarkCloseNotifier-4     309591        303388        -2.00%

benchmark                    old allocs     new allocs     delta
BenchmarkCloseNotifier-4     50             49             -2.00%

benchmark                    old bytes     new bytes     delta
BenchmarkCloseNotifier-4     36168         3140          -91.32%

Fixes #12455

Change-Id: I512e6aa2f1aeed2ed00246afb3350c819b65b87e
Reviewed-on: https://go-review.googlesource.com/14177
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-04 17:44:29 +00:00
Nodir Turakulov
8c2c35debe net/http/httptest: ResponseRecorder.WriteString
Fixes #11000

Change-Id: Ic137e8a6c5c6b5b7eee213aca9acf78368e1d686
Reviewed-on: https://go-review.googlesource.com/14296
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-04 17:23:41 +00:00
Didier Spezia
3c37a61455 cmd/compile/internal: slice/map literals janitoring
Simplify slice/map literal expressions.
Caught with gofmt -d -s, fixed with gofmt -w -s
Checked that the result can still be compiled with Go 1.4.

Change-Id: I5c58801c20919618d2ad52b8e2380d53df2783f1
Reviewed-on: https://go-review.googlesource.com/13831
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-04 15:27:59 +00:00
Didier Spezia
220b5f7b54 image/gif: map/slice literals janitoring
Simplify slice/map literal expressions.
Caught with gofmt -d -s, fixed with gofmt -w -s

Change-Id: Iefd5f263c4f89a81da9427a7b9d97f13c35ab64f
Reviewed-on: https://go-review.googlesource.com/13838
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-04 11:58:15 +00:00
Michael Hudson-Doyle
876b7cc227 cmd/compile, cmd/go: generate position independent code with -buildmode=c-shared on arm
All the code was there to do this, it just wasn't hooked up.

Fixes #10914

Change-Id: Ide8f9bbe50fecb5d11cd579915ee98d4c7efe403
Reviewed-on: https://go-review.googlesource.com/14142
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-04 07:08:09 +00:00
Michael Hudson-Doyle
40af15f28e runtime: teach softfloat interpreter about "add r11, pc, r11"
This is generated during fp code when -shared is active.

Change-Id: Ia1092299b9c3b63ff771ca4842158b42c34bd008
Reviewed-on: https://go-review.googlesource.com/14286
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-09-04 06:43:35 +00:00
Shenghou Ma
821e124c24 cmd/link/internal/ld: align PE .text section to 32-byte when external linking
Some symbols, for example, masks requires 16-byte alignment, and
they are placed in the text section. Before this change, the text
section is only aligned to 4-byte, and it's making masks unaligned.

Fixes #12415.

Change-Id: I7767778d1b4f7d3e74c2719a02848350782a4160
Reviewed-on: https://go-review.googlesource.com/14166
Run-TryBot: Minux Ma <minux@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-04 05:27:02 +00:00
Michael Hudson-Doyle
2c2cbb69c8 cmd/internal/ld: put read-only relocated data into .data.rel.ro when making a shared object
Currently Go produces shared libraries that cannot be shared between processes
because they have relocations against the text segment (not text section). This
fixes this by moving some data to sections with magic names recognized by the
static linker.

Fixes #10914
Updates #9210

Change-Id: I7178daadc0ae87953d5a084aa3d580f4e3b46d47
Reviewed-on: https://go-review.googlesource.com/10300
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-04 05:25:10 +00:00
Michael Hudson-Doyle
eaea5ade2b cmd/asm: fix handling of nested #if[n]defs
The lexer needs to process all #if[n]defs, even those found when processing is
disabled by a preceding failed conditional, or the first #endif in something
like:

    #ifdef <undefined>
    #ifdef whatever
    #endif
    #endif

terminates the first #ifdef and the second causes an error. And then the
processing of the inner #ifdefs needs to ignore their argument when they are
disabled by an outer failed condition.

Change-Id: Iba259498f1e16042f5b7580b9c000bb0599733d0
Reviewed-on: https://go-review.googlesource.com/14253
Reviewed-by: Rob Pike <r@golang.org>
2015-09-04 05:23:28 +00:00
Alex Brainman
13e06d89c3 internal/syscall/windows/registry: do not panic when data is large
Allow registry blobs to be as large as 500MB

Update #12493

Change-Id: I1d0e5c10772d25f8e7e17fed6e2e7dd12ca4e7cf
Reviewed-on: https://go-review.googlesource.com/14287
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-04 04:47:26 +00:00
Andrew Gerrand
b8efc006f2 all: remove executable bit from several files
Change-Id: Iab669b2a9dd0510c0e54f9ec1cbe2b83b991bceb
Reviewed-on: https://go-review.googlesource.com/14283
Reviewed-by: Minux Ma <minux@golang.org>
2015-09-04 02:59:49 +00:00
Michael Hudson-Doyle
06da8fd84a cmd/link: only embed runtime.goarm in the module that contains the runtime package
And do it properly so freebsd and nacl still work.

Change-Id: I6f9f30e93ceae6dee59215ed608c6a158bdbdbb0
Reviewed-on: https://go-review.googlesource.com/14280
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-04 02:20:47 +00:00
Shenghou Ma
dac87e9ed3 cmd/compile/internal/gc: allow //go:systemstack only in runtime
Fixes #12454.

Change-Id: I6406b0119bc4d6c3d1e6f1896b588b7d101448a3
Reviewed-on: https://go-review.googlesource.com/14274
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-04 02:16:50 +00:00
Joe Tsai
e16d80362d hash: update documentation for MakeTable in crc32 and crc64
Explicitly say that *Table returned by MakeTable may not be
modified. Otherwise, this leads to very subtle bugs that may
or may not manifest themselves.

Same comment was made on package crc64, to keep the future
open to the caching tables that crc32 effectively does.

Fixes: #12487.

Change-Id: I2881bebb8b16f6f8564412172774c79c2593c6c1
Reviewed-on: https://go-review.googlesource.com/14258
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-04 02:16:27 +00:00
Michael Hudson-Doyle
c788a8e05d Revert "cmd/link: only embed runtime.goarm in the module that contains the runtime package"
This reverts commit bf99d8f843.

Change-Id: Id4374ed35802cfbfe11e015ccd9526d3497dc8cc
Reviewed-on: https://go-review.googlesource.com/14239
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-09-03 21:20:53 +00:00
Rob Pike
37025536c3 net/rpc: don't exit if Accept gets an error
The default implementation of Accept, which spins up a new server
for every new connection, calls log.Fatal if the listener is closed,
stopping any outstanding work. Change that to a non-fatal log
call so work can continue.

There is no programmatic signaling of the problem, just the log,
but that should be enough.

Fixes #11221.

Change-Id: I7c7f6164a0a0143236729eb778d7638c51c34ed1
Reviewed-on: https://go-review.googlesource.com/14185
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-03 21:17:08 +00:00
Alexander Morozov
d5e32ebf54 syscall: fix formatting calls in tests
Change-Id: I39a2c4101e6c59f4cd693cb0368f3567ea37ca5b
Reviewed-on: https://go-review.googlesource.com/14255
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-03 21:08:04 +00:00
Rob Pike
36af087aef cmd/asm: handle CMPF and CMPD on ARM
These instructions are special cases that were missed in the translation.
The second argument must go into the Reg field not the To field.

Fixes #12458

For Go 1.5.1

Change-Id: Iad57c60c7e38e3bcfafda483ed5037ce670e8816
Reviewed-on: https://go-review.googlesource.com/14183
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-09-03 19:40:11 +00:00
Chris Hines
d737639c4a database/sql: close bad connections in commit or rollback:
Previously Tx.close always passed a nil error to tx.db.putConn. As a
result bad connections were reused, even if the driver returned
driver.ErrBadConn. Adding an err parameter to Tx.close allows it to
receive the driver error from Tx.Commit and Tx.Rollback and pass it
to tx.db.putConn.

Fixes #11264

Change-Id: I142b6b2509fa8d714bbc135cef7281a40803b3b8
Reviewed-on: https://go-review.googlesource.com/13912
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-03 17:07:37 +00:00
Michael Hudson-Doyle
bf99d8f843 cmd/link: only embed runtime.goarm in the module that contains the runtime package
Change-Id: Ia18984343ca4ced3671d967ff9a5b0e32874430c
Reviewed-on: https://go-review.googlesource.com/14220
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-03 16:22:21 +00:00
Michael Hudson-Doyle
9e6ba37b86 cmd/internal/obj: some platform independent bits of proper toolchain support for thread local storage
Also simplifies some silliness around making the .tbss section wrt internal
vs external linking. The "make TLS make sense" project has quite a few more
steps to go.

Issue #11270

Change-Id: Ia4fa135cb22d916728ead95bdbc0ebc1ae06f05c
Reviewed-on: https://go-review.googlesource.com/13990
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-03 14:06:07 +00:00
Michael Hudson-Doyle
7bf959c67a cmd/internal/obj: remove Link.Tlsoffset
Nothing uses it any more.

Change-Id: I42ee7222b06b1a79b8b44894f3071752f9166d7a
Reviewed-on: https://go-review.googlesource.com/14193
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-09-03 02:16:22 +00:00
Joe Tsai
5c78589b69 compress/flate: simplify inflate logic
The flate library contains generator code, which is used to generate
the fixed huffman table. This is done so that fixed blocks can be
processed quicker since there is no need generate the decoder table
for fixed codes.

Instead, delete the precomputed table, and use sync.Once to generate
it at runtime when used.

Advantages:
* Reduces duplicated logic in flate package
* Reduces binary size by approximately 2KiB

Disadvantages:
* For the simplest possible program that simply decodes the fixed
block "\x03\x00" once, the modified code takes 4.7% longer for the
first decode. Compression performance for subsequent blocks afterwards
has no noticeable slow down.

Change-Id: I8f351218debf7d732118808859eda481b01011f6
Reviewed-on: https://go-review.googlesource.com/14181
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-09-03 01:54:35 +00:00
Michael Hudson-Doyle
9f0baca505 runtime: fixes for arm64 shared libraries
Building for shared libraries requires that all functions that are declared
have an implementation and vice versa so make that so on arm64.

It would be nicer to not require the stub sigreturn (it will never be called)
but that seems a bit awkward.

Change-Id: I3cec81697161b452af81fa35939f748bd1acf7fd
Reviewed-on: https://go-review.googlesource.com/13995
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-09-03 01:07:40 +00:00
Didier Spezia
df37c4b987 cmd/asm: fix several panics with erroneous input
The parser tries to read as much information as possible,
issuing some errors when needed. Errors generally do not
stop the parsing.

With some pathological input, it may result in various
panics when the error message itself is built, or when the
next operand is parsed. It happens while parsing
pseudo-instructions.

For instance, the following lines all generate a panic:

	TEXT
	TEXT%
	TEXT 1,1
	TEXT $"toto", 0, $1
	FUNCDATA
	DATA 0
	DATA(0),1
	FUNCDATA(SB
	GLOBL 0, 1
	PCDATA 1

Added corresponding tests.

Introduced a writer in the parser to capture error messages
for testing purpose. It defaults to os.Stderr.

Added an explicit check when symbol names cannot be displayed.

Interrupted parsing early when the number of operands is wrong for
pseudo-instructions.

Note that the last point is a change of behavior, because some
operands will not get parsed anymore in case of early error.

IMO, it is acceptable, because only the first error of the line
is considered anyway. If it is not acceptable, it can probably
be improved at the price of a more verbose CL.

Fixes #11765
Fixes #11760
Fixes #11759

Change-Id: I9602a848132e358a1bccad794d7555e0823970dd
Reviewed-on: https://go-review.googlesource.com/13925
Reviewed-by: Rob Pike <r@golang.org>
2015-09-02 20:24:40 +00:00
Håvard Haugen
dc3540d982 compile/internal/gc: make typecheckok a bool
Change-Id: Ib3960321a4c8164f6b221bfd15977d2f34dbc65b
Reviewed-on: https://go-review.googlesource.com/14175
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-02 19:08:19 +00:00
Rob Pike
45537d893d cmd/doc: document that json.Decode documents encoding/json.Decoder.Decode
Refine the documentation in cmd/doc and go help doc.

Fixes #12377.

Change-Id: I670c0a5cf18c9c9d5bb9bb222d8a3dd3722a3934
Reviewed-on: https://go-review.googlesource.com/14121
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-02 17:58:17 +00:00
Rob Pike
43a7a9cf43 cmd/vet: diagnose using Printf on a function value
Printing a function value is nearly useless outside of debugging, but
can occur by mistake when one forgets to call it. Diagnose this.

I did this myself just the other day and it arose in cl/14031.
Easy to fix and seems worthwhile.

Fixes #12295.

Change-Id: Ice125a84559f0394f7fa7272b5d31ae602b07f83
Reviewed-on: https://go-review.googlesource.com/14122
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-02 17:58:04 +00:00
Håvard Haugen
dd42eff8fe cmd/compile/internal/gc: use slice instead of NodeList for Label.Use
Change-Id: I021c95df24edbff24ff2922769ef2b2acd47016a
Reviewed-on: https://go-review.googlesource.com/14081
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-09-01 22:13:16 +00:00
Håvard Haugen
e8da46f6db cmd/compile/internal/gc: remove dead code found by vet
See report in commit 3c9fa388df.

Change-Id: I74a5995a1c1ca62b8d01857e89b084502e7da928
Reviewed-on: https://go-review.googlesource.com/14170
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-01 21:21:15 +00:00
Dan Peterson
25b00177af net/http: make FileServer sort directory entries
Fixes #11879

Change-Id: If021f86b2764e01c69674e6a423699b822596f15
Reviewed-on: https://go-review.googlesource.com/14161
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-01 20:11:22 +00:00
Fabian Wickborn
1ac84d4300 build: Fix bootstrap.bash for official source tarballs
At the moment, bootstrap.bash assumes it is called from a git working
copy. Hence, it fails to complete when running in an unpacked official
source tarball where .git and .gitignore do not exist. This fix adds a
test for existence for .git and a -f switch for the removal of
.gitignore.

Fixes #12223

Change-Id: I7f305b83b38d5115504932bd38dadb7bdeb5d487
Reviewed-on: https://go-review.googlesource.com/13770
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-01 19:52:59 +00:00
Michael Hudson-Doyle
e92d0d82e0 cmd/link: remove some dead code
Change-Id: I125a12a2cb7e792f357e4d841f55c0bed2971dce
Reviewed-on: https://go-review.googlesource.com/14140
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-09-01 16:28:49 +00:00
Brad Fitzpatrick
9c514e149c io: add WriteString support to MultiWriter
Fixes #11805

Change-Id: I081e16b869dc706bd847ee645bb902bc671c123f
Reviewed-on: https://go-review.googlesource.com/12485
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-01 04:00:12 +00:00
Nigel Tao
8ceaefb74a io/ioutil: clarify docs for ReadDir sort order.
Change-Id: I6a4ab5a1f44b54cfa81a650055460587ceefb2fc
Reviewed-on: https://go-review.googlesource.com/14144
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-01 03:22:13 +00:00
Nigel Tao
e424d59680 image/draw: optimize out some bounds checks.
We could undoubtedly squeeze even more out of these loops, and in the
long term, a better compiler would be smarter with bounds checks, but in
the short term, this small change is an easy win.

benchmark                      old ns/op     new ns/op     delta
BenchmarkFillOver-8            1619470       1323192       -18.29%
BenchmarkCopyOver-8            1129369       1062787       -5.90%
BenchmarkGlyphOver-8           420070        378608        -9.87%

On github.com/golang/freetype/truetype's BenchmarkDrawString:
benchmark                 old ns/op     new ns/op     delta
BenchmarkDrawString-8     9561435       8807019       -7.89%

Change-Id: Ib1c6271ac18bced85e0fb5ebf250dd57d7747e75
Reviewed-on: https://go-review.googlesource.com/14093
Reviewed-by: Rob Pike <r@golang.org>
2015-09-01 00:34:26 +00:00
Paul Marks
754d4c052a net: Increase the acceptable delay in TestDialerDualstack
This may fix the flakiness on Windows/x64, assuming that it's actually
due to a variance in the connection time which slightly exceeds 100ms.

150ms + 95ms = 245ms, which is still low enough to avoid triggering
Happy Eyeballs (300ms) on non-Windows platforms.

Updates #12309

Change-Id: I816a36fbc0a3e5c90e3cf1b75a134faf0d91557c
Reviewed-on: https://go-review.googlesource.com/14120
Run-TryBot: Paul Marks <pmarks@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-31 21:36:04 +00:00
Dave Cheney
8d478e845c cmd/internal/obj/arm: remove CASE and BCASE
Update #10994

CASE and BCASE were used by 5c in switch statements, cmd/compile
does not use them.

Change-Id: I7a578c461b52b94690e35460926849b28971b770
Reviewed-on: https://go-review.googlesource.com/14009
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-31 21:03:57 +00:00
Keith Randall
a088f1b76c runtime: soften up hash checks a bit
The hash tests generate occasional failures, quiet them some more.

In particular we can get 1 collision when the expected number is
.001 or so. That shouldn't be a dealbreaker.

Fixes #12311

Change-Id: I784e91b5d21f4f1f166dc51bde2d1cd3a7a3bfea
Reviewed-on: https://go-review.googlesource.com/13902
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-08-31 19:38:24 +00:00
Shenghou Ma
24e4cd9eb6 fmt: fix scientific notation in docs
Fixes #12340.

Change-Id: I17a8b3711a8593ec60882a0dcadb38f0cc138f4b
Reviewed-on: https://go-review.googlesource.com/13949
Reviewed-by: Rob Pike <r@golang.org>
2015-08-31 18:43:00 +00:00
Shenghou Ma
32d3b96e8b runtime: implement cmpstring and bytes.Compare in assembly for ppc64
Change-Id: I15bf55aa5ac3588c05f0a253f583c52bab209892
Reviewed-on: https://go-review.googlesource.com/14041
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-08-31 18:41:58 +00:00
Alexander Morozov
5483761c13 syscall: remove unused kernelVersion function from tests
Change-Id: If0d00999c58f7421e4da06e1822ba5abccf72cac
Reviewed-on: https://go-review.googlesource.com/14111
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-31 17:07:16 +00:00
Alexander Morozov
ae82315b82 syscall: move check of unprivileged_userns_clone to whoamiCmd
This is basic validation and should be performed early

Fixes #12412

Change-Id: I903f7eeafdc22376704985a53d649698cf9d8ef4
Reviewed-on: https://go-review.googlesource.com/14110
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-31 16:34:31 +00:00
Dave Cheney
3578bdf3c3 internal/obj/arm64: remove CASE and BCASE
Fixes #10994

CASE and BCASE were used by 7c in switch statements, cmd/compile
does not use them, cmd/assemble couldn't assemble them, and the arm64
peephole optimiser didn't know about them.

Change-Id: Id04835fcb37e207f76d211ce54a4db9c057d6112
Reviewed-on: https://go-review.googlesource.com/14100
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Run-TryBot: Aram Hăvărneanu <aram@mgk.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-31 13:22:55 +00:00
Aaron Jacobs
019297a9aa os: remove a redundant branch in File.Read.
All implementations of File.read ensure that n >= 0. This is usually via
fixCount, except for Windows console reads, which only ever add to n.

Change-Id: Ic019d6a2da5ef1ac68d2690c908deca4fcc6b4a4
Reviewed-on: https://go-review.googlesource.com/12624
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-31 04:42:04 +00:00
Håvard Haugen
3c9fa388df cmd/compile/internal/gc: rename Fatal to Fatalf
This helps vet see a real issue:

    cmd/internal/gc$ go vet
    gen.go:1223: unreachable code

Fixes #12106.

Change-Id: I720868b07ae6b6d5a4dc6b238baa8c9c889da6d8
Reviewed-on: https://go-review.googlesource.com/14083
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-31 01:35:23 +00:00
Michael Hudson-Doyle
af799d94f9 cmd/link: pass value being relocated to archreloc
And clean up the mess on arm64 (the mess on arm is too confusing).

See issue #10050

Change-Id: I2ce813fe8646d4e818eb660612a7e4b2bb04de4c
Reviewed-on: https://go-review.googlesource.com/13884
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-08-31 00:07:59 +00:00
Shenghou Ma
5f2c420eb6 net: add -lsendfile to cgo LDFLAGS for solaris
Fixes external linking of net/http tests (or anything that uses
sendfile).

Fixes #12390.

Change-Id: Iee08998cf66e7b0ce851db138a00ebae6dc2395e
Reviewed-on: https://go-review.googlesource.com/14072
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
2015-08-30 22:01:07 +00:00
Austin Clements
77e528293b runtime: check that stack barrier unwind is in sync
Currently the stack barrier stub blindly unwinds the next stack
barrier from the G's stack barrier array without checking that it's
the right stack barrier. If through some bug the stack barrier array
position gets out of sync with where we actually are on the stack,
this could return to the wrong PC, which would lead to difficult to
debug crashes. To address this, this commit adds a check to the amd64
stack barrier stub that it's unwinding the correct stack barrier.

Updates #12238.

Change-Id: If824d95191d07e2512dc5dba0d9978cfd9f54e02
Reviewed-on: https://go-review.googlesource.com/13948
Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-30 16:07:02 +00:00
Austin Clements
3bfc9df21a runtime: add GODEBUG for stack barriers at every frame
Currently enabling the debugging mode where stack barriers are
installed at every frame requires recompiling the runtime. However,
this is potentially useful for field debugging and for runtime tests,
so make this mode a GODEBUG.

Updates #12238.

Change-Id: I6fb128f598b19568ae723a612e099c0ed96917f5
Reviewed-on: https://go-review.googlesource.com/13947
Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-30 16:06:55 +00:00
Austin Clements
e2bb03f175 runtime: don't install a stack barrier in cgocallback_gofunc's frame
Currently the runtime can install stack barriers in any frame.
However, the frame of cgocallback_gofunc is special: it's the one
function that switches from a regular G stack to the system stack on
return. Hence, the return PC slot in its frame on the G stack is
actually used to save getg().sched.pc (so tracebacks appear to unwind
to the last Go function running on that G), and not as an actual
return PC for cgocallback_gofunc.

Because of this, if we install a stack barrier in cgocallback_gofunc's
return PC slot, when cgocallback_gofunc does return, it will move the
stack barrier stub PC in to getg().sched.pc and switch back to the
system stack. The rest of the runtime doesn't know how to deal with a
stack barrier stub in sched.pc: nothing knows how to match it up with
the G's stack barrier array and, when the runtime removes stack
barriers, it doesn't know to undo the one in sched.pc. Hence, if the C
code later returns back in to Go code, it will attempt to return
through the stack barrier saved in sched.pc, which may no longer have
correct unwinding information.

Fix this by blacklisting cgocallback_gofunc's frame so the runtime
won't install a stack barrier in it's return PC slot.

Fixes #12238.

Change-Id: I46aa2155df2fd050dd50de3434b62987dc4947b8
Reviewed-on: https://go-review.googlesource.com/13944
Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-30 16:06:47 +00:00
Adam Langley
0cced63cc0 crypto/x509: emit PKIX names in a more standard order.
(See referenced bug for details.)

Fixes #11966.

Change-Id: I91f9c95594cf4fd6d25d9a81f155a643c7a1f8e0
Reviewed-on: https://go-review.googlesource.com/13038
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-30 15:34:48 +00:00
Adam Langley
cb5bca8e8a crypto/tls: reject ServerHellos with empty ALPN protocols.
https://tools.ietf.org/html/rfc7301#section-3.1 specifies that a
ProtocolName may not be empty. This change enforces this for ServerHello
messages—it's already enforced for ClientHello messages.

Change-Id: Ic5a5be6bebf07fba90a3cabd10b07ab7b4337f53
Reviewed-on: https://go-review.googlesource.com/12003
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-30 15:33:36 +00:00
aubble
34695c4742 crypto/tls: note in comments that setting GetCertificate is now sufficient.
In Go 1.5, Config.Certificates is no longer required if
Config.GetCertificate has been set. This change updated four comments to
reflect that.

Change-Id: Id72cc22fc79e931b2d645a7c3960c3241042762c
Reviewed-on: https://go-review.googlesource.com/13800
Reviewed-by: Adam Langley <agl@golang.org>
2015-08-29 22:23:04 +00:00
Vlad Krasnov
efeeee38c9 crypto/aes: dedicated asm version of AES-GCM
The existing implementation didn't use the CLMUL instructions for fast
and constant time binary-field multiplication. With this change, amd64
CPUs that support both AES and CLMUL instructions will use an optimised
asm implementation.

benchmark                 old ns/op     new ns/op     delta
BenchmarkAESGCMSeal8K     91723         3200          -96.51%
BenchmarkAESGCMOpen8K     91487         3324          -96.37%
BenchmarkAESGCMSeal1K     11873         546           -95.40%
BenchmarkAESGCMOpen1K     11833         594           -94.98%

benchmark                 old MB/s     new MB/s     speedup
BenchmarkAESGCMSeal8K     89.31        2559.62      28.66x
BenchmarkAESGCMOpen8K     89.54        2463.78      27.52x
BenchmarkAESGCMSeal1K     86.24        1872.49      21.71x
BenchmarkAESGCMOpen1K     86.53        1721.78      19.90x

Change-Id: Idd63233098356d8b353d16624747b74d0c3f193e
Reviewed-on: https://go-review.googlesource.com/10484
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2015-08-29 21:02:38 +00:00
aubble
bfa016150b crypto/tls: allow tls.Listen when only GetCertificate is provided.
Go 1.5 allowed TLS connections where Config.Certificates was nil as long
as the GetCertificate callback was given. However, tls.Listen wasn't
updated accordingly until this change.

Change-Id: I5f67f323f63c988ff79642f3daf8a6b2a153e6b2
Reviewed-on: https://go-review.googlesource.com/13801
Reviewed-by: Adam Langley <agl@golang.org>
2015-08-29 19:28:03 +00:00
Håvard Haugen
74245b0353 testing/quick: terminate for arbitrary recursive types
Recursive types R containing slices of R's did not terminate despite the
effort in CL 10821.

For recursive types there was a competition between slice expansion by a
factor 'complexSize', and termination with probability '1/complexSize'
which lead to stack overflow as soon as a recursive struct had slices
pointing to its own type.

Fix this by shrinking the size hint as a function of recursion depth.
This has the dual effect of reducing the number of elements generated
per slice and also increasing the probability for termination.

Fixes #11148.

Change-Id: Ib61155b4f2e2de3873d508d63a1f4be759426d67
Reviewed-on: https://go-review.googlesource.com/13830
Reviewed-by: Adam Langley <agl@golang.org>
2015-08-29 19:23:37 +00:00
David Leon Gil
ea0491b70a math/big: use optimized formula in ModSqrt for 3 mod 4 primes
For primes which are 3 mod 4, using Tonelli-Shanks is slower
and more complicated than using the identity

     a**((p+1)/4) mod p == sqrt(a)

For 2^450-2^225-1 and 2^10860-2^5430-1, which are 3 mod 4:

BenchmarkModSqrt225_TonelliTri      1000     1135375 ns/op
BenchmarkModSqrt225_3Mod4          10000      156009 ns/op
BenchmarkModSqrt5430_Tonelli           1  3448851386 ns/op
BenchmarkModSqrt5430_3Mod4             2   914616710 ns/op

~2.6x to 7x faster.

Fixes #11437 (which is a prime choice of issues to fix)

Change-Id: I813fb29454160483ec29825469e0370d517850c2
Reviewed-on: https://go-review.googlesource.com/11522
Reviewed-by: Adam Langley <agl@golang.org>
2015-08-29 19:11:03 +00:00
Michal Bohuslávek
fac1039615 encoding/asn1: fix panic when Marshaling nil.
Fixes #11127.

Change-Id: Ibcfc3a05e91fa4260d70b04bee2bbba2376bd313
Reviewed-on: https://go-review.googlesource.com/13923
Reviewed-by: Adam Langley <agl@golang.org>
2015-08-29 18:53:41 +00:00
Keith Randall
805e56ef47 runtime: short-circuit bytes.Compare if src and dst are the same slice
Should only matter on ppc64 and ppc64le.

Fixes #11336

Change-Id: Id4b0ac28b573648e1aa98e87bf010f00d006b146
Reviewed-on: https://go-review.googlesource.com/13901
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-08-29 02:43:57 +00:00
Ian Lance Taylor
d93f3b5e31 time: fix 400 year offset in comment
Change-Id: I33c2c222ea884d9ff57800ea5185644b5d8e591a
Reviewed-on: https://go-review.googlesource.com/14034
Reviewed-by: Minux Ma <minux@golang.org>
2015-08-29 01:03:42 +00:00
Robert Griesemer
3d3bc88bb5 cmd/compile/internal/gc: use slice instead of linked list for nodes to export
Change-Id: Ib79ab787fdc90a5a29b25474d91afa9bfaf51276
Reviewed-on: https://go-review.googlesource.com/13589
Reviewed-by: Minux Ma <minux@golang.org>
2015-08-28 22:49:15 +00:00
Robert Griesemer
68f4f96c1e cmd/compiler/internal/gc: fix argument for Sprintf
Val.Ctype used to be struct field, it's now a method.

Change-Id: I08f0b32b66dba15b2a392e84a557efb905b530cb
Reviewed-on: https://go-review.googlesource.com/14031
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-28 22:46:53 +00:00
Matthew Dempsky
8acaacb665 compress/gzip: clarify Latin-1 restrictions on gzip.Header
Fixes #12361.

Change-Id: Ifd62e8d93b2d733e67e0186c7185cd6291d3bbc1
Reviewed-on: https://go-review.googlesource.com/13939
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-28 22:05:53 +00:00
Russ Cox
63862afb27 cmd/internal/rsc.io: delete
The code is now in cmd/vendor/golang.org/x/arch.

Change-Id: I518d48c21b0d7fed914552b89ee41411f088456b
Reviewed-on: https://go-review.googlesource.com/14021
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-28 16:34:52 +00:00
Russ Cox
90dbd975fd cmd/internal/objfile: use golang.org/x/arch instead of rsc.io
Change-Id: I5348774ff01a5f0f706a1dba4aa9500661841f47
Reviewed-on: https://go-review.googlesource.com/14020
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-28 16:34:39 +00:00
Russ Cox
10efac8782 cmd/vendor/golang.org/x/arch: import arm/armasm and x86/x86asm
For use by cmd/objdump in place of the current cmd/internal/rsc.io/... tree.

Change-Id: I7d765ddf43ab4118a3221fd755ff0a2a02daa5de
Reviewed-on: https://go-review.googlesource.com/13979
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-28 16:34:30 +00:00
Russ Cox
9c04d00214 runtime: check explicitly for short unwinding of stacks
Right now we find out implicitly if stack barriers are in place,
or defers. This change makes sure we find out about short
unwinds always.

Change-Id: Ibdde1ba9c79eb792660dcb7aa6f186e4e4d559b3
Reviewed-on: https://go-review.googlesource.com/13966
Reviewed-by: Austin Clements <austin@google.com>
2015-08-28 16:05:59 +00:00
Daniel Johansson
12663b4627 registry: Explain how GetMUIStringValue works and where it falls short
GetMUIStringValue tries as a convenience to resolve string values even for pathless
resource DLLs by searching the system directory (one of several paths used
by the system's standard DLL search order algorithm). This would not be
needed if regLoadMUIString searched for pathless DLLs itself, but it
doesn't, instead it needs an absolute path, otherwise it will fail.

This approach works fine for solving issue #12015 (handle localized time
zone names; for which GetMUIStringValue was created) since tzres.dll that
is used to resolve localized time zone names has no path in the registry
but is located under the system directory.

However, this approach will fail if a pathless DLL is located somewhere
else than the system directory.

Because of this limitation GetMUIStringValue may have to be revised in the
future to allow for custom paths, possibly through another version of the
function.

See also:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms724890%28v=vs.85%29.aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682586%28v=vs.85%29.aspx

Change-Id: Ida66a0ef1928e0461ce248c795827902d785e6cd
Reviewed-on: https://go-review.googlesource.com/13929
Reviewed-by: Rob Pike <r@golang.org>
2015-08-28 05:41:29 +00:00
Dave Cheney
de786965e6 syscall: remove nacl srpc helper
Fixes #11961

Minux removed the use of SRPC in 003dccfa, but the SRPC name service
code was left in the tree. SRPC was removed in pepper_42 making the
code, which ran on startup, fail, even though it was not used.

Removing srpc_nacl.go for a total diff of -822 lines has got to count
as one of the easiest nacl fixes we've had to date.

Change-Id: Ic4e348146bfe47450bbb9cabb91699ba153e6bf0
Reviewed-on: https://go-review.googlesource.com/13958
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-28 04:44:44 +00:00
Alberto Donizetti
6403c957e0 compress/bzip2: make decoding faster
Issue 6754 reports that Go bzip2 Decode function is much slower
(about 2.5x in go1.5) than the Python equivalent (which is
actually just a wrapper around the usual C library) on random data.

Profiling the code shows that half a dozen of CMP instructions in a
tight loop are responsibile for most of the execution time.

This patch reduces the number of branches of the loop, greatly
improving performance on random data and speeding up decoding of
real data.

name            old time/op    new time/op    delta
DecodeDigits-4    9.28ms ± 1%    8.05ms ± 1%  -13.18%  (p=0.000 n=15+14)
DecodeTwain-4     28.9ms ± 2%    26.4ms ± 1%   -8.57%  (p=0.000 n=15+14)
DecodeRand-4      3.94ms ± 1%    3.06ms ± 1%  -22.45%  (p=0.000 n=15+14)

name            old speed      new speed      delta
DecodeDigits-4  4.65MB/s ± 1%  5.36MB/s ± 1%  +15.21%  (p=0.000 n=13+14)
DecodeTwain-4   4.32MB/s ± 2%  4.72MB/s ± 1%   +9.36%  (p=0.000 n=15+14)
DecodeRand-4    4.27MB/s ± 1%  5.51MB/s ± 1%  +28.86%  (p=0.000 n=15+14)

I've run some benchmark comparing Go bzip2 implementation with the
usual Linux bzip2 command (which is written in C). On my machine
this patch brings go1.5
  from ~2.26x to ~1.50x of bzip2 time (on 64MB  random data)
  from ~1.70x to ~1.50x of bzip2 time (on 100MB english text)
  from ~2.00x to ~1.88x of bzip2 time (on 64MB  /dev/zero data)

Fixes #6754

Change-Id: I3cb12d2c0c2243c1617edef1edc88f05f91d26d1
Reviewed-on: https://go-review.googlesource.com/13853
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-08-28 04:20:56 +00:00
Ian Lance Taylor
499845bfe0 cmd/go: -a does apply to the standard library
This changed in https://golang.org/cl/10761.

Update #12203.

Change-Id: Ia37ebb7ecba689ad3cb2559213d675f21cf03a95
Reviewed-on: https://go-review.googlesource.com/13799
Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-27 18:34:19 +00:00
Russ Cox
a82ed3bc81 cmd/go: enable vendoring experiment by default
If we're going to do this for Go 1.6 we might as well do it now
and find out what breaks.

Change-Id: I8306b7829d8d13b564a1466c902ec6ba1a5a58c1
Reviewed-on: https://go-review.googlesource.com/13967
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-27 17:33:03 +00:00
Russ Cox
35365b97f1 net: restore LookupPort for integer strings
This worked in Go 1.4 but was lost in the "pure Go" lookup
routines substituted late in the Go 1.5 cycle.

Fixes #12263.

Change-Id: I77ec9d97cd8e67ace99d6ac965e5bc16c151ba83
Reviewed-on: https://go-review.googlesource.com/13915
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-27 16:17:21 +00:00
Alexander Morozov
8261c887aa syscall: don't call Setgroups if Credential.Groups is empty
Setgroups with zero-length groups is no-op for changing groups and
supposed to be used only for determining curent groups length. Also
because we deny setgroups by default if use GidMappings we have
unnecessary error from that no-op syscall.

Change-Id: I8f74fbca9190a3dcbbef1d886c518e01fa05eb62
Reviewed-on: https://go-review.googlesource.com/13938
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-27 16:08:01 +00:00
Vincent Vanackere
b55c4a0c54 cmd/go: properly ignore import comments for vendored packages rooted at GOPATH
Fixes #12232.

Change-Id: Ide3fb7f5fc5ae377ae8683fbb94fd0dc01480549
Reviewed-on: https://go-review.googlesource.com/13924
Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-27 15:30:30 +00:00
Tim Cooijmans
34db31d5f5 src/runtime: Add missing defs for android/386.
Change-Id: I63bf6d2fdf41b49ff8783052d5d6c53b20e2f050
Reviewed-on: https://go-review.googlesource.com/13760
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-08-27 15:14:41 +00:00
Didier Spezia
7437e3f02e cmd/asm: fix potential infinite loop in parser
For ARM machines, the assembler supports list of registers
operands such as [R1,R2].

A list missing a ']' results in the parser issuing many errors
and consuming all the tokens. At EOF (i.e. end of the line),
it still loops.

Normally, a counter is maintained to make sure the parser
stops after 10 errors. However, multiple errors occuring on the
same line are simply ignored. Only the first one is reported.
At most one error per line is accounted.

Missing ']' in a register list therefore results in an
infinite loop.

Fixed the parser by explicitly checking for ']' to interrupt
this loops

In the operand tests, also fixed a wrong entry which I think was
not set on purpose (but still led to a successful result).

Fixes #11764

Change-Id: Ie87773388ee0d21b3a2a4cb941d4d911d0230ba4
Reviewed-on: https://go-review.googlesource.com/13920
Reviewed-by: Rob Pike <r@golang.org>
2015-08-27 10:26:40 +00:00
Rob Pike
be33e203ed text/template: add ExecError type and return it from Execute on error
Useful to discriminate evaluation errors from write errors.

Fixes #11898.

Change-Id: I907d339a3820e887872d78e0e2d8fd011451fd19
Reviewed-on: https://go-review.googlesource.com/13957
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-08-27 06:40:56 +00:00
Michael Hudson-Doyle
d497eeb005 runtime: remove unused xchgp/xchgp1
I noticed that they were unimplemented on arm64 but then that they were
in fact not used at all.

Change-Id: Iee579feda2a5e374fa571bcc8c89e4ef607d50f6
Reviewed-on: https://go-review.googlesource.com/13951
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-08-27 00:28:35 +00:00
Robert Griesemer
b9e4867e8d go/types: fix real(a) and imag(a) for untyped arguments
Fixes #11947.

Change-Id: I6225f96b8dea0cecb097f9c7452a1aa80ae4476d
Reviewed-on: https://go-review.googlesource.com/12939
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-08-26 21:16:31 +00:00
Brad Fitzpatrick
a34b8cb733 net/http/httputil: permit nil request body in ReverseProxy
Accepting a request with a nil body was never explicitly supported but
happened to work in the past.

This doesn't happen in most cases because usually people pass
a Server's incoming Request to the ReverseProxy's ServeHTTP method,
and incoming server requests are guaranteed to have non-nil bodies.

Still, it's a regression, so fix.

Fixes #12344

Change-Id: Id9a5a47aea3f2875d195b66c9a5f8581c4ca2aed
Reviewed-on: https://go-review.googlesource.com/13935
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-26 20:28:07 +00:00
Robert Griesemer
b1b3243a1b go/types: check for duplicate values in expression switches
Fixes #11578.

Change-Id: I29a542be247127f470ba6c39aac0d0f6a18de553
Reviewed-on: https://go-review.googlesource.com/13285
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-08-26 18:04:03 +00:00
Robert Griesemer
6184765f86 go/types, go/constant: remove backward-compatibility files (cleanup)
Not needed anymore since go/types is always built against the current
standard library.

Fixes #11538.

Change-Id: I2f07d73703f4e5661c4b5df5d487939dcf530b43
Reviewed-on: https://go-review.googlesource.com/13897
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-08-26 17:57:17 +00:00
Todd Neal
c1aee8c825 net/http: remove always true comparison
byte is unsigned so the comparison against zero is always true.

Change-Id: I8fa60245972be362ae920507a291f92c0f9831ad
Reviewed-on: https://go-review.googlesource.com/13941
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-26 04:55:58 +00:00
Daniel Johansson
cba1528ceb time: handle localized time zone names
The existing implementation fails to determine the correct time zone
abbreviations when the display language is non-English. This change adds
support for localized time zone names (standard- and daylightname)
by using the function RegLoadMUIString.

Fixes #12015

Change-Id: Ic0dc89c50993af8f292b199c20bc5932903e7e87
Reviewed-on: https://go-review.googlesource.com/13854
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-26 04:40:59 +00:00
Uttam C Pawar
32add8d7c8 bytes: improve Compare function on amd64 for large byte arrays
This patch contains only loop unrolling change for size > 63B

Following are the performance numbers for various sizes on
On Haswell based system: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz.

benchcmp go.head.8.25.15.txt go.head.8.25.15.opt.txt
benchmark                       old ns/op     new ns/op     delta
BenchmarkBytesCompare1-4        5.37          5.37          +0.00%
BenchmarkBytesCompare2-4        5.37          5.38          +0.19%
BenchmarkBytesCompare4-4        5.37          5.37          +0.00%
BenchmarkBytesCompare8-4        4.42          4.38          -0.90%
BenchmarkBytesCompare16-4       4.27          4.45          +4.22%
BenchmarkBytesCompare32-4       5.30          5.36          +1.13%
BenchmarkBytesCompare64-4       6.93          6.78          -2.16%
BenchmarkBytesCompare128-4      10.3          9.50          -7.77%
BenchmarkBytesCompare256-4      17.1          13.8          -19.30%
BenchmarkBytesCompare512-4      31.3          22.1          -29.39%
BenchmarkBytesCompare1024-4     62.5          39.0          -37.60%
BenchmarkBytesCompare2048-4     112           73.2          -34.64%

Change-Id: I4eeb1c22732fd62cbac97ba757b0d29f648d4ef1
Reviewed-on: https://go-review.googlesource.com/11871
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-26 03:52:20 +00:00
Todd Neal
a94e906c41 runtime: remove always false comparison in sigsend
s is a uint32 and can never be zero. It's max value is already tested
against sig.wanted, whose size is derived from _NSIG.  This also
matches the test in signal_enable.

Fixes #11282

Change-Id: I8eec9c7df8eb8682433616462fe51b264c092475
Reviewed-on: https://go-review.googlesource.com/13940
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-26 01:02:55 +00:00
Michael Hudson-Doyle
af78482d6b cmd/compile, cmd/link, reflect, runtime: remove type.zero field
No longer used after previous hashmap change.

Change-Id: I558470f872281e84a78406132df4e391d077b833
Reviewed-on: https://go-review.googlesource.com/13785
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-08-26 00:28:17 +00:00
Andy Maloney
dc110f245d cmd/cgo: annotate named return struct members in comments
If an exported function has named return variables, then show the names
as comments in the return struct we create in the header file.

Example here:

 https://groups.google.com/forum/#!topic/golang-nuts/r393ne4zIfY

Change-Id: I21fb4ca2673f6977bec35ccab0cef7d42b311f96
Reviewed-on: https://go-review.googlesource.com/13061
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-26 00:24:34 +00:00
Michael Hudson-Doyle
38519e69d0 cmd/compile, runtime: stop returning t.zero on hashmap miss
Previously t.zero always pointed to runtime.zerovalue. Change the hashmap code
to always return a runtime pointer directly, and change that pointer to point
to a larger buffer if one is needed.

(It might be better to only copy from the pointer returned by the mapaccess
functions when the value type is small enough and have the compiler insert
explicit zeroing for larger value types, but I tried and failed to do this).

This removes all uses of the zero field of the type data; the field itself can
be removed in a separate change.

Fixes #11491

Change-Id: I5b81752ff4067d74a5a281c41e88f151bae0171e
Reviewed-on: https://go-review.googlesource.com/13784
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-26 00:03:21 +00:00
Andy Maloney
79a3d239e9 cmd/cgo: change comments in generated C code to be C-style
Change-Id: I3889eda72ae0f57117f1d4299e3574f8bf68be67
Reviewed-on: https://go-review.googlesource.com/13310
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-08-26 00:01:08 +00:00
Michael Hudson-Doyle
7f9e443d9c cmd/link: call moduledata symbols "local.moduledata" if they are created by the linker
This was always a bit confusing, but it also fixes a problem: runtime.firstmoduledata
was always overridden in the linker to be a local symbol but cmd/internal/obj had
already rewritten code accessing it to access it via the GOT. This works on amd64, but
causes link failures on other platforms (e.g. arm64).

Change-Id: I9b8153af74b4d0f092211d63a000d15818f39773
Reviewed-on: https://go-review.googlesource.com/13786
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-25 23:48:12 +00:00
Ulrich Kunitz
6ec1809b83 cmd/compile: fix register allocation for == operator
The issue 12226 has been caused by the allocation of the same register
for the equality check of two byte values. The code in cgen.go freed the
register for the second operand before the allocation of the register
for the first operand.

Fixes #12226

Change-Id: Ie4dc33a488bd48a17f8ae9b497fd63c1ae390555
Reviewed-on: https://go-review.googlesource.com/13771
Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-25 18:10:14 +00:00
Austin Clements
05a3b1fce5 cmd/compile: fix uninitialized memory in compare of interface value
A comparison of the form l == r where l is an interface and r is
concrete performs a type assertion on l to convert it to r's type.
However, the compiler fails to zero the temporary where the result of
the type assertion is written, so if the type is a pointer type and a
stack scan occurs while in the type assertion, it may see an invalid
pointer on the stack.

Fix this by zeroing the temporary. This is equivalent to the fix for
type switches from c4092ac.

Fixes #12253.

Change-Id: Iaf205d456b856c056b317b4e888ce892f0c555b9
Reviewed-on: https://go-review.googlesource.com/13872
Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-25 14:37:08 +00:00
Dave Cheney
686d44d9e0 runtime: check pointer equality in arm64 cmpbody
Updates #11336

Follow the lead of amd64 by doing a pointer equality check
before comparing string/byte contents on arm64.

BenchmarkCompareBytesEqual-8               25.8           26.3           +1.94%
BenchmarkCompareBytesToNil-8               9.59           9.59           +0.00%
BenchmarkCompareBytesEmpty-8               9.59           9.17           -4.38%
BenchmarkCompareBytesIdentical-8           26.3           9.17           -65.13%
BenchmarkCompareBytesSameLength-8          16.3           16.3           +0.00%
BenchmarkCompareBytesDifferentLength-8     16.3           16.3           +0.00%
BenchmarkCompareBytesBigUnaligned-8        1132038        1131409        -0.06%
BenchmarkCompareBytesBig-8                 1126758        1128470        +0.15%
BenchmarkCompareBytesBigIdentical-8        1084366        9.17           -100.00%

Change-Id: Id7125c31957eff1ddb78897d4511bd50e79af3f7
Reviewed-on: https://go-review.googlesource.com/13885
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-25 03:29:47 +00:00
Todd Neal
3efe36d4c4 runtime: fix nmspinning comparison
nmspinning has a value range of [0, 2^31-1].  Update the comment to
indicate this and fix the comparison so it's not always false.

Fixes #11280

Change-Id: Iedaf0654dcba5e2c800645f26b26a1a781ea1991
Reviewed-on: https://go-review.googlesource.com/13877
Reviewed-by: Minux Ma <minux@golang.org>
2015-08-25 02:44:11 +00:00
Shenghou Ma
24be0997a2 runtime: add a missing hex conversion
gobuf.g is a guintptr, so without hex(), it will be printed as
a decimal, which is not very helpful and inconsistent with how
other pointers are printed.

Change-Id: I7c0432e9709e90a5c3b3e22ce799551a6242d017
Reviewed-on: https://go-review.googlesource.com/13879
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-08-25 01:37:54 +00:00
Didier Spezia
8286f18b94 debug/elf: map/slice literals janitoring
Simplify slice/map literal expressions.
Caught with gofmt -d -s, fixed with gofmt -w -s
Reformatted some expressions to improve readability.

Change-Id: Iaf123e6bd49162ec45c59297ad3b002ca59443bc
Reviewed-on: https://go-review.googlesource.com/13850
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-25 01:36:11 +00:00
Shenghou Ma
b11c8b9370 cmd/go: skip test using external linking on linux/ppc64 too
While we're at it, also fix a typo.

Change-Id: Id436f33cffa5683e2a8450cce5b545960cf2877e
Reviewed-on: https://go-review.googlesource.com/13878
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-08-25 01:33:25 +00:00
Todd Neal
7ebaa43754 encoding/gob: remove always false comparison
This is not a functional change. nr is a uint64 and can never be less
than zero, remove the no-op comparison.

Fixes #11279

Change-Id: Iebb36cc8fe97428b503e65d01b5e67d2b2bc7369
Reviewed-on: https://go-review.googlesource.com/13876
Run-TryBot: Todd Neal <todd@tneal.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-25 00:14:45 +00:00
Aaron Jacobs
acb4765709 os/signal: skip the nohup test on darwin when running in tmux.
The nohup command doesn't work in tmux on darwin.

Fixes #5135.

Change-Id: I1c21073d8bd54b49dd6b0bad86ef088d6d8e7a5f
Reviewed-on: https://go-review.googlesource.com/13883
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-25 00:14:24 +00:00
Joe Tsai
8e2d0e1c4c hash/fnv: fix wiki url
The URL is shown on go docs and is an eye-sore.

For go1.6.

Change-Id: I8b8ea3751200d06ed36acfe22f47ebb38107f8db
Reviewed-on: https://go-review.googlesource.com/13282
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-24 21:26:42 +00:00
Dave Cheney
1135b9d671 runtime: check pointer equality in arm cmpbody
Updates #11336

Follow the lead of amd64 do a pointer equality check
before comparing string/byte contents on arm.

BenchmarkCompareBytesEqual-4               208             211             +1.44%
BenchmarkCompareBytesToNil-4               83.6            81.8            -2.15%
BenchmarkCompareBytesEmpty-4               80.2            75.2            -6.23%
BenchmarkCompareBytesIdentical-4           208             75.2            -63.85%
BenchmarkCompareBytesSameLength-4          126             128             +1.59%
BenchmarkCompareBytesDifferentLength-4     128             130             +1.56%
BenchmarkCompareBytesBigUnaligned-4        14192804        14060971        -0.93%
BenchmarkCompareBytesBig-4                 12277313        12128193        -1.21%
BenchmarkCompareBytesBigIdentical-4        9385046         78.5            -100.00%

Change-Id: I5b24620018688c5fe04b6ff6743a24c4ce225788
Reviewed-on: https://go-review.googlesource.com/13881
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-24 21:18:33 +00:00
Rob Pike
b1eec186f2 fmt: in Scanf, %c can scan a space, so don't skip spaces at %c
In short, %c should just give you the next rune, period.
Apparently this is the design. I use the term loosely.

Fixes #12275

Change-Id: I6f30bed442c0e88eac2244d465c7d151b29cf393
Reviewed-on: https://go-review.googlesource.com/13821
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-08-24 20:25:07 +00:00
Tarmigan Casebolt
201a05ad2f encoding/asn1: fix unused assignments
Unused assignment for `err` encoding/asn1/marshal.go:622:3
Unused assignment for `err` encoding/asn1/marshal.go:650:5

Change-Id: I4226238645ce3640f25124cb405444e61439fd3f
Reviewed-on: https://go-review.googlesource.com/13847
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-24 18:24:49 +00:00
Matt Layher
759210b962 net: allow ParseMAC to parse 20-octet IPoIB link-layer address
Fixes #11763

Change-Id: Ie291b36a8c29694e80940836d7e6fd96d2d76494
Reviewed-on: https://go-review.googlesource.com/12382
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-24 16:34:43 +00:00
Tarmigan Casebolt
f7dc4eb921 image/gif: avoid unused assignment
Change-Id: Iaaecd8be9268c923f40cf0e5153cbf79f7015b8d
Reviewed-on: https://go-review.googlesource.com/13892
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-24 16:17:42 +00:00
Marcel van Lohuizen
c714bbbfd3 unicode: include rune 0 in RangeTables.
All of Go passes. No changes for the text repo.

Fixes #10153

Change-Id: I313369bf471c8974390a6d42075e5c54f6a81750
Reviewed-on: https://go-review.googlesource.com/13667
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-08-24 15:05:48 +00:00
Tarmigan Casebolt
1870c81205 go/internal/gcimporter: remove unused assignment
Change-Id: I0b19731a46e4e67a7dd503dd133cafc7678760a7
Reviewed-on: https://go-review.googlesource.com/13890
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-24 14:40:33 +00:00
Tarmigan Casebolt
e893724e75 math: avoid unused assignment in jn.go
Change-Id: Ie4f21bcd5849e994c63ec5bbda2dee6f3ec4da12
Reviewed-on: https://go-review.googlesource.com/13891
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-24 14:34:36 +00:00
Alex Brainman
cfb5bc993a internal/syscall/windows/registry: remove debugging dreg
Change-Id: I1b9f6ad322a7f68fa160c4f09d7fb56815e505a7
Reviewed-on: https://go-review.googlesource.com/13828
Reviewed-by: Rob Pike <r@golang.org>
2015-08-24 04:25:18 +00:00
Dave Cheney
f9379eb346 make.bash: abort if $GOROOT_BOOTSTRAP == $GOROOT
Fixes #12214

Change-Id: I82586b54ac7b9c0c71055bb66b921e3efbf4977c
Reviewed-on: https://go-review.googlesource.com/13719
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-08-24 03:04:52 +00:00
Josh Bleecher Snyder
397b4f6cbf cmd/internal/obj: delete Debugzerostack dead code
Fixes #11060

Change-Id: I4c6647fc2f103015b67e30dc2cdb6f771526c139
Reviewed-on: https://go-review.googlesource.com/13840
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-23 14:07:14 +00:00
Mikio Hara
c049d34006 net: drop redundant domain name length check
It is already validated by isDoaminName.

Change-Id: I7a955b632a5143e16b012641cf12bad452900753
Reviewed-on: https://go-review.googlesource.com/13789
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-08-23 10:43:46 +00:00
Andrew Gerrand
8ca785621e mime: move examples to external test file
Fixes #11257

Change-Id: I3f75db47b0f8e877d81e3c2dcea01ff747b47685
Reviewed-on: https://go-review.googlesource.com/13779
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-22 18:39:29 +00:00
Brad Fitzpatrick
b3a508c03e cmd/compile: in usage messages, name the binary "compile" instead of "Xg"
Fixes #12227

Change-Id: I7c1b93e50736185a641fb637000aae2f15bc04ed
Reviewed-on: https://go-review.googlesource.com/13820
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-08-22 15:39:13 +00:00
Ingo Oeser
5b92028155 html: speed up UnescapeString
Add benchmarks for for sparsely escaped and densely escaped strings.
Then speed up the sparse unescaping part heavily by using IndexByte and
copy to skip the parts containing no escaping very fast.

Unescaping densely escaped strings slower because of
the new function call overhead. But sparsely encoded strings are seen
more often in the utf8 enabled web.

We win part of the speed back by looking up entityName differently.

	benchmark                  old ns/op    new ns/op    delta
	BenchmarkEscape                31680        31396   -0.90%
	BenchmarkEscapeNone             6507         6872   +5.61%
	BenchmarkUnescape              36481        48298  +32.39%
	BenchmarkUnescapeNone            332          325   -2.11%
	BenchmarkUnescapeSparse         8836         3221  -63.55%
	BenchmarkUnescapeDense         30639        32224   +5.17%

Change-Id: If606cb01897a40eefe35ba98f2ff23bb25251606
Reviewed-on: https://go-review.googlesource.com/10172
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-22 12:45:38 +00:00
Justin Nuß
5f859ba83d time: Use AppendFormat in Marshal[Text|JSON]
The current implementations of MarshalJSON and MarshalText use
time.Format which returns a string (converted from a byte slice),
only to convert it back to a byte slice.

Avoid the conversion (and thus an allocation) by directly appending
the formatted time to a preallocated byte slice, using the new
AppendFormat function, introduced in golang.org/cl/1760.

This reduces the allocations done in Marshal[Text|JSON] by 50%.

benchmark                old ns/op     new ns/op     delta
BenchmarkMarshalJSON     626           507           -19.01%
BenchmarkMarshalText     598           511           -14.55%

benchmark                old allocs     new allocs     delta
BenchmarkMarshalJSON     2              1              -50.00%
BenchmarkMarshalText     2              1              -50.00%

benchmark                old bytes     new bytes     delta
BenchmarkMarshalJSON     96            48            -50.00%
BenchmarkMarshalText     96            48            -50.00%

Fixes #11025

Change-Id: I468f78d075a6ecc1cdc839df7fb407fbc6ff2e70
Reviewed-on: https://go-review.googlesource.com/10555
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-22 11:31:58 +00:00
Brad Fitzpatrick
2468227038 cmd/compile/internal, cmd/internal/obj: used keyed ProgInfo literals
Safer, more readable, shorter.

Change-Id: I5cf1f438e20a3df45fc43cc5c870a533f7c524bf
Reviewed-on: https://go-review.googlesource.com/10517
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-21 22:32:43 +00:00
Alberto Donizetti
85de30e72f cmd/compile: allow huge rsh in constants arithmetic
Currently an expression like

var v = 0 >> 1000

is rejected by gc with a "stupid shift" error, while gotype
compiles it successfully.

As suggested by gri on the issue tracker, allow an rsh right
operand to be any valid uint value.

Fixes #11328

Change-Id: I6ccb3b7f842338d91fd26ae37dd4fa279d7fc440
Reviewed-on: https://go-review.googlesource.com/13777
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-08-21 20:27:22 +00:00
Robert Griesemer
548041ed08 cmd/compile/internal/big: update vendored math/big
This updates the big package used by the compiler to match the
public big package which contains some updates and bug fixes.
Obtained by running vendor.bash in the internal/big directory.
No manual changes.

Change-Id: I299aecc6599d4a745a721ce48def32449640dbb2
Reviewed-on: https://go-review.googlesource.com/13815
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-08-21 20:03:16 +00:00
Robert Griesemer
e288271773 math/big: fix TestBytes test
Fixes #12231.

Change-Id: I1f07c444623cd864667e21b2fee534eacdc193bb
Reviewed-on: https://go-review.googlesource.com/13814
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-08-21 20:02:40 +00:00