summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-stack.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-stack.cpp')
-rw-r--r--src/wasm/wasm-stack.cpp41
1 files changed, 31 insertions, 10 deletions
diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp
index b6424cdde..70b52cfbb 100644
--- a/src/wasm/wasm-stack.cpp
+++ b/src/wasm/wasm-stack.cpp
@@ -2025,12 +2025,20 @@ void BinaryInstWriter::visitRttSub(RttSub* curr) {
void BinaryInstWriter::visitStructNew(StructNew* curr) {
o << int8_t(BinaryConsts::GCPrefix);
- if (curr->isWithDefault()) {
- o << U32LEB(BinaryConsts::StructNewDefaultWithRtt);
+ if (curr->rtt) {
+ if (curr->isWithDefault()) {
+ o << U32LEB(BinaryConsts::StructNewDefaultWithRtt);
+ } else {
+ o << U32LEB(BinaryConsts::StructNewWithRtt);
+ }
} else {
- o << U32LEB(BinaryConsts::StructNewWithRtt);
+ if (curr->isWithDefault()) {
+ o << U32LEB(BinaryConsts::StructNewDefault);
+ } else {
+ o << U32LEB(BinaryConsts::StructNew);
+ }
}
- parent.writeIndexedHeapType(curr->rtt->type.getHeapType());
+ parent.writeIndexedHeapType(curr->type.getHeapType());
}
void BinaryInstWriter::visitStructGet(StructGet* curr) {
@@ -2057,17 +2065,30 @@ void BinaryInstWriter::visitStructSet(StructSet* curr) {
void BinaryInstWriter::visitArrayNew(ArrayNew* curr) {
o << int8_t(BinaryConsts::GCPrefix);
- if (curr->isWithDefault()) {
- o << U32LEB(BinaryConsts::ArrayNewDefaultWithRtt);
+ if (curr->rtt) {
+ if (curr->isWithDefault()) {
+ o << U32LEB(BinaryConsts::ArrayNewDefaultWithRtt);
+ } else {
+ o << U32LEB(BinaryConsts::ArrayNewWithRtt);
+ }
} else {
- o << U32LEB(BinaryConsts::ArrayNewWithRtt);
+ if (curr->isWithDefault()) {
+ o << U32LEB(BinaryConsts::ArrayNewDefault);
+ } else {
+ o << U32LEB(BinaryConsts::ArrayNew);
+ }
}
- parent.writeIndexedHeapType(curr->rtt->type.getHeapType());
+ parent.writeIndexedHeapType(curr->type.getHeapType());
}
void BinaryInstWriter::visitArrayInit(ArrayInit* curr) {
- o << int8_t(BinaryConsts::GCPrefix) << U32LEB(BinaryConsts::ArrayInit);
- parent.writeIndexedHeapType(curr->rtt->type.getHeapType());
+ o << int8_t(BinaryConsts::GCPrefix);
+ if (curr->rtt) {
+ o << U32LEB(BinaryConsts::ArrayInit);
+ } else {
+ o << U32LEB(BinaryConsts::ArrayInitStatic);
+ }
+ parent.writeIndexedHeapType(curr->type.getHeapType());
o << U32LEB(curr->values.size());
}