1
0
mirror of https://github.com/golang/go synced 2024-09-30 22:08:32 -06:00
Commit Graph

44046 Commits

Author SHA1 Message Date
Praveen Kumar
6677a2a1fc strings: remove an obsolete doc note for FieldsFunc
Fixes #38630

Change-Id: I0b2b693dd88821dcfc035cf552b687565bb55ef6
GitHub-Last-Rev: 291b1b4dcf
GitHub-Pull-Request: golang/go#38631
Reviewed-on: https://go-review.googlesource.com/c/go/+/229763
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-04-23 22:10:10 +00:00
Matthew Dempsky
080a3ee8b2 cmd/compile: remove ODDDARG
No longer needed after the last CL. Separate commit because
renumbering Ops causes toolstash to complain.

Change-Id: I6223a790cc341f8184eccb503f95a1dfc32a81e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/229760
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-23 22:02:26 +00:00
Matthew Dempsky
a44d06d3b4 cmd/compile: use fixVariadicCall in escape analysis
This CL uses fixVariadicCall before escape analyzing function calls.
This has a number of benefits, though also some minor obstacles:

Most notably, it allows us to remove ODDDARG along with the logic
involved in setting it up, manipulating EscHoles, and later copying
its escape analysis flags to the actual slice argument. Instead, we
uniformly handle all variadic calls the same way. (E.g., issue31573.go
is updated because now f() and f(nil...) are handled identically.)

It also allows us to simplify handling of builtins and generic
function calls. Previously handling of calls was hairy enough to
require multiple dispatches on n.Op, whereas now the logic is uniform
enough that we can easily handle it with a single dispatch.

The downside is handling //go:uintptrescapes is now somewhat clumsy.
(It used to be clumsy, but it still is, too.) The proper fix here is
probably to stop using escape analysis tags for //go:uintptrescapes
and unsafe-uintptr, and have an earlier pass responsible for them.

Finally, note that while we now call fixVariadicCall in Escape, we
still have to call it in Order, because we don't (yet) run Escape on
all compiler-generated functions. In particular, the generated "init"
function for initializing package-level variables can contain calls to
variadic functions and isn't escape analyzed.

Passes toolstash-check -race.

Change-Id: I4cdb92a393ac487910aeee58a5cb8c1500eef881
Reviewed-on: https://go-review.googlesource.com/c/go/+/229759
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2020-04-23 22:02:12 +00:00
Matthew Dempsky
83d25c61e4 go/types: add UsesCgo config to support _cgo_gotypes.go
This CL adds a UsesCgo config setting to go/types to specify that the
_cgo_gotypes.go file generated by cmd/cgo has been provided as a
source file. The type checker then internally resolves C.bar qualified
identifiers to _Cfoo_bar as appropriate.

It also adds support to srcimporter to automatically run cgo.
Unfortunately, this functionality is not compatible with overriding
OpenFile, because cmd/cgo and gcc will directly open files.

Updates #16623.
Updates #35721.

Change-Id: I1e1965fe41b765b7a9da3431f2a86cc16025dee2
Reviewed-on: https://go-review.googlesource.com/c/go/+/33677
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-04-23 20:45:57 +00:00
Lynn Boger
0ef3ebcc83 cmd/compile: clean up PPC64.rules typed aux changes
This adds a few minor changes from the first review.

Passes toolstash-check

Change-Id: I00f6f1b0235d0a8c686aa8793d0473b8fc6b1495
Reviewed-on: https://go-review.googlesource.com/c/go/+/229699
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-23 20:40:40 +00:00
Josh Bleecher Snyder
6303c34d7f cmd/compile: remove dead values after flagalloc
Fix a longstanding TODO.

Provides widespread, minor improvements.
Negligible compiler cost.

Because the freeze nears, put in a safety flag to easily disable.

Change-Id: I338812181ab6d806fecf22afd3c3502e2c94f7a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/229600
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-23 19:40:07 +00:00
Josh Bleecher Snyder
e0915dea09 cmd/compile: splitload (CMPconst [0] x) into (TEST x x) on amd64
Provides minor widespread benefit to generated code.

Removes one source of random fluctuation when changing
other aspects of the compiler.

Change-Id: I16db6f5e240a97d27f05dc1ba5b8b729af3adb12
Reviewed-on: https://go-review.googlesource.com/c/go/+/229702
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-23 19:39:25 +00:00
Josh Bleecher Snyder
d9d88dd27f cmd/compile: allow named values on RHS of rewrite rules
Fixes #38621

Change-Id: Idbffdcc70903290dc58e5abb4867718bd5449fe1
Reviewed-on: https://go-review.googlesource.com/c/go/+/229701
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-23 19:39:12 +00:00
Lynn Boger
91b9c2f350 cmd/asm,cmd/internal/obj/ppc64: update instructions and tests
This change adds some instructions that were missing from the
ppc64 assembler, mostly power9 but a few others from earlier.

Tests in cmd/asm for ppc64 were updated: ppc64.s includes the
new instructions, and ppc64enc.s now includes not only the
new instructions but most ppc64 opcodes to provide a more
complete test of the ppc64 assembler.

The ppc64 instruction set is used for linux/ppc64le,
linux/ppc64, and aix/ppc64.

Change-Id: I8695f89dbca06174847963f4ef869f2e584d5bbf
Reviewed-on: https://go-review.googlesource.com/c/go/+/229479
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>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-23 19:28:16 +00:00
Dan Scales
939379ffb6 runtime: fix TestDeferWithRepeatedRepanics and TestIssue37688 to be less chatty
Converted some Println() statements (used to make sure that certain variables were
kept alive and not optimized out) to assignments into global variables, so the
tests don't produce extraneous output when there is a failure.

Fixes #38594

Change-Id: I7eb41bb02b2b1e78afd7849676b5c85bc11c759c
Reviewed-on: https://go-review.googlesource.com/c/go/+/229538
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-23 18:33:44 +00:00
Matthew Dempsky
681ba43077 cmd/compile: move fixVariadicCall from walk to order
This CL moves fixVariadicCall from mid-Walk of function calls to
early-Order, in preparation for moving it even earlier in the future.

Notably, rewriting variadic calls this early introduces two
compilation output changes:

1. Previously, Order visited the ODDDARG before the rest of the
arguments list, whereas the natural time to visit it is at the end of
the list (as we visit arguments left-to-right, and the ... argument is
the rightmost one). Changing this ordering permutes the autotmp
allocation order, which in turn permutes autotmp naming and stack
offsets.

2. Previously, Walk separately walked all of the variadic arguments
before walking the entire slice literal, whereas the more natural
thing to do is just walk the entire slice literal. This triggers
slightly different code paths for composite literal construction in
some cases.

Neither of these have semantic impact. They simply mean we're now
compiling f(a,b,c) the same way as we were already compiling
f([]T{a,b,c}...).

Change-Id: I40ccc5725697a116370111ebe746b2639562fe87
Reviewed-on: https://go-review.googlesource.com/c/go/+/229601
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2020-04-23 18:29:42 +00:00
Keith Randall
0d19b91b40 cmd/go: use response files when command line would be too long
Fixes #37768

Change-Id: I799a8da632890ad7595697d461c90e3c4c065d95
Reviewed-on: https://go-review.googlesource.com/c/go/+/229317
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-04-23 18:20:07 +00:00
Josh Bleecher Snyder
bf5b83a835 cmd/compile: convert splitload rules to typed aux
Passes toolstash-check -all.

Change-Id: Ia441582f7f67184eb831e184f9c3c0e3c11001bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/229698
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-23 17:52:48 +00:00
Josh Bleecher Snyder
e7c1873691 cmd/compile: optimize x & 1 != 0 to x & 1 on amd64
Triggers a handful of times in std+cmd.

Change-Id: I9bb8ce9a5f8bae2547cb61157cd8f256e1b63e76
Reviewed-on: https://go-review.googlesource.com/c/go/+/229602
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-23 17:52:28 +00:00
Cuong Manh Le
917aa72c14 cmd/compile: rewrite dec rules to use typed aux field
Passes toolstash-check -all.

Change-Id: Ia73233c2269017a5802df821ea2ca138c16a94ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/229519
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
2020-04-23 17:25:43 +00:00
Cuong Manh Le
7f0c479fff cmd/compile: rewrite dec64 rules to use typed aux field
Passes toolstash-check -all.

Change-Id: If9dd6c2155374eb9ef47639201ec90109a9e314c
Reviewed-on: https://go-review.googlesource.com/c/go/+/229518
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
2020-04-23 17:25:31 +00:00
Cherry Zhang
67bf856b96 [dev.link] all: merge branch 'master' into dev.link
Change-Id: Ia6426e8494244fde7e81a7c932c8e3c865676d3d
2020-04-23 11:47:20 -04:00
Cherry Zhang
dee3e3aebd [dev.link] cmd/link: clean up some tests
Use a separate directory for TestBuildFortvOS test files.

Remove a bad comment in TestTrampoline.

Change-Id: I2dc07ae575ec3f73fb7cea26743094b11a41b464
Reviewed-on: https://go-review.googlesource.com/c/go/+/229619
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-23 15:31:01 +00:00
Johan Jansson
c8dea8198e cmd/go: allow generate to process invalid packages
Allow go generate to process packages that contain invalid code. Ignore
errors when loading the package, but process only files which have a
valid package clause. Set $GOPACKAGE individually for each file, based
on the package clause.

Add test script for go generate and invalid packages.

Fixes #36422

Change-Id: I91ea088346a1548ccd6678b4595a527b948331ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/229097
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-23 15:19:53 +00:00
Josh Bleecher Snyder
e354309e1e cmd/compile: add ssa.Block.truncateValues
It is a common operation.

Passes toolstash-check.

Change-Id: Icc34600b0f79d0ecb19f257e3c7f23b6f01a26ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/229599
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-23 14:59:55 +00:00
Josh Bleecher Snyder
806318d6ad cmd/compile: simplify zcse
Minor refactoring.

Passes toolstash-check.

Change-Id: I91e981bf369d4b719163107644fa58f583356c25
Reviewed-on: https://go-review.googlesource.com/c/go/+/229598
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-23 14:59:41 +00:00
witchard
708ac9aacb cmd/go/internal/modget: improve GOINSECURE docs
Recommend use of GOINSECURE over -insecure flang and clarify that GOINSECURE
environment variable does not also imply GONOSUMDB.

Updates #37519 by adding documentation as discussed.

Change-Id: Ia8ab6b3ed1aa559343b72e4ca76c372ee6bf1941
GitHub-Last-Rev: 8d86991f0c
GitHub-Pull-Request: golang/go#38572
Reviewed-on: https://go-review.googlesource.com/c/go/+/229223
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-23 13:46:00 +00:00
Cuong Manh Le
e43239aabe cmd/compile: pre-alloc enough room for Escape.walkAll
Slightly reduce allocs, passes toolstash-check.

name          old time/op       new time/op       delta
Template            181ms ± 4%        174ms ± 0%  -3.59%  (p=0.008 n=5+5)

name          old user-time/op  new user-time/op  delta
Template            249ms ± 3%        240ms ± 2%  -3.59%  (p=0.016 n=5+5)

name          old alloc/op      new alloc/op      delta
Template           35.0MB ± 0%       34.9MB ± 0%  -0.09%  (p=0.008 n=5+5)
Unicode            28.6MB ± 0%       28.6MB ± 0%    ~     (p=0.421 n=5+5)
GoTypes             114MB ± 0%        114MB ± 0%  -0.10%  (p=0.008 n=5+5)
Compiler            542MB ± 0%        541MB ± 0%  -0.13%  (p=0.008 n=5+5)
SSA                1.21GB ± 0%       1.21GB ± 0%  -0.10%  (p=0.008 n=5+5)
Flate              22.0MB ± 0%       22.0MB ± 0%  -0.05%  (p=0.016 n=5+5)
GoParser           27.1MB ± 0%       27.0MB ± 0%  -0.05%  (p=0.008 n=5+5)
Reflect            74.8MB ± 0%       74.8MB ± 0%  -0.11%  (p=0.008 n=5+5)
Tar                33.0MB ± 0%       32.9MB ± 0%  -0.07%  (p=0.008 n=5+5)
XML                42.1MB ± 0%       42.1MB ± 0%  -0.07%  (p=0.008 n=5+5)
LinkCompiler        222MB ± 0%        222MB ± 0%    ~     (p=0.690 n=5+5)
[Geo mean]         81.3MB            81.2MB       -0.07%

name          old allocs/op     new allocs/op     delta
Template             347k ± 0%         347k ± 0%  -0.16%  (p=0.008 n=5+5)
Unicode              334k ± 0%         334k ± 0%  -0.03%  (p=0.016 n=5+5)
GoTypes             1.20M ± 0%        1.20M ± 0%  -0.12%  (p=0.008 n=5+5)
Compiler            5.13M ± 0%        5.12M ± 0%  -0.11%  (p=0.008 n=5+5)
SSA                 11.7M ± 0%        11.7M ± 0%  -0.13%  (p=0.008 n=5+5)
Flate                221k ± 0%         221k ± 0%  -0.18%  (p=0.008 n=5+5)
GoParser             280k ± 0%         280k ± 0%  -0.06%  (p=0.008 n=5+5)
Reflect              902k ± 0%         900k ± 0%  -0.28%  (p=0.008 n=5+5)
Tar                  323k ± 0%         322k ± 0%  -0.18%  (p=0.008 n=5+5)
XML                  401k ± 0%         401k ± 0%  -0.10%  (p=0.008 n=5+5)
LinkCompiler         735k ± 0%         735k ± 0%    ~     (p=0.841 n=5+5)
[Geo mean]           753k              752k       -0.12%

Change-Id: I647bd7752f28b74e6f400fa16cb69632f5c952b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/229517
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-04-23 07:33:21 +00:00
Matthew Dempsky
9f4dd09bf5 cmd/compile: refactor variadac call desugaring
In mid-Walk, we rewrite calls to variadic functions to use explicit
slice literals; e.g., rewriting f(a,b,c) into f([]T{a,b,c}...).
However, it would be useful to do that rewrite much earlier in the
compiler, so that other compiler passes can be simplified.

This CL refactors the rewrite logic into a new fixVariadicCall
function, which subsequent CLs can more easily move into earlier
compiler passes.

Passes toolstash-check -race.

Change-Id: I408e655f2d3aa00446a2e6accf8765abc3b16a8a
Reviewed-on: https://go-review.googlesource.com/c/go/+/229486
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2020-04-23 06:24:40 +00:00
Andrei Tudor Călin
952f7de3b4 testing: make TempDir work for subtests
ioutil.TempDir doesn't like path separators in its pattern. Modify
(*common).TempDir to replace path separators with underscores before
using the test name as a pattern for ioutil.TempDir.

Fixes #38465.

Change-Id: I9e8ae48b99648b2bf9f561762e845165aff01972
Reviewed-on: https://go-review.googlesource.com/c/go/+/229399
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-23 01:34:16 +00:00
Matthew Dempsky
f049d911e9 cmd/compile: be stricter about recognizing safety rule #4
unsafe.Pointer safety rule #4 says "The compiler handles a Pointer
converted to a uintptr in the argument list of a call". Within escape
analysis, we've always required this be a single conversion
unsafe.Pointer->uintptr conversion, but the corresponding logic in
order is somewhat laxer, allowing arbitrary chains of OCONVNOPs from
unsafe.Pointer to uintptr.

This CL changes order to be stricter to match escape analysis.

Passes toolstash-check.

Change-Id: Iadd210d2123accb2020f5728ea2a47814f703352
Reviewed-on: https://go-review.googlesource.com/c/go/+/229578
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-23 00:08:35 +00:00
Jeremy Faller
7466cad9c4 [dev.link] cmd/link: only allow heap area to grow to 10MB
With CL 228782, we've removed file I/O, but we're growing the memory too
much. This change will periodically flush the heap area to the mmapped
area (if possible).

Change-Id: I1622c738ee5a1a6d02bff5abb0a5751caf8095c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/229439
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-22 22:12:42 +00:00
Daniel Theophanes
ed7888aea6 database/sql: de-flake TestTxCannotCommitAfterRollback
Do not cancel rows during test. Only cancel the Tx.
Correct the referenced issue number on the test.

Fixes #38597

Change-Id: I0e8ba1bf2a8ba638d121c9c6938501fec1d5e961
Reviewed-on: https://go-review.googlesource.com/c/go/+/229478
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-22 22:10:09 +00:00
Kirill Korotaev
9a93baf4d7 encoding/base64: improve performance up to 20% total
Improve base64 encoding/decoding performance by
suppressing compiler boundary checks on decode.

name                 old speed      new speed      delta
EncodeToString-8      570MB/s ± 1%   573MB/s ± 1%     ~     (p=0.421 n=5+5)
DecodeString/2-8     88.6MB/s ± 3%  91.6MB/s ± 2%   +3.37%  (p=0.016 n=5+5)
DecodeString/4-8      162MB/s ± 1%   168MB/s ± 0%   +4.12%  (p=0.008 n=5+5)
DecodeString/8-8      203MB/s ± 0%   214MB/s ± 0%   +5.18%  (p=0.008 n=5+5)
DecodeString/64-8     471MB/s ± 1%   520MB/s ± 1%  +10.50%  (p=0.008 n=5+5)
DecodeString/8192-8   757MB/s ± 0%   895MB/s ± 1%  +18.29%  (p=0.008 n=5+5)

Change-Id: I135243c11aa4c974a4a4e95c5c2abb0635d52c8c
GitHub-Last-Rev: 2c87abcb28
GitHub-Pull-Request: golang/go#36910
Reviewed-on: https://go-review.googlesource.com/c/go/+/217117
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-22 21:36:41 +00:00
Hana (Hyang-Ah) Kim
0ee4b13830 net/http/pprof: allow "seconds" parameters to most profiles
golang.org/cl/147598 added the support for delta computation for mutex
and block profiles. In fact, this delta computation makes sense for
other types of profiles.

For example, /debug/pprof/allocs?seconds=x will provide how much allocation
was made during the specified period. /debug/pprof/goroutine?seconds=x will
provide the changes in the list of goroutines. This also makes sense for
custom profiles.

Update #23401
Update google/pprof#526

Change-Id: I45e9073eb001ea5b3f3d16e5a57f635193610656
Reviewed-on: https://go-review.googlesource.com/c/go/+/229537
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-04-22 21:08:58 +00:00
Hana (Hyang-Ah) Kim
3e342e8719 net/http/pprof: make TestDeltaProfile less flaky by retrying
In some slow environment, the goroutine for mutexHog2 may not run
within 1secs. So, try with increasing seconds parameters,
and declare failure if it still fails with the longest duration
parameter (32sec).

Also, relax the test condition - previously we expected the
profile's duration is within 0.5~2sec. But obviously, in some
slow environment, that's not even guaranteed. Just check we get
non-zero duration in the result.

Update #38544

Change-Id: Ia9b0d51429a2093e6c9eb92cf463ff6952ef3e10
Reviewed-on: https://go-review.googlesource.com/c/go/+/229498
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-22 21:08:29 +00:00
Lynn Boger
4a5d6916ed cmd/compile: update PPC64.rules to use typed aux values
Passes toolstash-check.

Change-Id: I874f8b834ef2f94daa971ecef2dbe4e14daf4213
Reviewed-on: https://go-review.googlesource.com/c/go/+/229305
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-22 20:56:14 +00:00
Michael Munday
ab7a65f283 cmd/compile: clean up codegen for branch-on-carry on s390x
This CL optimizes code that uses a carry from a function such as
bits.Add64 as the condition in an if statement. For example:

    x, c := bits.Add64(a, b, 0)
    if c != 0 {
        panic("overflow")
    }

Rather than converting the carry into a 0 or a 1 value and using
that as an input to a comparison instruction the carry flag is now
used as the input to a conditional branch directly. This typically
removes an ADD LOGICAL WITH CARRY instruction when user code is
doing overflow detection and is closer to the code that a user
would expect to generate.

Change-Id: I950431270955ab72f1b5c6db873b6abe769be0da
Reviewed-on: https://go-review.googlesource.com/c/go/+/219757
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-22 20:11:06 +00:00
Than McIntosh
00723603eb [dev.link] cmd/link/internal/loader: fix AttrSubSymbol
The code that runs as a part of loadlibfull converts the linker's
outer/sub state and sets the sym.Symbol AttrSubSymbol if a symbol has
both A) an outer sym, and B) is listed as a sub-symbol by some other
symbol.

Make sure that we have the same logic in the original loader method,
since we need to use it as part of dodata() prior to loadlibfull.

Change-Id: I200adab741d778a6ba821419e8ea131ad19375bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/229440
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-22 19:37:28 +00:00
Than McIntosh
25992d025f [dev.link] cmd/link/internal/loader: preprocess numeric constants earlier
Change the timing for preprocessing of integer/floating point constant
symbols so that we populate them with content at an earlier stage.
This is needed to allow them can be picked up by the loader-API
version of dodata().

Change-Id: Icf09f4f4b318b4f77e11d4a0f0a9cbecd76a1d6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/229438
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-22 18:12:02 +00:00
Alberto Donizetti
81df5e69fc cmd/compile: switch to typed aux for mips lowering rules
This covers most of the lowering rules.

Passes

  GOARCH=mips gotip build -toolexec 'toolstash -cmp' -a std
  GOARCH=mipsle gotip build -toolexec 'toolstash -cmp' -a std

Change-Id: I9d00aaebecb36622e3bdaf556e5a9377670bf86b
Reviewed-on: https://go-review.googlesource.com/c/go/+/229102
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-22 17:30:07 +00:00
Than McIntosh
45bd3b1bc4 [dev.link] cmd/link: create loader-specific version of GCProg
Create a new version of the GCProg type + methods that use loader APIs
instead of sym.Symbol.

This code isn't actually used just yet, but will be needed once the
wavefront reaches dodata() and we need to convert that phase.

Change-Id: I087521832015818204fe5c2ac99c7bd3f61b2bf0
Reviewed-on: https://go-review.googlesource.com/c/go/+/229037
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-22 16:47:33 +00:00
Katie Hockman
141b11d5a1 crypto/x509: disallow setting MaxPathLen without IsCA
Fixes #38216

Change-Id: I3222abe2153abb4cbfa65a4825c153ce128f56a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/228777
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2020-04-22 16:45:05 +00:00
Colin
12579009b3 database/sql: count connections expired in foreground with MaxLifetimeClosed
Previously the connection pool would only count connections
expired in the background connectionCleaner goroutine towards the
MaxLifetimeClosed stat.

This change increments the stat correctly when checking for
expiry in when acquiring and releasing a connection.

Fixes #38058

Change-Id: Id707ddd40a42a4c38658d5f2931da131647d6c29
GitHub-Last-Rev: 0f205ede43
GitHub-Pull-Request: golang/go#38263
Reviewed-on: https://go-review.googlesource.com/c/go/+/227278
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
2020-04-22 16:19:35 +00:00
Alberto Donizetti
0a00926481 runtime: fix bad link to issue tracker in test
Change-Id: Ie88ff3f0493f4119be25476a20038877e879c485
Reviewed-on: https://go-review.googlesource.com/c/go/+/229397
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-04-22 16:03:11 +00:00
David Finkel
38c2c12bc1 runtime/pprof: plumb labels for goroutine profiles
Goroutines are directly associated with labels. It's relatively easy to
plumb those through without creating goroutine-locals in the wild.

This is accomplished by splitting out most of the code from the public
`runtime.GoroutineProfile` into a new unexported
`runtime.goroutineProfileWithLabels`, which then has a thin wrapper
linked into the `runtime/pprof` package as
`runtime_goroutineProfileWithLabels`. (mirroring the way labels get
associated with the `g` for a goroutine in the first place)

Per-#6104, OS-thread creation profiles are a bit useless, as `M`s tend
to be created be created by a background goroutine. As such, I decided
not to add support for capturing the labels at `M`-creation-time, since
the stack-traces seem to always come out `nil` for my simple test
binaries.

This change currently provides labels for debug=0 and debug=1, as
debug=2 is currently entirely generated by the runtime package and I
don't see a clean way of getting the `labelMap` type handled properly
within the `runtime` package.

Update the comment added in cl/131275 to mention goroutine support for
labels.

Updates #23458

Change-Id: Ia4b558893d7d10156b77121cd9b70c4ccd9e1889
Reviewed-on: https://go-review.googlesource.com/c/go/+/189318
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2020-04-22 16:01:25 +00:00
Ruixin(Peter) Bao
0329c915a0 math/big: clean up whitespace in arith_s390x.s file
This CL looks big but it only does formatting changes to arith_s390x.s.
The file was formatted using asmfmt(https://github.com/klauspost/asmfmt)
, so there should not be any functional impact. I verified that the
generated assembly of big.test file is identical.

Change-Id: I8b4035ef082a4d0357881869327e25253f2d8be1
Reviewed-on: https://go-review.googlesource.com/c/go/+/229302
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-22 15:40:55 +00:00
Cherry Zhang
d8ab10525e [dev.link] cmd/link, cmd/oldlink: remove more darwin/386 and darwin/arm code
Updates #37610, #37611.

Change-Id: I0a497af03e24ddea40ed3e342f3a9362bf21ac0c
Reviewed-on: https://go-review.googlesource.com/c/go/+/229323
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2020-04-22 15:27:18 +00:00
Cherry Zhang
c33b7c7592 [dev.link] cmd/internal/goobj: add index to symbol name for indexed symbols
With old object files, when objdump an object file which, for
example, contains a call of fmt.Fprintf, it shows a symbol
reference like

	R_CALL:fmt.Fprintf

With new object files, as the symbol reference is indexed, the
reference becomes

	R_CALL:fmt.#33

The object file does not contain information of what symbol #33
in the fmt package is.

To make this more useful, print the index when dumping the symbol
definitions. This way, when dumping the fmt package, e.g.
"go tool nm fmt.a", it will print

   6c705 T fmt.Fprintf#33

So we can find out what symbol #33 actually is.

Change-Id: I320776597d28615ce18dd0617c352d2b8180db49
Reviewed-on: https://go-review.googlesource.com/c/go/+/229246
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-22 15:14:44 +00:00
Cherry Zhang
245a2f5780 [dev.link] cmd/link: delete ctxt.Reachparent
It is no longer needed as we have converted the fieldtrack pass
to using the loader.

Also free loader.Reachparent after we are done with it.

Change-Id: Ibc4b29f282e1e4aea363a1b549755e31f84b0295
Reviewed-on: https://go-review.googlesource.com/c/go/+/229322
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-22 14:57:26 +00:00
Cherry Zhang
9570fc8f71 [dev.link] cmd/link: reduce memory usage for storing symbol section information
Currently, we use a dense array to store symbol's sections. The
array element is a *sym.Section, which takes 8 bytes per symbol
on a 64-bit machine. And the array is created upfront.

To reduce memory usage, use a 16-bit index for sections, so we
store 2 bytes per symbol. The array is pointerless, reducing GC
work. Also create the array lazily.

This reduces some memory usage: linking cmd/compile,

name           old alloc/op   new alloc/op   delta
Loadlib_GC       42.1MB ± 0%    36.2MB ± 0%      -14.01%  (p=0.008 n=5+5)

name           old live-B     new live-B     delta
Loadlib_GC        16.8M ± 0%     15.4M ± 0%       -8.36%  (p=0.008 n=5+5)
Archive_GC        98.2M ± 0%     97.2M ± 0%       -1.02%  (p=0.008 n=5+5) # at the end

Change-Id: If8c41eded8859660bca648c5e6fdf5830810fbf6
Reviewed-on: https://go-review.googlesource.com/c/go/+/229306
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-22 14:40:35 +00:00
Martin Möhrmann
e93d5b5e05 unicode/utf8: optimize Valid and ValidString for ASCII checks
Add a fastpath that uses 32bit loads and compares to check
8 ASCII characters per loop iteration.

This avoids the overhead of comparing and branching
for every byte individually.

Combining two 32bit loads into an uint32 allows the same
code to be used for 32bit and 64bit platforms.

amd64 (Intel i7-3520M):
name                         old time/op  new time/op  delta
ValidTenASCIIChars           15.6ns ± 4%   8.5ns ±14%  -45.27%  (p=0.000 n=10+10)
ValidTenJapaneseChars        50.0ns ± 2%  52.7ns ±15%     ~     (p=0.469 n=10+10)
ValidStringTenASCIIChars     13.5ns ± 1%   7.9ns ± 5%  -41.56%  (p=0.000 n=10+10)
ValidStringTenJapaneseChars  46.3ns ± 2%  45.8ns ± 2%     ~     (p=0.085 n=10+10)

arm (Raspberry Pi 3):
name                         old time/op  new time/op  delta
ValidTenASCIIChars           87.5ns ± 0%  58.5ns ± 0%  -33.11%  (p=0.000 n=9+10)
ValidTenJapaneseChars         359ns ± 0%   384ns ± 0%   +6.96%  (p=0.000 n=10+9)
ValidStringTenASCIIChars     87.5ns ± 0%  57.5ns ± 0%  -34.31%  (p=0.000 n=10+10)
ValidStringTenJapaneseChars   356ns ± 0%   377ns ± 0%   +5.90%  (p=0.000 n=10+10)

Change-Id: I9da942bddb250ee1f0ef7aabb4a8cb48edd9053e
Reviewed-on: https://go-review.googlesource.com/c/go/+/228823
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-22 14:14:34 +00:00
Ruixin(Peter) Bao
a45ea55da7 cmd/internal: allow ADDE to work with memory location on s390x
Originally on s390x, ADDE does not work when adding numbers from a memory location.
For example: ADDE (R3), R4 will result in a failure.

Since ADDC, ADD and ADDW already supports adding from memory location,
let's support that for ADDE as well.

Change-Id: I7cbe112ea154733a621b948c6a21bbee63fb0c62
Reviewed-on: https://go-review.googlesource.com/c/go/+/229304
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-22 11:37:03 +00:00
Cuong Manh Le
79395c55e2 cmd/compile: remove ntz function
Use ntzX variants instead.

Passes toolstash-check -a.

Change-Id: I7a627f46f75c3d339034bd3e81c190cea5409c88
Reviewed-on: https://go-review.googlesource.com/c/go/+/229140
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-22 08:04:58 +00:00
Ian Lance Taylor
b71eafbcec time: use extended time format past end of zone transitions
This gives us better expected information for daylight savings time
transitions in year 2038 and beyond.

Fixes #36654

Change-Id: I5a39aed3c40b184e1d7bb7d6ce3aff5307c4c146
Reviewed-on: https://go-review.googlesource.com/c/go/+/215539
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-22 04:08:24 +00:00