summaryrefslogtreecommitdiffstats
path: root/lld/wasm/SymbolTable.cpp
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2018-12-08 06:17:43 +0000
committerHeejin Ahn <aheejin@gmail.com>2018-12-08 06:17:43 +0000
commite915a71f183a0d921f67dc1a95238885bcafeec8 (patch)
tree5fe7f26b14d29e41c8a9a9efd38aaebade20ce22 /lld/wasm/SymbolTable.cpp
parenta2125b8d9953e3720e9a9ec621ccbfd5f2cd78f0 (diff)
downloadbcm5719-llvm-e915a71f183a0d921f67dc1a95238885bcafeec8.tar.gz
bcm5719-llvm-e915a71f183a0d921f67dc1a95238885bcafeec8.zip
[WebAssembly] Add support for the event section
Summary: This adds support for the 'event section' specified in the exception handling proposal. Wasm exception handling binary model spec: https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md#changes-to-the-binary-model Reviewers: sbc100, ruiu Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D54875 llvm-svn: 348703
Diffstat (limited to 'lld/wasm/SymbolTable.cpp')
-rw-r--r--lld/wasm/SymbolTable.cpp53
1 files changed, 48 insertions, 5 deletions
diff --git a/lld/wasm/SymbolTable.cpp b/lld/wasm/SymbolTable.cpp
index 9c967ffa81d..c7983196db3 100644
--- a/lld/wasm/SymbolTable.cpp
+++ b/lld/wasm/SymbolTable.cpp
@@ -10,6 +10,7 @@
#include "SymbolTable.h"
#include "Config.h"
#include "InputChunks.h"
+#include "InputEvent.h"
#include "InputGlobal.h"
#include "WriterUtils.h"
#include "lld/Common/ErrorHandler.h"
@@ -111,9 +112,9 @@ static void checkFunctionType(Symbol *Existing, const InputFile *File,
if (!NewSig)
return;
- const WasmSignature *OldSig = ExistingFunction->FunctionType;
+ const WasmSignature *OldSig = ExistingFunction->Signature;
if (!OldSig) {
- ExistingFunction->FunctionType = NewSig;
+ ExistingFunction->Signature = NewSig;
return;
}
@@ -139,6 +140,28 @@ static void checkGlobalType(const Symbol *Existing, const InputFile *File,
}
}
+static void checkEventType(const Symbol *Existing, const InputFile *File,
+ const WasmEventType *NewType,
+ const WasmSignature *NewSig) {
+ auto ExistingEvent = dyn_cast<EventSymbol>(Existing);
+ if (!isa<EventSymbol>(Existing)) {
+ reportTypeError(Existing, File, WASM_SYMBOL_TYPE_EVENT);
+ return;
+ }
+
+ const WasmEventType *OldType = cast<EventSymbol>(Existing)->getEventType();
+ const WasmSignature *OldSig = ExistingEvent->Signature;
+ if (NewType->Attribute != OldType->Attribute)
+ error("Event 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() +
+ "\n>>> defined as " + toString(*OldSig) + " in " +
+ toString(Existing->getFile()) + "\n>>> defined as " +
+ toString(*NewSig) + " in " + toString(File));
+}
+
static void checkDataType(const Symbol *Existing, const InputFile *File) {
if (!isa<DataSymbol>(Existing))
reportTypeError(Existing, File, WASM_SYMBOL_TYPE_DATA);
@@ -222,10 +245,10 @@ Symbol *SymbolTable::addDefinedFunction(StringRef Name, uint32_t Flags,
// functions) but the old symbols does then preserve the old signature
const WasmSignature *OldSig = nullptr;
if (auto* F = dyn_cast<FunctionSymbol>(S))
- OldSig = F->FunctionType;
+ OldSig = F->Signature;
auto NewSym = replaceSymbol<DefinedFunction>(S, Name, Flags, File, Function);
- if (!NewSym->FunctionType)
- NewSym->FunctionType = OldSig;
+ if (!NewSym->Signature)
+ NewSym->Signature = OldSig;
}
return S;
}
@@ -271,6 +294,26 @@ Symbol *SymbolTable::addDefinedGlobal(StringRef Name, uint32_t Flags,
return S;
}
+Symbol *SymbolTable::addDefinedEvent(StringRef Name, uint32_t Flags,
+ InputFile *File, InputEvent *Event) {
+ LLVM_DEBUG(dbgs() << "addDefinedEvent:" << Name << "\n");
+
+ Symbol *S;
+ bool WasInserted;
+ std::tie(S, WasInserted) = insert(Name, File);
+
+ if (WasInserted || S->isLazy()) {
+ replaceSymbol<DefinedEvent>(S, Name, Flags, File, Event);
+ return S;
+ }
+
+ checkEventType(S, File, &Event->getType(), &Event->Signature);
+
+ if (shouldReplace(S, File, Flags))
+ replaceSymbol<DefinedEvent>(S, Name, Flags, File, Event);
+ return S;
+}
+
Symbol *SymbolTable::addUndefinedFunction(StringRef Name, uint32_t Flags,
InputFile *File,
const WasmSignature *Sig) {
OpenPOWER on IntegriCloud