Kovacsics Róbert has submitted this change and it was merged. (
https://gem5-review.googlesource.com/11829 )
Change subject: mem-cache: TempCacheBlk allocates and destroys its own data
......................................................................
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 <[email protected]>
Maintainer: Nikos Nikoleris <[email protected]>
---
M src/mem/cache/base.cc
M src/mem/cache/blk.hh
2 files changed, 10 insertions(+), 5 deletions(-)
Approvals:
Nikos Nikoleris: Looks good to me, approved; Looks good to me, approved
diff --git a/src/mem/cache/base.cc b/src/mem/cache/base.cc
index 862aa3a..a061410 100644
--- a/src/mem/cache/base.cc
+++ b/src/mem/cache/base.cc
@@ -113,8 +113,7 @@
// 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()
{
- delete [] tempBlock->data;
delete tempBlock;
}
diff --git a/src/mem/cache/blk.hh b/src/mem/cache/blk.hh
index 97e1d42..3bb0317 100644
--- a/src/mem/cache/blk.hh
+++ b/src/mem/cache/blk.hh
@@ -406,10 +406,17 @@
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.
--
To view, visit https://gem5-review.googlesource.com/11829
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I15a2fc1752085ff3681f5c74ec90be3828a559ea
Gerrit-Change-Number: 11829
Gerrit-PatchSet: 3
Gerrit-Owner: Kovacsics Róbert <[email protected]>
Gerrit-Reviewer: Kovacsics Róbert <[email protected]>
Gerrit-Reviewer: Nikos Nikoleris <[email protected]>
Gerrit-CC: Daniel Carvalho <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev