mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 02:57:46 +00:00
655075e5e0
This implements the block-based GC as a partially precise GC. This means that for most heap allocations it is known which words contain a pointer and which don't. This should in theory make the GC faster (because it can skip non-pointer object) and have fewer false positives in a GC cycle. It does however use a bit more RAM to store the layout of each object. Right now this GC seems to be slower than the conservative GC, but should be less likely to run out of memory as a result of false positives.
30 lines
818 B
Go
30 lines
818 B
Go
//go:build gc.conservative
|
|
|
|
// This implements the block-based heap as a fully conservative GC. No tracking
|
|
// of pointers is done, every word in an object is considered live if it looks
|
|
// like a pointer.
|
|
|
|
package runtime
|
|
|
|
const preciseHeap = false
|
|
|
|
type gcObjectScanner struct {
|
|
}
|
|
|
|
func newGCObjectScanner(block gcBlock) gcObjectScanner {
|
|
return gcObjectScanner{}
|
|
}
|
|
|
|
func (scanner *gcObjectScanner) pointerFree() bool {
|
|
// We don't know whether this object contains pointers, so conservatively
|
|
// return false.
|
|
return false
|
|
}
|
|
|
|
// nextIsPointer returns whether this could be a pointer. Because the GC is
|
|
// conservative, we can't do much more than check whether the object lies
|
|
// somewhere in the heap.
|
|
func (scanner gcObjectScanner) nextIsPointer(ptr, parent, addrOfWord uintptr) bool {
|
|
return isOnHeap(ptr)
|
|
}
|