forked from bytecodealliance/wasmtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cranelift: Support calling functions with
vmctx
arguments
This is a leftover from bytecodealliance#3302 where we used to inject a special `vmctx` struct if the test requested it. We've removed that capability in bytecodealliance#5386 but accidentally left this in, which caused some weird handling of these test invocations.
- Loading branch information
Showing
2 changed files
with
55 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
test interpret | ||
test run | ||
target x86_64 | ||
target s390x | ||
target aarch64 | ||
target riscv64 | ||
|
||
|
||
|
||
function %simple(i64 vmctx) -> i64 { | ||
gv0 = vmctx | ||
|
||
block0(v0: i64): | ||
v1 = global_value.i64 gv0 | ||
return v1 | ||
} | ||
; run: %simple(0) == 0 | ||
; run: %simple(10) == 10 | ||
|
||
|
||
|
||
|
||
;; This test sets up a more complex scenario. We build a vmctx struct | ||
;; and use it to call a function that loads from it. | ||
|
||
function %vm_state() -> i64 { | ||
fn0 = %load_at_0_and_add(i64 vmctx) -> i64 | ||
|
||
;; This is our vmctx struct | ||
ss1 = explicit_slot 8 | ||
|
||
block0: | ||
;; Store a 1 in the vmctx struct | ||
v1 = iconst.i64 1 | ||
stack_store.i64 v1, ss1 | ||
|
||
;; Call %load_at_0_and_add with vmctx | ||
v2 = stack_addr.i64 ss1 | ||
v3 = call fn0(v2) | ||
|
||
return v3 | ||
} | ||
; run: %vm_state() == 2 | ||
|
||
|
||
function %load_at_0_and_add(i64 vmctx) -> i64 { | ||
gv0 = vmctx | ||
gv1 = load.i64 notrap aligned gv0+0 | ||
|
||
block0(v0: i64): | ||
v1 = global_value.i64 gv1 | ||
v2 = iadd_imm.i64 v1, 1 | ||
return v2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters