[vmkit-commits] [vmkit] r55437 - in /vmkit/branches/isolate/lib/JnJVM: LLVMRuntime/runtime-default.ll VMCore/JavaCache.cpp VMCore/JavaCache.h VMCore/JavaJIT.cpp VMCore/JavaRuntimeJIT.cpp VMCore/JnjvmModule.cpp VMCore/JnjvmModule.h
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Wed Aug 27 14:44:41 PDT 2008
Author: geoffray
Date: Wed Aug 27 16:44:41 2008
New Revision: 55437
URL: http://llvm.org/viewvc/llvm-project?rev=55437&view=rev
Log:
Constant pool lookups only take the class and index (except for vtableLookup
to deal with a gcj/javac bug).
Modified:
vmkit/branches/isolate/lib/JnJVM/LLVMRuntime/runtime-default.ll
vmkit/branches/isolate/lib/JnJVM/VMCore/JavaCache.cpp
vmkit/branches/isolate/lib/JnJVM/VMCore/JavaCache.h
vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp
vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp
vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.h
Modified: vmkit/branches/isolate/lib/JnJVM/LLVMRuntime/runtime-default.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/LLVMRuntime/runtime-default.ll?rev=55437&r1=55436&r2=55437&view=diff
==============================================================================
--- vmkit/branches/isolate/lib/JnJVM/LLVMRuntime/runtime-default.ll (original)
+++ vmkit/branches/isolate/lib/JnJVM/LLVMRuntime/runtime-default.ll Wed Aug 27 16:44:41 2008
@@ -97,15 +97,18 @@
;;; vtableLookup - Look up the offset in a virtual table of a specific
;;; function. This function takes a class and an index to lookup in the
;;; constant pool and returns and stores it in the constant pool cache.
-declare i32 @vtableLookup(%JavaObject*, %JavaClass*, i32) readnone
+declare i32 @vtableLookup(%JavaClass*, i32, %JavaObject*) readnone
;;; newLookup - Look up a specific class. The function takes a class and an
;;; index to lookup in the constant pool and returns and stores it in the
;;; constant pool cache.
-declare %JavaClass* @newLookup(%JavaClass*, i32) readnone
+declare %JavaClass* @classLookup(%JavaClass*, i32) readnone
;;; fieldLookup - Look up a specific field.
-declare i8* @fieldLookup(%JavaObject*, %JavaClass*, i32, i32) readnone
+declare i32 @virtualFieldLookup(%JavaClass*, i32) readnone
+
+;;; fieldLookup - Look up a specific field.
+declare i8* @staticFieldLookup(%JavaClass*, i32) readnone
;;; JavaObjectAquire - This function is called when starting a synchronized
;;; block or method.
Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaCache.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaCache.cpp?rev=55437&r1=55436&r2=55437&view=diff
==============================================================================
--- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaCache.cpp (original)
+++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaCache.cpp Wed Aug 27 16:44:41 2008
@@ -44,7 +44,7 @@
enveloppe = E;
}
-Enveloppe::Enveloppe(JavaConstantPool* ctp, uint32 i) {
+Enveloppe::Enveloppe(UserConstantPool* ctp, uint32 i) {
firstCache = new CacheNode(this);
cacheLock = mvm::Lock::allocNormal();
ctpInfo = ctp;
Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaCache.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaCache.h?rev=55437&r1=55436&r2=55437&view=diff
==============================================================================
--- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaCache.h (original)
+++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaCache.h Wed Aug 27 16:44:41 2008
@@ -27,11 +27,11 @@
#include "types.h"
+#include "JnjvmConfig.h"
+
namespace jnjvm {
class Enveloppe;
-class JavaConstantPool;
-class UserClass;
/// CacheNode - A {class, method pointer} pair.
class CacheNode {
@@ -49,6 +49,12 @@
/// enveloppe - The container to which this class belongs to.
Enveloppe* enveloppe;
+#ifdef MULTIPLE_VM
+ ///definingClass - The class that defined the method being called.
+ ///
+ UserConstantPool* definingCtp;
+#endif
+
/// CacheNode - Creates a CacheNode with empty values.
CacheNode(Enveloppe* E);
};
@@ -67,7 +73,7 @@
/// ctpInfo - The constant pool info that owns the invokeinterface
/// bytecode. This is used to resolve the interface call at its first
/// occurence.
- JavaConstantPool* ctpInfo;
+ UserConstantPool* ctpInfo;
/// cacheLock - The linked list may be modified by concurrent thread. This
/// lock ensures that the list stays consistent.
@@ -79,7 +85,7 @@
/// Enveloppe - Allocates the linked list with the given constant pool info
/// at the given index, so as the resolution process knows which interface
/// method the invokeinterface bytecode references.
- Enveloppe(JavaConstantPool* info, uint32 index);
+ Enveloppe(UserConstantPool* info, uint32 index);
};
Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp?rev=55437&r1=55436&r2=55437&view=diff
==============================================================================
--- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp Wed Aug 27 16:44:41 2008
@@ -74,15 +74,6 @@
JITVerifyNull(args[0]);
-#if defined(MULTIPLE_VM)
- Value* cl = CallInst::Create(JnjvmModule::GetClassFunction, args[0], "",
- currentBlock);
-
- Value* newCtpCache = CallInst::Create(JnjvmModule::GetCtpCacheFunction, cl, "",
- currentBlock);
- args.push_back(newCtpCache);
-#endif
-
Value* VT = CallInst::Create(JnjvmModule::GetVTFunction, args[0], "",
currentBlock);
std::vector<Value*> indexes2; //[3];
@@ -107,12 +98,12 @@
currentBlock = ifFalse;
std::vector<Value*> Args;
- Args.push_back(args[0]);
LLVMClassInfo* LCI =
(LLVMClassInfo*)module->getClassInfo(compilingClass);
Args.push_back(LCI->getVar(this));
Constant* CI = ConstantInt::get(Type::Int32Ty, index);
Args.push_back(CI);
+ Args.push_back(args[0]);
val = invoke(JnjvmModule::VirtualLookupFunction, Args, "", currentBlock);
node->addIncoming(val, currentBlock);
llvm::BranchInst::Create(endBlock, currentBlock);
@@ -1809,17 +1800,21 @@
// ---------- In case we have to resolve -------------------------------- //
currentBlock = ifFalse;
std::vector<Value*> args;
- if (object) {
- args.push_back(object);
- } else {
- args.push_back(JnjvmModule::JavaObjectNullConstant);
- }
LLVMClassInfo* LCI = (LLVMClassInfo*)module->getClassInfo(compilingClass);
args.push_back(LCI->getVar(this));
Constant* CI = ConstantInt::get(Type::Int32Ty, index);
args.push_back(CI);
- args.push_back(stat ? mvm::jit::constantOne : mvm::jit::constantZero);
- Value* tmp = invoke(JnjvmModule::FieldLookupFunction, args, "", currentBlock);
+ Function* func = stat ? JnjvmModule::StaticFieldLookupFunction :
+ JnjvmModule::VirtualFieldLookupFunction;
+ Value* tmp = invoke(func, args, "", currentBlock);
+ if (!stat) {
+ Value* ptr = new BitCastInst(object, Pty, "", currentBlock);
+ args.clear();
+ args.push_back(zero);
+ args.push_back(tmp);
+ tmp = GetElementPtrInst::Create(ptr, args.begin(), args.end(), "",
+ currentBlock);
+ }
node->addIncoming(tmp, currentBlock);
llvm::BranchInst::Create(endBlock, currentBlock);
@@ -2016,29 +2011,23 @@
if (retType != Type::VoidTy) {
node = PHINode::Create(retType, "", endBlock);
}
+
+ JITVerifyNull(args[0]);
+
+ Value* zero = mvm::jit::constantZero;
+ Value* one = mvm::jit::constantOne;
+#ifndef MULTIPLE_VM
// ok now the cache
Enveloppe* enveloppe = new Enveloppe(compilingClass->ctpInfo, index);
compilingMethod->caches.push_back(enveloppe);
-
- Value* zero = mvm::jit::constantZero;
- Value* one = mvm::jit::constantOne;
-
+
Value* llvmEnv =
ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
uint64_t (enveloppe)),
JnjvmModule::EnveloppeType);
-
-
- JITVerifyNull(args[0]);
-
-#if defined(MULTIPLE_VM)
- Value* cl = CallInst::Create(JnjvmModule::GetClassFunction, args[0], "",
- currentBlock);
-
- Value* newCtpCache = CallInst::Create(JnjvmModule::GetCtpCacheFunction, cl, "",
- currentBlock);
- args.push_back(newCtpCache);
+#else
+ llvmEnv = getConstantPoolAt(index);
#endif
std::vector<Value*> args1;
@@ -2083,6 +2072,12 @@
_meth = new LoadInst(methPtr, "", currentBlock);
meth = new BitCastInst(_meth, virtualPtrType, "", currentBlock);
+#ifdef MULTIPLE_VM
+ cache = new LoadInst(cachePtr, "", currentBlock);
+ Value* newCtpCache = CallInst::Create(JnjvmModule::GetCtpCacheNodeFunction,
+ cache, "", currentBlock);
+ args.push_back(newCtpCache);
+#endif
ret = invoke(meth, args, "", currentBlock);
BranchInst::Create(endBlock, currentBlock);
Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp?rev=55437&r1=55436&r2=55437&view=diff
==============================================================================
--- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Wed Aug 27 16:44:41 2008
@@ -30,15 +30,6 @@
using namespace jnjvm;
-#ifdef MULTIPLE_VM
-extern "C" JavaString* stringLookup(UserClass* cl, uint32 index) {
- JavaConstantPool* ctpInfo = cl->getConstantPool();
- const UTF8* utf8 = ctpInfo->UTF8At(ctpInfo->ctpDef[index]);
- JavaString* str = JavaThread::get()->isolate->UTF8ToStr(utf8);
- return str;
-}
-#endif
-
extern "C" void* jnjvmVirtualLookup(CacheNode* cache, JavaObject *obj) {
Enveloppe* enveloppe = cache->enveloppe;
JavaConstantPool* ctpInfo = enveloppe->ctpInfo;
@@ -93,9 +84,29 @@
return rcache->methPtr;
}
-extern "C" void* fieldLookup(JavaObject* obj, UserClass* caller, uint32 index,
- uint32 stat) {
+extern "C" uint32 virtualFieldLookup(UserClass* caller, uint32 index) {
+ JavaConstantPool* ctpInfo = caller->getConstantPool();
+ if (ctpInfo->ctpRes[index]) {
+ return (uint32)ctpInfo->ctpRes[index];
+ }
+
+ UserCommonClass* cl = 0;
+ UserCommonClass* fieldCl = 0;
+ const UTF8* utf8 = 0;
+ Typedef* sign = 0;
+
+ ctpInfo->resolveField(index, cl, utf8, sign);
+
+ JavaField* field = cl->lookupField(utf8, sign->keyName, false, true, fieldCl);
+
+ ctpInfo->ctpRes[index] = (void*)field->ptrOffset;
+
+ return field->ptrOffset;
+}
+
+extern "C" void* staticFieldLookup(UserClass* caller, uint32 index) {
JavaConstantPool* ctpInfo = caller->getConstantPool();
+
if (ctpInfo->ctpRes[index]) {
return ctpInfo->ctpRes[index];
}
@@ -107,20 +118,56 @@
ctpInfo->resolveField(index, cl, utf8, sign);
- JavaField* field = cl->lookupField(utf8, sign->keyName, stat, true, fieldCl);
+ JavaField* field = cl->lookupField(utf8, sign->keyName, true, true, fieldCl);
+
+ fieldCl->initialiseClass(JavaThread::get()->isolate);
+ void* ptr =
+ (void*)((uint64)(((UserClass*)fieldCl)->getStaticInstance()) + field->ptrOffset);
+ ctpInfo->ctpRes[index] = ptr;
- void* ptr = 0;
- if (stat) {
- fieldCl->initialiseClass(JavaThread::get()->isolate);
- ptr = (void*)((uint64)(((UserClass*)fieldCl)->getStaticInstance()) + field->ptrOffset);
- ctpInfo->ctpRes[index] = ptr;
+ return ptr;
+}
+
+#ifdef MULTIPLE_VM
+extern "C" JavaString* stringLookup(UserClass* cl, uint32 index) {
+ JavaConstantPool* ctpInfo = cl->getConstantPool();
+ const UTF8* utf8 = ctpInfo->UTF8At(ctpInfo->ctpDef[index]);
+ JavaString* str = JavaThread::get()->isolate->UTF8ToStr(utf8);
+ ctpInfo->ctpRes[index] = str;
+ return str;
+}
+#endif
+
+#ifndef WITHOUT_VTABLE
+extern "C" uint32 vtableLookup(UserClass* caller, uint32 index, JavaObject* obj) {
+ UserCommonClass* cl = 0;
+ const UTF8* utf8 = 0;
+ Signdef* sign = 0;
+
+ caller->getConstantPool()->resolveMethod(index, cl, utf8, sign);
+ JavaMethod* dmeth = cl->lookupMethodDontThrow(utf8, sign->keyName, false,
+ true);
+ assert(obj->classOf->isReady() && "Class not ready in a virtual lookup.");
+ if (!dmeth) {
+ // Arg, it should have been an invoke interface.... Perform the lookup
+ // on the object class and do not update offset.
+ dmeth = obj->classOf->lookupMethod(utf8, sign->keyName, false, true);
} else {
- ptr = (void*)((uint64)obj + field->ptrOffset);
- ctpInfo->ctpRes[index] = (void*)field->ptrOffset;
+ caller->getConstantPool()->ctpRes[index] = (void*)dmeth->offset;
}
- return ptr;
+ assert(dmeth->classDef->isReady() && "Class not ready in a virtual lookup.");
+
+ return dmeth->offset;
}
+#endif
+
+extern "C" UserClass* classLookup(UserClass* caller, uint32 index) {
+ JavaConstantPool* ctpInfo = caller->getConstantPool();
+ UserClass* cl = (UserClass*)ctpInfo->loadClass(index);
+ return cl;
+}
+
extern "C" void printMethodStart(JavaMethod* meth) {
printf("[%d] executing %s\n", mvm::Thread::self(), meth->printString());
@@ -185,37 +232,6 @@
return cl->getClassDelegatee(vm);
}
-extern "C" UserClass* newLookup(UserClass* caller, uint32 index) {
- JavaConstantPool* ctpInfo = caller->getConstantPool();
- UserClass* cl = (UserClass*)ctpInfo->loadClass(index);
- return cl;
-}
-
-#ifndef WITHOUT_VTABLE
-extern "C" uint32 vtableLookup(JavaObject* obj, UserClass* caller, uint32 index) {
- UserCommonClass* cl = 0;
- const UTF8* utf8 = 0;
- Signdef* sign = 0;
-
- caller->getConstantPool()->resolveMethod(index, cl, utf8, sign);
- JavaMethod* dmeth = cl->lookupMethodDontThrow(utf8, sign->keyName, false,
- true);
- assert(obj->classOf->isReady() && "Class not ready in a virtual lookup.");
- if (!dmeth) {
- // Arg, it should have been an invoke interface.... Perform the lookup
- // on the object class and do not update offset.
- dmeth = obj->classOf->lookupMethod(utf8, sign->keyName, false, true);
- } else {
- caller->getConstantPool()->ctpRes[index] = (void*)dmeth->offset;
- }
-
- assert(dmeth->classDef->isReady() && "Class not ready in a virtual lookup.");
-
- return dmeth->offset;
-}
-#endif
-
-
static JavaArray* multiCallNewIntern(arrayCtor_t ctor, UserClassArray* cl,
uint32 len,
sint32* dims,
Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp?rev=55437&r1=55436&r2=55437&view=diff
==============================================================================
--- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp (original)
+++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp Wed Aug 27 16:44:41 2008
@@ -81,7 +81,8 @@
llvm::Function* JnjvmModule::OutOfMemoryErrorFunction = 0;
llvm::Function* JnjvmModule::JavaObjectAllocateFunction = 0;
llvm::Function* JnjvmModule::InterfaceLookupFunction = 0;
-llvm::Function* JnjvmModule::FieldLookupFunction = 0;
+llvm::Function* JnjvmModule::StaticFieldLookupFunction = 0;
+llvm::Function* JnjvmModule::VirtualFieldLookupFunction = 0;
#ifndef WITHOUT_VTABLE
llvm::Function* JnjvmModule::VirtualLookupFunction = 0;
#endif
@@ -957,9 +958,10 @@
ArrayLengthFunction = module->getFunction("arrayLength");
GetVTFunction = module->getFunction("getVT");
GetClassFunction = module->getFunction("getClass");
- ClassLookupFunction = module->getFunction("newLookup");
+ ClassLookupFunction = module->getFunction("classLookup");
GetVTFromClassFunction = module->getFunction("getVTFromClass");
- GetObjectSizeFromClassFunction = module->getFunction("getObjectSizeFromClass");
+ GetObjectSizeFromClassFunction =
+ module->getFunction("getObjectSizeFromClass");
GetClassDelegateeFunction = module->getFunction("getClassDelegatee");
InstanceOfFunction = module->getFunction("instanceOf");
@@ -973,7 +975,8 @@
ReleaseObjectFunction = module->getFunction("JavaObjectRelease");
OverflowThinLockFunction = module->getFunction("overflowThinLock");
- FieldLookupFunction = module->getFunction("fieldLookup");
+ VirtualFieldLookupFunction = module->getFunction("virtualFieldLookup");
+ StaticFieldLookupFunction = module->getFunction("staticFieldLookup");
GetExceptionFunction = module->getFunction("JavaThreadGetException");
GetJavaExceptionFunction = module->getFunction("JavaThreadGetJavaException");
@@ -982,7 +985,8 @@
module->getFunction("jniProceedPendingException");
GetSJLJBufferFunction = module->getFunction("getSJLJBuffer");
- NullPointerExceptionFunction = module->getFunction("jnjvmNullPointerException");
+ NullPointerExceptionFunction =
+ module->getFunction("jnjvmNullPointerException");
ClassCastExceptionFunction = module->getFunction("jnjvmClassCastException");
IndexOutOfBoundsExceptionFunction =
module->getFunction("indexOutOfBoundsException");
Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.h?rev=55437&r1=55436&r2=55437&view=diff
==============================================================================
--- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.h (original)
+++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.h Wed Aug 27 16:44:41 2008
@@ -313,7 +313,8 @@
static llvm::Function* GetSJLJBufferFunction;
static llvm::Function* InterfaceLookupFunction;
- static llvm::Function* FieldLookupFunction;
+ static llvm::Function* VirtualFieldLookupFunction;
+ static llvm::Function* StaticFieldLookupFunction;
static llvm::Function* PrintExecutionFunction;
static llvm::Function* PrintMethodStartFunction;
static llvm::Function* PrintMethodEndFunction;
More information about the vmkit-commits
mailing list