1
0
mirror of https://github.com/golang/go synced 2024-09-30 15:28:33 -06:00
Commit Graph

29939 Commits

Author SHA1 Message Date
Adam Langley
35e5fd0c4d crypto/tls: enable ChaCha20-Poly1305 cipher suites by default.
This change enables the ChaCha20-Poly1305 cipher suites by default. This
changes the default ClientHello and thus requires updating all the
tests.

Change-Id: I6683a2647caaff4a11f9e932babb6f07912cad94
Reviewed-on: https://go-review.googlesource.com/30958
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-18 06:54:30 +00:00
Adam Langley
cff3e7587a crypto/tls: add Config.GetConfigForClient
GetConfigForClient allows the tls.Config to be updated on a per-client
basis.

Fixes #16066.
Fixes #15707.
Fixes #15699.

Change-Id: I2c675a443d557f969441226729f98502b38901ea
Reviewed-on: https://go-review.googlesource.com/30790
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-18 06:44:05 +00:00
Russ Cox
7e2bf952a9 net/url: add PathEscape, PathUnescape
Fixes #13737.

Change-Id: Ib655dbf06f44709f687f8a2410c80f31e4075f13
Reviewed-on: https://go-review.googlesource.com/31322
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-18 06:34:58 +00:00
Russ Cox
59dae58174 net/url: document and add example for ParseQuery("x")
Fixes #16460.

Change-Id: Ie9d5f725d2d7e8210ab6f7604a5a05fc49f707de
Reviewed-on: https://go-review.googlesource.com/31331
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-18 06:19:46 +00:00
Rob Pike
ac1108bdcb fmt: fix documention for %#v on uints
It's the same as %#x not %x.

Just a documentation change; tests already cover it.

Fixes #17322

Change-Id: Ia9db229f781f9042ac5c0bb824e3d7a26fb74ec5
Reviewed-on: https://go-review.googlesource.com/31254
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-18 06:14:31 +00:00
Alberto Donizetti
f6cdfc7987 math/big: add benchmarks for big.Float String
In addition to the DecimalConversion benchmark, that exercises the
String method of the internal decimal type on a range of small shifts,
add a few benchmarks for the big.Float String method. They can be used
to obtain more realistic data on the real-world performance of
big.Float printing.

Change-Id: I7ada324e7603cb1ce7492ccaf3382db0096223ba
Reviewed-on: https://go-review.googlesource.com/31275
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-18 05:54:35 +00:00
Russ Cox
57666c3fe8 test: avoid matching file names in errcheck
Fixes #17030.

Change-Id: Ic7f237ac7553ae0176929056e64b01667ed59066
Reviewed-on: https://go-review.googlesource.com/31351
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-18 05:32:37 +00:00
David Symonds
5a0d50f4eb cmd/vet: fix formatting of headings in doc.go.
This will cause godoc to correctly render these docs,
since go/doc.ToHTML requires no punctuation for headings.

Change-Id: Ic95245147d3585f2ccc59d4424fcab17d2a5617b
Reviewed-on: https://go-review.googlesource.com/31319
Reviewed-by: Rob Pike <r@golang.org>
2016-10-18 00:06:20 +00:00
Hiroshi Ioka
4a5b3ef9b9 encoding/asn1: return error instead of dereferencing nil *big.Int in marshaling
Fixes #17461

Change-Id: I9954f6ae46c7e15560d7460841be8f2bc37233a9
Reviewed-on: https://go-review.googlesource.com/31121
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-17 22:29:32 +00:00
Matthew Dempsky
99b7984de7 cmd/link: remove some unnecessary comments
The comments about pcln functions are obsolete since those functions
now live in cmd/internal/obj. The copyright header is redundant with
the existing one at the top of the file.

Change-Id: I568fd3d259253a0d8eb3b0a157d008df1b5de106
Reviewed-on: https://go-review.googlesource.com/31315
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-17 22:00:55 +00:00
Cherry Zhang
c7e855658d cmd/link: trampoline support for external linking on ARM
all.bash passes with -debugtramp=2 (except the unavoidable
disassembly test as we change instructions). And successfully
build k8s.io/kubernetes/cmd/hyperkube in both internal linking
and external linking mode.

Fixes #17028.

Change-Id: Ic8fac6a394488155c5eba9215662db1c1086e24b
Reviewed-on: https://go-review.googlesource.com/31143
Reviewed-by: David Chase <drchase@google.com>
2016-10-17 21:38:06 +00:00
Adam Langley
007c907b80 crypto/tls: only store a single nonce for AES-GCM.
Although an AEAD, in general, can be used concurrently in both the seal
and open directions, TLS is easier. Since the transport keys are
different for different directions in TLS, an AEAD will only ever be
used in one direction. Thus we don't need separate buffers for seal and
open because they can never happen concurrently.

Also, fix the nonce size to twelve bytes since the fixed-prefix
construction for AEADs is superseded and will never be used for anything
else now.

Change-Id: Ibbf6c6b1da0e639f4ee0e3604410945dc7dcbb46
Reviewed-on: https://go-review.googlesource.com/30959
Run-TryBot: Adam Langley <agl@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-17 21:35:30 +00:00
Adam Langley
d1bfa3c68d Revert "crypto/tls: add CloseWrite method to Conn"
This reverts commit c6185aa632. That
commit seems to be causing flaky failures on the builders. See
discussion on the original thread: https://golang.org/cl/25159.

Change-Id: I26e72d962d4efdcee28a0bc61a53f246b046df77
Reviewed-on: https://go-review.googlesource.com/31316
Run-TryBot: Adam Langley <agl@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-10-17 21:33:09 +00:00
Adam Langley
67d8226b48 crypto/tls: support ChaCha20-Poly1305.
This change adds support for the ChaCha20-Poly1305 AEAD to crypto/tls,
as specified in https://tools.ietf.org/html/rfc7905.

Fixes #15499.

Change-Id: Iaa689be90e03f208c40b574eca399e56f3c7ecf1
Reviewed-on: https://go-review.googlesource.com/30957
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-17 21:05:26 +00:00
Adam Langley
e7edc7e27e vendor: update golang.org/x/crypto/chacha20poly1305
This change updates the vendored chacha20poly1305 package to match
revision 14f9af67c679edd414f72f13d67c917447113df2 of x/crypto.

Change-Id: I05a4ba86578b0f0cdb1ed7dd50fee3b38bb48cf5
Reviewed-on: https://go-review.googlesource.com/31312
Run-TryBot: Adam Langley <agl@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-17 21:05:08 +00:00
Chris Broadfoot
bb4c40b21a doc: document go1.7.2
Change-Id: I34b3650ee9512879ff7528336813a7850c46ea90
Reviewed-on: https://go-review.googlesource.com/31311
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-17 20:40:22 +00:00
Matthew Dempsky
7dd9c385f6 Revert "cmd/compile: inline convI2E"
This reverts commit 395d36a67d.

Appears to be responsible for builder failures.

Change-Id: Ic6c6307f662767e529060b88704a9f074785d99e
Reviewed-on: https://go-review.googlesource.com/31310
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2016-10-17 20:37:19 +00:00
Russ Cox
9ee21f90d2 math/big: add (*Int).Sqrt
This is needed for some of the more complex primality tests
(to filter out exact squares), and while the code is simple the
boundary conditions are not obvious, so it seems worth having
in the library.

Change-Id: Ica994a6b6c1e412a6f6d9c3cf823f9b653c6bcbd
Reviewed-on: https://go-review.googlesource.com/30706
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-10-17 20:30:19 +00:00
Lynn Boger
2190f771d8 bytes: fix typo in ppc64le asm for Compare
Correcting a line in asm_ppc64x.s in the cmpbodyLE function
that originally was R14 but accidentally changed to R4.

Fixes #17488

Change-Id: Id4ca6fb2e0cd81251557a0627e17b5e734c39e01
Reviewed-on: https://go-review.googlesource.com/31266
Reviewed-by: Michael Munday <munday@ca.ibm.com>
Run-TryBot: Michael Munday <munday@ca.ibm.com>
2016-10-17 20:01:17 +00:00
Michael Munday
1cfb5c3fd5 cmd/compile: merge loads into operations on s390x
Adds the new canMergeLoad function which can be used by rules to
decide whether a load can be merged into an operation. The function
ensures that the merge will not reorder the load relative to memory
operations (for example, stores) in such a way that the block can no
longer be scheduled.

This new function enables transformations such as:

MOVD 0(R1), R2
ADD  R2, R3

to:

ADD  0(R1), R3

The two-operand form of the following instructions can now read a
single memory operand:

 - ADD
 - ADDC
 - ADDW
 - MULLD
 - MULLW
 - SUB
 - SUBC
 - SUBE
 - SUBW
 - AND
 - ANDW
 - OR
 - ORW
 - XOR
 - XORW

Improves SHA3 performance by 6-8%.

Updates #15054.

Change-Id: Ibcb9122126cd1a26f2c01c0dfdbb42fe5e7b5b94
Reviewed-on: https://go-review.googlesource.com/29272
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-10-17 19:45:20 +00:00
Robert Griesemer
92221fe8bc math/big: slightly faster float->decimal conversion
Inspired by Alberto Donizetti's observations in
https://go-review.googlesource.com/#/c/30099/.

name                 old time/op  new time/op  delta
DecimalConversion-8   138µs ± 1%   136µs ± 2%  -1.85%  (p=0.000 n=10+10)

10 runs each, measured on a Mac Mini, 2.3 GHz Intel Core i7.

Performance improvements varied between -1.25% to -4.4%; -1.85% is
about in the middle of the observed improvement. The generated code
is slightly shorter in the inner loops of the conversion code.

Change-Id: I10fb3b2843da527691c39ad5e5e5bd37ed63e2fa
Reviewed-on: https://go-review.googlesource.com/31250
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-10-17 19:33:33 +00:00
Austin Clements
984753b665 runtime: fix GC assist retry path
GC assists retry if preempted or if they fail to park. However, on the
retry path they currently use stale statistics. In particular, the
retry can use "debtBytes", but debtBytes isn't updated when the debt
changes (since other than retries it is only used once). Also, though
less of a problem, the if the assist ratio has changed while the
assist was blocked, the retry will still use the old assist ratio.

Fix all of this by simply making the retry jump back to where we
compute these statistics, rather than just after.

Change-Id: I2ed8b4f0fc9f008ff060aa926f4334b662ac7d3f
Reviewed-on: https://go-review.googlesource.com/30701
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-10-17 19:09:37 +00:00
Austin Clements
81c431a537 runtime: abstract out assist queue management
This puts all of the assist queue-related code together and makes it
easier to modify how the assist queue works.

Change-Id: Id54e06702bdd5a5dd3fef2ce2c14cd7ca215303c
Reviewed-on: https://go-review.googlesource.com/30700
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-10-17 19:09:30 +00:00
Keith Randall
395d36a67d cmd/compile: inline convI2E
It's pretty simple.  For:
  e = (interface{})(i)
Do:
  tmp = i.itab
  if tmp != nil {
    tmp = tmp.typ_ // load type from itab
  }
  e = eface{tmp, i.data}

It is smaller and faster than calling the runtime.

Change-Id: I0ad27f62f4ec0b6cd53bc8530e4da0eae3e67a6c
Reviewed-on: https://go-review.googlesource.com/31260
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-10-17 19:09:07 +00:00
Austin Clements
d5bd797ee5 runtime: fix getArgInfo for deferred reflection calls
getArgInfo for reflect.makeFuncStub and reflect.methodValueCall is
necessarily special. These have dynamically determined argument maps
that are stored in their context (that is, their *funcval). These
functions are written to store this context at 0(SP) when called, and
getArgInfo retrieves it from there.

This technique works if getArgInfo is passed an active call frame for
one of these functions. However, getArgInfo is also used in
tracebackdefers, where the "call" is not a true call with an active
stack frame, but a deferred call. In this situation, getArgInfo
currently crashes because tracebackdefers passes a frame with sp set
to 0. However, the entire approach used by getArgInfo is flawed in
this situation because the wrapper has not actually executed, and
hence hasn't saved this metadata to any stack frame.

In the defer case, we know the *funcval from the _defer itself, so we
can fix this by teaching getArgInfo to use the *funcval context
directly when its available, and otherwise get it from the active call
frame.

While we're here, this commit simplifies getArgInfo a bit by making it
play more nicely with the type system. Rather than decoding the
*reflect.methodValue that is the wrapper's context as a *[2]uintptr,
just write out a copy of the reflect.methodValue type in the runtime.

Fixes #16331. Fixes #17471.

Change-Id: I81db4d985179b4a81c68c490cceeccbfc675456a
Reviewed-on: https://go-review.googlesource.com/31138
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-10-17 18:57:01 +00:00
Austin Clements
687d9d5d78 runtime: print a message on bad morestack
If morestack runs on the g0 or gsignal stack, it currently performs
some abort operation that typically produces a signal (e.g., it does
an INT $3 on x86). This is useful if you're running in a debugger, but
if you're not, the runtime tries to trap this signal, which is likely
to send the program into a deeper spiral of collapse and lead to very
confusing diagnostic output.

Help out people trying to debug without a debugger by making morestack
print an informative message before blowing up.

Change-Id: I2814c64509b137bfe20a00091d8551d18c2c4749
Reviewed-on: https://go-review.googlesource.com/31133
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-17 18:56:09 +00:00
Russ Cox
0ba3c607df cmd/dist, go/build: make CGO_ENABLED during make.bash sticky
Per discussion on #12808, it's a bit odd that if you do

	CGO_ENABLED=0 ./make.bash

then you get a toolchain that still tries to use cgo.
So make the CGO_ENABLED setting propagate into
the resulting toolchain as the default setting for that
environment variable, like we do with other variables
like CC and GOROOT.

No reasonable way to test automatically, but I did
test by hand that after the above command, 'go env'
shows CGO_ENABLED=0; before it showed CGO_ENABLED=1.

Fixes #12808.

Change-Id: I26a2fa6cc00e73bde8af7469270b27293392ed71
Reviewed-on: https://go-review.googlesource.com/31141
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-17 18:53:22 +00:00
Lynn Boger
1e28dce80a bytes: improve performance for bytes.Compare on ppc64x
This improves the performance for byte.Compare by rewriting
the cmpbody function in runtime/asm_ppc64x.s.  The previous code
had a simple loop which loaded a pair of bytes and compared them,
which is inefficient for long buffers.  The updated function checks
for 8 or 32 byte chunks and then loads and compares double words where
possible.

Because the byte.Compare result indicates greater or less than,
the doubleword loads must take endianness into account, using a
byte reversed load in the little endian case.

Fixes #17433

benchmark                                   old ns/op     new ns/op     delta
BenchmarkBytesCompare/8-16                  13.6          7.16          -47.35%
BenchmarkBytesCompare/16-16                 25.7          7.83          -69.53%
BenchmarkBytesCompare/32-16                 38.1          7.78          -79.58%
BenchmarkBytesCompare/64-16                 63.0          10.6          -83.17%
BenchmarkBytesCompare/128-16                112           13.0          -88.39%
BenchmarkBytesCompare/256-16                211           28.1          -86.68%
BenchmarkBytesCompare/512-16                410           38.6          -90.59%
BenchmarkBytesCompare/1024-16               807           60.2          -92.54%
BenchmarkBytesCompare/2048-16               1601          103           -93.57%

Change-Id: I121acc74fcd27c430797647b8d682eb0607c63eb
Reviewed-on: https://go-review.googlesource.com/30949
Reviewed-by: David Chase <drchase@google.com>
2016-10-17 18:46:20 +00:00
Quentin Smith
7c46f03498 strconv: strip \r in raw strings passed to Unquote
To match the language spec, strconv.Unquote needs to strip carriage
returns from the raw string.

Also fixes TestUnquote to not be a noop.

Fixes #15997

Change-Id: I2456f50f2ad3830f37e545f4f6774ced9fe609d7
Reviewed-on: https://go-review.googlesource.com/31210
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-10-17 18:34:02 +00:00
Michael Munday
6f4a6faf86 cmd/dist: disable math/big assembly when using the bootstrap compiler
The assembly in math/big may contain instructions that the bootstrap
compiler does not support. Disable it using the math_big_pure_go
build tag.

Fixes #17484.

Change-Id: I766cab6a888721ab4ed76ebdbfc87ad4e919ec41
Reviewed-on: https://go-review.googlesource.com/31142
Run-TryBot: Michael Munday <munday@ca.ibm.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-17 18:26:20 +00:00
Alberto Donizetti
cbf28ff87c strconv: make FormatFloat slowpath a little faster
The relevant benchmark (on an Intel i7-4510U machine):

name                      old time/op  new time/op  delta
FormatFloat/Slowpath64-4  68.6µs ± 0%  44.1µs ± 2%  -35.71%  (p=0.000 n=13+15)

Change-Id: I67eb0e81ce74ed57752d0280059f91419f09e93b
Reviewed-on: https://go-review.googlesource.com/30099
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-10-17 18:23:32 +00:00
Adam Langley
77b6a08e0d vendor: add golang.org/x/crypto/{chacha20poly1305,poly1305}
This change imports the chacha20poly1305 and poly1305 packages from
x/crypto at 5f4e837b98443e9e7a65072235205993af565d85. These packages
will be used to support the ChaCha20-Poly1305 AEAD in crypto/tls.

Change-Id: I1a38d671ef9aeff3bc41e3924655883d465a5617
Reviewed-on: https://go-review.googlesource.com/30956
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-17 18:11:24 +00:00
Russ Cox
9a97c3bfe4 cmd/go: accept plain file for .vcs (instead of directory)
Sometimes .git is a plain file; maybe others will follow.
This CL matches CL 21430, made in x/tools/go/vcs.

The change in the Swift test case makes the test case
pass by changing the test to match current behavior,
which I assume is better than the reverse.
(The test only runs locally and without -short, so the
builders are not seeing this particular failure.)

For #10322.

Change-Id: Iccd08819a01c5609a2880b9d8a99af936e20faff
Reviewed-on: https://go-review.googlesource.com/30948
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-17 17:05:39 +00:00
Lynn Boger
d26b0661c2 cmd/link: add trampolines for too far calls in ppc64x
This change adds support for trampolines on ppc64x when using
internal linking, in the case where the offset to the branch
target is larger than what fits in the field provided by the
branch instruction.

Fixes #16665

Change-Id: Icfee72910f38c94588d2adce517b64dee6176145
Reviewed-on: https://go-review.googlesource.com/30850
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-10-17 16:06:04 +00:00
Brad Fitzpatrick
0ce1d79a6a database/sql: accept nil pointers to Valuers implemented on value receivers
The driver.Valuer interface lets types map their Go representation to
a suitable database/sql/driver.Value.

If a user defines the Value method with a value receiver, such as:

    type MyStr string

    func (s MyStr) Value() (driver.Value, error) {
        return strings.ToUpper(string(s)), nil
    }

Then they can't use (*MyStr)(nil) as an argument to an SQL call via
database/sql, because *MyStr also implements driver.Value, but via a
compiler-generated wrapper which checks whether the pointer is nil and
panics if so.

We now accept (*MyStr)(nil) and map it to "nil" (an SQL "NULL")
if the Valuer method is implemented on MyStr instead of *MyStr.

If a user implements the driver.Value interface with a pointer
receiver, they retain full control of what nil means:

    type MyStr string

    func (s *MyStr) Value() (driver.Value, error) {
        if s == nil {
            return "missing MyStr", nil
        }
        return strings.ToUpper(string(*s)), nil
    }

Adds tests for both cases.

Fixes #8415

Change-Id: I897d609d80d46e2354d2669a8a3e090688eee3ad
Reviewed-on: https://go-review.googlesource.com/31259
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-17 15:26:25 +00:00
Russ Cox
237d7e34bc cmd/dist: use debug/pe directly for cmd/link
Delete vendored copy.

Change-Id: I06e9d3b709553a1a8d06275e99bd8f617aac5788
Reviewed-on: https://go-review.googlesource.com/31011
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-17 15:22:17 +00:00
Russ Cox
15040c11b9 cmd/dist: copy needed packages from standard library during bootstrap
This allows use of newer math/big (and later debug/pe)
without maintaining a vendored copy somewhere in cmd.

Use for math/big, deleting cmd/compile/internal/big.

Change-Id: I2bffa7a9ef115015be29fafdb02acc3e7a665d11
Reviewed-on: https://go-review.googlesource.com/31010
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-17 15:22:11 +00:00
Russ Cox
f444b48fe4 encoding/json: fix decoding of null into Unmarshaler, TextUnmarshaler
1. Define behavior for Unmarshal of JSON null into Unmarshaler and
TextUnmarshaler. Specifically, an Unmarshaler will be given the
literal null and can decide what to do (because otherwise
json.RawMessage is impossible to implement), and a TextUnmarshaler
will be skipped over (because there is no text to unmarshal), like
most other inappropriate types. Document this in Unmarshal, with a
reminder in UnmarshalJSON about handling null.

2. Test all this.

3. Fix the TextUnmarshaler case, which was returning an unmarshalling
error, to match the definition.

4. Fix the error that had been used for the TextUnmarshaler, since it
was claiming that there was a JSON string when in fact the problem was
NOT having a string.

5. Adjust time.Time and big.Int's UnmarshalJSON to ignore null, as is
conventional.

Fixes #9037.

Change-Id: If78350414eb8dda712867dc8f4ca35a9db041b0c
Reviewed-on: https://go-review.googlesource.com/30944
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-17 15:21:33 +00:00
Ben Burkert
c6185aa632 crypto/tls: add CloseWrite method to Conn
The CloseWrite method sends a close_notify alert record to the other
side of the connection. This record indicates that the sender has
finished sending on the connection. Unlike the Close method, the sender
may still read from the connection until it recieves a close_notify
record (or the underlying connection is closed). This is analogous to a
TCP half-close.

Updates #8579

Change-Id: I9c6bc193efcb25cc187f7735ee07170afa7fdde3
Reviewed-on: https://go-review.googlesource.com/25159
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-17 14:26:55 +00:00
Victor Vrantchan
b97b7537bc encoding/pem: add Decode example
For #16360.

Change-Id: I99d1e5ab1f814f65b3066a498158a442f1bd477f
Reviewed-on: https://go-review.googlesource.com/31137
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-17 14:02:33 +00:00
Martin Möhrmann
d295174030 runtime: speed up non-ASCII rune decoding
Copies utf8 constants and EncodeRune implementation from unicode/utf8.

Adds a new decoderune implementation that is used by the compiler
in code generated for ranging over strings. It does not handle
ASCII runes since these are handled directly before calls to decoderune.

The DecodeRuneInString implementation from unicode/utf8 is not used
since it uses a lookup table that would increase the use of cpu caches.

Adds more tests that check decoding of valid and invalid utf8 sequences.

name                              old time/op  new time/op  delta
RuneIterate/range2/ASCII-4        7.45ns ± 2%  7.45ns ± 1%     ~     (p=0.634 n=16+16)
RuneIterate/range2/Japanese-4     53.5ns ± 1%  49.2ns ± 2%   -8.03%  (p=0.000 n=20+20)
RuneIterate/range2/MixedLength-4  46.3ns ± 1%  41.0ns ± 2%  -11.57%  (p=0.000 n=20+20)

new:
"".decoderune t=1 size=423 args=0x28 locals=0x0
old:
"".charntorune t=1 size=666 args=0x28 locals=0x0

Change-Id: I1df1fdb385bb9ea5e5e71b8818ea2bf5ce62de52
Reviewed-on: https://go-review.googlesource.com/28490
Run-TryBot: Martin Möhrmann <martisch@uos.de>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-17 11:25:22 +00:00
Emmanuel Odeke
fe4307f060 net/http: support multiple identical Content-Length headers
Referencing RFC 7230 Section 3.3.2, this CL
deduplicates multiple identical Content-Length headers
of a message or rejects the message as invalid if the
Content-Length values differ.

Fixes #16490

Change-Id: Ia6b0f58ec7d35710b11a36113d2bd9128f693f64
Reviewed-on: https://go-review.googlesource.com/31252
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-17 09:02:42 +00:00
David du Colombier
516001f50f net: skip TestReadTimeoutUnblocksRead on Plan 9
Deadlines aren't implemented on Plan 9 yet.

Updates #17477.

Change-Id: I44ffdbef97276dfec56547e5189672b7da24bfc1
Reviewed-on: https://go-review.googlesource.com/31188
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David du Colombier <0intro@gmail.com>
2016-10-17 09:02:28 +00:00
Klaus Post
c1cd64d0ac compress/flate: use correct table for size estimation
The incorrect table was used for estimating output size.
This can give suboptimal selection of entropy encoder in rare cases.

Change-Id: I8b358200f2d1f9a3f9b79a44269d7be704e1d2d9
Reviewed-on: https://go-review.googlesource.com/31172
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-17 09:00:41 +00:00
Yasuhiro Matsumoto
05471e9ee6 crypto/x509: implement SystemCertPool on Windows
Fixes #16736

Change-Id: I335d201e3f6738d838de3881087cb640fc7670e8
Reviewed-on: https://go-review.googlesource.com/30578
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-17 08:29:16 +00:00
Daniel Theophanes
707a83341b database/sql: add option to use named parameter in query arguments
Modify the new Context methods to take a name-value driver struct.
This will require more modifications to drivers to use, but will
reduce the overall number of structures that need to be maintained
over time.

Fixes #12381

Change-Id: I30747533ce418a1be5991a0c8767a26e8451adbd
Reviewed-on: https://go-review.googlesource.com/30166
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-17 07:56:35 +00:00
Martin Möhrmann
99df54f196 bytes: encode size of rune read by ReadRune into lastRead to speed up UnreadRune
In ReadRune store the size of the rune that was read into lastRead
to avoid the need to call DecodeRuneLast in UnreadRune.

fmt:
name        old time/op  new time/op  delta
ScanInts-4   481µs ± 4%   458µs ± 3%  -4.64%  (p=0.000 n=20+20)

Change-Id: I500848e663a975f426402a4b3d27a541e5cac06c
Reviewed-on: https://go-review.googlesource.com/28817
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Run-TryBot: Martin Möhrmann <martisch@uos.de>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-17 06:00:35 +00:00
Brad Fitzpatrick
1e775fe4a3 net/http: add more docs on ErrHijacked
Updates #16456

Change-Id: Ifea651ea3ece2267a6f0c1638181d6ddd9248a9f
Reviewed-on: https://go-review.googlesource.com/31181
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-17 05:56:43 +00:00
Brad Fitzpatrick
7a7ea01c65 syscall, net: make deadline changes affect blocked read/write calls on nacl
Flesh out nacl's fake network system to match how all the other
platforms work: all other systems' SetReadDeadline and
SetWriteDeadline affect currently-blocked read & write calls.
This was documented in golang.org/cl/30164 because it was the status
quo and existing packages relied on it. (notably the net/http package)

And add a test.

Change-Id: I074a1054dcabcedc97b173dad5e827f8babf7cfc
Reviewed-on: https://go-review.googlesource.com/31178
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-17 05:53:00 +00:00
Caleb Spare
cd2c9df761 html/template: fix Clone so that t.Lookup(t.Name()) yields t
Template.escape makes the assumption that t.Lookup(t.Name()) is t
(escapeTemplate looks up the associated template by name and sets
escapeErr appropriately).

This assumption did not hold for a Cloned template, because the template
associated with t.Name() was a second copy of the original.

Add a test for the assumption that t.Lookup(t.Name()) == t.

One effect of this broken assumption was #16101: parallel Executes
racily accessed the template namespace because each Execute call saw
t.escapeErr == nil and re-escaped the template concurrently with read
accesses occurring outside the namespace mutex.

Add a test for this race.

Related to #12996 and CL 16104.

Fixes #16101

Change-Id: I59831d0847abbabb4ef9135f2912c6ce982f9837
Reviewed-on: https://go-review.googlesource.com/31092
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-10-17 00:35:20 +00:00