[vmkit-commits] [vmkit] r96514 - in /vmkit/trunk/lib/J3/VMCore: JavaClass.cpp JavaClass.h JavaConstantPool.cpp JavaRuntimeJIT.cpp Jnjvm.cpp Jnjvm.h

Nicolas Geoffray nicolas.geoffray at lip6.fr
Wed Feb 17 13:04:55 PST 2010


Author: geoffray
Date: Wed Feb 17 15:04:54 2010
New Revision: 96514

URL: http://llvm.org/viewvc/llvm-project?rev=96514&view=rev
Log:
Correctly implement invokespecial.


Modified:
    vmkit/trunk/lib/J3/VMCore/JavaClass.cpp
    vmkit/trunk/lib/J3/VMCore/JavaClass.h
    vmkit/trunk/lib/J3/VMCore/JavaConstantPool.cpp
    vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp
    vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp
    vmkit/trunk/lib/J3/VMCore/Jnjvm.h

Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.cpp?rev=96514&r1=96513&r2=96514&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/JavaClass.cpp Wed Feb 17 15:04:54 2010
@@ -363,11 +363,24 @@
   return cur;
 }
 
-JavaMethod* Class::lookupMethodDontThrow(const UTF8* name,
-                                               const UTF8* type,
-                                               bool isStatic,
-                                               bool recurse,
-                                               Class** methodCl) {
+JavaMethod* Class::lookupSpecialMethodDontThrow(const UTF8* name,
+                                                const UTF8* type,
+                                                Class* current) {
+  JavaMethod* meth = lookupMethodDontThrow(name, type, false, true, NULL);
+
+  if (isSuper(current->access) &&
+      current != meth->classDef &&
+      meth->classDef->isAssignableFrom(current) &&
+      !name->equals(classLoader->bootstrapLoader->initName)) {
+    meth = current->super->lookupMethodDontThrow(name, type, false, true, NULL);
+  }
+
+  return meth;
+}
+
+JavaMethod* Class::lookupMethodDontThrow(const UTF8* name, const UTF8* type,
+                                         bool isStatic, bool recurse,
+                                         Class** methodCl) {
   
   JavaMethod* methods = 0;
   uint32 nb = 0;

Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.h?rev=96514&r1=96513&r2=96514&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/J3/VMCore/JavaClass.h Wed Feb 17 15:04:54 2010
@@ -618,6 +618,14 @@
   JavaMethod* lookupInterfaceMethodDontThrow(const UTF8* name,
                                              const UTF8* type);
   
+  /// lookupSpecialMethodDontThrow - Lookup a method following the
+  /// invokespecial specification.
+  /// Do not throw if the method is not found.
+  ///
+  JavaMethod* lookupSpecialMethodDontThrow(const UTF8* name,
+                                           const UTF8* type,
+                                           Class* current);
+  
   /// lookupMethod - Lookup a method and throw an exception if not found.
   ///
   JavaMethod* lookupMethod(const UTF8* name, const UTF8* type, bool isStatic,

Modified: vmkit/trunk/lib/J3/VMCore/JavaConstantPool.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaConstantPool.cpp?rev=96514&r1=96513&r2=96514&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JavaConstantPool.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/JavaConstantPool.cpp Wed Feb 17 15:04:54 2010
@@ -433,8 +433,13 @@
     Class* lookup = cl->isArray() ? cl->super : cl->asClass();
     if (lookup->isResolved()) {
       // lookup the method
-      meth = lookup->lookupMethodDontThrow(utf8, sign->keyName,
-                                           isStatic(access), true, 0);
+      if (isStatic(access)) {
+        meth = lookup->lookupMethodDontThrow(utf8, sign->keyName,
+                                             true, true, 0);
+      } else {
+        meth = lookup->lookupSpecialMethodDontThrow(utf8, sign->keyName,
+                                                    classDef);
+      }
     }
   }
   

Modified: vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp?rev=96514&r1=96513&r2=96514&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp Wed Feb 17 15:04:54 2010
@@ -714,7 +714,12 @@
   ctpInfo->resolveMethod(ctpIndex, cl, utf8, sign);
   UserClass* lookup = cl->isArray() ? cl->super : cl->asClass();
   assert(lookup->isInitializing() && "Class not ready");
-  JavaMethod* callee = lookup->lookupMethod(utf8, sign->keyName, false, true,0);
+  JavaMethod* callee =
+    lookup->lookupSpecialMethodDontThrow(utf8, sign->keyName, caller->classDef);
+  
+  if (!callee) {
+    th->getJVM()->abstractMethodError(lookup, utf8);
+  }
 
   // Compile the found method.
   result = callee->compiledPtr();

Modified: vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp?rev=96514&r1=96513&r2=96514&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp Wed Feb 17 15:04:54 2010
@@ -526,6 +526,13 @@
         upcalls->InitNoSuchMethodError, str);
 }
 
+void Jnjvm::abstractMethodError(CommonClass* cl, const UTF8* name) {
+  JavaString* str = CreateNoSuchMsg(cl, name, this);
+  llvm_gcroot(str, 0);
+  error(upcalls->AbstractMethodError,
+        upcalls->InitAbstractMethodError, str);
+}
+
 static JavaString* CreateUnableToLoad(const UTF8* name, Jnjvm* vm) {
   ArrayUInt16* msg = (ArrayUInt16*)
     vm->upcalls->ArrayOfChar->doNew(15 + name->size, vm);

Modified: vmkit/trunk/lib/J3/VMCore/Jnjvm.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Jnjvm.h?rev=96514&r1=96513&r2=96514&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/VMCore/Jnjvm.h (original)
+++ vmkit/trunk/lib/J3/VMCore/Jnjvm.h Wed Feb 17 15:04:54 2010
@@ -267,6 +267,7 @@
   void classCastException(JavaObject* obj, UserCommonClass* cl);
   void noSuchFieldError(CommonClass* cl, const UTF8* name);
   void noSuchMethodError(CommonClass* cl, const UTF8* name); 
+  void abstractMethodError(CommonClass* cl, const UTF8* name); 
   void noClassDefFoundError(const UTF8* name);
   void classNotFoundException(JavaString* str);
 





More information about the vmkit-commits mailing list