diff options
author | David Chase <drchase@google.com> | 2019-11-08 16:11:29 -0500 |
---|---|---|
committer | Michael Knyszek <mknyszek@google.com> | 2019-11-08 23:22:06 +0000 |
commit | 11da2b227a71c9c041320e22843047ad9b0ab1a8 (patch) | |
tree | 4c19cff0feded160770e2896461e0bbb82c3d56f /src/runtime/mpagecache.go | |
parent | 42db1da8e9def3490ed904594ad80e1090bff654 (diff) | |
download | go-11da2b227a71c9c041320e22843047ad9b0ab1a8.tar.gz go-11da2b227a71c9c041320e22843047ad9b0ab1a8.zip |
runtime: copy some functions from math/bits to runtime/internal/sys
CL 201765 activated calls from the runtime to functions in math/bits.
When coverage and race detection were simultaneously enabled,
this caused a crash when the covered+race-checked code in
math/bits was called from the runtime before there was even a P.
PS Win for gdlv in helping sort this out.
TODO - next CL intrinsifies the new functions in
runtime/internal/sys
TODO/Would-be-nice - Ctz64 and TrailingZeros64 are the same
function; 386.s is intrinsified; clean all that up.
Fixes #35461.
Updates #35112.
Change-Id: I750a54dba493130ad3e68a06530ede7687d41e1d
Reviewed-on: https://go-review.googlesource.com/c/go/+/206199
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/mpagecache.go')
-rw-r--r-- | src/runtime/mpagecache.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/runtime/mpagecache.go b/src/runtime/mpagecache.go index 6581d40801..ec2f2d13ed 100644 --- a/src/runtime/mpagecache.go +++ b/src/runtime/mpagecache.go @@ -5,7 +5,7 @@ package runtime import ( - "math/bits" + "runtime/internal/sys" "unsafe" ) @@ -40,7 +40,7 @@ func (c *pageCache) alloc(npages uintptr) (uintptr, uintptr) { return 0, 0 } if npages == 1 { - i := uintptr(bits.TrailingZeros64(c.cache)) + i := uintptr(sys.TrailingZeros64(c.cache)) scav := (c.scav >> i) & 1 c.cache &^= 1 << i // set bit to mark in-use c.scav &^= 1 << i // clear bit to mark unscavenged @@ -61,7 +61,7 @@ func (c *pageCache) allocN(npages uintptr) (uintptr, uintptr) { return 0, 0 } mask := ((uint64(1) << npages) - 1) << i - scav := bits.OnesCount64(c.scav & mask) + scav := sys.OnesCount64(c.scav & mask) c.cache &^= mask // mark in-use bits c.scav &^= mask // clear scavenged bits return c.base + uintptr(i*pageSize), uintptr(scav) * pageSize |