Requests more memory be allocated to the WASM instance 1.
Takes one operand from the stack, an i32
representing the number of pages to request 1; Each page is defined as 64KiB 2.
Returns one result to the stack, an i32
representing the previous total size of memory in pages, or -1
if the operation failed 1.
Opcode | Instruction | Stack Arity |
---|---|---|
0x40 |
memory.grow |
;; Places 2 on the stack
i32.const 2
;; Takes one value off of the stack (2), and requests
;; that many additional pages of memory
memory.grow
;; Places -1 on the stack
i32.const -1
;; Takes two values off of the stack (the result from
;; memory.grow and -1) and compares them
i32.eq
if
;; If the two values are equal, the instance failed
;; to get more memory
end
Footnotes
-
Structure, Memory Instructions - https://www.w3.org/TR/wasm-core-2/syntax/instructions.html#memory-instructions ↩ ↩2 ↩3
-
Execution, Runtime Structure, Memory Instances - https://www.w3.org/TR/wasm-core-2/exec/runtime.html#memory-instances ↩