[vmkit-commits] [vmkit] r91628 - in /vmkit/trunk/lib/J3/Compiler: JavaAOTCompiler.cpp JavaJITCompiler.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Thu Dec 17 13:56:41 PST 2009


Author: geoffray
Date: Thu Dec 17 15:56:40 2009
New Revision: 91628

URL: http://llvm.org/viewvc/llvm-project?rev=91628&view=rev
Log:
Temporary hack in case a class does not imlement a method interface. This
should not happen, but maybe some Java compilers omit the check.


Modified:
    vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp
    vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp

Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=91628&r1=91627&r2=91628&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Thu Dec 17 15:56:40 2009
@@ -1487,6 +1487,7 @@
         JavaMethod* meth = cl->lookupMethodDontThrow(Imeth->name,
                                                      Imeth->type,
                                                      false, true, 0);
+        assert(meth && "No method found");
         LLVMMethodInfo* LMI = getMethodInfo(meth);
         Function* func = LMI->getMethod();
         IElemts.push_back(ConstantExpr::getBitCast(func, PTy));
@@ -1508,6 +1509,7 @@
         }
 
         if (SameMethod) {
+          assert(methods[0] && "No method found");
           LLVMMethodInfo* LMI = getMethodInfo(methods[0]);
           Function* func = LMI->getMethod();
           IElemts.push_back(ConstantExpr::getBitCast(func, PTy));
@@ -1526,6 +1528,7 @@
                et = methods.end(); it != et; ++it, ++Interf) {
             JavaMethod* Imeth = *Interf;
             JavaMethod* Cmeth = *it;
+            assert(Cmeth && "No method found");
 
             LLVMMethodInfo* LMI = getMethodInfo(Cmeth);
             Function* func = LMI->getMethod();

Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=91628&r1=91627&r2=91628&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Thu Dec 17 15:56:40 2009
@@ -255,6 +255,10 @@
 
 }
 
+extern "C" void ThrowUnfoundInterface() {
+  abort();
+}
+
 void JavaJITCompiler::makeIMT(Class* cl) {
   InterfaceMethodTable* IMT = cl->virtualVT->IMT;
   if (!IMT) return;
@@ -272,10 +276,14 @@
       JavaMethod* meth = cl->lookupMethodDontThrow(Imeth->name,
                                                    Imeth->type,
                                                    false, true, 0);
-      LLVMMethodInfo* LMI = getMethodInfo(meth);
-      Function* func = LMI->getMethod();
-      uintptr_t res = (uintptr_t)EE->getPointerToFunctionOrStub(func);
-      IMT->contents[i] = res;
+      if (meth) {
+        LLVMMethodInfo* LMI = getMethodInfo(meth);
+        Function* func = LMI->getMethod();
+        uintptr_t res = (uintptr_t)EE->getPointerToFunctionOrStub(func);
+        IMT->contents[i] = res;
+      } else {
+        IMT->contents[i] = (uintptr_t)ThrowUnfoundInterface;
+      }
     } else if (size > 1) {
       std::vector<JavaMethod*> methods;
       bool SameMethod = true;
@@ -289,15 +297,19 @@
        
         if (OldMethod && OldMethod != Cmeth) SameMethod = false;
         else OldMethod = Cmeth;
-        
-        methods.push_back(Cmeth);
+       
+        if (Cmeth) methods.push_back(Cmeth);
       }
 
       if (SameMethod) {
-        LLVMMethodInfo* LMI = getMethodInfo(methods[0]);
-        Function* func = LMI->getMethod();
-        uintptr_t res = (uintptr_t)EE->getPointerToFunctionOrStub(func);
-        IMT->contents[i] = res;
+        if (methods[0]) {
+          LLVMMethodInfo* LMI = getMethodInfo(methods[0]);
+          Function* func = LMI->getMethod();
+          uintptr_t res = (uintptr_t)EE->getPointerToFunctionOrStub(func);
+          IMT->contents[i] = res;
+        } else {
+          IMT->contents[i] = (uintptr_t)ThrowUnfoundInterface;
+        }
       } else {
 
         uint32_t length = 2 * size * sizeof(uintptr_t);
@@ -313,12 +325,16 @@
              et = methods.end(); it != et; ++it, j += 2, ++Interf) {
           JavaMethod* Imeth = *Interf;
           JavaMethod* Cmeth = *it;
-          
-          LLVMMethodInfo* LMI = getMethodInfo(Cmeth);
-          Function* func = LMI->getMethod();
-          uintptr_t res = (uintptr_t)EE->getPointerToFunctionOrStub(func);
+         
           table[j] = (uintptr_t)Imeth;
-          table[j + 1] = res;
+          if (Cmeth) {
+            LLVMMethodInfo* LMI = getMethodInfo(Cmeth);
+            Function* func = LMI->getMethod();
+            uintptr_t res = (uintptr_t)EE->getPointerToFunctionOrStub(func);
+            table[j + 1] = res;
+          } else {
+            table[j + 1] = (uintptr_t)ThrowUnfoundInterface;
+          }
         }
       }
     }





More information about the vmkit-commits mailing list