[vmkit-commits] [vmkit] r60223 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaJIT.cpp JavaJITOpcodes.cpp Jnjvm.cpp JnjvmClassLoader.cpp JnjvmModule.cpp JnjvmModule.h LowerConstantCalls.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Fri Nov 28 15:05:01 PST 2008
Author: geoffray
Date: Fri Nov 28 17:05:01 2008
New Revision: 60223
URL: http://llvm.org/viewvc/llvm-project?rev=60223&view=rev
Log:
Don't use global variables when not static compiling.
Modified:
vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp
vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.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/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=60223&r1=60222&r2=60223&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Fri Nov 28 17:05:01 2008
@@ -92,8 +92,7 @@
if (meth && !isAbstract(meth->access) && canBeInlined(meth)) {
Value* cl = CallInst::Create(module->GetClassFunction, args[0], "",
currentBlock);
- Value* cl2 = module->getNativeClass((Class*)cl);
- cl2 = new LoadInst(cl2, "", currentBlock);
+ Value* cl2 = module->getNativeClass((Class*)cl, currentBlock);
Value* test = new ICmpInst(ICmpInst::ICMP_EQ, cl, cl2, "", currentBlock);
@@ -241,8 +240,7 @@
val, "", currentBlock);
nativeArgs.push_back(res);
#else
- Value* cl = module->getJavaClass(compilingClass);
- cl= new LoadInst(cl, "", currentBlock);
+ Value* cl = module->getJavaClass(compilingClass, currentBlock);
nativeArgs.push_back(cl);
#endif
index = 2;
@@ -255,8 +253,8 @@
nativeArgs.push_back(i);
}
- Value* nativeFunc = module->getNativeFunction(compilingMethod, (void*)natPtr);
- nativeFunc = new LoadInst(nativeFunc, "", currentBlock);
+ Value* nativeFunc = module->getNativeFunction(compilingMethod, (void*)natPtr,
+ currentBlock);
Value* result = llvm::CallInst::Create(nativeFunc, nativeArgs.begin(),
nativeArgs.end(), "", currentBlock);
@@ -396,8 +394,7 @@
if (isVirtual(compilingMethod->access)) {
obj = llvmFunction->arg_begin();
} else {
- Value* cl = module->getJavaClass(compilingClass);
- obj = new LoadInst(cl, "", currentBlock);
+ obj = module->getJavaClass(compilingClass, currentBlock);
}
monitorEnter(obj);
}
@@ -407,8 +404,7 @@
if (isVirtual(compilingMethod->access)) {
obj = llvmFunction->arg_begin();
} else {
- Value* cl = module->getJavaClass(compilingClass);
- obj = new LoadInst(cl, "", currentBlock);
+ obj = module->getJavaClass(compilingClass, currentBlock);
}
monitorExit(obj);
}
@@ -835,8 +831,8 @@
if (isVirtual(compilingMethod->access)) {
argsSync = llvmFunction->arg_begin();
} else {
- Value* cl = module->getJavaClass(compilingClass);
- cl = new LoadInst(cl, "", currentBlock);
+ Value* cl = module->getJavaClass(compilingClass,
+ synchronizeExceptionBlock);
argsSync = cl;
}
llvm::CallInst::Create(module->ReleaseObjectFunction, argsSync, "",
@@ -997,8 +993,7 @@
isolateLocal, "", currentBlock);
#else
assert(cur->catchClass);
- cl = module->getNativeClass(cur->catchClass);
- cl = new LoadInst(cl, "", currentBlock);
+ cl = module->getNativeClass(cur->catchClass, currentBlock);
#endif
Value* cmp = CallInst::Create(module->CompareExceptionFunction, cl, "",
currentBlock);
@@ -1108,8 +1103,7 @@
const UTF8* utf8 = ctpInfo->UTF8At(ctpInfo->ctpDef[index]);
JavaString* str = compilingClass->classLoader->UTF8ToStr(utf8);
- Value* val = module->getString(str);
- val = new LoadInst(val, "", currentBlock);
+ Value* val = module->getString(str, currentBlock);
push(val, false);
#endif
@@ -1129,8 +1123,7 @@
#if !defined(ISOLATE)
if (ctpInfo->ctpRes[index]) {
CommonClass* cl = (CommonClass*)(ctpInfo->ctpRes[index]);
- Value* Val = module->getJavaClass(cl);
- Val = new LoadInst(Val, "", currentBlock);
+ Value* Val = module->getJavaClass(cl, currentBlock);
push(Val, false);
} else {
#endif
@@ -1606,10 +1599,8 @@
Cl = new LoadInst(Cl, "", currentBlock);
#else
JavaConstantPool* ctp = compilingClass->ctpInfo;
- Value* CTP = module->getConstantPool(ctp);
- CTP = new LoadInst(CTP, "", currentBlock);
- Value* Cl = module->getNativeClass(compilingClass);
- Cl = new LoadInst(Cl, "", currentBlock);
+ Value* CTP = module->getConstantPool(ctp, currentBlock);
+ Value* Cl = module->getNativeClass(compilingClass, currentBlock);
#endif
std::vector<Value*> Args;
@@ -1645,8 +1636,7 @@
CommonClass* cl = ctpInfo->getMethodClassIfLoaded(index);
Value* node = 0;
if (cl && (!cl->isClass() || cl->asClass()->isResolved())) {
- node = module->getNativeClass(cl);
- node = new LoadInst(node, "", currentBlock);
+ node = module->getNativeClass(cl, currentBlock);
if (node->getType() != module->JavaCommonClassType) {
node = new BitCastInst(node, module->JavaCommonClassType, "",
currentBlock);
@@ -1665,8 +1655,7 @@
Class* cl = (Class*)(ctpInfo->getMethodClassIfLoaded(index));
Value* node = 0;
if (cl && cl->isResolved()) {
- node = module->getNativeClass(cl);
- node = new LoadInst(node, "", currentBlock);
+ node = module->getNativeClass(cl, currentBlock);
} else {
node = getConstantPoolAt(index, module->ClassLookupFunction,
module->JavaCommonClassType, 0, doThrow);
@@ -1746,8 +1735,7 @@
const Type* type = 0;
if (stat) {
type = LCI->getStaticType();
- Value* Cl = module->getNativeClass(field->classDef);
- Cl = new LoadInst(Cl, "", currentBlock);
+ Value* Cl = module->getNativeClass(field->classDef, currentBlock);
if (needsInitialisationCheck(field->classDef, compilingClass)) {
Cl = invoke(module->InitialisationCheckFunction, Cl, "",
currentBlock);
@@ -1979,8 +1967,7 @@
if (!inlining)
enveloppe.initialise(compilingClass->ctpInfo, index);
- Value* llvmEnv = module->getEnveloppe(&enveloppe);
- llvmEnv = new LoadInst(llvmEnv, "", currentBlock);
+ Value* llvmEnv = module->getEnveloppe(&enveloppe, currentBlock);
#else
Value* llvmEnv = getConstantPoolAt(index,
module->EnveloppeLookupFunction,
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp?rev=60223&r1=60222&r2=60223&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Fri Nov 28 17:05:01 2008
@@ -1843,8 +1843,7 @@
JnjvmBootstrapLoader* loader =
compilingClass->classLoader->bootstrapLoader;
UserClassArray* dcl = loader->getArrayClass(id);
- valCl = module->getNativeClass(dcl);
- valCl = new LoadInst(valCl, "", currentBlock);
+ valCl = module->getNativeClass(dcl, currentBlock);
#else
Value* args[2] = { isolateLocal,
ConstantInt::get(Type::Int32Ty, id - 4) };
@@ -1854,7 +1853,7 @@
LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[charId];
sizeElement = LAI.sizeInBytesConstant;
- TheVT = module->getPrimitiveArrayVT(this);
+ TheVT = module->getPrimitiveArrayVT(currentBlock);
} else {
uint16 index = readU2(bytecodes, i);
valCl = getResolvedCommonClass(index);
@@ -1864,7 +1863,7 @@
valCl = CallInst::Create(module->GetArrayClassFunction, args,
args + 2, "", currentBlock);
sizeElement = module->constantPtrSize;
- TheVT = module->getReferenceArrayVT(this);
+ TheVT = module->getReferenceArrayVT(currentBlock);
}
llvm::Value* arg1 = popAsInt();
Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp?rev=60223&r1=60222&r2=60223&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Fri Nov 28 17:05:01 2008
@@ -1037,6 +1037,7 @@
JnjvmBootstrapLoader* bootstrapLoader = vm->bootstrapLoader;
bootstrapLoader->analyseClasspathEnv(vm->classpath);
+ bootstrapLoader->upcalls->initialiseClasspath(bootstrapLoader);
uint32 size = strlen(name);
if (size > 4 &&
Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp?rev=60223&r1=60222&r2=60223&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp Fri Nov 28 17:05:01 2008
@@ -50,8 +50,7 @@
JnjvmBootstrapLoader::JnjvmBootstrapLoader(bool staticCompilation) {
- TheModule = new JnjvmModule("Bootstrap JnJVM");
- getModule()->setIsStaticCompiling(staticCompilation);
+ TheModule = new JnjvmModule("Bootstrap JnJVM", staticCompilation);
TheModuleProvider = new JnjvmModuleProvider(getModule());
FunctionPasses = new FunctionPassManager(TheModuleProvider);
FunctionPasses->add(new TargetData(TheModule));
Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp?rev=60223&r1=60222&r2=60223&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp Fri Nov 28 17:05:01 2008
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/BasicBlock.h"
#include "llvm/CallingConv.h"
#include "llvm/Instructions.h"
#include "llvm/Support/MutexGuard.h"
@@ -72,120 +73,196 @@
llvm::ConstantInt* JnjvmModule::JavaObjectLockOffsetConstant;
llvm::ConstantInt* JnjvmModule::JavaObjectClassOffsetConstant;
-Value* JnjvmModule::getNativeClass(CommonClass* classDef) {
- llvm::GlobalVariable* varGV = 0;
- native_class_iterator End = nativeClasses.end();
- native_class_iterator I = nativeClasses.find(classDef);
- if (I == End) {
- const llvm::Type* Ty = classDef->isClass() ?
- JavaClassType : JavaCommonClassType;
- Constant* cons =
- ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
- uint64_t (classDef)),
- Ty);
+Value* JnjvmModule::getNativeClass(CommonClass* classDef, Value* Where) {
+ const llvm::Type* Ty = classDef->isClass() ? JavaClassType :
+ JavaCommonClassType;
+
+ if (staticCompilation) {
+ llvm::GlobalVariable* varGV = 0;
+ native_class_iterator End = nativeClasses.end();
+ native_class_iterator I = nativeClasses.find(classDef);
+ if (I == End) {
+ ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64_t (classDef));
+ Constant* cons = ConstantExpr::getIntToPtr(CI, Ty);
- varGV = new GlobalVariable(Ty, !staticCompilation,
- GlobalValue::ExternalLinkage,
- cons, "", this);
+ varGV = new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage,
+ cons, "", this);
- nativeClasses.insert(std::make_pair(classDef, varGV));
+ nativeClasses.insert(std::make_pair(classDef, varGV));
+ } else {
+ varGV = I->second;
+ }
+
+ if (BasicBlock* BB = dyn_cast<BasicBlock>(Where)) {
+ return new LoadInst(varGV, "", BB);
+ } else {
+ assert(dyn_cast<Instruction>(Where) && "Wrong use of module");
+ return new LoadInst(varGV, "", dyn_cast<Instruction>(Where));
+ }
} else {
- varGV = I->second;
- }
- return varGV;
+
+ ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64_t(classDef));
+ return ConstantExpr::getIntToPtr(CI, Ty);
+ }
}
-Value* JnjvmModule::getConstantPool(JavaConstantPool* ctp) {
- llvm::GlobalVariable* varGV = 0;
- constant_pool_iterator End = constantPools.end();
- constant_pool_iterator I = constantPools.find(ctp);
- if (I == End) {
+Value* JnjvmModule::getConstantPool(JavaConstantPool* ctp, Value* Where) {
+ if (staticCompilation) {
+ llvm::GlobalVariable* varGV = 0;
+ constant_pool_iterator End = constantPools.end();
+ constant_pool_iterator I = constantPools.find(ctp);
+ if (I == End) {
+ void* ptr = ctp->ctpRes;
+ assert(ptr && "No constant pool found");
+ ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64_t(ptr));
+ Constant* cons = ConstantExpr::getIntToPtr(CI, ConstantPoolType);
+ varGV = new GlobalVariable(ConstantPoolType, false,
+ GlobalValue::ExternalLinkage,
+ cons, "", this);
+ constantPools.insert(std::make_pair(ctp, varGV));
+ } else {
+ varGV = I->second;
+ }
+
+ if (BasicBlock* BB = dyn_cast<BasicBlock>(Where)) {
+ return new LoadInst(varGV, "", BB);
+ } else {
+ assert(dyn_cast<Instruction>(Where) && "Wrong use of module");
+ return new LoadInst(varGV, "", dyn_cast<Instruction>(Where));
+ }
+ } else {
void* ptr = ctp->ctpRes;
assert(ptr && "No constant pool found");
- Constant* cons =
- ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64(ptr)),
- ConstantPoolType);
- varGV = new GlobalVariable(ConstantPoolType, !staticCompilation,
- GlobalValue::ExternalLinkage,
- cons, "", this);
- constantPools.insert(std::make_pair(ctp, varGV));
- } else {
- varGV = I->second;
+ ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64_t(ptr));
+ return ConstantExpr::getIntToPtr(CI, ConstantPoolType);
}
- return varGV;
}
-Value* JnjvmModule::getString(JavaString* str) {
- llvm::GlobalVariable* varGV;
- string_iterator SI = strings.find(str);
- if (SI != strings.end()) {
- varGV = SI->second;
+Value* JnjvmModule::getString(JavaString* str, Value* Where) {
+ if (staticCompilation) {
+ llvm::GlobalVariable* varGV;
+ string_iterator SI = strings.find(str);
+ if (SI != strings.end()) {
+ varGV = SI->second;
+ } else {
+ assert(str && "No string given");
+ ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64(str));
+ Constant* cons = ConstantExpr::getIntToPtr(CI, JavaObjectType);
+ varGV = new GlobalVariable(JnjvmModule::JavaObjectType, false,
+ GlobalValue::ExternalLinkage,
+ cons, "", this);
+ strings.insert(std::make_pair(str, varGV));
+ }
+
+ if (BasicBlock* BB = dyn_cast<BasicBlock>(Where)) {
+ return new LoadInst(varGV, "", BB);
+ } else {
+ assert(dyn_cast<Instruction>(Where) && "Wrong use of module");
+ return new LoadInst(varGV, "", dyn_cast<Instruction>(Where));
+ }
} else {
- void* ptr = str;
- assert(ptr && "No string given");
- Constant* cons =
- ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64(ptr)),
- JnjvmModule::JavaObjectType);
- varGV = new GlobalVariable(JnjvmModule::JavaObjectType, !staticCompilation,
- GlobalValue::ExternalLinkage,
- cons, "", this);
- strings.insert(std::make_pair(str, varGV));
- }
- return varGV;
-}
-
-Value* JnjvmModule::getEnveloppe(Enveloppe* enveloppe) {
- llvm::GlobalVariable* varGV;
- enveloppe_iterator SI = enveloppes.find(enveloppe);
- if (SI != enveloppes.end()) {
- varGV = SI->second;
+ assert(str && "No string given");
+ ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64(str));
+ return ConstantExpr::getIntToPtr(CI, JavaObjectType);
+ }
+}
+
+Value* JnjvmModule::getEnveloppe(Enveloppe* enveloppe, Value* Where) {
+ if (staticCompilation) {
+ llvm::GlobalVariable* varGV;
+ enveloppe_iterator SI = enveloppes.find(enveloppe);
+ if (SI != enveloppes.end()) {
+ varGV = SI->second;
+ } else {
+ void* ptr = enveloppe;
+ assert(ptr && "No enveloppe given");
+ ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64(ptr));
+ Constant* cons = ConstantExpr::getIntToPtr(CI, EnveloppeType);
+ varGV = new GlobalVariable(JnjvmModule::EnveloppeType, false,
+ GlobalValue::ExternalLinkage,
+ cons, "", this);
+ enveloppes.insert(std::make_pair(enveloppe, varGV));
+ }
+
+ if (BasicBlock* BB = dyn_cast<BasicBlock>(Where)) {
+ return new LoadInst(varGV, "", BB);
+ } else {
+ assert(dyn_cast<Instruction>(Where) && "Wrong use of module");
+ return new LoadInst(varGV, "", dyn_cast<Instruction>(Where));
+ }
} else {
void* ptr = enveloppe;
assert(ptr && "No enveloppe given");
- Constant* cons =
- ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64(ptr)),
- JnjvmModule::EnveloppeType);
- varGV = new GlobalVariable(JnjvmModule::EnveloppeType, !staticCompilation,
- GlobalValue::ExternalLinkage,
- cons, "", this);
- enveloppes.insert(std::make_pair(enveloppe, varGV));
- }
- return varGV;
-}
-
-Value* JnjvmModule::getJavaClass(CommonClass* cl) {
- llvm::GlobalVariable* varGV = 0;
- java_class_iterator End = javaClasses.end();
- java_class_iterator I = javaClasses.find(cl);
- if (I == End) {
-
- JavaObject* obj = isStaticCompiling() ? 0 :
- cl->getClassDelegatee(JavaThread::get()->getJVM());
- assert((obj || isStaticCompiling()) && "Delegatee not created");
- Constant* cons =
- ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64(obj)),
- JnjvmModule::JavaObjectType);
- varGV = new GlobalVariable(JnjvmModule::JavaObjectType, !staticCompilation,
- GlobalValue::ExternalLinkage,
- cons, "", this);
+ ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64(ptr));
+ return ConstantExpr::getIntToPtr(CI, JnjvmModule::EnveloppeType);
+ }
+}
+
+Value* JnjvmModule::getJavaClass(CommonClass* cl, Value* Where) {
+ if (staticCompilation) {
+ llvm::GlobalVariable* varGV = 0;
+ java_class_iterator End = javaClasses.end();
+ java_class_iterator I = javaClasses.find(cl);
+ if (I == End) {
+
+ Constant* cons = ConstantExpr::getIntToPtr(constantZero, JavaObjectType);
+ varGV = new GlobalVariable(JnjvmModule::JavaObjectType, false,
+ GlobalValue::ExternalLinkage,
+ cons, "", this);
- javaClasses.insert(std::make_pair(cl, varGV));
+ javaClasses.insert(std::make_pair(cl, varGV));
+ } else {
+ varGV = I->second;
+ }
+
+ if (BasicBlock* BB = dyn_cast<BasicBlock>(Where)) {
+ return new LoadInst(varGV, "", BB);
+ } else {
+ assert(dyn_cast<Instruction>(Where) && "Wrong use of module");
+ return new LoadInst(varGV, "", dyn_cast<Instruction>(Where));
+ }
} else {
- varGV = I->second;
+ JavaObject* obj = cl->getClassDelegatee(JavaThread::get()->getJVM());
+ assert(obj && "Delegatee not created");
+ Constant* CI = ConstantInt::get(Type::Int64Ty, uint64(obj));
+ return ConstantExpr::getIntToPtr(CI, JavaObjectType);
}
- return varGV;
}
-Value* JnjvmModule::getStaticInstance(Class* classDef) {
- llvm::GlobalVariable* varGV = 0;
- static_instance_iterator End = staticInstances.end();
- static_instance_iterator I = staticInstances.find(classDef);
- if (I == End) {
- LLVMClassInfo* LCI = getClassInfo(classDef);
- LCI->getStaticType();
+Value* JnjvmModule::getStaticInstance(Class* classDef, Value* Where) {
+#ifdef ISOLATE
+ assert(0 && "Should not be here");
+ abort();
+#endif
+ if (staticCompilation) {
+ llvm::GlobalVariable* varGV = 0;
+ static_instance_iterator End = staticInstances.end();
+ static_instance_iterator I = staticInstances.find(classDef);
+ if (I == End) {
+ LLVMClassInfo* LCI = getClassInfo(classDef);
+ LCI->getStaticType();
+ void* obj = ((Class*)classDef)->getStaticInstance();
+ Constant* CI = ConstantInt::get(Type::Int64Ty, (uint64_t(obj)));
+ Constant* cons = ConstantExpr::getIntToPtr(CI, ptrType);
+
+ varGV = new GlobalVariable(ptrType, false,
+ GlobalValue::ExternalLinkage,
+ cons, "", this);
+
+ staticInstances.insert(std::make_pair(classDef, varGV));
+ } else {
+ varGV = I->second;
+ }
+
+ if (BasicBlock* BB = dyn_cast<BasicBlock>(Where)) {
+ return new LoadInst(varGV, "", BB);
+ } else {
+ assert(dyn_cast<Instruction>(Where) && "Wrong use of module");
+ return new LoadInst(varGV, "", dyn_cast<Instruction>(Where));
+ }
+ } else {
void* obj = ((Class*)classDef)->getStaticInstance();
-#ifndef ISOLATE
- if (!obj && !isStaticCompiling()) {
+ if (!obj) {
Class* cl = (Class*)classDef;
classDef->acquire();
obj = cl->getStaticInstance();
@@ -195,74 +272,86 @@
}
classDef->release();
}
-#endif
- Constant* cons =
- ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
- uint64_t (obj)), ptrType);
-
- varGV = new GlobalVariable(ptrType, !staticCompilation,
- GlobalValue::ExternalLinkage,
- cons, "", this);
-
- staticInstances.insert(std::make_pair(classDef, varGV));
- } else {
- varGV = I->second;
+ Constant* CI = ConstantInt::get(Type::Int64Ty, (uint64_t(obj)));
+ return ConstantExpr::getIntToPtr(CI, ptrType);
}
-
- return varGV;
}
-Value* JnjvmModule::getVirtualTable(Class* classDef) {
- llvm::GlobalVariable* varGV = 0;
- virtual_table_iterator End = virtualTables.end();
- virtual_table_iterator I = virtualTables.find(classDef);
- if (I == End) {
- if (!classDef->isArray() && !classDef->isPrimitive()) {
- LLVMClassInfo* LCI = getClassInfo((Class*)classDef);
- LCI->getVirtualType();
- }
- assert((classDef->virtualVT || isStaticCompiling()) &&
- "Virtual VT not created");
- Constant* cons =
- ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
- uint64_t(classDef->virtualVT)),
- JnjvmModule::VTType);
- varGV = new GlobalVariable(JnjvmModule::VTType, !staticCompilation,
- GlobalValue::ExternalLinkage,
- cons, "", this);
+Value* JnjvmModule::getVirtualTable(Class* classDef, Value* Where) {
+ if (staticCompilation) {
+ llvm::GlobalVariable* varGV = 0;
+ virtual_table_iterator End = virtualTables.end();
+ virtual_table_iterator I = virtualTables.find(classDef);
+ if (I == End) {
+ void* ptr = classDef->virtualVT;
+ ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64_t(ptr));
+ Constant* cons = ConstantExpr::getIntToPtr(CI, VTType);
+ varGV = new GlobalVariable(JnjvmModule::VTType, false,
+ GlobalValue::ExternalLinkage,
+ cons, "", this);
- virtualTables.insert(std::make_pair(classDef, varGV));
+ virtualTables.insert(std::make_pair(classDef, varGV));
+ } else {
+ varGV = I->second;
+ }
+
+ if (BasicBlock* BB = dyn_cast<BasicBlock>(Where)) {
+ return new LoadInst(varGV, "", BB);
+ } else {
+ assert(dyn_cast<Instruction>(Where) && "Wrong use of module");
+ return new LoadInst(varGV, "", dyn_cast<Instruction>(Where));
+ }
} else {
- varGV = I->second;
+ LLVMClassInfo* LCI = getClassInfo((Class*)classDef);
+ LCI->getVirtualType();
+ assert(classDef->virtualVT && "Virtual VT not created");
+ void* ptr = classDef->virtualVT;
+ ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64_t(ptr));
+ return ConstantExpr::getIntToPtr(CI, VTType);
}
- return varGV;
}
-Value* JnjvmModule::getNativeFunction(JavaMethod* meth, void* ptr) {
- llvm::GlobalVariable* varGV = 0;
- native_function_iterator End = nativeFunctions.end();
- native_function_iterator I = nativeFunctions.find(meth);
- if (I == End) {
-
+Value* JnjvmModule::getNativeFunction(JavaMethod* meth, void* ptr,
+ Value* Where) {
+ if (staticCompilation) {
+ llvm::GlobalVariable* varGV = 0;
+ native_function_iterator End = nativeFunctions.end();
+ native_function_iterator I = nativeFunctions.find(meth);
+ if (I == End) {
- LLVMSignatureInfo* LSI = getSignatureInfo(meth->getSignature());
- const llvm::Type* valPtrType = LSI->getNativePtrType();
+ LLVMSignatureInfo* LSI = getSignatureInfo(meth->getSignature());
+ const llvm::Type* valPtrType = LSI->getNativePtrType();
- assert((ptr || isStaticCompiling()) && "No native function given");
-
- Constant* cons =
- ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t(ptr)),
- valPtrType);
+ assert((ptr || isStaticCompiling()) && "No native function given");
- varGV = new GlobalVariable(valPtrType, !staticCompilation,
- GlobalValue::ExternalLinkage,
- cons, "", this);
+ Constant* cons =
+ ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t(ptr)),
+ valPtrType);
+
+ varGV = new GlobalVariable(valPtrType, false,
+ GlobalValue::ExternalLinkage,
+ cons, "", this);
- nativeFunctions.insert(std::make_pair(meth, varGV));
+ nativeFunctions.insert(std::make_pair(meth, varGV));
+ } else {
+ varGV = I->second;
+ }
+
+ if (BasicBlock* BB = dyn_cast<BasicBlock>(Where)) {
+ return new LoadInst(varGV, "", BB);
+ } else {
+ assert(dyn_cast<Instruction>(Where) && "Wrong use of module");
+ return new LoadInst(varGV, "", dyn_cast<Instruction>(Where));
+ }
} else {
- varGV = I->second;
+ LLVMSignatureInfo* LSI = getSignatureInfo(meth->getSignature());
+ const llvm::Type* valPtrType = LSI->getNativePtrType();
+
+ assert(ptr && "No native function given");
+
+ Constant* CI = ConstantInt::get(Type::Int64Ty, uint64_t(ptr));
+ return ConstantExpr::getIntToPtr(CI, valPtrType);
}
- return varGV;
}
#ifndef WITHOUT_VTABLE
@@ -1013,31 +1102,57 @@
OffsetStatusInTaskClassMirrorConstant = mvm::MvmModule::constantZero;
ClassReadyConstant = ConstantInt::get(Type::Int32Ty, ready);
-
- Constant* cons =
+
+ Constant* consPrim =
ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
uint64(JavaArray::VT)),
VTType);
- PrimitiveArrayVT = new GlobalVariable(VTType, !staticCompilation,
- GlobalValue::ExternalLinkage,
- cons, "", this);
-
- cons = ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
- uint64(ArrayObject::VT)),
- VTType);
- ReferenceArrayVT = new GlobalVariable(VTType, !staticCompilation,
- GlobalValue::ExternalLinkage,
- cons, "", this);
+
+ Constant* consRef =
+ ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
+ uint64(ArrayObject::VT)),
+ VTType);
+
+ if (staticCompilation) {
+ PrimitiveArrayVT = new GlobalVariable(VTType, false,
+ GlobalValue::ExternalLinkage,
+ consPrim, "", this);
+
+ ReferenceArrayVT = new GlobalVariable(VTType, false,
+ GlobalValue::ExternalLinkage,
+ consRef, "", this);
+ } else {
+ PrimitiveArrayVT = consPrim;
+ ReferenceArrayVT = consRef;
+ }
LLVMAssessorInfo::initialise();
}
-Value* JnjvmModule::getReferenceArrayVT(JavaJIT* JIT) {
- return new LoadInst(ReferenceArrayVT, "", JIT->currentBlock);
+Value* JnjvmModule::getReferenceArrayVT(Value* Where) {
+ if (staticCompilation) {
+ if (BasicBlock* BB = dyn_cast<BasicBlock>(Where)) {
+ return new LoadInst(ReferenceArrayVT, "", BB);
+ } else {
+ assert(dyn_cast<Instruction>(Where) && "Wrong use of module");
+ return new LoadInst(ReferenceArrayVT, "", dyn_cast<Instruction>(Where));
+ }
+ } else {
+ return ReferenceArrayVT;
+ }
}
-Value* JnjvmModule::getPrimitiveArrayVT(JavaJIT* JIT) {
- return new LoadInst(PrimitiveArrayVT, "", JIT->currentBlock);
+Value* JnjvmModule::getPrimitiveArrayVT(Value* Where) {
+ if (staticCompilation) {
+ if (BasicBlock* BB = dyn_cast<BasicBlock>(Where)) {
+ return new LoadInst(PrimitiveArrayVT, "", BB);
+ } else {
+ assert(dyn_cast<Instruction>(Where) && "Wrong use of module");
+ return new LoadInst(PrimitiveArrayVT, "", dyn_cast<Instruction>(Where));
+ }
+ } else {
+ return PrimitiveArrayVT;
+ }
}
void JnjvmModule::setMethod(JavaMethod* meth, const char* name) {
@@ -1257,25 +1372,35 @@
#ifdef SERVICE
Value* JnjvmModule::getIsolate(Jnjvm* isolate) {
- llvm::GlobalVariable* varGV = 0;
- isolate_iterator End = isolates.end();
- isolate_iterator I = isolates.find(isolate);
- if (I == End) {
+ if (staticCompilation)Â {
+ llvm::GlobalVariable* varGV = 0;
+ isolate_iterator End = isolates.end();
+ isolate_iterator I = isolates.find(isolate);
+ if (I == End) {
- Constant* cons =
- ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
- uint64_t(isolate)),
- ptrType);
-
- varGV = new GlobalVariable(ptrType, !staticCompilation,
- GlobalValue::ExternalLinkage,
- cons, "", this);
+ Constant* cons =
+ ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
+ uint64_t(isolate)),
+ ptrType);
+
+ varGV = new GlobalVariable(ptrType, !staticCompilation,
+ GlobalValue::ExternalLinkage,
+ cons, "", this);
- isolates.insert(std::make_pair(isolate, varGV));
+ isolates.insert(std::make_pair(isolate, varGV));
+ } else {
+ varGV = I->second;
+ }
+ if (BasicBlock* BB = dyn_cast<BasicBlock>(Where)) {
+ return new LoadInst(varGV, "", BB);
+ } else {
+ assert(dyn_cast<Instruction>(Where) && "Wrong use of module");
+ return new LoadInst(varGV, "", dyn_cast<Instruction>(Where));
+ }
} else {
- varGV = I->second;
+ ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64_t(isolate));
+ return ConstantExpr::get(CI, ptrType);
}
- return varGV;
}
#endif
Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h?rev=60223&r1=60222&r2=60223&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h Fri Nov 28 17:05:01 2008
@@ -376,18 +376,18 @@
void initialise();
void printStats();
- llvm::Value* getNativeClass(CommonClass* cl);
- llvm::Value* getJavaClass(CommonClass* cl);
- llvm::Value* getStaticInstance(Class* cl);
- llvm::Value* getVirtualTable(Class* cl);
+ llvm::Value* getNativeClass(CommonClass* cl, llvm::Value* Where);
+ llvm::Value* getJavaClass(CommonClass* cl, llvm::Value* Where);
+ llvm::Value* getStaticInstance(Class* cl, llvm::Value* Where);
+ llvm::Value* getVirtualTable(Class* cl, llvm::Value* Where);
- llvm::Value* getEnveloppe(Enveloppe* enveloppe);
- llvm::Value* getString(JavaString* str);
- llvm::Value* getConstantPool(JavaConstantPool* ctp);
- llvm::Value* getNativeFunction(JavaMethod* meth, void* natPtr);
+ llvm::Value* getEnveloppe(Enveloppe* enveloppe, llvm::Value* Where);
+ llvm::Value* getString(JavaString* str, llvm::Value* Where);
+ llvm::Value* getConstantPool(JavaConstantPool* ctp, llvm::Value* Where);
+ llvm::Value* getNativeFunction(JavaMethod* meth, void* natPtr, llvm::Value* Where);
- llvm::Value* getReferenceArrayVT(JavaJIT*);
- llvm::Value* getPrimitiveArrayVT(JavaJIT*);
+ llvm::Value* getReferenceArrayVT(llvm::Value* Where);
+ llvm::Value* getPrimitiveArrayVT(llvm::Value* Where);
#ifdef SERVICE
std::map<const Jnjvm*, llvm::GlobalVariable*> isolates;
Modified: vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp?rev=60223&r1=60222&r2=60223&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp Fri Nov 28 17:05:01 2008
@@ -154,8 +154,7 @@
ConstantInt* C = (ConstantInt*)CE->getOperand(0);
Class* cl = (Class*)C->getZExtValue();
if (cl->isResolved()) {
- Value* VT = module->getVirtualTable(cl);
- VT = new LoadInst(VT, "", CI);
+ Value* VT = module->getVirtualTable(cl, CI);
CI->replaceAllUsesWith(VT);
CI->eraseFromParent();
continue;
@@ -311,8 +310,7 @@
ConstantInt* C = (ConstantInt*)CE->getOperand(0);
Class* cl = (Class*)C->getZExtValue();
- Value* Replace = module->getStaticInstance(cl);
- Replace = new LoadInst(Replace, "", CI);
+ Value* Replace = module->getStaticInstance(cl, CI);
CI->replaceAllUsesWith(Replace);
CI->eraseFromParent();
@@ -498,8 +496,7 @@
const UTF8* arrayName = JCL->constructArrayName(1, cl->name);
UserCommonClass* dcl = JCL->constructArray(arrayName);
- Value* valCl = module->getNativeClass(dcl);
- valCl = new LoadInst(valCl, "", CI);
+ Value* valCl = module->getNativeClass(dcl, CI);
CI->replaceAllUsesWith(valCl);
CI->eraseFromParent();
continue;
More information about the vmkit-commits
mailing list