[llvm-commits] CVS: llvm/lib/Reoptimizer/TraceCache/TraceCache.cpp

Anand Shukla ashukla at cs.uiuc.edu
Fri Apr 4 14:29:02 PST 2003


Changes in directory llvm/lib/Reoptimizer/TraceCache:

TraceCache.cpp updated: 1.9 -> 1.10

---
Log message:

Added a simple traceadd routine

---
Diffs of the changes:

Index: llvm/lib/Reoptimizer/TraceCache/TraceCache.cpp
diff -u llvm/lib/Reoptimizer/TraceCache/TraceCache.cpp:1.9 llvm/lib/Reoptimizer/TraceCache/TraceCache.cpp:1.10
--- llvm/lib/Reoptimizer/TraceCache/TraceCache.cpp:1.9	Fri Feb 14 14:45:35 2003
+++ llvm/lib/Reoptimizer/TraceCache/TraceCache.cpp	Fri Apr  4 14:28:01 2003
@@ -368,3 +368,71 @@
 }
 
   
+#undef GET_TRACE_TIME
+
+//Do the following:
+//1. Insert a jump at location instrAddr with target as new trace
+bool TraceCache::addTrace(uint64_t instAddr, int sz, 
+                          int traceUniqId, uint64_t &addr){
+  
+  //remove trace if its already there
+  if(hasTraceAddr(instAddr))
+    removeTrace(instAddr);
+
+  while(isLimitSet && currSize+sz>limit){
+    if(currSize == 0)
+      return false;
+  
+    //erase first addr from queue
+    assert(allocationOrder.size()>0 && "No entries in trace!");
+    uint64_t addr = allocationOrder.front();
+    allocationOrder.pop_front();
+    removeTrace(addr);
+  }
+  
+  uint64_t traceStartAddr = mm->getMemory(sz);
+
+  if(traceStartAddr == 0) return false; //could not allocate space!
+
+  traces[instAddr] = traceStartAddr;
+  traceId[traceUniqId] = traceStartAddr;
+  reverseTraceId[instAddr] = traceUniqId;
+  traceSize[instAddr] = sz;
+  reverseMap[traceStartAddr] = instAddr;
+  currSize += sz;
+
+  //add instAddr to queue
+  allocationOrder.push_back(instAddr);
+  
+  //copy the first few instructions of the trace in the original code
+  //and write a jump instruction in its place
+  traceInstructions[instAddr].push_back(vm->readInstrFrmVm(instAddr));
+  traceInstructions[instAddr].push_back(vm->readInstrFrmVm(instAddr+4));
+
+#ifdef GET_TRACE_TIME
+  //two more: to accomodate call instruction and get time!
+  traceInstructions[instAddr].push_back(vm->readInstrFrmVm(instAddr+8));
+  traceInstructions[instAddr].push_back(vm->readInstrFrmVm(instAddr+12));
+
+  //write call instruction!
+  vm->writeCallLLVMTime(instAddr);
+
+  //Now write branch instruction with target as 
+  //traceStartAddr at the address instAddr
+  vm->writeBranchInstruction(instAddr+8, traceStartAddr);
+#endif
+
+#ifndef GET_TRACE_TIME
+  vm->writeBranchInstruction(instAddr, traceStartAddr);
+#endif
+  
+  doFlush(instAddr, instAddr+4);
+
+#ifdef GET_TRACE_TIME
+  doFlush(instAddr+8, instAddr+12);
+#endif
+  
+  addr = traceStartAddr;
+
+  return true;
+}





More information about the llvm-commits mailing list