[vmkit-commits] [vmkit] r60836 - in /vmkit/trunk/lib/JnJVM: LLVMRuntime/runtime-default.ll LLVMRuntime/runtime-isolate.ll LLVMRuntime/runtime-single.ll VMCore/JavaCache.cpp VMCore/JavaCache.h VMCore/JavaConstantPool.cpp VMCore/JavaConstantPool.h VMCore/JavaJIT.cpp VMCore/JavaRuntimeJIT.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Wed Dec 10 05:53:44 PST 2008
Author: geoffray
Date: Wed Dec 10 07:53:05 2008
New Revision: 60836
URL: http://llvm.org/viewvc/llvm-project?rev=60836&view=rev
Log:
Inline the first cache inside the enveloppe. And an
enveloppe now references name and sign, not the constant pool
it belongs to.
Modified:
vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll
vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-isolate.ll
vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-single.ll
vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h
vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.h
vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.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=60836&r1=60835&r2=60836&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll (original)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll Wed Dec 10 07:53:05 2008
@@ -21,9 +21,12 @@
%ArrayUInt32 = type { %JavaObject, i8*, [0 x i32] }
%ArrayUInt8 = type { %JavaObject, i8*, [0 x i8] }
+;;; The CacheNode type. The first field is the last called method.
+%CacheNode = type { i8*, %JavaCommonClass*, %CacheNode*, %Enveloppe* }
+
;;; The Enveloppe type, which contains the first cache and all the info
;;; to lookup in the constant pool.
-%Enveloppe = type { %CacheNode*, i8**, i8*, i32 }
+%Enveloppe = type { %CacheNode*, %UTF8*, i8*, i8*, %CacheNode }
;;; The task class mirror.
;;; Field 1: The class state
Modified: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-isolate.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-isolate.ll?rev=60836&r1=60835&r2=60836&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-isolate.ll (original)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-isolate.ll Wed Dec 10 07:53:05 2008
@@ -14,10 +14,6 @@
i16, %JavaClass**, i16, %JavaClass*, i16, i8, i32, i32, i8*,
void (i8*)* }
-;;; The CacheNode type. The second field is the last called method. The
-;;; last field is for multi vm environment.
-%CacheNode = type { i8*, %JavaCommonClass*, %CacheNode*, %Enveloppe*, i8** }
-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;; Isolate specific methods ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Modified: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-single.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-single.ll?rev=60836&r1=60835&r2=60836&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-single.ll (original)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-single.ll Wed Dec 10 07:53:05 2008
@@ -12,6 +12,3 @@
i16, %JavaClass**, i16, %JavaClass*, i16, i8, i32, i32, i8*,
void (i8*)* }
-
-;;; The CacheNode type. The second field is the last called method.
-%CacheNode = type { i8*, %JavaCommonClass*, %CacheNode*, %Enveloppe*}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp?rev=60836&r1=60835&r2=60836&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp Wed Dec 10 07:53:05 2008
@@ -25,32 +25,3 @@
#include "types.h"
using namespace jnjvm;
-
-Enveloppe::~Enveloppe() {
- CacheNode* cache = firstCache;
- CacheNode* next = firstCache;
- mvm::BumpPtrAllocator& allocator = ctpInfo->classDef->classLoader->allocator;
- while(next) {
- next = cache->next;
- cache->~CacheNode();
- allocator.Deallocate(cache);
- cache = next;
- }
-}
-
-CacheNode::CacheNode(Enveloppe* E) {
- lastCible = 0;
- methPtr = 0;
- next = 0;
- enveloppe = E;
-#ifdef ISOLATE_SHARING
- definingCtp = 0;
-#endif
-}
-
-void Enveloppe::initialise(UserConstantPool* ctp, uint32 i) {
- mvm::BumpPtrAllocator& allocator = ctp->classDef->classLoader->allocator;
- firstCache = new(allocator) CacheNode(this);
- ctpInfo = ctp;
- index = i;
-}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h?rev=60836&r1=60835&r2=60836&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h Wed Dec 10 07:53:05 2008
@@ -33,8 +33,9 @@
namespace jnjvm {
class Enveloppe;
+class Signdef;
class UserClass;
-class UserConstantPool;
+class UTF8;
/// CacheNode - A {class, method pointer} pair.
class CacheNode : public mvm::PermanentObject {
@@ -52,49 +53,69 @@
/// enveloppe - The container to which this class belongs to.
Enveloppe* enveloppe;
-#ifdef ISOLATE_SHARING
- ///definingClass - The class that defined the method being called.
- ///
- UserConstantPool* definingCtp;
-#endif
-
/// CacheNode - Creates a CacheNode with empty values.
- CacheNode(Enveloppe* E);
+ CacheNode(Enveloppe* E) {
+ lastCible = 0;
+ methPtr = 0;
+ next = 0;
+ enveloppe = E;
+ }
};
/// Enveloppe - A reference to the linked list of CacheNode.
class Enveloppe : public mvm::PermanentObject {
public:
- /// ~Enveloppe - Deletes all CacheNode in the linked list.
- ~Enveloppe();
-
/// firstCache - The first entry in the linked list, hence the last
/// class occurence for a given invokeinterface call.
+ ///
CacheNode *firstCache;
+
+ /// methodName - The name of the method to be called.
+ ///
+ const UTF8* methodName;
- /// ctpInfo - The constant pool info that owns the invokeinterface
- /// bytecode. This is used to resolve the interface call at its first
- /// occurence.
- UserConstantPool* ctpInfo;
+ /// methodSign - The signature of the method to be called.
+ ///
+ Signdef* methodSign;
/// cacheLock - The linked list may be modified by concurrent thread. This
/// lock ensures that the list stays consistent.
+ ///
mvm::LockNormal cacheLock;
- /// index - The index in the constant pool of the interface method.
- uint32 index;
+ /// allocator - Reference to the allocator in order to know where to allocate
+ /// cache nodes.
+ ///
+ mvm::BumpPtrAllocator* allocator;
+
+ /// bootCache - The first cache allocated for the enveloppe.
+ ///
+ CacheNode bootCache;
- /// 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(UserConstantPool* info, uint32 index) {
- initialise(info, index);
- }
+ /// Evenloppe - Default constructor. Does nothing.
+ ///
+ Enveloppe() : bootCache(this) {}
- Enveloppe() {}
+ /// Enveloppe - Allocates the linked list with the given name and signature
+ /// so as the resolution process knows which interface method the
+ /// invokeinterface bytecode refers to.
+ ///
+ Enveloppe(mvm::BumpPtrAllocator& Alloc, const UTF8* name, Signdef* sign) :
+ bootCache(this) {
+
+ initialise(Alloc, name, sign);
+ }
- void initialise(UserConstantPool* info, uint32 index);
+ /// initialise - Initialises the enveloppe, and allocates the first cache.
+ ///
+ void initialise(mvm::BumpPtrAllocator& Alloc, const UTF8* name,
+ Signdef* sign) {
+ allocator = &Alloc;
+ firstCache = &bootCache;
+ methodName = name;
+ methodSign = sign;
+ }
};
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp?rev=60836&r1=60835&r2=60836&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp Wed Dec 10 07:53:05 2008
@@ -447,15 +447,18 @@
}
-Signdef* JavaConstantPool::infoOfInterfaceOrVirtualMethod(uint32 index) {
+Signdef* JavaConstantPool::infoOfInterfaceOrVirtualMethod(uint32 index,
+ const UTF8*& name) {
uint8 id = typeAt(index);
if (id != ConstantMethodref && id != ConstantInterfaceMethodref)
JavaThread::get()->getJVM()->classFormatError(
"bad constant pool number for method at entry %d", index);
- Signdef* sign = resolveNameAndSign(ctpDef[index] & 0xFFFF);
-
+ sint32 entry = ctpDef[index];
+ sint32 ntIndex = entry & 0xFFFF;
+ Signdef* sign = resolveNameAndSign(ntIndex);
+ name = UTF8At(ctpDef[ntIndex] >> 16);
return sign;
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.h?rev=60836&r1=60835&r2=60836&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.h Wed Dec 10 07:53:05 2008
@@ -187,7 +187,7 @@
/// infoOfInterfaceOrVirtualMethod - Get the signature of the method
/// referenced at the given entry.
- Signdef* infoOfInterfaceOrVirtualMethod(uint32 index);
+ Signdef* infoOfInterfaceOrVirtualMethod(uint32 index, const UTF8*& name);
/// infoOfStaticOrSpecialMethod - Get the JIT representation of a
/// non-virtual method. Also returns its signature and the Jnjvm
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=60836&r1=60835&r2=60836&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Wed Dec 10 07:53:05 2008
@@ -77,7 +77,8 @@
}
#if !defined(WITHOUT_VTABLE)
- Signdef* signature = ctpInfo->infoOfInterfaceOrVirtualMethod(index);
+ const UTF8* name = 0;
+ Signdef* signature = ctpInfo->infoOfInterfaceOrVirtualMethod(index, name);
Typedef* retTypedef = signature->ret;
std::vector<Value*> args; // size = [signature->nbIn + 3];
LLVMSignatureInfo* LSI = module->getSignatureInfo(signature);
@@ -1972,7 +1973,8 @@
// Do the usual
JavaConstantPool* ctpInfo = compilingClass->ctpInfo;
- Signdef* signature = ctpInfo->infoOfInterfaceOrVirtualMethod(index);
+ const UTF8* name = 0;
+ Signdef* signature = ctpInfo->infoOfInterfaceOrVirtualMethod(index, name);
LLVMSignatureInfo* LSI = module->getSignatureInfo(signature);
const llvm::FunctionType* virtualType = LSI->getVirtualType();
@@ -2001,7 +2003,8 @@
*(new (compilingClass->classLoader->allocator) Enveloppe()) :
compilingMethod->enveloppes[nbEnveloppes++];
if (!inlining)
- enveloppe.initialise(compilingClass->ctpInfo, index);
+ enveloppe.initialise(compilingClass->classLoader->allocator, name,
+ signature);
Value* llvmEnv = module->getEnveloppe(&enveloppe, currentBlock);
#else
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp?rev=60836&r1=60835&r2=60836&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Wed Dec 10 07:53:05 2008
@@ -28,14 +28,8 @@
extern "C" void* jnjvmVirtualLookup(CacheNode* cache, JavaObject *obj) {
Enveloppe* enveloppe = cache->enveloppe;
- UserConstantPool* ctpInfo = enveloppe->ctpInfo;
UserCommonClass* ocl = obj->classOf;
- UserCommonClass* cl = 0;
- const UTF8* utf8 = 0;
- Signdef* sign = 0;
- uint32 index = enveloppe->index;
- ctpInfo->resolveMethod(index, cl, utf8, sign);
#ifndef SERVICE
assert((obj->classOf->isClass() &&
obj->classOf->asClass()->isInitializing()) &&
@@ -60,24 +54,24 @@
if (!rcache) {
UserClass* methodCl = 0;
UserClass* lookup = ocl->isArray() ? ocl->super : ocl->asClass();
- JavaMethod* dmeth = lookup->lookupMethod(utf8, sign->keyName, false, true,
- &methodCl);
+ JavaMethod* dmeth = lookup->lookupMethod(enveloppe->methodName,
+ enveloppe->methodSign->keyName,
+ false, true, &methodCl);
+
#if !defined(ISOLATE_SHARING) && !defined(SERVICE)
assert(dmeth->classDef->isInitializing() &&
"Class not ready in a virtual lookup.");
#endif
- if (cache->methPtr) {
- JnjvmClassLoader* loader = ctpInfo->classDef->classLoader;
- rcache = new(loader->allocator) CacheNode(enveloppe);
+
+ // Are we the first cache?
+ if (cache != &(enveloppe->bootCache)) {
+ rcache = new(*(enveloppe->allocator)) CacheNode(enveloppe);
} else {
rcache = cache;
}
rcache->methPtr = dmeth->compiledPtr();
rcache->lastCible = (UserClass*)ocl;
-#ifdef ISOLATE_SHARING
- rcache->definingCtp = methodCl->getConstantPool();
-#endif
}
More information about the vmkit-commits
mailing list