github.com/aykevl/tinygo@v0.5.0/src/runtime/arch_wasm.go (about)

     1  // +build wasm
     2  
     3  package runtime
     4  
     5  import (
     6  	"unsafe"
     7  )
     8  
     9  const GOARCH = "wasm"
    10  
    11  // The bitness of the CPU (e.g. 8, 32, 64).
    12  const TargetBits = 32
    13  
    14  //go:extern __heap_base
    15  var heapStartSymbol unsafe.Pointer
    16  
    17  var (
    18  	heapStart = uintptr(unsafe.Pointer(&heapStartSymbol))
    19  	heapEnd   = (heapStart + wasmPageSize - 1) &^ (wasmPageSize - 1) // conservative guess: one page of heap memory
    20  )
    21  
    22  const wasmPageSize = 64 * 1024
    23  
    24  // Align on word boundary.
    25  func align(ptr uintptr) uintptr {
    26  	return (ptr + 3) &^ 3
    27  }