1
0
mirror of https://github.com/golang/go synced 2024-11-26 22:31:23 -07:00
Commit Graph

53602 Commits

Author SHA1 Message Date
Ian Lance Taylor
d05ce23756 misc/cgo/testcarchive: permit SIGQUIT for TestSignalForwardingExternal
Occasionally the signal will be sent to a Go thread, which will cause
the program to exit with SIGQUIT rather than SIGSEGV.

Add TestSignalForwardingGo to test the case where the signal is
expected to be delivered to a Go thread.

This is a roll forward of CL 419014 which was rolled back in CL 424954.
This CL differs from 419014 in that it skips TestSignalForwardingGo
on darwin-amd64.

Fixes #53907

Change-Id: I5df3fd610c068df3bd48d9b3d7a9379248b97999
Reviewed-on: https://go-review.googlesource.com/c/go/+/425002
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-08-19 23:07:11 +00:00
Ian Lance Taylor
f3563bc55c debug/pe: fetch section size directly in (*Section).Data
Change-Id: Idc1f8b3fb6b4b2fdcc6dade048cc14c53715319f
Reviewed-on: https://go-review.googlesource.com/c/go/+/424197
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2022-08-19 21:29:19 +00:00
Ian Lance Taylor
375a80c9ef go/internal/gcimporter: use saferio to read indexed data
Avoid allocating large amounts of memory for corrupt input.

No test case because the problem can only happen for invalid data.
Let the fuzzer find cases like this.

Fixes #53787

Change-Id: I1b75a4c000b8d1112110309ec44b0ba9b4638d71
Reviewed-on: https://go-review.googlesource.com/c/go/+/416861
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dan Kortschak <dan@kortschak.io>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-08-19 21:29:17 +00:00
Ian Lance Taylor
1c4a803775 debug/plan9obj: use saferio to read section data
Avoid allocating large amounts of memory for corrupt input.

No test case because the problem can only happen for invalid data.
Let the fuzzer find cases like this.

Fixes #52521

Change-Id: I6a046f2e28e1255cf773ce135c5bb2b967ef43e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/414234
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dan Kortschak <dan@kortschak.io>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-08-19 21:29:13 +00:00
Michal Bohuslávek
5f0170f9a5 bytes, strings: s/after/before/ in CutSuffix
This follows on CL 407176 which added this function (in both
packages). This CL makes it consistent with the Cut function,
which uses “before” and “after” in return variable names.

Change-Id: Id4345d2fe0f50bf301a880803e87bf356986b518
Reviewed-on: https://go-review.googlesource.com/c/go/+/424922
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-08-19 20:56:43 +00:00
Tobias Klauser
2e06019dcd runtime/pprof: check Getrusage return value in addMaxRSS
Depending on the implementation of the getrusage syscall/function, the
value of rusage.Maxrss may be undefined in case of an error. Thus, only
report MaxRSS in case of no error.

Change-Id: I7572ccc53c49eb460e53bded3eb41736eed8d2ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/424815
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-08-19 20:04:40 +00:00
Tobias Klauser
2cc6983a21 runtime/pprof: report MaxRSS on windows
Use GetProcessMemoryInfo to report MaxRSS in memory profiles on windows.

Change-Id: I4ac5fe58961b1d5da8a5c1caa8a6e3d0a3281837
Reviewed-on: https://go-review.googlesource.com/c/go/+/424414
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-19 20:04:21 +00:00
Robert Griesemer
dbc3b44f85 go/types: match types2 errors for incorrect method receiver count
Use "method has no receiver" and "method has multiple receivers"
in error messages for invalid receiver counts, matching the
corresponding types2 errors.

For #54511.

Change-Id: I96fc99440d6206c74e9416069db052234baa8248
Reviewed-on: https://go-review.googlesource.com/c/go/+/424934
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-08-19 19:39:53 +00:00
Robert Griesemer
84232b0b89 go/types: match types2 errors for missing index expressions
Use "middle" and "final" rather than "2nd" and "3rd" in error messages
for invalid slice expressions. This is the original compiler error
message and many tests check for this specific message.

For #54511.

Change-Id: I86eb739aa7218b7f393fab1ab402732cb9e9a1f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/424906
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-08-19 19:39:51 +00:00
Robert Griesemer
6bedf4a2b4 go/types: match types2 error for invalid map key
Use "invalid" rather than "incomparable" in error message for map key
types that are not comparable. This is the original compiler error
message and many tests check for this specific message. The type
checker does provide an additional explanation if the reason for
the error is not obvious (e.g. for type parameters).

For #54511.

Change-Id: Idb76c48b4dfbfd66a7deac728a552e07f14e06d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/424905
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-08-19 19:39:50 +00:00
Robert Griesemer
9a1d3b0ad2 go/parser: match const/var decl parsing of syntax package
Use same approach to parsing const and var declarations
as the syntax package. Specifically, don't complain if
the first const specification in a const declaration
doesn't have a type and initialization expression. This
removes some duplicate errors when combined with the
type checker.

Adjust corresponding type checker tests accordingly.

For #54511.

Change-Id: I96702eba51dda6b581dad44577a7f93e4c02c857
Reviewed-on: https://go-review.googlesource.com/c/go/+/424904
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
2022-08-19 19:39:48 +00:00
Cuong Manh Le
bc69ad3a77 Revert "misc/cgo/testcarchive: permit SIGQUIT for TestSignalForwardingExternal"
This reverts CL 419014.

Reason for revert: broke darwin-amd64 builders

Change-Id: I77838e696a55c415d322ebb9846503de25b546d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/424954
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joedian Reid <joedian@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-08-19 19:35:55 +00:00
Andy Pan
bf4e35b658 runtime: fix a typo in comment of netpollblock()
Change-Id: Ia00acf248f3498d75e2451548f82d3c57cfed06f
Reviewed-on: https://go-review.googlesource.com/c/go/+/424995
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-19 18:39:56 +00:00
Robert Griesemer
a73808e1e0 go/parser: fix spelling in error message
Make spelling consistent with uses in other error messages.

Change-Id: I584cd22413842fb8bae1632ed34c8b0e7ef163cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/424902
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-08-19 17:47:49 +00:00
Robert Griesemer
9e88773383 go/types: remove machinery to select parsing mode (cleanup)
All code may be generic. Remove machinery to select parsing
mode (generic vs non-generic) since the parser doesn't support
this anymore. Adjust tests to more closely match corresponding
types2 code.

Change-Id: Id2398afe64d58714974ec96656fdf67c02ff5d04
Reviewed-on: https://go-review.googlesource.com/c/go/+/424900
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-19 17:46:09 +00:00
Robert Griesemer
4a530b8837 go/parser: remove (internal) ability to disable generic code
Generics are part of the language now; there's no need anymore
to switch back to a syntax without generics. Remove the associated
machinery and adjust short tests accordingly.

Change-Id: I6b16c5c75fd9354ee87e3b9bee110f49f514565a
Reviewed-on: https://go-review.googlesource.com/c/go/+/424857
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-08-19 17:46:07 +00:00
Robert Griesemer
4671aa5d06 go/parser: remove import path string syntax checking
The validity of an import path string is checked by the type checker
(and possibly other tools); it doesn't need to be done by the parser.
Remove the respective code and tests.

Also, adjust a corresponding go/types test which resolves a TODO.

For #54511.

Change-Id: Id1fc80df4e3e83be3ef123da3946ccb8f759779f
Reviewed-on: https://go-review.googlesource.com/c/go/+/424855
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-08-19 17:46:06 +00:00
Robert Griesemer
4a954fafa3 cmd/compile/internal/types2: match go/types for "..." related error msg
For #54511.

Change-Id: I571680dfc25d7b7198e84e11bd311ab8b24d72d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/424818
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-19 17:46:05 +00:00
Robert Griesemer
8892a51745 cmd/compile/internal/types2: use go/types/testdata/examples tests
Since the examples tests are now identical between the two type checkers,
remove the local copy of the examples tests and (for now) use the tests
in go/types/testdata/examples instead. Eventually we may decide to move
all tests out of the type checker directories and place them in a
shared space (e.g. internal/types/testdata).

For #54511.

Change-Id: Ibd8599d09e781b2219a23114b4b2049757971181
Reviewed-on: https://go-review.googlesource.com/c/go/+/424695
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
2022-08-19 17:46:04 +00:00
Robert Griesemer
5a53807950 go/types: remove TODO in testdata/examples/types.go
Follow-up on CL 424674. With this change, the files in
testdata/examples are identical to the corresponding
files for types2.

For #54511.

Change-Id: Ic61c089bbf61492094e31057ad2635803f50a30d
Reviewed-on: https://go-review.googlesource.com/c/go/+/424714
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-19 17:46:02 +00:00
Robert Griesemer
9b48ffa98a go/parser: disallow parenthesizing embedded types in structs
This was never permitted in Go but the flexibility to do so
was introduced through the generics prototype code where we
experimented with parentheses to enclose type parameters.
Restore original (pre-generics) behavior.

Fixes #51655.

Change-Id: Ia7a4b2e393e0214a70e840c8663cf4474c5c754b
Reviewed-on: https://go-review.googlesource.com/c/go/+/424694
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-19 17:46:01 +00:00
Tobias Klauser
0a1da095d1 runtime/internal/atomic: remove double-check in kernelcas on linux/arm
Older kernels which require the double check of the __kuser_cmpxchg
result are no longer supported as of Go 1.18 which requires at least
Linux 2.6.32.

For #45964

Change-Id: Ic3d6691bf006353ac51b9d43e742d970e3d4e961
Reviewed-on: https://go-review.googlesource.com/c/go/+/424556
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-08-19 17:28:00 +00:00
hopehook
dc8e2a6a8e io: add OffsetWriter, NewOffsetWriter
Offsetwriter refers to the design of SectionReader and removes
the section parameter n.

Since the size of the written data is determined by the user,
we cannot know where the end offset of the original data is.
The offset of SeekEnd is not valid in Seek method.

Fixes #45899.

Change-Id: I9d9445aecfa0dd4fc5168f2f65e1e3055c201b45
Reviewed-on: https://go-review.googlesource.com/c/go/+/406776
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-08-19 17:03:55 +00:00
Julie Qiu
7dad1d24b2 .github/ISSUE_TEMPLATE: add issue template for Go vulnerability management
Change-Id: Ia8bdd7909e94f3ab7248e88f0947db85ac744d79
Reviewed-on: https://go-review.googlesource.com/c/go/+/424928
Run-TryBot: Julie Qiu <julieqiu@google.com>
Auto-Submit: Julie Qiu <julieqiu@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2022-08-19 16:55:03 +00:00
qmuntal
48297f1fb1 unicode/utf16: add AppendRune
AppendRune appends the UTF-16 encoding of a rune to a []uint16.

    BenchmarkEncodeValidASCII-12                24.61ns 16B 1allocs
    BenchmarkEncodeValidJapaneseChars-12        18.79ns 8B  1allocs
    BenchmarkAppendRuneValidASCII-12            6.826ns 0B  0allocs
    BenchmarkAppendRuneValidJapaneseChars-12    3.547ns 0B  0allocs

The ASCII case is written to be inlineable.

Fixes #51896

Change-Id: I593b1029f603297ef6e80e036f2fee2a0938d38d
Reviewed-on: https://go-review.googlesource.com/c/go/+/409054
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
2022-08-19 16:45:08 +00:00
Robert Griesemer
f65ded5626 go/printer: rename printPos to setPos
Follow-up on feedback in CL 412557.

Change-Id: I5a693efccade97a62ab880c6e1b9e50cb597c293
Reviewed-on: https://go-review.googlesource.com/c/go/+/424814
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-08-19 16:33:22 +00:00
Cuong Manh Le
108021c195 strings: reduce allocation for byteReplacer
Though it increases the execution time, the function is already quite
fast for most users, the allocation is much more important.

name                       old time/op    new time/op    delta
ByteReplacerWriteString-8    1.23µs ± 0%    2.16µs ± 1%   +75.31%  (p=0.000 n=10+10)

name                       old alloc/op   new alloc/op   delta
ByteReplacerWriteString-8    2.69kB ± 0%    0.00kB       -100.00%  (p=0.000 n=10+10)

name                       old allocs/op  new allocs/op  delta
ByteReplacerWriteString-8      1.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)

Change-Id: I6a36df5fcb8e11ef27e6c7b252aa88e869592f3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/424136
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joedian Reid <joedian@golang.org>
2022-08-19 16:32:49 +00:00
Tobias Klauser
fe196a064e syscall: remove cloexecSocket fallback path
Support for Linux kernel versions requiring the fallback to CloseOnExec
was dropped from recent Go versions. The minimum Linux kernel version is
2.6.32 as of Go 1.18. The SOCK_CLOEXEC flag for the socket syscall is
supported since kernel version 2.6.27.

Follows a similar change for net.sysSocket in CL 403634.

For #45964

Change-Id: I8b6311f07c4ed7900a9af3ecb2e146c49db08665
Reviewed-on: https://go-review.googlesource.com/c/go/+/422374
Reviewed-by: Joedian Reid <joedian@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
2022-08-19 16:27:36 +00:00
Andy Pan
5729419420 strings: speed up ToUpper()/ToLower() by batch writing data with Builder
Updates #52371
Updates CL 423874

name                                                                    old time/op    new time/op    delta
ToUpper/#00-10                                                            2.85ns ± 0%    2.81ns ± 0%   -1.31%  (p=0.000 n=10+10)
ToUpper/ONLYUPPER-10                                                      12.7ns ± 0%    12.5ns ± 0%   -1.35%  (p=0.000 n=10+10)
ToUpper/abc-10                                                            20.9ns ± 1%    20.1ns ± 1%   -3.92%  (p=0.000 n=8+10)
ToUpper/AbC123-10                                                         26.9ns ± 1%    28.5ns ± 0%   +5.78%  (p=0.000 n=9+9)
ToUpper/azAZ09_-10                                                        27.4ns ± 1%    24.5ns ± 0%  -10.82%  (p=0.000 n=9+9)
ToUpper/longStrinGwitHmixofsmaLLandcAps-10                                95.9ns ± 1%   100.3ns ± 0%   +4.52%  (p=0.000 n=9+10)
ToUpper/RENAN_BASTOS_93_AOSDAJDJAIDJAIDAJIaidsjjaidijadsjiadjiOOKKO-10     188ns ± 0%     121ns ± 0%  -35.52%  (p=0.000 n=9+10)
ToUpper/longɐstringɐwithɐnonasciiⱯchars-10                                 168ns ± 0%     164ns ± 0%   -2.02%  (p=0.000 n=8+10)
ToUpper/ɐɐɐɐɐ-10                                                           134ns ± 0%     132ns ± 0%   -1.59%  (p=0.000 n=9+10)
ToUpper/a\u0080\U0010ffff-10                                              67.6ns ± 0%    66.4ns ± 0%   -1.73%  (p=0.000 n=10+10)
ToLower/#00-10                                                            2.87ns ± 4%    2.83ns ± 0%   -1.46%  (p=0.004 n=9+9)
ToLower/abc-10                                                            6.35ns ± 0%    6.29ns ± 0%   -0.98%  (p=0.000 n=9+9)
ToLower/AbC123-10                                                         25.6ns ± 1%    28.1ns ± 1%   +9.81%  (p=0.000 n=10+10)
ToLower/azAZ09_-10                                                        29.9ns ± 1%    30.1ns ± 1%   +0.64%  (p=0.023 n=9+10)
ToLower/longStrinGwitHmixofsmaLLandcAps-10                                96.7ns ± 1%    73.0ns ± 0%  -24.50%  (p=0.000 n=10+10)
ToLower/renan_bastos_93_AOSDAJDJAIDJAIDAJIaidsjjaidijadsjiadjiOOKKO-10     177ns ± 0%     118ns ± 0%  -33.61%  (p=0.000 n=7+8)
ToLower/LONGⱯSTRINGⱯWITHⱯNONASCIIⱯCHARS-10                                 159ns ± 1%     158ns ± 0%   -0.97%  (p=0.000 n=8+10)
ToLower/ⱭⱭⱭⱭⱭ-10                                                           125ns ± 1%     123ns ± 1%   -1.67%  (p=0.000 n=9+9)
ToLower/A\u0080\U0010ffff-10                                              68.4ns ± 1%    67.1ns ± 0%   -1.95%  (p=0.000 n=9+9)

name                                                                    old alloc/op   new alloc/op   delta
ToUpper/#00-10                                                             0.00B          0.00B          ~     (all equal)
ToUpper/ONLYUPPER-10                                                       0.00B          0.00B          ~     (all equal)
ToUpper/abc-10                                                             3.00B ± 0%     3.00B ± 0%     ~     (all equal)
ToUpper/AbC123-10                                                          8.00B ± 0%     8.00B ± 0%     ~     (all equal)
ToUpper/azAZ09_-10                                                         8.00B ± 0%     8.00B ± 0%     ~     (all equal)
ToUpper/longStrinGwitHmixofsmaLLandcAps-10                                 32.0B ± 0%     32.0B ± 0%     ~     (all equal)
ToUpper/RENAN_BASTOS_93_AOSDAJDJAIDJAIDAJIaidsjjaidijadsjiadjiOOKKO-10     64.0B ± 0%     64.0B ± 0%     ~     (all equal)
ToUpper/longɐstringɐwithɐnonasciiⱯchars-10                                 48.0B ± 0%     48.0B ± 0%     ~     (all equal)
ToUpper/ɐɐɐɐɐ-10                                                           48.0B ± 0%     48.0B ± 0%     ~     (all equal)
ToUpper/a\u0080\U0010ffff-10                                               16.0B ± 0%     16.0B ± 0%     ~     (all equal)
ToLower/#00-10                                                             0.00B          0.00B          ~     (all equal)
ToLower/abc-10                                                             0.00B          0.00B          ~     (all equal)
ToLower/AbC123-10                                                          8.00B ± 0%     8.00B ± 0%     ~     (all equal)
ToLower/azAZ09_-10                                                         8.00B ± 0%     8.00B ± 0%     ~     (all equal)
ToLower/longStrinGwitHmixofsmaLLandcAps-10                                 32.0B ± 0%     32.0B ± 0%     ~     (all equal)
ToLower/renan_bastos_93_AOSDAJDJAIDJAIDAJIaidsjjaidijadsjiadjiOOKKO-10     64.0B ± 0%     64.0B ± 0%     ~     (all equal)
ToLower/LONGⱯSTRINGⱯWITHⱯNONASCIIⱯCHARS-10                                 48.0B ± 0%     48.0B ± 0%     ~     (all equal)
ToLower/ⱭⱭⱭⱭⱭ-10                                                           24.0B ± 0%     24.0B ± 0%     ~     (all equal)
ToLower/A\u0080\U0010ffff-10                                               16.0B ± 0%     16.0B ± 0%     ~     (all equal)

name                                                                    old allocs/op  new allocs/op  delta
ToUpper/#00-10                                                              0.00           0.00          ~     (all equal)
ToUpper/ONLYUPPER-10                                                        0.00           0.00          ~     (all equal)
ToUpper/abc-10                                                              1.00 ± 0%      1.00 ± 0%     ~     (all equal)
ToUpper/AbC123-10                                                           1.00 ± 0%      1.00 ± 0%     ~     (all equal)
ToUpper/azAZ09_-10                                                          1.00 ± 0%      1.00 ± 0%     ~     (all equal)
ToUpper/longStrinGwitHmixofsmaLLandcAps-10                                  1.00 ± 0%      1.00 ± 0%     ~     (all equal)
ToUpper/RENAN_BASTOS_93_AOSDAJDJAIDJAIDAJIaidsjjaidijadsjiadjiOOKKO-10      1.00 ± 0%      1.00 ± 0%     ~     (all equal)
ToUpper/longɐstringɐwithɐnonasciiⱯchars-10                                  1.00 ± 0%      1.00 ± 0%     ~     (all equal)
ToUpper/ɐɐɐɐɐ-10                                                            2.00 ± 0%      2.00 ± 0%     ~     (all equal)
ToUpper/a\u0080\U0010ffff-10                                                1.00 ± 0%      1.00 ± 0%     ~     (all equal)
ToLower/#00-10                                                              0.00           0.00          ~     (all equal)
ToLower/abc-10                                                              0.00           0.00          ~     (all equal)
ToLower/AbC123-10                                                           1.00 ± 0%      1.00 ± 0%     ~     (all equal)
ToLower/azAZ09_-10                                                          1.00 ± 0%      1.00 ± 0%     ~     (all equal)
ToLower/longStrinGwitHmixofsmaLLandcAps-10                                  1.00 ± 0%      1.00 ± 0%     ~     (all equal)
ToLower/renan_bastos_93_AOSDAJDJAIDJAIDAJIaidsjjaidijadsjiadjiOOKKO-10      1.00 ± 0%      1.00 ± 0%     ~     (all equal)
ToLower/LONGⱯSTRINGⱯWITHⱯNONASCIIⱯCHARS-10                                  1.00 ± 0%      1.00 ± 0%     ~     (all equal)
ToLower/ⱭⱭⱭⱭⱭ-10                                                            1.00 ± 0%      1.00 ± 0%     ~     (all equal)
ToLower/A\u0080\U0010ffff-10                                                1.00 ± 0%      1.00 ± 0%     ~     (all equal)

Change-Id: Id3998ac4bae054ba3e6cf30545a257d5992b48be
Reviewed-on: https://go-review.googlesource.com/c/go/+/424139
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
2022-08-19 16:17:50 +00:00
Kir Kolyshkin
3204e62dd1 syscall: add new CLONE_ flags for Linux
The constants for these were auto-generated from the C includes
into zerrors_linux* files quite some time ago. The generator is
currently broken, but some new flags need to be added nevertheless.

As the flags won't change and the values are the same for all
architectures, we can just define them statically (as it's already
done in the runtime package):

 - remove the CLONE_* constants from zerrors_linux_*.go;
 - patch mkerrors.sh to not generate CLONE_ constants
   (in case it will be fixed and used in the future);
 - add the constants and some comments about them to exec_linux.go,
   using Linux v5.17 include/uapi/sched.h as the ultimate source.

This adds the following new flags:

 - CLONE_CLEAR_SIGHAND
 - CLONE_INTO_CGROUP
 - CLONE_NEWCGROUP
 - CLONE_NEWTIME
 - CLONE_PIDFD

For #51246.

Change-Id: I0c635723926218bd403d37e113ee4d62194463a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/407574
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joedian Reid <joedian@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-08-19 16:12:50 +00:00
ruinan
d654117075 cmd/compile: add intrinsic for MulUintptr on arm64
This CL adds intrinsic for runtime/internal/math.MulUintptr on arm64

Benchmark         master     ThisCL(ns/op)   delta
MulUintptr/small  0.95ns     0.79ns          -16%
MulUintptr/large  1.31ns     0.95ns          -27.6%

Change-Id: Ic7b453ad502826beffe93ce5531b8ba752312a1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/419556
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Eric Fang <eric.fang@arm.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Joedian Reid <joedian@golang.org>
2022-08-19 16:08:24 +00:00
Ludi Rehak
f15761b50b runtime: fix formula for computing number of padding bytes
In order to prevent false sharing of cache lines, structs are
padded with some number of bytes. These bytes are unused, serving
only to make the size of the struct a multiple of the size of the
cache line.

The current calculation of how much to pad is an overestimation,
when the struct size is already a multiple of the cache line size
without padding. For these cases, no padding is necessary, and
the size of the inner pad field should be 0. The bug is that the
pad field is sized to a whole 'nother cache line, wasting space.

Here is the current formula that can never return 0:
cpu.CacheLinePadSize - unsafe.Sizeof(myStruct{})%cpu.CacheLinePadSize

This change simply mods that calculation by cpu.CacheLinePadSize,
so that 0 will be returned instead of cpu.CacheLinePadSize.

Change-Id: I26a2b287171bf47a3b9121873b2722f728381b5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/414214
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-19 16:04:12 +00:00
Ian Lance Taylor
dee9adc0f7 encoding/gob: use saferio to read large buffer
Avoid allocating large amounts of memory for corrupt input.

No test case because the problem can only happen for invalid data.
Let the fuzzer find cases like this.

Fixes #53369

Change-Id: I67c5e75bf181ad84988d6d6da12507df0e6df8e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/413979
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-19 16:03:42 +00:00
Cuong Manh Le
f324355d1f runtime: remove pageAlloc.scav padding for atomic field alignment
CL 404096 makes atomic.Int64 8 bytes aligned everywhere.

Change-Id: I5a676f646260d6391bb071f9376cbdb1553e6e6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/424925
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-08-19 15:53:47 +00:00
Ian Lance Taylor
6001c043dc test: add test that caused gccgo crash
For #23870

Change-Id: I3bbe0f751254d1354a59a88b45e6f944c7a2fb4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/417874
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2022-08-19 03:32:27 +00:00
Ian Lance Taylor
011a525b21 test: add test that caused gccgo to crash
For #23868

Change-Id: I07b001836e8d1411609ab84786398a5b575bf8d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/417481
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2022-08-19 03:32:04 +00:00
Ian Lance Taylor
a409356c54 misc/cgo/testcarchive: permit SIGQUIT for TestSignalForwardingExternal
Occasionally the signal will be sent to a Go thread, which will cause
the program to exit with SIGQUIT rather than SIGSEGV.

Add TestSignalForwardingGo to test the case where the signal is
expected to be delivered to a Go thread.

Fixes #53907

Change-Id: Iaefb964c2be4a815c11c507fa89648f8a7740ba9
Reviewed-on: https://go-review.googlesource.com/c/go/+/419014
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-08-19 03:09:05 +00:00
Andy Pan
55ecc3a886 net: allow single dot in resolv.conf search statement
A single dot in a search statement doesn't affect DNS lookup, so just ignore it and a syntax error.

Fixes #54124

Change-Id: Idd43bd34c5c16af50cba51f0b6e24f992eec6e57
Reviewed-on: https://go-review.googlesource.com/c/go/+/423875
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-08-19 03:01:14 +00:00
Cuong Manh Le
ee833ed72e sync: use atomic.Uint64 for WaitGroup state
So it's guaranteed to have 64-bit alignment, simplify the code without
losing any performance:

name                     old time/op    new time/op    delta
WaitGroupUncontended-8     3.84ns ± 2%    3.82ns ± 1%   ~     (p=0.159 n=10+10)
WaitGroupAddDone-8         33.2ns ± 3%    33.0ns ± 3%   ~     (p=0.564 n=9+10)
WaitGroupAddDoneWork-8     39.3ns ± 1%    39.3ns ± 1%   ~     (p=1.000 n=8+9)
WaitGroupWait-8            0.70ns ± 3%    0.70ns ± 2%   ~     (p=0.720 n=9+10)
WaitGroupWaitWork-8        7.93ns ± 1%    7.99ns ± 3%   ~     (p=0.271 n=10+10)
WaitGroupActuallyWait-8     135ns ± 2%     135ns ± 1%   ~     (p=0.897 n=10+10)

Change-Id: I446b53fa92873419aadd592f45e51398f8ad8652
Reviewed-on: https://go-review.googlesource.com/c/go/+/424835
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-08-19 01:34:22 +00:00
Yuval Pavel Zholkover
e51b3ae0ee runtime: fast clock_gettime on FreeBSD, split getHPETTimecounter
Call only initHPETTimecounter on the system stack.
Use O_CLOEXEC flag when opening the HPET device.

FreeBSD 12.3-RELEASE-p2, AMD FX-8300
paulzhol@relic:~/go/src/time % ~/gocode/bin/benchcmp old_hpet.txt new_hpet.txt
benchcmp is deprecated in favor of benchstat: https://pkg.go.dev/golang.org/x/perf/cmd/benchstat
benchmark                   old ns/op     new ns/op     delta
BenchmarkNow-8              1420          1397          -1.62%
BenchmarkNowUnixNano-8      1421          1404          -1.20%
BenchmarkNowUnixMilli-8     1423          1405          -1.26%
BenchmarkNowUnixMicro-8     1423          1404          -1.34%

Update #50947

Change-Id: I553b5427fb0b86d7e070af4516b36326bc0aaf00
Reviewed-on: https://go-review.googlesource.com/c/go/+/391856
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-08-19 01:31:59 +00:00
Cuong Manh Le
a719a78c1b runtime: add and use runtime/internal/sys.NotInHeap
Updates #46731

Change-Id: Ic2208c8bb639aa1e390be0d62e2bd799ecf20654
Reviewed-on: https://go-review.googlesource.com/c/go/+/421878
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-08-19 00:29:18 +00:00
Matthew Dempsky
833367e98a internal/buildcfg: enable unified IR by default
Unified IR is now at feature parity with the non-unified frontend.

Change-Id: I2a8cd41267a66f5eb1f425b89d18c6d501676e07
Reviewed-on: https://go-review.googlesource.com/c/go/+/422235
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-08-18 22:53:59 +00:00
Robert Griesemer
0a4a57de4d cmd/compile/internal/types2: use go/types/testdata/spec tests
Since the spec tests are now identical between the two type checkers,
remove the local copy of the spec tests and (for now) use the tests
in go/types/testdata/spec instead. Eventually we may decide to move
all tests out of the type checker directories and place them in a
shared space (e.g. internal/types/testdata).

For #54511.

Change-Id: Ibc62230553a5ff215160dcc97696b333ae9cf685
Reviewed-on: https://go-review.googlesource.com/c/go/+/424676
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
2022-08-18 21:54:52 +00:00
Robert Griesemer
17211c355f go/types, types2: consolidate testdata/spec test files
Besides applying gofmt (which doesn't damage the tests in this case),
this removes a TODO for a set of nil-related tests.

The test files are now identical.

For #54511.

Change-Id: I0a286ad607f317f43972c1f5ee741b4f5bc9576d
Reviewed-on: https://go-review.googlesource.com/c/go/+/424675
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-08-18 21:54:30 +00:00
Robert Griesemer
9ad772033f go/types, types2: consolidate testdata/examples test files
Besides applying gofmt (which doesn't damage the tests in this case),
the ERROR comments in the types2 files now match the go/types files.
But because types2 still reports some errors are different positions,
the checking code now allows for some position discrepancy (similar
to what we do for other tests).

Except for an outstanding TODO in go/types/testdata/examples/types.go
the test files are now identical.

For #54511.

Change-Id: I5748e0f678d11c5c0bdf4fdf28bd04f0b11b5b23
Reviewed-on: https://go-review.googlesource.com/c/go/+/424674
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-08-18 21:54:10 +00:00
Robert Griesemer
9485d4c1bd cmd/compile/internal/syntax: handle missing index like in go/parser
Instead of simply reporting an error but otherwise dropping the
index expression from the parse tree when an index is missing
(as in: x[]), create an index expression with a "bad expression"
as index. This matches the behavior of go/parser and permits the
use of the same test case for both parsers.

(It would be simpler to adjust the go/parser to match the syntax
parser's behavior, but that would break backward-compatibility
of the go/parser.)

Adjust the affected test files.

For #54511.

Change-Id: If7668973794604593e869a24b560da92e100b812
Reviewed-on: https://go-review.googlesource.com/c/go/+/424654
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-08-18 21:46:39 +00:00
Russ Cox
39ec97da15 crypto/internal/boring: update to newer boringcrypto, add arm64
Update the version of BoringCrypto to boringssl tag
fips-20210429, for which FIPS approval is "in process".

Add GOARCH=arm64 BoringCrypto support.

Shuffle build to run as distinct steps in Docker so that
we can rerun later parts like build-goboring.sh without
rerunning all the setup.

Strip unnecessary parts of the syso using --strip-unneeded,
which cuts the amd64 syso from 10MB to 2.5MB.
The new arm64 syso is 2MB, so even though we added a new
architecture, we have half as much syso to distribute.

Change-Id: I0f7327389a3a485b82577abea9153d006418298f
Reviewed-on: https://go-review.googlesource.com/c/go/+/423362
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2022-08-18 21:28:09 +00:00
Robert Griesemer
5fcddf3997 go/types: match types2 error msg formatting for conversion errors
This resolves a TODO. Also, it allows go/types and types2 to use
identical test files in testdata/spec, a prerequisition for sharing
them eventually.

For #54511.

Change-Id: Ia9d11b15ada237c18b6ce8f72732f70134a1a06f
Reviewed-on: https://go-review.googlesource.com/c/go/+/424537
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-18 21:22:06 +00:00
Paul E. Murphy
0eb56ca468 internal/buildcfg: support GOPPC64=power10
This does not enable any new functionality. It should
behave identically to GOPPC64=power9.

Updates #44549

Change-Id: I9a860544527fcfe97cbaf89686459d40dcf9593e
Reviewed-on: https://go-review.googlesource.com/c/go/+/352791
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2022-08-18 19:12:13 +00:00
Cuong Manh Le
1aa5730f49 runtime: remove p padding field for atomic fields alignment
CL 424396 and CL 424397 changed timer0When/timerModifiedEarliest to
atomic.Uint64, just they're guaranted to have 64-bit alignment.

Change-Id: Idaff1059da2aac84520b9b0e34f9721a74dbba5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/424794
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-08-18 18:18:45 +00:00