summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ctor-eval/bad-indirect-call.wast15
-rw-r--r--test/ctor-eval/bad-indirect-call.wast.ctors1
-rw-r--r--test/ctor-eval/bad-indirect-call.wast.out23
-rw-r--r--test/ctor-eval/bad-indirect-call2.wast16
-rw-r--r--test/ctor-eval/bad-indirect-call2.wast.ctors1
-rw-r--r--test/ctor-eval/bad-indirect-call2.wast.out25
-rw-r--r--test/ctor-eval/basics-flatten.wast36
-rw-r--r--test/ctor-eval/basics-flatten.wast.ctors1
-rw-r--r--test/ctor-eval/basics-flatten.wast.out38
-rw-r--r--test/ctor-eval/basics.wast33
-rw-r--r--test/ctor-eval/basics.wast.ctors1
-rw-r--r--test/ctor-eval/basics.wast.out38
-rw-r--r--test/ctor-eval/imported.wast45
-rw-r--r--test/ctor-eval/imported.wast.ctors1
-rw-r--r--test/ctor-eval/imported.wast.out34
-rw-r--r--test/ctor-eval/imported2.wast26
-rw-r--r--test/ctor-eval/imported2.wast.ctors1
-rw-r--r--test/ctor-eval/imported2.wast.out30
-rw-r--r--test/ctor-eval/imported3.wast14
-rw-r--r--test/ctor-eval/imported3.wast.ctors1
-rw-r--r--test/ctor-eval/imported3.wast.out19
-rw-r--r--test/ctor-eval/indirect-call3.wast17
-rw-r--r--test/ctor-eval/indirect-call3.wast.ctors1
-rw-r--r--test/ctor-eval/indirect-call3.wast.out20
-rw-r--r--test/ctor-eval/just_some.wast17
-rw-r--r--test/ctor-eval/just_some.wast.ctors1
-rw-r--r--test/ctor-eval/just_some.wast.out24
-rw-r--r--test/ctor-eval/no_partial.wast10
-rw-r--r--test/ctor-eval/no_partial.wast.ctors1
-rw-r--r--test/ctor-eval/no_partial.wast.out17
-rw-r--r--test/ctor-eval/unsafe_call.wast16
-rw-r--r--test/ctor-eval/unsafe_call.wast.ctors1
-rw-r--r--test/ctor-eval/unsafe_call.wast.out26
-rw-r--r--test/ctor-eval/unsafe_store.wast10
-rw-r--r--test/ctor-eval/unsafe_store.wast.ctors1
-rw-r--r--test/ctor-eval/unsafe_store.wast.out11
-rw-r--r--test/ctor-eval/unsafe_store2.wast10
-rw-r--r--test/ctor-eval/unsafe_store2.wast.ctors1
-rw-r--r--test/ctor-eval/unsafe_store2.wast.out11
-rw-r--r--test/ctor-eval/unsafe_store3.wast10
-rw-r--r--test/ctor-eval/unsafe_store3.wast.ctors1
-rw-r--r--test/ctor-eval/unsafe_store3.wast.out11
42 files changed, 616 insertions, 0 deletions
diff --git a/test/ctor-eval/bad-indirect-call.wast b/test/ctor-eval/bad-indirect-call.wast
new file mode 100644
index 000000000..bed3112c3
--- /dev/null
+++ b/test/ctor-eval/bad-indirect-call.wast
@@ -0,0 +1,15 @@
+(module
+ (type $v (func))
+ (memory 256 256)
+ (data (i32.const 10) "waka waka waka waka waka")
+ (table 1 1 anyfunc)
+ (elem (i32.const 0) $call-indirect)
+ (export "test1" $test1)
+ (func $test1
+ (call_indirect $v (i32.const 1)) ;; unsafe to call, out of range
+ (i32.store8 (i32.const 20) (i32.const 120))
+ )
+ (func $call-indirect
+ (i32.store8 (i32.const 40) (i32.const 67))
+ )
+)
diff --git a/test/ctor-eval/bad-indirect-call.wast.ctors b/test/ctor-eval/bad-indirect-call.wast.ctors
new file mode 100644
index 000000000..a5bce3fd2
--- /dev/null
+++ b/test/ctor-eval/bad-indirect-call.wast.ctors
@@ -0,0 +1 @@
+test1
diff --git a/test/ctor-eval/bad-indirect-call.wast.out b/test/ctor-eval/bad-indirect-call.wast.out
new file mode 100644
index 000000000..27c849701
--- /dev/null
+++ b/test/ctor-eval/bad-indirect-call.wast.out
@@ -0,0 +1,23 @@
+(module
+ (type $v (func))
+ (table 1 1 anyfunc)
+ (elem (i32.const 0) $call-indirect)
+ (memory $0 256 256)
+ (data (i32.const 0) "\00\00\00\00\00\00\00\00\00\00waka waka waka waka waka")
+ (export "test1" (func $test1))
+ (func $test1 (type $v)
+ (call_indirect $v
+ (i32.const 1)
+ )
+ (i32.store8
+ (i32.const 20)
+ (i32.const 120)
+ )
+ )
+ (func $call-indirect (type $v)
+ (i32.store8
+ (i32.const 40)
+ (i32.const 67)
+ )
+ )
+)
diff --git a/test/ctor-eval/bad-indirect-call2.wast b/test/ctor-eval/bad-indirect-call2.wast
new file mode 100644
index 000000000..52eaab67c
--- /dev/null
+++ b/test/ctor-eval/bad-indirect-call2.wast
@@ -0,0 +1,16 @@
+(module
+ (type $v (func))
+ (memory 256 256)
+ (data (i32.const 10) "waka waka waka waka waka")
+ (import "env" "_abort" (func $_abort))
+ (table 2 2 anyfunc)
+ (elem (i32.const 0) $_abort $call-indirect)
+ (export "test1" $test1)
+ (func $test1
+ (call_indirect $v (i32.const 0)) ;; unsafe to call, imported
+ (i32.store8 (i32.const 20) (i32.const 120))
+ )
+ (func $call-indirect
+ (i32.store8 (i32.const 40) (i32.const 67))
+ )
+)
diff --git a/test/ctor-eval/bad-indirect-call2.wast.ctors b/test/ctor-eval/bad-indirect-call2.wast.ctors
new file mode 100644
index 000000000..a5bce3fd2
--- /dev/null
+++ b/test/ctor-eval/bad-indirect-call2.wast.ctors
@@ -0,0 +1 @@
+test1
diff --git a/test/ctor-eval/bad-indirect-call2.wast.out b/test/ctor-eval/bad-indirect-call2.wast.out
new file mode 100644
index 000000000..b07a2d40b
--- /dev/null
+++ b/test/ctor-eval/bad-indirect-call2.wast.out
@@ -0,0 +1,25 @@
+(module
+ (type $v (func))
+ (type $FUNCSIG$v (func))
+ (import "env" "_abort" (func $_abort))
+ (table 2 2 anyfunc)
+ (elem (i32.const 0) $_abort $call-indirect)
+ (memory $0 256 256)
+ (data (i32.const 0) "\00\00\00\00\00\00\00\00\00\00waka waka waka waka waka")
+ (export "test1" (func $test1))
+ (func $test1 (type $v)
+ (call_indirect $v
+ (i32.const 0)
+ )
+ (i32.store8
+ (i32.const 20)
+ (i32.const 120)
+ )
+ )
+ (func $call-indirect (type $v)
+ (i32.store8
+ (i32.const 40)
+ (i32.const 67)
+ )
+ )
+)
diff --git a/test/ctor-eval/basics-flatten.wast b/test/ctor-eval/basics-flatten.wast
new file mode 100644
index 000000000..3bbd27a6b
--- /dev/null
+++ b/test/ctor-eval/basics-flatten.wast
@@ -0,0 +1,36 @@
+(module
+ (type $v (func))
+ (memory 256 256)
+ ;; test flattening of multiple segments
+ (data (i32.const 10) "waka ")
+ (data (i32.const 15) "waka") ;; skip a byte here
+ (data (i32.const 20) "waka waka waka")
+ (table 1 1 anyfunc)
+ (elem (i32.const 0) $call-indirect)
+ (export "test1" $test1)
+ (export "test2" $test2)
+ (export "test3" $test3)
+ (func $test1
+ (drop (i32.const 0)) ;; no work at all, really
+ (call $safe-to-call) ;; safe to call
+ (call_indirect $v (i32.const 0)) ;; safe to call
+ )
+ (func $test2
+ (drop (i32.load (i32.const 12))) ;; a safe load
+ (drop (i32.load16 (i32.const 12)))
+ (drop (i32.load8 (i32.const 12)))
+ )
+ (func $test3
+ (i32.store (i32.const 12) (i32.const 115)) ;; a safe store, should alter memory
+ (i32.store16 (i32.const 20) (i32.const 31353))
+ (i32.store8 (i32.const 23) (i32.const 120))
+ )
+ (func $safe-to-call
+ (drop (i32.const 1))
+ (i32.store8 (i32.const 10) (i32.const 110)) ;; safe write too (lowest possible)
+ (i32.store8 (i32.const 33) (i32.const 109)) ;; safe write too (highest possible)
+ )
+ (func $call-indirect
+ (i32.store8 (i32.const 40) (i32.const 67))
+ )
+)
diff --git a/test/ctor-eval/basics-flatten.wast.ctors b/test/ctor-eval/basics-flatten.wast.ctors
new file mode 100644
index 000000000..c7060ede5
--- /dev/null
+++ b/test/ctor-eval/basics-flatten.wast.ctors
@@ -0,0 +1 @@
+test1,test2,test3
diff --git a/test/ctor-eval/basics-flatten.wast.out b/test/ctor-eval/basics-flatten.wast.out
new file mode 100644
index 000000000..33177707e
--- /dev/null
+++ b/test/ctor-eval/basics-flatten.wast.out
@@ -0,0 +1,38 @@
+(module
+ (type $v (func))
+ (table 1 1 anyfunc)
+ (elem (i32.const 0) $call-indirect)
+ (memory $0 256 256)
+ (data (i32.const 0) "\00\00\00\00\00\00\00\00\00\00nas\00\00\00aka\00yzkx waka wakm\00\00\00\00\00\00C")
+ (export "test1" (func $test1))
+ (export "test2" (func $test2))
+ (export "test3" (func $test3))
+ (func $test1 (type $v)
+ (nop)
+ )
+ (func $test2 (type $v)
+ (nop)
+ )
+ (func $test3 (type $v)
+ (nop)
+ )
+ (func $safe-to-call (type $v)
+ (drop
+ (i32.const 1)
+ )
+ (i32.store8
+ (i32.const 10)
+ (i32.const 110)
+ )
+ (i32.store8
+ (i32.const 33)
+ (i32.const 109)
+ )
+ )
+ (func $call-indirect (type $v)
+ (i32.store8
+ (i32.const 40)
+ (i32.const 67)
+ )
+ )
+)
diff --git a/test/ctor-eval/basics.wast b/test/ctor-eval/basics.wast
new file mode 100644
index 000000000..a81b2de2f
--- /dev/null
+++ b/test/ctor-eval/basics.wast
@@ -0,0 +1,33 @@
+(module
+ (type $v (func))
+ (memory 256 256)
+ (data (i32.const 10) "waka waka waka waka waka")
+ (table 1 1 anyfunc)
+ (elem (i32.const 0) $call-indirect)
+ (export "test1" $test1)
+ (export "test2" $test2)
+ (export "test3" $test3)
+ (func $test1
+ (drop (i32.const 0)) ;; no work at all, really
+ (call $safe-to-call) ;; safe to call
+ (call_indirect $v (i32.const 0)) ;; safe to call
+ )
+ (func $test2
+ (drop (i32.load (i32.const 12))) ;; a safe load
+ (drop (i32.load16 (i32.const 12)))
+ (drop (i32.load8 (i32.const 12)))
+ )
+ (func $test3
+ (i32.store (i32.const 12) (i32.const 115)) ;; a safe store, should alter memory
+ (i32.store16 (i32.const 20) (i32.const 31353))
+ (i32.store8 (i32.const 23) (i32.const 120))
+ )
+ (func $safe-to-call
+ (drop (i32.const 1))
+ (i32.store8 (i32.const 10) (i32.const 110)) ;; safe write too (lowest possible)
+ (i32.store8 (i32.const 33) (i32.const 109)) ;; safe write too (highest possible)
+ )
+ (func $call-indirect
+ (i32.store8 (i32.const 40) (i32.const 67))
+ )
+)
diff --git a/test/ctor-eval/basics.wast.ctors b/test/ctor-eval/basics.wast.ctors
new file mode 100644
index 000000000..c7060ede5
--- /dev/null
+++ b/test/ctor-eval/basics.wast.ctors
@@ -0,0 +1 @@
+test1,test2,test3
diff --git a/test/ctor-eval/basics.wast.out b/test/ctor-eval/basics.wast.out
new file mode 100644
index 000000000..bf7735185
--- /dev/null
+++ b/test/ctor-eval/basics.wast.out
@@ -0,0 +1,38 @@
+(module
+ (type $v (func))
+ (table 1 1 anyfunc)
+ (elem (i32.const 0) $call-indirect)
+ (memory $0 256 256)
+ (data (i32.const 0) "\00\00\00\00\00\00\00\00\00\00nas\00\00\00aka yzkx waka wakm\00\00\00\00\00\00C")
+ (export "test1" (func $test1))
+ (export "test2" (func $test2))
+ (export "test3" (func $test3))
+ (func $test1 (type $v)
+ (nop)
+ )
+ (func $test2 (type $v)
+ (nop)
+ )
+ (func $test3 (type $v)
+ (nop)
+ )
+ (func $safe-to-call (type $v)
+ (drop
+ (i32.const 1)
+ )
+ (i32.store8
+ (i32.const 10)
+ (i32.const 110)
+ )
+ (i32.store8
+ (i32.const 33)
+ (i32.const 109)
+ )
+ )
+ (func $call-indirect (type $v)
+ (i32.store8
+ (i32.const 40)
+ (i32.const 67)
+ )
+ )
+)
diff --git a/test/ctor-eval/imported.wast b/test/ctor-eval/imported.wast
new file mode 100644
index 000000000..3f065377d
--- /dev/null
+++ b/test/ctor-eval/imported.wast
@@ -0,0 +1,45 @@
+(module
+ (memory 256 256)
+ (data (i32.const 10) "waka waka waka waka waka")
+ ;; stack imports are special
+ (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32))
+ (import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32))
+ ;; other imports must not be touched!
+ (import "env" "tempDoublePtr" (global $tempDoublePtr i32))
+ (export "test1" $test1)
+ (export "test2" $test2)
+ (export "test3" $test3)
+ ;; ok to modify a global, if we keep it the same value
+ (global $mine (mut i32) (i32.const 1))
+ ;; stack imports are ok to use. their uses are the same as other
+ ;; globals - must keep the same value (which means, unwind the stack)
+ (global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
+ (global $STACK_MAX (mut i32) (get_global $STACK_MAX$asm2wasm$import))
+ ;; a global initialized by an import, so bad, but ok if not used
+ (global $do-not-use (mut i32) (get_global $tempDoublePtr))
+ (func $test1
+ (local $temp i32)
+ (set_global $mine (i32.const 1))
+ (set_local $temp (get_global $STACKTOP))
+ (set_global $STACKTOP (i32.const 1337)) ;; bad
+ (set_global $STACKTOP (get_local $temp)) ;; save us
+ ;; use the stack memory
+ (i32.store (get_local $temp) (i32.const 1337))
+ (if
+ (i32.ne
+ (i32.load (get_local $temp))
+ (i32.const 1337)
+ )
+ (unreachable) ;; they should be equal, never get here
+ )
+ ;; finally, do a valid store
+ (i32.store8 (i32.const 12) (i32.const 115))
+ )
+ (func $test2
+ (set_global $tempDoublePtr (i32.const 1)) ;; bad!
+ (i32.store8 (i32.const 13) (i32.const 115))
+ )
+ (func $test3
+ (i32.store8 (i32.const 14) (i32.const 115))
+ )
+)
diff --git a/test/ctor-eval/imported.wast.ctors b/test/ctor-eval/imported.wast.ctors
new file mode 100644
index 000000000..c7060ede5
--- /dev/null
+++ b/test/ctor-eval/imported.wast.ctors
@@ -0,0 +1 @@
+test1,test2,test3
diff --git a/test/ctor-eval/imported.wast.out b/test/ctor-eval/imported.wast.out
new file mode 100644
index 000000000..eeb405454
--- /dev/null
+++ b/test/ctor-eval/imported.wast.out
@@ -0,0 +1,34 @@
+(module
+ (type $0 (func))
+ (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32))
+ (import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32))
+ (import "env" "tempDoublePtr" (global $tempDoublePtr i32))
+ (global $mine (mut i32) (i32.const 1))
+ (global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
+ (global $STACK_MAX (mut i32) (get_global $STACK_MAX$asm2wasm$import))
+ (global $do-not-use (mut i32) (get_global $tempDoublePtr))
+ (memory $0 256 256)
+ (data (i32.const 0) "\00\00\00\00\00\00\00\00\00\00wasa waka waka waka waka")
+ (export "test1" (func $test1))
+ (export "test2" (func $test2))
+ (export "test3" (func $test3))
+ (func $test1 (type $0)
+ (local $temp i32)
+ (nop)
+ )
+ (func $test2 (type $0)
+ (set_global $tempDoublePtr
+ (i32.const 1)
+ )
+ (i32.store8
+ (i32.const 13)
+ (i32.const 115)
+ )
+ )
+ (func $test3 (type $0)
+ (i32.store8
+ (i32.const 14)
+ (i32.const 115)
+ )
+ )
+)
diff --git a/test/ctor-eval/imported2.wast b/test/ctor-eval/imported2.wast
new file mode 100644
index 000000000..bfdbc5ee8
--- /dev/null
+++ b/test/ctor-eval/imported2.wast
@@ -0,0 +1,26 @@
+(module
+ (memory 256 256)
+ (data (i32.const 10) "waka waka waka waka waka")
+ ;; stack imports are special-cased
+ (import "env" "STACKTOP" (global $STACKTOP i32))
+ (import "env" "STACK_MAX" (global $STACK_MAX i32))
+ ;; other imports must not be touched!
+ (import "env" "tempDoublePtr" (global $tempDoublePtr i32))
+ (export "test1" $test1)
+ (export "test2" $test2)
+ (export "test3" $test3)
+ ;; ok to modify a global, if we keep it the same value
+ (global $mine (mut i32) (i32.const 1))
+ (func $test1
+ (set_global $mine (i32.const 2))
+ (set_global $mine (i32.const 1)) ;; restore!
+ (i32.store8 (i32.const 12) (i32.const 115))
+ )
+ (func $test2
+ (set_global $mine (i32.const 2)) ;; embadden
+ (i32.store8 (i32.const 13) (i32.const 115))
+ )
+ (func $test3
+ (i32.store8 (i32.const 14) (i32.const 115))
+ )
+)
diff --git a/test/ctor-eval/imported2.wast.ctors b/test/ctor-eval/imported2.wast.ctors
new file mode 100644
index 000000000..c7060ede5
--- /dev/null
+++ b/test/ctor-eval/imported2.wast.ctors
@@ -0,0 +1 @@
+test1,test2,test3
diff --git a/test/ctor-eval/imported2.wast.out b/test/ctor-eval/imported2.wast.out
new file mode 100644
index 000000000..7922dd944
--- /dev/null
+++ b/test/ctor-eval/imported2.wast.out
@@ -0,0 +1,30 @@
+(module
+ (type $0 (func))
+ (import "env" "STACKTOP" (global $STACKTOP i32))
+ (import "env" "STACK_MAX" (global $STACK_MAX i32))
+ (import "env" "tempDoublePtr" (global $tempDoublePtr i32))
+ (global $mine (mut i32) (i32.const 1))
+ (memory $0 256 256)
+ (data (i32.const 0) "\00\00\00\00\00\00\00\00\00\00wasa waka waka waka waka")
+ (export "test1" (func $test1))
+ (export "test2" (func $test2))
+ (export "test3" (func $test3))
+ (func $test1 (type $0)
+ (nop)
+ )
+ (func $test2 (type $0)
+ (set_global $mine
+ (i32.const 2)
+ )
+ (i32.store8
+ (i32.const 13)
+ (i32.const 115)
+ )
+ )
+ (func $test3 (type $0)
+ (i32.store8
+ (i32.const 14)
+ (i32.const 115)
+ )
+ )
+)
diff --git a/test/ctor-eval/imported3.wast b/test/ctor-eval/imported3.wast
new file mode 100644
index 000000000..b43ce3038
--- /dev/null
+++ b/test/ctor-eval/imported3.wast
@@ -0,0 +1,14 @@
+(module
+ (memory 256 256)
+ (data (i32.const 10) "waka waka waka waka waka")
+ ;; imports must not be used
+ (import "env" "tempDoublePtr" (global $tempDoublePtr i32))
+ (export "test1" $test1)
+ (export "test2" $test2)
+ (export "test3" $test3)
+ (global $mine (mut i32) (get_global $tempDoublePtr)) ;; BAD, if used
+ (func $test1
+ (drop (get_global $mine))
+ (i32.store8 (i32.const 13) (i32.const 115)) ;; we never get here.
+ )
+)
diff --git a/test/ctor-eval/imported3.wast.ctors b/test/ctor-eval/imported3.wast.ctors
new file mode 100644
index 000000000..a5bce3fd2
--- /dev/null
+++ b/test/ctor-eval/imported3.wast.ctors
@@ -0,0 +1 @@
+test1
diff --git a/test/ctor-eval/imported3.wast.out b/test/ctor-eval/imported3.wast.out
new file mode 100644
index 000000000..4322a0237
--- /dev/null
+++ b/test/ctor-eval/imported3.wast.out
@@ -0,0 +1,19 @@
+(module
+ (type $0 (func))
+ (import "env" "tempDoublePtr" (global $tempDoublePtr i32))
+ (global $mine (mut i32) (get_global $tempDoublePtr))
+ (memory $0 256 256)
+ (data (i32.const 0) "\00\00\00\00\00\00\00\00\00\00waka waka waka waka waka")
+ (export "test1" (func $test1))
+ (export "test2" (func $test2))
+ (export "test3" (func $test3))
+ (func $test1 (type $0)
+ (drop
+ (get_global $mine)
+ )
+ (i32.store8
+ (i32.const 13)
+ (i32.const 115)
+ )
+ )
+)
diff --git a/test/ctor-eval/indirect-call3.wast b/test/ctor-eval/indirect-call3.wast
new file mode 100644
index 000000000..9eaa90821
--- /dev/null
+++ b/test/ctor-eval/indirect-call3.wast
@@ -0,0 +1,17 @@
+(module
+ (type $v (func))
+ (memory 256 256)
+ (data (i32.const 10) "waka waka waka waka waka")
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "_abort" (func $_abort))
+ (table 2 2 anyfunc)
+ (elem (get_global $tableBase) $_abort $call-indirect)
+ (export "test1" $test1)
+ (func $test1
+ (call_indirect $v (i32.const 1)) ;; safe to call
+ (i32.store8 (i32.const 20) (i32.const 120))
+ )
+ (func $call-indirect
+ (i32.store8 (i32.const 40) (i32.const 67))
+ )
+)
diff --git a/test/ctor-eval/indirect-call3.wast.ctors b/test/ctor-eval/indirect-call3.wast.ctors
new file mode 100644
index 000000000..a5bce3fd2
--- /dev/null
+++ b/test/ctor-eval/indirect-call3.wast.ctors
@@ -0,0 +1 @@
+test1
diff --git a/test/ctor-eval/indirect-call3.wast.out b/test/ctor-eval/indirect-call3.wast.out
new file mode 100644
index 000000000..63d6273da
--- /dev/null
+++ b/test/ctor-eval/indirect-call3.wast.out
@@ -0,0 +1,20 @@
+(module
+ (type $v (func))
+ (type $FUNCSIG$v (func))
+ (import "env" "tableBase" (global $tableBase i32))
+ (import "env" "_abort" (func $_abort))
+ (table 2 2 anyfunc)
+ (elem (get_global $tableBase) $_abort $call-indirect)
+ (memory $0 256 256)
+ (data (i32.const 0) "\00\00\00\00\00\00\00\00\00\00waka waka xaka waka waka\00\00\00\00\00\00C")
+ (export "test1" (func $test1))
+ (func $test1 (type $v)
+ (nop)
+ )
+ (func $call-indirect (type $v)
+ (i32.store8
+ (i32.const 40)
+ (i32.const 67)
+ )
+ )
+)
diff --git a/test/ctor-eval/just_some.wast b/test/ctor-eval/just_some.wast
new file mode 100644
index 000000000..64aa18d27
--- /dev/null
+++ b/test/ctor-eval/just_some.wast
@@ -0,0 +1,17 @@
+(module
+ (memory 256 256)
+ (data (i32.const 10) "waka waka waka waka waka")
+ (export "test1" $test1)
+ (export "test2" $test2)
+ (export "test3" $test3)
+ (func $test1
+ (i32.store8 (i32.const 12) (i32.const 115)) ;; a safe store, should alter memory
+ )
+ (func $test2
+ (unreachable)
+ (i32.store8 (i32.const 13) (i32.const 114)) ;; a safe store, should alter memory, but we trapped already
+ )
+ (func $test3
+ (i32.store8 (i32.const 13) (i32.const 113)) ;; a safe store, should alter memory, but we trapped already
+ )
+)
diff --git a/test/ctor-eval/just_some.wast.ctors b/test/ctor-eval/just_some.wast.ctors
new file mode 100644
index 000000000..c7060ede5
--- /dev/null
+++ b/test/ctor-eval/just_some.wast.ctors
@@ -0,0 +1 @@
+test1,test2,test3
diff --git a/test/ctor-eval/just_some.wast.out b/test/ctor-eval/just_some.wast.out
new file mode 100644
index 000000000..41e3d7338
--- /dev/null
+++ b/test/ctor-eval/just_some.wast.out
@@ -0,0 +1,24 @@
+(module
+ (type $0 (func))
+ (memory $0 256 256)
+ (data (i32.const 0) "\00\00\00\00\00\00\00\00\00\00wasa waka waka waka waka")
+ (export "test1" (func $test1))
+ (export "test2" (func $test2))
+ (export "test3" (func $test3))
+ (func $test1 (type $0)
+ (nop)
+ )
+ (func $test2 (type $0)
+ (unreachable)
+ (i32.store8
+ (i32.const 13)
+ (i32.const 114)
+ )
+ )
+ (func $test3 (type $0)
+ (i32.store8
+ (i32.const 13)
+ (i32.const 113)
+ )
+ )
+)
diff --git a/test/ctor-eval/no_partial.wast b/test/ctor-eval/no_partial.wast
new file mode 100644
index 000000000..18ef177b7
--- /dev/null
+++ b/test/ctor-eval/no_partial.wast
@@ -0,0 +1,10 @@
+(module
+ (memory 256 256)
+ (data (i32.const 10) "waka waka waka waka waka")
+ (export "test1" $test1)
+ (func $test1
+ (i32.store8 (i32.const 12) (i32.const 115)) ;; a safe store, should alter memory
+ (unreachable)
+ (i32.store8 (i32.const 13) (i32.const 114)) ;; a safe store, should alter memory, but we trapped already, and so must roll back the first one too
+ )
+)
diff --git a/test/ctor-eval/no_partial.wast.ctors b/test/ctor-eval/no_partial.wast.ctors
new file mode 100644
index 000000000..a5bce3fd2
--- /dev/null
+++ b/test/ctor-eval/no_partial.wast.ctors
@@ -0,0 +1 @@
+test1
diff --git a/test/ctor-eval/no_partial.wast.out b/test/ctor-eval/no_partial.wast.out
new file mode 100644
index 000000000..fc25804a7
--- /dev/null
+++ b/test/ctor-eval/no_partial.wast.out
@@ -0,0 +1,17 @@
+(module
+ (type $0 (func))
+ (memory $0 256 256)
+ (data (i32.const 0) "\00\00\00\00\00\00\00\00\00\00waka waka waka waka waka")
+ (export "test1" (func $test1))
+ (func $test1 (type $0)
+ (i32.store8
+ (i32.const 12)
+ (i32.const 115)
+ )
+ (unreachable)
+ (i32.store8
+ (i32.const 13)
+ (i32.const 114)
+ )
+ )
+)
diff --git a/test/ctor-eval/unsafe_call.wast b/test/ctor-eval/unsafe_call.wast
new file mode 100644
index 000000000..703760744
--- /dev/null
+++ b/test/ctor-eval/unsafe_call.wast
@@ -0,0 +1,16 @@
+(module
+ (memory 256 256)
+ (data (i32.const 10) "waka waka waka waka waka")
+ (export "test1" $test1)
+ (export "test2" $test2)
+ (export "test3" $test3)
+ (func $test1
+ (call $unsafe-to-call) ;; unsafe to call
+ (i32.store (i32.const 12) (i32.const 115)) ;; a safe store, should alter memory
+ (i32.store16 (i32.const 20) (i32.const 31353))
+ (i32.store8 (i32.const 23) (i32.const 120))
+ )
+ (func $unsafe-to-call
+ (unreachable)
+ )
+)
diff --git a/test/ctor-eval/unsafe_call.wast.ctors b/test/ctor-eval/unsafe_call.wast.ctors
new file mode 100644
index 000000000..a5bce3fd2
--- /dev/null
+++ b/test/ctor-eval/unsafe_call.wast.ctors
@@ -0,0 +1 @@
+test1
diff --git a/test/ctor-eval/unsafe_call.wast.out b/test/ctor-eval/unsafe_call.wast.out
new file mode 100644
index 000000000..124cf2578
--- /dev/null
+++ b/test/ctor-eval/unsafe_call.wast.out
@@ -0,0 +1,26 @@
+(module
+ (type $0 (func))
+ (memory $0 256 256)
+ (data (i32.const 0) "\00\00\00\00\00\00\00\00\00\00waka waka waka waka waka")
+ (export "test1" (func $test1))
+ (export "test2" (func $test2))
+ (export "test3" (func $test3))
+ (func $test1 (type $0)
+ (call $unsafe-to-call)
+ (i32.store
+ (i32.const 12)
+ (i32.const 115)
+ )
+ (i32.store16
+ (i32.const 20)
+ (i32.const 31353)
+ )
+ (i32.store8
+ (i32.const 23)
+ (i32.const 120)
+ )
+ )
+ (func $unsafe-to-call (type $0)
+ (unreachable)
+ )
+)
diff --git a/test/ctor-eval/unsafe_store.wast b/test/ctor-eval/unsafe_store.wast
new file mode 100644
index 000000000..f851672a7
--- /dev/null
+++ b/test/ctor-eval/unsafe_store.wast
@@ -0,0 +1,10 @@
+(module
+ (memory 256 256)
+ (data (i32.const 10) "waka waka waka waka waka")
+ (export "test1" $test1)
+ (export "test2" $test2)
+ (export "test3" $test3)
+ (func $test1
+ (i32.store8 (i32.const 9) (i32.const 109)) ;; before first segment
+ )
+)
diff --git a/test/ctor-eval/unsafe_store.wast.ctors b/test/ctor-eval/unsafe_store.wast.ctors
new file mode 100644
index 000000000..a5bce3fd2
--- /dev/null
+++ b/test/ctor-eval/unsafe_store.wast.ctors
@@ -0,0 +1 @@
+test1
diff --git a/test/ctor-eval/unsafe_store.wast.out b/test/ctor-eval/unsafe_store.wast.out
new file mode 100644
index 000000000..8bbc2fed4
--- /dev/null
+++ b/test/ctor-eval/unsafe_store.wast.out
@@ -0,0 +1,11 @@
+(module
+ (type $0 (func))
+ (memory $0 256 256)
+ (data (i32.const 0) "\00\00\00\00\00\00\00\00\00mwaka waka waka waka waka")
+ (export "test1" (func $test1))
+ (export "test2" (func $test2))
+ (export "test3" (func $test3))
+ (func $test1 (type $0)
+ (nop)
+ )
+)
diff --git a/test/ctor-eval/unsafe_store2.wast b/test/ctor-eval/unsafe_store2.wast
new file mode 100644
index 000000000..cc5eb1105
--- /dev/null
+++ b/test/ctor-eval/unsafe_store2.wast
@@ -0,0 +1,10 @@
+(module
+ (memory 256 256)
+ (data (i32.const 10) "waka waka waka waka waka")
+ (export "test1" $test1)
+ (export "test2" $test2)
+ (export "test3" $test3)
+ (func $test1
+ (i32.store8 (i32.const 34) (i32.const 109)) ;; after last segment
+ )
+)
diff --git a/test/ctor-eval/unsafe_store2.wast.ctors b/test/ctor-eval/unsafe_store2.wast.ctors
new file mode 100644
index 000000000..a5bce3fd2
--- /dev/null
+++ b/test/ctor-eval/unsafe_store2.wast.ctors
@@ -0,0 +1 @@
+test1
diff --git a/test/ctor-eval/unsafe_store2.wast.out b/test/ctor-eval/unsafe_store2.wast.out
new file mode 100644
index 000000000..798a4a23d
--- /dev/null
+++ b/test/ctor-eval/unsafe_store2.wast.out
@@ -0,0 +1,11 @@
+(module
+ (type $0 (func))
+ (memory $0 256 256)
+ (data (i32.const 0) "\00\00\00\00\00\00\00\00\00\00waka waka waka waka wakam")
+ (export "test1" (func $test1))
+ (export "test2" (func $test2))
+ (export "test3" (func $test3))
+ (func $test1 (type $0)
+ (nop)
+ )
+)
diff --git a/test/ctor-eval/unsafe_store3.wast b/test/ctor-eval/unsafe_store3.wast
new file mode 100644
index 000000000..701e4b32e
--- /dev/null
+++ b/test/ctor-eval/unsafe_store3.wast
@@ -0,0 +1,10 @@
+(module
+ (memory 256 256)
+ (data (i32.const 10) "waka waka waka waka waka")
+ (export "test1" $test1)
+ (export "test2" $test2)
+ (export "test3" $test3)
+ (func $test1
+ (i32.store16 (i32.const 33) (i32.const 109)) ;; after last segment due to size of type
+ )
+)
diff --git a/test/ctor-eval/unsafe_store3.wast.ctors b/test/ctor-eval/unsafe_store3.wast.ctors
new file mode 100644
index 000000000..a5bce3fd2
--- /dev/null
+++ b/test/ctor-eval/unsafe_store3.wast.ctors
@@ -0,0 +1 @@
+test1
diff --git a/test/ctor-eval/unsafe_store3.wast.out b/test/ctor-eval/unsafe_store3.wast.out
new file mode 100644
index 000000000..e8ad4f5b8
--- /dev/null
+++ b/test/ctor-eval/unsafe_store3.wast.out
@@ -0,0 +1,11 @@
+(module
+ (type $0 (func))
+ (memory $0 256 256)
+ (data (i32.const 0) "\00\00\00\00\00\00\00\00\00\00waka waka waka waka wakm\00")
+ (export "test1" (func $test1))
+ (export "test2" (func $test2))
+ (export "test3" (func $test3))
+ (func $test1 (type $0)
+ (nop)
+ )
+)