From 341dbf266258dcbdb1e5e9f09c244b8ac271faaf Mon Sep 17 00:00:00 2001 From: Andreas Hansson Date: Sat, 27 Sep 2014 09:08:36 -0400 Subject: arch: Use const StaticInstPtr references where possible This patch optimises the passing of StaticInstPtr by avoiding copying the reference-counting pointer. This avoids first incrementing and then decrementing the reference-counting pointer. --- src/cpu/o3/cpu.cc | 5 +++-- src/cpu/o3/cpu.hh | 2 +- src/cpu/o3/dyn_inst.hh | 5 +++-- src/cpu/o3/dyn_inst_impl.hh | 8 ++++---- 4 files changed, 11 insertions(+), 9 deletions(-) (limited to 'src/cpu/o3') diff --git a/src/cpu/o3/cpu.cc b/src/cpu/o3/cpu.cc index 7ed3944cf..925b3d2d8 100644 --- a/src/cpu/o3/cpu.cc +++ b/src/cpu/o3/cpu.cc @@ -946,12 +946,13 @@ FullO3CPU::processInterrupts(const Fault &interrupt) this->interrupts->updateIntrInfo(this->threadContexts[0]); DPRINTF(O3CPU, "Interrupt %s being handled\n", interrupt->name()); - this->trap(interrupt, 0, NULL); + this->trap(interrupt, 0, nullptr); } template void -FullO3CPU::trap(const Fault &fault, ThreadID tid, StaticInstPtr inst) +FullO3CPU::trap(const Fault &fault, ThreadID tid, + const StaticInstPtr &inst) { // Pass the thread's TC into the invoke method. fault->invoke(this->threadContexts[tid], inst); diff --git a/src/cpu/o3/cpu.hh b/src/cpu/o3/cpu.hh index c263790ce..96cd071e4 100644 --- a/src/cpu/o3/cpu.hh +++ b/src/cpu/o3/cpu.hh @@ -376,7 +376,7 @@ class FullO3CPU : public BaseO3CPU { return globalSeqNum++; } /** Traps to handle given fault. */ - void trap(const Fault &fault, ThreadID tid, StaticInstPtr inst); + void trap(const Fault &fault, ThreadID tid, const StaticInstPtr &inst); /** HW return from error interrupt. */ Fault hwrei(ThreadID tid); diff --git a/src/cpu/o3/dyn_inst.hh b/src/cpu/o3/dyn_inst.hh index ea961092d..80d502f0e 100644 --- a/src/cpu/o3/dyn_inst.hh +++ b/src/cpu/o3/dyn_inst.hh @@ -83,12 +83,13 @@ class BaseO3DynInst : public BaseDynInst public: /** BaseDynInst constructor given a binary instruction. */ - BaseO3DynInst(StaticInstPtr staticInst, StaticInstPtr macroop, + BaseO3DynInst(const StaticInstPtr &staticInst, const StaticInstPtr ¯oop, TheISA::PCState pc, TheISA::PCState predPC, InstSeqNum seq_num, O3CPU *cpu); /** BaseDynInst constructor given a static inst pointer. */ - BaseO3DynInst(StaticInstPtr _staticInst, StaticInstPtr _macroop); + BaseO3DynInst(const StaticInstPtr &_staticInst, + const StaticInstPtr &_macroop); ~BaseO3DynInst(); diff --git a/src/cpu/o3/dyn_inst_impl.hh b/src/cpu/o3/dyn_inst_impl.hh index e51054f8d..fa3ce28fa 100644 --- a/src/cpu/o3/dyn_inst_impl.hh +++ b/src/cpu/o3/dyn_inst_impl.hh @@ -49,8 +49,8 @@ #include "debug/O3PipeView.hh" template -BaseO3DynInst::BaseO3DynInst(StaticInstPtr staticInst, - StaticInstPtr macroop, +BaseO3DynInst::BaseO3DynInst(const StaticInstPtr &staticInst, + const StaticInstPtr ¯oop, TheISA::PCState pc, TheISA::PCState predPC, InstSeqNum seq_num, O3CPU *cpu) : BaseDynInst(staticInst, macroop, pc, predPC, seq_num, cpu) @@ -59,8 +59,8 @@ BaseO3DynInst::BaseO3DynInst(StaticInstPtr staticInst, } template -BaseO3DynInst::BaseO3DynInst(StaticInstPtr _staticInst, - StaticInstPtr _macroop) +BaseO3DynInst::BaseO3DynInst(const StaticInstPtr &_staticInst, + const StaticInstPtr &_macroop) : BaseDynInst(_staticInst, _macroop) { initVars(); -- cgit v1.2.3