inorder: fix cache/fetch unit memory leaks
--- need to delete the cache request's data on clearRequest() now that we are recycling requests --- fetch unit needs to deallocate the fetch buffer blocks when they are replaced or squashed.
This commit is contained in:
parent
72b5233112
commit
8b4b4a1ba5
|
@ -648,8 +648,6 @@ CacheUnit::write(DynInstPtr inst, uint8_t *data, unsigned size,
|
|||
|
||||
if (inst->fault == NoFault) {
|
||||
if (!cache_req->splitAccess) {
|
||||
// Remove this line since storeData is saved in INST?
|
||||
cache_req->reqData = new uint8_t[size];
|
||||
doCacheAccess(inst, write_res);
|
||||
} else {
|
||||
doCacheAccess(inst, write_res, cache_req);
|
||||
|
|
|
@ -249,6 +249,10 @@ class CacheRequest : public ResourceRequest
|
|||
|
||||
void clearRequest()
|
||||
{
|
||||
if (reqData && !splitAccess) {
|
||||
delete [] reqData;
|
||||
}
|
||||
|
||||
memReq = NULL;
|
||||
reqData = NULL;
|
||||
dataPkt = NULL;
|
||||
|
|
|
@ -56,6 +56,31 @@ FetchUnit::FetchUnit(string res_name, int res_id, int res_width,
|
|||
predecoder(NULL)
|
||||
{ }
|
||||
|
||||
FetchUnit::~FetchUnit()
|
||||
{
|
||||
std::list<FetchBlock*>::iterator fetch_it = fetchBuffer.begin();
|
||||
std::list<FetchBlock*>::iterator end_it = fetchBuffer.end();
|
||||
while (fetch_it != end_it) {
|
||||
delete (*fetch_it)->block;
|
||||
delete *fetch_it;
|
||||
fetch_it++;
|
||||
}
|
||||
fetchBuffer.clear();
|
||||
|
||||
|
||||
std::list<FetchBlock*>::iterator pend_it = pendingFetch.begin();
|
||||
std::list<FetchBlock*>::iterator pend_end = pendingFetch.end();
|
||||
while (pend_it != pend_end) {
|
||||
if ((*pend_it)->block) {
|
||||
delete (*pend_it)->block;
|
||||
}
|
||||
|
||||
delete *pend_it;
|
||||
pend_it++;
|
||||
}
|
||||
pendingFetch.clear();
|
||||
}
|
||||
|
||||
void
|
||||
FetchUnit::createMachInst(std::list<FetchBlock*>::iterator fetch_it,
|
||||
DynInstPtr inst)
|
||||
|
@ -328,6 +353,8 @@ FetchUnit::execute(int slot_num)
|
|||
return;
|
||||
}
|
||||
|
||||
delete [] (*repl_it)->block;
|
||||
delete *repl_it;
|
||||
fetchBuffer.erase(repl_it);
|
||||
}
|
||||
|
||||
|
@ -506,6 +533,10 @@ FetchUnit::squashCacheRequest(CacheReqPtr req_ptr)
|
|||
DPRINTF(InOrderCachePort, "[sn:%i] Removing Pending Fetch "
|
||||
"for block %08p (cnt=%i)\n", inst->seqNum,
|
||||
block_addr, (*block_it)->cnt);
|
||||
if ((*block_it)->block) {
|
||||
delete [] (*block_it)->block;
|
||||
}
|
||||
delete *block_it;
|
||||
pendingFetch.erase(block_it);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,8 @@ class FetchUnit : public CacheUnit
|
|||
FetchUnit(std::string res_name, int res_id, int res_width,
|
||||
int res_latency, InOrderCPU *_cpu, ThePipeline::Params *params);
|
||||
|
||||
virtual ~FetchUnit();
|
||||
|
||||
typedef ThePipeline::DynInstPtr DynInstPtr;
|
||||
typedef TheISA::ExtMachInst ExtMachInst;
|
||||
|
||||
|
|
Loading…
Reference in a new issue