mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 19:17:47 +00:00
26ac03a3f6
Loop over valid pointer locations in heap objects instead of checking if each location is valid. The conservative scanning code is now shared between markRoots and the heap scan. This also removes the ending alignment requirement from markRoots, since the new scan* functions do not require an aligned length. This requirement was occasionally violated by the linux global marking code. This saves some code space and has negligible impact on performance.
31 lines
866 B
Go
31 lines
866 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
|
|
|
|
import "unsafe"
|
|
|
|
// parseGCLayout stores the layout information passed to alloc into a gcLayout value.
|
|
// The conservative GC discards this information.
|
|
func parseGCLayout(layout unsafe.Pointer) gcLayout {
|
|
return gcLayout{}
|
|
}
|
|
|
|
// gcLayout tracks pointer locations in a heap object.
|
|
// The conservative GC treats all locations as potential pointers, so this doesn't need to store anything.
|
|
type gcLayout struct {
|
|
}
|
|
|
|
func (l gcLayout) pointerFree() bool {
|
|
// We don't know whether this object contains pointers, so conservatively
|
|
// return false.
|
|
return false
|
|
}
|
|
|
|
func (l gcLayout) scan(start, len uintptr) {
|
|
scanConservative(start, len)
|
|
}
|