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

51567 Commits

Author SHA1 Message Date
fanzha02
5fd0ed7aaf cmd/compile: set conversions to unsafe.Pointer as an escaping operation when -asan is enabled
When ASan is enabled, treat conversions to unsafe.Pointer as
an escaping operation. In this way, all pointer operations on
the stack objects will become operations on the escaped heap
objects. As we've already supported ASan detection of error
memory accesses to heap objects. With this trick, we can use
-asan option to report errors on bad stack operations.

Add test cases.

Updates #44853.

CustomizedGitHooks: yes
Change-Id: I4e7fe46a3ce01f0d219e6a67dc50f4aff7d2ad87
Reviewed-on: https://go-review.googlesource.com/c/go/+/325629
Trust: Fannie Zhang <Fannie.Zhang@arm.com>
Reviewed-by: Keith Randall <khr@golang.org>
2022-03-16 07:03:20 +00:00
Meng Zhuo
d34287a4f6 cmd/link: default generic ABI compression for ELF
This CL change all debug dwarf headers to generic ABI
"Compression header" for ELF
(http://www.sco.com/developers/gabi/latest/ch4.sheader.html#compression_header)

Fixes #50796

Change-Id: I188625e596f11cd120dbd802ac2d79341d5eaf41
Reviewed-on: https://go-review.googlesource.com/c/go/+/380755
Trust: mzh <mzh@golangcn.org>
Run-TryBot: mzh <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-03-16 05:32:52 +00:00
Matthew Dempsky
6e49c592de go/types: return Universe for (*Package)(nil).Scope()
Port of go.dev/cl/325469.

Fixes #46594.

Change-Id: I4bcdafecaa86885360599c204678871646bb221b
Reviewed-on: https://go-review.googlesource.com/c/go/+/385997
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-03-16 00:34:27 +00:00
Matthew Dempsky
1cb34fbb26 go/types, cmd/compile: remove unused Interface.obj field
Change-Id: I6d0f629f9c7379074a03c8f13b99924d872872a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/385996
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-03-16 00:34:15 +00:00
Russ Cox
0d71234ee4 reflect: avoid panic in reflect.Kind.String for negative Kind
Kind(-1).String() used to panic; let's not.

Change-Id: I1dfc0e3298beb37d77713d8327579bbde90dd156
Reviewed-on: https://go-review.googlesource.com/c/go/+/393015
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-15 20:06:05 +00:00
Cherry Mui
db3045b4be cmd/asm: support -d=pctab flag
To debug PC data generation.

Change-Id: Id7ac8d607cc27ad52db490bd758c3a768c3e1df2
Reviewed-on: https://go-review.googlesource.com/c/go/+/388015
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-15 18:37:49 +00:00
Bryan Mills
b4428325e2 Revert "os: raise open file rlimit at startup"
This reverts CL 392415.

Reason for revert: new test is failing on at least darwin-amd64-10_14, darwin-amd64-10_15, and openbsd-arm64-jsing.

Updates #46279.

Change-Id: I2890b72f8ee74f31000d65f7d47b5bb0ed5d6007
Reviewed-on: https://go-review.googlesource.com/c/go/+/393016
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2022-03-15 18:09:24 +00:00
Ian Lance Taylor
201a2e9c2f compress/gzip: add example of compressing reader
For #51092

Change-Id: If0a233651ac75f113569ddfffd056084f6092564
Reviewed-on: https://go-review.googlesource.com/c/go/+/389514
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-15 17:59:01 +00:00
Ian Lance Taylor
4e26ab0ed8 cmd/go: document that 'go run' strips debug info
Change-Id: Ie7293a33862853ac56ee0a9017b201d8ff0ba1f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/392574
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-03-15 17:29:54 +00:00
Russ Cox
1178255f85 all: untab /* */ doc comments
A long time ago, gofmt insisted on inserting tabs in /* */ comments
at the top level of the file, like this:

	/*
		Package doc comment.
	*/
	package p

Gofmt still insists on the tab for comments not at top level,
but it has relaxed the rules about top-level comments.
A few very old doc comments are indented, left over from the old rule.

We are considering formatting doc comments, and so to make
everything consistent, standardize on unindented doc comments
by removing tabs in the few doc comments that are still indented this way.

Also update some cmd/gofmt testdata to match.

Change-Id: I293742e39b52f8a48ec41f72ca4acdafa7ce43bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/384261
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-15 17:17:30 +00:00
Keith Randall
9b112cec83 internal/cpu: don't run SSE3 disable test if GOAMD64>1
That feature can't be disabled if the microarchitectural version
requires it.

Change-Id: Iad8aaa8089d2f023e9ae5044c6da33224499f09b
Reviewed-on: https://go-review.googlesource.com/c/go/+/392994
Run-TryBot: Keith Randall <khr@golang.org>
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Martin Möhrmann <martin@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-15 17:04:57 +00:00
Russ Cox
b054c7dc17 os: raise open file rlimit at startup
Some systems set an artificially low soft limit on open file count,
for compatibility with code that uses select and its hard-coded
maximum file descriptor (limited by the size of fd_set).

Go does not use select, so it should not be subject to these limits.
On some systems the limit is 256, which is very easy to run into, even
in simple programs like gofmt when they parallelize walking a file tree.

After a long discussion on go.dev/issue/46279, we decided the best
approach was for Go to raise the limit unconditionally for itself, and
then leave old software to set the limit back as needed. Code that
really wants Go to leave the limit alone can set the hard limit, which
Go of course has no choice but to respect.

Fixes #46279.

Change-Id: Id6107503437d47a870a41be25e822fc79cea08b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/392415
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-15 15:21:54 +00:00
Archana R
7b15e297a2 cmd/compile: fix PrefetchStreamed builtin implementation on PPC64
This CL fixes encoding of PrefetchStreamed on PPC64 to be consistent
with what is implemented on AMD64 and ARM64 platforms which is
prefetchNTA (prefetch non-temporal access). Looking at the definition
of prefetchNTA, the closest corresponding Touch hint (TH) value to be
used on PPC64 is 16 that states that the address is accessed in a
transient manner. Current usage of TH=8 may cause degraded
performance.

Change-Id: I393bf5a9b971a22f632b3cbfb4fa659062af9a27
Reviewed-on: https://go-review.googlesource.com/c/go/+/390316
Reviewed-by: Paul Murphy <murp@ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-15 15:12:55 +00:00
Ian Lance Taylor
e475cf2e70 syscall: add race annotations to Windows ReadFile and WriteFile
For #51618
Fixes #51673

Change-Id: Ie63408d62303293d80afed8d5cf1cb164a8abecc
Reviewed-on: https://go-review.googlesource.com/c/go/+/392774
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-15 02:22:54 +00:00
fanzha02
49f16625c8 cmd/internal/obj/arm64: add TRN1 and TRN2 instructions support
Add test cases.

Fixes #51628

Change-Id: I433367d87e6bb5da5579c4be540079b92701c1fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/392294
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Fannie Zhang <Fannie.Zhang@arm.com>
2022-03-15 01:25:23 +00:00
eric fang
44a0da4ff1 cmd/internal/obj/arm64: refactor the handling of shifted RSP
Some arithmetic operation instructions such as ADD and SUB support two
formats of left shift (<<) operation, namely shifted register format and
extended register format. And the encoding, supported registers and shifted
amount are both different.

The assembly parser doesn't distinguish them and parses them into TYPE_SHIFT
type, because the parser can't tell them apart and in most cases extended
left-shift can be replaced by shifted left-shift. The only exception is
when the second source register or the destination register is RSP.

This CL converts this case into the extended format in the preprocess stage,
which helps to simplify some of the logic of the new assembler implementation
and also makes this situation look more reasonable.

Change-Id: I2cd7d2d663b38a7ba77a9fef1092708b8cb9bc3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/311709
Trust: Eric Fang <eric.fang@arm.com>
Run-TryBot: Eric Fang <eric.fang@arm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-03-15 01:00:36 +00:00
Rob Pike
41a82aa9c3 text/template/parse: allow space after continue or break
Trivial fix: We must skip space after either of these keywords
before we expect a closing delimiter.

Also delete the stutter-generating extra 'in' in the error message.
(See what I did there?)

Fixes #51670

Change-Id: If5415632c36eaac6699bdc0aa6ce18be956c9b53
Reviewed-on: https://go-review.googlesource.com/c/go/+/392615
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-15 00:19:35 +00:00
Keith Randall
15728ce950 cmd/compile: disable rewrite loop detector for deadcode-only changes
We're guaranteed we won't infinite loop on deadcode-only changes,
because each change converts valid -> invalid, and there are only a
finite number of valid values.

The loops this test is looking for are those generated by rule
applications, so it isn't useful to check for loops when rules aren't
involved.

Fixes #51639

Change-Id: Idf1abeab9d47baafddc3a1197d5064faaf07ef78
Reviewed-on: https://go-review.googlesource.com/c/go/+/392760
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
2022-03-15 00:05:18 +00:00
Russ Cox
b7041c7ad1 cmd/api: require proposal # for new API features
Having the proposal numbers recorded in the API files
should help significantly when it comes time to audit
the new API additions at the end of each release cycle.

Change-Id: Id18e8cbdf892228a10ac17e4e21c7e17de5d4ff7
Reviewed-on: https://go-review.googlesource.com/c/go/+/392414
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-14 21:43:16 +00:00
Keith Randall
5ccd8e5133 internal/cpu: disallow disabling options that are required for microarch
e.g., if GOAMD64=v3, don't allow GODEBUG=cpu.XXX=off for XXX which
are required for v3.

Change-Id: Ib58a4c8b13c5464ba476448ba44bbb261218787c
Reviewed-on: https://go-review.googlesource.com/c/go/+/391694
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>
2022-03-14 21:23:36 +00:00
Robert Griesemer
41fe746857 go/types, types2: use correct underlying type in union set computation
Fixes #51658.

Change-Id: Ibf415d7e12849b8f50b58d74713613d4e65bc347
Reviewed-on: https://go-review.googlesource.com/c/go/+/392575
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-03-14 18:03:37 +00:00
Cuong Manh Le
8419ec295c cmd/compile: fix wrong dict param when getting dict type
CL 338129 added getDictionaryType to get the dictionary type from the
specified dict param, but still using the one in info.dictParam, which
is wrong.

Fixes #51413

Change-Id: Ie13460c1e5751c4c5fc44479a44f6eed8b3b06e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/391994
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2022-03-14 17:55:47 +00:00
Bryan C. Mills
676858f3d4 cmd/go: use testGOROOT in TestListTemplateContextFunction
This test uses testgo to run 'go list', so it should use the correct
GOROOT for testgo. (This may be particularly relevant when the test
binary itself is build with -trimpath, in which case runtime.GOROOT()
is not valid.)

Updates #51483

Change-Id: I79b310f88e3a200122d6289073df1385e3e97cca
Reviewed-on: https://go-review.googlesource.com/c/go/+/391801
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
2022-03-14 17:51:51 +00:00
Bryan C. Mills
d99ff03821 go/build: set PWD for go subcommands
Since these commands already include an explicit Env field,
they will not be fixed automatically by proposal #50599.

Change-Id: Ia8157a71cf0cfe208bdc0da9aef54be3d26c795f
Reviewed-on: https://go-review.googlesource.com/c/go/+/391804
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
2022-03-14 16:40:05 +00:00
Bryan C. Mills
471d319fb2 debug/buildinfo: use testenv.GoToolPath in tests instead of resolving "go" from $PATH
Updates #37475.

Change-Id: I8c3237438da3e9521ce3be26a0b5d5ca36944b17
Reviewed-on: https://go-review.googlesource.com/c/go/+/391803
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
2022-03-14 16:33:16 +00:00
Cuong Manh Le
7900576bac cmd/compile: remove unified IR stmtTypeDeclHack
After CL 385998, unified IR quirks mode was gone, it's time to remove
stmtTypeDeclHack, too.

Change-Id: Id73dd1d6c11b91c0c6c6cbe85f1b06977a9876d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/392214
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-03-14 11:03:14 +00:00
Uzondu Enudeme
ab0f7611d7 net/url: add OmitHost bool to url.URL
Previously, myscheme:/path and myscheme:///path were treated as the same URL
although materially different. The distinction made clear by RFC 3986 sec. 5.3 where
a different recomposition behavior is expected when a URI reference has an undefined
host(authority) as in myscheme:/path vs. one with an empty host(authority)
as in myscheme:///path.

This change fixes the Parse/String roundtrip limitation for URLs with an undefined
host and a single slash.

Fixes #46059

Change-Id: I1b8d6042135513616374ff8c8dfb1cdb640f8efe
Reviewed-on: https://go-review.googlesource.com/c/go/+/391294
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-14 09:19:01 +00:00
Tobias Klauser
3c2e73c8c3 runtime/pprof: use syscall.RUSAGE_SELF
Change-Id: Idc37429de5a48e708eda868ca7fa26b28620bac0
Reviewed-on: https://go-review.googlesource.com/c/go/+/391854
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-13 21:31:06 +00:00
Ian Lance Taylor
842d37ee5f syscall: add race annotations to Pread and Pwrite
Fixes #51618

Change-Id: Ife894d8c313dce8c4929f40fa0ac90a069f77a89
Reviewed-on: https://go-review.googlesource.com/c/go/+/391954
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2022-03-12 23:32:36 +00:00
eh-steve
baf61e4a67 encoding/hex: implement Decode with a lookup table
Implement hex decode using a 256 byte lookup table instead of branching logic.

In happy flow, uses 3x 64 byte (or 5x 32 byte) cache lines.

	name             old time/op    new time/op    delta
	Decode/256-64       223ns ± 3%     135ns ± 2%  -39.64%  (p=0.000 n=8+8)
	Decode/1024-64      872ns ± 2%     512ns ± 2%  -41.25%  (p=0.000 n=8+8)
	Decode/4096-64     3.43µs ± 1%    2.01µs ± 2%  -41.31%  (p=0.001 n=7+7)
	Decode/16384-64    13.9µs ± 1%     8.0µs ± 1%  -42.69%  (p=0.000 n=8+7)

	name             old speed      new speed      delta
	Decode/256-64    1.15GB/s ± 3%  1.90GB/s ± 2%  +65.66%  (p=0.000 n=8+8)
	Decode/1024-64   1.17GB/s ± 2%  2.00GB/s ± 2%  +70.22%  (p=0.000 n=8+8)
	Decode/4096-64   1.20GB/s ± 1%  2.04GB/s ± 2%  +70.39%  (p=0.001 n=7+7)
	Decode/16384-64  1.18GB/s ± 1%  2.06GB/s ± 1%  +74.49%  (p=0.000 n=8+7)

Also reduces amd64 object size by 766 bytes, despite the extra RODATA due to removal of `fromHexChar()` and duplicated inlined versions of it and simplification of `Decode()`.

Change-Id: I0988c7a30562ec154eff11db6e27954e0ce2b611
GitHub-Last-Rev: 64818018af
GitHub-Pull-Request: golang/go#51432
Reviewed-on: https://go-review.googlesource.com/c/go/+/390037
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-11 21:51:20 +00:00
Paul E. Murphy
7b1ba972dc cmd/asm: add support for bdnz/bdz extended mnemonics on PPC64
Support BDNZ and BDZ mnemonics, they are commonly used
POWER instructions. The raw BC mnemonic is not easy
to read.

Likewise, cleanup code surrounding these changes.

Change-Id: I72f1dad5013f7856bd0dd320bfb17b5a9f3c69ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/390696
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Trust: Paul Murphy <murp@ibm.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-11 14:06:56 +00:00
Tobias Klauser
c1f22134f2 runtime/pprof, syscall: report MaxRSS on all unix platforms
All unix platforms currently supported by Go provide the getrusage
syscall. On aix and solaris the Getrusage syscall wrapper is not
available yet, so add and use it to report MaxRSS in memory profiles.

Change-Id: Ie880a3058171031fd2e12ccf9adfb85ce18858b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/391434
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Pratt <mpratt@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-11 06:03:26 +00:00
Robert Griesemer
fe75fe3c7a spec: various minor clarifications
- Allow for a type parameter as length/capacity to make.
- Be slightly more precise in prose for append.
- Add a couple of links.

Change-Id: Ib97e528bab1ab55d271beeeb53d9bb7a07047b9b
Reviewed-on: https://go-review.googlesource.com/c/go/+/391754
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-11 06:00:18 +00:00
Robert Griesemer
59d80227ef spec: clean up intro and replace bolded text with prose
- Remove "Draft" disclaimer. We're not done but the spec
  is in usable shape with respect to generics features.

- Remove section on "Earlier version" and fold information
  into the "Intro" section.

- Remove caveat for shifts: the rules for arithmetic operators
  on type parameters apply for them as well.

- Simply state that we don't support arguments of type parameter
  type for the built-ins real, imag, and complex.

Fixes #51182.

Change-Id: I6df1427de685cfe7055b64e91753aa7ebff70565
Reviewed-on: https://go-review.googlesource.com/c/go/+/391695
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-11 06:00:14 +00:00
Bryan C. Mills
751b8798dd cmd/compile/internal/amd64: fix "missing objdump" skip in TestGoAMD64v1
The skip was erroneously applied to errors from the call to StdoutPipe
instead of Start, and even then was a bit too broad.

Change-Id: I417c9a74692383230fc6d99ebb4149fdc532533e
Reviewed-on: https://go-review.googlesource.com/c/go/+/391800
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-11 05:22:30 +00:00
Bryan C. Mills
ef7d0413c2 cmd/go: use the correct gofmt binary in TestScript/fmt_load_errors
Otherwise, this test may fail when GOROOT/bin is not in $PATH.

Change-Id: Id744f365f6604716207184c9ea49436ab2e3a835
Reviewed-on: https://go-review.googlesource.com/c/go/+/391802
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-11 05:06:51 +00:00
Cuong Manh Le
9743e9b6d8 cmd/compile: fix re-export closure
For hidden closure built during stenciling to implement a function
instantiation, the function may come from other package, not local
package, which causes the ICE for code that re-export the hidden closure
after inlining.

To fix it, use the closure package for export writer when writing out
the closure itself.

Fixes #51423

Change-Id: I23b067ba14e2d602a0fc3b2e99bd9317afbe53ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/391574
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-11 00:42:08 +00:00
Steven Johnstone
5003ed884a internal/fuzz: minimization should not reduce coverage
Minimization should result in a fuzz input which
includes the same coverage bits as the original
input.

Updates #48326

Change-Id: I6c5f30058b57ccd1a096ad0e9452a4dfbb7d9aab
Reviewed-on: https://go-review.googlesource.com/c/go/+/391454
Trust: Bryan Mills <bcmills@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-10 23:06:14 +00:00
Roland Shoemaker
bd71dee2b4 internal/fuzz: don't use dirty coverage maps during minimization
When minimizing a value, if the value cannot be minimized (i.e. it is
the final value is the same value as was sent for minimization) return
the initial coverage map, rather than the coverageSnapshot, which is
actually the coverage map for the final minimization step and may not
accurately reflect whether the input actually expands the coverage set
or not.

Updates #48326

Change-Id: I01f0eebe5841e808b6799647d2e5fe3aa45cd2e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/391614
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-10 22:50:18 +00:00
Robert Griesemer
914195c132 go/types, types2: remove incorrect assertion (don't crash)
The removed assertion was never incorrect, as signatures may
be from methods in interfaces, and (some) interfaces set the
receivers of their methods (so we have a position for error
reporting).

This CL changes the issue below from a release blocker to an
issue for Go 1.19.

For #51593.

Change-Id: I0c5f2913b397b9ab557ed74a80cc7a715e840412
Reviewed-on: https://go-review.googlesource.com/c/go/+/391615
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-10 21:10:30 +00:00
Keith Randall
2e46a0a997 cmd/compile: fix expression switches using type parameters
Both the thing we're switching on, as well as the cases we're switching for.
Convert anything containing a type parameter to interface{} before the
comparison happens.

Fixes #51522

Change-Id: I97ba9429ed332cb7d4240cb60f46d42226dcfa5f
Reviewed-on: https://go-review.googlesource.com/c/go/+/391594
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-03-10 19:30:33 +00:00
Keith Randall
8cf11694ab cmd/compile: fix transform of OEQ/ONE when one arg is a type param
At this point in stenciling, we have shape types, not raw type parameters.
The code was correct in the other part of this function.

Update #51522

Change-Id: Ife495160a2be5f6af5400363c3efb68dda518b5f
Reviewed-on: https://go-review.googlesource.com/c/go/+/391475
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-10 18:50:50 +00:00
Joe Tsai
91daaabd56 flag: add TextVar function
The TextVar function makes it easier to integrate the flag package
with any Go type that implements encoding.Text{Marshaler,Unmarshaler}.

Fixes #45754

Change-Id: Id23c37d59cf8c9699a7943a22ce27a45eb685c0f
Reviewed-on: https://go-review.googlesource.com/c/go/+/313329
Trust: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-10 16:56:17 +00:00
Joe Tsai
2d026a4ea5 bytes: rely on runtime.growslice for growing
Rather than naively making a slice of capacity 2*c+n,
rely on the append(..., make(...)) pattern to allocate a
slice that aligns up to the closest size class.

Performance:
	name                          old time/op    new time/op    delta
	BufferWriteBlock/N4096       3.03µs ± 6%    2.04µs ± 6%  -32.60%  (p=0.000 n=10+10)
	BufferWriteBlock/N65536      47.8µs ± 6%    28.1µs ± 2%  -41.32%  (p=0.000 n=9+8)
	BufferWriteBlock/N1048576     844µs ± 7%     510µs ± 5%  -39.59%  (p=0.000 n=8+9)

	name                          old alloc/op   new alloc/op   delta
	BufferWriteBlock/N4096       12.3kB ± 0%     7.2kB ± 0%  -41.67%  (p=0.000 n=10+10)
	BufferWriteBlock/N65536       258kB ± 0%     130kB ± 0%  -49.60%  (p=0.000 n=10+10)
	BufferWriteBlock/N1048576    4.19MB ± 0%    2.10MB ± 0%  -49.98%  (p=0.000 n=10+8)

	name                          old allocs/op  new allocs/op  delta
	BufferWriteBlock/N4096         3.00 ± 0%      3.00 ± 0%     ~     (all equal)
	BufferWriteBlock/N65536        7.00 ± 0%      7.00 ± 0%     ~     (all equal)
	BufferWriteBlock/N1048576      11.0 ± 0%      11.0 ± 0%     ~     (all equal)

The performance is faster since the growth rate is capped at 2x,
while previously it could grow by amounts potentially much greater than 2x,
leading to significant amounts of memory waste and extra copying.

Credit goes to Martin Möhrmann for suggesting the
append(b, make([]T, n)...) pattern.

Fixes #42984
Updates #51462

Change-Id: I7b23f75dddbf53f8b8b93485bb1a1fff9649b96b
Reviewed-on: https://go-review.googlesource.com/c/go/+/349994
Trust: Joseph Tsai <joetsai@digital-static.net>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2022-03-10 16:24:16 +00:00
Michael Pratt
1cf67709be runtime: fix SegvInCgo skip check
CL 390034 changed this throw message to add the goid, breaking the
match.

For #50979.

Change-Id: I52d97695484938701e5b7c269e2caf0c87d44d7a
Reviewed-on: https://go-review.googlesource.com/c/go/+/391139
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-03-10 16:06:29 +00:00
Daniel Martí
5a040c5a36 go/token: allocate fewer times at init time
go/token has had a global "keywords" map filled at init time for years.
Overall, the package's init time cost is small, as per GODEBUG=inittrace=1:

	init go/token @0.51 ms, 0.004 ms clock, 1776 bytes, 5 allocs
	init go/token @0.44 ms, 0.003 ms clock, 1776 bytes, 5 allocs
	init go/token @0.45 ms, 0.003 ms clock, 1568 bytes, 4 allocs

However, adding the map size hint does help with the allocations:

	init go/token @0.45 ms, 0.002 ms clock, 944 bytes, 2 allocs
	init go/token @0.46 ms, 0.002 ms clock, 944 bytes, 2 allocs
	init go/token @0.55 ms, 0.003 ms clock, 1152 bytes, 3 allocs

Three samples are rather unscientific, and the clock time is basically
unchanged, but we might as well reduce the allocs.

Change-Id: I48121a4cea4113d991882e32f274d7b7736800dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/391094
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2022-03-10 09:12:04 +00:00
Meng Zhuo
29b968e766 runtime,cmd/compile: change reg duff{zero,copy} for regabi riscv64
As CL 356519 require, X8-X23 will be argument register, however X10, X11
is used by duff device.

This CL changes X10, X11 into X24, X25 to meet the prerequisite.

Update #40724

Change-Id: Ie9b899afbba7e9a51bb7dacd89e49ca1c1fc33ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/357976
Trust: mzh <mzh@golangcn.org>
Run-TryBot: mzh <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
2022-03-10 06:26:28 +00:00
Robert Griesemer
00535b8398 spec: remove note re: field accesses on type literals
For #51576.

Change-Id: I43f72c3fb618e724d46360a70ab9f8abc3d63273
Reviewed-on: https://go-review.googlesource.com/c/go/+/391137
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-10 01:57:27 +00:00
Robert Griesemer
6fb07317e5 spec: more adjustments/corrections
- Change section title from "Type parameters lists" to
  "Type parameter declarations" as the enclosing section
  is about declarations.

- Correct section on parsing ambiguity in type parameter
  lists.

- Rephrase paragraphs on type parameters for method receivers
  and adjust examples.

- Remove duplicate prose in section on function argument type
  inference.

- Clarified "after substitution" column in Instantiations section.

Change-Id: Id76be9804ad96a3f1221e5c4942552dde015dfcb
Reviewed-on: https://go-review.googlesource.com/c/go/+/390994
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-10 01:57:22 +00:00
Robert Griesemer
46f352de2d spec: remove notion of specific types
Specific types were introduced to explain rules for operands of
type parameter type. Specific types are really an implementation
mechanism to represent (possibly infinite) type sets in the machine;
they are not needed in the specification.

A specific type is either standing for a single named or unnamed
type, or it is the underlying (unnamed) type of an infinite set of
types. Each rule that applies to a type T of the set of specific
types must also apply to all types T' in the type set for which T
is a representative of. Thus, in the spec we can simply refer to
the type set directly, infinite or not.

Rather then excluding operands with empty type sets in each instance,
leave unspecified what happens when such an operand is used. Instead
give an implementation some leeway with an implementation restriction.

(The implementation restriction also needs to be formulated for types,
such as in conversions, which technically are not "operands". Left for
another CL.)

Minor: Remove the two uses of the word "concrete" to refer to non-
interface types; instead just say "non-interface type" for clarity.

Change-Id: I67ac89a640c995369c9d421a03820a0c0435835a
Reviewed-on: https://go-review.googlesource.com/c/go/+/390694
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-10 01:57:17 +00:00