mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-16 10:43:29 +00:00
runtime: allow custom-gc SetFinalizer and clarify KeepAlive
This commit is contained in:
@@ -687,3 +687,7 @@ func ReadMemStats(m *MemStats) {
|
|||||||
m.Frees = gcFrees
|
m.Frees = gcFrees
|
||||||
m.Sys = uint64(heapEnd - heapStart)
|
m.Sys = uint64(heapEnd - heapStart)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SetFinalizer(obj interface{}, finalizer interface{}) {
|
||||||
|
// Unimplemented.
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ package runtime
|
|||||||
// - func free(ptr unsafe.Pointer)
|
// - func free(ptr unsafe.Pointer)
|
||||||
// - func markRoots(start, end uintptr)
|
// - func markRoots(start, end uintptr)
|
||||||
// - func GC()
|
// - func GC()
|
||||||
|
// - func SetFinalizer(obj interface{}, finalizer interface{})
|
||||||
// - func ReadMemStats(ms *runtime.MemStats)
|
// - func ReadMemStats(ms *runtime.MemStats)
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@@ -51,6 +52,9 @@ func markRoots(start, end uintptr)
|
|||||||
// GC is called to explicitly run garbage collection.
|
// GC is called to explicitly run garbage collection.
|
||||||
func GC()
|
func GC()
|
||||||
|
|
||||||
|
// SetFinalizer registers a finalizer.
|
||||||
|
func SetFinalizer(obj interface{}, finalizer interface{})
|
||||||
|
|
||||||
// ReadMemStats populates m with memory statistics.
|
// ReadMemStats populates m with memory statistics.
|
||||||
func ReadMemStats(ms *MemStats)
|
func ReadMemStats(ms *MemStats)
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,10 @@ func GC() {
|
|||||||
// No-op.
|
// No-op.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SetFinalizer(obj interface{}, finalizer interface{}) {
|
||||||
|
// No-op.
|
||||||
|
}
|
||||||
|
|
||||||
func initHeap() {
|
func initHeap() {
|
||||||
// preinit() may have moved heapStart; reset heapptr
|
// preinit() may have moved heapStart; reset heapptr
|
||||||
heapptr = heapStart
|
heapptr = heapStart
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ func GC() {
|
|||||||
// Unimplemented.
|
// Unimplemented.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SetFinalizer(obj interface{}, finalizer interface{}) {
|
||||||
|
// Unimplemented.
|
||||||
|
}
|
||||||
|
|
||||||
func initHeap() {
|
func initHeap() {
|
||||||
// Nothing to initialize.
|
// Nothing to initialize.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,11 +89,10 @@ func UnlockOSThread() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func KeepAlive(x interface{}) {
|
func KeepAlive(x interface{}) {
|
||||||
// Unimplemented. Only required with SetFinalizer().
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetFinalizer(obj interface{}, finalizer interface{}) {
|
|
||||||
// Unimplemented.
|
// Unimplemented.
|
||||||
|
// TODO: This function needs to be implemented in a way that LLVM doesn't optimize away the x
|
||||||
|
// parameter. This will likely need either a volatile operation or calling an assembly stub
|
||||||
|
// that simply returns.
|
||||||
}
|
}
|
||||||
|
|
||||||
var godebugUpdate func(string, string)
|
var godebugUpdate func(string, string)
|
||||||
|
|||||||
Reference in New Issue
Block a user