inorder: cleanup in destructors

cleanup hanging pointers and other cruft in the destructors
This commit is contained in:
Korey Sewell 2011-02-18 14:29:26 -05:00
parent 8b4b4a1ba5
commit 91c48b1c3b
7 changed files with 43 additions and 23 deletions

View file

@ -356,6 +356,17 @@ InOrderCPU::InOrderCPU(Params *params)
InOrderCPU::~InOrderCPU() InOrderCPU::~InOrderCPU()
{ {
delete resPool; delete resPool;
std::map<SkedID, ThePipeline::RSkedPtr>::iterator sked_it =
skedCache.begin();
std::map<SkedID, ThePipeline::RSkedPtr>::iterator sked_end =
skedCache.end();
while (sked_it != sked_end) {
delete (*sked_it).second;
sked_it++;
}
skedCache.clear();
} }
std::map<InOrderCPU::SkedID, ThePipeline::RSkedPtr> InOrderCPU::skedCache; std::map<InOrderCPU::SkedID, ThePipeline::RSkedPtr> InOrderCPU::skedCache;
@ -460,7 +471,7 @@ InOrderCPU::createBackEndSked(DynInstPtr inst)
W.needs(Grad, GraduationUnit::GraduateInst); W.needs(Grad, GraduationUnit::GraduateInst);
// Insert Front Schedule into our cache of // Insert Back Schedule into our cache of
// resource schedules // resource schedules
addToSkedCache(inst, res_sked); addToSkedCache(inst, res_sked);

View file

@ -315,6 +315,7 @@ class InOrderCPU : public BaseCPU
void addToSkedCache(DynInstPtr inst, ThePipeline::RSkedPtr inst_sked) void addToSkedCache(DynInstPtr inst, ThePipeline::RSkedPtr inst_sked)
{ {
SkedID sked_id = genSkedID(inst); SkedID sked_id = genSkedID(inst);
assert(skedCache.find(sked_id) == skedCache.end());
skedCache[sked_id] = inst_sked; skedCache[sked_id] = inst_sked;
} }

View file

@ -44,12 +44,17 @@ PipelineStage::PipelineStage(Params *params, unsigned stage_num)
stageBufferMax(params->stageWidth), stageBufferMax(params->stageWidth),
prevStageValid(false), nextStageValid(false), idle(false) prevStageValid(false), nextStageValid(false), idle(false)
{ {
switchedOutBuffer.resize(ThePipeline::MaxThreads);
switchedOutValid.resize(ThePipeline::MaxThreads);
init(params); init(params);
} }
PipelineStage::~PipelineStage()
{
for(ThreadID tid = 0; tid < numThreads; tid++) {
skidBuffer[tid].clear();
stalls[tid].resources.clear();
}
}
void void
PipelineStage::init(Params *params) PipelineStage::init(Params *params)
{ {
@ -66,6 +71,12 @@ PipelineStage::init(Params *params)
else else
lastStallingStage[tid] = NumStages - 1; lastStallingStage[tid] = NumStages - 1;
} }
if ((InOrderCPU::ThreadModel) params->threadModel ==
InOrderCPU::SwitchOnCacheMiss) {
switchedOutBuffer.resize(ThePipeline::MaxThreads);
switchedOutValid.resize(ThePipeline::MaxThreads);
}
} }
@ -190,9 +201,6 @@ PipelineStage::takeOverFrom()
stalls[tid].resources.clear(); stalls[tid].resources.clear();
while (!insts[tid].empty())
insts[tid].pop();
skidBuffer[tid].clear(); skidBuffer[tid].clear();
} }
wroteToTimeBuffer = false; wroteToTimeBuffer = false;

View file

@ -91,10 +91,7 @@ class PipelineStage
public: public:
PipelineStage(Params *params, unsigned stage_num); PipelineStage(Params *params, unsigned stage_num);
/** MUST use init() function if this constructor is used. */ virtual ~PipelineStage();
PipelineStage() { }
virtual ~PipelineStage() { }
/** PipelineStage initialization. */ /** PipelineStage initialization. */
void init(Params *params); void init(Params *params);
@ -268,16 +265,6 @@ class PipelineStage
*/ */
unsigned instsProcessed; unsigned instsProcessed;
/** Queue of all instructions coming from previous stage on this cycle. */
std::queue<DynInstPtr> insts[ThePipeline::MaxThreads];
/** Queue of instructions that are finished processing and ready to go
* next stage. This is used to prevent from processing an instrution more
* than once on any stage. NOTE: It is up to the PROGRAMMER must manage
* this as a queue
*/
std::list<DynInstPtr> instsToNextStage;
/** Skid buffer between previous stage and this one. */ /** Skid buffer between previous stage and this one. */
std::list<DynInstPtr> skidBuffer[ThePipeline::MaxThreads]; std::list<DynInstPtr> skidBuffer[ThePipeline::MaxThreads];

View file

@ -45,6 +45,14 @@ RegDepMap::RegDepMap(int size)
regMap.resize(size); regMap.resize(size);
} }
RegDepMap::~RegDepMap()
{
for (int i = 0; i < regMap.size(); i++) {
regMap[i].clear();
}
regMap.clear();
}
string string
RegDepMap::name() RegDepMap::name()
{ {

View file

@ -48,7 +48,7 @@ class RegDepMap
public: public:
RegDepMap(int size = TheISA::TotalNumRegs); RegDepMap(int size = TheISA::TotalNumRegs);
~RegDepMap() { } ~RegDepMap();
std::string name(); std::string name();

View file

@ -53,7 +53,11 @@ Resource::~Resource()
delete [] resourceEvent; delete [] resourceEvent;
} }
delete deniedReq; delete deniedReq;
for (int i = 0; i < width; i++) {
delete reqs[i];
}
} }
@ -386,6 +390,7 @@ ResourceRequest::~ResourceRequest()
DPRINTF(ResReqCount, "Res. Req %i deleted. resReqCount=%i.\n", reqID, DPRINTF(ResReqCount, "Res. Req %i deleted. resReqCount=%i.\n", reqID,
res->cpu->resReqCount); res->cpu->resReqCount);
#endif #endif
inst = NULL;
} }
void void