void removeModule(ModuleHandleT H) { LazyEmitLayer.removeModuleSet(H); }
JITSymbol findSymbol(const std::string &Name) {
- return LazyEmitLayer.findSymbol(Name, false);
+ return LazyEmitLayer.findSymbol(Name, true);
}
JITSymbol findSymbolIn(ModuleHandleT H, const std::string &Name) {
- return LazyEmitLayer.findSymbolIn(H, Name, false);
+ return LazyEmitLayer.findSymbolIn(H, Name, true);
}
JITSymbol findUnmangledSymbol(const std::string &Name) {
makeStub(*F, *FunctionBodyPointer);
// Step 4) Add the module containing the stub to the JIT.
- auto StubH = addModule(C.takeM());
+ auto H = addModule(C.takeM());
// Step 5) Set the compile and update actions.
//
// The update action will update FunctionBodyPointer to point at the newly
// compiled function.
std::shared_ptr<FunctionAST> Fn = std::move(FnAST);
- CallbackInfo.setCompileAction([this, Fn, BodyPtrName, StubH]() {
+ CallbackInfo.setCompileAction([this, Fn]() {
auto H = addModule(IRGen(Session, *Fn));
- auto BodySym = findUnmangledSymbolIn(H, Fn->Proto->Name);
- auto BodyPtrSym = findUnmangledSymbolIn(StubH, BodyPtrName);
- assert(BodySym && "Missing function body.");
- assert(BodyPtrSym && "Missing function pointer.");
- auto BodyAddr = BodySym.getAddress();
- auto BodyPtr = reinterpret_cast<void*>(
- static_cast<uintptr_t>(BodyPtrSym.getAddress()));
- memcpy(BodyPtr, &BodyAddr, sizeof(uintptr_t));
- return BodyAddr;
+ return findUnmangledSymbolIn(H, Fn->Proto->Name).getAddress();
});
+ CallbackInfo.setUpdateAction(
+ getLocalFPUpdater(LazyEmitLayer, H, mangle(BodyPtrName)));
- return StubH;
+ return H;
}
SessionContext &Session;