From f54020eb8155371725ab75b0fc5c419287eca084 Mon Sep 17 00:00:00 2001 From: Giacomo Travaglini Date: Mon, 4 Jun 2018 09:40:19 +0100 Subject: misc: Using smart pointers for memory Requests This patch is changing the underlying type for RequestPtr from Request* to shared_ptr. Having memory requests being managed by smart pointers will simplify the code; it will also prevent memory leakage and dangling pointers. Change-Id: I7749af38a11ac8eb4d53d8df1252951e0890fde3 Signed-off-by: Giacomo Travaglini Reviewed-by: Andreas Sandberg Reviewed-on: https://gem5-review.googlesource.com/10996 Reviewed-by: Nikos Nikoleris Maintainer: Nikos Nikoleris --- src/arch/arm/stage2_lookup.hh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/arch/arm/stage2_lookup.hh') diff --git a/src/arch/arm/stage2_lookup.hh b/src/arch/arm/stage2_lookup.hh index 870276b0a..8ce3a3a39 100644 --- a/src/arch/arm/stage2_lookup.hh +++ b/src/arch/arm/stage2_lookup.hh @@ -68,13 +68,13 @@ class Stage2LookUp : public BaseTLB::Translation bool functional; TLB::ArmTranslationType tranType; TlbEntry *stage2Te; - Request req; + RequestPtr req; Fault fault; bool complete; bool selfDelete; public: - Stage2LookUp(TLB *s1Tlb, TLB *s2Tlb, TlbEntry s1Te, RequestPtr _req, + Stage2LookUp(TLB *s1Tlb, TLB *s2Tlb, TlbEntry s1Te, const RequestPtr &_req, TLB::Translation *_transState, BaseTLB::Mode _mode, bool _timing, bool _functional, TLB::ArmTranslationType _tranType) : stage1Tlb(s1Tlb), stage2Tlb(s2Tlb), stage1Te(s1Te), s1Req(_req), @@ -82,13 +82,14 @@ class Stage2LookUp : public BaseTLB::Translation functional(_functional), tranType(_tranType), stage2Te(nullptr), fault(NoFault), complete(false), selfDelete(false) { - req.setVirt(0, s1Te.pAddr(s1Req->getVaddr()), s1Req->getSize(), - s1Req->getFlags(), s1Req->masterId(), 0); + req = std::make_shared(); + req->setVirt(0, s1Te.pAddr(s1Req->getVaddr()), s1Req->getSize(), + s1Req->getFlags(), s1Req->masterId(), 0); } Fault getTe(ThreadContext *tc, TlbEntry *destTe); - void mergeTe(RequestPtr req, BaseTLB::Mode mode); + void mergeTe(const RequestPtr &req, BaseTLB::Mode mode); void setSelfDelete() { selfDelete = true; } @@ -96,7 +97,7 @@ class Stage2LookUp : public BaseTLB::Translation void markDelayed() {} - void finish(const Fault &fault, RequestPtr req, ThreadContext *tc, + void finish(const Fault &fault, const RequestPtr &req, ThreadContext *tc, BaseTLB::Mode mode); }; -- cgit v1.2.3