[vmkit-commits] [vmkit] r62606 - in /vmkit/trunk: include/mvm/JIT.h lib/JnJVM/VMCore/JnjvmModule.cpp lib/JnJVM/VMCore/JnjvmModuleProvider.cpp lib/Mvm/Runtime/JIT.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Tue Jan 20 12:02:45 PST 2009
Author: geoffray
Date: Tue Jan 20 14:02:44 2009
New Revision: 62606
URL: http://llvm.org/viewvc/llvm-project?rev=62606&view=rev
Log:
Forgot that JIT compiling in LLVM may play with IR. Use the JIT
lock for IR protection
Modified:
vmkit/trunk/include/mvm/JIT.h
vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp
vmkit/trunk/lib/Mvm/Runtime/JIT.cpp
Modified: vmkit/trunk/include/mvm/JIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/JIT.h?rev=62606&r1=62605&r2=62606&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/JIT.h (original)
+++ vmkit/trunk/include/mvm/JIT.h Tue Jan 20 14:02:44 2009
@@ -160,7 +160,6 @@
static llvm::ExecutionEngine* executionEngine;
static mvm::LockNormal protectEngine;
- static mvm::LockRecursive protectIR;
static llvm::Module *globalModule;
static llvm::ExistingModuleProvider *globalModuleProvider;
static llvm::FunctionPassManager* globalFunctionPasses;
@@ -172,6 +171,9 @@
llvm::TargetMachine* TheTarget = 0);
static int disassemble(unsigned int* addr);
+
+ static void protectIR();
+ static void unprotectIR();
};
Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp?rev=62606&r1=62605&r2=62606&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp Tue Jan 20 14:02:44 2009
@@ -1576,7 +1576,7 @@
const llvm::FunctionType* LLVMSignatureInfo::getVirtualType() {
if (!virtualType) {
// Lock here because we are called by arbitrary code
- mvm::MvmModule::protectIR.lock();
+ mvm::MvmModule::protectIR();
std::vector<const llvm::Type*> llvmArgs;
uint32 size = signature->nbArguments;
Typedef* const* arguments = signature->getArgumentsType();
@@ -1596,7 +1596,7 @@
LLVMAssessorInfo& LAI =
JnjvmModule::getTypedefInfo(signature->getReturnType());
virtualType = FunctionType::get(LAI.llvmType, llvmArgs, false);
- mvm::MvmModule::protectIR.unlock();
+ mvm::MvmModule::unprotectIR();
}
return virtualType;
}
@@ -1604,7 +1604,7 @@
const llvm::FunctionType* LLVMSignatureInfo::getStaticType() {
if (!staticType) {
// Lock here because we are called by arbitrary code
- mvm::MvmModule::protectIR.lock();
+ mvm::MvmModule::protectIR();
std::vector<const llvm::Type*> llvmArgs;
uint32 size = signature->nbArguments;
Typedef* const* arguments = signature->getArgumentsType();
@@ -1622,7 +1622,7 @@
LLVMAssessorInfo& LAI =
JnjvmModule::getTypedefInfo(signature->getReturnType());
staticType = FunctionType::get(LAI.llvmType, llvmArgs, false);
- mvm::MvmModule::protectIR.unlock();
+ mvm::MvmModule::unprotectIR();
}
return staticType;
}
@@ -1630,7 +1630,7 @@
const llvm::FunctionType* LLVMSignatureInfo::getNativeType() {
if (!nativeType) {
// Lock here because we are called by arbitrary code
- mvm::MvmModule::protectIR.lock();
+ mvm::MvmModule::protectIR();
std::vector<const llvm::Type*> llvmArgs;
uint32 size = signature->nbArguments;
Typedef* const* arguments = signature->getArgumentsType();
@@ -1651,7 +1651,7 @@
LLVMAssessorInfo& LAI =
JnjvmModule::getTypedefInfo(signature->getReturnType());
nativeType = FunctionType::get(LAI.llvmType, llvmArgs, false);
- mvm::MvmModule::protectIR.unlock();
+ mvm::MvmModule::unprotectIR();
}
return nativeType;
}
@@ -1793,7 +1793,7 @@
const FunctionType* LLVMSignatureInfo::getVirtualBufType() {
if (!virtualBufType) {
// Lock here because we are called by arbitrary code
- mvm::MvmModule::protectIR.lock();
+ mvm::MvmModule::protectIR();
std::vector<const llvm::Type*> Args2;
Args2.push_back(JnjvmModule::ConstantPoolType); // ctp
Args2.push_back(getVirtualPtrType());
@@ -1802,7 +1802,7 @@
LLVMAssessorInfo& LAI =
JnjvmModule::getTypedefInfo(signature->getReturnType());
virtualBufType = FunctionType::get(LAI.llvmType, Args2, false);
- mvm::MvmModule::protectIR.unlock();
+ mvm::MvmModule::unprotectIR();
}
return virtualBufType;
}
@@ -1810,7 +1810,7 @@
const FunctionType* LLVMSignatureInfo::getStaticBufType() {
if (!staticBufType) {
// Lock here because we are called by arbitrary code
- mvm::MvmModule::protectIR.lock();
+ mvm::MvmModule::protectIR();
std::vector<const llvm::Type*> Args;
Args.push_back(JnjvmModule::ConstantPoolType); // ctp
Args.push_back(getStaticPtrType());
@@ -1818,7 +1818,7 @@
LLVMAssessorInfo& LAI =
JnjvmModule::getTypedefInfo(signature->getReturnType());
staticBufType = FunctionType::get(LAI.llvmType, Args, false);
- mvm::MvmModule::protectIR.unlock();
+ mvm::MvmModule::unprotectIR();
}
return staticBufType;
}
@@ -1826,7 +1826,7 @@
Function* LLVMSignatureInfo::getVirtualBuf() {
if (!virtualBufFunction) {
// Lock here because we are called by arbitrary code
- mvm::MvmModule::protectIR.lock();
+ mvm::MvmModule::protectIR();
virtualBufFunction = createFunctionCallBuf(true);
if (!signature->initialLoader->getModule()->isStaticCompiling()) {
signature->setVirtualCallBuf((intptr_t)
@@ -1834,7 +1834,7 @@
// Now that it's compiled, we don't need the IR anymore
virtualBufFunction->deleteBody();
}
- mvm::MvmModule::protectIR.unlock();
+ mvm::MvmModule::unprotectIR();
}
return virtualBufFunction;
}
@@ -1842,7 +1842,7 @@
Function* LLVMSignatureInfo::getVirtualAP() {
if (!virtualAPFunction) {
// Lock here because we are called by arbitrary code
- mvm::MvmModule::protectIR.lock();
+ mvm::MvmModule::protectIR();
virtualAPFunction = createFunctionCallAP(true);
if (!signature->initialLoader->getModule()->isStaticCompiling()) {
signature->setVirtualCallAP((intptr_t)
@@ -1850,7 +1850,7 @@
// Now that it's compiled, we don't need the IR anymore
virtualAPFunction->deleteBody();
}
- mvm::MvmModule::protectIR.unlock();
+ mvm::MvmModule::unprotectIR();
}
return virtualAPFunction;
}
@@ -1858,7 +1858,7 @@
Function* LLVMSignatureInfo::getStaticBuf() {
if (!staticBufFunction) {
// Lock here because we are called by arbitrary code
- mvm::MvmModule::protectIR.lock();
+ mvm::MvmModule::protectIR();
staticBufFunction = createFunctionCallBuf(false);
if (!signature->initialLoader->getModule()->isStaticCompiling()) {
signature->setStaticCallBuf((intptr_t)
@@ -1866,7 +1866,7 @@
// Now that it's compiled, we don't need the IR anymore
staticBufFunction->deleteBody();
}
- mvm::MvmModule::protectIR.unlock();
+ mvm::MvmModule::unprotectIR();
}
return staticBufFunction;
}
@@ -1874,7 +1874,7 @@
Function* LLVMSignatureInfo::getStaticAP() {
if (!staticAPFunction) {
// Lock here because we are called by arbitrary code
- mvm::MvmModule::protectIR.lock();
+ mvm::MvmModule::protectIR();
staticAPFunction = createFunctionCallAP(false);
if (!signature->initialLoader->getModule()->isStaticCompiling()) {
signature->setStaticCallAP((intptr_t)
@@ -1882,25 +1882,25 @@
// Now that it's compiled, we don't need the IR anymore
staticAPFunction->deleteBody();
}
- mvm::MvmModule::protectIR.unlock();
+ mvm::MvmModule::unprotectIR();
}
return staticAPFunction;
}
void JnjvmModule::resolveVirtualClass(Class* cl) {
// Lock here because we may be called by a class resolver
- mvm::MvmModule::protectIR.lock();
+ mvm::MvmModule::protectIR();
LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl);
LCI->getVirtualType();
- mvm::MvmModule::protectIR.unlock();
+ mvm::MvmModule::unprotectIR();
}
void JnjvmModule::resolveStaticClass(Class* cl) {
// Lock here because we may be called by a class initializer
- mvm::MvmModule::protectIR.lock();
+ mvm::MvmModule::protectIR();
LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl);
LCI->getStaticType();
- mvm::MvmModule::protectIR.unlock();
+ mvm::MvmModule::unprotectIR();
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp?rev=62606&r1=62605&r2=62606&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp Tue Jan 20 14:02:44 2009
@@ -122,7 +122,7 @@
Function* func = LMI->getMethod();
if (func->hasNotBeenReadFromBitcode()) {
// We are jitting. Take the lock.
- M->protectIR.lock();
+ M->protectIR();
JavaJIT jit(meth, func);
if (isNative(meth->access)) {
jit.nativeCompile();
@@ -132,7 +132,7 @@
mvm::MvmModule::runPasses(func, M->globalFunctionPasses);
mvm::MvmModule::runPasses(func, JavaFunctionPasses);
}
- M->protectIR.unlock();
+ M->unprotectIR();
}
return func;
}
Modified: vmkit/trunk/lib/Mvm/Runtime/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/JIT.cpp?rev=62606&r1=62605&r2=62606&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Runtime/JIT.cpp Tue Jan 20 14:02:44 2009
@@ -245,7 +245,6 @@
llvm::FunctionPassManager* MvmModule::globalFunctionPasses;
llvm::ExecutionEngine* MvmModule::executionEngine;
mvm::LockNormal MvmModule::protectEngine;
-mvm::LockRecursive MvmModule::protectIR;
uint64 MvmModule::getTypeSize(const llvm::Type* type) {
@@ -315,3 +314,11 @@
addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs
}
+
+void MvmModule::protectIR() {
+ if (executionEngine) executionEngine->lock.acquire();
+}
+
+void MvmModule::unprotectIR() {
+ if (executionEngine) executionEngine->lock.release();
+}
More information about the vmkit-commits
mailing list