Commit graph

29844 commits

Author SHA1 Message Date
Brad Fitzpatrick 214bf68097 net/http: remove TODO about the Server's base context
I decided not to expand the API for this per discusion on #16220.

Fixes #16220

Change-Id: I65cb2eacd4ec28c79438a8f7c30024524a484ce6
Reviewed-on: https://go-review.googlesource.com/30082
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-30 03:57:24 +00:00
Matthew Dempsky dd748cf314 cmd/compile: make Afunclit the default/only behavior for Naddr
Naddr used to translate PFUNC Nodes into references to the function
literal wrapper, and then Afunclit could be used to rewrite it to
reference the function text itself. But now everywhere we use Naddr on
PFUNC Nodes, we immediately call Afunclit anyway. So just merge
Afunclit's behavior into Naddr.

Passes toolstash/buildall.

Change-Id: If2ca6d7f314c1a0711df9b8209aace16ba4b8bc0
Reviewed-on: https://go-review.googlesource.com/30073
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-09-29 23:13:18 +00:00
Daniel Theophanes d2df8498f3 database/sql: close Rows when context is cancelled
To prevent leaking connections, close any open Rows when the
context is cancelled. Also enforce context cancel while reading
rows off of the wire.

Change-Id: I62237ecdb7d250d6734f6ce3d2b0bcb16dc6fda7
Reviewed-on: https://go-review.googlesource.com/29957
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-29 22:26:42 +00:00
Matthew Dempsky 6dc356a76a cmd/compile/internal/ssa: erase register copies deterministically
Fixes #17288.

Change-Id: I2ddd01d14667d5c6a2e19bd70489da8d9869d308
Reviewed-on: https://go-review.googlesource.com/30072
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-09-29 22:22:36 +00:00
Brad Fitzpatrick c1e06dcb61 net/http: use atomic.Value for Transport's alternate protocol map
Fix an old TODO and use atomic.Value for holding the Transport's
alternate protocol map. It is very frequently accessed and almost
never set or updated.

Change-Id: Ic5a71c504bdac76678114c6390d1fc0673e07aa9
Reviewed-on: https://go-review.googlesource.com/29967
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-29 20:43:04 +00:00
Brad Fitzpatrick 8e69d43b32 net: add Buffers type, do writev on unix
No fast path currently for solaris, windows, nacl, plan9.

Fixes #13451

Change-Id: I24b3233a2e3a57fc6445e276a5c0d7b097884007
Reviewed-on: https://go-review.googlesource.com/29951
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-09-29 20:33:45 +00:00
Nodir Turakulov ffd1c781b7 html/template: check "type" attribute in <script>
Currently any script tag is treated as a javascript container, although
<script type="text/template"> must not be. Check "type" attribute of
"script" tag. If it is present and it is not a JS MIME type, do not
transition to elementScript state.

Fixes #12149, where // inside text template was treated as regexp.
Fixes #6701

Change-Id: I8fc9e504f7280bdd800f40383c061853665ac8a2
Reviewed-on: https://go-review.googlesource.com/14336
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-09-29 20:12:31 +00:00
Matthew Dempsky f5516559e6 cmd/compile/internal/x86: fix zero-range merging logic
All other architectures merge stack-zeroing ranges if there are at
most two pointers/registers of memory between them, but x86 is
erroneously coded to require *exactly* two.

Shaves a tiny amount of text size off cmd/go when building for
GOARCH=386 and eliminates an unnecessary inconsistency between x86's
defframe and the other GOARCHes'.

   text	   data	    bss	    dec	    hex	filename
5241015	 191051	  93336	5525402	 544f9a	go.before
5240224	 191051	  93336	5524611	 544c83	go.after

Change-Id: Ib15ec8c07bca11e824640f0ab32abfc4bb160496
Reviewed-on: https://go-review.googlesource.com/30050
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-09-29 18:54:16 +00:00
Alberto Donizetti 2b49d129c4 cmd/compile: delete unused (*Node) SetInt, SetBigInt, Bool
Introduced in CL 9263 (prepare to unexport gc.Mp*) and CL 9267
(prepare Node.Val to be unexported), their only callers were in
the old backend and all got deleted in CL 29168 (cmd/compile:
delete lots of the legacy backend).

Update #16357

Change-Id: I0a5d76b98b418e8ec0984c033c3bc0ac3fc5f38a
Reviewed-on: https://go-review.googlesource.com/29997
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-29 18:52:14 +00:00
Joe Tsai 6fea452e38 archive/tar: move parse/format functionality into strconv.go
Move all parse/format related functionality into strconv.go
and thoroughly test them. This also reduces the amount of noise
inside reader.go and writer.go.

There was zero functionality change other than moving code around.

Change-Id: I3bc288d10c20ebb3814b30b75d8acd7be62b85d7
Reviewed-on: https://go-review.googlesource.com/28470
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-29 18:38:28 +00:00
Joe Tsai a09e1de0ea net/http: document how Request.Cookie deals with duplicate cookies
RFC 6265, section 4.2.2 says:
<<<
Although cookies are serialized linearly in the Cookie header,
servers SHOULD NOT rely upon the serialization order.  In particular,
if the Cookie header contains two cookies with the same name (e.g.,
that were set with different Path or Domain attributes), servers
SHOULD NOT rely upon the order in which these cookies appear in the
header.
>>>

This statement seems to indicate that cookies should conceptually
be thought of as a map of keys to sets of values (map[key][]value).
However, in practice, everyone pretty much treats cookies as a
map[key]value and the API for Request.Cookie seems to indicate that.

We should update the documentation for Request.Cookie to warn the
user what happens when there is are multiple cookies with the same
key. I deliberately did not want to say *which* cookie is returned.

Change-Id: Id3e0e24b2b14ca2d9ea8b13f82ba739edaa71cf0
Reviewed-on: https://go-review.googlesource.com/29364
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-29 18:26:32 +00:00
Matthew Dempsky 518cc7f307 cmd/internal/obj/arm: cleanup some unnecessary temps and conversions
Change-Id: I573278c9aee80e62463b2542774dabeec7c3b098
Reviewed-on: https://go-review.googlesource.com/29969
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-09-29 18:14:05 +00:00
Brad Fitzpatrick 985d3d307c net: make proto and port lookups fall back to baked-in maps on Windows
In https://golang.org/cl/28951 I cleaned up the lookupProtocol and
lookupPort paths to be consistently case-insensitive across operating
systems and to share the same baked-in maps of port & proto values
that can be relied on to exist on any platform.

I missed the fallback to the baked-in maps on Windows, though, which
broke Windows XP. This should fix it.

Fixes #17175

Change-Id: Iecd434fb684304137ee27f5521cfaa8c351a1bde
Reviewed-on: https://go-review.googlesource.com/29968
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-09-29 18:09:54 +00:00
Alberto Donizetti d58219e50b cmd/compile: delete unused IntLiteral function
IntLiteral was only called by the gins functions in
cmd/compile/internal/{arm64,mips64,ppc64}/gsubr.go
but CL 29220 (cmd/compile: remove gins) deleted them,
so IntLiteral is now unused.

Change-Id: I2652b6d2ace6fdadc1982f65e749f3982513371e
Reviewed-on: https://go-review.googlesource.com/29996
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-09-29 17:25:28 +00:00
Alberto Donizetti c5434f2973 time: update test for tzdata-2016g
Fixes #17276

Change-Id: I0188cf9bc5fdb48c71ad929cc54206d03e0b96e4
Reviewed-on: https://go-review.googlesource.com/29995
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-09-29 16:26:28 +00:00
Ilya Tocar 731b3ed18d math: make sqrt smaller on AMD64
This makes function fit in 16 bytes, saving 16 bytes.

Change-Id: Iac5d2add42f6dae985b2a5cbe19ad4bd4bcc92ec
Reviewed-on: https://go-review.googlesource.com/29151
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-09-29 15:56:52 +00:00
Cherry Zhang fedb0b3018 cmd/internal/obj/arm: optimize MOVW $-off(R), R
When offset < 0 and -offset fits in instruction, generate SUB
instruction, instead of ADD with constant from the pool.

Fixes #13280.

Change-Id: I57d97fe9300fe1f6554365e2262393ef50acbdd3
Reviewed-on: https://go-review.googlesource.com/30014
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-09-29 15:20:46 +00:00
Ilya Tocar 26531b3846 cmd/internal/obj/x86: cleanup
Remove duplicate vars, commented out code  and duplicate lines.
When choosing between 2 aliases, on with more uses was chosen.

Change-Id: I7bc15f1693de3f6d378cef9c09469970a659db40
Reviewed-on: https://go-review.googlesource.com/29152
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-09-29 11:45:43 +00:00
Matthew Dempsky 03a1dc3522 cmd/compile: don't crash on (unsafe.Sizeof)(0)
Fixes #17270.

Change-Id: I4affa57e10baf1a758bc0977265d160f220b2945
Reviewed-on: https://go-review.googlesource.com/29960
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-09-28 23:13:53 +00:00
Cherry Zhang 4d07d3e29c cmd/compile: re-enable nilcheck removal for newobject
Also add compiler debug ouput and add a test.

Fixes #15390.

Change-Id: Iceba1414c29bcc213b87837387bf8ded1f3157f1
Reviewed-on: https://go-review.googlesource.com/30011
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-09-28 19:41:49 +00:00
Blixt 456a01ac47 encoding/binary: add bool support
This change adds support for decoding and encoding the bool type. The
encoding is a single byte, with a zero value for false and a non-zero
value for true.

Closes #16856.

Change-Id: I1d1114b320263691473bb100cad0f380e0204186
Reviewed-on: https://go-review.googlesource.com/28514
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-28 16:20:41 +00:00
Andrew Gerrand 5e7bae5082 doc: add testing Name method to go1.8.txt
Change-Id: I6d413f747e6a6c30c5e0e9afdffd5ec18dce7e08
Reviewed-on: https://go-review.googlesource.com/29974
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-28 16:06:39 +00:00
Mikio Hara a0d330f1dd runtime, runtime/cgo: revert CL 18814; don't drop signal stack in new thread on dragonfly
This change reverts CL 18814 which is a workaroud for older DragonFly
BSD kernels, and fixes #13945 and #13947 in a more general way the
same as other platforms except NetBSD.

This is a followup to CL 29491.

Updates #16329.

Change-Id: I771670bc672c827f2b3dbc7fd7417c49897cb991
Reviewed-on: https://go-review.googlesource.com/29971
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-09-28 14:45:06 +00:00
Ian Lance Taylor eb268cb321 runtime: minor simplifications to signal code
Change setsig, setsigstack, getsig, raise, raiseproc to take uint32 for
signal number parameter, as that is the type mostly used for signal
numbers.  Same for dieFromSignal, sigInstallGoHandler, raisebadsignal.

Remove setsig restart parameter, as it is always either true or
irrelevant.

Don't check the handler in setsigstack, as the only caller does that
anyhow.

Don't bother to convert the handler from sigtramp to sighandler in
getsig, as it will never be called when the handler is sigtramp or
sighandler.

Don't check the return value from rt_sigaction in the GNU/Linux version
of setsigstack; no other setsigstack checks it, and it never fails.

Change-Id: I6bbd677e048a77eddf974dd3d017bc3c560fbd48
Reviewed-on: https://go-review.googlesource.com/29953
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-28 13:12:47 +00:00
Andrew Gerrand 594cddd625 testing: add Name method to *T and *B
Fixes #17231

Change-Id: I0d6007ab504f2277cb6affc9e2050157a6ad4d5e
Reviewed-on: https://go-review.googlesource.com/29970
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-09-28 10:15:28 +00:00
Alex Brainman db82cf4e50 runtime: use RtlGenRandom instead of CryptGenRandom
This change replaces the use of CryptGenRandom with RtlGenRandom in
Windows to generate cryptographically random numbers during process
startup. RtlGenRandom uses the same RNG as CryptGenRandom, but it has many
fewer DLL dependencies and so does not affect process startup time as
much.

This makes running simple Go program on my computers faster.

Windows XP:
benchmark                      old ns/op     new ns/op     delta
BenchmarkRunningGoProgram-2     47408573      10784148      -77.25%

Windows 7 (VM):
benchmark                    old ns/op     new ns/op     delta
BenchmarkRunningGoProgram     16260390      12792150      -21.33%

Windows 7:
benchmark                      old ns/op     new ns/op     delta
BenchmarkRunningGoProgram-2     13600778      10050574      -26.10%

Fixes #15589

Change-Id: I2816239a2056e3d4a6dcd86a6fa2bb619c6008fe
Reviewed-on: https://go-review.googlesource.com/29700
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-28 05:21:53 +00:00
Keith Randall 98938189a1 cmd/compile: remove duplicate nilchecks
Mark nil check operations as faulting if their arg is zero.
This lets the late nilcheck pass remove duplicates.

Fixes #17242.

Change-Id: I4c9938d8a5a1e43edd85b4a66f0b34004860bcd9
Reviewed-on: https://go-review.googlesource.com/29952
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-09-27 23:54:01 +00:00
Cherry Zhang ba94dd3438 math: add some assembly implementations on ARM64
Also add GP<->FP move addressing mode to FMOVS, FMOVD
instructions.

Ceil-8                 37.1ns ± 0%   7.9ns ± 0%  -78.64%          (p=0.000 n=4+5)
Dim-8                  20.9ns ± 1%  11.3ns ± 0%  -45.93%          (p=0.008 n=5+5)
Floor-8                22.9ns ± 0%   7.9ns ± 0%  -65.41%          (p=0.029 n=4+4)
Gamma-8                 117ns ± 0%    94ns ± 1%  -19.50%          (p=0.016 n=4+5)
PowInt-8                121ns ± 0%   108ns ± 1%  -11.07%          (p=0.008 n=5+5)
PowFrac-8               331ns ± 0%   318ns ± 0%   -3.93%          (p=0.000 n=5+4)
Trunc-8                18.8ns ± 0%   7.9ns ± 0%  -57.83%          (p=0.016 n=4+5)

Change-Id: I709b7f1a914b28adc27414522db551e2630cfb92
Reviewed-on: https://go-review.googlesource.com/29734
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-09-27 23:52:12 +00:00
Brad Fitzpatrick a73020f847 net/http: add more IDNA2008 tests and fix some omissions
It wasn't lowercasing the string, folding widths, and putting strings
into NFC form. Do those.

Fixes #13835

Change-Id: Ia3de6159417cacec203b48e206e51d79f945df58
Reviewed-on: https://go-review.googlesource.com/29860
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
2016-09-27 22:06:32 +00:00
Brad Fitzpatrick 36c164ec9c vendor: add golang.org/x/text/unicode/norm + x/test/width for IDNA support
Add golang.org/x/text/unicode/norm from x/text git rev a7c02369.

Needed by net/http for IDNA normalization.

Updates #13835

Change-Id: I8b024e179d573f2b093c209a4b9e4f71f7d4a1f2
Reviewed-on: https://go-review.googlesource.com/29859
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
2016-09-27 22:06:23 +00:00
mike andrews 15b4d187b8 encoding/json: fix a bug in the documentation
Documentation made reference to an unknown entity "DisableHTMLEscaping,"
    but I think it actually meant the method "Encoder.SetEscapeHTML."

    Fixes #17255

Change-Id: I18fda76f8066110caef85fd33698de83d632e646
Reviewed-on: https://go-review.googlesource.com/29931
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-09-27 21:41:34 +00:00
Ian Lance Taylor fdc167164e runtime: remove sigmask type, use sigset instead
The OS-independent sigmask type was not pulling its weight. Replace it
with the OS-dependent sigset type. This requires adding an OS-specific
sigaddset function, but permits removing the OS-specific sigmaskToSigset
function.

Change-Id: I43307b512b0264ec291baadaea902f05ce212305
Reviewed-on: https://go-review.googlesource.com/29950
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-27 21:33:44 +00:00
Daniel Theophanes e13df02e5f database/sql: add context methods
Add context methods to sql and sql/driver methods. If
the driver doesn't implement context methods the connection
pool will still handle timeouts when a query fails to return
in time or when a connection is not available from the pool
in time.

There will be a follow-up CL that will add support for
context values that specify transaction levels and modes
that a driver can use.

Fixes #15123

Change-Id: Ia99f3957aa3f177b23044dd99d4ec217491a30a7
Reviewed-on: https://go-review.googlesource.com/29381
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-09-27 19:41:09 +00:00
Luigi Riefolo 54a72d90f6 go/doc: add IsPredeclared function
IsPredeclared allows simplifying src/golang.org/x/tools/godoc/linkify.go

Change-Id: I56b3223896f844630bc2e940255572d1682f0d06
Reviewed-on: https://go-review.googlesource.com/29870
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-09-27 18:01:26 +00:00
Ian Lance Taylor 097a581dc0 runtime: simplify signalstack by dropping nil as argument
Change the two calls to signalstack(nil) to inline the code
instead (it's two lines).

Change-Id: Ie92a05494f924f279e40ac159f1b677fda18f281
Reviewed-on: https://go-review.googlesource.com/29854
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-27 17:08:29 +00:00
Elias Naur 60482d8a8b runtime: relax SetFinalizer documentation to allow &local
The SetFinalizer documentation states that

"The argument obj must be a pointer to an object allocated by calling
new or by taking the address of a composite literal."

which precludes pointers to local variables. According to a comment
on #6591, this case is expected to work. This CL updates the documentation
for SetFinalizer accordingly.

Fixes #6591

Change-Id: Id861b3436bc1c9521361ea2d51c1ce74a121c1af
Reviewed-on: https://go-review.googlesource.com/29592
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2016-09-27 16:38:47 +00:00
Michael Munday 413f1ef4de cmd/asm: fix parsing of the s390x VLE{G,F,H,B} instructions
This commit makes the assembler frontend reorder the operands so that
they are in the order the backend expects. The index should be first
for consistency with the other vector instructions.

Before this commit no operand order would have been accepted so this
isn't a breaking change.

Change-Id: I188d57eeb338d27fa1fa6845de0d6d1521b7a6c3
Reviewed-on: https://go-review.googlesource.com/29855
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bill O'Farrell <billotosyr@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-27 16:01:11 +00:00
Michael Munday a30b5a3d19 cmd/asm: add s390x instructions BLTU and BLEU
These instructions are the same as BLT and BLE except that they
also branch if the 'unordered' bit is set in the condition code.

They are already used by the SSA backend. This change allows them
to be used in hand-written assembly code.

Change-Id: Ie9b5985a5e87ea22e8043567a286e09dce16a2db
Reviewed-on: https://go-review.googlesource.com/29930
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bill O'Farrell <billotosyr@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-27 16:01:01 +00:00
Michael Munday 17a8ec2c4f cmd/asm, cmd/internal/obj/s390x: improve add/multiply-immediate codegen
Use the A{,G}HI instructions where possible (4 bytes instead of 6 bytes
for A{,G}FI). Also, use 32-bit operations where appropriate for
multiplication.

Change-Id: I4041781cda26be52b54e4804a9e71552310762d0
Reviewed-on: https://go-review.googlesource.com/29733
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bill O'Farrell <billotosyr@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-27 16:00:51 +00:00
Michael Munday 3436f0776f reflect, runtime: optimize Value.Call on s390x and add benchmark
Use an MVC loop to copy arguments in runtime.call* rather than copying
bytes individually.

I've added the benchmark CallArgCopy to test the speed of Value.Call
for various argument sizes.

name                    old speed      new speed       delta
CallArgCopy/size=128     439MB/s ± 1%    582MB/s ± 1%   +32.41%  (p=0.000 n=10+10)
CallArgCopy/size=256     695MB/s ± 1%   1172MB/s ± 1%   +68.67%  (p=0.000 n=10+10)
CallArgCopy/size=1024    573MB/s ± 8%   4175MB/s ± 2%  +628.11%  (p=0.000 n=10+10)
CallArgCopy/size=4096   1.46GB/s ± 2%  10.19GB/s ± 1%  +600.52%  (p=0.000 n=10+10)
CallArgCopy/size=65536  1.51GB/s ± 0%  12.30GB/s ± 1%  +716.30%   (p=0.000 n=9+10)

Change-Id: I87dae4809330e7964f6cb4a9e40e5b3254dd519d
Reviewed-on: https://go-review.googlesource.com/28096
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bill O'Farrell <billotosyr@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-27 16:00:19 +00:00
Alberto Donizetti 6c43c0c2fd cmd/compile: remove commented-out old c code
Change-Id: I9b2e6c45f7e83543a06d0aafd08a911f7b6485fd
Reviewed-on: https://go-review.googlesource.com/29874
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-27 15:59:19 +00:00
Cherry Zhang f876fb9bae cmd/compile: move value around before kick it out of register
When allocating registers, before kicking out the existing value,
copy it to a spare register if there is one. So later use of this
value can be found in register instead of reload from spill. This
is very helpful for instructions of which the input and/or output
can only be in specific registers, e.g. DIV on x86, MUL/DIV on
MIPS. May also be helpful in general.

For "go build -a cmd/go" on AMD64, reduce "spilled value remains"
by 1% (not including args, which almost certainly remain).

For the code in issue #16061 on AMD64:
MaxRem-12   111µs ± 1%    94µs ± 0%  -15.38%  (p=0.008 n=5+5)

Go1 benchmark on AMD64:
BinaryTree17-12              2.32s ± 2%     2.30s ± 1%    ~     (p=0.421 n=5+5)
Fannkuch11-12                2.52s ± 0%     2.44s ± 0%  -3.44%  (p=0.008 n=5+5)
FmtFprintfEmpty-12          39.9ns ± 3%    39.8ns ± 0%    ~     (p=0.635 n=5+4)
FmtFprintfString-12          114ns ± 1%     113ns ± 1%    ~     (p=0.905 n=5+5)
FmtFprintfInt-12             102ns ± 6%      98ns ± 1%    ~     (p=0.087 n=5+5)
FmtFprintfIntInt-12          146ns ± 5%     147ns ± 1%    ~     (p=0.238 n=5+5)
FmtFprintfPrefixedInt-12     155ns ± 2%     151ns ± 1%  -2.58%  (p=0.008 n=5+5)
FmtFprintfFloat-12           231ns ± 1%     232ns ± 1%    ~     (p=0.286 n=5+5)
FmtManyArgs-12               657ns ± 1%     649ns ± 0%  -1.31%  (p=0.008 n=5+5)
GobDecode-12                6.35ms ± 0%    6.29ms ± 1%    ~     (p=0.056 n=5+5)
GobEncode-12                5.38ms ± 1%    5.45ms ± 1%    ~     (p=0.056 n=5+5)
Gzip-12                      209ms ± 0%     209ms ± 1%    ~     (p=0.690 n=5+5)
Gunzip-12                   31.2ms ± 1%    31.1ms ± 1%    ~     (p=0.548 n=5+5)
HTTPClientServer-12          123µs ± 4%     130µs ± 8%    ~     (p=0.151 n=5+5)
JSONEncode-12               14.0ms ± 1%    14.0ms ± 1%    ~     (p=0.421 n=5+5)
JSONDecode-12               41.2ms ± 1%    41.1ms ± 2%    ~     (p=0.421 n=5+5)
Mandelbrot200-12            3.96ms ± 1%    3.98ms ± 0%    ~     (p=0.421 n=5+5)
GoParse-12                  2.88ms ± 1%    2.88ms ± 1%    ~     (p=0.841 n=5+5)
RegexpMatchEasy0_32-12      68.0ns ± 3%    66.6ns ± 1%  -2.00%  (p=0.024 n=5+5)
RegexpMatchEasy0_1K-12       728ns ± 8%     682ns ± 1%  -6.26%  (p=0.008 n=5+5)
RegexpMatchEasy1_32-12      66.8ns ± 2%    66.0ns ± 1%    ~     (p=0.302 n=5+5)
RegexpMatchEasy1_1K-12       291ns ± 2%     288ns ± 1%    ~     (p=0.111 n=5+5)
RegexpMatchMedium_32-12      103ns ± 2%     100ns ± 0%  -2.53%  (p=0.016 n=5+4)
RegexpMatchMedium_1K-12     31.9µs ± 1%    31.3µs ± 0%  -1.75%  (p=0.008 n=5+5)
RegexpMatchHard_32-12       1.59µs ± 2%    1.59µs ± 1%    ~     (p=0.548 n=5+5)
RegexpMatchHard_1K-12       48.3µs ± 2%    47.7µs ± 1%    ~     (p=0.222 n=5+5)
Revcomp-12                   340ms ± 1%     338ms ± 1%    ~     (p=0.421 n=5+5)
Template-12                 46.3ms ± 1%    46.5ms ± 1%    ~     (p=0.690 n=5+5)
TimeParse-12                 252ns ± 1%     247ns ± 0%  -1.91%  (p=0.000 n=5+4)
TimeFormat-12                277ns ± 1%     267ns ± 0%  -3.82%  (p=0.008 n=5+5)
[Geo mean]                  48.8µs         48.3µs       -0.93%

It has very little effect on binary size and compiler speed.
compilebench:
Template       230ms ±10%      231ms ± 8%    ~             (p=0.546 n=9+9)
Unicode        123ms ± 6%      124ms ± 9%    ~           (p=0.481 n=10+10)
GoTypes        742ms ± 6%      755ms ± 3%    ~           (p=0.123 n=10+10)
Compiler       3.10s ± 3%      3.08s ± 1%    ~           (p=0.631 n=10+10)

Fixes #16061.

Change-Id: Id99cdc7a182ee10a704fa0f04e8e0d0809b2ac56
Reviewed-on: https://go-review.googlesource.com/29732
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-09-27 15:44:58 +00:00
Cherry Zhang 9d4b40f55d runtime, cmd/compile: implement and use DUFFCOPY on ARM64
Change-Id: I8984eac30e5df78d4b94f19412135d3cc36969f8
Reviewed-on: https://go-review.googlesource.com/29910
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-09-27 15:07:31 +00:00
Oliver Tonnhofer 7de7d20e9f image/png: improve compression by skipping filter for paletted images
Compression of paletted images is more efficient if they are not filtered.
This patch skips filtering for cbP8 images.
The improvements are demonstrated at https://github.com/olt/compressbench

Fixes #16196

Change-Id: Ie973aad287cacf9057e394bb01cf0e4448a77618
Reviewed-on: https://go-review.googlesource.com/29872
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-09-27 14:01:20 +00:00
Alberto Donizetti 590f3f0c9d cmd/compile: fix misaligned comments
Realign multi-line comments that got misaligned by the c->go
conversion.

Change-Id: I584b902e95cf588aa14febf1e0b6dfa499c303c2
Reviewed-on: https://go-review.googlesource.com/29871
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-27 14:00:39 +00:00
Sam Whited 8f9e2ab557 database/sql: add doc comment for ErrTxDone
Change-Id: Idffb82cdcba4985954d061bdb021217f47ff4985
Reviewed-on: https://go-review.googlesource.com/29850
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-27 03:16:13 +00:00
Michal Bohuslávek 9ed0715bb6 math/big: support negative numbers in ModInverse
Fixes #16984

Change-Id: I3a330e82941a068ca6097985af4ab221275fd336
Reviewed-on: https://go-review.googlesource.com/29299
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2016-09-27 00:42:56 +00:00
Austin Clements f8b2314c56 runtime: optimize defer code
This optimizes deferproc and deferreturn in various ways.

The most important optimization is that it more carefully arranges to
prevent preemption or stack growth. Currently we do this by switching
to the system stack on every deferproc and every deferreturn. While we
need to be on the system stack for the slow path of allocating and
freeing defers, in the common case we can fit in the nosplit stack.
Hence, this change pushes the system stack switch down into the slow
paths and makes everything now exposed to the user stack nosplit. This
also eliminates the need for various acquirem/releasem pairs, since we
are now preventing preemption by preventing stack split checks.

As another smaller optimization, we special case the common cases of
zero-sized and pointer-sized defer frames to respectively skip the
copy and perform the copy in line instead of calling memmove.

This speeds up the runtime defer benchmark by 42%:

name           old time/op  new time/op  delta
Defer-4        75.1ns ± 1%  43.3ns ± 1%  -42.31%   (p=0.000 n=8+10)

In reality, this speeds up defer by about 2.2X. The two benchmarks
below compare a Lock/defer Unlock pair (DeferLock) with a Lock/Unlock
pair (NoDeferLock). NoDeferLock establishes a baseline cost, so these
two benchmarks together show that this change reduces the overhead of
defer from 61.4ns to 27.9ns.

name           old time/op  new time/op  delta
DeferLock-4    77.4ns ± 1%  43.9ns ± 1%  -43.31%  (p=0.000 n=10+10)
NoDeferLock-4  16.0ns ± 0%  15.9ns ± 0%   -0.39%    (p=0.000 n=9+8)

This also shaves 34ns off cgo calls:

name       old time/op  new time/op  delta
CgoNoop-4   122ns ± 1%  88.3ns ± 1%  -27.72%  (p=0.000 n=8+9)

Updates #14939, #16051.

Change-Id: I2baa0dea378b7e4efebbee8fca919a97d5e15f38
Reviewed-on: https://go-review.googlesource.com/29656
Reviewed-by: Keith Randall <khr@golang.org>
2016-09-26 22:01:35 +00:00
Austin Clements d211c2d377 runtime: implement getcallersp in Go
This makes it possible to inline getcallersp. getcallersp is on the
hot path of defers, so this slightly speeds up defer:

name           old time/op  new time/op  delta
Defer-4        78.3ns ± 2%  75.1ns ± 1%  -4.00%   (p=0.000 n=9+8)

Updates #14939.

Change-Id: Icc1cc4cd2f0a81fc4c8344432d0b2e783accacdd
Reviewed-on: https://go-review.googlesource.com/29655
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-09-26 22:01:32 +00:00
Austin Clements aaf4099a5c runtime: update malloc.go documentation
The big documentation comment at the top of malloc.go has gotten
woefully out of date. Update it.

Change-Id: Ibdb1bdcfdd707a6dc9db79d0633a36a28882301b
Reviewed-on: https://go-review.googlesource.com/29731
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-09-26 22:00:53 +00:00