Skip to content

Commit 0be9bfe

Browse files
authored
[EH] Prune exnref-returning/receiving exports (#7290)
Like v128, JS VMs will trap on an exnref on the boundary between JS and wasm, so the fuzzer must prune such exports (we run that pruning when we intend to compare d8 to the binaryen interpreter; after the pruning, all exports should behave the same between those VMs).
1 parent eeed865 commit 0be9bfe

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

src/passes/LegalizeJSInterface.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ struct LegalizeAndPruneJSInterface : public LegalizeJSInterface {
374374
}
375375

376376
// The params are allowed to be multivalue, but not the results. Otherwise
377-
// look for SIMD.
377+
// look for SIMD etc.
378378
auto sig = func->type.getSignature();
379379
auto illegal = isIllegal(sig.results);
380380
illegal =
@@ -409,7 +409,8 @@ struct LegalizeAndPruneJSInterface : public LegalizeJSInterface {
409409

410410
bool isIllegal(Type type) {
411411
auto features = type.getFeatures();
412-
return features.hasSIMD() || features.hasMultivalue();
412+
return features.hasSIMD() || features.hasMultivalue() ||
413+
features.hasExceptionHandling();
413414
}
414415
};
415416

test/lit/passes/legalize-and-prune-js-interface.wast

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,13 @@
128128

129129
;; CHECK: (type $3 (func (result i32 i32)))
130130

131-
;; CHECK: (type $4 (func (param i32)))
131+
;; CHECK: (type $4 (func (result exnref)))
132132

133-
;; CHECK: (type $5 (func (param i32 i32) (result i32)))
133+
;; CHECK: (type $5 (func (param i32)))
134134

135-
;; CHECK: (import "env" "setTempRet0" (func $setTempRet0 (type $4) (param i32)))
135+
;; CHECK: (type $6 (func (param i32 i32) (result i32)))
136+
137+
;; CHECK: (import "env" "setTempRet0" (func $setTempRet0 (type $5) (param i32)))
136138

137139
;; CHECK: (export "export-64" (func $legalstub$export-64))
138140

@@ -167,9 +169,17 @@
167169
;; This will be pruned.
168170
(unreachable)
169171
)
172+
173+
;; CHECK: (func $export-exn (type $4) (result exnref)
174+
;; CHECK-NEXT: (ref.null noexn)
175+
;; CHECK-NEXT: )
176+
(func $export-exn (export "export-exn") (result exnref)
177+
;; This will be pruned.
178+
(ref.null noexn)
179+
)
170180
)
171181

172-
;; CHECK: (func $legalstub$export-64 (type $5) (param $0 i32) (param $1 i32) (result i32)
182+
;; CHECK: (func $legalstub$export-64 (type $6) (param $0 i32) (param $1 i32) (result i32)
173183
;; CHECK-NEXT: (local $2 i64)
174184
;; CHECK-NEXT: (local.set $2
175185
;; CHECK-NEXT: (call $export-64

0 commit comments

Comments
 (0)