aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mbitmap.go
diff options
context:
space:
mode:
authorKeith Randall <khr@google.com>2022-08-09 15:44:16 +0000
committerKeith Randall <khr@google.com>2022-08-09 16:09:24 +0000
commite1a8e0e05d4959d0b669cb968482a5dcfe0c95f8 (patch)
tree6bb45c62e9e2b24ddb845abace6472128f8893d2 /src/runtime/mbitmap.go
parent0d9ed0638be1aa5c68c1bef0713c338e206a6656 (diff)
downloadgo-e1a8e0e05d4959d0b669cb968482a5dcfe0c95f8.tar.xz
Revert "runtime: process ptr bitmaps one word at a time"
This reverts commit c3833a55433f4b2981253f64444fe5c3d1bc910a. Reason for revert: Bug somewhere in this code, causing wasm and maybe linux/386 to fail. Change-Id: I05f7cfa467598ca0c2c84fd4f752cc4ef117cc51 Reviewed-on: https://go-review.googlesource.com/c/go/+/422394 Run-TryBot: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime/mbitmap.go')
-rw-r--r--src/runtime/mbitmap.go83
1 files changed, 12 insertions, 71 deletions
diff --git a/src/runtime/mbitmap.go b/src/runtime/mbitmap.go
index d454949926..1c7ae8a68e 100644
--- a/src/runtime/mbitmap.go
+++ b/src/runtime/mbitmap.go
@@ -893,19 +893,6 @@ func (h writeHeapBits) flush(addr, size uintptr) {
}
}
-// Read the bytes starting at the aligned pointer p into a uintptr.
-// Read is little-endian.
-func readUintptr(p *byte) uintptr {
- x := *(*uintptr)(unsafe.Pointer(p))
- if goarch.BigEndian {
- if goarch.PtrSize == 8 {
- return uintptr(sys.Bswap64(uint64(x)))
- }
- return uintptr(sys.Bswap32(uint32(x)))
- }
- return x
-}
-
// heapBitsSetType records that the new allocation [x, x+size)
// holds in [x, x+dataSize) one or more values of type typ.
// (The number of values is given by dataSize / typ.size.)
@@ -930,7 +917,7 @@ func readUintptr(p *byte) uintptr {
// machines, callers must execute a store/store (publication) barrier
// between calling this function and making the object reachable.
func heapBitsSetType(x, size, dataSize uintptr, typ *_type) {
- const doubleCheck = false // slow but helpful; enable to test modifications to this code
+ const doubleCheck = true // slow but helpful; enable to test modifications to this code
if doubleCheck && dataSize%typ.size != 0 {
throw("heapBitsSetType: dataSize not a multiple of typ.size")
@@ -1008,65 +995,19 @@ func heapBitsSetType(x, size, dataSize uintptr, typ *_type) {
// objects with scalar tails, all but the last tail does have to
// be initialized, because there is no way to say "skip forward".
- ptrs := typ.ptrdata / goarch.PtrSize
- if typ.size == dataSize { // Single element
- if ptrs <= ptrBits { // Single small element
- m := readUintptr(typ.gcdata)
- h = h.write(m, ptrs)
- } else { // Single large element
- p := typ.gcdata
- for {
- h = h.write(readUintptr(p), ptrBits)
- p = addb(p, ptrBits/8)
- ptrs -= ptrBits
- if ptrs <= ptrBits {
- break
- }
- }
- m := readUintptr(p)
- h = h.write(m, ptrs)
+ for i := uintptr(0); true; i += typ.size {
+ p := typ.gcdata
+ var j uintptr
+ for j = 0; j+8*goarch.PtrSize < typ.ptrdata; j += 8 * goarch.PtrSize {
+ h = h.write(uintptr(*p), 8)
+ p = add1(p)
}
- } else { // Repeated element
- words := typ.size / goarch.PtrSize // total words, including scalar tail
- if words <= ptrBits { // Repeated small element
- n := dataSize / typ.size
- m := readUintptr(typ.gcdata)
- // Make larger unit to repeat
- for words <= ptrBits/2 {
- if n&1 != 0 {
- h = h.write(m, words)
- }
- n /= 2
- m |= m << words
- ptrs += words
- words *= 2
- if n == 1 {
- break
- }
- }
- for n > 1 {
- h = h.write(m, words)
- n--
- }
- h = h.write(m, ptrs)
- } else { // Repeated large element
- for i := uintptr(0); true; i += typ.size {
- p := typ.gcdata
- j := ptrs
- for j > ptrBits {
- h = h.write(readUintptr(p), ptrBits)
- p = addb(p, ptrBits/8)
- j -= ptrBits
- }
- m := readUintptr(p)
- h = h.write(m, j)
- if i+typ.size == dataSize {
- break // don't need the trailing nonptr bits on the last element.
- }
- // Pad with zeros to the start of the next element.
- h = h.pad(typ.size - typ.ptrdata)
- }
+ h = h.write(uintptr(*p), (typ.ptrdata-j)/goarch.PtrSize)
+ if i+typ.size == dataSize {
+ break // don't need the trailing nonptr bits on the last element.
}
+ // Pad with zeros to the start of the next element.
+ h = h.pad(typ.size - typ.ptrdata)
}
h.flush(x, size)