From 0622f30961fc32b967bb1ef784afc5a205b16f6e Mon Sep 17 00:00:00 2001 From: Andreas Hansson Date: Tue, 19 Feb 2013 05:56:05 -0500 Subject: mem: Add predecessor to SenderState base class This patch adds a predecessor field to the SenderState base class to make the process of linking them up more uniform, and enable a traversal of the stack without knowing the specific type of the subclasses. There are a number of simplifications done as part of changing the SenderState, particularly in the RubyTest. --- src/mem/cache/cache_impl.hh | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'src/mem/cache') diff --git a/src/mem/cache/cache_impl.hh b/src/mem/cache/cache_impl.hh index a5f1b4844..d2c9f900e 100644 --- a/src/mem/cache/cache_impl.hh +++ b/src/mem/cache/cache_impl.hh @@ -348,24 +348,12 @@ Cache::access(PacketPtr pkt, BlkType *&blk, class ForwardResponseRecord : public Packet::SenderState { - Packet::SenderState *prevSenderState; - PortID prevSrc; -#ifndef NDEBUG - BaseCache *cache; -#endif public: - ForwardResponseRecord(Packet *pkt, BaseCache *_cache) - : prevSenderState(pkt->senderState), prevSrc(pkt->getSrc()) -#ifndef NDEBUG - , cache(_cache) -#endif + + PortID prevSrc; + + ForwardResponseRecord(PortID prev_src) : prevSrc(prev_src) {} - void restore(Packet *pkt, BaseCache *_cache) - { - assert(_cache == cache); - pkt->senderState = prevSenderState; - pkt->setDest(prevSrc); - } }; @@ -389,7 +377,7 @@ Cache::timingAccess(PacketPtr pkt) if (pkt->isResponse()) { // must be cache-to-cache response from upper to lower level ForwardResponseRecord *rec = - dynamic_cast(pkt->senderState); + dynamic_cast(pkt->popSenderState()); assert(!system->bypassCaches()); if (rec == NULL) { @@ -402,7 +390,7 @@ Cache::timingAccess(PacketPtr pkt) return true; } - rec->restore(pkt, this); + pkt->setDest(rec->prevSrc); delete rec; memSidePort->schedTimingSnoopResp(pkt, time); return true; @@ -1293,14 +1281,14 @@ Cache::handleSnoop(PacketPtr pkt, BlkType *blk, if (is_timing) { Packet snoopPkt(pkt, true); // clear flags snoopPkt.setExpressSnoop(); - snoopPkt.senderState = new ForwardResponseRecord(pkt, this); + snoopPkt.pushSenderState(new ForwardResponseRecord(pkt->getSrc())); cpuSidePort->sendTimingSnoopReq(&snoopPkt); if (snoopPkt.memInhibitAsserted()) { // cache-to-cache response from some upper cache assert(!alreadyResponded); pkt->assertMemInhibit(); } else { - delete snoopPkt.senderState; + delete snoopPkt.popSenderState(); } if (snoopPkt.sharedAsserted()) { pkt->assertShared(); -- cgit v1.2.3