diff -r 42807286d6cb -r c9ca95595667 src/mem/cache/blk.hh --- a/src/mem/cache/blk.hh Tue Aug 28 17:57:51 2012 -0500 +++ b/src/mem/cache/blk.hh Thu Aug 30 11:38:41 2012 -0500 @@ -189,6 +189,16 @@ } /** + * Invalidate the block and clear all state. + */ + void invalidate() + { + status = 0; + isTouched = false; + clearLoadLocks(); + } + + /** * Check to see if a block has been written. * @return True if the block is dirty. */ diff -r 42807286d6cb -r c9ca95595667 src/mem/cache/cache_impl.hh --- a/src/mem/cache/cache_impl.hh Tue Aug 28 17:57:51 2012 -0500 +++ b/src/mem/cache/cache_impl.hh Thu Aug 30 11:38:41 2012 -0500 @@ -170,7 +170,9 @@ pkt->assertMemInhibit(); } // on ReadExReq we give up our copy unconditionally - tags->invalidateBlk(blk); + assert(blk != tempBlock); + tags->invalidate(blk); + blk->invalidate(); } else if (blk->isWritable() && !pending_downgrade && !pkt->sharedAsserted() && !pkt->req->isInstFetch()) { // we can give the requester an exclusive copy (by not @@ -210,7 +212,9 @@ // to just ack those as long as we have an exclusive // copy at this level. assert(pkt->isUpgrade()); - tags->invalidateBlk(blk); + assert(blk != tempBlock); + tags->invalidate(blk); + blk->invalidate(); } } @@ -280,7 +284,8 @@ } else if (pkt->isWrite()) { blk = tags->findBlock(pkt->getAddr()); if (blk != NULL) { - tags->invalidateBlk(blk); + tags->invalidate(blk); + blk->invalidate(); } } @@ -444,7 +449,8 @@ } else if (pkt->isWrite()) { BlkType *blk = tags->findBlock(pkt->getAddr()); if (blk != NULL) { - tags->invalidateBlk(blk); + tags->invalidate(blk); + blk->invalidate(); } } @@ -644,7 +650,8 @@ if (pkt->isInvalidate()) { BlkType *blk = tags->findBlock(pkt->getAddr()); if (blk && blk->isValid()) { - tags->invalidateBlk(blk); + tags->invalidate(blk); + blk->invalidate(); DPRINTF(Cache, "rcvd mem-inhibited %s on 0x%x: invalidating\n", pkt->cmdString(), pkt->getAddr()); } @@ -953,9 +960,11 @@ mshr->popTarget(); } - if (blk) { + if (blk && blk->isValid()) { if (pkt->isInvalidate() || mshr->hasPostInvalidate()) { - tags->invalidateBlk(blk); + assert(blk != tempBlock); + tags->invalidate(blk); + blk->invalidate(); } else if (mshr->hasPostDowngrade()) { blk->status &= ~BlkWritable; } @@ -988,8 +997,7 @@ if (blk->isDirty()) { allocateWriteBuffer(writebackBlk(blk), time, true); } - blk->status &= ~BlkValid; - tags->invalidateBlk(blk); + blk->invalidate(); } delete pkt; @@ -1087,8 +1095,8 @@ tags->insertBlock(pkt->getAddr(), blk, id); } - // starting from scratch with a new block - blk->status = 0; + // we should never be overwriting a valid block + assert(!blk->isValid()); } else { // existing block... probably an upgrade assert(blk->tag == tags->extractTag(addr)); @@ -1259,7 +1267,9 @@ // Do this last in case it deallocates block data or something // like that if (invalidate) { - tags->invalidateBlk(blk); + assert(blk != tempBlock); + tags->invalidate(blk); + blk->invalidate(); } } diff -r 42807286d6cb -r c9ca95595667 src/mem/cache/tags/fa_lru.hh --- a/src/mem/cache/tags/fa_lru.hh Tue Aug 28 17:57:51 2012 -0500 +++ b/src/mem/cache/tags/fa_lru.hh Thu Aug 30 11:38:41 2012 -0500 @@ -168,7 +168,7 @@ * Invalidate a cache block. * @param blk The block to invalidate. */ - void invalidateBlk(BlkType *blk); + void invalidate(BlkType *blk); /** * Access block and update replacement data. May not succeed, in which case diff -r 42807286d6cb -r c9ca95595667 src/mem/cache/tags/fa_lru.cc --- a/src/mem/cache/tags/fa_lru.cc Tue Aug 28 17:57:51 2012 -0500 +++ b/src/mem/cache/tags/fa_lru.cc Thu Aug 30 11:38:41 2012 -0500 @@ -152,13 +152,10 @@ } void -FALRU::invalidateBlk(FALRU::BlkType *blk) +FALRU::invalidate(FALRU::BlkType *blk) { - if (blk) { - blk->status = 0; - blk->isTouched = false; - tagsInUse--; - } + assert(blk); + tagsInUse--; } FALRUBlk* diff -r 42807286d6cb -r c9ca95595667 src/mem/cache/tags/iic.hh --- a/src/mem/cache/tags/iic.hh Tue Aug 28 17:57:51 2012 -0500 +++ b/src/mem/cache/tags/iic.hh Thu Aug 30 11:38:41 2012 -0500 @@ -408,7 +408,7 @@ * Invalidate a block. * @param blk The block to invalidate. */ - void invalidateBlk(BlkType *blk); + void invalidate(BlkType *blk); /** * Access block and update replacement data. May not succeed, in which case diff -r 42807286d6cb -r c9ca95595667 src/mem/cache/tags/iic.cc --- a/src/mem/cache/tags/iic.cc Tue Aug 28 17:57:51 2012 -0500 +++ b/src/mem/cache/tags/iic.cc Thu Aug 30 11:38:41 2012 -0500 @@ -615,7 +615,7 @@ } void -IIC::invalidateBlk(IIC::BlkType *tag_ptr) +IIC::invalidate(IIC::BlkType *tag_ptr) { if (tag_ptr) { for (int i = 0; i < tag_ptr->numData; ++i) { diff -r 42807286d6cb -r c9ca95595667 src/mem/cache/tags/lru.hh --- a/src/mem/cache/tags/lru.hh Tue Aug 28 17:57:51 2012 -0500 +++ b/src/mem/cache/tags/lru.hh Thu Aug 30 11:38:41 2012 -0500 @@ -127,7 +127,7 @@ * Invalidate the given block. * @param blk The block to invalidate. */ - void invalidateBlk(BlkType *blk); + void invalidate(BlkType *blk); /** * Access block and update replacement data. May not succeed, in which case diff -r 42807286d6cb -r c9ca95595667 src/mem/cache/tags/lru.cc --- a/src/mem/cache/tags/lru.cc Tue Aug 28 17:57:51 2012 -0500 +++ b/src/mem/cache/tags/lru.cc Thu Aug 30 11:38:41 2012 -0500 @@ -92,7 +92,7 @@ ++blkIndex; // invalidate new cache block - blk->status = 0; + blk->invalidate(); //EGH Fix Me : do we need to initialize blk? @@ -186,8 +186,11 @@ // deal with evicted block assert(blk->srcMasterId < cache->system->maxMasters()); occupancies[blk->srcMasterId]--; + + blk->invalidate(); } + blk->isTouched = true; // Set tag for new block. Caller is responsible for setting status. blk->tag = extractTag(addr); @@ -201,23 +204,18 @@ } void -LRU::invalidateBlk(BlkType *blk) +LRU::invalidate(BlkType *blk) { - if (blk) { - if (blk->isValid()) { - tagsInUse--; - assert(blk->srcMasterId < cache->system->maxMasters()); - occupancies[blk->srcMasterId]--; - blk->srcMasterId = Request::invldMasterId; - } - blk->status = 0; - blk->isTouched = false; - blk->clearLoadLocks(); + assert(blk); + assert(blk->isValid()); + tagsInUse--; + assert(blk->srcMasterId < cache->system->maxMasters()); + occupancies[blk->srcMasterId]--; + blk->srcMasterId = Request::invldMasterId; - // should be evicted before valid blocks - unsigned set = blk->set; - sets[set].moveToTail(blk); - } + // should be evicted before valid blocks + unsigned set = blk->set; + sets[set].moveToTail(blk); } void