diff options
author | Josh Bleecher Snyder <josharian@gmail.com> | 2018-04-01 11:01:36 -0700 |
---|---|---|
committer | Josh Bleecher Snyder <josharian@gmail.com> | 2018-04-29 05:24:44 +0000 |
commit | 5af0b28a7308ed40af8e315b2a50ac6401bb24c9 (patch) | |
tree | 1f2b11fd6f56663636d16a96cf0692f54641d9a7 /src/runtime/mbitmap.go | |
parent | 13cd0061390af0621516ec22b1a3987712b4da3b (diff) | |
download | go-5af0b28a7308ed40af8e315b2a50ac6401bb24c9.tar.gz go-5af0b28a7308ed40af8e315b2a50ac6401bb24c9.zip |
runtime: iterate over set bits in adjustpointers
There are several things combined in this change.
First, eliminate the gobitvector type in favor
of adding a ptrbit method to bitvector.
In non-performance-critical code, use that method.
In performance critical code, though, load the bitvector data
one byte at a time and iterate only over set bits.
To support that, add and use sys.Ctz8.
name old time/op new time/op delta
StackCopyPtr-8 81.8ms ± 5% 78.9ms ± 3% -3.58% (p=0.000 n=97+96)
StackCopy-8 65.9ms ± 3% 62.8ms ± 3% -4.67% (p=0.000 n=96+92)
StackCopyNoCache-8 105ms ± 3% 102ms ± 3% -3.38% (p=0.000 n=96+95)
Change-Id: I00b80f45612708bd440b1a411a57fa6dfa24aa74
Reviewed-on: https://go-review.googlesource.com/109716
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/mbitmap.go')
-rw-r--r-- | src/runtime/mbitmap.go | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/runtime/mbitmap.go b/src/runtime/mbitmap.go index 69bd0b502b..5c7d812403 100644 --- a/src/runtime/mbitmap.go +++ b/src/runtime/mbitmap.go @@ -2021,9 +2021,8 @@ func getgcmask(ep interface{}) (mask []byte) { n := (*ptrtype)(unsafe.Pointer(t)).elem.size mask = make([]byte, n/sys.PtrSize) for i := uintptr(0); i < n; i += sys.PtrSize { - bitmap := bv.bytedata off := (uintptr(p) + i - frame.varp + size) / sys.PtrSize - mask[i/sys.PtrSize] = (*addb(bitmap, off/8) >> (off % 8)) & 1 + mask[i/sys.PtrSize] = bv.ptrbit(off) } } return |