diff options
| author | Josh Bleecher Snyder <josharian@gmail.com> | 2020-01-31 21:01:55 -0800 |
|---|---|---|
| committer | Josh Bleecher Snyder <josharian@gmail.com> | 2020-04-08 22:19:53 +0000 |
| commit | b6feb03b24a75164438c3419c0bc01fef62825a0 (patch) | |
| tree | fca94723ac770660d74137f13b825ebad914449d /src/runtime/os_linux.go | |
| parent | ade0811dc8b7a57091019e148c094c4da9689184 (diff) | |
| download | go-b6feb03b24a75164438c3419c0bc01fef62825a0.tar.xz | |
cmd/compile,runtime: pass only ptr and len to some runtime calls
Some runtime calls accept a slice, but only use ptr and len.
This change modifies most such routines to accept only ptr and len.
After this change, the only runtime calls that accept an unnecessary
cap arg are concatstrings and slicerunetostring.
Neither is particularly common, and both are complicated to modify.
Negligible compiler performance impact. Shrinks binaries a little.
There are only a few regressions; the one I investigated was
due to register allocation fluctuation.
Passes 'go test -race std cmd', modulo #38265 and #38266.
Wow, does that take a long time to run.
Updates #36890
file before after Δ %
compile 19655024 19655152 +128 +0.001%
cover 5244840 5236648 -8192 -0.156%
dist 3662376 3658280 -4096 -0.112%
link 6680056 6675960 -4096 -0.061%
pprof 14789844 14777556 -12288 -0.083%
test2json 2824744 2820648 -4096 -0.145%
trace 11647876 11639684 -8192 -0.070%
vet 8260472 8256376 -4096 -0.050%
total 115163736 115118808 -44928 -0.039%
Change-Id: Idb29fa6a81d6a82bfd3b65740b98cf3275ca0a78
Reviewed-on: https://go-review.googlesource.com/c/go/+/227163
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/os_linux.go')
| -rw-r--r-- | src/runtime/os_linux.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go index d8c1827852..7b95ff2428 100644 --- a/src/runtime/os_linux.go +++ b/src/runtime/os_linux.go @@ -277,13 +277,14 @@ func getHugePageSize() uintptr { if fd < 0 { return 0 } - n := read(fd, noescape(unsafe.Pointer(&numbuf[0])), int32(len(numbuf))) + ptr := noescape(unsafe.Pointer(&numbuf[0])) + n := read(fd, ptr, int32(len(numbuf))) closefd(fd) if n <= 0 { return 0 } - l := n - 1 // remove trailing newline - v, ok := atoi(slicebytetostringtmp(numbuf[:l])) + n-- // remove trailing newline + v, ok := atoi(slicebytetostringtmp((*byte)(ptr), int(n))) if !ok || v < 0 { v = 0 } |
