mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-10 14:03:39 +00:00
runtime: unify GC interface
Make sure every to-be-implemented GC can use the same interface. As a result, a 1MB chunk of RAM is allocated on Unix systems on init instead of allocating on demand.
This commit is contained in:
@@ -8,10 +8,14 @@ import (
|
||||
|
||||
func _Cfunc_putchar(c int) int
|
||||
func _Cfunc_usleep(usec uint) int
|
||||
func _Cfunc_calloc(nmemb, size uintptr) unsafe.Pointer
|
||||
func _Cfunc_malloc(size uintptr) unsafe.Pointer
|
||||
func _Cfunc_abort()
|
||||
func _Cfunc_clock_gettime(clk_id uint, ts *timespec)
|
||||
|
||||
const heapSize = 1 * 1024 * 1024 // 1MB to start
|
||||
|
||||
var heapStart = uintptr(_Cfunc_malloc(heapSize))
|
||||
|
||||
type timeUnit int64
|
||||
|
||||
const tickMicros = 1
|
||||
@@ -62,27 +66,3 @@ func abort() {
|
||||
// panic() exits with exit code 2.
|
||||
_Cfunc_abort()
|
||||
}
|
||||
|
||||
func alloc(size uintptr) unsafe.Pointer {
|
||||
buf := _Cfunc_calloc(1, size)
|
||||
if buf == nil {
|
||||
runtimePanic("cannot allocate memory")
|
||||
}
|
||||
return buf
|
||||
}
|
||||
|
||||
func free(ptr unsafe.Pointer) {
|
||||
//C.free(ptr) // TODO
|
||||
}
|
||||
|
||||
func GC() {
|
||||
// Unimplemented.
|
||||
}
|
||||
|
||||
func KeepAlive(x interface{}) {
|
||||
// Unimplemented. Only required with SetFinalizer().
|
||||
}
|
||||
|
||||
func SetFinalizer(obj interface{}, finalizer interface{}) {
|
||||
// Unimplemented.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user