1
0
mirror of https://github.com/golang/go synced 2024-09-30 13:18:34 -06:00
Commit Graph

30167 Commits

Author SHA1 Message Date
Joe Tsai
8eca08611a unicode/utf8: optimize ValidRune
Re-writing the switch statement as a single boolean expression
reduces the number of branches that the compiler generates.
It is also arguably easier to read as a pair of numeric ranges
that valid runes can exist in.

No test changes since the existing test does a good job of
testing all of the boundaries.

This change was to gain back some performance after a correctness
fix done in http://golang.org/cl/32123.

The correctness fix (CL/32123) slowed down the benchmarks slightly:
	benchmark                   old ns/op     new ns/op     delta
	BenchmarkIndexRune/10-4     19.3          21.6          +11.92%
	BenchmarkIndexRune/32-4     33.6          35.2          +4.76%

Since the fix relies on utf8.ValidRune, this CL improves benchmarks:
	benchmark                   old ns/op     new ns/op     delta
	BenchmarkIndexRune/10-4     21.6          20.0          -7.41%
	BenchmarkIndexRune/32-4     35.2          33.5          -4.83%

Change-Id: Ib1ca10a2e29c90e879a8ef9b7221c33e85d015d8
Reviewed-on: https://go-review.googlesource.com/32122
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-26 23:02:52 +00:00
Robert Griesemer
3cfc757c62 go/scanner: recognize invalid floating-point constant exponent
Fixes #17621.

Change-Id: Id3e75c9b7fba2cf8e791c8817f890556ca238e9d
Reviewed-on: https://go-review.googlesource.com/32096
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-10-26 23:02:42 +00:00
Joe Tsai
4b2665786e bytes, strings: fix regression in IndexRune
In all previous versions of Go, the behavior of IndexRune(s, r)
where r was utf.RuneError was that it would effectively return the
index of any invalid UTF-8 byte sequence (include RuneError).
Optimizations made in http://golang.org/cl/28537 and
http://golang.org/cl/28546 altered this undocumented behavior such
that RuneError would only match on the RuneError rune itself.

Although, the new behavior is arguably reasonable, it did break code
that depended on the previous behavior. Thus, we add special checks
to ensure that we preserve the old behavior.

There is a slight performance hit for correctness:
	benchmark                   old ns/op     new ns/op     delta
	BenchmarkIndexRune/10-4     19.3          21.6          +11.92%
	BenchmarkIndexRune/32-4     33.6          35.2          +4.76%
This only occurs on small strings. The performance hit for larger strings
is neglible and not shown.

Fixes #17611

Change-Id: I1d863a741213d46c40b2e1724c41245df52502a5
Reviewed-on: https://go-review.googlesource.com/32123
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-26 23:02:27 +00:00
Adam Langley
4f1e7be51f crypto/x509: use Certificate.Equals and CertPool.contains.
By using these utility functions, the code can be made a little shorter.
Thanks to Omar Shafie for pointing this out in
https://golang.org/cl/27393/.

Change-Id: I33fd97cf7d60a31d0844ec16c12bba530dcc6f6d
Reviewed-on: https://go-review.googlesource.com/32120
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-26 22:58:21 +00:00
Brad Fitzpatrick
f697cf2255 net/http/httptest: doc tweaks
From lost-in-flight comments on CL 32190.

Change-Id: I2029cbac6d24b5944a796b359080011ec3a8da92
Reviewed-on: https://go-review.googlesource.com/32210
Reviewed-by: Caleb Spare <cespare@gmail.com>
Reviewed-by: Martin Möhrmann <martisch@uos.de>
2016-10-26 22:55:05 +00:00
Brad Fitzpatrick
8e4ea2f5e8 net/http/httptest: add more docs on ResponseRecord fields
Fixes #16717

Change-Id: I7b6518609796a537437539c35461a18e9e6f207f
Reviewed-on: https://go-review.googlesource.com/32190
Reviewed-by: Martin Möhrmann <martisch@uos.de>
2016-10-26 22:45:13 +00:00
Jaana Burcu Dogan
31f50643c3 context: add comments to the WithCancel example, apply minor improvements
Fixes #17534.

Change-Id: I28af74b287a5a09d5f6607a012f3d5d133b04ed2
Reviewed-on: https://go-review.googlesource.com/32017
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-26 22:35:07 +00:00
Carl Johnson
117c9c35cd net/http: Improve docs for Response.ParseForm
- Removes a subject-verb disagreement.
- Documents that PATCH requests also populate PostForm.
- Explains that r.PostForm is always set (but blank for GET etc.).

Fixes #16609

Change-Id: I6b4693f8eb6db7c66fd9b9cd1df8927f50d46d50
Reviewed-on: https://go-review.googlesource.com/32091
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-26 22:25:23 +00:00
Joe Tsai
03361fd350 bytes, strings: fix snake-case in variable name
Change-Id: I40896fffbffefa359d08abda346933aa996f628d
Reviewed-on: https://go-review.googlesource.com/32124
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-26 21:51:48 +00:00
Than McIntosh
d80e8de54e cmd/compile: avoid truncating fieldname var locations
Don't include package path when creating LSyms for auto and param
variables during Prog generation, and update the DWARF emit routine
accordingly (remove the code that chops off package path from names in
DWARF var location expressions). Implementation suggested by mdempsky@.

The intent of this change is to have saner location expressions in cases
where the variable corresponds to a structure field. For example, the
SSA compiler's "decompose" phase can take a slice value and break it
apart into three scalar variables corresponding to the fields (slice "X"
gets split into "X.len", "X.cap", "X.ptr"). In such cases we want the
name in the location expression to omit the package path but preserve
the original variable name (e.g. "X").

Fixes #16338

Change-Id: Ibc444e7f3454b70fc500a33f0397e669d127daa1
Reviewed-on: https://go-review.googlesource.com/31819
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-10-26 21:14:46 +00:00
Brad Fitzpatrick
c7e0dda450 net/http: add Server.ReadHeaderTimeout, IdleTimeout, document WriteTimeout
Updates #14204
Updates #16450
Updates #16100

Change-Id: Ic283bcec008a8e0bfbcfd8531d30fffe71052531
Reviewed-on: https://go-review.googlesource.com/32024
Reviewed-by: Tom Bergan <tombergan@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-26 21:04:24 +00:00
Brad Fitzpatrick
1625da2410 encoding/json: marshal the RawMessage value type the same as its pointer type
Fixes #14493
Updates #6458 (changes its behavior)

Change-Id: I851a8113fd312dae3384e989ec2b70949dc22838
Reviewed-on: https://go-review.googlesource.com/21811
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Quentin Smith <quentin@golang.org>
2016-10-26 21:03:00 +00:00
Brad Fitzpatrick
587b80322c api: update next.txt
Change-Id: I5ad338c90c311bd4cfdcd3d221a1f3e506a97d53
Reviewed-on: https://go-review.googlesource.com/32118
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-26 19:46:59 +00:00
David Chase
bea5252a13 cmd/compile: add explicit 'where' to EscStep data for explanations
Sometimes neither the src nor the dst of an escape edge
contains the line number appropriate to the edge, so add
a field so that can be set correctly.

Also updated some of the explanations to be less jargon-y
and perhaps more informative, and folded bug example into
test.

Cleaned up some of the function/method names in esc.go
and did a quick sanity check that each "bundling" function
was actually called often enough to justify its existence.

Fixes #17459.

Change-Id: Ieba53ab0a6ba1f7a6c4962bc0b702ede9cc3a3cc
Reviewed-on: https://go-review.googlesource.com/31660
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-10-26 18:46:59 +00:00
Mikio Hara
6d9c8c926d net/http: gofmt -w -s
Change-Id: I6815a8560dd9fe0a0ebd485a0693f7044ba09848
Reviewed-on: https://go-review.googlesource.com/32137
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-26 18:24:08 +00:00
Austin Clements
d6625caf53 runtime: scan mark worker stacks like normal
Currently, markroot delays scanning mark worker stacks until mark
termination by putting the mark worker G directly on the rescan list
when it encounters one during the mark phase. Without this, since mark
workers are non-preemptible, two mark workers that attempt to scan
each other's stacks can deadlock.

However, this is annoyingly asymmetric and causes some real problems.
First, markroot does not own the G at that point, so it's not
technically safe to add it to the rescan list. I haven't been able to
find a specific problem this could cause, but I suspect it's the root
cause of issue #17099. Second, this will interfere with the hybrid
barrier, since there is no stack rescanning during mark termination
with the hybrid barrier.

This commit switches to a different approach. We move the mark
worker's call to gcDrain to the system stack and set the mark worker's
status to _Gwaiting for the duration of the drain to indicate that
it's preemptible. This lets another mark worker scan its G stack while
the drain is running on the system stack. We don't return to the G
stack until we can switch back to _Grunning, which ensures we don't
race with a stack scan. This lets us eliminate the special case for
mark worker stack scans and scan them just like any other goroutine.
The only subtlety to this approach is that we have to disable stack
shrinking for mark workers; they could be referring to captured
variables from the G stack, so it's not safe to move their stacks.

Updates #17099 and #17503.

Change-Id: Ia5213949ec470af63e24dfce01df357c12adbbea
Reviewed-on: https://go-review.googlesource.com/31820
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-10-26 18:13:16 +00:00
David du Colombier
8e4e103a00 net/rpc: enable TestGobError on Plan 9
This issue has been fixed in CL 31271.

Fixes #8908.

Change-Id: I8015490e2d992e09c664560e42188315e0e0669e
Reviewed-on: https://go-review.googlesource.com/32150
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-26 18:05:24 +00:00
Austin Clements
f46324cffb cmd/compile: remove unused writebarrierptr, typedmemmove Nodes
Now that SSA's write barrier pass is generating calls to these,
compile doesn't need to look them up.

Change-Id: Ib50e5f2c67b247ca280d467c399e23877988bc12
Reviewed-on: https://go-review.googlesource.com/32170
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-10-26 16:22:45 +00:00
David du Colombier
a0cf021be5 os: consider only files from #M as regular on Plan 9
TestRemoveDevNull was added in CL 31657. However, this test
was failing on Plan 9, because /dev/null was considered as
a regular file.

On Plan 9, there is no special mode to distinguish between
device files and regular files.

However, files are served by different servers. For example,
/dev/null is served by #c (devcons), while /bin/cat is served
by #M (devmnt).

We chose to consider only the files served by #M as regular
files. All files served by different servers will be considered
as device files.

Fixes #17598.

Change-Id: Ibb1c3357d742cf2a7de15fc78c9e436dc31982bb
Reviewed-on: https://go-review.googlesource.com/32152
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-26 16:18:00 +00:00
Russ Cox
49543695c5 flag: arrange for FlagSet.Usage to be non-nil by default
This allows callers to invoke f.Usage() themselves and get the default
usage handler instead of a panic (from calling a nil function).

Fixes #16955.

Change-Id: Ie337fd9e1f85daf78c5eae7b5c41d5ad8c1f89bf
Reviewed-on: https://go-review.googlesource.com/31576
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-10-26 16:13:40 +00:00
Rob Pike
f9027d61ab all: freeze net/rpc and reword the 'frozen' message in other frozen packages
Make the messages grammatically korrect and consistent.

Fixes #16844

Change-Id: I7c137b4dc25c0c875ed07b0c64c67ae984c39cbc
Reviewed-on: https://go-review.googlesource.com/32112
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-26 16:11:07 +00:00
Rob Pike
cec84f7309 doc/effectivego: reword confusing sentence
For some reason git won't let me write

	doc/effective_go.html: reword confusing sentence

or even

	doc/effective_go: reword confusing sentence

as the subject line for this CL, but that's not important. The
actual CL just rewrites one sentence and adds an option to grep in
the associated example.

Fixes #15875

Change-Id: Iee159ea751caf4b73eacf3dfc86e29032646373f
Reviewed-on: https://go-review.googlesource.com/32110
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-26 16:09:54 +00:00
Austin Clements
3193c71c5b runtime: fix bad pointer with 0 stack barriers
Currently, if the number of stack barriers for a stack is 0, we'll
create a zero-length slice that points just past the end of the stack
allocation. This bad pointer causes GC panics.

Fix this by creating a nil slice if the stack barrier count is 0.

In practice, the only way this can happen is if
GODEBUG=gcstackbarrieroff=1 is set because even the minimum size stack
reserves space for two stack barriers.

Change-Id: I3527c9a504c445b64b81170ee285a28594e7983d
Reviewed-on: https://go-review.googlesource.com/31762
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-10-26 15:46:25 +00:00
Austin Clements
d1cc83472d runtime: debug code to panic when marking a free object
This adds debug code enabled in gccheckmark mode that panics if we
attempt to mark an unallocated object. This is a common issue with the
hybrid barrier when we're manipulating uninitialized memory that
contains stale pointers. This also tends to catch bugs that will lead
to "sweep increased allocation count" crashes closer to the source of
the bug.

Change-Id: I443ead3eac6f316a46f50b106078b524cac317f4
Reviewed-on: https://go-review.googlesource.com/31761
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-10-26 15:46:00 +00:00
Austin Clements
79561a84ce runtime: simplify reflectcall write barriers
Currently reflectcall has a subtle dance with write barriers where the
assembly code copies the result values from the stack to the in-heap
argument frame without write barriers and then calls into the runtime
after the fact to invoke the necessary write barriers.

For the hybrid barrier (and for ROC), we need to switch to a
*pre*-write write barrier, which is very difficult to do with the
current setup. We could tie ourselves in knots of subtle reasoning
about why it's okay in this particular case to have a post-write write
barrier, but this commit instead takes a different approach. Rather
than making things more complex, this simplifies reflection calls so
that the argument copy is done in Go using normal bulk write barriers.

The one difficulty with this approach is that calling into Go requires
putting arguments on the stack, but the call* functions "donate" their
entire stack frame to the called function. We can get away with this
now because the copy avoids using the stack and has copied the results
out before we clobber the stack frame to call into the write barrier.
The solution in this CL is to call another function, passing arguments
in registers instead of on the stack, and let that other function
reserve more stack space and setup the arguments for the runtime.

This approach seemed to work out the best. I also tried making the
call* functions reserve 32 extra bytes of frame for the write barrier
arguments and adjust SP up by 32 bytes around the call. However, even
with the necessary changes to the assembler to correct the spdelta
table, the runtime was still having trouble with the frame layout (and
the changes to the assembler caused many other things that do strange
things with the SP to fail to assemble). The approach I took doesn't
require any funny business with the SP.

Updates #17503.

Change-Id: Ie2bb0084b24d6cff38b5afb218b9e0534ad2119e
Reviewed-on: https://go-review.googlesource.com/31655
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-10-26 15:44:44 +00:00
Russ Cox
1c3ab3d431 cmd/go: report missing vendor visibility error
The logic for saving the list of packages was not always
preferring to keep error messages around correctly.
The missed error led to an internal consistency failure later.

Fixes #17119.

Change-Id: I9723b5d2518c25e2cac5249e6a7b907be95b521c
Reviewed-on: https://go-review.googlesource.com/31812
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Quentin Smith <quentin@golang.org>
2016-10-26 15:15:38 +00:00
Filippo Valsorda
51c959b62c crypto/tls: expand ClientHelloInfo
Fixes #17430

Change-Id: Ia1c25363d64e3091455ce00644438715aff30a0d
Reviewed-on: https://go-review.googlesource.com/31391
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Filippo Valsorda <hi@filippo.io>
2016-10-26 15:00:29 +00:00
Russ Cox
4b9490ee72 fmt: document that unexported struct fields don't get the String/Error treatment
Fixes #17409.

Change-Id: Ib49ff4a467431b5c1e6637e5144979cf0bfba489
Reviewed-on: https://go-review.googlesource.com/31817
Reviewed-by: Martin Möhrmann <martisch@uos.de>
Reviewed-by: Quentin Smith <quentin@golang.org>
2016-10-26 13:56:45 +00:00
Russ Cox
59b0e14760 cmd/go: diagnose non-canonical import paths before compilation
If we leave it for compilation sometimes the error appears first
in derived vendor paths, without any indication where they came from.
This is better.

$ go1.7 build canonical/d
cmd/go/testdata/src/canonical/a/a.go:3: non-canonical import path "canonical/a//vendor/c" (should be "canonical/a/vendor/c")
cmd/go/testdata/src/canonical/a/a.go:3: can't find import: "canonical/a//vendor/c"

$ go build canonical/d
package canonical/d
	imports canonical/b
	imports canonical/a/: non-canonical import path: "canonical/a/" should be "canonical/a"
$

Fixes #16954.

Change-Id: I315ccec92a00d98a08c139b3dc4e17dbc640edd0
Reviewed-on: https://go-review.googlesource.com/31668
Reviewed-by: Quentin Smith <quentin@golang.org>
2016-10-26 13:54:45 +00:00
Russ Cox
e3324a4b66 cmd/vet: diagnose non-space-separated struct tag like json:"x",xml:"y"
This is not strictly illegal but it probably should be (too late)
and doesn't mean what it looks like it means:
the second key-value pair has the key ",xml".

Fixes #14466.

Change-Id: I174bccc23fd28affeb87f57f77c6591634ade641
Reviewed-on: https://go-review.googlesource.com/32031
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Quentin Smith <quentin@golang.org>
2016-10-26 13:37:51 +00:00
Michael Munday
3202aa7800 cmd/compile: improve s390x SSA rules for logical ops
This CL introduces some minor changes to match rules more closely
to the instructions they are targeting. s390x logical operation
with immediate instructions typically leave some bits in the
target register unchanged. This means for example that an XOR
with -1 requires 2 instructions. It is better in cases such as
this to create a constant and leave it visible to the compiler
so that it can be reused rather than hiding it in the assembler.

This CL also tweaks the rules a bit to ensure that constants are
folded when possible.

Change-Id: I1c6dee31ece00fc3c5fdf6a24f1abbc91dd2db2a
Reviewed-on: https://go-review.googlesource.com/31754
Reviewed-by: Keith Randall <khr@golang.org>
2016-10-26 12:30:28 +00:00
Alexander Morozov
2481481ff7 runtime: fix comments in time.go
Change-Id: I5c501f598f41241e6d7b21d98a126827a3c3ad9a
Reviewed-on: https://go-review.googlesource.com/32018
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-26 03:51:33 +00:00
Francesc Campoy
6e02750dd6 cmd/dist: ignore stderr when listing packages to test
Currently any warning will make dist fail because the
text will be considered as part of the package list.

Change-Id: I09a14089cd0448c3779e2f767e9356fe3325d8d9
Reviewed-on: https://go-review.googlesource.com/32111
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Andrew Gerrand <adg@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-10-26 02:24:45 +00:00
Matthew Dempsky
d89b70d433 cmd/compile: slightly regularize interface method types
Use a single *struct{} type instance rather than reconstructing one
for every declared/imported interface method. Minor allocations win:

name       old alloc/op    new alloc/op    delta
Template      41.8MB ± 0%     41.7MB ± 0%  -0.10%         (p=0.000 n=9+10)
Unicode       34.2MB ± 0%     34.2MB ± 0%    ~           (p=0.971 n=10+10)
GoTypes        123MB ± 0%      122MB ± 0%  -0.03%         (p=0.000 n=9+10)
Compiler       495MB ± 0%      495MB ± 0%  -0.01%        (p=0.000 n=10+10)

name       old allocs/op   new allocs/op   delta
Template        409k ± 0%       408k ± 0%  -0.13%        (p=0.000 n=10+10)
Unicode         354k ± 0%       354k ± 0%    ~           (p=0.516 n=10+10)
GoTypes        1.22M ± 0%      1.22M ± 0%  -0.03%        (p=0.009 n=10+10)
Compiler       4.43M ± 0%      4.43M ± 0%  -0.02%        (p=0.000 n=10+10)

Change-Id: Id3a4ca3dd09112bb96ccc982b06c9e79f661d31f
Reviewed-on: https://go-review.googlesource.com/32051
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-10-25 23:54:41 +00:00
Keith Randall
c78d072c8e Revert "Revert "cmd/compile: inline convI2E""
This reverts commit 7dd9c385f6.

Reason for revert: Reverting the revert, which will re-enable the convI2E optimization.  We originally reverted the convI2E optimization because it was making the builder fail, but the underlying cause was later determined to be unrelated.

Original CL: https://go-review.googlesource.com/31260
Revert CL: https://go-review.googlesource.com/31310
Real bug: https://go-review.googlesource.com/c/25159
Real fix: https://go-review.googlesource.com/c/31316

Change-Id: I17237bb577a23a7675a5caab970ccda71a4124f2
Reviewed-on: https://go-review.googlesource.com/32023
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-10-25 23:51:34 +00:00
Joe Tsai
c60d9a33bf net/http: fix redirect logic to handle mutations of cookies
In the situation where the Client.Jar is set and the Request.Header
has cookies manually inserted, the redirect logic needs to be
able to apply changes to cookies from "Set-Cookie" headers to both
the Jar and the manually inserted Header cookies.

Since Header cookies lack information about the original domain
and path, the logic in this CL simply removes cookies from the
initial Header if any subsequent "Set-Cookie" matches. Thus,
in the event of cookie conflicts, the logic preserves the behavior
prior to change made in golang.org/cl/28930.

Fixes #17494
Updates #4800

Change-Id: I645194d9f97ff4d95bd07ca36de1d6cdf2f32429
Reviewed-on: https://go-review.googlesource.com/31435
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-25 23:51:29 +00:00
Matthew Dempsky
70d685dc72 cmd/compile: don't wrap numeric or type literals in OPAREN
It's only necessary to wrap named OTYPE or OLITERAL nodes, because
their line numbers reflect the line number of the declaration, rather
than use.

Saves a lot of wrapper nodes in composite-literal-heavy packages like
Unicode.

name       old alloc/op    new alloc/op    delta
Template      41.8MB ± 0%     41.8MB ± 0%  -0.07%        (p=0.000 n=10+10)
Unicode       36.6MB ± 0%     34.2MB ± 0%  -6.55%        (p=0.000 n=10+10)
GoTypes        123MB ± 0%      123MB ± 0%  -0.02%        (p=0.004 n=10+10)
Compiler       495MB ± 0%      495MB ± 0%  -0.03%        (p=0.000 n=10+10)

name       old allocs/op   new allocs/op   delta
Template        409k ± 0%       409k ± 0%  -0.05%        (p=0.029 n=10+10)
Unicode         371k ± 0%       354k ± 0%  -4.48%         (p=0.000 n=10+9)
GoTypes        1.22M ± 0%      1.22M ± 0%    ~           (p=0.075 n=10+10)
Compiler       4.44M ± 0%      4.44M ± 0%  -0.02%        (p=0.000 n=10+10)

Change-Id: Id1183170835125c778fb41b7e76d06d5ecd4f7a1
Reviewed-on: https://go-review.googlesource.com/32021
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-10-25 23:01:51 +00:00
Matthew Dempsky
57df2f802f cmd/compile: remove old lexer and parser
Change-Id: I7306d28930dc4538a3bee31ff5d22f3f40681ec5
Reviewed-on: https://go-review.googlesource.com/32020
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-25 22:39:30 +00:00
Austin Clements
575b1dda4e runtime: eliminate allspans snapshot
Now that sweeping and span marking use the sweep list, there's no need
for the work.spans snapshot of the allspans list. This change
eliminates the few remaining uses of it, which are either dead code or
can use allspans directly, and removes work.spans and its support
functions.

Change-Id: Id5388b42b1e68e8baee853d8eafb8bb4ff95bb43
Reviewed-on: https://go-review.googlesource.com/30537
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-10-25 22:33:02 +00:00
Austin Clements
c95a8e458f runtime: make markrootSpans time proportional to in-use spans
Currently markrootSpans iterates over all spans ever allocated to find
the in-use spans. Since we now have a list of in-use spans, change it
to iterate over that instead.

This, combined with the previous change, fixes #9265. Before these two
changes, blowing up the heap to 8GB and then shrinking it to a 0MB
live set caused the small-heap portion of the test to run 60x slower
than without the initial blowup. With these two changes, the time is
indistinguishable.

No significant effect on other benchmarks.

Change-Id: I4a27e533efecfb5d18cba3a87c0181a81d0ddc1e
Reviewed-on: https://go-review.googlesource.com/30536
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-10-25 22:32:59 +00:00
Austin Clements
f9497a6747 runtime: make sweep time proportional to in-use spans
Currently sweeping walks the list of all spans, which means the work
in sweeping is proportional to the maximum number of spans ever used.
If the heap was once large but is now small, this causes an
amortization failure: on a small heap, GCs happen frequently, but a
full sweep still has to happen in each GC cycle, which means we spent
a lot of time in sweeping.

Fix this by creating a separate list consisting of just the in-use
spans to be swept, so sweeping is proportional to the number of in-use
spans (which is proportional to the live heap). Specifically, we
create two lists: a list of unswept in-use spans and a list of swept
in-use spans. At the start of the sweep cycle, the swept list becomes
the unswept list and the new swept list is empty. Allocating a new
in-use span adds it to the swept list. Sweeping moves spans from the
unswept list to the swept list.

This fixes the amortization problem because a shrinking heap moves
spans off the unswept list without adding them to the swept list,
reducing the time required by the next sweep cycle.

Updates #9265. This fix eliminates almost all of the time spent in
sweepone; however, markrootSpans has essentially the same bug, so now
the test program from this issue spends all of its time in
markrootSpans.

No significant effect on other benchmarks.

Change-Id: Ib382e82790aad907da1c127e62b3ab45d7a4ac1e
Reviewed-on: https://go-review.googlesource.com/30535
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-10-25 22:32:57 +00:00
Austin Clements
45baff61e3 runtime: expand comment on work.spans
Change-Id: I4b8a6f5d9bc5aba16026d17f99f3512dacde8d2d
Reviewed-on: https://go-review.googlesource.com/30534
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-10-25 22:32:54 +00:00
Austin Clements
5915ce6674 runtime: use len(h.spans) to indicate mapped region
Currently we set the len and cap of h.spans to the full reserved
region of the address space and track the actual mapped region
separately in h.spans_mapped. Since we have both the len and cap at
our disposal, change things so len(h.spans) tracks how much of the
spans array is mapped and eliminate h.spans_mapped. This simplifies
mheap and means we'll get nice "index out of bounds" exceptions if we
do try to go off the end of the spans rather than a SIGSEGV.

Change-Id: I8ed9a1a9a844d90e9fd2e269add4704623dbdfe6
Reviewed-on: https://go-review.googlesource.com/30533
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-10-25 22:32:51 +00:00
Austin Clements
6b0f668044 runtime: consolidate h_spans and mheap_.spans
Like h_allspans and mheap_.allspans, these were two ways of referring
to the spans array from when the runtime was split between C and Go.
Clean this up by making mheap_.spans a slice and eliminating h_spans.

Change-Id: I3aa7038d53c3a4252050aa33e468c48dfed0b70e
Reviewed-on: https://go-review.googlesource.com/30532
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-10-25 22:32:48 +00:00
Austin Clements
66e849b168 runtime: eliminate mheap.nspan and use range loops
This was necessary in the C days when allspans was an mspan**, but now
that allspans is a Go slice, this is redundant with len(allspans) and
we can use range loops over allspans.

Change-Id: Ie1dc39611e574e29a896e01690582933f4c5be7e
Reviewed-on: https://go-review.googlesource.com/30531
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-10-25 22:32:45 +00:00
Austin Clements
4d6207790b runtime: consolidate h_allspans and mheap_.allspans
These are two ways to refer to the allspans array that hark back to
when the runtime was split between C and Go. Clean this up by making
mheap_.allspans a slice and eliminating h_allspans.

Change-Id: Ic9360d040cf3eb590b5dfbab0b82e8ace8525610
Reviewed-on: https://go-review.googlesource.com/30530
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-10-25 22:32:42 +00:00
Matthew Dempsky
adda7ad295 cmd/compile/internal/gc: enable new parser by default
Change-Id: I3c784986755cfbbe1b8eb8da4d64227bd109a3b0
Reviewed-on: https://go-review.googlesource.com/27203
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-10-25 22:28:40 +00:00
David du Colombier
263a825b05 syscall: use name+(NN)FP on plan9/amd64
Generated from go vet.

Change-Id: Ie775c29b505166e0bd511826ef20eeb153a0424c
Reviewed-on: https://go-review.googlesource.com/32071
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-25 22:13:35 +00:00
David du Colombier
71f72e9d4f syscall: use name+(NN)FP on plan9/386
Generated from go vet.

Change-Id: I2620e5544be46485a876c7dce26b0592bf5a4101
Reviewed-on: https://go-review.googlesource.com/32070
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-25 22:13:29 +00:00
Cherry Zhang
f6aec889e1 cmd/compile: add a writebarrier phase in SSA
When the compiler insert write barriers, the frontend makes
conservative decisions at an early stage. This may have false
positives which result in write barriers for stack writes.

A new phase, writebarrier, is added to the SSA backend, to delay
the decision and eliminate false positives. The frontend still
makes conservative decisions. When building SSA, instead of
emitting runtime calls directly, it emits WB ops (StoreWB,
MoveWB, etc.), which will be expanded to branches and runtime
calls in writebarrier phase. Writes to static locations on stack
are detected and write barriers are removed.

All write barriers of stack writes found by the script from
issue #17330 are eliminated (except two false positives).

Fixes #17330.

Change-Id: I9bd66333da9d0ceb64dcaa3c6f33502798d1a0f8
Reviewed-on: https://go-review.googlesource.com/31131
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2016-10-25 21:53:40 +00:00