mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 02:27:48 +00:00
runtime: add some more asserts to the GC
This commit is contained in:
committed by
Ron Evans
parent
6917faabf5
commit
3bf2487dc5
@@ -93,6 +93,9 @@ type gcBlock uintptr
|
||||
// blockFromAddr returns a block given an address somewhere in the heap (which
|
||||
// might not be heap-aligned).
|
||||
func blockFromAddr(addr uintptr) gcBlock {
|
||||
if gcAsserts && (addr < poolStart || addr >= heapEnd) {
|
||||
runtimePanic("gc: trying to get block from invalid address")
|
||||
}
|
||||
return gcBlock((addr - poolStart) / bytesPerBlock)
|
||||
}
|
||||
|
||||
@@ -113,6 +116,11 @@ func (b gcBlock) findHead() gcBlock {
|
||||
for b.state() == blockStateTail {
|
||||
b--
|
||||
}
|
||||
if gcAsserts {
|
||||
if b.state() != blockStateHead && b.state() != blockStateMark {
|
||||
runtimePanic("gc: found tail without head")
|
||||
}
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user