1
0
mirror of https://github.com/golang/go synced 2024-09-25 03:20:13 -06:00
Commit Graph

37738 Commits

Author SHA1 Message Date
Matthew Dempsky
f7a633aa79 cmd/compile: use "N variables but M values" error for OAS
Makes the error message more consistent between OAS and OAS2.

Fixes #26616.

Change-Id: I07ab46c5ef8a37efb2cb557632697f5d1bf789f7
Reviewed-on: https://go-review.googlesource.com/131280
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-09-04 19:05:56 +00:00
Alessandro Arzilli
9c833831b2 cmd/link: move dwarf part of DWARF generation before type name mangling
Splits part of dwarfgeneratedebugsyms into a new function,
dwarfGenerateDebugInfo which is called between deadcode elimination
and type name mangling.
This function takes care of collecting and processing the DIEs for
all functions and package-level variables and also generates DIEs
for all types used in the program.

Fixes #23733

Change-Id: I75ef0608fbed2dffc3be7a477f1b03e7e740ec61
Reviewed-on: https://go-review.googlesource.com/111237
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2018-09-04 17:44:41 +00:00
Alexey Naidonov
669fa8f36a cmd/compile: remove unnecessary nil-check
Removes unnecessary nil-check when referencing offset from an
address. Suggested by Keith Randall in golang/go#27180.

Updates golang/go#27180

Change-Id: I326ed7fda7cfa98b7e4354c811900707fee26021
Reviewed-on: https://go-review.googlesource.com/131735
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-09-04 17:44:14 +00:00
Josh Bleecher Snyder
24e51bbe64 cmd/compile: prefer rematerializeable arg0 for HMUL
This prevents accidental regalloc regressions
that otherwise can occur from unrelated changes.

Change-Id: Iea356fb1a24766361fce13748dc1b46e57b21cea
Reviewed-on: https://go-review.googlesource.com/129375
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-09-04 14:57:03 +00:00
Josh Bleecher Snyder
2179e495ce encoding/binary: simplify Read and Write
There's no need to manually manage the backing slice for bs.
Removing it simplifies the code, removes some allocations,
and speeds it up slightly.

Fixes #27403

name                     old time/op    new time/op    delta
ReadSlice1000Int32s-8      6.39µs ± 1%    6.31µs ± 1%   -1.37%  (p=0.000 n=27+27)
ReadStruct-8               1.25µs ± 2%    1.23µs ± 2%   -1.06%  (p=0.003 n=30+29)
ReadInts-8                  301ns ± 0%     297ns ± 1%   -1.21%  (p=0.000 n=27+30)
WriteInts-8                 325ns ± 1%     320ns ± 1%   -1.59%  (p=0.000 n=26+29)
WriteSlice1000Int32s-8     6.60µs ± 0%    6.52µs ± 0%   -1.23%  (p=0.000 n=28+27)
PutUint16-8                0.72ns ± 2%    0.71ns ± 2%     ~     (p=0.286 n=30+30)
PutUint32-8                0.71ns ± 1%    0.71ns ± 0%   -0.42%  (p=0.003 n=30+25)
PutUint64-8                0.78ns ± 2%    0.78ns ± 0%   -0.55%  (p=0.001 n=30+27)
LittleEndianPutUint16-8    0.57ns ± 0%    0.57ns ± 0%     ~     (all equal)
LittleEndianPutUint32-8    0.57ns ± 0%    0.57ns ± 0%     ~     (all equal)
LittleEndianPutUint64-8    0.57ns ± 0%    0.57ns ± 0%     ~     (all equal)
PutUvarint32-8             23.1ns ± 1%    23.1ns ± 1%     ~     (p=0.925 n=26+29)
PutUvarint64-8             57.5ns ± 2%    57.3ns ± 1%     ~     (p=0.338 n=30+26)
[Geo mean]                 23.0ns         22.9ns        -0.61%

name                     old speed      new speed      delta
ReadSlice1000Int32s-8     626MB/s ± 1%   634MB/s ± 1%   +1.38%  (p=0.000 n=27+27)
ReadStruct-8             60.2MB/s ± 2%  60.8MB/s ± 2%   +1.08%  (p=0.002 n=30+29)
ReadInts-8                100MB/s ± 1%   101MB/s ± 1%   +1.24%  (p=0.000 n=27+30)
WriteInts-8              92.2MB/s ± 1%  93.6MB/s ± 1%   +1.56%  (p=0.000 n=26+29)
WriteSlice1000Int32s-8    606MB/s ± 0%   614MB/s ± 0%   +1.24%  (p=0.000 n=28+27)
PutUint16-8              2.80GB/s ± 1%  2.80GB/s ± 1%     ~     (p=0.095 n=28+29)
PutUint32-8              5.61GB/s ± 1%  5.62GB/s ± 1%     ~     (p=0.069 n=27+28)
PutUint64-8              10.2GB/s ± 1%  10.2GB/s ± 0%   +0.15%  (p=0.039 n=27+27)
LittleEndianPutUint16-8  3.50GB/s ± 1%  3.50GB/s ± 1%     ~     (p=0.552 n=30+29)
LittleEndianPutUint32-8  7.01GB/s ± 1%  7.02GB/s ± 1%     ~     (p=0.160 n=29+27)
LittleEndianPutUint64-8  14.0GB/s ± 1%  14.0GB/s ± 1%     ~     (p=0.413 n=29+29)
PutUvarint32-8            174MB/s ± 1%   173MB/s ± 1%     ~     (p=0.648 n=25+30)
PutUvarint64-8            139MB/s ± 2%   140MB/s ± 1%     ~     (p=0.271 n=30+26)
[Geo mean]                906MB/s        911MB/s        +0.55%

name                     old alloc/op   new alloc/op   delta
ReadSlice1000Int32s-8      4.14kB ± 0%    4.13kB ± 0%   -0.19%  (p=0.000 n=30+30)
ReadStruct-8                 200B ± 0%      200B ± 0%     ~     (all equal)
ReadInts-8                  64.0B ± 0%     32.0B ± 0%  -50.00%  (p=0.000 n=30+30)
WriteInts-8                  112B ± 0%       64B ± 0%  -42.86%  (p=0.000 n=30+30)
WriteSlice1000Int32s-8     4.14kB ± 0%    4.13kB ± 0%   -0.19%  (p=0.000 n=30+30)
PutUint16-8                 0.00B          0.00B          ~     (all equal)
PutUint32-8                 0.00B          0.00B          ~     (all equal)
PutUint64-8                 0.00B          0.00B          ~     (all equal)
LittleEndianPutUint16-8     0.00B          0.00B          ~     (all equal)
LittleEndianPutUint32-8     0.00B          0.00B          ~     (all equal)
LittleEndianPutUint64-8     0.00B          0.00B          ~     (all equal)
PutUvarint32-8              0.00B          0.00B          ~     (all equal)
PutUvarint64-8              0.00B          0.00B          ~     (all equal)
[Geo mean]                   476B           370B       -22.22%

name                     old allocs/op  new allocs/op  delta
ReadSlice1000Int32s-8        3.00 ± 0%      2.00 ± 0%  -33.33%  (p=0.000 n=30+30)
ReadStruct-8                 16.0 ± 0%      16.0 ± 0%     ~     (all equal)
ReadInts-8                   8.00 ± 0%      8.00 ± 0%     ~     (all equal)
WriteInts-8                  14.0 ± 0%      14.0 ± 0%     ~     (all equal)
WriteSlice1000Int32s-8       3.00 ± 0%      2.00 ± 0%  -33.33%  (p=0.000 n=30+30)
PutUint16-8                  0.00           0.00          ~     (all equal)
PutUint32-8                  0.00           0.00          ~     (all equal)
PutUint64-8                  0.00           0.00          ~     (all equal)
LittleEndianPutUint16-8      0.00           0.00          ~     (all equal)
LittleEndianPutUint32-8      0.00           0.00          ~     (all equal)
LittleEndianPutUint64-8      0.00           0.00          ~     (all equal)
PutUvarint32-8               0.00           0.00          ~     (all equal)
PutUvarint64-8               0.00           0.00          ~     (all equal)
[Geo mean]                   6.94           5.90       -14.97%

Change-Id: I3790b93e4190d98621d5f2c47e42929a18f56c2e
Reviewed-on: https://go-review.googlesource.com/133135
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-09-04 14:52:30 +00:00
Agniva De Sarker
e2e44a5d16 misc/wasm: handle error during instantiateStreaming
The same catch block is there in wasm_exec.js for node processes.
Added it in browser invocations too, to prevent uncaught exceptions.

Change-Id: Icab577ec585fa86df3c76db508b49401bcdb52ae
Reviewed-on: https://go-review.googlesource.com/132916
Reviewed-by: Richard Musiol <neelance@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-09-04 07:02:45 +00:00
Leigh McCulloch
db3f52db8e go/types: correct misspelling in function doc
The indirectType function comment uses the phrase 'layed out'. In the
context of that phrase, where something is being placed or sprawled,
the word should be 'laid'. 'Layed' is a misspelling of 'laid'.

Change-Id: I05ecb97637276e2252c47e92a0bd678130714889
GitHub-Last-Rev: 6ee67371b4
GitHub-Pull-Request: golang/go#27444
Reviewed-on: https://go-review.googlesource.com/132779
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-09-04 00:01:08 +00:00
Iskander Sharipov
67ac554d79 cmd/compile/internal/gc: fix invalid positions for sink nodes in esc.go
Make OAS2 and OAS2FUNC sink locations point to the assignment position,
not the nth LHS position.

Fixes #26987

Change-Id: Ibeb9df2da754da8b6638fe1e49e813f37515c13c
Reviewed-on: https://go-review.googlesource.com/129315
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-09-03 16:46:59 +00:00
Alexey Palazhchenko
5ed30d82b7 database/sql: fix Rows.Columns() documentation
Fixes #27202

Change-Id: I83620748a81500e433795c7b2b7f13399d17f777
GitHub-Last-Rev: 64457e12ce
GitHub-Pull-Request: golang/go#27472
Reviewed-on: https://go-review.googlesource.com/133057
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
2018-09-03 16:28:42 +00:00
Ivan Kutuzov
5188c87c95 encoding/pem: fix for TestFuzz, PEM type should not contain a colon
Fixes #22238

Change-Id: I8184f789bd4120f3e71c9374c7c2fcbfa95935bf
Reviewed-on: https://go-review.googlesource.com/132635
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-09-03 15:04:25 +00:00
Michael Munday
6f9b94ab66 cmd/compile: implement OnesCount{8,16,32,64} intrinsics on s390x
This CL implements the math/bits.OnesCount{8,16,32,64} functions
as intrinsics on s390x using the 'population count' (popcnt)
instruction. This instruction was released as the 'population-count'
facility which uses the same facility bit (45) as the
'distinct-operands' facility which is a pre-requisite for Go on
s390x. We can therefore use it without a feature check.

The s390x popcnt instruction treats a 64 bit register as a vector
of 8 bytes, summing the number of ones in each byte individually.
It then writes the results to the corresponding bytes in the
output register. Therefore to implement OnesCount{16,32,64} we
need to sum the individual byte counts using some extra
instructions. To do this efficiently I've added some additional
pseudo operations to the s390x SSA backend.

Unlike other architectures the new instruction sequence is faster
for OnesCount8, so that is implemented using the intrinsic.

name         old time/op  new time/op  delta
OnesCount    3.21ns ± 1%  1.35ns ± 0%  -58.00%  (p=0.000 n=20+20)
OnesCount8   0.91ns ± 1%  0.81ns ± 0%  -11.43%  (p=0.000 n=20+20)
OnesCount16  1.51ns ± 3%  1.21ns ± 0%  -19.71%  (p=0.000 n=20+17)
OnesCount32  1.91ns ± 0%  1.12ns ± 1%  -41.60%  (p=0.000 n=19+20)
OnesCount64  3.18ns ± 4%  1.35ns ± 0%  -57.52%  (p=0.000 n=20+20)

Change-Id: Id54f0bd28b6db9a887ad12c0d72fcc168ef9c4e0
Reviewed-on: https://go-review.googlesource.com/114675
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-09-03 14:35:38 +00:00
Iskander Sharipov
ff468a43be cmd/compile/internal/gc: better handling of self-assignments in esc.go
Teach escape analysis to recognize these assignment patterns
as not causing the src to leak:

	val.x = val.y
	val.x[i] = val.y[j]
	val.x1.x2 = val.x1.y2
	... etc

Helps to avoid "leaking param" with assignments showed above.
The implementation is based on somewhat similiar xs=xs[a:b]
special case that is ignored by the escape analysis.

We may figure out more generalized version of this,
but this one looks like a safe step into that direction.

Updates #14858

Change-Id: I6fe5bfedec9c03bdc1d7624883324a523bd11fde
Reviewed-on: https://go-review.googlesource.com/126395
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2018-09-03 14:28:51 +00:00
Charles Kenney
b794ca64d2 runtime/trace: fix syntax errors in NewTask doc example
Fixes #27406

Change-Id: I9c6f5bac5b26558fa7628233c74a62faf676e811
GitHub-Last-Rev: 29d19f7193
GitHub-Pull-Request: golang/go#27437
Reviewed-on: https://go-review.googlesource.com/132775
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-09-03 07:14:25 +00:00
Ankit Goyal
860484a15f strconv: add example for IsGraphic
Change-Id: I58ba1f5d5c942d6a345c19df1bca80b63fb5abf5
Reviewed-on: https://go-review.googlesource.com/132777
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-09-03 05:45:52 +00:00
Phil Pearl
317afdc3fb strings: simplify Join using Builder
The existing implementation has a bunch of special cases and
suffers an additional allocation for longer arrays. We can replace
this code with a simple implementation using Builder, improve
performance and reduce complexity.

name      old time/op    new time/op    delta
Join/0-8    3.53ns ± 3%    3.72ns ± 2%   +5.56%  (p=0.000 n=10+10)
Join/1-8    3.94ns ± 4%    3.40ns ± 4%  -13.57%  (p=0.000 n=10+10)
Join/2-8    57.0ns ± 3%    51.0ns ± 1%  -10.48%  (p=0.000 n=10+9)
Join/3-8    74.9ns ± 2%    65.5ns ± 4%  -12.60%  (p=0.000 n=10+10)
Join/4-8     105ns ± 0%      79ns ± 4%  -24.63%  (p=0.000 n=6+10)
Join/5-8     116ns ± 2%      91ns ± 4%  -21.95%  (p=0.000 n=10+10)
Join/6-8     131ns ± 1%     104ns ± 1%  -20.66%  (p=0.000 n=10+10)
Join/7-8     141ns ± 0%     114ns ± 4%  -18.82%  (p=0.000 n=9+10)

name      old alloc/op   new alloc/op   delta
Join/0-8     0.00B          0.00B          ~     (all equal)
Join/1-8     0.00B          0.00B          ~     (all equal)
Join/2-8     16.0B ± 0%     16.0B ± 0%     ~     (all equal)
Join/3-8     32.0B ± 0%     32.0B ± 0%     ~     (all equal)
Join/4-8     96.0B ± 0%     48.0B ± 0%  -50.00%  (p=0.000 n=10+10)
Join/5-8     96.0B ± 0%     48.0B ± 0%  -50.00%  (p=0.000 n=10+10)
Join/6-8      128B ± 0%       64B ± 0%  -50.00%  (p=0.000 n=10+10)
Join/7-8      128B ± 0%       64B ± 0%  -50.00%  (p=0.000 n=10+10)

name      old allocs/op  new allocs/op  delta
Join/0-8      0.00           0.00          ~     (all equal)
Join/1-8      0.00           0.00          ~     (all equal)
Join/2-8      1.00 ± 0%      1.00 ± 0%     ~     (all equal)
Join/3-8      1.00 ± 0%      1.00 ± 0%     ~     (all equal)
Join/4-8      2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.000 n=10+10)
Join/5-8      2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.000 n=10+10)
Join/6-8      2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.000 n=10+10)
Join/7-8      2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.000 n=10+10)

Change-Id: I866a50e809c398512cb87648c955eaa4bf4d8606
Reviewed-on: https://go-review.googlesource.com/132895
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-09-02 20:08:07 +00:00
Giovanni Bajo
dd5e9b32ff cmd/compile: add testcase for #24876
This is still not fixed, the testcase reflects that there are still
a few boundchecks. Let's fix the good alternative with an explicit
test though.

Updates #24876

Change-Id: I4da35eb353e19052bd7b69ea6190a69ced8b9b3d
Reviewed-on: https://go-review.googlesource.com/107355
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Giovanni Bajo <rasky@develer.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-09-02 10:34:51 +00:00
Giovanni Bajo
f02cc88f46 test: relax whitespaces matching in codegen tests
The codegen testsuite uses regexp to parse the syntax, but it doesn't
have a way to tell line comments containing checks from line comments
containing English sentences. This means that any syntax error (that
is, non-matching regexp) is currently ignored and not reported.

There were some tests in memcombine.go that had an extraneous space
and were thus effectively disabled. It would be great if we could
report it as a syntax error, but for now we just punt and swallow the
spaces as a workaround, to avoid the same mistake again.

Fixes #25452

Change-Id: Ic7747a2278bc00adffd0c199ce40937acbbc9cf0
Reviewed-on: https://go-review.googlesource.com/113835
Run-TryBot: Giovanni Bajo <rasky@develer.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-09-02 10:31:37 +00:00
Leigh McCulloch
c9cc20bd3a crypto/x509: revert change of article in SystemCertPool docs
The words 'the returned' were changed to 'a returned' in
8201b92aae when referring to the value
returned by SystemCertPool. Brad Fitz pointed out after that commit was
merged that it makes the wording of this function doc inconsistent with
rest of the stdlib since 'a returned' is not used anywhere, but 'the
returned' is frequently used.

Fixes #27385

Change-Id: I289b533a5a0b5c63eaf0abb6dec0085388ecf76b
GitHub-Last-Rev: 6c83b80257
GitHub-Pull-Request: golang/go#27438
Reviewed-on: https://go-review.googlesource.com/132776
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-09-01 15:43:42 +00:00
Giovanni Bajo
1d15354fb9 os/exec: document how to do special args quoting on Windows
Updates #27199

Change-Id: I5cb6540266901697d3558ce75b8de63b1bfc2ce0
Reviewed-on: https://go-review.googlesource.com/132695
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2018-09-01 04:45:46 +00:00
Muhammad Falak R Wani
579768e078 fmt: add example for Fscanln
Updates golang/go#27376.

Change-Id: I9f33233f1aafa10941a63fcb4e49d351ea7ee246
Reviewed-on: https://go-review.googlesource.com/132675
Reviewed-by: Kevin Burke <kev@inburke.com>
Run-TryBot: Kevin Burke <kev@inburke.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-31 19:05:37 +00:00
Venil Noronha
4d01f9243c fmt: add example for Fscanf
Change-Id: Ia3dcb3a82e452fdcf0d087e8cd01ac01ca831c84
Reviewed-on: https://go-review.googlesource.com/132597
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Kevin Burke <kev@inburke.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
2018-08-31 18:27:09 +00:00
Than McIntosh
88206b8931 test: improve runtime/pprof tests for gccgo
In the CPU profile tests for gccgo, check to make sure that the
runtime's sigprof handler itself doesn't appear in the profile. Add a
"skip if gccgo" guard to one testpoint.

Updates #26595

Change-Id: I92a44161d61f17b9305ce09532134edd229745a7
Reviewed-on: https://go-review.googlesource.com/126316
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-31 13:54:24 +00:00
Carlos Eduardo Seo
dbd8af7472 runtime: add support for VDSO on ppc64x for use in walltime/nanotime
This change adds support for VDSO on ppc64x, making it possible to
avoid a syscall in walltime and nanotime.

BenchmarkClockVDSOAndFallbackPaths/vDSO-192             20000000    66.0 ns/op
BenchmarkClockVDSOAndFallbackPaths/Fallback-192          1000000    1456 ns/op

Change-Id: I3373bd804b6f122961de3ae9d034e6ccf35748e6
Reviewed-on: https://go-review.googlesource.com/131135
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2018-08-31 13:12:31 +00:00
Alex Brainman
8359b5e134 internal/poll: advance file position in windows sendfile
Some versions of Windows (Windows 10 1803) do not set file
position after TransmitFile completes. So just use Seek
to set file position before returning from sendfile.

Fixes #25722

Change-Id: I7a49be10304b5db19dda707b13ac93d338aeb190
Reviewed-on: https://go-review.googlesource.com/131976
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Yasuhiro MATSUMOTO <mattn.jp@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-31 09:16:02 +00:00
Giovanni Bajo
09ea3c08e8 cmd/compile: in prove, fix fence-post implications for unsigned domain
Fence-post implications of the form "x-1 >= w && x > min ⇒ x > w"
were not correctly handling unsigned domain, by always checking signed
limits.

This bug was uncovered once we taught prove that len(x) is always
>= 0 in the signed domain.

In the code being miscompiled (s[len(s)-1]), prove checks
whether len(s)-1 >= len(s) in the unsigned domain; if it proves
that this is always false, it can remove the bound check.

Notice that len(s)-1 >= len(s) can be true for len(s) = 0 because
of the wrap-around, so this is something prove should not be
able to deduce.

But because of the bug, the gate condition for the fence-post
implication was len(s) > MinInt64 instead of len(s) > 0; that
condition would be good in the signed domain but not in the
unsigned domain. And since in CL105635 we taught prove that
len(s) >= 0, the condition incorrectly triggered
(len(s) >= 0 > MinInt64) and things were going downfall.

Fixes #27251
Fixes #27289

Change-Id: I3dbcb1955ac5a66a0dcbee500f41e8d219409be5
Reviewed-on: https://go-review.googlesource.com/132495
Reviewed-by: Keith Randall <khr@golang.org>
2018-08-31 08:54:38 +00:00
Dina Garmash
8a2b5f1f39 doc: fix os.Pipe() call in the example.
Short variable declarations example passes an fd argument to os.Pipe call.
However, os.Pipe() takes no arguments and returns 2 Files and an error:
https://golang.org/src/os/pipe_linux.go?s=319:360#L1

Fixes: #27384

Change-Id: I0a709f51e0878c57185d901b899d209f001dfcce
Reviewed-on: https://go-review.googlesource.com/132284
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-08-31 06:39:16 +00:00
Drew Flower
58e970ed79 fmt: add an example for Sprintln
Change-Id: I0fcb5e626bf3d6891592c21b912c824743d7eaa0
Reviewed-on: https://go-review.googlesource.com/132280
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-31 03:52:48 +00:00
Rhys Hiltner
677c4acc98 doc: recommend benchstat for performance commits
The benchstat tool computes statistics about benchmarks, including
whether any differences are statistically significant. Recommend its use
in commit messages of performance-related changes rather than the
simpler benchcmp tool.

Change-Id: I4b35c2d892b48e60c3064489b035774792c19c30
Reviewed-on: https://go-review.googlesource.com/132515
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-31 03:52:31 +00:00
Venil Noronha
7c96f9b527 A+C: add VMware as author, Venil Noronha as contributor
Change-Id: I0dd843ac06f1b9987aa2fc90ae62074e668d6d4d
Reviewed-on: https://go-review.googlesource.com/132438
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-31 02:14:24 +00:00
Rodolfo Rodriguez
eeb2a11eea fmt: add Println example
Change-Id: Ifd509c0c6a6ea41094b6ae1f4931414325b152fd
Reviewed-on: https://go-review.googlesource.com/132475
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-31 00:43:12 +00:00
Robert Griesemer
770e37d249 go/types: better names for internal helper functions (cleanup)
Internal helper functions for type-checking type expressions were
renamed to make it clearer when they should be used:

	typExpr (w/o def) -> typ
	typExpr (w/  def) -> definedType
	typ               -> indirectType
	typExprInternal   -> typInternal

The rename emphasizes that in most cases Checker.typ should be used
to compute the types.Type from an ast.Type. If the type is defined,
definedType should be used. For composite type elements which are
not "inlined" in memory, indirectType should be used.

In the process, implicitly changed several uses of indirectType
(old: typ) to typ (old: typExpr) by not changing the respective
function call source. These implicit changes are ok in those
places because either call is fine where we are not concerned
about composite type elements. But using typ (old: typExpr) is
more efficient than using indirectType (old: typ).

Change-Id: I4ad14d5357c5f94b6f1c33173de575c4cd05c703
Reviewed-on: https://go-review.googlesource.com/130595
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-08-30 22:54:39 +00:00
Robert Griesemer
43469ddf74 go/types: remove explicit path parameter from most type-checker functions (cleanup)
Now that most of the type-checker is using the object-coloring mechanism
to detect cycles, remove the explicit path parameter from the functions
that don't rely on it anymore.

Some of the syntactic-based resolver code (for aliases, interfaces)
still use an explicit path; leaving those unchanged for now.

The function cycle was moved from typexpr.go (where it is not used
anymore) to resolver.go (where it's still used). It has not changed.

Fixes #25773.

Change-Id: I2100adc8d66d5da9de9277dee94a1f08e5a88487
Reviewed-on: https://go-review.googlesource.com/130476
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-08-30 22:54:34 +00:00
Robert Griesemer
ce2e883afc go/types: track local cycles using same mechanism as for global objects
For Go 1.11, cycle tracking of global (package-level) objects was changed
to use a Checker-level object path rather than relying on the explicit
path parameter that is passed around to some (but not all) type-checker
functions.

This change now uses the same mechanism for the detection of local
type cycles (local non-type objects cannot create cycles by definition
of the spec).

As a result, local alias cycles are now correctly detected as well
(issue #27106).

The path parameter that is explicitly passed around to some type-checker
methods is still present and will be removed in a follow-up CL.

Also:
- removed useCycleMarking flag and respective dead code
- added a couple more tests
- improved documentation

Fixes #27106.
Updates #25773.

Change-Id: I7cbf304bceb43a8d52e6483dcd0fa9ef7e1ea71c
Reviewed-on: https://go-review.googlesource.com/130455
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-08-30 22:54:29 +00:00
Andrew Bonventre
5ac2476748 cmd/compile: make math/bits.RotateLeft* an intrinsic on amd64
Previously, pattern matching was good enough to achieve good performance
for the RotateLeft* functions, but the inlining cost for them was much
too high. Make RotateLeft* intrinsic on amd64 as a stop-gap for now to
reduce inlining costs.

This should be done (or at least looked at) for other architectures
as well.

Updates golang/go#17566

Change-Id: I6a106ff00b6c4e3f490650af3e083ed2be00c819
Reviewed-on: https://go-review.googlesource.com/132435
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2018-08-30 22:48:28 +00:00
Leigh McCulloch
8201b92aae crypto/x509: clarify docs for SystemCertPool
The sentence in the docs for SystemCertPool that states that mutations
to a returned pool do not affect any other pool is ambiguous as to who
the any other pools are, because pools can be created in multiple ways
that have nothing to do with the system certificate pool. Also the use
of the word 'the' instead of 'a' early in the sentence implies there is
only one shared pool ever returned.

Fixes #27385

Change-Id: I43adbfca26fdd66c4adbf06eb85361139a1dea93
GitHub-Last-Rev: 2f1ba09fa4
GitHub-Pull-Request: golang/go#27388
Reviewed-on: https://go-review.googlesource.com/132378
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2018-08-30 22:13:10 +00:00
Kevin Burke
3eb0b2e80d fmt: remove spelling mistake in example
"someting" is misspelled and the error handling both clobbers the
error that occurs and distracts from the point of the example, which
is to demonstrate how Printf works. It's better to just panic with the
error.

Change-Id: I5fb0a4a1a8b4772cbe0302582fa878d95e3a4060
Reviewed-on: https://go-review.googlesource.com/132376
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-30 21:59:03 +00:00
Agniva De Sarker
04bee23014 cmd/dist: wait for run jobs to finish in case of a compiler error
Instead of calling run synchronously, we pass it through bgrun
and immediately wait for it to finish. This pushes all jobs
to execute through the bgwork channel and therefore causes
them to exit cleanly in case of a compiler error.

Fixes #25981

Change-Id: I789a85d23fabf32d144ab85a3c9f53546cb7765a
Reviewed-on: https://go-review.googlesource.com/127776
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-30 21:11:54 +00:00
Rebecca Stambler
6c0b8b5f8c go/types: fix crash following misuse of [...]T in composite literal
The type-checker currently crashes when checking code such as:

	_ = map[string][...]int{"": {1, 2, 3}}

In this case, the type checker reports an error for map[string][...]int,
then proceeds to type-check the values of the map literal using a hint
type of [...]int. When type-checking the inner composite (array) literal,
the length of the open array type is computed from the elements,
then the array type is recorded, but the literal has no explicit type
syntax against which to record the type, so this code causes the
type-checker to panic. Add a nil check before calling
check.recordTypeAndValue to avoid that.

Updates #22467

Change-Id: Ic4453ba485b7b88ede2a89f209365eda9e032abc
Reviewed-on: https://go-review.googlesource.com/132355
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-08-30 21:07:35 +00:00
Andrei Tudor Călin
bd49b3d580 net: refactor readerAtEOF splice test
Refactor TestSplice/readerAtEOF to handle cases where we disable
splice on older kernels better.

If splice is disabled, net.splice and poll.Splice do not get to
observe EOF on the reader, because poll.Splice returns immediately
with EINVAL. The test fails unexpectedly, because the splice operation
is reported as not handled.

This change refactors the test to handle the aforementioned case
correctly, by not calling net.splice directly, but using a higher
level check.

Fixes #27355.

Change-Id: I0d5606b4775213f2dbbb84ef82ddfc3bab662a31
Reviewed-on: https://go-review.googlesource.com/132096
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-30 20:24:01 +00:00
Dylan Waits
796e4bdc6b fmt: add example for Fprintln
Change-Id: Idc4aa53e443b89eeba496d00f6b409268e29ec21
Reviewed-on: https://go-review.googlesource.com/132241
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-30 20:12:14 +00:00
ianzapolsky
d5c7abf73a fmt: add an example for Errorf
The errors package has an example for Errorf, but the fmt
package does not. Copy the Errorf example from errors to
fmt. Move existing Stringer example into separate file, so as
not to break the assumption that the entire file will be
presented as the example.

Change-Id: I8a210a69362017fa08615a8c3feccdeee8427e22
Reviewed-on: https://go-review.googlesource.com/132239
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-30 19:40:13 +00:00
Venil Noronha
e84409ac95 time: add example for LoadLocation
Change-Id: I8e55e9397eb6844b5856f8bde9c26185c446a80e
Reviewed-on: https://go-review.googlesource.com/132238
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-30 19:38:38 +00:00
Dmitry Neverov
a2a8396f53 html/template: add an example for the Delims method
Change-Id: I7ba55e3f6ebbaae41188316a66a40f994c037ad9
Reviewed-on: https://go-review.googlesource.com/132240
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-30 19:36:15 +00:00
Erin Masatsugu
5e755e9d6d bytes: add example for Buffer.Len
Change-Id: Ide50aba940727a7b32cd33dea5315050f1a34717
Reviewed-on: https://go-review.googlesource.com/132237
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-30 19:10:14 +00:00
David Timm
0dac1e2e87 net/http: add example for http.HandleFunc
Change-Id: Id0e2fb2abad5b776ac0ed76e55e36c6b774b5b7a
Reviewed-on: https://go-review.googlesource.com/132278
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-30 19:02:30 +00:00
Venil Noronha
d3b9572759 fmt: add an example for Sprintf
Signed-off-by: Venil Noronha <veniln@vmware.com>

Change-Id: Ie5f50bc31db1eee11582b70b0e25c726090d4037
Reviewed-on: https://go-review.googlesource.com/132236
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-30 18:56:34 +00:00
G. Hussain Chinoy
f882d89b76 ghchinoy: add example for ioutil.WriteFile
Change-Id: I65c3bda498562fdf39994ec1cadce7947e2d84b5
Reviewed-on: https://go-review.googlesource.com/132277
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2018-08-30 18:38:34 +00:00
Cherry Zhang
360771e422 cmd/compile: don't clobber dead slots in runtime.wbBufFlush
runtime.wbBufFlush must not modify its arguments, because the
argument slots are also used as spill slots in runtime.gcWriteBarrier.
So, GOEXPERIMENT=clobberdead must not clobber them.

Updates #27326.

Change-Id: Id02bb22a45201eecee748d89e7bdb3df7e4940e4
Reviewed-on: https://go-review.googlesource.com/131957
Reviewed-by: Keith Randall <khr@golang.org>
2018-08-30 18:27:20 +00:00
Cherry Zhang
c8545722a1 cmd/compile: only clobber dead slots at call sites
We now have safepoints at nearly all the instructions. When
GOEXPERIMENT=clobberdead is on, it inserts clobbers nearly at
every instruction. Currently this doesn't work. (Maybe the stack
maps at non-call safepoints are still imprecise. I haven't
investigated.) For now, only use call-based safepoints if the
experiment is on.

Updates #27326.

Change-Id: I72cda9b422d9637cc5738e681502035af7a5c02d
Reviewed-on: https://go-review.googlesource.com/131956
Reviewed-by: Keith Randall <khr@golang.org>
2018-08-30 18:27:08 +00:00
Rebecca Stambler
c99687f87a go/types: handle nil pointer when panic is written outside of a function
The current implementation crashes when someone writes a panic outside of
a function, which makes sense since that is broken code. This fix allows
one to type-check broken code.

Updates #22467

Change-Id: I81b90dbd918162a20c60a821340898eaf02e648d
Reviewed-on: https://go-review.googlesource.com/132235
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-08-30 16:53:43 +00:00