[vmkit-commits] [vmkit] r55600 - in /vmkit/branches/isolate/lib/JnJVM: Classpath/Classpath.cpp Classpath/ClasspathVMThread.cpp.inc Isolate/IsolateCommonClass.cpp Isolate/IsolateCommonClass.h VMCore/JavaClass.cpp VMCore/JavaClass.h VMCore/JavaConstantPool.cpp VMCore/JavaMetaJIT.cpp VMCore/JavaRuntimeJIT.cpp VMCore/Jni.cpp VMCore/Jnjvm.cpp VMCore/JnjvmModule.cpp VMCore/JnjvmModuleProvider.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Mon Sep 1 01:08:09 PDT 2008


Author: geoffray
Date: Mon Sep  1 03:08:08 2008
New Revision: 55600

URL: http://llvm.org/viewvc/llvm-project?rev=55600&view=rev
Log:
Add a definingCl when doing a lookup of a method.


Modified:
    vmkit/branches/isolate/lib/JnJVM/Classpath/Classpath.cpp
    vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMThread.cpp.inc
    vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp
    vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.h
    vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp
    vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h
    vmkit/branches/isolate/lib/JnJVM/VMCore/JavaConstantPool.cpp
    vmkit/branches/isolate/lib/JnJVM/VMCore/JavaMetaJIT.cpp
    vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
    vmkit/branches/isolate/lib/JnJVM/VMCore/Jni.cpp
    vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp
    vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp
    vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp

Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/Classpath.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Classpath/Classpath.cpp?rev=55600&r1=55599&r2=55600&view=diff

==============================================================================
--- vmkit/branches/isolate/lib/JnJVM/Classpath/Classpath.cpp (original)
+++ vmkit/branches/isolate/lib/JnJVM/Classpath/Classpath.cpp Mon Sep  1 03:08:08 2008
@@ -45,7 +45,9 @@
 jclass Cl) {
 
   UserCommonClass* cl = NativeUtil::resolvedImplClass(Cl, true);
-  if (cl->lookupMethodDontThrow(Jnjvm::clinitName, Jnjvm::clinitType, true, false))
+  UserClass* methodCl = 0;
+  if (cl->lookupMethodDontThrow(Jnjvm::clinitName, Jnjvm::clinitType, true,
+                                false, methodCl))
     return true;
   else
     return false;

Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMThread.cpp.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMThread.cpp.inc?rev=55600&r1=55599&r2=55600&view=diff

==============================================================================
--- vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMThread.cpp.inc (original)
+++ vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMThread.cpp.inc Mon Sep  1 03:08:08 2008
@@ -77,7 +77,8 @@
   vm->numThreads++;
   vm->lock->unlock();
 #endif
-  JavaMethod* method = vmthClass->lookupMethod(Jnjvm::runName, Jnjvm::clinitType, ACC_VIRTUAL, true);
+  UserClass* methodCl = 0;
+  JavaMethod* method = vmthClass->lookupMethod(Jnjvm::runName, Jnjvm::clinitType, false, true, methodCl);
   method->invokeIntSpecial(isolate, (UserClass*)vmthClass, vmThread);
 
   

Modified: vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp?rev=55600&r1=55599&r2=55600&view=diff

==============================================================================
--- vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp (original)
+++ vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp Mon Sep  1 03:08:08 2008
@@ -217,26 +217,32 @@
 JavaMethod* UserCommonClass::lookupMethodDontThrow(const UTF8* name,
                                                    const UTF8* type,
                                                    bool isStatic,
-                                                   bool recurse) {
+                                                   bool recurse,
+                                                   UserClass*& methodCl) {
   
   CommonClass::FieldCmp CC(name, type);
   CommonClass::method_map* map = isStatic ? getStaticMethods() :
                                             getVirtualMethods();
   CommonClass::method_iterator End = map->end();
   CommonClass::method_iterator I = map->find(CC);
-  if (I != End) return I->second;
+  if (I != End) {
+    methodCl = (UserClass*)this;
+    return I->second;
+  }
   
   JavaMethod *cur = 0;
   
   if (recurse) {
     if (super) cur = super->lookupMethodDontThrow(name, type, isStatic,
-                                                  recurse);
+                                                  recurse, methodCl);
     if (cur) return cur;
+
     if (isStatic) {
       std::vector<UserClass*>* interfaces = getInterfaces();
       for (std::vector<UserClass*>::iterator i = interfaces->begin(),
            e = interfaces->end(); i!= e; i++) {
-        cur = (*i)->lookupMethodDontThrow(name, type, isStatic, recurse);
+        cur = (*i)->lookupMethodDontThrow(name, type, isStatic, recurse,
+                                          methodCl);
         if (cur) return cur;
       }
     }
@@ -246,8 +252,10 @@
 }
 
 JavaMethod* UserCommonClass::lookupMethod(const UTF8* name, const UTF8* type,
-                                          bool isStatic, bool recurse) {
-  JavaMethod* res = lookupMethodDontThrow(name, type, isStatic, recurse);
+                                          bool isStatic, bool recurse,
+                                          UserClass*& methodCl) {
+  JavaMethod* res = lookupMethodDontThrow(name, type, isStatic, recurse,
+                                          methodCl);
   if (!res) {
     JavaThread::get()->isolate->noSuchMethodError(this->classDef, name);
   }
@@ -274,20 +282,15 @@
   if (recurse) {
     if (super) cur = super->lookupFieldDontThrow(name, type, isStatic,
                                                  recurse, definingClass);
-    if (cur) {
-      definingClass = (UserClass*)super;
-      return cur;
-    }
+    if (cur) return cur;
+
     if (isStatic) {
       std::vector<UserClass*>* interfaces = getInterfaces();
       for (std::vector<UserClass*>::iterator i = interfaces->begin(),
            e = interfaces->end(); i!= e; i++) {
         cur = (*i)->lookupFieldDontThrow(name, type, isStatic, recurse,
                                          definingClass);
-        if (cur) {
-          definingClass = *i;
-          return cur;
-        }
+        if (cur) return cur;
       }
     }
   }

Modified: vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.h?rev=55600&r1=55599&r2=55600&view=diff

==============================================================================
--- vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.h (original)
+++ vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.h Mon Sep  1 03:08:08 2008
@@ -174,10 +174,11 @@
 
 
   JavaMethod* lookupMethodDontThrow(const UTF8* name, const UTF8* type,
-                                    bool isStatic, bool recurse);
+                                    bool isStatic, bool recurse,
+                                    UserClass*& methodCl);
 
   JavaMethod* lookupMethod(const UTF8* name, const UTF8* type,
-                           bool isStatic, bool recurse);
+                           bool isStatic, bool recurse, UserClass*& methodCl);
 
   JavaField* lookupField(const UTF8* name, const UTF8* type,
                          bool isStatic, bool recurse,

Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp?rev=55600&r1=55599&r2=55600&view=diff

==============================================================================
--- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp Mon Sep  1 03:08:08 2008
@@ -331,26 +331,31 @@
 JavaMethod* CommonClass::lookupMethodDontThrow(const UTF8* name,
                                                const UTF8* type,
                                                bool isStatic,
-                                               bool recurse) {
+                                               bool recurse,
+                                               Class*& methodCl) {
   
   CommonClass::FieldCmp CC(name, type);
   CommonClass::method_map* map = isStatic ? getStaticMethods() :
                                             getVirtualMethods();
   CommonClass::method_iterator End = map->end();
   CommonClass::method_iterator I = map->find(CC);
-  if (I != End) return I->second;
+  if (I != End) {
+    methodCl = (Class*)this;
+    return I->second;
+  }
   
   JavaMethod *cur = 0;
   
   if (recurse) {
     if (super) cur = super->lookupMethodDontThrow(name, type, isStatic,
-                                                  recurse);
+                                                  recurse, methodCl);
     if (cur) return cur;
     if (isStatic) {
       std::vector<Class*>* interfaces = getInterfaces();
       for (std::vector<Class*>::iterator i = interfaces->begin(),
            e = interfaces->end(); i!= e; i++) {
-        cur = (*i)->lookupMethodDontThrow(name, type, isStatic, recurse);
+        cur = (*i)->lookupMethodDontThrow(name, type, isStatic, recurse,
+                                          methodCl);
         if (cur) return cur;
       }
     }
@@ -360,8 +365,10 @@
 }
 
 JavaMethod* CommonClass::lookupMethod(const UTF8* name, const UTF8* type,
-                                      bool isStatic, bool recurse) {
-  JavaMethod* res = lookupMethodDontThrow(name, type, isStatic, recurse);
+                                      bool isStatic, bool recurse,
+                                      Class*& methodCl) {
+  JavaMethod* res = lookupMethodDontThrow(name, type, isStatic, recurse,
+                                          methodCl);
   if (!res) {
     JavaThread::get()->isolate->noSuchMethodError(this, name);
   }
@@ -388,20 +395,14 @@
   if (recurse) {
     if (super) cur = super->lookupFieldDontThrow(name, type, isStatic,
                                                  recurse, definingClass);
-    if (cur) {
-      definingClass = (Class*)super;
-      return cur;
-    }
+    if (cur) return cur;
     if (isStatic) {
       std::vector<Class*>* interfaces = getInterfaces();
       for (std::vector<Class*>::iterator i = interfaces->begin(),
            e = interfaces->end(); i!= e; i++) {
         cur = (*i)->lookupFieldDontThrow(name, type, isStatic, recurse,
                                          definingClass);
-        if (cur) {
-          definingClass = *i;
-          return cur;
-        }
+        if (cur) return cur;
       }
     }
   }

Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h?rev=55600&r1=55599&r2=55600&view=diff

==============================================================================
--- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h Mon Sep  1 03:08:08 2008
@@ -370,12 +370,12 @@
   /// Do not throw if the method is not found.
   ///
   JavaMethod* lookupMethodDontThrow(const UTF8* name, const UTF8* type,
-                                    bool isStatic, bool recurse);
+                                    bool isStatic, bool recurse, Class*& cl);
   
   /// lookupMethod - Lookup a method and throw an exception if not found.
   ///
   JavaMethod* lookupMethod(const UTF8* name, const UTF8* type, bool isStatic,
-                           bool recurse);
+                           bool recurse, Class*& cl);
   
   /// lookupFieldDontThrow - Lookup a field in the field map of this class. Do
   /// not throw if the field is not found.

Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaConstantPool.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaConstantPool.cpp?rev=55600&r1=55599&r2=55600&view=diff

==============================================================================
--- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaConstantPool.cpp (original)
+++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaConstantPool.cpp Mon Sep  1 03:08:08 2008
@@ -351,9 +351,10 @@
   const UTF8* utf8 = UTF8At(ctpDef[ntIndex] >> 16);
   cl = getMethodClassIfLoaded(entry >> 16);
   if (cl && cl->status >= classRead) {
+    Class* methodCl = 0;
     // lookup the method
-    meth = 
-      cl->lookupMethodDontThrow(utf8, sign->keyName, isStatic(access), false);
+    meth = cl->lookupMethodDontThrow(utf8, sign->keyName, isStatic(access),
+                                     false, methodCl);
   } 
 }
 
@@ -395,8 +396,9 @@
   CommonClass* cl = getMethodClassIfLoaded(entry >> 16);
   if (cl && cl->status >= classRead) {
     // lookup the method
-    meth =
-      cl->lookupMethodDontThrow(utf8, sign->keyName, isStatic(access), false);
+    Class* methodCl = 0;
+    meth = cl->lookupMethodDontThrow(utf8, sign->keyName, isStatic(access),
+                                     false, methodCl);
     if (meth) { 
       // don't throw if no meth, the exception will be thrown just in time
       JnjvmModule* M = classDef->classLoader->TheModule;

Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaMetaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaMetaJIT.cpp?rev=55600&r1=55599&r2=55600&view=diff

==============================================================================
--- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaMetaJIT.cpp (original)
+++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaMetaJIT.cpp Mon Sep  1 03:08:08 2008
@@ -34,9 +34,10 @@
   
   cl->initialiseClass(vm);
   bool stat = access == ACC_STATIC ? true : false;
+  UserClass* methodCl = 0;
   JavaMethod* method = cl->lookupMethod(loader->asciizConstructUTF8(func), 
                                         loader->asciizConstructUTF8(sign), stat,
-                                        true);
+                                        true, methodCl);
   va_list ap;
   va_start(ap, access);
   if (stat) {
@@ -141,7 +142,8 @@
   } \
   \
   verifyNull(obj);\
-  JavaMethod* meth = obj->classOf->lookupMethod(name, type, false, true);\
+  UserClass* methodCl = 0; \
+  JavaMethod* meth = obj->classOf->lookupMethod(name, type, false, true, methodCl);\
   \
   Signdef* sign = getSignature(); \
   void* func = meth->compiledPtr();\

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=55600&r1=55599&r2=55600&view=diff

==============================================================================
--- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Mon Sep  1 03:08:08 2008
@@ -58,12 +58,12 @@
   }
 
   if (!rcache) {
+    UserClass* methodCl = 0;
+    JavaMethod* dmeth = ocl->lookupMethod(utf8, sign->keyName, false, true,
+                                          methodCl);
 #ifndef MULTIPLE_VM
-    JavaMethod* dmeth = ocl->lookupMethod(utf8, sign->keyName, false, true);
     assert(dmeth->classDef->isReady() &&
            "Class not ready in a virtual lookup.");
-#else
-    JavaMethod* dmeth = ocl->lookupMethod(utf8, sign->keyName, false, true);
 #endif
     if (cache->methPtr) {
       rcache = new CacheNode(enveloppe);
@@ -73,6 +73,9 @@
     
     rcache->methPtr = dmeth->compiledPtr();
     rcache->lastCible = (UserClass*)ocl;
+#ifdef MULTIPLE_VM
+    rcache->definingCtp = methodCl->getConstantPool();
+#endif
     
   }
 
@@ -156,8 +159,9 @@
   Signdef* sign = 0;
   
   caller->getConstantPool()->resolveMethod(index, cl, utf8, sign);
+  UserClass* methodCl = 0;
   JavaMethod* dmeth = cl->lookupMethodDontThrow(utf8, sign->keyName, false,
-                                                true);
+                                                true, methodCl);
   if (!dmeth) {
     va_list ap;
     va_start(ap, index);
@@ -166,7 +170,8 @@
     assert(obj->classOf->isReady() && "Class not ready in a virtual lookup.");
     // Arg, the bytecode is buggy! Perform the lookup on the object class
     // and do not update offset.
-    dmeth = obj->classOf->lookupMethod(utf8, sign->keyName, false, true);
+    dmeth = obj->classOf->lookupMethod(utf8, sign->keyName, false, true,
+                                       methodCl);
   } else {
     caller->getConstantPool()->ctpRes[index] = (void*)dmeth->offset;
   }

Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/Jni.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/Jni.cpp?rev=55600&r1=55599&r2=55600&view=diff

==============================================================================
--- vmkit/branches/isolate/lib/JnJVM/VMCore/Jni.cpp (original)
+++ vmkit/branches/isolate/lib/JnJVM/VMCore/Jni.cpp Mon Sep  1 03:08:08 2008
@@ -140,9 +140,10 @@
   UserCommonClass* cl = NativeUtil::resolvedImplClass(clazz, true);
   if (cl->isArray()) assert(0 && "implement me");
   JavaObject* res = ((UserClass*)cl)->doNew(vm);
-  JavaMethod* init =
-    cl->lookupMethod(Jnjvm::initName, 
-                     cl->classLoader->asciizConstructUTF8("(Ljava/lang/String;)V"), 0, 1);
+  UserClass* methodCl = 0;
+  JavaMethod* init = cl->lookupMethod(Jnjvm::initName, 
+              cl->classLoader->asciizConstructUTF8("(Ljava/lang/String;)V"),
+              false, true, methodCl);
   init->invokeIntSpecial(vm, (UserClass*)cl, res, vm->asciizToStr(msg));
   th->pendingException = res;
   th->returnFromNative();
@@ -300,9 +301,11 @@
   UserCommonClass* cl = NativeUtil::resolvedImplClass(clazz, true);
   const UTF8* name = cl->classLoader->asciizConstructUTF8(aname);
   const UTF8* type = cl->classLoader->asciizConstructUTF8(atype);
+  UserClass* methodCl = 0;
   JavaMethod* meth = cl->lookupMethod(
       name->javaToInternal(cl->classLoader->hashUTF8, 0, name->size),
-      type->javaToInternal(cl->classLoader->hashUTF8, 0, type->size), false, true);
+      type->javaToInternal(cl->classLoader->hashUTF8, 0, type->size), false,
+      true, methodCl);
 
   return (jmethodID)meth;
 
@@ -1134,9 +1137,11 @@
   UserCommonClass* cl = NativeUtil::resolvedImplClass(clazz, true);
   const UTF8* name = cl->classLoader->asciizConstructUTF8(aname);
   const UTF8* type = cl->classLoader->asciizConstructUTF8(atype);
+  UserClass* methodCl = 0;
   JavaMethod* meth = cl->lookupMethod(
       name->javaToInternal(cl->classLoader->hashUTF8, 0, name->size),
-      type->javaToInternal(cl->classLoader->hashUTF8, 0, type->size), true, true);
+      type->javaToInternal(cl->classLoader->hashUTF8, 0, type->size), true,
+      true, methodCl);
 
   return (jmethodID)meth;
 

Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp?rev=55600&r1=55599&r2=55600&view=diff

==============================================================================
--- vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp (original)
+++ vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp Mon Sep  1 03:08:08 2008
@@ -109,9 +109,10 @@
       cl->resolveStaticClass();
       
       status = inClinit;
+      UserClass* methodCl;
       JavaMethod* meth = lookupMethodDontThrow(Jnjvm::clinitName,
                                                Jnjvm::clinitType, true,
-                                               false);
+                                               false, methodCl);
       
       PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "; ", 0);
       PRINT_DEBUG(JNJVM_LOAD, 0, LIGHT_GREEN, "clinit ", 0);

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=55600&r1=55599&r2=55600&view=diff

==============================================================================
--- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp (original)
+++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp Mon Sep  1 03:08:08 2008
@@ -226,8 +226,10 @@
       }
     } else {
     
+      Class* methodCl = 0;
       JavaMethod* parent = cl->super? 
-        cl->super->lookupMethodDontThrow(meth->name, meth->type, false, true) :
+        cl->super->lookupMethodDontThrow(meth->name, meth->type, false, true,
+                                         methodCl) :
         0;
 
       uint64_t offset = 0;

Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp?rev=55600&r1=55599&r2=55600&view=diff

==============================================================================
--- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp (original)
+++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp Mon Sep  1 03:08:08 2008
@@ -36,7 +36,9 @@
   Signdef* sign = 0;
 
   ctpInfo->resolveMethod(index, cl, utf8, sign);
-  JavaMethod* meth = cl->lookupMethod(utf8, sign->keyName, isStatic, true);
+  Class* methodCl = 0;
+  JavaMethod* meth = cl->lookupMethod(utf8, sign->keyName, isStatic, true,
+                                      methodCl);
 
 #ifndef MULTIPLE_VM
   // A multi environment would have already initialized the class. Besides,





More information about the vmkit-commits mailing list