mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 02:33:06 +01:00
[WebAssembly] Rename event to tag
We recently decided to change 'event' to 'tag', and 'event section' to 'tag section', out of the rationale that the section contains a generalized tag that references a type, which may be used for something other than exceptions, and the name 'event' can be confusing in the web context. See - https://github.com/WebAssembly/exception-handling/issues/159#issuecomment-857910130 - https://github.com/WebAssembly/exception-handling/pull/161 Reviewed By: tlively Differential Revision: https://reviews.llvm.org/D104423
This commit is contained in:
parent
2576f49320
commit
f7b0205560
@ -101,15 +101,15 @@ struct WasmGlobal {
|
||||
StringRef SymbolName; // from the "linking" section
|
||||
};
|
||||
|
||||
struct WasmEventType {
|
||||
// Kind of event. Currently only WASM_EVENT_ATTRIBUTE_EXCEPTION is possible.
|
||||
struct WasmTagType {
|
||||
// Kind of tag. Currently only WASM_TAG_ATTRIBUTE_EXCEPTION is possible.
|
||||
uint32_t Attribute;
|
||||
uint32_t SigIndex;
|
||||
};
|
||||
|
||||
struct WasmEvent {
|
||||
struct WasmTag {
|
||||
uint32_t Index;
|
||||
WasmEventType Type;
|
||||
WasmTagType Type;
|
||||
StringRef SymbolName; // from the "linking" section
|
||||
};
|
||||
|
||||
@ -122,7 +122,7 @@ struct WasmImport {
|
||||
WasmGlobalType Global;
|
||||
WasmTableType Table;
|
||||
WasmLimits Memory;
|
||||
WasmEventType Event;
|
||||
WasmTagType Tag;
|
||||
};
|
||||
};
|
||||
|
||||
@ -238,7 +238,7 @@ enum : unsigned {
|
||||
WASM_SEC_CODE = 10, // Function bodies (code)
|
||||
WASM_SEC_DATA = 11, // Data segments
|
||||
WASM_SEC_DATACOUNT = 12, // Data segment count
|
||||
WASM_SEC_EVENT = 13 // Event declarations
|
||||
WASM_SEC_TAG = 13 // Tag declarations
|
||||
};
|
||||
|
||||
// Type immediate encodings used in various contexts.
|
||||
@ -260,7 +260,7 @@ enum : unsigned {
|
||||
WASM_EXTERNAL_TABLE = 0x1,
|
||||
WASM_EXTERNAL_MEMORY = 0x2,
|
||||
WASM_EXTERNAL_GLOBAL = 0x3,
|
||||
WASM_EXTERNAL_EVENT = 0x4,
|
||||
WASM_EXTERNAL_TAG = 0x4,
|
||||
};
|
||||
|
||||
// Opcodes used in initializer expressions.
|
||||
@ -343,7 +343,7 @@ enum : unsigned {
|
||||
enum : unsigned {
|
||||
WASM_COMDAT_DATA = 0x0,
|
||||
WASM_COMDAT_FUNCTION = 0x1,
|
||||
// GLOBAL, EVENT, and TABLE are in here but LLVM doesn't use them yet.
|
||||
// GLOBAL, TAG, and TABLE are in here but LLVM doesn't use them yet.
|
||||
WASM_COMDAT_SECTION = 0x5,
|
||||
};
|
||||
|
||||
@ -353,7 +353,7 @@ enum WasmSymbolType : unsigned {
|
||||
WASM_SYMBOL_TYPE_DATA = 0x1,
|
||||
WASM_SYMBOL_TYPE_GLOBAL = 0x2,
|
||||
WASM_SYMBOL_TYPE_SECTION = 0x3,
|
||||
WASM_SYMBOL_TYPE_EVENT = 0x4,
|
||||
WASM_SYMBOL_TYPE_TAG = 0x4,
|
||||
WASM_SYMBOL_TYPE_TABLE = 0x5,
|
||||
};
|
||||
|
||||
@ -362,9 +362,9 @@ enum WasmSegmentFlag : unsigned {
|
||||
WASM_SEG_FLAG_TLS = 0x2,
|
||||
};
|
||||
|
||||
// Kinds of event attributes.
|
||||
enum WasmEventAttribute : unsigned {
|
||||
WASM_EVENT_ATTRIBUTE_EXCEPTION = 0x0,
|
||||
// Kinds of tag attributes.
|
||||
enum WasmTagAttribute : unsigned {
|
||||
WASM_TAG_ATTRIBUTE_EXCEPTION = 0x0,
|
||||
};
|
||||
|
||||
const unsigned WASM_SYMBOL_BINDING_MASK = 0x3;
|
||||
|
@ -12,7 +12,7 @@ WASM_RELOC(R_WASM_TYPE_INDEX_LEB, 6)
|
||||
WASM_RELOC(R_WASM_GLOBAL_INDEX_LEB, 7)
|
||||
WASM_RELOC(R_WASM_FUNCTION_OFFSET_I32, 8)
|
||||
WASM_RELOC(R_WASM_SECTION_OFFSET_I32, 9)
|
||||
WASM_RELOC(R_WASM_EVENT_INDEX_LEB, 10)
|
||||
WASM_RELOC(R_WASM_TAG_INDEX_LEB, 10)
|
||||
WASM_RELOC(R_WASM_MEMORY_ADDR_REL_SLEB, 11)
|
||||
WASM_RELOC(R_WASM_TABLE_INDEX_REL_SLEB, 12)
|
||||
WASM_RELOC(R_WASM_GLOBAL_INDEX_I32, 13)
|
||||
|
@ -24,7 +24,7 @@ class Function;
|
||||
class MachineBasicBlock;
|
||||
|
||||
namespace WebAssembly {
|
||||
enum EventTag { CPP_EXCEPTION = 0, C_LONGJMP = 1 };
|
||||
enum Tag { CPP_EXCEPTION = 0, C_LONGJMP = 1 };
|
||||
}
|
||||
|
||||
using BBOrMBB = PointerUnion<const BasicBlock *, MachineBasicBlock *>;
|
||||
|
@ -27,7 +27,7 @@ class MCSymbolWasm : public MCSymbol {
|
||||
wasm::WasmSignature *Signature = nullptr;
|
||||
Optional<wasm::WasmGlobalType> GlobalType;
|
||||
Optional<wasm::WasmTableType> TableType;
|
||||
Optional<wasm::WasmEventType> EventType;
|
||||
Optional<wasm::WasmTagType> TagType;
|
||||
|
||||
/// An expression describing how to calculate the size of a symbol. If a
|
||||
/// symbol has no size this field will be NULL.
|
||||
@ -47,7 +47,7 @@ public:
|
||||
bool isGlobal() const { return Type == wasm::WASM_SYMBOL_TYPE_GLOBAL; }
|
||||
bool isTable() const { return Type == wasm::WASM_SYMBOL_TYPE_TABLE; }
|
||||
bool isSection() const { return Type == wasm::WASM_SYMBOL_TYPE_SECTION; }
|
||||
bool isEvent() const { return Type == wasm::WASM_SYMBOL_TYPE_EVENT; }
|
||||
bool isTag() const { return Type == wasm::WASM_SYMBOL_TYPE_TAG; }
|
||||
|
||||
Optional<wasm::WasmSymbolType> getType() const { return Type; }
|
||||
|
||||
@ -143,11 +143,11 @@ public:
|
||||
setTableType({uint8_t(VT), Limits});
|
||||
}
|
||||
|
||||
const wasm::WasmEventType &getEventType() const {
|
||||
assert(EventType.hasValue());
|
||||
return EventType.getValue();
|
||||
const wasm::WasmTagType &getTagType() const {
|
||||
assert(TagType.hasValue());
|
||||
return TagType.getValue();
|
||||
}
|
||||
void setEventType(wasm::WasmEventType ET) { EventType = ET; }
|
||||
void setTagType(wasm::WasmTagType ET) { TagType = ET; }
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
@ -37,15 +37,15 @@ public:
|
||||
WasmSymbol(const wasm::WasmSymbolInfo &Info,
|
||||
const wasm::WasmGlobalType *GlobalType,
|
||||
const wasm::WasmTableType *TableType,
|
||||
const wasm::WasmEventType *EventType,
|
||||
const wasm::WasmTagType *TagType,
|
||||
const wasm::WasmSignature *Signature)
|
||||
: Info(Info), GlobalType(GlobalType), TableType(TableType),
|
||||
EventType(EventType), Signature(Signature) {}
|
||||
TagType(TagType), Signature(Signature) {}
|
||||
|
||||
const wasm::WasmSymbolInfo &Info;
|
||||
const wasm::WasmGlobalType *GlobalType;
|
||||
const wasm::WasmTableType *TableType;
|
||||
const wasm::WasmEventType *EventType;
|
||||
const wasm::WasmTagType *TagType;
|
||||
const wasm::WasmSignature *Signature;
|
||||
|
||||
bool isTypeFunction() const {
|
||||
@ -64,7 +64,7 @@ public:
|
||||
return Info.Kind == wasm::WASM_SYMBOL_TYPE_SECTION;
|
||||
}
|
||||
|
||||
bool isTypeEvent() const { return Info.Kind == wasm::WASM_SYMBOL_TYPE_EVENT; }
|
||||
bool isTypeTag() const { return Info.Kind == wasm::WASM_SYMBOL_TYPE_TAG; }
|
||||
|
||||
bool isDefined() const { return !isUndefined(); }
|
||||
|
||||
@ -143,7 +143,7 @@ public:
|
||||
ArrayRef<wasm::WasmTable> tables() const { return Tables; }
|
||||
ArrayRef<wasm::WasmLimits> memories() const { return Memories; }
|
||||
ArrayRef<wasm::WasmGlobal> globals() const { return Globals; }
|
||||
ArrayRef<wasm::WasmEvent> events() const { return Events; }
|
||||
ArrayRef<wasm::WasmTag> tags() const { return Tags; }
|
||||
ArrayRef<wasm::WasmExport> exports() const { return Exports; }
|
||||
ArrayRef<WasmSymbol> syms() const { return Symbols; }
|
||||
const wasm::WasmLinkingData &linkingData() const { return LinkingData; }
|
||||
@ -156,7 +156,7 @@ public:
|
||||
uint32_t getNumImportedGlobals() const { return NumImportedGlobals; }
|
||||
uint32_t getNumImportedTables() const { return NumImportedTables; }
|
||||
uint32_t getNumImportedFunctions() const { return NumImportedFunctions; }
|
||||
uint32_t getNumImportedEvents() const { return NumImportedEvents; }
|
||||
uint32_t getNumImportedTags() const { return NumImportedTags; }
|
||||
uint32_t getNumSections() const { return Sections.size(); }
|
||||
void moveSymbolNext(DataRefImpl &Symb) const override;
|
||||
|
||||
@ -223,18 +223,18 @@ private:
|
||||
bool isValidTableNumber(uint32_t Index) const;
|
||||
bool isDefinedGlobalIndex(uint32_t Index) const;
|
||||
bool isDefinedTableNumber(uint32_t Index) const;
|
||||
bool isValidEventIndex(uint32_t Index) const;
|
||||
bool isDefinedEventIndex(uint32_t Index) const;
|
||||
bool isValidTagIndex(uint32_t Index) const;
|
||||
bool isDefinedTagIndex(uint32_t Index) const;
|
||||
bool isValidFunctionSymbol(uint32_t Index) const;
|
||||
bool isValidTableSymbol(uint32_t Index) const;
|
||||
bool isValidGlobalSymbol(uint32_t Index) const;
|
||||
bool isValidEventSymbol(uint32_t Index) const;
|
||||
bool isValidTagSymbol(uint32_t Index) const;
|
||||
bool isValidDataSymbol(uint32_t Index) const;
|
||||
bool isValidSectionSymbol(uint32_t Index) const;
|
||||
wasm::WasmFunction &getDefinedFunction(uint32_t Index);
|
||||
const wasm::WasmFunction &getDefinedFunction(uint32_t Index) const;
|
||||
wasm::WasmGlobal &getDefinedGlobal(uint32_t Index);
|
||||
wasm::WasmEvent &getDefinedEvent(uint32_t Index);
|
||||
wasm::WasmTag &getDefinedTag(uint32_t Index);
|
||||
|
||||
const WasmSection &getWasmSection(DataRefImpl Ref) const;
|
||||
const wasm::WasmRelocation &getWasmRelocation(DataRefImpl Ref) const;
|
||||
@ -249,7 +249,7 @@ private:
|
||||
Error parseFunctionSection(ReadContext &Ctx);
|
||||
Error parseTableSection(ReadContext &Ctx);
|
||||
Error parseMemorySection(ReadContext &Ctx);
|
||||
Error parseEventSection(ReadContext &Ctx);
|
||||
Error parseTagSection(ReadContext &Ctx);
|
||||
Error parseGlobalSection(ReadContext &Ctx);
|
||||
Error parseExportSection(ReadContext &Ctx);
|
||||
Error parseStartSection(ReadContext &Ctx);
|
||||
@ -278,7 +278,7 @@ private:
|
||||
std::vector<wasm::WasmTable> Tables;
|
||||
std::vector<wasm::WasmLimits> Memories;
|
||||
std::vector<wasm::WasmGlobal> Globals;
|
||||
std::vector<wasm::WasmEvent> Events;
|
||||
std::vector<wasm::WasmTag> Tags;
|
||||
std::vector<wasm::WasmImport> Imports;
|
||||
std::vector<wasm::WasmExport> Exports;
|
||||
std::vector<wasm::WasmElemSegment> ElemSegments;
|
||||
@ -296,10 +296,10 @@ private:
|
||||
uint32_t NumImportedGlobals = 0;
|
||||
uint32_t NumImportedTables = 0;
|
||||
uint32_t NumImportedFunctions = 0;
|
||||
uint32_t NumImportedEvents = 0;
|
||||
uint32_t NumImportedTags = 0;
|
||||
uint32_t CodeSection = 0;
|
||||
uint32_t DataSection = 0;
|
||||
uint32_t EventSection = 0;
|
||||
uint32_t TagSection = 0;
|
||||
uint32_t GlobalSection = 0;
|
||||
uint32_t TableSection = 0;
|
||||
};
|
||||
@ -317,7 +317,7 @@ public:
|
||||
WASM_SEC_ORDER_FUNCTION,
|
||||
WASM_SEC_ORDER_TABLE,
|
||||
WASM_SEC_ORDER_MEMORY,
|
||||
WASM_SEC_ORDER_EVENT,
|
||||
WASM_SEC_ORDER_TAG,
|
||||
WASM_SEC_ORDER_GLOBAL,
|
||||
WASM_SEC_ORDER_EXPORT,
|
||||
WASM_SEC_ORDER_START,
|
||||
|
@ -77,7 +77,7 @@ struct Global {
|
||||
wasm::WasmInitExpr InitExpr;
|
||||
};
|
||||
|
||||
struct Event {
|
||||
struct Tag {
|
||||
uint32_t Index;
|
||||
uint32_t Attribute;
|
||||
uint32_t SigIndex;
|
||||
@ -92,7 +92,7 @@ struct Import {
|
||||
Global GlobalImport;
|
||||
Table TableImport;
|
||||
Limits Memory;
|
||||
Event EventImport;
|
||||
Tag TagImport;
|
||||
};
|
||||
};
|
||||
|
||||
@ -316,14 +316,14 @@ struct MemorySection : Section {
|
||||
std::vector<Limits> Memories;
|
||||
};
|
||||
|
||||
struct EventSection : Section {
|
||||
EventSection() : Section(wasm::WASM_SEC_EVENT) {}
|
||||
struct TagSection : Section {
|
||||
TagSection() : Section(wasm::WASM_SEC_TAG) {}
|
||||
|
||||
static bool classof(const Section *S) {
|
||||
return S->Type == wasm::WASM_SEC_EVENT;
|
||||
return S->Type == wasm::WASM_SEC_TAG;
|
||||
}
|
||||
|
||||
std::vector<Event> Events;
|
||||
std::vector<Tag> Tags;
|
||||
};
|
||||
|
||||
struct GlobalSection : Section {
|
||||
@ -425,7 +425,7 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::SymbolInfo)
|
||||
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::InitFunction)
|
||||
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::ComdatEntry)
|
||||
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Comdat)
|
||||
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Event)
|
||||
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Tag)
|
||||
|
||||
namespace llvm {
|
||||
namespace yaml {
|
||||
@ -570,8 +570,8 @@ template <> struct ScalarEnumerationTraits<WasmYAML::RelocType> {
|
||||
static void enumeration(IO &IO, WasmYAML::RelocType &Kind);
|
||||
};
|
||||
|
||||
template <> struct MappingTraits<WasmYAML::Event> {
|
||||
static void mapping(IO &IO, WasmYAML::Event &Event);
|
||||
template <> struct MappingTraits<WasmYAML::Tag> {
|
||||
static void mapping(IO &IO, WasmYAML::Tag &Tag);
|
||||
};
|
||||
|
||||
} // end namespace yaml
|
||||
|
@ -20,8 +20,8 @@ std::string llvm::wasm::toString(wasm::WasmSymbolType Type) {
|
||||
return "WASM_SYMBOL_TYPE_DATA";
|
||||
case wasm::WASM_SYMBOL_TYPE_SECTION:
|
||||
return "WASM_SYMBOL_TYPE_SECTION";
|
||||
case wasm::WASM_SYMBOL_TYPE_EVENT:
|
||||
return "WASM_SYMBOL_TYPE_EVENT";
|
||||
case wasm::WASM_SYMBOL_TYPE_TAG:
|
||||
return "WASM_SYMBOL_TYPE_TAG";
|
||||
}
|
||||
llvm_unreachable("unknown symbol type");
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ class WasmObjectWriter : public MCObjectWriter {
|
||||
// for TABLE_INDEX relocation types (i.e. address taken functions).
|
||||
DenseMap<const MCSymbolWasm *, uint32_t> TableIndices;
|
||||
// Maps function/global/table symbols to the
|
||||
// function/global/table/event/section index space.
|
||||
// function/global/table/tag/section index space.
|
||||
DenseMap<const MCSymbolWasm *, uint32_t> WasmIndices;
|
||||
DenseMap<const MCSymbolWasm *, uint32_t> GOTIndices;
|
||||
// Maps data symbols to the Wasm segment and offset/size with the segment.
|
||||
@ -219,7 +219,7 @@ class WasmObjectWriter : public MCObjectWriter {
|
||||
unsigned NumFunctionImports = 0;
|
||||
unsigned NumGlobalImports = 0;
|
||||
unsigned NumTableImports = 0;
|
||||
unsigned NumEventImports = 0;
|
||||
unsigned NumTagImports = 0;
|
||||
uint32_t SectionCount = 0;
|
||||
|
||||
enum class DwoMode {
|
||||
@ -317,7 +317,7 @@ private:
|
||||
uint32_t writeCodeSection(const MCAssembler &Asm, const MCAsmLayout &Layout,
|
||||
ArrayRef<WasmFunction> Functions);
|
||||
uint32_t writeDataSection(const MCAsmLayout &Layout);
|
||||
void writeEventSection(ArrayRef<wasm::WasmEventType> Events);
|
||||
void writeTagSection(ArrayRef<wasm::WasmTagType> Tags);
|
||||
void writeGlobalSection(ArrayRef<wasm::WasmGlobal> Globals);
|
||||
void writeTableSection(ArrayRef<wasm::WasmTable> Tables);
|
||||
void writeRelocSection(uint32_t SectionIndex, StringRef Name,
|
||||
@ -337,9 +337,9 @@ private:
|
||||
|
||||
uint32_t getRelocationIndexValue(const WasmRelocationEntry &RelEntry);
|
||||
uint32_t getFunctionType(const MCSymbolWasm &Symbol);
|
||||
uint32_t getEventType(const MCSymbolWasm &Symbol);
|
||||
uint32_t getTagType(const MCSymbolWasm &Symbol);
|
||||
void registerFunctionType(const MCSymbolWasm &Symbol);
|
||||
void registerEventType(const MCSymbolWasm &Symbol);
|
||||
void registerTagType(const MCSymbolWasm &Symbol);
|
||||
};
|
||||
|
||||
} // end anonymous namespace
|
||||
@ -612,9 +612,9 @@ WasmObjectWriter::getProvisionalValue(const WasmRelocationEntry &RelEntry,
|
||||
case wasm::R_WASM_FUNCTION_INDEX_LEB:
|
||||
case wasm::R_WASM_GLOBAL_INDEX_LEB:
|
||||
case wasm::R_WASM_GLOBAL_INDEX_I32:
|
||||
case wasm::R_WASM_EVENT_INDEX_LEB:
|
||||
case wasm::R_WASM_TAG_INDEX_LEB:
|
||||
case wasm::R_WASM_TABLE_NUMBER_LEB:
|
||||
// Provisional value is function/global/event Wasm index
|
||||
// Provisional value is function/global/tag Wasm index
|
||||
assert(WasmIndices.count(RelEntry.Symbol) > 0 && "symbol not found in wasm index space");
|
||||
return WasmIndices[RelEntry.Symbol];
|
||||
case wasm::R_WASM_FUNCTION_OFFSET_I32:
|
||||
@ -717,7 +717,7 @@ void WasmObjectWriter::applyRelocations(
|
||||
case wasm::R_WASM_TYPE_INDEX_LEB:
|
||||
case wasm::R_WASM_GLOBAL_INDEX_LEB:
|
||||
case wasm::R_WASM_MEMORY_ADDR_LEB:
|
||||
case wasm::R_WASM_EVENT_INDEX_LEB:
|
||||
case wasm::R_WASM_TAG_INDEX_LEB:
|
||||
case wasm::R_WASM_TABLE_NUMBER_LEB:
|
||||
writePatchableLEB<5>(Stream, Value, Offset);
|
||||
break;
|
||||
@ -813,9 +813,9 @@ void WasmObjectWriter::writeImportSection(ArrayRef<wasm::WasmImport> Imports,
|
||||
encodeULEB128(0, W->OS); // flags
|
||||
encodeULEB128(NumElements, W->OS); // initial
|
||||
break;
|
||||
case wasm::WASM_EXTERNAL_EVENT:
|
||||
encodeULEB128(Import.Event.Attribute, W->OS);
|
||||
encodeULEB128(Import.Event.SigIndex, W->OS);
|
||||
case wasm::WASM_EXTERNAL_TAG:
|
||||
encodeULEB128(Import.Tag.Attribute, W->OS);
|
||||
encodeULEB128(Import.Tag.SigIndex, W->OS);
|
||||
break;
|
||||
default:
|
||||
llvm_unreachable("unsupported import kind");
|
||||
@ -839,17 +839,17 @@ void WasmObjectWriter::writeFunctionSection(ArrayRef<WasmFunction> Functions) {
|
||||
endSection(Section);
|
||||
}
|
||||
|
||||
void WasmObjectWriter::writeEventSection(ArrayRef<wasm::WasmEventType> Events) {
|
||||
if (Events.empty())
|
||||
void WasmObjectWriter::writeTagSection(ArrayRef<wasm::WasmTagType> Tags) {
|
||||
if (Tags.empty())
|
||||
return;
|
||||
|
||||
SectionBookkeeping Section;
|
||||
startSection(Section, wasm::WASM_SEC_EVENT);
|
||||
startSection(Section, wasm::WASM_SEC_TAG);
|
||||
|
||||
encodeULEB128(Events.size(), W->OS);
|
||||
for (const wasm::WasmEventType &Event : Events) {
|
||||
encodeULEB128(Event.Attribute, W->OS);
|
||||
encodeULEB128(Event.SigIndex, W->OS);
|
||||
encodeULEB128(Tags.size(), W->OS);
|
||||
for (const wasm::WasmTagType &Tag : Tags) {
|
||||
encodeULEB128(Tag.Attribute, W->OS);
|
||||
encodeULEB128(Tag.SigIndex, W->OS);
|
||||
}
|
||||
|
||||
endSection(Section);
|
||||
@ -1103,7 +1103,7 @@ void WasmObjectWriter::writeLinkingMetaDataSection(
|
||||
switch (Sym.Kind) {
|
||||
case wasm::WASM_SYMBOL_TYPE_FUNCTION:
|
||||
case wasm::WASM_SYMBOL_TYPE_GLOBAL:
|
||||
case wasm::WASM_SYMBOL_TYPE_EVENT:
|
||||
case wasm::WASM_SYMBOL_TYPE_TAG:
|
||||
case wasm::WASM_SYMBOL_TYPE_TABLE:
|
||||
encodeULEB128(Sym.ElementIndex, W->OS);
|
||||
if ((Sym.Flags & wasm::WASM_SYMBOL_UNDEFINED) == 0 ||
|
||||
@ -1196,8 +1196,8 @@ uint32_t WasmObjectWriter::getFunctionType(const MCSymbolWasm &Symbol) {
|
||||
return TypeIndices[&Symbol];
|
||||
}
|
||||
|
||||
uint32_t WasmObjectWriter::getEventType(const MCSymbolWasm &Symbol) {
|
||||
assert(Symbol.isEvent());
|
||||
uint32_t WasmObjectWriter::getTagType(const MCSymbolWasm &Symbol) {
|
||||
assert(Symbol.isTag());
|
||||
assert(TypeIndices.count(&Symbol));
|
||||
return TypeIndices[&Symbol];
|
||||
}
|
||||
@ -1222,8 +1222,8 @@ void WasmObjectWriter::registerFunctionType(const MCSymbolWasm &Symbol) {
|
||||
LLVM_DEBUG(dbgs() << " -> type index: " << Pair.first->second << "\n");
|
||||
}
|
||||
|
||||
void WasmObjectWriter::registerEventType(const MCSymbolWasm &Symbol) {
|
||||
assert(Symbol.isEvent());
|
||||
void WasmObjectWriter::registerTagType(const MCSymbolWasm &Symbol) {
|
||||
assert(Symbol.isTag());
|
||||
|
||||
// TODO Currently we don't generate imported exceptions, but if we do, we
|
||||
// should have a way of infering types of imported exceptions.
|
||||
@ -1238,7 +1238,7 @@ void WasmObjectWriter::registerEventType(const MCSymbolWasm &Symbol) {
|
||||
Signatures.push_back(S);
|
||||
TypeIndices[&Symbol] = Pair.first->second;
|
||||
|
||||
LLVM_DEBUG(dbgs() << "registerEventType: " << Symbol << " new:" << Pair.second
|
||||
LLVM_DEBUG(dbgs() << "registerTagType: " << Symbol << " new:" << Pair.second
|
||||
<< "\n");
|
||||
LLVM_DEBUG(dbgs() << " -> type index: " << Pair.first->second << "\n");
|
||||
}
|
||||
@ -1292,8 +1292,8 @@ void WasmObjectWriter::prepareImports(
|
||||
registerFunctionType(*cast<MCSymbolWasm>(BS));
|
||||
}
|
||||
|
||||
if (WS.isEvent())
|
||||
registerEventType(WS);
|
||||
if (WS.isTag())
|
||||
registerTagType(WS);
|
||||
|
||||
if (WS.isTemporary())
|
||||
continue;
|
||||
@ -1321,19 +1321,19 @@ void WasmObjectWriter::prepareImports(
|
||||
Imports.push_back(Import);
|
||||
assert(WasmIndices.count(&WS) == 0);
|
||||
WasmIndices[&WS] = NumGlobalImports++;
|
||||
} else if (WS.isEvent()) {
|
||||
} else if (WS.isTag()) {
|
||||
if (WS.isWeak())
|
||||
report_fatal_error("undefined event symbol cannot be weak");
|
||||
report_fatal_error("undefined tag symbol cannot be weak");
|
||||
|
||||
wasm::WasmImport Import;
|
||||
Import.Module = WS.getImportModule();
|
||||
Import.Field = WS.getImportName();
|
||||
Import.Kind = wasm::WASM_EXTERNAL_EVENT;
|
||||
Import.Event.Attribute = wasm::WASM_EVENT_ATTRIBUTE_EXCEPTION;
|
||||
Import.Event.SigIndex = getEventType(WS);
|
||||
Import.Kind = wasm::WASM_EXTERNAL_TAG;
|
||||
Import.Tag.Attribute = wasm::WASM_TAG_ATTRIBUTE_EXCEPTION;
|
||||
Import.Tag.SigIndex = getTagType(WS);
|
||||
Imports.push_back(Import);
|
||||
assert(WasmIndices.count(&WS) == 0);
|
||||
WasmIndices[&WS] = NumEventImports++;
|
||||
WasmIndices[&WS] = NumTagImports++;
|
||||
} else if (WS.isTable()) {
|
||||
if (WS.isWeak())
|
||||
report_fatal_error("undefined table symbol cannot be weak");
|
||||
@ -1398,7 +1398,7 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
|
||||
SmallVector<uint32_t, 4> TableElems;
|
||||
SmallVector<wasm::WasmImport, 4> Imports;
|
||||
SmallVector<wasm::WasmExport, 4> Exports;
|
||||
SmallVector<wasm::WasmEventType, 1> Events;
|
||||
SmallVector<wasm::WasmTagType, 1> Tags;
|
||||
SmallVector<wasm::WasmGlobal, 1> Globals;
|
||||
SmallVector<wasm::WasmTable, 1> Tables;
|
||||
SmallVector<wasm::WasmSymbolInfo, 4> SymbolInfos;
|
||||
@ -1632,23 +1632,23 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
|
||||
}
|
||||
LLVM_DEBUG(dbgs() << " -> table index: "
|
||||
<< WasmIndices.find(&WS)->second << "\n");
|
||||
} else if (WS.isEvent()) {
|
||||
} else if (WS.isTag()) {
|
||||
// C++ exception symbol (__cpp_exception)
|
||||
unsigned Index;
|
||||
if (WS.isDefined()) {
|
||||
Index = NumEventImports + Events.size();
|
||||
wasm::WasmEventType Event;
|
||||
Event.SigIndex = getEventType(WS);
|
||||
Event.Attribute = wasm::WASM_EVENT_ATTRIBUTE_EXCEPTION;
|
||||
Index = NumTagImports + Tags.size();
|
||||
wasm::WasmTagType Tag;
|
||||
Tag.SigIndex = getTagType(WS);
|
||||
Tag.Attribute = wasm::WASM_TAG_ATTRIBUTE_EXCEPTION;
|
||||
assert(WasmIndices.count(&WS) == 0);
|
||||
WasmIndices[&WS] = Index;
|
||||
Events.push_back(Event);
|
||||
Tags.push_back(Tag);
|
||||
} else {
|
||||
// An import; the index was assigned above.
|
||||
assert(WasmIndices.count(&WS) > 0);
|
||||
}
|
||||
LLVM_DEBUG(dbgs() << " -> event index: "
|
||||
<< WasmIndices.find(&WS)->second << "\n");
|
||||
LLVM_DEBUG(dbgs() << " -> tag index: " << WasmIndices.find(&WS)->second
|
||||
<< "\n");
|
||||
|
||||
} else {
|
||||
assert(WS.isSection());
|
||||
@ -1703,7 +1703,7 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
|
||||
DataLocations[&WS] = Ref;
|
||||
LLVM_DEBUG(dbgs() << " -> index:" << Ref.Segment << "\n");
|
||||
} else {
|
||||
report_fatal_error("don't yet support global/event aliases");
|
||||
report_fatal_error("don't yet support global/tag aliases");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1858,7 +1858,7 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
|
||||
writeFunctionSection(Functions);
|
||||
writeTableSection(Tables);
|
||||
// Skip the "memory" section; we import the memory instead.
|
||||
writeEventSection(Events);
|
||||
writeTagSection(Tags);
|
||||
writeGlobalSection(Globals);
|
||||
writeExportSection(Exports);
|
||||
const MCSymbol *IndirectFunctionTable =
|
||||
|
@ -572,7 +572,7 @@ static bool supportsWasm32(uint64_t Type) {
|
||||
case wasm::R_WASM_GLOBAL_INDEX_LEB:
|
||||
case wasm::R_WASM_FUNCTION_OFFSET_I32:
|
||||
case wasm::R_WASM_SECTION_OFFSET_I32:
|
||||
case wasm::R_WASM_EVENT_INDEX_LEB:
|
||||
case wasm::R_WASM_TAG_INDEX_LEB:
|
||||
case wasm::R_WASM_GLOBAL_INDEX_I32:
|
||||
case wasm::R_WASM_TABLE_NUMBER_LEB:
|
||||
case wasm::R_WASM_MEMORY_ADDR_LOCREL_I32:
|
||||
@ -609,7 +609,7 @@ static uint64_t resolveWasm32(uint64_t Type, uint64_t Offset, uint64_t S,
|
||||
case wasm::R_WASM_GLOBAL_INDEX_LEB:
|
||||
case wasm::R_WASM_FUNCTION_OFFSET_I32:
|
||||
case wasm::R_WASM_SECTION_OFFSET_I32:
|
||||
case wasm::R_WASM_EVENT_INDEX_LEB:
|
||||
case wasm::R_WASM_TAG_INDEX_LEB:
|
||||
case wasm::R_WASM_GLOBAL_INDEX_I32:
|
||||
case wasm::R_WASM_TABLE_NUMBER_LEB:
|
||||
case wasm::R_WASM_MEMORY_ADDR_LOCREL_I32:
|
||||
|
@ -316,8 +316,8 @@ Error WasmObjectFile::parseSection(WasmSection &Sec) {
|
||||
return parseTableSection(Ctx);
|
||||
case wasm::WASM_SEC_MEMORY:
|
||||
return parseMemorySection(Ctx);
|
||||
case wasm::WASM_SEC_EVENT:
|
||||
return parseEventSection(Ctx);
|
||||
case wasm::WASM_SEC_TAG:
|
||||
return parseTagSection(Ctx);
|
||||
case wasm::WASM_SEC_GLOBAL:
|
||||
return parseGlobalSection(Ctx);
|
||||
case wasm::WASM_SEC_EXPORT:
|
||||
@ -507,19 +507,19 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
|
||||
|
||||
std::vector<wasm::WasmImport *> ImportedGlobals;
|
||||
std::vector<wasm::WasmImport *> ImportedFunctions;
|
||||
std::vector<wasm::WasmImport *> ImportedEvents;
|
||||
std::vector<wasm::WasmImport *> ImportedTags;
|
||||
std::vector<wasm::WasmImport *> ImportedTables;
|
||||
ImportedGlobals.reserve(Imports.size());
|
||||
ImportedFunctions.reserve(Imports.size());
|
||||
ImportedEvents.reserve(Imports.size());
|
||||
ImportedTags.reserve(Imports.size());
|
||||
ImportedTables.reserve(Imports.size());
|
||||
for (auto &I : Imports) {
|
||||
if (I.Kind == wasm::WASM_EXTERNAL_FUNCTION)
|
||||
ImportedFunctions.emplace_back(&I);
|
||||
else if (I.Kind == wasm::WASM_EXTERNAL_GLOBAL)
|
||||
ImportedGlobals.emplace_back(&I);
|
||||
else if (I.Kind == wasm::WASM_EXTERNAL_EVENT)
|
||||
ImportedEvents.emplace_back(&I);
|
||||
else if (I.Kind == wasm::WASM_EXTERNAL_TAG)
|
||||
ImportedTags.emplace_back(&I);
|
||||
else if (I.Kind == wasm::WASM_EXTERNAL_TABLE)
|
||||
ImportedTables.emplace_back(&I);
|
||||
}
|
||||
@ -529,7 +529,7 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
|
||||
const wasm::WasmSignature *Signature = nullptr;
|
||||
const wasm::WasmGlobalType *GlobalType = nullptr;
|
||||
const wasm::WasmTableType *TableType = nullptr;
|
||||
const wasm::WasmEventType *EventType = nullptr;
|
||||
const wasm::WasmTagType *TagType = nullptr;
|
||||
|
||||
Info.Kind = readUint8(Ctx);
|
||||
Info.Flags = readVaruint32(Ctx);
|
||||
@ -660,11 +660,11 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
|
||||
break;
|
||||
}
|
||||
|
||||
case wasm::WASM_SYMBOL_TYPE_EVENT: {
|
||||
case wasm::WASM_SYMBOL_TYPE_TAG: {
|
||||
Info.ElementIndex = readVaruint32(Ctx);
|
||||
if (!isValidEventIndex(Info.ElementIndex) ||
|
||||
IsDefined != isDefinedEventIndex(Info.ElementIndex))
|
||||
return make_error<GenericBinaryError>("invalid event symbol index",
|
||||
if (!isValidTagIndex(Info.ElementIndex) ||
|
||||
IsDefined != isDefinedTagIndex(Info.ElementIndex))
|
||||
return make_error<GenericBinaryError>("invalid tag symbol index",
|
||||
object_error::parse_failed);
|
||||
if (!IsDefined && (Info.Flags & wasm::WASM_SYMBOL_BINDING_MASK) ==
|
||||
wasm::WASM_SYMBOL_BINDING_WEAK)
|
||||
@ -672,23 +672,23 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
|
||||
object_error::parse_failed);
|
||||
if (IsDefined) {
|
||||
Info.Name = readString(Ctx);
|
||||
unsigned EventIndex = Info.ElementIndex - NumImportedEvents;
|
||||
wasm::WasmEvent &Event = Events[EventIndex];
|
||||
Signature = &Signatures[Event.Type.SigIndex];
|
||||
EventType = &Event.Type;
|
||||
if (Event.SymbolName.empty())
|
||||
Event.SymbolName = Info.Name;
|
||||
unsigned TagIndex = Info.ElementIndex - NumImportedTags;
|
||||
wasm::WasmTag &Tag = Tags[TagIndex];
|
||||
Signature = &Signatures[Tag.Type.SigIndex];
|
||||
TagType = &Tag.Type;
|
||||
if (Tag.SymbolName.empty())
|
||||
Tag.SymbolName = Info.Name;
|
||||
|
||||
} else {
|
||||
wasm::WasmImport &Import = *ImportedEvents[Info.ElementIndex];
|
||||
wasm::WasmImport &Import = *ImportedTags[Info.ElementIndex];
|
||||
if ((Info.Flags & wasm::WASM_SYMBOL_EXPLICIT_NAME) != 0) {
|
||||
Info.Name = readString(Ctx);
|
||||
Info.ImportName = Import.Field;
|
||||
} else {
|
||||
Info.Name = Import.Field;
|
||||
}
|
||||
EventType = &Import.Event;
|
||||
Signature = &Signatures[EventType->SigIndex];
|
||||
TagType = &Import.Tag;
|
||||
Signature = &Signatures[TagType->SigIndex];
|
||||
if (!Import.Module.empty()) {
|
||||
Info.ImportModule = Import.Module;
|
||||
}
|
||||
@ -710,7 +710,7 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
|
||||
object_error::parse_failed);
|
||||
LinkingData.SymbolTable.emplace_back(Info);
|
||||
Symbols.emplace_back(LinkingData.SymbolTable.back(), GlobalType, TableType,
|
||||
EventType, Signature);
|
||||
TagType, Signature);
|
||||
LLVM_DEBUG(dbgs() << "Adding symbol: " << Symbols.back() << "\n");
|
||||
}
|
||||
|
||||
@ -899,9 +899,9 @@ Error WasmObjectFile::parseRelocSection(StringRef Name, ReadContext &Ctx) {
|
||||
return make_error<GenericBinaryError>("invalid relocation global index",
|
||||
object_error::parse_failed);
|
||||
break;
|
||||
case wasm::R_WASM_EVENT_INDEX_LEB:
|
||||
if (!isValidEventSymbol(Reloc.Index))
|
||||
return make_error<GenericBinaryError>("invalid relocation event index",
|
||||
case wasm::R_WASM_TAG_INDEX_LEB:
|
||||
if (!isValidTagSymbol(Reloc.Index))
|
||||
return make_error<GenericBinaryError>("invalid relocation tag index",
|
||||
object_error::parse_failed);
|
||||
break;
|
||||
case wasm::R_WASM_MEMORY_ADDR_LEB:
|
||||
@ -1064,10 +1064,10 @@ Error WasmObjectFile::parseImportSection(ReadContext &Ctx) {
|
||||
object_error::parse_failed);
|
||||
break;
|
||||
}
|
||||
case wasm::WASM_EXTERNAL_EVENT:
|
||||
NumImportedEvents++;
|
||||
Im.Event.Attribute = readVarint32(Ctx);
|
||||
Im.Event.SigIndex = readVarint32(Ctx);
|
||||
case wasm::WASM_EXTERNAL_TAG:
|
||||
NumImportedTags++;
|
||||
Im.Tag.Attribute = readVarint32(Ctx);
|
||||
Im.Tag.SigIndex = readVarint32(Ctx);
|
||||
break;
|
||||
default:
|
||||
return make_error<GenericBinaryError>("unexpected import kind",
|
||||
@ -1136,20 +1136,20 @@ Error WasmObjectFile::parseMemorySection(ReadContext &Ctx) {
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
Error WasmObjectFile::parseEventSection(ReadContext &Ctx) {
|
||||
EventSection = Sections.size();
|
||||
Error WasmObjectFile::parseTagSection(ReadContext &Ctx) {
|
||||
TagSection = Sections.size();
|
||||
uint32_t Count = readVaruint32(Ctx);
|
||||
Events.reserve(Count);
|
||||
Tags.reserve(Count);
|
||||
while (Count--) {
|
||||
wasm::WasmEvent Event;
|
||||
Event.Index = NumImportedEvents + Events.size();
|
||||
Event.Type.Attribute = readVaruint32(Ctx);
|
||||
Event.Type.SigIndex = readVaruint32(Ctx);
|
||||
Events.push_back(Event);
|
||||
wasm::WasmTag Tag;
|
||||
Tag.Index = NumImportedTags + Tags.size();
|
||||
Tag.Type.Attribute = readVaruint32(Ctx);
|
||||
Tag.Type.SigIndex = readVaruint32(Ctx);
|
||||
Tags.push_back(Tag);
|
||||
}
|
||||
|
||||
if (Ctx.Ptr != Ctx.End)
|
||||
return make_error<GenericBinaryError>("event section ended prematurely",
|
||||
return make_error<GenericBinaryError>("tag section ended prematurely",
|
||||
object_error::parse_failed);
|
||||
return Error::success();
|
||||
}
|
||||
@ -1194,9 +1194,9 @@ Error WasmObjectFile::parseExportSection(ReadContext &Ctx) {
|
||||
return make_error<GenericBinaryError>("invalid global export",
|
||||
object_error::parse_failed);
|
||||
break;
|
||||
case wasm::WASM_EXTERNAL_EVENT:
|
||||
if (!isValidEventIndex(Ex.Index))
|
||||
return make_error<GenericBinaryError>("invalid event export",
|
||||
case wasm::WASM_EXTERNAL_TAG:
|
||||
if (!isValidTagIndex(Ex.Index))
|
||||
return make_error<GenericBinaryError>("invalid tag export",
|
||||
object_error::parse_failed);
|
||||
break;
|
||||
case wasm::WASM_EXTERNAL_MEMORY:
|
||||
@ -1238,12 +1238,12 @@ bool WasmObjectFile::isDefinedTableNumber(uint32_t Index) const {
|
||||
return Index >= NumImportedTables && isValidTableNumber(Index);
|
||||
}
|
||||
|
||||
bool WasmObjectFile::isValidEventIndex(uint32_t Index) const {
|
||||
return Index < NumImportedEvents + Events.size();
|
||||
bool WasmObjectFile::isValidTagIndex(uint32_t Index) const {
|
||||
return Index < NumImportedTags + Tags.size();
|
||||
}
|
||||
|
||||
bool WasmObjectFile::isDefinedEventIndex(uint32_t Index) const {
|
||||
return Index >= NumImportedEvents && isValidEventIndex(Index);
|
||||
bool WasmObjectFile::isDefinedTagIndex(uint32_t Index) const {
|
||||
return Index >= NumImportedTags && isValidTagIndex(Index);
|
||||
}
|
||||
|
||||
bool WasmObjectFile::isValidFunctionSymbol(uint32_t Index) const {
|
||||
@ -1258,8 +1258,8 @@ bool WasmObjectFile::isValidGlobalSymbol(uint32_t Index) const {
|
||||
return Index < Symbols.size() && Symbols[Index].isTypeGlobal();
|
||||
}
|
||||
|
||||
bool WasmObjectFile::isValidEventSymbol(uint32_t Index) const {
|
||||
return Index < Symbols.size() && Symbols[Index].isTypeEvent();
|
||||
bool WasmObjectFile::isValidTagSymbol(uint32_t Index) const {
|
||||
return Index < Symbols.size() && Symbols[Index].isTypeTag();
|
||||
}
|
||||
|
||||
bool WasmObjectFile::isValidDataSymbol(uint32_t Index) const {
|
||||
@ -1286,9 +1286,9 @@ wasm::WasmGlobal &WasmObjectFile::getDefinedGlobal(uint32_t Index) {
|
||||
return Globals[Index - NumImportedGlobals];
|
||||
}
|
||||
|
||||
wasm::WasmEvent &WasmObjectFile::getDefinedEvent(uint32_t Index) {
|
||||
assert(isDefinedEventIndex(Index));
|
||||
return Events[Index - NumImportedEvents];
|
||||
wasm::WasmTag &WasmObjectFile::getDefinedTag(uint32_t Index) {
|
||||
assert(isDefinedTagIndex(Index));
|
||||
return Tags[Index - NumImportedTags];
|
||||
}
|
||||
|
||||
Error WasmObjectFile::parseStartSection(ReadContext &Ctx) {
|
||||
@ -1515,7 +1515,7 @@ uint64_t WasmObjectFile::getWasmSymbolValue(const WasmSymbol &Sym) const {
|
||||
switch (Sym.Info.Kind) {
|
||||
case wasm::WASM_SYMBOL_TYPE_FUNCTION:
|
||||
case wasm::WASM_SYMBOL_TYPE_GLOBAL:
|
||||
case wasm::WASM_SYMBOL_TYPE_EVENT:
|
||||
case wasm::WASM_SYMBOL_TYPE_TAG:
|
||||
case wasm::WASM_SYMBOL_TYPE_TABLE:
|
||||
return Sym.Info.ElementIndex;
|
||||
case wasm::WASM_SYMBOL_TYPE_DATA: {
|
||||
@ -1564,7 +1564,7 @@ WasmObjectFile::getSymbolType(DataRefImpl Symb) const {
|
||||
return SymbolRef::ST_Data;
|
||||
case wasm::WASM_SYMBOL_TYPE_SECTION:
|
||||
return SymbolRef::ST_Debug;
|
||||
case wasm::WASM_SYMBOL_TYPE_EVENT:
|
||||
case wasm::WASM_SYMBOL_TYPE_TAG:
|
||||
return SymbolRef::ST_Other;
|
||||
case wasm::WASM_SYMBOL_TYPE_TABLE:
|
||||
return SymbolRef::ST_Other;
|
||||
@ -1600,8 +1600,8 @@ uint32_t WasmObjectFile::getSymbolSectionIdImpl(const WasmSymbol &Sym) const {
|
||||
return DataSection;
|
||||
case wasm::WASM_SYMBOL_TYPE_SECTION:
|
||||
return Sym.Info.ElementIndex;
|
||||
case wasm::WASM_SYMBOL_TYPE_EVENT:
|
||||
return EventSection;
|
||||
case wasm::WASM_SYMBOL_TYPE_TAG:
|
||||
return TagSection;
|
||||
case wasm::WASM_SYMBOL_TYPE_TABLE:
|
||||
return TableSection;
|
||||
default:
|
||||
@ -1623,7 +1623,7 @@ Expected<StringRef> WasmObjectFile::getSectionName(DataRefImpl Sec) const {
|
||||
ECase(TABLE);
|
||||
ECase(MEMORY);
|
||||
ECase(GLOBAL);
|
||||
ECase(EVENT);
|
||||
ECase(TAG);
|
||||
ECase(EXPORT);
|
||||
ECase(START);
|
||||
ECase(ELEM);
|
||||
@ -1822,8 +1822,8 @@ int WasmSectionOrderChecker::getSectionOrder(unsigned ID,
|
||||
return WASM_SEC_ORDER_DATA;
|
||||
case wasm::WASM_SEC_DATACOUNT:
|
||||
return WASM_SEC_ORDER_DATACOUNT;
|
||||
case wasm::WASM_SEC_EVENT:
|
||||
return WASM_SEC_ORDER_EVENT;
|
||||
case wasm::WASM_SEC_TAG:
|
||||
return WASM_SEC_ORDER_TAG;
|
||||
default:
|
||||
return WASM_SEC_ORDER_NONE;
|
||||
}
|
||||
@ -1845,9 +1845,9 @@ int WasmSectionOrderChecker::DisallowedPredecessors
|
||||
// WASM_SEC_ORDER_TABLE
|
||||
{WASM_SEC_ORDER_TABLE, WASM_SEC_ORDER_MEMORY},
|
||||
// WASM_SEC_ORDER_MEMORY
|
||||
{WASM_SEC_ORDER_MEMORY, WASM_SEC_ORDER_EVENT},
|
||||
// WASM_SEC_ORDER_EVENT
|
||||
{WASM_SEC_ORDER_EVENT, WASM_SEC_ORDER_GLOBAL},
|
||||
{WASM_SEC_ORDER_MEMORY, WASM_SEC_ORDER_TAG},
|
||||
// WASM_SEC_ORDER_TAG
|
||||
{WASM_SEC_ORDER_TAG, WASM_SEC_ORDER_GLOBAL},
|
||||
// WASM_SEC_ORDER_GLOBAL
|
||||
{WASM_SEC_ORDER_GLOBAL, WASM_SEC_ORDER_EXPORT},
|
||||
// WASM_SEC_ORDER_EXPORT
|
||||
|
@ -41,7 +41,7 @@ private:
|
||||
void writeSectionContent(raw_ostream &OS, WasmYAML::FunctionSection &Section);
|
||||
void writeSectionContent(raw_ostream &OS, WasmYAML::TableSection &Section);
|
||||
void writeSectionContent(raw_ostream &OS, WasmYAML::MemorySection &Section);
|
||||
void writeSectionContent(raw_ostream &OS, WasmYAML::EventSection &Section);
|
||||
void writeSectionContent(raw_ostream &OS, WasmYAML::TagSection &Section);
|
||||
void writeSectionContent(raw_ostream &OS, WasmYAML::GlobalSection &Section);
|
||||
void writeSectionContent(raw_ostream &OS, WasmYAML::ExportSection &Section);
|
||||
void writeSectionContent(raw_ostream &OS, WasmYAML::StartSection &Section);
|
||||
@ -61,7 +61,7 @@ private:
|
||||
uint32_t NumImportedFunctions = 0;
|
||||
uint32_t NumImportedGlobals = 0;
|
||||
uint32_t NumImportedTables = 0;
|
||||
uint32_t NumImportedEvents = 0;
|
||||
uint32_t NumImportedTags = 0;
|
||||
|
||||
bool HasError = false;
|
||||
yaml::ErrorHandler ErrHandler;
|
||||
@ -189,7 +189,7 @@ void WasmWriter::writeSectionContent(raw_ostream &OS,
|
||||
case wasm::WASM_SYMBOL_TYPE_FUNCTION:
|
||||
case wasm::WASM_SYMBOL_TYPE_GLOBAL:
|
||||
case wasm::WASM_SYMBOL_TYPE_TABLE:
|
||||
case wasm::WASM_SYMBOL_TYPE_EVENT:
|
||||
case wasm::WASM_SYMBOL_TYPE_TAG:
|
||||
encodeULEB128(Info.ElementIndex, SubSection.getStream());
|
||||
if ((Info.Flags & wasm::WASM_SYMBOL_UNDEFINED) == 0 ||
|
||||
(Info.Flags & wasm::WASM_SYMBOL_EXPLICIT_NAME) != 0)
|
||||
@ -385,10 +385,10 @@ void WasmWriter::writeSectionContent(raw_ostream &OS,
|
||||
writeUint8(OS, Import.GlobalImport.Mutable);
|
||||
NumImportedGlobals++;
|
||||
break;
|
||||
case wasm::WASM_EXTERNAL_EVENT:
|
||||
writeUint32(OS, Import.EventImport.Attribute);
|
||||
writeUint32(OS, Import.EventImport.SigIndex);
|
||||
NumImportedEvents++;
|
||||
case wasm::WASM_EXTERNAL_TAG:
|
||||
writeUint32(OS, Import.TagImport.Attribute);
|
||||
writeUint32(OS, Import.TagImport.SigIndex);
|
||||
NumImportedTags++;
|
||||
break;
|
||||
case wasm::WASM_EXTERNAL_MEMORY:
|
||||
writeLimits(Import.Memory, OS);
|
||||
@ -450,17 +450,17 @@ void WasmWriter::writeSectionContent(raw_ostream &OS,
|
||||
}
|
||||
|
||||
void WasmWriter::writeSectionContent(raw_ostream &OS,
|
||||
WasmYAML::EventSection &Section) {
|
||||
encodeULEB128(Section.Events.size(), OS);
|
||||
uint32_t ExpectedIndex = NumImportedEvents;
|
||||
for (auto &Event : Section.Events) {
|
||||
if (Event.Index != ExpectedIndex) {
|
||||
reportError("unexpected event index: " + Twine(Event.Index));
|
||||
WasmYAML::TagSection &Section) {
|
||||
encodeULEB128(Section.Tags.size(), OS);
|
||||
uint32_t ExpectedIndex = NumImportedTags;
|
||||
for (auto &Tag : Section.Tags) {
|
||||
if (Tag.Index != ExpectedIndex) {
|
||||
reportError("unexpected tag index: " + Twine(Tag.Index));
|
||||
return;
|
||||
}
|
||||
++ExpectedIndex;
|
||||
encodeULEB128(Event.Attribute, OS);
|
||||
encodeULEB128(Event.SigIndex, OS);
|
||||
encodeULEB128(Tag.Attribute, OS);
|
||||
encodeULEB128(Tag.SigIndex, OS);
|
||||
}
|
||||
}
|
||||
|
||||
@ -626,7 +626,7 @@ bool WasmWriter::writeWasm(raw_ostream &OS) {
|
||||
writeSectionContent(StringStream, *S);
|
||||
else if (auto S = dyn_cast<WasmYAML::MemorySection>(Sec.get()))
|
||||
writeSectionContent(StringStream, *S);
|
||||
else if (auto S = dyn_cast<WasmYAML::EventSection>(Sec.get()))
|
||||
else if (auto S = dyn_cast<WasmYAML::TagSection>(Sec.get()))
|
||||
writeSectionContent(StringStream, *S);
|
||||
else if (auto S = dyn_cast<WasmYAML::GlobalSection>(Sec.get()))
|
||||
writeSectionContent(StringStream, *S);
|
||||
|
@ -120,9 +120,9 @@ static void sectionMapping(IO &IO, WasmYAML::MemorySection &Section) {
|
||||
IO.mapOptional("Memories", Section.Memories);
|
||||
}
|
||||
|
||||
static void sectionMapping(IO &IO, WasmYAML::EventSection &Section) {
|
||||
static void sectionMapping(IO &IO, WasmYAML::TagSection &Section) {
|
||||
commonSectionMapping(IO, Section);
|
||||
IO.mapOptional("Events", Section.Events);
|
||||
IO.mapOptional("Tags", Section.Tags);
|
||||
}
|
||||
|
||||
static void sectionMapping(IO &IO, WasmYAML::GlobalSection &Section) {
|
||||
@ -229,10 +229,10 @@ void MappingTraits<std::unique_ptr<WasmYAML::Section>>::mapping(
|
||||
Section.reset(new WasmYAML::MemorySection());
|
||||
sectionMapping(IO, *cast<WasmYAML::MemorySection>(Section.get()));
|
||||
break;
|
||||
case wasm::WASM_SEC_EVENT:
|
||||
case wasm::WASM_SEC_TAG:
|
||||
if (!IO.outputting())
|
||||
Section.reset(new WasmYAML::EventSection());
|
||||
sectionMapping(IO, *cast<WasmYAML::EventSection>(Section.get()));
|
||||
Section.reset(new WasmYAML::TagSection());
|
||||
sectionMapping(IO, *cast<WasmYAML::TagSection>(Section.get()));
|
||||
break;
|
||||
case wasm::WASM_SEC_GLOBAL:
|
||||
if (!IO.outputting())
|
||||
@ -284,7 +284,7 @@ void ScalarEnumerationTraits<WasmYAML::SectionType>::enumeration(
|
||||
ECase(TABLE);
|
||||
ECase(MEMORY);
|
||||
ECase(GLOBAL);
|
||||
ECase(EVENT);
|
||||
ECase(TAG);
|
||||
ECase(EXPORT);
|
||||
ECase(START);
|
||||
ECase(ELEM);
|
||||
@ -396,9 +396,9 @@ void MappingTraits<WasmYAML::Import>::mapping(IO &IO,
|
||||
} else if (Import.Kind == wasm::WASM_EXTERNAL_GLOBAL) {
|
||||
IO.mapRequired("GlobalType", Import.GlobalImport.Type);
|
||||
IO.mapRequired("GlobalMutable", Import.GlobalImport.Mutable);
|
||||
} else if (Import.Kind == wasm::WASM_EXTERNAL_EVENT) {
|
||||
IO.mapRequired("EventAttribute", Import.EventImport.Attribute);
|
||||
IO.mapRequired("EventSigIndex", Import.EventImport.SigIndex);
|
||||
} else if (Import.Kind == wasm::WASM_EXTERNAL_TAG) {
|
||||
IO.mapRequired("TagAttribute", Import.TagImport.Attribute);
|
||||
IO.mapRequired("TagSigIndex", Import.TagImport.SigIndex);
|
||||
} else if (Import.Kind == wasm::WASM_EXTERNAL_TABLE) {
|
||||
IO.mapRequired("Table", Import.TableImport);
|
||||
} else if (Import.Kind == wasm::WASM_EXTERNAL_MEMORY) {
|
||||
@ -510,8 +510,8 @@ void MappingTraits<WasmYAML::SymbolInfo>::mapping(IO &IO,
|
||||
IO.mapRequired("Global", Info.ElementIndex);
|
||||
} else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_TABLE) {
|
||||
IO.mapRequired("Table", Info.ElementIndex);
|
||||
} else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_EVENT) {
|
||||
IO.mapRequired("Event", Info.ElementIndex);
|
||||
} else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_TAG) {
|
||||
IO.mapRequired("Tag", Info.ElementIndex);
|
||||
} else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_DATA) {
|
||||
if ((Info.Flags & wasm::WASM_SYMBOL_UNDEFINED) == 0) {
|
||||
IO.mapRequired("Segment", Info.DataRef.Segment);
|
||||
@ -525,10 +525,10 @@ void MappingTraits<WasmYAML::SymbolInfo>::mapping(IO &IO,
|
||||
}
|
||||
}
|
||||
|
||||
void MappingTraits<WasmYAML::Event>::mapping(IO &IO, WasmYAML::Event &Event) {
|
||||
IO.mapRequired("Index", Event.Index);
|
||||
IO.mapRequired("Attribute", Event.Attribute);
|
||||
IO.mapRequired("SigIndex", Event.SigIndex);
|
||||
void MappingTraits<WasmYAML::Tag>::mapping(IO &IO, WasmYAML::Tag &Tag) {
|
||||
IO.mapRequired("Index", Tag.Index);
|
||||
IO.mapRequired("Attribute", Tag.Attribute);
|
||||
IO.mapRequired("SigIndex", Tag.SigIndex);
|
||||
}
|
||||
|
||||
void ScalarBitSetTraits<WasmYAML::LimitFlags>::bitset(
|
||||
@ -572,7 +572,7 @@ void ScalarEnumerationTraits<WasmYAML::SymbolKind>::enumeration(
|
||||
ECase(GLOBAL);
|
||||
ECase(TABLE);
|
||||
ECase(SECTION);
|
||||
ECase(EVENT);
|
||||
ECase(TAG);
|
||||
#undef ECase
|
||||
}
|
||||
|
||||
@ -597,7 +597,7 @@ void ScalarEnumerationTraits<WasmYAML::ExportKind>::enumeration(
|
||||
ECase(TABLE);
|
||||
ECase(MEMORY);
|
||||
ECase(GLOBAL);
|
||||
ECase(EVENT);
|
||||
ECase(TAG);
|
||||
#undef ECase
|
||||
}
|
||||
|
||||
|
@ -899,7 +899,7 @@ public:
|
||||
TOut.emitImportName(WasmSym, ImportName);
|
||||
}
|
||||
|
||||
if (DirectiveID.getString() == ".eventtype") {
|
||||
if (DirectiveID.getString() == ".tagtype") {
|
||||
auto SymName = expectIdent();
|
||||
if (SymName.empty())
|
||||
return true;
|
||||
@ -909,8 +909,8 @@ public:
|
||||
return true;
|
||||
WasmSym->setSignature(Signature.get());
|
||||
addSignature(std::move(Signature));
|
||||
WasmSym->setType(wasm::WASM_SYMBOL_TYPE_EVENT);
|
||||
TOut.emitEventType(WasmSym);
|
||||
WasmSym->setType(wasm::WASM_SYMBOL_TYPE_TAG);
|
||||
TOut.emitTagType(WasmSym);
|
||||
// TODO: backend also calls TOut.emitIndIdx, but that is not implemented.
|
||||
return expect(AsmToken::EndOfStatement, "EOL");
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ MCDisassembler::DecodeStatus WebAssemblyDisassembler::getInstruction(
|
||||
case WebAssembly::OPERAND_OFFSET64:
|
||||
case WebAssembly::OPERAND_P2ALIGN:
|
||||
case WebAssembly::OPERAND_TYPEINDEX:
|
||||
case WebAssembly::OPERAND_EVENT:
|
||||
case WebAssembly::OPERAND_TAG:
|
||||
case MCOI::OPERAND_IMMEDIATE: {
|
||||
if (!parseLEBImmediate(MI, Size, Bytes, false))
|
||||
return MCDisassembler::Fail;
|
||||
|
@ -154,7 +154,7 @@ void WebAssemblyMCCodeEmitter::encodeInstruction(
|
||||
case WebAssembly::OPERAND_SIGNATURE:
|
||||
case WebAssembly::OPERAND_TYPEINDEX:
|
||||
case WebAssembly::OPERAND_GLOBAL:
|
||||
case WebAssembly::OPERAND_EVENT:
|
||||
case WebAssembly::OPERAND_TAG:
|
||||
FixupKind = MCFixupKind(WebAssembly::fixup_uleb128_i32);
|
||||
break;
|
||||
case WebAssembly::OPERAND_OFFSET64:
|
||||
|
@ -72,8 +72,8 @@ enum OperandType {
|
||||
OPERAND_SIGNATURE,
|
||||
/// type signature immediate for call_indirect.
|
||||
OPERAND_TYPEINDEX,
|
||||
/// Event index.
|
||||
OPERAND_EVENT,
|
||||
/// Tag index.
|
||||
OPERAND_TAG,
|
||||
/// A list of branch targets for br_list.
|
||||
OPERAND_BRLIST,
|
||||
/// 32-bit unsigned table number.
|
||||
|
@ -91,9 +91,9 @@ void WebAssemblyTargetAsmStreamer::emitTableType(const MCSymbolWasm *Sym) {
|
||||
OS << '\n';
|
||||
}
|
||||
|
||||
void WebAssemblyTargetAsmStreamer::emitEventType(const MCSymbolWasm *Sym) {
|
||||
assert(Sym->isEvent());
|
||||
OS << "\t.eventtype\t" << Sym->getName() << " ";
|
||||
void WebAssemblyTargetAsmStreamer::emitTagType(const MCSymbolWasm *Sym) {
|
||||
assert(Sym->isTag());
|
||||
OS << "\t.tagtype\t" << Sym->getName() << " ";
|
||||
OS << WebAssembly::typeListToString(Sym->getSignature()->Params);
|
||||
OS << "\n";
|
||||
}
|
||||
|
@ -42,8 +42,8 @@ public:
|
||||
virtual void emitGlobalType(const MCSymbolWasm *Sym) = 0;
|
||||
/// .tabletype
|
||||
virtual void emitTableType(const MCSymbolWasm *Sym) = 0;
|
||||
/// .eventtype
|
||||
virtual void emitEventType(const MCSymbolWasm *Sym) = 0;
|
||||
/// .tagtype
|
||||
virtual void emitTagType(const MCSymbolWasm *Sym) = 0;
|
||||
/// .import_module
|
||||
virtual void emitImportModule(const MCSymbolWasm *Sym,
|
||||
StringRef ImportModule) = 0;
|
||||
@ -71,7 +71,7 @@ public:
|
||||
void emitIndIdx(const MCExpr *Value) override;
|
||||
void emitGlobalType(const MCSymbolWasm *Sym) override;
|
||||
void emitTableType(const MCSymbolWasm *Sym) override;
|
||||
void emitEventType(const MCSymbolWasm *Sym) override;
|
||||
void emitTagType(const MCSymbolWasm *Sym) override;
|
||||
void emitImportModule(const MCSymbolWasm *Sym, StringRef ImportModule) override;
|
||||
void emitImportName(const MCSymbolWasm *Sym, StringRef ImportName) override;
|
||||
void emitExportName(const MCSymbolWasm *Sym, StringRef ExportName) override;
|
||||
@ -88,7 +88,7 @@ public:
|
||||
void emitIndIdx(const MCExpr *Value) override;
|
||||
void emitGlobalType(const MCSymbolWasm *Sym) override {}
|
||||
void emitTableType(const MCSymbolWasm *Sym) override {}
|
||||
void emitEventType(const MCSymbolWasm *Sym) override {}
|
||||
void emitTagType(const MCSymbolWasm *Sym) override {}
|
||||
void emitImportModule(const MCSymbolWasm *Sym,
|
||||
StringRef ImportModule) override {}
|
||||
void emitImportName(const MCSymbolWasm *Sym,
|
||||
@ -109,7 +109,7 @@ public:
|
||||
void emitIndIdx(const MCExpr *) override {}
|
||||
void emitGlobalType(const MCSymbolWasm *) override {}
|
||||
void emitTableType(const MCSymbolWasm *) override {}
|
||||
void emitEventType(const MCSymbolWasm *) override {}
|
||||
void emitTagType(const MCSymbolWasm *) override {}
|
||||
void emitImportModule(const MCSymbolWasm *, StringRef) override {}
|
||||
void emitImportName(const MCSymbolWasm *, StringRef) override {}
|
||||
void emitExportName(const MCSymbolWasm *, StringRef) override {}
|
||||
|
@ -104,8 +104,8 @@ unsigned WebAssemblyWasmObjectWriter::getRelocType(const MCValue &Target,
|
||||
return wasm::R_WASM_GLOBAL_INDEX_LEB;
|
||||
if (SymA.isFunction())
|
||||
return wasm::R_WASM_FUNCTION_INDEX_LEB;
|
||||
if (SymA.isEvent())
|
||||
return wasm::R_WASM_EVENT_INDEX_LEB;
|
||||
if (SymA.isTag())
|
||||
return wasm::R_WASM_TAG_INDEX_LEB;
|
||||
if (SymA.isTable())
|
||||
return wasm::R_WASM_TABLE_NUMBER_LEB;
|
||||
return wasm::R_WASM_MEMORY_ADDR_LEB;
|
||||
|
@ -209,7 +209,7 @@ void WebAssemblyAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
|
||||
|
||||
void WebAssemblyAsmPrinter::emitEndOfAsmFile(Module &M) {
|
||||
for (auto &It : OutContext.getSymbols()) {
|
||||
// Emit .globaltype, .eventtype, or .tabletype declarations.
|
||||
// Emit .globaltype, .tagtype, or .tabletype declarations.
|
||||
auto Sym = cast<MCSymbolWasm>(It.getValue());
|
||||
if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_GLOBAL) {
|
||||
// .globaltype already handled by emitGlobalVariable for defined
|
||||
@ -217,8 +217,8 @@ void WebAssemblyAsmPrinter::emitEndOfAsmFile(Module &M) {
|
||||
// written to the file.
|
||||
if (Sym->isUndefined())
|
||||
getTargetStreamer()->emitGlobalType(Sym);
|
||||
} else if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_EVENT)
|
||||
getTargetStreamer()->emitEventType(Sym);
|
||||
} else if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_TAG)
|
||||
getTargetStreamer()->emitTagType(Sym);
|
||||
else if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_TABLE)
|
||||
getTargetStreamer()->emitTableType(Sym);
|
||||
}
|
||||
|
@ -129,8 +129,8 @@ let Predicates = [HasExceptionHandling] in {
|
||||
|
||||
// Throwing an exception: throw / rethrow
|
||||
let isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in {
|
||||
defm THROW : I<(outs), (ins event_op:$tag, variable_ops),
|
||||
(outs), (ins event_op:$tag),
|
||||
defm THROW : I<(outs), (ins tag_op:$tag, variable_ops),
|
||||
(outs), (ins tag_op:$tag),
|
||||
[(WebAssemblythrow (WebAssemblywrapper texternalsym:$tag))],
|
||||
"throw \t$tag", "throw \t$tag", 0x08>;
|
||||
defm RETHROW : NRI<(outs), (ins i32imm:$depth), [], "rethrow \t$depth", 0x09>;
|
||||
@ -149,9 +149,9 @@ defm END_TRY : NRI<(outs), (ins), [], "end_try", 0x0b>;
|
||||
let hasCtrlDep = 1, hasSideEffects = 1 in {
|
||||
// Currently 'catch' can only extract an i32, which is sufficient for C++
|
||||
// support, but according to the spec 'catch' can extract any number of values
|
||||
// based on the event type.
|
||||
defm CATCH : I<(outs I32:$dst), (ins event_op:$tag),
|
||||
(outs), (ins event_op:$tag),
|
||||
// based on the tag type.
|
||||
defm CATCH : I<(outs I32:$dst), (ins tag_op:$tag),
|
||||
(outs), (ins tag_op:$tag),
|
||||
[(set I32:$dst,
|
||||
(WebAssemblycatch (WebAssemblywrapper texternalsym:$tag)))],
|
||||
"catch \t$dst, $tag", "catch \t$tag", 0x07>;
|
||||
|
@ -196,8 +196,8 @@ def P2Align : Operand<i32> {
|
||||
let PrintMethod = "printWebAssemblyP2AlignOperand";
|
||||
}
|
||||
|
||||
let OperandType = "OPERAND_EVENT" in
|
||||
def event_op : Operand<i32>;
|
||||
let OperandType = "OPERAND_TAG" in
|
||||
def tag_op : Operand<i32>;
|
||||
|
||||
} // OperandType = "OPERAND_P2ALIGN"
|
||||
|
||||
|
@ -116,11 +116,10 @@ MCSymbol *WebAssemblyMCInstLower::GetExternalSymbolSymbol(
|
||||
SmallVector<wasm::ValType, 4> Returns;
|
||||
SmallVector<wasm::ValType, 4> Params;
|
||||
if (strcmp(Name, "__cpp_exception") == 0) {
|
||||
WasmSym->setType(wasm::WASM_SYMBOL_TYPE_EVENT);
|
||||
WasmSym->setType(wasm::WASM_SYMBOL_TYPE_TAG);
|
||||
// We can't confirm its signature index for now because there can be
|
||||
// imported exceptions. Set it to be 0 for now.
|
||||
WasmSym->setEventType(
|
||||
{wasm::WASM_EVENT_ATTRIBUTE_EXCEPTION, /* SigIndex */ 0});
|
||||
WasmSym->setTagType({wasm::WASM_TAG_ATTRIBUTE_EXCEPTION, /* SigIndex */ 0});
|
||||
// We may have multiple C++ compilation units to be linked together, each of
|
||||
// which defines the exception symbol. To resolve them, we declare them as
|
||||
// weak.
|
||||
@ -179,8 +178,8 @@ MCOperand WebAssemblyMCInstLower::lowerSymbolOperand(const MachineOperand &MO,
|
||||
report_fatal_error("Function addresses with offsets not supported");
|
||||
if (WasmSym->isGlobal())
|
||||
report_fatal_error("Global indexes with offsets not supported");
|
||||
if (WasmSym->isEvent())
|
||||
report_fatal_error("Event indexes with offsets not supported");
|
||||
if (WasmSym->isTag())
|
||||
report_fatal_error("Tag indexes with offsets not supported");
|
||||
if (WasmSym->isTable())
|
||||
report_fatal_error("Table indexes with offsets not supported");
|
||||
|
||||
|
@ -372,4 +372,4 @@ attributes #0 = { nounwind }
|
||||
attributes #1 = { noreturn }
|
||||
|
||||
; CHECK: __cpp_exception:
|
||||
; CHECK: .eventtype __cpp_exception i32
|
||||
; CHECK: .tagtype __cpp_exception i32
|
||||
|
@ -15,5 +15,5 @@ define i32 @test(i8* %p) {
|
||||
}
|
||||
|
||||
; CHECK-DAG: .globaltype
|
||||
; CHECK-DAG: .eventtype
|
||||
; CHECK-DAG: .tagtype
|
||||
; CHECK-DAG: .functype
|
||||
|
@ -8,7 +8,7 @@
|
||||
.type test_annotation,@function
|
||||
test_annotation:
|
||||
.functype test_annotation () -> ()
|
||||
.eventtype __cpp_exception i32
|
||||
.tagtype __cpp_exception i32
|
||||
try
|
||||
br 0
|
||||
catch __cpp_exception
|
||||
|
@ -12,7 +12,7 @@ test0:
|
||||
.Ltest0begin:
|
||||
# Test all types:
|
||||
.functype test0 (i32, i64) -> (i32)
|
||||
.eventtype __cpp_exception i32
|
||||
.tagtype __cpp_exception i32
|
||||
.local f32, f64, v128, v128
|
||||
# Explicit getlocal/setlocal:
|
||||
local.get 2
|
||||
@ -131,7 +131,7 @@ empty_fref_table:
|
||||
# CHECK-LABEL: test0:
|
||||
# CHECK-NEXT: .Ltest0begin:
|
||||
# CHECK-NEXT: .functype test0 (i32, i64) -> (i32)
|
||||
# CHECK-NEXT: .eventtype __cpp_exception i32
|
||||
# CHECK-NEXT: .tagtype __cpp_exception i32
|
||||
# CHECK-NEXT: .local f32, f64
|
||||
# CHECK-NEXT: local.get 2
|
||||
# CHECK-NEXT: local.set 2
|
||||
|
@ -1,9 +1,9 @@
|
||||
; RUN: llc -filetype=obj -exception-model=wasm -mattr=+exception-handling %s -o - | obj2yaml | FileCheck %s
|
||||
|
||||
; This is a regression test for a decoding bug that happens when an event's
|
||||
; This is a regression test for a decoding bug that happens when a tag's
|
||||
; sigindex is greater than 63, so we put 63 dummy functions with different
|
||||
; signatures before the function that contains the 'throw' instruction to make
|
||||
; the event's sigindex 64.
|
||||
; the tag's sigindex 64.
|
||||
|
||||
target triple = "wasm32-unknown-unknown"
|
||||
|
||||
@ -334,12 +334,12 @@ define i32 @test_throw(i8* %p) {
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
; Checks to see if the event index is correctly decoded in ULEB128. If it is
|
||||
; Checks to see if the tag index is correctly decoded in ULEB128. If it is
|
||||
; decoded with LEB128, 64 will not be correctly decoded. 64 is the smallest
|
||||
; number with which its LEB128 and ULEB128 encodings are different, because its
|
||||
; 7th least significant bit is not 0.
|
||||
; CHECK: - Type: EVENT
|
||||
; CHECK-NEXT: Events:
|
||||
; CHECK: - Type: TAG
|
||||
; CHECK-NEXT: Tags:
|
||||
; CHECK-NEXT: - Index: 0
|
||||
; CHECK-NEXT: Attribute: 0
|
||||
; CHECK-NEXT: SigIndex: 64
|
@ -28,18 +28,18 @@ define i32 @test_throw1(i8* %p) {
|
||||
; CHECK-NEXT: - I32
|
||||
; CHECK-NEXT: ReturnTypes: []
|
||||
|
||||
; CHECK: - Type: EVENT
|
||||
; CHECK-NEXT: Events:
|
||||
; CHECK: - Type: TAG
|
||||
; CHECK-NEXT: Tags:
|
||||
; CHECK-NEXT: - Index: 0
|
||||
; CHECK-NEXT: Attribute: 0
|
||||
; CHECK-NEXT: SigIndex: 1
|
||||
|
||||
; CHECK-NEXT: - Type: CODE
|
||||
; CHECK-NEXT: Relocations:
|
||||
; CHECK-NEXT: - Type: R_WASM_EVENT_INDEX_LEB
|
||||
; CHECK-NEXT: - Type: R_WASM_TAG_INDEX_LEB
|
||||
; CHECK-NEXT: Index: 1
|
||||
; CHECK-NEXT: Offset: 0x6
|
||||
; CHECK-NEXT: - Type: R_WASM_EVENT_INDEX_LEB
|
||||
; CHECK-NEXT: - Type: R_WASM_TAG_INDEX_LEB
|
||||
; CHECK-NEXT: Index: 1
|
||||
; CHECK-NEXT: Offset: 0x11
|
||||
|
||||
@ -49,11 +49,11 @@ define i32 @test_throw1(i8* %p) {
|
||||
; CHECK-NEXT: SymbolTable:
|
||||
|
||||
; CHECK: - Index: 1
|
||||
; CHECK-NEXT: Kind: EVENT
|
||||
; CHECK-NEXT: Kind: TAG
|
||||
; CHECK-NEXT: Name: __cpp_exception
|
||||
; CHECK-NEXT: Flags: [ BINDING_WEAK ]
|
||||
; CHECK-NEXT: Event: 0
|
||||
; CHECK-NEXT: Tag: 0
|
||||
|
||||
; SEC: Type: EVENT (0xD)
|
||||
; SEC: Type: TAG (0xD)
|
||||
; SEC-NEXT: Size: 3
|
||||
; SEC-NEXT: Offset: 63
|
@ -17,14 +17,14 @@ Sections:
|
||||
ReturnTypes: []
|
||||
- Type: FUNCTION
|
||||
FunctionTypes: [ 0 ]
|
||||
- Type: EVENT
|
||||
Events:
|
||||
- Type: TAG
|
||||
Tags:
|
||||
- Index: 0
|
||||
Attribute: 0
|
||||
SigIndex: 1
|
||||
- Type: CODE
|
||||
Relocations:
|
||||
- Type: R_WASM_EVENT_INDEX_LEB
|
||||
- Type: R_WASM_TAG_INDEX_LEB
|
||||
Index: 1
|
||||
Offset: 0x00000006
|
||||
- Type: 10
|
||||
@ -44,10 +44,10 @@ Sections:
|
||||
Flags: [ ]
|
||||
Function: 0
|
||||
- Index: 1
|
||||
Kind: EVENT
|
||||
Kind: TAG
|
||||
Name: __cpp_exception
|
||||
Flags: [ BINDING_WEAK ]
|
||||
Event: 0
|
||||
Tag: 0
|
||||
...
|
||||
|
||||
# CHECK: --- !WASM
|
||||
@ -67,17 +67,17 @@ Sections:
|
||||
# CHECK-NEXT: ReturnTypes: []
|
||||
# CHECK-NEXT: - Type: FUNCTION
|
||||
# CHECK-NEXT: FunctionTypes: [ 0 ]
|
||||
# CHECK-NEXT: - Type: EVENT
|
||||
# CHECK-NEXT: Events:
|
||||
# CHECK-NEXT: - Type: TAG
|
||||
# CHECK-NEXT: Tags:
|
||||
# CHECK-NEXT: - Index: 0
|
||||
# CHECK-NEXT: Attribute: 0
|
||||
# CHECK-NEXT: SigIndex: 1
|
||||
# CHECK-NEXT: - Type: CODE
|
||||
# CHECK-NEXT: Relocations:
|
||||
# CHECK-NEXT: - Type: R_WASM_EVENT_INDEX_LEB
|
||||
# CHECK-NEXT: - Type: R_WASM_TAG_INDEX_LEB
|
||||
# CHECK-NEXT: Index: 1
|
||||
# CHECK-NEXT: Offset: 0x6
|
||||
# CHECK-NEXT: - Type: R_WASM_EVENT_INDEX_LEB
|
||||
# CHECK-NEXT: - Type: R_WASM_TAG_INDEX_LEB
|
||||
# CHECK-NEXT: Index: 1
|
||||
# CHECK-NEXT: Offset: 0x6
|
||||
# CHECK-NEXT: Functions:
|
||||
@ -94,7 +94,7 @@ Sections:
|
||||
# CHECK-NEXT: Flags: [ ]
|
||||
# CHECK-NEXT: Function: 0
|
||||
# CHECK-NEXT: - Index: 1
|
||||
# CHECK-NEXT: Kind: EVENT
|
||||
# CHECK-NEXT: Kind: TAG
|
||||
# CHECK-NEXT: Name: __cpp_exception
|
||||
# CHECK-NEXT: Flags: [ BINDING_WEAK ]
|
||||
# CHECK-NEXT: Event: 0
|
||||
# CHECK-NEXT: Tag: 0
|
||||
|
@ -23,8 +23,8 @@ namespace {
|
||||
static const EnumEntry<unsigned> WasmSymbolTypes[] = {
|
||||
#define ENUM_ENTRY(X) \
|
||||
{ #X, wasm::WASM_SYMBOL_TYPE_##X }
|
||||
ENUM_ENTRY(FUNCTION), ENUM_ENTRY(DATA), ENUM_ENTRY(GLOBAL),
|
||||
ENUM_ENTRY(SECTION), ENUM_ENTRY(EVENT), ENUM_ENTRY(TABLE),
|
||||
ENUM_ENTRY(FUNCTION), ENUM_ENTRY(DATA), ENUM_ENTRY(GLOBAL),
|
||||
ENUM_ENTRY(SECTION), ENUM_ENTRY(TAG), ENUM_ENTRY(TABLE),
|
||||
#undef ENUM_ENTRY
|
||||
};
|
||||
|
||||
@ -33,7 +33,7 @@ static const EnumEntry<uint32_t> WasmSectionTypes[] = {
|
||||
{ #X, wasm::WASM_SEC_##X }
|
||||
ENUM_ENTRY(CUSTOM), ENUM_ENTRY(TYPE), ENUM_ENTRY(IMPORT),
|
||||
ENUM_ENTRY(FUNCTION), ENUM_ENTRY(TABLE), ENUM_ENTRY(MEMORY),
|
||||
ENUM_ENTRY(GLOBAL), ENUM_ENTRY(EVENT), ENUM_ENTRY(EXPORT),
|
||||
ENUM_ENTRY(GLOBAL), ENUM_ENTRY(TAG), ENUM_ENTRY(EXPORT),
|
||||
ENUM_ENTRY(START), ENUM_ENTRY(ELEM), ENUM_ENTRY(CODE),
|
||||
ENUM_ENTRY(DATA), ENUM_ENTRY(DATACOUNT),
|
||||
#undef ENUM_ENTRY
|
||||
|
@ -132,7 +132,7 @@ WasmDumper::dumpCustomSection(const WasmSection &WasmSec) {
|
||||
case wasm::WASM_SYMBOL_TYPE_FUNCTION:
|
||||
case wasm::WASM_SYMBOL_TYPE_GLOBAL:
|
||||
case wasm::WASM_SYMBOL_TYPE_TABLE:
|
||||
case wasm::WASM_SYMBOL_TYPE_EVENT:
|
||||
case wasm::WASM_SYMBOL_TYPE_TAG:
|
||||
Info.ElementIndex = Symbol.ElementIndex;
|
||||
break;
|
||||
case wasm::WASM_SYMBOL_TYPE_SECTION:
|
||||
@ -238,9 +238,9 @@ ErrorOr<WasmYAML::Object *> WasmDumper::dump() {
|
||||
Im.GlobalImport.Type = Import.Global.Type;
|
||||
Im.GlobalImport.Mutable = Import.Global.Mutable;
|
||||
break;
|
||||
case wasm::WASM_EXTERNAL_EVENT:
|
||||
Im.EventImport.Attribute = Import.Event.Attribute;
|
||||
Im.EventImport.SigIndex = Import.Event.SigIndex;
|
||||
case wasm::WASM_EXTERNAL_TAG:
|
||||
Im.TagImport.Attribute = Import.Tag.Attribute;
|
||||
Im.TagImport.SigIndex = Import.Tag.SigIndex;
|
||||
break;
|
||||
case wasm::WASM_EXTERNAL_TABLE:
|
||||
// FIXME: Currently we always output an index of 0 for any imported
|
||||
@ -280,16 +280,16 @@ ErrorOr<WasmYAML::Object *> WasmDumper::dump() {
|
||||
S = std::move(MemorySec);
|
||||
break;
|
||||
}
|
||||
case wasm::WASM_SEC_EVENT: {
|
||||
auto EventSec = std::make_unique<WasmYAML::EventSection>();
|
||||
for (auto &Event : Obj.events()) {
|
||||
WasmYAML::Event E;
|
||||
E.Index = Event.Index;
|
||||
E.Attribute = Event.Type.Attribute;
|
||||
E.SigIndex = Event.Type.SigIndex;
|
||||
EventSec->Events.push_back(E);
|
||||
case wasm::WASM_SEC_TAG: {
|
||||
auto TagSec = std::make_unique<WasmYAML::TagSection>();
|
||||
for (auto &Tag : Obj.tags()) {
|
||||
WasmYAML::Tag T;
|
||||
T.Index = Tag.Index;
|
||||
T.Attribute = Tag.Type.Attribute;
|
||||
T.SigIndex = Tag.Type.SigIndex;
|
||||
TagSec->Tags.push_back(T);
|
||||
}
|
||||
S = std::move(EventSec);
|
||||
S = std::move(TagSec);
|
||||
break;
|
||||
}
|
||||
case wasm::WASM_SEC_GLOBAL: {
|
||||
|
Loading…
Reference in New Issue
Block a user