Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/wasm/wasm-binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7343,6 +7343,9 @@ bool WasmBinaryReader::maybeVisitStructNew(Expression*& out, uint32_t code) {
if (code == BinaryConsts::StructNew ||
code == BinaryConsts::StructNewDefault) {
auto heapType = getIndexedHeapType();
if (!heapType.isStruct()) {
throwError("Expected struct heaptype");
}
std::vector<Expression*> operands;
if (code == BinaryConsts::StructNew) {
auto numOperands = heapType.getStruct().fields.size();
Expand Down Expand Up @@ -7390,6 +7393,9 @@ bool WasmBinaryReader::maybeVisitStructSet(Expression*& out, uint32_t code) {
}
auto* curr = allocator.alloc<StructSet>();
auto heapType = getIndexedHeapType();
if (!heapType.isStruct()) {
throwError("Expected struct heaptype");
}
curr->index = getU32LEB();
curr->value = popNonVoidExpression();
curr->ref = popNonVoidExpression();
Expand All @@ -7402,6 +7408,9 @@ bool WasmBinaryReader::maybeVisitStructSet(Expression*& out, uint32_t code) {
bool WasmBinaryReader::maybeVisitArrayNewData(Expression*& out, uint32_t code) {
if (code == BinaryConsts::ArrayNew || code == BinaryConsts::ArrayNewDefault) {
auto heapType = getIndexedHeapType();
if (!heapType.isArray()) {
throwError("Expected array heaptype");
}
auto* size = popNonVoidExpression();
Expression* init = nullptr;
if (code == BinaryConsts::ArrayNew) {
Expand All @@ -7418,6 +7427,9 @@ bool WasmBinaryReader::maybeVisitArrayNewElem(Expression*& out, uint32_t code) {
code == BinaryConsts::ArrayNewElem) {
auto isData = code == BinaryConsts::ArrayNewData;
auto heapType = getIndexedHeapType();
if (!heapType.isArray()) {
throwError("Expected array heaptype");
}
auto segIdx = getU32LEB();
auto* size = popNonVoidExpression();
auto* offset = popNonVoidExpression();
Expand All @@ -7441,6 +7453,9 @@ bool WasmBinaryReader::maybeVisitArrayNewFixed(Expression*& out,
uint32_t code) {
if (code == BinaryConsts::ArrayNewFixed) {
auto heapType = getIndexedHeapType();
if (!heapType.isArray()) {
throwError("Expected array heaptype");
}
auto size = getU32LEB();
std::vector<Expression*> values(size);
for (size_t i = 0; i < size; i++) {
Expand Down Expand Up @@ -7481,6 +7496,9 @@ bool WasmBinaryReader::maybeVisitArraySet(Expression*& out, uint32_t code) {
return false;
}
auto heapType = getIndexedHeapType();
if (!heapType.isArray()) {
throwError("Expected array heaptype");
}
auto* value = popNonVoidExpression();
auto* index = popNonVoidExpression();
auto* ref = popNonVoidExpression();
Expand All @@ -7503,7 +7521,13 @@ bool WasmBinaryReader::maybeVisitArrayCopy(Expression*& out, uint32_t code) {
return false;
}
auto destHeapType = getIndexedHeapType();
if (!destHeapType.isArray()) {
throwError("Expected array heaptype");
}
auto srcHeapType = getIndexedHeapType();
if (!srcHeapType.isArray()) {
throwError("Expected array heaptype");
}
auto* length = popNonVoidExpression();
auto* srcIndex = popNonVoidExpression();
auto* srcRef = popNonVoidExpression();
Expand All @@ -7521,6 +7545,9 @@ bool WasmBinaryReader::maybeVisitArrayFill(Expression*& out, uint32_t code) {
return false;
}
auto heapType = getIndexedHeapType();
if (!heapType.isArray()) {
throwError("Expected array heaptype");
}
auto* size = popNonVoidExpression();
auto* value = popNonVoidExpression();
auto* index = popNonVoidExpression();
Expand All @@ -7542,6 +7569,9 @@ bool WasmBinaryReader::maybeVisitArrayInit(Expression*& out, uint32_t code) {
return false;
}
auto heapType = getIndexedHeapType();
if (!heapType.isArray()) {
throwError("Expected array heaptype");
}
Index segIdx = getU32LEB();
auto* size = popNonVoidExpression();
auto* offset = popNonVoidExpression();
Expand Down