cranelift: Correctly calculate heap addresses in interpreter (#5155)

We were accidentally including the size as part of the offset when
computing heap addresses.
This commit is contained in:
Afonso Bordado
2022-10-31 22:07:14 +00:00
committed by GitHub
parent 6d289723bd
commit faeeed4fb9
2 changed files with 27 additions and 3 deletions

View File

@@ -204,3 +204,20 @@ block0(v0: i64, v1: i32):
; heap: static, size=0x1000, ptr=vmctx+0, bound=vmctx+8
; run: %iadd_imm(1) == 1
; run: %iadd_imm(-1) == -1
function %heap_limit_i64(i64 vmctx, i64, i32) -> i32 {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
heap0 = static gv1, min 0, bound 0x8, offset_guard 0, index_type i64
block0(v0: i64, v1: i64, v2: i32):
v3 = heap_addr.i64 heap0, v1, 4
store.i32 v2, v3
v4 = load.i32 v3
return v4
}
; heap: static, size=0x8, ptr=vmctx+0, bound=vmctx+8
; run: %heap_limit_i64(0, 1) == 1
; run: %heap_limit_i64(0, -1) == -1
; run: %heap_limit_i64(4, 1) == 1
; run: %heap_limit_i64(4, -1) == -1