Skip to content

Commit a3a2c4f

Browse files
authored
[Custom Descriptors] Exact imports require CD (#8042)
Validate that exact function imports require custom descriptors. An alternative approach (that we may switch to in the future if necessary) would be to always allow exact imports, but then strip them out in the binary writer when custom descriptors are not enabled. For now take the more explicit what-you-see-is-what-you-get approach.
1 parent efa8a80 commit a3a2c4f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/wasm/wasm-validator.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4159,7 +4159,12 @@ void FunctionValidator::visitFunction(Function* curr) {
41594159
curr->name,
41604160
"all used types should be allowed");
41614161

4162-
if (!curr->imported()) {
4162+
if (curr->imported()) {
4163+
shouldBeTrue(
4164+
curr->type.isInexact() || getModule()->features.hasCustomDescriptors(),
4165+
curr->name,
4166+
"exact imports require custom descriptors [--enable-custom-descriptors]");
4167+
} else {
41634168
shouldBeTrue(
41644169
curr->type.isExact(), curr->name, "defined function should be exact");
41654170
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
;; Test that exact imports require custom descriptors.
2+
3+
;; RUN: not wasm-opt %s -all --disable-custom-descriptors 2>&1 | filecheck %s
4+
5+
;; CHECK: exact imports require custom descriptors [--enable-custom-descriptors]
6+
7+
(module
8+
(import "" "" (func $f (exact)))
9+
)

0 commit comments

Comments
 (0)