]> Cypherpunks repositories - gostls13.git/log
gostls13.git
7 years agocmd/compile/internal/syntax: follow Go naming conventions for error methods
Robert Griesemer [Wed, 14 Feb 2018 23:22:44 +0000 (15:22 -0800)]
cmd/compile/internal/syntax: follow Go naming conventions for error methods

Also, remove parser.error method (in favor of parser.errorAt) as it's only
used twice.

This is a purely cosmetic change.

Change-Id: Idb3b8b50f1c2e4d10de2ffb1c1184ceba8f7de8a
Reviewed-on: https://go-review.googlesource.com/94030
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agocmd/compile: fix constant folding of right shifts on s390x
Keith Randall [Wed, 14 Feb 2018 22:21:31 +0000 (14:21 -0800)]
cmd/compile: fix constant folding of right shifts on s390x

Repeat previous fix on amd64 for s390x.
Sub-word right shifts should sign extend before shifting.

Update #23812

Change-Id: I2d770190c7d8a22310b0dbd9facb3fb05afa362a
Reviewed-on: https://go-review.googlesource.com/94028
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/compile: fix printing of untyped types in -W output
Matthew Dempsky [Wed, 14 Feb 2018 21:51:51 +0000 (13:51 -0800)]
cmd/compile: fix printing of untyped types in -W output

It's always useful to distinguish "bool" and "string" from "untyped
bool" and "untyped string", so change typefmt to do this
unconditionally.

Also, while here, replace a bare 0 with its named constant FErr.

Fixes #23833.

Change-Id: I3fcb8d7204686937439caaaf8b3973fc236d0387
Reviewed-on: https://go-review.googlesource.com/94021
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/compile: fix go:uintptrescapes tag for unnamed parameters
Cherry Zhang [Fri, 8 Dec 2017 03:01:42 +0000 (22:01 -0500)]
cmd/compile: fix go:uintptrescapes tag for unnamed parameters

The tag was overwritten by the code for special handling unnamed
parameters.

Fixes #23045.

Change-Id: Ie2e1db3e902a07a2bbbc2a3424cea300f0a42cc3
Reviewed-on: https://go-review.googlesource.com/82775
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agoencoding/json: make error capture logic in recover more type safe
Joe Tsai [Wed, 6 Dec 2017 06:53:48 +0000 (22:53 -0800)]
encoding/json: make error capture logic in recover more type safe

Rather than only ignoring runtime.Error panics, which are a very
narrow set of possible panic values, switch it such that the json
package only captures panic values that have been properly wrapped
in a jsonError struct. This ensures that only intentional panics
originating from the json package are captured.

Fixes #23012

Change-Id: I5e85200259edd2abb1b0512ce6cc288849151a6d
Reviewed-on: https://go-review.googlesource.com/94019
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agogo/types: make gotype continue after syntax errors
Robert Griesemer [Wed, 14 Feb 2018 00:37:51 +0000 (16:37 -0800)]
go/types: make gotype continue after syntax errors

This avoids odd behavior where sometimes a lot of useful
errors are not reported simply because of a small syntax
error.

Tested manually with non-existing files. (We cannot easily
add an automatic test because this is a stand-alone binary
in this directory that must be built manually.)

Fixes #23593.

Change-Id: Iff90f95413bed7d1023fa0a5c9eb0414144428a9
Reviewed-on: https://go-review.googlesource.com/93815
Reviewed-by: Alan Donovan <adonovan@google.com>
7 years agocmd/compile: constant fold !true and !false
Keith Randall [Mon, 22 Jan 2018 18:06:10 +0000 (10:06 -0800)]
cmd/compile: constant fold !true and !false

Constant fold Not of boolean constants.

Noticed while working on #23504.

Change-Id: I965705154ee7348a1a159fad4e029b922d3171b3
Reviewed-on: https://go-review.googlesource.com/88956
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
7 years agotest: add test case for incorrect gccgo compilation error
Ian Lance Taylor [Thu, 25 Jan 2018 18:33:00 +0000 (10:33 -0800)]
test: add test case for incorrect gccgo compilation error

Updates #23489

Change-Id: Ie846ccfe4c4d9295857f5da6863ac8f2ac0f2f6a
Reviewed-on: https://go-review.googlesource.com/89935
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agotest: add a test that gccgo miscompiled
Ian Lance Taylor [Fri, 2 Feb 2018 19:16:56 +0000 (11:16 -0800)]
test: add a test that gccgo miscompiled

Updates #20923

Change-Id: Ia1210ea3dec39e5db2521aeafca24d6e731f0c93
Reviewed-on: https://go-review.googlesource.com/91657
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agotest: add test for rounding to positive zero
Ian Lance Taylor [Mon, 5 Feb 2018 03:15:18 +0000 (19:15 -0800)]
test: add test for rounding to positive zero

Per the language spec clarification in https://golang.org/cl/14727.

Updates #12576
Updates #12621

Change-Id: I1e459c3c11a571bd29582761faacaa9ca3178ba6
Reviewed-on: https://go-review.googlesource.com/91895
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/compile/internal/ssa: don't spill register offsets on amd64
Ilya Tocar [Mon, 4 Dec 2017 20:24:16 +0000 (14:24 -0600)]
cmd/compile/internal/ssa: don't spill register offsets on amd64

Transform (ADDQconst SP) into (LEA SP), because lea is rematerializeable,
so this avoids register spill. We can't mark ADDQconst as rematerializeable,
because it clobbers flags. This makes go binary ~2kb smaller.

For reference here is generated code for function from bug report.
Before:
        CALL    "".g(SB)
        MOVBLZX (SP), AX
        LEAQ    8(SP), DI
        TESTB   AX, AX
        JEQ     15
        MOVQ    "".p(SP), SI
        DUFFCOPY        $196
        MOVQ    $0, (SP)
        PCDATA  $0, $1
        CALL    "".h(SB)
        RET
        MOVQ    DI, ""..autotmp_2-8(SP) // extra spill
        PCDATA  $0, $2
        CALL    "".g(SB)
        MOVQ    ""..autotmp_2-8(SP), DI // extra register fill
        MOVQ    "".p(SP), SI
        DUFFCOPY        $196
        MOVQ    $1, (SP)
        PCDATA  $0, $1
        CALL    "".h(SB)
        JMP     14
        END

After:
        CALL    "".g(SB)
        MOVBLZX (SP), AX
        TESTB   AX, AX
        JEQ     15
        LEAQ    8(SP), DI
        MOVQ    "".p(SP), SI
        DUFFCOPY        $196
        MOVQ    $0, (SP)
        PCDATA  $0, $1
        CALL    "".h(SB)
        RET
        PCDATA  $0, $0  // no spill
        CALL    "".g(SB)
        LEAQ    8(SP), DI // rematerialized instead
        MOVQ    "".p(SP), SI
        DUFFCOPY        $196
        MOVQ    $1, (SP)
        PCDATA  $0, $1
        CALL    "".h(SB)
        JMP     14
        END

Fixes #22947

Change-Id: I8f33b860dc6c8828373477171b172ca2ce30074f
Reviewed-on: https://go-review.googlesource.com/81815
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
7 years agocmd/compile/internal/amd64: update popcnt code generation
Ilya Tocar [Thu, 7 Dec 2017 16:56:45 +0000 (10:56 -0600)]
cmd/compile/internal/amd64: update popcnt code generation

Popcnt has false dependency on output register and generates
MOVQ $0, reg to break it. But recently we switched MOVQ $0, reg
encoding from xor reg, reg  to actual mov $0, reg. This CL updates
code generation for popcnt to use actual XOR.

Change-Id: I4c1fc11e85758b53ba2679165fa55614ec54b27d
Reviewed-on: https://go-review.googlesource.com/82516
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
7 years agocmd/compile/internal: pass LocalSlot values, not pointers
Heschi Kreinick [Tue, 30 Jan 2018 00:21:25 +0000 (19:21 -0500)]
cmd/compile/internal: pass LocalSlot values, not pointers

Because getStackOffset is a function pointer, the compiler assumes that
its arguments escape. Pass a value instead to avoid heap allocations.

Change-Id: Ib94e5941847f134cd00e873040a4d7fcf15ced26
Reviewed-on: https://go-review.googlesource.com/92397
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
7 years agocmd/compile/internal: reuse memory for valueToProgAfter
Heschi Kreinick [Mon, 29 Jan 2018 22:01:41 +0000 (17:01 -0500)]
cmd/compile/internal: reuse memory for valueToProgAfter

Not a big improvement, but does help edge cases like the SSA package.
Change-Id: I40e531110b97efd5f45955be477fd0f4faa8d545
Reviewed-on: https://go-review.googlesource.com/92396
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
7 years agocmd/compile/internal/ssa: use math/bits for register sets
Heschi Kreinick [Mon, 29 Jan 2018 21:09:11 +0000 (16:09 -0500)]
cmd/compile/internal/ssa: use math/bits for register sets

Using bits.TrailingZeroes instead of iterating over each bit is a small
but easy win for the common case of only one or two registers being set.

I copied in the implementation for use with pre-1.9 bootstraps.

Change-Id: Ieaa768554d7d5239a5617fbf34f1ee0b32ce1de5
Reviewed-on: https://go-review.googlesource.com/92395
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
7 years agocmd/compile/internal/ssa: reduce location list memory use
Heschi Kreinick [Mon, 22 Jan 2018 22:06:26 +0000 (17:06 -0500)]
cmd/compile/internal/ssa: reduce location list memory use

Put everything that showed up in the allocation profile into the cache,
and reuse it across functions.

After this CL, the overhead of enabling location lists is getting
pretty close to the desired 5%:

compilecmp -all -beforeflags -dwarflocationlists=0 -afterflags -dwarflocationlists=1 -n 30 4ebad42292b6a4090faf37753dd768d2965e38c4 4ebad42292b6a4090faf37753dd768d2965e38c4
compilecmp  -dwarflocationlists=0 4ebad42292b6a4090faf37753dd768d2965e38c4  -dwarflocationlists=1 4ebad42292b6a4090faf37753dd768d2965e38c4
benchstat -geomean  /tmp/869550129 /tmp/143495132
completed   30 of   30, estimated time remaining 0s (eta 3:24PM)
name        old time/op       new time/op       delta
Template          199ms ± 4%        209ms ± 6%   +5.17%  (p=0.000 n=29+30)
Unicode          99.2ms ± 8%      100.5ms ± 6%     ~     (p=0.112 n=30+30)
GoTypes           642ms ± 3%        684ms ± 3%   +6.54%  (p=0.000 n=29+30)
SSA               8.00s ± 1%        8.71s ± 1%   +8.78%  (p=0.000 n=29+29)
Flate             129ms ± 7%        134ms ± 5%   +3.77%  (p=0.000 n=30+30)
GoParser          157ms ± 4%        164ms ± 5%   +4.35%  (p=0.000 n=29+30)
Reflect           428ms ± 3%        450ms ± 4%   +5.09%  (p=0.000 n=30+30)
Tar               195ms ± 5%        204ms ± 8%   +4.78%  (p=0.000 n=30+30)
XML               228ms ± 4%        241ms ± 4%   +5.62%  (p=0.000 n=30+29)
StdCmd            15.4s ± 1%        16.7s ± 1%   +8.29%  (p=0.000 n=29+29)
[Geo mean]        476ms             502ms        +5.35%

name        old user-time/op  new user-time/op  delta
Template          294ms ±18%        304ms ±15%     ~     (p=0.242 n=29+29)
Unicode           182ms ±27%        172ms ±28%     ~     (p=0.104 n=30+30)
GoTypes           957ms ±15%       1016ms ±12%   +6.16%  (p=0.000 n=30+30)
SSA               13.3s ± 5%        14.3s ± 3%   +7.32%  (p=0.000 n=30+28)
Flate             188ms ±17%        193ms ±17%     ~     (p=0.288 n=28+29)
GoParser          232ms ±16%        238ms ±13%     ~     (p=0.065 n=30+29)
Reflect           585ms ±13%        620ms ±10%   +5.88%  (p=0.000 n=30+30)
Tar               298ms ±21%        332ms ±23%  +11.32%  (p=0.000 n=30+30)
XML               329ms ±17%        343ms ±12%   +4.18%  (p=0.032 n=30+30)
[Geo mean]        492ms             513ms        +4.13%

name        old alloc/op      new alloc/op      delta
Template         38.3MB ± 0%       40.3MB ± 0%   +5.29%  (p=0.000 n=30+30)
Unicode          29.3MB ± 0%       29.6MB ± 0%   +1.28%  (p=0.000 n=30+29)
GoTypes           110MB ± 0%        118MB ± 0%   +6.97%  (p=0.000 n=29+30)
SSA              1.48GB ± 0%       1.61GB ± 0%   +9.06%  (p=0.000 n=30+30)
Flate            24.8MB ± 0%       26.0MB ± 0%   +4.99%  (p=0.000 n=29+30)
GoParser         30.9MB ± 0%       32.2MB ± 0%   +4.20%  (p=0.000 n=30+30)
Reflect          76.8MB ± 0%       80.6MB ± 0%   +4.97%  (p=0.000 n=30+30)
Tar              39.6MB ± 0%       41.7MB ± 0%   +5.22%  (p=0.000 n=29+30)
XML              42.0MB ± 0%       45.4MB ± 0%   +8.22%  (p=0.000 n=29+30)
[Geo mean]       63.9MB            67.5MB        +5.56%

name        old allocs/op     new allocs/op     delta
Template           383k ± 0%         405k ± 0%   +5.69%  (p=0.000 n=30+30)
Unicode            343k ± 0%         346k ± 0%   +0.98%  (p=0.000 n=30+27)
GoTypes           1.15M ± 0%        1.22M ± 0%   +6.17%  (p=0.000 n=29+29)
SSA               12.2M ± 0%        13.2M ± 0%   +8.15%  (p=0.000 n=30+30)
Flate              234k ± 0%         249k ± 0%   +6.44%  (p=0.000 n=30+30)
GoParser           315k ± 0%         332k ± 0%   +5.31%  (p=0.000 n=30+28)
Reflect            972k ± 0%        1010k ± 0%   +3.89%  (p=0.000 n=30+30)
Tar                394k ± 0%         415k ± 0%   +5.35%  (p=0.000 n=28+30)
XML                404k ± 0%         429k ± 0%   +6.31%  (p=0.000 n=29+29)
[Geo mean]         651k              686k        +5.35%

Change-Id: Ia005a8d6b33ce9f8091322f004376a3d6e5c1a94
Reviewed-on: https://go-review.googlesource.com/89357
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
7 years agocmd/compile: reimplement location list generation
Heschi Kreinick [Thu, 26 Oct 2017 19:40:17 +0000 (15:40 -0400)]
cmd/compile: reimplement location list generation

Completely redesign and reimplement location list generation to be more
efficient, and hopefully not too hard to understand.

RegKills are gone. Instead of using the regalloc's liveness
calculations, redo them using the Ops' clobber information. Besides
saving a lot of Values, this avoids adding RegKills to blocks that would
be empty otherwise, which was messing up optimizations. This does mean
that it's much harder to tell whether the generation process is buggy
(there's nothing to cross-check it with), and there may be disagreements
with GC liveness. But the performance gain is significant, and it's nice
not to be messing with earlier compiler phases.

The intermediate representations are gone. Instead of producing
ssa.BlockDebugs, then dwarf.LocationLists, and then finally real
location lists, go directly from the SSA to a (mostly) real location
list. Because the SSA analysis happens before assembly, it stores
encoded block/value IDs where PCs would normally go. It would be easier
to do the SSA analysis after assembly, but I didn't want to retain the
SSA just for that.

Generation proceeds in two phases: first, it traverses the function in
CFG order, storing the state of the block at the beginning and end. End
states are used to produce the start states of the successor blocks. In
the second phase, it traverses in program text order and produces the
location lists. The processing in the second phase is redundant, but
much cheaper than storing the intermediate representation. It might be
possible to combine the two phases somewhat to take advantage of cases
where the CFG matches the block layout, but I haven't tried.

Location lists are finalized by adding a base address selection entry,
translating each encoded block/value ID to a real PC, and adding the
terminating zero entry. This probably won't work on OSX, where dsymutil
will choke on the base address selection. I tried emitting CU-relative
relocations for each address, and it was *very* bad for performance --
it uses more memory storing all the relocations than it does for the
actual location list bytes. I think I'm going to end up synthesizing the
relocations in the linker only on OSX, but TBD.

TestNexting needs updating: with more optimizations working, the
debugger doesn't stop on the continue (line 88) any more, and the test's
duplicate suppression kicks in. Also, dx and dy live a little longer
now, but they have the correct values.

Change-Id: Ie772dfe23a4e389ca573624fac4d05401ae32307
Reviewed-on: https://go-review.googlesource.com/89356
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
7 years agocmd/compile/internal: decouple scope tracking from location lists
Heschi Kreinick [Tue, 23 Jan 2018 19:10:08 +0000 (14:10 -0500)]
cmd/compile/internal: decouple scope tracking from location lists

We're trying to enable location lists by default, and it's easier to do
that if we don't have to worry about scope tracking at the same time.
We can evaluate their performance impact separately.

However, that does mean that "err" is ambiguous in the test case, so
rename it to err2 for now.

Change-Id: I24f119016185c52b7d9affc74207f6a5b450fb6f
Reviewed-on: https://go-review.googlesource.com/89355
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
7 years agoruntime: use private futexes on Linux
Ian Lance Taylor [Mon, 27 Nov 2017 23:40:28 +0000 (15:40 -0800)]
runtime: use private futexes on Linux

By default futexes are permitted in shared memory regions, which
requires the kernel to translate the memory address. Since our futexes
are never in shared memory, set FUTEX_PRIVATE_FLAG, which makes futex
operations slightly more efficient.

Change-Id: I2a82365ed27d5cd8d53c5382ebaca1a720a80952
Reviewed-on: https://go-review.googlesource.com/80144
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
7 years agocmd/asm: add PRFM instruction on ARM64
fanzha02 [Thu, 30 Nov 2017 08:30:53 +0000 (08:30 +0000)]
cmd/asm: add PRFM instruction on ARM64

The current assembler cannot handle PRFM(immediate) instruciton.
The fix creates a prfopfield struct that contains the eight
prefetch operations and the value to use in instruction. And add
the test cases.

Fixes #22932

Change-Id: I621d611bd930ef3c42306a4372447c46d53b2ccf
Reviewed-on: https://go-review.googlesource.com/81675
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agocmd/internal/obj/mips: support NEG, avoid crash with illegal instruction
Cherry Zhang [Thu, 25 Jan 2018 16:46:06 +0000 (11:46 -0500)]
cmd/internal/obj/mips: support NEG, avoid crash with illegal instruction

Add support of NEG{V,W} pseudo-instructions, which are translated
to a SUB instruction from R0 with proper width.

Also turn illegal instruction to UNDEF, to avoid crashing in
asmout when it tries to read the operands.

Fixes #23548.

Change-Id: I047b27559ccd9594c3dcf62ab039b636098f30a3
Reviewed-on: https://go-review.googlesource.com/89896
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
7 years agonacl*.bash: pass flags to make.bash
Cherry Zhang [Sat, 10 Feb 2018 20:32:28 +0000 (15:32 -0500)]
nacl*.bash: pass flags to make.bash

Just like all.bash passes flags to make.bash, I think it makes
sense that naclmake.bash and nacltest.bash do so as well. For
example, on a slow machine I can do "./nacltest.bash -v" to see
the build progress.

Change-Id: Id766dd590e6b83e8b5345822580dc1b05eac8ea3
Reviewed-on: https://go-review.googlesource.com/93117
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
7 years agocmd/compile: CALLudiv on nacl/arm doesn't clobber R12
Cherry Zhang [Fri, 9 Feb 2018 17:47:33 +0000 (12:47 -0500)]
cmd/compile: CALLudiv on nacl/arm doesn't clobber R12

On nacl/arm, R12 is clobbered by the RET instruction in function
that has a frame. runtime.udiv doesn't have a frame, so it does
not clobber R12.

Change-Id: I0de448749f615908f6659e92d201ba3eb2f8266d
Reviewed-on: https://go-review.googlesource.com/93116
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
7 years agoruntime/internal/atomic: add early nil check on ARM
Cherry Zhang [Mon, 12 Feb 2018 22:00:01 +0000 (17:00 -0500)]
runtime/internal/atomic: add early nil check on ARM

If nil, fault before taking the lock or calling into the kernel.

Change-Id: I013d78a5f9233c2a9197660025f679940655d384
Reviewed-on: https://go-review.googlesource.com/93636
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
7 years agoruntime/internal/atomic: unify sys_*_arm.s on non-linux
Cherry Zhang [Mon, 12 Feb 2018 19:27:46 +0000 (14:27 -0500)]
runtime/internal/atomic: unify sys_*_arm.s on non-linux

Updates #23778.

Change-Id: I80e57a15b6e3bbc2e25ea186399ff0e360fc5c21
Reviewed-on: https://go-review.googlesource.com/93635
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
7 years agocmd/compile: replace range loop over list of nodes with orderexprlistinplace
Martin Möhrmann [Wed, 17 Jan 2018 20:00:26 +0000 (21:00 +0100)]
cmd/compile: replace range loop over list of nodes with orderexprlistinplace

Replace explicit range loop that applies orderexprinplace on a
list of nodes with existing helper function orderexprlistinplace.

Passes toolstash -cmp.

Change-Id: Ic8098ed08cf67f319de3faa83b00a5b73bbde95d
Reviewed-on: https://go-review.googlesource.com/88815
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agogithub: add a Pull Request template
Andrew Bonventre [Wed, 14 Feb 2018 05:27:10 +0000 (00:27 -0500)]
github: add a Pull Request template

Change-Id: I02938b2435e3a98efea7ee5545a6f8f5f6f794b4
Reviewed-on: https://go-review.googlesource.com/93915
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/compile: generate tbz/tbnz when comparing against zero on arm64
Chad Rosier [Wed, 7 Feb 2018 20:37:33 +0000 (15:37 -0500)]
cmd/compile: generate tbz/tbnz when comparing against zero on arm64

The tbz/tbnz checks the sign bit to determine if the value is >= 0 or < 0.

go1 benchmark results:
name                   old speed      new speed      delta
JSONEncode             94.4MB/s ± 1%  95.7MB/s ± 0%  +1.36%  (p=0.000 n=10+9)
JSONDecode             19.7MB/s ± 1%  19.9MB/s ± 1%  +1.08%  (p=0.000 n=9+10)
Gzip                   45.5MB/s ± 0%  46.0MB/s ± 0%  +1.06%  (p=0.000 n=10+10)
Revcomp                 376MB/s ± 0%   379MB/s ± 0%  +0.69%  (p=0.000 n=10+10)
RegexpMatchHard_1K     12.6MB/s ± 0%  12.7MB/s ± 0%  +0.57%  (p=0.000 n=10+8)
RegexpMatchMedium_32   3.21MB/s ± 0%  3.22MB/s ± 0%  +0.31%  (p=0.000 n=9+10)
RegexpMatchEasy1_1K    1.27GB/s ± 0%  1.27GB/s ± 0%  +0.23%  (p=0.000 n=9+9)
RegexpMatchHard_32     11.4MB/s ± 0%  11.4MB/s ± 1%  +0.19%  (p=0.036 n=10+8)
RegexpMatchEasy0_1K    1.77GB/s ± 0%  1.77GB/s ± 0%  +0.13%  (p=0.000 n=9+10)
RegexpMatchMedium_1K   19.3MB/s ± 0%  19.3MB/s ± 0%  +0.04%  (p=0.008 n=10+8)
RegexpMatchEasy0_32     131MB/s ± 0%   131MB/s ± 0%    ~     (p=0.211 n=10+10)
GobDecode              57.5MB/s ± 1%  57.6MB/s ± 2%    ~     (p=0.469 n=10+10)
GobEncode              58.6MB/s ± 1%  58.5MB/s ± 2%    ~     (p=0.781 n=10+10)
GoParse                9.40MB/s ± 0%  9.39MB/s ± 0%  -0.19%  (p=0.005 n=10+9)
RegexpMatchEasy1_32     133MB/s ± 0%   133MB/s ± 0%  -0.48%  (p=0.000 n=10+10)
Template               20.9MB/s ± 0%  20.6MB/s ± 0%  -1.54%  (p=0.000 n=8+10)

Change-Id: I411efe44db35c3962445618d5a47c12e31b3925b
Reviewed-on: https://go-review.googlesource.com/92715
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agosyscall, os: use pipe2 syscall on NetBSD instead of pipe
Tobias Klauser [Wed, 14 Feb 2018 14:56:39 +0000 (14:56 +0000)]
syscall, os: use pipe2 syscall on NetBSD instead of pipe

The pipe2 syscall is part of NetBSD since version 6.0 and thus exists in
all officially supported versions (6.0 through 6.1 and 7.0+).

Follows CL 38426

Change-Id: I7b62b507300c3dfbcc6ae56408a7d7088ddccc77
Reviewed-on: https://go-review.googlesource.com/94035
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/go: put "go help" list in the right order, take 2
Nate Wilkinson [Mon, 12 Feb 2018 17:33:27 +0000 (10:33 -0700)]
cmd/go: put "go help" list in the right order, take 2

The previous fix had "bug" and "build" in the wrong order.

Fixes #23791

Change-Id: I4897428516b159966c13c1054574c4f6fbf0fbac
Reviewed-on: https://go-review.googlesource.com/94017
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agosync: enable profiling of RWMutex
Lorenz Bauer [Wed, 10 Jan 2018 10:50:19 +0000 (10:50 +0000)]
sync: enable profiling of RWMutex

Include reader / writer interactions of RWMutex in the mutex profile.
Writer contention is already included in the profile, since a plain Mutex
is used to control exclusion.

Fixes #18496

Change-Id: Ib0dc1ffa0fd5e6d964a6f7764d7f09556eb63f00
Reviewed-on: https://go-review.googlesource.com/87095
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Peter Weinberger <pjw@google.com>
7 years agocrypto/cipher: add NewGCMWithNonceAndTagSize for custom tag sizes.
Conrado Gouvea [Fri, 14 Jul 2017 01:14:37 +0000 (22:14 -0300)]
crypto/cipher: add NewGCMWithNonceAndTagSize for custom tag sizes.

GCM allows using tag sizes smaller than the block size. This adds a
NewGCMWithNonceAndTagSize function which allows specifying the tag
size.

Fixes #19594

Change-Id: Ib2008c6f13ad6d916638b1523c0ded8a80eaf42d
Reviewed-on: https://go-review.googlesource.com/48510
Reviewed-by: Filippo Valsorda <hi@filippo.io>
Run-TryBot: Filippo Valsorda <hi@filippo.io>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocrypto/rsa: improve error message for keys too short for PSS
Filippo Valsorda [Thu, 8 Feb 2018 15:19:24 +0000 (16:19 +0100)]
crypto/rsa: improve error message for keys too short for PSS

Fixes #23736

Change-Id: I850d91a512394c4292927d51c475064bfa4e3053
Reviewed-on: https://go-review.googlesource.com/92815
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoreflect: add embedded field test
Ian Lance Taylor [Thu, 1 Feb 2018 01:12:29 +0000 (17:12 -0800)]
reflect: add embedded field test

Gccgo failed this test.

Updates #23620

Change-Id: I3979a6d3b87d2d014850accf9cb7f356349e6195
Reviewed-on: https://go-review.googlesource.com/91138
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
7 years agoruntime: remove extraneous stackPreempt setting
David Crawshaw [Sun, 24 Sep 2017 14:48:18 +0000 (10:48 -0400)]
runtime: remove extraneous stackPreempt setting

The stackguard is set to stackPreempt earlier in reentersyscall, and
as it comes with throwsplit = true there's no way for the stackguard
to be set to anything else by the end of reentersyscall.

Change-Id: I4e942005b22ac784c52398c74093ac887fc8ec24
Reviewed-on: https://go-review.googlesource.com/65673
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
7 years agocmd/compile/internal/ssa: optimize arm64 with FNMULS/FNMULD
Ben Shi [Wed, 7 Feb 2018 12:24:41 +0000 (12:24 +0000)]
cmd/compile/internal/ssa: optimize arm64 with FNMULS/FNMULD

FNMULS&FNMULD are efficient arm64 instructions, which can be used
to improve FP performance. This CL use them to optimize pairs of neg-mul
operations.

Here are benchmark test results on Raspberry Pi 3 with ArchLinux.

1. A special test case gets about 15% improvement.
(https://github.com/benshi001/ugo1/blob/master/fpmul_test.go)
FPMul-4                     485µs ± 0%     410µs ± 0%  -15.49%  (p=0.000 n=26+23)

2. There is little regression in the go1 benchmark (excluding noise).
name                     old time/op    new time/op    delta
BinaryTree17-4              42.0s ± 3%     42.1s ± 2%    ~     (p=0.542 n=39+40)
Fannkuch11-4                33.3s ± 3%     32.9s ± 1%    ~     (p=0.200 n=40+32)
FmtFprintfEmpty-4           534ns ± 0%     534ns ± 0%    ~     (all equal)
FmtFprintfString-4         1.09µs ± 1%    1.09µs ± 0%    ~     (p=0.950 n=32+32)
FmtFprintfInt-4            1.14µs ± 0%    1.14µs ± 1%    ~     (p=0.571 n=32+31)
FmtFprintfIntInt-4         1.79µs ± 3%    1.76µs ± 0%  -1.42%  (p=0.004 n=40+34)
FmtFprintfPrefixedInt-4    2.17µs ± 0%    2.17µs ± 0%    ~     (p=0.073 n=31+34)
FmtFprintfFloat-4          3.33µs ± 3%    3.28µs ± 0%  -1.46%  (p=0.001 n=40+34)
FmtManyArgs-4              7.28µs ± 6%    7.19µs ± 0%    ~     (p=0.641 n=40+33)
GobDecode-4                96.5ms ± 4%    96.5ms ± 9%    ~     (p=0.214 n=40+40)
GobEncode-4                79.5ms ± 0%    80.7ms ± 4%  +1.51%  (p=0.000 n=34+40)
Gzip-4                      4.53s ± 4%     4.56s ± 4%  +0.60%  (p=0.000 n=40+40)
Gunzip-4                    451ms ± 3%     442ms ± 0%  -1.93%  (p=0.000 n=40+32)
HTTPClientServer-4          530µs ± 1%     535µs ± 1%  +0.88%  (p=0.000 n=39+39)
JSONEncode-4                214ms ± 4%     211ms ± 0%    ~     (p=0.059 n=40+31)
JSONDecode-4                865ms ± 5%     864ms ± 4%  -0.06%  (p=0.003 n=40+40)
Mandelbrot200-4            52.0ms ± 3%    52.1ms ± 3%    ~     (p=0.556 n=40+40)
GoParse-4                  43.1ms ± 8%    42.1ms ± 0%    ~     (p=0.083 n=40+33)
RegexpMatchEasy0_32-4      1.02µs ± 3%    1.02µs ± 4%  +0.06%  (p=0.020 n=40+40)
RegexpMatchEasy0_1K-4      3.90µs ± 0%    3.96µs ± 3%  +1.58%  (p=0.000 n=31+40)
RegexpMatchEasy1_32-4       967ns ± 4%     981ns ± 3%  +1.40%  (p=0.000 n=40+40)
RegexpMatchEasy1_1K-4      6.41µs ± 4%    6.43µs ± 3%    ~     (p=0.386 n=40+40)
RegexpMatchMedium_32-4     1.76µs ± 3%    1.78µs ± 3%  +1.08%  (p=0.000 n=40+40)
RegexpMatchMedium_1K-4      561µs ± 0%     562µs ± 0%  +0.09%  (p=0.003 n=34+31)
RegexpMatchHard_32-4       31.5µs ± 2%    31.1µs ± 4%  -1.17%  (p=0.000 n=30+40)
RegexpMatchHard_1K-4        960µs ± 3%     950µs ± 4%  -1.02%  (p=0.016 n=40+40)
Revcomp-4                   7.79s ± 7%     7.79s ± 4%    ~     (p=0.859 n=40+40)
Template-4                  889ms ± 6%     872ms ± 3%  -1.86%  (p=0.025 n=40+31)
TimeParse-4                4.80µs ± 0%    4.89µs ± 3%  +1.71%  (p=0.001 n=31+40)
TimeFormat-4               4.70µs ± 1%    4.78µs ± 3%  +1.57%  (p=0.000 n=33+40)
[Geo mean]                  710µs          709µs       -0.13%

name                     old speed      new speed      delta
GobDecode-4              7.96MB/s ± 4%  7.96MB/s ± 9%    ~     (p=0.174 n=40+40)
GobEncode-4              9.65MB/s ± 0%  9.51MB/s ± 4%  -1.45%  (p=0.000 n=34+40)
Gzip-4                   4.29MB/s ± 4%  4.26MB/s ± 4%  -0.59%  (p=0.000 n=40+40)
Gunzip-4                 43.0MB/s ± 3%  43.9MB/s ± 0%  +1.90%  (p=0.000 n=40+32)
JSONEncode-4             9.09MB/s ± 4%  9.22MB/s ± 0%    ~     (p=0.429 n=40+31)
JSONDecode-4             2.25MB/s ± 5%  2.25MB/s ± 4%    ~     (p=0.278 n=40+40)
GoParse-4                1.35MB/s ± 7%  1.37MB/s ± 0%    ~     (p=0.071 n=40+25)
RegexpMatchEasy0_32-4    31.5MB/s ± 3%  31.5MB/s ± 4%  -0.08%  (p=0.018 n=40+40)
RegexpMatchEasy0_1K-4     263MB/s ± 0%   259MB/s ± 3%  -1.51%  (p=0.000 n=31+40)
RegexpMatchEasy1_32-4    33.1MB/s ± 4%  32.6MB/s ± 3%  -1.38%  (p=0.000 n=40+40)
RegexpMatchEasy1_1K-4     160MB/s ± 4%   159MB/s ± 3%    ~     (p=0.364 n=40+40)
RegexpMatchMedium_32-4    565kB/s ± 3%   562kB/s ± 2%    ~     (p=0.208 n=40+40)
RegexpMatchMedium_1K-4   1.82MB/s ± 0%  1.82MB/s ± 0%  -0.27%  (p=0.000 n=34+31)
RegexpMatchHard_32-4     1.02MB/s ± 3%  1.03MB/s ± 4%  +1.04%  (p=0.000 n=32+40)
RegexpMatchHard_1K-4     1.07MB/s ± 4%  1.08MB/s ± 4%  +0.94%  (p=0.003 n=40+40)
Revcomp-4                32.6MB/s ± 7%  32.6MB/s ± 4%    ~     (p=0.965 n=40+40)
Template-4               2.18MB/s ± 6%  2.22MB/s ± 3%  +1.83%  (p=0.020 n=40+31)
[Geo mean]               7.77MB/s       7.78MB/s       +0.16%

3. There is little change in the compilecmp benchmark (excluding noise).
name        old time/op       new time/op       delta
Template          2.37s ± 3%        2.35s ± 4%    ~     (p=0.529 n=10+10)
Unicode           1.38s ± 8%        1.36s ± 5%    ~     (p=0.247 n=10+10)
GoTypes           8.10s ± 2%        8.10s ± 2%    ~     (p=0.971 n=10+10)
Compiler          40.5s ± 4%        40.8s ± 1%    ~     (p=0.529 n=10+10)
SSA                115s ± 2%         115s ± 3%    ~     (p=0.684 n=10+10)
Flate             1.45s ± 5%        1.46s ± 3%    ~     (p=0.796 n=10+10)
GoParser          1.86s ± 4%        1.84s ± 2%    ~     (p=0.095 n=9+10)
Reflect           5.11s ± 2%        5.13s ± 2%    ~     (p=0.315 n=10+10)
Tar               2.22s ± 3%        2.23s ± 1%    ~     (p=0.299 n=9+7)
XML               2.72s ± 3%        2.72s ± 3%    ~     (p=0.912 n=10+10)
[Geo mean]        5.03s             5.02s       -0.21%

name        old user-time/op  new user-time/op  delta
Template          2.92s ± 2%        2.89s ± 1%    ~     (p=0.247 n=10+10)
Unicode           1.71s ± 5%        1.69s ± 4%    ~     (p=0.393 n=10+10)
GoTypes           9.78s ± 2%        9.76s ± 2%    ~     (p=0.631 n=10+10)
Compiler          49.1s ± 2%        49.1s ± 1%    ~     (p=0.796 n=10+10)
SSA                144s ± 1%         144s ± 2%    ~     (p=0.796 n=10+10)
Flate             1.74s ± 2%        1.73s ± 3%    ~     (p=0.842 n=10+9)
GoParser          2.23s ± 3%        2.25s ± 2%    ~     (p=0.143 n=10+10)
Reflect           5.93s ± 3%        5.98s ± 2%    ~     (p=0.211 n=10+9)
Tar               2.65s ± 2%        2.69s ± 3%  +1.51%  (p=0.010 n=9+10)
XML               3.25s ± 2%        3.21s ± 1%  -1.24%  (p=0.035 n=10+9)
[Geo mean]        6.07s             6.07s       -0.08%

name        old text-bytes    new text-bytes    delta
HelloSize         641kB ± 0%        641kB ± 0%    ~     (all equal)

name        old data-bytes    new data-bytes    delta
HelloSize        9.46kB ± 0%       9.46kB ± 0%    ~     (all equal)

name        old bss-bytes     new bss-bytes     delta
HelloSize         125kB ± 0%        125kB ± 0%    ~     (all equal)

name        old exe-bytes     new exe-bytes     delta
HelloSize        1.24MB ± 0%       1.24MB ± 0%    ~     (all equal)

Change-Id: Id095d998c380eef929755124084df02446a6b7c1
Reviewed-on: https://go-review.googlesource.com/92555
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agomisc/cgo/testcshared: increase sleep in TestUnexportedSymbols
Ian Lance Taylor [Wed, 14 Feb 2018 05:15:05 +0000 (21:15 -0800)]
misc/cgo/testcshared: increase sleep in TestUnexportedSymbols

Increase the sleep and wait for up to 2 seconds for the dup2.
Apparently it can sometimes take a long time.

Fixes #23784

Change-Id: I929530b057bbcd842b28a7640c39dd68d719ff7d
Reviewed-on: https://go-review.googlesource.com/93895
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agopath/filepath: fix escaped chars in Glob on non-Windows
Daniel Martí [Thu, 11 Jan 2018 20:23:22 +0000 (20:23 +0000)]
path/filepath: fix escaped chars in Glob on non-Windows

Backslashes are ignored in Match and Glob on Windows, since those
collide with the separator character. However, they should still work in
both functions on other operating systems.

hasMeta did not reflect this logic - it always treated a backslash as a
non-special character. Do that only on Windows.

Assuming this is what the TODO was referring to, remove it. There are no
other characters that scanChunk treats especially.

Fixes #23418.

Change-Id: Ie0bd795812e0ed9d8c8c1bbc3137f29d960cba84
Reviewed-on: https://go-review.googlesource.com/87455
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agopath: remove filename mentions from pattern godocs
Daniel Martí [Tue, 16 Jan 2018 16:55:06 +0000 (16:55 +0000)]
path: remove filename mentions from pattern godocs

path.Match works purely with strings, not file paths. That's what sets
it apart from filepath.Match. For example, only filepath.Match will
change its behavior towards backslashes on Windows, to accomodate for
the file path separator on that system.

As such, path.Match should make no mention of file names. Nor should
path.ErrBadPattern mention globbing at all - the package has no notion
of globbing, and the error concerns only patterns.

For a similar reason, remove the mention of globbing from
filepath.ErrBadPattern. The error isn't reserved to just globbing, as it
can be returned from filepath.Match. And, as before, it only concerns
the patterns themselves.

Change-Id: I58a83ffa3e2549625d8e546ef916652525504bd1
Reviewed-on: https://go-review.googlesource.com/87857
Reviewed-by: Rob Pike <r@golang.org>
7 years agomath/big: fix %s verbs in Float tests error messages
Alberto Donizetti [Wed, 10 Jan 2018 16:31:25 +0000 (17:31 +0100)]
math/big: fix %s verbs in Float tests error messages

Fatalf calls in two Float tests use the %s verb with Floats values,
which is not allowed and results in failure messages that look like
this:

    float_test.go:1385: i = 0, prec = 1, ToZero:
                     %!s(*big.Float=1) [0]
                /    %!s(*big.Float=1) [0]
                =    %!s(*big.Float=0.0625)
                want %!s(*big.Float=1)

Switch to %v.

Change-Id: Ifdc80bf19c91ca1b190f6551a6d0a51b42ed5919
Reviewed-on: https://go-review.googlesource.com/87199
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/compile: change type of clear argument of ordercopyexpr to bool
Martin Möhrmann [Wed, 17 Jan 2018 19:26:23 +0000 (20:26 +0100)]
cmd/compile: change type of clear argument of ordercopyexpr to bool

ordercopyexpr is only called with 0 or 1 as value for the clear
argument. The clear variable in ordercopyexpr is only used in the
call to ordertemp which has a clear argument of type bool.

Change the clear argument of ordercopyexpr from int to bool and change
calls to ordercopyexpr to use false instead of 0 and true instead of 1.

Passes toolstash -cmp.

Change-Id: Ic264aafd3b0c8b99f6ef028ffaa2e30f23f9125a
Reviewed-on: https://go-review.googlesource.com/88115
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
7 years agointernal/cpu: make arm64 capability bits naming less verbose
Martin Möhrmann [Sun, 4 Feb 2018 20:23:25 +0000 (21:23 +0100)]
internal/cpu: make arm64 capability bits naming less verbose

This makes the constant names less verbose and aligns them more
with the Linux kernel which uses HWCAP_XXX for the constant names.

Change-Id: Ia7d079b59b57978adc045945951eaa1d99b41fac
Reviewed-on: https://go-review.googlesource.com/91738
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoruntime: add symbol for AT_FDCWD on Linux amd64 and mips64x
Tobias Klauser [Tue, 13 Feb 2018 16:07:54 +0000 (17:07 +0100)]
runtime: add symbol for AT_FDCWD on Linux amd64 and mips64x

Also order the syscall number list by numerically for mips64x.

Follow-up for CL 92895.

Change-Id: I5f01f8c626132a06160997fce8a2aef0c486bb1c
Reviewed-on: https://go-review.googlesource.com/93616
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agodoc/articles/wiki: highlight the use of _ warning
Agniva De Sarker [Thu, 11 Jan 2018 16:49:01 +0000 (22:19 +0530)]
doc/articles/wiki: highlight the use of _ warning

This moves the paragraph mentioning the use of _ higher up
to emphasize the warning and thereby reducing chances of getting
stuck.

Fixes #22617

Change-Id: I64352a3e966a22d86fc9d381332bade49d74714a
Reviewed-on: https://go-review.googlesource.com/87375
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agoencoding/hex: fix potential incorrect Dumper output when Close is called multiple...
Tim Cooper [Fri, 26 Jan 2018 20:36:15 +0000 (16:36 -0400)]
encoding/hex: fix potential incorrect Dumper output when Close is called multiple times

Fixes #23574

Change-Id: I69573de47daa6fd53cc99a78c0c4b867460242e3
Reviewed-on: https://go-review.googlesource.com/90275
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>

7 years agocmd/compile: fix constant folding of right shifts
Keith Randall [Tue, 13 Feb 2018 20:33:55 +0000 (12:33 -0800)]
cmd/compile: fix constant folding of right shifts

The sub-word shifts need to sign-extend before shifting, to avoid
bringing in data from higher in the argument.

Fixes #23812

Change-Id: I0a95a0b49c48f3b40b85765bb4a9bb492be0cd73
Reviewed-on: https://go-review.googlesource.com/93716
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agogo/build: add go1.11 build tag
Mikio Hara [Tue, 13 Feb 2018 22:20:26 +0000 (07:20 +0900)]
go/build: add go1.11 build tag

As usual, adding go1.11 early in the cycle so that we can start
regression testing of the master toolchain.

Change-Id: Ie96eca7223722d60d7acc6b3b996b76740c36419
Reviewed-on: https://go-review.googlesource.com/93775
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agoruntime/trace: fix TestTraceSymbolize when GOMAXPROCS=1
David du Colombier [Tue, 13 Feb 2018 21:11:20 +0000 (22:11 +0100)]
runtime/trace: fix TestTraceSymbolize when GOMAXPROCS=1

CL 92916 added the GOMAXPROCS test in TestTraceSymbolize.

This test only succeeds when the value of GOMAXPROCS changes.

Since the test calls runtime.GOMAXPROCS(1), it will fails
on machines where GOMAXPROCS=1.

This change fixes the test by calling runtime.GOMAXPROCS(oldGoMaxProcs+1).

Fixes #23816.

Change-Id: I1183dbbd7db6077cbd7fa0754032ff32793b2195
Reviewed-on: https://go-review.googlesource.com/93735
Run-TryBot: David du Colombier <0intro@gmail.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agoruntime: remove unused memlimit function
Austin Clements [Mon, 29 Jan 2018 17:22:32 +0000 (12:22 -0500)]
runtime: remove unused memlimit function

Change-Id: Id057dcc85d64e5c670710fbab6cacd4b906cf594
Reviewed-on: https://go-review.googlesource.com/93655
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agotext/template: never call reflect.Zero(nil)
Daniel Martí [Sun, 17 Dec 2017 22:32:15 +0000 (22:32 +0000)]
text/template: never call reflect.Zero(nil)

It makes no sense to try to get the zero value of a nil type, hence the
panic. When we have a nil type, use reflect.ValueOf(nil) instead.

This was showing itself if one used a missing field on the data between
parentheses, when the data was a nil interface:

t := template.Must(template.New("test").Parse(`{{ (.).foo }}`))
var v interface{}
t.Execute(os.Stdout, v)

Resulting in:

panic: reflect: Zero(nil) [recovered]
panic: reflect: Zero(nil)

Fixes #21171.

Change-Id: Ifcc4a0c67e6df425b65bc9f82fde6fcf03828579
Reviewed-on: https://go-review.googlesource.com/84482
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
7 years agotime: add example for FixedZone
Kevin Burke [Tue, 13 Feb 2018 17:06:59 +0000 (09:06 -0800)]
time: add example for FixedZone

Change-Id: I8a6c3e225038cbeb315433fabf8835f582836d3e
Reviewed-on: https://go-review.googlesource.com/93657
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agodatabase/sql: remove duplicate validation
Tamir Duberstein [Wed, 31 Jan 2018 16:58:03 +0000 (11:58 -0500)]
database/sql: remove duplicate validation

Since https://golang.org/cl/38533, this validation is performed in
driverArgs.

Change-Id: I13a3ca46a1aa3197370de1095fb46ab83ea4628c
Reviewed-on: https://go-review.googlesource.com/91115
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agodatabase/sql: include SQL column name in Scan() error message
HaraldNordgren [Sun, 7 Jan 2018 14:08:59 +0000 (15:08 +0100)]
database/sql: include SQL column name in Scan() error message

When 'convertAssign' gives an error, instead of giving just the index of
the failing column -- which is not always helpful, especially when there
are lots of columns in the query -- utilize 'rs.rowsi.Columns()' to
extract the underlying column name and include that in the error string:

    sql: Scan error on column index 0, name "some_column": ...

Fixes #23362

Change-Id: I0fe71ff3c25f4c0dd9fc6aa2c2da2360dd93e3e0
Reviewed-on: https://go-review.googlesource.com/86537
Reviewed-by: Harald Nordgren <haraldnordgren@gmail.com>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/vet: replace hasMethod with isFormatter
Daniel Martí [Wed, 31 Jan 2018 20:53:44 +0000 (20:53 +0000)]
cmd/vet: replace hasMethod with isFormatter

The former checks if a type has a method called "Format". The latter
checks if a type satisfies fmt.Formatter.

isFormatter does exactly what we want, so it's both simpler and more
accurate. Remove the only use of hasMethod in its favor.

Change-Id: Idc156a99081c3308f98512b87011a04aa8c6638d
Reviewed-on: https://go-review.googlesource.com/91215
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
7 years agocmd/compile: print usage to stderr for consistency
Daniel Martí [Sun, 24 Dec 2017 16:50:28 +0000 (16:50 +0000)]
cmd/compile: print usage to stderr for consistency

All the other tools and commands print the usage text to standard error.
"go tool compile" was the odd one out, so fix it.

While at it, make objabi.Flagprint a bit more Go-like with an io.Writer
instead of a file descriptor, which is likely a leftover from the C
days.

Fixes #23234.

Change-Id: I9abf2e79461e61c8c8bfaee2c6bf8faf26e0e6c3
Reviewed-on: https://go-review.googlesource.com/85418
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agoruntime: avoid bad unwinding from sigpanic in C code
Austin Clements [Wed, 31 Jan 2018 17:05:24 +0000 (12:05 -0500)]
runtime: avoid bad unwinding from sigpanic in C code

Currently, if a sigpanic call is injected into C code, it's possible
for preparePanic to leave the stack in a state where traceback can't
unwind correctly past the sigpanic.

Specifically, shouldPushPanic sniffs the stack to decide where to put
the PC from the signal context. In the cgo case, it will find that
!findfunc(pc).valid() because pc is in C code, and then it will check
if the top of the stack looks like a Go PC. However, this stack slot
is just in a C frame, so it could be uninitialized and contain
anything, including what looks like a valid Go PC. For example, in
https://build.golang.org/log/c601a18e2af24794e6c0899e05dddbb08caefc17,
it sees 1c02c23a <runtime.newproc1+682>. When this condition is met,
it skips putting the signal PC on the stack at all. As a result, when
we later unwind from the sigpanic, we'll "successfully" but
incorrectly unwind to whatever PC was in this uninitialized slot and
go who knows where from there.

Fix this by making shouldPushPanic assume that the signal PC is always
usable if we're running C code, so we always make it appear like
sigpanic's caller.

This lets us be pickier again about unexpected return PCs in
gentraceback.

Updates #23640.

Change-Id: I1e8ade24b031bd905d48e92d5e60c982e8edf160
Reviewed-on: https://go-review.googlesource.com/91137
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agoruntime: refactor test for pushing sigpanic frame
Austin Clements [Wed, 31 Jan 2018 22:34:22 +0000 (17:34 -0500)]
runtime: refactor test for pushing sigpanic frame

This logic is duplicated in all of the preparePanic functions. Pull it
out into one architecture-independent function.

Change-Id: I7ef4e78e3eda0b7be1a480fb5245fc7424fb2b4e
Reviewed-on: https://go-review.googlesource.com/91255
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agocmd/go: put "go help" list in alphabetical order
Nate Wilkinson [Mon, 12 Feb 2018 17:33:27 +0000 (10:33 -0700)]
cmd/go: put "go help" list in alphabetical order

Fixes #23791

Change-Id: I3ded0cd6e9fea14f477f90cf4ad1fb9ff95257f4
Reviewed-on: https://go-review.googlesource.com/93416
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agogo/types: better handle arrays whose length expression is invalid
Robert Griesemer [Tue, 13 Feb 2018 00:42:31 +0000 (16:42 -0800)]
go/types: better handle arrays whose length expression is invalid

While doing that, establish a negative value as signal for unknown
array lengths and adjust various array-length processing code to
handle that case.

Fixes #23712.

Change-Id: Icf488faaf972638b42b22d4b4607d1c512c8fc2c
Reviewed-on: https://go-review.googlesource.com/93438
Reviewed-by: Alan Donovan <adonovan@google.com>
7 years agoimage/gif: support non-looping animated gifs (LoopCount=-1)
Peter Teichman [Mon, 12 Feb 2018 19:23:31 +0000 (19:23 +0000)]
image/gif: support non-looping animated gifs (LoopCount=-1)

The Netscape looping application extension encodes how many
times the animation should restart, and if it's present
there is no way to signal that a GIF should play only once.

Use LoopCount=-1 to signal when a decoded GIF had no looping
extension, and update the encoder to omit that extension
block when LoopCount=-1.

Fixes #15768

GitHub-Last-Rev: 249744f0e28ef8907aa876070a102cb5493f5084
GitHub-Pull-Request: golang/go#23761
Change-Id: Ic915268505bf12bdad690b59148983a7d78d693b
Reviewed-on: https://go-review.googlesource.com/93076
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agodoc: mention net/http Server Content-Type change
Brad Fitzpatrick [Tue, 5 Dec 2017 22:31:25 +0000 (22:31 +0000)]
doc: mention net/http Server Content-Type change

Updates #20784

Change-Id: Ic07c78a86da5026e407ac9ecb3117d320c198048
Reviewed-on: https://go-review.googlesource.com/82016
Reviewed-by: Andrew Bonventre <andybons@golang.org>
7 years agocmd/go/internal/test: remove redundant if statement
Andrew Bonventre [Sun, 28 Jan 2018 03:09:25 +0000 (22:09 -0500)]
cmd/go/internal/test: remove redundant if statement

Just return the result of the function call as they are
both functionally equivalent.

Change-Id: Ia7847c9b018475051bf6f7a7c532b515bd68c024
Reviewed-on: https://go-review.googlesource.com/90375
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agomath: use Abs rather than if x < 0 { x = -x }
Thanabodee Charoenpiriyakij [Sun, 17 Dec 2017 09:11:14 +0000 (16:11 +0700)]
math: use Abs rather than if x < 0 { x = -x }

This is the benchmark result base on darwin with amd64 architecture:

name     old time/op  new time/op  delta
Cos      10.2ns ± 2%  10.3ns ± 3%  +1.18%  (p=0.032 n=10+10)
Cosh     25.3ns ± 3%  24.6ns ± 2%  -3.00%  (p=0.000 n=10+10)
Hypot    6.40ns ± 2%  6.19ns ± 3%  -3.36%  (p=0.000 n=10+10)
HypotGo  7.16ns ± 3%  6.54ns ± 2%  -8.66%  (p=0.000 n=10+10)
J0       66.0ns ± 2%  63.7ns ± 1%  -3.42%  (p=0.000 n=9+10)

Fixes #21812

Change-Id: I2b88fbdfc250cd548f8f08b44ce2eb172dcacf43
Reviewed-on: https://go-review.googlesource.com/84437
Reviewed-by: Giovanni Bajo <rasky@develer.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Giovanni Bajo <rasky@develer.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/go/internal/get: fix regexes for "any" character matching
Piyush Mishra [Fri, 9 Feb 2018 03:32:17 +0000 (03:32 +0000)]
cmd/go/internal/get: fix regexes for "any" character matching

Minor bug: `hubajazz.net` and `gitbapache.org` would match, probably shouldn't

GitHub-Last-Rev: 75bd338569ca41f83b9c36fe3d5ae3b4db0a26cc
GitHub-Pull-Request: golang/go#23755
Change-Id: Ie9c9ab1c15364eccdab8cf3b106b9c370e7f532f
Reviewed-on: https://go-review.googlesource.com/92997
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/compile: report the struct type in invalid number of initializer values
Emmanuel Odeke [Sun, 11 Feb 2018 04:10:26 +0000 (20:10 -0800)]
cmd/compile: report the struct type in invalid number of initializer values

Fixes #23732

Disambiguate "too few" or "too many" values in struct
initializer messages by reporting the name of the literal.

After:
issue23732.go:27:3: too few values in Foo literal
issue23732.go:34:12: too many values in Bar literal
issue23732.go:40:6: too few values in Foo literal
issue23732.go:40:12: too many values in Bar literal

Change-Id: Ieca37298441d907ac78ffe960c5ab55741a362ef
Reviewed-on: https://go-review.googlesource.com/93277
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agoruntime/gdb: use goroutine atomicstatus to determine the state
Hana Kim [Tue, 16 Jan 2018 20:31:12 +0000 (15:31 -0500)]
runtime/gdb: use goroutine atomicstatus to determine the state

Previously find_goroutine determined whether a goroutine is
stopped by checking the sched.sp field. This heuristic doesn't
always hold but causes find_goroutine to return bogus pc/sp
info for running goroutines.

This change uses the atomicstatus bit to determine
the state which is more accurate.

R=go1.11

Change-Id: I537d432d9e0363257120a196ce2ba52da2970f59
Reviewed-on: https://go-review.googlesource.com/49691
Reviewed-by: Austin Clements <austin@google.com>
7 years agoruntime: remove hardcoded runtime consts from gdb script
Hana Kim [Tue, 16 Jan 2018 20:21:34 +0000 (15:21 -0500)]
runtime: remove hardcoded runtime consts from gdb script

Instead evaluate and read the runtime internal constants
defined in runtime2.go

R=go1.11

Change-Id: If2f4b87e5b3f62f0c0ff1e86a90db8e37a78abb6
Reviewed-on: https://go-review.googlesource.com/87877
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Austin Clements <austin@google.com>
7 years agopath: add example for Match
Jeff Dupont [Thu, 27 Jul 2017 03:27:53 +0000 (20:27 -0700)]
path: add example for Match

Change-Id: I5ab475011e9200c5055809e658d14c04c0a07a8a
Reviewed-on: https://go-review.googlesource.com/51413
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoruntime/trace: add stack tests for GOMAXPROCS
Hana Kim [Thu, 8 Feb 2018 18:23:48 +0000 (13:23 -0500)]
runtime/trace: add stack tests for GOMAXPROCS

and reorganize test log messages for stack dumps
for easier debugging.

The error log will be formatted like the following:

trace_stack_test.go:282: Did not match event GoCreate with stack
 runtime/trace_test.TestTraceSymbolize  :39
 testing.tRunner  :0

Seen 30 events of the type
Offset 1890
 runtime/trace_test.TestTraceSymbolize /go/src/runtime/trace/trace_stack_test.go:30
 testing.tRunner /go/src/testing/testing.go:777
Offset 1899
 runtime/trace_test.TestTraceSymbolize /go/src/runtime/trace/trace_stack_test.go:30
 testing.tRunner /go/src/testing/testing.go:777
 ...

Change-Id: I0468de04507d6ae38ba84d99d13f7bf592e8d115
Reviewed-on: https://go-review.googlesource.com/92916
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>

7 years agoregexp: don't allocate when All methods find no matches
Josh Bleecher Snyder [Mon, 18 Dec 2017 18:53:55 +0000 (10:53 -0800)]
regexp: don't allocate when All methods find no matches

name                old time/op    new time/op    delta
FindAllNoMatches-8     216ns ± 3%     122ns ± 2%   -43.52%  (p=0.000 n=10+10)

name                old alloc/op   new alloc/op   delta
FindAllNoMatches-8      240B ± 0%        0B       -100.00%  (p=0.000 n=10+10)

name                old allocs/op  new allocs/op  delta
FindAllNoMatches-8      1.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)

This work was supported by Sourcegraph.

Change-Id: I30aac201370ccfb40a6ff637402020ac20f61f70
Reviewed-on: https://go-review.googlesource.com/87418
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agonet/http: add StatusMisdirectedRequest (421)
Ryuma Yoshida [Sun, 11 Feb 2018 07:50:48 +0000 (16:50 +0900)]
net/http: add StatusMisdirectedRequest (421)

Fixes #23776

Change-Id: Iff03d8b295afc1fd9435694b10246c723d323eda
Reviewed-on: https://go-review.googlesource.com/93296
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Kunpei Sakai <namusyaka@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agonet/smtp: return error from SendMail when required AUTH not available
Johnny Luo [Fri, 24 Nov 2017 10:21:44 +0000 (21:21 +1100)]
net/smtp: return error from SendMail when required AUTH not available

Return an error if an Auth is passed to SendMail but the server does not support authentication.

Fixes #22145

Change-Id: I49a37259c47bbe5145e30fa8a2d05444e60cb378
Reviewed-on: https://go-review.googlesource.com/79776
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoarchive/tar: automatically promote TypeRegA
Caio Marcelo de Oliveira Filho [Tue, 2 Jan 2018 00:16:43 +0000 (16:16 -0800)]
archive/tar: automatically promote TypeRegA

Change Reader to promote TypeRegA to TypeReg in headers, unless their
name have a trailing slash which is already promoted to TypeDir. This
will allow client code to handle just TypeReg instead both TypeReg and
TypeRegA.

Change Writer to promote TypeRegA to TypeReg or TypeDir in the headers
depending on whether the name has a trailing slash. This normalization
is motivated by the specification (in pax(1)):

   0 represents a regular file. For backwards-compatibility, a
   typeflag value of binary zero ( '\0' ) should be recognized as
   meaning a regular file when extracting files from the
   archive. Archives written with this version of the archive file
   format create regular files with a typeflag value of the
   ISO/IEC 646:1991 standard IRV '0'.

Fixes #22768.

Change-Id: I149ec55824580d446cdde5a0d7a0457ad7b03466
Reviewed-on: https://go-review.googlesource.com/85656
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agoall: use HTTPS for iana.org links
Kevin Burke [Wed, 24 Jan 2018 06:11:51 +0000 (22:11 -0800)]
all: use HTTPS for iana.org links

iana.org, www.iana.org and data.iana.org all present a valid TLS
certificate, so let's use it when fetching data or linking to
resources to avoid errors in transit.

Change-Id: Ib3ce7c19789c4e9d982a776b61d8380ddc63194d
Reviewed-on: https://go-review.googlesource.com/89416
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agostrconv: detect invalid UTF-8 in the Unquote fast path
Brad Fitzpatrick [Wed, 7 Feb 2018 04:28:49 +0000 (04:28 +0000)]
strconv: detect invalid UTF-8 in the Unquote fast path

Fixes #23685

Change-Id: I3625bd01f860077ee0976df9e3dfb66754804bcd
Reviewed-on: https://go-review.googlesource.com/92535
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agonet/http/fcgi: update URL to spec documentation
Brad Fitzpatrick [Thu, 8 Feb 2018 21:19:42 +0000 (21:19 +0000)]
net/http/fcgi: update URL to spec documentation

Fixes #23748

Change-Id: Iacdbd57c53492175cf1d3045640db61151e10731
Reviewed-on: https://go-review.googlesource.com/92955
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
7 years agocrypto/tls: handle errors in generate_cert.go
Kevin Burke [Thu, 1 Feb 2018 20:21:44 +0000 (12:21 -0800)]
crypto/tls: handle errors in generate_cert.go

I don't expect these to hit often, but we should still alert users if
we fail to write the correct data to the file, or fail to close it.

Change-Id: I33774e94108f7f18ed655ade8cca229b1993d4d2
Reviewed-on: https://go-review.googlesource.com/91456
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoruntime: remove legacy eager write barrier
Austin Clements [Mon, 15 Jan 2018 17:27:17 +0000 (12:27 -0500)]
runtime: remove legacy eager write barrier

Now that the buffered write barrier is implemented for all
architectures, we can remove the old eager write barrier
implementation. This CL removes the implementation from the runtime,
support in the compiler for calling it, and updates some compiler
tests that relied on the old eager barrier support. It also makes sure
that all of the useful comments from the old write barrier
implementation still have a place to live.

Fixes #22460.

Updates #21640 since this fixes the layering concerns of the write
barrier (but not the other things in that issue).

Change-Id: I580f93c152e89607e0a72fe43370237ba97bae74
Reviewed-on: https://go-review.googlesource.com/92705
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Rick Hudson <rlh@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agoruntime: eliminate all writebarrierptr* calls
Austin Clements [Mon, 15 Jan 2018 05:00:02 +0000 (00:00 -0500)]
runtime: eliminate all writebarrierptr* calls

Calls to writebarrierptr can simply be actual pointer writes. Calls to
writebarrierptr_prewrite need to go through the write barrier buffer.

Updates #22460.

Change-Id: I92cee4da98c5baa499f1977563757c76f95bf0ca
Reviewed-on: https://go-review.googlesource.com/92704
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Rick Hudson <rlh@golang.org>
7 years agoruntime: buffered write barrier for s390x
Austin Clements [Wed, 15 Nov 2017 22:54:24 +0000 (14:54 -0800)]
runtime: buffered write barrier for s390x

Updates #22460.

Change-Id: I3f793e69577c1b837ad2666e6209a97a452405d4
Reviewed-on: https://go-review.googlesource.com/92703
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agoruntime: buffered write barrier for ppc64
Austin Clements [Wed, 15 Nov 2017 22:54:24 +0000 (14:54 -0800)]
runtime: buffered write barrier for ppc64

Updates #22460.

Change-Id: I6040c4024111c80361c81eb7eec5071ec9efb4f9
Reviewed-on: https://go-review.googlesource.com/92702
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agoruntime: buffered write barrier for mips
Austin Clements [Wed, 15 Nov 2017 22:54:24 +0000 (14:54 -0800)]
runtime: buffered write barrier for mips

Updates #22460.

Change-Id: Ieaca94385c3bb88dcc8351c3866b4b0e2a1412b5
Reviewed-on: https://go-review.googlesource.com/92701
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agoruntime: buffered write barrier for mips64
Austin Clements [Wed, 15 Nov 2017 22:54:24 +0000 (14:54 -0800)]
runtime: buffered write barrier for mips64

Updates #22460.

Change-Id: I9718bff3a346e765601cfd1890417bdfa0f7b9d8
Reviewed-on: https://go-review.googlesource.com/92700
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agoruntime: buffered write barrier for arm64
Austin Clements [Wed, 15 Nov 2017 22:54:24 +0000 (14:54 -0800)]
runtime: buffered write barrier for arm64

Updates #22460.

Change-Id: I5f8fbece9545840f5fc4c9834e2050b0920776f0
Reviewed-on: https://go-review.googlesource.com/92699
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agoruntime: buffered write barrier for arm
Austin Clements [Wed, 15 Nov 2017 22:54:24 +0000 (14:54 -0800)]
runtime: buffered write barrier for arm

Updates #22460.

Change-Id: I5581df7ad553237db7df3701b117ad99e0593b78
Reviewed-on: https://go-review.googlesource.com/92698
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agoruntime: buffered write barrier for amd64p32
Austin Clements [Wed, 15 Nov 2017 22:54:24 +0000 (14:54 -0800)]
runtime: buffered write barrier for amd64p32

Updates #22460.

Change-Id: I6656d478625e5e54aa2eaa38d99dfb0f71ea1fdd
Reviewed-on: https://go-review.googlesource.com/92697
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agoruntime: buffered write barrier for 386
Austin Clements [Wed, 15 Nov 2017 22:54:24 +0000 (14:54 -0800)]
runtime: buffered write barrier for 386

Updates #22460.

Change-Id: I3c8e90fd6bcda7e28911036591873d63665aaca7
Reviewed-on: https://go-review.googlesource.com/92696
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agocmd/compile: calls can clobber g on s390x
Austin Clements [Thu, 8 Feb 2018 15:31:07 +0000 (10:31 -0500)]
cmd/compile: calls can clobber g on s390x

Because a call may ultimately invoke runtime.setg, we have to assume
that g may be clobbered by any call. All of the other architectures
that use a g register already do this, but it was missing from the
s390x caller save clobber set.

Change-Id: Ia931638d42c44979839f20d71097acf31475f423
Reviewed-on: https://go-review.googlesource.com/92835
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agocmd/internal/obj/mips: fix use of R28 on 32-bit MIPS
Cherry Zhang [Thu, 8 Feb 2018 16:39:50 +0000 (11:39 -0500)]
cmd/internal/obj/mips: fix use of R28 on 32-bit MIPS

R28 is used as the SB register on MIPS64, and it was printed as
"RSB" on both 32-bit and 64-bit MIPS. This is confusing on MIPS32
as there R28 is just a general purpose register. Further, this
string representation is used in the assembler's frontend to parse
register symbols, and this leads to failure in parsing R28 in
MIPS32 assembly code. Change rconv to always print the register
as R28. This fixes the parsing problem on MIPS32, and this is
a reasonable representation on both MIPS32 and MIPS64.

Change-Id: I30d6c0a442fbb08ea615f32f1763b5baadcee1da
Reviewed-on: https://go-review.googlesource.com/92915
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
7 years agocmd/internal/obj/mips: use LR as temporary register in RET
Cherry Zhang [Tue, 21 Nov 2017 14:25:29 +0000 (09:25 -0500)]
cmd/internal/obj/mips: use LR as temporary register in RET

On mips/mips64, for non-leaf function, RET is assembled as
MOV (SP), R4       // load saved LR
ADD $framesize, SP
JMP (R4)

This clobbers R4 unnecessarily. Use the link register as
temporary instead.

Probably for Go 1.11.

Change-Id: I2209db7be11074ed2e0e0829cace95ebfb709e9f
Reviewed-on: https://go-review.googlesource.com/79016
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Austin Clements <austin@google.com>
7 years agosyscall: support syscalls without error return on Linux
Tobias Klauser [Mon, 18 Dec 2017 10:59:26 +0000 (11:59 +0100)]
syscall: support syscalls without error return on Linux

Add the rawSyscallNoError wrapper function which is used for Linux
syscalls that don't return an error and convert all applicable
occurences of RawSyscall to use it instead.

Fixes #22924

Change-Id: Iff1eddb54573d459faa01471f10398b3d38528dd
Reviewed-on: https://go-review.googlesource.com/84485
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agosyscall: support Getwd on all BSDs
Tobias Klauser [Thu, 14 Dec 2017 10:59:33 +0000 (11:59 +0100)]
syscall: support Getwd on all BSDs

All supported BSDs provide the SYS___GETCWD syscall which can be used to
implement syscall.Getwd. With this change os.Getwd can use a single
syscall instead of falling back to the current kludge solution on the
BSDs.

This doesn't add any new exported functions to the frozen syscall
package, only ImplementsGetwd changes to true for dragonfly, freebsd,
netbsd and openbsd.

As suggested by Ian, this follows CL 83755 which did the same for
golang.org/x/sys/unix.

Also, an entry for netbsd/arm is added to mkall.sh which was used to
generate the syscall wrappers there.

Change-Id: I84da1ec61a6b8625443699a63cde556b6442ad41
Reviewed-on: https://go-review.googlesource.com/84484
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agosyscall: reuse BSD forkExecPipe for Solaris
Tobias Klauser [Fri, 1 Dec 2017 12:57:57 +0000 (12:57 +0000)]
syscall: reuse BSD forkExecPipe for Solaris

The function was duplicated for Solaris. Reuse the BSD version instead.

Change-Id: Ibc812bcf36d21f4a7ceeef7b4fb091fa9479bfa8
Reviewed-on: https://go-review.googlesource.com/81395
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agoruntime: use Android O friendly syscalls on 64-bit machines
Jason A. Donenfeld [Thu, 8 Feb 2018 15:59:17 +0000 (16:59 +0100)]
runtime: use Android O friendly syscalls on 64-bit machines

Android O disallows open on 64-bit, so let's use openat with AT_FDCWD to
achieve the same behavior.

Android O disallows epoll_wait on 64-bit, so let's use epoll_pwait with
the last argument as NULL to achieve the same behavior.

See here:
https://android.googlesource.com/platform/bionic/+/master/libc/seccomp/arm64_app_policy.cpp
https://android.googlesource.com/platform/bionic/+/master/libc/seccomp/mips64_app_policy.cpp
https://android.googlesource.com/platform/bionic/+/master/libc/seccomp/x86_64_app_policy.cpp

Fixes #23750

Change-Id: If8d5a663357471e5d2c1f516151344a9d05b188a
Reviewed-on: https://go-review.googlesource.com/92895
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agoruntime: fix typo in comment
Yasuhiro Matsumoto [Tue, 13 Feb 2018 10:23:37 +0000 (10:23 +0000)]
runtime: fix typo in comment

GitHub-Last-Rev: d6a6fa39095cac8a9acfeacbbafd636e1aa9b55b
GitHub-Pull-Request: golang/go#23809
Change-Id: Ife18ba2f982b5e1c30bda32d13dcd441778b986a
Reviewed-on: https://go-review.googlesource.com/93575
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agoos: add UserCacheDir
Andrew Bonventre [Mon, 20 Nov 2017 18:36:22 +0000 (13:36 -0500)]
os: add UserCacheDir

Adds a function that returns an OS-dependent location
for user-specific cache data.

Fixes golang/go#22536

Change-Id: Ifff015452494571ad357fa2d945d66a5992c751d
Reviewed-on: https://go-review.googlesource.com/78835
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoVERSION: remove erroneously committed VERSION file
Brad Fitzpatrick [Tue, 13 Feb 2018 06:10:32 +0000 (06:10 +0000)]
VERSION: remove erroneously committed VERSION file

This file wasn't supposed to be checked in.

Change-Id: Ib0db0a330a3e030b0e6e5fde12088df5ac610ebc
Reviewed-on: https://go-review.googlesource.com/93555
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/asm: fix crash on bad symbol for TEXT
Rob Pike [Mon, 29 Jan 2018 00:28:17 +0000 (11:28 +1100)]
cmd/asm: fix crash on bad symbol for TEXT

Was missing a check in validSymbol.

Fixes #23580.

Can wait for go1.11. Probably safe but the crash is only for
invalid input, so not worth the risk.

Change-Id: I51f88c5be35a8880536147d1fe5c5dd6798c29de
Reviewed-on: https://go-review.googlesource.com/90398
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agodoc: fix typo in OverflowInt godoc
Mark Rushakoff [Tue, 13 Feb 2018 01:15:38 +0000 (01:15 +0000)]
doc: fix typo in OverflowInt godoc

Change-Id: I426310e0c05c2b4a0123299ade0fe11721d40b10
GitHub-Last-Rev: 651c0291d6f2561e3e179a0b97e0e73ac6d21e2f
GitHub-Pull-Request: golang/go#23801
Reviewed-on: https://go-review.googlesource.com/93475
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agogo/types: use consistent receiver names
Daniel Martí [Sun, 4 Feb 2018 09:25:55 +0000 (09:25 +0000)]
go/types: use consistent receiver names

Inconsistent names are quite obvious on the godoc HTML rendering:

type Array
    func NewArray(elem Type, len int64) *Array
    func (a *Array) Elem() Type
    func (a *Array) Len() int64
    func (t *Array) String() string
    func (t *Array) Underlying() Type

Fix all the String and Underlying methods to be consistent with their
types. This makes these two lists of methods less consistent, but that's
not visible to the user.

This also makes the inconsistent receiver names rule in golint happy.

Change-Id: I7c84d6bae1235887233a70d5f7f61a224106e952
Reviewed-on: https://go-review.googlesource.com/91736
Reviewed-by: Robert Griesemer <gri@golang.org>