github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/runtime/gc_conservative.go (about)

     1  //go:build gc.conservative
     2  
     3  // This implements the block-based heap as a fully conservative GC. No tracking
     4  // of pointers is done, every word in an object is considered live if it looks
     5  // like a pointer.
     6  
     7  package runtime
     8  
     9  const preciseHeap = false
    10  
    11  type gcObjectScanner struct {
    12  }
    13  
    14  func newGCObjectScanner(block gcBlock) gcObjectScanner {
    15  	return gcObjectScanner{}
    16  }
    17  
    18  func (scanner *gcObjectScanner) pointerFree() bool {
    19  	// We don't know whether this object contains pointers, so conservatively
    20  	// return false.
    21  	return false
    22  }
    23  
    24  // nextIsPointer returns whether this could be a pointer. Because the GC is
    25  // conservative, we can't do much more than check whether the object lies
    26  // somewhere in the heap.
    27  func (scanner gcObjectScanner) nextIsPointer(ptr, parent, addrOfWord uintptr) bool {
    28  	return isOnHeap(ptr)
    29  }