summaryrefslogtreecommitdiff
path: root/test/interp/return-call-indirect.txt
diff options
context:
space:
mode:
authorFrancis McCabe <frankmccabe@mac.com>2018-10-12 14:05:00 -0700
committerBen Smith <binjimin@gmail.com>2018-10-12 14:05:00 -0700
commit8292bd817c873a77d2a0a14dbbd9892b4e9c7860 (patch)
tree36cf470e1d629f11e90c03fc6368ff9a3594f560 /test/interp/return-call-indirect.txt
parent27d833c6c8bbb041c43e5f67e1049d6c0095bd56 (diff)
downloadwabt-8292bd817c873a77d2a0a14dbbd9892b4e9c7860.tar.gz
wabt-8292bd817c873a77d2a0a14dbbd9892b4e9c7860.tar.bz2
wabt-8292bd817c873a77d2a0a14dbbd9892b4e9c7860.zip
Implemented tail call instructions: (#926)
return_call return_call_indirect with some simple tests thereof.
Diffstat (limited to 'test/interp/return-call-indirect.txt')
-rw-r--r--test/interp/return-call-indirect.txt38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/interp/return-call-indirect.txt b/test/interp/return-call-indirect.txt
new file mode 100644
index 00000000..83e478eb
--- /dev/null
+++ b/test/interp/return-call-indirect.txt
@@ -0,0 +1,38 @@
+;;; TOOL: run-interp
+;;; ARGS: --enable-tail-call
+(module
+ (type $iii_i (func (param i32 i32 i32)(result i32)))
+ (table anyfunc (elem $facInd))
+
+ (func (export "facInd10") (result i32)
+ i32.const 10
+ i32.const 1
+ i32.const 0
+ i32.const 0
+ call_indirect (type $iii_i))
+
+(;; Tail call version of factorial, using indirect call ;;)
+(;; fac(Ix,So) => Ix==0?So:fac(Ix-1,So*Ix) ;;)
+ (func $facInd (type $iii_i)
+ get_local 0
+ i32.const 0
+ i32.gt_s
+ if (result i32)
+ get_local 0
+ i32.const 1
+ i32.sub
+ get_local 1
+ get_local 0
+ i32.mul
+ get_local 2
+ get_local 2
+ return_call_indirect (type $iii_i)
+ unreachable
+ else
+ get_local 1
+ return
+ end)
+)
+(;; STDOUT ;;;
+facInd10() => i32:3628800
+;;; STDOUT ;;)