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/iew_impl.hh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/cpu/o3/iew_impl.hh') diff --git a/src/cpu/o3/iew_impl.hh b/src/cpu/o3/iew_impl.hh index 8270a71b5..e46bc5ba5 100644 --- a/src/cpu/o3/iew_impl.hh +++ b/src/cpu/o3/iew_impl.hh @@ -478,7 +478,7 @@ DefaultIEW::squash(ThreadID tid) template void -DefaultIEW::squashDueToBranch(DynInstPtr &inst, ThreadID tid) +DefaultIEW::squashDueToBranch(const DynInstPtr& inst, ThreadID tid) { DPRINTF(IEW, "[tid:%i]: Squashing from a specific instruction, PC: %s " "[sn:%i].\n", tid, inst->pcState(), inst->seqNum); @@ -503,7 +503,7 @@ DefaultIEW::squashDueToBranch(DynInstPtr &inst, ThreadID tid) template void -DefaultIEW::squashDueToMemOrder(DynInstPtr &inst, ThreadID tid) +DefaultIEW::squashDueToMemOrder(const DynInstPtr& inst, ThreadID tid) { DPRINTF(IEW, "[tid:%i]: Memory violation, squashing violator and younger " "insts, PC: %s [sn:%i].\n", tid, inst->pcState(), inst->seqNum); @@ -566,28 +566,28 @@ DefaultIEW::unblock(ThreadID tid) template void -DefaultIEW::wakeDependents(DynInstPtr &inst) +DefaultIEW::wakeDependents(const DynInstPtr& inst) { instQueue.wakeDependents(inst); } template void -DefaultIEW::rescheduleMemInst(DynInstPtr &inst) +DefaultIEW::rescheduleMemInst(const DynInstPtr& inst) { instQueue.rescheduleMemInst(inst); } template void -DefaultIEW::replayMemInst(DynInstPtr &inst) +DefaultIEW::replayMemInst(const DynInstPtr& inst) { instQueue.replayMemInst(inst); } template void -DefaultIEW::blockMemInst(DynInstPtr& inst) +DefaultIEW::blockMemInst(const DynInstPtr& inst) { instQueue.blockMemInst(inst); } @@ -601,7 +601,7 @@ DefaultIEW::cacheUnblocked() template void -DefaultIEW::instToCommit(DynInstPtr &inst) +DefaultIEW::instToCommit(const DynInstPtr& inst) { // This function should not be called after writebackInsts in a // single cycle. That will cause problems with an instruction @@ -1578,7 +1578,7 @@ DefaultIEW::tick() template void -DefaultIEW::updateExeInstStats(DynInstPtr &inst) +DefaultIEW::updateExeInstStats(const DynInstPtr& inst) { ThreadID tid = inst->threadNumber; @@ -1610,7 +1610,7 @@ DefaultIEW::updateExeInstStats(DynInstPtr &inst) template void -DefaultIEW::checkMisprediction(DynInstPtr &inst) +DefaultIEW::checkMisprediction(const DynInstPtr& inst) { ThreadID tid = inst->threadNumber; -- cgit v1.2.3