summaryrefslogtreecommitdiff
path: root/src/wasm/wasm.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2023-05-04 16:44:09 -0700
committerGitHub <noreply@github.com>2023-05-04 16:44:09 -0700
commit7f8e4cbf6273c9b13b3a1a42f5e2833ea0d0f686 (patch)
treecc0343495b994c67a01b5143e6345d45a1c3587d /src/wasm/wasm.cpp
parent09fe432c0d3cb7562767a8e06d4e918beb5990c2 (diff)
downloadbinaryen-7f8e4cbf6273c9b13b3a1a42f5e2833ea0d0f686.tar.gz
binaryen-7f8e4cbf6273c9b13b3a1a42f5e2833ea0d0f686.tar.bz2
binaryen-7f8e4cbf6273c9b13b3a1a42f5e2833ea0d0f686.zip
[NFC] Refactor each of ArrayNewSeg and ArrayInit into subclasses for Data/Elem (#5692)
ArrayNewSeg => ArrayNewSegData, ArrayNewSegElem ArrayInit => ArrayInitData, ArrayInitElem Basically we remove the opcode and use the class type to differentiate them. This adds some code but it makes the representation simpler and more compact in memory, and it will help with #5690
Diffstat (limited to 'src/wasm/wasm.cpp')
-rw-r--r--src/wasm/wasm.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index f3e345895..c3f262998 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -1057,7 +1057,13 @@ void ArrayNew::finalize() {
}
}
-void ArrayNewSeg::finalize() {
+void ArrayNewData::finalize() {
+ if (offset->type == Type::unreachable || size->type == Type::unreachable) {
+ type = Type::unreachable;
+ }
+}
+
+void ArrayNewElem::finalize() {
if (offset->type == Type::unreachable || size->type == Type::unreachable) {
type = Type::unreachable;
}
@@ -1118,7 +1124,16 @@ void ArrayFill::finalize() {
}
}
-void ArrayInit::finalize() {
+void ArrayInitData::finalize() {
+ if (ref->type == Type::unreachable || index->type == Type::unreachable ||
+ offset->type == Type::unreachable || size->type == Type::unreachable) {
+ type = Type::unreachable;
+ } else {
+ type = Type::none;
+ }
+}
+
+void ArrayInitElem::finalize() {
if (ref->type == Type::unreachable || index->type == Type::unreachable ||
offset->type == Type::unreachable || size->type == Type::unreachable) {
type = Type::unreachable;