[vmkit-commits] [vmkit] r61606 - in /vmkit/trunk/lib/JnJVM/VMCore: Jnjvm.cpp JnjvmModule.cpp JnjvmModule.h LowerConstantCalls.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sat Jan 3 04:53:19 PST 2009
Author: geoffray
Date: Sat Jan 3 06:53:19 2009
New Revision: 61606
URL: http://llvm.org/viewvc/llvm-project?rev=61606&view=rev
Log:
We don't need to set a class as being constant, we are already
getting the constant values when compiling. This enables static
initialization and java.lang.Class objects to be checked directly
on the class object.
Modified:
vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h
vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp
Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp?rev=61606&r1=61605&r2=61606&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Sat Jan 3 06:53:19 2009
@@ -1098,9 +1098,7 @@
// Use the owner class field of the class so that we know if the class
// belongs to the list of classes that we are static compiling.
cl->setOwnerClass(JavaThread::get());
- llvm::Value* LCL = cl->classLoader->getModule()->getNativeClass(cl);
- if (cl->needsInitialisationCheck())
- cl->classLoader->getModule()->getInitializationState(LCL);
+ cl->classLoader->getModule()->getNativeClass(cl);
for (uint32 i = 0; i < cl->nbVirtualMethods; ++i) {
JavaMethod& meth = cl->virtualMethods[i];
Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp?rev=61606&r1=61605&r2=61606&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp Sat Jan 3 06:53:19 2009
@@ -110,7 +110,7 @@
}
GlobalVariable* varGV =
- new GlobalVariable(Ty, true, GlobalValue::ExternalLinkage, 0,
+ new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage, 0,
classDef->printString(), this);
nativeClasses.insert(std::make_pair(classDef, varGV));
@@ -142,28 +142,6 @@
return ConstantExpr::getIntToPtr(CI, Ty);
}
}
-GlobalVariable* JnjvmModule::getInitializationState(Value* value) {
-
- initialization_iterator End = initializationStates.end();
- initialization_iterator I = initializationStates.find(value);
- if (I == End) {
- const char* clName = value->getName().c_str();
- char* newName = (char*)alloca(strlen(clName) + 9);
- sprintf(newName, "%s<clinit>", clName);
- GlobalVariable* varGV = new GlobalVariable(Type::Int1Ty, false,
- GlobalValue::ExternalLinkage,
- 0, newName, this);
-
- initializationStates.insert(std::make_pair(value, varGV));
-
- varGV->setInitializer(ConstantInt::getFalse());
-
- return varGV;
-
- } else {
- return I->second;
- }
-}
Constant* JnjvmModule::getConstantPool(JavaConstantPool* ctp) {
if (staticCompilation) {
Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h?rev=61606&r1=61605&r2=61606&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h Sat Jan 3 06:53:19 2009
@@ -190,11 +190,7 @@
std::map<const Enveloppe*, llvm::Constant*> enveloppes;
std::map<const JavaMethod*, llvm::Constant*> nativeFunctions;
std::map<const UTF8*, llvm::Constant*> utf8s;
- std::map<llvm::Value*, llvm::GlobalVariable*> initializationStates;
- typedef std::map<llvm::Value*, llvm::GlobalVariable*>::iterator
- initialization_iterator;
-
typedef std::map<const CommonClass*, llvm::Constant*>::iterator
native_class_iterator;
@@ -408,7 +404,6 @@
llvm::Constant* getString(JavaString* str);
llvm::Constant* getConstantPool(JavaConstantPool* ctp);
llvm::Constant* getNativeFunction(JavaMethod* meth, void* natPtr);
- llvm::GlobalVariable* getInitializationState(llvm::Value* Cl);
llvm::Constant* getReferenceArrayVT();
llvm::Constant* getPrimitiveArrayVT();
Modified: vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp?rev=61606&r1=61605&r2=61606&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp Sat Jan 3 06:53:19 2009
@@ -269,25 +269,18 @@
NBB = Invoke->getNormalDest();
}
- Value* StatusPtr = 0;
- Value* test = 0;
Value* Cl = Call.getArgument(0);
- if (module->isStaticCompiling()) {
- StatusPtr = module->getInitializationState(Cl);
- test = new LoadInst(StatusPtr, "", CI);
- } else {
- Value* TCM = getTCM(module, Call.getArgument(0), CI);
- Value* GEP[2] = { module->constantZero,
- module->OffsetStatusInTaskClassMirrorConstant };
- StatusPtr = GetElementPtrInst::Create(TCM, GEP, GEP + 2, "", CI);
-
- Value* Status = new LoadInst(StatusPtr, "", CI);
- test = new ICmpInst(ICmpInst::ICMP_EQ, Status,
- jnjvm::JnjvmModule::ClassReadyConstant,
- "", CI);
- }
+ Value* TCM = getTCM(module, Call.getArgument(0), CI);
+ Value* GEP[2] = { module->constantZero,
+ module->OffsetStatusInTaskClassMirrorConstant };
+ Value* StatusPtr = GetElementPtrInst::Create(TCM, GEP, GEP + 2, "",
+ CI);
+
+ Value* Status = new LoadInst(StatusPtr, "", CI);
+ Value* test = new ICmpInst(ICmpInst::ICMP_EQ, Status,
+ module->ClassReadyConstant,
+ "", CI);
-
BasicBlock* trueCl = BasicBlock::Create("Initialized", &F);
BasicBlock* falseCl = BasicBlock::Create("Uninitialized", &F);
PHINode* node = llvm::PHINode::Create(JnjvmModule::JavaClassType, "", trueCl);
@@ -300,15 +293,8 @@
Value* Args[1] = { Cl };
BasicBlock* UI = Invoke->getUnwindDest();
- BasicBlock* normalDest = 0;
- if (module->isStaticCompiling()) {
- normalDest = BasicBlock::Create("Static Initialized", &F);
- } else {
- normalDest = trueCl;
- }
-
res = InvokeInst::Create(module->InitialiseClassFunction,
- normalDest, UI, Args, Args + 1,
+ trueCl, UI, Args, Args + 1,
"", falseCl);
// For some reason, an LLVM pass may add PHI nodes to the
@@ -331,17 +317,9 @@
Temp++;
}
- if (module->isStaticCompiling()) {
- new StoreInst(ConstantInt::getTrue(), StatusPtr, normalDest);
- BranchInst::Create(trueCl, normalDest);
- falseCl = normalDest;
- }
-
} else {
res = CallInst::Create(module->InitialiseClassFunction,
Cl, "", falseCl);
- if (module->isStaticCompiling())
- new StoreInst(ConstantInt::getTrue(), StatusPtr, falseCl);
BranchInst::Create(trueCl, falseCl);
}
More information about the vmkit-commits
mailing list