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
6 changes: 2 additions & 4 deletions src/wasm-interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -4724,10 +4724,8 @@ class ModuleRunnerBase : public ExpressionRunner<SubType> {
if (funcValue.isNull()) {
trap("null ref");
}
auto funcName = funcValue.getFunc();
auto* func = self()->getModule()->getFunction(funcName);
return Literal(std::make_shared<ContData>(
self()->makeFuncData(funcName, func->type), curr->type.getHeapType()));
return Literal(
std::make_shared<ContData>(funcValue, curr->type.getHeapType()));
}
Flow visitContBind(ContBind* curr) {
Literals arguments;
Expand Down
22 changes: 22 additions & 0 deletions test/lit/exec/cont_external_funcref.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

;; RUN: wasm-opt %s -all --fuzz-exec-before --fuzz-exec-second=%s.second -q -o /dev/null 2>&1 | filecheck %s

;; Export a function reference from the first module to the second. The second
;; can create a continuation without erroring, even though it uses a funcref
;; from another module.

(module
(type $func (func))

(global $global (ref $func) (ref.func $func))

(export "global$func" (global $global))

(func $func
)
)

;; CHECK: [fuzz-exec] running second module
;; CHECK-NEXT: [fuzz-exec] calling export
;; CHECK-NEXT: [fuzz-exec] note result: export => 42

15 changes: 15 additions & 0 deletions test/lit/exec/cont_external_funcref.wast.second
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
(module
(type $func (func))
(type $cont (cont $func))
(import "primary" "global$func" (global $gimport (ref $func)))

(func $export (export "export") (result i32)
(drop
(cont.new $cont
(global.get $gimport)
)
)
(i32.const 42)
)
)

Loading