[vmkit-commits] [vmkit] r61575 - in /vmkit/trunk/lib/JnJVM/VMCore: JnjvmModule.cpp JnjvmModule.h LowerConstantCalls.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Fri Jan 2 05:43:28 PST 2009
Author: geoffray
Date: Fri Jan 2 07:43:28 2009
New Revision: 61575
URL: http://llvm.org/viewvc/llvm-project?rev=61575&view=rev
Log:
Correct handling of initialization states when static compiling.
Modified:
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/JnjvmModule.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp?rev=61575&r1=61574&r2=61575&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp Fri Jan 2 07:43:28 2009
@@ -134,6 +134,26 @@
}
}
+GlobalVariable* JnjvmModule::getInitializationState(Value* value) {
+
+ initialization_iterator End = initializationStates.end();
+ initialization_iterator I = initializationStates.find(value);
+ if (I == End) {
+ GlobalVariable* varGV = new GlobalVariable(Type::Int1Ty, false,
+ GlobalValue::ExternalLinkage,
+ 0, "", 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) {
llvm::Constant* varGV = 0;
Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h?rev=61575&r1=61574&r2=61575&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h Fri Jan 2 07:43:28 2009
@@ -190,6 +190,10 @@
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;
@@ -404,6 +408,7 @@
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=61575&r1=61574&r2=61575&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp Fri Jan 2 07:43:28 2009
@@ -268,19 +268,25 @@
assert(Invoke && "Last instruction is not an invoke");
NBB = Invoke->getNormalDest();
}
-
+
+ Value* StatusPtr = 0;
+ Value* test = 0;
Value* Cl = Call.getArgument(0);
- 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,
- jnjvm::JnjvmModule::ClassReadyConstant,
- "", CI);
+ 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);
+ }
+
BasicBlock* trueCl = BasicBlock::Create("Initialized", &F);
BasicBlock* falseCl = BasicBlock::Create("Uninitialized", &F);
@@ -293,8 +299,16 @@
if (InvokeInst* Invoke = dyn_cast<InvokeInst>(CI)) {
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,
- trueCl, UI, Args, Args + 1,
+ normalDest, UI, Args, Args + 1,
"", falseCl);
// For some reason, an LLVM pass may add PHI nodes to the
@@ -316,9 +330,18 @@
PHI->addIncoming(Val, trueCl);
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