[llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp

Alkis Evlogimenos alkis at cs.uiuc.edu
Sat Dec 4 20:05:14 PST 2004



Changes in directory llvm-java/lib/Compiler:

Compiler.cpp updated: 1.156 -> 1.157
---
Log message:

Add debug statement whenever a function is added to the list of
functions to compile.


---
Diffs of the changes:  (+19 -7)

Index: llvm-java/lib/Compiler/Compiler.cpp
diff -u llvm-java/lib/Compiler/Compiler.cpp:1.156 llvm-java/lib/Compiler/Compiler.cpp:1.157
--- llvm-java/lib/Compiler/Compiler.cpp:1.156	Sat Dec  4 19:30:03 2004
+++ llvm-java/lib/Compiler/Compiler.cpp	Sat Dec  4 22:05:04 2004
@@ -135,6 +135,17 @@
     }
 
   private:
+    /// Schedule a method for compilation. Returns true if this is the
+    /// first time this function was scheduled.
+    bool scheduleFunction(Function* function) {
+      if (toCompileFunctions_.insert(function)) {
+        DEBUG(std::cerr << "Scheduling function: " << function->getName()
+              << " for compilation\n");
+        return true;
+      }
+      return false;
+    }
+
     /// Given a llvm::Java::Constant returns a llvm::Constant.
     llvm::Constant* getConstant(Constant* c) {
       if (dynamic_cast<ConstantString*>(c))
@@ -392,7 +403,7 @@
             getType(method->getDescriptor(), ci.type));
 
           Function* vfun = module_.getOrInsertFunction(funcName, funcTy);
-          toCompileFunctions_.insert(vfun);
+          scheduleFunction(vfun);
 
           unsigned& index = vi.m2iMap[methodDescr];
           if (!index) {
@@ -762,7 +773,8 @@
           const FunctionType* funcTy = cast<FunctionType>(
             getType(method->getDescriptor(), getClassInfo(cf).type));
           Function* vfun = module_.getOrInsertFunction(funcName, funcTy);
-          toCompileFunctions_.insert(vfun);
+          if (!method->isAbstract())
+            scheduleFunction(vfun);
 
           unsigned& index = vi.m2iMap[methodDescr];
           if (!index) {
@@ -1352,7 +1364,7 @@
 
           // Insert a call to it right before the terminator of the only
           // basic block in llvm_java_static_init.
-          bool inserted =  toCompileFunctions_.insert(init);
+          bool inserted =  scheduleFunction(init);
           assert(inserted && "Class initialization method already called!");
           assert(hook->front().getTerminator() &&
                  LLVM_JAVA_STATIC_INIT " should have a terminator!");
@@ -1427,12 +1439,12 @@
 
       // Create the method requested.
       Function* function = getFunction(getMethod(classMethodDesc));
-      toCompileFunctions_.insert(function);
+      scheduleFunction(function);
       // Compile the transitive closure of methods called by this method.
       for (unsigned i = 0; i != toCompileFunctions_.size(); ++i) {
         Function* f = toCompileFunctions_[i];
         compileMethodOnly(f->getName());
-        DEBUG(std::cerr << i << '/' << toCompileFunctions_.size()
+        DEBUG(std::cerr << i+1 << '/' << toCompileFunctions_.size()
               << " functions compiled\n");
       }
 
@@ -2097,14 +2109,14 @@
       FunctionType* funcTy =
         cast<FunctionType>(getType(nameAndType->getDescriptor(), ci.type));
       Function* function = module_.getOrInsertFunction(funcName, funcTy);
-      toCompileFunctions_.insert(function);
+      scheduleFunction(function);
       makeCall(function, getParams(funcTy));
     }
 
     void do_invokestatic(unsigned index) {
       Method* method = getMethod(cf_->getConstantMethodRef(index));
       Function* function = getFunction(method);
-      toCompileFunctions_.insert(function);
+      scheduleFunction(function);
       makeCall(function, getParams(function->getFunctionType()));
     }
 






More information about the llvm-commits mailing list