1
0
mirror of https://github.com/golang/go synced 2024-11-05 18:36:10 -07:00
Commit Graph

41128 Commits

Author SHA1 Message Date
spacewander
4a457e3edc net/http: merge IsDir checks in fs.go's serveFile function
Fixes #33385

Change-Id: I497ccd868d408a9c5648c72aa5ce41221368daf4
GitHub-Last-Rev: 3bf483808e
GitHub-Pull-Request: golang/go#33423
Reviewed-on: https://go-review.googlesource.com/c/go/+/188677
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-02 11:13:03 +00:00
itchyny
7450960a13 encoding/json: fix scanner byte offset on scanEnd
scanEnd is delayed one byte so we decrement
the scanner bytes count by 1 to ensure that
this value is correct in the next call of Decode.

Fixes #32399

Change-Id: I8c8698e7f95bbcf0373aceaa05319819eae9d86f
GitHub-Last-Rev: 0ac25d8de2
GitHub-Pull-Request: golang/go#32598
Reviewed-on: https://go-review.googlesource.com/c/go/+/182117
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-02 11:00:29 +00:00
Derek Phan
9c295bdeab net/http: remove redundant port validation
The URL port is already checked in net/url, so we can remove the redundant validation in net/http.

Fixes #33600

Change-Id: I62511a452df6262d4b66180933758d34627ff9df
GitHub-Last-Rev: c19afa3102
GitHub-Pull-Request: golang/go#33611
Reviewed-on: https://go-review.googlesource.com/c/go/+/190057
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-02 09:45:08 +00:00
LE Manh Cuong
fa7d40abe0 cmd/link: always set .dynsym info field
CL 187979 added set .dynsym info field, but it won't when
there are no global symbols. This CL sets that field
unconditionally.

Fixes #34000

Change-Id: Icc2f8bc74afdade88a377793e6760912b03686ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/192600
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-09-01 23:59:23 +00:00
Tom Thorogood
79669dc705 encoding/json: revert Compact HTML escaping documentation
This partly reverts CL 173417 as it incorrectly documented that Compact
performed HTML escaping and the output was safe to embed inside HTML
<script> tags. This has never been true.

Although Compact does escape U+2028 and U+2029, it doesn't escape <, >
or &. Compact is thus only performing a subset of HTML escaping and it's
output is not safe to embed inside HTML <script> tags.

A more complete fix would be for Compact to either never perform any
HTML escaping, as it was prior to CL 10883045, or to actually perform
the same HTML escaping as HTMLEscape. Neither change is likely safe
enough for go1.13.

Updates #30357

Change-Id: I912f0fe9611097d988048b28228c4a5b985080ba
GitHub-Last-Rev: aebababc92
GitHub-Pull-Request: golang/go#33427
Reviewed-on: https://go-review.googlesource.com/c/go/+/188717
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-01 16:43:30 +00:00
William Poussier
85f3ca7488 encoding/json: fix panic for nil instances of TextMarshaler in map keys
This change adds a a check in the encodeWithString.resolve method
to ensure that a reflect.Value with kind Ptr is not nil before
the type assertion to TextMarshaler.

If the value is nil, the method returns a nil error, and the map key
encodes to an empty string.

Fixes #33675

Change-Id: I0a04cf690ae67006f6a9c5f8cbb4cc99d236bca8
GitHub-Last-Rev: 6c987c9084
GitHub-Pull-Request: golang/go#33700
Reviewed-on: https://go-review.googlesource.com/c/go/+/190697
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2019-09-01 16:39:38 +00:00
Alex Gaynor
a806c213e7 doc: make the draft 1.13 release notes expected release date accurate
Change-Id: I17148bb2b8021ed305ed0d230675d51c41736a11
GitHub-Last-Rev: 2998d46d10
GitHub-Pull-Request: golang/go#34004
Reviewed-on: https://go-review.googlesource.com/c/go/+/192797
Reviewed-by: Ingo Oeser <nightlyone@googlemail.com>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2019-09-01 16:37:25 +00:00
Alberto Donizetti
e6d2544d20 test/codegen: mention -all_codegen in the README
For performance reasons (avoiding costly cross-compilations) CL 177577
changed the codegen test harness to only run the tests for the
machine's GOARCH by default.

This change updates the codegen README accordingly, explaining what
all.bash does run by default and how to perform the tests for all
architectures.

Fixes #33924

Change-Id: I43328d878c3e449ebfda46f7e69963a44a511d40
Reviewed-on: https://go-review.googlesource.com/c/go/+/192619
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2019-09-01 15:37:13 +00:00
Daniel Martí
c51909e3a5 cmd/compile: remove a few unused bits of code
Just the low-hanging fruit; code that was either never used, or its last
use was removed a while ago.

Change-Id: Ic7f90aeee3e6daf7edc16cde3c0a767d67e617ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/192618
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-01 14:25:12 +00:00
Andrew Bonventre
99df76f086 mime: update type of .js and .mjs files to text/javascript
application/javascript is being deprecated per
https://datatracker.ietf.org/doc/draft-ietf-dispatch-javascript-mjs/

Specify a charset to be consistent with other text/* mime types.

Fixes #32351

Change-Id: I7300f6cfdbcf574103764991cb75172a252a3400
Reviewed-on: https://go-review.googlesource.com/c/go/+/186927
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2019-09-01 10:08:53 +00:00
Irbe Krumina
54a9c16533 path: change the output format of ExampleSplit function
At the moment the last output line of ExampleSplit- two empty strings- are being
trimmed from the output.  I have formatted the output of the function to avoid
whitespace trimming and show empty strings more clearly.

Fixes #23542

Change-Id: Ic2a4d98cfa06db1466c6c6d98099542df9e7c88b
Reviewed-on: https://go-review.googlesource.com/c/go/+/191397
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2019-09-01 10:08:36 +00:00
jsign
d15dfdc023 io/ioutil: don't check for short write in WriteFile
*os.File already does it.

Fixes #33064

Change-Id: I3edf0a31bf6d6e5023f47f01ebc92ed057357278
GitHub-Last-Rev: e6a5ba45d7
GitHub-Pull-Request: golang/go#33065
Reviewed-on: https://go-review.googlesource.com/c/go/+/185857
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-01 02:31:50 +00:00
Ou Changkun
d6143914e4 runtime: remove outdated comment in select sortkey
This CL removes an outdated comment regarding converting a pointer to `uintptr`.
The comment was introduced in Go 1.4 and runtime GC was under the consideration of major revisions. According to the current situation, Go runtime memory allocator has no fragmentation issue. Therefore compact GC won't be implemented in the near future.

Change-Id: I5c336d81d810cf57b76797f05428421bb39a5b9f
GitHub-Last-Rev: 2ab4be3885
GitHub-Pull-Request: golang/go#33685
Reviewed-on: https://go-review.googlesource.com/c/go/+/190520
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-01 00:05:48 +00:00
Brian Kessler
b003afe4fe cmd/compile: intrinsify RotateLeft32 on wasm
wasm has 32-bit versions of all integer operations. This change
lowers RotateLeft32 to i32.rotl on wasm and intrinsifies the math/bits
call.  Benchmarking on amd64 under node.js this is ~25% faster.

node v10.15.3/amd64
name          old time/op  new time/op  delta
RotateLeft    8.37ns ± 1%  8.28ns ± 0%   -1.05%  (p=0.029 n=4+4)
RotateLeft8   11.9ns ± 1%  11.8ns ± 0%     ~     (p=0.167 n=5+5)
RotateLeft16  11.8ns ± 0%  11.8ns ± 0%     ~     (all equal)
RotateLeft32  11.9ns ± 1%   8.7ns ± 0%  -26.32%  (p=0.008 n=5+5)
RotateLeft64  8.31ns ± 1%  8.43ns ± 2%     ~     (p=0.063 n=5+5)

Updates #31265

Change-Id: I5b8e155978faeea536c4f6427ac9564d2f096a46
Reviewed-on: https://go-review.googlesource.com/c/go/+/182359
Run-TryBot: Brian Kessler <brian.m.kessler@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Richard Musiol <neelance@gmail.com>
2019-08-31 17:03:04 +00:00
LE Manh Cuong
12dbd20a50 cmd/link: set .dynsym info field
.dynsym section info field is the index of first non-local symbol, mean
the number of local symbols.

The go linker have never ever set it before, so just set it.

Fixes #33358

Change-Id: Ifde2deb7c15471b04d565861f5d81daffb0c0d3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/187979
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-08-31 15:49:08 +00:00
Jason A. Donenfeld
c96d794f66 ld: ensure that PE versions sync for internal and external linkage
Previously users who opted into cgo might have received a bit of a
behavior surprise when their mingw installation defaulted to a
potentially older and different set of compatibility hacks. Since Go is
explicitly targeting >=6.1 for internal linkage, propagate these changes
to external linkage too.

While we're at it, we move these values into constant variables so that
they don't become out of sync and allow for easy updating as Go
gradually drops compatibility for older operating systems.

Change-Id: I41e654d135be6e3db9088e73efeb414933e36caa
Reviewed-on: https://go-review.googlesource.com/c/go/+/191842
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-08-31 14:56:29 +00:00
Jason A. Donenfeld
8fc35238a7 ld: mark PE executables as terminal services aware
This has been the default in MSVC for a very long time, and it's hard to
imagine modern programs actually wanting the old legacy behavior. For
example, no modern programs try to install their junk into C:\windows
and therefore need to have an emulated writable windows directory.
That's not really even allowed by ACLs on modern systems.

Change-Id: Iadaca6815e39ea5c6b05c1cac5a95cfc35e5b48a
Reviewed-on: https://go-review.googlesource.com/c/go/+/191840
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-08-31 14:54:31 +00:00
Elias Naur
2afe9d4dec runtime: don't forward SIGPIPE on macOS
macOS and iOS deliver SIGPIPE signals to the main thread and not
the thread that raised it by writing to a closed socket or pipe.

SIGPIPE signals can be suppressed for sockets with the SO_NOSIGPIPE
option, but there is no similar option for pipes. We have no other
choice but to never forward SIGPIPE on macOS.

This is a fixup of reverted CL 188297.

Fixes #33384

Change-Id: I09b258b078857ad3b22025bc2902d1b12d2afd92
Reviewed-on: https://go-review.googlesource.com/c/go/+/191785
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-08-31 06:19:40 +00:00
OlgaVlPetrova
9f85668a65 cmd/compile/internal/ssa: simplify s = s <op> x to s <op>= x
Change-Id: I366b89e35d194ca2a7eb97a8253497bd3fc2af94
Reviewed-on: https://go-review.googlesource.com/c/go/+/142019
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-08-31 02:52:13 +00:00
Eli Bendersky
d47526ed77 test2json: default to "pass" when the test doesn't report failures
When a test has a TestMain that doesn't run any tests (doesn't invoke
m.Run), `go test` passes, but `go test -json` reports a "fail" event
though the exit code is still 0.

This CL fixes test2json to behave similarly to `go test` in such cases -
no output from the test is taken as "pass" by default, not as "fail".

Fixes #31969

Change-Id: I1829d40fc30dc2879e73974fac416f6a34212ccd
Reviewed-on: https://go-review.googlesource.com/c/go/+/192104
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-08-31 01:06:32 +00:00
Emmanuel Odeke
bac5b3f0fe os: skip TestPipeThreads on GOOS=darwin
Updates #32326.
Updates #33953.

Change-Id: I97a1cbe682becfe9592e19294d4d94f5e5b16c21
Reviewed-on: https://go-review.googlesource.com/c/go/+/192342
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-08-31 00:57:57 +00:00
Simon Ferquel
e5e5fb024a runtime: do not crash in lastcontinuehandler when running as DLL
If Go DLL is used by external C program, and lastcontinuehandler
is reached, lastcontinuehandler will crash the process it is
running in.

But it should not be up to Go runtime to decide if process to be
crashed or not - it should be up to C runtime. This CL adjusts
lastcontinuehandler to not to crash when running as DLL.

Fixes #32648.

Change-Id: Ia455e69b8dde2a6f42f06b90e8af4aa322ca269a
GitHub-Last-Rev: dbdffcb432
GitHub-Pull-Request: golang/go#32574
Reviewed-on: https://go-review.googlesource.com/c/go/+/181839
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-08-31 00:47:27 +00:00
Ben Shi
1786ecd502 cmd/compile: eliminate WASM's redundant extension & wrapping
This CL eliminates unnecessary pairs of I32WrapI64 and
I64ExtendI32U generated by the WASM backend for IF
statements. And it makes the total size of pkg/js_wasm/
decreases about 490KB.

Change-Id: I16b0abb686c4e30d5624323166ec2d0ec57dbe2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/191758
Run-TryBot: Ben Shi <powerman1st@163.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Richard Musiol <neelance@gmail.com>
2019-08-30 21:20:03 +00:00
Cherry Zhang
cd03fd05b5 runtime: remove unnecessary variable decls in asm.s
runtime/asm.s contains two variable declarations that don't seem
needed. The variables are defined in Go and not referenced in
assembly. They were added in 2014 during the C to Go transition.
Maybe they were useful at that time, but not now. Remove them.

Change-Id: Id00d724813d18db47126c2f2b8cacfc9d77ffd4b
Reviewed-on: https://go-review.googlesource.com/c/go/+/192378
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2019-08-30 20:41:54 +00:00
David Chase
b177d8802c cmd/compile: print lines missing is_stmt if testing.Verbose()
helpful for debugging failures to figure out which lines
disappeared to cause the failure.

Change-Id: Id42b64a65f76eed47e01003f05346bc09cec27e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/188019
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-08-30 20:11:59 +00:00
micnncim
4219aec60a syscall: fix duplicate comments
Removed repetitions of "the" in some comments.

Change-Id: I36a6f51609765076de32e1b97398c4c08743aafc
GitHub-Last-Rev: 4d06aea6a7
GitHub-Pull-Request: golang/go#33797
Reviewed-on: https://go-review.googlesource.com/c/go/+/191497
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-08-30 19:28:35 +00:00
Ben Shi
8d5197d818 cmd/compile: optimize 386's math.bits.TrailingZeros16
This CL reverts CL 192097 and fixes the issue in CL 189277.

Change-Id: Icd271262e1f5019a8e01c91f91c12c1261eeb02b
Reviewed-on: https://go-review.googlesource.com/c/go/+/192519
Run-TryBot: Ben Shi <powerman1st@163.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-08-30 17:37:00 +00:00
zdjones
ba068c1a6f cmd/compile: rename poset method dominates to reaches
The partially ordered set uses a method named 'dominates' to determine whether
two nodes are partially ordered. Dominates does a depth-first search of the
DAG, beginning at the source node, and returns true as soon as it finds a path
to the target node. In the context of the forest-of-DAGs that makes up the
poset, dominates is not necessarily checking dominance, but is checking
reachability. See the issue tracker for a more detailed discussion of the
difference.

Fortunately, reachability is logically correct everywhere dominates is currently
used in poset.go. Reachability within a DAG is sufficient to establish the
partial ordering (source < target).

This CL changes the name of the method (dominates -> reaches) and updates
all the comments in the file accordingly.

Fixes #33971.

Change-Id: Ia3a34f7b14b363801d75b05099cfc686035f7d96
Reviewed-on: https://go-review.googlesource.com/c/go/+/192617
Reviewed-by: Giovanni Bajo <rasky@develer.com>
Run-TryBot: Giovanni Bajo <rasky@develer.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-30 17:22:14 +00:00
Rhys Hiltner
9d480edadc cmd/cover: skip go list when profile is empty
Only call "go list" when explicitly listing packages. An empty coverage
profile references no packages, and would otherwise lead to "go list"
implicitly looking at the package in "." (which might not exist).

Fixes #33855

Change-Id: I02d4e374405d86f03d105fe14648aa03b4d2284c
Reviewed-on: https://go-review.googlesource.com/c/go/+/192340
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-30 17:07:53 +00:00
Clément Chigot
87113f7ead syscall: fix coredump bit for aix/ppc64
Change-Id: I92173c3b5f842b829aac7c4d7abbe8b5113e530a
Reviewed-on: https://go-review.googlesource.com/c/go/+/191787
Run-TryBot: Clément Chigot <clement.chigot@atos.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-08-30 14:30:26 +00:00
Jason A. Donenfeld
d85072ff86 runtime: monitor for suspend/resume to kick timeouts
Starting in Windows 8, the wait functions don't take into account
suspend time, even though the monotonic counters do. This results in
timer buckets stalling on resume. Therefore, this commit makes it so
that on resume, we return from the wait functions and recalculate the
amount of time left to wait.

Fixes: #31528

Change-Id: I0db02cc72188cb620954e87a0180e0a3c83f4a56
Reviewed-on: https://go-review.googlesource.com/c/go/+/191957
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-08-30 14:20:49 +00:00
Ben Shi
8c5de667d3 cmd/compile: update README for rulegen
Update cmd/compile/internal/ssa/gen/README, suggest using go-1.13
and above for rulegen.

Change-Id: I5256d6f1bb4273b5eb7d5122a4364add52fc42c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/192517
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-30 08:28:40 +00:00
Tobias Klauser
3ff590ebf5 cmd/compile: regenerate known formats in fmtmap_test.go
This fixes TestFormats after CL 192278.

Change-Id: I7ffb8f76b4f6469d1b161d41687306e0d9e7abd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/191786
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-30 08:19:45 +00:00
Keith Randall
579c69ac1c internal/fmtsort: don't out-of-bounds panic if there's a race condition
Raising an out-of-bounds panic is confusing. There's no indication
that the underlying problem is a race.

The runtime already does a pretty good job of detecting this kind of
race (modification while iterating). We might as well just reorganize
a bit to avoid the out-of-bounds panic.

Fixes #33275

Change-Id: Icdd337ad2eb3c84f999db0850ec1d2ff2c146b6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/191197
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
2019-08-30 05:41:23 +00:00
Keith Randall
f484e9699d runtime: use all 64 bits of hash seed on arm64
Fixes #33960

Change-Id: I4f8cf65dcf4140a97e7b368572b31c171c453316
Reviewed-on: https://go-review.googlesource.com/c/go/+/192498
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-08-30 00:10:31 +00:00
Robert Griesemer
5411953df5 cmd/compile: avoid follow-on errors for literals with syntax errors
- only convert literal strings if there were no syntax errors
  (some of the conversion routines exit if there is an error)
- mark nodes for literals with syntax errors to avoid follow-on
  errors
- don't attempt to import packages whose path had syntax errors

Fixes #32133.

Change-Id: I1803ad48c65abfecf6f48ddff1e27eded5e282c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/192437
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-08-29 23:37:07 +00:00
Robert Griesemer
117400ec09 cmd/compile/internal/syntax: add BasicLit.Bad field for lexical errors
The new (internal) field scanner.bad indicates whether a syntax error
occurred while scanning a literal; the corresponding scanner.lit
string may be syntactically incorrect in that case. Store the value
of scanner.bad together with the scanner.lit in BasicLit.

Clean up error handling so that all syntactic errors use one of the
scanner's error reporting methods which also set scanner.bad. Make
use of the new field in a few places where we used to track a prior
error separately.

Preliminary step towards fixing #32133 in a comprehensive manner.

Change-Id: I4d79ad6e3b50632dd5fb3fc32ca3df0598ee77b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/192278
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-08-29 23:37:01 +00:00
Keith Randall
bf36219cdd bytes/hash: add hashing package for bytes and strings
Fixes #28322

R=go1.14

RELNOTE=yes

Change-Id: Ic29f8b587c8c77472260836a5c3e13edaded13fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/186877
Reviewed-by: Alan Donovan <adonovan@google.com>
2019-08-29 21:27:53 +00:00
Keith Randall
fbfb41e638 runtime: switch default order of hashing algorithms
Currently the standard hasher is memhash, which checks whether aes
instructions are available, and if so redirects to aeshash.

With this CL, we call aeshash directly, which then redirects to the
fallback hash if aes instructions are not available.

This reduces the overhead for the hash function in the common case,
as it requires just one call instead of two. On architectures which
have no assembly hasher, it's a single jump slower.

Thanks to Martin for this idea.

name         old time/op  new time/op  delta
BigKeyMap-4  22.6ns ± 1%  21.1ns ± 2%  -6.55%  (p=0.000 n=9+10)

Change-Id: Ib7ca77b63d28222eb0189bc3d7130531949d853c
Reviewed-on: https://go-review.googlesource.com/c/go/+/190998
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
2019-08-29 21:16:09 +00:00
Josh Bleecher Snyder
9675f81928 cmd/compile: add more Neg/Com optimizations
This is a grab-bag of minor optimizations.

While we're here, document the c != -(1<<31)
constraints better (#31888).

file    before    after     Δ       %
go      14669924  14665828  -4096   -0.028%
asm     4867088   4858896   -8192   -0.168%
compile 23988320  23984224  -4096   -0.017%
cover   5210856   5206760   -4096   -0.079%
link    6084376   6080280   -4096   -0.067%
total   132181084 132156508 -24576  -0.019%

file                                                      before    after     Δ       %
archive/tar.a                                             516708    516702    -6      -0.001%
bufio.a                                                   182200    181974    -226    -0.124%
bytes.a                                                   217624    216890    -734    -0.337%
cmd/compile/internal/gc.a                                 8865412   8865228   -184    -0.002%
cmd/compile/internal/ssa.a                                29921002  29933976  +12974  +0.043%
cmd/go/internal/modfetch/codehost.a                       530602    530430    -172    -0.032%
cmd/go/internal/modfetch.a                                679664    679578    -86     -0.013%
cmd/go/internal/modfile.a                                 411102    410928    -174    -0.042%
cmd/go/internal/test.a                                    315218    315126    -92     -0.029%
cmd/go/internal/tlog.a                                    183242    183256    +14     +0.008%
cmd/go/internal/txtar.a                                   23148     23060     -88     -0.380%
cmd/internal/bio.a                                        132064    132060    -4      -0.003%
cmd/internal/buildid.a                                    107174    107172    -2      -0.002%
cmd/internal/edit.a                                       33208     33354     +146    +0.440%
cmd/internal/obj/arm.a                                    416488    416432    -56     -0.013%
cmd/internal/obj/arm64.a                                  2772626   2772622   -4      -0.000%
cmd/internal/obj/x86.a                                    923186    923114    -72     -0.008%
cmd/internal/obj.a                                        679834    679836    +2      +0.000%
cmd/internal/objfile.a                                    358374    358372    -2      -0.001%
cmd/internal/test2json.a                                  67482     67434     -48     -0.071%
cmd/link/internal/ld.a                                    2836280   2836110   -170    -0.006%
cmd/link/internal/loadpe.a                                148234    147736    -498    -0.336%
cmd/link/internal/objfile.a                               144534    144434    -100    -0.069%
cmd/link/internal/ppc64.a                                 170876    170382    -494    -0.289%
cmd/vendor/github.com/google/pprof/internal/elfexec.a     49896     49892     -4      -0.008%
cmd/vendor/github.com/google/pprof/internal/graph.a       437478    437404    -74     -0.017%
cmd/vendor/github.com/google/pprof/profile.a              902040    902044    +4      +0.000%
cmd/vendor/github.com/ianlancetaylor/demangle.a           1217856   1217854   -2      -0.000%
cmd/vendor/golang.org/x/arch/x86/x86asm.a                 561332    560684    -648    -0.115%
cmd/vendor/golang.org/x/crypto/ssh/terminal.a             153788    153784    -4      -0.003%
cmd/vendor/golang.org/x/sys/unix.a                        1043894   1043814   -80     -0.008%
cmd/vendor/golang.org/x/tools/go/analysis/passes/printf.a 288458    288414    -44     -0.015%
compress/flate.a                                          369024    368132    -892    -0.242%
crypto/aes.a                                              109058    108968    -90     -0.083%
crypto/cipher.a                                           150410    150544    +134    +0.089%
crypto/elliptic.a                                         323572    323758    +186    +0.057%
crypto/md5.a                                              50868     50788     -80     -0.157%
crypto/rsa.a                                              195292    195214    -78     -0.040%
crypto/sha1.a                                             70936     70858     -78     -0.110%
crypto/sha256.a                                           75316     75236     -80     -0.106%
crypto/sha512.a                                           84846     84768     -78     -0.092%
crypto/subtle.a                                           6520      6514      -6      -0.092%
crypto/tls.a                                              1654916   1654852   -64     -0.004%
crypto/x509.a                                             888674    888638    -36     -0.004%
database/sql.a                                            730280    730198    -82     -0.011%
debug/gosym.a                                             184936    184862    -74     -0.040%
debug/macho.a                                             272138    272136    -2      -0.001%
debug/plan9obj.a                                          78444     78368     -76     -0.097%
encoding/base64.a                                         82126     81882     -244    -0.297%
encoding/binary.a                                         187196    187150    -46     -0.025%
encoding/gob.a                                            897868    897870    +2      +0.000%
encoding/json.a                                           659934    659832    -102    -0.015%
encoding/pem.a                                            59138     58870     -268    -0.453%
encoding/xml.a                                            694054    693300    -754    -0.109%
fmt.a                                                     484518    484196    -322    -0.066%
go/format.a                                               33962     33994     +32     +0.094%
go/printer.a                                              437132    437134    +2      +0.000%
go/scanner.a                                              141774    141772    -2      -0.001%
go/token.a                                                125130    125126    -4      -0.003%
go/types.a                                                2192086   2191994   -92     -0.004%
html/template.a                                           599038    598770    -268    -0.045%
html.a                                                    184842    184710    -132    -0.071%
image/draw.a                                              129592    129238    -354    -0.273%
image/gif.a                                               171824    171716    -108    -0.063%
image/internal/imageutil.a                                20282     19272     -1010   -4.980%
image/jpeg.a                                              275608    275114    -494    -0.179%
image/png.a                                               343416    343620    +204    +0.059%
image.a                                                   362244    362210    -34     -0.009%
index/suffixarray.a                                       113040    112954    -86     -0.076%
internal/trace.a                                          518972    518838    -134    -0.026%
math/big.a                                                1012670   1012354   -316    -0.031%
math.a                                                    219338    219334    -4      -0.002%
mime/multipart.a                                          178854    178502    -352    -0.197%
mime/quotedprintable.a                                    49226     48936     -290    -0.589%
net/http/cgi.a                                            172328    172324    -4      -0.002%
net/http.a                                                4000180   3999732   -448    -0.011%
net.a                                                     1858330   1858252   -78     -0.004%
path/filepath.a                                           107496    107498    +2      +0.002%
reflect.a                                                 1439776   1439994   +218    +0.015%
regexp/syntax.a                                           459430    459432    +2      +0.000%
regexp.a                                                  416394    416400    +6      +0.001%
runtime/debug.a                                           42106     42100     -6      -0.014%
runtime/pprof/internal/profile.a                          608718    608720    +2      +0.000%
runtime/pprof.a                                           355474    355476    +2      +0.001%
runtime.a                                                 3555748   3555796   +48     +0.001%
strconv.a                                                 294432    294410    -22     -0.007%
strings.a                                                 292148    292090    -58     -0.020%
syscall.a                                                 859682    859470    -212    -0.025%
text/tabwriter.a                                          65614     65148     -466    -0.710%
vendor/golang.org/x/crypto/chacha20poly1305.a             126736    126728    -8      -0.006%
vendor/golang.org/x/crypto/cryptobyte.a                   269112    269114    +2      +0.001%
vendor/golang.org/x/crypto/internal/chacha20.a            61842     61262     -580    -0.938%
vendor/golang.org/x/crypto/poly1305.a                     47410     47404     -6      -0.013%
vendor/golang.org/x/net/dns/dnsmessage.a                  628700    628012    -688    -0.109%
vendor/golang.org/x/net/idna.a                            237678    237826    +148    +0.062%
vendor/golang.org/x/net/route.a                           187852    187458    -394    -0.210%
vendor/golang.org/x/sys/unix.a                            1022426   1022348   -78     -0.008%
vendor/golang.org/x/text/transform.a                      117954    118104    +150    +0.127%
vendor/golang.org/x/text/unicode/bidi.a                   291398    291404    +6      +0.002%
vendor/golang.org/x/text/unicode/norm.a                   534640    534540    -100    -0.019%
total                                                     128945190 128945128 -62     -0.000%

Change-Id: I346dc31356d5ef7774b824cf202169610bd26432
Reviewed-on: https://go-review.googlesource.com/c/go/+/175778
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-08-29 19:55:20 +00:00
Josh Bleecher Snyder
75198b9a9c cmd/compile: simplify postorder
Use a bool instead of markKind;
it doesn't save space, but the semantics are more obvious.
Move type markKind closer to its only remaining use.

Change-Id: I9945a7baaeb764295a2709f83120ce3a82fa3beb
Reviewed-on: https://go-review.googlesource.com/c/go/+/177880
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2019-08-29 19:54:46 +00:00
Josh Bleecher Snyder
b8cbcacabe cmd/compile: optimize more pointer comparisons
The existing pointer comparison optimizations
don't include pointer arithmetic. Add them.

These rules trigger a few times in std cmd, while compiling:

time.Duration.String
cmd/go/internal/tlog.NodeHash
crypto/tls.ticketKeyFromBytes (3 times)
crypto/elliptic.(*p256Point).p256ScalarMult (15 times!)
crypto/elliptic.initTable

These weird comparisons occur when using the copy builtin,
which does a pointer comparison between src and dst.

This also happens to fix #32454, by optimizing enough
early on that all values can be eliminated.

Fixes #32454

Change-Id: I799d45743350bddd15a295dc1e12f8d03c11d1c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/180940
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-08-29 19:35:18 +00:00
Josh Bleecher Snyder
abda0a6a92 cmd/compile: remove redundant rules
EqPtr and NeqPtr are marked as commutative,
so the transformations for rules are already
generated by the preceding two lines.

Change-Id: Ibecba5c8e54d9df00c84e1dae7e5d8cb53eeff43
Reviewed-on: https://go-review.googlesource.com/c/go/+/180939
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-08-29 19:32:42 +00:00
Cuong Manh Le
97bc039c9c cmd/compile: emit error message for broken type
The original report in #5172 was that cmd/compile was generating bogus
follow-on error messages when typechecking a struct failed. Instead of
fixing those follow-on error messages, golang.org/cl/9614044 suppress all
follow-on error messages after struct typecheck fails. We should
continue emitting error messages instead.

While at it, also add the test case for original report.

Fixes #33947

Change-Id: I4a5c6878977128abccd704350a12df743631c7bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/191944
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-08-29 19:08:00 +00:00
LE Manh Cuong
24c6dd9823 cmd/compile: fix internal error on complex comparison
Complex type is the only TIDEAL that lack of support for all comparison
operators. When rewriting constant comparison into literal node, that
missing cause compiler raise an internal error.

Checking the operator is available for complex type before that fix the
problem.

We can make this check works more generally if there's more type lack of
supporting all comparison operators added, but it does not seem to be
happened, so just check explicitly for complex only.

Fixes #32723

Change-Id: I4938b1bdcbcdae9a9d87436024984bd2ab12995e
Reviewed-on: https://go-review.googlesource.com/c/go/+/183459
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-08-29 18:24:31 +00:00
LE Manh Cuong
b136267b87 cmd/compile: do not set n.Type.Sym in typecheckdeftype
typecheckdef calls typecheckdeftype, which will also set n.Type.Sym,
causing duplicated work. So do not set n.Type.Sym in typecheckdeftype to
prevent this, and also keep populating n.Type info in one place make
more sense.

Change-Id: I62671babd750f9d5d0bbfcf8d7eecd2cc314c955
Reviewed-on: https://go-review.googlesource.com/c/go/+/179579
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-08-29 18:23:57 +00:00
Josh Bleecher Snyder
2393d16147 cmd/compile: handle infinite loops in shortcircuit pass
The newly upgraded shortcircuit pass attempted to remove infinite loops.
Stop doing that.

Fixes #33903

Change-Id: I0fc9c1b5f2427e54ce650806602ef5e3ad65aca5
Reviewed-on: https://go-review.googlesource.com/c/go/+/192144
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-08-29 17:41:49 +00:00
LE Manh Cuong
e87fe0f1f5 cmd/compile: make typecheck set n.Type.Nod when returning OTYPE
typecheck only set n.Type.Nod for declared type, and leave it nil for
anonymous types, type alias. It leads to compiler crashes, because
n.Type.Nod is nil at the time dowidth was called.

Fixing it by set n.Type.Nod right after n.Type initialization if n.Op is
OTYPE.

When embedding interface cycles involve in type alias, it also helps
pointing the error message to the position of the type alias
declaration, instead of position of embedding interface.

Fixes #31872

Change-Id: Ia18391e987036a91f42ba0c08b5506f52d07f683
Reviewed-on: https://go-review.googlesource.com/c/go/+/191540
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-08-29 16:43:07 +00:00
Daniel Martí
647dc1afc5 Revert "runtime: don't forward SIGPIPE on macOS"
This reverts CL 188297.

Reason for revert: broke multiple of the darwin builders.

Fixes #33943.

Change-Id: Iacff98d1450edc70402dc7a220d16fcd73337c9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/191784
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-08-29 15:37:46 +00:00
Than McIntosh
35ac194557 test: new testcase for gollvm bug
Testcase for a gollvm bug (assert in Llvm_backend::materializeComposite).

Updates golang/go#33020.

Change-Id: Icdf5b4b2b6eb55a5b48a31a61c41215b1ae4cf01
Reviewed-on: https://go-review.googlesource.com/c/go/+/191743
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-08-29 15:21:31 +00:00