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:
Ayke van Laethem
2018-11-17 15:30:38 +01:00
parent ef93001ab8
commit 9181f2d4ce
5 changed files with 27 additions and 4 deletions
+7 -1
View File
@@ -14,7 +14,13 @@ const TargetBits = 32
//go:extern _heap_start
var heapStartSymbol unsafe.Pointer
var heapStart = uintptr(unsafe.Pointer(&heapStartSymbol))
//go:extern _heap_end
var heapEndSymbol unsafe.Pointer
var (
heapStart = uintptr(unsafe.Pointer(&heapStartSymbol))
heapEnd = uintptr(unsafe.Pointer(&heapEndSymbol))
)
// Align on word boundary.
func align(ptr uintptr) uintptr {