From e8276ed965266530b6a1ab3503e19a6c1c923b6f Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Mon, 28 Aug 2017 14:34:46 -0700 Subject: [PATCH] Add more heap expansion tests. --- .../filetests/isa/intel/legalize-memory.cton | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cranelift/filetests/isa/intel/legalize-memory.cton b/cranelift/filetests/isa/intel/legalize-memory.cton index 1aaf044f9f..5db903aa52 100644 --- a/cranelift/filetests/isa/intel/legalize-memory.cton +++ b/cranelift/filetests/isa/intel/legalize-memory.cton @@ -4,6 +4,7 @@ set is_64bit isa intel ; regex: V=v\d+ +; regex: EBB=ebb\d+ function %vmctx(i64 vmctx) -> i64 { gv1 = vmctx-16 @@ -50,3 +51,27 @@ ebb0(v0: i32, v999: i64): v4 = fadd v2, v3 return v4 } + +; SpiderMonkey VM-style static 4+2 GB heap. +; Offsets >= 2 GB do require a boundscheck. +function %staticheap_sm64(i32, i64 vmctx) -> f32 spiderwasm { + gv0 = vmctx+64 + heap0 = static gv0, min 0x1000, bound 0x1_0000_0000, guard 0x8000_0000 + +ebb0(v0: i32, v999: i64): + ; check: $ebb0( + v1 = heap_addr.i64 heap0, v0, 0x8000_0000 + ; Boundscheck code + ; check: $(oob=$V) = icmp + ; nextln: brz $oob, $(ok=$EBB) + ; nextln: trap + ; check: $ok: + ; Checks here are assuming that no pipehole opts fold the load offsets. + ; nextln: $(xoff=$V) = uextend.i64 $v0 + ; nextln: $(haddr=$V) = iadd_imm.i64 $v999, 64 + ; nextln: $(hbase=$V) = load.i64 $haddr + ; nextln: $v1 = iadd $hbase, $xoff + v2 = load.f32 v1+0x7fff_ffff + ; nextln: $v2 = load.f32 $v1+0x7fff_ffff + return v2 +}