summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/wasm-binary.h18
-rw-r--r--src/wasm/wasm-binary.cpp26
2 files changed, 22 insertions, 22 deletions
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index 32eb7657c..8c1990224 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -376,15 +376,15 @@ enum EncodedType {
// string reference types
stringref = -0x19, // 0x67
// type forms
- Func = -0x20, // 0x60
- Cont = -0x23, // 0x5d
- Struct = -0x21, // 0x5f
- Array = -0x22, // 0x5e
- Sub = -0x30, // 0x50
- SubFinal = -0x31, // 0x4f
- Shared = -0x1b, // 0x65
- // isorecursive recursion groups
- Rec = -0x32, // 0x4e
+ Func = 0x60,
+ Cont = 0x5d,
+ Struct = 0x5f,
+ Array = 0x5e,
+ Sub = 0x50,
+ SubFinal = 0x4f,
+ SharedDef = 0x65,
+ Shared = -0x1b, // Also 0x65 as an SLEB128
+ Rec = 0x4e,
// block_type
Empty = -0x40, // 0x40
};
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 8565ddaad..865ca39ca 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -269,7 +269,7 @@ void WasmBinaryWriter::writeTypes() {
// size 1 are implicit, so only emit a group header for larger groups.
auto currGroup = type.getRecGroup();
if (lastGroup != currGroup && currGroup.size() > 1) {
- o << S32LEB(BinaryConsts::EncodedType::Rec) << U32LEB(currGroup.size());
+ o << uint8_t(BinaryConsts::EncodedType::Rec) << U32LEB(currGroup.size());
}
lastGroup = currGroup;
// Emit the type definition.
@@ -277,9 +277,9 @@ void WasmBinaryWriter::writeTypes() {
auto super = type.getDeclaredSuperType();
if (super || type.isOpen()) {
if (type.isOpen()) {
- o << S32LEB(BinaryConsts::EncodedType::Sub);
+ o << uint8_t(BinaryConsts::EncodedType::Sub);
} else {
- o << S32LEB(BinaryConsts::EncodedType::SubFinal);
+ o << uint8_t(BinaryConsts::EncodedType::SubFinal);
}
if (super) {
o << U32LEB(1);
@@ -289,11 +289,11 @@ void WasmBinaryWriter::writeTypes() {
}
}
if (type.isShared()) {
- o << S32LEB(BinaryConsts::EncodedType::Shared);
+ o << uint8_t(BinaryConsts::EncodedType::SharedDef);
}
switch (type.getKind()) {
case HeapTypeKind::Func: {
- o << S32LEB(BinaryConsts::EncodedType::Func);
+ o << uint8_t(BinaryConsts::EncodedType::Func);
auto sig = type.getSignature();
for (auto& sigType : {sig.params, sig.results}) {
o << U32LEB(sigType.size());
@@ -304,7 +304,7 @@ void WasmBinaryWriter::writeTypes() {
break;
}
case HeapTypeKind::Struct: {
- o << S32LEB(BinaryConsts::EncodedType::Struct);
+ o << uint8_t(BinaryConsts::EncodedType::Struct);
auto fields = type.getStruct().fields;
o << U32LEB(fields.size());
for (const auto& field : fields) {
@@ -313,11 +313,11 @@ void WasmBinaryWriter::writeTypes() {
break;
}
case HeapTypeKind::Array:
- o << S32LEB(BinaryConsts::EncodedType::Array);
+ o << uint8_t(BinaryConsts::EncodedType::Array);
writeField(type.getArray().element);
break;
case HeapTypeKind::Cont:
- o << S32LEB(BinaryConsts::EncodedType::Cont);
+ o << uint8_t(BinaryConsts::EncodedType::Cont);
writeHeapType(type.getContinuation().type);
break;
case HeapTypeKind::Basic:
@@ -2405,7 +2405,7 @@ void WasmBinaryReader::readTypes() {
for (size_t i = 0; i < builder.size(); i++) {
BYN_TRACE("read one\n");
- auto form = getS32LEB();
+ auto form = getInt8();
if (form == BinaryConsts::EncodedType::Rec) {
uint32_t groupSize = getU32LEB();
if (groupSize == 0u) {
@@ -2416,7 +2416,7 @@ void WasmBinaryReader::readTypes() {
// allocate space for the extra types.
builder.grow(groupSize - 1);
builder.createRecGroup(i, groupSize);
- form = getS32LEB();
+ form = getInt8();
}
std::optional<uint32_t> superIndex;
if (form == BinaryConsts::EncodedType::Sub ||
@@ -2432,11 +2432,11 @@ void WasmBinaryReader::readTypes() {
}
superIndex = getU32LEB();
}
- form = getS32LEB();
+ form = getInt8();
}
- if (form == BinaryConsts::Shared) {
+ if (form == BinaryConsts::SharedDef) {
builder[i].setShared();
- form = getS32LEB();
+ form = getInt8();
}
if (form == BinaryConsts::EncodedType::Func) {
builder[i] = readSignatureDef();