[WebAssembly] Make WasmSymbol's signature usable for events (NFC)

Summary:
WasmSignature used to use its `WasmSignature` member variable only for
function types, but now it also can be used for events as well.

Reviewers: sbc100

Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits

Differential Revision: https://reviews.llvm.org/D55247

llvm-svn: 348702
This commit is contained in:
Heejin Ahn 2018-12-08 06:16:13 +00:00
parent fe5a6c315b
commit a2125b8d99
3 changed files with 12 additions and 18 deletions

View File

@ -331,14 +331,6 @@ inline bool operator!=(const WasmGlobalType &LHS, const WasmGlobalType &RHS) {
return !(LHS == RHS);
}
inline bool operator==(const WasmEventType &LHS, const WasmEventType &RHS) {
return LHS.Attribute == RHS.Attribute && LHS.SigIndex == RHS.SigIndex;
}
inline bool operator!=(const WasmEventType &LHS, const WasmEventType &RHS) {
return !(LHS == RHS);
}
std::string toString(wasm::WasmSymbolType type);
std::string relocTypetoString(uint32_t type);

View File

@ -37,16 +37,16 @@ namespace object {
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;

View File

@ -468,7 +468,7 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
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 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
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 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
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 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
} else {
wasm::WasmImport &Import = *ImportedEvents[Info.ElementIndex];
EventType = &Import.Event;
Signature = &Signatures[EventType->SigIndex];
Info.Name = Import.Field;
}
break;
@ -589,8 +591,8 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
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");
}