Skip to content

Commit 1d891d4

Browse files
committed
[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 - WebAssembly/exception-handling#159 (comment) - WebAssembly/exception-handling#161 Reviewed By: tlively Differential Revision: https://reviews.llvm.org/D104423
1 parent 6aaf4fa commit 1d891d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+440
-444
lines changed

lld/include/lld/Common/LLVM.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class WasmSymbol;
4444
} // namespace object
4545

4646
namespace wasm {
47-
struct WasmEvent;
48-
struct WasmEventType;
47+
struct WasmTag;
48+
struct WasmTagType;
4949
struct WasmFunction;
5050
struct WasmGlobal;
5151
struct WasmGlobalType;
@@ -87,8 +87,6 @@ using llvm::object::WasmObjectFile;
8787
using llvm::object::WasmSection;
8888
using llvm::object::WasmSegment;
8989
using llvm::object::WasmSymbol;
90-
using llvm::wasm::WasmEvent;
91-
using llvm::wasm::WasmEventType;
9290
using llvm::wasm::WasmFunction;
9391
using llvm::wasm::WasmGlobal;
9492
using llvm::wasm::WasmGlobalType;
@@ -98,6 +96,8 @@ using llvm::wasm::WasmRelocation;
9896
using llvm::wasm::WasmSignature;
9997
using llvm::wasm::WasmTable;
10098
using llvm::wasm::WasmTableType;
99+
using llvm::wasm::WasmTag;
100+
using llvm::wasm::WasmTagType;
101101
} // end namespace lld.
102102

103103
namespace std {

lld/test/wasm/event-section.ll renamed to lld/test/wasm/tag-section.ll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
; RUN: llc -filetype=obj -exception-model=wasm -mattr=+exception-handling %p/Inputs/event-section1.ll -o %t1.o
2-
; RUN: llc -filetype=obj -exception-model=wasm -mattr=+exception-handling %p/Inputs/event-section2.ll -o %t2.o
1+
; RUN: llc -filetype=obj -exception-model=wasm -mattr=+exception-handling %p/Inputs/tag-section1.ll -o %t1.o
2+
; RUN: llc -filetype=obj -exception-model=wasm -mattr=+exception-handling %p/Inputs/tag-section2.ll -o %t2.o
33
; RUN: llc -filetype=obj -exception-model=wasm -mattr=+exception-handling %s -o %t.o
44
; RUN: wasm-ld -o %t.wasm %t.o %t1.o %t2.o
55
; RUN: wasm-ld --export-all -o %t-export-all.wasm %t.o %t1.o %t2.o
@@ -29,17 +29,17 @@ define void @_start() {
2929
; CHECK-NEXT: - I32
3030
; CHECK-NEXT: ReturnTypes: []
3131

32-
; CHECK: - Type: EVENT
33-
; CHECK-NEXT: Events:
32+
; CHECK: - Type: TAG
33+
; CHECK-NEXT: Tags:
3434
; CHECK-NEXT: - Index: 0
3535
; CHECK-NEXT: Attribute: 0
3636
; CHECK-NEXT: SigIndex: 1
3737

38-
; Global section has to come after event section
38+
; Global section has to come after tag section
3939
; CHECK: - Type: GLOBAL
4040

4141
; EXPORT-ALL: - Type: EXPORT
4242
; EXPORT-ALL-NEXT Exports:
4343
; EXPORT-ALL: - Name: __cpp_exception
44-
; EXPORT-ALL: Kind: EVENT
44+
; EXPORT-ALL: Kind: TAG
4545
; EXPORT-ALL: Index: 0

lld/wasm/InputChunks.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void InputChunk::relocate(uint8_t *buf) const {
117117
case R_WASM_TYPE_INDEX_LEB:
118118
case R_WASM_FUNCTION_INDEX_LEB:
119119
case R_WASM_GLOBAL_INDEX_LEB:
120-
case R_WASM_EVENT_INDEX_LEB:
120+
case R_WASM_TAG_INDEX_LEB:
121121
case R_WASM_MEMORY_ADDR_LEB:
122122
case R_WASM_TABLE_NUMBER_LEB:
123123
encodeULEB128(value, loc, 5);
@@ -208,7 +208,7 @@ static unsigned writeCompressedReloc(uint8_t *buf, const WasmRelocation &rel,
208208
case R_WASM_TYPE_INDEX_LEB:
209209
case R_WASM_FUNCTION_INDEX_LEB:
210210
case R_WASM_GLOBAL_INDEX_LEB:
211-
case R_WASM_EVENT_INDEX_LEB:
211+
case R_WASM_TAG_INDEX_LEB:
212212
case R_WASM_MEMORY_ADDR_LEB:
213213
case R_WASM_MEMORY_ADDR_LEB64:
214214
case R_WASM_TABLE_NUMBER_LEB:
@@ -228,7 +228,7 @@ static unsigned getRelocWidthPadded(const WasmRelocation &rel) {
228228
case R_WASM_TYPE_INDEX_LEB:
229229
case R_WASM_FUNCTION_INDEX_LEB:
230230
case R_WASM_GLOBAL_INDEX_LEB:
231-
case R_WASM_EVENT_INDEX_LEB:
231+
case R_WASM_TAG_INDEX_LEB:
232232
case R_WASM_MEMORY_ADDR_LEB:
233233
case R_WASM_TABLE_NUMBER_LEB:
234234
case R_WASM_TABLE_INDEX_SLEB:

lld/wasm/InputElement.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
namespace lld {
1919
namespace wasm {
2020

21-
// Represents a single element (Global, Event, Table, etc) within an input
21+
// Represents a single element (Global, Tag, Table, etc) within an input
2222
// file.
2323
class InputElement {
2424
protected:
@@ -71,17 +71,17 @@ class InputGlobal : public InputElement {
7171
WasmInitExpr initExpr;
7272
};
7373

74-
class InputEvent : public InputElement {
74+
class InputTag : public InputElement {
7575
public:
76-
InputEvent(const WasmSignature &s, const WasmEvent &e, ObjFile *f)
77-
: InputElement(e.SymbolName, f), signature(s), type(e.Type) {}
76+
InputTag(const WasmSignature &s, const WasmTag &t, ObjFile *f)
77+
: InputElement(t.SymbolName, f), signature(s), type(t.Type) {}
7878

79-
const WasmEventType &getType() const { return type; }
79+
const WasmTagType &getType() const { return type; }
8080

8181
const WasmSignature &signature;
8282

8383
private:
84-
WasmEventType type;
84+
WasmTagType type;
8585
};
8686

8787
class InputTable : public InputElement {

lld/wasm/InputFiles.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void ObjFile::dumpInfo() const {
9393
"\n Symbols : " + Twine(symbols.size()) +
9494
"\n Function Imports : " + Twine(wasmObj->getNumImportedFunctions()) +
9595
"\n Global Imports : " + Twine(wasmObj->getNumImportedGlobals()) +
96-
"\n Event Imports : " + Twine(wasmObj->getNumImportedEvents()) +
96+
"\n Tag Imports : " + Twine(wasmObj->getNumImportedTags()) +
9797
"\n Table Imports : " + Twine(wasmObj->getNumImportedTables()));
9898
}
9999

@@ -209,8 +209,8 @@ uint64_t ObjFile::calcNewValue(const WasmRelocation &reloc, uint64_t tombstone,
209209
if (auto gs = dyn_cast<GlobalSymbol>(sym))
210210
return gs->getGlobalIndex();
211211
return sym->getGOTIndex();
212-
case R_WASM_EVENT_INDEX_LEB:
213-
return getEventSymbol(reloc.Index)->getEventIndex();
212+
case R_WASM_TAG_INDEX_LEB:
213+
return getTagSymbol(reloc.Index)->getTagIndex();
214214
case R_WASM_FUNCTION_OFFSET_I32:
215215
case R_WASM_FUNCTION_OFFSET_I64: {
216216
auto *f = cast<DefinedFunction>(sym);
@@ -343,10 +343,10 @@ void ObjFile::addLegacyIndirectFunctionTableIfNeeded(
343343
LLVM_DEBUG(dbgs() << "Synthesizing symbol for table import: " << info->Name
344344
<< "\n");
345345
const WasmGlobalType *globalType = nullptr;
346-
const WasmEventType *eventType = nullptr;
346+
const WasmTagType *tagType = nullptr;
347347
const WasmSignature *signature = nullptr;
348348
auto *wasmSym = make<WasmSymbol>(*info, globalType, &tableImport->Table,
349-
eventType, signature);
349+
tagType, signature);
350350
Symbol *sym = createUndefined(*wasmSym, false);
351351
// We're only sure it's a TableSymbol if the createUndefined succeeded.
352352
if (errorCount())
@@ -515,9 +515,9 @@ void ObjFile::parse(bool ignoreComdats) {
515515
for (const WasmGlobal &g : wasmObj->globals())
516516
globals.emplace_back(make<InputGlobal>(g, this));
517517

518-
// Populate `Events`.
519-
for (const WasmEvent &e : wasmObj->events())
520-
events.emplace_back(make<InputEvent>(types[e.Type.SigIndex], e, this));
518+
// Populate `Tags`.
519+
for (const WasmTag &t : wasmObj->tags())
520+
tags.emplace_back(make<InputTag>(types[t.Type.SigIndex], t, this));
521521

522522
// Populate `Symbols` based on the symbols in the object.
523523
symbols.reserve(wasmObj->getNumberOfSymbols());
@@ -556,8 +556,8 @@ GlobalSymbol *ObjFile::getGlobalSymbol(uint32_t index) const {
556556
return cast<GlobalSymbol>(symbols[index]);
557557
}
558558

559-
EventSymbol *ObjFile::getEventSymbol(uint32_t index) const {
560-
return cast<EventSymbol>(symbols[index]);
559+
TagSymbol *ObjFile::getTagSymbol(uint32_t index) const {
560+
return cast<TagSymbol>(symbols[index]);
561561
}
562562

563563
TableSymbol *ObjFile::getTableSymbol(uint32_t index) const {
@@ -612,12 +612,11 @@ Symbol *ObjFile::createDefined(const WasmSymbol &sym) {
612612
return nullptr;
613613
return make<SectionSymbol>(flags, section, this);
614614
}
615-
case WASM_SYMBOL_TYPE_EVENT: {
616-
InputEvent *event =
617-
events[sym.Info.ElementIndex - wasmObj->getNumImportedEvents()];
615+
case WASM_SYMBOL_TYPE_TAG: {
616+
InputTag *tag = tags[sym.Info.ElementIndex - wasmObj->getNumImportedTags()];
618617
if (sym.isBindingLocal())
619-
return make<DefinedEvent>(name, flags, this, event);
620-
return symtab->addDefinedEvent(name, flags, this, event);
618+
return make<DefinedTag>(name, flags, this, tag);
619+
return symtab->addDefinedTag(name, flags, this, tag);
621620
}
622621
case WASM_SYMBOL_TYPE_TABLE: {
623622
InputTable *table =

lld/wasm/InputFiles.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class InputChunk;
3131
class InputFunction;
3232
class InputSegment;
3333
class InputGlobal;
34-
class InputEvent;
34+
class InputTag;
3535
class InputTable;
3636
class InputSection;
3737

@@ -139,7 +139,7 @@ class ObjFile : public InputFile {
139139
std::vector<InputChunk *> segments;
140140
std::vector<InputFunction *> functions;
141141
std::vector<InputGlobal *> globals;
142-
std::vector<InputEvent *> events;
142+
std::vector<InputTag *> tags;
143143
std::vector<InputTable *> tables;
144144
std::vector<InputChunk *> customSections;
145145
llvm::DenseMap<uint32_t, InputChunk *> customSectionsByIndex;
@@ -149,7 +149,7 @@ class ObjFile : public InputFile {
149149
DataSymbol *getDataSymbol(uint32_t index) const;
150150
GlobalSymbol *getGlobalSymbol(uint32_t index) const;
151151
SectionSymbol *getSectionSymbol(uint32_t index) const;
152-
EventSymbol *getEventSymbol(uint32_t index) const;
152+
TagSymbol *getTagSymbol(uint32_t index) const;
153153
TableSymbol *getTableSymbol(uint32_t index) const;
154154

155155
private:

lld/wasm/MarkLive.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ void markLive() {
162162
for (InputGlobal *g : obj->globals)
163163
if (!g->live)
164164
message("removing unused section " + toString(g));
165-
for (InputEvent *e : obj->events)
166-
if (!e->live)
167-
message("removing unused section " + toString(e));
165+
for (InputTag *t : obj->tags)
166+
if (!t->live)
167+
message("removing unused section " + toString(t));
168168
for (InputTable *t : obj->tables)
169169
if (!t->live)
170170
message("removing unused section " + toString(t));

lld/wasm/OutputSections.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ static StringRef sectionTypeToString(uint32_t sectionType) {
4949
return "MEMORY";
5050
case WASM_SEC_GLOBAL:
5151
return "GLOBAL";
52-
case WASM_SEC_EVENT:
53-
return "EVENT";
52+
case WASM_SEC_TAG:
53+
return "TAG";
5454
case WASM_SEC_EXPORT:
5555
return "EXPORT";
5656
case WASM_SEC_START:

lld/wasm/SymbolTable.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -168,23 +168,23 @@ static void checkGlobalType(const Symbol *existing, const InputFile *file,
168168
}
169169
}
170170

171-
static void checkEventType(const Symbol *existing, const InputFile *file,
172-
const WasmEventType *newType,
173-
const WasmSignature *newSig) {
174-
auto existingEvent = dyn_cast<EventSymbol>(existing);
175-
if (!isa<EventSymbol>(existing)) {
176-
reportTypeError(existing, file, WASM_SYMBOL_TYPE_EVENT);
171+
static void checkTagType(const Symbol *existing, const InputFile *file,
172+
const WasmTagType *newType,
173+
const WasmSignature *newSig) {
174+
const auto *existingTag = dyn_cast<TagSymbol>(existing);
175+
if (!isa<TagSymbol>(existing)) {
176+
reportTypeError(existing, file, WASM_SYMBOL_TYPE_TAG);
177177
return;
178178
}
179179

180-
const WasmEventType *oldType = cast<EventSymbol>(existing)->getEventType();
181-
const WasmSignature *oldSig = existingEvent->signature;
180+
const WasmTagType *oldType = cast<TagSymbol>(existing)->getTagType();
181+
const WasmSignature *oldSig = existingTag->signature;
182182
if (newType->Attribute != oldType->Attribute)
183-
error("Event type mismatch: " + existing->getName() + "\n>>> defined as " +
183+
error("Tag type mismatch: " + existing->getName() + "\n>>> defined as " +
184184
toString(*oldType) + " in " + toString(existing->getFile()) +
185185
"\n>>> defined as " + toString(*newType) + " in " + toString(file));
186186
if (*newSig != *oldSig)
187-
warn("Event signature mismatch: " + existing->getName() +
187+
warn("Tag signature mismatch: " + existing->getName() +
188188
"\n>>> defined as " + toString(*oldSig) + " in " +
189189
toString(existing->getFile()) + "\n>>> defined as " +
190190
toString(*newSig) + " in " + toString(file));
@@ -413,24 +413,24 @@ Symbol *SymbolTable::addDefinedGlobal(StringRef name, uint32_t flags,
413413
return s;
414414
}
415415

416-
Symbol *SymbolTable::addDefinedEvent(StringRef name, uint32_t flags,
417-
InputFile *file, InputEvent *event) {
418-
LLVM_DEBUG(dbgs() << "addDefinedEvent:" << name << "\n");
416+
Symbol *SymbolTable::addDefinedTag(StringRef name, uint32_t flags,
417+
InputFile *file, InputTag *tag) {
418+
LLVM_DEBUG(dbgs() << "addDefinedTag:" << name << "\n");
419419

420420
Symbol *s;
421421
bool wasInserted;
422422
std::tie(s, wasInserted) = insert(name, file);
423423

424424
auto replaceSym = [&]() {
425-
replaceSymbol<DefinedEvent>(s, name, flags, file, event);
425+
replaceSymbol<DefinedTag>(s, name, flags, file, tag);
426426
};
427427

428428
if (wasInserted || s->isLazy()) {
429429
replaceSym();
430430
return s;
431431
}
432432

433-
checkEventType(s, file, &event->getType(), &event->signature);
433+
checkTagType(s, file, &tag->getType(), &tag->signature);
434434

435435
if (shouldReplace(s, file, flags))
436436
replaceSym();

lld/wasm/SymbolTable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ class SymbolTable {
5757
InputChunk *segment, uint64_t address, uint64_t size);
5858
Symbol *addDefinedGlobal(StringRef name, uint32_t flags, InputFile *file,
5959
InputGlobal *g);
60-
Symbol *addDefinedEvent(StringRef name, uint32_t flags, InputFile *file,
61-
InputEvent *e);
60+
Symbol *addDefinedTag(StringRef name, uint32_t flags, InputFile *file,
61+
InputTag *t);
6262
Symbol *addDefinedTable(StringRef name, uint32_t flags, InputFile *file,
6363
InputTable *t);
6464

0 commit comments

Comments
 (0)