diff --git a/lld/include/lld/Common/LLVM.h b/lld/include/lld/Common/LLVM.h --- a/lld/include/lld/Common/LLVM.h +++ b/lld/include/lld/Common/LLVM.h @@ -44,8 +44,8 @@ } // namespace object namespace wasm { -struct WasmEvent; -struct WasmEventType; +struct WasmTag; +struct WasmTagType; struct WasmFunction; struct WasmGlobal; struct WasmGlobalType; @@ -87,8 +87,6 @@ using llvm::object::WasmSection; using llvm::object::WasmSegment; using llvm::object::WasmSymbol; -using llvm::wasm::WasmEvent; -using llvm::wasm::WasmEventType; using llvm::wasm::WasmFunction; using llvm::wasm::WasmGlobal; using llvm::wasm::WasmGlobalType; @@ -98,6 +96,8 @@ using llvm::wasm::WasmSignature; using llvm::wasm::WasmTable; using llvm::wasm::WasmTableType; +using llvm::wasm::WasmTag; +using llvm::wasm::WasmTagType; } // end namespace lld. namespace std { diff --git a/lld/test/wasm/Inputs/event-section1.ll b/lld/test/wasm/Inputs/tag-section1.ll rename from lld/test/wasm/Inputs/event-section1.ll rename to lld/test/wasm/Inputs/tag-section1.ll diff --git a/lld/test/wasm/Inputs/event-section2.ll b/lld/test/wasm/Inputs/tag-section2.ll rename from lld/test/wasm/Inputs/event-section2.ll rename to lld/test/wasm/Inputs/tag-section2.ll diff --git a/lld/test/wasm/event-section.ll b/lld/test/wasm/tag-section.ll rename from lld/test/wasm/event-section.ll rename to lld/test/wasm/tag-section.ll --- a/lld/test/wasm/event-section.ll +++ b/lld/test/wasm/tag-section.ll @@ -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/event-section2.ll -o %t2.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/tag-section2.ll -o %t2.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 --export-all -o %t-export-all.wasm %t.o %t1.o %t2.o @@ -29,17 +29,17 @@ ; CHECK-NEXT: - I32 ; CHECK-NEXT: ReturnTypes: [] -; CHECK: - Type: EVENT -; CHECK-NEXT: Events: +; CHECK: - Type: TAG +; CHECK-NEXT: Tags: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Attribute: 0 ; CHECK-NEXT: SigIndex: 1 -; Global section has to come after event section +; Global section has to come after tag section ; CHECK: - Type: GLOBAL ; EXPORT-ALL: - Type: EXPORT ; EXPORT-ALL-NEXT Exports: ; EXPORT-ALL: - Name: __cpp_exception -; EXPORT-ALL: Kind: EVENT +; EXPORT-ALL: Kind: TAG ; EXPORT-ALL: Index: 0 diff --git a/lld/wasm/InputChunks.cpp b/lld/wasm/InputChunks.cpp --- a/lld/wasm/InputChunks.cpp +++ b/lld/wasm/InputChunks.cpp @@ -117,7 +117,7 @@ case R_WASM_TYPE_INDEX_LEB: case R_WASM_FUNCTION_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_TABLE_NUMBER_LEB: encodeULEB128(value, loc, 5); @@ -208,7 +208,7 @@ case R_WASM_TYPE_INDEX_LEB: case R_WASM_FUNCTION_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_LEB64: case R_WASM_TABLE_NUMBER_LEB: @@ -228,7 +228,7 @@ case R_WASM_TYPE_INDEX_LEB: case R_WASM_FUNCTION_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_TABLE_NUMBER_LEB: case R_WASM_TABLE_INDEX_SLEB: diff --git a/lld/wasm/InputElement.h b/lld/wasm/InputElement.h --- a/lld/wasm/InputElement.h +++ b/lld/wasm/InputElement.h @@ -18,7 +18,7 @@ namespace lld { 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. class InputElement { protected: @@ -71,17 +71,17 @@ WasmInitExpr initExpr; }; -class InputEvent : public InputElement { +class InputTag : public InputElement { public: - InputEvent(const WasmSignature &s, const WasmEvent &e, ObjFile *f) - : InputElement(e.SymbolName, f), signature(s), type(e.Type) {} + InputTag(const WasmSignature &s, const WasmTag &t, ObjFile *f) + : InputElement(t.SymbolName, f), signature(s), type(t.Type) {} - const WasmEventType &getType() const { return type; } + const WasmTagType &getType() const { return type; } const WasmSignature &signature; private: - WasmEventType type; + WasmTagType type; }; class InputTable : public InputElement { diff --git a/lld/wasm/InputFiles.h b/lld/wasm/InputFiles.h --- a/lld/wasm/InputFiles.h +++ b/lld/wasm/InputFiles.h @@ -31,7 +31,7 @@ class InputFunction; class InputSegment; class InputGlobal; -class InputEvent; +class InputTag; class InputTable; class InputSection; @@ -139,7 +139,7 @@ std::vector segments; std::vector functions; std::vector globals; - std::vector events; + std::vector tags; std::vector tables; std::vector customSections; llvm::DenseMap customSectionsByIndex; @@ -149,7 +149,7 @@ DataSymbol *getDataSymbol(uint32_t index) const; GlobalSymbol *getGlobalSymbol(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; private: diff --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp --- a/lld/wasm/InputFiles.cpp +++ b/lld/wasm/InputFiles.cpp @@ -93,7 +93,7 @@ "\n Symbols : " + Twine(symbols.size()) + "\n Function Imports : " + Twine(wasmObj->getNumImportedFunctions()) + "\n Global Imports : " + Twine(wasmObj->getNumImportedGlobals()) + - "\n Event Imports : " + Twine(wasmObj->getNumImportedEvents()) + + "\n Tag Imports : " + Twine(wasmObj->getNumImportedTags()) + "\n Table Imports : " + Twine(wasmObj->getNumImportedTables())); } @@ -209,8 +209,8 @@ if (auto gs = dyn_cast(sym)) return gs->getGlobalIndex(); return sym->getGOTIndex(); - case R_WASM_EVENT_INDEX_LEB: - return getEventSymbol(reloc.Index)->getEventIndex(); + case R_WASM_TAG_INDEX_LEB: + return getTagSymbol(reloc.Index)->getTagIndex(); case R_WASM_FUNCTION_OFFSET_I32: case R_WASM_FUNCTION_OFFSET_I64: { auto *f = cast(sym); @@ -343,10 +343,10 @@ LLVM_DEBUG(dbgs() << "Synthesizing symbol for table import: " << info->Name << "\n"); const WasmGlobalType *globalType = nullptr; - const WasmEventType *eventType = nullptr; + const WasmTagType *tagType = nullptr; const WasmSignature *signature = nullptr; auto *wasmSym = make(*info, globalType, &tableImport->Table, - eventType, signature); + tagType, signature); Symbol *sym = createUndefined(*wasmSym, false); // We're only sure it's a TableSymbol if the createUndefined succeeded. if (errorCount()) @@ -515,9 +515,9 @@ for (const WasmGlobal &g : wasmObj->globals()) globals.emplace_back(make(g, this)); - // Populate `Events`. - for (const WasmEvent &e : wasmObj->events()) - events.emplace_back(make(types[e.Type.SigIndex], e, this)); + // Populate `Tags`. + for (const WasmTag &t : wasmObj->tags()) + tags.emplace_back(make(types[t.Type.SigIndex], t, this)); // Populate `Symbols` based on the symbols in the object. symbols.reserve(wasmObj->getNumberOfSymbols()); @@ -556,8 +556,8 @@ return cast(symbols[index]); } -EventSymbol *ObjFile::getEventSymbol(uint32_t index) const { - return cast(symbols[index]); +TagSymbol *ObjFile::getTagSymbol(uint32_t index) const { + return cast(symbols[index]); } TableSymbol *ObjFile::getTableSymbol(uint32_t index) const { @@ -612,12 +612,11 @@ return nullptr; return make(flags, section, this); } - case WASM_SYMBOL_TYPE_EVENT: { - InputEvent *event = - events[sym.Info.ElementIndex - wasmObj->getNumImportedEvents()]; + case WASM_SYMBOL_TYPE_TAG: { + InputTag *tag = tags[sym.Info.ElementIndex - wasmObj->getNumImportedTags()]; if (sym.isBindingLocal()) - return make(name, flags, this, event); - return symtab->addDefinedEvent(name, flags, this, event); + return make(name, flags, this, tag); + return symtab->addDefinedTag(name, flags, this, tag); } case WASM_SYMBOL_TYPE_TABLE: { InputTable *table = diff --git a/lld/wasm/MarkLive.cpp b/lld/wasm/MarkLive.cpp --- a/lld/wasm/MarkLive.cpp +++ b/lld/wasm/MarkLive.cpp @@ -162,9 +162,9 @@ for (InputGlobal *g : obj->globals) if (!g->live) message("removing unused section " + toString(g)); - for (InputEvent *e : obj->events) - if (!e->live) - message("removing unused section " + toString(e)); + for (InputTag *t : obj->tags) + if (!t->live) + message("removing unused section " + toString(t)); for (InputTable *t : obj->tables) if (!t->live) message("removing unused section " + toString(t)); diff --git a/lld/wasm/OutputSections.cpp b/lld/wasm/OutputSections.cpp --- a/lld/wasm/OutputSections.cpp +++ b/lld/wasm/OutputSections.cpp @@ -49,8 +49,8 @@ return "MEMORY"; case WASM_SEC_GLOBAL: return "GLOBAL"; - case WASM_SEC_EVENT: - return "EVENT"; + case WASM_SEC_TAG: + return "TAG"; case WASM_SEC_EXPORT: return "EXPORT"; case WASM_SEC_START: diff --git a/lld/wasm/SymbolTable.h b/lld/wasm/SymbolTable.h --- a/lld/wasm/SymbolTable.h +++ b/lld/wasm/SymbolTable.h @@ -57,8 +57,8 @@ InputChunk *segment, uint64_t address, uint64_t size); Symbol *addDefinedGlobal(StringRef name, uint32_t flags, InputFile *file, InputGlobal *g); - Symbol *addDefinedEvent(StringRef name, uint32_t flags, InputFile *file, - InputEvent *e); + Symbol *addDefinedTag(StringRef name, uint32_t flags, InputFile *file, + InputTag *t); Symbol *addDefinedTable(StringRef name, uint32_t flags, InputFile *file, InputTable *t); diff --git a/lld/wasm/SymbolTable.cpp b/lld/wasm/SymbolTable.cpp --- a/lld/wasm/SymbolTable.cpp +++ b/lld/wasm/SymbolTable.cpp @@ -168,23 +168,23 @@ } } -static void checkEventType(const Symbol *existing, const InputFile *file, - const WasmEventType *newType, - const WasmSignature *newSig) { - auto existingEvent = dyn_cast(existing); - if (!isa(existing)) { - reportTypeError(existing, file, WASM_SYMBOL_TYPE_EVENT); +static void checkTagType(const Symbol *existing, const InputFile *file, + const WasmTagType *newType, + const WasmSignature *newSig) { + const auto *existingTag = dyn_cast(existing); + if (!isa(existing)) { + reportTypeError(existing, file, WASM_SYMBOL_TYPE_TAG); return; } - const WasmEventType *oldType = cast(existing)->getEventType(); - const WasmSignature *oldSig = existingEvent->signature; + const WasmTagType *oldType = cast(existing)->getTagType(); + const WasmSignature *oldSig = existingTag->signature; 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()) + "\n>>> defined as " + toString(*newType) + " in " + toString(file)); if (*newSig != *oldSig) - warn("Event signature mismatch: " + existing->getName() + + warn("Tag signature mismatch: " + existing->getName() + "\n>>> defined as " + toString(*oldSig) + " in " + toString(existing->getFile()) + "\n>>> defined as " + toString(*newSig) + " in " + toString(file)); @@ -413,16 +413,16 @@ return s; } -Symbol *SymbolTable::addDefinedEvent(StringRef name, uint32_t flags, - InputFile *file, InputEvent *event) { - LLVM_DEBUG(dbgs() << "addDefinedEvent:" << name << "\n"); +Symbol *SymbolTable::addDefinedTag(StringRef name, uint32_t flags, + InputFile *file, InputTag *tag) { + LLVM_DEBUG(dbgs() << "addDefinedTag:" << name << "\n"); Symbol *s; bool wasInserted; std::tie(s, wasInserted) = insert(name, file); auto replaceSym = [&]() { - replaceSymbol(s, name, flags, file, event); + replaceSymbol(s, name, flags, file, tag); }; if (wasInserted || s->isLazy()) { @@ -430,7 +430,7 @@ return s; } - checkEventType(s, file, &event->getType(), &event->signature); + checkTagType(s, file, &tag->getType(), &tag->signature); if (shouldReplace(s, file, flags)) replaceSym(); diff --git a/lld/wasm/Symbols.h b/lld/wasm/Symbols.h --- a/lld/wasm/Symbols.h +++ b/lld/wasm/Symbols.h @@ -33,7 +33,7 @@ class InputSegment; class InputFunction; class InputGlobal; -class InputEvent; +class InputTag; class InputSection; class InputTable; class OutputSection; @@ -47,7 +47,7 @@ DefinedFunctionKind, DefinedDataKind, DefinedGlobalKind, - DefinedEventKind, + DefinedTagKind, DefinedTableKind, SectionKind, OutputSectionKind, @@ -414,48 +414,48 @@ llvm::Optional importModule; }; -// Wasm events are features that suspend the current execution and transfer the -// control flow to a corresponding handler. Currently the only supported event -// kind is exceptions. +// A tag is a general format to distinguish typed entities. Each tag has an +// attribute and a type. Currently the attribute can only specify that the tag +// is for an exception tag. // -// Event tags are values to distinguish different events. For exceptions, they -// can be used to distinguish different language's exceptions, i.e., all C++ -// exceptions have the same tag. Wasm can generate code capable of doing -// different handling actions based on the tag of caught exceptions. +// In exception handling, tags are used to distinguish different kinds of +// exceptions. For example, they can be used to distinguish different language's +// exceptions, e.g., all C++ exceptions have the same tag and Java 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 -// symbol is a weak symbol generated in every object file in which exceptions -// are used, and has name '__cpp_exception' for linking. -class EventSymbol : public Symbol { +// A single TagSymbol object represents a single tag. The C++ exception symbol +// is a weak symbol generated in every object file in which exceptions are used, +// and is named '__cpp_exception' for linking. +class TagSymbol : public Symbol { 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 - uint32_t getEventIndex() const; - void setEventIndex(uint32_t index); - bool hasEventIndex() const; + // Get/set the tag index + uint32_t getTagIndex() const; + void setTagIndex(uint32_t index); + bool hasTagIndex() const; const WasmSignature *signature; protected: - EventSymbol(StringRef name, Kind k, uint32_t flags, InputFile *f, - const WasmEventType *eventType, const WasmSignature *sig) - : Symbol(name, k, flags, f), signature(sig), eventType(eventType) {} + TagSymbol(StringRef name, Kind k, uint32_t flags, InputFile *f, + const WasmTagType *tagType, const WasmSignature *sig) + : Symbol(name, k, flags, f), signature(sig), tagType(tagType) {} - const WasmEventType *eventType; - uint32_t eventIndex = INVALID_INDEX; + const WasmTagType *tagType; + uint32_t tagIndex = INVALID_INDEX; }; -class DefinedEvent : public EventSymbol { +class DefinedTag : public TagSymbol { public: - DefinedEvent(StringRef name, uint32_t flags, InputFile *file, - InputEvent *event); + DefinedTag(StringRef name, uint32_t flags, InputFile *file, InputTag *tag); - 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 @@ -588,7 +588,7 @@ alignas(DefinedFunction) char a[sizeof(DefinedFunction)]; alignas(DefinedData) char b[sizeof(DefinedData)]; 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(LazySymbol) char f[sizeof(LazySymbol)]; alignas(UndefinedFunction) char g[sizeof(UndefinedFunction)]; diff --git a/lld/wasm/Symbols.cpp b/lld/wasm/Symbols.cpp --- a/lld/wasm/Symbols.cpp +++ b/lld/wasm/Symbols.cpp @@ -48,8 +48,8 @@ return "DefinedGlobal"; case wasm::Symbol::DefinedTableKind: return "DefinedTable"; - case wasm::Symbol::DefinedEventKind: - return "DefinedEvent"; + case wasm::Symbol::DefinedTagKind: + return "DefinedTag"; case wasm::Symbol::UndefinedFunctionKind: return "UndefinedFunction"; case wasm::Symbol::UndefinedDataKind: @@ -100,8 +100,8 @@ return WASM_SYMBOL_TYPE_DATA; if (isa(this)) return WASM_SYMBOL_TYPE_GLOBAL; - if (isa(this)) - return WASM_SYMBOL_TYPE_EVENT; + if (isa(this)) + return WASM_SYMBOL_TYPE_TAG; if (isa(this)) return WASM_SYMBOL_TYPE_TABLE; if (isa(this) || isa(this)) @@ -137,8 +137,8 @@ bool Symbol::isLive() const { if (auto *g = dyn_cast(this)) return g->global->live; - if (auto *e = dyn_cast(this)) - return e->event->live; + if (auto *t = dyn_cast(this)) + return t->tag->live; if (auto *t = dyn_cast(this)) return t->table->live; if (InputChunk *c = getChunk()) @@ -153,8 +153,8 @@ file->markLive(); if (auto *g = dyn_cast(this)) g->global->live = true; - if (auto *e = dyn_cast(this)) - e->event->live = true; + if (auto *t = dyn_cast(this)) + t->tag->live = true; if (auto *t = dyn_cast(this)) t->table->live = true; if (InputChunk *c = getChunk()) { @@ -336,31 +336,31 @@ global ? &global->getType() : nullptr), global(global) {} -uint32_t EventSymbol::getEventIndex() const { - if (auto *f = dyn_cast(this)) - return f->event->getAssignedIndex(); - assert(eventIndex != INVALID_INDEX); - return eventIndex; +uint32_t TagSymbol::getTagIndex() const { + if (auto *f = dyn_cast(this)) + return f->tag->getAssignedIndex(); + assert(tagIndex != INVALID_INDEX); + return tagIndex; } -void EventSymbol::setEventIndex(uint32_t index) { - LLVM_DEBUG(dbgs() << "setEventIndex " << name << " -> " << index << "\n"); - assert(eventIndex == INVALID_INDEX); - eventIndex = index; +void TagSymbol::setTagIndex(uint32_t index) { + LLVM_DEBUG(dbgs() << "setTagIndex " << name << " -> " << index << "\n"); + assert(tagIndex == INVALID_INDEX); + tagIndex = index; } -bool EventSymbol::hasEventIndex() const { - if (auto *f = dyn_cast(this)) - return f->event->hasAssignedIndex(); - return eventIndex != INVALID_INDEX; +bool TagSymbol::hasTagIndex() const { + if (auto *f = dyn_cast(this)) + return f->tag->hasAssignedIndex(); + return tagIndex != INVALID_INDEX; } -DefinedEvent::DefinedEvent(StringRef name, uint32_t flags, InputFile *file, - InputEvent *event) - : EventSymbol(name, DefinedEventKind, flags, file, - event ? &event->getType() : nullptr, - event ? &event->signature : nullptr), - event(event) {} +DefinedTag::DefinedTag(StringRef name, uint32_t flags, InputFile *file, + InputTag *tag) + : TagSymbol(name, DefinedTagKind, flags, file, + tag ? &tag->getType() : nullptr, + tag ? &tag->signature : nullptr), + tag(tag) {} void TableSymbol::setLimits(const WasmLimits &limits) { if (auto *t = dyn_cast(this)) diff --git a/lld/wasm/SyntheticSections.h b/lld/wasm/SyntheticSections.h --- a/lld/wasm/SyntheticSections.h +++ b/lld/wasm/SyntheticSections.h @@ -113,9 +113,9 @@ assert(isSealed); return numImportedFunctions; } - uint32_t getNumImportedEvents() const { + uint32_t getNumImportedTags() const { assert(isSealed); - return numImportedEvents; + return numImportedTags; } uint32_t getNumImportedTables() const { assert(isSealed); @@ -129,7 +129,7 @@ bool isSealed = false; unsigned numImportedGlobals = 0; unsigned numImportedFunctions = 0; - unsigned numImportedEvents = 0; + unsigned numImportedTags = 0; unsigned numImportedTables = 0; }; @@ -169,24 +169,23 @@ uint64_t maxMemoryPages = 0; }; -// The event section contains a list of declared wasm events associated with the -// module. Currently the only supported event kind is exceptions. A single event -// entry represents a single event with an event tag. All C++ exceptions are -// represented by a single event. An event entry in this section contains -// information on what kind of event it is (e.g. exception) and the type of -// values contained in a single event object. (In wasm, an event can contain -// multiple values of primitive types. But for C++ exceptions, we just throw a -// pointer which is an i32 value (for wasm32 architecture), so the signature of -// C++ exception is (i32)->(void), because all event types are assumed to have -// void return type to share WasmSignature with functions.) -class EventSection : public SyntheticSection { +// The tag section contains a list of declared wasm tags associated with the +// module. Currently the only supported tag kind is exceptions. All C++ +// exceptions are represented by a single tag. A tag entry in this section +// contains information on what kind of tag it is (e.g. exception) and the type +// of values associated with the tag. (In Wasm, a tag can contain multiple +// values of primitive types. But for C++ exceptions, we just throw a pointer +// which is an i32 value (for wasm32 architecture), so the signature of C++ +// exception is (i32)->(void), because all exception tag types are assumed to +// have void return type to share WasmSignature with functions.) +class TagSection : public SyntheticSection { public: - EventSection() : SyntheticSection(llvm::wasm::WASM_SEC_EVENT) {} + TagSection() : SyntheticSection(llvm::wasm::WASM_SEC_TAG) {} void writeBody() override; - bool isNeeded() const override { return inputEvents.size() > 0; } - void addEvent(InputEvent *event); + bool isNeeded() const override { return inputTags.size() > 0; } + void addTag(InputTag *tag); - std::vector inputEvents; + std::vector inputTags; }; class GlobalSection : public SyntheticSection { @@ -363,7 +362,7 @@ TableSection *tableSec; MemorySection *memorySec; GlobalSection *globalSec; - EventSection *eventSec; + TagSection *tagSec; ExportSection *exportSec; StartSection *startSec; ElemSection *elemSec; diff --git a/lld/wasm/SyntheticSections.cpp b/lld/wasm/SyntheticSections.cpp --- a/lld/wasm/SyntheticSections.cpp +++ b/lld/wasm/SyntheticSections.cpp @@ -114,8 +114,8 @@ f->setFunctionIndex(numImportedFunctions++); else if (auto *g = dyn_cast(sym)) g->setGlobalIndex(numImportedGlobals++); - else if (auto *e = dyn_cast(sym)) - e->setEventIndex(numImportedEvents++); + else if (auto *t = dyn_cast(sym)) + t->setTagIndex(numImportedTags++); else cast(sym)->setTableNumber(numImportedTables++); } @@ -165,10 +165,10 @@ } else if (auto *globalSym = dyn_cast(sym)) { import.Kind = WASM_EXTERNAL_GLOBAL; import.Global = *globalSym->getGlobalType(); - } else if (auto *eventSym = dyn_cast(sym)) { - import.Kind = WASM_EXTERNAL_EVENT; - import.Event.Attribute = eventSym->getEventType()->Attribute; - import.Event.SigIndex = out.typeSec->lookupType(*eventSym->signature); + } else if (auto *tagSym = dyn_cast(sym)) { + import.Kind = WASM_EXTERNAL_TAG; + import.Tag.Attribute = tagSym->getTagType()->Attribute; + import.Tag.SigIndex = out.typeSec->lookupType(*tagSym->signature); } else { auto *tableSym = cast(sym); import.Kind = WASM_EXTERNAL_TABLE; @@ -267,25 +267,24 @@ writeUleb128(os, maxMemoryPages, "max pages"); } -void EventSection::writeBody() { +void TagSection::writeBody() { raw_ostream &os = bodyOutputStream; - writeUleb128(os, inputEvents.size(), "event count"); - for (InputEvent *e : inputEvents) { - WasmEventType type = e->getType(); - type.SigIndex = out.typeSec->lookupType(e->signature); - writeEventType(os, type); + writeUleb128(os, inputTags.size(), "tag count"); + for (InputTag *t : inputTags) { + WasmTagType type = t->getType(); + type.SigIndex = out.typeSec->lookupType(t->signature); + writeTagType(os, type); } } -void EventSection::addEvent(InputEvent *event) { - if (!event->live) +void TagSection::addTag(InputTag *tag) { + if (!tag->live) return; - uint32_t eventIndex = - out.importSec->getNumImportedEvents() + inputEvents.size(); - LLVM_DEBUG(dbgs() << "addEvent: " << eventIndex << "\n"); - event->assignIndex(eventIndex); - inputEvents.push_back(event); + uint32_t tagIndex = out.importSec->getNumImportedTags() + inputTags.size(); + LLVM_DEBUG(dbgs() << "addTag: " << tagIndex << "\n"); + tag->assignIndex(tagIndex); + inputTags.push_back(tag); } void GlobalSection::assignIndexes() { @@ -505,8 +504,8 @@ writeUleb128(sub.os, g->getGlobalIndex(), "index"); if (sym->isDefined() || (flags & WASM_SYMBOL_EXPLICIT_NAME) != 0) writeStr(sub.os, sym->getName(), "sym name"); - } else if (auto *e = dyn_cast(sym)) { - writeUleb128(sub.os, e->getEventIndex(), "index"); + } else if (auto *t = dyn_cast(sym)) { + writeUleb128(sub.os, t->getTagIndex(), "index"); if (sym->isDefined() || (flags & WASM_SYMBOL_EXPLICIT_NAME) != 0) writeStr(sub.os, sym->getName(), "sym name"); } else if (auto *t = dyn_cast(sym)) { diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp --- a/lld/wasm/Writer.cpp +++ b/lld/wasm/Writer.cpp @@ -391,7 +391,7 @@ addSection(out.functionSec); addSection(out.tableSec); addSection(out.memorySec); - addSection(out.eventSec); + addSection(out.tagSec); addSection(out.globalSec); addSection(out.exportSec); addSection(out.startSec); @@ -625,8 +625,8 @@ continue; } export_ = {name, WASM_EXTERNAL_GLOBAL, g->getGlobalIndex()}; - } else if (auto *e = dyn_cast(sym)) { - export_ = {name, WASM_EXTERNAL_EVENT, e->getEventIndex()}; + } else if (auto *t = dyn_cast(sym)) { + export_ = {name, WASM_EXTERNAL_TAG, t->getTagIndex()}; } else if (auto *d = dyn_cast(sym)) { if (d->segment && d->segment->isTLS()) { // We can't currenly export TLS data symbols. @@ -668,8 +668,8 @@ // 1. Any signature used in the TYPE relocation // 2. The signatures of all imported functions // 3. The signatures of all defined functions - // 4. The signatures of all imported events - // 5. The signatures of all defined events + // 4. The signatures of all imported tags + // 5. The signatures of all defined tags for (ObjFile *file : symtab->objectFiles) { ArrayRef types = file->getWasmObj()->types(); @@ -681,15 +681,15 @@ for (const Symbol *sym : out.importSec->importedSymbols) { if (auto *f = dyn_cast(sym)) out.typeSec->registerType(*f->signature); - else if (auto *e = dyn_cast(sym)) - out.typeSec->registerType(*e->signature); + else if (auto *t = dyn_cast(sym)) + out.typeSec->registerType(*t->signature); } for (const InputFunction *f : out.functionSec->inputFunctions) out.typeSec->registerType(f->signature); - for (const InputEvent *e : out.eventSec->inputEvents) - out.typeSec->registerType(e->signature); + for (const InputTag *t : out.tagSec->inputTags) + out.typeSec->registerType(t->signature); } // In a command-style link, create a wrapper for each exported symbol @@ -797,9 +797,9 @@ } for (ObjFile *file : symtab->objectFiles) { - LLVM_DEBUG(dbgs() << "Events: " << file->getName() << "\n"); - for (InputEvent *event : file->events) - out.eventSec->addEvent(event); + LLVM_DEBUG(dbgs() << "Tags: " << file->getName() << "\n"); + for (InputTag *tag : file->tags) + out.tagSec->addTag(tag); } for (ObjFile *file : symtab->objectFiles) { @@ -1361,7 +1361,7 @@ out.functionSec = make(); out.tableSec = make(); out.memorySec = make(); - out.eventSec = make(); + out.tagSec = make(); out.globalSec = make(); out.exportSec = make(); out.startSec = make(); @@ -1494,12 +1494,12 @@ if (errorHandler().verbose) { log("Defined Functions: " + Twine(out.functionSec->inputFunctions.size())); 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("Function Imports : " + Twine(out.importSec->getNumImportedFunctions())); 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())); for (ObjFile *file : symtab->objectFiles) file->dumpInfo(); diff --git a/lld/wasm/WriterUtils.h b/lld/wasm/WriterUtils.h --- a/lld/wasm/WriterUtils.h +++ b/lld/wasm/WriterUtils.h @@ -51,9 +51,9 @@ 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); @@ -66,7 +66,7 @@ std::string toString(llvm::wasm::ValType type); std::string toString(const llvm::wasm::WasmSignature &sig); 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); } // namespace lld diff --git a/lld/wasm/WriterUtils.cpp b/lld/wasm/WriterUtils.cpp --- a/lld/wasm/WriterUtils.cpp +++ b/lld/wasm/WriterUtils.cpp @@ -58,8 +58,8 @@ toString(static_cast(type.Type)); } -std::string toString(const WasmEventType &type) { - if (type.Attribute == WASM_EVENT_ATTRIBUTE_EXCEPTION) +std::string toString(const WasmTagType &type) { + if (type.Attribute == WASM_TAG_ATTRIBUTE_EXCEPTION) return "exception"; return "unknown"; } @@ -202,13 +202,13 @@ writeU8(os, type.Mutable, "global mutable"); } -void writeEventType(raw_ostream &os, const WasmEventType &type) { - writeUleb128(os, type.Attribute, "event attribute"); +void writeTagType(raw_ostream &os, const WasmTagType &type) { + writeUleb128(os, type.Attribute, "tag attribute"); writeUleb128(os, type.SigIndex, "sig index"); } -void writeEvent(raw_ostream &os, const WasmEvent &event) { - writeEventType(os, event.Type); +void writeTag(raw_ostream &os, const WasmTag &tag) { + writeTagType(os, tag.Type); } void writeTableType(raw_ostream &os, const WasmTableType &type) { @@ -227,8 +227,8 @@ case WASM_EXTERNAL_GLOBAL: writeGlobalType(os, import.Global); break; - case WASM_EXTERNAL_EVENT: - writeEventType(os, import.Event); + case WASM_EXTERNAL_TAG: + writeTagType(os, import.Tag); break; case WASM_EXTERNAL_MEMORY: writeLimits(os, import.Memory); @@ -251,8 +251,8 @@ case WASM_EXTERNAL_GLOBAL: writeUleb128(os, export_.Index, "global index"); break; - case WASM_EXTERNAL_EVENT: - writeUleb128(os, export_.Index, "event index"); + case WASM_EXTERNAL_TAG: + writeUleb128(os, export_.Index, "tag index"); break; case WASM_EXTERNAL_MEMORY: writeUleb128(os, export_.Index, "memory index"); diff --git a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp --- a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp +++ b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp @@ -196,7 +196,7 @@ m_sect_infos.push_back(section_info{*offset_ptr + c.tell(), section_length, section_id, *sect_name}); *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(), static_cast(payload_len), section_id, ConstString()}); diff --git a/llvm/include/llvm/BinaryFormat/Wasm.h b/llvm/include/llvm/BinaryFormat/Wasm.h --- a/llvm/include/llvm/BinaryFormat/Wasm.h +++ b/llvm/include/llvm/BinaryFormat/Wasm.h @@ -101,15 +101,15 @@ StringRef SymbolName; // from the "linking" section }; -struct WasmEventType { - // Kind of event. Currently only WASM_EVENT_ATTRIBUTE_EXCEPTION is possible. +struct WasmTagType { + // Kind of tag. Currently only WASM_TAG_ATTRIBUTE_EXCEPTION is possible. uint32_t Attribute; uint32_t SigIndex; }; -struct WasmEvent { +struct WasmTag { uint32_t Index; - WasmEventType Type; + WasmTagType Type; StringRef SymbolName; // from the "linking" section }; @@ -122,7 +122,7 @@ WasmGlobalType Global; WasmTableType Table; WasmLimits Memory; - WasmEventType Event; + WasmTagType Tag; }; }; @@ -238,7 +238,7 @@ WASM_SEC_CODE = 10, // Function bodies (code) WASM_SEC_DATA = 11, // Data segments WASM_SEC_DATACOUNT = 12, // Data segment count - WASM_SEC_EVENT = 13 // Event declarations + WASM_SEC_TAG = 13 // Tag declarations }; // Type immediate encodings used in various contexts. @@ -260,7 +260,7 @@ WASM_EXTERNAL_TABLE = 0x1, WASM_EXTERNAL_MEMORY = 0x2, WASM_EXTERNAL_GLOBAL = 0x3, - WASM_EXTERNAL_EVENT = 0x4, + WASM_EXTERNAL_TAG = 0x4, }; // Opcodes used in initializer expressions. @@ -343,7 +343,7 @@ enum : unsigned { WASM_COMDAT_DATA = 0x0, WASM_COMDAT_FUNCTION = 0x1, - // GLOBAL, EVENT, and TABLE are in here but LLVM doesn't use them yet. + // GLOBAL, TAG, and TABLE are in here but LLVM doesn't use them yet. WASM_COMDAT_SECTION = 0x5, }; @@ -353,7 +353,7 @@ WASM_SYMBOL_TYPE_DATA = 0x1, WASM_SYMBOL_TYPE_GLOBAL = 0x2, WASM_SYMBOL_TYPE_SECTION = 0x3, - WASM_SYMBOL_TYPE_EVENT = 0x4, + WASM_SYMBOL_TYPE_TAG = 0x4, WASM_SYMBOL_TYPE_TABLE = 0x5, }; @@ -362,9 +362,9 @@ WASM_SEG_FLAG_TLS = 0x2, }; -// Kinds of event attributes. -enum WasmEventAttribute : unsigned { - WASM_EVENT_ATTRIBUTE_EXCEPTION = 0x0, +// Kinds of tag attributes. +enum WasmTagAttribute : unsigned { + WASM_TAG_ATTRIBUTE_EXCEPTION = 0x0, }; const unsigned WASM_SYMBOL_BINDING_MASK = 0x3; diff --git a/llvm/include/llvm/BinaryFormat/WasmRelocs.def b/llvm/include/llvm/BinaryFormat/WasmRelocs.def --- a/llvm/include/llvm/BinaryFormat/WasmRelocs.def +++ b/llvm/include/llvm/BinaryFormat/WasmRelocs.def @@ -12,7 +12,7 @@ WASM_RELOC(R_WASM_GLOBAL_INDEX_LEB, 7) WASM_RELOC(R_WASM_FUNCTION_OFFSET_I32, 8) WASM_RELOC(R_WASM_SECTION_OFFSET_I32, 9) -WASM_RELOC(R_WASM_EVENT_INDEX_LEB, 10) +WASM_RELOC(R_WASM_TAG_INDEX_LEB, 10) WASM_RELOC(R_WASM_MEMORY_ADDR_REL_SLEB, 11) WASM_RELOC(R_WASM_TABLE_INDEX_REL_SLEB, 12) WASM_RELOC(R_WASM_GLOBAL_INDEX_I32, 13) diff --git a/llvm/include/llvm/CodeGen/WasmEHFuncInfo.h b/llvm/include/llvm/CodeGen/WasmEHFuncInfo.h --- a/llvm/include/llvm/CodeGen/WasmEHFuncInfo.h +++ b/llvm/include/llvm/CodeGen/WasmEHFuncInfo.h @@ -24,7 +24,7 @@ class MachineBasicBlock; namespace WebAssembly { -enum EventTag { CPP_EXCEPTION = 0, C_LONGJMP = 1 }; +enum Tag { CPP_EXCEPTION = 0, C_LONGJMP = 1 }; } using BBOrMBB = PointerUnion; diff --git a/llvm/include/llvm/MC/MCSymbolWasm.h b/llvm/include/llvm/MC/MCSymbolWasm.h --- a/llvm/include/llvm/MC/MCSymbolWasm.h +++ b/llvm/include/llvm/MC/MCSymbolWasm.h @@ -27,7 +27,7 @@ wasm::WasmSignature *Signature = nullptr; Optional GlobalType; Optional TableType; - Optional EventType; + Optional TagType; /// An expression describing how to calculate the size of a symbol. If a /// symbol has no size this field will be NULL. @@ -47,7 +47,7 @@ bool isGlobal() const { return Type == wasm::WASM_SYMBOL_TYPE_GLOBAL; } bool isTable() const { return Type == wasm::WASM_SYMBOL_TYPE_TABLE; } bool isSection() const { return Type == wasm::WASM_SYMBOL_TYPE_SECTION; } - bool isEvent() const { return Type == wasm::WASM_SYMBOL_TYPE_EVENT; } + bool isTag() const { return Type == wasm::WASM_SYMBOL_TYPE_TAG; } Optional getType() const { return Type; } @@ -143,11 +143,11 @@ setTableType({uint8_t(VT), Limits}); } - const wasm::WasmEventType &getEventType() const { - assert(EventType.hasValue()); - return EventType.getValue(); + const wasm::WasmTagType &getTagType() const { + assert(TagType.hasValue()); + return TagType.getValue(); } - void setEventType(wasm::WasmEventType ET) { EventType = ET; } + void setTagType(wasm::WasmTagType ET) { TagType = ET; } }; } // end namespace llvm diff --git a/llvm/include/llvm/Object/Wasm.h b/llvm/include/llvm/Object/Wasm.h --- a/llvm/include/llvm/Object/Wasm.h +++ b/llvm/include/llvm/Object/Wasm.h @@ -37,15 +37,15 @@ WasmSymbol(const wasm::WasmSymbolInfo &Info, const wasm::WasmGlobalType *GlobalType, const wasm::WasmTableType *TableType, - const wasm::WasmEventType *EventType, + const wasm::WasmTagType *TagType, const wasm::WasmSignature *Signature) : Info(Info), GlobalType(GlobalType), TableType(TableType), - EventType(EventType), Signature(Signature) {} + TagType(TagType), Signature(Signature) {} const wasm::WasmSymbolInfo &Info; const wasm::WasmGlobalType *GlobalType; const wasm::WasmTableType *TableType; - const wasm::WasmEventType *EventType; + const wasm::WasmTagType *TagType; const wasm::WasmSignature *Signature; bool isTypeFunction() const { @@ -64,7 +64,7 @@ return Info.Kind == wasm::WASM_SYMBOL_TYPE_SECTION; } - bool isTypeEvent() const { return Info.Kind == wasm::WASM_SYMBOL_TYPE_EVENT; } + bool isTypeTag() const { return Info.Kind == wasm::WASM_SYMBOL_TYPE_TAG; } bool isDefined() const { return !isUndefined(); } @@ -143,7 +143,7 @@ ArrayRef tables() const { return Tables; } ArrayRef memories() const { return Memories; } ArrayRef globals() const { return Globals; } - ArrayRef events() const { return Events; } + ArrayRef tags() const { return Tags; } ArrayRef exports() const { return Exports; } ArrayRef syms() const { return Symbols; } const wasm::WasmLinkingData &linkingData() const { return LinkingData; } @@ -156,7 +156,7 @@ uint32_t getNumImportedGlobals() const { return NumImportedGlobals; } uint32_t getNumImportedTables() const { return NumImportedTables; } uint32_t getNumImportedFunctions() const { return NumImportedFunctions; } - uint32_t getNumImportedEvents() const { return NumImportedEvents; } + uint32_t getNumImportedTags() const { return NumImportedTags; } uint32_t getNumSections() const { return Sections.size(); } void moveSymbolNext(DataRefImpl &Symb) const override; @@ -223,18 +223,18 @@ bool isValidTableNumber(uint32_t Index) const; bool isDefinedGlobalIndex(uint32_t Index) const; bool isDefinedTableNumber(uint32_t Index) const; - bool isValidEventIndex(uint32_t Index) const; - bool isDefinedEventIndex(uint32_t Index) const; + bool isValidTagIndex(uint32_t Index) const; + bool isDefinedTagIndex(uint32_t Index) const; bool isValidFunctionSymbol(uint32_t Index) const; bool isValidTableSymbol(uint32_t Index) const; bool isValidGlobalSymbol(uint32_t Index) const; - bool isValidEventSymbol(uint32_t Index) const; + bool isValidTagSymbol(uint32_t Index) const; bool isValidDataSymbol(uint32_t Index) const; bool isValidSectionSymbol(uint32_t Index) const; wasm::WasmFunction &getDefinedFunction(uint32_t Index); const wasm::WasmFunction &getDefinedFunction(uint32_t Index) const; wasm::WasmGlobal &getDefinedGlobal(uint32_t Index); - wasm::WasmEvent &getDefinedEvent(uint32_t Index); + wasm::WasmTag &getDefinedTag(uint32_t Index); const WasmSection &getWasmSection(DataRefImpl Ref) const; const wasm::WasmRelocation &getWasmRelocation(DataRefImpl Ref) const; @@ -249,7 +249,7 @@ Error parseFunctionSection(ReadContext &Ctx); Error parseTableSection(ReadContext &Ctx); Error parseMemorySection(ReadContext &Ctx); - Error parseEventSection(ReadContext &Ctx); + Error parseTagSection(ReadContext &Ctx); Error parseGlobalSection(ReadContext &Ctx); Error parseExportSection(ReadContext &Ctx); Error parseStartSection(ReadContext &Ctx); @@ -278,7 +278,7 @@ std::vector Tables; std::vector Memories; std::vector Globals; - std::vector Events; + std::vector Tags; std::vector Imports; std::vector Exports; std::vector ElemSegments; @@ -296,10 +296,10 @@ uint32_t NumImportedGlobals = 0; uint32_t NumImportedTables = 0; uint32_t NumImportedFunctions = 0; - uint32_t NumImportedEvents = 0; + uint32_t NumImportedTags = 0; uint32_t CodeSection = 0; uint32_t DataSection = 0; - uint32_t EventSection = 0; + uint32_t TagSection = 0; uint32_t GlobalSection = 0; uint32_t TableSection = 0; }; @@ -317,7 +317,7 @@ WASM_SEC_ORDER_FUNCTION, WASM_SEC_ORDER_TABLE, WASM_SEC_ORDER_MEMORY, - WASM_SEC_ORDER_EVENT, + WASM_SEC_ORDER_TAG, WASM_SEC_ORDER_GLOBAL, WASM_SEC_ORDER_EXPORT, WASM_SEC_ORDER_START, diff --git a/llvm/include/llvm/ObjectYAML/WasmYAML.h b/llvm/include/llvm/ObjectYAML/WasmYAML.h --- a/llvm/include/llvm/ObjectYAML/WasmYAML.h +++ b/llvm/include/llvm/ObjectYAML/WasmYAML.h @@ -77,7 +77,7 @@ wasm::WasmInitExpr InitExpr; }; -struct Event { +struct Tag { uint32_t Index; uint32_t Attribute; uint32_t SigIndex; @@ -92,7 +92,7 @@ Global GlobalImport; Table TableImport; Limits Memory; - Event EventImport; + Tag TagImport; }; }; @@ -316,14 +316,14 @@ std::vector Memories; }; -struct EventSection : Section { - EventSection() : Section(wasm::WASM_SEC_EVENT) {} +struct TagSection : Section { + TagSection() : Section(wasm::WASM_SEC_TAG) {} static bool classof(const Section *S) { - return S->Type == wasm::WASM_SEC_EVENT; + return S->Type == wasm::WASM_SEC_TAG; } - std::vector Events; + std::vector Tags; }; struct GlobalSection : Section { @@ -425,7 +425,7 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::InitFunction) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::ComdatEntry) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Comdat) -LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Event) +LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Tag) namespace llvm { namespace yaml { @@ -570,8 +570,8 @@ static void enumeration(IO &IO, WasmYAML::RelocType &Kind); }; -template <> struct MappingTraits { - static void mapping(IO &IO, WasmYAML::Event &Event); +template <> struct MappingTraits { + static void mapping(IO &IO, WasmYAML::Tag &Tag); }; } // end namespace yaml diff --git a/llvm/lib/BinaryFormat/Wasm.cpp b/llvm/lib/BinaryFormat/Wasm.cpp --- a/llvm/lib/BinaryFormat/Wasm.cpp +++ b/llvm/lib/BinaryFormat/Wasm.cpp @@ -20,8 +20,8 @@ return "WASM_SYMBOL_TYPE_DATA"; case wasm::WASM_SYMBOL_TYPE_SECTION: return "WASM_SYMBOL_TYPE_SECTION"; - case wasm::WASM_SYMBOL_TYPE_EVENT: - return "WASM_SYMBOL_TYPE_EVENT"; + case wasm::WASM_SYMBOL_TYPE_TAG: + return "WASM_SYMBOL_TYPE_TAG"; } llvm_unreachable("unknown symbol type"); } diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp --- a/llvm/lib/MC/WasmObjectWriter.cpp +++ b/llvm/lib/MC/WasmObjectWriter.cpp @@ -195,7 +195,7 @@ // for TABLE_INDEX relocation types (i.e. address taken functions). DenseMap TableIndices; // Maps function/global/table symbols to the - // function/global/table/event/section index space. + // function/global/table/tag/section index space. DenseMap WasmIndices; DenseMap GOTIndices; // Maps data symbols to the Wasm segment and offset/size with the segment. @@ -219,7 +219,7 @@ unsigned NumFunctionImports = 0; unsigned NumGlobalImports = 0; unsigned NumTableImports = 0; - unsigned NumEventImports = 0; + unsigned NumTagImports = 0; uint32_t SectionCount = 0; enum class DwoMode { @@ -317,7 +317,7 @@ uint32_t writeCodeSection(const MCAssembler &Asm, const MCAsmLayout &Layout, ArrayRef Functions); uint32_t writeDataSection(const MCAsmLayout &Layout); - void writeEventSection(ArrayRef Events); + void writeTagSection(ArrayRef Tags); void writeGlobalSection(ArrayRef Globals); void writeTableSection(ArrayRef Tables); void writeRelocSection(uint32_t SectionIndex, StringRef Name, @@ -337,9 +337,9 @@ uint32_t getRelocationIndexValue(const WasmRelocationEntry &RelEntry); uint32_t getFunctionType(const MCSymbolWasm &Symbol); - uint32_t getEventType(const MCSymbolWasm &Symbol); + uint32_t getTagType(const MCSymbolWasm &Symbol); void registerFunctionType(const MCSymbolWasm &Symbol); - void registerEventType(const MCSymbolWasm &Symbol); + void registerTagType(const MCSymbolWasm &Symbol); }; } // end anonymous namespace @@ -612,9 +612,9 @@ case wasm::R_WASM_FUNCTION_INDEX_LEB: case wasm::R_WASM_GLOBAL_INDEX_LEB: case wasm::R_WASM_GLOBAL_INDEX_I32: - case wasm::R_WASM_EVENT_INDEX_LEB: + case wasm::R_WASM_TAG_INDEX_LEB: case wasm::R_WASM_TABLE_NUMBER_LEB: - // Provisional value is function/global/event Wasm index + // Provisional value is function/global/tag Wasm index assert(WasmIndices.count(RelEntry.Symbol) > 0 && "symbol not found in wasm index space"); return WasmIndices[RelEntry.Symbol]; case wasm::R_WASM_FUNCTION_OFFSET_I32: @@ -717,7 +717,7 @@ case wasm::R_WASM_TYPE_INDEX_LEB: case wasm::R_WASM_GLOBAL_INDEX_LEB: case wasm::R_WASM_MEMORY_ADDR_LEB: - case wasm::R_WASM_EVENT_INDEX_LEB: + case wasm::R_WASM_TAG_INDEX_LEB: case wasm::R_WASM_TABLE_NUMBER_LEB: writePatchableLEB<5>(Stream, Value, Offset); break; @@ -813,9 +813,9 @@ encodeULEB128(0, W->OS); // flags encodeULEB128(NumElements, W->OS); // initial break; - case wasm::WASM_EXTERNAL_EVENT: - encodeULEB128(Import.Event.Attribute, W->OS); - encodeULEB128(Import.Event.SigIndex, W->OS); + case wasm::WASM_EXTERNAL_TAG: + encodeULEB128(Import.Tag.Attribute, W->OS); + encodeULEB128(Import.Tag.SigIndex, W->OS); break; default: llvm_unreachable("unsupported import kind"); @@ -839,17 +839,17 @@ endSection(Section); } -void WasmObjectWriter::writeEventSection(ArrayRef Events) { - if (Events.empty()) +void WasmObjectWriter::writeTagSection(ArrayRef Tags) { + if (Tags.empty()) return; SectionBookkeeping Section; - startSection(Section, wasm::WASM_SEC_EVENT); + startSection(Section, wasm::WASM_SEC_TAG); - encodeULEB128(Events.size(), W->OS); - for (const wasm::WasmEventType &Event : Events) { - encodeULEB128(Event.Attribute, W->OS); - encodeULEB128(Event.SigIndex, W->OS); + encodeULEB128(Tags.size(), W->OS); + for (const wasm::WasmTagType &Tag : Tags) { + encodeULEB128(Tag.Attribute, W->OS); + encodeULEB128(Tag.SigIndex, W->OS); } endSection(Section); @@ -1103,7 +1103,7 @@ switch (Sym.Kind) { case wasm::WASM_SYMBOL_TYPE_FUNCTION: case wasm::WASM_SYMBOL_TYPE_GLOBAL: - case wasm::WASM_SYMBOL_TYPE_EVENT: + case wasm::WASM_SYMBOL_TYPE_TAG: case wasm::WASM_SYMBOL_TYPE_TABLE: encodeULEB128(Sym.ElementIndex, W->OS); if ((Sym.Flags & wasm::WASM_SYMBOL_UNDEFINED) == 0 || @@ -1196,8 +1196,8 @@ return TypeIndices[&Symbol]; } -uint32_t WasmObjectWriter::getEventType(const MCSymbolWasm &Symbol) { - assert(Symbol.isEvent()); +uint32_t WasmObjectWriter::getTagType(const MCSymbolWasm &Symbol) { + assert(Symbol.isTag()); assert(TypeIndices.count(&Symbol)); return TypeIndices[&Symbol]; } @@ -1222,8 +1222,8 @@ LLVM_DEBUG(dbgs() << " -> type index: " << Pair.first->second << "\n"); } -void WasmObjectWriter::registerEventType(const MCSymbolWasm &Symbol) { - assert(Symbol.isEvent()); +void WasmObjectWriter::registerTagType(const MCSymbolWasm &Symbol) { + assert(Symbol.isTag()); // TODO Currently we don't generate imported exceptions, but if we do, we // should have a way of infering types of imported exceptions. @@ -1238,7 +1238,7 @@ Signatures.push_back(S); TypeIndices[&Symbol] = Pair.first->second; - LLVM_DEBUG(dbgs() << "registerEventType: " << Symbol << " new:" << Pair.second + LLVM_DEBUG(dbgs() << "registerTagType: " << Symbol << " new:" << Pair.second << "\n"); LLVM_DEBUG(dbgs() << " -> type index: " << Pair.first->second << "\n"); } @@ -1292,8 +1292,8 @@ registerFunctionType(*cast(BS)); } - if (WS.isEvent()) - registerEventType(WS); + if (WS.isTag()) + registerTagType(WS); if (WS.isTemporary()) continue; @@ -1321,19 +1321,19 @@ Imports.push_back(Import); assert(WasmIndices.count(&WS) == 0); WasmIndices[&WS] = NumGlobalImports++; - } else if (WS.isEvent()) { + } else if (WS.isTag()) { if (WS.isWeak()) - report_fatal_error("undefined event symbol cannot be weak"); + report_fatal_error("undefined tag symbol cannot be weak"); wasm::WasmImport Import; Import.Module = WS.getImportModule(); Import.Field = WS.getImportName(); - Import.Kind = wasm::WASM_EXTERNAL_EVENT; - Import.Event.Attribute = wasm::WASM_EVENT_ATTRIBUTE_EXCEPTION; - Import.Event.SigIndex = getEventType(WS); + Import.Kind = wasm::WASM_EXTERNAL_TAG; + Import.Tag.Attribute = wasm::WASM_TAG_ATTRIBUTE_EXCEPTION; + Import.Tag.SigIndex = getTagType(WS); Imports.push_back(Import); assert(WasmIndices.count(&WS) == 0); - WasmIndices[&WS] = NumEventImports++; + WasmIndices[&WS] = NumTagImports++; } else if (WS.isTable()) { if (WS.isWeak()) report_fatal_error("undefined table symbol cannot be weak"); @@ -1398,7 +1398,7 @@ SmallVector TableElems; SmallVector Imports; SmallVector Exports; - SmallVector Events; + SmallVector Tags; SmallVector Globals; SmallVector Tables; SmallVector SymbolInfos; @@ -1632,23 +1632,23 @@ } LLVM_DEBUG(dbgs() << " -> table index: " << WasmIndices.find(&WS)->second << "\n"); - } else if (WS.isEvent()) { + } else if (WS.isTag()) { // C++ exception symbol (__cpp_exception) unsigned Index; if (WS.isDefined()) { - Index = NumEventImports + Events.size(); - wasm::WasmEventType Event; - Event.SigIndex = getEventType(WS); - Event.Attribute = wasm::WASM_EVENT_ATTRIBUTE_EXCEPTION; + Index = NumTagImports + Tags.size(); + wasm::WasmTagType Tag; + Tag.SigIndex = getTagType(WS); + Tag.Attribute = wasm::WASM_TAG_ATTRIBUTE_EXCEPTION; assert(WasmIndices.count(&WS) == 0); WasmIndices[&WS] = Index; - Events.push_back(Event); + Tags.push_back(Tag); } else { // An import; the index was assigned above. assert(WasmIndices.count(&WS) > 0); } - LLVM_DEBUG(dbgs() << " -> event index: " - << WasmIndices.find(&WS)->second << "\n"); + LLVM_DEBUG(dbgs() << " -> tag index: " << WasmIndices.find(&WS)->second + << "\n"); } else { assert(WS.isSection()); @@ -1703,7 +1703,7 @@ DataLocations[&WS] = Ref; LLVM_DEBUG(dbgs() << " -> index:" << Ref.Segment << "\n"); } else { - report_fatal_error("don't yet support global/event aliases"); + report_fatal_error("don't yet support global/tag aliases"); } } } @@ -1858,7 +1858,7 @@ writeFunctionSection(Functions); writeTableSection(Tables); // Skip the "memory" section; we import the memory instead. - writeEventSection(Events); + writeTagSection(Tags); writeGlobalSection(Globals); writeExportSection(Exports); const MCSymbol *IndirectFunctionTable = diff --git a/llvm/lib/Object/RelocationResolver.cpp b/llvm/lib/Object/RelocationResolver.cpp --- a/llvm/lib/Object/RelocationResolver.cpp +++ b/llvm/lib/Object/RelocationResolver.cpp @@ -572,7 +572,7 @@ case wasm::R_WASM_GLOBAL_INDEX_LEB: case wasm::R_WASM_FUNCTION_OFFSET_I32: case wasm::R_WASM_SECTION_OFFSET_I32: - case wasm::R_WASM_EVENT_INDEX_LEB: + case wasm::R_WASM_TAG_INDEX_LEB: case wasm::R_WASM_GLOBAL_INDEX_I32: case wasm::R_WASM_TABLE_NUMBER_LEB: case wasm::R_WASM_MEMORY_ADDR_LOCREL_I32: @@ -609,7 +609,7 @@ case wasm::R_WASM_GLOBAL_INDEX_LEB: case wasm::R_WASM_FUNCTION_OFFSET_I32: case wasm::R_WASM_SECTION_OFFSET_I32: - case wasm::R_WASM_EVENT_INDEX_LEB: + case wasm::R_WASM_TAG_INDEX_LEB: case wasm::R_WASM_GLOBAL_INDEX_I32: case wasm::R_WASM_TABLE_NUMBER_LEB: case wasm::R_WASM_MEMORY_ADDR_LOCREL_I32: diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp --- a/llvm/lib/Object/WasmObjectFile.cpp +++ b/llvm/lib/Object/WasmObjectFile.cpp @@ -316,8 +316,8 @@ return parseTableSection(Ctx); case wasm::WASM_SEC_MEMORY: return parseMemorySection(Ctx); - case wasm::WASM_SEC_EVENT: - return parseEventSection(Ctx); + case wasm::WASM_SEC_TAG: + return parseTagSection(Ctx); case wasm::WASM_SEC_GLOBAL: return parseGlobalSection(Ctx); case wasm::WASM_SEC_EXPORT: @@ -507,19 +507,19 @@ std::vector ImportedGlobals; std::vector ImportedFunctions; - std::vector ImportedEvents; + std::vector ImportedTags; std::vector ImportedTables; ImportedGlobals.reserve(Imports.size()); ImportedFunctions.reserve(Imports.size()); - ImportedEvents.reserve(Imports.size()); + ImportedTags.reserve(Imports.size()); ImportedTables.reserve(Imports.size()); for (auto &I : Imports) { if (I.Kind == wasm::WASM_EXTERNAL_FUNCTION) ImportedFunctions.emplace_back(&I); else if (I.Kind == wasm::WASM_EXTERNAL_GLOBAL) ImportedGlobals.emplace_back(&I); - else if (I.Kind == wasm::WASM_EXTERNAL_EVENT) - ImportedEvents.emplace_back(&I); + else if (I.Kind == wasm::WASM_EXTERNAL_TAG) + ImportedTags.emplace_back(&I); else if (I.Kind == wasm::WASM_EXTERNAL_TABLE) ImportedTables.emplace_back(&I); } @@ -529,7 +529,7 @@ const wasm::WasmSignature *Signature = nullptr; const wasm::WasmGlobalType *GlobalType = nullptr; const wasm::WasmTableType *TableType = nullptr; - const wasm::WasmEventType *EventType = nullptr; + const wasm::WasmTagType *TagType = nullptr; Info.Kind = readUint8(Ctx); Info.Flags = readVaruint32(Ctx); @@ -660,11 +660,11 @@ break; } - case wasm::WASM_SYMBOL_TYPE_EVENT: { + case wasm::WASM_SYMBOL_TYPE_TAG: { Info.ElementIndex = readVaruint32(Ctx); - if (!isValidEventIndex(Info.ElementIndex) || - IsDefined != isDefinedEventIndex(Info.ElementIndex)) - return make_error("invalid event symbol index", + if (!isValidTagIndex(Info.ElementIndex) || + IsDefined != isDefinedTagIndex(Info.ElementIndex)) + return make_error("invalid tag symbol index", object_error::parse_failed); if (!IsDefined && (Info.Flags & wasm::WASM_SYMBOL_BINDING_MASK) == wasm::WASM_SYMBOL_BINDING_WEAK) @@ -672,23 +672,23 @@ object_error::parse_failed); if (IsDefined) { Info.Name = readString(Ctx); - unsigned EventIndex = Info.ElementIndex - NumImportedEvents; - wasm::WasmEvent &Event = Events[EventIndex]; - Signature = &Signatures[Event.Type.SigIndex]; - EventType = &Event.Type; - if (Event.SymbolName.empty()) - Event.SymbolName = Info.Name; + unsigned TagIndex = Info.ElementIndex - NumImportedTags; + wasm::WasmTag &Tag = Tags[TagIndex]; + Signature = &Signatures[Tag.Type.SigIndex]; + TagType = &Tag.Type; + if (Tag.SymbolName.empty()) + Tag.SymbolName = Info.Name; } else { - wasm::WasmImport &Import = *ImportedEvents[Info.ElementIndex]; + wasm::WasmImport &Import = *ImportedTags[Info.ElementIndex]; if ((Info.Flags & wasm::WASM_SYMBOL_EXPLICIT_NAME) != 0) { Info.Name = readString(Ctx); Info.ImportName = Import.Field; } else { Info.Name = Import.Field; } - EventType = &Import.Event; - Signature = &Signatures[EventType->SigIndex]; + TagType = &Import.Tag; + Signature = &Signatures[TagType->SigIndex]; if (!Import.Module.empty()) { Info.ImportModule = Import.Module; } @@ -710,7 +710,7 @@ object_error::parse_failed); LinkingData.SymbolTable.emplace_back(Info); Symbols.emplace_back(LinkingData.SymbolTable.back(), GlobalType, TableType, - EventType, Signature); + TagType, Signature); LLVM_DEBUG(dbgs() << "Adding symbol: " << Symbols.back() << "\n"); } @@ -899,9 +899,9 @@ return make_error("invalid relocation global index", object_error::parse_failed); break; - case wasm::R_WASM_EVENT_INDEX_LEB: - if (!isValidEventSymbol(Reloc.Index)) - return make_error("invalid relocation event index", + case wasm::R_WASM_TAG_INDEX_LEB: + if (!isValidTagSymbol(Reloc.Index)) + return make_error("invalid relocation tag index", object_error::parse_failed); break; case wasm::R_WASM_MEMORY_ADDR_LEB: @@ -1064,10 +1064,10 @@ object_error::parse_failed); break; } - case wasm::WASM_EXTERNAL_EVENT: - NumImportedEvents++; - Im.Event.Attribute = readVarint32(Ctx); - Im.Event.SigIndex = readVarint32(Ctx); + case wasm::WASM_EXTERNAL_TAG: + NumImportedTags++; + Im.Tag.Attribute = readVarint32(Ctx); + Im.Tag.SigIndex = readVarint32(Ctx); break; default: return make_error("unexpected import kind", @@ -1136,20 +1136,20 @@ return Error::success(); } -Error WasmObjectFile::parseEventSection(ReadContext &Ctx) { - EventSection = Sections.size(); +Error WasmObjectFile::parseTagSection(ReadContext &Ctx) { + TagSection = Sections.size(); uint32_t Count = readVaruint32(Ctx); - Events.reserve(Count); + Tags.reserve(Count); while (Count--) { - wasm::WasmEvent Event; - Event.Index = NumImportedEvents + Events.size(); - Event.Type.Attribute = readVaruint32(Ctx); - Event.Type.SigIndex = readVaruint32(Ctx); - Events.push_back(Event); + wasm::WasmTag Tag; + Tag.Index = NumImportedTags + Tags.size(); + Tag.Type.Attribute = readVaruint32(Ctx); + Tag.Type.SigIndex = readVaruint32(Ctx); + Tags.push_back(Tag); } if (Ctx.Ptr != Ctx.End) - return make_error("event section ended prematurely", + return make_error("tag section ended prematurely", object_error::parse_failed); return Error::success(); } @@ -1194,9 +1194,9 @@ return make_error("invalid global export", object_error::parse_failed); break; - case wasm::WASM_EXTERNAL_EVENT: - if (!isValidEventIndex(Ex.Index)) - return make_error("invalid event export", + case wasm::WASM_EXTERNAL_TAG: + if (!isValidTagIndex(Ex.Index)) + return make_error("invalid tag export", object_error::parse_failed); break; case wasm::WASM_EXTERNAL_MEMORY: @@ -1238,12 +1238,12 @@ return Index >= NumImportedTables && isValidTableNumber(Index); } -bool WasmObjectFile::isValidEventIndex(uint32_t Index) const { - return Index < NumImportedEvents + Events.size(); +bool WasmObjectFile::isValidTagIndex(uint32_t Index) const { + return Index < NumImportedTags + Tags.size(); } -bool WasmObjectFile::isDefinedEventIndex(uint32_t Index) const { - return Index >= NumImportedEvents && isValidEventIndex(Index); +bool WasmObjectFile::isDefinedTagIndex(uint32_t Index) const { + return Index >= NumImportedTags && isValidTagIndex(Index); } bool WasmObjectFile::isValidFunctionSymbol(uint32_t Index) const { @@ -1258,8 +1258,8 @@ return Index < Symbols.size() && Symbols[Index].isTypeGlobal(); } -bool WasmObjectFile::isValidEventSymbol(uint32_t Index) const { - return Index < Symbols.size() && Symbols[Index].isTypeEvent(); +bool WasmObjectFile::isValidTagSymbol(uint32_t Index) const { + return Index < Symbols.size() && Symbols[Index].isTypeTag(); } bool WasmObjectFile::isValidDataSymbol(uint32_t Index) const { @@ -1286,9 +1286,9 @@ return Globals[Index - NumImportedGlobals]; } -wasm::WasmEvent &WasmObjectFile::getDefinedEvent(uint32_t Index) { - assert(isDefinedEventIndex(Index)); - return Events[Index - NumImportedEvents]; +wasm::WasmTag &WasmObjectFile::getDefinedTag(uint32_t Index) { + assert(isDefinedTagIndex(Index)); + return Tags[Index - NumImportedTags]; } Error WasmObjectFile::parseStartSection(ReadContext &Ctx) { @@ -1515,7 +1515,7 @@ switch (Sym.Info.Kind) { case wasm::WASM_SYMBOL_TYPE_FUNCTION: case wasm::WASM_SYMBOL_TYPE_GLOBAL: - case wasm::WASM_SYMBOL_TYPE_EVENT: + case wasm::WASM_SYMBOL_TYPE_TAG: case wasm::WASM_SYMBOL_TYPE_TABLE: return Sym.Info.ElementIndex; case wasm::WASM_SYMBOL_TYPE_DATA: { @@ -1564,7 +1564,7 @@ return SymbolRef::ST_Data; case wasm::WASM_SYMBOL_TYPE_SECTION: return SymbolRef::ST_Debug; - case wasm::WASM_SYMBOL_TYPE_EVENT: + case wasm::WASM_SYMBOL_TYPE_TAG: return SymbolRef::ST_Other; case wasm::WASM_SYMBOL_TYPE_TABLE: return SymbolRef::ST_Other; @@ -1600,8 +1600,8 @@ return DataSection; case wasm::WASM_SYMBOL_TYPE_SECTION: return Sym.Info.ElementIndex; - case wasm::WASM_SYMBOL_TYPE_EVENT: - return EventSection; + case wasm::WASM_SYMBOL_TYPE_TAG: + return TagSection; case wasm::WASM_SYMBOL_TYPE_TABLE: return TableSection; default: @@ -1623,7 +1623,7 @@ ECase(TABLE); ECase(MEMORY); ECase(GLOBAL); - ECase(EVENT); + ECase(TAG); ECase(EXPORT); ECase(START); ECase(ELEM); @@ -1822,8 +1822,8 @@ return WASM_SEC_ORDER_DATA; case wasm::WASM_SEC_DATACOUNT: return WASM_SEC_ORDER_DATACOUNT; - case wasm::WASM_SEC_EVENT: - return WASM_SEC_ORDER_EVENT; + case wasm::WASM_SEC_TAG: + return WASM_SEC_ORDER_TAG; default: return WASM_SEC_ORDER_NONE; } @@ -1845,9 +1845,9 @@ // WASM_SEC_ORDER_TABLE {WASM_SEC_ORDER_TABLE, WASM_SEC_ORDER_MEMORY}, // WASM_SEC_ORDER_MEMORY - {WASM_SEC_ORDER_MEMORY, WASM_SEC_ORDER_EVENT}, - // WASM_SEC_ORDER_EVENT - {WASM_SEC_ORDER_EVENT, WASM_SEC_ORDER_GLOBAL}, + {WASM_SEC_ORDER_MEMORY, WASM_SEC_ORDER_TAG}, + // WASM_SEC_ORDER_TAG + {WASM_SEC_ORDER_TAG, WASM_SEC_ORDER_GLOBAL}, // WASM_SEC_ORDER_GLOBAL {WASM_SEC_ORDER_GLOBAL, WASM_SEC_ORDER_EXPORT}, // WASM_SEC_ORDER_EXPORT diff --git a/llvm/lib/ObjectYAML/WasmEmitter.cpp b/llvm/lib/ObjectYAML/WasmEmitter.cpp --- a/llvm/lib/ObjectYAML/WasmEmitter.cpp +++ b/llvm/lib/ObjectYAML/WasmEmitter.cpp @@ -41,7 +41,7 @@ void writeSectionContent(raw_ostream &OS, WasmYAML::FunctionSection &Section); void writeSectionContent(raw_ostream &OS, WasmYAML::TableSection &Section); void writeSectionContent(raw_ostream &OS, WasmYAML::MemorySection &Section); - void writeSectionContent(raw_ostream &OS, WasmYAML::EventSection &Section); + void writeSectionContent(raw_ostream &OS, WasmYAML::TagSection &Section); void writeSectionContent(raw_ostream &OS, WasmYAML::GlobalSection &Section); void writeSectionContent(raw_ostream &OS, WasmYAML::ExportSection &Section); void writeSectionContent(raw_ostream &OS, WasmYAML::StartSection &Section); @@ -61,7 +61,7 @@ uint32_t NumImportedFunctions = 0; uint32_t NumImportedGlobals = 0; uint32_t NumImportedTables = 0; - uint32_t NumImportedEvents = 0; + uint32_t NumImportedTags = 0; bool HasError = false; yaml::ErrorHandler ErrHandler; @@ -189,7 +189,7 @@ case wasm::WASM_SYMBOL_TYPE_FUNCTION: case wasm::WASM_SYMBOL_TYPE_GLOBAL: case wasm::WASM_SYMBOL_TYPE_TABLE: - case wasm::WASM_SYMBOL_TYPE_EVENT: + case wasm::WASM_SYMBOL_TYPE_TAG: encodeULEB128(Info.ElementIndex, SubSection.getStream()); if ((Info.Flags & wasm::WASM_SYMBOL_UNDEFINED) == 0 || (Info.Flags & wasm::WASM_SYMBOL_EXPLICIT_NAME) != 0) @@ -385,10 +385,10 @@ writeUint8(OS, Import.GlobalImport.Mutable); NumImportedGlobals++; break; - case wasm::WASM_EXTERNAL_EVENT: - writeUint32(OS, Import.EventImport.Attribute); - writeUint32(OS, Import.EventImport.SigIndex); - NumImportedEvents++; + case wasm::WASM_EXTERNAL_TAG: + writeUint32(OS, Import.TagImport.Attribute); + writeUint32(OS, Import.TagImport.SigIndex); + NumImportedTags++; break; case wasm::WASM_EXTERNAL_MEMORY: writeLimits(Import.Memory, OS); @@ -450,17 +450,17 @@ } void WasmWriter::writeSectionContent(raw_ostream &OS, - WasmYAML::EventSection &Section) { - encodeULEB128(Section.Events.size(), OS); - uint32_t ExpectedIndex = NumImportedEvents; - for (auto &Event : Section.Events) { - if (Event.Index != ExpectedIndex) { - reportError("unexpected event index: " + Twine(Event.Index)); + WasmYAML::TagSection &Section) { + encodeULEB128(Section.Tags.size(), OS); + uint32_t ExpectedIndex = NumImportedTags; + for (auto &Tag : Section.Tags) { + if (Tag.Index != ExpectedIndex) { + reportError("unexpected tag index: " + Twine(Tag.Index)); return; } ++ExpectedIndex; - encodeULEB128(Event.Attribute, OS); - encodeULEB128(Event.SigIndex, OS); + encodeULEB128(Tag.Attribute, OS); + encodeULEB128(Tag.SigIndex, OS); } } @@ -626,7 +626,7 @@ writeSectionContent(StringStream, *S); else if (auto S = dyn_cast(Sec.get())) writeSectionContent(StringStream, *S); - else if (auto S = dyn_cast(Sec.get())) + else if (auto S = dyn_cast(Sec.get())) writeSectionContent(StringStream, *S); else if (auto S = dyn_cast(Sec.get())) writeSectionContent(StringStream, *S); diff --git a/llvm/lib/ObjectYAML/WasmYAML.cpp b/llvm/lib/ObjectYAML/WasmYAML.cpp --- a/llvm/lib/ObjectYAML/WasmYAML.cpp +++ b/llvm/lib/ObjectYAML/WasmYAML.cpp @@ -120,9 +120,9 @@ IO.mapOptional("Memories", Section.Memories); } -static void sectionMapping(IO &IO, WasmYAML::EventSection &Section) { +static void sectionMapping(IO &IO, WasmYAML::TagSection &Section) { commonSectionMapping(IO, Section); - IO.mapOptional("Events", Section.Events); + IO.mapOptional("Tags", Section.Tags); } static void sectionMapping(IO &IO, WasmYAML::GlobalSection &Section) { @@ -229,10 +229,10 @@ Section.reset(new WasmYAML::MemorySection()); sectionMapping(IO, *cast(Section.get())); break; - case wasm::WASM_SEC_EVENT: + case wasm::WASM_SEC_TAG: if (!IO.outputting()) - Section.reset(new WasmYAML::EventSection()); - sectionMapping(IO, *cast(Section.get())); + Section.reset(new WasmYAML::TagSection()); + sectionMapping(IO, *cast(Section.get())); break; case wasm::WASM_SEC_GLOBAL: if (!IO.outputting()) @@ -284,7 +284,7 @@ ECase(TABLE); ECase(MEMORY); ECase(GLOBAL); - ECase(EVENT); + ECase(TAG); ECase(EXPORT); ECase(START); ECase(ELEM); @@ -396,9 +396,9 @@ } else if (Import.Kind == wasm::WASM_EXTERNAL_GLOBAL) { IO.mapRequired("GlobalType", Import.GlobalImport.Type); IO.mapRequired("GlobalMutable", Import.GlobalImport.Mutable); - } else if (Import.Kind == wasm::WASM_EXTERNAL_EVENT) { - IO.mapRequired("EventAttribute", Import.EventImport.Attribute); - IO.mapRequired("EventSigIndex", Import.EventImport.SigIndex); + } else if (Import.Kind == wasm::WASM_EXTERNAL_TAG) { + IO.mapRequired("TagAttribute", Import.TagImport.Attribute); + IO.mapRequired("TagSigIndex", Import.TagImport.SigIndex); } else if (Import.Kind == wasm::WASM_EXTERNAL_TABLE) { IO.mapRequired("Table", Import.TableImport); } else if (Import.Kind == wasm::WASM_EXTERNAL_MEMORY) { @@ -510,8 +510,8 @@ IO.mapRequired("Global", Info.ElementIndex); } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_TABLE) { IO.mapRequired("Table", Info.ElementIndex); - } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_EVENT) { - IO.mapRequired("Event", Info.ElementIndex); + } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_TAG) { + IO.mapRequired("Tag", Info.ElementIndex); } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_DATA) { if ((Info.Flags & wasm::WASM_SYMBOL_UNDEFINED) == 0) { IO.mapRequired("Segment", Info.DataRef.Segment); @@ -525,10 +525,10 @@ } } -void MappingTraits::mapping(IO &IO, WasmYAML::Event &Event) { - IO.mapRequired("Index", Event.Index); - IO.mapRequired("Attribute", Event.Attribute); - IO.mapRequired("SigIndex", Event.SigIndex); +void MappingTraits::mapping(IO &IO, WasmYAML::Tag &Tag) { + IO.mapRequired("Index", Tag.Index); + IO.mapRequired("Attribute", Tag.Attribute); + IO.mapRequired("SigIndex", Tag.SigIndex); } void ScalarBitSetTraits::bitset( @@ -572,7 +572,7 @@ ECase(GLOBAL); ECase(TABLE); ECase(SECTION); - ECase(EVENT); + ECase(TAG); #undef ECase } @@ -597,7 +597,7 @@ ECase(TABLE); ECase(MEMORY); ECase(GLOBAL); - ECase(EVENT); + ECase(TAG); #undef ECase } diff --git a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp --- a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp +++ b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp @@ -899,7 +899,7 @@ TOut.emitImportName(WasmSym, ImportName); } - if (DirectiveID.getString() == ".eventtype") { + if (DirectiveID.getString() == ".tagtype") { auto SymName = expectIdent(); if (SymName.empty()) return true; @@ -909,8 +909,8 @@ return true; WasmSym->setSignature(Signature.get()); addSignature(std::move(Signature)); - WasmSym->setType(wasm::WASM_SYMBOL_TYPE_EVENT); - TOut.emitEventType(WasmSym); + WasmSym->setType(wasm::WASM_SYMBOL_TYPE_TAG); + TOut.emitTagType(WasmSym); // TODO: backend also calls TOut.emitIndIdx, but that is not implemented. return expect(AsmToken::EndOfStatement, "EOL"); } diff --git a/llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp b/llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp --- a/llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp +++ b/llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp @@ -203,7 +203,7 @@ case WebAssembly::OPERAND_OFFSET64: case WebAssembly::OPERAND_P2ALIGN: case WebAssembly::OPERAND_TYPEINDEX: - case WebAssembly::OPERAND_EVENT: + case WebAssembly::OPERAND_TAG: case MCOI::OPERAND_IMMEDIATE: { if (!parseLEBImmediate(MI, Size, Bytes, false)) return MCDisassembler::Fail; diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp @@ -154,7 +154,7 @@ case WebAssembly::OPERAND_SIGNATURE: case WebAssembly::OPERAND_TYPEINDEX: case WebAssembly::OPERAND_GLOBAL: - case WebAssembly::OPERAND_EVENT: + case WebAssembly::OPERAND_TAG: FixupKind = MCFixupKind(WebAssembly::fixup_uleb128_i32); break; case WebAssembly::OPERAND_OFFSET64: diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h @@ -72,8 +72,8 @@ OPERAND_SIGNATURE, /// type signature immediate for call_indirect. OPERAND_TYPEINDEX, - /// Event index. - OPERAND_EVENT, + /// Tag index. + OPERAND_TAG, /// A list of branch targets for br_list. OPERAND_BRLIST, /// 32-bit unsigned table number. diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h @@ -42,8 +42,8 @@ virtual void emitGlobalType(const MCSymbolWasm *Sym) = 0; /// .tabletype virtual void emitTableType(const MCSymbolWasm *Sym) = 0; - /// .eventtype - virtual void emitEventType(const MCSymbolWasm *Sym) = 0; + /// .tagtype + virtual void emitTagType(const MCSymbolWasm *Sym) = 0; /// .import_module virtual void emitImportModule(const MCSymbolWasm *Sym, StringRef ImportModule) = 0; @@ -71,7 +71,7 @@ void emitIndIdx(const MCExpr *Value) override; void emitGlobalType(const MCSymbolWasm *Sym) override; void emitTableType(const MCSymbolWasm *Sym) override; - void emitEventType(const MCSymbolWasm *Sym) override; + void emitTagType(const MCSymbolWasm *Sym) override; void emitImportModule(const MCSymbolWasm *Sym, StringRef ImportModule) override; void emitImportName(const MCSymbolWasm *Sym, StringRef ImportName) override; void emitExportName(const MCSymbolWasm *Sym, StringRef ExportName) override; @@ -88,7 +88,7 @@ void emitIndIdx(const MCExpr *Value) override; void emitGlobalType(const MCSymbolWasm *Sym) override {} void emitTableType(const MCSymbolWasm *Sym) override {} - void emitEventType(const MCSymbolWasm *Sym) override {} + void emitTagType(const MCSymbolWasm *Sym) override {} void emitImportModule(const MCSymbolWasm *Sym, StringRef ImportModule) override {} void emitImportName(const MCSymbolWasm *Sym, @@ -109,7 +109,7 @@ void emitIndIdx(const MCExpr *) override {} void emitGlobalType(const MCSymbolWasm *) override {} void emitTableType(const MCSymbolWasm *) override {} - void emitEventType(const MCSymbolWasm *) override {} + void emitTagType(const MCSymbolWasm *) override {} void emitImportModule(const MCSymbolWasm *, StringRef) override {} void emitImportName(const MCSymbolWasm *, StringRef) override {} void emitExportName(const MCSymbolWasm *, StringRef) override {} diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp @@ -91,9 +91,9 @@ OS << '\n'; } -void WebAssemblyTargetAsmStreamer::emitEventType(const MCSymbolWasm *Sym) { - assert(Sym->isEvent()); - OS << "\t.eventtype\t" << Sym->getName() << " "; +void WebAssemblyTargetAsmStreamer::emitTagType(const MCSymbolWasm *Sym) { + assert(Sym->isTag()); + OS << "\t.tagtype\t" << Sym->getName() << " "; OS << WebAssembly::typeListToString(Sym->getSignature()->Params); OS << "\n"; } diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp @@ -104,8 +104,8 @@ return wasm::R_WASM_GLOBAL_INDEX_LEB; if (SymA.isFunction()) return wasm::R_WASM_FUNCTION_INDEX_LEB; - if (SymA.isEvent()) - return wasm::R_WASM_EVENT_INDEX_LEB; + if (SymA.isTag()) + return wasm::R_WASM_TAG_INDEX_LEB; if (SymA.isTable()) return wasm::R_WASM_TABLE_NUMBER_LEB; return wasm::R_WASM_MEMORY_ADDR_LEB; diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp --- a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp @@ -209,7 +209,7 @@ void WebAssemblyAsmPrinter::emitEndOfAsmFile(Module &M) { for (auto &It : OutContext.getSymbols()) { - // Emit .globaltype, .eventtype, or .tabletype declarations. + // Emit .globaltype, .tagtype, or .tabletype declarations. auto Sym = cast(It.getValue()); if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_GLOBAL) { // .globaltype already handled by emitGlobalVariable for defined @@ -217,8 +217,8 @@ // written to the file. if (Sym->isUndefined()) getTargetStreamer()->emitGlobalType(Sym); - } else if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_EVENT) - getTargetStreamer()->emitEventType(Sym); + } else if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_TAG) + getTargetStreamer()->emitTagType(Sym); else if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_TABLE) getTargetStreamer()->emitTableType(Sym); } diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrControl.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrControl.td --- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrControl.td +++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrControl.td @@ -129,8 +129,8 @@ // Throwing an exception: throw / rethrow let isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in { -defm THROW : I<(outs), (ins event_op:$tag, variable_ops), - (outs), (ins event_op:$tag), +defm THROW : I<(outs), (ins tag_op:$tag, variable_ops), + (outs), (ins tag_op:$tag), [(WebAssemblythrow (WebAssemblywrapper texternalsym:$tag))], "throw \t$tag", "throw \t$tag", 0x08>; defm RETHROW : NRI<(outs), (ins i32imm:$depth), [], "rethrow \t$depth", 0x09>; @@ -149,9 +149,9 @@ let hasCtrlDep = 1, hasSideEffects = 1 in { // Currently 'catch' can only extract an i32, which is sufficient for C++ // support, but according to the spec 'catch' can extract any number of values -// based on the event type. -defm CATCH : I<(outs I32:$dst), (ins event_op:$tag), - (outs), (ins event_op:$tag), +// based on the tag type. +defm CATCH : I<(outs I32:$dst), (ins tag_op:$tag), + (outs), (ins tag_op:$tag), [(set I32:$dst, (WebAssemblycatch (WebAssemblywrapper texternalsym:$tag)))], "catch \t$dst, $tag", "catch \t$tag", 0x07>; diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td --- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td +++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td @@ -196,8 +196,8 @@ let PrintMethod = "printWebAssemblyP2AlignOperand"; } -let OperandType = "OPERAND_EVENT" in -def event_op : Operand; +let OperandType = "OPERAND_TAG" in +def tag_op : Operand; } // OperandType = "OPERAND_P2ALIGN" diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp --- a/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp @@ -116,11 +116,10 @@ SmallVector Returns; SmallVector Params; if (strcmp(Name, "__cpp_exception") == 0) { - WasmSym->setType(wasm::WASM_SYMBOL_TYPE_EVENT); + WasmSym->setType(wasm::WASM_SYMBOL_TYPE_TAG); // We can't confirm its signature index for now because there can be // imported exceptions. Set it to be 0 for now. - WasmSym->setEventType( - {wasm::WASM_EVENT_ATTRIBUTE_EXCEPTION, /* SigIndex */ 0}); + WasmSym->setTagType({wasm::WASM_TAG_ATTRIBUTE_EXCEPTION, /* SigIndex */ 0}); // We may have multiple C++ compilation units to be linked together, each of // which defines the exception symbol. To resolve them, we declare them as // weak. @@ -179,8 +178,8 @@ report_fatal_error("Function addresses with offsets not supported"); if (WasmSym->isGlobal()) report_fatal_error("Global indexes with offsets not supported"); - if (WasmSym->isEvent()) - report_fatal_error("Event indexes with offsets not supported"); + if (WasmSym->isTag()) + report_fatal_error("Tag indexes with offsets not supported"); if (WasmSym->isTable()) report_fatal_error("Table indexes with offsets not supported"); diff --git a/llvm/test/CodeGen/WebAssembly/exception.ll b/llvm/test/CodeGen/WebAssembly/exception.ll --- a/llvm/test/CodeGen/WebAssembly/exception.ll +++ b/llvm/test/CodeGen/WebAssembly/exception.ll @@ -372,4 +372,4 @@ attributes #1 = { noreturn } ; CHECK: __cpp_exception: -; CHECK: .eventtype __cpp_exception i32 +; CHECK: .tagtype __cpp_exception i32 diff --git a/llvm/test/CodeGen/WebAssembly/null-streamer.ll b/llvm/test/CodeGen/WebAssembly/null-streamer.ll --- a/llvm/test/CodeGen/WebAssembly/null-streamer.ll +++ b/llvm/test/CodeGen/WebAssembly/null-streamer.ll @@ -15,5 +15,5 @@ } ; CHECK-DAG: .globaltype -; CHECK-DAG: .eventtype +; CHECK-DAG: .tagtype ; CHECK-DAG: .functype diff --git a/llvm/test/MC/WebAssembly/annotations.s b/llvm/test/MC/WebAssembly/annotations.s --- a/llvm/test/MC/WebAssembly/annotations.s +++ b/llvm/test/MC/WebAssembly/annotations.s @@ -8,7 +8,7 @@ .type test_annotation,@function test_annotation: .functype test_annotation () -> () - .eventtype __cpp_exception i32 + .tagtype __cpp_exception i32 try br 0 catch __cpp_exception diff --git a/llvm/test/MC/WebAssembly/basic-assembly.s b/llvm/test/MC/WebAssembly/basic-assembly.s --- a/llvm/test/MC/WebAssembly/basic-assembly.s +++ b/llvm/test/MC/WebAssembly/basic-assembly.s @@ -12,7 +12,7 @@ .Ltest0begin: # Test all types: .functype test0 (i32, i64) -> (i32) - .eventtype __cpp_exception i32 + .tagtype __cpp_exception i32 .local f32, f64, v128, v128 # Explicit getlocal/setlocal: local.get 2 @@ -131,7 +131,7 @@ # CHECK-LABEL: test0: # CHECK-NEXT: .Ltest0begin: # CHECK-NEXT: .functype test0 (i32, i64) -> (i32) -# CHECK-NEXT: .eventtype __cpp_exception i32 +# CHECK-NEXT: .tagtype __cpp_exception i32 # CHECK-NEXT: .local f32, f64 # CHECK-NEXT: local.get 2 # CHECK-NEXT: local.set 2 diff --git a/llvm/test/MC/WebAssembly/event-section-decoding.ll b/llvm/test/MC/WebAssembly/tag-section-decoding.ll rename from llvm/test/MC/WebAssembly/event-section-decoding.ll rename to llvm/test/MC/WebAssembly/tag-section-decoding.ll --- a/llvm/test/MC/WebAssembly/event-section-decoding.ll +++ b/llvm/test/MC/WebAssembly/tag-section-decoding.ll @@ -1,9 +1,9 @@ ; RUN: llc -filetype=obj -exception-model=wasm -mattr=+exception-handling %s -o - | obj2yaml | FileCheck %s -; This is a regression test for a decoding bug that happens when an event's +; This is a regression test for a decoding bug that happens when a tag's ; sigindex is greater than 63, so we put 63 dummy functions with different ; signatures before the function that contains the 'throw' instruction to make -; the event's sigindex 64. +; the tag's sigindex 64. target triple = "wasm32-unknown-unknown" @@ -334,12 +334,12 @@ ret i32 0 } -; Checks to see if the event index is correctly decoded in ULEB128. If it is +; Checks to see if the tag index is correctly decoded in ULEB128. If it is ; decoded with LEB128, 64 will not be correctly decoded. 64 is the smallest ; number with which its LEB128 and ULEB128 encodings are different, because its ; 7th least significant bit is not 0. -; CHECK: - Type: EVENT -; CHECK-NEXT: Events: +; CHECK: - Type: TAG +; CHECK-NEXT: Tags: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Attribute: 0 ; CHECK-NEXT: SigIndex: 64 diff --git a/llvm/test/MC/WebAssembly/event-section.ll b/llvm/test/MC/WebAssembly/tag-section.ll rename from llvm/test/MC/WebAssembly/event-section.ll rename to llvm/test/MC/WebAssembly/tag-section.ll --- a/llvm/test/MC/WebAssembly/event-section.ll +++ b/llvm/test/MC/WebAssembly/tag-section.ll @@ -28,18 +28,18 @@ ; CHECK-NEXT: - I32 ; CHECK-NEXT: ReturnTypes: [] -; CHECK: - Type: EVENT -; CHECK-NEXT: Events: +; CHECK: - Type: TAG +; CHECK-NEXT: Tags: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Attribute: 0 ; CHECK-NEXT: SigIndex: 1 ; CHECK-NEXT: - Type: CODE ; CHECK-NEXT: Relocations: -; CHECK-NEXT: - Type: R_WASM_EVENT_INDEX_LEB +; CHECK-NEXT: - Type: R_WASM_TAG_INDEX_LEB ; CHECK-NEXT: Index: 1 ; CHECK-NEXT: Offset: 0x6 -; CHECK-NEXT: - Type: R_WASM_EVENT_INDEX_LEB +; CHECK-NEXT: - Type: R_WASM_TAG_INDEX_LEB ; CHECK-NEXT: Index: 1 ; CHECK-NEXT: Offset: 0x11 @@ -49,11 +49,11 @@ ; CHECK-NEXT: SymbolTable: ; CHECK: - Index: 1 -; CHECK-NEXT: Kind: EVENT +; CHECK-NEXT: Kind: TAG ; CHECK-NEXT: Name: __cpp_exception ; CHECK-NEXT: Flags: [ BINDING_WEAK ] -; CHECK-NEXT: Event: 0 +; CHECK-NEXT: Tag: 0 -; SEC: Type: EVENT (0xD) +; SEC: Type: TAG (0xD) ; SEC-NEXT: Size: 3 ; SEC-NEXT: Offset: 63 diff --git a/llvm/test/ObjectYAML/wasm/event_section.yaml b/llvm/test/ObjectYAML/wasm/event_section.yaml --- a/llvm/test/ObjectYAML/wasm/event_section.yaml +++ b/llvm/test/ObjectYAML/wasm/event_section.yaml @@ -17,14 +17,14 @@ ReturnTypes: [] - Type: FUNCTION FunctionTypes: [ 0 ] - - Type: EVENT - Events: + - Type: TAG + Tags: - Index: 0 Attribute: 0 SigIndex: 1 - Type: CODE Relocations: - - Type: R_WASM_EVENT_INDEX_LEB + - Type: R_WASM_TAG_INDEX_LEB Index: 1 Offset: 0x00000006 - Type: 10 @@ -44,10 +44,10 @@ Flags: [ ] Function: 0 - Index: 1 - Kind: EVENT + Kind: TAG Name: __cpp_exception Flags: [ BINDING_WEAK ] - Event: 0 + Tag: 0 ... # CHECK: --- !WASM @@ -67,17 +67,17 @@ # CHECK-NEXT: ReturnTypes: [] # CHECK-NEXT: - Type: FUNCTION # CHECK-NEXT: FunctionTypes: [ 0 ] -# CHECK-NEXT: - Type: EVENT -# CHECK-NEXT: Events: +# CHECK-NEXT: - Type: TAG +# CHECK-NEXT: Tags: # CHECK-NEXT: - Index: 0 # CHECK-NEXT: Attribute: 0 # CHECK-NEXT: SigIndex: 1 # CHECK-NEXT: - Type: CODE # CHECK-NEXT: Relocations: -# CHECK-NEXT: - Type: R_WASM_EVENT_INDEX_LEB +# CHECK-NEXT: - Type: R_WASM_TAG_INDEX_LEB # CHECK-NEXT: Index: 1 # CHECK-NEXT: Offset: 0x6 -# CHECK-NEXT: - Type: R_WASM_EVENT_INDEX_LEB +# CHECK-NEXT: - Type: R_WASM_TAG_INDEX_LEB # CHECK-NEXT: Index: 1 # CHECK-NEXT: Offset: 0x6 # CHECK-NEXT: Functions: @@ -94,7 +94,7 @@ # CHECK-NEXT: Flags: [ ] # CHECK-NEXT: Function: 0 # CHECK-NEXT: - Index: 1 -# CHECK-NEXT: Kind: EVENT +# CHECK-NEXT: Kind: TAG # CHECK-NEXT: Name: __cpp_exception # CHECK-NEXT: Flags: [ BINDING_WEAK ] -# CHECK-NEXT: Event: 0 +# CHECK-NEXT: Tag: 0 diff --git a/llvm/tools/llvm-readobj/WasmDumper.cpp b/llvm/tools/llvm-readobj/WasmDumper.cpp --- a/llvm/tools/llvm-readobj/WasmDumper.cpp +++ b/llvm/tools/llvm-readobj/WasmDumper.cpp @@ -23,8 +23,8 @@ static const EnumEntry WasmSymbolTypes[] = { #define ENUM_ENTRY(X) \ { #X, wasm::WASM_SYMBOL_TYPE_##X } - ENUM_ENTRY(FUNCTION), ENUM_ENTRY(DATA), ENUM_ENTRY(GLOBAL), - ENUM_ENTRY(SECTION), ENUM_ENTRY(EVENT), ENUM_ENTRY(TABLE), + ENUM_ENTRY(FUNCTION), ENUM_ENTRY(DATA), ENUM_ENTRY(GLOBAL), + ENUM_ENTRY(SECTION), ENUM_ENTRY(TAG), ENUM_ENTRY(TABLE), #undef ENUM_ENTRY }; @@ -33,7 +33,7 @@ { #X, wasm::WASM_SEC_##X } ENUM_ENTRY(CUSTOM), ENUM_ENTRY(TYPE), ENUM_ENTRY(IMPORT), ENUM_ENTRY(FUNCTION), ENUM_ENTRY(TABLE), ENUM_ENTRY(MEMORY), - ENUM_ENTRY(GLOBAL), ENUM_ENTRY(EVENT), ENUM_ENTRY(EXPORT), + ENUM_ENTRY(GLOBAL), ENUM_ENTRY(TAG), ENUM_ENTRY(EXPORT), ENUM_ENTRY(START), ENUM_ENTRY(ELEM), ENUM_ENTRY(CODE), ENUM_ENTRY(DATA), ENUM_ENTRY(DATACOUNT), #undef ENUM_ENTRY diff --git a/llvm/tools/obj2yaml/wasm2yaml.cpp b/llvm/tools/obj2yaml/wasm2yaml.cpp --- a/llvm/tools/obj2yaml/wasm2yaml.cpp +++ b/llvm/tools/obj2yaml/wasm2yaml.cpp @@ -132,7 +132,7 @@ case wasm::WASM_SYMBOL_TYPE_FUNCTION: case wasm::WASM_SYMBOL_TYPE_GLOBAL: case wasm::WASM_SYMBOL_TYPE_TABLE: - case wasm::WASM_SYMBOL_TYPE_EVENT: + case wasm::WASM_SYMBOL_TYPE_TAG: Info.ElementIndex = Symbol.ElementIndex; break; case wasm::WASM_SYMBOL_TYPE_SECTION: @@ -238,9 +238,9 @@ Im.GlobalImport.Type = Import.Global.Type; Im.GlobalImport.Mutable = Import.Global.Mutable; break; - case wasm::WASM_EXTERNAL_EVENT: - Im.EventImport.Attribute = Import.Event.Attribute; - Im.EventImport.SigIndex = Import.Event.SigIndex; + case wasm::WASM_EXTERNAL_TAG: + Im.TagImport.Attribute = Import.Tag.Attribute; + Im.TagImport.SigIndex = Import.Tag.SigIndex; break; case wasm::WASM_EXTERNAL_TABLE: // FIXME: Currently we always output an index of 0 for any imported @@ -280,16 +280,16 @@ S = std::move(MemorySec); break; } - case wasm::WASM_SEC_EVENT: { - auto EventSec = std::make_unique(); - for (auto &Event : Obj.events()) { - WasmYAML::Event E; - E.Index = Event.Index; - E.Attribute = Event.Type.Attribute; - E.SigIndex = Event.Type.SigIndex; - EventSec->Events.push_back(E); + case wasm::WASM_SEC_TAG: { + auto TagSec = std::make_unique(); + for (auto &Tag : Obj.tags()) { + WasmYAML::Tag T; + T.Index = Tag.Index; + T.Attribute = Tag.Type.Attribute; + T.SigIndex = Tag.Type.SigIndex; + TagSec->Tags.push_back(T); } - S = std::move(EventSec); + S = std::move(TagSec); break; } case wasm::WASM_SEC_GLOBAL: {