From 0c50a0b4fe3956f9d2e08e75d47c9cbd79bf0268 Mon Sep 17 00:00:00 2001 From: Rekai Gonzalez-Alberquilla Date: Mon, 6 Feb 2017 11:10:06 +0000 Subject: cpu: Fix the usage of const DynInstPtr Summary: Usage of const DynInstPtr& when possible and introduction of move operators to RefCountingPtr. In many places, scoped references to dynamic instructions do a copy of the DynInstPtr when a reference would do. This is detrimental to performance. On top of that, in case there is a need for reference tracking for debugging, the redundant copies make the process much more painful than it already is. Also, from the theoretical point of view, a function/method that defines a convenience name to access an instruction should not be considered an owner of the data, i.e., doing a copy and not a reference is not justified. On a related topic, C++11 introduces move semantics, and those are useful when, for example, there is a class modelling a HW structure that contains a list, and has a getHeadOfList function, to prevent doing a copy to an internal variable -> update pointer, remove from the list -> update pointer, return value making a copy to the assined variable -> update pointer, destroy the returned value -> update pointer. Change-Id: I3bb46c20ef23b6873b469fd22befb251ac44d2f6 Signed-off-by: Giacomo Gabrielli Reviewed-on: https://gem5-review.googlesource.com/c/13105 Reviewed-by: Andreas Sandberg Reviewed-by: Jason Lowe-Power Maintainer: Andreas Sandberg Maintainer: Jason Lowe-Power --- src/cpu/o3/lsq_unit.hh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/cpu/o3/lsq_unit.hh') diff --git a/src/cpu/o3/lsq_unit.hh b/src/cpu/o3/lsq_unit.hh index f5b60b2fc..813a3cac7 100644 --- a/src/cpu/o3/lsq_unit.hh +++ b/src/cpu/o3/lsq_unit.hh @@ -116,11 +116,11 @@ class LSQUnit { void tick() { usedStorePorts = 0; } /** Inserts an instruction. */ - void insert(DynInstPtr &inst); + void insert(const DynInstPtr &inst); /** Inserts a load instruction. */ - void insertLoad(DynInstPtr &load_inst); + void insertLoad(const DynInstPtr &load_inst); /** Inserts a store instruction. */ - void insertStore(DynInstPtr &store_inst); + void insertStore(const DynInstPtr &store_inst); /** Check for ordering violations in the LSQ. For a store squash if we * ever find a conflicting load. For a load, only squash if we @@ -128,7 +128,7 @@ class LSQUnit { * @param load_idx index to start checking at * @param inst the instruction to check */ - Fault checkViolations(int load_idx, DynInstPtr &inst); + Fault checkViolations(int load_idx, const DynInstPtr &inst); /** Check if an incoming invalidate hits in the lsq on a load * that might have issued out of order wrt another load beacuse @@ -137,11 +137,11 @@ class LSQUnit { void checkSnoop(PacketPtr pkt); /** Executes a load instruction. */ - Fault executeLoad(DynInstPtr &inst); + Fault executeLoad(const DynInstPtr &inst); Fault executeLoad(int lq_idx) { panic("Not implemented"); return NoFault; } /** Executes a store instruction. */ - Fault executeStore(DynInstPtr &inst); + Fault executeStore(const DynInstPtr &inst); /** Commits the head load. */ void commitLoad(); @@ -233,7 +233,7 @@ class LSQUnit { void resetState(); /** Writes back the instruction, sending it to IEW. */ - void writeback(DynInstPtr &inst, PacketPtr pkt); + void writeback(const DynInstPtr &inst, PacketPtr pkt); /** Writes back a store that couldn't be completed the previous cycle. */ void writebackPendingStore(); @@ -313,7 +313,8 @@ class LSQUnit { class WritebackEvent : public Event { public: /** Constructs a writeback event. */ - WritebackEvent(DynInstPtr &_inst, PacketPtr pkt, LSQUnit *lsq_ptr); + WritebackEvent(const DynInstPtr &_inst, PacketPtr pkt, + LSQUnit *lsq_ptr); /** Processes the writeback event. */ void process(); @@ -348,7 +349,7 @@ class LSQUnit { } /** Constructs a store queue entry for a given instruction. */ - SQEntry(DynInstPtr &_inst) + SQEntry(const DynInstPtr &_inst) : inst(_inst), req(NULL), sreqLow(NULL), sreqHigh(NULL), size(0), isSplit(0), canWB(0), committed(0), completed(0), isAllZeros(0) { -- cgit v1.2.3