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

45067 Commits

Author SHA1 Message Date
Cherry Zhang
20819440fc cmd/internal/objfile: correct file table reading for Go object file
Apparently I never actually understood the new file table in Go
object files. The PC value stream actually encodes the file index
in the per-CU table. I thought it was indexing into a per-function
table, which then contains index to the per-CU table. Remove the
extra indirection.

Change-Id: I0aea5629f7b3888ebe3a04fea437aa15ce89519e
Reviewed-on: https://go-review.googlesource.com/c/go/+/262779
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-10-16 14:40:50 +00:00
Daniel Martí
771f5f2e48 compress/flate: revert a goto for-loop
In https://golang.org/cl/16528, a goto loop was chosen over a regular
for loop since that would make the function inlinable.

Thanks to the recent https://golang.org/cl/256459, for loops without a
label can now be inlined. So we can undo the workaround and simplify the
code.

Also add the function to TestIntendedInlining, which passes both before
and after the change, as expected.

For #14768.

Change-Id: Ie5df55a6bcb07c538ca331eef2f908807ff0b516
Reviewed-on: https://go-review.googlesource.com/c/go/+/263037
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2020-10-16 14:23:21 +00:00
Jay Conrod
8ee4d6e1bf cmd/go/internal/modload: move fetch to import.go
From a comment in CL 262341. It makes more sense in import.go than in
mvs.go.

Change-Id: If4dfa1091077e110c5041bc849d99bc0be2bd8e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/262780
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-10-16 14:02:35 +00:00
Lynn Boger
e981936855 cmd/internal/obj/ppc64,cmd/asm/internal/asm/testdata: fix up ppc64 testcases
When a fix was made at the end of the last release related to
NOPs, it was discovered that the ppc64.s testcase was out of date
and contained comments that weren't being processed. Essentially the
instructions in that test were being assembled but there was no
verification that the encodings weres correct. The ppc64enc.s file
was mostly complete and included the valid encodings for verification.
This change moves ppc64enc.s to ppc64.s and adds the instructions
that were missing.

This also adds a minor fix to asm9.go on the assembly of the
addex that was discovered during this testing.

Change-Id: Iaada1563b137849ad195fa88f32ecc9ab3e1e95f
Reviewed-on: https://go-review.googlesource.com/c/go/+/260217
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
2020-10-16 12:48:42 +00:00
Russ Cox
af8748054b sort: update comments
- Describe requirements on Less more precisely.
- Standardize on x for the variable name of the data being sorted
  (was variously a, p, slice).
- Many other minor wording changes.

Fixes #41951.

Change-Id: Ic9e222a53ec035fcc3b5ddfc7f0eefbe1bb2890d
Reviewed-on: https://go-review.googlesource.com/c/go/+/262657
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2020-10-16 04:13:45 +00:00
Russ Cox
912262b806 cmd/internal/obj: move LSym.Func into LSym.Extra
This creates space for a different kind of extension field
in LSym without making the struct any larger.
(There are many LSym, so we care about keeping the struct small.)

Change-Id: Ib16edb9e15f54c2a7351c8b875e19684058711e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/243943
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-10-16 03:02:36 +00:00
Russ Cox
59202c4204 net/http: deflake TestServerEmptyBodyRace_h1, or at least try
Fixes #22540.
For #33585.

Change-Id: I504b5a91ce1a39cd4ffd2380178a1b8f82f49dd3
Reviewed-on: https://go-review.googlesource.com/c/go/+/261698
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-10-16 00:59:55 +00:00
ananya saxena
7602d41196 net/http: remove DualStack in DefaultTransport
Removing `DualStack` from `http.DefaultTransport` since it is deprecated
https://github.com/golang/go/blob/master/src/net/dial.go#L61

Change-Id: Id8ea1e68796ef8a8d49f7a04d0c4815aa92a1804
GitHub-Last-Rev: 0907b59fa7
GitHub-Pull-Request: golang/go#41233
Reviewed-on: https://go-review.googlesource.com/c/go/+/253198
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Damien Neil <dneil@google.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
2020-10-15 23:12:53 +00:00
Michael Matloob
21e441c461 cmd/go: rewrite paths for overlaid files using -trimpath
Pass the trimpath flag to cmd/compile to use the correct file paths
for files that are overlaid: that is, the "destination" path in the
overlay's Replace mapping rather than the "source" path.

Also fix paths to go source files provided to the gccgo compiler.

For #39958

Change-Id: I3741aeb2272bd0d5aa32cb28133b61e58264fd39
Reviewed-on: https://go-review.googlesource.com/c/go/+/257198
Trust: Michael Matloob <matloob@golang.org>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-10-15 21:40:46 +00:00
Cherry Zhang
748c0d87e2 cmd/dist: only build ios_exec wrapper for ios
Not for darwin/arm64.

Updates #38485.

Change-Id: I08a5f00fd77f20c9c483755a36755a63cf10aa1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/262558
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2020-10-15 20:10:46 +00:00
Matthew Dempsky
1bcf6beec5 cmd/compile: use staticValue for inlining logic
This CL replaces the ad hoc and duplicated logic for detecting
inlinable calls with a single "inlCallee" function, which uses the
"staticValue" helper function introduced in an earlier commit.

Updates #41474.

Change-Id: I103d4091b10366fce1344ef2501222b7df68f21d
Reviewed-on: https://go-review.googlesource.com/c/go/+/256460
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Matthew Dempsky <mdempsky@google.com>
2020-10-15 18:35:44 +00:00
Ian Lance Taylor
64fb6ae95f runtime: stop preemption during syscall.Exec on Darwin
On current macOS versions a program that receives a signal during an
execve can fail with a SIGILL signal. This appears to be a macOS
kernel bug. It has been reported to Apple.

This CL partially works around the problem by using execLock to not
send preemption signals during execve. Of course some other stray
signal could occur, but at least we can avoid exacerbating the problem.
We can't simply disable signals, as that would mean that the exec'ed
process would start with all signals blocked, which it likely does not
expect.

Fixes #41702

Change-Id: I91b0add967b315671ddcf73269c4d30136e579b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/262438
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-10-15 18:30:07 +00:00
Matthew Dempsky
497ea0610e cmd/compile: allow inlining of "for" loops
We already allow inlining "if" and "goto" statements, so we might as
well allow "for" loops too. The majority of frontend support is
already there too.

The critical missing feature at the moment is that inlining doesn't
properly reassociate OLABEL nodes with their control statement (e.g.,
OFOR) after inlining. This eventually causes SSA construction to fail.

As a workaround, this CL only enables inlining for unlabeled "for"
loops. It's left to a (yet unplanned) future CL to add support for
labeled "for" loops.

The increased opportunity for inlining leads to a small growth in
binary size. For example:

$ size go.old go.new
   text	   data	    bss	    dec	    hex	filename
9740163	 320064	 230656	10290883	 9d06c3	go.old
9793399	 320064	 230656	10344119	 9dd6b7	go.new

Updates #14768.
Fixes #41474.

Change-Id: I827db0b2b9d9fa2934db05caf6baa463f0cd032a
Reviewed-on: https://go-review.googlesource.com/c/go/+/256459
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2020-10-15 18:26:33 +00:00
Matthew Dempsky
c0417df156 cmd/compile: improve escape analysis of known calls
Escape analysis is currently very naive about identifying calls to
known functions: it only recognizes direct calls to a declared
function, or direct calls to a closure.

This CL adds a new "staticValue" helper function that can trace back
through local variables that were initialized and never reassigned
based on a similar optimization already used by inlining. (And to be
used by inlining in a followup CL.)

Updates #41474.

Change-Id: I8204fd3b1e150ab77a27f583985cf099a8572b2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/256458
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
2020-10-15 18:26:06 +00:00
Matthew Dempsky
cced777026 cmd/compile: set n.Name.Defn for inlined parameters
Normally, when variables are declared and initialized using ":=", we
set the variable's n.Name.Defn to point to the initialization
assignment node (i.e., OAS or OAS2). Further, some frontend
optimizations look for variables that are initialized but never
reassigned.

However, when inl.go inlines calls, it was declaring the inlined
variables, and then separately assigning to them. This CL changes
inl.go tweaks the AST to fit the combined declaration+initialization
pattern.

This isn't terribly useful by itself, but it allows further followup
optimizations.

Updates #41474.

Change-Id: I62a9752c60414305679e0ed15a6563baa0224efa
Reviewed-on: https://go-review.googlesource.com/c/go/+/256457
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2020-10-15 18:25:47 +00:00
Alberto Donizetti
8773d14164 cmd/compile: make assignop/convertop reason a return param
On a negative answer, the assignop and convertop functions write the
reason why to a string pointer passed as an argument, likely a C-ism
leftover since the compiler's machine assisted translation to Go.

This change makes why a return parameter.

It also fixes a few places where the assignop/convertop result was
compared to 0. While OXXX's value may be zero now, using the named
constant is more robust.

Change-Id: Id9147ed4c1b97d658d30a2f778f876b7867006b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/261857
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
2020-10-15 18:08:54 +00:00
Alberto Donizetti
3c9488edff cmd/compile: clean up C->Go translation artifacts in badtype
Change-Id: I576a596ed8e9ce14e3750031d0e338e9276eff1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/262537
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-10-15 18:07:26 +00:00
Cuong Manh Le
50b7171af0 cmd/compile: simplify exprformat untyped condition checking
L1337 in fmt.go can be checked just by using "!n.Type.IsUntyped".

Passes toolstash-check.

Change-Id: I5b0c81543bc929367f70713d0ca40b289f905b48
Reviewed-on: https://go-review.googlesource.com/c/go/+/262637
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-10-15 17:21:17 +00:00
Joel Sing
623319a847 cmd/link/internal/arm64: handle calls to SDYNIMPORT with internal linking
Handle calls to symbols that are SDYNIMPORT when linking internally on arm64.

Update #36435

Change-Id: I8b5421171bf471cf31c91d90b8ba99511d2c9e2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/250181
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-10-15 16:42:52 +00:00
Michael Pratt
2517f4946b runtime: remove debugCachedWork
debugCachedWork and all of its dependent fields and code were added to
aid in debugging issue #27993. Now that the source of the problem is
known and mitigated (via the extra work check after STW in gcMarkDone),
these extra checks are no longer required and simply make the code more
difficult to follow.

Remove it all.

Updates #27993

Change-Id: I594beedd5ca61733ba9cc9eaad8f80ea92df1a0d
Reviewed-on: https://go-review.googlesource.com/c/go/+/262350
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2020-10-15 15:55:19 +00:00
Obeyda Djeffal
aa161e799d cmd/go: make sure CC and CXX are absolute
Add check in cmd/go/internal/work.BuildInit and
cmd/go/internal/envcmd.checkEnvWrite.

Fixes #38372

Change-Id: I196ea93a0469e4667ef785f7c1dc4574bdf7ff78
Reviewed-on: https://go-review.googlesource.com/c/go/+/228517
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Trust: Michael Matloob <matloob@golang.org>
2020-10-15 15:40:06 +00:00
Jean de Klerk
8cd75f3da0 token: more descriptive panics
Currently, there are several panics in token that simply say "illegal!". This CL
adds the values.

This is valuable when the token call is wrapped under several layers and you
can't easily see which value is being passed to token.

Change-Id: Ib04b55cafcd9b9ec6820dcf416fc4d49afaea15f
Reviewed-on: https://go-review.googlesource.com/c/go/+/262017
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Trust: Jean de Klerk <deklerk@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-10-14 22:35:32 +00:00
Cherry Zhang
e4ec30965b cmd/link: support internal linking on darwin/arm64
Add support of internal linking on darwin/arm64 (macOS).

Still incomplete. Pure Go binaries work. Cgo doesn't. TLS is not
set up when cgo is not used (as before) (so asynchronous
preemption is not enabled).

Internal linking is not enabled by default but can be requested
via -ldflags=-linkmode=internal.

Updates #38485.

Change-Id: I1e0c81b6028edcb1ac26dcdafeb9bb3f788cf732
Reviewed-on: https://go-review.googlesource.com/c/go/+/261643
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-10-14 21:32:26 +00:00
Roland Shoemaker
2ec71e5732 crypto/x509: add signature verification to CreateCertificate
This changes checks the signature generated during CreateCertificate
and returns an error if the verification fails. A benchmark is also
added. For RSA keys the delta looks to be insignificant, but for
ECDSA keys it introduces a much larger delta which is not ideal.

name          old time/op  new time/op   delta
RSA_2048-8    1.38ms ± 6%   1.41ms ± 2%      ~     (p=0.182 n=10)
ECDSA_P256-8  42.6µs ± 4%  116.8µs ± 4%  +174.00%  (p=0.000 n=1

Fixes #40458

Change-Id: I22827795bb9bb6868b4fa47391927db1d3bc19a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/259697
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
Trust: Roland Shoemaker <roland@golang.org>
2020-10-14 20:17:49 +00:00
alandonovan
fbf62beb4e sort: document requirements of Less relation
Fixes #34915

Change-Id: Ia62ff3b6f198ddcd79e8afc7b4f5514a44f2442c
Reviewed-on: https://go-review.googlesource.com/c/go/+/261959
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Akhil Indurti <aindurti@gmail.com>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
2020-10-14 19:35:59 +00:00
Damien Neil
9c56300e62 net/http: return 505 status for rejected protocol version
When rejecting a request with an unsupported HTTP protocol version,
return a 505 error ("HTTP Version Not Supported") instead of 400.

Fixes #40454.

Change-Id: I0269f0f5755d90d1b772ba0094a6bb24b5eb4701
Reviewed-on: https://go-review.googlesource.com/c/go/+/261977
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Urban Ishimwe <urbainishimwe@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-10-14 18:05:16 +00:00
Mohamed Attahri
b95f0b1231 io: add a new ReadSeekCloser interface
Research showed that this interface is defined frequently enough in
real-world usage to justify its addition to the standard library.

Fixes #40962

Change-Id: I522fe8f9b8753c3fa42ccc1def49611cf88cd340
GitHub-Last-Rev: 6a45be66b4
GitHub-Pull-Request: golang/go#41939
Reviewed-on: https://go-review.googlesource.com/c/go/+/261577
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2020-10-14 17:05:21 +00:00
Russ Cox
1671509ea3 cmd: go get golang.org/x/tools@d88ec18 && go mod vendor
This brings in CL 261725, which applies the vet buildtag checker
to ignored files.

For #41184.

Change-Id: I5f241db5a71fa84d0af0b9e9f8a75ff5bb3dd116
Reviewed-on: https://go-review.googlesource.com/c/go/+/261958
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-10-14 15:19:33 +00:00
Russ Cox
52669c4a68 cmd/go: update go list docs for IgnoredOtherFiles
Change-Id: I8eb7f34754c7be899d389fe807af65aa5fd5bbc4
Reviewed-on: https://go-review.googlesource.com/c/go/+/261957
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-10-14 15:19:28 +00:00
ZhangYunHao
a3bc52b786 sync: fix typo in pooldequeue
.

Change-Id: I26fa26d67d01bcd583a1efaaf9a38398cbf793f7
GitHub-Last-Rev: ded020d02c
GitHub-Pull-Request: golang/go#41932
Reviewed-on: https://go-review.googlesource.com/c/go/+/261477
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Austin Clements <austin@google.com>
2020-10-14 13:38:41 +00:00
Tobias Klauser
d83168eb38 lib/time, time, time/tzdata: use slim tz data format
Follow-up for CL 261363 which had to retain the fat tz data format due
to failing test.

The reason for the failed tests was that when caching location data, the
extended time format past the end of zone transitions was not
considered. The respective change was introduced in (*Location).lookup
by CL 215539.

This slims down zoneinfo.zip (and thus also the embedded copy in
time/tzdata) by ~350KB.

Change-Id: I412f79de98ba45358b8696aca784999b3479135e
Reviewed-on: https://go-review.googlesource.com/c/go/+/261877
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-14 09:00:41 +00:00
Tobias Klauser
fc3a6f4533 syscall: remove stray TODO comment
This was addressed by CL 2816 and the same comment was deleted from
asm_linux_386.s.

Change-Id: Icc797993161d67e7c4f4cdb11c2b96ac88e00dd9
Reviewed-on: https://go-review.googlesource.com/c/go/+/261458
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-14 08:05:58 +00:00
Alberto Donizetti
e2931612b0 cmd/compile: rename strlit, Bool, and Int64 *Node accessors
The Node type has shortcuts to access bool and int Values:

  func (n *Node) Int64() int64
    for n.Val().U.(*Mpint).Int64()

  func (n *Node) Bool() bool
    for n.Val().U.(bool)

I was convinced we didn't have one for string literal nodes, until I
noticed that we do, it's just called strlit, it's not a method, and
it's later in the file:

  func strlit(n *Node) string

This change, for consistency:
- Renames strlit to StringVal and makes it a *Node method
- Renames Bool and Int64 to BoolVal and Int64Val
- Moves StringVal near the other two

Change-Id: I18e635384c35eb3a238fd52b1ccd322b1a74d733
Reviewed-on: https://go-review.googlesource.com/c/go/+/261361
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-10-14 08:00:39 +00:00
Martin Möhrmann
7c58ef732e runtime: implement GODEBUG=inittrace=1 support
Setting inittrace=1 causes the runtime to emit a single line to standard error for
each package with init work, summarizing the execution time and memory allocation.

The emitted debug information for init functions can be used to find bottlenecks
or regressions in Go startup performance.

Packages with no init function work (user defined or compiler generated) are omitted.

Tracing plugin inits is not supported as they can execute concurrently. This would
make the implementation of tracing more complex while adding support for a very rare
use case. Plugin inits can be traced separately by testing a main package importing
the plugins package imports explicitly.

$ GODEBUG=inittrace=1 go test
init internal/bytealg @0.008 ms, 0 ms clock, 0 bytes, 0 allocs
init runtime @0.059 ms, 0.026 ms clock, 0 bytes, 0 allocs
init math @0.19 ms, 0.001 ms clock, 0 bytes, 0 allocs
init errors @0.22 ms, 0.004 ms clock, 0 bytes, 0 allocs
init strconv @0.24 ms, 0.002 ms clock, 32 bytes, 2 allocs
init sync @0.28 ms, 0.003 ms clock, 16 bytes, 1 allocs
init unicode @0.44 ms, 0.11 ms clock, 23328 bytes, 24 allocs
...

Inspired by stapelberg@google.com who instrumented doInit
in a prototype to measure init times with GDB.

Fixes #41378

Change-Id: Ic37c6a0cfc95488de9e737f5e346b8dbb39174e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/254659
Trust: Martin Möhrmann <moehrmann@google.com>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-10-14 05:34:32 +00:00
Cherry Zhang
f46a5b1e45 cmd/link: support PIE internal linking on darwin/amd64
This CL adds support of PIE internal linking on darwin/amd64.

This is also preparation for supporting internal linking on
darwin/arm64 (macOS), which requires PIE for everything.

Updates #38485.

Change-Id: I2ed58583dcc102f5e0521982491fc7ba6f2754ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/261642
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-10-14 00:19:23 +00:00
Cherry Zhang
c8eea1633e cmd/internal/obj: remove LSym.RefIdx
LSym.RefIdx was for the old object files. I should have deleted
it when I deleted old object file code.

Change-Id: I8294f43a1e7ba45b1d75e84cc83cbaf2cb32f025
Reviewed-on: https://go-review.googlesource.com/c/go/+/262077
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-10-13 23:38:08 +00:00
Ian Lance Taylor
e43ef8dda2 test: add test that fails with gofrontend
The gofrontend code doesn't correctly handle inlining a function that
refers to a constant with methods.

For #35739

Change-Id: I6bd0b5cd4272dbe9969634b4821e668acacfdcf9
Reviewed-on: https://go-review.googlesource.com/c/go/+/261662
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-10-13 22:50:26 +00:00
Matthew Dempsky
85bb4294c0 cmd/compile: fix and improve alias detection
"aliased" is the function responsible for detecting whether we can
turn "a, b = x, y" into just "a = x; b = y", or we need to pre-compute
y and save it in a temporary variable because it might depend on a.

It currently has two issues:

1. It suboptimally treats assignments to blank as writes to heap
   memory. Users generally won't write "_, b = x, y" directly, but it
   comes up a lot in generated code within the compiler.

   This CL changes it to ignore blank assignments.

2. When deciding whether the assigned variable might be referenced by
   pointers, it mistakenly checks Class() and Name.Addrtaken() on "n"
   (the *value* expression being assigned) rather than "a" (the
   destination expression).

   It doesn't appear to result in correctness issues (i.e.,
   incorrectly reporting no aliasing when there is potential aliasing),
   due to all the (overly conservative) rewrite passes before code
   reaches here. But it generates unnecessary code and could have
   correctness issues if we improve those other passes to be more
   aggressive.

   This CL fixes the misuse of "n" for "a" by renaming the variables
   to "r" and "l", respectively, to make their meaning clearer.

Improving these two cases shaves 4.6kB of text from cmd/go, and 93kB
from k8s.io/kubernetes/cmd/kubelet:

       text	   data	    bss	    dec	    hex	filename
    9732136	 290072	 231552	10253760	 9c75c0	go.before
    9727542	 290072	 231552	10249166	 9c63ce	go.after
    97977637	1007051	 301344	99286032	5eafc10	kubelet.before
    97884549	1007051	 301344	99192944	5e99070	kubelet.after

While here, this CL also collapses "memwrite" and "varwrite" into a
single variable. Logically, they're detecting the same thing: are we
assigning to a memory location that a pointer might alias. There's no
need for two variables.

Updates #6853.
Updates #23017.

Change-Id: I5a307b8e20bcd2196e85c55eb025d3f01e303008
Reviewed-on: https://go-review.googlesource.com/c/go/+/261677
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-10-13 20:44:46 +00:00
Bryan C. Mills
c9211577eb cmd/go/internal/modfetch: remove error return from Lookup
We generally don't care about errors in resolving a repo if the result
we're looking for is already in the module cache. Moreover, we can
avoid some expense in initializing the repo if all of the methods we
plan to call on it hit in the cache — especially when using
GOPROXY=direct.

This also incidentally fixes a possible (but rare) bug in Download:
we had forgotten to reset the downloaded file in case the Zip method
returned an error after writing a nonzero number of bytes.

For #37438

Change-Id: Ib64f10f763f6d1936536b8e1f7d31ed1b463e955
Reviewed-on: https://go-review.googlesource.com/c/go/+/259158
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-10-13 20:13:34 +00:00
Bryan C. Mills
3a65abfbda cmd/go: adjust ImportMissingError when module lookup is disabled
Previously, ImportMissingError said
"cannot find module providing package …"
even when we didn't even attempt to find such a module.

Now, we write "no module requirement provides package …"
when we did not attempt to identify a suitable module,
and suggest either 'go mod tidy' or 'go get -d' as appropriate.

Fixes #41576

Change-Id: I979bb999da4066828c54d99a310ea66bb31032ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/258298
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-10-13 20:13:25 +00:00
Bryan Boreham
076a45acd5 fmt: explain how Formatter interface affects verbs and flags
Formatter is mentioned further down, but it's helpful
to add it amongst the verbs and flags.

Background: I spent a while puzzling how "%+v" prints
a stack trace for github.com/pkg/errors when this isn't
documented under 'flags'.

Change-Id: Ic70145902a36780147dedca568b3cf482974fc38
GitHub-Last-Rev: 6571b499f2
GitHub-Pull-Request: golang/go#39860
Reviewed-on: https://go-review.googlesource.com/c/go/+/240000
Reviewed-by: Rob Pike <r@golang.org>
Trust: Rob Pike <r@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
2020-10-13 19:15:53 +00:00
Martin Möhrmann
e08059f4fc runtime: remove unused alg constants
CL 191198 removed algarray from the runtime
which used these constants as indices.

Change-Id: Ia669cf410372ef5113dadccd115a39ff8d47e5c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/261364
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
Trust: Martin Möhrmann <moehrmann@google.com>
2020-10-13 18:27:28 +00:00
Martin Möhrmann
6b66b59328 internal/cpu: remove unused arm64 capabilities
Change-Id: I038b0fe165931b8ec3ef59f08dc73c8128d56572
Reviewed-on: https://go-review.googlesource.com/c/go/+/261365
Trust: Martin Möhrmann <moehrmann@google.com>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-10-13 18:26:39 +00:00
Tao Qingyun
ad53103aef io: add ErrBadWriteCount
Fixes #39978

Change-Id: Ib41459861ba9f7cf0bf1fc95b1479c358c4bdbd8
GitHub-Last-Rev: 19cbb1461c
GitHub-Pull-Request: golang/go#39989
Reviewed-on: https://go-review.googlesource.com/c/go/+/240740
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-10-13 17:36:36 +00:00
Fazlul Shahriar
58e51b1e62 cmd/go/internal/fsys: skip symlink test on Plan 9
Fixes #41950
Fixes #41954

Change-Id: I95d97f076fa928f3638309b78748d7ccc7277b14
Reviewed-on: https://go-review.googlesource.com/c/go/+/261897
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-10-13 16:27:46 +00:00
Lynn Boger
a15ec3895b cmd/link: update plt size appropriately on ppc64
When attempting to enable internal linking with cgo on ppc64
it was discovered that the plt size was not being updated
after adding entries to it, which resulted in this error:

  .plt: initialize bounds (16 < 24)

This changes fixes that problem.

Updates #21961

Change-Id: Ie17539c329f5a4802e5defd93852dcdde19ded8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/261837
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-10-13 16:26:21 +00:00
Cherry Zhang
575ea5a87a cmd/link: set runtime.text to the address of the first function
In CL 240065 we changed it to set to FlagTextAddr. Normally it
is the address of the first function, except on plan9/amd64
where, as FlagTextAddr is not aligned, it is rounded up. Set it
to the actual text start address.

Fixes #41137.

Change-Id: I1bba67f5eb4e24d9f745a11350fc999ff48bff45
Reviewed-on: https://go-review.googlesource.com/c/go/+/261644
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David du Colombier <0intro@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-10-13 14:50:14 +00:00
Tobias Klauser
5b509d993d lib/time, time/tzdata: update tz data to 2020b
Set ZFLAGS="-b fat" as the default was changed to '-b slim', see
http://mm.icann.org/pipermail/tz-announce/2020-October/000059.html
This will make sure that backwards-compatibibilty data is still emitted.

Updates #22487

Change-Id: I310a1b3a91e435673d1df41fbf8bb76abce1f94d
Reviewed-on: https://go-review.googlesource.com/c/go/+/261363
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-13 08:36:41 +00:00
Tobias Klauser
e69f6e8393 internal/bytealg: fix typo in IndexRabinKarp{,Bytes} godoc
Change-Id: I09ba19e19b195e345a0fe29d542e0d86529b0d31
Reviewed-on: https://go-review.googlesource.com/c/go/+/261359
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-13 06:48:02 +00:00
Russ Cox
c8fdfa756e go/build: reject //go:build without // +build
We are converting from using error-prone ad-hoc syntax // +build lines
to less error-prone, standard boolean syntax //go:build lines.
The timeline is:

Go 1.16: prepare for transition
 - Builds still use // +build for file selection.
 - Source files may not contain //go:build without // +build.
 - Builds fail when a source file contains //go:build lines without // +build lines. <<<

Go 1.17: start transition
 - Builds prefer //go:build for file selection, falling back to // +build
   for files containing only // +build.
 - Source files may contain //go:build without // +build (but they won't build with Go 1.16).
 - Gofmt moves //go:build and // +build lines to proper file locations.
 - Gofmt introduces //go:build lines into files with only // +build lines.
 - Go vet rejects files with mismatched //go:build and // +build lines.

Go 1.18: complete transition
 - Go fix removes // +build lines, leaving behind equivalent // +build lines.

This CL provides part of the <<< marked line above in the Go 1.16 step:
rejecting files containing //go:build but not // +build.

For #41184.

Change-Id: I29b8a789ab1526ab5057f613d5533bd2060ba9cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/240600
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-13 03:12:23 +00:00