[llvm-commits] CVS: reopt/lib/TraceCache/VirtualMem.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Fri Apr 23 16:26:06 PDT 2004
Changes in directory reopt/lib/TraceCache:
VirtualMem.cpp updated: 1.15 -> 1.16
---
Log message:
copyToVM has been renamed to writeTraceToVM. Its arguments have been reordered
for consistency with writeInstToVM. Also, it now uses a single write() system
call instead of one per word, for efficiency.
Use sizeof(unsigned int) instead of hardcoding 4 all over the place.
Document writeInstToVM and writeTraceToVM.
---
Diffs of the changes: (+15 -16)
Index: reopt/lib/TraceCache/VirtualMem.cpp
diff -u reopt/lib/TraceCache/VirtualMem.cpp:1.15 reopt/lib/TraceCache/VirtualMem.cpp:1.16
--- reopt/lib/TraceCache/VirtualMem.cpp:1.15 Wed Apr 21 15:32:47 2004
+++ reopt/lib/TraceCache/VirtualMem.cpp Fri Apr 23 16:25:10 2004
@@ -26,22 +26,10 @@
throw std::string ("Error opening address space file in procfs.");
}
-/// Emit the instruction words in TRACE to memory starting at address traceStartAddr.
-///
-void VirtualMem::copyToVM(std::vector<unsigned int> &trace,
- uint64_t traceStartAddr){
- lseek(fp, traceStartAddr, SEEK_SET);
-
- for(int i=0, sz = trace.size(); i<sz; i++){
- unsigned int instr = trace[i];
- write(fp, &instr, 4);
- }
-}
-
unsigned int VirtualMem::readInstrFrmVm(uint64_t frm){
lseek(fp, frm, SEEK_SET);
unsigned int instr=0;
- read(fp, &instr, 4);
+ read (fp, &instr, sizeof (unsigned int));
return instr;
}
@@ -63,9 +51,20 @@
return readInstrFrmVm (frm);
}
-void VirtualMem::writeInstToVM(uint64_t dest, unsigned int newInstr){
- lseek(fp, dest, SEEK_SET);
- write(fp, &newInstr, 4);
+/// writeInstToVM - Emit the word newInstr to memory at address destAddr.
+///
+void VirtualMem::writeInstToVM (uint64_t destAddr, unsigned int newInstr) {
+ lseek (fp, destAddr, SEEK_SET);
+ write (fp, &newInstr, sizeof (unsigned int));
+}
+
+/// writeTraceToVM - Emit the words in newInstrs to memory starting at
+/// address destAddr.
+///
+void VirtualMem::writeTraceToVM (uint64_t destAddr,
+ std::vector<unsigned int> &newInstrs) {
+ lseek (fp, destAddr, SEEK_SET);
+ write (fp, &newInstrs[0], newInstrs.size () * sizeof (unsigned int));
}
/// changeBranchTarget - Handles two kinds of branches for now, namely,
More information about the llvm-commits
mailing list