[vmkit-commits] [vmkit] r59144 - in /vmkit/trunk/lib/JnJVM: LLVMRuntime/runtime-default.ll VMCore/JavaJIT.cpp VMCore/JnjvmModule.cpp VMCore/JnjvmModule.h VMCore/JnjvmModuleProvider.cpp VMCore/JnjvmModuleProvider.h VMCore/LowerConstantCalls.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Wed Nov 12 08:55:15 PST 2008
Author: geoffray
Date: Wed Nov 12 10:55:14 2008
New Revision: 59144
URL: http://llvm.org/viewvc/llvm-project?rev=59144&view=rev
Log:
Getting the static instance of a class is now made through
a VMKit intrinsic which is lowered during LowerConstantCalls pass.
Modified:
vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll
vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h
vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp
vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.h
vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp
Modified: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll?rev=59144&r1=59143&r2=59144&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll (original)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll Wed Nov 12 10:55:14 2008
@@ -81,6 +81,9 @@
;;; getDepth - Get the depth of the class.
declare i32 @getDepth(%JavaClass*) readnone
+;;; getStaticInstance - Get the static instance of this class.
+declare %JavaObject* @getStaticInstance(%JavaClass*) readnone
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;; Generic Runtime methods ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=59144&r1=59143&r2=59144&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Wed Nov 12 10:55:14 2008
@@ -436,24 +436,12 @@
if (isVirtual(compilingMethod->access)) {
obj = llvmFunction->arg_begin();
} else {
-#ifndef ISOLATE_SHARING
- obj = module->getStaticInstance(compilingClass);
- obj = new LoadInst(obj, "", currentBlock);
-#else
- obj = getStaticInstanceCtp();
-#endif
+ Value* cl = module->getNativeClass(compilingClass);
+ cl = new LoadInst(cl, "", currentBlock);
+ obj = CallInst::Create(module->GetStaticInstanceFunction, cl, "",
+ currentBlock);
}
-#ifndef SERVICE_VM
monitorEnter(obj);
-#else
- if (ServiceDomain::isLockableDomain(compilingClass->isolate)) {
- llvm::CallInst::Create(module->AquireObjectInSharedDomainFunction,
- obj, "", currentBlock);
- } else {
- llvm::CallInst::Create(module->AquireObjectFunction,
- obj, "", currentBlock);
- }
-#endif
}
void JavaJIT::endSynchronize() {
@@ -461,24 +449,12 @@
if (isVirtual(compilingMethod->access)) {
obj = llvmFunction->arg_begin();
} else {
-#ifndef ISOLATE_SHARING
- obj = module->getStaticInstance(compilingClass);
- obj = new LoadInst(obj, "", currentBlock);
-#else
- obj = getStaticInstanceCtp();
-#endif
+ Value* cl = module->getNativeClass(compilingClass);
+ cl = new LoadInst(cl, "", currentBlock);
+ obj = CallInst::Create(module->GetStaticInstanceFunction, cl, "",
+ currentBlock);
}
-#ifndef SERVICE_VM
monitorExit(obj);
-#else
- if (ServiceDomain::isLockableDomain(compilingClass->isolate)) {
- llvm::CallInst::Create(module->ReleaseObjectInSharedDomainFunction,
- argsSync.begin(), argsSync.end(), "", currentBlock);
- } else {
- llvm::CallInst::Create(module->ReleaseObjectFunction, argsSync.begin(),
- argsSync.end(), "", currentBlock);
- }
-#endif
}
@@ -917,16 +893,14 @@
if (isVirtual(compilingMethod->access)) {
argsSync.push_back(llvmFunction->arg_begin());
} else {
-#ifndef ISOLATE_SHARING
- Value* arg = module->getStaticInstance(compilingClass);
- arg = new LoadInst(arg, "", currentBlock);
-#else
- Value* arg = getStaticInstanceCtp();
-#endif
+ Value* cl = module->getNativeClass(compilingClass);
+ cl = new LoadInst(cl, "", currentBlock);
+ Value* arg = CallInst::Create(module->GetStaticInstanceFunction, cl, "",
+ currentBlock);
argsSync.push_back(arg);
}
- llvm::CallInst::Create(module->ReleaseObjectFunction, argsSync.begin(), argsSync.end(),
- "", synchronizeExceptionBlock);
+ llvm::CallInst::Create(module->ReleaseObjectFunction, argsSync.begin(),
+ argsSync.end(), "", synchronizeExceptionBlock);
llvm::BranchInst::Create(endExceptionBlock, synchronizeExceptionBlock);
@@ -1818,15 +1792,17 @@
currentBlock);
CallInst::Create(module->ForceInitialisationCheckFunction, Cl, "",
currentBlock);
- object = module->getStaticInstance(field->classDef);
- object = new LoadInst(object, "", currentBlock);
+ object = CallInst::Create(module->GetStaticInstanceFunction, Cl, "",
+ currentBlock);
type = LCI->getStaticType();
return fieldGetter(this, type, object, LFI->getOffset());
}
if (field->classDef->isReady()) {
- object = module->getStaticInstance(field->classDef);
- object = new LoadInst(object, "", currentBlock);
+ Value* Cl = module->getNativeClass(field->classDef);
+ Cl = new LoadInst(Cl, "", currentBlock);
+ object = CallInst::Create(module->GetStaticInstanceFunction, Cl, "",
+ currentBlock);
type = LCI->getStaticType();
return fieldGetter(this, type, object, LFI->getOffset());
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp?rev=59144&r1=59143&r2=59144&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp Wed Nov 12 10:55:14 2008
@@ -1041,6 +1041,7 @@
ImplementsFunction = module->getFunction("implements");
InstantiationOfArrayFunction = module->getFunction("instantiationOfArray");
GetDepthFunction = module->getFunction("getDepth");
+ GetStaticInstanceFunction = module->getFunction("getStaticInstance");
GetDisplayFunction = module->getFunction("getDisplay");
GetClassInDisplayFunction = module->getFunction("getClassInDisplay");
AquireObjectFunction = module->getFunction("JavaObjectAquire");
Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h?rev=59144&r1=59143&r2=59144&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h Wed Nov 12 10:55:14 2008
@@ -283,6 +283,7 @@
llvm::Function* InstantiationOfArrayFunction;
llvm::Function* GetDepthFunction;
llvm::Function* GetClassInDisplayFunction;
+ llvm::Function* GetStaticInstanceFunction;
llvm::Function* GetDisplayFunction;
llvm::Function* AquireObjectFunction;
llvm::Function* ReleaseObjectFunction;
Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp?rev=59144&r1=59143&r2=59144&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp Wed Nov 12 10:55:14 2008
@@ -132,6 +132,7 @@
JavaJIT jit(meth, func);
if (isNative(meth->access)) {
jit.nativeCompile();
+ mvm::MvmModule::runPasses(func, perNativeFunctionPasses);
} else {
jit.javaCompile();
mvm::MvmModule::runPasses(func, perFunctionPasses);
@@ -253,6 +254,11 @@
perFunctionPasses = new llvm::FunctionPassManager(this);
perFunctionPasses->add(new llvm::TargetData(m));
AddStandardCompilePasses(m, perFunctionPasses);
+
+ perNativeFunctionPasses = new llvm::FunctionPassManager(this);
+ perNativeFunctionPasses->add(new llvm::TargetData(m));
+ addPass(perNativeFunctionPasses, createInstructionCombiningPass()); // Cleanup for scalarrepl.
+ addPass(perNativeFunctionPasses, mvm::createLowerConstantCallsPass());
}
JnjvmModuleProvider::~JnjvmModuleProvider() {
@@ -260,4 +266,6 @@
mvm::MvmModule::executionEngine->removeModuleProvider(this);
mvm::MvmModule::protectEngine.unlock();
delete TheModule;
+ delete perFunctionPasses;
+ delete perNativeFunctionPasses;
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.h?rev=59144&r1=59143&r2=59144&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.h Wed Nov 12 10:55:14 2008
@@ -43,6 +43,7 @@
reverse_callback_iterator;
llvm::FunctionPassManager* perFunctionPasses;
+ llvm::FunctionPassManager* perNativeFunctionPasses;
public:
Modified: vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp?rev=59144&r1=59143&r2=59144&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp Wed Nov 12 10:55:14 2008
@@ -227,6 +227,20 @@
BranchInst::Create(NBB, ifTrue);
break;
}
+ } else if (V == module->GetStaticInstanceFunction) {
+ Changed = true;
+#if !defined(ISOLATE) && !defined(ISOLATE_SHARING)
+ ConstantExpr* CE = dyn_cast<ConstantExpr>(Call.getArgument(0));
+ assert(CE && "Wrong use of GetStaticInstanceFunction");
+ ConstantInt* C = (ConstantInt*)CE->getOperand(0);
+ Class* cl = (Class*)C->getZExtValue();
+
+ Value* Replace = module->getStaticInstance(cl);
+ Replace = new LoadInst(Replace, "", CI);
+ CI->replaceAllUsesWith(Replace);
+ CI->eraseFromParent();
+#endif
+
} else if (V == module->InitialisationCheckFunction) {
Changed = true;
#ifdef ISOLATE
More information about the vmkit-commits
mailing list