[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:
Heejin Ahn 2021-06-15 01:49:43 -07:00
parent 6aaf4fa288
commit 1d891d44f3
52 changed files with 440 additions and 444 deletions

View File

@ -44,8 +44,8 @@ class WasmSymbol;
} // namespace object } // namespace object
namespace wasm { namespace wasm {
struct WasmEvent; struct WasmTag;
struct WasmEventType; struct WasmTagType;
struct WasmFunction; struct WasmFunction;
struct WasmGlobal; struct WasmGlobal;
struct WasmGlobalType; struct WasmGlobalType;
@ -87,8 +87,6 @@ using llvm::object::WasmObjectFile;
using llvm::object::WasmSection; using llvm::object::WasmSection;
using llvm::object::WasmSegment; using llvm::object::WasmSegment;
using llvm::object::WasmSymbol; using llvm::object::WasmSymbol;
using llvm::wasm::WasmEvent;
using llvm::wasm::WasmEventType;
using llvm::wasm::WasmFunction; using llvm::wasm::WasmFunction;
using llvm::wasm::WasmGlobal; using llvm::wasm::WasmGlobal;
using llvm::wasm::WasmGlobalType; using llvm::wasm::WasmGlobalType;
@ -98,6 +96,8 @@ using llvm::wasm::WasmRelocation;
using llvm::wasm::WasmSignature; using llvm::wasm::WasmSignature;
using llvm::wasm::WasmTable; using llvm::wasm::WasmTable;
using llvm::wasm::WasmTableType; using llvm::wasm::WasmTableType;
using llvm::wasm::WasmTag;
using llvm::wasm::WasmTagType;
} // end namespace lld. } // end namespace lld.
namespace std { namespace std {

View File

@ -1,5 +1,5 @@
; RUN: llc -filetype=obj -exception-model=wasm -mattr=+exception-handling %p/Inputs/event-section1.ll -o %t1.o ; RUN: llc -filetype=obj -exception-model=wasm -mattr=+exception-handling %p/Inputs/tag-section1.ll -o %t1.o
; RUN: llc -filetype=obj -exception-model=wasm -mattr=+exception-handling %p/Inputs/event-section2.ll -o %t2.o ; RUN: llc -filetype=obj -exception-model=wasm -mattr=+exception-handling %p/Inputs/tag-section2.ll -o %t2.o
; RUN: llc -filetype=obj -exception-model=wasm -mattr=+exception-handling %s -o %t.o ; RUN: llc -filetype=obj -exception-model=wasm -mattr=+exception-handling %s -o %t.o
; RUN: wasm-ld -o %t.wasm %t.o %t1.o %t2.o ; RUN: wasm-ld -o %t.wasm %t.o %t1.o %t2.o
; RUN: wasm-ld --export-all -o %t-export-all.wasm %t.o %t1.o %t2.o ; RUN: wasm-ld --export-all -o %t-export-all.wasm %t.o %t1.o %t2.o
@ -29,17 +29,17 @@ define void @_start() {
; CHECK-NEXT: - I32 ; CHECK-NEXT: - I32
; CHECK-NEXT: ReturnTypes: [] ; CHECK-NEXT: ReturnTypes: []
; CHECK: - Type: EVENT ; CHECK: - Type: TAG
; CHECK-NEXT: Events: ; CHECK-NEXT: Tags:
; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Attribute: 0 ; CHECK-NEXT: Attribute: 0
; CHECK-NEXT: SigIndex: 1 ; CHECK-NEXT: SigIndex: 1
; Global section has to come after event section ; Global section has to come after tag section
; CHECK: - Type: GLOBAL ; CHECK: - Type: GLOBAL
; EXPORT-ALL: - Type: EXPORT ; EXPORT-ALL: - Type: EXPORT
; EXPORT-ALL-NEXT Exports: ; EXPORT-ALL-NEXT Exports:
; EXPORT-ALL: - Name: __cpp_exception ; EXPORT-ALL: - Name: __cpp_exception
; EXPORT-ALL: Kind: EVENT ; EXPORT-ALL: Kind: TAG
; EXPORT-ALL: Index: 0 ; EXPORT-ALL: Index: 0

View File

@ -117,7 +117,7 @@ void InputChunk::relocate(uint8_t *buf) const {
case R_WASM_TYPE_INDEX_LEB: case R_WASM_TYPE_INDEX_LEB:
case R_WASM_FUNCTION_INDEX_LEB: case R_WASM_FUNCTION_INDEX_LEB:
case R_WASM_GLOBAL_INDEX_LEB: case R_WASM_GLOBAL_INDEX_LEB:
case R_WASM_EVENT_INDEX_LEB: case R_WASM_TAG_INDEX_LEB:
case R_WASM_MEMORY_ADDR_LEB: case R_WASM_MEMORY_ADDR_LEB:
case R_WASM_TABLE_NUMBER_LEB: case R_WASM_TABLE_NUMBER_LEB:
encodeULEB128(value, loc, 5); encodeULEB128(value, loc, 5);
@ -208,7 +208,7 @@ static unsigned writeCompressedReloc(uint8_t *buf, const WasmRelocation &rel,
case R_WASM_TYPE_INDEX_LEB: case R_WASM_TYPE_INDEX_LEB:
case R_WASM_FUNCTION_INDEX_LEB: case R_WASM_FUNCTION_INDEX_LEB:
case R_WASM_GLOBAL_INDEX_LEB: case R_WASM_GLOBAL_INDEX_LEB:
case R_WASM_EVENT_INDEX_LEB: case R_WASM_TAG_INDEX_LEB:
case R_WASM_MEMORY_ADDR_LEB: case R_WASM_MEMORY_ADDR_LEB:
case R_WASM_MEMORY_ADDR_LEB64: case R_WASM_MEMORY_ADDR_LEB64:
case R_WASM_TABLE_NUMBER_LEB: case R_WASM_TABLE_NUMBER_LEB:
@ -228,7 +228,7 @@ static unsigned getRelocWidthPadded(const WasmRelocation &rel) {
case R_WASM_TYPE_INDEX_LEB: case R_WASM_TYPE_INDEX_LEB:
case R_WASM_FUNCTION_INDEX_LEB: case R_WASM_FUNCTION_INDEX_LEB:
case R_WASM_GLOBAL_INDEX_LEB: case R_WASM_GLOBAL_INDEX_LEB:
case R_WASM_EVENT_INDEX_LEB: case R_WASM_TAG_INDEX_LEB:
case R_WASM_MEMORY_ADDR_LEB: case R_WASM_MEMORY_ADDR_LEB:
case R_WASM_TABLE_NUMBER_LEB: case R_WASM_TABLE_NUMBER_LEB:
case R_WASM_TABLE_INDEX_SLEB: case R_WASM_TABLE_INDEX_SLEB:

View File

@ -18,7 +18,7 @@
namespace lld { namespace lld {
namespace wasm { namespace wasm {
// Represents a single element (Global, Event, Table, etc) within an input // Represents a single element (Global, Tag, Table, etc) within an input
// file. // file.
class InputElement { class InputElement {
protected: protected:
@ -71,17 +71,17 @@ private:
WasmInitExpr initExpr; WasmInitExpr initExpr;
}; };
class InputEvent : public InputElement { class InputTag : public InputElement {
public: public:
InputEvent(const WasmSignature &s, const WasmEvent &e, ObjFile *f) InputTag(const WasmSignature &s, const WasmTag &t, ObjFile *f)
: InputElement(e.SymbolName, f), signature(s), type(e.Type) {} : InputElement(t.SymbolName, f), signature(s), type(t.Type) {}
const WasmEventType &getType() const { return type; } const WasmTagType &getType() const { return type; }
const WasmSignature &signature; const WasmSignature &signature;
private: private:
WasmEventType type; WasmTagType type;
}; };
class InputTable : public InputElement { class InputTable : public InputElement {

View File

@ -93,7 +93,7 @@ void ObjFile::dumpInfo() const {
"\n Symbols : " + Twine(symbols.size()) + "\n Symbols : " + Twine(symbols.size()) +
"\n Function Imports : " + Twine(wasmObj->getNumImportedFunctions()) + "\n Function Imports : " + Twine(wasmObj->getNumImportedFunctions()) +
"\n Global Imports : " + Twine(wasmObj->getNumImportedGlobals()) + "\n Global Imports : " + Twine(wasmObj->getNumImportedGlobals()) +
"\n Event Imports : " + Twine(wasmObj->getNumImportedEvents()) + "\n Tag Imports : " + Twine(wasmObj->getNumImportedTags()) +
"\n Table Imports : " + Twine(wasmObj->getNumImportedTables())); "\n Table Imports : " + Twine(wasmObj->getNumImportedTables()));
} }
@ -209,8 +209,8 @@ uint64_t ObjFile::calcNewValue(const WasmRelocation &reloc, uint64_t tombstone,
if (auto gs = dyn_cast<GlobalSymbol>(sym)) if (auto gs = dyn_cast<GlobalSymbol>(sym))
return gs->getGlobalIndex(); return gs->getGlobalIndex();
return sym->getGOTIndex(); return sym->getGOTIndex();
case R_WASM_EVENT_INDEX_LEB: case R_WASM_TAG_INDEX_LEB:
return getEventSymbol(reloc.Index)->getEventIndex(); return getTagSymbol(reloc.Index)->getTagIndex();
case R_WASM_FUNCTION_OFFSET_I32: case R_WASM_FUNCTION_OFFSET_I32:
case R_WASM_FUNCTION_OFFSET_I64: { case R_WASM_FUNCTION_OFFSET_I64: {
auto *f = cast<DefinedFunction>(sym); auto *f = cast<DefinedFunction>(sym);
@ -343,10 +343,10 @@ void ObjFile::addLegacyIndirectFunctionTableIfNeeded(
LLVM_DEBUG(dbgs() << "Synthesizing symbol for table import: " << info->Name LLVM_DEBUG(dbgs() << "Synthesizing symbol for table import: " << info->Name
<< "\n"); << "\n");
const WasmGlobalType *globalType = nullptr; const WasmGlobalType *globalType = nullptr;
const WasmEventType *eventType = nullptr; const WasmTagType *tagType = nullptr;
const WasmSignature *signature = nullptr; const WasmSignature *signature = nullptr;
auto *wasmSym = make<WasmSymbol>(*info, globalType, &tableImport->Table, auto *wasmSym = make<WasmSymbol>(*info, globalType, &tableImport->Table,
eventType, signature); tagType, signature);
Symbol *sym = createUndefined(*wasmSym, false); Symbol *sym = createUndefined(*wasmSym, false);
// We're only sure it's a TableSymbol if the createUndefined succeeded. // We're only sure it's a TableSymbol if the createUndefined succeeded.
if (errorCount()) if (errorCount())
@ -515,9 +515,9 @@ void ObjFile::parse(bool ignoreComdats) {
for (const WasmGlobal &g : wasmObj->globals()) for (const WasmGlobal &g : wasmObj->globals())
globals.emplace_back(make<InputGlobal>(g, this)); globals.emplace_back(make<InputGlobal>(g, this));
// Populate `Events`. // Populate `Tags`.
for (const WasmEvent &e : wasmObj->events()) for (const WasmTag &t : wasmObj->tags())
events.emplace_back(make<InputEvent>(types[e.Type.SigIndex], e, this)); tags.emplace_back(make<InputTag>(types[t.Type.SigIndex], t, this));
// Populate `Symbols` based on the symbols in the object. // Populate `Symbols` based on the symbols in the object.
symbols.reserve(wasmObj->getNumberOfSymbols()); symbols.reserve(wasmObj->getNumberOfSymbols());
@ -556,8 +556,8 @@ GlobalSymbol *ObjFile::getGlobalSymbol(uint32_t index) const {
return cast<GlobalSymbol>(symbols[index]); return cast<GlobalSymbol>(symbols[index]);
} }
EventSymbol *ObjFile::getEventSymbol(uint32_t index) const { TagSymbol *ObjFile::getTagSymbol(uint32_t index) const {
return cast<EventSymbol>(symbols[index]); return cast<TagSymbol>(symbols[index]);
} }
TableSymbol *ObjFile::getTableSymbol(uint32_t index) const { TableSymbol *ObjFile::getTableSymbol(uint32_t index) const {
@ -612,12 +612,11 @@ Symbol *ObjFile::createDefined(const WasmSymbol &sym) {
return nullptr; return nullptr;
return make<SectionSymbol>(flags, section, this); return make<SectionSymbol>(flags, section, this);
} }
case WASM_SYMBOL_TYPE_EVENT: { case WASM_SYMBOL_TYPE_TAG: {
InputEvent *event = InputTag *tag = tags[sym.Info.ElementIndex - wasmObj->getNumImportedTags()];
events[sym.Info.ElementIndex - wasmObj->getNumImportedEvents()];
if (sym.isBindingLocal()) if (sym.isBindingLocal())
return make<DefinedEvent>(name, flags, this, event); return make<DefinedTag>(name, flags, this, tag);
return symtab->addDefinedEvent(name, flags, this, event); return symtab->addDefinedTag(name, flags, this, tag);
} }
case WASM_SYMBOL_TYPE_TABLE: { case WASM_SYMBOL_TYPE_TABLE: {
InputTable *table = InputTable *table =

View File

@ -31,7 +31,7 @@ class InputChunk;
class InputFunction; class InputFunction;
class InputSegment; class InputSegment;
class InputGlobal; class InputGlobal;
class InputEvent; class InputTag;
class InputTable; class InputTable;
class InputSection; class InputSection;
@ -139,7 +139,7 @@ public:
std::vector<InputChunk *> segments; std::vector<InputChunk *> segments;
std::vector<InputFunction *> functions; std::vector<InputFunction *> functions;
std::vector<InputGlobal *> globals; std::vector<InputGlobal *> globals;
std::vector<InputEvent *> events; std::vector<InputTag *> tags;
std::vector<InputTable *> tables; std::vector<InputTable *> tables;
std::vector<InputChunk *> customSections; std::vector<InputChunk *> customSections;
llvm::DenseMap<uint32_t, InputChunk *> customSectionsByIndex; llvm::DenseMap<uint32_t, InputChunk *> customSectionsByIndex;
@ -149,7 +149,7 @@ public:
DataSymbol *getDataSymbol(uint32_t index) const; DataSymbol *getDataSymbol(uint32_t index) const;
GlobalSymbol *getGlobalSymbol(uint32_t index) const; GlobalSymbol *getGlobalSymbol(uint32_t index) const;
SectionSymbol *getSectionSymbol(uint32_t index) const; SectionSymbol *getSectionSymbol(uint32_t index) const;
EventSymbol *getEventSymbol(uint32_t index) const; TagSymbol *getTagSymbol(uint32_t index) const;
TableSymbol *getTableSymbol(uint32_t index) const; TableSymbol *getTableSymbol(uint32_t index) const;
private: private:

View File

@ -162,9 +162,9 @@ void markLive() {
for (InputGlobal *g : obj->globals) for (InputGlobal *g : obj->globals)
if (!g->live) if (!g->live)
message("removing unused section " + toString(g)); message("removing unused section " + toString(g));
for (InputEvent *e : obj->events) for (InputTag *t : obj->tags)
if (!e->live) if (!t->live)
message("removing unused section " + toString(e)); message("removing unused section " + toString(t));
for (InputTable *t : obj->tables) for (InputTable *t : obj->tables)
if (!t->live) if (!t->live)
message("removing unused section " + toString(t)); message("removing unused section " + toString(t));

View File

@ -49,8 +49,8 @@ static StringRef sectionTypeToString(uint32_t sectionType) {
return "MEMORY"; return "MEMORY";
case WASM_SEC_GLOBAL: case WASM_SEC_GLOBAL:
return "GLOBAL"; return "GLOBAL";
case WASM_SEC_EVENT: case WASM_SEC_TAG:
return "EVENT"; return "TAG";
case WASM_SEC_EXPORT: case WASM_SEC_EXPORT:
return "EXPORT"; return "EXPORT";
case WASM_SEC_START: case WASM_SEC_START:

View File

@ -168,23 +168,23 @@ static void checkGlobalType(const Symbol *existing, const InputFile *file,
} }
} }
static void checkEventType(const Symbol *existing, const InputFile *file, static void checkTagType(const Symbol *existing, const InputFile *file,
const WasmEventType *newType, const WasmTagType *newType,
const WasmSignature *newSig) { const WasmSignature *newSig) {
auto existingEvent = dyn_cast<EventSymbol>(existing); const auto *existingTag = dyn_cast<TagSymbol>(existing);
if (!isa<EventSymbol>(existing)) { if (!isa<TagSymbol>(existing)) {
reportTypeError(existing, file, WASM_SYMBOL_TYPE_EVENT); reportTypeError(existing, file, WASM_SYMBOL_TYPE_TAG);
return; return;
} }
const WasmEventType *oldType = cast<EventSymbol>(existing)->getEventType(); const WasmTagType *oldType = cast<TagSymbol>(existing)->getTagType();
const WasmSignature *oldSig = existingEvent->signature; const WasmSignature *oldSig = existingTag->signature;
if (newType->Attribute != oldType->Attribute) if (newType->Attribute != oldType->Attribute)
error("Event type mismatch: " + existing->getName() + "\n>>> defined as " + error("Tag type mismatch: " + existing->getName() + "\n>>> defined as " +
toString(*oldType) + " in " + toString(existing->getFile()) + toString(*oldType) + " in " + toString(existing->getFile()) +
"\n>>> defined as " + toString(*newType) + " in " + toString(file)); "\n>>> defined as " + toString(*newType) + " in " + toString(file));
if (*newSig != *oldSig) if (*newSig != *oldSig)
warn("Event signature mismatch: " + existing->getName() + warn("Tag signature mismatch: " + existing->getName() +
"\n>>> defined as " + toString(*oldSig) + " in " + "\n>>> defined as " + toString(*oldSig) + " in " +
toString(existing->getFile()) + "\n>>> defined as " + toString(existing->getFile()) + "\n>>> defined as " +
toString(*newSig) + " in " + toString(file)); toString(*newSig) + " in " + toString(file));
@ -413,16 +413,16 @@ Symbol *SymbolTable::addDefinedGlobal(StringRef name, uint32_t flags,
return s; return s;
} }
Symbol *SymbolTable::addDefinedEvent(StringRef name, uint32_t flags, Symbol *SymbolTable::addDefinedTag(StringRef name, uint32_t flags,
InputFile *file, InputEvent *event) { InputFile *file, InputTag *tag) {
LLVM_DEBUG(dbgs() << "addDefinedEvent:" << name << "\n"); LLVM_DEBUG(dbgs() << "addDefinedTag:" << name << "\n");
Symbol *s; Symbol *s;
bool wasInserted; bool wasInserted;
std::tie(s, wasInserted) = insert(name, file); std::tie(s, wasInserted) = insert(name, file);
auto replaceSym = [&]() { auto replaceSym = [&]() {
replaceSymbol<DefinedEvent>(s, name, flags, file, event); replaceSymbol<DefinedTag>(s, name, flags, file, tag);
}; };
if (wasInserted || s->isLazy()) { if (wasInserted || s->isLazy()) {
@ -430,7 +430,7 @@ Symbol *SymbolTable::addDefinedEvent(StringRef name, uint32_t flags,
return s; return s;
} }
checkEventType(s, file, &event->getType(), &event->signature); checkTagType(s, file, &tag->getType(), &tag->signature);
if (shouldReplace(s, file, flags)) if (shouldReplace(s, file, flags))
replaceSym(); replaceSym();

View File

@ -57,8 +57,8 @@ public:
InputChunk *segment, uint64_t address, uint64_t size); InputChunk *segment, uint64_t address, uint64_t size);
Symbol *addDefinedGlobal(StringRef name, uint32_t flags, InputFile *file, Symbol *addDefinedGlobal(StringRef name, uint32_t flags, InputFile *file,
InputGlobal *g); InputGlobal *g);
Symbol *addDefinedEvent(StringRef name, uint32_t flags, InputFile *file, Symbol *addDefinedTag(StringRef name, uint32_t flags, InputFile *file,
InputEvent *e); InputTag *t);
Symbol *addDefinedTable(StringRef name, uint32_t flags, InputFile *file, Symbol *addDefinedTable(StringRef name, uint32_t flags, InputFile *file,
InputTable *t); InputTable *t);

View File

@ -48,8 +48,8 @@ std::string toString(wasm::Symbol::Kind kind) {
return "DefinedGlobal"; return "DefinedGlobal";
case wasm::Symbol::DefinedTableKind: case wasm::Symbol::DefinedTableKind:
return "DefinedTable"; return "DefinedTable";
case wasm::Symbol::DefinedEventKind: case wasm::Symbol::DefinedTagKind:
return "DefinedEvent"; return "DefinedTag";
case wasm::Symbol::UndefinedFunctionKind: case wasm::Symbol::UndefinedFunctionKind:
return "UndefinedFunction"; return "UndefinedFunction";
case wasm::Symbol::UndefinedDataKind: case wasm::Symbol::UndefinedDataKind:
@ -100,8 +100,8 @@ WasmSymbolType Symbol::getWasmType() const {
return WASM_SYMBOL_TYPE_DATA; return WASM_SYMBOL_TYPE_DATA;
if (isa<GlobalSymbol>(this)) if (isa<GlobalSymbol>(this))
return WASM_SYMBOL_TYPE_GLOBAL; return WASM_SYMBOL_TYPE_GLOBAL;
if (isa<EventSymbol>(this)) if (isa<TagSymbol>(this))
return WASM_SYMBOL_TYPE_EVENT; return WASM_SYMBOL_TYPE_TAG;
if (isa<TableSymbol>(this)) if (isa<TableSymbol>(this))
return WASM_SYMBOL_TYPE_TABLE; return WASM_SYMBOL_TYPE_TABLE;
if (isa<SectionSymbol>(this) || isa<OutputSectionSymbol>(this)) if (isa<SectionSymbol>(this) || isa<OutputSectionSymbol>(this))
@ -137,8 +137,8 @@ bool Symbol::isDiscarded() const {
bool Symbol::isLive() const { bool Symbol::isLive() const {
if (auto *g = dyn_cast<DefinedGlobal>(this)) if (auto *g = dyn_cast<DefinedGlobal>(this))
return g->global->live; return g->global->live;
if (auto *e = dyn_cast<DefinedEvent>(this)) if (auto *t = dyn_cast<DefinedTag>(this))
return e->event->live; return t->tag->live;
if (auto *t = dyn_cast<DefinedTable>(this)) if (auto *t = dyn_cast<DefinedTable>(this))
return t->table->live; return t->table->live;
if (InputChunk *c = getChunk()) if (InputChunk *c = getChunk())
@ -153,8 +153,8 @@ void Symbol::markLive() {
file->markLive(); file->markLive();
if (auto *g = dyn_cast<DefinedGlobal>(this)) if (auto *g = dyn_cast<DefinedGlobal>(this))
g->global->live = true; g->global->live = true;
if (auto *e = dyn_cast<DefinedEvent>(this)) if (auto *t = dyn_cast<DefinedTag>(this))
e->event->live = true; t->tag->live = true;
if (auto *t = dyn_cast<DefinedTable>(this)) if (auto *t = dyn_cast<DefinedTable>(this))
t->table->live = true; t->table->live = true;
if (InputChunk *c = getChunk()) { if (InputChunk *c = getChunk()) {
@ -336,31 +336,31 @@ DefinedGlobal::DefinedGlobal(StringRef name, uint32_t flags, InputFile *file,
global ? &global->getType() : nullptr), global ? &global->getType() : nullptr),
global(global) {} global(global) {}
uint32_t EventSymbol::getEventIndex() const { uint32_t TagSymbol::getTagIndex() const {
if (auto *f = dyn_cast<DefinedEvent>(this)) if (auto *f = dyn_cast<DefinedTag>(this))
return f->event->getAssignedIndex(); return f->tag->getAssignedIndex();
assert(eventIndex != INVALID_INDEX); assert(tagIndex != INVALID_INDEX);
return eventIndex; return tagIndex;
} }
void EventSymbol::setEventIndex(uint32_t index) { void TagSymbol::setTagIndex(uint32_t index) {
LLVM_DEBUG(dbgs() << "setEventIndex " << name << " -> " << index << "\n"); LLVM_DEBUG(dbgs() << "setTagIndex " << name << " -> " << index << "\n");
assert(eventIndex == INVALID_INDEX); assert(tagIndex == INVALID_INDEX);
eventIndex = index; tagIndex = index;
} }
bool EventSymbol::hasEventIndex() const { bool TagSymbol::hasTagIndex() const {
if (auto *f = dyn_cast<DefinedEvent>(this)) if (auto *f = dyn_cast<DefinedTag>(this))
return f->event->hasAssignedIndex(); return f->tag->hasAssignedIndex();
return eventIndex != INVALID_INDEX; return tagIndex != INVALID_INDEX;
} }
DefinedEvent::DefinedEvent(StringRef name, uint32_t flags, InputFile *file, DefinedTag::DefinedTag(StringRef name, uint32_t flags, InputFile *file,
InputEvent *event) InputTag *tag)
: EventSymbol(name, DefinedEventKind, flags, file, : TagSymbol(name, DefinedTagKind, flags, file,
event ? &event->getType() : nullptr, tag ? &tag->getType() : nullptr,
event ? &event->signature : nullptr), tag ? &tag->signature : nullptr),
event(event) {} tag(tag) {}
void TableSymbol::setLimits(const WasmLimits &limits) { void TableSymbol::setLimits(const WasmLimits &limits) {
if (auto *t = dyn_cast<DefinedTable>(this)) if (auto *t = dyn_cast<DefinedTable>(this))

View File

@ -33,7 +33,7 @@ class InputChunk;
class InputSegment; class InputSegment;
class InputFunction; class InputFunction;
class InputGlobal; class InputGlobal;
class InputEvent; class InputTag;
class InputSection; class InputSection;
class InputTable; class InputTable;
class OutputSection; class OutputSection;
@ -47,7 +47,7 @@ public:
DefinedFunctionKind, DefinedFunctionKind,
DefinedDataKind, DefinedDataKind,
DefinedGlobalKind, DefinedGlobalKind,
DefinedEventKind, DefinedTagKind,
DefinedTableKind, DefinedTableKind,
SectionKind, SectionKind,
OutputSectionKind, OutputSectionKind,
@ -414,48 +414,48 @@ public:
llvm::Optional<StringRef> importModule; llvm::Optional<StringRef> importModule;
}; };
// Wasm events are features that suspend the current execution and transfer the // A tag is a general format to distinguish typed entities. Each tag has an
// control flow to a corresponding handler. Currently the only supported event // attribute and a type. Currently the attribute can only specify that the tag
// kind is exceptions. // is for an exception tag.
// //
// Event tags are values to distinguish different events. For exceptions, they // In exception handling, tags are used to distinguish different kinds of
// can be used to distinguish different language's exceptions, i.e., all C++ // exceptions. For example, they can be used to distinguish different language's
// exceptions have the same tag. Wasm can generate code capable of doing // exceptions, e.g., all C++ exceptions have the same tag and Java exceptions
// different handling actions based on the tag of caught exceptions. // would have a distinct tag. Wasm can filter the exceptions it catches based on
// their tag.
// //
// A single EventSymbol object represents a single tag. C++ exception event // A single TagSymbol object represents a single tag. The C++ exception symbol
// symbol is a weak symbol generated in every object file in which exceptions // is a weak symbol generated in every object file in which exceptions are used,
// are used, and has name '__cpp_exception' for linking. // and is named '__cpp_exception' for linking.
class EventSymbol : public Symbol { class TagSymbol : public Symbol {
public: public:
static bool classof(const Symbol *s) { return s->kind() == DefinedEventKind; } static bool classof(const Symbol *s) { return s->kind() == DefinedTagKind; }
const WasmEventType *getEventType() const { return eventType; } const WasmTagType *getTagType() const { return tagType; }
// Get/set the event index // Get/set the tag index
uint32_t getEventIndex() const; uint32_t getTagIndex() const;
void setEventIndex(uint32_t index); void setTagIndex(uint32_t index);
bool hasEventIndex() const; bool hasTagIndex() const;
const WasmSignature *signature; const WasmSignature *signature;
protected: protected:
EventSymbol(StringRef name, Kind k, uint32_t flags, InputFile *f, TagSymbol(StringRef name, Kind k, uint32_t flags, InputFile *f,
const WasmEventType *eventType, const WasmSignature *sig) const WasmTagType *tagType, const WasmSignature *sig)
: Symbol(name, k, flags, f), signature(sig), eventType(eventType) {} : Symbol(name, k, flags, f), signature(sig), tagType(tagType) {}
const WasmEventType *eventType; const WasmTagType *tagType;
uint32_t eventIndex = INVALID_INDEX; uint32_t tagIndex = INVALID_INDEX;
}; };
class DefinedEvent : public EventSymbol { class DefinedTag : public TagSymbol {
public: public:
DefinedEvent(StringRef name, uint32_t flags, InputFile *file, DefinedTag(StringRef name, uint32_t flags, InputFile *file, InputTag *tag);
InputEvent *event);
static bool classof(const Symbol *s) { return s->kind() == DefinedEventKind; } static bool classof(const Symbol *s) { return s->kind() == DefinedTagKind; }
InputEvent *event; InputTag *tag;
}; };
// LazySymbol represents a symbol that is not yet in the link, but we know where // LazySymbol represents a symbol that is not yet in the link, but we know where
@ -588,7 +588,7 @@ union SymbolUnion {
alignas(DefinedFunction) char a[sizeof(DefinedFunction)]; alignas(DefinedFunction) char a[sizeof(DefinedFunction)];
alignas(DefinedData) char b[sizeof(DefinedData)]; alignas(DefinedData) char b[sizeof(DefinedData)];
alignas(DefinedGlobal) char c[sizeof(DefinedGlobal)]; alignas(DefinedGlobal) char c[sizeof(DefinedGlobal)];
alignas(DefinedEvent) char d[sizeof(DefinedEvent)]; alignas(DefinedTag) char d[sizeof(DefinedTag)];
alignas(DefinedTable) char e[sizeof(DefinedTable)]; alignas(DefinedTable) char e[sizeof(DefinedTable)];
alignas(LazySymbol) char f[sizeof(LazySymbol)]; alignas(LazySymbol) char f[sizeof(LazySymbol)];
alignas(UndefinedFunction) char g[sizeof(UndefinedFunction)]; alignas(UndefinedFunction) char g[sizeof(UndefinedFunction)];

View File

@ -114,8 +114,8 @@ void ImportSection::addImport(Symbol *sym) {
f->setFunctionIndex(numImportedFunctions++); f->setFunctionIndex(numImportedFunctions++);
else if (auto *g = dyn_cast<GlobalSymbol>(sym)) else if (auto *g = dyn_cast<GlobalSymbol>(sym))
g->setGlobalIndex(numImportedGlobals++); g->setGlobalIndex(numImportedGlobals++);
else if (auto *e = dyn_cast<EventSymbol>(sym)) else if (auto *t = dyn_cast<TagSymbol>(sym))
e->setEventIndex(numImportedEvents++); t->setTagIndex(numImportedTags++);
else else
cast<TableSymbol>(sym)->setTableNumber(numImportedTables++); cast<TableSymbol>(sym)->setTableNumber(numImportedTables++);
} }
@ -165,10 +165,10 @@ void ImportSection::writeBody() {
} else if (auto *globalSym = dyn_cast<GlobalSymbol>(sym)) { } else if (auto *globalSym = dyn_cast<GlobalSymbol>(sym)) {
import.Kind = WASM_EXTERNAL_GLOBAL; import.Kind = WASM_EXTERNAL_GLOBAL;
import.Global = *globalSym->getGlobalType(); import.Global = *globalSym->getGlobalType();
} else if (auto *eventSym = dyn_cast<EventSymbol>(sym)) { } else if (auto *tagSym = dyn_cast<TagSymbol>(sym)) {
import.Kind = WASM_EXTERNAL_EVENT; import.Kind = WASM_EXTERNAL_TAG;
import.Event.Attribute = eventSym->getEventType()->Attribute; import.Tag.Attribute = tagSym->getTagType()->Attribute;
import.Event.SigIndex = out.typeSec->lookupType(*eventSym->signature); import.Tag.SigIndex = out.typeSec->lookupType(*tagSym->signature);
} else { } else {
auto *tableSym = cast<TableSymbol>(sym); auto *tableSym = cast<TableSymbol>(sym);
import.Kind = WASM_EXTERNAL_TABLE; import.Kind = WASM_EXTERNAL_TABLE;
@ -267,25 +267,24 @@ void MemorySection::writeBody() {
writeUleb128(os, maxMemoryPages, "max pages"); writeUleb128(os, maxMemoryPages, "max pages");
} }
void EventSection::writeBody() { void TagSection::writeBody() {
raw_ostream &os = bodyOutputStream; raw_ostream &os = bodyOutputStream;
writeUleb128(os, inputEvents.size(), "event count"); writeUleb128(os, inputTags.size(), "tag count");
for (InputEvent *e : inputEvents) { for (InputTag *t : inputTags) {
WasmEventType type = e->getType(); WasmTagType type = t->getType();
type.SigIndex = out.typeSec->lookupType(e->signature); type.SigIndex = out.typeSec->lookupType(t->signature);
writeEventType(os, type); writeTagType(os, type);
} }
} }
void EventSection::addEvent(InputEvent *event) { void TagSection::addTag(InputTag *tag) {
if (!event->live) if (!tag->live)
return; return;
uint32_t eventIndex = uint32_t tagIndex = out.importSec->getNumImportedTags() + inputTags.size();
out.importSec->getNumImportedEvents() + inputEvents.size(); LLVM_DEBUG(dbgs() << "addTag: " << tagIndex << "\n");
LLVM_DEBUG(dbgs() << "addEvent: " << eventIndex << "\n"); tag->assignIndex(tagIndex);
event->assignIndex(eventIndex); inputTags.push_back(tag);
inputEvents.push_back(event);
} }
void GlobalSection::assignIndexes() { void GlobalSection::assignIndexes() {
@ -505,8 +504,8 @@ void LinkingSection::writeBody() {
writeUleb128(sub.os, g->getGlobalIndex(), "index"); writeUleb128(sub.os, g->getGlobalIndex(), "index");
if (sym->isDefined() || (flags & WASM_SYMBOL_EXPLICIT_NAME) != 0) if (sym->isDefined() || (flags & WASM_SYMBOL_EXPLICIT_NAME) != 0)
writeStr(sub.os, sym->getName(), "sym name"); writeStr(sub.os, sym->getName(), "sym name");
} else if (auto *e = dyn_cast<EventSymbol>(sym)) { } else if (auto *t = dyn_cast<TagSymbol>(sym)) {
writeUleb128(sub.os, e->getEventIndex(), "index"); writeUleb128(sub.os, t->getTagIndex(), "index");
if (sym->isDefined() || (flags & WASM_SYMBOL_EXPLICIT_NAME) != 0) if (sym->isDefined() || (flags & WASM_SYMBOL_EXPLICIT_NAME) != 0)
writeStr(sub.os, sym->getName(), "sym name"); writeStr(sub.os, sym->getName(), "sym name");
} else if (auto *t = dyn_cast<TableSymbol>(sym)) { } else if (auto *t = dyn_cast<TableSymbol>(sym)) {

View File

@ -113,9 +113,9 @@ public:
assert(isSealed); assert(isSealed);
return numImportedFunctions; return numImportedFunctions;
} }
uint32_t getNumImportedEvents() const { uint32_t getNumImportedTags() const {
assert(isSealed); assert(isSealed);
return numImportedEvents; return numImportedTags;
} }
uint32_t getNumImportedTables() const { uint32_t getNumImportedTables() const {
assert(isSealed); assert(isSealed);
@ -129,7 +129,7 @@ protected:
bool isSealed = false; bool isSealed = false;
unsigned numImportedGlobals = 0; unsigned numImportedGlobals = 0;
unsigned numImportedFunctions = 0; unsigned numImportedFunctions = 0;
unsigned numImportedEvents = 0; unsigned numImportedTags = 0;
unsigned numImportedTables = 0; unsigned numImportedTables = 0;
}; };
@ -169,24 +169,23 @@ public:
uint64_t maxMemoryPages = 0; uint64_t maxMemoryPages = 0;
}; };
// The event section contains a list of declared wasm events associated with the // The tag section contains a list of declared wasm tags associated with the
// module. Currently the only supported event kind is exceptions. A single event // module. Currently the only supported tag kind is exceptions. All C++
// entry represents a single event with an event tag. All C++ exceptions are // exceptions are represented by a single tag. A tag entry in this section
// represented by a single event. An event entry in this section contains // contains information on what kind of tag it is (e.g. exception) and the type
// information on what kind of event it is (e.g. exception) and the type of // of values associated with the tag. (In Wasm, a tag can contain multiple
// values contained in a single event object. (In wasm, an event can contain // values of primitive types. But for C++ exceptions, we just throw a pointer
// multiple values of primitive types. But for C++ exceptions, we just throw a // which is an i32 value (for wasm32 architecture), so the signature of C++
// pointer which is an i32 value (for wasm32 architecture), so the signature of // exception is (i32)->(void), because all exception tag types are assumed to
// C++ exception is (i32)->(void), because all event types are assumed to have // have void return type to share WasmSignature with functions.)
// void return type to share WasmSignature with functions.) class TagSection : public SyntheticSection {
class EventSection : public SyntheticSection {
public: public:
EventSection() : SyntheticSection(llvm::wasm::WASM_SEC_EVENT) {} TagSection() : SyntheticSection(llvm::wasm::WASM_SEC_TAG) {}
void writeBody() override; void writeBody() override;
bool isNeeded() const override { return inputEvents.size() > 0; } bool isNeeded() const override { return inputTags.size() > 0; }
void addEvent(InputEvent *event); void addTag(InputTag *tag);
std::vector<InputEvent *> inputEvents; std::vector<InputTag *> inputTags;
}; };
class GlobalSection : public SyntheticSection { class GlobalSection : public SyntheticSection {
@ -363,7 +362,7 @@ struct OutStruct {
TableSection *tableSec; TableSection *tableSec;
MemorySection *memorySec; MemorySection *memorySec;
GlobalSection *globalSec; GlobalSection *globalSec;
EventSection *eventSec; TagSection *tagSec;
ExportSection *exportSec; ExportSection *exportSec;
StartSection *startSec; StartSection *startSec;
ElemSection *elemSec; ElemSection *elemSec;

View File

@ -391,7 +391,7 @@ void Writer::addSections() {
addSection(out.functionSec); addSection(out.functionSec);
addSection(out.tableSec); addSection(out.tableSec);
addSection(out.memorySec); addSection(out.memorySec);
addSection(out.eventSec); addSection(out.tagSec);
addSection(out.globalSec); addSection(out.globalSec);
addSection(out.exportSec); addSection(out.exportSec);
addSection(out.startSec); addSection(out.startSec);
@ -625,8 +625,8 @@ void Writer::calculateExports() {
continue; continue;
} }
export_ = {name, WASM_EXTERNAL_GLOBAL, g->getGlobalIndex()}; export_ = {name, WASM_EXTERNAL_GLOBAL, g->getGlobalIndex()};
} else if (auto *e = dyn_cast<DefinedEvent>(sym)) { } else if (auto *t = dyn_cast<DefinedTag>(sym)) {
export_ = {name, WASM_EXTERNAL_EVENT, e->getEventIndex()}; export_ = {name, WASM_EXTERNAL_TAG, t->getTagIndex()};
} else if (auto *d = dyn_cast<DefinedData>(sym)) { } else if (auto *d = dyn_cast<DefinedData>(sym)) {
if (d->segment && d->segment->isTLS()) { if (d->segment && d->segment->isTLS()) {
// We can't currenly export TLS data symbols. // We can't currenly export TLS data symbols.
@ -668,8 +668,8 @@ void Writer::calculateTypes() {
// 1. Any signature used in the TYPE relocation // 1. Any signature used in the TYPE relocation
// 2. The signatures of all imported functions // 2. The signatures of all imported functions
// 3. The signatures of all defined functions // 3. The signatures of all defined functions
// 4. The signatures of all imported events // 4. The signatures of all imported tags
// 5. The signatures of all defined events // 5. The signatures of all defined tags
for (ObjFile *file : symtab->objectFiles) { for (ObjFile *file : symtab->objectFiles) {
ArrayRef<WasmSignature> types = file->getWasmObj()->types(); ArrayRef<WasmSignature> types = file->getWasmObj()->types();
@ -681,15 +681,15 @@ void Writer::calculateTypes() {
for (const Symbol *sym : out.importSec->importedSymbols) { for (const Symbol *sym : out.importSec->importedSymbols) {
if (auto *f = dyn_cast<FunctionSymbol>(sym)) if (auto *f = dyn_cast<FunctionSymbol>(sym))
out.typeSec->registerType(*f->signature); out.typeSec->registerType(*f->signature);
else if (auto *e = dyn_cast<EventSymbol>(sym)) else if (auto *t = dyn_cast<TagSymbol>(sym))
out.typeSec->registerType(*e->signature); out.typeSec->registerType(*t->signature);
} }
for (const InputFunction *f : out.functionSec->inputFunctions) for (const InputFunction *f : out.functionSec->inputFunctions)
out.typeSec->registerType(f->signature); out.typeSec->registerType(f->signature);
for (const InputEvent *e : out.eventSec->inputEvents) for (const InputTag *t : out.tagSec->inputTags)
out.typeSec->registerType(e->signature); out.typeSec->registerType(t->signature);
} }
// In a command-style link, create a wrapper for each exported symbol // In a command-style link, create a wrapper for each exported symbol
@ -797,9 +797,9 @@ void Writer::assignIndexes() {
} }
for (ObjFile *file : symtab->objectFiles) { for (ObjFile *file : symtab->objectFiles) {
LLVM_DEBUG(dbgs() << "Events: " << file->getName() << "\n"); LLVM_DEBUG(dbgs() << "Tags: " << file->getName() << "\n");
for (InputEvent *event : file->events) for (InputTag *tag : file->tags)
out.eventSec->addEvent(event); out.tagSec->addTag(tag);
} }
for (ObjFile *file : symtab->objectFiles) { for (ObjFile *file : symtab->objectFiles) {
@ -1361,7 +1361,7 @@ void Writer::createSyntheticSections() {
out.functionSec = make<FunctionSection>(); out.functionSec = make<FunctionSection>();
out.tableSec = make<TableSection>(); out.tableSec = make<TableSection>();
out.memorySec = make<MemorySection>(); out.memorySec = make<MemorySection>();
out.eventSec = make<EventSection>(); out.tagSec = make<TagSection>();
out.globalSec = make<GlobalSection>(); out.globalSec = make<GlobalSection>();
out.exportSec = make<ExportSection>(); out.exportSec = make<ExportSection>();
out.startSec = make<StartSection>(); out.startSec = make<StartSection>();
@ -1494,12 +1494,12 @@ void Writer::run() {
if (errorHandler().verbose) { if (errorHandler().verbose) {
log("Defined Functions: " + Twine(out.functionSec->inputFunctions.size())); log("Defined Functions: " + Twine(out.functionSec->inputFunctions.size()));
log("Defined Globals : " + Twine(out.globalSec->numGlobals())); log("Defined Globals : " + Twine(out.globalSec->numGlobals()));
log("Defined Events : " + Twine(out.eventSec->inputEvents.size())); log("Defined Tags : " + Twine(out.tagSec->inputTags.size()));
log("Defined Tables : " + Twine(out.tableSec->inputTables.size())); log("Defined Tables : " + Twine(out.tableSec->inputTables.size()));
log("Function Imports : " + log("Function Imports : " +
Twine(out.importSec->getNumImportedFunctions())); Twine(out.importSec->getNumImportedFunctions()));
log("Global Imports : " + Twine(out.importSec->getNumImportedGlobals())); log("Global Imports : " + Twine(out.importSec->getNumImportedGlobals()));
log("Event Imports : " + Twine(out.importSec->getNumImportedEvents())); log("Tag Imports : " + Twine(out.importSec->getNumImportedTags()));
log("Table Imports : " + Twine(out.importSec->getNumImportedTables())); log("Table Imports : " + Twine(out.importSec->getNumImportedTables()));
for (ObjFile *file : symtab->objectFiles) for (ObjFile *file : symtab->objectFiles)
file->dumpInfo(); file->dumpInfo();

View File

@ -58,8 +58,8 @@ std::string toString(const WasmGlobalType &type) {
toString(static_cast<ValType>(type.Type)); toString(static_cast<ValType>(type.Type));
} }
std::string toString(const WasmEventType &type) { std::string toString(const WasmTagType &type) {
if (type.Attribute == WASM_EVENT_ATTRIBUTE_EXCEPTION) if (type.Attribute == WASM_TAG_ATTRIBUTE_EXCEPTION)
return "exception"; return "exception";
return "unknown"; return "unknown";
} }
@ -202,13 +202,13 @@ void writeGlobalType(raw_ostream &os, const WasmGlobalType &type) {
writeU8(os, type.Mutable, "global mutable"); writeU8(os, type.Mutable, "global mutable");
} }
void writeEventType(raw_ostream &os, const WasmEventType &type) { void writeTagType(raw_ostream &os, const WasmTagType &type) {
writeUleb128(os, type.Attribute, "event attribute"); writeUleb128(os, type.Attribute, "tag attribute");
writeUleb128(os, type.SigIndex, "sig index"); writeUleb128(os, type.SigIndex, "sig index");
} }
void writeEvent(raw_ostream &os, const WasmEvent &event) { void writeTag(raw_ostream &os, const WasmTag &tag) {
writeEventType(os, event.Type); writeTagType(os, tag.Type);
} }
void writeTableType(raw_ostream &os, const WasmTableType &type) { void writeTableType(raw_ostream &os, const WasmTableType &type) {
@ -227,8 +227,8 @@ void writeImport(raw_ostream &os, const WasmImport &import) {
case WASM_EXTERNAL_GLOBAL: case WASM_EXTERNAL_GLOBAL:
writeGlobalType(os, import.Global); writeGlobalType(os, import.Global);
break; break;
case WASM_EXTERNAL_EVENT: case WASM_EXTERNAL_TAG:
writeEventType(os, import.Event); writeTagType(os, import.Tag);
break; break;
case WASM_EXTERNAL_MEMORY: case WASM_EXTERNAL_MEMORY:
writeLimits(os, import.Memory); writeLimits(os, import.Memory);
@ -251,8 +251,8 @@ void writeExport(raw_ostream &os, const WasmExport &export_) {
case WASM_EXTERNAL_GLOBAL: case WASM_EXTERNAL_GLOBAL:
writeUleb128(os, export_.Index, "global index"); writeUleb128(os, export_.Index, "global index");
break; break;
case WASM_EXTERNAL_EVENT: case WASM_EXTERNAL_TAG:
writeUleb128(os, export_.Index, "event index"); writeUleb128(os, export_.Index, "tag index");
break; break;
case WASM_EXTERNAL_MEMORY: case WASM_EXTERNAL_MEMORY:
writeUleb128(os, export_.Index, "memory index"); writeUleb128(os, export_.Index, "memory index");

View File

@ -51,9 +51,9 @@ void writeLimits(raw_ostream &os, const llvm::wasm::WasmLimits &limits);
void writeGlobalType(raw_ostream &os, const llvm::wasm::WasmGlobalType &type); void writeGlobalType(raw_ostream &os, const llvm::wasm::WasmGlobalType &type);
void writeEventType(raw_ostream &os, const llvm::wasm::WasmEventType &type); void writeTagType(raw_ostream &os, const llvm::wasm::WasmTagType &type);
void writeEvent(raw_ostream &os, const llvm::wasm::WasmEvent &event); void writeTag(raw_ostream &os, const llvm::wasm::WasmTag &tag);
void writeTableType(raw_ostream &os, const llvm::wasm::WasmTableType &type); void writeTableType(raw_ostream &os, const llvm::wasm::WasmTableType &type);
@ -66,7 +66,7 @@ void writeExport(raw_ostream &os, const llvm::wasm::WasmExport &export_);
std::string toString(llvm::wasm::ValType type); std::string toString(llvm::wasm::ValType type);
std::string toString(const llvm::wasm::WasmSignature &sig); std::string toString(const llvm::wasm::WasmSignature &sig);
std::string toString(const llvm::wasm::WasmGlobalType &type); std::string toString(const llvm::wasm::WasmGlobalType &type);
std::string toString(const llvm::wasm::WasmEventType &type); std::string toString(const llvm::wasm::WasmTagType &type);
std::string toString(const llvm::wasm::WasmTableType &type); std::string toString(const llvm::wasm::WasmTableType &type);
} // namespace lld } // namespace lld

View File

@ -196,7 +196,7 @@ bool ObjectFileWasm::DecodeNextSection(lldb::offset_t *offset_ptr) {
m_sect_infos.push_back(section_info{*offset_ptr + c.tell(), section_length, m_sect_infos.push_back(section_info{*offset_ptr + c.tell(), section_length,
section_id, *sect_name}); section_id, *sect_name});
*offset_ptr += (c.tell() + section_length); *offset_ptr += (c.tell() + section_length);
} else if (section_id <= llvm::wasm::WASM_SEC_EVENT) { } else if (section_id <= llvm::wasm::WASM_SEC_TAG) {
m_sect_infos.push_back(section_info{*offset_ptr + c.tell(), m_sect_infos.push_back(section_info{*offset_ptr + c.tell(),
static_cast<uint32_t>(payload_len), static_cast<uint32_t>(payload_len),
section_id, ConstString()}); section_id, ConstString()});

View File

@ -101,15 +101,15 @@ struct WasmGlobal {
StringRef SymbolName; // from the "linking" section StringRef SymbolName; // from the "linking" section
}; };
struct WasmEventType { struct WasmTagType {
// Kind of event. Currently only WASM_EVENT_ATTRIBUTE_EXCEPTION is possible. // Kind of tag. Currently only WASM_TAG_ATTRIBUTE_EXCEPTION is possible.
uint32_t Attribute; uint32_t Attribute;
uint32_t SigIndex; uint32_t SigIndex;
}; };
struct WasmEvent { struct WasmTag {
uint32_t Index; uint32_t Index;
WasmEventType Type; WasmTagType Type;
StringRef SymbolName; // from the "linking" section StringRef SymbolName; // from the "linking" section
}; };
@ -122,7 +122,7 @@ struct WasmImport {
WasmGlobalType Global; WasmGlobalType Global;
WasmTableType Table; WasmTableType Table;
WasmLimits Memory; WasmLimits Memory;
WasmEventType Event; WasmTagType Tag;
}; };
}; };
@ -238,7 +238,7 @@ enum : unsigned {
WASM_SEC_CODE = 10, // Function bodies (code) WASM_SEC_CODE = 10, // Function bodies (code)
WASM_SEC_DATA = 11, // Data segments WASM_SEC_DATA = 11, // Data segments
WASM_SEC_DATACOUNT = 12, // Data segment count 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. // Type immediate encodings used in various contexts.
@ -260,7 +260,7 @@ enum : unsigned {
WASM_EXTERNAL_TABLE = 0x1, WASM_EXTERNAL_TABLE = 0x1,
WASM_EXTERNAL_MEMORY = 0x2, WASM_EXTERNAL_MEMORY = 0x2,
WASM_EXTERNAL_GLOBAL = 0x3, WASM_EXTERNAL_GLOBAL = 0x3,
WASM_EXTERNAL_EVENT = 0x4, WASM_EXTERNAL_TAG = 0x4,
}; };
// Opcodes used in initializer expressions. // Opcodes used in initializer expressions.
@ -343,7 +343,7 @@ enum : unsigned {
enum : unsigned { enum : unsigned {
WASM_COMDAT_DATA = 0x0, WASM_COMDAT_DATA = 0x0,
WASM_COMDAT_FUNCTION = 0x1, 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, WASM_COMDAT_SECTION = 0x5,
}; };
@ -353,7 +353,7 @@ enum WasmSymbolType : unsigned {
WASM_SYMBOL_TYPE_DATA = 0x1, WASM_SYMBOL_TYPE_DATA = 0x1,
WASM_SYMBOL_TYPE_GLOBAL = 0x2, WASM_SYMBOL_TYPE_GLOBAL = 0x2,
WASM_SYMBOL_TYPE_SECTION = 0x3, WASM_SYMBOL_TYPE_SECTION = 0x3,
WASM_SYMBOL_TYPE_EVENT = 0x4, WASM_SYMBOL_TYPE_TAG = 0x4,
WASM_SYMBOL_TYPE_TABLE = 0x5, WASM_SYMBOL_TYPE_TABLE = 0x5,
}; };
@ -362,9 +362,9 @@ enum WasmSegmentFlag : unsigned {
WASM_SEG_FLAG_TLS = 0x2, WASM_SEG_FLAG_TLS = 0x2,
}; };
// Kinds of event attributes. // Kinds of tag attributes.
enum WasmEventAttribute : unsigned { enum WasmTagAttribute : unsigned {
WASM_EVENT_ATTRIBUTE_EXCEPTION = 0x0, WASM_TAG_ATTRIBUTE_EXCEPTION = 0x0,
}; };
const unsigned WASM_SYMBOL_BINDING_MASK = 0x3; const unsigned WASM_SYMBOL_BINDING_MASK = 0x3;

View File

@ -12,7 +12,7 @@ WASM_RELOC(R_WASM_TYPE_INDEX_LEB, 6)
WASM_RELOC(R_WASM_GLOBAL_INDEX_LEB, 7) WASM_RELOC(R_WASM_GLOBAL_INDEX_LEB, 7)
WASM_RELOC(R_WASM_FUNCTION_OFFSET_I32, 8) WASM_RELOC(R_WASM_FUNCTION_OFFSET_I32, 8)
WASM_RELOC(R_WASM_SECTION_OFFSET_I32, 9) 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_MEMORY_ADDR_REL_SLEB, 11)
WASM_RELOC(R_WASM_TABLE_INDEX_REL_SLEB, 12) WASM_RELOC(R_WASM_TABLE_INDEX_REL_SLEB, 12)
WASM_RELOC(R_WASM_GLOBAL_INDEX_I32, 13) WASM_RELOC(R_WASM_GLOBAL_INDEX_I32, 13)

View File

@ -24,7 +24,7 @@ class Function;
class MachineBasicBlock; class MachineBasicBlock;
namespace WebAssembly { namespace WebAssembly {
enum EventTag { CPP_EXCEPTION = 0, C_LONGJMP = 1 }; enum Tag { CPP_EXCEPTION = 0, C_LONGJMP = 1 };
} }
using BBOrMBB = PointerUnion<const BasicBlock *, MachineBasicBlock *>; using BBOrMBB = PointerUnion<const BasicBlock *, MachineBasicBlock *>;

View File

@ -27,7 +27,7 @@ class MCSymbolWasm : public MCSymbol {
wasm::WasmSignature *Signature = nullptr; wasm::WasmSignature *Signature = nullptr;
Optional<wasm::WasmGlobalType> GlobalType; Optional<wasm::WasmGlobalType> GlobalType;
Optional<wasm::WasmTableType> TableType; 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 /// An expression describing how to calculate the size of a symbol. If a
/// symbol has no size this field will be NULL. /// 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 isGlobal() const { return Type == wasm::WASM_SYMBOL_TYPE_GLOBAL; }
bool isTable() const { return Type == wasm::WASM_SYMBOL_TYPE_TABLE; } bool isTable() const { return Type == wasm::WASM_SYMBOL_TYPE_TABLE; }
bool isSection() const { return Type == wasm::WASM_SYMBOL_TYPE_SECTION; } 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; } Optional<wasm::WasmSymbolType> getType() const { return Type; }
@ -143,11 +143,11 @@ public:
setTableType({uint8_t(VT), Limits}); setTableType({uint8_t(VT), Limits});
} }
const wasm::WasmEventType &getEventType() const { const wasm::WasmTagType &getTagType() const {
assert(EventType.hasValue()); assert(TagType.hasValue());
return EventType.getValue(); return TagType.getValue();
} }
void setEventType(wasm::WasmEventType ET) { EventType = ET; } void setTagType(wasm::WasmTagType ET) { TagType = ET; }
}; };
} // end namespace llvm } // end namespace llvm

View File

@ -37,15 +37,15 @@ public:
WasmSymbol(const wasm::WasmSymbolInfo &Info, WasmSymbol(const wasm::WasmSymbolInfo &Info,
const wasm::WasmGlobalType *GlobalType, const wasm::WasmGlobalType *GlobalType,
const wasm::WasmTableType *TableType, const wasm::WasmTableType *TableType,
const wasm::WasmEventType *EventType, const wasm::WasmTagType *TagType,
const wasm::WasmSignature *Signature) const wasm::WasmSignature *Signature)
: Info(Info), GlobalType(GlobalType), TableType(TableType), : Info(Info), GlobalType(GlobalType), TableType(TableType),
EventType(EventType), Signature(Signature) {} TagType(TagType), Signature(Signature) {}
const wasm::WasmSymbolInfo &Info; const wasm::WasmSymbolInfo &Info;
const wasm::WasmGlobalType *GlobalType; const wasm::WasmGlobalType *GlobalType;
const wasm::WasmTableType *TableType; const wasm::WasmTableType *TableType;
const wasm::WasmEventType *EventType; const wasm::WasmTagType *TagType;
const wasm::WasmSignature *Signature; const wasm::WasmSignature *Signature;
bool isTypeFunction() const { bool isTypeFunction() const {
@ -64,7 +64,7 @@ public:
return Info.Kind == wasm::WASM_SYMBOL_TYPE_SECTION; 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(); } bool isDefined() const { return !isUndefined(); }
@ -143,7 +143,7 @@ public:
ArrayRef<wasm::WasmTable> tables() const { return Tables; } ArrayRef<wasm::WasmTable> tables() const { return Tables; }
ArrayRef<wasm::WasmLimits> memories() const { return Memories; } ArrayRef<wasm::WasmLimits> memories() const { return Memories; }
ArrayRef<wasm::WasmGlobal> globals() const { return Globals; } 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<wasm::WasmExport> exports() const { return Exports; }
ArrayRef<WasmSymbol> syms() const { return Symbols; } ArrayRef<WasmSymbol> syms() const { return Symbols; }
const wasm::WasmLinkingData &linkingData() const { return LinkingData; } const wasm::WasmLinkingData &linkingData() const { return LinkingData; }
@ -156,7 +156,7 @@ public:
uint32_t getNumImportedGlobals() const { return NumImportedGlobals; } uint32_t getNumImportedGlobals() const { return NumImportedGlobals; }
uint32_t getNumImportedTables() const { return NumImportedTables; } uint32_t getNumImportedTables() const { return NumImportedTables; }
uint32_t getNumImportedFunctions() const { return NumImportedFunctions; } 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(); } uint32_t getNumSections() const { return Sections.size(); }
void moveSymbolNext(DataRefImpl &Symb) const override; void moveSymbolNext(DataRefImpl &Symb) const override;
@ -223,18 +223,18 @@ private:
bool isValidTableNumber(uint32_t Index) const; bool isValidTableNumber(uint32_t Index) const;
bool isDefinedGlobalIndex(uint32_t Index) const; bool isDefinedGlobalIndex(uint32_t Index) const;
bool isDefinedTableNumber(uint32_t Index) const; bool isDefinedTableNumber(uint32_t Index) const;
bool isValidEventIndex(uint32_t Index) const; bool isValidTagIndex(uint32_t Index) const;
bool isDefinedEventIndex(uint32_t Index) const; bool isDefinedTagIndex(uint32_t Index) const;
bool isValidFunctionSymbol(uint32_t Index) const; bool isValidFunctionSymbol(uint32_t Index) const;
bool isValidTableSymbol(uint32_t Index) const; bool isValidTableSymbol(uint32_t Index) const;
bool isValidGlobalSymbol(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 isValidDataSymbol(uint32_t Index) const;
bool isValidSectionSymbol(uint32_t Index) const; bool isValidSectionSymbol(uint32_t Index) const;
wasm::WasmFunction &getDefinedFunction(uint32_t Index); wasm::WasmFunction &getDefinedFunction(uint32_t Index);
const wasm::WasmFunction &getDefinedFunction(uint32_t Index) const; const wasm::WasmFunction &getDefinedFunction(uint32_t Index) const;
wasm::WasmGlobal &getDefinedGlobal(uint32_t Index); 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 WasmSection &getWasmSection(DataRefImpl Ref) const;
const wasm::WasmRelocation &getWasmRelocation(DataRefImpl Ref) const; const wasm::WasmRelocation &getWasmRelocation(DataRefImpl Ref) const;
@ -249,7 +249,7 @@ private:
Error parseFunctionSection(ReadContext &Ctx); Error parseFunctionSection(ReadContext &Ctx);
Error parseTableSection(ReadContext &Ctx); Error parseTableSection(ReadContext &Ctx);
Error parseMemorySection(ReadContext &Ctx); Error parseMemorySection(ReadContext &Ctx);
Error parseEventSection(ReadContext &Ctx); Error parseTagSection(ReadContext &Ctx);
Error parseGlobalSection(ReadContext &Ctx); Error parseGlobalSection(ReadContext &Ctx);
Error parseExportSection(ReadContext &Ctx); Error parseExportSection(ReadContext &Ctx);
Error parseStartSection(ReadContext &Ctx); Error parseStartSection(ReadContext &Ctx);
@ -278,7 +278,7 @@ private:
std::vector<wasm::WasmTable> Tables; std::vector<wasm::WasmTable> Tables;
std::vector<wasm::WasmLimits> Memories; std::vector<wasm::WasmLimits> Memories;
std::vector<wasm::WasmGlobal> Globals; std::vector<wasm::WasmGlobal> Globals;
std::vector<wasm::WasmEvent> Events; std::vector<wasm::WasmTag> Tags;
std::vector<wasm::WasmImport> Imports; std::vector<wasm::WasmImport> Imports;
std::vector<wasm::WasmExport> Exports; std::vector<wasm::WasmExport> Exports;
std::vector<wasm::WasmElemSegment> ElemSegments; std::vector<wasm::WasmElemSegment> ElemSegments;
@ -296,10 +296,10 @@ private:
uint32_t NumImportedGlobals = 0; uint32_t NumImportedGlobals = 0;
uint32_t NumImportedTables = 0; uint32_t NumImportedTables = 0;
uint32_t NumImportedFunctions = 0; uint32_t NumImportedFunctions = 0;
uint32_t NumImportedEvents = 0; uint32_t NumImportedTags = 0;
uint32_t CodeSection = 0; uint32_t CodeSection = 0;
uint32_t DataSection = 0; uint32_t DataSection = 0;
uint32_t EventSection = 0; uint32_t TagSection = 0;
uint32_t GlobalSection = 0; uint32_t GlobalSection = 0;
uint32_t TableSection = 0; uint32_t TableSection = 0;
}; };
@ -317,7 +317,7 @@ public:
WASM_SEC_ORDER_FUNCTION, WASM_SEC_ORDER_FUNCTION,
WASM_SEC_ORDER_TABLE, WASM_SEC_ORDER_TABLE,
WASM_SEC_ORDER_MEMORY, WASM_SEC_ORDER_MEMORY,
WASM_SEC_ORDER_EVENT, WASM_SEC_ORDER_TAG,
WASM_SEC_ORDER_GLOBAL, WASM_SEC_ORDER_GLOBAL,
WASM_SEC_ORDER_EXPORT, WASM_SEC_ORDER_EXPORT,
WASM_SEC_ORDER_START, WASM_SEC_ORDER_START,

View File

@ -77,7 +77,7 @@ struct Global {
wasm::WasmInitExpr InitExpr; wasm::WasmInitExpr InitExpr;
}; };
struct Event { struct Tag {
uint32_t Index; uint32_t Index;
uint32_t Attribute; uint32_t Attribute;
uint32_t SigIndex; uint32_t SigIndex;
@ -92,7 +92,7 @@ struct Import {
Global GlobalImport; Global GlobalImport;
Table TableImport; Table TableImport;
Limits Memory; Limits Memory;
Event EventImport; Tag TagImport;
}; };
}; };
@ -316,14 +316,14 @@ struct MemorySection : Section {
std::vector<Limits> Memories; std::vector<Limits> Memories;
}; };
struct EventSection : Section { struct TagSection : Section {
EventSection() : Section(wasm::WASM_SEC_EVENT) {} TagSection() : Section(wasm::WASM_SEC_TAG) {}
static bool classof(const Section *S) { 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 { 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::InitFunction)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::ComdatEntry) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::ComdatEntry)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Comdat) 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 llvm {
namespace yaml { namespace yaml {
@ -570,8 +570,8 @@ template <> struct ScalarEnumerationTraits<WasmYAML::RelocType> {
static void enumeration(IO &IO, WasmYAML::RelocType &Kind); static void enumeration(IO &IO, WasmYAML::RelocType &Kind);
}; };
template <> struct MappingTraits<WasmYAML::Event> { template <> struct MappingTraits<WasmYAML::Tag> {
static void mapping(IO &IO, WasmYAML::Event &Event); static void mapping(IO &IO, WasmYAML::Tag &Tag);
}; };
} // end namespace yaml } // end namespace yaml

View File

@ -20,8 +20,8 @@ std::string llvm::wasm::toString(wasm::WasmSymbolType Type) {
return "WASM_SYMBOL_TYPE_DATA"; return "WASM_SYMBOL_TYPE_DATA";
case wasm::WASM_SYMBOL_TYPE_SECTION: case wasm::WASM_SYMBOL_TYPE_SECTION:
return "WASM_SYMBOL_TYPE_SECTION"; return "WASM_SYMBOL_TYPE_SECTION";
case wasm::WASM_SYMBOL_TYPE_EVENT: case wasm::WASM_SYMBOL_TYPE_TAG:
return "WASM_SYMBOL_TYPE_EVENT"; return "WASM_SYMBOL_TYPE_TAG";
} }
llvm_unreachable("unknown symbol type"); llvm_unreachable("unknown symbol type");
} }

View File

@ -195,7 +195,7 @@ class WasmObjectWriter : public MCObjectWriter {
// for TABLE_INDEX relocation types (i.e. address taken functions). // for TABLE_INDEX relocation types (i.e. address taken functions).
DenseMap<const MCSymbolWasm *, uint32_t> TableIndices; DenseMap<const MCSymbolWasm *, uint32_t> TableIndices;
// Maps function/global/table symbols to the // 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> WasmIndices;
DenseMap<const MCSymbolWasm *, uint32_t> GOTIndices; DenseMap<const MCSymbolWasm *, uint32_t> GOTIndices;
// Maps data symbols to the Wasm segment and offset/size with the segment. // 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 NumFunctionImports = 0;
unsigned NumGlobalImports = 0; unsigned NumGlobalImports = 0;
unsigned NumTableImports = 0; unsigned NumTableImports = 0;
unsigned NumEventImports = 0; unsigned NumTagImports = 0;
uint32_t SectionCount = 0; uint32_t SectionCount = 0;
enum class DwoMode { enum class DwoMode {
@ -317,7 +317,7 @@ private:
uint32_t writeCodeSection(const MCAssembler &Asm, const MCAsmLayout &Layout, uint32_t writeCodeSection(const MCAssembler &Asm, const MCAsmLayout &Layout,
ArrayRef<WasmFunction> Functions); ArrayRef<WasmFunction> Functions);
uint32_t writeDataSection(const MCAsmLayout &Layout); 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 writeGlobalSection(ArrayRef<wasm::WasmGlobal> Globals);
void writeTableSection(ArrayRef<wasm::WasmTable> Tables); void writeTableSection(ArrayRef<wasm::WasmTable> Tables);
void writeRelocSection(uint32_t SectionIndex, StringRef Name, void writeRelocSection(uint32_t SectionIndex, StringRef Name,
@ -337,9 +337,9 @@ private:
uint32_t getRelocationIndexValue(const WasmRelocationEntry &RelEntry); uint32_t getRelocationIndexValue(const WasmRelocationEntry &RelEntry);
uint32_t getFunctionType(const MCSymbolWasm &Symbol); uint32_t getFunctionType(const MCSymbolWasm &Symbol);
uint32_t getEventType(const MCSymbolWasm &Symbol); uint32_t getTagType(const MCSymbolWasm &Symbol);
void registerFunctionType(const MCSymbolWasm &Symbol); void registerFunctionType(const MCSymbolWasm &Symbol);
void registerEventType(const MCSymbolWasm &Symbol); void registerTagType(const MCSymbolWasm &Symbol);
}; };
} // end anonymous namespace } // end anonymous namespace
@ -612,9 +612,9 @@ WasmObjectWriter::getProvisionalValue(const WasmRelocationEntry &RelEntry,
case wasm::R_WASM_FUNCTION_INDEX_LEB: case wasm::R_WASM_FUNCTION_INDEX_LEB:
case wasm::R_WASM_GLOBAL_INDEX_LEB: case wasm::R_WASM_GLOBAL_INDEX_LEB:
case wasm::R_WASM_GLOBAL_INDEX_I32: 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: 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"); assert(WasmIndices.count(RelEntry.Symbol) > 0 && "symbol not found in wasm index space");
return WasmIndices[RelEntry.Symbol]; return WasmIndices[RelEntry.Symbol];
case wasm::R_WASM_FUNCTION_OFFSET_I32: 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_TYPE_INDEX_LEB:
case wasm::R_WASM_GLOBAL_INDEX_LEB: case wasm::R_WASM_GLOBAL_INDEX_LEB:
case wasm::R_WASM_MEMORY_ADDR_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: case wasm::R_WASM_TABLE_NUMBER_LEB:
writePatchableLEB<5>(Stream, Value, Offset); writePatchableLEB<5>(Stream, Value, Offset);
break; break;
@ -813,9 +813,9 @@ void WasmObjectWriter::writeImportSection(ArrayRef<wasm::WasmImport> Imports,
encodeULEB128(0, W->OS); // flags encodeULEB128(0, W->OS); // flags
encodeULEB128(NumElements, W->OS); // initial encodeULEB128(NumElements, W->OS); // initial
break; break;
case wasm::WASM_EXTERNAL_EVENT: case wasm::WASM_EXTERNAL_TAG:
encodeULEB128(Import.Event.Attribute, W->OS); encodeULEB128(Import.Tag.Attribute, W->OS);
encodeULEB128(Import.Event.SigIndex, W->OS); encodeULEB128(Import.Tag.SigIndex, W->OS);
break; break;
default: default:
llvm_unreachable("unsupported import kind"); llvm_unreachable("unsupported import kind");
@ -839,17 +839,17 @@ void WasmObjectWriter::writeFunctionSection(ArrayRef<WasmFunction> Functions) {
endSection(Section); endSection(Section);
} }
void WasmObjectWriter::writeEventSection(ArrayRef<wasm::WasmEventType> Events) { void WasmObjectWriter::writeTagSection(ArrayRef<wasm::WasmTagType> Tags) {
if (Events.empty()) if (Tags.empty())
return; return;
SectionBookkeeping Section; SectionBookkeeping Section;
startSection(Section, wasm::WASM_SEC_EVENT); startSection(Section, wasm::WASM_SEC_TAG);
encodeULEB128(Events.size(), W->OS); encodeULEB128(Tags.size(), W->OS);
for (const wasm::WasmEventType &Event : Events) { for (const wasm::WasmTagType &Tag : Tags) {
encodeULEB128(Event.Attribute, W->OS); encodeULEB128(Tag.Attribute, W->OS);
encodeULEB128(Event.SigIndex, W->OS); encodeULEB128(Tag.SigIndex, W->OS);
} }
endSection(Section); endSection(Section);
@ -1103,7 +1103,7 @@ void WasmObjectWriter::writeLinkingMetaDataSection(
switch (Sym.Kind) { switch (Sym.Kind) {
case wasm::WASM_SYMBOL_TYPE_FUNCTION: case wasm::WASM_SYMBOL_TYPE_FUNCTION:
case wasm::WASM_SYMBOL_TYPE_GLOBAL: case wasm::WASM_SYMBOL_TYPE_GLOBAL:
case wasm::WASM_SYMBOL_TYPE_EVENT: case wasm::WASM_SYMBOL_TYPE_TAG:
case wasm::WASM_SYMBOL_TYPE_TABLE: case wasm::WASM_SYMBOL_TYPE_TABLE:
encodeULEB128(Sym.ElementIndex, W->OS); encodeULEB128(Sym.ElementIndex, W->OS);
if ((Sym.Flags & wasm::WASM_SYMBOL_UNDEFINED) == 0 || if ((Sym.Flags & wasm::WASM_SYMBOL_UNDEFINED) == 0 ||
@ -1196,8 +1196,8 @@ uint32_t WasmObjectWriter::getFunctionType(const MCSymbolWasm &Symbol) {
return TypeIndices[&Symbol]; return TypeIndices[&Symbol];
} }
uint32_t WasmObjectWriter::getEventType(const MCSymbolWasm &Symbol) { uint32_t WasmObjectWriter::getTagType(const MCSymbolWasm &Symbol) {
assert(Symbol.isEvent()); assert(Symbol.isTag());
assert(TypeIndices.count(&Symbol)); assert(TypeIndices.count(&Symbol));
return TypeIndices[&Symbol]; return TypeIndices[&Symbol];
} }
@ -1222,8 +1222,8 @@ void WasmObjectWriter::registerFunctionType(const MCSymbolWasm &Symbol) {
LLVM_DEBUG(dbgs() << " -> type index: " << Pair.first->second << "\n"); LLVM_DEBUG(dbgs() << " -> type index: " << Pair.first->second << "\n");
} }
void WasmObjectWriter::registerEventType(const MCSymbolWasm &Symbol) { void WasmObjectWriter::registerTagType(const MCSymbolWasm &Symbol) {
assert(Symbol.isEvent()); assert(Symbol.isTag());
// TODO Currently we don't generate imported exceptions, but if we do, we // TODO Currently we don't generate imported exceptions, but if we do, we
// should have a way of infering types of imported exceptions. // should have a way of infering types of imported exceptions.
@ -1238,7 +1238,7 @@ void WasmObjectWriter::registerEventType(const MCSymbolWasm &Symbol) {
Signatures.push_back(S); Signatures.push_back(S);
TypeIndices[&Symbol] = Pair.first->second; TypeIndices[&Symbol] = Pair.first->second;
LLVM_DEBUG(dbgs() << "registerEventType: " << Symbol << " new:" << Pair.second LLVM_DEBUG(dbgs() << "registerTagType: " << Symbol << " new:" << Pair.second
<< "\n"); << "\n");
LLVM_DEBUG(dbgs() << " -> type index: " << Pair.first->second << "\n"); LLVM_DEBUG(dbgs() << " -> type index: " << Pair.first->second << "\n");
} }
@ -1292,8 +1292,8 @@ void WasmObjectWriter::prepareImports(
registerFunctionType(*cast<MCSymbolWasm>(BS)); registerFunctionType(*cast<MCSymbolWasm>(BS));
} }
if (WS.isEvent()) if (WS.isTag())
registerEventType(WS); registerTagType(WS);
if (WS.isTemporary()) if (WS.isTemporary())
continue; continue;
@ -1321,19 +1321,19 @@ void WasmObjectWriter::prepareImports(
Imports.push_back(Import); Imports.push_back(Import);
assert(WasmIndices.count(&WS) == 0); assert(WasmIndices.count(&WS) == 0);
WasmIndices[&WS] = NumGlobalImports++; WasmIndices[&WS] = NumGlobalImports++;
} else if (WS.isEvent()) { } else if (WS.isTag()) {
if (WS.isWeak()) if (WS.isWeak())
report_fatal_error("undefined event symbol cannot be weak"); report_fatal_error("undefined tag symbol cannot be weak");
wasm::WasmImport Import; wasm::WasmImport Import;
Import.Module = WS.getImportModule(); Import.Module = WS.getImportModule();
Import.Field = WS.getImportName(); Import.Field = WS.getImportName();
Import.Kind = wasm::WASM_EXTERNAL_EVENT; Import.Kind = wasm::WASM_EXTERNAL_TAG;
Import.Event.Attribute = wasm::WASM_EVENT_ATTRIBUTE_EXCEPTION; Import.Tag.Attribute = wasm::WASM_TAG_ATTRIBUTE_EXCEPTION;
Import.Event.SigIndex = getEventType(WS); Import.Tag.SigIndex = getTagType(WS);
Imports.push_back(Import); Imports.push_back(Import);
assert(WasmIndices.count(&WS) == 0); assert(WasmIndices.count(&WS) == 0);
WasmIndices[&WS] = NumEventImports++; WasmIndices[&WS] = NumTagImports++;
} else if (WS.isTable()) { } else if (WS.isTable()) {
if (WS.isWeak()) if (WS.isWeak())
report_fatal_error("undefined table symbol cannot be weak"); 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<uint32_t, 4> TableElems;
SmallVector<wasm::WasmImport, 4> Imports; SmallVector<wasm::WasmImport, 4> Imports;
SmallVector<wasm::WasmExport, 4> Exports; SmallVector<wasm::WasmExport, 4> Exports;
SmallVector<wasm::WasmEventType, 1> Events; SmallVector<wasm::WasmTagType, 1> Tags;
SmallVector<wasm::WasmGlobal, 1> Globals; SmallVector<wasm::WasmGlobal, 1> Globals;
SmallVector<wasm::WasmTable, 1> Tables; SmallVector<wasm::WasmTable, 1> Tables;
SmallVector<wasm::WasmSymbolInfo, 4> SymbolInfos; SmallVector<wasm::WasmSymbolInfo, 4> SymbolInfos;
@ -1632,23 +1632,23 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
} }
LLVM_DEBUG(dbgs() << " -> table index: " LLVM_DEBUG(dbgs() << " -> table index: "
<< WasmIndices.find(&WS)->second << "\n"); << WasmIndices.find(&WS)->second << "\n");
} else if (WS.isEvent()) { } else if (WS.isTag()) {
// C++ exception symbol (__cpp_exception) // C++ exception symbol (__cpp_exception)
unsigned Index; unsigned Index;
if (WS.isDefined()) { if (WS.isDefined()) {
Index = NumEventImports + Events.size(); Index = NumTagImports + Tags.size();
wasm::WasmEventType Event; wasm::WasmTagType Tag;
Event.SigIndex = getEventType(WS); Tag.SigIndex = getTagType(WS);
Event.Attribute = wasm::WASM_EVENT_ATTRIBUTE_EXCEPTION; Tag.Attribute = wasm::WASM_TAG_ATTRIBUTE_EXCEPTION;
assert(WasmIndices.count(&WS) == 0); assert(WasmIndices.count(&WS) == 0);
WasmIndices[&WS] = Index; WasmIndices[&WS] = Index;
Events.push_back(Event); Tags.push_back(Tag);
} else { } else {
// An import; the index was assigned above. // An import; the index was assigned above.
assert(WasmIndices.count(&WS) > 0); assert(WasmIndices.count(&WS) > 0);
} }
LLVM_DEBUG(dbgs() << " -> event index: " LLVM_DEBUG(dbgs() << " -> tag index: " << WasmIndices.find(&WS)->second
<< WasmIndices.find(&WS)->second << "\n"); << "\n");
} else { } else {
assert(WS.isSection()); assert(WS.isSection());
@ -1703,7 +1703,7 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
DataLocations[&WS] = Ref; DataLocations[&WS] = Ref;
LLVM_DEBUG(dbgs() << " -> index:" << Ref.Segment << "\n"); LLVM_DEBUG(dbgs() << " -> index:" << Ref.Segment << "\n");
} else { } 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); writeFunctionSection(Functions);
writeTableSection(Tables); writeTableSection(Tables);
// Skip the "memory" section; we import the memory instead. // Skip the "memory" section; we import the memory instead.
writeEventSection(Events); writeTagSection(Tags);
writeGlobalSection(Globals); writeGlobalSection(Globals);
writeExportSection(Exports); writeExportSection(Exports);
const MCSymbol *IndirectFunctionTable = const MCSymbol *IndirectFunctionTable =

View File

@ -572,7 +572,7 @@ static bool supportsWasm32(uint64_t Type) {
case wasm::R_WASM_GLOBAL_INDEX_LEB: case wasm::R_WASM_GLOBAL_INDEX_LEB:
case wasm::R_WASM_FUNCTION_OFFSET_I32: case wasm::R_WASM_FUNCTION_OFFSET_I32:
case wasm::R_WASM_SECTION_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_GLOBAL_INDEX_I32:
case wasm::R_WASM_TABLE_NUMBER_LEB: case wasm::R_WASM_TABLE_NUMBER_LEB:
case wasm::R_WASM_MEMORY_ADDR_LOCREL_I32: 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_GLOBAL_INDEX_LEB:
case wasm::R_WASM_FUNCTION_OFFSET_I32: case wasm::R_WASM_FUNCTION_OFFSET_I32:
case wasm::R_WASM_SECTION_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_GLOBAL_INDEX_I32:
case wasm::R_WASM_TABLE_NUMBER_LEB: case wasm::R_WASM_TABLE_NUMBER_LEB:
case wasm::R_WASM_MEMORY_ADDR_LOCREL_I32: case wasm::R_WASM_MEMORY_ADDR_LOCREL_I32:

View File

@ -316,8 +316,8 @@ Error WasmObjectFile::parseSection(WasmSection &Sec) {
return parseTableSection(Ctx); return parseTableSection(Ctx);
case wasm::WASM_SEC_MEMORY: case wasm::WASM_SEC_MEMORY:
return parseMemorySection(Ctx); return parseMemorySection(Ctx);
case wasm::WASM_SEC_EVENT: case wasm::WASM_SEC_TAG:
return parseEventSection(Ctx); return parseTagSection(Ctx);
case wasm::WASM_SEC_GLOBAL: case wasm::WASM_SEC_GLOBAL:
return parseGlobalSection(Ctx); return parseGlobalSection(Ctx);
case wasm::WASM_SEC_EXPORT: case wasm::WASM_SEC_EXPORT:
@ -507,19 +507,19 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
std::vector<wasm::WasmImport *> ImportedGlobals; std::vector<wasm::WasmImport *> ImportedGlobals;
std::vector<wasm::WasmImport *> ImportedFunctions; std::vector<wasm::WasmImport *> ImportedFunctions;
std::vector<wasm::WasmImport *> ImportedEvents; std::vector<wasm::WasmImport *> ImportedTags;
std::vector<wasm::WasmImport *> ImportedTables; std::vector<wasm::WasmImport *> ImportedTables;
ImportedGlobals.reserve(Imports.size()); ImportedGlobals.reserve(Imports.size());
ImportedFunctions.reserve(Imports.size()); ImportedFunctions.reserve(Imports.size());
ImportedEvents.reserve(Imports.size()); ImportedTags.reserve(Imports.size());
ImportedTables.reserve(Imports.size()); ImportedTables.reserve(Imports.size());
for (auto &I : Imports) { for (auto &I : Imports) {
if (I.Kind == wasm::WASM_EXTERNAL_FUNCTION) if (I.Kind == wasm::WASM_EXTERNAL_FUNCTION)
ImportedFunctions.emplace_back(&I); ImportedFunctions.emplace_back(&I);
else if (I.Kind == wasm::WASM_EXTERNAL_GLOBAL) else if (I.Kind == wasm::WASM_EXTERNAL_GLOBAL)
ImportedGlobals.emplace_back(&I); ImportedGlobals.emplace_back(&I);
else if (I.Kind == wasm::WASM_EXTERNAL_EVENT) else if (I.Kind == wasm::WASM_EXTERNAL_TAG)
ImportedEvents.emplace_back(&I); ImportedTags.emplace_back(&I);
else if (I.Kind == wasm::WASM_EXTERNAL_TABLE) else if (I.Kind == wasm::WASM_EXTERNAL_TABLE)
ImportedTables.emplace_back(&I); ImportedTables.emplace_back(&I);
} }
@ -529,7 +529,7 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
const wasm::WasmSignature *Signature = nullptr; const wasm::WasmSignature *Signature = nullptr;
const wasm::WasmGlobalType *GlobalType = nullptr; const wasm::WasmGlobalType *GlobalType = nullptr;
const wasm::WasmTableType *TableType = nullptr; const wasm::WasmTableType *TableType = nullptr;
const wasm::WasmEventType *EventType = nullptr; const wasm::WasmTagType *TagType = nullptr;
Info.Kind = readUint8(Ctx); Info.Kind = readUint8(Ctx);
Info.Flags = readVaruint32(Ctx); Info.Flags = readVaruint32(Ctx);
@ -660,11 +660,11 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
break; break;
} }
case wasm::WASM_SYMBOL_TYPE_EVENT: { case wasm::WASM_SYMBOL_TYPE_TAG: {
Info.ElementIndex = readVaruint32(Ctx); Info.ElementIndex = readVaruint32(Ctx);
if (!isValidEventIndex(Info.ElementIndex) || if (!isValidTagIndex(Info.ElementIndex) ||
IsDefined != isDefinedEventIndex(Info.ElementIndex)) IsDefined != isDefinedTagIndex(Info.ElementIndex))
return make_error<GenericBinaryError>("invalid event symbol index", return make_error<GenericBinaryError>("invalid tag symbol index",
object_error::parse_failed); object_error::parse_failed);
if (!IsDefined && (Info.Flags & wasm::WASM_SYMBOL_BINDING_MASK) == if (!IsDefined && (Info.Flags & wasm::WASM_SYMBOL_BINDING_MASK) ==
wasm::WASM_SYMBOL_BINDING_WEAK) wasm::WASM_SYMBOL_BINDING_WEAK)
@ -672,23 +672,23 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
object_error::parse_failed); object_error::parse_failed);
if (IsDefined) { if (IsDefined) {
Info.Name = readString(Ctx); Info.Name = readString(Ctx);
unsigned EventIndex = Info.ElementIndex - NumImportedEvents; unsigned TagIndex = Info.ElementIndex - NumImportedTags;
wasm::WasmEvent &Event = Events[EventIndex]; wasm::WasmTag &Tag = Tags[TagIndex];
Signature = &Signatures[Event.Type.SigIndex]; Signature = &Signatures[Tag.Type.SigIndex];
EventType = &Event.Type; TagType = &Tag.Type;
if (Event.SymbolName.empty()) if (Tag.SymbolName.empty())
Event.SymbolName = Info.Name; Tag.SymbolName = Info.Name;
} else { } else {
wasm::WasmImport &Import = *ImportedEvents[Info.ElementIndex]; wasm::WasmImport &Import = *ImportedTags[Info.ElementIndex];
if ((Info.Flags & wasm::WASM_SYMBOL_EXPLICIT_NAME) != 0) { if ((Info.Flags & wasm::WASM_SYMBOL_EXPLICIT_NAME) != 0) {
Info.Name = readString(Ctx); Info.Name = readString(Ctx);
Info.ImportName = Import.Field; Info.ImportName = Import.Field;
} else { } else {
Info.Name = Import.Field; Info.Name = Import.Field;
} }
EventType = &Import.Event; TagType = &Import.Tag;
Signature = &Signatures[EventType->SigIndex]; Signature = &Signatures[TagType->SigIndex];
if (!Import.Module.empty()) { if (!Import.Module.empty()) {
Info.ImportModule = Import.Module; Info.ImportModule = Import.Module;
} }
@ -710,7 +710,7 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
object_error::parse_failed); object_error::parse_failed);
LinkingData.SymbolTable.emplace_back(Info); LinkingData.SymbolTable.emplace_back(Info);
Symbols.emplace_back(LinkingData.SymbolTable.back(), GlobalType, TableType, Symbols.emplace_back(LinkingData.SymbolTable.back(), GlobalType, TableType,
EventType, Signature); TagType, Signature);
LLVM_DEBUG(dbgs() << "Adding symbol: " << Symbols.back() << "\n"); 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", return make_error<GenericBinaryError>("invalid relocation global index",
object_error::parse_failed); object_error::parse_failed);
break; break;
case wasm::R_WASM_EVENT_INDEX_LEB: case wasm::R_WASM_TAG_INDEX_LEB:
if (!isValidEventSymbol(Reloc.Index)) if (!isValidTagSymbol(Reloc.Index))
return make_error<GenericBinaryError>("invalid relocation event index", return make_error<GenericBinaryError>("invalid relocation tag index",
object_error::parse_failed); object_error::parse_failed);
break; break;
case wasm::R_WASM_MEMORY_ADDR_LEB: case wasm::R_WASM_MEMORY_ADDR_LEB:
@ -1064,10 +1064,10 @@ Error WasmObjectFile::parseImportSection(ReadContext &Ctx) {
object_error::parse_failed); object_error::parse_failed);
break; break;
} }
case wasm::WASM_EXTERNAL_EVENT: case wasm::WASM_EXTERNAL_TAG:
NumImportedEvents++; NumImportedTags++;
Im.Event.Attribute = readVarint32(Ctx); Im.Tag.Attribute = readVarint32(Ctx);
Im.Event.SigIndex = readVarint32(Ctx); Im.Tag.SigIndex = readVarint32(Ctx);
break; break;
default: default:
return make_error<GenericBinaryError>("unexpected import kind", return make_error<GenericBinaryError>("unexpected import kind",
@ -1136,20 +1136,20 @@ Error WasmObjectFile::parseMemorySection(ReadContext &Ctx) {
return Error::success(); return Error::success();
} }
Error WasmObjectFile::parseEventSection(ReadContext &Ctx) { Error WasmObjectFile::parseTagSection(ReadContext &Ctx) {
EventSection = Sections.size(); TagSection = Sections.size();
uint32_t Count = readVaruint32(Ctx); uint32_t Count = readVaruint32(Ctx);
Events.reserve(Count); Tags.reserve(Count);
while (Count--) { while (Count--) {
wasm::WasmEvent Event; wasm::WasmTag Tag;
Event.Index = NumImportedEvents + Events.size(); Tag.Index = NumImportedTags + Tags.size();
Event.Type.Attribute = readVaruint32(Ctx); Tag.Type.Attribute = readVaruint32(Ctx);
Event.Type.SigIndex = readVaruint32(Ctx); Tag.Type.SigIndex = readVaruint32(Ctx);
Events.push_back(Event); Tags.push_back(Tag);
} }
if (Ctx.Ptr != Ctx.End) 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); object_error::parse_failed);
return Error::success(); return Error::success();
} }
@ -1194,9 +1194,9 @@ Error WasmObjectFile::parseExportSection(ReadContext &Ctx) {
return make_error<GenericBinaryError>("invalid global export", return make_error<GenericBinaryError>("invalid global export",
object_error::parse_failed); object_error::parse_failed);
break; break;
case wasm::WASM_EXTERNAL_EVENT: case wasm::WASM_EXTERNAL_TAG:
if (!isValidEventIndex(Ex.Index)) if (!isValidTagIndex(Ex.Index))
return make_error<GenericBinaryError>("invalid event export", return make_error<GenericBinaryError>("invalid tag export",
object_error::parse_failed); object_error::parse_failed);
break; break;
case wasm::WASM_EXTERNAL_MEMORY: case wasm::WASM_EXTERNAL_MEMORY:
@ -1238,12 +1238,12 @@ bool WasmObjectFile::isDefinedTableNumber(uint32_t Index) const {
return Index >= NumImportedTables && isValidTableNumber(Index); return Index >= NumImportedTables && isValidTableNumber(Index);
} }
bool WasmObjectFile::isValidEventIndex(uint32_t Index) const { bool WasmObjectFile::isValidTagIndex(uint32_t Index) const {
return Index < NumImportedEvents + Events.size(); return Index < NumImportedTags + Tags.size();
} }
bool WasmObjectFile::isDefinedEventIndex(uint32_t Index) const { bool WasmObjectFile::isDefinedTagIndex(uint32_t Index) const {
return Index >= NumImportedEvents && isValidEventIndex(Index); return Index >= NumImportedTags && isValidTagIndex(Index);
} }
bool WasmObjectFile::isValidFunctionSymbol(uint32_t Index) const { 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(); return Index < Symbols.size() && Symbols[Index].isTypeGlobal();
} }
bool WasmObjectFile::isValidEventSymbol(uint32_t Index) const { bool WasmObjectFile::isValidTagSymbol(uint32_t Index) const {
return Index < Symbols.size() && Symbols[Index].isTypeEvent(); return Index < Symbols.size() && Symbols[Index].isTypeTag();
} }
bool WasmObjectFile::isValidDataSymbol(uint32_t Index) const { bool WasmObjectFile::isValidDataSymbol(uint32_t Index) const {
@ -1286,9 +1286,9 @@ wasm::WasmGlobal &WasmObjectFile::getDefinedGlobal(uint32_t Index) {
return Globals[Index - NumImportedGlobals]; return Globals[Index - NumImportedGlobals];
} }
wasm::WasmEvent &WasmObjectFile::getDefinedEvent(uint32_t Index) { wasm::WasmTag &WasmObjectFile::getDefinedTag(uint32_t Index) {
assert(isDefinedEventIndex(Index)); assert(isDefinedTagIndex(Index));
return Events[Index - NumImportedEvents]; return Tags[Index - NumImportedTags];
} }
Error WasmObjectFile::parseStartSection(ReadContext &Ctx) { Error WasmObjectFile::parseStartSection(ReadContext &Ctx) {
@ -1515,7 +1515,7 @@ uint64_t WasmObjectFile::getWasmSymbolValue(const WasmSymbol &Sym) const {
switch (Sym.Info.Kind) { switch (Sym.Info.Kind) {
case wasm::WASM_SYMBOL_TYPE_FUNCTION: case wasm::WASM_SYMBOL_TYPE_FUNCTION:
case wasm::WASM_SYMBOL_TYPE_GLOBAL: case wasm::WASM_SYMBOL_TYPE_GLOBAL:
case wasm::WASM_SYMBOL_TYPE_EVENT: case wasm::WASM_SYMBOL_TYPE_TAG:
case wasm::WASM_SYMBOL_TYPE_TABLE: case wasm::WASM_SYMBOL_TYPE_TABLE:
return Sym.Info.ElementIndex; return Sym.Info.ElementIndex;
case wasm::WASM_SYMBOL_TYPE_DATA: { case wasm::WASM_SYMBOL_TYPE_DATA: {
@ -1564,7 +1564,7 @@ WasmObjectFile::getSymbolType(DataRefImpl Symb) const {
return SymbolRef::ST_Data; return SymbolRef::ST_Data;
case wasm::WASM_SYMBOL_TYPE_SECTION: case wasm::WASM_SYMBOL_TYPE_SECTION:
return SymbolRef::ST_Debug; return SymbolRef::ST_Debug;
case wasm::WASM_SYMBOL_TYPE_EVENT: case wasm::WASM_SYMBOL_TYPE_TAG:
return SymbolRef::ST_Other; return SymbolRef::ST_Other;
case wasm::WASM_SYMBOL_TYPE_TABLE: case wasm::WASM_SYMBOL_TYPE_TABLE:
return SymbolRef::ST_Other; return SymbolRef::ST_Other;
@ -1600,8 +1600,8 @@ uint32_t WasmObjectFile::getSymbolSectionIdImpl(const WasmSymbol &Sym) const {
return DataSection; return DataSection;
case wasm::WASM_SYMBOL_TYPE_SECTION: case wasm::WASM_SYMBOL_TYPE_SECTION:
return Sym.Info.ElementIndex; return Sym.Info.ElementIndex;
case wasm::WASM_SYMBOL_TYPE_EVENT: case wasm::WASM_SYMBOL_TYPE_TAG:
return EventSection; return TagSection;
case wasm::WASM_SYMBOL_TYPE_TABLE: case wasm::WASM_SYMBOL_TYPE_TABLE:
return TableSection; return TableSection;
default: default:
@ -1623,7 +1623,7 @@ Expected<StringRef> WasmObjectFile::getSectionName(DataRefImpl Sec) const {
ECase(TABLE); ECase(TABLE);
ECase(MEMORY); ECase(MEMORY);
ECase(GLOBAL); ECase(GLOBAL);
ECase(EVENT); ECase(TAG);
ECase(EXPORT); ECase(EXPORT);
ECase(START); ECase(START);
ECase(ELEM); ECase(ELEM);
@ -1822,8 +1822,8 @@ int WasmSectionOrderChecker::getSectionOrder(unsigned ID,
return WASM_SEC_ORDER_DATA; return WASM_SEC_ORDER_DATA;
case wasm::WASM_SEC_DATACOUNT: case wasm::WASM_SEC_DATACOUNT:
return WASM_SEC_ORDER_DATACOUNT; return WASM_SEC_ORDER_DATACOUNT;
case wasm::WASM_SEC_EVENT: case wasm::WASM_SEC_TAG:
return WASM_SEC_ORDER_EVENT; return WASM_SEC_ORDER_TAG;
default: default:
return WASM_SEC_ORDER_NONE; return WASM_SEC_ORDER_NONE;
} }
@ -1845,9 +1845,9 @@ int WasmSectionOrderChecker::DisallowedPredecessors
// WASM_SEC_ORDER_TABLE // WASM_SEC_ORDER_TABLE
{WASM_SEC_ORDER_TABLE, WASM_SEC_ORDER_MEMORY}, {WASM_SEC_ORDER_TABLE, WASM_SEC_ORDER_MEMORY},
// WASM_SEC_ORDER_MEMORY // WASM_SEC_ORDER_MEMORY
{WASM_SEC_ORDER_MEMORY, WASM_SEC_ORDER_EVENT}, {WASM_SEC_ORDER_MEMORY, WASM_SEC_ORDER_TAG},
// WASM_SEC_ORDER_EVENT // WASM_SEC_ORDER_TAG
{WASM_SEC_ORDER_EVENT, WASM_SEC_ORDER_GLOBAL}, {WASM_SEC_ORDER_TAG, WASM_SEC_ORDER_GLOBAL},
// WASM_SEC_ORDER_GLOBAL // WASM_SEC_ORDER_GLOBAL
{WASM_SEC_ORDER_GLOBAL, WASM_SEC_ORDER_EXPORT}, {WASM_SEC_ORDER_GLOBAL, WASM_SEC_ORDER_EXPORT},
// WASM_SEC_ORDER_EXPORT // WASM_SEC_ORDER_EXPORT

View File

@ -41,7 +41,7 @@ private:
void writeSectionContent(raw_ostream &OS, WasmYAML::FunctionSection &Section); void writeSectionContent(raw_ostream &OS, WasmYAML::FunctionSection &Section);
void writeSectionContent(raw_ostream &OS, WasmYAML::TableSection &Section); void writeSectionContent(raw_ostream &OS, WasmYAML::TableSection &Section);
void writeSectionContent(raw_ostream &OS, WasmYAML::MemorySection &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::GlobalSection &Section);
void writeSectionContent(raw_ostream &OS, WasmYAML::ExportSection &Section); void writeSectionContent(raw_ostream &OS, WasmYAML::ExportSection &Section);
void writeSectionContent(raw_ostream &OS, WasmYAML::StartSection &Section); void writeSectionContent(raw_ostream &OS, WasmYAML::StartSection &Section);
@ -61,7 +61,7 @@ private:
uint32_t NumImportedFunctions = 0; uint32_t NumImportedFunctions = 0;
uint32_t NumImportedGlobals = 0; uint32_t NumImportedGlobals = 0;
uint32_t NumImportedTables = 0; uint32_t NumImportedTables = 0;
uint32_t NumImportedEvents = 0; uint32_t NumImportedTags = 0;
bool HasError = false; bool HasError = false;
yaml::ErrorHandler ErrHandler; yaml::ErrorHandler ErrHandler;
@ -189,7 +189,7 @@ void WasmWriter::writeSectionContent(raw_ostream &OS,
case wasm::WASM_SYMBOL_TYPE_FUNCTION: case wasm::WASM_SYMBOL_TYPE_FUNCTION:
case wasm::WASM_SYMBOL_TYPE_GLOBAL: case wasm::WASM_SYMBOL_TYPE_GLOBAL:
case wasm::WASM_SYMBOL_TYPE_TABLE: case wasm::WASM_SYMBOL_TYPE_TABLE:
case wasm::WASM_SYMBOL_TYPE_EVENT: case wasm::WASM_SYMBOL_TYPE_TAG:
encodeULEB128(Info.ElementIndex, SubSection.getStream()); encodeULEB128(Info.ElementIndex, SubSection.getStream());
if ((Info.Flags & wasm::WASM_SYMBOL_UNDEFINED) == 0 || if ((Info.Flags & wasm::WASM_SYMBOL_UNDEFINED) == 0 ||
(Info.Flags & wasm::WASM_SYMBOL_EXPLICIT_NAME) != 0) (Info.Flags & wasm::WASM_SYMBOL_EXPLICIT_NAME) != 0)
@ -385,10 +385,10 @@ void WasmWriter::writeSectionContent(raw_ostream &OS,
writeUint8(OS, Import.GlobalImport.Mutable); writeUint8(OS, Import.GlobalImport.Mutable);
NumImportedGlobals++; NumImportedGlobals++;
break; break;
case wasm::WASM_EXTERNAL_EVENT: case wasm::WASM_EXTERNAL_TAG:
writeUint32(OS, Import.EventImport.Attribute); writeUint32(OS, Import.TagImport.Attribute);
writeUint32(OS, Import.EventImport.SigIndex); writeUint32(OS, Import.TagImport.SigIndex);
NumImportedEvents++; NumImportedTags++;
break; break;
case wasm::WASM_EXTERNAL_MEMORY: case wasm::WASM_EXTERNAL_MEMORY:
writeLimits(Import.Memory, OS); writeLimits(Import.Memory, OS);
@ -450,17 +450,17 @@ void WasmWriter::writeSectionContent(raw_ostream &OS,
} }
void WasmWriter::writeSectionContent(raw_ostream &OS, void WasmWriter::writeSectionContent(raw_ostream &OS,
WasmYAML::EventSection &Section) { WasmYAML::TagSection &Section) {
encodeULEB128(Section.Events.size(), OS); encodeULEB128(Section.Tags.size(), OS);
uint32_t ExpectedIndex = NumImportedEvents; uint32_t ExpectedIndex = NumImportedTags;
for (auto &Event : Section.Events) { for (auto &Tag : Section.Tags) {
if (Event.Index != ExpectedIndex) { if (Tag.Index != ExpectedIndex) {
reportError("unexpected event index: " + Twine(Event.Index)); reportError("unexpected tag index: " + Twine(Tag.Index));
return; return;
} }
++ExpectedIndex; ++ExpectedIndex;
encodeULEB128(Event.Attribute, OS); encodeULEB128(Tag.Attribute, OS);
encodeULEB128(Event.SigIndex, OS); encodeULEB128(Tag.SigIndex, OS);
} }
} }
@ -626,7 +626,7 @@ bool WasmWriter::writeWasm(raw_ostream &OS) {
writeSectionContent(StringStream, *S); writeSectionContent(StringStream, *S);
else if (auto S = dyn_cast<WasmYAML::MemorySection>(Sec.get())) else if (auto S = dyn_cast<WasmYAML::MemorySection>(Sec.get()))
writeSectionContent(StringStream, *S); 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); writeSectionContent(StringStream, *S);
else if (auto S = dyn_cast<WasmYAML::GlobalSection>(Sec.get())) else if (auto S = dyn_cast<WasmYAML::GlobalSection>(Sec.get()))
writeSectionContent(StringStream, *S); writeSectionContent(StringStream, *S);

View File

@ -120,9 +120,9 @@ static void sectionMapping(IO &IO, WasmYAML::MemorySection &Section) {
IO.mapOptional("Memories", Section.Memories); IO.mapOptional("Memories", Section.Memories);
} }
static void sectionMapping(IO &IO, WasmYAML::EventSection &Section) { static void sectionMapping(IO &IO, WasmYAML::TagSection &Section) {
commonSectionMapping(IO, Section); commonSectionMapping(IO, Section);
IO.mapOptional("Events", Section.Events); IO.mapOptional("Tags", Section.Tags);
} }
static void sectionMapping(IO &IO, WasmYAML::GlobalSection &Section) { 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()); Section.reset(new WasmYAML::MemorySection());
sectionMapping(IO, *cast<WasmYAML::MemorySection>(Section.get())); sectionMapping(IO, *cast<WasmYAML::MemorySection>(Section.get()));
break; break;
case wasm::WASM_SEC_EVENT: case wasm::WASM_SEC_TAG:
if (!IO.outputting()) if (!IO.outputting())
Section.reset(new WasmYAML::EventSection()); Section.reset(new WasmYAML::TagSection());
sectionMapping(IO, *cast<WasmYAML::EventSection>(Section.get())); sectionMapping(IO, *cast<WasmYAML::TagSection>(Section.get()));
break; break;
case wasm::WASM_SEC_GLOBAL: case wasm::WASM_SEC_GLOBAL:
if (!IO.outputting()) if (!IO.outputting())
@ -284,7 +284,7 @@ void ScalarEnumerationTraits<WasmYAML::SectionType>::enumeration(
ECase(TABLE); ECase(TABLE);
ECase(MEMORY); ECase(MEMORY);
ECase(GLOBAL); ECase(GLOBAL);
ECase(EVENT); ECase(TAG);
ECase(EXPORT); ECase(EXPORT);
ECase(START); ECase(START);
ECase(ELEM); ECase(ELEM);
@ -396,9 +396,9 @@ void MappingTraits<WasmYAML::Import>::mapping(IO &IO,
} else if (Import.Kind == wasm::WASM_EXTERNAL_GLOBAL) { } else if (Import.Kind == wasm::WASM_EXTERNAL_GLOBAL) {
IO.mapRequired("GlobalType", Import.GlobalImport.Type); IO.mapRequired("GlobalType", Import.GlobalImport.Type);
IO.mapRequired("GlobalMutable", Import.GlobalImport.Mutable); IO.mapRequired("GlobalMutable", Import.GlobalImport.Mutable);
} else if (Import.Kind == wasm::WASM_EXTERNAL_EVENT) { } else if (Import.Kind == wasm::WASM_EXTERNAL_TAG) {
IO.mapRequired("EventAttribute", Import.EventImport.Attribute); IO.mapRequired("TagAttribute", Import.TagImport.Attribute);
IO.mapRequired("EventSigIndex", Import.EventImport.SigIndex); IO.mapRequired("TagSigIndex", Import.TagImport.SigIndex);
} else if (Import.Kind == wasm::WASM_EXTERNAL_TABLE) { } else if (Import.Kind == wasm::WASM_EXTERNAL_TABLE) {
IO.mapRequired("Table", Import.TableImport); IO.mapRequired("Table", Import.TableImport);
} else if (Import.Kind == wasm::WASM_EXTERNAL_MEMORY) { } else if (Import.Kind == wasm::WASM_EXTERNAL_MEMORY) {
@ -510,8 +510,8 @@ void MappingTraits<WasmYAML::SymbolInfo>::mapping(IO &IO,
IO.mapRequired("Global", Info.ElementIndex); IO.mapRequired("Global", Info.ElementIndex);
} else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_TABLE) { } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_TABLE) {
IO.mapRequired("Table", Info.ElementIndex); IO.mapRequired("Table", Info.ElementIndex);
} else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_EVENT) { } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_TAG) {
IO.mapRequired("Event", Info.ElementIndex); IO.mapRequired("Tag", Info.ElementIndex);
} else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_DATA) { } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_DATA) {
if ((Info.Flags & wasm::WASM_SYMBOL_UNDEFINED) == 0) { if ((Info.Flags & wasm::WASM_SYMBOL_UNDEFINED) == 0) {
IO.mapRequired("Segment", Info.DataRef.Segment); 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) { void MappingTraits<WasmYAML::Tag>::mapping(IO &IO, WasmYAML::Tag &Tag) {
IO.mapRequired("Index", Event.Index); IO.mapRequired("Index", Tag.Index);
IO.mapRequired("Attribute", Event.Attribute); IO.mapRequired("Attribute", Tag.Attribute);
IO.mapRequired("SigIndex", Event.SigIndex); IO.mapRequired("SigIndex", Tag.SigIndex);
} }
void ScalarBitSetTraits<WasmYAML::LimitFlags>::bitset( void ScalarBitSetTraits<WasmYAML::LimitFlags>::bitset(
@ -572,7 +572,7 @@ void ScalarEnumerationTraits<WasmYAML::SymbolKind>::enumeration(
ECase(GLOBAL); ECase(GLOBAL);
ECase(TABLE); ECase(TABLE);
ECase(SECTION); ECase(SECTION);
ECase(EVENT); ECase(TAG);
#undef ECase #undef ECase
} }
@ -597,7 +597,7 @@ void ScalarEnumerationTraits<WasmYAML::ExportKind>::enumeration(
ECase(TABLE); ECase(TABLE);
ECase(MEMORY); ECase(MEMORY);
ECase(GLOBAL); ECase(GLOBAL);
ECase(EVENT); ECase(TAG);
#undef ECase #undef ECase
} }

View File

@ -899,7 +899,7 @@ public:
TOut.emitImportName(WasmSym, ImportName); TOut.emitImportName(WasmSym, ImportName);
} }
if (DirectiveID.getString() == ".eventtype") { if (DirectiveID.getString() == ".tagtype") {
auto SymName = expectIdent(); auto SymName = expectIdent();
if (SymName.empty()) if (SymName.empty())
return true; return true;
@ -909,8 +909,8 @@ public:
return true; return true;
WasmSym->setSignature(Signature.get()); WasmSym->setSignature(Signature.get());
addSignature(std::move(Signature)); addSignature(std::move(Signature));
WasmSym->setType(wasm::WASM_SYMBOL_TYPE_EVENT); WasmSym->setType(wasm::WASM_SYMBOL_TYPE_TAG);
TOut.emitEventType(WasmSym); TOut.emitTagType(WasmSym);
// TODO: backend also calls TOut.emitIndIdx, but that is not implemented. // TODO: backend also calls TOut.emitIndIdx, but that is not implemented.
return expect(AsmToken::EndOfStatement, "EOL"); return expect(AsmToken::EndOfStatement, "EOL");
} }

View File

@ -203,7 +203,7 @@ MCDisassembler::DecodeStatus WebAssemblyDisassembler::getInstruction(
case WebAssembly::OPERAND_OFFSET64: case WebAssembly::OPERAND_OFFSET64:
case WebAssembly::OPERAND_P2ALIGN: case WebAssembly::OPERAND_P2ALIGN:
case WebAssembly::OPERAND_TYPEINDEX: case WebAssembly::OPERAND_TYPEINDEX:
case WebAssembly::OPERAND_EVENT: case WebAssembly::OPERAND_TAG:
case MCOI::OPERAND_IMMEDIATE: { case MCOI::OPERAND_IMMEDIATE: {
if (!parseLEBImmediate(MI, Size, Bytes, false)) if (!parseLEBImmediate(MI, Size, Bytes, false))
return MCDisassembler::Fail; return MCDisassembler::Fail;

View File

@ -154,7 +154,7 @@ void WebAssemblyMCCodeEmitter::encodeInstruction(
case WebAssembly::OPERAND_SIGNATURE: case WebAssembly::OPERAND_SIGNATURE:
case WebAssembly::OPERAND_TYPEINDEX: case WebAssembly::OPERAND_TYPEINDEX:
case WebAssembly::OPERAND_GLOBAL: case WebAssembly::OPERAND_GLOBAL:
case WebAssembly::OPERAND_EVENT: case WebAssembly::OPERAND_TAG:
FixupKind = MCFixupKind(WebAssembly::fixup_uleb128_i32); FixupKind = MCFixupKind(WebAssembly::fixup_uleb128_i32);
break; break;
case WebAssembly::OPERAND_OFFSET64: case WebAssembly::OPERAND_OFFSET64:

View File

@ -72,8 +72,8 @@ enum OperandType {
OPERAND_SIGNATURE, OPERAND_SIGNATURE,
/// type signature immediate for call_indirect. /// type signature immediate for call_indirect.
OPERAND_TYPEINDEX, OPERAND_TYPEINDEX,
/// Event index. /// Tag index.
OPERAND_EVENT, OPERAND_TAG,
/// A list of branch targets for br_list. /// A list of branch targets for br_list.
OPERAND_BRLIST, OPERAND_BRLIST,
/// 32-bit unsigned table number. /// 32-bit unsigned table number.

View File

@ -91,9 +91,9 @@ void WebAssemblyTargetAsmStreamer::emitTableType(const MCSymbolWasm *Sym) {
OS << '\n'; OS << '\n';
} }
void WebAssemblyTargetAsmStreamer::emitEventType(const MCSymbolWasm *Sym) { void WebAssemblyTargetAsmStreamer::emitTagType(const MCSymbolWasm *Sym) {
assert(Sym->isEvent()); assert(Sym->isTag());
OS << "\t.eventtype\t" << Sym->getName() << " "; OS << "\t.tagtype\t" << Sym->getName() << " ";
OS << WebAssembly::typeListToString(Sym->getSignature()->Params); OS << WebAssembly::typeListToString(Sym->getSignature()->Params);
OS << "\n"; OS << "\n";
} }

View File

@ -42,8 +42,8 @@ public:
virtual void emitGlobalType(const MCSymbolWasm *Sym) = 0; virtual void emitGlobalType(const MCSymbolWasm *Sym) = 0;
/// .tabletype /// .tabletype
virtual void emitTableType(const MCSymbolWasm *Sym) = 0; virtual void emitTableType(const MCSymbolWasm *Sym) = 0;
/// .eventtype /// .tagtype
virtual void emitEventType(const MCSymbolWasm *Sym) = 0; virtual void emitTagType(const MCSymbolWasm *Sym) = 0;
/// .import_module /// .import_module
virtual void emitImportModule(const MCSymbolWasm *Sym, virtual void emitImportModule(const MCSymbolWasm *Sym,
StringRef ImportModule) = 0; StringRef ImportModule) = 0;
@ -71,7 +71,7 @@ public:
void emitIndIdx(const MCExpr *Value) override; void emitIndIdx(const MCExpr *Value) override;
void emitGlobalType(const MCSymbolWasm *Sym) override; void emitGlobalType(const MCSymbolWasm *Sym) override;
void emitTableType(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 emitImportModule(const MCSymbolWasm *Sym, StringRef ImportModule) override;
void emitImportName(const MCSymbolWasm *Sym, StringRef ImportName) override; void emitImportName(const MCSymbolWasm *Sym, StringRef ImportName) override;
void emitExportName(const MCSymbolWasm *Sym, StringRef ExportName) override; void emitExportName(const MCSymbolWasm *Sym, StringRef ExportName) override;
@ -88,7 +88,7 @@ public:
void emitIndIdx(const MCExpr *Value) override; void emitIndIdx(const MCExpr *Value) override;
void emitGlobalType(const MCSymbolWasm *Sym) override {} void emitGlobalType(const MCSymbolWasm *Sym) override {}
void emitTableType(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, void emitImportModule(const MCSymbolWasm *Sym,
StringRef ImportModule) override {} StringRef ImportModule) override {}
void emitImportName(const MCSymbolWasm *Sym, void emitImportName(const MCSymbolWasm *Sym,
@ -109,7 +109,7 @@ public:
void emitIndIdx(const MCExpr *) override {} void emitIndIdx(const MCExpr *) override {}
void emitGlobalType(const MCSymbolWasm *) override {} void emitGlobalType(const MCSymbolWasm *) override {}
void emitTableType(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 emitImportModule(const MCSymbolWasm *, StringRef) override {}
void emitImportName(const MCSymbolWasm *, StringRef) override {} void emitImportName(const MCSymbolWasm *, StringRef) override {}
void emitExportName(const MCSymbolWasm *, StringRef) override {} void emitExportName(const MCSymbolWasm *, StringRef) override {}

View File

@ -104,8 +104,8 @@ unsigned WebAssemblyWasmObjectWriter::getRelocType(const MCValue &Target,
return wasm::R_WASM_GLOBAL_INDEX_LEB; return wasm::R_WASM_GLOBAL_INDEX_LEB;
if (SymA.isFunction()) if (SymA.isFunction())
return wasm::R_WASM_FUNCTION_INDEX_LEB; return wasm::R_WASM_FUNCTION_INDEX_LEB;
if (SymA.isEvent()) if (SymA.isTag())
return wasm::R_WASM_EVENT_INDEX_LEB; return wasm::R_WASM_TAG_INDEX_LEB;
if (SymA.isTable()) if (SymA.isTable())
return wasm::R_WASM_TABLE_NUMBER_LEB; return wasm::R_WASM_TABLE_NUMBER_LEB;
return wasm::R_WASM_MEMORY_ADDR_LEB; return wasm::R_WASM_MEMORY_ADDR_LEB;

View File

@ -209,7 +209,7 @@ void WebAssemblyAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
void WebAssemblyAsmPrinter::emitEndOfAsmFile(Module &M) { void WebAssemblyAsmPrinter::emitEndOfAsmFile(Module &M) {
for (auto &It : OutContext.getSymbols()) { for (auto &It : OutContext.getSymbols()) {
// Emit .globaltype, .eventtype, or .tabletype declarations. // Emit .globaltype, .tagtype, or .tabletype declarations.
auto Sym = cast<MCSymbolWasm>(It.getValue()); auto Sym = cast<MCSymbolWasm>(It.getValue());
if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_GLOBAL) { if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_GLOBAL) {
// .globaltype already handled by emitGlobalVariable for defined // .globaltype already handled by emitGlobalVariable for defined
@ -217,8 +217,8 @@ void WebAssemblyAsmPrinter::emitEndOfAsmFile(Module &M) {
// written to the file. // written to the file.
if (Sym->isUndefined()) if (Sym->isUndefined())
getTargetStreamer()->emitGlobalType(Sym); getTargetStreamer()->emitGlobalType(Sym);
} else if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_EVENT) } else if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_TAG)
getTargetStreamer()->emitEventType(Sym); getTargetStreamer()->emitTagType(Sym);
else if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_TABLE) else if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_TABLE)
getTargetStreamer()->emitTableType(Sym); getTargetStreamer()->emitTableType(Sym);
} }

View File

@ -129,8 +129,8 @@ let Predicates = [HasExceptionHandling] in {
// Throwing an exception: throw / rethrow // Throwing an exception: throw / rethrow
let isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in { let isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in {
defm THROW : I<(outs), (ins event_op:$tag, variable_ops), defm THROW : I<(outs), (ins tag_op:$tag, variable_ops),
(outs), (ins event_op:$tag), (outs), (ins tag_op:$tag),
[(WebAssemblythrow (WebAssemblywrapper texternalsym:$tag))], [(WebAssemblythrow (WebAssemblywrapper texternalsym:$tag))],
"throw \t$tag", "throw \t$tag", 0x08>; "throw \t$tag", "throw \t$tag", 0x08>;
defm RETHROW : NRI<(outs), (ins i32imm:$depth), [], "rethrow \t$depth", 0x09>; 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 { let hasCtrlDep = 1, hasSideEffects = 1 in {
// Currently 'catch' can only extract an i32, which is sufficient for C++ // 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 // support, but according to the spec 'catch' can extract any number of values
// based on the event type. // based on the tag type.
defm CATCH : I<(outs I32:$dst), (ins event_op:$tag), defm CATCH : I<(outs I32:$dst), (ins tag_op:$tag),
(outs), (ins event_op:$tag), (outs), (ins tag_op:$tag),
[(set I32:$dst, [(set I32:$dst,
(WebAssemblycatch (WebAssemblywrapper texternalsym:$tag)))], (WebAssemblycatch (WebAssemblywrapper texternalsym:$tag)))],
"catch \t$dst, $tag", "catch \t$tag", 0x07>; "catch \t$dst, $tag", "catch \t$tag", 0x07>;

View File

@ -196,8 +196,8 @@ def P2Align : Operand<i32> {
let PrintMethod = "printWebAssemblyP2AlignOperand"; let PrintMethod = "printWebAssemblyP2AlignOperand";
} }
let OperandType = "OPERAND_EVENT" in let OperandType = "OPERAND_TAG" in
def event_op : Operand<i32>; def tag_op : Operand<i32>;
} // OperandType = "OPERAND_P2ALIGN" } // OperandType = "OPERAND_P2ALIGN"

View File

@ -116,11 +116,10 @@ MCSymbol *WebAssemblyMCInstLower::GetExternalSymbolSymbol(
SmallVector<wasm::ValType, 4> Returns; SmallVector<wasm::ValType, 4> Returns;
SmallVector<wasm::ValType, 4> Params; SmallVector<wasm::ValType, 4> Params;
if (strcmp(Name, "__cpp_exception") == 0) { 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 // We can't confirm its signature index for now because there can be
// imported exceptions. Set it to be 0 for now. // imported exceptions. Set it to be 0 for now.
WasmSym->setEventType( WasmSym->setTagType({wasm::WASM_TAG_ATTRIBUTE_EXCEPTION, /* SigIndex */ 0});
{wasm::WASM_EVENT_ATTRIBUTE_EXCEPTION, /* SigIndex */ 0});
// We may have multiple C++ compilation units to be linked together, each of // 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 // which defines the exception symbol. To resolve them, we declare them as
// weak. // weak.
@ -179,8 +178,8 @@ MCOperand WebAssemblyMCInstLower::lowerSymbolOperand(const MachineOperand &MO,
report_fatal_error("Function addresses with offsets not supported"); report_fatal_error("Function addresses with offsets not supported");
if (WasmSym->isGlobal()) if (WasmSym->isGlobal())
report_fatal_error("Global indexes with offsets not supported"); report_fatal_error("Global indexes with offsets not supported");
if (WasmSym->isEvent()) if (WasmSym->isTag())
report_fatal_error("Event indexes with offsets not supported"); report_fatal_error("Tag indexes with offsets not supported");
if (WasmSym->isTable()) if (WasmSym->isTable())
report_fatal_error("Table indexes with offsets not supported"); report_fatal_error("Table indexes with offsets not supported");

View File

@ -372,4 +372,4 @@ attributes #0 = { nounwind }
attributes #1 = { noreturn } attributes #1 = { noreturn }
; CHECK: __cpp_exception: ; CHECK: __cpp_exception:
; CHECK: .eventtype __cpp_exception i32 ; CHECK: .tagtype __cpp_exception i32

View File

@ -15,5 +15,5 @@ define i32 @test(i8* %p) {
} }
; CHECK-DAG: .globaltype ; CHECK-DAG: .globaltype
; CHECK-DAG: .eventtype ; CHECK-DAG: .tagtype
; CHECK-DAG: .functype ; CHECK-DAG: .functype

View File

@ -8,7 +8,7 @@
.type test_annotation,@function .type test_annotation,@function
test_annotation: test_annotation:
.functype test_annotation () -> () .functype test_annotation () -> ()
.eventtype __cpp_exception i32 .tagtype __cpp_exception i32
try try
br 0 br 0
catch __cpp_exception catch __cpp_exception

View File

@ -12,7 +12,7 @@ test0:
.Ltest0begin: .Ltest0begin:
# Test all types: # Test all types:
.functype test0 (i32, i64) -> (i32) .functype test0 (i32, i64) -> (i32)
.eventtype __cpp_exception i32 .tagtype __cpp_exception i32
.local f32, f64, v128, v128 .local f32, f64, v128, v128
# Explicit getlocal/setlocal: # Explicit getlocal/setlocal:
local.get 2 local.get 2
@ -131,7 +131,7 @@ empty_fref_table:
# CHECK-LABEL: test0: # CHECK-LABEL: test0:
# CHECK-NEXT: .Ltest0begin: # CHECK-NEXT: .Ltest0begin:
# CHECK-NEXT: .functype test0 (i32, i64) -> (i32) # 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 f32, f64
# CHECK-NEXT: local.get 2 # CHECK-NEXT: local.get 2
# CHECK-NEXT: local.set 2 # CHECK-NEXT: local.set 2

View File

@ -1,9 +1,9 @@
; RUN: llc -filetype=obj -exception-model=wasm -mattr=+exception-handling %s -o - | obj2yaml | FileCheck %s ; 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 ; sigindex is greater than 63, so we put 63 dummy functions with different
; signatures before the function that contains the 'throw' instruction to make ; 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" target triple = "wasm32-unknown-unknown"
@ -334,12 +334,12 @@ define i32 @test_throw(i8* %p) {
ret i32 0 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 ; 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 ; number with which its LEB128 and ULEB128 encodings are different, because its
; 7th least significant bit is not 0. ; 7th least significant bit is not 0.
; CHECK: - Type: EVENT ; CHECK: - Type: TAG
; CHECK-NEXT: Events: ; CHECK-NEXT: Tags:
; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Attribute: 0 ; CHECK-NEXT: Attribute: 0
; CHECK-NEXT: SigIndex: 64 ; CHECK-NEXT: SigIndex: 64

View File

@ -28,18 +28,18 @@ define i32 @test_throw1(i8* %p) {
; CHECK-NEXT: - I32 ; CHECK-NEXT: - I32
; CHECK-NEXT: ReturnTypes: [] ; CHECK-NEXT: ReturnTypes: []
; CHECK: - Type: EVENT ; CHECK: - Type: TAG
; CHECK-NEXT: Events: ; CHECK-NEXT: Tags:
; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Attribute: 0 ; CHECK-NEXT: Attribute: 0
; CHECK-NEXT: SigIndex: 1 ; CHECK-NEXT: SigIndex: 1
; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: - Type: CODE
; CHECK-NEXT: Relocations: ; 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: Index: 1
; CHECK-NEXT: Offset: 0x6 ; 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: Index: 1
; CHECK-NEXT: Offset: 0x11 ; CHECK-NEXT: Offset: 0x11
@ -49,11 +49,11 @@ define i32 @test_throw1(i8* %p) {
; CHECK-NEXT: SymbolTable: ; CHECK-NEXT: SymbolTable:
; CHECK: - Index: 1 ; CHECK: - Index: 1
; CHECK-NEXT: Kind: EVENT ; CHECK-NEXT: Kind: TAG
; CHECK-NEXT: Name: __cpp_exception ; CHECK-NEXT: Name: __cpp_exception
; CHECK-NEXT: Flags: [ BINDING_WEAK ] ; 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: Size: 3
; SEC-NEXT: Offset: 63 ; SEC-NEXT: Offset: 63

View File

@ -17,14 +17,14 @@ Sections:
ReturnTypes: [] ReturnTypes: []
- Type: FUNCTION - Type: FUNCTION
FunctionTypes: [ 0 ] FunctionTypes: [ 0 ]
- Type: EVENT - Type: TAG
Events: Tags:
- Index: 0 - Index: 0
Attribute: 0 Attribute: 0
SigIndex: 1 SigIndex: 1
- Type: CODE - Type: CODE
Relocations: Relocations:
- Type: R_WASM_EVENT_INDEX_LEB - Type: R_WASM_TAG_INDEX_LEB
Index: 1 Index: 1
Offset: 0x00000006 Offset: 0x00000006
- Type: 10 - Type: 10
@ -44,10 +44,10 @@ Sections:
Flags: [ ] Flags: [ ]
Function: 0 Function: 0
- Index: 1 - Index: 1
Kind: EVENT Kind: TAG
Name: __cpp_exception Name: __cpp_exception
Flags: [ BINDING_WEAK ] Flags: [ BINDING_WEAK ]
Event: 0 Tag: 0
... ...
# CHECK: --- !WASM # CHECK: --- !WASM
@ -67,17 +67,17 @@ Sections:
# CHECK-NEXT: ReturnTypes: [] # CHECK-NEXT: ReturnTypes: []
# CHECK-NEXT: - Type: FUNCTION # CHECK-NEXT: - Type: FUNCTION
# CHECK-NEXT: FunctionTypes: [ 0 ] # CHECK-NEXT: FunctionTypes: [ 0 ]
# CHECK-NEXT: - Type: EVENT # CHECK-NEXT: - Type: TAG
# CHECK-NEXT: Events: # CHECK-NEXT: Tags:
# CHECK-NEXT: - Index: 0 # CHECK-NEXT: - Index: 0
# CHECK-NEXT: Attribute: 0 # CHECK-NEXT: Attribute: 0
# CHECK-NEXT: SigIndex: 1 # CHECK-NEXT: SigIndex: 1
# CHECK-NEXT: - Type: CODE # CHECK-NEXT: - Type: CODE
# CHECK-NEXT: Relocations: # 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: Index: 1
# CHECK-NEXT: Offset: 0x6 # 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: Index: 1
# CHECK-NEXT: Offset: 0x6 # CHECK-NEXT: Offset: 0x6
# CHECK-NEXT: Functions: # CHECK-NEXT: Functions:
@ -94,7 +94,7 @@ Sections:
# CHECK-NEXT: Flags: [ ] # CHECK-NEXT: Flags: [ ]
# CHECK-NEXT: Function: 0 # CHECK-NEXT: Function: 0
# CHECK-NEXT: - Index: 1 # CHECK-NEXT: - Index: 1
# CHECK-NEXT: Kind: EVENT # CHECK-NEXT: Kind: TAG
# CHECK-NEXT: Name: __cpp_exception # CHECK-NEXT: Name: __cpp_exception
# CHECK-NEXT: Flags: [ BINDING_WEAK ] # CHECK-NEXT: Flags: [ BINDING_WEAK ]
# CHECK-NEXT: Event: 0 # CHECK-NEXT: Tag: 0

View File

@ -23,8 +23,8 @@ namespace {
static const EnumEntry<unsigned> WasmSymbolTypes[] = { static const EnumEntry<unsigned> WasmSymbolTypes[] = {
#define ENUM_ENTRY(X) \ #define ENUM_ENTRY(X) \
{ #X, wasm::WASM_SYMBOL_TYPE_##X } { #X, wasm::WASM_SYMBOL_TYPE_##X }
ENUM_ENTRY(FUNCTION), ENUM_ENTRY(DATA), ENUM_ENTRY(GLOBAL), ENUM_ENTRY(FUNCTION), ENUM_ENTRY(DATA), ENUM_ENTRY(GLOBAL),
ENUM_ENTRY(SECTION), ENUM_ENTRY(EVENT), ENUM_ENTRY(TABLE), ENUM_ENTRY(SECTION), ENUM_ENTRY(TAG), ENUM_ENTRY(TABLE),
#undef ENUM_ENTRY #undef ENUM_ENTRY
}; };
@ -33,7 +33,7 @@ static const EnumEntry<uint32_t> WasmSectionTypes[] = {
{ #X, wasm::WASM_SEC_##X } { #X, wasm::WASM_SEC_##X }
ENUM_ENTRY(CUSTOM), ENUM_ENTRY(TYPE), ENUM_ENTRY(IMPORT), ENUM_ENTRY(CUSTOM), ENUM_ENTRY(TYPE), ENUM_ENTRY(IMPORT),
ENUM_ENTRY(FUNCTION), ENUM_ENTRY(TABLE), ENUM_ENTRY(MEMORY), 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(START), ENUM_ENTRY(ELEM), ENUM_ENTRY(CODE),
ENUM_ENTRY(DATA), ENUM_ENTRY(DATACOUNT), ENUM_ENTRY(DATA), ENUM_ENTRY(DATACOUNT),
#undef ENUM_ENTRY #undef ENUM_ENTRY

View File

@ -132,7 +132,7 @@ WasmDumper::dumpCustomSection(const WasmSection &WasmSec) {
case wasm::WASM_SYMBOL_TYPE_FUNCTION: case wasm::WASM_SYMBOL_TYPE_FUNCTION:
case wasm::WASM_SYMBOL_TYPE_GLOBAL: case wasm::WASM_SYMBOL_TYPE_GLOBAL:
case wasm::WASM_SYMBOL_TYPE_TABLE: case wasm::WASM_SYMBOL_TYPE_TABLE:
case wasm::WASM_SYMBOL_TYPE_EVENT: case wasm::WASM_SYMBOL_TYPE_TAG:
Info.ElementIndex = Symbol.ElementIndex; Info.ElementIndex = Symbol.ElementIndex;
break; break;
case wasm::WASM_SYMBOL_TYPE_SECTION: case wasm::WASM_SYMBOL_TYPE_SECTION:
@ -238,9 +238,9 @@ ErrorOr<WasmYAML::Object *> WasmDumper::dump() {
Im.GlobalImport.Type = Import.Global.Type; Im.GlobalImport.Type = Import.Global.Type;
Im.GlobalImport.Mutable = Import.Global.Mutable; Im.GlobalImport.Mutable = Import.Global.Mutable;
break; break;
case wasm::WASM_EXTERNAL_EVENT: case wasm::WASM_EXTERNAL_TAG:
Im.EventImport.Attribute = Import.Event.Attribute; Im.TagImport.Attribute = Import.Tag.Attribute;
Im.EventImport.SigIndex = Import.Event.SigIndex; Im.TagImport.SigIndex = Import.Tag.SigIndex;
break; break;
case wasm::WASM_EXTERNAL_TABLE: case wasm::WASM_EXTERNAL_TABLE:
// FIXME: Currently we always output an index of 0 for any imported // 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); S = std::move(MemorySec);
break; break;
} }
case wasm::WASM_SEC_EVENT: { case wasm::WASM_SEC_TAG: {
auto EventSec = std::make_unique<WasmYAML::EventSection>(); auto TagSec = std::make_unique<WasmYAML::TagSection>();
for (auto &Event : Obj.events()) { for (auto &Tag : Obj.tags()) {
WasmYAML::Event E; WasmYAML::Tag T;
E.Index = Event.Index; T.Index = Tag.Index;
E.Attribute = Event.Type.Attribute; T.Attribute = Tag.Type.Attribute;
E.SigIndex = Event.Type.SigIndex; T.SigIndex = Tag.Type.SigIndex;
EventSec->Events.push_back(E); TagSec->Tags.push_back(T);
} }
S = std::move(EventSec); S = std::move(TagSec);
break; break;
} }
case wasm::WASM_SEC_GLOBAL: { case wasm::WASM_SEC_GLOBAL: {