diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ctor-eval/results.wast | 51 | ||||
-rw-r--r-- | test/ctor-eval/results.wast.ctors | 2 | ||||
-rw-r--r-- | test/ctor-eval/results.wast.out | 37 | ||||
-rw-r--r-- | test/lit/help/wasm-ctor-eval.test | 4 |
4 files changed, 89 insertions, 5 deletions
diff --git a/test/ctor-eval/results.wast b/test/ctor-eval/results.wast index 83fc245fe..a01904149 100644 --- a/test/ctor-eval/results.wast +++ b/test/ctor-eval/results.wast @@ -1,7 +1,54 @@ (module - (func "test1" (result i32) + (global $global1 (mut i32) (i32.const 1)) + (global $global2 (mut i32) (i32.const 2)) + (global $global3 (mut i32) (i32.const 3)) + + (func $test1 (export "test1") + ;; This function can be evalled. But in this test we keep this export, + ;; so we should still see an export, but the export should do nothing since + ;; the code has already run. + ;; + ;; In comparison, test3 below, with a result, will still contain a + ;; (constant) result in the remaining export once we can handle results. + + (global.set $global1 + (i32.const 11) + ) + ) + + (func $test2 (export "test2") + ;; As the above function, but the export is *not* kept. + (global.set $global2 + (i32.const 12) + ) + ) + + (func $test3 (export "test3") (result i32) ;; The presence of a result stops us from evalling this function (at least - ;; for now). + ;; for now). Not even the global set will be evalled. + (global.set $global3 + (i32.const 13) + ) (i32.const 42) ) + + (func "keepalive" (result i32) + ;; Keep everything alive to see the changes. + + ;; These should call the original $test1, not the one that is nopped out + ;; after evalling. + (call $test1) + (call $test2) + + (drop + (call $test3) + ) + + ;; Keeping these alive should show the changes to the globals (that should + ;; contain 11, 12, and 3). + (i32.add + (global.get $global1) + (global.get $global2) + ) + ) ) diff --git a/test/ctor-eval/results.wast.ctors b/test/ctor-eval/results.wast.ctors index a5bce3fd2..c7060ede5 100644 --- a/test/ctor-eval/results.wast.ctors +++ b/test/ctor-eval/results.wast.ctors @@ -1 +1 @@ -test1 +test1,test2,test3 diff --git a/test/ctor-eval/results.wast.out b/test/ctor-eval/results.wast.out index b9dc2cf57..b4c947eb7 100644 --- a/test/ctor-eval/results.wast.out +++ b/test/ctor-eval/results.wast.out @@ -1,7 +1,40 @@ (module + (type $none_=>_none (func)) (type $none_=>_i32 (func (result i32))) - (export "test1" (func $0)) - (func $0 (result i32) + (global $global1 (mut i32) (i32.const 11)) + (global $global2 (mut i32) (i32.const 12)) + (global $global3 (mut i32) (i32.const 3)) + (export "test1" (func $test1_0)) + (export "test3" (func $test3)) + (export "keepalive" (func $3)) + (func $test1 + (global.set $global1 + (i32.const 11) + ) + ) + (func $test2 + (global.set $global2 + (i32.const 12) + ) + ) + (func $test3 (result i32) + (global.set $global3 + (i32.const 13) + ) (i32.const 42) ) + (func $3 (result i32) + (call $test1) + (call $test2) + (drop + (call $test3) + ) + (i32.add + (global.get $global1) + (global.get $global2) + ) + ) + (func $test1_0 + (nop) + ) ) diff --git a/test/lit/help/wasm-ctor-eval.test b/test/lit/help/wasm-ctor-eval.test index 364ac5d4c..b3b577250 100644 --- a/test/lit/help/wasm-ctor-eval.test +++ b/test/lit/help/wasm-ctor-eval.test @@ -19,6 +19,10 @@ ;; CHECK-NEXT: --ctors,-c Comma-separated list of global ;; CHECK-NEXT: constructor functions to evaluate ;; CHECK-NEXT: +;; CHECK-NEXT: --kept-exports,-ke Comma-separated list of ctors whose +;; CHECK-NEXT: exports we keep around even if we eval +;; CHECK-NEXT: those ctors +;; CHECK-NEXT: ;; CHECK-NEXT: --ignore-external-input,-ipi Assumes no env vars are to be read, stdin ;; CHECK-NEXT: is empty, etc. ;; CHECK-NEXT: |