diff options
author | Alon Zakai <azakai@google.com> | 2024-04-29 13:32:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-29 13:32:46 -0700 |
commit | 8c99af063794e022f22dfb013f99ec25857ace5f (patch) | |
tree | dcc1abdbb6d248148a15d01e120406f296c37678 | |
parent | 85a8600ec0d205d414b2d0873f840568008d6d93 (diff) | |
download | binaryen-8c99af063794e022f22dfb013f99ec25857ace5f.tar.gz binaryen-8c99af063794e022f22dfb013f99ec25857ace5f.tar.bz2 binaryen-8c99af063794e022f22dfb013f99ec25857ace5f.zip |
[Strings] wasm-ctor-eval: Stop on seeing a string view, which we cannot precompute (#6561)
-rw-r--r-- | src/tools/wasm-ctor-eval.cpp | 8 | ||||
-rw-r--r-- | test/lit/ctor-eval/string_view.wast | 32 |
2 files changed, 40 insertions, 0 deletions
diff --git a/src/tools/wasm-ctor-eval.cpp b/src/tools/wasm-ctor-eval.cpp index a806333af..4018be0e7 100644 --- a/src/tools/wasm-ctor-eval.cpp +++ b/src/tools/wasm-ctor-eval.cpp @@ -93,6 +93,14 @@ public: // serialize them.) throw FailToEvalException("table.set: TODO"); } + + Flow visitStringAs(StringAs* curr) { + // TODO: It is not clear how we can handle string.as, since it can lead to + // us needing string_views in globals, but string.as is not a constant + // instruction, so we cannot generate such globals atm. Perhaps we + // could generate them in the start function? + throw FailToEvalException("string.as: TODO"); + } }; // Build an artificial `env` module based on a module's imports, so that the diff --git a/test/lit/ctor-eval/string_view.wast b/test/lit/ctor-eval/string_view.wast new file mode 100644 index 000000000..5906e4f60 --- /dev/null +++ b/test/lit/ctor-eval/string_view.wast @@ -0,0 +1,32 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. +;; RUN: foreach %s %t wasm-ctor-eval --ctors=test --kept-exports=test --quiet -all -S -o - | filecheck %s + +;; We cannot precompute string views atm. + +(module + ;; CHECK: (type $0 (func)) + + ;; CHECK: (export "test" (func $test)) + (export "test" (func $test)) + + ;; CHECK: (func $test (type $0) + ;; CHECK-NEXT: (local $temp-view (ref stringview_wtf16)) + ;; CHECK-NEXT: (local.set $temp-view + ;; CHECK-NEXT: (string.as_wtf16 + ;; CHECK-NEXT: (string.const "test") + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $test + (local $temp-view (ref stringview_wtf16)) + ;; This code will remain: we cannot precompute a value that we store in a + ;; global, as string.as is not a constant instruction that can appear in a + ;; global. + (local.set $temp-view + (string.as_wtf16 + (string.const "test") + ) + ) + ) +) + |