diff options
Diffstat (limited to 'src/runtime/mbitmap_allocheaders.go')
| -rw-r--r-- | src/runtime/mbitmap_allocheaders.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/runtime/mbitmap_allocheaders.go b/src/runtime/mbitmap_allocheaders.go index 03cec5ffcc..33535a515a 100644 --- a/src/runtime/mbitmap_allocheaders.go +++ b/src/runtime/mbitmap_allocheaders.go @@ -48,9 +48,9 @@ // is zeroed, so the GC just observes nil pointers. // Note that this "tiled" bitmap isn't stored anywhere; it is generated on-the-fly. // -// For objects without their own span, the type metadata is stored in the last -// word of the allocation slot. For objects with their own span, the type metadata -// is stored in the mspan. +// For objects without their own span, the type metadata is stored in the first +// word before the object at the beginning of the allocation slot. For objects +// with their own span, the type metadata is stored in the mspan. // // The bitmap for small unallocated objects in scannable spans is not maintained // (can be junk). @@ -167,7 +167,8 @@ func (span *mspan) typePointersOf(addr, size uintptr) typePointers { } // typePointersOfUnchecked is like typePointersOf, but assumes addr is the base -// pointer of an object in span. It returns an iterator that generates all pointers +// of an allocation slot in a span (the start of the object if no header, the +// header otherwise). It returns an iterator that generates all pointers // in the range [addr, addr+span.elemsize). // // nosplit because it is used during write barriers and must not be preempted. @@ -192,8 +193,9 @@ func (span *mspan) typePointersOfUnchecked(addr uintptr) typePointers { // All of these objects have a header. var typ *_type if spc.sizeclass() != 0 { - // Pull the allocation header from the last word of the object. - typ = *(**_type)(unsafe.Pointer(addr + span.elemsize - mallocHeaderSize)) + // Pull the allocation header from the first word of the object. + typ = *(**_type)(unsafe.Pointer(addr)) + addr += mallocHeaderSize } else { typ = span.largeType } |
