mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-13 15:33:40 +00:00
runtime: add "end of heap" to detect out of memory
This can be used in the future to trigger garbage collection. For now, it provides a more useful error message in case the heap is completely filled up.
This commit is contained in:
@@ -14,7 +14,12 @@ const TargetBits = 32
|
||||
//go:extern __heap_base
|
||||
var heapStartSymbol unsafe.Pointer
|
||||
|
||||
var heapStart = uintptr(unsafe.Pointer(&heapStartSymbol))
|
||||
var (
|
||||
heapStart = uintptr(unsafe.Pointer(&heapStartSymbol))
|
||||
heapEnd = (heapStart + wasmPageSize - 1) & (wasmPageSize - 1) // conservative guess: one page of heap memory
|
||||
)
|
||||
|
||||
const wasmPageSize = 64 * 1024
|
||||
|
||||
// Align on word boundary.
|
||||
func align(ptr uintptr) uintptr {
|
||||
|
||||
Reference in New Issue
Block a user