mem-cache: TempCacheBlk allocates and destroys its own data
This change is because I want to make CacheBlk::data private, so that I can track all the places which write to it. But to keep that commit smaller (it is pretty big, because of all the places which might change it), I have split this into a commit of its own. Change-Id: I15a2fc1752085ff3681f5c74ec90be3828a559ea Reviewed-on: https://gem5-review.googlesource.com/11829 Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
This commit is contained in:
committed by
Kovacsics Róbert
parent
cd3e7230be
commit
2fe3d66026
4
src/mem/cache/base.cc
vendored
4
src/mem/cache/base.cc
vendored
@@ -113,8 +113,7 @@ BaseCache::BaseCache(const BaseCacheParams *p, unsigned blk_size)
|
||||
// forward snoops is overridden in init() once we can query
|
||||
// whether the connected master is actually snooping or not
|
||||
|
||||
tempBlock = new TempCacheBlk();
|
||||
tempBlock->data = new uint8_t[blkSize];
|
||||
tempBlock = new TempCacheBlk(blkSize);
|
||||
|
||||
tags->setCache(this);
|
||||
if (prefetcher)
|
||||
@@ -123,7 +122,6 @@ BaseCache::BaseCache(const BaseCacheParams *p, unsigned blk_size)
|
||||
|
||||
BaseCache::~BaseCache()
|
||||
{
|
||||
delete [] tempBlock->data;
|
||||
delete tempBlock;
|
||||
}
|
||||
|
||||
|
||||
11
src/mem/cache/blk.hh
vendored
11
src/mem/cache/blk.hh
vendored
@@ -406,10 +406,17 @@ class TempCacheBlk final : public CacheBlk
|
||||
Addr _addr;
|
||||
|
||||
public:
|
||||
TempCacheBlk() : CacheBlk() {}
|
||||
/**
|
||||
* Creates a temporary cache block, with its own storage.
|
||||
* @param size The size (in bytes) of this cache block.
|
||||
*/
|
||||
TempCacheBlk(unsigned size) : CacheBlk()
|
||||
{
|
||||
data = new uint8_t[size];
|
||||
}
|
||||
TempCacheBlk(const TempCacheBlk&) = delete;
|
||||
TempCacheBlk& operator=(const TempCacheBlk&) = delete;
|
||||
~TempCacheBlk() {};
|
||||
~TempCacheBlk() { delete [] data; };
|
||||
|
||||
/**
|
||||
* Invalidate the block and clear all state.
|
||||
|
||||
Reference in New Issue
Block a user