aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/sys
AgeCommit message (Collapse)Author
2026-02-06cmd/compile: allow equal functions to perform unaligned load on loong64Guoqi Chen
The Go compiler always generates Loong64 binaries, which can execute any processor of LA364, LA464, LA664 or higher core. And these processors support unaligned memory access [1]. goos: linux goarch: loong64 pkg: strings cpu: Loongson-3A6000 @ 2500.00MHz | old.txt | new.txt | | sec/op | sec/op vs base | StringPrefix3 4.0040n ± 0% 0.4003n ± 0% -90.00% (p=0.000 n=10) StringPrefix5 4.0040n ± 0% 0.4003n ± 0% -90.00% (p=0.000 n=10) StringPrefix6 3.6030n ± 0% 0.4002n ± 0% -88.89% (p=0.000 n=10) StringPrefix7 4.0040n ± 0% 0.4002n ± 0% -90.00% (p=0.000 n=10) geomean 3.900n 0.4003n -89.74% goos: linux goarch: loong64 pkg: strings cpu: Loongson-3A5000-HV @ 2500.00MHz | old.txt │ new.txt | | sec/op │ sec/op vs base | StringPrefix3 5.6160n ± 0% 0.4011n ± 0% -92.86% (p=0.000 n=10) StringPrefix5 5.6180n ± 0% 0.4011n ± 0% -92.86% (p=0.000 n=10) StringPrefix6 5.2170n ± 0% 0.4011n ± 0% -92.31% (p=0.000 n=10) StringPrefix7 5.6170n ± 0% 0.4009n ± 0% -92.86% (p=0.000 n=10) geomean 5.514n 0.4010n -92.73% goos: linux goarch: loong64 pkg: strings cpu: Loongson-3B6000M @ 2400.00MHz | old.txt │ new.txt | | sec/op │ sec/op vs base | StringPrefix3 5.0060n ± 0% 0.4223n ± 1% -91.56% (p=0.000 n=10) StringPrefix5 4.5890n ± 0% 0.4214n ± 0% -90.82% (p=0.000 n=10) StringPrefix6 4.5890n ± 0% 0.4190n ± 1% -90.87% (p=0.000 n=10) StringPrefix7 4.5890n ± 0% 0.4226n ± 1% -90.79% (p=0.000 n=10) geomean 4.690n 0.4213n -91.02% [1]: https://go.dev/wiki/MinimumRequirements#loong64 Change-Id: I1870080e0122a7d136685e3045699d0cf1e4194d Reviewed-on: https://go-review.googlesource.com/c/go/+/742260 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Meidan Li <limeidan@loongson.cn> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Michael Pratt <mpratt@google.com>
2025-11-17cmd/internal/sys,internal/goarch,runtime: enable the use of compressed ↵Joel Sing
instructions on riscv64 Enable the use of compressed instructions on riscv64 by reducing the PC quantum to two bytes and reducing the minimum instruction length to two bytes. Change gostartcall on riscv64 to land at two times the PC quantum into goexit, so that we retain four byte alignment and revise the NOP instructions in goexit to ensure that they are never compressed. Additionally, adjust PCALIGN so that it correctly handles two byte offsets. Fixes #47560 Updates #71105 Cq-Include-Trybots: luci.golang.try:gotip-linux-riscv64 Change-Id: I4329a8fbfcb4de636aadaeadabb826bc22698640 Reviewed-on: https://go-review.googlesource.com/c/go/+/523477 Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: Mark Freeman <markfreeman@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
2025-09-27cmd/compile: implement jump table on loong64limeidan
Following CL 357330, use jump tables on Loong64. goos: linux goarch: loong64 pkg: cmd/compile/internal/test cpu: Loongson-3A6000-HV @ 2500.00MHz │ old │ new │ │ sec/op │ sec/op vs base │ Switch8Predictable 2.352n ± 0% 2.101n ± 0% -10.65% (p=0.000 n=10) Switch8Unpredictable 11.99n ± 0% 10.25n ± 0% -14.51% (p=0.000 n=10) Switch32Predictable 3.153n ± 0% 1.887n ± 1% -40.14% (p=0.000 n=10) Switch32Unpredictable 12.47n ± 0% 10.22n ± 0% -18.00% (p=0.000 n=10) SwitchStringPredictable 3.162n ± 0% 3.352n ± 0% +6.01% (p=0.000 n=10) SwitchStringUnpredictable 14.70n ± 0% 13.31n ± 0% -9.46% (p=0.000 n=10) SwitchTypePredictable 3.702n ± 0% 2.201n ± 0% -40.55% (p=0.000 n=10) SwitchTypeUnpredictable 16.18n ± 0% 14.48n ± 0% -10.51% (p=0.000 n=10) SwitchInterfaceTypePredictable 7.654n ± 0% 9.680n ± 0% +26.47% (p=0.000 n=10) SwitchInterfaceTypeUnpredictable 22.04n ± 0% 22.44n ± 0% +1.81% (p=0.000 n=10) geomean 7.441n 6.469n -13.07% Change-Id: Id6f30fa73349c60fac17670084daee56973a955f Reviewed-on: https://go-review.googlesource.com/c/go/+/705396 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: abner chenc <chenguoqi@loongson.cn>
2025-04-09cmd/compile: set unalignedOK to make memcombine work properly on loong64limeidan
goos: linux goarch: loong64 pkg: unicode/utf8 cpu: Loongson-3A6000-HV @ 2500.00MHz │ old │ new │ │ sec/op │ sec/op vs base │ ValidTenASCIIChars 7.604n ± 0% 6.805n ± 0% -10.51% (p=0.000 n=10) Valid100KASCIIChars 37.41µ ± 0% 16.58µ ± 0% -55.67% (p=0.000 n=10) ValidTenJapaneseChars 60.84n ± 0% 58.62n ± 0% -3.64% (p=0.000 n=10) ValidLongMostlyASCII 113.5µ ± 0% 113.5µ ± 0% ~ (p=0.303 n=10) ValidLongJapanese 204.6µ ± 0% 206.8µ ± 0% +1.07% (p=0.000 n=10) ValidStringTenASCIIChars 7.604n ± 0% 6.803n ± 0% -10.53% (p=0.000 n=10) ValidString100KASCIIChars 38.05µ ± 0% 17.14µ ± 0% -54.97% (p=0.000 n=10) ValidStringTenJapaneseChars 60.58n ± 0% 59.48n ± 0% -1.82% (p=0.000 n=10) ValidStringLongMostlyASCII 113.5µ ± 0% 113.4µ ± 0% -0.10% (p=0.000 n=10) ValidStringLongJapanese 205.9µ ± 0% 207.3µ ± 0% +0.67% (p=0.000 n=10) geomean 3.324µ 2.756µ -17.08% Change-Id: Id43b6e2e41907bd4b92f421dacde31f048db47d6 Reviewed-on: https://go-review.googlesource.com/c/go/+/662495 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: abner chenc <chenguoqi@loongson.cn> Reviewed-by: Keith Randall <khr@google.com>
2025-02-25internal/abi: use arch family instead of arch stringKeith Randall
No point in using string comparison when we can use integer comparison instead. Unify the constants in cmd/internal/sys and internal/goarch while we are at it. Change-Id: I5681a601030307b7b286f958a8965559cb43506d Reviewed-on: https://go-review.googlesource.com/c/go/+/652175 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Stapelberg <stapelberg@google.com> Reviewed-by: Keith Randall <khr@google.com>
2025-02-04cmd/internal/sys: allow unaligned loads on big-endian ppc64Keith Randall
According to https://go.dev/wiki/MinimumRequirements, we've required power8 since Go 1.9. Before that, we supported power5 which couldn't do unaligned loads. But power8 should be able to (it does for ppc64le). In fact, I think we already support unaligned loads in some cases, for instance cmd/compile/internal/ssa/config.go lists big-endian ppc64 as having unaligned loads. Change-Id: I4a75f09d4b5199a889e0e8db0b3b7a1fa23145f3 Reviewed-on: https://go-review.googlesource.com/c/go/+/631318 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-08-20cmd/compile/internal/ssagen: improve intrinsic architecture handlingJoel Sing
The architecture handling code for intrinsics is more complex than it needs to be. sys.Archs is already an array of *sys.Arch and the existing InFamily function can be used instead of a reimplementation. Add some test coverage for sys.Arch.InFamily while here. Change-Id: Ia764f211114fea65424c09a421c5ccb02b7187b0 Reviewed-on: https://go-review.googlesource.com/c/go/+/605476 Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2022-10-04cmd/internal/sys: migrate support.go functions to new internal pkgThan McIntosh
Separate out the functions from cmd/internal/sys/support.go and migrate them to a new package internal/platform, so that functions such as "RaceDetectorSupported" can be called from tests in std as well as in cmd. This isn't a complete move of everything in cmd/internal/sys; there are still many functions left. The original version of this CL (patch set 1) called the new package "internal/sys", but for packages that needed both "internal/sys" and "cmd/internal/sys" the import of the former had to be done with a different name, which was confusing and also required a hack in cmd/dist. Updates #56006. Change-Id: I866d62e75adbf3a640a06e2c7386a6e9e2a18d91 Reviewed-on: https://go-review.googlesource.com/c/go/+/438475 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Than McIntosh <thanm@google.com>
2022-08-26runtime: add address sanitizer support for ppc64leArchana R
updates #44853 Change-Id: I71905ee1bcb99ce7300bbed2daad3617d2643c53 Reviewed-on: https://go-review.googlesource.com/c/go/+/408814 Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Benny Siegert <bsiegert@gmail.com> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Archana Ravindar <aravind5@in.ibm.com>
2022-05-16runtime: add address sanitizer support for riscv64Meng Zhuo
Updates #44853 Change-Id: I3ba6ec0cfc6c7f311b586deedb1cda0f87a637aa Reviewed-on: https://go-review.googlesource.com/c/go/+/375256 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Joel Sing <joel@sing.id.au> Run-TryBot: Zhuo Meng <mzh@golangcn.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: David Chase <drchase@google.com>
2022-05-13cmd/compile: use jump table on ARM64Cherry Mui
Following CL 357330, use jump tables on ARM64. name old time/op new time/op delta Switch8Predictable-4 3.41ns ± 0% 3.21ns ± 0% ~ (p=0.079 n=4+5) Switch8Unpredictable-4 12.0ns ± 0% 9.5ns ± 0% -21.17% (p=0.000 n=5+4) Switch32Predictable-4 3.06ns ± 0% 2.82ns ± 0% -7.78% (p=0.008 n=5+5) Switch32Unpredictable-4 13.3ns ± 0% 9.5ns ± 0% -28.87% (p=0.016 n=4+5) SwitchStringPredictable-4 3.71ns ± 0% 3.21ns ± 0% -13.43% (p=0.000 n=5+4) SwitchStringUnpredictable-4 14.8ns ± 0% 15.1ns ± 0% +2.37% (p=0.008 n=5+5) Change-Id: Ia0b85df7ca9273cf70c05eb957225c6e61822fa6 Reviewed-on: https://go-review.googlesource.com/c/go/+/403979 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com>
2022-05-04cmd,runtime: enable race detector on s390xIlya Leoshkevich
LLVM has SystemZ ThreadSanitizer support now [1], this patch integrates it with golang. The biggest part is the glue code in race_s390x.s, which is derived from race_arm64.s, and then the support needs to be enabled in four places. [1] https://reviews.llvm.org/D105629 Change-Id: I1d4e51beb4042603b681e4aca9af6072879d54d6 Reviewed-on: https://go-review.googlesource.com/c/go/+/336549 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Keith Randall <khr@golang.org>
2022-04-19internal/sys: add LR and fixed frame size to sys.ArchAustin Clements
Storing this information in the Arch eliminates some code duplication between the compiler and linker. This information is entirely determined by the Arch, so the current approach of attaching it to an entire Ctxt is a little silly. This will also make it easier to use this information from tests. The next CL will be a rote refactoring to eliminate the Ctxt.FixedFrameSize methods. Change-Id: I315c524fa66a0ea99f63ae5a2a6fdc367d843bad Reviewed-on: https://go-review.googlesource.com/c/go/+/400818 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-14cmd/compile: implement jump tablesKeith Randall
Performance is kind of hard to exactly quantify. One big difference between jump tables and the old binary search scheme is that there's only 1 branch statement instead of O(n) of them. That can be both a blessing and a curse, and can make evaluating jump tables very hard to do. The single branch can become a choke point for the hardware branch predictor. A branch table jump must fit all of its state in a single branch predictor entry (technically, a branch target predictor entry). With binary search that predictor state can be spread among lots of entries. In cases where the case selection is repetitive and thus predictable, binary search can perform better. The big win for a jump table is that it doesn't consume so much of the branch predictor's resources. But that benefit is essentially never observed in microbenchmarks, because the branch predictor can easily keep state for all the binary search branches in a microbenchmark. So that benefit is really hard to measure. So predictable switch microbenchmarks are ~useless - they will almost always favor the binary search scheme. Fully unpredictable switch microbenchmarks are better, as they aren't lying to us quite so much. In a perfectly unpredictable situation, a jump table will expect to incur 1-1/N branch mispredicts, where a binary search would incur lg(N)/2 of them. That makes the crossover point at about N=4. But of course switches in real programs are seldom fully unpredictable, so we'll use a higher crossover point. Beyond the branch predictor, jump tables tend to execute more instructions per switch but have no additional instructions per case, which also argues for a larger crossover. As far as code size goes, with this CL cmd/go has a slightly smaller code segment and a slightly larger overall size (from the jump tables themselves which live in the data segment). This is a case where some FDO (feedback-directed optimization) would be really nice to have. #28262 Some large-program benchmarks might help make the case for this CL. Especially if we can turn on branch mispredict counters so we can see how much using jump tables can free up branch prediction resources that can be gainfully used elsewhere in the program. name old time/op new time/op delta Switch8Predictable 1.89ns ± 2% 1.27ns ± 3% -32.58% (p=0.000 n=9+10) Switch8Unpredictable 9.33ns ± 1% 7.50ns ± 1% -19.60% (p=0.000 n=10+9) Switch32Predictable 2.20ns ± 2% 1.64ns ± 1% -25.39% (p=0.000 n=10+9) Switch32Unpredictable 10.0ns ± 2% 7.6ns ± 2% -24.04% (p=0.000 n=10+10) Fixes #5496 Update #34381 Change-Id: I3ff56011d02be53f605ca5fd3fb96b905517c34f Reviewed-on: https://go-review.googlesource.com/c/go/+/357330 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@google.com>
2022-01-12cmd/go: enable fuzz testing for FreeBSDAyan George
Add "freebsd" to GOOS for which sys.FuzzSupported() returns true and add freebsd to the build tags to fuzz test source. Fixes #46554 Change-Id: I5f695ecc8f09c0ab4279ced23b4715b788fcade0 Reviewed-on: https://go-review.googlesource.com/c/go/+/377855 Trust: Bryan Mills <bcmills@google.com> Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Katie Hockman <katie@golang.org>
2021-11-05cmd/link: enable internal linking of PIE binaries on ppc64lePaul E. Murphy
The amd64/arm64 relocation processing is used as a template and updated for ppc64le. This requires updating the TOC relocation handling code to support linux type TOC relocations too (note, AIX uses TOC-indirect accesses). Noteably, the shared flag of go functions is used as a proxy for the local entry point offset encoded in elf objects. Functions in go ppc64le shared objects always[1] insert 2 instructions to regenerate the TOC pointer. [1] excepting a couple special runtime functions, see preprocess in obj9.go for specific details of this behavior. Change-Id: I3646e6dc8a0a0ffe712771a976983315eae5c418 Reviewed-on: https://go-review.googlesource.com/c/go/+/352829 Run-TryBot: Paul Murphy <murp@ibm.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
2021-11-03all: add support for c-archive and c-shared on linux/riscv64Joel Sing
This provides the runtime glue (_rt0_riscv64_linux_lib) for c-archive and c-shared support, along with enabling both of these buildmodes on linux/riscv64. Both misc/cgo/testcarchive and misc/cgo/testcshared now pass on this platform. Fixes #47100 Change-Id: I7ad75b23ae1d592dbac60d15bba557668287711f Reviewed-on: https://go-review.googlesource.com/c/go/+/334872 Trust: Joel Sing <joel@sing.id.au> Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-11-02cmd/dist: add asan tests in misc/cgo/testsanitizers packagefanzha02
Add asan tests to check the use of Go with -asan option. Currenly, the address sanitizer in Go only checks for error memory access to heap objects. TODO: Enable check for error memory access to global objects. Updates #44853. Change-Id: I83579f229f117b5684a369fc8f365f4dea140648 Reviewed-on: https://go-review.googlesource.com/c/go/+/298615 Trust: fannie zhang <Fannie.Zhang@arm.com> Run-TryBot: fannie zhang <Fannie.Zhang@arm.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-29Revert "cmd/go: remove support for -buildmode=shared"Bryan C. Mills
This reverts CL 359096. Updates #47788. Reason for revert: -buildmode=shared may have actually been working in a few very specific cases. We should not remove -buildmode=shared until we have implemented an alternative to support those few cases. Change-Id: Ia962b06abacc11f6f29fc29d092773be175e32f1 Reviewed-on: https://go-review.googlesource.com/c/go/+/359575 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2021-10-28cmd/go: consolidate fuzz-support checksBryan C. Mills
We had been repeating conditions for specific platforms and architectures to gate fuzzing tests, but the more of those tests we add the more we will have to update if the set of supported platforms and archictures expands over time. We also ought to provide a friendlier error message when 'go test -fuzz' is used on non-supported platforms. This change adds predicates in cmd/internal/sys, which already contains similar predicates for related functionality (such as the race detector), and uses those predicates in 'go test' and TestScript. For #48495 Change-Id: If24c3997aeb4d201258e21e5b6cf4f7c08fbadd7 Reviewed-on: https://go-review.googlesource.com/c/go/+/359481 Trust: Bryan C. Mills <bcmills@google.com> Trust: Katie Hockman <katie@golang.org> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Katie Hockman <katie@golang.org>
2021-10-27cmd/go: remove support for -buildmode=sharedBryan C. Mills
It never worked in module mode (or with a read-only GOROOT). A proposal to drop it was filed (and approved) in https://golang.org/issue/47788. Fixes #47788 Change-Id: I0c12f38eb0c5dfe9384fbdb49ed202301fa4273d Reviewed-on: https://go-review.googlesource.com/c/go/+/359096 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-10-25cmd/compile: add -asan optionfanzha02
The -asan option causes the compiler to add instrumentation for the C/C++ address sanitizer. Every memory read/write will be replaced by a call to asanread/asanwrite. This CL also inserts asan instrumentation during SSA building. This CL passes tests but is not usable by itself. The actual implementation of asanread/asanwrite in the runtime package, and support for -asan in the go tool and tests, will follow in subsequent CLs. Updates #44853. Change-Id: Ia18c9c5d5c351857420d2f6835f0daec2ad31096 Reviewed-on: https://go-review.googlesource.com/c/go/+/298611 Trust: fannie zhang <Fannie.Zhang@arm.com> Run-TryBot: fannie zhang <Fannie.Zhang@arm.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-06cmd/compile: make encoding/binary loads/stores cheaper to inlineJosh Bleecher Snyder
The encoding/binary little- and big-endian load and store routines are frequently used in performance sensitive code. They look fairly complex to the inliner. Though the routines themselves can be inlined, code using them typically cannot be. Yet they typically compile down to an instruction or two on architectures that support merging such loads. This change teaches the inliner to treat calls to these methods as cheap, so that code using them will be more inlineable. It'd be better to teach the inliner that this pattern of code is cheap, rather than these particular methods. However, that is difficult to do robustly when working with the IR representation. And the broader project of which that would be a part, namely to model the rest of the compiler in the inliner, is probably a non-starter. By way of contrast, imperfect though it is, this change is an easy, cheap, and useful heuristic. If/when we base inlining decisions on more accurate information obtained later in the compilation process, or on PGO/FGO, we can remove this and other such heuristics. Newly inlineable functions in the standard library: crypto/cipher.gcmInc32 crypto/sha512.appendUint64 crypto/md5.appendUint64 crypto/sha1.appendUint64 crypto/sha256.appendUint64 vendor/golang.org/x/crypto/poly1305.initialize encoding/gob.(*encoderState).encodeUint vendor/golang.org/x/text/unicode/norm.buildRecompMap net/http.(*http2SettingsFrame).Setting net/http.http2parseGoAwayFrame net/http.http2parseWindowUpdateFrame Benchmark impact for encoding/gob (the only package I measured): name old time/op new time/op delta EndToEndPipe-8 2.25µs ± 1% 2.21µs ± 3% -1.79% (p=0.000 n=28+27) EndToEndByteBuffer-8 93.3ns ± 5% 94.2ns ± 5% ~ (p=0.174 n=30+30) EndToEndSliceByteBuffer-8 10.5µs ± 1% 10.6µs ± 1% +0.87% (p=0.000 n=30+30) EncodeComplex128Slice-8 1.81µs ± 0% 1.75µs ± 1% -3.23% (p=0.000 n=28+30) EncodeFloat64Slice-8 900ns ± 1% 847ns ± 0% -5.91% (p=0.000 n=29+28) EncodeInt32Slice-8 1.02µs ± 0% 0.90µs ± 0% -11.82% (p=0.000 n=28+26) EncodeStringSlice-8 1.16µs ± 1% 1.04µs ± 1% -10.20% (p=0.000 n=29+26) EncodeInterfaceSlice-8 28.7µs ± 3% 29.2µs ± 6% ~ (p=0.067 n=29+30) DecodeComplex128Slice-8 7.98µs ± 1% 7.96µs ± 1% -0.27% (p=0.017 n=30+30) DecodeFloat64Slice-8 4.33µs ± 1% 4.34µs ± 1% +0.24% (p=0.022 n=30+29) DecodeInt32Slice-8 4.18µs ± 1% 4.18µs ± 0% ~ (p=0.074 n=30+28) DecodeStringSlice-8 13.2µs ± 1% 13.1µs ± 1% -0.64% (p=0.000 n=28+28) DecodeStringsSlice-8 31.9µs ± 1% 31.8µs ± 1% -0.34% (p=0.001 n=30+30) DecodeBytesSlice-8 8.88µs ± 1% 8.84µs ± 1% -0.48% (p=0.000 n=30+30) DecodeInterfaceSlice-8 64.1µs ± 1% 64.2µs ± 1% ~ (p=0.173 n=30+28) DecodeMap-8 74.3µs ± 0% 74.2µs ± 0% ~ (p=0.131 n=29+30) Fixes #42958 Change-Id: Ie048b8976fb403d8bcc72ac6bde4b33e133e2a47 Reviewed-on: https://go-review.googlesource.com/c/go/+/349931 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2021-10-02cmd/go: remove double parallelism from "go fmt"Daniel Martí
Now that gofmt knows how to format many files in parallel, there's no need for "go fmt" to have its own parallelism. Instead of running "gofmt -l -w $file" in parallel with GOMAXPROCS, simply collect a large list of files and hand it to "gofmt -l -w $files". The benchmark below was obtained via: benchcmd -n 10 FmtGorootCmd go fmt cmd We can see a drastic improvement in system time per call. This makes sense, as we used to fork+exec one gofmt program per file, and now we only do that for every thousand or so files. We also see an increase in peak memory usage and user CPU time. This seems to be because each gofmt process was very short lived before. This meant that there was a limit to the total amount of allocations produced by go/parser and go/printer before the process stopped, and thus the GC probably didn't kick in most of the time. Now that each gofmt process formats hundreds or thousands of files, a lot of those allocations pile up in the same process, making peak-RSS go higher and piling on garbage for the GC to clean up. Finally, note that time/op seems largely unchanged. I did many benchmark runs; some ended up in noise like the one below, and others gave small wall time speed-ups of 3-4%. It seems like we get very little wall time benefit, possibly due to the factors mentioned earlier cancelling each other out. Overall, it seems worthwhile to not let "go fmt" do its own parallelism, to keep the tool simpler to understand and maintain going forward. Plus, the sys-time savings do seem to be the biggest change here. name old time/op new time/op delta FmtGorootCmd 850ms ± 4% 842ms ± 6% ~ (p=0.529 n=10+10) name old user-time/op new user-time/op delta FmtGorootCmd 7.30s ± 4% 7.67s ± 3% +5.07% (p=0.000 n=10+10) name old sys-time/op new sys-time/op delta FmtGorootCmd 1.66s ± 7% 0.43s ±24% -74.08% (p=0.000 n=10+10) name old peak-RSS-bytes new peak-RSS-bytes delta FmtGorootCmd 30.1MB ± 4% 199.4MB ±21% +563.03% (p=0.000 n=10+10) To make use of the already-present "maximum exec arg length limit" constant in cmd/go/internal, move it to cmd/internal. Fixes #43566. Change-Id: If864151d0c851a40bf7138f9864640f15a066d48 Reviewed-on: https://go-review.googlesource.com/c/go/+/353309 Trust: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-09-06cmd/internal/sys: fix placement of loong64 definitionWANG Xuerui
In rebasing the patch series up to CL 339015, the branches were messed up by me, and changes from v3 to v4 of CL 339009 was lost. Fix the ordering to restore alphabetical order per original review. Change-Id: I8e57c96e996c4f962cab684a9d305a8dbdeea43b Reviewed-on: https://go-review.googlesource.com/c/go/+/347731 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Meng Zhuo <mzh@golangcn.org>
2021-09-06cmd/internal/sys: declare loong64 archWANG Xuerui
Updates #46229 Change-Id: Icb736f2440443e9245872b091d13e5bdfb6cb01a Reviewed-on: https://go-review.googlesource.com/c/go/+/339009 Reviewed-by: Meng Zhuo <mzh@golangcn.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Trust: Meng Zhuo <mzh@golangcn.org> Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Meng Zhuo <mzh@golangcn.org> TryBot-Result: Go Bot <gobot@golang.org>
2021-06-14cmd/internal/sys: mark windows/arm64 as c-shared-capableJason A. Donenfeld
The platform supports c-shared now, so flip this on. I've given this a small smoke test using [1], and it was able to pass packets and generally function well. Since [1] uses quite a bit of Go functionality under the hood, I think it's a decent test that a lot of things that should be working are working. So this commit enables it. [1] https://git.zx2c4.com/wireguard-windows/about/embeddable-dll-service/README.md Updates #46502. Change-Id: I5c771d033bd20e5ce472c315d7c207bbc1020b4a Reviewed-on: https://go-review.googlesource.com/c/go/+/326310 Trust: Jason A. Donenfeld <Jason@zx2c4.com> Trust: Alex Brainman <alex.brainman@gmail.com> Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-05-24cmd/compile: ensure equal functions don't do unaligned loadsKeith Randall
On architectures which don't support unaligned loads, make sure we don't generate code that requires them. Generated hash functions also matter in this respect, but they all look ok. Update #37716 Fixes #46283 Change-Id: I6197fdfe04da4428092c99bd871d93738789e16b Reviewed-on: https://go-review.googlesource.com/c/go/+/322151 Trust: Keith Randall <khr@golang.org> Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: eric fang <eric.fang@arm.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-03-11cmd/dist: refactor test constraints for misc/cgo/testsantizersfanzha02
Currently, the cmd/dist runs test cases in misc/cgo/testsantizers only when memeory sanitizer is supported, but the tsan tests in misc/cgo/testsanitizers do not require support for -msan option, which makes tsan tests can not be run on some unsupported -msan option platforms. Therefore, this patch moves the test constraints from cmd/dist to msan_test.go, so that the tsan tests in misc/cgo/testsanitizers can be run on any system where the C compiler supports -fsanitize=thread option. Change-Id: I779c92eedd0270050f1a0b1a69ecce50c3712bc9 Reviewed-on: https://go-review.googlesource.com/c/go/+/297774 Trust: fannie zhang <Fannie.Zhang@arm.com> Run-TryBot: fannie zhang <Fannie.Zhang@arm.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-23runtime: enable race detector on openbsd/amd64Joel Sing
Now that this commit[1] has landed in LLVM the .syso file can be generated for OpenBSD. With the changes to src/runtime running the sample race[2] detects the data race as expected. Based on golang/go#39464 (https://go-review.googlesource.com/c/go/+/237057) from Aaron Bieber <deftly@gmail.com>, however the race_openbsd_amd64.syso file has been built on OpenBSD 6.4 and necessary changes added to race.bash. [1] https://github.com/llvm/llvm-project/commit/fcf6ae2f070eba73074b6ec8d8281e54d29dbeeb [2] https://golang.org/doc/articles/race_detector.html Change-Id: Ic2479ccfa91d6b2cb4585346a11d813d96450f68 Reviewed-on: https://go-review.googlesource.com/c/go/+/275892 Trust: Joel Sing <joel@sing.id.au> Run-TryBot: Joel Sing <joel@sing.id.au> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2020-11-04cmd/compile,cmd/dist,cmd/go: enable pie buildmode for linux/riscv64Joel Sing
Enable pie as a buildmode for linux/riscv64, along with associated tests. Change-Id: I3fb0234d534dbeb96aa6cee6ae872304fbe02cf4 Reviewed-on: https://go-review.googlesource.com/c/go/+/267317 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2020-10-30runtime, cmd: support race detector on darwin/arm64Cherry Zhang
https://reviews.llvm.org/D90435 is the counterpart in LLVM TSAN. race_linux_arm64.syso is built with LLVM commit 00da38ce2d36c07f12c287dc515d37bb7bc410e9 on a macOS/ARM64 machine. (It is not built on a builder with golang.org/x/build/cmd/racebuild as we don't have darwin/arm64 builder for now.) Updates #38485. Change-Id: I391efdacd9480197e308370bfccd05777deb4aee Reviewed-on: https://go-review.googlesource.com/c/go/+/266373 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-29Revert "cmd/compile,cmd/internal/sys: enable additional build modes on ↵Joel Sing
linux/riscv64" This reverts CL 263457. It turns out that this still missed changes to cmd/link/internal/ld/config.go and some of these build modes also fail once cgo is enabled. Disable again for now. Change-Id: Iaf40d44e1551afd5b040d357f04af134f55a64a9 Reviewed-on: https://go-review.googlesource.com/c/go/+/266317 Reviewed-by: Cherry Zhang <cherryyz@google.com> Trust: Joel Sing <joel@sing.id.au>
2020-10-28cmd/link: enable internal linking by default on darwin/arm64Cherry Zhang
With previous CLs, internal linking without cgo should work well. Enable it by default. And stop always requiring cgo. Enable tests that were previously disabled due to the lack of internal linking. Updates #38485. Change-Id: I45125b9c263fd21d6847aa6b14ecaea3a2989b29 Reviewed-on: https://go-review.googlesource.com/c/go/+/265121 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2020-10-27cmd/compile,cmd/internal/sys: enable additional build modes on linux/riscv64Joel Sing
Enable c-archive, c-shared, shared and pie build modes for linux/riscv64. Change-Id: I15a8a51b84dbbb82a5b6592aec84a7f09f0cc37f Reviewed-on: https://go-review.googlesource.com/c/go/+/263457 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2020-10-22all: add GOOS=ios GOARCH=amd64 target for the ios simulatorElias Naur
The Go toolchain has supported the simulator for years, but always in buildmode=c-archive which is intrinsically externally linked and PIE. This CL moves that support from GOOS=darwin GOARCH=amd64 -tags=ios to just GOOS=ios GOARCH=amd64 to match the change for iOS devices. This change also forces external linking and defaults to buildmode=pie to support Go binaries in the default buildmode to run on the simulator. CL 255257 added the necessary support to the exec wrapper. Updates #38485 Fixes #42100 Change-Id: I6e6ee0e8d421be53b31e3d403880e5b9b880d031 Reviewed-on: https://go-review.googlesource.com/c/go/+/263798 Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> Trust: Elias Naur <mail@eliasnaur.com>
2020-10-14cmd/link: support internal linking on darwin/arm64Cherry Zhang
Add support of internal linking on darwin/arm64 (macOS). Still incomplete. Pure Go binaries work. Cgo doesn't. TLS is not set up when cgo is not used (as before) (so asynchronous preemption is not enabled). Internal linking is not enabled by default but can be requested via -ldflags=-linkmode=internal. Updates #38485. Change-Id: I1e0c81b6028edcb1ac26dcdafeb9bb3f788cf732 Reviewed-on: https://go-review.googlesource.com/c/go/+/261643 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2020-10-14cmd/link: support PIE internal linking on darwin/amd64Cherry Zhang
This CL adds support of PIE internal linking on darwin/amd64. This is also preparation for supporting internal linking on darwin/arm64 (macOS), which requires PIE for everything. Updates #38485. Change-Id: I2ed58583dcc102f5e0521982491fc7ba6f2754ed Reviewed-on: https://go-review.googlesource.com/c/go/+/261642 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2020-10-12cmd/go: don't always link in cgo for PIECherry Zhang
Internal linking for PIE is now supported and enabled by default on some platforms, for which cgo is not needed. Don't always bring in cgo. Change-Id: I043ed436f0e6a3acbcc53ec543f06e193d614b36 Reviewed-on: https://go-review.googlesource.com/c/go/+/261498 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-09all: enable more tests on macOS/ARM64Cherry Zhang
On macOS, we can do "go build", can exec, and have the source tree available, so we can enable more tests. Skip ones that don't work. Most of them are due to that it requires external linking (for now) and some tests don't work with external linking (e.g. runtime deadlock detection). For them, helper functions CanInternalLink/MustInternalLink are introduced. I still want to have internal linking implemented, but it is still a good idea to identify which tests don't work with external linking. Updates #38485. Change-Id: I6b14697573cf3f371daf54b9ddd792acf232f2f2 Reviewed-on: https://go-review.googlesource.com/c/go/+/260719 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-10-06cmd/link: support C-shared buildmode on macOS/ARM64Cherry Zhang
It just works, after the plugin work. Updates #38485. Change-Id: I55aa11b380a33a729fccb731b77f48bc7d0dea2e Reviewed-on: https://go-review.googlesource.com/c/go/+/259443 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2020-10-06cmd/link: support PIE on macOS/ARM64Cherry Zhang
On macOS/ARM64 everything must be PIE, and we already build PIE in exe buildmode. Support PIE buildmode as well. Updates #38485. Change-Id: I10b68c2f6eb77714e31c26116c61a0e28bf9a358 Reviewed-on: https://go-review.googlesource.com/c/go/+/259442 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2020-10-06cmd/link: support plugin on macOS/ARM64Cherry Zhang
Updates #38485. Change-Id: I8295f7fad55b1f9701162f9d2902b3499137c64d Reviewed-on: https://go-review.googlesource.com/c/go/+/259441 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2020-09-23all: add GOOS=iosCherry Zhang
Introduce GOOS=ios for iOS systems. GOOS=ios matches "darwin" build tag, like GOOS=android matches "linux" and GOOS=illumos matches "solaris". Only ios/arm64 is supported (ios/amd64 is not). GOOS=ios and GOOS=darwin remain essentially the same at this point. They will diverge at later time, to differentiate macOS and iOS. Uses of GOOS=="darwin" are changed to (GOOS=="darwin" || GOOS=="ios"), except if it clearly means macOS (e.g. GOOS=="darwin" && GOARCH=="amd64"), it remains GOOS=="darwin". Updates #38485. Change-Id: I4faacdc1008f42434599efb3c3ad90763a83b67c Reviewed-on: https://go-review.googlesource.com/c/go/+/254740 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2020-04-08all: remove scattered remnants of darwin/386Austin Clements
This removes all conditions and conditional code (that I could find) that depended on darwin/386. Fixes #37610. Change-Id: I630d9ea13613fb7c0bcdb981e8367facff250ba0 Reviewed-on: https://go-review.googlesource.com/c/go/+/227582 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-08all: remove scattered remnants of darwin/armAustin Clements
This removes all conditions and conditional code (that I could find) that depended on darwin/arm. Fixes #35439 (since that only happened on darwin/arm) Fixes #37611. Change-Id: Ia4c32a5a4368ed75231075832b0b5bfb1ad11986 Reviewed-on: https://go-review.googlesource.com/c/go/+/227198 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-01cmd/go, cmd/link: implement -buildmode=pie on windowsAlex Brainman
This CL implements windows version of -buildmode=pie code in both cmd/go and cmd/link. Windows executables built with -buildmode=pie set (unlike the one built with -buildmode=exe) will have extra .reloc PE section, and will have no IMAGE_FILE_RELOCS_STRIPPED flag set. They will also have IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE flag set, and IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA flag set for windows/amd64. Both cgo and non-cgo versions are implemented. And TestBuildmodePIE is extended to test both cgo and non-cgo versions on windows and linux. This CL used some code from CLs 152759 and 203602. RELNOTE=yes Fixes #27144 Updates #35192 Change-Id: I1249e4ffbd79bd4277efefb56db321c390c0f76f Reviewed-on: https://go-review.googlesource.com/c/go/+/214397 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-02-26cmd/link: default to internal linking for android/arm64Elias Naur
The bootstrapping process (make.bash) on all other platforms use internal linking. This change brings android/arm64 in line, fixing the scary warning on our self-hosted Corellium builders: warning: unable to find runtime/cgo.a The linkmode default is changed to internal for all Android programs, but in practice that won't matter outside our builders: using Go with Android apps requires buildmode=c-shared which uses linkmode external. Fixes #31343 Updates #31819 Change-Id: I3b3ada5ed69a7989e6d8e5960bbebf5e1c22aada Reviewed-on: https://go-review.googlesource.com/c/go/+/207299 Run-TryBot: Elias Naur <mail@eliasnaur.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-11-22cmd/go/internal/work: reduce code duplication in buildModeInit by using ↵Bryan C. Mills
sys.BuildModeSupported Updates #34347 Change-Id: I6ea02d4737999bf24f5335508b5ed2352b498122 Reviewed-on: https://go-review.googlesource.com/c/go/+/208458 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-11-22cmd/go: add a 'buildmode' condition for script testsBryan C. Mills
In CL 208233 I am fixing a panic that occurs only with a specific build mode. I want that test to run on all platforms that support that build mode, but the logic for determining support is somewhat involved. For now, I am duplicating that logic into the cmd/internal/sys package, which already reports platform support for other build flags. We can refactor cmd/go/internal/work to use the extracted function in a followup CL. Updates #35759 Change-Id: Ibbaedde4d1e8f683c650beedd10849bc27e7a6e7 Reviewed-on: https://go-review.googlesource.com/c/go/+/208457 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>