summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2023-03-17 11:01:12 -0700
committerGitHub <noreply@github.com>2023-03-17 11:01:12 -0700
commit69ff3bf4f10d1f50343a3db7e4730b576f679c70 (patch)
tree1481214262da0e13e8a517a23bcb63a8ba99f055 /src
parentecbebfbee12f2f25af648119604915fc37427f6f (diff)
downloadbinaryen-69ff3bf4f10d1f50343a3db7e4730b576f679c70.tar.gz
binaryen-69ff3bf4f10d1f50343a3db7e4730b576f679c70.tar.bz2
binaryen-69ff3bf4f10d1f50343a3db7e4730b576f679c70.zip
[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).
Diffstat (limited to 'src')
-rw-r--r--src/ir/properties.h4
-rw-r--r--src/tools/wasm-ctor-eval.cpp5
2 files changed, 8 insertions, 1 deletions
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<Const>() || curr->is<RefNull>() || curr->is<RefFunc>() ||
- curr->is<StringConst>();
+ curr->is<StringConst>() ||
+ (curr->is<RefAs>() && (curr->cast<RefAs>()->op == ExternExternalize ||
+ curr->cast<RefAs>()->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);