mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 16:24:23 +00:00
Fix the cleanup process of exception information in JIT. Now JIT
deregisters registered by it FDE structures allowing consecutive JIT runs to succeed. Patch by Yuri. Fixes PR8285. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117004 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -126,10 +126,12 @@ protected:
|
|||||||
/// pointer is invoked to create it. If this returns null, the JIT will abort.
|
/// pointer is invoked to create it. If this returns null, the JIT will abort.
|
||||||
void* (*LazyFunctionCreator)(const std::string &);
|
void* (*LazyFunctionCreator)(const std::string &);
|
||||||
|
|
||||||
/// ExceptionTableRegister - If Exception Handling is set, the JIT will
|
/// ExceptionTableRegister - If Exception Handling is set, the JIT will
|
||||||
/// register dwarf tables with this function
|
/// register dwarf tables with this function.
|
||||||
typedef void (*EERegisterFn)(void*);
|
typedef void (*EERegisterFn)(void*);
|
||||||
static EERegisterFn ExceptionTableRegister;
|
EERegisterFn ExceptionTableRegister;
|
||||||
|
EERegisterFn ExceptionTableDeregister;
|
||||||
|
std::vector<void*> AllExceptionTables;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// lock - This lock is protects the ExecutionEngine, JIT, JITResolver and
|
/// lock - This lock is protects the ExecutionEngine, JIT, JITResolver and
|
||||||
@ -373,17 +375,26 @@ public:
|
|||||||
|
|
||||||
/// InstallExceptionTableRegister - The JIT will use the given function
|
/// InstallExceptionTableRegister - The JIT will use the given function
|
||||||
/// to register the exception tables it generates.
|
/// to register the exception tables it generates.
|
||||||
static void InstallExceptionTableRegister(void (*F)(void*)) {
|
void InstallExceptionTableRegister(EERegisterFn F) {
|
||||||
ExceptionTableRegister = F;
|
ExceptionTableRegister = F;
|
||||||
}
|
}
|
||||||
|
void InstallExceptionTableDeregister(EERegisterFn F) {
|
||||||
|
ExceptionTableDeregister = F;
|
||||||
|
}
|
||||||
|
|
||||||
/// RegisterTable - Registers the given pointer as an exception table. It uses
|
/// RegisterTable - Registers the given pointer as an exception table. It uses
|
||||||
/// the ExceptionTableRegister function.
|
/// the ExceptionTableRegister function.
|
||||||
static void RegisterTable(void* res) {
|
void RegisterTable(void* res) {
|
||||||
if (ExceptionTableRegister)
|
if (ExceptionTableRegister) {
|
||||||
ExceptionTableRegister(res);
|
ExceptionTableRegister(res);
|
||||||
|
AllExceptionTables.push_back(res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// DeregisterAllTables - Deregisters all previously registered pointers to an
|
||||||
|
/// exception tables. It uses the ExceptionTableoDeregister function.
|
||||||
|
void DeregisterAllTables();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit ExecutionEngine(Module *M);
|
explicit ExecutionEngine(Module *M);
|
||||||
|
|
||||||
|
@ -47,12 +47,12 @@ ExecutionEngine *(*ExecutionEngine::JITCtor)(
|
|||||||
const SmallVectorImpl<std::string>& MAttrs) = 0;
|
const SmallVectorImpl<std::string>& MAttrs) = 0;
|
||||||
ExecutionEngine *(*ExecutionEngine::InterpCtor)(Module *M,
|
ExecutionEngine *(*ExecutionEngine::InterpCtor)(Module *M,
|
||||||
std::string *ErrorStr) = 0;
|
std::string *ErrorStr) = 0;
|
||||||
ExecutionEngine::EERegisterFn ExecutionEngine::ExceptionTableRegister = 0;
|
|
||||||
|
|
||||||
|
|
||||||
ExecutionEngine::ExecutionEngine(Module *M)
|
ExecutionEngine::ExecutionEngine(Module *M)
|
||||||
: EEState(*this),
|
: EEState(*this),
|
||||||
LazyFunctionCreator(0) {
|
LazyFunctionCreator(0),
|
||||||
|
ExceptionTableRegister(0),
|
||||||
|
ExceptionTableDeregister(0) {
|
||||||
CompilingLazily = false;
|
CompilingLazily = false;
|
||||||
GVCompilationDisabled = false;
|
GVCompilationDisabled = false;
|
||||||
SymbolSearchingDisabled = false;
|
SymbolSearchingDisabled = false;
|
||||||
@ -66,6 +66,16 @@ ExecutionEngine::~ExecutionEngine() {
|
|||||||
delete Modules[i];
|
delete Modules[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExecutionEngine::DeregisterAllTables() {
|
||||||
|
if (ExceptionTableDeregister) {
|
||||||
|
std::vector<void*>::iterator it = AllExceptionTables.begin();
|
||||||
|
std::vector<void*>::iterator ite = AllExceptionTables.end();
|
||||||
|
for (; it != ite; ++it)
|
||||||
|
ExceptionTableDeregister(*it);
|
||||||
|
AllExceptionTables.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// This class automatically deletes the memory block when the GlobalVariable is
|
// This class automatically deletes the memory block when the GlobalVariable is
|
||||||
// destroyed.
|
// destroyed.
|
||||||
|
@ -87,6 +87,7 @@ extern "C" void LLVMLinkInJIT() {
|
|||||||
// values of an opaque key, used by libgcc to find dwarf tables.
|
// values of an opaque key, used by libgcc to find dwarf tables.
|
||||||
|
|
||||||
extern "C" void __register_frame(void*);
|
extern "C" void __register_frame(void*);
|
||||||
|
extern "C" void __deregister_frame(void*);
|
||||||
|
|
||||||
#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED <= 1050
|
#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED <= 1050
|
||||||
# define USE_KEYMGR 1
|
# define USE_KEYMGR 1
|
||||||
@ -318,8 +319,10 @@ JIT::JIT(Module *M, TargetMachine &tm, TargetJITInfo &tji,
|
|||||||
LOI = (LibgccObjectInfo*)calloc(sizeof(struct LibgccObjectInfo), 1);
|
LOI = (LibgccObjectInfo*)calloc(sizeof(struct LibgccObjectInfo), 1);
|
||||||
_keymgr_set_and_unlock_processwide_ptr(KEYMGR_GCC3_DW2_OBJ_LIST, LOI);
|
_keymgr_set_and_unlock_processwide_ptr(KEYMGR_GCC3_DW2_OBJ_LIST, LOI);
|
||||||
InstallExceptionTableRegister(DarwinRegisterFrame);
|
InstallExceptionTableRegister(DarwinRegisterFrame);
|
||||||
|
// Not sure about how to deregister on Darwin.
|
||||||
#else
|
#else
|
||||||
InstallExceptionTableRegister(__register_frame);
|
InstallExceptionTableRegister(__register_frame);
|
||||||
|
InstallExceptionTableDeregister(__deregister_frame);
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
#endif // __GNUC__
|
#endif // __GNUC__
|
||||||
|
|
||||||
@ -328,6 +331,9 @@ JIT::JIT(Module *M, TargetMachine &tm, TargetJITInfo &tji,
|
|||||||
}
|
}
|
||||||
|
|
||||||
JIT::~JIT() {
|
JIT::~JIT() {
|
||||||
|
// Unregister all exception tables registered by this JIT.
|
||||||
|
DeregisterAllTables();
|
||||||
|
// Cleanup.
|
||||||
AllJits->Remove(this);
|
AllJits->Remove(this);
|
||||||
delete jitstate;
|
delete jitstate;
|
||||||
delete JCE;
|
delete JCE;
|
||||||
|
Reference in New Issue
Block a user