Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/tools/wasm-ctor-eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,16 @@ EvalCtorOutcome evalCtor(EvallingModuleRunner& instance,
results = flow.values;

if (flow.breaking()) {
if (flow.suspendTag) {
// A suspend reached the exit of the function, so it is unhandled in
// it. TODO: We could support the case of the calling function
// handling it.
if (!quiet) {
std::cout << " ...stopping due to unhandled suspend\n";
}
return EvalCtorOutcome();
}

// We are returning out of the function (either via a return, or via a
// break to |block|, which has the same outcome. That means we don't
// need to execute any more lines, and can consider them to be
Expand Down
22 changes: 17 additions & 5 deletions test/lit/ctor-eval/cont.wast
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; RUN: foreach %s %t wasm-ctor-eval --ctors=test --kept-exports=test --quiet -all -S -o - | filecheck %s
;; RUN: foreach %s %t wasm-ctor-eval --ctors=test,test2 --kept-exports=test,test2 --quiet -all -S -o - | filecheck %s

;; Test that we can precompute continuations.

(module
;; CHECK: (type $f (func))
(type $f (func))
(type $k (cont $f))

;; CHECK: (type $1 (func (result i32)))

;; CHECK: (tag $more (type $f))
(tag $more)

(global $g (mut i32) (i32.const 0))
Expand Down Expand Up @@ -45,11 +49,19 @@
)
(global.get $g)
)
)
;; CHECK: (type $0 (func (result i32)))

;; CHECK: (export "test" (func $test_3))
;; CHECK: (export "test" (func $test_4))

;; CHECK: (export "test2" (func $test2))

;; CHECK: (func $test_3 (type $0) (result i32)
;; CHECK: (func $test2 (type $f)
;; CHECK-NEXT: (suspend $more)
;; CHECK-NEXT: )
(func $test2 (export "test2")
;; This unhandled suspend will trap, and should not be precomputed.
(suspend $more)
)
)
;; CHECK: (func $test_4 (type $1) (result i32)
;; CHECK-NEXT: (i32.const 3)
;; CHECK-NEXT: )
Loading