diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index e94c879184..b041d4c1fc 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -676,9 +676,7 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer { } var scanSize uintptr - if noscan { - heapBitsSetTypeNoScan(uintptr(x)) - } else { + if !noscan { // If allocating a defer+arg block, now that we've picked a malloc size // large enough to hold everything, cut the "asked for" size down to // just the defer header, so that the GC bitmap will record the arg block diff --git a/src/runtime/mbitmap.go b/src/runtime/mbitmap.go index 26e511d495..e23c5cf6c9 100644 --- a/src/runtime/mbitmap.go +++ b/src/runtime/mbitmap.go @@ -45,6 +45,11 @@ // not checkmarked, and is the dead encoding. // These properties must be preserved when modifying the encoding. // +// The bitmap for noscan spans is not maintained. Code must ensure +// that an object is scannable before consulting its bitmap by +// checking either the noscan bit in the span or by consulting its +// type's information. +// // Checkmarks // // In a concurrent garbage collector, one worries about failing to mark @@ -1363,13 +1368,6 @@ Phase4: } } -// heapBitsSetTypeNoScan marks x as noscan by setting the first word -// of x in the heap bitmap to scalar/dead. -func heapBitsSetTypeNoScan(x uintptr) { - h := heapBitsForAddr(uintptr(x)) - *h.bitp &^= (bitPointer | bitMarked) << h.shift -} - var debugPtrmask struct { lock mutex data *byte