Add heap_load, heap_store, and heap_addr instructions.
These are used when lowering WebAssembly sandbox code.
This commit is contained in:
@@ -533,49 +533,13 @@ than the native pointer size, for example unsigned :type:`i32` offsets on a
|
||||
:arg Name: String identifying the heap in the runtime environment.
|
||||
:result H: Heap identifier.
|
||||
|
||||
.. inst:: a = heap_load H, p, Offset
|
||||
|
||||
Load a value at the address ``p + Offset`` in the heap H.
|
||||
|
||||
Trap if the heap access would be out of bounds.
|
||||
|
||||
:arg H: Heap identifier created by :inst:`heap`.
|
||||
:arg iN p: Unsigned base address in heap.
|
||||
:arg Offset: Immediate signed offset.
|
||||
:flag align(N): Expected alignment of ``p + Offset``. Power of two.
|
||||
:flag aligntrap: Always trap if the memory access is misaligned.
|
||||
:result T a: Loaded value.
|
||||
|
||||
.. inst:: a = heap_store H, x, p, Offset
|
||||
|
||||
Store a value at the address ``p + Offset`` in the heap H.
|
||||
|
||||
Trap if the heap access would be out of bounds.
|
||||
|
||||
:arg H: Heap identifier created by :inst:`heap`.
|
||||
:arg T x: Value to be stored.
|
||||
:arg iN p: Unsigned base address in heap.
|
||||
:arg Offset: Immediate signed offset.
|
||||
:flag align(N): Expected alignment of ``p + Offset``. Power of two.
|
||||
:flag aligntrap: Always trap if the memory access is misaligned.
|
||||
.. autoinst:: heap_load
|
||||
.. autoinst:: heap_store
|
||||
|
||||
When optimizing heap accesses, Cretonne may separate the heap bounds checking
|
||||
and address computations from the memory accesses.
|
||||
|
||||
.. inst:: a = heap_addr H, p, Size
|
||||
|
||||
Bounds check and compute absolute address of heap memory.
|
||||
|
||||
Verify that the address range ``p .. p + Size - 1`` is valid in the heap H,
|
||||
and trap if not.
|
||||
|
||||
Convert the heap-relative address in ``p`` to a real absolute address and
|
||||
return it.
|
||||
|
||||
:arg H: Heap identifier created by :inst:`heap`.
|
||||
:arg iN p: Unsigned base address in heap.
|
||||
:arg Size: Immediate unsigned byte count for range to verify.
|
||||
:result iPtr a: Absolute address corresponding to ``p``.
|
||||
.. autoinst:: heap_addr
|
||||
|
||||
A small example using heaps::
|
||||
|
||||
|
||||
@@ -114,3 +114,17 @@ ebb0:
|
||||
; nextln: $v2 = stack_load.i32 $ss10+4
|
||||
; nextln: stack_store $v1, $ss10+2
|
||||
; nextln: stack_store $v2, $ss2
|
||||
|
||||
; Heap access instructions.
|
||||
function heap(i32) {
|
||||
; TODO: heap0 = heap %foo
|
||||
ebb0(v1: i32):
|
||||
v2 = heap_load.f32 v1
|
||||
v3 = heap_load.f32 v1+12
|
||||
heap_store v3, v1
|
||||
}
|
||||
; sameln: function heap(i32) {
|
||||
; nextln: ebb0($v1: i32):
|
||||
; nextln: $v2 = heap_load.f32 $v1
|
||||
; nextln: $v3 = heap_load.f32 $v1+12
|
||||
; nextln: heap_store $v3, $v1
|
||||
|
||||
Reference in New Issue
Block a user