[vmkit-commits] [vmkit] r60036 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaClass.cpp JavaClass.h JavaConstantPool.cpp JavaJIT.cpp JavaJIT.h

Nicolas Geoffray nicolas.geoffray at lip6.fr
Tue Nov 25 10:10:37 PST 2008


Author: geoffray
Date: Tue Nov 25 12:10:37 2008
New Revision: 60036

URL: http://llvm.org/viewvc/llvm-project?rev=60036&view=rev
Log:
Better handling of buggy invokevirtual which are in fact invokeinterface.


Modified:
    vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Tue Nov 25 12:10:37 2008
@@ -419,6 +419,16 @@
   return buf->contents()->cString();
 }
 
+JavaMethod* CommonClass::lookupInterfaceMethodDontThrow(const UTF8* name,
+                                                        const UTF8* type) {
+  for (uint16 i = 0; i < nbInterfaces; ++i) {
+    Class* I = interfaces[i];
+    JavaMethod* cur = I->lookupMethodDontThrow(name, type, false, true, 0);
+    if (cur) return cur;
+  }
+  return 0;
+}
+
 JavaMethod* CommonClass::lookupMethodDontThrow(const UTF8* name,
                                                const UTF8* type,
                                                bool isStatic,

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Tue Nov 25 12:10:37 2008
@@ -369,6 +369,13 @@
   JavaMethod* lookupMethodDontThrow(const UTF8* name, const UTF8* type,
                                     bool isStatic, bool recurse, Class** cl);
   
+  /// lookupInterfaceMethodDontThrow - Lookup a method in the interfaces of
+  /// this class.
+  /// Do not throw if the method is not found.
+  ///
+  JavaMethod* lookupInterfaceMethodDontThrow(const UTF8* name,
+                                             const UTF8* type);
+  
   /// 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/JnJVM/VMCore/JavaConstantPool.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp?rev=60036&r1=60035&r2=60036&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp Tue Nov 25 12:10:37 2008
@@ -370,9 +370,8 @@
     // interface method. Lookup the method as if it was static.
     // The caller is responsible for taking any action if the method is
     // an interface method.
-    
     if (!meth) {
-      meth = cl->lookupMethodDontThrow(utf8, sign->keyName, true, true, 0);
+      meth = cl->lookupInterfaceMethodDontThrow(utf8, sign->keyName);
     }
   }
 }

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=60036&r1=60035&r2=60036&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Tue Nov 25 12:10:37 2008
@@ -69,9 +69,12 @@
   if ((cl && isFinal(cl->access)) || 
       (meth && (isFinal(meth->access) || isPrivate(meth->access))))
     return invokeSpecial(index);
- 
-  if (meth && isInterface(meth->classDef->access))
-    return invokeInterfaceOrVirtual(index);
+
+  // If the method is in fact a method defined in an interface,
+  // call invokeInterfaceOrVirtual instead.
+  if (meth && isInterface(meth->classDef->access)) {
+    return invokeInterfaceOrVirtual(index, true);
+  }
 
 #if !defined(WITHOUT_VTABLE)
   Signdef* signature = ctpInfo->infoOfInterfaceOrVirtualMethod(index);
@@ -1979,7 +1982,7 @@
 }
 
 
-void JavaJIT::invokeInterfaceOrVirtual(uint16 index) {
+void JavaJIT::invokeInterfaceOrVirtual(uint16 index, bool buggyVirtual) {
   
   // Do the usual
   JavaConstantPool* ctpInfo = compilingClass->ctpInfo;
@@ -2008,7 +2011,9 @@
 
 #ifndef ISOLATE_SHARING
   // ok now the cache
-  Enveloppe& enveloppe = compilingMethod->enveloppes[nbEnveloppes++];
+  Enveloppe& enveloppe = buggyVirtual ?
+    *(new (compilingClass->classLoader->allocator) Enveloppe()) :
+    compilingMethod->enveloppes[nbEnveloppes++];
   if (!inlining)
     enveloppe.initialise(compilingClass->ctpInfo, index);
    

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h?rev=60036&r1=60035&r2=60036&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h Tue Nov 25 12:10:37 2008
@@ -222,7 +222,7 @@
   void makeArgs(llvm::FunctionType::param_iterator it,
                 uint32 index, std::vector<llvm::Value*>& result, uint32 nb);
   void invokeVirtual(uint16 index);
-  void invokeInterfaceOrVirtual(uint16 index);
+  void invokeInterfaceOrVirtual(uint16 index, bool buggyVirtual = false);
   void invokeSpecial(uint16 index);
   void invokeStatic(uint16 index);
   void invokeNew(uint16 index);





More information about the vmkit-commits mailing list