Set the LLVM type of the VT as an array of functions.

llvm-svn: 61136
diff --git a/vmkit/lib/JnJVM/LLVMRuntime/runtime-boehm.ll b/vmkit/lib/JnJVM/LLVMRuntime/runtime-boehm.ll
index 49b175b..19e9fa5 100644
--- a/vmkit/lib/JnJVM/LLVMRuntime/runtime-boehm.ll
+++ b/vmkit/lib/JnJVM/LLVMRuntime/runtime-boehm.ll
@@ -2,4 +2,4 @@
 ;;;;;;;;;;;;;;;;;;;; Collector specific methods ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-declare %JavaObject* @gcmalloc(i32, %VT)
+declare %JavaObject* @gcmalloc(i32, %VT*)
diff --git a/vmkit/lib/JnJVM/LLVMRuntime/runtime-default.ll b/vmkit/lib/JnJVM/LLVMRuntime/runtime-default.ll
index 5fa6ba5..62a58a8 100644
--- a/vmkit/lib/JnJVM/LLVMRuntime/runtime-default.ll
+++ b/vmkit/lib/JnJVM/LLVMRuntime/runtime-default.ll
@@ -3,10 +3,10 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 ;;; A virtual table is an array of function pointers.
-%VT = type i32 (...)**
+%VT = type [0 x i32 (...)*]
 
 ;;; The root of all Java Objects: a VT, a class and a lock.
-%JavaObject = type { %VT, %JavaCommonClass*, i8* }
+%JavaObject = type { %VT*, %JavaCommonClass*, i8* }
 
 ;;; Types for Java arrays. A size of 0 means an undefined size.
 %JavaArray = type { %JavaObject, i8* }
@@ -55,7 +55,7 @@
 declare i32 @arrayLength(%JavaObject*) readnone 
 
 ;;; getVT - Get the VT of the object.
-declare %VT @getVT(%JavaObject*) readnone 
+declare %VT* @getVT(%JavaObject*) readnone 
 
 ;;; getClass - Get the class of an object.
 declare %JavaCommonClass* @getClass(%JavaObject*) readnone 
@@ -64,7 +64,7 @@
 declare i8* @getLock(%JavaObject*)
 
 ;;; getVTFromClass - Get the VT of a class from its runtime representation.
-declare %VT @getVTFromClass(%JavaClass*) readnone 
+declare %VT* @getVTFromClass(%JavaClass*) readnone 
 
 ;;; getObjectSizeFromClass - Get the size of a class from its runtime
 ;;; representation.
@@ -185,7 +185,7 @@
 declare void @jniProceedPendingException()
 declare i8*  @getSJLJBuffer()
 
-declare %JavaObject* @gcmalloc(i32, %VT)
+declare %JavaObject* @gcmalloc(i32, %VT*)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Debugging methods ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
diff --git a/vmkit/lib/JnJVM/LLVMRuntime/runtime-isolate.ll b/vmkit/lib/JnJVM/LLVMRuntime/runtime-isolate.ll
index 7e1a1c8..00658cc 100644
--- a/vmkit/lib/JnJVM/LLVMRuntime/runtime-isolate.ll
+++ b/vmkit/lib/JnJVM/LLVMRuntime/runtime-isolate.ll
@@ -2,13 +2,13 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;; Isolate specific types ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-%Jnjvm = type {%VT, %JavaClass*, [9 x %JavaClass*]}
+%Jnjvm = type { %VT*, %JavaClass*, [9 x %JavaClass*] }
 
 %JavaCommonClass = type { %JavaCommonClass**, i32, [32 x %JavaObject*],
                           i16, %JavaClass**, i16, %UTF8*, %JavaClass*, i8* }
 
 
-%JavaClass = type { %JavaCommonClass, i32, %VT, [32 x %TaskClassMirror], i8*, 
+%JavaClass = type { %JavaCommonClass, i32, %VT*, [32 x %TaskClassMirror], i8*, 
                     %JavaField*, i16, %JavaField*, i16, %JavaMethod*, i16, 
                     %JavaMethod*, i16, i8*, %ArrayUInt8*, i8*, %Attribut*, 
                     i16, %JavaClass**, i16, %JavaClass*, i16, i8, i32, i32, i8*,
diff --git a/vmkit/lib/JnJVM/LLVMRuntime/runtime-single.ll b/vmkit/lib/JnJVM/LLVMRuntime/runtime-single.ll
index e15e75c..1fc93c4 100644
--- a/vmkit/lib/JnJVM/LLVMRuntime/runtime-single.ll
+++ b/vmkit/lib/JnJVM/LLVMRuntime/runtime-single.ll
@@ -6,7 +6,7 @@
                           %JavaClass**, i16, %UTF8*, %JavaClass*, i8* } 
 
 
-%JavaClass = type { %JavaCommonClass, i32, %VT, [1 x %TaskClassMirror], i8*, 
+%JavaClass = type { %JavaCommonClass, i32, %VT*, [1 x %TaskClassMirror], i8*, 
                     %JavaField*, i16, %JavaField*, i16, %JavaMethod*, i16, 
                     %JavaMethod*, i16, i8*, %ArrayUInt8*, i8*, %Attribut*, 
                     i16, %JavaClass**, i16, %JavaClass*, i16, i8, i32, i32, i8*,
diff --git a/vmkit/lib/JnJVM/VMCore/JavaJIT.cpp b/vmkit/lib/JnJVM/VMCore/JavaJIT.cpp
index 545a9fd..d4e739f 100644
--- a/vmkit/lib/JnJVM/VMCore/JavaJIT.cpp
+++ b/vmkit/lib/JnJVM/VMCore/JavaJIT.cpp
@@ -114,14 +114,16 @@
 
   Value* VT = CallInst::Create(module->GetVTFunction, args[0], "",
                                currentBlock);
-  Value* indexes2; //[3];
+  Value* indexes2[2];
+  indexes2[0] = module->constantZero;
+
 #ifdef ISOLATE_SHARING
   Value* indexesCtp; //[3];
 #endif
   if (meth) {
     LLVMMethodInfo* LMI = module->getMethodInfo(meth);
     ConstantInt* Offset = LMI->getOffset();
-    indexes2 = Offset;
+    indexes2[1] = Offset;
 #ifdef ISOLATE_SHARING
     indexesCtp = ConstantInt::get(Type::Int32Ty,
                                   Offset->getZExtValue() * -1);
@@ -130,7 +132,7 @@
     
     Value* val = getConstantPoolAt(index, module->VirtualLookupFunction,
                                    Type::Int32Ty, args[0], true);
-    indexes2 = val;
+    indexes2[1] = val;
 #ifdef ISOLATE_SHARING
     Value* mul = BinaryOperator::CreateMul(val, module->constantMinusOne,
                                            "", currentBlock);
@@ -138,9 +140,11 @@
 #endif
   }
   
-  Value* FuncPtr = GetElementPtrInst::Create(VT, indexes2, "", currentBlock);
+  Value* FuncPtr = GetElementPtrInst::Create(VT, indexes2, indexes2 + 2, "",
+                                             currentBlock);
     
   Value* Func = new LoadInst(FuncPtr, "", currentBlock);
+  
   Func = new BitCastInst(Func, LSI->getVirtualPtrType(), "", currentBlock);
 #ifdef ISOLATE_SHARING
   Value* CTP = GetElementPtrInst::Create(VT, indexesCtp, "", currentBlock);
diff --git a/vmkit/lib/JnJVM/VMCore/JnjvmModule.cpp b/vmkit/lib/JnJVM/VMCore/JnjvmModule.cpp
index eb580f4..395439d 100644
--- a/vmkit/lib/JnJVM/VMCore/JnjvmModule.cpp
+++ b/vmkit/lib/JnJVM/VMCore/JnjvmModule.cpp
@@ -536,7 +536,7 @@
     COPY(ArrayObject)
 
 #undef COPY
-
+    
    }
 #endif
   
@@ -1041,7 +1041,7 @@
   Module* module = this;
   initialModule = this;
 
-  VTType = module->getTypeByName("VT");
+  VTType = PointerType::getUnqual(module->getTypeByName("VT"));
 
 #ifdef ISOLATE_SHARING
   JnjvmType = 
diff --git a/vmkit/lib/Mvm/Runtime/LLVMRuntime.ll b/vmkit/lib/Mvm/Runtime/LLVMRuntime.ll
index 2010c98..e9169b5 100644
--- a/vmkit/lib/Mvm/Runtime/LLVMRuntime.ll
+++ b/vmkit/lib/Mvm/Runtime/LLVMRuntime.ll
@@ -3,7 +3,7 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 ;;; A virtual table is an array of function pointers.
-%VT = type i32 (...)**
+%VT = type [0 x i32 (...)*]
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Printing functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;