[vmkit-commits] [vmkit] r180387 - DEBUG related macros have been corrected

Peter Senna Tschudin peter.senna at gmail.com
Thu Apr 25 10:05:50 PDT 2013


Author: peter.senna
Date: Thu Apr 25 12:04:16 2013
New Revision: 180387

URL: http://llvm.org/viewvc/llvm-project?rev=180387&view=rev
Log:
DEBUG related macros have been corrected
(cherry picked from commit 74e68300ea023b404327dbe6a8a69a7b92164f67)

Modified:
    vmkit/trunk/lib/j3/Compiler/EscapeAnalysis.cpp
    vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp
    vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp
    vmkit/trunk/lib/j3/VMCore/JavaClass.cpp
    vmkit/trunk/lib/j3/VMCore/JavaConstantPool.cpp
    vmkit/trunk/lib/j3/VMCore/Jnjvm.cpp

Modified: vmkit/trunk/lib/j3/Compiler/EscapeAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/EscapeAnalysis.cpp?rev=180387&r1=180386&r2=180387&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/Compiler/EscapeAnalysis.cpp (original)
+++ vmkit/trunk/lib/j3/Compiler/EscapeAnalysis.cpp Thu Apr 25 12:04:16 2013
@@ -200,7 +200,7 @@ bool EscapeAnalysis::processMalloc(Instr
   // The object does not have a finalizer and is never used. Remove the
   // allocation as it will not have side effects.
   if (!hasFinalizer && !Alloc->getNumUses()) {
-    DEBUG(errs() << "Escape analysis removes instruction " << *Alloc << ": ");
+    //DEBUG(errs() << "Escape analysis removes instruction " << *Alloc << ": ");
     Alloc->eraseFromParent();
     return true;
   }
@@ -218,9 +218,9 @@ bool EscapeAnalysis::processMalloc(Instr
         // we don't end up with tons of allocations on the stack.
         BasicBlock* BB = CurLoop->getLoopPreheader();
         assert(BB && "No Preheader!");
-        DEBUG(errs() << "Escape analysis hoisting to " << BB->getName().str());
-        DEBUG(errs() << ": ");
-        DEBUG(errs() << *Alloc);
+      //DEBUG(errs() << "Escape analysis hoisting to " << BB->getName().str());
+        //DEBUG(errs() << ": ");
+        //DEBUG(errs() << *Alloc);
         Alloc->removeFromParent();
         BB->getInstList().insert(BB->getTerminator(), Alloc);
       }
@@ -228,8 +228,8 @@ bool EscapeAnalysis::processMalloc(Instr
       AllocaInst* AI = new AllocaInst(Type::getInt8Ty(Context), Size, "",
                                       Alloc);
       BitCastInst* BI = new BitCastInst(AI, Alloc->getType(), "", Alloc);
-      DEBUG(errs() << "escape");
-      DEBUG(errs() << Alloc->getParent()->getParent()->getName().str() << "\n");
+      //DEBUG(errs() << "escape");
+      //DEBUG(errs() << Alloc->getParent()->getParent()->getName().str() << "\n");
       Alloc->replaceAllUsesWith(BI);
       // If it's an invoke, replace the invoke with a direct branch.
       if (InvokeInst *CI = dyn_cast<InvokeInst>(Alloc)) {

Modified: vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp?rev=180387&r1=180386&r2=180387&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp Thu Apr 25 12:04:16 2013
@@ -8,8 +8,8 @@
 //===----------------------------------------------------------------------===//
 
 
-#define DEBUG 0
-#define JNJVM_COMPILE 0
+//#define DEBUG 0
+#define JNJVM_COMPILE 2
 #define JNJVM_EXECUTE 0
 
 #include <string>
@@ -375,7 +375,7 @@ static llvm::Function* GetNativeCallee(J
 
 llvm::Function* JavaJIT::nativeCompile(word_t natPtr) {
   
-  PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "native compile %s.%s\n",
+  PRINT_DEBUG(JNJVM_COMPILE, 1, DARK_GREEN, "nativeCompile %s.%s\n",
               UTF8Buffer(compilingClass->name).cString(),
               UTF8Buffer(compilingMethod->name).cString());
   
@@ -958,8 +958,8 @@ Instruction* JavaJIT::inlineCompile(Basi
   reader.cursor = start;
   compileOpcodes(reader, codeLen);
   
-  PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL,
-              "--> end inline compiling %s.%s\n",
+  PRINT_DEBUG(JNJVM_COMPILE, 1, DARK_MAGENTA,
+              "--> end inlineCompile for %s.%s\n",
               UTF8Buffer(compilingClass->name).cString(),
               UTF8Buffer(compilingMethod->name).cString());
 
@@ -993,7 +993,9 @@ static char* setInstructionName(char *s,
 }
 
 llvm::Function* JavaJIT::javaCompile() {
-  PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "compiling %s.%s\n",
+
+  PRINT_DEBUG(JNJVM_COMPILE, 1, DARK_CYAN, "javacompile for (%s.)%s.%s\n",
+			  (compilingClass->super)?UTF8Buffer(compilingClass->super->name).cString():"",
               UTF8Buffer(compilingClass->name).cString(),
               UTF8Buffer(compilingMethod->name).cString());
 
@@ -1270,7 +1272,7 @@ llvm::Function* JavaJIT::javaCompile() {
  
   delete[] opcodeInfos;
 
-  PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "--> end compiling %s.%s\n",
+  PRINT_DEBUG(JNJVM_COMPILE, 1, DARK_CYAN, "--> end of javacompile for %s.%s\n",
               UTF8Buffer(compilingClass->name).cString(),
               UTF8Buffer(compilingMethod->name).cString());
    

Modified: vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp?rev=180387&r1=180386&r2=180387&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp Thu Apr 25 12:04:16 2013
@@ -7,9 +7,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#define DEBUG 0
-#define JNJVM_COMPILE 0
-#define JNJVM_EXECUTE 0
+#define JNJVM_COMPILE 2
+#define JNJVM_EXECUTE 1
+
 
 #include <cstring>
 
@@ -107,9 +107,9 @@ void JavaJIT::compileOpcodes(Reader& rea
     reader.cursor = start + i;
     uint8 bytecode = reader.readU1();
     
-    PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "\t[at %5d] %-5d ", i,
+    PRINT_DEBUG(JNJVM_COMPILE, 1, DARK_BLUE, "\t[at %5d] %-5d ", i,
                 bytecode);
-    PRINT_DEBUG(JNJVM_COMPILE, 1, LIGHT_BLUE, "compiling ");
+    PRINT_DEBUG(JNJVM_COMPILE, 1, LIGHT_BLUE, " compiling ");
     PRINT_DEBUG(JNJVM_COMPILE, 1, LIGHT_CYAN, OpcodeNames[bytecode]);
     PRINT_DEBUG(JNJVM_COMPILE, 1, LIGHT_BLUE, "\n");
     
@@ -2380,12 +2380,15 @@ void JavaJIT::compileOpcodes(Reader& rea
 }
 
 void JavaJIT::exploreOpcodes(Reader& reader, uint32 codeLength) {
+	PRINT_DEBUG(JNJVM_COMPILE, 1, DARK_YELLOW, "exploreOpcodes %d \n", codeLength);
+
   bool wide = false;
   uint32 start = reader.cursor;
   for(uint32 i = 0; i < codeLength; ++i) {
     reader.cursor = start + i;
     uint8 bytecode = reader.readU1();
-    PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "\t[at %5d] %-5d ", i,
+
+    PRINT_DEBUG(JNJVM_COMPILE, 1, DARK_CYAN, "\t[at %5d] %-5d ", i,
                 bytecode);
     PRINT_DEBUG(JNJVM_COMPILE, 1, LIGHT_BLUE, "exploring ");
     PRINT_DEBUG(JNJVM_COMPILE, 1, LIGHT_CYAN, OpcodeNames[bytecode]);

Modified: vmkit/trunk/lib/j3/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaClass.cpp?rev=180387&r1=180386&r2=180387&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/j3/VMCore/JavaClass.cpp Thu Apr 25 12:04:16 2013
@@ -7,7 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#define JNJVM_LOAD 0
+#define JNJVM_LOAD 1
 
 #include "debug.h"
 #include "types.h"
@@ -887,12 +887,10 @@ void Class::readMethods(Reader& reader)
 }
 
 void Class::readClass() {
+  PRINT_DEBUG(JNJVM_LOAD, 0, LIGHT_GREEN, "readClass \t");
+  PRINT_DEBUG(JNJVM_LOAD, 0, DARK_MAGENTA, "%s\n", UTF8Buffer(this->name).cString());
 
   assert(getInitializationState() == loaded && "Wrong init state");
-  
-  PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "; ", 0);
-  PRINT_DEBUG(JNJVM_LOAD, 0, LIGHT_GREEN, "reading ", 0);
-  PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "%s\n", vmkit::PrintBuffer(this).cString());
 
   Reader reader(bytes);
   uint32 magic;

Modified: vmkit/trunk/lib/j3/VMCore/JavaConstantPool.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaConstantPool.cpp?rev=180387&r1=180386&r2=180387&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/JavaConstantPool.cpp (original)
+++ vmkit/trunk/lib/j3/VMCore/JavaConstantPool.cpp Thu Apr 25 12:04:16 2013
@@ -52,8 +52,7 @@ uint32 JavaConstantPool::CtpReaderClass(
                                    uint32 index) {
   uint16 entry = reader.readU2();
   ctp->ctpDef[index] = entry;
-  PRINT_DEBUG(JNJVM_LOAD, 3, COLOR_NORMAL, "; [%5d] <class>\t\tutf8 is at %d\n", e,
-              entry);
+  PRINT_DEBUG(JNJVM_LOAD, 3, COLOR_NORMAL, "; [%5d] <class>\t\tutf8 is at %d\n",entry);
   return 1;
 }
   
@@ -61,8 +60,7 @@ uint32 JavaConstantPool::CtpReaderIntege
                                      uint32 index) {
   uint32 val = reader.readU4();
   ctp->ctpDef[index] = val;
-  PRINT_DEBUG(JNJVM_LOAD, 3, COLOR_NORMAL, "; [%5d] <class>\tinteger: %d\n", e,
-              val);
+  PRINT_DEBUG(JNJVM_LOAD, 3, COLOR_NORMAL, "; [%5d] <class>\tinteger: %d\n", val);
   return 1;
 }
   
@@ -70,8 +68,7 @@ uint32 JavaConstantPool::CtpReaderFloat(
                                    uint32 index) { 
   uint32 val = reader.readU4();
   ctp->ctpDef[index] = val;
-  PRINT_DEBUG(JNJVM_LOAD, 3, COLOR_NORMAL, "; [%5d] <class>\tfloat: %d\n", e,
-              val);
+  PRINT_DEBUG(JNJVM_LOAD, 3, COLOR_NORMAL, "; [%5d] <class>\tfloat: %d\n", val);
   return 1;
 }
   
@@ -139,8 +136,8 @@ uint32 JavaConstantPool::CtpReaderLong(J
                                        uint32 index) {
   ctp->ctpDef[index + 1] = reader.readU4();
   ctp->ctpDef[index] = reader.readU4();
-  PRINT_DEBUG(JNJVM_LOAD, 3, COLOR_NORMAL, "; [%5d] <long>%d %d\n", index,
-              ctpDef[e], ctpDef[e + 1]);
+  PRINT_DEBUG(JNJVM_LOAD, 3, COLOR_NORMAL, "; [%5d] <long>%d %d %d\n", index,
+              ctp->ctpDef[index], ctp->ctpDef[index + 1]);
   return 2;
 }
 
@@ -223,7 +220,7 @@ const UTF8* JavaConstantPool::UTF8At(uin
     ctpRes[entry] = const_cast<UTF8*>(utf8);
   
     PRINT_DEBUG(JNJVM_LOAD, 3, COLOR_NORMAL, "; [%5d] <utf8>\t\t\"%s\"\n",
-                entry, UTF8Buffer(utf8)->cString());
+                entry, UTF8Buffer(utf8).cString());
 
   }
   return (const UTF8*)ctpRes[entry];

Modified: vmkit/trunk/lib/j3/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/Jnjvm.cpp?rev=180387&r1=180386&r2=180387&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/j3/VMCore/Jnjvm.cpp Thu Apr 25 12:04:16 2013
@@ -7,7 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#define JNJVM_LOAD 0
+#define JNJVM_LOAD 1
 
 #include <cfloat>
 #include <climits>
@@ -44,7 +44,7 @@ const char* Jnjvm::dirSeparator = "/";
 const char* Jnjvm::envSeparator = ":";
 const unsigned int Jnjvm::Magic = 0xcafebabe;
 
-/// initialiseClass - Java class initialisation. Java specification §2.17.5.
+/// initialiseClass - Java class initialization. Java specification §2.17.5.
 
 void UserClass::initialiseClass(Jnjvm* vm) {
   JavaObject* exc = NULL;
@@ -158,9 +158,9 @@ void UserClass::initialiseClass(Jnjvm* v
     //    final static variables and fields of interfaces whose values are 
     //    compile-time constants are initialized first.
     
-    PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "; ", 0);
-    PRINT_DEBUG(JNJVM_LOAD, 0, LIGHT_GREEN, "clinit ", 0);
-    PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "%s\n", vmkit::PrintString(this).cString());
+    //PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "; ");
+    PRINT_DEBUG(JNJVM_LOAD, 0, LIGHT_GREEN, "clinit ");
+    PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "%s\n", UTF8Buffer(this->name).cString());
 
     JavaField* fields = cl->getStaticFields();
     for (uint32 i = 0; i < cl->nbStaticFields; ++i) {
@@ -1344,6 +1344,13 @@ ArrayUInt16* Jnjvm::asciizToArray(const
 }
 
 void Jnjvm::startCollection() {
+
+#if DEBUG > 0
+	printf("Start Collection\n");
+	vmkit::Thread::get()->printBacktrace();
+	fflush(stdout);
+#endif
+
   finalizerThread->FinalizationQueueLock.acquire();
   referenceThread->ToEnqueueLock.acquire();
   referenceThread->SoftReferencesQueue.acquire();
@@ -1359,6 +1366,12 @@ void Jnjvm::endCollection() {
   referenceThread->PhantomReferencesQueue.release();
   finalizerThread->FinalizationCond.broadcast();
   referenceThread->EnqueueCond.broadcast();
+
+#if DEBUG > 0
+  printf("End Collection\n");
+  vmkit::Thread::get()->printBacktrace();
+  fflush(stdout);
+#endif
 }
   
 void Jnjvm::scanWeakReferencesQueue(word_t closure) {





More information about the vmkit-commits mailing list