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/arch/mips/faults.cc | 8 ++++---- src/arch/mips/faults.hh | 28 ++++++++++++++-------------- src/arch/mips/stacktrace.cc | 2 +- src/arch/mips/stacktrace.hh | 6 +++--- src/arch/mips/utility.hh | 2 +- 5 files changed, 23 insertions(+), 23 deletions(-) (limited to 'src/arch/mips') diff --git a/src/arch/mips/faults.cc b/src/arch/mips/faults.cc index 3697601dc..eae6bc927 100644 --- a/src/arch/mips/faults.cc +++ b/src/arch/mips/faults.cc @@ -131,7 +131,7 @@ MipsFaultBase::setExceptionState(ThreadContext *tc, uint8_t excCode) } void -MipsFaultBase::invoke(ThreadContext *tc, StaticInstPtr inst) +MipsFaultBase::invoke(ThreadContext *tc, const StaticInstPtr &inst) { if (FullSystem) { DPRINTF(MipsPRA, "Fault %s encountered.\n", name()); @@ -143,7 +143,7 @@ MipsFaultBase::invoke(ThreadContext *tc, StaticInstPtr inst) } void -ResetFault::invoke(ThreadContext *tc, StaticInstPtr inst) +ResetFault::invoke(ThreadContext *tc, const StaticInstPtr &inst) { if (FullSystem) { DPRINTF(MipsPRA, "%s encountered.\n", name()); @@ -160,13 +160,13 @@ ResetFault::invoke(ThreadContext *tc, StaticInstPtr inst) } void -SoftResetFault::invoke(ThreadContext *tc, StaticInstPtr inst) +SoftResetFault::invoke(ThreadContext *tc, const StaticInstPtr &inst) { panic("Soft reset not implemented.\n"); } void -NonMaskableInterrupt::invoke(ThreadContext *tc, StaticInstPtr inst) +NonMaskableInterrupt::invoke(ThreadContext *tc, const StaticInstPtr &inst) { panic("Non maskable interrupt not implemented.\n"); } diff --git a/src/arch/mips/faults.hh b/src/arch/mips/faults.hh index 98638ac9a..d843acc50 100644 --- a/src/arch/mips/faults.hh +++ b/src/arch/mips/faults.hh @@ -102,8 +102,8 @@ class MipsFaultBase : public FaultBase return base(tc) + offset(tc); } - void invoke(ThreadContext * tc, - StaticInstPtr inst = StaticInst::nullStaticInstPtr); + void invoke(ThreadContext * tc, const StaticInstPtr &inst = + StaticInst::nullStaticInstPtr); }; template @@ -134,23 +134,23 @@ class MachineCheckFault : public MipsFault class ResetFault : public MipsFault { public: - void invoke(ThreadContext * tc, - StaticInstPtr inst = StaticInst::nullStaticInstPtr); + void invoke(ThreadContext * tc, const StaticInstPtr &inst = + StaticInst::nullStaticInstPtr); }; class SoftResetFault : public MipsFault { public: - void invoke(ThreadContext * tc, - StaticInstPtr inst = StaticInst::nullStaticInstPtr); + void invoke(ThreadContext * tc, const StaticInstPtr &inst = + StaticInst::nullStaticInstPtr); }; class NonMaskableInterrupt : public MipsFault { public: - void invoke(ThreadContext * tc, - StaticInstPtr inst = StaticInst::nullStaticInstPtr); + void invoke(ThreadContext * tc, const StaticInstPtr &inst = + StaticInst::nullStaticInstPtr); }; class CoprocessorUnusableFault : public MipsFault @@ -162,8 +162,8 @@ class CoprocessorUnusableFault : public MipsFault {} void - invoke(ThreadContext * tc, - StaticInstPtr inst = StaticInst::nullStaticInstPtr) + invoke(ThreadContext * tc, const StaticInstPtr &inst = + StaticInst::nullStaticInstPtr) { MipsFault::invoke(tc, inst); if (FullSystem) { @@ -197,8 +197,8 @@ class AddressFault : public MipsFault {} void - invoke(ThreadContext * tc, - StaticInstPtr inst = StaticInst::nullStaticInstPtr) + invoke(ThreadContext * tc, const StaticInstPtr &inst = + StaticInst::nullStaticInstPtr) { MipsFault::invoke(tc, inst); if (FullSystem) @@ -250,8 +250,8 @@ class TlbFault : public AddressFault } void - invoke(ThreadContext * tc, - StaticInstPtr inst = StaticInst::nullStaticInstPtr) + invoke(ThreadContext * tc, const StaticInstPtr &inst = + StaticInst::nullStaticInstPtr) { if (FullSystem) { DPRINTF(MipsPRA, "Fault %s encountered.\n", this->name()); diff --git a/src/arch/mips/stacktrace.cc b/src/arch/mips/stacktrace.cc index bb761a243..78457c09c 100644 --- a/src/arch/mips/stacktrace.cc +++ b/src/arch/mips/stacktrace.cc @@ -96,7 +96,7 @@ StackTrace::StackTrace() { } -StackTrace::StackTrace(ThreadContext *_tc, StaticInstPtr inst) +StackTrace::StackTrace(ThreadContext *_tc, const StaticInstPtr &inst) : tc(0), stack(64) { trace(_tc, inst); diff --git a/src/arch/mips/stacktrace.hh b/src/arch/mips/stacktrace.hh index f4dc04d29..c817824ea 100644 --- a/src/arch/mips/stacktrace.hh +++ b/src/arch/mips/stacktrace.hh @@ -75,7 +75,7 @@ class StackTrace public: StackTrace(); - StackTrace(ThreadContext *tc, StaticInstPtr inst); + StackTrace(ThreadContext *tc, const StaticInstPtr &inst); ~StackTrace(); void clear() @@ -85,7 +85,7 @@ class StackTrace } bool valid() const { return tc != NULL; } - bool trace(ThreadContext *tc, StaticInstPtr inst); + bool trace(ThreadContext *tc, const StaticInstPtr &inst); public: const std::vector &getstack() const { return stack; } @@ -107,7 +107,7 @@ class StackTrace }; inline bool -StackTrace::trace(ThreadContext *tc, StaticInstPtr inst) +StackTrace::trace(ThreadContext *tc, const StaticInstPtr &inst) { if (!inst->isCall() && !inst->isReturn()) return false; diff --git a/src/arch/mips/utility.hh b/src/arch/mips/utility.hh index 876066203..242dddbf7 100644 --- a/src/arch/mips/utility.hh +++ b/src/arch/mips/utility.hh @@ -115,7 +115,7 @@ void copyMiscRegs(ThreadContext *src, ThreadContext *dest); void skipFunction(ThreadContext *tc); inline void -advancePC(PCState &pc, const StaticInstPtr inst) +advancePC(PCState &pc, const StaticInstPtr &inst) { pc.advance(); } -- cgit v1.2.3