diff options
author | Alon Zakai <azakai@google.com> | 2023-05-04 16:44:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-04 16:44:09 -0700 |
commit | 7f8e4cbf6273c9b13b3a1a42f5e2833ea0d0f686 (patch) | |
tree | cc0343495b994c67a01b5143e6345d45a1c3587d /src/ir/effects.h | |
parent | 09fe432c0d3cb7562767a8e06d4e918beb5990c2 (diff) | |
download | binaryen-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/ir/effects.h')
-rw-r--r-- | src/ir/effects.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/ir/effects.h b/src/ir/effects.h index c5251ae64..fe2520299 100644 --- a/src/ir/effects.h +++ b/src/ir/effects.h @@ -755,7 +755,12 @@ private: } } void visitArrayNew(ArrayNew* curr) {} - void visitArrayNewSeg(ArrayNewSeg* curr) { + void visitArrayNewData(ArrayNewData* curr) { + // Traps on out of bounds access to segments or access to dropped + // segments. + parent.implicitTrap = true; + } + void visitArrayNewElem(ArrayNewElem* curr) { // Traps on out of bounds access to segments or access to dropped // segments. parent.implicitTrap = true; @@ -808,7 +813,7 @@ private: // Traps when the destination is null or when out of bounds. parent.implicitTrap = true; } - void visitArrayInit(ArrayInit* curr) { + template<typename ArrayInit> void visitArrayInit(ArrayInit* curr) { if (curr->ref->type.isNull()) { parent.trap = true; return; @@ -818,6 +823,8 @@ private: // destination, or when the source segment has been dropped. parent.implicitTrap = true; } + void visitArrayInitData(ArrayInitData* curr) { visitArrayInit(curr); } + void visitArrayInitElem(ArrayInitElem* curr) { visitArrayInit(curr); } void visitRefAs(RefAs* curr) { if (curr->op == ExternInternalize || curr->op == ExternExternalize) { // These conversions are infallible. |