1
0
mirror of https://github.com/golang/go synced 2024-10-01 07:38:32 -06:00
Commit Graph

34598 Commits

Author SHA1 Message Date
Jeremy Faller
b3e2a72e6f Revert "cmd/link: prefix syms with "_" on darwin links"
This reverts commit 06e5529ece.

Reason for revert: darwin_386 is unhappy. (Almost as unhappy as I am.)

https://build.golang.org/log/292c90a4ef1c93597b865ab8513b66a95d93d022

Change-Id: I690566ce1d8212317fc3dc349ad0d4d5a2bb58eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/196033
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
2019-09-17 22:04:57 +00:00
Pantelis Sampaziotis
575386d632 time: add examples for microseconds and milliseconds methods
This change adds testable examples for the new Microseconds and Milliseconds methods that were introduced in Go 1.13.

Fixes #34354

Change-Id: Ibdbfd770ca2192f9086f756918325f7327ce0482
GitHub-Last-Rev: 4575f48f5f
GitHub-Pull-Request: golang/go#34355
Reviewed-on: https://go-review.googlesource.com/c/go/+/195979
Reviewed-by: Alexander Rakoczy <alex@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-17 20:11:12 +00:00
Jeremy Faller
06e5529ece cmd/link: prefix syms with "_" on darwin links
RELNOTE=This change adds an underscore to all Go symbols in darwin, and
the behavior might be confusing to users of tools like "nm", etc.

Fixes #33808

Change-Id: I19ad626026ccae1e87b3bb97b6bb9fd55e95e121
Reviewed-on: https://go-review.googlesource.com/c/go/+/195619
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-09-17 19:29:43 +00:00
Than McIntosh
df855da653 debug/elf: apply more relocations when reading DWARF data sections
The elf reader's method for reading in DWARF section data has support
for applying selected relocations when the debug/dwarf readers are
being used on relocatable objects. This patch extends the set of
relocations applied slightly. In particlar, prior to this for some
architectures we were only applying relocations whose target symbol
was a section symbol; now we also include some relocations that target
other symbols. This is needed to get meaningful values for compilation
unit DIE low_pc attributes, which typically target a specific function
symbol in text.

Fixes #31363.

Change-Id: I34b02e7904cd7f2dea74197f73fa648141d15212
Reviewed-on: https://go-review.googlesource.com/c/go/+/195679
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-09-17 18:46:32 +00:00
Daniel Martí
7d16e44d4f cmd/compile: reduce the regexp work in rulegen
As correctly pointed out by Giovanni Bajo, doing a single regexp pass
should be much faster than doing hundreds per architecture. We can then
use a map to keep track of what ops are handled in each file. And the
amount of saved work is evident:

	name     old time/op         new time/op         delta
	Rulegen          2.48s ± 1%          2.02s ± 1%  -18.44%  (p=0.008 n=5+5)

	name     old user-time/op    new user-time/op    delta
	Rulegen          10.9s ± 1%           8.9s ± 0%  -18.27%  (p=0.008 n=5+5)

	name     old sys-time/op     new sys-time/op     delta
	Rulegen          209ms ±28%          236ms ±18%     ~     (p=0.310 n=5+5)

	name     old peak-RSS-bytes  new peak-RSS-bytes  delta
	Rulegen          178MB ± 3%          176MB ± 3%     ~     (p=0.548 n=5+5)

The speed-up is so large that we don't need to parallelize it anymore;
the numbers above are with the removed goroutines. Adding them back in
doesn't improve performance noticeably at all:

	name     old time/op         new time/op         delta
	Rulegen          2.02s ± 1%          2.01s ± 1%   ~     (p=0.421 n=5+5)

	name     old user-time/op    new user-time/op    delta
	Rulegen          8.90s ± 0%          8.96s ± 1%   ~     (p=0.095 n=5+5)

While at it, remove an unused method.

Change-Id: I328b56e63b64a9ab48147e67e7d5a385c795ec54
Reviewed-on: https://go-review.googlesource.com/c/go/+/195739
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-09-17 18:22:37 +00:00
LE Manh Cuong
ec4e8517cd cmd/compile: support more length types for slice extension optimization
golang.org/cl/109517 optimized the compiler to avoid the allocation for make in
append(x, make([]T, y)...). This was only implemented for the case that y has type int.

This change extends the optimization to trigger for all integer types where the value
is known at compile time to fit into an int.

name             old time/op    new time/op    delta
ExtendInt-12        106ns ± 4%     106ns ± 0%      ~     (p=0.351 n=10+6)
ExtendUint64-12    1.03µs ± 5%    0.10µs ± 4%   -90.01%  (p=0.000 n=9+10)

name             old alloc/op   new alloc/op   delta
ExtendInt-12        0.00B          0.00B           ~     (all equal)
ExtendUint64-12    13.6kB ± 0%     0.0kB       -100.00%  (p=0.000 n=10+10)

name             old allocs/op  new allocs/op  delta
ExtendInt-12         0.00           0.00           ~     (all equal)
ExtendUint64-12      1.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)

Updates #29785

Change-Id: Ief7760097c285abd591712da98c5b02bc3961fcd
Reviewed-on: https://go-review.googlesource.com/c/go/+/182559
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-09-17 17:18:17 +00:00
Keith Randall
07ad840098 runtime: remove unneeded noinline directives
Now that mid-stack inlining reports backtraces correctly, we no
longer need to protect against inlining in a few critical areas.

Update #19348
Update #28640
Update #34276

Change-Id: Ie68487e6482c3a9509ecf7ecbbd40fe43cee8381
Reviewed-on: https://go-review.googlesource.com/c/go/+/195818
Reviewed-by: David Chase <drchase@google.com>
2019-09-17 17:17:11 +00:00
Tamir Duberstein
38543c2813 net: avoid transiting durations through floats
This slightly simplified the code. I stumbled upon this when support was
being added to Fuchsia (and this pattern was initially cargo-culted).

Change-Id: Ica090a118a0056c5c1b51697691bc7308f0d424a
Reviewed-on: https://go-review.googlesource.com/c/go/+/177878
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-17 16:25:15 +00:00
Joel Sing
c3c53661ba cmd/asm,cmd/internal/obj/riscv: implement integer computational instructions
Add support for assembling integer computational instructions.

Based on the riscv-go port.

Updates #27532

Change-Id: Ibf02649eebd65ce96002a9ca0624266d96def2cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/195079
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-09-17 04:37:46 +00:00
Robert Griesemer
606fa2db7a go/types: remove unused pathString and rename objPathString to pathString (cleanup)
This eliminates an old TODO.

Change-Id: I36d666905f43252f5d338b11ef9c1ed8b5f22b1f
Reviewed-on: https://go-review.googlesource.com/c/go/+/195817
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-09-17 03:03:59 +00:00
Matthew Dempsky
8f3d9855a1 cmd/compile: major refactoring of switch walking
There are a lot of complexities to handling switches efficiently:

1. Order matters for expression switches with non-constant cases and
for type expressions with interface types. We have to respect
side-effects, and we also can't allow later cases to accidentally take
precedence over earlier cases.

2. For runs of integers, floats, and string constants in expression
switches or runs of concrete types in type switches, we want to emit
efficient binary searches.

3. For runs of consecutive integers in expression switches, we want to
collapse them into range comparisons.

4. For binary searches of strings, we want to compare by length first,
because that's more efficient and we don't need to respect any
particular ordering.

5. For "switch true { ... }" and "switch false { ... }", we want to
optimize "case x:" as simply "if x" or "if !x", respectively, unless x
is interface-typed.

The current swt.go code reflects how these constraints have been
incrementally added over time, with each of them being handled ad
hocly in different parts of the code. Also, the existing code tries
very hard to reuse logic between expression and type switches, even
though the similarities are very superficial.

This CL rewrites switch handling to better abstract away the logic
involved in constructing the binary searches. In particular, it's
intended to make further optimizations to switch dispatch much easier.

It also eliminates the need for both OXCASE and OCASE ops, and a
subsequent CL can collapse the two.

Passes toolstash-check.

Change-Id: Ifcd1e56f81f858117a412971d82e98abe7c4481f
Reviewed-on: https://go-review.googlesource.com/c/go/+/194660
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-09-16 23:05:09 +00:00
Lucas Bremgartner
c1000c500c encoding/json: validate strings when decoding into Number
Unmarshaling a string into a json.Number should first check that the string is a valid Number.
If not, we should fail without decoding it.

Fixes #14702

Change-Id: I286178e93df74ad63c0a852c3f3489577072cf47
GitHub-Last-Rev: fe69bb68ee
GitHub-Pull-Request: golang/go#34272
Reviewed-on: https://go-review.googlesource.com/c/go/+/195045
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-16 21:56:53 +00:00
Daniel Martí
0e0bff840e cmd/compiler: skip some go/printer work in rulegen
We use go/format on the final output, so don't bother with the added
tabwriter work to align comments when using go/printer.

	name     old time/op         new time/op         delta
	Rulegen          2.53s ± 2%          2.48s ± 1%  -2.20%  (p=0.032 n=5+5)

	name     old user-time/op    new user-time/op    delta
	Rulegen          11.2s ± 1%          10.8s ± 0%  -3.72%  (p=0.008 n=5+5)

	name     old sys-time/op     new sys-time/op     delta
	Rulegen          218ms ±17%          207ms ±19%    ~     (p=0.548 n=5+5)

	name     old peak-RSS-bytes  new peak-RSS-bytes  delta
	Rulegen          184MB ± 3%          175MB ± 4%    ~     (p=0.056 n=5+5)

Change-Id: I53bad2ab15cace67415f2171fffcd13ed596e62b
Reviewed-on: https://go-review.googlesource.com/c/go/+/195219
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-16 21:37:16 +00:00
Daniel Martí
357e8f83f8 cmd/compile: parallelize another big chunk of rulegen
rulegen has a sanity check that ensures all the arch-specific opcodes
are handled by each of the gen files.

This is an expensive chunk of work, particularly since there are a lot
of opcodes in total, and each one of them compiles and runs a regular
expression.

Parallelize that for each architecture, which greatly speeds up 'go run
*.go' on my laptop with four real CPU cores.

	name     old time/op         new time/op         delta
	Rulegen          3.39s ± 1%          2.53s ± 2%  -25.34%  (p=0.008 n=5+5)

	name     old user-time/op    new user-time/op    delta
	Rulegen          10.6s ± 1%          11.2s ± 1%   +6.09%  (p=0.008 n=5+5)

	name     old sys-time/op     new sys-time/op     delta
	Rulegen          201ms ± 7%          218ms ±17%     ~     (p=0.548 n=5+5)

	name     old peak-RSS-bytes  new peak-RSS-bytes  delta
	Rulegen          182MB ± 3%          184MB ± 3%     ~     (p=0.690 n=5+5)

Change-Id: Iec538ed0fa7eb867eeeeaab3da1e2615ce32cbb9
Reviewed-on: https://go-review.googlesource.com/c/go/+/195218
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-09-16 21:37:11 +00:00
Jay Conrod
4d18a7ceb2 cmd/go: don't split internal test main packages twice
Fixes #34321

Change-Id: Ia6253038c525089e20a1da64a2c5c9dcc57edd74
Reviewed-on: https://go-review.googlesource.com/c/go/+/195677
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-09-16 20:09:44 +00:00
Matthew Dempsky
7f907b9cee cmd/compile: require -lang=go1.14 for overlapping interfaces
Support for overlapping interfaces is a new (proposed) Go language
feature to be supported in Go 1.14, so it shouldn't be supported under
-lang=go1.13 or earlier.

Fixes #34329.

Change-Id: I5fea5716b7d135476980bc40b4f6e8c611b67735
Reviewed-on: https://go-review.googlesource.com/c/go/+/195678
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-09-16 19:43:54 +00:00
Jay Conrod
aa680c0c49 cmd/go: don't include package dir in cache key when -trimpath is set
The '-trimpath' flag tells 'go build' to trim any paths from the
output files that are tied to the current workspace or toolchain. When
this flag is set, we do not need to include the package directory in
the text hashed to construct the action ID for each package.

Fixes #33772

Change-Id: I20b902d2f58019709b15864ca79aa0d9255ae707
Reviewed-on: https://go-review.googlesource.com/c/go/+/195318
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-09-16 16:25:41 +00:00
Matthew Dempsky
606019cb4b cmd/compile: trim function name prefix from escape diagnostics
This information is redundant with the position information already
provided. Also, no other -m diagnostics print out function name.

While here, report parameter leak diagnostics against the parameter
declaration position rather than the function, and use Warnl for
"moved to heap" messages.

Test cases updated programmatically by removing the first word from
every "no match for" error emitted by run.go:

go run run.go |& \
  sed -E -n 's/^(.*):(.*): no match for `([^ ]* (.*))` in:$/\1!\2!\3!\4/p' | \
  while IFS='!' read -r fn line before after; do
    before=$(echo "$before" | sed 's/[.[\*^$()+?{|]/\\&/g')
    after=$(echo "$after" | sed -E 's/(\&|\\)/\\&/g')
    fn=$(find . -name "${fn}" | head -1)
    sed -i -E -e "${line}s/\"${before}\"/\"${after}\"/" "${fn}"
  done

Passes toolstash-check.

Change-Id: I6e02486b1409e4a8dbb2b9b816d22095835426b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/195040
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-09-16 15:30:51 +00:00
Ian Lance Taylor
4ae25ff140 os/signal: split up sleeps waiting for signal
Try to deflake TestNohup.

The kernel will deliver a signal as a thread returns from a syscall.
If the only active thread is sleeping, and the system is busy,
the kernel may not get around to waking up a thread to catch the signal.
Try splitting up the sleep, to give the kernel another change to deliver.

I don't know if this will help, but it seems worth a try.

Fixes #33174

Change-Id: I34b3240af706501ab8538cb25c4846d1d30d7691
Reviewed-on: https://go-review.googlesource.com/c/go/+/194879
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-09-16 15:19:42 +00:00
Maya Rashish
531f1d50cc syscall: avoid zeroing unused syscall arguments
Zeroing unused registers is not required. Removing it makes the code
very slightly smaller and very slightly faster.

Change-Id: I1ec17b497db971ca8a3641e3e94c063571419f27
GitHub-Last-Rev: f721bb2636
GitHub-Pull-Request: golang/go#31596
Reviewed-on: https://go-review.googlesource.com/c/go/+/173160
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-09-16 14:18:15 +00:00
Lucas Bremgartner
49e7c7672d encoding/json: make Number with the ,string option marshal with quotes
Add quotes when marshaling a json.Number with the string option
set via a struct tag. This ensures that the resulting json
can be unmarshaled into the source struct without error.

Fixes #34268

Change-Id: Ide167d9dec77019554870b5957b37dc258119d81
GitHub-Last-Rev: dde81b7120
GitHub-Pull-Request: golang/go#34269
Reviewed-on: https://go-review.googlesource.com/c/go/+/195043
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-16 11:56:15 +00:00
Cuong Manh Le
75da700d0a cmd/compile: consistently use strlit to access constants string values
Passes toolstash-check.

Change-Id: Ieaef20b7649787727b69469f93ffc942022bc079
Reviewed-on: https://go-review.googlesource.com/c/go/+/195198
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-09-16 11:41:20 +00:00
Ben Shi
d12c62d12d go/parser: fix ignored errors in ParseExprFrom
This CL fixes a bug in ParseExprFrom which makes
error messages ignored when there are 10+ errors
in a single expression.

fixes #34241
fixes #34274

Change-Id: I29a82d3e3e726279005eb6fbcd7ee3aebffaa679
Reviewed-on: https://go-review.googlesource.com/c/go/+/194638
Run-TryBot: Ben Shi <powerman1st@163.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-09-15 00:18:30 +00:00
Nigel Tao
4e215554aa compress/lzw: clarify code invariants
This follows on from https://go-review.googlesource.com/c/go/+/191358
which was submitted as a comment-only change.

Benchmarks don't show any significant change:

compress/lzw
name            old speed      new speed      delta
Decoder/1e4-56  92.8MB/s ± 1%  92.7MB/s ± 1%   ~     (p=1.000 n=5+5)
Decoder/1e5-56   100MB/s ± 1%   100MB/s ± 1%   ~     (p=0.746 n=5+5)
Decoder/1e6-56   101MB/s ± 1%   101MB/s ± 1%   ~     (p=0.381 n=5+5)

image/gif
name                old speed      new speed      delta
Decode-56           63.2MB/s ± 1%  63.2MB/s ± 1%   ~     (p=0.690 n=5+5)

Change-Id: Ic36b5410cb06ca258da32e40da1f1ff6c44cff86
Reviewed-on: https://go-review.googlesource.com/c/go/+/194938
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-14 02:23:31 +00:00
Tim Cooper
8cc57c0ccc log: add Lmsgprefix flag
The Lmsgprefix flag moves the logger's prefix from the
beginning of the line to after the log header. For example,
a logger with the prefix "LOG " and LstdFlags would output:

    LOG 2009/11/10 23:00:00 entry text

Adding the Lmsgprefix flag would output:

    2009/11/10 23:00:00 LOG entry text

Fixes #32062

Change-Id: I9f7c9739abeb53c424112aaeed33444eeefdfbbc
Reviewed-on: https://go-review.googlesource.com/c/go/+/186182
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2019-09-13 23:21:54 +00:00
Jay Conrod
24781a1faf cmd/go: fix link error for -coverpkg in GOPATH mode
If a generated test main package transitively depends on a main
package, the main package will now always be rebuilt as a library and
will not be compiled with '-p main'.

This expands the fix for #30907, which only applied to packages with
the BuildInfo set (main packages built in module mode). Linking
multiple packages with BuildInfo caused link errors, but it appears
these errors apply to some symbols in GOPATH mode.

Fixes #34114

Change-Id: Ic1e53437942269a950dd7e45d163707922c92edd
Reviewed-on: https://go-review.googlesource.com/c/go/+/195279
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-13 16:25:00 +00:00
Joel Sing
79877e5f91 cmd/link: simplify determineLinkMode
Simplify determineLinkMode by calling mustLinkExternal upfront,
then doing a first pass for LinkModeAuto, followed by a second pass
that determines if the link mode is valid.

Change-Id: I9d7668107c159f8fe330b8c05fee035bbe9875fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/195078
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-13 09:40:36 +00:00
Ruixin Bao
98aa97806b cmd/compile: add math/bits.Mul64 intrinsic on s390x
This change adds an intrinsic for Mul64 on s390x. To achieve that,
a new assembly instruction, MLGR, is introduced in s390x/asmz.go. This assembly
instruction directly uses an existing instruction on Z and supports multiplication
of two 64 bit unsigned integer and stores the result in two separate registers.

In this case, we require the multiplcand to be stored in register R3 and
the output result (the high and low 64 bit of the product) to be stored in
R2 and R3 respectively.

A test case is also added.

Benchmark:
name      old time/op  new time/op  delta
Mul-18    11.1ns ± 0%   1.4ns ± 0%  -87.39%  (p=0.002 n=8+10)
Mul32-18  2.07ns ± 0%  2.07ns ± 0%     ~     (all equal)
Mul64-18  11.1ns ± 1%   1.4ns ± 0%  -87.42%  (p=0.000 n=10+10)

Change-Id: Ieca6ad1f61fff9a48a31d50bbd3f3c6d9e6675c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/194572
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-13 09:04:48 +00:00
Cherry Zhang
03f63654c4 Revert "cmd/link: prefix syms with "_" on external darwin links"
This reverts CL 194381

Reason for revert: break tests like add2line.

Change-Id: I9e858c7ada340a842bd0cad719616ad30fae4aaa
Reviewed-on: https://go-review.googlesource.com/c/go/+/195137
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-09-12 21:02:57 +00:00
Joel Sing
6c6ad3086e cmd/asm,cmd/internal/obj: initial support for riscv64 assembler
Provide the initial framework for the riscv64 assembler. For now this
only supports raw WORD instructions, but at least allows for basic
testing. Additional functionality will be added in separate changes.

Based on the riscv-go port.

Updates #27532

Change-Id: I181ffb2d37a34764a3e91eded177d13a89c69f9a
Reviewed-on: https://go-review.googlesource.com/c/go/+/194117
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-09-12 18:54:38 +00:00
Jay Conrod
9428861378 cmd/go: document <module>/@latest endpoint in 'go help goproxy'
Updates #32789

Change-Id: Ie5e8e3b7b6a923aa9068c8af3ac8f081bd92c830
Reviewed-on: https://go-review.googlesource.com/c/go/+/190838
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-12 18:47:09 +00:00
Jeremy Faller
2959ba1f55 cmd/link: prefix syms with "_" on external darwin links
Fixes #33808

Change-Id: If1f30bc80004093ffdf9121768464dfb3a6e1f63
Reviewed-on: https://go-review.googlesource.com/c/go/+/194381
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-09-12 18:44:26 +00:00
Bryan C. Mills
1dd7164555 cmd/go/internal/work: include detail in errors from cache operations
Since the cache has been required since Go 1.12, also remove redundant
checks for a nil cache.

Updates #29127
Updates #29667

Change-Id: Ibc59b659306a4eef2d4f0e3d0b651986d6cf84ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/188021
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-09-12 18:33:05 +00:00
Cuong Manh Le
48e482ef0c cmd/compile: do not mark export for send only chan
No changes in compilebench, pass toolstash-check.

Change-Id: I2688f7b45af0eaa0cf3b38e726bce6e68c20f69c
Reviewed-on: https://go-review.googlesource.com/c/go/+/195077
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-09-12 17:41:57 +00:00
Tom Thorogood
9cce08d724 cmd/go/internal/renameio,runtime: avoid leaking temp directory in test
TestWriteFileModeAppliesUmask and TestVectoredHandlerDontCrashOnLibrary
could both leak /tmp/go-build-* directories which isn't very friendly.

Change-Id: Ibee9c33d49ad48958fae4df73853b82d92314bf0
GitHub-Last-Rev: 814e2fa4bb
GitHub-Pull-Request: golang/go#34253
Reviewed-on: https://go-review.googlesource.com/c/go/+/194880
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-12 15:52:35 +00:00
Ruixin Bao
90e0b40ab2 cmd/internal/obj/s390x: use 12 bit load and store instruction when possible on s390x
Originally, we default to use load and store instruction with 20 bit displacement.
However, that is not necessary. Some instructions have a displacement smaller
than 12 bit. This CL allows the usage of 12 bit load and store instruction when
that happens.

This change also reduces the size of .text section in go binary by 19 KB.

Some tests are also added to verify the functionality of the change.

Change-Id: I13edea06ca653d4b9ffeaefe8d010bc2f065c2ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/194857
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-12 15:49:54 +00:00
Bryan C. Mills
c20eb96e6b cmd/go/internal/modload: add an Unwrap method on ImportMissingError
Jay suggested this in CL 189780, and it seems semantically correct.

As far as I can tell this has no impact one way or the other right
now, but might prevent confusion (or at least give us more experience
with error handling!) in future changes.

Updates #30748
Updates #28459
Updates #30322

Change-Id: I5d7e9a08ea141628ed6a8fd03c62d0d3c2edf2bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/194817
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-09-12 14:09:30 +00:00
Bryan C. Mills
9a44023ce9 cmd/go/internal/web: include snippets of plain-text server responses in error detail
For the server response to be displayed, the response must be served
as type text/plain with charset us-ascii or utf-8, and must consist of
only graphic characters and whitespace.

We truncate the server response at the first blank line or after 8
lines or a fixed number of characters, and tab-indent (if multiple
lines) to ensure that the response is offset from ordinary go command
output.

Fixes #30748

Change-Id: I0bc1d734737e456e3251aee2252463b6355e8c97
Reviewed-on: https://go-review.googlesource.com/c/go/+/189783
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-09-12 14:09:20 +00:00
Bryan C. Mills
54b7afb4ef cmd/go/internal/modfetch: reduce path redundancy in checkMod error reporting
Updates #30748

Change-Id: I38a6cdc9c9b488fec579e6362a4284e26e0f526e
Reviewed-on: https://go-review.googlesource.com/c/go/+/189782
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-09-12 14:08:25 +00:00
Bryan C. Mills
3d522b1088 cmd/go/internal/module: in VersionError, do not wrap an existing ModuleError
VersionError wraps the given error in a ModuleError struct.

If the given error is already a ModuleError for the same path and
version, we now return it directly instead of wrapping.
This makes it safer to call VersionError if we don't know whether
a given error is already wrapped.

Updates #30748

Change-Id: I41b23f6c3ead0ec382e848696da51f478da1ad35
Reviewed-on: https://go-review.googlesource.com/c/go/+/189781
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-09-12 14:08:16 +00:00
Daniel Martí
1581bb9843 cmd/compile: stop using go/types in rulegen
Using go/types to get rid of all unused variables in CL 189798 was a
neat idea, but it was pretty expensive. go/types is a full typechecker,
which does a lot more work than we actually need. Moreover, we had to
run it multiple times, to catch variables that became unused after
removing existing unused variables.

Instead, write our own little detector for unused imports and variables.
It doesn't use ast.Walk, as we need to know what fields we're
inspecting. For example, in "foo := bar", "foo" is declared, and "bar"
is used, yet they both appear as simple *ast.Ident cases under ast.Walk.

The code is documented to explain how unused variables are detected in a
single syntax tree pass. Since this happens after we've generated a
complete go/ast.File, we don't need to worry about our own simplified
node types.

The generated code is the same, but rulegen is much faster and uses less
memory at its peak, so it should scale better with time.

With 'benchcmd Rulegen go run *.go' on perflock, we get:

	name     old time/op         new time/op         delta
	Rulegen          4.00s ± 0%          3.41s ± 1%  -14.70%  (p=0.008 n=5+5)

	name     old user-time/op    new user-time/op    delta
	Rulegen          14.1s ± 1%          10.6s ± 1%  -24.62%  (p=0.008 n=5+5)

	name     old sys-time/op     new sys-time/op     delta
	Rulegen          318ms ±26%          263ms ± 9%     ~     (p=0.056 n=5+5)

	name     old peak-RSS-bytes  new peak-RSS-bytes  delta
	Rulegen          231MB ± 4%          181MB ± 3%  -21.69%  (p=0.008 n=5+5)

Change-Id: I8387d52818f6131357868ad348dac8c96d926191
Reviewed-on: https://go-review.googlesource.com/c/go/+/191782
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-09-12 10:48:58 +00:00
Nigel Tao
396d625330 compress/lzw: fix comment re high-code invariant
The listed invariant, while technically true, was misleading, and the
invariant can be tightened. We never actually get to (d.hi ==
d.overflow), due to the "d.hi--" line in the decoder.decode method.

This is a comment-only commit, changing the comment to match the code.

A follow-up commit could restore the comment, changing the code to match
the original intented invariant. But the first step is to have the
comment and the code say the same thing.

Change-Id: Ifc9f78d5060454fc107af9be298026bf3043d400
Reviewed-on: https://go-review.googlesource.com/c/go/+/191358
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-12 07:45:53 +00:00
Cuong Manh Le
3f0437e175 cmd/compile: generalize isfat to handle 1-field structs and 1-element arrays
After CL 192979, it is safe now to optimize isfat slightly to handle
1-field structs and 1-element arrays.

Change-Id: Ie3bc30299abbcef36eee7a0681997cc2f88ed6a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/192980
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-09-12 06:48:02 +00:00
Cuong Manh Le
55c0ad4b62 cmd/compile: allow iota inside function in a ConstSpec
Fixes #22344

Change-Id: I7c400d9d4ebcab279d08a8c190508d82cbd20899
Reviewed-on: https://go-review.googlesource.com/c/go/+/194717
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-09-12 06:46:57 +00:00
Cuong Manh Le
88076ebc92 go/types: fix iota undefined after ConstDecl inside function in ConstSpec
When reaching const declaration, Checker override context iota to use
correct iota value, but does not restore the old value when exit, and
always set context iota to nil. It ends up with undefined iota after
const declaration.

To fix it, preserve the original iota value and restore it after const
declaration.

Fixes #34228

Change-Id: I42d5efb55a57e5ddc369bb72d31f1f039c92361c
Reviewed-on: https://go-review.googlesource.com/c/go/+/194737
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-09-12 04:15:00 +00:00
Matthew Dempsky
0b739fd4df cmd/compile: move duplicate type-case checking into typecheck
Part of the general trend of moving yyerror calls out of walk and into
typecheck.

Notably, this requires splitting test/typeswitch2.go into two files,
because now some of the errors are reported during typecheck and
others are still reported during walk; and if there were any errors
during typecheck, then cmd/compile exits without invoking walk.

Passes toolstash-check.

Change-Id: I05ee0c00b99af659ee1eef098d342d0d736cf31e
Reviewed-on: https://go-review.googlesource.com/c/go/+/194659
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-09-11 23:33:11 +00:00
Matthew Dempsky
e7e2b1c2b9 cmd/compile: separate type and expression switch typechecking
While superficially type and expression switch handling seem similar
and that it would be worthwhile to unify typechecking them, it turns
out they're actually different enough that separately handling them is
fewer lines of code and easier to understand as well.

Passes toolstash-check.

Change-Id: I357d6912dd580639b6001bccdb2e227ed83c6fe9
Reviewed-on: https://go-review.googlesource.com/c/go/+/194566
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-09-11 23:01:45 +00:00
Bryan C. Mills
28287552bc Revert "cmd/go/internal/modconv: use modules to examine instead of using only direct source control entries"
This reverts CL 191218.

Reason for revert: broke cmd/go/internal/modconv in the 'linux-amd64-longtest' builder.
(https://build.golang.org/log/e28011d0f918d4b4c503ab47e479d9e76c769abd)

Change-Id: I0d260b0a5ad510d3d304c8aac8286fcab921d2fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/194797
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2019-09-11 21:10:45 +00:00
Dominik Honnef
d5df4d61ce cmd/gofmt: don't turn nil slices into empty slices during rewriting
The go/ast package uses and guarantees nil slices for optional
elements that weren't present in the parsed source code, such as the
list of return values of a function. Packages using go/ast rely on
this attribute and check for nils explicitly.

One such package is go/printer. In the presence of empty slices
instead of nil slices, it generates invalid code, such as "case :"
instead of "default:". The issues that this CL fixes are all
manifestations of that problem, each for a different syntactic
element.

Fixes #33103
Fixes #33104
Fixes #33105

Change-Id: I219f95a7da820eaf697a4ee227d458ab6e4a80bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/187917
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-11 20:34:54 +00:00
Jay Conrod
8875fb97c5 cmd/go: strip trailing slash from versioned arguments
'go get' accepts arguments of the form path@version, and it passes
them through search.CleanPatterns before querying proxies. With this
change, CleanPatterns preserves text after '@' and will strip trailing
slashes from the patn.

Previously, we did not strip trailing slashes when a version was
present, which caused proxy base URL validation to fail. Module paths
that end with ".go" (for example, github.com/nats-io/nats.go) use
trailing slashes to prevent 'go build' and other commands from
interpreting packages as source file names, so this caused unnecessary
problems for them.

Updates #32483

Change-Id: Id3730c52089e52f1cac446617c20132a3021a808
Reviewed-on: https://go-review.googlesource.com/c/go/+/194600
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-09-11 20:19:25 +00:00
Aofei Sheng
04867cd891 cmd/go/internal/modconv: use modules to examine instead of using only direct source control entries
Since modules now support parsing multiple forms of versions (including
commit hash and source control tag), I think modconv.ConvertLegacyConfig
no longer needs modfetch.ImportRepoRev. So I suggest that we use modules
to convert legacy config instead of using VCS directly. By doing this,
we can make the module proxy participate in the conversion process and
benefit from it (such as speeding up "go mod init" or breaking through
the firewall).

And since modconv.ConvertLegacyConfig is the only caller of
modfetch.ImportRepoRev, I think modfetch.ImportRepoRev can be removed.

Fixes #33767

Change-Id: Ic79b14fa805ed297ca1735a8498cfed2a5ddeec2
Reviewed-on: https://go-review.googlesource.com/c/go/+/191218
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-09-11 19:02:10 +00:00
William Poussier
cc39d8087b encoding/json: encode nil encoding.TextMarshaler instance as "null"
Fixes #34235.

Change-Id: Ia3795fd18860530fa6a4b171545f525e784ffdcb
GitHub-Last-Rev: 1a319c4528
GitHub-Pull-Request: golang/go#34238
Reviewed-on: https://go-review.googlesource.com/c/go/+/194642
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-11 18:37:43 +00:00
Joel Sing
85c60bd0f3 cmd/internal/obj/riscv: fix up instruction groupings
Some of the instructions were incorrectly grouped - untangle this and
separate the RV64I instructions, which are under separate sections of
the RISC-V specification.

Change-Id: I232962ab4054bf0b4745887506f51e74ea73f73d
Reviewed-on: https://go-review.googlesource.com/c/go/+/194238
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-09-11 16:48:56 +00:00
Bryan C. Mills
6f1667ea3e cmd/go/internal/modload: propagate errors from Query for missing imports
Updates #30748
Updates #28459

Change-Id: I1c34b3dae0bf9361dba0dae66bb868901ecafe29
Reviewed-on: https://go-review.googlesource.com/c/go/+/189780
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-09-11 16:28:37 +00:00
Bryan C. Mills
2a4c0afee7 cmd/go/internal/get: propagate server errors if no go-import tags are found
Updates #30748

Change-Id: Ic93c68c1c4b2728f383edfdb06371ecc79a6f7b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/189779
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-09-11 16:27:30 +00:00
Bryan C. Mills
95e1ea4598 cmd/go/internal/get: propagate parse errors in parseMetaGoImports
The signature of parseMetaGoImports implies that it can return an error,
but it has not done so since CL 119675. Restore the missing error check,
and remove the named return-values to avoid reintroducing this bug in the
future.

Updates #30748
Updates #21291

Change-Id: Iab19ade5b1c23c282f3c385a55ed277465526515
Reviewed-on: https://go-review.googlesource.com/c/go/+/189778
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-09-11 16:25:52 +00:00
Bryan C. Mills
8fb9fa36f5 cmd/go/internal/get: make the implementation of charsetReader match its comment
The doc comment for charsetReader claims that it supports UTF-8,
but in practice it does not: instead, it is never invoked for UTF-8.

We could update the comment to clarify that fact, but it seems simpler
to change the implementation to match the comment.

Change-Id: I39b11395ccef3feff96480b9294e8f2a232728dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/189777
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-09-11 16:24:33 +00:00
Bryan C. Mills
51be44bfaf cmd/go/internal/web: log complete URLs
Incoming URLs may omit the scheme to indicate “either HTTP or HTTPS”.
For such URLs, log the scheme actually used instead of leaving it out.

(This issue was noticed while triaging #34075.)

Updates #34075

Change-Id: I39e5ca83543dd780258d41d5c2c4ba907cd20e5c
Reviewed-on: https://go-review.googlesource.com/c/go/+/193262
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-09-11 14:54:57 +00:00
fanzha02
23f7398671 cmd/go/internal/work: use pie link mode when using MSAN on arm64
Currently, when running the "CC=clang go run -msan misc/cgo/
testsanitizers/testdata/msan.go" command on arm64, it will
report an error and the error is reported by llvm/compiler-rt/
lib/msan and it is "Make sure to compile with -fPIE and to link
with -pie".

This CL fixes this issue, using PIE link mode when using MSAN
on arm64.

This CL also updates the related document and go build help message.

Fixes #33712

Change-Id: I0cc9d95f3fa264d6c042c27a40ccbb82826922fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/190482
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-09-11 14:29:18 +00:00
Bryan C. Mills
f6c691e0e1 cmd/go/internal/modfetch/codehost: treat nonexistent repositories as “not found”
If a go-import directive refers to a nonexistent repository, today we
treat that as an error fetching a module that actually exists.
That makes the HTTP server responsible for determining which
repositories do or do not exist, which may in general depend on
the user's separately-stored credentials, and imposes significant
complexity on such a server, which can otherwise be very simple.

Instead, check the repository URL and/or error message to try to
determine whether the repository exists at all. If the repo does not
exist, treat its absence as a “not found” error — as if the server had
not returned it in the first place.

Updates #34094

Change-Id: I142619ff43b96d0de428cdd0b01cca828c9ba234
Reviewed-on: https://go-review.googlesource.com/c/go/+/194561
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-09-11 14:02:43 +00:00
Lucas Bremgartner
0e015e20cf encoding/json: fix and optimize marshal for quoted string
Since Go 1.2 every string can be marshaled to JSON without error even if it
contains invalid UTF-8 byte sequences. Therefore there is no need to use
Marshal again for the only reason of enclosing the string in double quotes.
Not using Marshal here also removes the error check as there has not been a
way for Marshal to fail anyway.

name          old time/op    new time/op    delta
Issue34127-4     360ns ± 3%     200ns ± 3%  -44.56%  (p=0.008 n=5+5)

name          old alloc/op   new alloc/op   delta
Issue34127-4     56.0B ± 0%     40.0B ± 0%  -28.57%  (p=0.008 n=5+5)

name          old allocs/op  new allocs/op  delta
Issue34127-4      3.00 ± 0%      2.00 ± 0%  -33.33%  (p=0.008 n=5+5)

Fixes #34154

Change-Id: Ib60dc11980f9b20d8bef2982de7168943d632263
GitHub-Last-Rev: 9b0ac1d4c5
GitHub-Pull-Request: golang/go#34127
Reviewed-on: https://go-review.googlesource.com/c/go/+/193604
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-11 12:26:35 +00:00
Ruixin(Peter) Bao
11c2411c50 cmd/compile/internal/s390x: replace 4-byte NOP with a 2-byte NOP on s390x
Added a new instruction, NOPH, with the encoding [0x0700](i.e: bcr 0, 0) and
replace the current 4-byte nop that was encoded using the WORD instruction.

This reduces the size of .text section in go binary by around 17KB and make
generated code easier to read.

Change-Id: I6a756df39e93c4415ea6d038ba4af001b8ccb286
Reviewed-on: https://go-review.googlesource.com/c/go/+/194344
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-11 12:19:26 +00:00
Howard Zhang
b25ec50b69 syscall: implement rawVforkSyscall for linux/arm64
This allows the use of CLONE_VFORK and CLONE_VM for fork/exec, preventing
"fork/exec ...: cannot allocate memory" failures from occuring when attempting
to execute commands from a Go process that has a large memory footprint.
Additionally, this should reduce the latency of fork/exec on linux/arm64.

With CLONE_VM the child process shares the same memory with the parent
process. On its own this would lead to conflicting use of the same
memory, so CLONE_VFORK is used to suspend the parent process until the
child releases the memory when switching to the new program binary
via the exec syscall. When the parent process continues to run, one
has to consider the changes to memory that the child process did,
namely the return address of the syscall function needs to be restored
from a register.

exec.Command() callers can start in a faster manner, as child process who
do exec commands job can be cloned faster via vfork than via fork on arm64.

The same problem was addressed on linux/amd64 via issue #5838.

Updates #31936
Contributed by Howard Zhang <howard.zhang@arm.com> and Bin Lu <bin.lu@arm.com>

Change-Id: Ia99d81d877f564ec60d19f17e596276836576eaf
Reviewed-on: https://go-review.googlesource.com/c/go/+/189418
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-09-11 07:19:55 +00:00
Yuichi Nishiwaki
904f046e2b runtime: fix crash during VDSO calls on arm
As discussed in #32912, a crash occurs when go runtime calls a VDSO function (say
__vdso_clock_gettime) and a signal arrives to that thread.
Since VDSO functions temporarily destroy the G register (R10),
Go functions asynchronously executed in that thread (i.e. Go's signal
handler) can try to load data from the destroyed G, which causes
segmentation fault.

To fix the issue a guard is inserted in front of sigtrampgo, so that the control escapes from
signal handlers without touching G in case the signal occurred in the VDSO context.
The test case included in the patch is take from discussion in a relevant thread on github:
https://github.com/golang/go/issues/32912#issuecomment-517874531.
This patch not only fixes the issue on AArch64 but also that on 32bit ARM.

Fixes #32912

Change-Id: I657472e54b7aa3c617fabc5019ce63aa4105624a
GitHub-Last-Rev: 28ce42c4a0
GitHub-Pull-Request: golang/go#34030
Reviewed-on: https://go-review.googlesource.com/c/go/+/192937
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-09-11 03:32:35 +00:00
Sven Taute
8ef6d6a8f2 encoding/base32: increase performance and code reuse
Add benchmarks for the Encode/Decode functions operating on []byte and increase decoding performance by removing the calls to strings.Map/bytes.Map and reusing the newline filtering code that is used by NewDecoder.
Cut allocations in half for DecodeString.

Comparison using the new benchmarks:
name            old time/op    new time/op     delta
Encode            16.7µs ± 1%     17.0µs ± 2%    +2.25%  (p=0.000 n=9+9)
EncodeToString    21.1µs ± 1%     20.9µs ± 1%    -0.96%  (p=0.000 n=10+10)
Decode             141µs ± 1%       54µs ± 1%   -61.51%  (p=0.000 n=10+10)
DecodeString      81.4µs ± 0%     54.7µs ± 1%   -32.79%  (p=0.000 n=9+10)

name            old speed      new speed       delta
Encode           492MB/s ± 1%    481MB/s ± 2%    -2.19%  (p=0.000 n=9+9)
EncodeToString   389MB/s ± 1%    392MB/s ± 1%    +0.97%  (p=0.000 n=10+10)
Decode          93.0MB/s ± 1%  241.6MB/s ± 1%  +159.82%  (p=0.000 n=10+10)
DecodeString     161MB/s ± 0%    240MB/s ± 1%   +48.78%  (p=0.000 n=9+10)

Change-Id: Id53633514a9e14ecd0389d52114b2b8ca64370cb
GitHub-Last-Rev: f4be3cf55c
GitHub-Pull-Request: golang/go#30376
Reviewed-on: https://go-review.googlesource.com/c/go/+/163598
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-09-11 00:56:39 +00:00
Huan Du
4dc11ae26b reflect: fix panic in DeepEqual when checking a cycle
Before this change, when DeepEqual checks values with cycle, it may
panic due to stack overflow.

Here is a sample to reproduce the issue.

    makeCycleMap := func() interface{} {
        cycleMap := map[string]interface{}{}
        cycleMap["foo"] = cycleMap
        return cycleMap
    }

    m1 := makeCycleMap()
    m2 := makeCycleMap()
    reflect.DeepEqual(m1, m2) // stack overflow

The root cause is that DeepEqual fails to cache interface values
in visited map, which is used to detect cycle. DeepEqual calls
CanAddr to check whether a value should be cached or not. However,
all values referenced by interface don't have flagAddr thus all these
values are not cached.

THe fix is to remove CanAddr calls and use underlying ptr in value
directly. As ptr is only read-only in DeepEqual for caching, it's
safe to do so. We don't use UnsafeAddr this time, because this method
panics when CanAddr returns false.

Fixes #33907

Change-Id: I2aa88cc060a2c2192b1d34c129c0aad4bd5597e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/191940
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-09-11 00:56:01 +00:00
Marko Kungla
a5026af57c reflect: enhance docs for IsZero and IsValid
Make it clear that IsValid checks that we have valid
reflect.Value and not the value of `v`

fixes #34152

Change-Id: Ib3d359eeb3a82bf733b9ed17c777fc4c143bc29c
Reviewed-on: https://go-review.googlesource.com/c/go/+/193841
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-09-11 00:16:10 +00:00
Matthew Dempsky
b9704872d1 cmd/compile: better integrate parameter tagging with escape.go
This CL moves parameter tagging to before escape analysis is complete,
so we still have access to EscLocation. This will be useful once
EscLocation starts tracking higher-fidelity escape details.

Notably, this CL stops using n.Esc to record parameter escape analysis
details. Now escape analysis only ever sets n.Esc to EscNone or
EscHeap. (It still defaults to EscUnknown, and is set to EscNever in
some places though.)

Passes toolstash-check.

Updates #33981.

Change-Id: I50a91ea1e38c442092de6cd14e20b211f8f818c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/193178
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-09-10 23:01:30 +00:00
Pantelis Sampaziotis
68a6536848 regexp: add example for NumSubexp
Updates #21450

Change-Id: Idf276e97f816933cc0f752cdcd5e713b5c975833
GitHub-Last-Rev: 198e585f92
GitHub-Pull-Request: golang/go#33490
Reviewed-on: https://go-review.googlesource.com/c/go/+/189138
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-09-10 20:33:25 +00:00
Than McIntosh
cb30430af8 go/internal/gccgoimporter: remove guard on some assertions
Remove unnecessary conditional guard for a couple of assertions in the
type parser's update() method (inspired by comment from Robert). No
change in functionality.

Change-Id: I706a54569e75c6960768247889b7dec3f267dde9
Reviewed-on: https://go-review.googlesource.com/c/go/+/194565
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-09-10 19:57:03 +00:00
Bryan C. Mills
de4c0730cb cmd/go/internal/modfetch: report the module path for errors in (*codeRepo).Versions
Updates #34094

Change-Id: Ifd10b51c2b4ebe77c4f8f68726e411f54c13b9c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/194560
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-09-10 19:07:34 +00:00
Bryan C. Mills
5bb19e3454 cmd/go/internal/module: document Version usage for filesystem replacements
Updates #34085

Change-Id: I57250d0c51a27f0bd3e223588dde9d6d955e0fcf
Reviewed-on: https://go-review.googlesource.com/c/go/+/193618
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-09-10 19:03:09 +00:00
Ian Lance Taylor
0a3b65c492 go/internal/gccgoimporter: support embedded field in pointer loop
If an embedded field refers to a type via a pointer, the parser needs
to know the name of the embedded field. It is possible that the
pointer type is not yet resolved. This CL fixes the parser to handle
that case by setting the pointer element type to the unresolved named
type while the pointer is being resolved.

Fixes #34182

Change-Id: I48435e0404362a85effd7463685c502290fa3c57
Reviewed-on: https://go-review.googlesource.com/c/go/+/194440
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-09-10 17:21:14 +00:00
Matthew Dempsky
23bf6af996 cmd/compile: refactor escape analysis parameter tagging
No behavior change; just inverting the loop ordering so the
per-parameter behavior is a bit clearer.

Passes toolstash-check.

Updates #33981.

Change-Id: I9bfcd7d0a4aff65a27ced157767ca2ba8038319a
Reviewed-on: https://go-review.googlesource.com/c/go/+/193177
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-09-10 16:56:54 +00:00
andig
cf630586ca encoding/json: don't reset before returning buffer to pool
Reset is already performed when retrieving from pool

Change-Id: Ia810dd18d3e55a1565a5ad435a00d1e46724576c
GitHub-Last-Rev: d9df74a4ae
GitHub-Pull-Request: golang/go#34195
Reviewed-on: https://go-review.googlesource.com/c/go/+/194338
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2019-09-10 14:58:40 +00:00
Ian Lance Taylor
f668573a5e cmd/go: for gccgo, look for tool build ID before hashing entire file
Also fix the key used to store the ID.

This is a significant speedup in cmd/go run time when using an
unreleased toolchain. For example, the TestGoBuildTestOnly cmd/go test
goes from 15 seconds to 1 second.

Change-Id: Ibfd697d55084db059c6b563f70f71f635e935391
Reviewed-on: https://go-review.googlesource.com/c/go/+/194441
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-09-10 14:25:46 +00:00
Michael Munday
5c5f217b63 cmd/compile: improve s390x sign/zero extension removal
This CL gets rid of the MOVDreg and MOVDnop SSA operations on
s390x. They were originally inserted to help avoid situations
where a sign/zero extension was elided but a spill invalidated
the optimization. It's not really clear we need to do this though
(amd64 doesn't have these ops for example) so long as we are
careful when removing sign/zero extensions. Also, the MOVDreg
technique doesn't work if the register is spilled before the
MOVDreg op (I haven't seen that in practice).

Removing these ops reduces the complexity of the rules and also
allows us to unblock optimizations. For example, the compiler can
now merge the loads in binary.{Big,Little}Endian.PutUint16 which
it wasn't able to do before. This CL reduces the size of the .text
section in the go tool by about 4.7KB (0.09%).

Change-Id: Icaddae7f2e4f9b2debb6fabae845adb3f73b41db
Reviewed-on: https://go-review.googlesource.com/c/go/+/173897
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-09-10 13:17:24 +00:00
Agniva De Sarker
b38be35e4c cmd/compile: optimize const rotates for wasm architecture
This removes the unnecessary code to check whether the shift
is within limits or not when the shift amount is a constant.

The rules hit 23034 times when building std cmd.

grep -E "Wasm.rules:(106|107|121|122|139|140)" rulelog | wc -l
23034

Reduces the size of pkg/js_wasm by 132 bytes.

Change-Id: I64a2b8faca08c3b5039d6a027d4676130d2db18d
Reviewed-on: https://go-review.googlesource.com/c/go/+/194239
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Richard Musiol <neelance@gmail.com>
2019-09-10 09:12:32 +00:00
Romain Baugue
b6ec56bc26 encoding/json: don't indirect pointers when decoding null
The indirect method checked the type of the child when indirecting a
pointer. If the current value is a pointer and we are decoding null, we
can skip this entirely and return early, avoiding the whole descent.

Fixes #31776

Change-Id: Ib8b2a2357572c41f56fceac59b5a858980f3f65e
Reviewed-on: https://go-review.googlesource.com/c/go/+/174699
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2019-09-10 08:24:29 +00:00
Robert Griesemer
cdd2c265cc cmd/compile/internal/scanner: report at most one lexical error per number literal
Leave reporting of multiple errors for strings alone for now;
we probably want to see all incorrect escape sequences in
runes/strings independent of other errors.

Fixes #33961.

Change-Id: Id722e95f802687963eec647d1d1841bd6ed17d35
Reviewed-on: https://go-review.googlesource.com/c/go/+/192499
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-09-10 03:10:11 +00:00
Matthew Dempsky
a2cf16d42c cmd/compile: remove vestigial TDDDFIELD
Change-Id: I4a582f8efcf413665a7513c163334fa8d978a7e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/194437
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-09 23:17:01 +00:00
sergeilem
a3a1bdff79 encoding/asn1: handle ASN1's string type BMPString
This code enables handling of ASN1's string type BMPString, used in some digital signatures.
Parsing code taken from golang.org/x/crypto/pkcs12.

Change-Id: Ibeae9cf4d8ae7c18f8b5420ad9244a16e117ff6b
GitHub-Last-Rev: 6945253514
GitHub-Pull-Request: golang/go#26690
Reviewed-on: https://go-review.googlesource.com/c/go/+/126624
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2019-09-09 23:04:30 +00:00
Eric Rutherford
5e907e38b8 path: improve documentation to call out cases where Clean is called
Rewording the comments for Join to do a better job of calling out
when Clean is called. Also clarifing other portions of the comment.

Fixes #29875

Change-Id: Ied43983bb10a97922898d28af133de0930224496
Reviewed-on: https://go-review.googlesource.com/c/go/+/194339
Reviewed-by: Rob Pike <r@golang.org>
2019-09-09 22:56:39 +00:00
Matthew Dempsky
e710a1fb2e cmd/compile: report more precise errors about untyped constants
Previously, we used a single "untyped number" type for all untyped
numeric constants. This led to vague error messages like "string(1.0)"
reporting that "1 (type untyped number)" can't be converted to string,
even though "string(1)" is valid.

This CL makes cmd/compile more like go/types by utilizing
types.Ideal{int,rune,float,complex} instead of types.Types[TIDEAL],
and keeping n.Type in sync with n.Val().Ctype() during constant
folding.

Thanks to K Heller for looking into this issue, and for the included
test case.

Fixes #21979.

Change-Id: Ibfea88c05704bc3c0a502a455d018a375589754d
Reviewed-on: https://go-review.googlesource.com/c/go/+/194019
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-09-09 22:12:15 +00:00
Ainar Garipov
51c8d969bd src: gofmt -s
Change-Id: I56d7eeaf777ac30886ee77428ca1ac72b77fbf7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/193849
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-09 18:57:05 +00:00
Eli Bendersky
28f8f55bd2 encoding/json: clarify Unmarshal behavior for map keys
This is a documentation-only change

Fixes #33298

Change-Id: I816058a872b57dc868dff11887214d9de92d9342
Reviewed-on: https://go-review.googlesource.com/c/go/+/188821
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-09 17:28:54 +00:00
Martin Möhrmann
5bb59b6d16 Revert "compile: prefer an AND instead of SHR+SHL instructions"
This reverts commit 9ec7074a94.

Reason for revert: broke s390x (copysign, abs) and arm64 (bitfield) tests.

Change-Id: I16c1b389c062e8c4aa5de079f1d46c9b25b0db52
Reviewed-on: https://go-review.googlesource.com/c/go/+/193850
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
Reviewed-by: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-09 07:33:25 +00:00
Martin Möhrmann
9ec7074a94 compile: prefer an AND instead of SHR+SHL instructions
On modern 64bit CPUs a SHR, SHL or AND instruction take 1 cycle to execute.
A pair of shifts that operate on the same register will take 2 cycles
and needs to wait for the input register value to be available.

Large constants used to mask the high bits of a register with an AND
instruction can not be encoded as an immediate in the AND instruction
on amd64 and therefore need to be loaded into a register with a MOV
instruction.

However that MOV instruction is not dependent on the output register and
on many CPUs does not compete with the AND or shift instructions for
execution ports.

Using a pair of shifts to mask high bits instead of an AND to mask high
bits of a register has a shorter encoding and uses one less general
purpose register but is slower due to taking one clock cycle longer
if there is no register pressure that would make the AND variant need to
generate a spill.

For example the instructions emitted for (x & 1 << 63) before this CL are:
48c1ea3f                SHRQ $0x3f, DX
48c1e23f                SHLQ $0x3f, DX

after this CL the instructions are the same as GCC and LLVM use:
48b80000000000000080    MOVQ $0x8000000000000000, AX
4821d0                  ANDQ DX, AX

Some platforms such as arm64 already have SSA optimization rules to fuse
two shift instructions back into an AND.

Removing the general rule to rewrite AND to SHR+SHL speeds up this benchmark:

var GlobalU uint

func BenchmarkAndHighBits(b *testing.B) {
	x := uint(0)
	for i := 0; i < b.N; i++ {
		x &= 1 << 63
	}
	GlobalU = x
}

amd64/darwin on Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz:
name           old time/op  new time/op  delta
AndHighBits-4  0.61ns ± 6%  0.42ns ± 6%  -31.42%  (p=0.000 n=25+25):

Updates #33826
Updates #32781

Change-Id: I862d3587446410c447b9a7265196b57f85358633
Reviewed-on: https://go-review.googlesource.com/c/go/+/191780
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-09-09 06:49:17 +00:00
Keisuke Kishimoto
844e642392 syscall: minor cleanup of duplicated code
Call the Nano methods of Timespec and Timeval in TimespecToNsec and
TimevalToNsec respectively, instead of duplicating the implementation.

Change-Id: I17551ea54c59c1e45ce472e029c625093a67251a
GitHub-Last-Rev: fecf43d163
GitHub-Pull-Request: golang/go#33390
Reviewed-on: https://go-review.googlesource.com/c/go/+/188397
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-09 03:11:53 +00:00
Ainar Garipov
0efbd10157 all: fix typos
Use the following (suboptimal) script to obtain a list of possible
typos:

  #!/usr/bin/env sh

  set -x

  git ls-files |\
    grep -e '\.\(c\|cc\|go\)$' |\
    xargs -n 1\
    awk\
    '/\/\// { gsub(/.*\/\//, ""); print; } /\/\*/, /\*\// { gsub(/.*\/\*/, ""); gsub(/\*\/.*/, ""); }' |\
    hunspell -d en_US -l |\
    grep '^[[:upper:]]\{0,1\}[[:lower:]]\{1,\}$' |\
    grep -v -e '^.\{1,4\}$' -e '^.\{16,\}$' |\
    sort -f |\
    uniq -c |\
    awk '$1 == 1 { print $2; }'

Then, go through the results manually and fix the most obvious typos in
the non-vendored code.

Change-Id: I3cb5830a176850e1a0584b8a40b47bde7b260eae
Reviewed-on: https://go-review.googlesource.com/c/go/+/193848
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-09-08 17:28:20 +00:00
Elias Naur
83a78eb911 syscall: re-generate zsyscall_darwin_arm*.s
I missed that in CL 193843.

Updates #34133

Change-Id: I70b420f022cc7f8289f07375bfc2ade20cf3ffe7
Reviewed-on: https://go-review.googlesource.com/c/go/+/193846
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-09-08 09:20:26 +00:00
Elias Naur
2711fababd net,os: disable more sysctl tests on iOS
Updates #34133

Change-Id: I27c75993176cf876f2d80f70982528258c509b68
Reviewed-on: https://go-review.googlesource.com/c/go/+/193845
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-09-07 22:40:14 +00:00
smasher164
141b09726d net/http: make copyValues append instead of calling Add
This results in a performance boost:

name          old time/op    new time/op    delta
CopyValues-4    3.46µs ± 3%    1.53µs ± 3%  -55.85%  (p=0.000 n=18+19)

name          old alloc/op   new alloc/op   delta
CopyValues-4    1.52kB ± 0%    0.74kB ± 0%  -51.58%  (p=0.000 n=20+20)

name          old allocs/op  new allocs/op  delta
CopyValues-4      24.0 ± 0%      11.0 ± 0%  -54.17%  (p=0.000 n=20+20)

Fixes #33744.

Change-Id: Ibc653fb076a9a6aaa775fcc9ca720fb90e68cf96
Reviewed-on: https://go-review.googlesource.com/c/go/+/191057
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-09-07 22:21:30 +00:00
Elias Naur
a5025fdcde log/syslog: skip unsupported tests on iOS
CL 193843 disabled sysctl on iOS. This change disables two tests that
rely on sysctl.

Updates #34133

Change-Id: I7c569a1992a50ad6027a294c1fd535cccddcfc4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/193844
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-09-07 21:44:30 +00:00
Elias Naur
78d9949103 syscall: disable sysctl on iOS
Sysctl is blocked by the App Store submission checks.

Fixes #34133

Change-Id: I9e83cf87e942d6249e9bb67a95dba230e44badd9
Reviewed-on: https://go-review.googlesource.com/c/go/+/193843
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-09-07 18:43:44 +00:00
Joel Sing
7ef890db91 cmd/internal/obj: instructions and registers for RISC-V
Start implementing an assembler for RISC-V - this provides register
definitions and instruction mnemonics as defined in the RISC-V
Instruction Set Manual, along with instruction encoding.

The instruction encoding is generated by the parse_opcodes script with
the "opcodes" and "opcodes-pseudo" files from (`make inst.go`):

  https://github.com/riscv/riscv-opcodes

This is based on the riscv-go port:

  https://github.com/riscv/riscv-go

Contributors to the riscv-go port are:

  Amol Bhave <ammubhave@gmail.com>
  Benjamin Barenblat <bbaren@google.com>
  Josh Bleecher Snyder <josharian@gmail.com>
  Michael Pratt <michael@pratt.im>
  Michael Yenik <myenik@google.com>
  Ronald G. Minnich <rminnich@gmail.com>
  Stefan O'Rear <sorear2@gmail.com>

This port has been updated to Go 1.13:

  https://github.com/4a6f656c/riscv-go

Updates #27532

Change-Id: I257b6de87e9864df61a2b0ce9be15968c1227b49
Reviewed-on: https://go-review.googlesource.com/c/go/+/193677
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-09-07 13:24:59 +00:00
Joel Sing
112a72a020 cmd/asm/internal/arch: consolidate LinkArch handling
Rather than manually setting the LinkArch for each case, pass the correct
*obj.LinkArch to the arch* function, as is already done for archX86().

Change-Id: I4cf950780aa30a1385e785fb1d26edacb99bda79
Reviewed-on: https://go-review.googlesource.com/c/go/+/193818
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-07 09:43:04 +00:00
Emmanuel T Odeke
3a067f71e9 net: handle >=2GiB files with sendfile on Windows
CL 187037 applied a fix to handle the case where
files larger than 2GiB were not being sendfile-d,
in one shot, rejecting any files whose size was
larger than the 2GiB.

This CL allows files that are larger than limit
by SendFile-ing in chunks of upto 2GiB per chunk.

The test has been excluded as testing with 3GB
requires creating a local file, flushing it
and then doing sendfile which takes a while
and could cause flakes on computers without capacity,
but the test can be retroactively accessed at:
https://go-review.googlesource.com/c/go/+/192518/8/src/net/sendfile_windows_test.go

Fixes #33193.

Change-Id: If57c25bc289aec82b748890ac1ac4f55798d6a5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/192518
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-09-07 08:46:41 +00:00
Matthew Dempsky
581526ce96 cmd/compile: rewrite untyped constant conversion logic
This CL detangles the hairy mess that was convlit+defaultlit. In
particular, it makes the following changes:

1. convlit1 now follows the standard typecheck behavior of setting
"n.Type = nil" if there's an error. Notably, this means for a lot of
test cases, we now avoid reporting useless follow-on error messages.
For example, after reporting that "1 << s + 1.0" has an invalid shift,
we no longer also report that it can't be assigned to string.

2. Previously, assignconvfn had some extra logic for trying to
suppress errors from convlit/defaultlit so that it could provide its
own errors with better context information. Instead, this extra
context information is now passed down into convlit1 directly.

3. Relatedly, this CL also removes redundant calls to defaultlit prior
to assignconv. As a consequence, when an expression doesn't make sense
for a particular assignment (e.g., assigning an untyped string to an
integer), the error messages now say "untyped string" instead of just
"string". This is more consistent with go/types behavior.

4. defaultlit2 is now smarter about only trying to convert pairs of
untyped constants when it's likely to succeed. This allows us to
report better error messages for things like 3+"x"; instead of "cannot
convert 3 to string" we now report "mismatched types untyped number
and untyped string".

Passes toolstash-check.

Change-Id: I26822a02dc35855bd0ac774907b1cf5737e91882
Reviewed-on: https://go-review.googlesource.com/c/go/+/187657
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-09-06 23:15:48 +00:00
Matthew Dempsky
ad1f2c9618 cmd/compile: use CTNIL for pointer-typed OLITERALs
We used to be more aggressive about constant folding in the frontend,
handling expressions that the Go spec does not consider constant;
e.g., "(*int)(unsafe.Pointer(uintptr(200)))". However, that led to a
lot of subtle Go spec conformance issues, so we've since abandoned
that effort (CL 151320), leaving SSA to handle these cases instead.

As such, the only time we now end up with pointer-typed OLITERALs is
when "nil" is implicitly converted to a pointer-typed variable.
Instead of representing these OLITERALs with an CTINT of 0, we can
just use CTNIL.

Saves a few bytes of memory and lines of code.

Change-Id: Ibc5c756b992fdc89c3bdaf4fda3aa352e8e2b101
Reviewed-on: https://go-review.googlesource.com/c/go/+/193437
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-09-06 22:55:17 +00:00
Matthew Dempsky
e6ba19f913 Revert "cmd/compile: improve errors for invalid conversions of consts"
This reverts commit 2da9c3e0f9.

Reason for revert: while the new error messages are more informative,
they're not strictly correct. This CL also conflicts with CL 187657.

Change-Id: I1c36cf7e86c2f35ee83a4f98918ee38aa1f59965
Reviewed-on: https://go-review.googlesource.com/c/go/+/193977
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-09-06 22:44:48 +00:00
Mihai Borobocea
8a8cf5bf6d text/template: refer to sorted map keys as "ordered" not "comparable" in docs
Consistent with the spec's definition of "ordered" and "comparable".

Fixes #34147

Change-Id: Id13186df5343588d80eaebfeb23092596a846d51
Reviewed-on: https://go-review.googlesource.com/c/go/+/193840
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2019-09-06 21:22:26 +00:00
Matthew Dempsky
5e43856aa9 cmd/compile: rename Etype to ctxType
golang.org/cl/150140 renamed the other Efoo constants to ctxFoo, but
forgot about Etype.

gorename -from '"cmd/compile/internal/gc".Etype -to ctxType

Change-Id: I142dd42ca84a398f8d2316d75ead3331c023b820
Reviewed-on: https://go-review.googlesource.com/c/go/+/193958
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2019-09-06 20:05:29 +00:00
K. "pestophagous" Heller
2da9c3e0f9 cmd/compile: improve errors for invalid conversions of consts
Follow-up to Change-Id: If6e52c59eab438599d641ecf6f110ebafca740a9

This addresses the remaining tech debt on issue 21979.

The aforementioned previous CL silenced one of two mostly redundant
compiler errors. However, the silenced error was the more expressive
error. This CL now imbues the surviving error with the same level
of expressiveness as the old semi-redundant error.

Fixes #21979

Change-Id: I3273d48c88bbab073fabe53421d801df621ce321
Reviewed-on: https://go-review.googlesource.com/c/go/+/191079
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-09-06 18:03:49 +00:00
Joel Sing
a3ceb57fb4 cmd/internal/sys: provide architecture definition for riscv64
Updates #27532

Change-Id: I7ecf5239d6bc49408a2f155d0f5398ee716fd443
Reviewed-on: https://go-review.googlesource.com/c/go/+/193678
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-09-06 17:49:50 +00:00
Yuval Pavel Zholkover
c78ac39ae9 cmd/link: use gold when dynamic linking on arm,arm64 only on Linux and Android
Fixes freebsd/arm build.

Change-Id: Id9b1905a5335f86d317dab7514e0ce7cb74aba1d
Reviewed-on: https://go-review.googlesource.com/c/go/+/193537
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-09-06 17:41:07 +00:00
Sjoerd Siebinga
e3d3e115e8 cmd/go: add a test for -sectcreate in LDFLAGS
It was already covered by a regex pattern, but it didn't have a test.

To fix the issue for good, added regression test.

Fixes #28832.

Change-Id: I861e3bed92d3b9484fd8671270dbd2e264b10d2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/191311
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-06 17:34:02 +00:00
Cuong Manh Le
d535501a8e cmd/compile: remove tempname usages
CL 59610 merged tempname to tempAt, but some of comments and error
message still refer to tempname. So changing to tempAt instead.

Change-Id: I032f3bedc135d17124b0daaf22c97d0d5ada0a6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/193817
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-09-06 16:59:11 +00:00
Than McIntosh
b1a20253fe cmd/link: memoize/cache whether plugin.Open symbol available
Perform a single lookup of "plugin.Open" at the point where we set the
loaded flag for the context, then cache whether the result is nil, so
that we can consult this cached value later on (instead of having to
look up the symbol each time). This helps speed up the DynLinkingGo()
context method, which is called from within some very hot loops in the
linker (when linking 'hyperkube' from kubernetes, reduces total calls
to "sym.(*Symbols).ROLookup" from 6.5M to 4.3M)

Change-Id: I92a2ea2b21d24f67aec0a7afeef4acc77c095adf
Reviewed-on: https://go-review.googlesource.com/c/go/+/193260
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-09-06 12:16:32 +00:00
Matthew Dempsky
9da99049ba cmd/compile: restore lineno before returning in defaultlitreuse
This affects the position information that's associated with the
implicit OCONV nodes created in assignconvfn.

Not super important and the followup rewrite CL fixes this too, but
fixing it separately is easy and makes toolstash-check happier.

Change-Id: Ifd65dc524b367812d14a4d996647a5d40665fb38
Reviewed-on: https://go-review.googlesource.com/c/go/+/193606
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-09-06 06:20:27 +00:00
Ian Lance Taylor
3aae49b8b4 cmd/dist: default to clang on OpenBSD
OpenBSD ships with GCC 4.2, the last version of GCC that used GPLv2.
As that is quite old (current GCC version is GCC 9, GCC 4.2 was
released in 2007), default to clang.

Change-Id: Ib93e7b4f4f3ffb9e047e60ffca3696d26ab08aac
Reviewed-on: https://go-review.googlesource.com/c/go/+/193621
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-06 04:54:12 +00:00
Cuong Manh Le
1406ece446 cmd/compile: preserve loop depth when evaluating block
Add block method to preserve loop depth when evaluating statements in a
block, so escape analysis can handle looping label more precisely.

Updates #22438

Change-Id: I39b306544a6c0ee3fcbebbe0d0ee735cb71773e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/193517
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-09-06 01:35:46 +00:00
Ian Lance Taylor
c99598cbd3 errors: clarify docs for when As returns false
Change-Id: Ic8d8399f726c1f9376499fdae92bea41632586ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/193602
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2019-09-06 00:03:32 +00:00
psampaz
2b6b474f64 regexp: add example for ReplaceAll
Updates #21450

Change-Id: Ia31c20b52bae5daeb33d918234c2f0944a8aeb07
GitHub-Last-Rev: cc85544770
GitHub-Pull-Request: golang/go#33489
Reviewed-on: https://go-review.googlesource.com/c/go/+/189137
Run-TryBot: Sylvain Zimmer <sylvinus@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-09-05 23:52:39 +00:00
Richard Musiol
547021d723 cmd/internal/obj/wasm: refactor handling of wasm variables
This commit improves how registers get mapped to wasm variables. This
is a preparation for future improvements (e.g. adding 32 bit float
registers).

Change-Id: I374c80b2d6c9bcce6b0e373fe921b5ad4dee40ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/191777
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-09-05 21:27:49 +00:00
Michael Knyszek
aae0b5b0b2 runtime: use hard heap goal if we've done more scan work than expected
This change makes it so that if we're already finding ourselves in a
situation where we've done more scan work than expected in the
steady-state (that is, 50% of heap_scan for GOGC=100), then we fall back
on the hard heap goal instead of continuing to assume the expected case.

In some cases its possible that we're already doing more scan work than
expected, and if GC assists come in just at that window where we notice
it, they might accumulate way too much assist credit, causing undue heap
growths if GOMAXPROCS=1 (since the fractional background worker isn't
guaranteed to fire). This case seems awfully specific, and that's
because it's exactly the case for TestGcSys, which has been flaky for
some time as a result.

Fixes #28574, #27636, and #27156.

Change-Id: I771f42bed34739dbb1b84ad82cfe247f70836031
Reviewed-on: https://go-review.googlesource.com/c/go/+/184097
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-09-04 21:52:18 +00:00
Bryan C. Mills
d21953df04 cmd/go/internal/test: prepend -test.timeout rather than appending
Tests may accept positional arguments, in which case the -test.timeout
flag must be passed before those arguments.

Fixes #34072

Change-Id: I5b92d7c0edc4f9e1efb63b0733937b76236c0eff
Reviewed-on: https://go-review.googlesource.com/c/go/+/193297
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-09-04 20:38:05 +00:00
Austin Clements
5ff38e4761 runtime: platform-independent faketime support
This adds a platform-independent implementation of nacl's faketime
support. It can be enabled by setting the faketime build tag.

Updates #30439.

Change-Id: Iee097004d56d796e6d2bfdd303a092c067ade87e
Reviewed-on: https://go-review.googlesource.com/c/go/+/192740
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-04 17:56:53 +00:00
Austin Clements
0607cdda6b syscall: redirect writes to runtime.write in faketime mode
If the faketime build tag is set, this causes syscall.Write for FDs 1
and 2 to redirect to runtime.write, since that's where we'll apply the
faketime framing. This is equivalent to what nacl currently does in
naclFile.write.

We do this on all of the platforms except nacl, which has its own
faketime support and we're about to remove, and Windows, which would
require other changes to support faketime so we're leaving alone for
now.

Updates #30439.

Change-Id: I138a5ca63577d92d15b5437d037bd3159fa84ee7
Reviewed-on: https://go-review.googlesource.com/c/go/+/192739
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-09-04 17:56:17 +00:00
Austin Clements
4af3c17f8c runtime: wrap nanotime, walltime, and write
In preparation for general faketime support, this renames the existing
nanotime, walltime, and write functions to nanotime1, walltime1, and
write1 and wraps them with trivial Go functions. This will let us
inject different implementations on all platforms when faketime is
enabled.

Updates #30439.

Change-Id: Ice5ccc513a32a6d89ea051638676d3ee05b00418
Reviewed-on: https://go-review.googlesource.com/c/go/+/192738
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-04 17:56:09 +00:00
Bryan C. Mills
6719d889e1 cmd/go/internal/get: avoid panic in metaImportsForPrefix if web.Get fails
Fixes #34049

Change-Id: I817b83ee2d0ca6d01ec64998f14bc4f32e365d66
Reviewed-on: https://go-review.googlesource.com/c/go/+/193259
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-09-04 17:09:25 +00:00
Jonathan Amsterdam
d9a3d902ec errors: fix wrong code in package doc
You can't call Unwrap on the return value of fmt.Errorf, but
you can pass the result to errors.Unwrap.

Also, move the description of the Unwrap function up so the
example makes sense.

Fixes #34061.

Change-Id: Ica07c44665c5e65deea4aa6a146fc543a5a0a99d
Reviewed-on: https://go-review.googlesource.com/c/go/+/193298
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Katie Hockman <katie@golang.org>
2019-09-04 17:08:55 +00:00
Michael Anthony Knyszek
7b294cdd8d runtime: don't hold worldsema across mark phase
This change makes it so that worldsema isn't held across the mark phase.
This means that various operations like ReadMemStats may now stop the
world during the mark phase, reducing latency on such operations.

Only three such operations are still no longer allowed to occur during
marking: GOMAXPROCS, StartTrace, and StopTrace.

For the former it's because any change to GOMAXPROCS impacts GC mark
background worker scheduling and the details there are tricky.

For the latter two it's because tracing needs to observe consistent GC
start and GC end events, and if StartTrace or StopTrace may stop the
world during marking, then it's possible for it to see a GC end event
without a start or GC start event without an end, respectively.

To ensure that GOMAXPROCS and StartTrace/StopTrace cannot proceed until
marking is complete, the runtime now holds a new semaphore, gcsema,
across the mark phase just like it used to with worldsema.

Fixes #19812.

Change-Id: I15d43ed184f711b3d104e8f267fb86e335f86bf9
Reviewed-on: https://go-review.googlesource.com/c/go/+/182657
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-09-04 15:53:59 +00:00
Tobias Klauser
033299fab6 all: add a space before +build in build tag comments
Add a space before build tag comments so it corresponds to the format
documented at https://golang.org/pkg/go/build/.

Change-Id: I8349d0343597e304b97fb5479847231ed8945b1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/193237
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-04 15:10:03 +00:00
Filippo Valsorda
1452119867 crypto/x509: remove IsCA exception for broken Entrust root
The exception allowed a specific intermediate [1] to chain up to a
broken root that lacked the CA:TRUE X509v3 Basic Constraint.

The broken root [2] is expiring at the end of 2019, so we can remove the
exception in Go 1.14.

Moreover, there is a reissued version of that root [3] (same Subject and
SPKI, valid CA) which expires in 2029, so root stores should have
migrated to it already, making the exception unnecessary.

[1]: https://crt.sh/?caid=57
[2]: https://crt.sh/?id=1616049
[3]: https://crt.sh/?id=55

Change-Id: I43f51100982791b0e8bac90d143b60851cd46dfc
Reviewed-on: https://go-review.googlesource.com/c/go/+/193038
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-03 21:10:31 +00:00
Keith Randall
36f30ba289 cmd/compile,runtime: generate hash functions only for types which are map keys
Right now we generate hash functions for all types, just in case they
are used as map keys. That's a lot of wasted effort and binary size
for types which will never be used as a map key. Instead, generate
hash functions only for types that we know are map keys.

Just doing that is a bit too simple, since maps with an interface type
as a key might have to hash any concrete key type that implements that
interface. So for that case, implement hashing of such types at
runtime (instead of with generated code). It will be slower, but only
for maps with interface types as keys, and maybe only a bit slower as
the aeshash time probably dominates the dispatch time.

Reorg where we keep the equals and hash functions. Move the hash function
from the key type to the map type, saving a field in every non-map type.
That leaves only one function in the alg structure, so get rid of that and
just keep the equal function in the type descriptor itself.

cmd/go now has 10 generated hash functions, instead of 504. Makes
cmd/go 1.0% smaller. Update #6853.

Speed on non-interface keys is unchanged. Speed on interface keys
is ~20% slower:

name                  old time/op  new time/op  delta
MapInterfaceString-8  23.0ns ±21%  27.6ns ±14%  +20.01%  (p=0.002 n=10+10)
MapInterfacePtr-8     19.4ns ±16%  23.7ns ± 7%  +22.48%   (p=0.000 n=10+8)

Change-Id: I7c2e42292a46b5d4e288aaec4029bdbb01089263
Reviewed-on: https://go-review.googlesource.com/c/go/+/191198
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
2019-09-03 20:41:29 +00:00
Ian Lance Taylor
aee084b3ca cmd/compile/internal/gc: use GoToolPath in TestDeps
Updates #31563
Fixes #34041

Change-Id: Ib9fdcd2f83d867fd31b42eab3a813f5cef88860e
Reviewed-on: https://go-review.googlesource.com/c/go/+/193077
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-09-03 19:54:33 +00:00
Keith Randall
7c90e2cbda bytes/hash: disable seed test on 32-bit platforms
The distribution of hash outputs when varying the seed is
not good enough on 32-bit platforms.

This isn't a likely attack vector (the adversary controlling the seed),
so it isn't a huge deal. Would be nice to fix, though. For now, just
skip this test.

Fixes #33988

Change-Id: Icf51ab687fc215422a5492ae78e6f414b33e04cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/193078
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-03 19:37:16 +00:00
Cuong Manh Le
d2f958d8d1 cmd/compile: extend ssa.go to handle 1-element array and 1-field struct
Assinging to 1-element array/1-field struct variable is considered clobbering
the whole variable. By emitting OpVarDef in this case, liveness analysis
can now know the variable is redefined.

Also, the isfat is not necessary anymore, and will be removed in follow up CL.

Fixes #33916

Change-Id: Iece0d90b05273f333d59d6ee5b12ee7dc71908c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/192979
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-09-03 19:33:04 +00:00
Than McIntosh
9da7abd2eb debug/dwarf: better handling for DW_FORM_indirect
Fix a buglet in abbrev processing related to DW_FORM_indirect. When
reading an abbrev entry if we encounter an attribute with form
DW_FORM_indirect, leave the class as ClassUnknown, then when the
abbrev is walked during the reading of the DIE fill in the class based
on the value read at that point (code for handling DW_FORM_indirect
seems to be already partially in place in the DIE reader).

Updates #33488.

Change-Id: I9dc89abf5cc8d7ea96824c0011bef979de0540bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/190158
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2019-09-03 18:35:32 +00:00
Matthew Dempsky
9f89edcd96 cmd/compile: silence esc diagnostics about directiface OCONVIFACEs
In general, a conversion to interface type may require values to be
boxed, which in turn necessitates escape analysis to determine whether
the boxed representation can be stack allocated.

However, esc.go used to unconditionally print escape analysis
decisions about OCONVIFACE, even for conversions that don't require
boxing (e.g., pointers, channels, maps, functions).

For test compatibility with esc.go, escape.go similarly printed these
useless diagnostics. This CL removes the diagnostics, and updates test
expectations accordingly.

Change-Id: I97c57a4a08e44d265bba516c78426ff4f2bf1e12
Reviewed-on: https://go-review.googlesource.com/c/go/+/192697
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-09-03 17:52:06 +00:00
Matthew Dempsky
a71967e4c5 cmd/compile: replace copytype to setUnderlying
While here, change the params to be easier to understand: "t" is now
always the type being updated, and "underlying" is now used to
represent the underlying type.

Updates #33658.

Change-Id: Iabb64414ca3abaa8c780e4c9093e0c77b76fabf9
Reviewed-on: https://go-review.googlesource.com/c/go/+/192724
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-09-03 17:50:54 +00:00
Matthew Dempsky
380ef6b759 cmd/compile: simplify {defer,resume}checkwidth logic
This CL extends {defer,resume}checkwidth to support nesting, which
simplifies usage.

Updates #33658.

Change-Id: Ib3ffb8a7cabfae2cbeba74e21748c228436f4726
Reviewed-on: https://go-review.googlesource.com/c/go/+/192721
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-09-03 17:38:32 +00:00
Ian Lance Taylor
adf20ee3c5 debug/dwarf, debug/elf: support DWARF 5
Change-Id: I6e9d47865c198299d497911c58235cd40f775e34
Reviewed-on: https://go-review.googlesource.com/c/go/+/175138
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-09-03 17:37:24 +00:00
Ian Lance Taylor
663680b3d4 debug/dwarf: add new constants defined in DWARF 5
Also add a few other missing constants.

Also rerun current version of stringer.

Change-Id: I004ef27f6b40fe2cab64c52d169255dfea43fa01
Reviewed-on: https://go-review.googlesource.com/c/go/+/175137
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2019-09-03 17:32:37 +00:00
Changkun Ou
3c56143442 runtime: one lock per order
This CL implements one lock per order of stackpool. It improves performance when mutator stack growth deeply, see benchmark below:

```
name                old time/op  new time/op  delta
StackGrowth-8       3.60ns ± 5%  3.59ns ± 1%    ~     (p=0.794 n=10+9)
StackGrowthDeep-8    370ns ± 1%   335ns ± 1%  -9.47%  (p=0.000 n=9+9)
StackCopyPtr-8      72.6ms ± 0%  71.6ms ± 1%  -1.31%  (p=0.000 n=9+9)
StackCopy-8         53.5ms ± 0%  53.2ms ± 1%  -0.54%  (p=0.006 n=8+9)
StackCopyNoCache-8   100ms ± 0%    99ms ± 0%  -0.70%  (p=0.000 n=8+8)
```

Change-Id: I1170d3fd9e6ff8516e25f669d0aaf1861311420f
GitHub-Last-Rev: 13b820cddd
GitHub-Pull-Request: golang/go#33399
Reviewed-on: https://go-review.googlesource.com/c/go/+/188478
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-09-03 17:10:37 +00:00
Ayan George
88ca80b322 plugin: add freebsd/amd64 plugin support
Change-Id: I4e7b0e99fd0f6f7d6a8ef60e9d3cb5baeb80a2b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/191617
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-09-03 14:27:24 +00:00
Daniel Martí
b36a7a502a Revert "runtime: remove slow time compatibility hacks for wine"
This reverts CL 191759.

Reason for revert: broke most Go programs using the time package on Wine,
including on 4.15, the latest stable version. Only wine-staging (with
experimental patches) contains an upstream fix we could rely on.

Change-Id: Ic8ba126022e54f412174042fbb9abed82d5eb318
Reviewed-on: https://go-review.googlesource.com/c/go/+/192622
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-09-02 21:46:03 +00:00
Ivan Trubach
060669a689 cmd/doc: make -src mode deterministic
These changes make cmd/doc -src deterministic, or, more precisely,
go/ast.MergePackageFiles, which is used by cmd/doc. So far the order of
comments depended on the package file map iteration order.

cmd/doc with -src flag has been inserting and omitting random comments
ever since the addition of -src flag. After investigating the code path
with the debugger, I’ve noticed that ast.File.Comments slice order changes
between invocations of the command. The bug was introduced in 3e24f2d,
which ironically claimed to “fix formatting of -src output”. The commit
implemented the collection of comments by iterating over the map and
c7cdce1 “godoc: make ?m=src mode deterministic” did’t actually make
go/ast.MergePackageFiles deterministic.

I’ve found this issue after running “go doc -src sync.WaitGroup.Wait”.
There are likely other packages and functions affected, but the bug
should be somewhat reproducible across all Go versions.

Change-Id: Iae223e99550c0a3b54005c5cde36f909e655b66b
GitHub-Last-Rev: c49532f79f
GitHub-Pull-Request: golang/go#33553
Reviewed-on: https://go-review.googlesource.com/c/go/+/189477
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-09-02 15:31:19 +00:00
tomocy
2f04903fec net: document concurrency safety and example for Dialer
Fixes #33743.

Change-Id: I80621321d56b6cf312a86e272800f1ad03c5544c
GitHub-Last-Rev: d91cb36975
GitHub-Pull-Request: golang/go#33856
Reviewed-on: https://go-review.googlesource.com/c/go/+/191879
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-09-02 14:47:38 +00:00
Daniel Martí
03ac39ce5e std: remove unused bits of code all over the place
Some were never used, and some haven't been used for years.

One exception is net/http's readerAndCloser, which was only used in a
test. Move it to a test file.

While at it, remove a check in regexp that could never fire; the field
is an uint32, so it can never be negative.

Change-Id: Ia2200f6afa106bae4034045ea8233b452f38747b
Reviewed-on: https://go-review.googlesource.com/c/go/+/192621
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-02 12:57:37 +00:00
peter zhang
d5fe73393c math/big: fix a duplicate "the" in a comment
Change-Id: Ib637381ab8a12aeb798576b781e1b3c458ba812d
GitHub-Last-Rev: 12994496b6
GitHub-Pull-Request: golang/go#34017
Reviewed-on: https://go-review.googlesource.com/c/go/+/192877
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2019-09-02 11:42:47 +00:00
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
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
Jason A. Donenfeld
b4ad49f9f7 runtime: remove slow time compatibility hacks for wine
A few years ago, Wine-specific detection was added as an ugly hack to
work around shortcomings in the emulation layer. Probably it's best to
not special case this emulator versus that emulator versus the real
deal, but there were two arguments presented in the hack's favor:

  1. Wine is useful and developers will appreciate being able to debug
     stuff with it.

  2. The existing KUSER_SHARED_DATA technique for gathering time is
     undocumented, and we shouldn't be relying on it anyway, since
     Microsoft might remove it without notice.

As it turns out, neither one of these are, at the time of writing, true.
(1) has been handled for some time by Wine with the introduction of the
commit entitled "ntdll: Create thread to update user_shared_data time
values when necessary". And (2) is in fact documented:
https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/ntddk/ns-ntddk-kuser_shared_data
https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/-kuser
It's in use so widely by both third-party software (such as games, a
massive market segment) and by Microsoft binaries that removing it from
the operating system will basically never happen.

So with both issues taken care of, this commit simply gets rid of the
old hack.

Change-Id: I80093f50e0d10d53648128d0f9dd76b1b92a119e
Reviewed-on: https://go-review.googlesource.com/c/go/+/191759
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-29 13:57:31 +00:00
Lynn Boger
8f79ca1d1a cmd/internal/obj/ppc64: add support for vmrgow,vmrgew
This adds support for ppc64 instructions vmrgow and vmrgew which
are needed for an improved implementation of chacha20.

Change-Id: I967a2de54236bcc573a99f7e2b222d5a8bb29e03
Reviewed-on: https://go-review.googlesource.com/c/go/+/192117
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
2019-08-29 13:27:55 +00:00
Elias Naur
d56a86e01f 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.

Fixes #33384

Change-Id: Ice3de75b121f00006ee11c26d560e619536460be
Reviewed-on: https://go-review.googlesource.com/c/go/+/188297
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-08-29 12:51:31 +00:00
Constantin Konstantinidis
5cf5a6fc5e os: return an error when the argument of Mkdir on Windows is os.DevNull
Test added.

Fixes #24556

Change-Id: I4d1cd4513142edeea1a983fbfde46c2fccecab2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/186139
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-29 09:53:56 +00:00
Tomas Dabasinskas
cb325fed43 net: fix resolving local windows machine ptr
Fixes #29600

Change-Id: Ie60b5c8f8356dfc16b3ef6d3cee520b9ce6a61aa
GitHub-Last-Rev: 76cbdb96a6
GitHub-Pull-Request: golang/go#32214
Reviewed-on: https://go-review.googlesource.com/c/go/+/178701
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-29 09:26:02 +00:00
Prashant Agrawal
3b92f36d15 debug/pe: enable parsing of variable length optional header in PE file
The debug/pe package assumes there are always 16 entries in
DataDirectory in OptionalHeader32/64
ref pe.go:
...
NumberOfRvaAndSizes uint32
DataDirectory [16]DataDirectory
}
...

But that is not always the case, there could be less no of
entries (PE signed linux kernel for example):
$ sudo pev /boot/vmlinuz-4.15.0-47-generic
....
Data-dictionary entries:	6
....

In such case, the parsing gives incorrect results.
This changes aims to fix that by:
1. Determining type of optional header by looking at header
   magic instead of size
2. Parsing optional header in 2 steps:
   a. Fixed part
   b. Variable data directories part

Testing:
1. Fixed existing test cases to reflect the change
2. Added new file (modified linux kernel image)
   which has smaller number of data directories

Fixes #32126

Change-Id: Iee56ecc4369a0e75a4be805e7cb8555c7d81ae2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/177959
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-29 08:57:06 +00:00
Agniva De Sarker
8e4399ff77 cmd/compile: refactor zero value size to be a constant
Change-Id: I31dd4fb55d5974cd45de00148039d04f8a7d5cb3
Reviewed-on: https://go-review.googlesource.com/c/go/+/187257
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
2019-08-29 08:35:32 +00:00
Tianon Gravi
5d1a95175e runtime: treat CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT, CTRL_SHUTDOWN_EVENT as SIGTERM on Windows
This matches the existing behavior of treating CTRL_C_EVENT, CTRL_BREAK_EVENT as a synthesized SIGINT event.

See https://docs.microsoft.com/en-us/windows/console/handlerroutine for a good documentation source upstream to confirm these values.

As for the usage of these events, the "Timeouts" section of that upstream documentation is important to note, especially the limited window in which to do any cleanup before the program will be forcibly killed (defaults typically 5s, but as low as 500ms, and in many cases configurable system-wide).

These events are especially relevant for Windows containers, where these events (particularly `CTRL_SHUTDOWN_EVENT`) are one of the only ways containers can "gracefully" shut down (https://github.com/moby/moby/issues/25982#issuecomment-466804071).

This was verified by making a simple `main()` which implements the same code as in `ExampleNotify_allSignals` but in a `for` loop, building a `main.exe`, running that in a container, then doing `docker kill -sTERM` on said container.  The program prints `Got signal: SIGTERM`, then exits after the aforementioned timeout, as expected.  Behavior before this patch is that the program gets no notification (and thus no output) but still exits after the timeout.

Fixes #7479

Change-Id: I2af79421cd484a0fbb9467bb7ddb5f0e8bc3610e
GitHub-Last-Rev: 9e05d631b5
GitHub-Pull-Request: golang/go#33311
Reviewed-on: https://go-review.googlesource.com/c/go/+/187739
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-29 08:15:20 +00:00
Tobias Klauser
d865b5caa6 syscall: enable ReadDirent tests on aix, linux and solaris
Change-Id: I13fd6bad4600ef909b13ac517ba6a06909b5c703
Reviewed-on: https://go-review.googlesource.com/c/go/+/182379
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-08-29 06:41:00 +00:00
Matthew Dempsky
777304a5d3 Revert "cmd/compile: make isfat handle 1-element array, 1-field struct"
This reverts commit 5322776215.

Reason for revert: broke js-wasm builder.

Change-Id: If22762317c4a9e00f5060eb84377a4a52d601fca
Reviewed-on: https://go-review.googlesource.com/c/go/+/192157
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-08-28 20:28:13 +00:00
Matthew Dempsky
aced50af3b cmd/compile: update fmt_test.go for esc.go code cleanup
CL 187598 removed a bunch of esc.go's debug messages, so some format
strings are no longer needed.

Fixes #33915.

Change-Id: Iaadf12b5d68358e1abb00210f5aa8be01b36ce82
Reviewed-on: https://go-review.googlesource.com/c/go/+/192142
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-28 20:26:53 +00:00
LE Manh Cuong
5322776215 cmd/compile: make isfat handle 1-element array, 1-field struct
This will improve liveness analysis slightly, the same logic as
isdirectiface curently does. In:

	type T struct {
	    m map[int]int
	}

        v := T{}
        v.m = make(map[int]int)

T is considered "fat", now it is not. So assigning to v.m is considered
to clobber the entire v.

This is follow up of CL 179057.

Change-Id: Id6b4807b8e8521ef5d8bcb14fedb6dceb9dbf18c
Reviewed-on: https://go-review.googlesource.com/c/go/+/179578
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-28 19:48:31 +00:00
LE Manh Cuong
515bb0129d cmd/compile: remove isfat from order expr
isfat was removed in walkexpr in CL 32313. For consistency,
remove it from order expr, too.

Change-Id: I0a47e0da13ba0168d6a055d990b8efad26ad790d
Reviewed-on: https://go-review.googlesource.com/c/go/+/179057
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-28 19:47:04 +00:00
Cholerae Hu
52cff70100 cmd/compile: truncate constant arithmetic result with typed complex numbers
Fixes #33285

Change-Id: Idd125e3342058051216be3f105330aef987320c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/187697
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-08-28 19:45:44 +00:00
LE Manh Cuong
25ebf015f6 cmd/compile: ensure interface-to-concrete comparison panics when it should
In interface-to-concrete comparisons, we are short circuiting on the interface
value's dynamic type before evaluating the concrete expression for side effects,
causing concrete expression won't panic at runtime, while it should.

To fix it, evaluating the RHS of comparison before we do the short-circuit.

We also want to prioritize panics in the LHS over the RHS, so evaluating
the LHS too.

Fixes #32187

Change-Id: I15b58a523491b7fd1856b8fdb9ba0cba5d11ebb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/178817
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-28 19:45:00 +00:00
LE Manh Cuong
400d021233 cmd/compile: fix wrong field type in scasetype
The only place set releasetime to negative is in runtime.selectgo
(when blockprofilerate greater than zero), so we are safe in compiler
code.

But scasetype must keep in sync with runtime/select.go scase struct, so
releasetime must be int64.

Change-Id: I39ea944f5f2872452d3ffd57f7604d51e0d2590a
Reviewed-on: https://go-review.googlesource.com/c/go/+/179799
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-28 19:43:09 +00:00
Matthew Dempsky
0b9b152ee3 cmd/compile: remove unused code from esc.go
Change-Id: Idb7b97ced559c40d4e3beae5c661c71825200af7
Reviewed-on: https://go-review.googlesource.com/c/go/+/187598
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-08-28 19:27:50 +00:00
Matthew Dempsky
991b0fd46c cmd/compile: remove -newescape flag
Drops support for old escape analysis pass. Subsequent, separate CL
will remove dead code.

While here, fix a minor error in fmt.go: it was still looking for
esc.go's NodeEscState in n.Opt() rather than escape.go's EscLocation.
But this only affected debug diagnostics printed during escape
analysis itself.

Change-Id: I62512e1b31c75ba0577550a5fd7824abc3159ed5
Reviewed-on: https://go-review.googlesource.com/c/go/+/187597
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-28 19:27:30 +00:00
Brad Fitzpatrick
7ed973b4d9 net/http: don't panic serving dir in ServeFile with empty Request.URL.Path
Updates #30165
Updates #31622

Change-Id: I7a4b91aa7c5c3af8c0b1273cbb42046feddf7d78
Reviewed-on: https://go-review.googlesource.com/c/go/+/180499
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-28 18:38:52 +00:00
Ayan George
b3a1205a11 runtime: simplify GOOS detection in mstart()
The existing condition is long and repetitive.  Using select/case with
multiple values in the expression list is more concise and clearer.

Change-Id: I43f8abcf958e433468728f1d89ff1436332b29da
Reviewed-on: https://go-review.googlesource.com/c/go/+/188519
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-28 18:37:57 +00:00
Jordi Martin
f45eb9ff3c io: add error check on pipe close functions to avoid error overwriting
The current implementation allows multiple calls `Close` and `CloseWithError` in every side of the pipe, as a result, the original error can be overwritten.

This CL fixes this behavior adding an error existence check on `atomicError` type
and keeping the first error still available.

Fixes #24283

Change-Id: Iefe8f758aeb775309424365f8177511062514150
GitHub-Last-Rev: b559540d7a
GitHub-Pull-Request: golang/go#33239
Reviewed-on: https://go-review.googlesource.com/c/go/+/187197
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-28 18:35:24 +00:00
empijei
89865f8ba6 crypto/x509: allow nil Certificates to be compared in Equal
The current implementation panics on nil certificates,
so introduce a nil check and early return true if both
are nil, false if only one is.

Fixes #28743

Change-Id: I71b0dee3e505d3ad562a4470ccc22c3a2579bc52
Reviewed-on: https://go-review.googlesource.com/c/go/+/167118
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-08-28 17:13:49 +00:00
Mostyn Bramley-Moore
84198445d4 crypto/ecdsa: improve documentation readability
Include references in the package-level comment block, expand
the obscure IRO acronym, and add a reference for "the standard
(cryptographic) assumptions".

Fixes #33589

Change-Id: I76c3b0a2f7258b3ab4bf1c8e7681c5d159720a20
GitHub-Last-Rev: 30d5a1e2fb
GitHub-Pull-Request: golang/go#33723
Reviewed-on: https://go-review.googlesource.com/c/go/+/190840
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2019-08-28 16:28:19 +00:00
Eric Lagergren
9dfa4cb026 math/big: document that Rat.Denom might modify the receiver
Fixes #33792

Change-Id: I306a95883c3db2d674d3294a6feb50adc50ee5d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/192017
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-08-28 16:20:00 +00:00
Meng Zhuo
307544f427 runtime, cmd/compile: implement and use DUFFCOPY on MIPS64
OS: Linux loongson 3.10.84 mips64el
CPU: Loongson 3A3000 quad core

name                   old time/op    new time/op    delta
BinaryTree17              23.5s ± 1%     23.2s ± 0%  -1.12%  (p=0.008 n=5+5)
Fannkuch11                10.2s ± 0%     10.1s ± 0%  -0.19%  (p=0.008 n=5+5)
FmtFprintfEmpty           450ns ± 0%     446ns ± 1%  -0.89%  (p=0.024 n=5+5)
FmtFprintfString          722ns ± 1%     721ns ± 1%    ~     (p=0.762 n=5+5)
FmtFprintfInt             693ns ± 2%     691ns ± 2%    ~     (p=0.889 n=5+5)
FmtFprintfIntInt          912ns ± 1%     911ns ± 0%    ~     (p=0.722 n=5+5)
FmtFprintfPrefixedInt    1.35µs ± 2%    1.35µs ± 2%    ~     (p=1.000 n=5+5)
FmtFprintfFloat          1.79µs ± 0%    1.78µs ± 0%    ~     (p=0.683 n=5+5)
FmtManyArgs              3.46µs ± 1%    3.48µs ± 1%    ~     (p=0.246 n=5+5)
GobDecode                48.8ms ± 1%    48.6ms ± 0%    ~     (p=0.222 n=5+5)
GobEncode                37.7ms ± 1%    37.4ms ± 1%    ~     (p=0.095 n=5+5)
Gzip                      1.72s ± 1%     1.72s ± 0%    ~     (p=0.905 n=5+4)
Gunzip                    342ms ± 0%     342ms ± 0%    ~     (p=0.421 n=5+5)
HTTPClientServer          219µs ± 1%     219µs ± 1%    ~     (p=1.000 n=5+5)
JSONEncode               89.1ms ± 1%    89.4ms ± 1%    ~     (p=0.222 n=5+5)
JSONDecode                292ms ± 1%     291ms ± 0%    ~     (p=0.421 n=5+5)
Mandelbrot200            15.7ms ± 0%    15.6ms ± 0%    ~     (p=0.690 n=5+5)
GoParse                  19.5ms ± 1%    19.6ms ± 1%    ~     (p=0.310 n=5+5)
RegexpMatchEasy0_32       534ns ± 1%     529ns ± 1%    ~     (p=0.056 n=5+5)
RegexpMatchEasy0_1K      2.75µs ± 0%    2.74µs ± 0%  -0.46%  (p=0.008 n=5+5)
RegexpMatchEasy1_32       572ns ± 2%     565ns ± 3%    ~     (p=0.310 n=5+5)
RegexpMatchEasy1_1K      4.15µs ± 0%    4.15µs ± 1%    ~     (p=0.548 n=5+5)
RegexpMatchMedium_32     31.2ns ± 0%    31.1ns ± 0%  -0.45%  (p=0.016 n=5+4)
RegexpMatchMedium_1K      235µs ± 1%     235µs ± 0%    ~     (p=1.000 n=5+5)
RegexpMatchHard_32       13.9µs ± 1%    13.5µs ± 1%  -2.74%  (p=0.008 n=5+5)
RegexpMatchHard_1K        416µs ± 2%     410µs ± 2%    ~     (p=0.056 n=5+5)
Revcomp                   6.36s ± 0%     6.34s ± 0%  -0.31%  (p=0.008 n=5+5)
Template                  352ms ± 1%     353ms ± 0%  +0.45%  (p=0.032 n=5+5)
TimeParse                2.04µs ± 4%    2.01µs ± 0%    ~     (p=0.056 n=5+5)
TimeFormat               2.97µs ± 0%    2.97µs ± 0%    ~     (p=1.000 n=5+5)

name                   old speed      new speed      delta
GobDecode              15.7MB/s ± 1%  15.8MB/s ± 0%    ~     (p=0.206 n=5+5)
GobEncode              20.4MB/s ± 1%  20.5MB/s ± 1%    ~     (p=0.056 n=5+5)
Gzip                   11.3MB/s ± 1%  11.3MB/s ± 0%    ~     (p=0.841 n=5+4)
Gunzip                 56.7MB/s ± 0%  56.8MB/s ± 0%    ~     (p=0.389 n=5+5)
JSONEncode             21.8MB/s ± 1%  21.7MB/s ± 1%    ~     (p=0.246 n=5+5)
JSONDecode             6.66MB/s ± 0%  6.67MB/s ± 0%    ~     (p=0.857 n=4+5)
GoParse                2.97MB/s ± 1%  2.96MB/s ± 1%    ~     (p=0.238 n=5+5)
RegexpMatchEasy0_32    59.9MB/s ± 1%  60.5MB/s ± 1%  +0.92%  (p=0.032 n=5+5)
RegexpMatchEasy0_1K     372MB/s ± 0%   374MB/s ± 0%  +0.46%  (p=0.008 n=5+5)
RegexpMatchEasy1_32    56.0MB/s ± 2%  56.7MB/s ± 3%    ~     (p=0.310 n=5+5)
RegexpMatchEasy1_1K     247MB/s ± 0%   247MB/s ± 1%    ~     (p=0.548 n=5+5)
RegexpMatchMedium_32   32.0MB/s ± 0%  32.1MB/s ± 0%    ~     (p=0.135 n=5+5)
RegexpMatchMedium_1K   4.35MB/s ± 1%  4.35MB/s ± 1%    ~     (p=0.825 n=5+5)
RegexpMatchHard_32     2.30MB/s ± 1%  2.37MB/s ± 1%  +2.78%  (p=0.008 n=5+5)
RegexpMatchHard_1K     2.47MB/s ± 1%  2.50MB/s ± 2%    ~     (p=0.095 n=5+5)
Revcomp                40.0MB/s ± 0%  40.1MB/s ± 0%  +0.31%  (p=0.016 n=5+5)
Template               5.51MB/s ± 1%  5.49MB/s ± 0%    ~     (p=0.190 n=5+5)

Change-Id: I540a2e4e7992376ce04f93b332f64fc3b6071237
Reviewed-on: https://go-review.googlesource.com/c/go/+/185078
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-28 15:49:59 +00:00
Tobias Klauser
b58d9bb8c8 syscall: move Renameat to syscall_linux_$GOARCH.go
On linux/riscv64, the renameat syscall no longer exists and has been
superseded by renameat2. Thus we'll have to use Renameat2 to implement
Renameat on linux/riscv64 for #27532. Prepare for this by moving the
Renameat definition to the GOARCH specific files.

Follow CL 157899 which did the same for golang.org/x/sys/unix

Change-Id: I9670213cc3987df48fee962ddee36915a7785560
Reviewed-on: https://go-review.googlesource.com/c/go/+/192077
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-08-28 15:44:01 +00:00
Ben Shi
3cfd003a8a cmd/compile: optimize ARM's math.bits.RotateLeft32
This CL optimizes math.bits.RotateLeft32 to inline
"MOVW Rx@>Ry, Rd" on ARM.

The benchmark results of math/bits show some improvements.
name               old time/op  new time/op  delta
RotateLeft-4       9.42ns ± 0%  6.91ns ± 0%  -26.66%  (p=0.000 n=40+33)
RotateLeft8-4      8.79ns ± 0%  8.79ns ± 0%   -0.04%  (p=0.000 n=40+31)
RotateLeft16-4     8.79ns ± 0%  8.79ns ± 0%   -0.04%  (p=0.000 n=40+32)
RotateLeft32-4     8.16ns ± 0%  7.54ns ± 0%   -7.68%  (p=0.000 n=40+40)
RotateLeft64-4     15.7ns ± 0%  15.7ns ± 0%     ~     (all equal)

updates #31265

Change-Id: I77bc1c2c702d5323fc7cad5264a8e2d5666bf712
Reviewed-on: https://go-review.googlesource.com/c/go/+/188697
Run-TryBot: Ben Shi <powerman1st@163.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-08-28 15:41:58 +00:00
Ben Shi
c683ab8128 cmd/compile: optimize ARM's math.Abs
This CL optimizes math.Abs to an inline ABSD instruction on ARM.

The benchmark results of src/math/ show big improvements.
name                   old time/op  new time/op  delta
Acos-4                  181ns ± 0%   182ns ± 0%   +0.30%  (p=0.000 n=40+40)
Acosh-4                 202ns ± 0%   202ns ± 0%     ~     (all equal)
Asin-4                  163ns ± 0%   163ns ± 0%     ~     (all equal)
Asinh-4                 242ns ± 0%   242ns ± 0%     ~     (all equal)
Atan-4                  120ns ± 0%   121ns ± 0%   +0.83%  (p=0.000 n=40+40)
Atanh-4                 202ns ± 0%   202ns ± 0%     ~     (all equal)
Atan2-4                 173ns ± 0%   173ns ± 0%     ~     (all equal)
Cbrt-4                 1.06µs ± 0%  1.06µs ± 0%   +0.09%  (p=0.000 n=39+37)
Ceil-4                 72.9ns ± 0%  72.8ns ± 0%     ~     (p=0.237 n=40+40)
Copysign-4             13.2ns ± 0%  13.2ns ± 0%     ~     (all equal)
Cos-4                   193ns ± 0%   183ns ± 0%   -5.18%  (p=0.000 n=40+40)
Cosh-4                  254ns ± 0%   239ns ± 0%   -5.91%  (p=0.000 n=40+40)
Erf-4                   112ns ± 0%   112ns ± 0%     ~     (all equal)
Erfc-4                  117ns ± 0%   117ns ± 0%     ~     (all equal)
Erfinv-4                127ns ± 0%   127ns ± 1%     ~     (p=0.492 n=40+40)
Erfcinv-4               128ns ± 0%   128ns ± 0%     ~     (all equal)
Exp-4                   212ns ± 0%   206ns ± 0%   -3.05%  (p=0.000 n=40+40)
ExpGo-4                 216ns ± 0%   209ns ± 0%   -3.24%  (p=0.000 n=40+40)
Expm1-4                 142ns ± 0%   142ns ± 0%     ~     (all equal)
Exp2-4                  191ns ± 0%   184ns ± 0%   -3.45%  (p=0.000 n=40+40)
Exp2Go-4                194ns ± 0%   187ns ± 0%   -3.61%  (p=0.000 n=40+40)
Abs-4                  14.4ns ± 0%   6.3ns ± 0%  -56.39%  (p=0.000 n=38+39)
Dim-4                  12.6ns ± 0%  12.6ns ± 0%     ~     (all equal)
Floor-4                49.6ns ± 0%  49.6ns ± 0%     ~     (all equal)
Max-4                  27.6ns ± 0%  27.6ns ± 0%     ~     (all equal)
Min-4                  27.0ns ± 0%  27.0ns ± 0%     ~     (all equal)
Mod-4                   349ns ± 0%   305ns ± 1%  -12.55%  (p=0.000 n=33+40)
Frexp-4                54.0ns ± 0%  47.1ns ± 0%  -12.78%  (p=0.000 n=38+38)
Gamma-4                 242ns ± 0%   234ns ± 0%   -3.16%  (p=0.000 n=36+40)
Hypot-4                84.8ns ± 0%  67.8ns ± 0%  -20.05%  (p=0.000 n=31+35)
HypotGo-4              88.5ns ± 0%  71.6ns ± 0%  -19.12%  (p=0.000 n=40+38)
Ilogb-4                45.8ns ± 0%  38.9ns ± 0%  -15.12%  (p=0.000 n=40+32)
J0-4                    821ns ± 0%   802ns ± 0%   -2.33%  (p=0.000 n=33+40)
J1-4                    816ns ± 0%   807ns ± 0%   -1.05%  (p=0.000 n=40+29)
Jn-4                   1.67µs ± 0%  1.65µs ± 0%   -1.45%  (p=0.000 n=40+39)
Ldexp-4                61.5ns ± 0%  54.6ns ± 0%  -11.27%  (p=0.000 n=40+32)
Lgamma-4                188ns ± 0%   188ns ± 0%     ~     (all equal)
Log-4                   154ns ± 0%   147ns ± 0%   -4.78%  (p=0.000 n=40+40)
Logb-4                 50.9ns ± 0%  42.7ns ± 0%  -16.11%  (p=0.000 n=34+39)
Log1p-4                 160ns ± 0%   159ns ± 0%     ~     (p=0.828 n=40+40)
Log10-4                 173ns ± 0%   166ns ± 0%   -4.05%  (p=0.000 n=40+40)
Log2-4                 65.3ns ± 0%  58.4ns ± 0%  -10.57%  (p=0.000 n=37+37)
Modf-4                 36.4ns ± 0%  36.4ns ± 0%     ~     (all equal)
Nextafter32-4          36.4ns ± 0%  36.4ns ± 0%     ~     (all equal)
Nextafter64-4          32.7ns ± 0%  32.6ns ± 0%     ~     (p=0.375 n=40+40)
PowInt-4                300ns ± 0%   277ns ± 0%   -7.78%  (p=0.000 n=40+40)
PowFrac-4               676ns ± 0%   635ns ± 0%   -6.00%  (p=0.000 n=40+35)
Pow10Pos-4             17.6ns ± 0%  17.6ns ± 0%     ~     (all equal)
Pow10Neg-4             22.0ns ± 0%  22.0ns ± 0%     ~     (all equal)
Round-4                30.1ns ± 0%  30.1ns ± 0%     ~     (all equal)
RoundToEven-4          38.9ns ± 0%  38.9ns ± 0%     ~     (all equal)
Remainder-4             291ns ± 0%   263ns ± 0%   -9.62%  (p=0.000 n=40+40)
Signbit-4              11.3ns ± 0%  11.3ns ± 0%     ~     (all equal)
Sin-4                   185ns ± 0%   185ns ± 0%     ~     (all equal)
Sincos-4                230ns ± 0%   230ns ± 0%     ~     (all equal)
Sinh-4                  253ns ± 0%   246ns ± 0%   -2.77%  (p=0.000 n=39+39)
SqrtIndirect-4         41.4ns ± 0%  41.4ns ± 0%     ~     (all equal)
SqrtLatency-4          13.8ns ± 0%  13.8ns ± 0%     ~     (all equal)
SqrtIndirectLatency-4  37.0ns ± 0%  37.0ns ± 0%     ~     (p=0.632 n=40+40)
SqrtGoLatency-4         911ns ± 0%   911ns ± 0%   +0.08%  (p=0.000 n=40+40)
SqrtPrime-4            13.2µs ± 0%  13.2µs ± 0%   +0.01%  (p=0.038 n=38+40)
Tan-4                   205ns ± 0%   205ns ± 0%     ~     (all equal)
Tanh-4                  264ns ± 0%   247ns ± 0%   -6.44%  (p=0.000 n=39+32)
Trunc-4                45.2ns ± 0%  45.2ns ± 0%     ~     (all equal)
Y0-4                    796ns ± 0%   792ns ± 0%   -0.55%  (p=0.000 n=35+40)
Y1-4                    804ns ± 0%   797ns ± 0%   -0.82%  (p=0.000 n=24+40)
Yn-4                   1.64µs ± 0%  1.62µs ± 0%   -1.27%  (p=0.000 n=40+39)
Float64bits-4          8.16ns ± 0%  8.16ns ± 0%   +0.04%  (p=0.000 n=35+40)
Float64frombits-4      10.7ns ± 0%  10.7ns ± 0%     ~     (all equal)
Float32bits-4          7.53ns ± 0%  7.53ns ± 0%     ~     (p=0.760 n=40+40)
Float32frombits-4      6.91ns ± 0%  6.91ns ± 0%   -0.04%  (p=0.002 n=32+38)
[Geo mean]              111ns        106ns        -3.98%

Change-Id: I54f4fd7f5160db020b430b556bde59cc0fdb996d
Reviewed-on: https://go-review.googlesource.com/c/go/+/188678
Run-TryBot: Ben Shi <powerman1st@163.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-08-28 15:41:28 +00:00
Meng Zhuo
8403d4ea90 cmd/asm: add V[LD|ST][2-4] vector instructions on arm64
This change adds VLD2, VLD3, VLD4, VST2, VST3, VST4 (multiple structures)
for image or multi media optimazation.

Change-Id: Iae3538ef4434e436e3fb2f19153c58f918f773af
Reviewed-on: https://go-review.googlesource.com/c/go/+/166518
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-08-28 15:29:12 +00:00
Illya Yalovyy
be452cea42 math/big: fast path for Cmp if same
math/big.Int Cmp method does not have a fast path for the case if x and y are the same.

Fixes #30856

Change-Id: Ia9a5b5f72db9d73af1b13ed6ac39ecff87d10393
Reviewed-on: https://go-review.googlesource.com/c/go/+/178957
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-08-28 15:08:00 +00:00
Cherry Zhang
1abe22c3c1 cmd/compile: don't mark stack object symbol DUPOK
Stack object symbol is named as <FunctionName>.stkobj. If the
function itself is not DUPOK, its stack object symbol should only
be defined in the package where the function is defined,
therefore no duplicates.

If in the future we change the stack object symbol to
content-hash naming, as other gcdata symbols, we can mark it as
DUPOK.

Change-Id: I5aee96578940e2f76e7115d96cd2716021672c03
Reviewed-on: https://go-review.googlesource.com/c/go/+/191437
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-08-28 15:05:12 +00:00
Daniel Martí
81fde0c941 net/http: fix a long test after CL 185117
The net/url error in question now quotes the URL, so update the expected
output string.

While at it, also update a comment in httputil, though that doesn't
affect any test.

Fixes #33910.

Change-Id: I0981f528b24337c2952ef60c0db3b7ff72d72110
Reviewed-on: https://go-review.googlesource.com/c/go/+/192078
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-28 14:02:41 +00:00
Bryan C. Mills
372b0eed17 Revert "cmd/compile: optimize 386's math.bits.TrailingZeros16"
This reverts CL 189277.

Reason for revert: broke 32-bit builders.

Updates #33902

Change-Id: Ie5f180d0371a90e5057ed578c334372e5fc3a286
Reviewed-on: https://go-review.googlesource.com/c/go/+/192097
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2019-08-28 12:57:59 +00:00
Nao YONASHIRO
bc92fe8b34 compress/flate: improve deflate performance by register allocating the index
Use local index variable to help the go compiler use a
register to for the hash index instead of continuous
memory read and write operations.

compress/flate:
Encode/Digits/Huffman/1e4-4        35.3µs ± 1%    32.7µs ± 0%  -7.48%  (p=0.000 n=17+19)
Encode/Digits/Huffman/1e5-4         330µs ± 0%     312µs ± 0%  -5.55%  (p=0.000 n=17+18)
Encode/Digits/Huffman/1e6-4        3.30ms ± 0%    3.12ms ± 0%  -5.64%  (p=0.000 n=18+19)
Encode/Digits/Speed/1e4-4           157µs ± 0%     156µs ± 0%  -0.41%  (p=0.000 n=17+19)
Encode/Digits/Speed/1e5-4          1.46ms ± 0%    1.46ms ± 1%    ~     (p=0.478 n=20+19)
Encode/Digits/Speed/1e6-4          14.4ms ± 0%    14.4ms ± 0%    ~     (p=0.835 n=19+20)
Encode/Digits/Default/1e4-4         309µs ± 0%     310µs ± 0%  +0.23%  (p=0.000 n=19+17)
Encode/Digits/Default/1e5-4        4.76ms ± 0%    4.76ms ± 0%    ~     (p=0.297 n=19+19)
Encode/Digits/Default/1e6-4        51.0ms ± 0%    51.0ms ± 1%    ~     (p=0.233 n=18+19)
Encode/Digits/Compression/1e4-4     309µs ± 0%     310µs ± 0%  +0.21%  (p=0.000 n=17+20)
Encode/Digits/Compression/1e5-4    4.76ms ± 0%    4.76ms ± 0%    ~     (p=0.749 n=20+19)
Encode/Digits/Compression/1e6-4    50.9ms ± 0%    50.9ms ± 0%    ~     (p=0.499 n=18+19)
Encode/Newton/Huffman/1e4-4        51.9µs ± 0%    48.0µs ± 0%  -7.61%  (p=0.000 n=19+19)
Encode/Newton/Huffman/1e5-4         396µs ± 0%     377µs ± 0%  -4.79%  (p=0.000 n=18+19)
Encode/Newton/Huffman/1e6-4        3.95ms ± 0%    3.74ms ± 0%  -5.21%  (p=0.000 n=20+17)
Encode/Newton/Speed/1e4-4           155µs ± 0%     154µs ± 0%  -0.67%  (p=0.000 n=17+18)
Encode/Newton/Speed/1e5-4          1.17ms ± 0%    1.16ms ± 0%  -0.64%  (p=0.000 n=20+16)
Encode/Newton/Speed/1e6-4          11.6ms ± 0%    11.5ms ± 0%  -0.63%  (p=0.000 n=19+20)
Encode/Newton/Default/1e4-4         347µs ± 0%     347µs ± 0%    ~     (p=0.744 n=20+19)
Encode/Newton/Default/1e5-4        5.06ms ± 0%    5.02ms ± 0%  -0.77%  (p=0.000 n=20+19)
Encode/Newton/Default/1e6-4        53.3ms ± 1%    52.8ms ± 0%  -0.91%  (p=0.000 n=18+16)
Encode/Newton/Compression/1e4-4     351µs ± 0%     351µs ± 0%    ~     (p=0.277 n=20+20)
Encode/Newton/Compression/1e5-4    6.90ms ± 0%    6.85ms ± 0%  -0.61%  (p=0.000 n=19+18)
Encode/Newton/Compression/1e6-4    73.2ms ± 0%    72.8ms ± 0%  -0.52%  (p=0.000 n=18+18)

name                             old speed      new speed      delta
Encode/Digits/Huffman/1e4-4       283MB/s ± 1%   306MB/s ± 0%  +8.09%  (p=0.000 n=17+19)
Encode/Digits/Huffman/1e5-4       303MB/s ± 0%   321MB/s ± 0%  +5.87%  (p=0.000 n=18+18)
Encode/Digits/Huffman/1e6-4       303MB/s ± 0%   321MB/s ± 0%  +5.98%  (p=0.000 n=18+19)
Encode/Digits/Speed/1e4-4        63.9MB/s ± 0%  64.2MB/s ± 0%  +0.41%  (p=0.000 n=17+19)
Encode/Digits/Speed/1e5-4        68.5MB/s ± 0%  68.4MB/s ± 1%    ~     (p=0.481 n=20+19)
Encode/Digits/Speed/1e6-4        69.4MB/s ± 0%  69.3MB/s ± 0%    ~     (p=0.712 n=19+20)
Encode/Digits/Default/1e4-4      32.3MB/s ± 0%  32.3MB/s ± 0%  -0.23%  (p=0.000 n=19+17)
Encode/Digits/Default/1e5-4      21.0MB/s ± 0%  21.0MB/s ± 0%    ~     (p=0.460 n=19+19)
Encode/Digits/Default/1e6-4      19.6MB/s ± 0%  19.6MB/s ± 1%    ~     (p=0.180 n=18+19)
Encode/Digits/Compression/1e4-4  32.3MB/s ± 0%  32.3MB/s ± 0%  -0.21%  (p=0.000 n=17+20)
Encode/Digits/Compression/1e5-4  21.0MB/s ± 0%  21.0MB/s ± 0%    ~     (p=0.700 n=20+19)
Encode/Digits/Compression/1e6-4  19.6MB/s ± 0%  19.6MB/s ± 0%    ~     (p=0.486 n=18+19)
Encode/Newton/Huffman/1e4-4       193MB/s ± 0%   208MB/s ± 0%  +8.23%  (p=0.000 n=19+19)
Encode/Newton/Huffman/1e5-4       252MB/s ± 0%   265MB/s ± 0%  +5.04%  (p=0.000 n=18+19)
Encode/Newton/Huffman/1e6-4       253MB/s ± 0%   267MB/s ± 0%  +5.49%  (p=0.000 n=20+17)
Encode/Newton/Speed/1e4-4        64.5MB/s ± 0%  65.0MB/s ± 0%  +0.67%  (p=0.000 n=17+18)
Encode/Newton/Speed/1e5-4        85.7MB/s ± 0%  86.3MB/s ± 0%  +0.65%  (p=0.000 n=20+16)
Encode/Newton/Speed/1e6-4        86.2MB/s ± 0%  86.7MB/s ± 0%  +0.63%  (p=0.000 n=19+20)
Encode/Newton/Default/1e4-4      28.9MB/s ± 0%  28.9MB/s ± 0%    ~     (p=0.840 n=20+19)
Encode/Newton/Default/1e5-4      19.8MB/s ± 0%  19.9MB/s ± 0%  +0.78%  (p=0.000 n=20+19)
Encode/Newton/Default/1e6-4      18.8MB/s ± 1%  18.9MB/s ± 0%  +0.93%  (p=0.000 n=18+16)
Encode/Newton/Compression/1e4-4  28.5MB/s ± 0%  28.5MB/s ± 0%    ~     (p=0.244 n=20+20)
Encode/Newton/Compression/1e5-4  14.5MB/s ± 0%  14.6MB/s ± 0%  +0.61%  (p=0.000 n=19+18)
Encode/Newton/Compression/1e6-4  13.7MB/s ± 0%  13.7MB/s ± 0%  +0.53%  (p=0.000 n=18+18)

image/png:
name                        old time/op    new time/op    delta
EncodeGray-4                  2.16ms ± 1%    1.85ms ± 1%  -14.17%  (p=0.000 n=86+91)
EncodeGrayWithBufferPool-4    1.99ms ± 0%    1.69ms ± 0%  -15.09%  (p=0.000 n=97+94)
EncodeNRGBOpaque-4            6.51ms ± 1%    5.62ms ± 1%  -13.66%  (p=0.000 n=90+92)
EncodeNRGBA-4                 7.33ms ± 1%    6.12ms ± 1%  -16.49%  (p=0.000 n=89+90)
EncodePaletted-4              5.10ms ± 1%    4.96ms ± 1%   -2.76%  (p=0.000 n=90+87)
EncodeRGBOpaque-4             6.51ms ± 1%    5.63ms ± 1%  -13.49%  (p=0.000 n=94+87)
EncodeRGBA-4                  24.3ms ± 2%    23.0ms ± 0%   -5.23%  (p=0.000 n=91+89)

name                        old speed      new speed      delta
EncodeGray-4                 142MB/s ± 1%   166MB/s ± 1%  +16.50%  (p=0.000 n=86+91)
EncodeGrayWithBufferPool-4   154MB/s ± 0%   182MB/s ± 0%  +17.78%  (p=0.000 n=97+94)
EncodeNRGBOpaque-4           189MB/s ± 1%   219MB/s ± 1%  +15.82%  (p=0.000 n=90+93)
EncodeNRGBA-4                168MB/s ± 1%   201MB/s ± 1%  +19.75%  (p=0.000 n=89+90)
EncodePaletted-4            60.3MB/s ± 1%  62.0MB/s ± 1%   +2.84%  (p=0.000 n=90+87)
EncodeRGBOpaque-4            189MB/s ± 1%   218MB/s ± 1%  +15.60%  (p=0.000 n=94+87)
EncodeRGBA-4                50.6MB/s ± 2%  53.4MB/s ± 0%   +5.51%  (p=0.000 n=91+89)

Change-Id: Ifed4486a7ba19a26abe5cbf2142f15cc7464e84f
Reviewed-on: https://go-review.googlesource.com/c/go/+/187837
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-08-28 12:48:37 +00:00
Stefan Baebler
64cfe9fe22 net/url: improve url parsing error messages by quoting
Current implementation doesn't always make it obvious what the exact
problem with the URL is, so this makes it clearer by consistently quoting
the invalid URL, as is the norm in other parsing implementations, eg.:
strconv.Atoi(" 123") returns an error: parsing " 123": invalid syntax

Updates #29261

Change-Id: Icc6bff8b4a4584677c0f769992823e6e1e0d397d
GitHub-Last-Rev: 648b9d93fe
GitHub-Pull-Request: golang/go#29384
Reviewed-on: https://go-review.googlesource.com/c/go/+/185117
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-28 12:47:06 +00:00
Martin Möhrmann
5fb74fc138 runtime: reduce allocations when building pprof LabelSet
Pre-allocate the slice of labels with enough capacity
to avoid growslice calls.

Change-Id: I89db59ac722c03b0202e042d1f707bb041e0999f
Reviewed-on: https://go-review.googlesource.com/c/go/+/181517
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-08-28 10:43:11 +00:00
Eddie Scholtz
37373592af encoding/xml: rename fInnerXml to fInnerXML
Per the code review guidelines: "Words in names that are
initialisms or acronyms have a consistent case."

Change-Id: I347b02d2f48455f2cbbc040191ba197e3e8f23fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/191970
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-28 10:21:40 +00:00
Martin Möhrmann
5ff12f6269 net/url: use strings.IndexByte instead of strings.Index in split function
Production profiling shows ~15% of url.Parse time being spend in the overhead
of calling strings.IndexByte through strings.Index instead of calling
strings.IndexByte directly.

name   old time/op  new time/op  delta
Split  15.5ns ± 2%  10.7ns ± 3%  -30.98%  (p=0.000 n=20+19)

Change-Id: Ie25dd4afa93539a1335a91ab2a4a367f97bd3df0
Reviewed-on: https://go-review.googlesource.com/c/go/+/178877
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-08-28 10:04:01 +00:00
Cuong Manh Le
6a73e94c10 cmd/compile: remove gc.eqtype in comments
golang.org/cl/143180 changed gc.eqtype to types.Identical, but gc.eqtype
is still mentioned in some comments. Remove them and update comments to
mention new functions instead.

Change-Id: I6c5eece5221f524556ee55db80de0e4bdfaf166e
Reviewed-on: https://go-review.googlesource.com/c/go/+/191357
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-08-28 09:28:59 +00:00
Nao YONASHIRO
f04f594a1f image/png: hoist repetitive pixels per byte out of loop in Encode
The existing implementation has calculated pixels per byte for each pixel.
reduce the calculation of pixels per byte.

name                        old time/op    new time/op     delta
EncodeGray-4                  2.16ms ± 1%     2.16ms ± 1%    -0.28%  (p=0.000 n=86+84)
EncodeGrayWithBufferPool-4    1.99ms ± 0%     1.97ms ± 0%    -0.72%  (p=0.000 n=97+92)
EncodeNRGBOpaque-4            6.51ms ± 1%     6.48ms ± 1%    -0.45%  (p=0.000 n=90+85)
EncodeNRGBA-4                 7.33ms ± 1%     7.28ms ± 0%    -0.69%  (p=0.000 n=89+87)
EncodePaletted-4              5.10ms ± 1%     2.29ms ± 0%   -55.11%  (p=0.000 n=90+85)
EncodeRGBOpaque-4             6.51ms ± 1%     6.51ms ± 0%      ~     (p=0.311 n=94+88)
EncodeRGBA-4                  24.3ms ± 2%     24.1ms ± 1%    -0.87%  (p=0.000 n=91+91)

name                        old speed      new speed       delta
EncodeGray-4                 142MB/s ± 1%    143MB/s ± 1%    +0.26%  (p=0.000 n=86+85)
EncodeGrayWithBufferPool-4   154MB/s ± 0%    156MB/s ± 0%    +0.73%  (p=0.000 n=97+92)
EncodeNRGBOpaque-4           189MB/s ± 1%    190MB/s ± 1%    +0.44%  (p=0.000 n=90+86)
EncodeNRGBA-4                168MB/s ± 1%    169MB/s ± 0%    +0.69%  (p=0.000 n=89+87)
EncodePaletted-4            60.3MB/s ± 1%  134.2MB/s ± 0%  +122.74%  (p=0.000 n=90+85)
EncodeRGBOpaque-4            189MB/s ± 1%    189MB/s ± 0%      ~     (p=0.326 n=94+88)
EncodeRGBA-4                50.6MB/s ± 2%   51.1MB/s ± 1%    +0.87%  (p=0.000 n=91+91)

name                        old alloc/op   new alloc/op    delta
EncodeGray-4                   852kB ± 0%      852kB ± 0%    +0.00%  (p=0.000 n=100+100)
EncodeGrayWithBufferPool-4    1.49kB ± 2%     1.47kB ± 1%    -0.88%  (p=0.000 n=95+90)
EncodeNRGBOpaque-4             860kB ± 0%      860kB ± 0%    +0.00%  (p=0.003 n=98+58)
EncodeNRGBA-4                  864kB ± 0%      864kB ± 0%    +0.00%  (p=0.021 n=100+99)
EncodePaletted-4               849kB ± 0%      849kB ± 0%    +0.00%  (p=0.040 n=100+100)
EncodeRGBOpaque-4              860kB ± 0%      860kB ± 0%      ~     (p=0.062 n=66+98)
EncodeRGBA-4                  3.32MB ± 0%     3.32MB ± 0%    -0.00%  (p=0.044 n=99+99)

name                        old allocs/op  new allocs/op   delta
EncodeGray-4                    32.0 ± 0%       32.0 ± 0%      ~     (all equal)
EncodeGrayWithBufferPool-4      3.00 ± 0%       3.00 ± 0%      ~     (all equal)
EncodeNRGBOpaque-4              32.0 ± 0%       32.0 ± 0%      ~     (all equal)
EncodeNRGBA-4                   32.0 ± 0%       32.0 ± 0%      ~     (all equal)
EncodePaletted-4                36.0 ± 0%       36.0 ± 0%      ~     (all equal)
EncodeRGBOpaque-4               32.0 ± 0%       32.0 ± 0%      ~     (all equal)
EncodeRGBA-4                    614k ± 0%       614k ± 0%      ~     (all equal)

Change-Id: I716bde2dc80d8111d75d3d765fc09223f770d5a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/187417
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-28 09:02:35 +00:00
Agniva De Sarker
7be97af2ff cmd/compile: apply optimization for readonly globals on wasm
Extend the optimization introduced in CL 141118 to the wasm architecture.

And for reference, the rules trigger 212 times while building std and cmd

$GOOS=js GOARCH=wasm gotip build std cmd
$grep -E "Wasm.rules:44(1|2|3|4)" rulelog | wc -l
212

Updates #26498

Change-Id: I153684a2b98589ae812b42268da08b65679e09d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/185477
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Richard Musiol <neelance@gmail.com>
2019-08-28 05:55:52 +00:00
Agniva De Sarker
07f0460737 runtime,syscall/js: reuse wasm memory DataView
Currently, every call to mem() incurs a new DataView object. This was necessary
because the wasm linear memory could grow at any time.

Now, whenever the memory grows, we make a call to the front-end. This allows us to
reuse the existing DataView object and create a new one only when the memory actually grows.

This gives us a boost in performance during DOM operations, while incurring an extra
trip to front-end when memory grows. However, since the GrowMemory calls are meant to decrease
over the runtime of an application, this is a good tradeoff in the long run.

The benchmarks have been tested inside a browser (Google Chrome 75.0.3770.90 (Official Build) (64-bit)).
It is hard to get stable nos. for DOM operations since the jumps make the timing very unreliable.
But overall, it shows a clear gain.

name  old time/op  new time/op  delta
DOM    135µs ±26%    84µs ±10%  -37.22%  (p=0.000 n=10+9)

Go1 benchmarks do not show any noticeable degradation:
name                   old time/op    new time/op    delta
BinaryTree17              22.5s ± 0%     22.5s ± 0%     ~     (p=0.743 n=8+9)
Fannkuch11                15.1s ± 0%     15.1s ± 0%   +0.17%  (p=0.000 n=9+9)
FmtFprintfEmpty           324ns ± 1%     303ns ± 0%   -6.64%  (p=0.000 n=9+10)
FmtFprintfString          535ns ± 1%     515ns ± 0%   -3.85%  (p=0.000 n=10+10)
FmtFprintfInt             609ns ± 0%     589ns ± 0%   -3.28%  (p=0.000 n=10+10)
FmtFprintfIntInt          938ns ± 0%     920ns ± 0%   -1.92%  (p=0.000 n=9+10)
FmtFprintfPrefixedInt     950ns ± 0%     924ns ± 0%   -2.72%  (p=0.000 n=10+9)
FmtFprintfFloat          1.41µs ± 1%    1.43µs ± 0%   +1.01%  (p=0.000 n=10+10)
FmtManyArgs              3.66µs ± 1%    3.46µs ± 0%   -5.43%  (p=0.000 n=9+10)
GobDecode                38.8ms ± 1%    37.8ms ± 0%   -2.50%  (p=0.000 n=10+8)
GobEncode                26.3ms ± 1%    26.3ms ± 0%     ~     (p=0.853 n=10+10)
Gzip                      1.16s ± 1%     1.16s ± 0%   -0.37%  (p=0.008 n=10+9)
Gunzip                    210ms ± 0%     208ms ± 1%   -1.01%  (p=0.000 n=10+10)
JSONEncode               48.0ms ± 0%    48.1ms ± 1%   +0.29%  (p=0.019 n=9+9)
JSONDecode                348ms ± 1%     326ms ± 1%   -6.34%  (p=0.000 n=10+10)
Mandelbrot200            6.62ms ± 0%    6.64ms ± 0%   +0.37%  (p=0.000 n=7+9)
GoParse                  23.9ms ± 1%    24.7ms ± 1%   +2.98%  (p=0.000 n=9+9)
RegexpMatchEasy0_32       555ns ± 0%     561ns ± 0%   +1.10%  (p=0.000 n=8+10)
RegexpMatchEasy0_1K      3.94µs ± 1%    3.94µs ± 0%     ~     (p=0.906 n=9+8)
RegexpMatchEasy1_32       516ns ± 0%     524ns ± 0%   +1.51%  (p=0.000 n=9+10)
RegexpMatchEasy1_1K      4.39µs ± 1%    4.40µs ± 1%     ~     (p=0.171 n=10+10)
RegexpMatchMedium_32     25.1ns ± 0%    25.5ns ± 0%   +1.51%  (p=0.000 n=9+8)
RegexpMatchMedium_1K      196µs ± 0%     203µs ± 1%   +3.23%  (p=0.000 n=9+10)
RegexpMatchHard_32       11.2µs ± 1%    11.6µs ± 1%   +3.62%  (p=0.000 n=10+10)
RegexpMatchHard_1K        334µs ± 1%     348µs ± 1%   +4.21%  (p=0.000 n=9+10)
Revcomp                   2.39s ± 0%     2.41s ± 0%   +0.78%  (p=0.000 n=8+9)
Template                  385ms ± 1%     336ms ± 0%  -12.61%  (p=0.000 n=10+9)
TimeParse                2.18µs ± 1%    2.18µs ± 1%     ~     (p=0.424 n=10+10)
TimeFormat               2.28µs ± 1%    2.22µs ± 1%   -2.30%  (p=0.000 n=10+10)

name                   old speed      new speed      delta
GobDecode              19.8MB/s ± 1%  20.3MB/s ± 0%   +2.56%  (p=0.000 n=10+8)
GobEncode              29.1MB/s ± 1%  29.2MB/s ± 0%     ~     (p=0.810 n=10+10)
Gzip                   16.7MB/s ± 1%  16.8MB/s ± 0%   +0.37%  (p=0.007 n=10+9)
Gunzip                 92.2MB/s ± 0%  93.2MB/s ± 1%   +1.03%  (p=0.000 n=10+10)
JSONEncode             40.4MB/s ± 0%  40.3MB/s ± 1%   -0.28%  (p=0.025 n=9+9)
JSONDecode             5.58MB/s ± 1%  5.96MB/s ± 1%   +6.80%  (p=0.000 n=10+10)
GoParse                2.42MB/s ± 0%  2.35MB/s ± 1%   -2.83%  (p=0.000 n=8+9)
RegexpMatchEasy0_32    57.7MB/s ± 0%  57.0MB/s ± 0%   -1.09%  (p=0.000 n=8+10)
RegexpMatchEasy0_1K     260MB/s ± 1%   260MB/s ± 0%     ~     (p=0.963 n=9+8)
RegexpMatchEasy1_32    62.1MB/s ± 0%  61.1MB/s ± 0%   -1.53%  (p=0.000 n=10+10)
RegexpMatchEasy1_1K     233MB/s ± 1%   233MB/s ± 1%     ~     (p=0.190 n=10+10)
RegexpMatchMedium_32   39.8MB/s ± 0%  39.1MB/s ± 1%   -1.74%  (p=0.000 n=9+10)
RegexpMatchMedium_1K   5.21MB/s ± 0%  5.05MB/s ± 1%   -3.09%  (p=0.000 n=9+10)
RegexpMatchHard_32     2.86MB/s ± 1%  2.76MB/s ± 1%   -3.43%  (p=0.000 n=10+10)
RegexpMatchHard_1K     3.06MB/s ± 1%  2.94MB/s ± 1%   -4.06%  (p=0.000 n=9+10)
Revcomp                 106MB/s ± 0%   105MB/s ± 0%   -0.77%  (p=0.000 n=8+9)
Template               5.04MB/s ± 1%  5.77MB/s ± 0%  +14.48%  (p=0.000 n=10+9)

Updates #32591

Change-Id: Id567e14a788e359248b2129ef1cf0adc8cc4ab7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/183457
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Richard Musiol <neelance@gmail.com>
2019-08-28 05:11:20 +00:00
Agniva De Sarker
e7a4ab427d net/http/httputil: fix goroutine leak for DumpRequestOut
When an invalid URL was passed to DumpRequestOut, it would directly return
without gracefully shutting down the reader goroutine.

So we create a channel and signal the reader goroutine to exit
if an error occurs during roundtrip.

Fixes #32571

Change-Id: I8c2970f1601e599f3d1ebfed298faf5f5716fc2c
Reviewed-on: https://go-review.googlesource.com/c/go/+/182037
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-08-28 04:44:32 +00:00
Agniva De Sarker
8fedb2d338 cmd/compile: optimize bounded shifts on wasm
Use the shiftIsBounded function to generate more efficient
Shift instructions.

Updates #25167

Change-Id: Id350f8462dc3a7ed3bfed0bcbea2860b8f40048a
Reviewed-on: https://go-review.googlesource.com/c/go/+/182558
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Richard Musiol <neelance@gmail.com>
2019-08-28 04:44:21 +00:00
Agniva De Sarker
b9ef4c0f56 cmd/compile: coalesce a few shift rules for wasm
Change-Id: I1b76daba90afd474390db8d9c238445abaac7ca6
Reviewed-on: https://go-review.googlesource.com/c/go/+/182557
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Richard Musiol <neelance@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-08-28 04:43:53 +00:00
Sam Arnold
3d48ae355b strconv: Speed improvement to number parsing
Run underscore validation only if we have seen underscores.

Some performance results on my laptop:
name                   old time/op  new time/op  delta
Atof64Decimal-12       30.5ns ± 0%  23.8ns ± 0%  -22.02%  (p=0.016 n=5+4)
Atof64Float-12         39.0ns ± 0%  28.7ns ± 0%  -26.39%  (p=0.002 n=6+6)
Atof64FloatExp-12      64.4ns ± 1%  54.4ns ± 1%  -15.65%  (p=0.002 n=6+6)
Atof64Big-12            115ns ± 1%    87ns ± 1%  -24.45%  (p=0.002 n=6+6)
Atof64RandomBits-12     187ns ±14%   156ns ±19%  -16.46%  (p=0.032 n=6+6)
Atof64RandomFloats-12   126ns ± 0%   105ns ± 1%  -16.65%  (p=0.000 n=6+5)
Atof32Decimal-12       32.0ns ± 1%  24.0ns ± 1%  -24.97%  (p=0.002 n=6+6)
Atof32Float-12         37.1ns ± 1%  27.0ns ± 1%  -27.42%  (p=0.002 n=6+6)
Atof32FloatExp-12      68.4ns ± 1%  54.2ns ± 1%  -20.77%  (p=0.002 n=6+6)
Atof32Random-12        92.0ns ± 1%  77.4ns ± 0%  -15.81%  (p=0.000 n=6+5)
ParseInt/Pos/7bit-12   19.4ns ± 1%  13.8ns ±10%  -28.94%  (p=0.002 n=6+6)
ParseInt/Pos/26bit-12  29.1ns ± 1%  19.8ns ± 2%  -31.92%  (p=0.002 n=6+6)
ParseInt/Pos/31bit-12  33.1ns ± 0%  22.3ns ± 3%  -32.62%  (p=0.004 n=5+6)
ParseInt/Pos/56bit-12  47.8ns ± 1%  30.7ns ± 1%  -35.78%  (p=0.004 n=6+5)
ParseInt/Pos/63bit-12  51.9ns ± 1%  33.4ns ± 2%  -35.49%  (p=0.002 n=6+6)
ParseInt/Neg/7bit-12   18.5ns ± 4%  13.4ns ± 3%  -27.88%  (p=0.002 n=6+6)
ParseInt/Neg/26bit-12  28.4ns ± 3%  19.7ns ± 3%  -30.38%  (p=0.002 n=6+6)
ParseInt/Neg/31bit-12  31.9ns ± 1%  21.8ns ± 2%  -31.56%  (p=0.002 n=6+6)
ParseInt/Neg/56bit-12  46.2ns ± 0%  30.6ns ± 1%  -33.73%  (p=0.004 n=5+6)
ParseInt/Neg/63bit-12  50.2ns ± 1%  33.2ns ± 1%  -33.96%  (p=0.002 n=6+6)

Fixes #33330

Change-Id: I119da66457c2fbaf6e88bb90cf56417a16df8f0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/187957
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-08-28 03:23:59 +00:00
Ben Shi
22355d6cd2 cmd/compile: optimize 386's math.bits.TrailingZeros16
This CL optimizes math.bits.TrailingZeros16 on 386 with
a pair of BSFL and ORL instrcutions.

The case TrailingZeros16-4 of the benchmark test in
math/bits shows big improvement.
name               old time/op  new time/op  delta
TrailingZeros16-4  1.55ns ± 1%  0.87ns ± 1%  -43.87%  (p=0.000 n=50+49)

Change-Id: Ia899975b0e46f45dcd20223b713ed632bc32740b
Reviewed-on: https://go-review.googlesource.com/c/go/+/189277
Run-TryBot: Ben Shi <powerman1st@163.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-08-28 02:29:54 +00:00
Ben Shi
731e6fc34e cmd/compile: generate Select on WASM
This CL performs the branchelim optimization on WASM with its
select instruction. And the total size of pkg/js_wasm decreased
about 80KB by this optimization.

Change-Id: I868eb146120a1cac5c4609c8e9ddb07e4da8a1d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/190957
Run-TryBot: Ben Shi <powerman1st@163.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Richard Musiol <neelance@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-08-28 02:29:25 +00:00
fanzha02
9c67516ed6 cmd/internal/obj/arm64: add support for most system registers
This patch supports the EL0 and EL1 system registers used in MRS/MSR
instructions. This patch refactors the assembler code, allowing the
assembler to read system register information from the automatically
generated sysRegEnc.go file and move existing declared system registers
to the sysRegEnc.go file.

This patch adds 431 system registers, it is worth noting that the number
of special registers is initialized to less than 1024 in the list7.go file.

This CL also adds some test cases to test the newly added system registers.

The test cases are contributed by Dianhong Xu <Dianhong.Xu@arm.com>

Change-Id: Ic09a937eaaeefe82bd08b5dd726808f8ff6cebf6
Reviewed-on: https://go-review.googlesource.com/c/go/+/189577
Reviewed-by: Ben Shi <powerman1st@163.com>
Run-TryBot: Ben Shi <powerman1st@163.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-28 02:28:49 +00:00
Keith Randall
b91b3d9c31 cmd/compile: remove auxSymInt32
We never used it, might as well get rid of it.

Change-Id: I5c23c93e90173bff9ac1fc1b8ae1e2025215d6eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/191938
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-08-28 00:40:22 +00:00
Filippo Valsorda
a8c2e5c6ad crypto/tls: remove TLS 1.3 opt-out
Fixes #30055

Change-Id: If757c43b52fc7bf62b0afb1c720615329fb5569d
Reviewed-on: https://go-review.googlesource.com/c/go/+/191999
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-08-27 22:25:08 +00:00
Filippo Valsorda
ffcb678f47 crypto/tls: remove SSLv3 support
SSLv3 has been irreparably broken since the POODLE attack 5 years ago
and RFC 7568 (f.k.a. draft-ietf-tls-sslv3-diediedie) prohibits its use
in no uncertain terms.

As announced in the Go 1.13 release notes, remove support for it
entirely in Go 1.14.

Updates #32716

Change-Id: Id653557961d8f75f484a01e6afd2e104a4ccceaf
Reviewed-on: https://go-review.googlesource.com/c/go/+/191976
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-08-27 22:24:05 +00:00
Josh Bleecher Snyder
52ae04fdfc cmd/compile: improve shortcircuit pass
While working on #30645, I noticed that many instances
in which the walkinrange optimization could apply
were not even being considered.

This was because of extraneous blocks in the CFG,
of the type that shortcircuit normally removes.

The change improves the shortcircuit pass to handle
most of those cases. (There are a few that can only be
reasonably detected later in compilation, after other
optimizations have been run, but not enough to be worth chasing.)

Notable changes:

* Instead of calculating live-across-blocks values, use v.Uses == 1.
  This is cheaper and more straightforward.
  v.Uses did not exist when this pass was initially written.
* Incorporate a fusePlain and loop until stable.
  This is necessary to find many of the instances.
* Allow Copy and Not wrappers around Phi values.
  This significantly increases effectiveness.
* Allow removal of all preds, creating a dead block.
  The previous pass stopped unnecessarily at one pred.
* Use phielimValue during cleanup instead of manually
  setting the op to OpCopy.

The result is marginally faster compilation and smaller code.

name        old time/op       new time/op       delta
Template          213ms ± 2%        212ms ± 2%  -0.63%  (p=0.002 n=49+48)
Unicode          90.0ms ± 2%       89.8ms ± 2%    ~     (p=0.122 n=48+48)
GoTypes           710ms ± 3%        711ms ± 2%    ~     (p=0.433 n=45+49)
Compiler          3.23s ± 2%        3.22s ± 2%    ~     (p=0.124 n=47+49)
SSA               10.0s ± 1%        10.0s ± 1%  -0.43%  (p=0.000 n=48+50)
Flate             135ms ± 3%        135ms ± 2%    ~     (p=0.311 n=49+49)
GoParser          158ms ± 2%        158ms ± 2%    ~     (p=0.757 n=48+48)
Reflect           447ms ± 2%        447ms ± 2%    ~     (p=0.815 n=49+48)
Tar               189ms ± 2%        189ms ± 3%    ~     (p=0.530 n=47+49)
XML               251ms ± 3%        250ms ± 1%  -0.75%  (p=0.002 n=49+48)
[Geo mean]        427ms             426ms       -0.25%

name        old user-time/op  new user-time/op  delta
Template          265ms ± 2%        265ms ± 2%    ~     (p=0.969 n=48+50)
Unicode           119ms ± 6%        119ms ± 6%    ~     (p=0.738 n=50+50)
GoTypes           923ms ± 2%        925ms ± 2%    ~     (p=0.057 n=43+47)
Compiler          4.37s ± 2%        4.37s ± 2%    ~     (p=0.691 n=50+46)
SSA               13.4s ± 1%        13.4s ± 1%    ~     (p=0.282 n=42+49)
Flate             162ms ± 2%        162ms ± 2%    ~     (p=0.774 n=48+50)
GoParser          186ms ± 2%        186ms ± 3%    ~     (p=0.213 n=47+47)
Reflect           572ms ± 2%        573ms ± 3%    ~     (p=0.303 n=50+49)
Tar               240ms ± 3%        240ms ± 2%    ~     (p=0.939 n=46+44)
XML               302ms ± 2%        302ms ± 2%    ~     (p=0.399 n=47+47)
[Geo mean]        540ms             541ms       +0.07%

name        old alloc/op      new alloc/op      delta
Template         36.8MB ± 0%       36.7MB ± 0%  -0.42%  (p=0.008 n=5+5)
Unicode          28.1MB ± 0%       28.1MB ± 0%    ~     (p=0.151 n=5+5)
GoTypes           124MB ± 0%        124MB ± 0%  -0.26%  (p=0.008 n=5+5)
Compiler          571MB ± 0%        566MB ± 0%  -0.84%  (p=0.008 n=5+5)
SSA              1.86GB ± 0%       1.85GB ± 0%  -0.58%  (p=0.008 n=5+5)
Flate            22.8MB ± 0%       22.8MB ± 0%  -0.17%  (p=0.008 n=5+5)
GoParser         27.3MB ± 0%       27.3MB ± 0%  -0.20%  (p=0.008 n=5+5)
Reflect          79.5MB ± 0%       79.3MB ± 0%  -0.20%  (p=0.008 n=5+5)
Tar              34.7MB ± 0%       34.6MB ± 0%  -0.42%  (p=0.008 n=5+5)
XML              45.4MB ± 0%       45.3MB ± 0%  -0.29%  (p=0.008 n=5+5)
[Geo mean]       80.0MB            79.7MB       -0.34%

name        old allocs/op     new allocs/op     delta
Template           378k ± 0%         377k ± 0%  -0.22%  (p=0.008 n=5+5)
Unicode            339k ± 0%         339k ± 0%    ~     (p=0.643 n=5+5)
GoTypes           1.36M ± 0%        1.36M ± 0%  -0.10%  (p=0.008 n=5+5)
Compiler          5.51M ± 0%        5.50M ± 0%  -0.13%  (p=0.008 n=5+5)
SSA               17.5M ± 0%        17.5M ± 0%  -0.14%  (p=0.008 n=5+5)
Flate              234k ± 0%         234k ± 0%  -0.04%  (p=0.008 n=5+5)
GoParser           299k ± 0%         299k ± 0%  -0.05%  (p=0.008 n=5+5)
Reflect            978k ± 0%         979k ± 0%  +0.02%  (p=0.016 n=5+5)
Tar                351k ± 0%         351k ± 0%  -0.04%  (p=0.008 n=5+5)
XML                435k ± 0%         435k ± 0%  -0.11%  (p=0.008 n=5+5)
[Geo mean]         840k              840k       -0.08%

file      before    after     Δ       %
go        14794788  14770212  -24576  -0.166%
addr2line 4203688   4199592   -4096   -0.097%
api       5954056   5941768   -12288  -0.206%
asm       4862704   4846320   -16384  -0.337%
cgo       4778920   4770728   -8192   -0.171%
compile   24001568  23923792  -77776  -0.324%
cover     5198440   5190248   -8192   -0.158%
dist      3595248   3587056   -8192   -0.228%
doc       4618504   4610312   -8192   -0.177%
fix       3337416   3333320   -4096   -0.123%
link      6120408   6116312   -4096   -0.067%
nm        4149064   4140872   -8192   -0.197%
objdump   4555608   4547416   -8192   -0.180%
pprof     14616324  14595844  -20480  -0.140%
test2json 2766328   2762232   -4096   -0.148%
trace     11638844  11622460  -16384  -0.141%
vet       8274936   8258552   -16384  -0.198%
total     132520780 132270972 -249808 -0.189%

Change-Id: Ifcd235a2a6e5f13ed5c93e62523e2ef61321fccf
Reviewed-on: https://go-review.googlesource.com/c/go/+/178197
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-08-27 22:15:13 +00:00
Bryan C. Mills
0a778cf57d cmd/go/internal/get: remove '--' separator from 'git ls-remote' command
'git ls-remote' started recognizing the '--' separator at some point
after 2.7.4, but git defaults to version 2.7.4 on Ubuntu 16.04 LTS,
which remains supported by Ubuntu until April 2021.

We added '--' tokens to most VCS commands as a defensive measure in
CL 181237, but it isn't strictly necessary here because the 'scheme'
argument to our template is chosen from a predefined list: we can
safely drop it to retain compatibility.

Fixes #33836
Updates #26746

Change-Id: Ibb53366b95f8029b587e0b7646a439330d759ac7
Reviewed-on: https://go-review.googlesource.com/c/go/+/191978
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-08-27 21:10:24 +00:00
Josh Bleecher Snyder
260e3d0818 cmd/compile: run deadcode before lowered CSE
CSE can make dead values live again.
Running deadcode first avoids that;
it also makes CSE more efficient.

file    before    after     Δ       %       
api     5970616   5966520   -4096   -0.069% 
asm     4867088   4846608   -20480  -0.421% 
compile 23988320  23935072  -53248  -0.222% 
link    6084376   6080280   -4096   -0.067% 
nm      4165736   4161640   -4096   -0.098% 
objdump 4572216   4568120   -4096   -0.090% 
pprof   14452996  14457092  +4096   +0.028% 
trace   11467292  11471388  +4096   +0.036% 
total   132181100 132099180 -81920  -0.062% 

Compiler performance impact is negligible:

name        old alloc/op      new alloc/op      delta
Template         38.8MB ± 0%       38.8MB ± 0%  -0.04%  (p=0.008 n=5+5)
Unicode          28.2MB ± 0%       28.2MB ± 0%    ~     (p=1.000 n=5+5)
GoTypes           131MB ± 0%        131MB ± 0%  -0.14%  (p=0.008 n=5+5)
Compiler          606MB ± 0%        606MB ± 0%  -0.05%  (p=0.008 n=5+5)
SSA              2.14GB ± 0%       2.13GB ± 0%  -0.26%  (p=0.008 n=5+5)
Flate            24.0MB ± 0%       24.0MB ± 0%  -0.18%  (p=0.008 n=5+5)
GoParser         28.8MB ± 0%       28.8MB ± 0%  -0.15%  (p=0.008 n=5+5)
Reflect          83.8MB ± 0%       83.7MB ± 0%  -0.11%  (p=0.008 n=5+5)
Tar              36.4MB ± 0%       36.4MB ± 0%  -0.09%  (p=0.008 n=5+5)
XML              47.9MB ± 0%       47.8MB ± 0%  -0.15%  (p=0.008 n=5+5)
[Geo mean]       84.6MB            84.5MB       -0.12%

name        old allocs/op     new allocs/op     delta
Template           379k ± 0%         380k ± 0%  +0.15%  (p=0.008 n=5+5)
Unicode            340k ± 0%         340k ± 0%    ~     (p=0.738 n=5+5)
GoTypes           1.36M ± 0%        1.36M ± 0%  +0.05%  (p=0.008 n=5+5)
Compiler          5.49M ± 0%        5.49M ± 0%  +0.12%  (p=0.008 n=5+5)
SSA               17.5M ± 0%        17.5M ± 0%  -0.18%  (p=0.008 n=5+5)
Flate              235k ± 0%         235k ± 0%    ~     (p=0.079 n=5+5)
GoParser           302k ± 0%         302k ± 0%    ~     (p=0.310 n=5+5)
Reflect            976k ± 0%         977k ± 0%  +0.08%  (p=0.008 n=5+5)
Tar                352k ± 0%         352k ± 0%  +0.12%  (p=0.008 n=5+5)
XML                436k ± 0%         436k ± 0%  -0.05%  (p=0.008 n=5+5)
[Geo mean]         842k              842k       +0.03%


Change-Id: I53e8faed1859885ca5c4a5d45067a50984f3eff1
Reviewed-on: https://go-review.googlesource.com/c/go/+/175879
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-08-27 21:04:53 +00:00
Stefan Baebler
cc6feab396 net/url: fail TestParseErrors test when getting an unwanted error
The TestParseErrors test function was not strict with unwanted errors
received from url.Parse(). It was not failing in such cases, now it does

Fixes #33646
Updates #29098

Change-Id: I069521093e2bff8b1fcd41ffd3f9799f3108bc61
GitHub-Last-Rev: e6844c57f9
GitHub-Pull-Request: golang/go#33876
Reviewed-on: https://go-review.googlesource.com/c/go/+/191966
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2019-08-27 21:02:43 +00:00
Anderson Queiroz
2b59894425 net/http: enhance documentation for Server.Addr
Fixes golang/go#31249

Change-Id: I3280f8ab170ed31d4efb71106533e016d430d44c
Reviewed-on: https://go-review.googlesource.com/c/go/+/191557
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-08-27 20:52:49 +00:00
Filippo Valsorda
2ebc3d8157 crypto/tls: make SSLv3 again disabled by default
It was mistakenly re-enabled in CL 146217.

Fixes #33837

Change-Id: I8c0e1787114c6232df5888e51e355906622295bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/191877
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-08-27 20:43:47 +00:00
Bryan C. Mills
8f5353fd1c cmd/go/internal/modload: fix swapped paths in error message
Updates #33879

Change-Id: Ifc91490b1cb791fdf5ffe69ef81c0ec0e6cbecc3
Reviewed-on: https://go-review.googlesource.com/c/go/+/191997
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
2019-08-27 20:36:50 +00:00
Matthew Dempsky
c302785df9 cmd/compile: fix "previous" position info for duplicate switch cases
Because the Node AST represents references to declared objects (e.g.,
variables, packages, types, constants) by directly pointing to the
referred object, we don't have use-position info for these objects.

For switch statements with duplicate cases, we report back where the
first duplicate value appeared. However, due to the AST
representation, if the value was a declared constant, we mistakenly
reported the constant declaration position as the previous case
position.

This CL reports back against the 'case' keyword's position instead, if
there's no more precise information available to us.

It also refactors code to emit the same "previous at" error message
for duplicate values in map literals.

Thanks to Emmanuel Odeke for the test case.

Fixes #33460.

Change-Id: Iec69542ccd4aad594dde8df02d1b880a422c5622
Reviewed-on: https://go-review.googlesource.com/c/go/+/188901
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-27 19:53:05 +00:00
Matthew Dempsky
c1df5187d0 runtime: simplify some pointer conversions
Use efaceOf to safely convert from *interface{} to *_eface, and to
make it clearer what the pointer arithmetic is computing.

Incidentally, remove a spurious unsafe.Pointer->*uint8->unsafe.Pointer
round trip conversion in newproc.

No behavior change.

Change-Id: I2ad9d791d35d8bd008ef43b03dad1589713c5fd4
Reviewed-on: https://go-review.googlesource.com/c/go/+/190457
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-08-27 19:51:43 +00:00