inorder-mem: clean up allocation/deletion of requests/packets
authorKorey Sewell <ksewell@umich.edu>
Tue, 12 May 2009 19:01:15 +0000 (15:01 -0400)
committerKorey Sewell <ksewell@umich.edu>
Tue, 12 May 2009 19:01:15 +0000 (15:01 -0400)
* * *

src/cpu/inorder/inorder_dyn_inst.cc
src/cpu/inorder/inorder_dyn_inst.hh
src/cpu/inorder/resources/cache_unit.cc
src/cpu/inorder/resources/cache_unit.hh
src/cpu/inorder/resources/tlb_unit.hh

index 9355a9f6f23a2eaf157d1ee9c53e7a30c21477e1..da73d482adab4837db395d2beb6e41a773d0eb47 100644 (file)
@@ -108,7 +108,9 @@ InOrderDynInst::setMachInst(ExtMachInst machInst)
 void
 InOrderDynInst::initVars()
 {
-    req = NULL;
+    fetchMemReq = NULL;
+    dataMemReq = NULL;
+
     effAddr = 0;
     physEffAddr = 0;
 
@@ -170,8 +172,14 @@ InOrderDynInst::initVars()
 
 InOrderDynInst::~InOrderDynInst()
 {
-    if (req) {
-        delete req;
+    if (fetchMemReq != 0x0) {
+        delete fetchMemReq;
+        fetchMemReq = NULL;
+    }
+
+    if (dataMemReq != 0x0) {
+        delete dataMemReq;
+        dataMemReq = NULL;
     }
 
     if (traceData) {
index 042a6485a055a18202434467e5c9a39028192666..86c60221e927bbef14433104f0b900f0f83f8fb3 100644 (file)
@@ -634,7 +634,8 @@ class InOrderDynInst : public FastAlloc, public RefCounted
     /** Read Effective Address from instruction & do memory access */
     Fault memAccess();
 
-    RequestPtr memReq;
+    RequestPtr fetchMemReq;
+    RequestPtr dataMemReq;
 
     bool memAddrReady;
 
index 5e374fa40d179bb0b67657abdddbf1aed016df40..68daee5121a68e3036deeb5a04f2ef733c7d7ada 100644 (file)
@@ -252,6 +252,8 @@ CacheUnit::execute(int slot_num)
         break;
 
       case CompleteFetch:
+        // @TODO: MOVE Functionality of handling fetched data into 'fetch unit'
+        //        let cache-unit just be responsible for transferring data.
         if (cache_req->isMemAccComplete()) {
             DPRINTF(InOrderCachePort,
                     "[tid:%i]: Completing Fetch Access for [sn:%i]\n",
@@ -284,6 +286,8 @@ CacheUnit::execute(int slot_num)
                 inst->traceData->setPC(inst->readPC());
             }
 
+            delete cache_req->dataPkt;
+
             cache_req->done();
         } else {
             DPRINTF(InOrderCachePort,
@@ -481,6 +485,7 @@ CacheUnit::processCacheCompletion(PacketPtr pkt)
                 cache_pkt->cacheReq->getInst()->seqNum);
 
         cache_pkt->cacheReq->done();
+        delete cache_pkt;
         return;
     }
 
@@ -543,6 +548,8 @@ CacheUnit::processCacheCompletion(PacketPtr pkt)
                         getMemData(cache_pkt));
 
             }
+
+            delete cache_pkt;
         }
 
         cache_req->setMemAccPending(false);
index 219329683ad6bee21a1ad76cf90057f87281d96f..4cde686b86b352843d334f9d818292c67a5bab15 100644 (file)
@@ -246,7 +246,13 @@ class CacheRequest : public ResourceRequest
         : ResourceRequest(cres, inst, stage_num, res_idx, slot_num, cmd),
           pktCmd(pkt_cmd), memAccComplete(false), memAccPending(false)
     {
-        memReq = inst->memReq;
+        if (cmd == CacheUnit::InitiateFetch ||
+            cmd == CacheUnit::CompleteFetch ||
+            cmd == CacheUnit::Fetch) {
+            memReq = inst->fetchMemReq;
+        } else {
+            memReq = inst->dataMemReq;
+        }
 
         reqData = new uint8_t[req_size];
         retryPkt = NULL;
@@ -273,9 +279,6 @@ class CacheRequest : public ResourceRequest
             delete retryPkt;
         }
 #endif
-
-        if (memReq)
-            delete memReq;
     }
 
     virtual PacketDataPtr getData()
index 67e1bda1d8ee68c7252f7c89339c16f84ce15179..4ca240ba807b8034e6faa8b4c111688a97c06e31 100644 (file)
@@ -106,21 +106,22 @@ class TLBUnitRequest : public ResourceRequest {
             aligned_addr = inst->getMemAddr();
             req_size = sizeof(TheISA::MachInst);
             flags = 0;
+            inst->fetchMemReq = new Request(inst->readTid(), aligned_addr, req_size,
+                                            flags, inst->readPC(), res->cpu->readCpuId(), inst->readTid());
+            memReq = inst->fetchMemReq;
         } else {
             aligned_addr = inst->getMemAddr();;
             req_size = inst->getMemAccSize();
             flags = inst->getMemFlags();
-        }
 
-        if (req_size == 0 && (inst->isDataPrefetch() || inst->isInstPrefetch())) {
-            req_size = 8;
-        }
+            if (req_size == 0 && (inst->isDataPrefetch() || inst->isInstPrefetch())) {
+                req_size = 8;
+            }
 
-        // @TODO: Add Vaddr & Paddr functions
-        inst->memReq = new Request(inst->readTid(), aligned_addr, req_size,
+            inst->dataMemReq = new Request(inst->readTid(), aligned_addr, req_size,
                                    flags, inst->readPC(), res->cpu->readCpuId(), inst->readTid());
-
-        memReq = inst->memReq;
+            memReq = inst->dataMemReq;
+        }
     }
 
     RequestPtr memReq;