Skip to content

Commit 8c99af0

Browse files
authored
[Strings] wasm-ctor-eval: Stop on seeing a string view, which we cannot precompute (#6561)
1 parent 85a8600 commit 8c99af0

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

src/tools/wasm-ctor-eval.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ class EvallingModuleRunner : public ModuleRunnerBase<EvallingModuleRunner> {
9393
// serialize them.)
9494
throw FailToEvalException("table.set: TODO");
9595
}
96+
97+
Flow visitStringAs(StringAs* curr) {
98+
// TODO: It is not clear how we can handle string.as, since it can lead to
99+
// us needing string_views in globals, but string.as is not a constant
100+
// instruction, so we cannot generate such globals atm. Perhaps we
101+
// could generate them in the start function?
102+
throw FailToEvalException("string.as: TODO");
103+
}
96104
};
97105

98106
// Build an artificial `env` module based on a module's imports, so that the
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
;; We cannot precompute string views atm.
5+
6+
(module
7+
;; CHECK: (type $0 (func))
8+
9+
;; CHECK: (export "test" (func $test))
10+
(export "test" (func $test))
11+
12+
;; CHECK: (func $test (type $0)
13+
;; CHECK-NEXT: (local $temp-view (ref stringview_wtf16))
14+
;; CHECK-NEXT: (local.set $temp-view
15+
;; CHECK-NEXT: (string.as_wtf16
16+
;; CHECK-NEXT: (string.const "test")
17+
;; CHECK-NEXT: )
18+
;; CHECK-NEXT: )
19+
;; CHECK-NEXT: )
20+
(func $test
21+
(local $temp-view (ref stringview_wtf16))
22+
;; This code will remain: we cannot precompute a value that we store in a
23+
;; global, as string.as is not a constant instruction that can appear in a
24+
;; global.
25+
(local.set $temp-view
26+
(string.as_wtf16
27+
(string.const "test")
28+
)
29+
)
30+
)
31+
)
32+

0 commit comments

Comments
 (0)