runtime: require explicit GC layouts

This commit is contained in:
Jake Bailey
2026-08-07 10:21:19 -07:00
committed by Ron Evans
parent 1a4cb2032e
commit a7360d5ad3
28 changed files with 279 additions and 108 deletions
+3 -2
View File
@@ -31,6 +31,7 @@ package runtime
// Moss.
import (
"internal/gclayout"
"internal/reflectlite"
"internal/task"
"runtime/interrupt"
@@ -501,7 +502,7 @@ func alloc(size uintptr, layout unsafe.Pointer) unsafe.Pointer {
func realloc(ptr unsafe.Pointer, size uintptr) unsafe.Pointer {
if ptr == nil {
return alloc(size, nil)
return alloc(size, gclayout.NoPtrs.AsPtr())
}
// Find the first block of the original allocation.
@@ -526,7 +527,7 @@ func realloc(ptr unsafe.Pointer, size uintptr) unsafe.Pointer {
}
// Create a new allocation and copy the old data.
newAlloc := alloc(size, nil)
newAlloc := alloc(size, gclayout.NoPtrs.AsPtr())
memcpy(newAlloc, ptr, oldSize)
free(ptr)