diff options
Diffstat (limited to 'runtime/arch/mips/context_mips.cc')
-rw-r--r-- | runtime/arch/mips/context_mips.cc | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/runtime/arch/mips/context_mips.cc b/runtime/arch/mips/context_mips.cc index ad28891..789dbbb 100644 --- a/runtime/arch/mips/context_mips.cc +++ b/runtime/arch/mips/context_mips.cc @@ -24,14 +24,14 @@ namespace art { namespace mips { -static const uint32_t gZero = 0; +static constexpr uint32_t gZero = 0; void MipsContext::Reset() { for (size_t i = 0; i < kNumberOfCoreRegisters; i++) { - gprs_[i] = NULL; + gprs_[i] = nullptr; } for (size_t i = 0; i < kNumberOfFRegisters; i++) { - fprs_[i] = NULL; + fprs_[i] = nullptr; } gprs_[SP] = &sp_; gprs_[RA] = &ra_; @@ -68,20 +68,35 @@ void MipsContext::FillCalleeSaves(const StackVisitor& fr) { } } -void MipsContext::SetGPR(uint32_t reg, uintptr_t value) { +bool MipsContext::SetGPR(uint32_t reg, uintptr_t value) { CHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters)); CHECK_NE(gprs_[reg], &gZero); // Can't overwrite this static value since they are never reset. - CHECK(gprs_[reg] != NULL); - *gprs_[reg] = value; + if (gprs_[reg] != nullptr) { + *gprs_[reg] = value; + return true; + } else { + return false; + } +} + +bool MipsContext::SetFPR(uint32_t reg, uintptr_t value) { + CHECK_LT(reg, static_cast<uint32_t>(kNumberOfFRegisters)); + CHECK_NE(fprs_[reg], &gZero); // Can't overwrite this static value since they are never reset. + if (fprs_[reg] != nullptr) { + *fprs_[reg] = value; + return true; + } else { + return false; + } } void MipsContext::SmashCallerSaves() { // This needs to be 0 because we want a null/zero return value. gprs_[V0] = const_cast<uint32_t*>(&gZero); gprs_[V1] = const_cast<uint32_t*>(&gZero); - gprs_[A1] = NULL; - gprs_[A2] = NULL; - gprs_[A3] = NULL; + gprs_[A1] = nullptr; + gprs_[A2] = nullptr; + gprs_[A3] = nullptr; } extern "C" void art_quick_do_long_jump(uint32_t*, uint32_t*); @@ -90,10 +105,10 @@ void MipsContext::DoLongJump() { uintptr_t gprs[kNumberOfCoreRegisters]; uint32_t fprs[kNumberOfFRegisters]; for (size_t i = 0; i < kNumberOfCoreRegisters; ++i) { - gprs[i] = gprs_[i] != NULL ? *gprs_[i] : MipsContext::kBadGprBase + i; + gprs[i] = gprs_[i] != nullptr ? *gprs_[i] : MipsContext::kBadGprBase + i; } for (size_t i = 0; i < kNumberOfFRegisters; ++i) { - fprs[i] = fprs_[i] != NULL ? *fprs_[i] : MipsContext::kBadGprBase + i; + fprs[i] = fprs_[i] != nullptr ? *fprs_[i] : MipsContext::kBadGprBase + i; } art_quick_do_long_jump(gprs, fprs); } |