From 69ff3bf4f10d1f50343a3db7e4730b576f679c70 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 17 Mar 2023 11:01:12 -0700 Subject: [Wasm GC] Allow extern.externalize in globals (#5585) This fixes wasm-ctor-eval on evalling a GC data structure that contains a field initialized with an externalized value. Per the spec this is a constant instruction and I verified that V8 allows this. Also add missing validation in wasm-ctor-eval of the output (which makes debugging this kind of thing a little easier). --- src/ir/properties.h | 4 +++- src/tools/wasm-ctor-eval.cpp | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ir/properties.h b/src/ir/properties.h index 0fee67ad2..13eea6ba2 100644 --- a/src/ir/properties.h +++ b/src/ir/properties.h @@ -83,7 +83,9 @@ inline bool isNamedControlFlow(Expression* curr) { // isValidInConstantExpression or find better names(#4845) inline bool isSingleConstantExpression(const Expression* curr) { return curr->is() || curr->is() || curr->is() || - curr->is(); + curr->is() || + (curr->is() && (curr->cast()->op == ExternExternalize || + curr->cast()->op == ExternInternalize)); } inline bool isConstantExpression(const Expression* curr) { diff --git a/src/tools/wasm-ctor-eval.cpp b/src/tools/wasm-ctor-eval.cpp index 195a5350f..5e1bf6b22 100644 --- a/src/tools/wasm-ctor-eval.cpp +++ b/src/tools/wasm-ctor-eval.cpp @@ -1064,6 +1064,11 @@ int main(int argc, const char* argv[]) { if (canEval(wasm)) { evalCtors(wasm, ctors, keptExports); + if (!WasmValidator().validate(wasm)) { + std::cout << wasm << '\n'; + Fatal() << "error in validating output"; + } + // Do some useful optimizations after the evalling { PassRunner passRunner(&wasm); -- cgit v1.2.3