[PATCH] D55247: [WebAssembly] Make WasmSymbol's signature usable for events
Heejin Ahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 3 20:04:58 PST 2018
aheejin created this revision.
aheejin added a reviewer: sbc100.
Herald added subscribers: llvm-commits, sunfish, jgravelle-google, dschuff.
WasmSignature used to use its `WasmSignature` member variable only for
function types, but now it also can be used for events as well.
Repository:
rL LLVM
https://reviews.llvm.org/D55247
Files:
include/llvm/BinaryFormat/Wasm.h
include/llvm/Object/Wasm.h
lib/Object/WasmObjectFile.cpp
Index: lib/Object/WasmObjectFile.cpp
===================================================================
--- lib/Object/WasmObjectFile.cpp
+++ lib/Object/WasmObjectFile.cpp
@@ -468,7 +468,7 @@
while (Count--) {
wasm::WasmSymbolInfo Info;
- const wasm::WasmSignature *FunctionType = nullptr;
+ const wasm::WasmSignature *Signature = nullptr;
const wasm::WasmGlobalType *GlobalType = nullptr;
const wasm::WasmEventType *EventType = nullptr;
@@ -486,13 +486,13 @@
if (IsDefined) {
Info.Name = readString(Ctx);
unsigned FuncIndex = Info.ElementIndex - NumImportedFunctions;
- FunctionType = &Signatures[FunctionTypes[FuncIndex]];
+ Signature = &Signatures[FunctionTypes[FuncIndex]];
wasm::WasmFunction &Function = Functions[FuncIndex];
if (Function.SymbolName.empty())
Function.SymbolName = Info.Name;
} else {
wasm::WasmImport &Import = *ImportedFunctions[Info.ElementIndex];
- FunctionType = &Signatures[Import.SigIndex];
+ Signature = &Signatures[Import.SigIndex];
Info.Name = Import.Field;
Info.Module = Import.Module;
}
@@ -565,6 +565,7 @@
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;
@@ -572,6 +573,7 @@
} else {
wasm::WasmImport &Import = *ImportedEvents[Info.ElementIndex];
EventType = &Import.Event;
+ Signature = &Signatures[EventType->SigIndex];
Info.Name = Import.Field;
}
break;
@@ -589,8 +591,8 @@
Twine(Info.Name),
object_error::parse_failed);
LinkingData.SymbolTable.emplace_back(Info);
- Symbols.emplace_back(LinkingData.SymbolTable.back(), FunctionType,
- GlobalType, EventType);
+ Symbols.emplace_back(LinkingData.SymbolTable.back(), GlobalType, EventType,
+ Signature);
LLVM_DEBUG(dbgs() << "Adding symbol: " << Symbols.back() << "\n");
}
Index: include/llvm/Object/Wasm.h
===================================================================
--- include/llvm/Object/Wasm.h
+++ include/llvm/Object/Wasm.h
@@ -37,16 +37,16 @@
class WasmSymbol {
public:
WasmSymbol(const wasm::WasmSymbolInfo &Info,
- const wasm::WasmSignature *FunctionType,
const wasm::WasmGlobalType *GlobalType,
- const wasm::WasmEventType *EventType)
- : Info(Info), FunctionType(FunctionType), GlobalType(GlobalType),
- EventType(EventType) {}
+ const wasm::WasmEventType *EventType,
+ const wasm::WasmSignature *Signature)
+ : Info(Info), GlobalType(GlobalType), EventType(EventType),
+ Signature(Signature) {}
const wasm::WasmSymbolInfo &Info;
- const wasm::WasmSignature *FunctionType;
const wasm::WasmGlobalType *GlobalType;
const wasm::WasmEventType *EventType;
+ const wasm::WasmSignature *Signature;
bool isTypeFunction() const {
return Info.Kind == wasm::WASM_SYMBOL_TYPE_FUNCTION;
Index: include/llvm/BinaryFormat/Wasm.h
===================================================================
--- include/llvm/BinaryFormat/Wasm.h
+++ include/llvm/BinaryFormat/Wasm.h
@@ -332,7 +332,7 @@
}
inline bool operator==(const WasmEventType &LHS, const WasmEventType &RHS) {
- return LHS.Attribute == RHS.Attribute && LHS.SigIndex == RHS.SigIndex;
+ return LHS.Attribute == RHS.Attribute;
}
inline bool operator!=(const WasmEventType &LHS, const WasmEventType &RHS) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55247.176541.patch
Type: text/x-patch
Size: 3827 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181204/d7274609/attachment.bin>
More information about the llvm-commits
mailing list