mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 02:27:48 +00:00
4643401a1d
Instead of markGlobals calling markRoots unconditionally (which doesn't
make sense for -gc=none and -gc=leaking), provide markRoots as a
callback function.
This is in preparation for -gc=boehm, where the previous design is even
more awkward and a callback makes far more sense.
I've tested the size impact using `make smoketest XTENSA=0`. There is
none, except for two cases:
* One with `-opt=0` so const-propagation for the callback didn't take
place.
* One other on AVR, I don't know why but as it's only 16 bytes in a
very specific case I'm going to assume it's just a random change in
compiler output that caused a size difference.
40 lines
861 B
Go
40 lines
861 B
Go
//go:build gc.none
|
|
|
|
package runtime
|
|
|
|
// This GC strategy provides no memory allocation at all. It can be useful to
|
|
// detect where in a program memory is allocated (via linker errors) or for
|
|
// targets that have far too little RAM even for the leaking memory allocator.
|
|
|
|
import (
|
|
"unsafe"
|
|
)
|
|
|
|
var gcTotalAlloc uint64 // for runtime.MemStats
|
|
var gcMallocs uint64
|
|
var gcFrees uint64
|
|
|
|
func alloc(size uintptr, layout unsafe.Pointer) unsafe.Pointer
|
|
|
|
func realloc(ptr unsafe.Pointer, size uintptr) unsafe.Pointer
|
|
|
|
func free(ptr unsafe.Pointer) {
|
|
// Nothing to free when nothing gets allocated.
|
|
}
|
|
|
|
func GC() {
|
|
// Unimplemented.
|
|
}
|
|
|
|
func SetFinalizer(obj interface{}, finalizer interface{}) {
|
|
// Unimplemented.
|
|
}
|
|
|
|
func initHeap() {
|
|
// Nothing to initialize.
|
|
}
|
|
|
|
func setHeapEnd(newHeapEnd uintptr) {
|
|
// Nothing to do here, this function is never actually called.
|
|
}
|