[vmkit-commits] [vmkit] r77594 - in /vmkit/trunk: include/mvm/JIT.h lib/JnJVM/Compiler/JITInfo.cpp lib/JnJVM/Compiler/JavaJITCompiler.cpp lib/JnJVM/Compiler/JnjvmModule.cpp lib/Mvm/Compiler/JIT.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Thu Jul 30 05:57:54 PDT 2009
Author: geoffray
Date: Thu Jul 30 07:57:45 2009
New Revision: 77594
URL: http://llvm.org/viewvc/llvm-project?rev=77594&view=rev
Log:
Avoid recursively locking the JIT lock.
Modified:
vmkit/trunk/include/mvm/JIT.h
vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp
vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp
vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp
vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
Modified: vmkit/trunk/include/mvm/JIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/JIT.h?rev=77594&r1=77593&r2=77594&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/JIT.h (original)
+++ vmkit/trunk/include/mvm/JIT.h Thu Jul 30 07:57:45 2009
@@ -183,7 +183,7 @@
static int disassemble(unsigned int* addr);
- static void protectIR();
+ static bool protectIR();
static void unprotectIR();
static void copyDefinitions(llvm::Module* Dst, llvm::Module* Src);
Modified: vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp?rev=77594&r1=77593&r2=77594&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp Thu Jul 30 07:57:45 2009
@@ -214,7 +214,7 @@
const llvm::FunctionType* LLVMSignatureInfo::getVirtualType() {
if (!virtualType) {
// Lock here because we are called by arbitrary code
- mvm::MvmModule::protectIR();
+ bool un = mvm::MvmModule::protectIR();
std::vector<const llvm::Type*> llvmArgs;
uint32 size = signature->nbArguments;
Typedef* const* arguments = signature->getArgumentsType();
@@ -234,7 +234,7 @@
LLVMAssessorInfo& LAI =
JavaLLVMCompiler::getTypedefInfo(signature->getReturnType());
virtualType = FunctionType::get(LAI.llvmType, llvmArgs, false);
- mvm::MvmModule::unprotectIR();
+ if (un) mvm::MvmModule::unprotectIR();
}
return virtualType;
}
@@ -242,7 +242,7 @@
const llvm::FunctionType* LLVMSignatureInfo::getStaticType() {
if (!staticType) {
// Lock here because we are called by arbitrary code
- mvm::MvmModule::protectIR();
+ bool un = mvm::MvmModule::protectIR();
std::vector<const llvm::Type*> llvmArgs;
uint32 size = signature->nbArguments;
Typedef* const* arguments = signature->getArgumentsType();
@@ -260,7 +260,7 @@
LLVMAssessorInfo& LAI =
JavaLLVMCompiler::getTypedefInfo(signature->getReturnType());
staticType = FunctionType::get(LAI.llvmType, llvmArgs, false);
- mvm::MvmModule::unprotectIR();
+ if (un) mvm::MvmModule::unprotectIR();
}
return staticType;
}
@@ -268,7 +268,7 @@
const llvm::FunctionType* LLVMSignatureInfo::getNativeType() {
if (!nativeType) {
// Lock here because we are called by arbitrary code
- mvm::MvmModule::protectIR();
+ bool un = mvm::MvmModule::protectIR();
std::vector<const llvm::Type*> llvmArgs;
uint32 size = signature->nbArguments;
Typedef* const* arguments = signature->getArgumentsType();
@@ -298,7 +298,7 @@
const llvm::Type* RetType = LAI.llvmType == JnjvmModule::JavaObjectType ?
LAI.llvmTypePtr : LAI.llvmType;
nativeType = FunctionType::get(RetType, llvmArgs, false);
- mvm::MvmModule::unprotectIR();
+ if (un) mvm::MvmModule::unprotectIR();
}
return nativeType;
}
@@ -447,7 +447,7 @@
const FunctionType* LLVMSignatureInfo::getVirtualBufType() {
if (!virtualBufType) {
// Lock here because we are called by arbitrary code
- mvm::MvmModule::protectIR();
+ bool un = mvm::MvmModule::protectIR();
std::vector<const llvm::Type*> Args2;
Args2.push_back(JnjvmModule::ConstantPoolType); // ctp
Args2.push_back(getVirtualPtrType());
@@ -456,7 +456,7 @@
LLVMAssessorInfo& LAI =
JavaLLVMCompiler::getTypedefInfo(signature->getReturnType());
virtualBufType = FunctionType::get(LAI.llvmType, Args2, false);
- mvm::MvmModule::unprotectIR();
+ if (un) mvm::MvmModule::unprotectIR();
}
return virtualBufType;
}
@@ -464,7 +464,7 @@
const FunctionType* LLVMSignatureInfo::getStaticBufType() {
if (!staticBufType) {
// Lock here because we are called by arbitrary code
- mvm::MvmModule::protectIR();
+ bool un = mvm::MvmModule::protectIR();
std::vector<const llvm::Type*> Args;
Args.push_back(JnjvmModule::ConstantPoolType); // ctp
Args.push_back(getStaticPtrType());
@@ -472,7 +472,7 @@
LLVMAssessorInfo& LAI =
JavaLLVMCompiler::getTypedefInfo(signature->getReturnType());
staticBufType = FunctionType::get(LAI.llvmType, Args, false);
- mvm::MvmModule::unprotectIR();
+ if (un) mvm::MvmModule::unprotectIR();
}
return staticBufType;
}
@@ -480,7 +480,7 @@
Function* LLVMSignatureInfo::getVirtualBuf() {
// Lock here because we are called by arbitrary code. Also put that here
// because we are waiting on virtualBufFunction to have an address.
- mvm::MvmModule::protectIR();
+ bool un = mvm::MvmModule::protectIR();
if (!virtualBufFunction) {
virtualBufFunction = createFunctionCallBuf(true);
if (!signature->initialLoader->getCompiler()->isStaticCompiling()) {
@@ -490,14 +490,14 @@
virtualBufFunction->deleteBody();
}
}
- mvm::MvmModule::unprotectIR();
+ if (un) mvm::MvmModule::unprotectIR();
return virtualBufFunction;
}
Function* LLVMSignatureInfo::getVirtualAP() {
// Lock here because we are called by arbitrary code. Also put that here
// because we are waiting on virtualAPFunction to have an address.
- mvm::MvmModule::protectIR();
+ bool un = mvm::MvmModule::protectIR();
if (!virtualAPFunction) {
virtualAPFunction = createFunctionCallAP(true);
if (!signature->initialLoader->getCompiler()->isStaticCompiling()) {
@@ -507,14 +507,14 @@
virtualAPFunction->deleteBody();
}
}
- mvm::MvmModule::unprotectIR();
+ if (un) mvm::MvmModule::unprotectIR();
return virtualAPFunction;
}
Function* LLVMSignatureInfo::getStaticBuf() {
// Lock here because we are called by arbitrary code. Also put that here
// because we are waiting on staticBufFunction to have an address.
- mvm::MvmModule::protectIR();
+ bool un = mvm::MvmModule::protectIR();
if (!staticBufFunction) {
staticBufFunction = createFunctionCallBuf(false);
if (!signature->initialLoader->getCompiler()->isStaticCompiling()) {
@@ -524,14 +524,14 @@
staticBufFunction->deleteBody();
}
}
- mvm::MvmModule::unprotectIR();
+ if (un) mvm::MvmModule::unprotectIR();
return staticBufFunction;
}
Function* LLVMSignatureInfo::getStaticAP() {
// Lock here because we are called by arbitrary code. Also put that here
// because we are waiting on staticAPFunction to have an address.
- mvm::MvmModule::protectIR();
+ bool un = mvm::MvmModule::protectIR();
if (!staticAPFunction) {
staticAPFunction = createFunctionCallAP(false);
if (!signature->initialLoader->getCompiler()->isStaticCompiling()) {
@@ -541,7 +541,7 @@
staticAPFunction->deleteBody();
}
}
- mvm::MvmModule::unprotectIR();
+ if (un) mvm::MvmModule::unprotectIR();
return staticAPFunction;
}
Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp?rev=77594&r1=77593&r2=77594&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp Thu Jul 30 07:57:45 2009
@@ -209,10 +209,10 @@
void* JavaJITCompiler::materializeFunction(JavaMethod* meth) {
Function* func = parseFunction(meth);
- mvm::MvmModule::protectIR();
+ bool un = mvm::MvmModule::protectIR();
void* res = mvm::MvmModule::executionEngine->getPointerToGlobal(func);
func->deleteBody();
- mvm::MvmModule::unprotectIR();
+ if (un) mvm::MvmModule::unprotectIR();
return res;
}
Modified: vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp?rev=77594&r1=77593&r2=77594&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp Thu Jul 30 07:57:45 2009
@@ -72,18 +72,18 @@
void JavaLLVMCompiler::resolveVirtualClass(Class* cl) {
// Lock here because we may be called by a class resolver
- mvm::MvmModule::protectIR();
+ bool un = mvm::MvmModule::protectIR();
LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl);
LCI->getVirtualType();
- mvm::MvmModule::unprotectIR();
+ if (un) mvm::MvmModule::unprotectIR();
}
void JavaLLVMCompiler::resolveStaticClass(Class* cl) {
// Lock here because we may be called by a class initializer
- mvm::MvmModule::protectIR();
+ bool un = mvm::MvmModule::protectIR();
LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl);
LCI->getStaticType();
- mvm::MvmModule::unprotectIR();
+ if (un) mvm::MvmModule::unprotectIR();
}
@@ -332,7 +332,7 @@
Function* func = LMI->getMethod();
if (func->hasNotBeenReadFromBitcode()) {
// We are jitting. Take the lock.
- JnjvmModule::protectIR();
+ bool un = JnjvmModule::protectIR();
if (func->hasNotBeenReadFromBitcode()) {
JavaJIT jit(this, meth, func);
if (isNative(meth->access)) {
@@ -344,7 +344,7 @@
JnjvmModule::runPasses(func, JavaFunctionPasses);
}
}
- JnjvmModule::unprotectIR();
+ if (un) JnjvmModule::unprotectIR();
}
return func;
}
Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=77594&r1=77593&r2=77594&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Thu Jul 30 07:57:45 2009
@@ -307,14 +307,19 @@
// We protect the creation of IR with the executionEngine lock because
// codegen'ing a function may also create IR objects.
-void MvmModule::protectIR() {
+bool MvmModule::protectIR() {
if (executionEngine) {
mvm::Thread* th = mvm::Thread::get();
+
+ // If we already own the lock, don't lock it again.
+ if (th->isMvmThread() && th->releaseJIT) return false;
+
th->enterUncooperativeCode();
executionEngine->lock.acquire();
th->leaveUncooperativeCode();
if (th->isMvmThread()) th->releaseJIT = releaseJIT;
}
+ return true;
}
void MvmModule::unprotectIR() {
More information about the vmkit-commits
mailing list