all: make WebAssembly initial linear memory size configurable

When the target supports it, allow the (initial) heap size to be
configured. Currently only supported in WebAssembly.

This also changes the default heap size of WebAssembly from 64kB to 1MB.
This commit is contained in:
Ayke van Laethem
2019-07-07 19:43:46 +02:00
committed by Ron Evans
parent 152caa3b0a
commit d627208c48
2 changed files with 44 additions and 2 deletions
+4 -1
View File
@@ -14,9 +14,12 @@ const TargetBits = 32
//go:extern __heap_base
var heapStartSymbol unsafe.Pointer
//go:export llvm.wasm.memory.size.i32
func wasm_memory_size(index int32) int32
var (
heapStart = uintptr(unsafe.Pointer(&heapStartSymbol))
heapEnd = (heapStart + wasmPageSize - 1) &^ (wasmPageSize - 1) // conservative guess: one page of heap memory
heapEnd = uintptr(wasm_memory_size(0) * wasmPageSize)
)
const wasmPageSize = 64 * 1024