diff options
author | Alon Zakai <azakai@google.com> | 2023-02-23 10:58:59 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-23 10:58:59 -0800 |
commit | 549b0f45be3749fd5f612a2eb225ca1cc40081a6 (patch) | |
tree | 89803ede90ae3fbfde7cdf924aed3646cc28693b | |
parent | 5a0aef47cda663b312c34454857601ee78d77ab6 (diff) | |
download | binaryen-549b0f45be3749fd5f612a2eb225ca1cc40081a6.tar.gz binaryen-549b0f45be3749fd5f612a2eb225ca1cc40081a6.tar.bz2 binaryen-549b0f45be3749fd5f612a2eb225ca1cc40081a6.zip |
[wasm-ctor-eval] Stop evalling at table.set for now (#5516)
Until we get full support for serializing table changes, stop evalling so we do
not break things.
-rw-r--r-- | src/tools/wasm-ctor-eval.cpp | 7 | ||||
-rw-r--r-- | test/lit/ctor-eval/table.wat | 60 |
2 files changed, 67 insertions, 0 deletions
diff --git a/src/tools/wasm-ctor-eval.cpp b/src/tools/wasm-ctor-eval.cpp index 561b08cfc..d41094c67 100644 --- a/src/tools/wasm-ctor-eval.cpp +++ b/src/tools/wasm-ctor-eval.cpp @@ -73,6 +73,13 @@ public: return ModuleRunnerBase<EvallingModuleRunner>::visitGlobalGet(curr); } + + Flow visitTableSet(TableSet* curr) { + // TODO: Full dynamic table support. For now we stop evalling when we see a + // table.set. (To support this we need to track sets and add code to + // serialize them.) + throw FailToEvalException("table.set: TODO"); + } }; // Build an artificial `env` module based on a module's imports, so that the diff --git a/test/lit/ctor-eval/table.wat b/test/lit/ctor-eval/table.wat new file mode 100644 index 000000000..055de67b0 --- /dev/null +++ b/test/lit/ctor-eval/table.wat @@ -0,0 +1,60 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. +;; RUN: wasm-ctor-eval %s --ctors=run --kept-exports=run --quiet -all -S -o - | filecheck %s + +(module + ;; CHECK: (type $none_=>_none (func)) + (type $none_=>_none (func)) + + ;; CHECK: (table $0 22 funcref) + (table $0 22 funcref) + + (elem (i32.const 0) $nop) + + ;; CHECK: (elem (i32.const 0) $nop) + + ;; CHECK: (elem declare func $trap) + + ;; CHECK: (export "run" (func $run_0)) + (export "run" (func $run)) + + (func $run (type $none_=>_none) + ;; This call can be evalled away (it does nothing as the target is a nop). + (call_indirect $0 (type $none_=>_none) + (i32.const 0) + ) + + ;; We stop at this table.set, which is not handled yet. The call after it + ;; should also remain where it is. Note that if we just ignore the set then + ;; we'd call the wrong function later (we should call $trap, not $nop). + (table.set $0 + (i32.const 0) + (ref.func $trap) + ) + (call_indirect $0 (type $none_=>_none) + (i32.const 0) + ) + ) + + ;; CHECK: (func $nop (type $none_=>_none) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + (func $nop (type $none_=>_none) + (nop) + ) + + ;; CHECK: (func $trap (type $none_=>_none) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + (func $trap (type $none_=>_none) + (unreachable) + ) +) +;; CHECK: (func $run_0 (type $none_=>_none) +;; CHECK-NEXT: (table.set $0 +;; CHECK-NEXT: (i32.const 0) +;; CHECK-NEXT: (ref.func $trap) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (call_indirect $0 (type $none_=>_none) +;; CHECK-NEXT: (i32.const 0) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) |