1
0
mirror of https://github.com/golang/go synced 2024-11-24 10:20:01 -07:00
Commit Graph

49450 Commits

Author SHA1 Message Date
Robert Findley
cb9ccd494b go/types: move typeHash to environment.go
This is a pure code move, with no other changes.

Change-Id: Id31f1f960d3208dc614556de89bf39b7ca77df3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/347560
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-09-08 16:31:42 +00:00
Robert Findley
a1a6540bf1 go/types: implement deduplication of instances using the Environment
Implement deduplication of type instances via the Environment by
recording a map of unique IDs for *Named types. This avoids an issue
with the existing type hash, where qualified names alone were not
sufficient to differentiate two *Named types that have the same fully
qualified name but which are distinct pointers. It also allows us to
drop the scope accounting for local types.

A subtle bug is also fixed in subst.go, where the instance t was passed
to typeHash rather than t.orig.

Change-Id: I85639ccc1c9bfee470babd2fc85375484c8ed0b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/344390
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-09-08 16:31:21 +00:00
Bryan C. Mills
409434d623 cmd/go/internal/modload: scan dependencies of root paths when raising version limits in editRequirements
Fixes #47979

Change-Id: I1d9d854cda1378e20c70e6c6789b77e42e467ca7
Reviewed-on: https://go-review.googlesource.com/c/go/+/347290
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-09-08 16:19:36 +00:00
Robert Griesemer
054710ce46 cmd/compile/internal/types2: reduce number of delayed functions (optimization)
Rather than create and delay execution of a closure for each type parameter
in a type parameter list, just create one per type parameter list.

While at it, inline the small amount of code for getting the type constraint
and remove the respective function.

Change-Id: I49a00ff0a7b7e43eb53992dd7dbfac25ff23b42c
Reviewed-on: https://go-review.googlesource.com/c/go/+/348018
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-09-08 15:51:14 +00:00
Robert Griesemer
73a062c3e7 cmd/compile/internal/types2: handle recursive type parameter constraints
Check type constraints after the respective type parameter list
has been associated with a parameterized type so that recursive
type parameter constraints "see" a parameterized type.

Fixes #45550.
Fixes #47796.

Change-Id: Iac74610ca017a78013820624230c857395506aff
Reviewed-on: https://go-review.googlesource.com/c/go/+/348090
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-09-08 15:51:08 +00:00
Dmitri Shuralyov
9581d891ab cmd/pprof: update vendored github.com/google/pprof
Pull in the latest published version of github.com/google/pprof
that is available at this time in the Go 1.18 development cycle.

Done with:

	go get -d github.com/google/pprof@latest
	go mod tidy
	go mod vendor

For #36905.

Change-Id: Ib25aa38365ec70a0bed2a8a6527e5823ab9f9ded
Reviewed-on: https://go-review.googlesource.com/c/go/+/348410
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2021-09-08 15:36:36 +00:00
Michael Munday
8214257347 test/codegen: fix package name for test case
The codegen tests are currently skipped (see #48247). The test
added in CL 346050 did not compile because it was in the main
package but did not contain a main function. Changing the package
to 'codegen' fixes the issue.

Updates #48247.

Change-Id: I0a0eaca8e6a7d7b335606d2c76a204ac0c12e6d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/348392
Trust: Michael Munday <mike.munday@lowrisc.org>
Run-TryBot: Michael Munday <mike.munday@lowrisc.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-08 14:51:40 +00:00
Michael Munday
1da64686f8 test/codegen: fix compilation of bitfield tests
The codegen tests are currently skipped (see #48247) and the
bitfield tests do not actually compile due to a duplicate function
name (sbfiz5) added in CL 267602. Renaming the function fixes the
issue.

Updates #48247.

Change-Id: I626fd5ef13732dc358e73ace9ddcc4cbb6ae5b21
Reviewed-on: https://go-review.googlesource.com/c/go/+/348391
Trust: Michael Munday <mike.munday@lowrisc.org>
Run-TryBot: Michael Munday <mike.munday@lowrisc.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-08 14:51:31 +00:00
Michael Munday
fdc2072420 test/codegen: remove broken riscv64 test
This test is not executed by default (see #48247) and does not
actually pass. It was added in CL 346689. The code generation
changes made in that CL only change how instructions are assembled,
they do not actually affect the output of the compiler. This test
is unfortunately therefore invalid and will never pass.

Updates #48247.

Change-Id: I0c807e4a111336e5a097fe4e3af2805f9932a87f
Reviewed-on: https://go-review.googlesource.com/c/go/+/348390
Trust: Michael Munday <mike.munday@lowrisc.org>
Run-TryBot: Michael Munday <mike.munday@lowrisc.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-08 14:51:22 +00:00
Dmitri Shuralyov
64bdad2011 all: update vendored golang.org/x/tools
Now that issue #48124 is resolved, ran the
following commands inside the cmd module:

	go get -d golang.org/x/tools@36045662144327e4475f9d356f49ab32ce730049  # main branch
	go mod tidy
	go mod vendor

For #36905.
Updates #48124.

Change-Id: I9dc736c2c5256f7d9e80fd9c52c6725ecf0b8001
Reviewed-on: https://go-review.googlesource.com/c/go/+/348409
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
2021-09-08 14:25:12 +00:00
Paul E. Murphy
9295723079 cmd/link: rework .TOC. handling for ppc64le
Setup .TOC. to point to the same place for all objects. Today, the linker
assumes all call relocations can use the local function entry point of
imported object files. This requires a consistent pointer across all
objects.

This intentionally computes the .TOC. pointer in all linking configurations.
In some cases the .TOC. is not used today (e.g linking position-dependent go
only code). It is harmless and simple to compute in all cases, so just
do it for easier maintenance.

Notably, .TOC. is used in some cases when static linking is requested on
ppc64le/linux:

* Position-independent C code using a PC-rel relocation against .TOC.. cgo
  generated C object files are usually compiled PIC even if the go binary
  itself is not.

* Anything which causes PLT stub generation. The stubs always generate
  a .TOC. relative relocation.

* The race detector. Today, this links in an externally compiled archive which
  contains position-independent object files.

Similarly, position-independent linking is always punted to the external
linker on ppc64 today.

Updates #21961
Fixes #15409

Change-Id: Ifd8294b9249e16ba8b92eaf876d15d162f9c61fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/304458
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
2021-09-08 11:57:03 +00:00
Joel Sing
50c69cc3a9 cmd/link/internal/riscv64,cmd/internal/obj/riscv: make error messages consistent
Be consistent with both style/wording and formatting of error messages.

Change-Id: I23013d904333a67a8f17dd364bb5015f54f419c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/345050
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-08 06:59:06 +00:00
Joel Sing
c50d811c7a cmd/interna/obj/riscv: use obj.REG_NONE rather than 0
No functional change, but makes the code consistent and more readable.

Change-Id: I33db681fe0ed501842755f27b6e7843cdc8877cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/345049
Trust: Joel Sing <joel@sing.id.au>
Trust: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
2021-09-08 06:58:13 +00:00
Joel Sing
f030043e37 cmd/internal/obj/riscv: simplify machine code output
Use cursym.WriteInt rather than building up a slice of bytes and then writing them
out via PutUint32. This also allows for variable instruction sizes, which will be
needed when support for compressed (2 byte length) instructions is added.

Change-Id: I17c9ffa52d27c91a24e161317e3db28e224804ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/344460
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-08 06:56:06 +00:00
Joel Sing
da790cccc5 cmd/internal/obj/riscv: absorb rewriteMOV into instruction generation
Replace the now poorly named rewriteMOV function with a markRelocs function,
absorbing the MOV validation into the instruction generation code.

Change-Id: I6ae94553f7f300862c40310343ef0be8f44a4b0f
Reviewed-on: https://go-review.googlesource.com/c/go/+/344459
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-08 06:38:19 +00:00
Joel Sing
f5bdbf311c cmd/internal/obj/riscv: simplify rewriteMOV
Rewrite and simplify the rewriteMOV function in preparation for eliminating it
entirely. Improve some error messages in the process.

Change-Id: Id9a77be5174d46cc23651930c2e9068ee6555690
Reviewed-on: https://go-review.googlesource.com/c/go/+/344458
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-08 05:32:14 +00:00
Keith Randall
bab79dd362 reflect: add back signaling NaN test
I was a little too agressive in CL 258957 (removing 387 support) in
removing a signaling NaN test that should probably still exist.
I should have just removed the 387 skip, not the entire test.

Change-Id: I97ca53f190eb0de00e43b96629b2cae677e7dacb
Reviewed-on: https://go-review.googlesource.com/c/go/+/348209
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-09-08 00:34:17 +00:00
Ian Lance Taylor
963218cc9c reflect: correct typoo in comment
Change-Id: Ic3c69906a8afde63278f173df0427b1c460c9f3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/348189
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-08 00:02:45 +00:00
Dan Scales
3fff213ac2 cmd/compile: add CONVIFACE nodes needed in generic code due to assignments
Added new function earlyTransformAssign() to add needed CONVIFACE nodes
due to assignments in generic functions.

Fixes #48049

Change-Id: I7cd9cee6ecf34ed2ef0743d1b17645b9f520fa00
Reviewed-on: https://go-review.googlesource.com/c/go/+/347914
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-09-07 23:27:08 +00:00
Keith Randall
b606739be6 reflect: add test for passing float32 signaling NaNs
Update #40724

Change-Id: I110cdb7c4a2c5db6b85ca951143430555261abf3
Reviewed-on: https://go-review.googlesource.com/c/go/+/348017
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-09-07 23:10:23 +00:00
Josh Bleecher Snyder
b5e33a50fe reflect: rename MapIter method receiver variable from it to iter
This is easier to use in documentation.
Adjust the existing documentation that worked around the unfortunate name.

Change-Id: Ia4b7793ab94dfd7fb3968ee983be56cc38c30ec3
Reviewed-on: https://go-review.googlesource.com/c/go/+/347769
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-09-07 23:09:28 +00:00
Josh Bleecher Snyder
07f623063d reflect: add MapIter.Reset
This allows callers to do (amortized) allocation-free iteration
over many maps.

Fixes #46293

Change-Id: I3aa6134dd00da35b508bd1e3b487332a871a3673
Reviewed-on: https://go-review.googlesource.com/c/go/+/321891
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-09-07 23:09:06 +00:00
Dan Scales
a9a01a3fbd cmd/compile: remove now-unneeded SetHasTParam() for cached ptr element
We had code in NewPtr() to set the HasTParam/HasShape flag as needed for
the cached ptr element if it wasn't set correctly based on its Elem.
This was causing the race mentioned in the issue.

But that setting code is no longer needed, as long as we call
SetRParams() soon after calling NewIncompleteNamedType(), before
creating/translating the underlying type (which we do). The
HasTParam/HasShape attribute can only come from setting of rparams or a
direct typeparam/shape somewhere in the underlying type, both of which
don't depend on recursion, etc. (as long as the rparams are set early).
Added a check that HasTParam/HasShape are set correctly for the cached
pointer/slice elems in NewPtr() and NewSlice().

Fixes #48191

Change-Id: Ide7d82efb77ae97901e75b2e6c65bd1bfc25e0ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/348089
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-09-07 22:23:36 +00:00
korzhao
dcf3545774 encoding/gob: optimize decoding of slice
In CL 345572, we used the reflect.Value.SetLen method to avoid
extra memory allocation for reflect.Value.Slice.
This also applies to function decodeSlice

name                   old time/op    new time/op    delta
DecodeStringsSlice-12    96.5µs ±12%    63.0µs ± 8%  -34.68%  (p=0.000 n=9+10)

name                   old alloc/op   new alloc/op   delta
DecodeStringsSlice-12    89.3kB ± 0%    65.3kB ± 0%  -26.89%  (p=0.000 n=10+10)

name                   old allocs/op  new allocs/op  delta
DecodeStringsSlice-12     3.18k ± 0%     2.18k ± 0%  -31.47%  (p=0.000 n=10+10)

Change-Id: Ifdb43716cc90a265962dec022704a5571f447fd8
Reviewed-on: https://go-review.googlesource.com/c/go/+/347533
Reviewed-by: Joe Tsai <joetsai@digital-static.net>
Reviewed-by: Rob Pike <r@golang.org>
Trust: Joe Tsai <joetsai@digital-static.net>
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-07 21:39:06 +00:00
Dan Scales
80783558b0 cmd/compile: make sure imported instantiated types have their methods created
We should be putting a newly instantiated imported type in
Instantiate/doInst onto the instTypeList, so its methods/dictionaries
are instantiated. To do this, we needed a more general way to add a
type to instTypeList, so add NeedInstType(), analogous to
NeedRuntimeType(). This has the extra advantage that now all types
created by the type substituter are added to instTypeList without any
extra code, which was easy to forget. doInst() now correctly calls
NeedInstType().

This is a bit aggressive, since a fully instantiated type in a generic
function/method may never be used, if the generic method is never
instantiated in the local package. But it should be fairly uncommon for
a generic method to mention a fully instantiated type (but it does
happen in this bug).

Fixes both cases mentioned in the bug.

Fixed #48185

Change-Id: I19b5012dfac17e306c8005f8595a648b0ab280d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/347909
Trust: Dan Scales <danscales@google.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-09-07 20:37:05 +00:00
Ruslan Andreev
23f4f0db68 cmd/compile: add prefetch intrinsic support
This CL provide new intrinsics to emit prefetch instructions for AMD64
and ARM64 platforms:
Prefetch - prefetches data from memory address to cache;
PrefetchStreamed - prefetches data from memory address, with a hint
that this data is being streamed.

This patch also provides prefetch calls pointed by RSC inside scanobject
and greyobject of GC mark logic.

Performance results provided by Michael:
https://perf.golang.org/search?q=upload:20210901.9

Benchmark parameters:
tree2 -heapsize=1000000000 -cpus=8
tree -n=18
parser
peano

Benchmarks AMD64 (Xeon - Cascade Lake):
name        old time/op  new time/op  delta
Tree2-8     36.1ms ± 6%  33.4ms ± 5%  -7.65%  (p=0.000 n=9+9)
Tree-8       326ms ± 1%   324ms ± 1%  -0.44%  (p=0.006 n=9+10)
Parser-8     2.75s ± 1%   2.71s ± 1%  -1.47%  (p=0.008 n=5+5)
Peano-8     63.1ms ± 1%  63.0ms ± 1%    ~     (p=0.730 n=9+9)
[Geo mean]   213ms        207ms       -2.45%

Benchmarks ARM64 (Kunpeng 920):
name        old time/op  new time/op  delta
Tree2-8     50.3ms ± 8%  44.1ms ± 5%  -12.24%  (p=0.000 n=10+9)
Tree-8       494ms ± 1%   493ms ± 1%     ~     (p=0.684 n=10+10)
Parser-8     3.99s ± 1%   3.93s ± 1%   -1.37%  (p=0.016 n=5+5)
Peano-8     84.4ms ± 0%  84.1ms ± 1%     ~     (p=0.068 n=8+10)
[Geo mean]   302ms        291ms        -3.67%

Change-Id: I43e10bc2f9512dc49d7631dd8843a79036fa43d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/328289
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-07 20:27:30 +00:00
zikaeroh
d92101f452 cmd/compile: resolve TODO in inl.go
If the condition is a bool constant, there's no need to walk both
branches.

Passes toolstash -cmp.

Change-Id: I4ee5e3553ce07c2213efba0d33d869b4a1b57783
Reviewed-on: https://go-review.googlesource.com/c/go/+/347911
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-07 19:39:04 +00:00
korzhao
903958d2f5 encoding/gob: marshal maps using reflect.Value.MapRange
golang.org/cl/33572 added a map iterator.

use the reflect.Value.MapRange to fix map keys that contain a NaN

Fixes #24075

Change-Id: I0214d6f26c2041797703e48eac16404f189d6982
GitHub-Last-Rev: 5c01e117f4
GitHub-Pull-Request: golang/go#47476
Reviewed-on: https://go-review.googlesource.com/c/go/+/338609
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2021-09-07 19:14:23 +00:00
Dan Scales
6640171914 cmd/compile: fix type substituter to copy Funarg value for structs
We were missing copying the Funarg value when substituting for a struct
type.

Change-Id: Id0c2d9e55fb15987acb9edba6f74cf57cfd3417e
Reviewed-on: https://go-review.googlesource.com/c/go/+/347913
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
2021-09-07 18:37:34 +00:00
Matthew Dempsky
e581ec07ee cmd/compile: fix lazy loading in reader2
Calling reader2.obj fully loads the referenced object, which is
necessary in general; but for reading the package index, we just need
to setup the name->index mapping. This CL adds this, so that lazy
loading works as intended.

Change-Id: Ie51d59e2247d99b46f9dc69fba7ce89e2584b7c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/348011
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-09-07 18:36:13 +00:00
Cuong Manh Le
81188661f1 go/types: do not format TParams when hashing
This is a port of CL 347534 to go/types.

Change-Id: I2b15a29992c430e34592d110be16d7b2b10521a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/348029
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-07 17:50:42 +00:00
Cuong Manh Le
2a4845257f cmd/compile: fix deadlock in (*Named).load
For lazy import resolution, there's reentrancy issue with (*Named).load
method, when "t.resolve(t)" can lead us to the same named type, thus
(*Named).load is called recursively, causing the deadlock.

The main problem is that when instantinate a type, we calculate the type
hashing, including TParams. Calling t.TParams().Len() triggers the
reentrancy call to "(*Named).load".

To fix this, just not checking TParams().Len() if we are hashing.

Updates #48185

Change-Id: Ie34842d7b10fad5d11fbcf75bb1c64a89deac6b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/347534
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-07 17:38:14 +00:00
Vyacheslav Pachkov
bca8c6ffa2 cmd/link: resolve magic value in gdbscript section generation
According to the .debug_gdb_scripts section specification
[https://sourceware.org/gdb/onlinedocs/gdb/dotdebug_005fgdb_005fscripts-section.html],
each entry begins with a non-null prefix byte that specifies the kind of entry.
This commit resolves a question about magic byte and replaces a
hardcoded value with a meaningful constant "GdbScriptPythonFileId"
inside writegdbscript function.

Change-Id: I456c742bcb539a5853b9e2a6811033f35c37e7d4
GitHub-Last-Rev: 2f1c4cb9ee
GitHub-Pull-Request: golang/go#47646
Reviewed-on: https://go-review.googlesource.com/c/go/+/341391
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-09-07 16:20:11 +00:00
wdvxdr
21de6bc463 cmd/compile: simplify less with non-negative number and constant 0 or 1
The most common cases:
len(s) > 0
len(s) < 1

and they can be simplified to:
len(s) != 0
len(s) == 0

Fixes #48054

Change-Id: I16e5b0cffcfab62a4acc2a09977a6cd3543dd000
Reviewed-on: https://go-review.googlesource.com/c/go/+/346050
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-07 14:53:41 +00:00
korzhao
6226020c2f cmd/compile: make sure that the names created for instantiated type are the same
Now we have two functions that create names for instantiated types.
They are inconsistent when dealing with byte/rune type.

This CL makes instTypeName2 reuse the code of typecheck.InstTypeName

Fixes #48198

Change-Id: I4c216b532cba6618ef9b63fd0b76e8f1c0ed7a75
Reviewed-on: https://go-review.googlesource.com/c/go/+/347491
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-07 03:56:13 +00:00
Tobias Klauser
a1938435d6 syscall: use dup3 in forkAndExecInChild1 on all Linux platforms
The minimum required Linux kernel version for Go 1.18 will be changed to
2.6.32, see #45964. The dup3 syscall was added in 2.6.27, so the
fallback to use the dup2 syscall in forkAndExecInChild1 on some
platforms can be removed.

For #45964

Change-Id: I8e04d7b5b2488990a061a080ed64ea303ad048b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/347350
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-06 19:10:15 +00:00
WANG Xuerui
20a71c9a1d cmd/internal/sys: fix placement of loong64 definition
In rebasing the patch series up to CL 339015, the branches were messed
up by me, and changes from v3 to v4 of CL 339009 was lost. Fix the
ordering to restore alphabetical order per original review.

Change-Id: I8e57c96e996c4f962cab684a9d305a8dbdeea43b
Reviewed-on: https://go-review.googlesource.com/c/go/+/347731
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Meng Zhuo <mzh@golangcn.org>
2021-09-06 17:00:36 +00:00
korzhao
ecfff58fb8 cmd/compile: fix delay transformation in *subster.node()
Add OCALL, OCALLFUNC, OCALLMETH, OCALLINTER, ODYNAMICDOTTYPE transformations to the CALL check switch statement.

Fixes #48042

Change-Id: Ied93efd979c5b2c56b72fad26fccfd9f887361d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/345949
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
2021-09-06 14:02:24 +00:00
WANG Xuerui
c7f09eeb13 cmd/internal/sys: declare loong64 arch
Updates #46229

Change-Id: Icb736f2440443e9245872b091d13e5bdfb6cb01a
Reviewed-on: https://go-review.googlesource.com/c/go/+/339009
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Meng Zhuo <mzh@golangcn.org>
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-06 06:52:46 +00:00
fanzha02
7b69ddc171 cmd/compile: merge sign extension and shift into SBFIZ
This patch adds some rules to rewrite "(LeftShift (SignExtend x) lc)"
expression as "SBFIZ".

Add the test cases.

Change-Id: I294c4ba09712eeb02c7a952447bb006780f1e60d
Reviewed-on: https://go-review.googlesource.com/c/go/+/267602
Trust: fannie zhang <Fannie.Zhang@arm.com>
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: fannie zhang <Fannie.Zhang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-09-06 03:31:53 +00:00
fanzha02
43b05173a2 cmd/compile: merge zero/sign extensions with UBFX/SBFX on arm64
The UBFX and SBFX already zero/sign extend the result. Further
zero/sign extensions are thus unnecessary as long as they leave
the top bits unaltered. This patch absorbs zero/sign extensions
into UBFX/SBFX.

Add the related test cases.

Change-Id: I7c4516c8b52d677f77bf3aaedab87c4a28056ec0
Reviewed-on: https://go-review.googlesource.com/c/go/+/265039
Trust: fannie zhang <Fannie.Zhang@arm.com>
Trust: Keith Randall <khr@golang.org>
Run-TryBot: fannie zhang <Fannie.Zhang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-06 03:31:43 +00:00
Josh Bleecher Snyder
7619a4528d reflect: improve panic when MapIter has no associated map Value
it := new(reflect.MapIter)
it.Next()

This generates a nil pointer dereference panic from reflect.Value.pointer.
Generate a clearer panic.

For #46293

Change-Id: I32a22c797e1ba3a7b4e70b38ceb4dedb44d264fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/321890
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-09-05 23:10:46 +00:00
Josh Bleecher Snyder
1b2d794ca3 reflect: allocate hiter as part of MapIter
This reduces the number of allocations per
reflect map iteration from two to one.

For #46293

Change-Id: Ibcff5f42fc512e637b6e460bad4518e7ac83d4c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/321889
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-09-05 23:09:32 +00:00
Robert Griesemer
9133245be7 cmd/compile/internal/types2: detect constraint type inference cycles
See the detailed explanations in the code.

Fixes #48136.

Change-Id: I1667aabfbbff97967913b080c77e7ec04ea82feb
Reviewed-on: https://go-review.googlesource.com/c/go/+/347300
Trust: Robert Griesemer <gri@golang.org>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-09-04 20:35:25 +00:00
Joel Sing
28dae3defb cmd/internal/obj/riscv: improve code generation for loading of constants
Loading of constants that are 12 bits or smaller is currently performed using a single
ADDIW instruction, while constants between 13 bits and 32 bits are loaded using a
LUI+ADDIW pair.

Instead, use a single ADDI instruction for the 12 bits or smaller case - this
translates to the LI pseudo-instruction, making objdump more readable and giving:

   11c7c:       fff00293                li      t0,-1
   11c80:       00000313                li      t1,0

Rather than:

   11c7c:       fff0029b                addiw   t0,zero,-1
   11c80:       0000031b                sext.w  t1,zero

In the case where a constant exceeds 12 bits, an LUI instruction is required,
however if the lower 12 bits are zero, the ADDIW instruction can be omitted.
The same applies to the case where immediate splitting is performed for other
immediate instructions.

This removes around 900 instructions from the Go binary.

Change-Id: Id6c77774b3b429fa525da018a6926b85df838a2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/344457
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-04 19:33:54 +00:00
Joel Sing
37e9c1d6fe cmd/internal/obj/riscv: avoid obj.Prog rewriting for address to register loads
Rather than rewriting the obj.Prog for a MOV pseudo-instruction targeting
an address to register load, generate the appropriate machine instruction
sequence directly.

Change-Id: I507195b6d24ff3253eadcc807ddbe27dca97d220
Reviewed-on: https://go-review.googlesource.com/c/go/+/344456
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-04 19:33:36 +00:00
Joel Sing
2d90df91a8 cmd/internal/obj/riscv: avoid obj.Prog rewriting for immediate splitting
Rather than rewriting the obj.Prog for a immediate instructions that need
splitting, generate the appropriate machine instruction sequence directly.

Change-Id: Ie90f0e2a98f97a29281e445c4c3b0c47b793ef4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/344453
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-04 19:33:01 +00:00
korzhao
5c224ec921 database/sql: improve the documentation of Conn.Raw
Fixes #47500

Change-Id: Ibd44e4db15ea45bb53a6651a6567edfe6104d3d6
GitHub-Last-Rev: 61b8abbc28
GitHub-Pull-Request: golang/go#47503
Reviewed-on: https://go-review.googlesource.com/c/go/+/338970
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Trust: Cherry Mui <cherryyz@google.com>
2021-09-04 15:01:53 +00:00
Joel Sing
ba66d62b68 cmd/internal/obj/riscv: avoid obj.Prog rewriting for memory stores
Rather than rewriting the obj.Prog for a MOV pseudo-instruction targeting
a register to memory stores, generate the appropriate machine instruction
sequence directly.

Change-Id: I6eac8637e1fcb48c04d9f331cac7ae5d8cc54092
Reviewed-on: https://go-review.googlesource.com/c/go/+/344455
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-04 10:59:00 +00:00
Joel Sing
5ec298d7b0 cmd/internal/obj/riscv: avoid obj.Prog rewriting for memory loads
Rather than rewriting the obj.Prog for a MOV pseudo-instruction targeting
a memory to register load, generate the appropriate machine instruction
sequence directly.

Change-Id: I4c7292ba00f576ec71d4842b6ff27a8ce6db0650
Reviewed-on: https://go-review.googlesource.com/c/go/+/344454
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-04 10:58:11 +00:00