Skip to content

Commit 216ea0b

Browse files
authored
[StackSwitching] Implementing partial cont.bind-ing (#8464)
1 parent 2eb472c commit 216ea0b

2 files changed

Lines changed: 50 additions & 3 deletions

File tree

src/wasm-interpreter.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4775,9 +4775,9 @@ class ModuleRunnerBase : public ExpressionRunner<SubType> {
47754775
auto old = cont.getSingleValue().getContData();
47764776
auto newData = *old;
47774777
newData.type = curr->type.getHeapType();
4778-
newData.resumeArguments = arguments;
4779-
// We handle only the simple case of applying all parameters, for now. TODO
4780-
assert(old->resumeArguments.empty());
4778+
for (auto arg : arguments) {
4779+
newData.resumeArguments.push_back(arg);
4780+
}
47814781
// The old one is done.
47824782
old->executed = true;
47834783
return Literal(std::make_shared<ContData>(newData));

test/lit/exec/cont_bindings.wast

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
;; NOTE: Assertions have been generated by update_lit_checks.py --output=fuzz-exec and should not be edited.
2+
3+
;; RUN: foreach %s %t wasm-opt -all --fuzz-exec-before -q -o /dev/null 2>&1 | filecheck %s
4+
5+
(module
6+
(import "fuzzing-support" "log-i32" (func $log-i32 (param i32)))
7+
(import "fuzzing-support" "log-f64" (func $log-f64 (param f64)))
8+
9+
(rec
10+
(type $F1 (func (param i32 f64)))
11+
(type $F2 (func (param f64)))
12+
(type $F3 (func))
13+
14+
(type $C1 (cont $F1))
15+
(type $C2 (cont $F2))
16+
(type $C3 (cont $F3))
17+
)
18+
19+
(func $f1 (type $F1) (param $x i32) (param $y f64)
20+
(call $log-i32
21+
(local.get $x)
22+
)
23+
(call $log-f64
24+
(local.get $y)
25+
)
26+
)
27+
28+
;; CHECK: [fuzz-exec] calling bindings
29+
;; CHECK-NEXT: [LoggingExternalInterface logging 42]
30+
;; CHECK-NEXT: [LoggingExternalInterface logging 3.14159]
31+
(func $bindings (export "bindings")
32+
;; Start with an $F1 with two params, then bind each param in successive
33+
;; operations.
34+
(resume $C3
35+
(cont.bind $C2 $C3
36+
(f64.const 3.14159)
37+
(cont.bind $C1 $C2
38+
(i32.const 42)
39+
(cont.new $C1
40+
(ref.func $f1)
41+
)
42+
)
43+
)
44+
)
45+
)
46+
)
47+

0 commit comments

Comments
 (0)