mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-18 18:42:46 +02:00
[WebAssembly] Make tag attribute's encoding uint8
This changes the encoding of the `attribute` field, which currently only contains the value `0` denoting this tag is for an exception, from `varuint32` to `uint8`. This field is effectively unused at the moment and reserved for future use, and it is not likely to need `varuint32` even in future. See https://github.com/WebAssembly/exception-handling/pull/162. This does not change any encoded binaries because `0` is encoded in the same way both in `varuint32` and `uint8`. Reviewed By: tlively Differential Revision: https://reviews.llvm.org/D104571
This commit is contained in:
parent
0c81356419
commit
68b04daf84
@ -103,7 +103,7 @@ struct WasmGlobal {
|
|||||||
|
|
||||||
struct WasmTagType {
|
struct WasmTagType {
|
||||||
// Kind of tag. Currently only WASM_TAG_ATTRIBUTE_EXCEPTION is possible.
|
// Kind of tag. Currently only WASM_TAG_ATTRIBUTE_EXCEPTION is possible.
|
||||||
uint32_t Attribute;
|
uint8_t Attribute;
|
||||||
uint32_t SigIndex;
|
uint32_t SigIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -363,7 +363,7 @@ enum WasmSegmentFlag : unsigned {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Kinds of tag attributes.
|
// Kinds of tag attributes.
|
||||||
enum WasmTagAttribute : unsigned {
|
enum WasmTagAttribute : uint8_t {
|
||||||
WASM_TAG_ATTRIBUTE_EXCEPTION = 0x0,
|
WASM_TAG_ATTRIBUTE_EXCEPTION = 0x0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -814,7 +814,7 @@ void WasmObjectWriter::writeImportSection(ArrayRef<wasm::WasmImport> Imports,
|
|||||||
encodeULEB128(NumElements, W->OS); // initial
|
encodeULEB128(NumElements, W->OS); // initial
|
||||||
break;
|
break;
|
||||||
case wasm::WASM_EXTERNAL_TAG:
|
case wasm::WASM_EXTERNAL_TAG:
|
||||||
encodeULEB128(Import.Tag.Attribute, W->OS);
|
W->OS << char(Import.Tag.Attribute);
|
||||||
encodeULEB128(Import.Tag.SigIndex, W->OS);
|
encodeULEB128(Import.Tag.SigIndex, W->OS);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -848,7 +848,7 @@ void WasmObjectWriter::writeTagSection(ArrayRef<wasm::WasmTagType> Tags) {
|
|||||||
|
|
||||||
encodeULEB128(Tags.size(), W->OS);
|
encodeULEB128(Tags.size(), W->OS);
|
||||||
for (const wasm::WasmTagType &Tag : Tags) {
|
for (const wasm::WasmTagType &Tag : Tags) {
|
||||||
encodeULEB128(Tag.Attribute, W->OS);
|
W->OS << char(Tag.Attribute);
|
||||||
encodeULEB128(Tag.SigIndex, W->OS);
|
encodeULEB128(Tag.SigIndex, W->OS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1066,7 +1066,7 @@ Error WasmObjectFile::parseImportSection(ReadContext &Ctx) {
|
|||||||
}
|
}
|
||||||
case wasm::WASM_EXTERNAL_TAG:
|
case wasm::WASM_EXTERNAL_TAG:
|
||||||
NumImportedTags++;
|
NumImportedTags++;
|
||||||
Im.Tag.Attribute = readVarint32(Ctx);
|
Im.Tag.Attribute = readUint8(Ctx);
|
||||||
Im.Tag.SigIndex = readVarint32(Ctx);
|
Im.Tag.SigIndex = readVarint32(Ctx);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1143,7 +1143,7 @@ Error WasmObjectFile::parseTagSection(ReadContext &Ctx) {
|
|||||||
while (Count--) {
|
while (Count--) {
|
||||||
wasm::WasmTag Tag;
|
wasm::WasmTag Tag;
|
||||||
Tag.Index = NumImportedTags + Tags.size();
|
Tag.Index = NumImportedTags + Tags.size();
|
||||||
Tag.Type.Attribute = readVaruint32(Ctx);
|
Tag.Type.Attribute = readUint8(Ctx);
|
||||||
Tag.Type.SigIndex = readVaruint32(Ctx);
|
Tag.Type.SigIndex = readVaruint32(Ctx);
|
||||||
Tags.push_back(Tag);
|
Tags.push_back(Tag);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user