diff options
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r-- | src/wasm/wasm-binary.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index ab229f111..ee3c1a6fa 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -584,11 +584,8 @@ void WasmBinaryWriter::writeElementSegments() { Index tableIdx = 0; bool isPassive = segment->table.isNull(); - // if all items are ref.func, we can use the shorter form. - bool usesExpressions = - std::any_of(segment->data.begin(), - segment->data.end(), - [](Expression* curr) { return !curr->is<RefFunc>(); }); + // If the segment is MVP, we can use the shorter form. + bool usesExpressions = TableUtils::usesExpressions(segment.get(), wasm); bool hasTableIndex = false; if (!isPassive) { @@ -620,7 +617,7 @@ void WasmBinaryWriter::writeElementSegments() { // elemType writeType(segment->type); } else { - // elemKind funcref + // MVP elemKind of funcref o << U32LEB(0); } } @@ -2864,12 +2861,12 @@ void WasmBinaryBuilder::readElementSegments() { if (usesExpressions) { segment->type = getType(); if (!segment->type.isFunction()) { - throwError("Invalid type for an element segment"); + throwError("Invalid type for a usesExpressions element segment"); } } else { auto elemKind = getU32LEB(); if (elemKind != 0x0) { - throwError("Only funcref elem kinds are valid."); + throwError("Invalid kind (!= funcref(0)) since !usesExpressions."); } } } |