[llvm-commits] CVS: reopt/lib/LightWtProfiling/Timer.h scheduler.cpp

Brian Gaeke gaeke at cs.uiuc.edu
Wed Sep 10 15:38:26 PDT 2003


Changes in directory reopt/lib/LightWtProfiling:

Timer.h updated: 1.1 -> 1.2
scheduler.cpp updated: 1.2 -> 1.3

---
Log message:

Timer.h: Add prototypes for functions used by scheduler.cpp
scheduler.cpp: Sort #includes. Don't use namespace std. Pretty up the
 end of it.


---
Diffs of the changes:

Index: reopt/lib/LightWtProfiling/Timer.h
diff -u reopt/lib/LightWtProfiling/Timer.h:1.1 reopt/lib/LightWtProfiling/Timer.h:1.2
--- reopt/lib/LightWtProfiling/Timer.h:1.1	Wed Aug  6 16:48:30 2003
+++ reopt/lib/LightWtProfiling/Timer.h	Wed Sep 10 15:35:55 2003
@@ -3,6 +3,8 @@
 
 #include "Support/DataTypes.h"
 
+extern void mask_interrupt ();
+extern void unmask_interrupt ();
 extern int initialize_timer ();
 extern uint64_t llvm_interval_counter;
 


Index: reopt/lib/LightWtProfiling/scheduler.cpp
diff -u reopt/lib/LightWtProfiling/scheduler.cpp:1.2 reopt/lib/LightWtProfiling/scheduler.cpp:1.3
--- reopt/lib/LightWtProfiling/scheduler.cpp:1.2	Fri Aug 22 12:43:41 2003
+++ reopt/lib/LightWtProfiling/scheduler.cpp	Wed Sep 10 15:35:55 2003
@@ -1,10 +1,8 @@
-#include <queue>
-#include <iostream>
+#include "Globals.h"
+#include "Timer.h"
 #include "reopt/VirtualMem.h"
 #include "reopt/InstrUtils.h"
-
-
-using namespace std;
+#include <queue>
 
 class priority_queue_entry
 {
@@ -16,7 +14,6 @@
     uint64_t addr;
 };
 
-
 bool operator<=(priority_queue_entry p1, priority_queue_entry p2)
 {
     return p1.cycle_to_process <= p2.cycle_to_process;
@@ -57,65 +54,34 @@
   }
 };
 
-
-priority_queue<priority_queue_entry, vector<priority_queue_entry>, my_compare> pqueue;
-extern uint64_t llvm_interval_counter;
-extern VirtualMem* vm;
-extern "C" void llvm_first_trigger();
-
-void repair_trace(uint64_t){}
-
-extern "C" int do_timer_interval()
-{
-  //  std::cerr<<"examining queue of size  "<< pqueue.size()<<std::endl;
-    while(1)
-    {
-      //       std::cerr << "count = " << llvm_interval_counter << std::endl;
-	if(pqueue.size())
-	{
-          //	    std::cerr << "size  " << pqueue.size() << std::endl;
-	    const priority_queue_entry p = pqueue.top();
-	    if(p.cycle_to_process <= llvm_interval_counter)
-	    {
-	      //std::cerr << "Found one at : 0x" << hex << p.addr << dec <<  std::endl;
-	      //the trace needs to be restored to the zero state
-              vm->writeInstToVM(p.addr, 
-				getCallInstr((uint64_t)&llvm_first_trigger,  p.addr));
-              doFlush(p.addr-16, p.addr+16);
-	      pqueue.pop();
-	    }
-	    else 
-	      break;
-	}
-        else
-            break;
-    }
-    return 0;
+std::priority_queue<priority_queue_entry, std::vector<priority_queue_entry>,
+		    my_compare> pqueue;
+extern "C" void llvm_first_trigger ();
+
+/// Examine the queue, processing and removing entries for which
+/// cycle_to_process <= llvm_interval_counter. We process entries by
+/// inserting a call to llvm_first_trigger() at addr.
+///
+extern "C" void do_timer_interval () {
+  while(!pqueue.empty ()
+	&& pqueue.top ().cycle_to_process <= llvm_interval_counter) {
+    uint64_t addr = pqueue.top ().addr;
+    // Insert a call at ADDR to llvm_first_trigger.
+    vm->writeInstToVM (addr, 
+		       getCallInstr ((uint64_t)&llvm_first_trigger, addr));
+    doFlush (addr-16, addr+16);
+    pqueue.pop ();
+  }
 }
 
-extern "C" void mask_interrupt();
-extern "C" void unmask_interrupt();
-
+/// Insert a new pair <TIME,ADDR> into the priority queue (with
+/// interrupts masked, though these *_interrupt fns don't do anything
+/// at the moment!)
+///
 int insert_address_at(uint64_t time, uint64_t addr)
 {
-  // mask_interrupt();
-  //printf("\t\t\t inserting time = %lu\n", time);
-    pqueue.push(priority_queue_entry(time,addr));
-    //printf("\t\t\t size = %lu\n", pqueue.size());
-    //  unmask_interrupt();
-    return 0;
-}
-
-//uint64_t elements[] = { 1,5,8,2,4,6,3,9,0,7 };
-//
-//int main()
-//{
-//  for( int i = 0; i < 10; i++)
-//  {
-//    insert_address_at(elements[i], (uint64_t)&elements[i]);
-//  }
-//  
-//  llvm_interval_counter = 10;
-//  
-//  do_timer_interval();
-//}
+  mask_interrupt();
+  pqueue.push(priority_queue_entry(time,addr));
+  unmask_interrupt();
+  return 0;
+}





More information about the llvm-commits mailing list