Skip to content

Commit 04adfce

Browse files
authored
[wasm-ctor-eval] Do not error on non-constant code in the start function (#8778)
Before, we did not catch the Nonconstant exception.
1 parent 9f2642a commit 04adfce

2 files changed

Lines changed: 44 additions & 1 deletion

File tree

src/tools/wasm-ctor-eval.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1485,11 +1485,16 @@ void evalCtors(Module& wasm,
14851485
}
14861486
}
14871487
} catch (FailToEvalException& fail) {
1488-
// that's it, we failed to even create the instance
1488+
// That's it, we failed to even create the instance.
14891489
if (!quiet) {
14901490
std::cout << " ...stopping since could not create module instance: "
14911491
<< fail.why << "\n";
14921492
}
1493+
} catch (NonconstantException& fail) {
1494+
// We can also fail during start due to a non-constant operation.
1495+
if (!quiet) {
1496+
std::cout << " ...stopping since non-constant in start\n";
1497+
}
14931498
} catch (TopologicalSort::CycleException e) {
14941499
// We use a topological sort for GC globals. If there is a non-breakable
14951500
// cycle there, we will hit an error (we can break cycles in nullable and
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
2+
;; RUN: foreach %s %t wasm-ctor-eval --ctors=test --kept-exports=test --quiet -all -S -o - | filecheck %s
3+
4+
;; A non-constant (relaxed SIMD) operation in the start function. We should not
5+
;; error.
6+
(module
7+
;; CHECK: (type $0 (func (param v128)))
8+
9+
;; CHECK: (type $1 (func))
10+
11+
;; CHECK: (import "a" "b" (func $import (type $0) (param v128)))
12+
(import "a" "b" (func $import (param v128)))
13+
14+
;; CHECK: (export "test" (func $0))
15+
(export "test" (func $0))
16+
17+
;; CHECK: (start $0)
18+
(start $0)
19+
20+
;; CHECK: (func $0 (type $1)
21+
;; CHECK-NEXT: (call $import
22+
;; CHECK-NEXT: (f32x4.relaxed_min
23+
;; CHECK-NEXT: (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000)
24+
;; CHECK-NEXT: (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000)
25+
;; CHECK-NEXT: )
26+
;; CHECK-NEXT: )
27+
;; CHECK-NEXT: )
28+
(func $0
29+
;; The import avoids vacuum from removing the entire body.
30+
(call $import
31+
(f32x4.relaxed_min
32+
(v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000)
33+
(v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000)
34+
)
35+
)
36+
)
37+
)
38+

0 commit comments

Comments
 (0)