[vmkit-commits] [vmkit] r61854 - in /vmkit/trunk/lib/JnJVM: LLVMRuntime/runtime-default.ll VMCore/JavaJIT.cpp VMCore/JavaJITOpcodes.cpp VMCore/JnjvmModule.cpp VMCore/JnjvmModule.h

Nicolas Geoffray nicolas.geoffray at lip6.fr
Wed Jan 7 01:16:04 PST 2009


Author: geoffray
Date: Wed Jan  7 03:16:02 2009
New Revision: 61854

URL: http://llvm.org/viewvc/llvm-project?rev=61854&view=rev
Log:
The static compiler can now emit debug info when executing.


Modified:
    vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll
    vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h

Modified: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll?rev=61854&r1=61853&r2=61854&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll (original)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll Wed Jan  7 03:16:02 2009
@@ -207,6 +207,6 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Debugging methods ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-declare void @printExecution(i32, i32, i8*)
-declare void @printMethodStart(i8*)
-declare void @printMethodEnd(i8*)
+declare void @printExecution(i32, i32, %JavaMethod*)
+declare void @printMethodStart(%JavaMethod*)
+declare void @printMethodEnd(%JavaMethod*)

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Wed Jan  7 03:16:02 2009
@@ -637,9 +637,7 @@
     
 #if JNJVM_EXECUTE > 0
     {
-    Value* arg = ConstantExpr::getIntToPtr(
-          ConstantInt::get(Type::Int64Ty, uint64_t (compilingMethod)),
-          module->ptrType);
+    Value* arg = module->getMethodInClass(compilingMethod);
 
     llvm::CallInst::Create(module->PrintMethodStartFunction, arg, "",
                            currentBlock);
@@ -813,9 +811,7 @@
 
 #if JNJVM_EXECUTE > 0
     {
-    Value* arg =  ConstantExpr::getIntToPtr(
-          ConstantInt::get(Type::Int64Ty, uint64_t (compilingMethod)),
-          module->ptrType);
+    Value* arg = module->getMethodInClass(compilingMethod); 
     CallInst::Create(module->PrintMethodEndFunction, arg, "", currentBlock);
     }
 #endif

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Wed Jan  7 03:16:02 2009
@@ -123,9 +123,9 @@
     
     PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "\t[at %5d] %-5d ", i,
                 bytecodes[i]);
-    PRINT_DEBUG(JNJVM_COMPILE, 1, LIGHT_BLUE, "compiling ", 0);
-    PRINT_DEBUG(JNJVM_COMPILE, 1, LIGHT_CYAN, OpcodeNames[bytecodes[i]], 0);
-    PRINT_DEBUG(JNJVM_COMPILE, 1, LIGHT_BLUE, "\n", 0);
+    PRINT_DEBUG(JNJVM_COMPILE, 1, LIGHT_BLUE, "compiling ");
+    PRINT_DEBUG(JNJVM_COMPILE, 1, LIGHT_CYAN, OpcodeNames[bytecodes[i]]);
+    PRINT_DEBUG(JNJVM_COMPILE, 1, LIGHT_BLUE, "\n");
     
     Opinfo* opinfo = &(opcodeInfos[i]);
     if (opinfo->newBlock) {
@@ -146,10 +146,7 @@
       Value* args[3] = {
         ConstantInt::get(Type::Int32Ty, (int64_t)bytecodes[i]),
         ConstantInt::get(Type::Int32Ty, (int64_t)i),
-    
-        ConstantExpr::getIntToPtr(
-            ConstantInt::get(Type::Int64Ty, (int64_t)compilingMethod),
-            module->ptrType) 
+        module->getMethodInClass(compilingMethod)
       };
     
     
@@ -2198,9 +2195,9 @@
     
     PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "\t[at %5d] %-5d ", i,
                 bytecodes[i]);
-    PRINT_DEBUG(JNJVM_COMPILE, 1, LIGHT_BLUE, "exploring ",0);
-    PRINT_DEBUG(JNJVM_COMPILE, 1, LIGHT_CYAN, OpcodeNames[bytecodes[i]], 0);
-    PRINT_DEBUG(JNJVM_COMPILE, 1, LIGHT_BLUE, "\n", 0);
+    PRINT_DEBUG(JNJVM_COMPILE, 1, LIGHT_BLUE, "exploring ");
+    PRINT_DEBUG(JNJVM_COMPILE, 1, LIGHT_CYAN, OpcodeNames[bytecodes[i]]);
+    PRINT_DEBUG(JNJVM_COMPILE, 1, LIGHT_BLUE, "\n");
     
     switch (bytecodes[i]) {
       

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp Wed Jan  7 03:16:02 2009
@@ -199,6 +199,50 @@
   }
 }
 
+Constant* JnjvmModule::getMethodInClass(JavaMethod* meth) {
+  if (staticCompilation) {
+    method_iterator SI = methods.find(meth);
+    if (SI != methods.end()) {
+      return SI->second;
+    } else {
+      Class* cl = meth->classDef;
+      Constant* MOffset = 0;
+      Constant* COffset = 0;
+      
+      if (isVirtual(meth->access)) {
+        COffset = ConstantInt::get(Type::Int32Ty, 9);
+        for (uint32 i = 0; i < cl->nbVirtualMethods; ++i) {
+          if (&cl->virtualMethods[i] == meth) {
+            MOffset = ConstantInt::get(Type::Int32Ty, i);
+            break;
+          }
+        }
+      } else {
+        COffset = ConstantInt::get(Type::Int32Ty, 11);
+        for (uint32 i = 0; i < cl->nbStaticMethods; ++i) {
+          if (&cl->staticMethods[i] == meth) {
+            MOffset = ConstantInt::get(Type::Int32Ty, i);
+            break;
+          }
+        }
+      }
+
+      Constant* C = getNativeClass(cl);
+
+      Value* Elts[3]  = { constantZero, COffset, MOffset };
+      
+      Constant* res = ConstantExpr::getGetElementPtr(C, Elts, 3);
+
+      methods.insert(std::make_pair(meth, res));
+      return res;
+    }
+    
+  } else {
+    ConstantInt* CI = ConstantInt::get(Type::Int64Ty, (int64_t)meth);
+    return ConstantExpr::getIntToPtr(CI, JavaMethodType);
+  }
+}
+
 Constant* JnjvmModule::getString(JavaString* str) {
   if (staticCompilation) {
     string_iterator SI = strings.find(str);

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h Wed Jan  7 03:16:02 2009
@@ -191,12 +191,16 @@
   std::map<const Enveloppe*, llvm::Constant*> enveloppes;
   std::map<const JavaMethod*, llvm::Constant*> nativeFunctions;
   std::map<const UTF8*, llvm::Constant*> utf8s;
+  std::map<const JavaMethod*, llvm::Constant*> methods;
+  
+  typedef std::map<const JavaMethod*, llvm::Constant*>::iterator
+    method_iterator;
   
   typedef std::map<const CommonClass*, llvm::Constant*>::iterator
-    native_class_iterator;  
+    native_class_iterator; 
   
   typedef std::map<const ClassArray*, llvm::GlobalVariable*>::iterator
-    array_class_iterator;  
+    array_class_iterator;
   
   typedef std::map<const CommonClass*, llvm::Constant*>::iterator
     java_class_iterator;
@@ -205,7 +209,7 @@
     virtual_table_iterator;
   
   typedef std::map<const Class*, llvm::Constant*>::iterator
-    static_instance_iterator;  
+    static_instance_iterator;
   
   typedef std::map<const JavaConstantPool*, llvm::Constant*>::iterator
     constant_pool_iterator;
@@ -407,6 +411,7 @@
   llvm::Constant* getJavaClass(CommonClass* cl);
   llvm::Constant* getStaticInstance(Class* cl);
   llvm::Constant* getVirtualTable(Class* cl);
+  llvm::Constant* getMethodInClass(JavaMethod* meth);
   
   llvm::Constant* getEnveloppe(Enveloppe* enveloppe);
   llvm::Constant* getString(JavaString* str);





More information about the vmkit-commits mailing list