aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/WasmObjectWriter.cpp
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2021-06-15 01:49:43 -0700
committerHeejin Ahn <aheejin@gmail.com>2021-06-17 20:34:19 -0700
commit1d891d44f33f99c55e779acaeac4628e4ac9aaaf (patch)
treeed05e40d4fa4c7001f0da4a088f6e8fc54091091 /llvm/lib/MC/WasmObjectWriter.cpp
parent6aaf4fa2885600b0e31042071ad06f78218ab0f2 (diff)
downloadllvm-1d891d44f33f99c55e779acaeac4628e4ac9aaaf.zip
llvm-1d891d44f33f99c55e779acaeac4628e4ac9aaaf.tar.gz
llvm-1d891d44f33f99c55e779acaeac4628e4ac9aaaf.tar.bz2
[WebAssembly] Rename event to tag
We recently decided to change 'event' to 'tag', and 'event section' to 'tag section', out of the rationale that the section contains a generalized tag that references a type, which may be used for something other than exceptions, and the name 'event' can be confusing in the web context. See - https://github.com/WebAssembly/exception-handling/issues/159#issuecomment-857910130 - https://github.com/WebAssembly/exception-handling/pull/161 Reviewed By: tlively Differential Revision: https://reviews.llvm.org/D104423
Diffstat (limited to 'llvm/lib/MC/WasmObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/WasmObjectWriter.cpp86
1 files changed, 43 insertions, 43 deletions
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index 2320818..41f50f6 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -195,7 +195,7 @@ class WasmObjectWriter : public MCObjectWriter {
// for TABLE_INDEX relocation types (i.e. address taken functions).
DenseMap<const MCSymbolWasm *, uint32_t> TableIndices;
// Maps function/global/table symbols to the
- // function/global/table/event/section index space.
+ // function/global/table/tag/section index space.
DenseMap<const MCSymbolWasm *, uint32_t> WasmIndices;
DenseMap<const MCSymbolWasm *, uint32_t> GOTIndices;
// Maps data symbols to the Wasm segment and offset/size with the segment.
@@ -219,7 +219,7 @@ class WasmObjectWriter : public MCObjectWriter {
unsigned NumFunctionImports = 0;
unsigned NumGlobalImports = 0;
unsigned NumTableImports = 0;
- unsigned NumEventImports = 0;
+ unsigned NumTagImports = 0;
uint32_t SectionCount = 0;
enum class DwoMode {
@@ -317,7 +317,7 @@ private:
uint32_t writeCodeSection(const MCAssembler &Asm, const MCAsmLayout &Layout,
ArrayRef<WasmFunction> Functions);
uint32_t writeDataSection(const MCAsmLayout &Layout);
- void writeEventSection(ArrayRef<wasm::WasmEventType> Events);
+ void writeTagSection(ArrayRef<wasm::WasmTagType> Tags);
void writeGlobalSection(ArrayRef<wasm::WasmGlobal> Globals);
void writeTableSection(ArrayRef<wasm::WasmTable> Tables);
void writeRelocSection(uint32_t SectionIndex, StringRef Name,
@@ -337,9 +337,9 @@ private:
uint32_t getRelocationIndexValue(const WasmRelocationEntry &RelEntry);
uint32_t getFunctionType(const MCSymbolWasm &Symbol);
- uint32_t getEventType(const MCSymbolWasm &Symbol);
+ uint32_t getTagType(const MCSymbolWasm &Symbol);
void registerFunctionType(const MCSymbolWasm &Symbol);
- void registerEventType(const MCSymbolWasm &Symbol);
+ void registerTagType(const MCSymbolWasm &Symbol);
};
} // end anonymous namespace
@@ -612,9 +612,9 @@ WasmObjectWriter::getProvisionalValue(const WasmRelocationEntry &RelEntry,
case wasm::R_WASM_FUNCTION_INDEX_LEB:
case wasm::R_WASM_GLOBAL_INDEX_LEB:
case wasm::R_WASM_GLOBAL_INDEX_I32:
- case wasm::R_WASM_EVENT_INDEX_LEB:
+ case wasm::R_WASM_TAG_INDEX_LEB:
case wasm::R_WASM_TABLE_NUMBER_LEB:
- // Provisional value is function/global/event Wasm index
+ // Provisional value is function/global/tag Wasm index
assert(WasmIndices.count(RelEntry.Symbol) > 0 && "symbol not found in wasm index space");
return WasmIndices[RelEntry.Symbol];
case wasm::R_WASM_FUNCTION_OFFSET_I32:
@@ -717,7 +717,7 @@ void WasmObjectWriter::applyRelocations(
case wasm::R_WASM_TYPE_INDEX_LEB:
case wasm::R_WASM_GLOBAL_INDEX_LEB:
case wasm::R_WASM_MEMORY_ADDR_LEB:
- case wasm::R_WASM_EVENT_INDEX_LEB:
+ case wasm::R_WASM_TAG_INDEX_LEB:
case wasm::R_WASM_TABLE_NUMBER_LEB:
writePatchableLEB<5>(Stream, Value, Offset);
break;
@@ -813,9 +813,9 @@ void WasmObjectWriter::writeImportSection(ArrayRef<wasm::WasmImport> Imports,
encodeULEB128(0, W->OS); // flags
encodeULEB128(NumElements, W->OS); // initial
break;
- case wasm::WASM_EXTERNAL_EVENT:
- encodeULEB128(Import.Event.Attribute, W->OS);
- encodeULEB128(Import.Event.SigIndex, W->OS);
+ case wasm::WASM_EXTERNAL_TAG:
+ encodeULEB128(Import.Tag.Attribute, W->OS);
+ encodeULEB128(Import.Tag.SigIndex, W->OS);
break;
default:
llvm_unreachable("unsupported import kind");
@@ -839,17 +839,17 @@ void WasmObjectWriter::writeFunctionSection(ArrayRef<WasmFunction> Functions) {
endSection(Section);
}
-void WasmObjectWriter::writeEventSection(ArrayRef<wasm::WasmEventType> Events) {
- if (Events.empty())
+void WasmObjectWriter::writeTagSection(ArrayRef<wasm::WasmTagType> Tags) {
+ if (Tags.empty())
return;
SectionBookkeeping Section;
- startSection(Section, wasm::WASM_SEC_EVENT);
+ startSection(Section, wasm::WASM_SEC_TAG);
- encodeULEB128(Events.size(), W->OS);
- for (const wasm::WasmEventType &Event : Events) {
- encodeULEB128(Event.Attribute, W->OS);
- encodeULEB128(Event.SigIndex, W->OS);
+ encodeULEB128(Tags.size(), W->OS);
+ for (const wasm::WasmTagType &Tag : Tags) {
+ encodeULEB128(Tag.Attribute, W->OS);
+ encodeULEB128(Tag.SigIndex, W->OS);
}
endSection(Section);
@@ -1103,7 +1103,7 @@ void WasmObjectWriter::writeLinkingMetaDataSection(
switch (Sym.Kind) {
case wasm::WASM_SYMBOL_TYPE_FUNCTION:
case wasm::WASM_SYMBOL_TYPE_GLOBAL:
- case wasm::WASM_SYMBOL_TYPE_EVENT:
+ case wasm::WASM_SYMBOL_TYPE_TAG:
case wasm::WASM_SYMBOL_TYPE_TABLE:
encodeULEB128(Sym.ElementIndex, W->OS);
if ((Sym.Flags & wasm::WASM_SYMBOL_UNDEFINED) == 0 ||
@@ -1196,8 +1196,8 @@ uint32_t WasmObjectWriter::getFunctionType(const MCSymbolWasm &Symbol) {
return TypeIndices[&Symbol];
}
-uint32_t WasmObjectWriter::getEventType(const MCSymbolWasm &Symbol) {
- assert(Symbol.isEvent());
+uint32_t WasmObjectWriter::getTagType(const MCSymbolWasm &Symbol) {
+ assert(Symbol.isTag());
assert(TypeIndices.count(&Symbol));
return TypeIndices[&Symbol];
}
@@ -1222,8 +1222,8 @@ void WasmObjectWriter::registerFunctionType(const MCSymbolWasm &Symbol) {
LLVM_DEBUG(dbgs() << " -> type index: " << Pair.first->second << "\n");
}
-void WasmObjectWriter::registerEventType(const MCSymbolWasm &Symbol) {
- assert(Symbol.isEvent());
+void WasmObjectWriter::registerTagType(const MCSymbolWasm &Symbol) {
+ assert(Symbol.isTag());
// TODO Currently we don't generate imported exceptions, but if we do, we
// should have a way of infering types of imported exceptions.
@@ -1238,7 +1238,7 @@ void WasmObjectWriter::registerEventType(const MCSymbolWasm &Symbol) {
Signatures.push_back(S);
TypeIndices[&Symbol] = Pair.first->second;
- LLVM_DEBUG(dbgs() << "registerEventType: " << Symbol << " new:" << Pair.second
+ LLVM_DEBUG(dbgs() << "registerTagType: " << Symbol << " new:" << Pair.second
<< "\n");
LLVM_DEBUG(dbgs() << " -> type index: " << Pair.first->second << "\n");
}
@@ -1292,8 +1292,8 @@ void WasmObjectWriter::prepareImports(
registerFunctionType(*cast<MCSymbolWasm>(BS));
}
- if (WS.isEvent())
- registerEventType(WS);
+ if (WS.isTag())
+ registerTagType(WS);
if (WS.isTemporary())
continue;
@@ -1321,19 +1321,19 @@ void WasmObjectWriter::prepareImports(
Imports.push_back(Import);
assert(WasmIndices.count(&WS) == 0);
WasmIndices[&WS] = NumGlobalImports++;
- } else if (WS.isEvent()) {
+ } else if (WS.isTag()) {
if (WS.isWeak())
- report_fatal_error("undefined event symbol cannot be weak");
+ report_fatal_error("undefined tag symbol cannot be weak");
wasm::WasmImport Import;
Import.Module = WS.getImportModule();
Import.Field = WS.getImportName();
- Import.Kind = wasm::WASM_EXTERNAL_EVENT;
- Import.Event.Attribute = wasm::WASM_EVENT_ATTRIBUTE_EXCEPTION;
- Import.Event.SigIndex = getEventType(WS);
+ Import.Kind = wasm::WASM_EXTERNAL_TAG;
+ Import.Tag.Attribute = wasm::WASM_TAG_ATTRIBUTE_EXCEPTION;
+ Import.Tag.SigIndex = getTagType(WS);
Imports.push_back(Import);
assert(WasmIndices.count(&WS) == 0);
- WasmIndices[&WS] = NumEventImports++;
+ WasmIndices[&WS] = NumTagImports++;
} else if (WS.isTable()) {
if (WS.isWeak())
report_fatal_error("undefined table symbol cannot be weak");
@@ -1398,7 +1398,7 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
SmallVector<uint32_t, 4> TableElems;
SmallVector<wasm::WasmImport, 4> Imports;
SmallVector<wasm::WasmExport, 4> Exports;
- SmallVector<wasm::WasmEventType, 1> Events;
+ SmallVector<wasm::WasmTagType, 1> Tags;
SmallVector<wasm::WasmGlobal, 1> Globals;
SmallVector<wasm::WasmTable, 1> Tables;
SmallVector<wasm::WasmSymbolInfo, 4> SymbolInfos;
@@ -1632,23 +1632,23 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
}
LLVM_DEBUG(dbgs() << " -> table index: "
<< WasmIndices.find(&WS)->second << "\n");
- } else if (WS.isEvent()) {
+ } else if (WS.isTag()) {
// C++ exception symbol (__cpp_exception)
unsigned Index;
if (WS.isDefined()) {
- Index = NumEventImports + Events.size();
- wasm::WasmEventType Event;
- Event.SigIndex = getEventType(WS);
- Event.Attribute = wasm::WASM_EVENT_ATTRIBUTE_EXCEPTION;
+ Index = NumTagImports + Tags.size();
+ wasm::WasmTagType Tag;
+ Tag.SigIndex = getTagType(WS);
+ Tag.Attribute = wasm::WASM_TAG_ATTRIBUTE_EXCEPTION;
assert(WasmIndices.count(&WS) == 0);
WasmIndices[&WS] = Index;
- Events.push_back(Event);
+ Tags.push_back(Tag);
} else {
// An import; the index was assigned above.
assert(WasmIndices.count(&WS) > 0);
}
- LLVM_DEBUG(dbgs() << " -> event index: "
- << WasmIndices.find(&WS)->second << "\n");
+ LLVM_DEBUG(dbgs() << " -> tag index: " << WasmIndices.find(&WS)->second
+ << "\n");
} else {
assert(WS.isSection());
@@ -1703,7 +1703,7 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
DataLocations[&WS] = Ref;
LLVM_DEBUG(dbgs() << " -> index:" << Ref.Segment << "\n");
} else {
- report_fatal_error("don't yet support global/event aliases");
+ report_fatal_error("don't yet support global/tag aliases");
}
}
}
@@ -1858,7 +1858,7 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
writeFunctionSection(Functions);
writeTableSection(Tables);
// Skip the "memory" section; we import the memory instead.
- writeEventSection(Events);
+ writeTagSection(Tags);
writeGlobalSection(Globals);
writeExportSection(Exports);
const MCSymbol *IndirectFunctionTable =