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

52421 Commits

Author SHA1 Message Date
Ian Lance Taylor
301fd8ac8b net: send EDNS(0) packet length in DNS query
Advertise to DNS resolvers that we are willing and able to accept up
to 1232 bytes in a DNS packet. The value 1232 was chosen based on
https://dnsflagday.net/2020/.

For #6464
For #21160
For #44135
For #51127
Fixes #51153

Change-Id: If9182d5210bfe047cf0a4d46163effc6812ab677
Reviewed-on: https://go-review.googlesource.com/c/go/+/386016
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-03 00:37:10 +00:00
Keith Randall
d3672054fb cmd/compile: don't include instantiating types in type hash
This CL is a bit overkill, but it is pretty safe for 1.18. We'll
want to revisit for 1.19 so we can avoid the hash collisions between
types, e.g. G[int] and G[float64], that will cause some slowdowns
(but not incorrect behavior). Thanks Cherry for the simple idea.

Fixes #51250

Change-Id: I68130e09ba68e7cc35687bc623f63547bc552867
Reviewed-on: https://go-review.googlesource.com/c/go/+/389474
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-03 00:23:02 +00:00
Carlos Amedee
bcb89fc17a doc: start draft of go1.19 release notes, move go1.18 to x/website
This template is based on CL 342070 and previous ones like it.
Continue to eagerly include often-used sections, and clarify that
the TODO is about completing the section, or removing if it turns
out not to be needed.

Move the Go 1.18 release notes to x/website, since that's the new
home for past Go release notes as of CL 291711. They're added to
x/website in CL 388556.

For #51400
Updates #47694

Change-Id: I7b5213e039ad6e14a7ff7ad486311efcecc06824
Reviewed-on: https://go-review.googlesource.com/c/go/+/388515
Trust: Carlos Amedee <carlos@golang.org>
Run-TryBot: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Alex Rakoczy <alex@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-02 20:53:54 +00:00
Ian Lance Taylor
2cb9e116d3 doc/go1.18: warn about possible breakage of 1.18 generic code
The Go 1 compatibility guarantee permits us to break code if there is
a specification error or a bug. Emphasize that for generics.

Change-Id: I8379a14cdab9f63bb747e961ca12d1adecfc2eb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/388454
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2022-03-02 20:14:06 +00:00
Keith Randall
9eb14f1b0e doc: mention change in append behavior
Introduced in CL 347917.

Change-Id: I99b34341f787e779bd45b967110e70a035fa6558
Reviewed-on: https://go-review.googlesource.com/c/go/+/386217
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <martin@golang.org>
Trust: Martin Möhrmann <martin@golang.org>
Run-TryBot: Martin Möhrmann <martin@golang.org>
2022-03-02 20:12:33 +00:00
Lynn Boger
fc5b64e19b crypto/sha512: add BE support to PPC64 asm implementation
This adds big endian support for the assembly implementation of
sha512. There was a recent request to do this for sha256 for
AIX users; for completeness, the same is being done for sha512.
The majority of the code is common between big and little
endian with a few differences controlled by ifdefs: with LE
the generation of a mask is needed along with VPERM instructions
to put bytes in the correct order; some VPERMs need the V
registers in a different order.

name        old time/op    new time/op     delta
Hash8Bytes    1.02µs ± 0%     0.38µs ± 0%   -62.68%
Hash1K        7.01µs ± 0%     2.43µs ± 0%   -65.42%
Hash8K        50.2µs ± 0%     14.6µs ± 0%   -70.89%

Updates #50785

Change-Id: I739b5e7c07b22b5748af11ca781e82ac67adb4f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/388654
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-02 20:02:12 +00:00
Joe Tsai
986b04c0f1 encoding/binary: add AppendByteOrder
AppendByteOrder specifies new methods for LittleEndian and BigEndian
for appending an unsigned integer to a byte slice.

The performance of AppendXXX methods are slower than PutXXX methods
since the former needs to do a few slice operations,
while the latter is essentially a single integer store.
In practice, existing usages of PutXXX performed slicing operations
around the call such that this cost was present, regardless.

name                           time/op
PutUint16-24                   0.48ns ± 2%
AppendUint16-24                1.54ns ± 1%
PutUint32-24                   0.46ns ± 2%
AppendUint32-24                0.89ns ± 1%
PutUint64-24                   0.46ns ± 2%
AppendUint64-24                0.89ns ± 1%
LittleEndianPutUint16-24       0.47ns ± 2%
LittleEndianAppendUint16-24    1.54ns ± 1%
LittleEndianPutUint32-24       0.45ns ± 3%
LittleEndianAppendUint32-24    0.92ns ± 2%
LittleEndianPutUint64-24       0.46ns ± 3%
LittleEndianAppendUint64-24    0.95ns ± 4%

Fixes #50601

Change-Id: I33d2bbc93a3ce01a9269feac33a2432bc1166ead
Reviewed-on: https://go-review.googlesource.com/c/go/+/386017
Trust: Joseph Tsai <joetsai@digital-static.net>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-02 18:21:38 +00:00
Joe Tsai
a5b8b56d1d reflect: allow Value.Bytes on addressable byte arrays
Modify Value.Bytes to be callable addressable byte arrays.
While related, the behavior of Value.SetBytes was not modified.

Fixes #47066

Change-Id: Ic3ba4432353b8da5f33b3188e20034a33b2f6ee8
Reviewed-on: https://go-review.googlesource.com/c/go/+/357331
Trust: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-02 18:06:42 +00:00
Michael Matloob
ec4687f337 cmd/go: allow users to specify required fields in JSON output
For #29666

Change-Id: Ibae3d75bb2c19571c8d473cb47d6c4b3a880bba8
Reviewed-on: https://go-review.googlesource.com/c/go/+/381035
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-02 18:04:10 +00:00
Tobias Klauser
6c6a8fb702 syscall: remove accept on Linux
accept is no longer used on Linux since CL 346849 changed Accept to use
accept4 only.

For #45964

Change-Id: I72c13df1457016c4785ec13d356ab89cbca644b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/386415
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-02 17:47:07 +00:00
Joe Tsai
5a03cbd12a encoding/json: use reflect.Value.UnsafePointer over Pointer
The latter returns a uintptr, while the former returns a unsafe.Pointer.
A uintptr is unsafe if Go ever switches to a moving GC,
while a unsafe.Pointer will be properly tracked by the GC.

We do not use unsafe.Pointer for any unsafe type conversions,
and only use it for comparability purposes, which is relatively safe.

Updates #40592

Change-Id: I813e218668704b63a3043acda4331205a3835a66
Reviewed-on: https://go-review.googlesource.com/c/go/+/360855
Trust: Joseph Tsai <joetsai@digital-static.net>
Trust: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-02 17:42:53 +00:00
Phil Bracikowski
4a13f6f42d compress/gzip: return unexpected EOF for certain truncated streams
For cases where RFC 1952 requires a field, the code returns the error
io.ErrUnexpectedEOF except in two places: for the FNAME flag or the
FCOMMENT flag. These flags expect a null-terminated string and
readString may return an EOF if the Reader is truncated before a
null byte is found. For consistency with parsing other parts of the
header, this is converted to an unexpected EOF herein.

Follow-up to CL 14832.

Fixes #51417

Change-Id: I173283a6ae309e4a8e52fc15df404ce5db06eff1
GitHub-Last-Rev: 2e573cd961
GitHub-Pull-Request: golang/go#51418
Reviewed-on: https://go-review.googlesource.com/c/go/+/389034
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Trust: Joseph Tsai <joetsai@digital-static.net>
Trust: Ian Lance Taylor <iant@golang.org>
2022-03-02 17:03:04 +00:00
MoZhonghua
f79a983891 cmd/link: don't generate typedef DWARF entry for noalg.struct{...}
cmd/compile uses "noalg.struct {...}" as type name when hash and eq algorithm generation of this struct type is suppressed. This should be treated as normal struct type, that is, link shouldn't generate DW_TAG_typedef DIE for it.

Change-Id: Ifada8a818bcfa2e5615f85ead9582cead923b86c
GitHub-Last-Rev: 15de3e4a84
GitHub-Pull-Request: golang/go#50237
Reviewed-on: https://go-review.googlesource.com/c/go/+/373054
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-02 16:54:21 +00:00
Jinwook Jeong
40e24a942b regexp: fix typo in the overview
Correct the slice expression in the description of Index functions.

Change-Id: I97a1b670c4c7e600d858f6550b647f677ef90b41
Reviewed-on: https://go-review.googlesource.com/c/go/+/360058
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>
2022-03-02 11:49:04 +00:00
Alan Donovan
fd2e1e743a unicode/utf8: optimize Valid to parity with ValidString
The benchmarks added in this change revealed that ValidString
runs ~17% faster than Valid([]byte) on the ASCII prefix
of the input. Inspection of the assembly revealed that the
code generated for p[8:] required recomputing the slice capacity
to handle the cap=0 special case, which added an ADD -8 instruction.
By making len=cap, the capacity becomes a common subexpression
with the length, saving the ADD instruction.
(Thanks to khr for the tip.)

Incidentally, I tried a number of other optimizations but was
unable to make consistent gains across all benchmarks. The most
promising was to retain the bitmask of non-ASCII bytes from the
fast loop; the slow loop would shift it, and when it becomes zero,
return to the fast loop. This made the MostlyASCII benchmark 4x
faster, but made the other cases slower by up to 10%.

cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
benchmark                                   old ns/op     new ns/op     delta
BenchmarkValidTenASCIIChars-16              4.09          4.06          -0.85%
BenchmarkValid100KASCIIChars-16             9325          7747          -16.92%
BenchmarkValidTenJapaneseChars-16           27.0          27.2          +0.85%
BenchmarkValidLongMostlyASCII-16            57277         58361         +1.89%
BenchmarkValidLongJapanese-16               94002         93131         -0.93%
BenchmarkValidStringTenASCIIChars-16        4.15          4.07          -1.74%
BenchmarkValidString100KASCIIChars-16       7980          8019          +0.49%
BenchmarkValidStringTenJapaneseChars-16     26.0          25.9          -0.38%
BenchmarkValidStringLongMostlyASCII-16      58550         58006         -0.93%
BenchmarkValidStringLongJapanese-16         97964         100038        +2.12%

Change-Id: Ic9d585dedd9af83c27dd791ecd805150ac949f15
Reviewed-on: https://go-review.googlesource.com/c/go/+/375594
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Alex Rakoczy <alex@golang.org>
2022-03-02 11:33:18 +00:00
chanxuehong
bebe9aa423 go/token: slight performance improvement for IsIdentifier
If name is empty or a keyword, we can skip the loop entirely.
Otherwise, we do the same amount of work as before.

Here is the benchmark result for go/parser:

name          old time/op    new time/op    delta
Parse-12        2.53ms ± 2%    2.47ms ± 1%  -2.38%  (p=0.000 n=9+10)
ParseOnly-12    1.97ms ± 1%    1.93ms ± 2%  -1.80%  (p=0.000 n=10+10)
Resolve-12       560µs ± 1%     558µs ± 1%    ~     (p=0.200 n=9+8)

name          old speed      new speed      delta
Parse-12      26.1MB/s ± 2%  26.8MB/s ± 1%  +2.44%  (p=0.000 n=9+10)
ParseOnly-12  33.6MB/s ± 1%  34.3MB/s ± 2%  +1.82%  (p=0.000 n=10+10)
Resolve-12     118MB/s ± 2%   119MB/s ± 1%    ~     (p=0.116 n=10+8)

Change-Id: I87ac9c2637a6c0e697382b74245ac88ef523bba7
GitHub-Last-Rev: 036bc38d83
GitHub-Pull-Request: golang/go#48534
Reviewed-on: https://go-review.googlesource.com/c/go/+/351389
Trust: David Chase <drchase@google.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Robert Griesemer <gri@golang.org>
2022-03-02 11:28:40 +00:00
cuiweixie
9f1239b90a math/big: produce valid JSON in Int.MarshalJSON when nil
Fixes #50940.

Change-Id: Ie2a0c4505ca9d7e448017d9d00a020a6b3996be3
GitHub-Last-Rev: afd8c6b559
GitHub-Pull-Request: golang/go#50941
Reviewed-on: https://go-review.googlesource.com/c/go/+/381963
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
2022-03-02 11:27:34 +00:00
Robert Griesemer
6da16b6ad5 go/types, types2: clarify a comment and add an extra test
Confirm that the current implementation of core type unification
looks correct and update the respective comment. Add an extra test.

Fixes #51376.

Change-Id: I6a603a4baeee2ede5bb4a1d60766204a808936d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/388294
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-01 23:49:01 +00:00
Robert Griesemer
0807986fe6 go/types, types2: correctly consider ~ (tilde) in constraint type inference
When doing constraint type inference, we must consider whether the
constraint's core type is precise (no tilde) or imprecise (tilde,
or not a single specific type). In the latter case, we cannot infer
an unknown type argument from the (imprecise) core type because there
are infinitely many possible types. For instance, given

        [E ~byte]

if we don't know E, we cannot infer that E must be byte (it could be
myByte, etc.). On the other hand, if we do know the type argument,
say for S in this example:

        [S ~[]E, E any]

we must consider the underlying type of S when matching against ~[]E
because we have a tilde.

Because constraint type inference may infer type arguments that were
not eligible initially (because they were unknown and the core type
is imprecise), we must iterate the process until nothing changes any-
more. For instance, given

        [S ~[]E, M ~map[string]S, E any]

where we initially only know the type argument for M, we must ignore
S (and E) at first. After one iteration of constraint type inference,
S is known at which point we can infer E as well.

The change is large-ish but the actual functional changes are small:

- There's a new method "unknowns" to determine the number of as of yet
  unknown type arguments.

- The adjCoreType function has been adjusted to also return tilde
  and single-type information. This is now conveniently returned
  as (*term, bool), and the function has been renamed to coreTerm.

- The original constraint type inference loop has been adjusted to
  consider tilde information.

- This adjusted original constraint type inference loop has been
  nested in another loop for iteration, together with some minimal
  logic to control termination.

The remaining changes are modifications to tests:

- There's a substantial new test for this issue.

- Several existing test cases were adjusted to accomodate the
  fact that they inferred incorrect types: tildes have been
  removed throughout. Most of these tests are for pathological
  cases.

- A couple of tests were adjusted where there was a difference
  between the go/types and types2 version.

Fixes #51229.

Change-Id: If0bf5fb70ec22913b5a2da89adbf8a27fbc921d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/387977
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-01 23:48:58 +00:00
Keith Randall
aaa3d39f27 cmd/compile: include all entries in map literal hint size
Currently we only include static entries in the hint for sizing
the map when allocating a map for a map literal. Change that to
include all entries.

This will be an overallocation if the dynamic entries in the map have
equal keys, but equal keys in map literals are rare, and at worst we
waste a bit of space.

Fixes #43020

Change-Id: I232f82f15316bdf4ea6d657d25a0b094b77884ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/383634
Run-TryBot: Keith Randall <khr@golang.org>
Trust: Keith Randall <khr@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-01 23:20:30 +00:00
Matthew Dempsky
d40e7bb174 internal/pkgbits: add version number
Especially once this code gets copied into x/tools, we need a way to
evolve the file format, so add an explicit version number.

Change-Id: I9cc2e357c3ca3f07fd8d0c0ba4e4a95f89edeac6
Reviewed-on: https://go-review.googlesource.com/c/go/+/388914
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2022-03-01 22:02:33 +00:00
Cherry Mui
b0db2f00a0 cmd/compile: use AutogeneratedPos for method value wrapper
We use AutogeneratedPos for most compiler-generated functions. But
for method value wrappers we currently don't. Instead, we use the
Pos for their (direct) declaration if there is one, otherwise
not set it in methodValueWrapper, which will probably cause it to
inherit from the caller, i.e. the Pos of that method value
expression. If that Pos has inline information, it will cause the
method wrapper to have bogus inline information, which could lead
to infinite loop when printing a stack trace.

Change it to use AutogeneratedPos instead.

Fixes #51401.

Change-Id: I398dfe85f9f875e1fd82dc2f489dab63ada6570d
Reviewed-on: https://go-review.googlesource.com/c/go/+/388794
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-03-01 21:27:42 +00:00
Matthew Dempsky
f4722d8449 test: workaround codegen bug in typeparam/mdempsky/13.go
This test case is failing on the noopt builder, because it disables
inlining. Evidently the explicit -gcflags flag in all of our generics
tests was overriding the noopt builder's default mode.

This CL restores a noop -gcflags to get the builder green again until
the issue can be properly fixed.

Updates #51413.

Change-Id: I61d22a007105f756104ba690b73f1d68ce4be281
Reviewed-on: https://go-review.googlesource.com/c/go/+/388894
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-01 20:52:30 +00:00
Matthew Dempsky
d6d2ebb7b8 cmd/compile/internal/ir: remove unused -G=0 node types
ir.PkgName was only used by the old -G=0 frontend for representing
identifiers that refer to a package name. The new types2-based
frontends directly resolve the qualified identifier to the respective
object during IR construction.

Similarly, most of the ir.*Type nodes were only needed for
representing types in the IR prior to type checking. The new
types2-based frontends directly construct the corresponding types.Type
instead.

Exception: The internal typecheck.DeclFunc API used for
compiler-generated functions still depends on ir.FuncType, so that IR
node type is retained for now. (Eventually, we should update
typecheck.DeclFunc and callers to not depend on it, but it's not
urgent.)

Change-Id: I982f1bbd41eef5b42ce0f32676c7dc4a8ab6d0ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/388538
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2022-03-01 19:46:09 +00:00
Matthew Dempsky
0fcb94895f cmd/compile/internal/typecheck: remove unused -G=0 code
The typechecking code for dealing with dot imports and redeclaration
errors can be removed, as these will now always be caught by types2
instead. Even when running the typecheck on internally constructed IR,
we'll never introduce new imports or redeclare identifiers.

Also, Func.Shortname (and typecheck.addmethod) was only used by the
-G=0 frontend. The new types2-based frontends directly associate
methods with their receiver type during IR construction.

Change-Id: I6578a448412141c87a0a53a6566639d9c00eeed7
Reviewed-on: https://go-review.googlesource.com/c/go/+/388537
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2022-03-01 19:46:03 +00:00
Matthew Dempsky
ad52356536 cmd/compile: remove a bunch of dead noder code
This code was only needed for supporting -G=0 mode, which is now gone.

Change-Id: I504887ab179e357a3cd21ef582f9edae49f6cbb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/388536
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2022-03-01 19:45:51 +00:00
Matthew Dempsky
302af4be8e cmd/compile: remove -G flag
Post 1.18, we're committed to types2 as cmd/compile's type checker.

Change-Id: I30d2dd2b2ba62832fcdcaeb996fcbc8a4a05d591
Reviewed-on: https://go-review.googlesource.com/c/go/+/388535
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2022-03-01 19:45:44 +00:00
Matthew Dempsky
e24977d231 all: avoid use of cmd/compile -G flag in tests
The next CL will remove the -G flag, effectively hard-coding it to its
current default (-G=3).

Change-Id: Ib4743b529206928f9f1cca9fdb19989728327831
Reviewed-on: https://go-review.googlesource.com/c/go/+/388534
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-01 19:45:34 +00:00
Matthew Dempsky
258fc75505 cmd/compile/internal/importer: lazier unified IR importing
No need to eagerly read the object dictionary or setup the object
reader outside of the lazy resolve function.

Change-Id: Ic4245b0c09f3beaff97860d7f2dfb5b2b5778cc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/388615
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-03-01 19:33:00 +00:00
Matthew Dempsky
44e92e11c7 cmd/compile: move unified IR's reader2 into importer package
This keeps cmd/compile/internal/importer similar to how
go/internal/gcimporter will work after unified IR support is added in
a subsequent CL.

Change-Id: Id3c000f3a13a54a725602552c6b3191d1affb184
Reviewed-on: https://go-review.googlesource.com/c/go/+/388614
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-03-01 19:32:51 +00:00
Keith Randall
620a3c0596 cmd/compile: use bool->uint8 op instead of copy
Just a cleanup to make sure that generic SSA is properly typed.

Change-Id: Ie75fa972ae4e5fdaca535968769bca36044191c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/372574
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-03-01 18:48:36 +00:00
Keith Randall
510ad4561f runtime: improve work stealing randomness
For certain values of GOMAXPROCS, the current code is less random than
it looks. For example with GOMAXPROCS=12, there are 4 coprimes: 1 5 7 11.
That's bad, as 12 and 4 are not relatively prime. So if pos == 2, then we
always pick 7 as the inc. We want to pick pos and inc independently
at random.

Change-Id: I5c7e4f01f9223cbc2db12a685dc0bced2cf39abf
Reviewed-on: https://go-review.googlesource.com/c/go/+/369976
Run-TryBot: Keith Randall <khr@golang.org>
Trust: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2022-03-01 18:43:08 +00:00
zhouguangyuan
d9fd9201ad cmd/compile: avoid generating unreachable branch for select cases
Fixes #50823

Change-Id: I1c12e875b840eecadefb0d9e044ff2a268ccfbaa
Reviewed-on: https://go-review.googlesource.com/c/go/+/380894
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
2022-03-01 18:13:15 +00:00
Keith Randall
d81464e1eb cmd/compile: don't panic when printing package-less symbols
Some of the SSA pseudo-variables like the memory variable don't
have a package. Print those gracefully instead of printing a panic.

Fixes #51108

Change-Id: I5c29029356e045c5cf70909d6e63666ebc58ffaa
Reviewed-on: https://go-review.googlesource.com/c/go/+/384614
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-01 18:12:19 +00:00
Matthew Dempsky
21998413ad cmd/compile: unified IR support for implicit interfaces
Change-Id: Ibdaa0750f7bc47b513c047fdf4b7145ebba9e870
Reviewed-on: https://go-review.googlesource.com/c/go/+/386001
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
2022-03-01 07:36:46 +00:00
Matthew Dempsky
7c151f3280 internal/pkgbits: extract unified IR coding-level logic
This logic is needed for the go/types unified IR importer, so extract
it into a separate internal package so we can reuse a single copy.

Change-Id: I5f734b76e580fdb69ee39e45ac553c22d01c5909
Reviewed-on: https://go-review.googlesource.com/c/go/+/386000
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
2022-03-01 07:36:05 +00:00
Matthew Dempsky
6d881da9c8 cmd/compile: shuffle and simplify sync markers
Change-Id: I5894ac4697212267380b7a03876927bbf3e1de2b
Reviewed-on: https://go-review.googlesource.com/c/go/+/385999
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-01 07:35:26 +00:00
Matthew Dempsky
4f04e1d99f cmd/compile: remove unified IR quirks mode
Unified IR quirks mode existed to help bootstrap unified IR by forcing
it to produce bit-for-bit identical output to the original gc noder
and typechecker. However, I believe it's far enough along now to stand
on its own, plus we have good test coverage of generics already for
-G=3 mode.

Change-Id: I8bf412c8bb5d720eadeac3fe31f49dc73679da70
Reviewed-on: https://go-review.googlesource.com/c/go/+/385998
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-03-01 06:01:28 +00:00
Carlos Amedee
936c7fbc1c internal/goversion: update Version to 1.19
This is the start of the Go 1.19 development cycle, so update the
Version value accordingly. It represents the Go 1.x version that will
soon open up for development (and eventually become released).

Updates #40705
Updates #51336

Change-Id: Ic4b3f2c04b1fa5c588cb6d62e829f2ed1864e511
Reviewed-on: https://go-review.googlesource.com/c/go/+/388376
Trust: Carlos Amedee <carlos@golang.org>
Run-TryBot: Carlos Amedee <carlos@golang.org>
Trust: Alex Rakoczy <alex@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Alex Rakoczy <alex@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-28 22:24:58 +00:00
Michael Matloob
acc5f55bac cmd/go: make work and work_edit script tests version-independent
The work and work_edit script tests ran go work init, which put the
current Go version into the go.work files. Before this change, the tests
used cmp to compare the outputs with a file that contained a literal
"go 1.18" line. Instead, use cmpenv so we can compare with
"go $goversion". (Some of the test cases still compare against files
that contain "go 1.18" lines, but these tests explicitly set the version
to go 1.18 either in the original go.work files or using go work edit.)

Change-Id: Iea2caa7697b5fe5939070558b1664f70130095ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/388514
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2022-02-28 22:02:43 +00:00
Tobias Klauser
f04d5c118c cmd/internal/obj/riscv/testdata/testbranch: add //go:build lines
Change-Id: I95ea33c0aad7d427da99c0ea7d0869f10ed5dd71
Reviewed-on: https://go-review.googlesource.com/c/go/+/388334
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-02-28 21:56:43 +00:00
cuishuang
9fe3676bc7 all: fix typos
Change-Id: I93ff3d33a5db130dd57a9545456f2961fc3f668b
GitHub-Last-Rev: f95fafc049
GitHub-Pull-Request: golang/go#51394
Reviewed-on: https://go-review.googlesource.com/c/go/+/388314
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2022-02-28 21:52:59 +00:00
Robert Griesemer
f9285818b6 go/types, types2: fix string to type parameter conversions
Converting an untyped constant to a type parameter results
in a non-constant value; but the constant must still be
representable by all specific types of the type parameter.

Adjust the special handling for constant-to-type parameter
conversions to also include string-to-[]byte and []rune
conversions, which are handled separately for conversions
to types that are not type parameters because those are not
constant conversions in non-generic code.

Fixes #51386.

Change-Id: I15e5a0fd281efd15af387280cd3dee320a1ac5e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/388254
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-02-28 21:50:54 +00:00
Dan Scales
eb8198d2f6 cmd/compile: deal with constructed types that have shapes in them
We convert type args to shape types inside instantiations. If an
instantiation constructs a compound type based on that shape type and
uses that as a type arg to another generic function being called, then
we have a type arg with a shape type embedded inside of it. In that
case, we need to substitute out those embedded shape types with their
underlying type.

If we don't do this, we may create extra unneeded shape types that
have these other shape types embedded in them. This may lead to
generating extra shape instantiations, and a mismatch between the
instantiations that we used in generating dictionaries and the
instantations that are actually called.

Updates #51303

Change-Id: Ieef894a5fac176cfd1415f95926086277ad09759
Reviewed-on: https://go-review.googlesource.com/c/go/+/387674
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-28 19:38:22 +00:00
Matthew Dempsky
b33592dcfd spec: the -'s possessive suffix is English, not code
Change-Id: I2debcf926ef116c632c7366646d37de8686b7c9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/388174
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
2022-02-28 19:00:23 +00:00
Cherry Mui
57e3809884 runtime: avoid cgo_unsafe_args for syscall.syscall functions on darwin/arm64
Currently, syscall.syscall-like functions are defined as
cgo_unsafe_args, which makes them ABI0, as it takes the address of
the argument area based on ABI0 layout. Those functions are
linkname'd to the syscall package. When compiling the syscall
package, the compiler doesn't know they are ABI0 therefore
generate an ABIInternal call, which will use the wrapper. As some
of the functions (e.g. syscall6) has many arguments, the wrapper
would take a good amount of stack space. And those functions must
be nosplit. This causes nosplit overflow when building with -N -l
and -race.

Avoid that by rewriting the functions to not use cgo_unsafe_args.
Instead, make a struct locally and pass the address of that
struct. This way the functions are ABIInternal and the call will
not use the wrapper.

Fixes #51247.

Change-Id: I76c1ab86b9d28664fa7d5b9c7928fbb2fd8d1417
Reviewed-on: https://go-review.googlesource.com/c/go/+/386719
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-02-28 17:51:12 +00:00
Dan Scales
06a43e4ab6 cmd/compile: fix case for structural types where we should be looking at typeparams
In getInstantiation, we were not computing tparams correctly for the
case where the receiver of a method was a fully-instantiated type. This
wasn't affecting later parts of the function, since method
instantiations of fully-instantiated types were already being calculated
in an earlier path. But it did give us a non-typeparam when trying to
see if a shape was associated with a type param with a structural type.
The fix is just to get the typeparams associated with the base generic
type. Then we can eliminate a conditional check later in the code.
The tparam parameter of Shapify should always be non-nil

Fixes #51367

Change-Id: I6f95fe603886148b2dad0c581416c51373c85009
Reviewed-on: https://go-review.googlesource.com/c/go/+/388116
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2022-02-28 15:58:07 +00:00
Keith Randall
0907d57abf cmd/compile: emit types of constants which are instantiated generic types
Normally types of constants are emitted when the type is defined (an
ODCLTYPE). However, the types of constants where the type is an
instantiated generic type made inside the constant declaration, do not
normally get emitted. But the DWARF processor in the linker wants
to see those types. So we emit them during stenciling.

Fixes #51245

Change-Id: I59f20f1d7b91501c9ac760cf839a354356331fc6
Reviewed-on: https://go-review.googlesource.com/c/go/+/388117
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-02-28 15:50:51 +00:00
Dmitri Shuralyov
9c4a8620c8 CONTRIBUTORS: update for the Go 1.18 release
This update was created using the updatecontrib command:

	go install golang.org/x/build/cmd/updatecontrib@latest
	cd gotip
	updatecontrib

With manual changes based on publicly available information
to canonicalize letter case and formatting for a few names.

For #12042.

Change-Id: If08b7e798cff6ec4248011bdadcc524b510aaff7
Reviewed-on: https://go-review.googlesource.com/c/go/+/388394
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Trust: Carlos Amedee <carlos@golang.org>
2022-02-28 15:43:07 +00:00
Dan Scales
57dda9795d test: add new test case for 51219 that triggers the types2 issue
The existing test for 51219 didn't actually trigger the types2 issue - I
hadn't been able to minimize the test case yet properly. This new test
case issue51219b.go now does trigger the types2 issue (it's only
slightly different).

Updates #51219

Change-Id: Iaba8144b4702ff4fefec86c899b8acef127b10dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/387814
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-02-28 14:59:04 +00:00