ArmInterface: return ref instead of copy for GetTimer (#5227)

* ArmInterface: return ref instead of copy for GetTimer

* ArmInterface: add const ref GetTimer

* ArmInterface: return raw pointer instead of shared_ptr in GetTimer

* remove more unnecessary shared_ptr usage

* Fix save states

* fix unit tests
This commit is contained in:
Ben 2020-04-22 07:44:58 +02:00 committed by GitHub
parent 38c3c9c74b
commit 39463f1f6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 46 additions and 32 deletions

View file

@ -228,8 +228,12 @@ public:
virtual void PurgeState() = 0;
std::shared_ptr<Core::Timing::Timer> GetTimer() {
return timer;
Core::Timing::Timer& GetTimer() {
return *timer;
}
const Core::Timing::Timer& GetTimer() const {
return *timer;
}
u32 GetID() const {

View file

@ -137,10 +137,10 @@ public:
}
void AddTicks(std::uint64_t ticks) override {
parent.GetTimer()->AddTicks(ticks);
parent.GetTimer().AddTicks(ticks);
}
std::uint64_t GetTicksRemaining() override {
s64 ticks = parent.GetTimer()->GetDowncount();
s64 ticks = parent.GetTimer().GetDowncount();
return static_cast<u64>(ticks <= 0 ? 0 : ticks);
}

View file

@ -3865,7 +3865,7 @@ SWI_INST : {
if (inst_base->cond == ConditionCode::AL || CondPassed(cpu, inst_base->cond)) {
DEBUG_ASSERT(cpu->system != nullptr);
swi_inst* const inst_cream = (swi_inst*)inst_base->component;
cpu->system->GetRunningCore().GetTimer()->AddTicks(num_instrs);
cpu->system->GetRunningCore().GetTimer().AddTicks(num_instrs);
cpu->NumInstrsToExecute =
num_instrs >= cpu->NumInstrsToExecute ? 0 : cpu->NumInstrsToExecute - num_instrs;
num_instrs = 0;