From 0bcb2902ec21393d71c94e63aa6733cb5311a0cc Mon Sep 17 00:00:00 2001 From: Sebastien Hertz Date: Tue, 17 Jun 2014 15:52:45 +0200 Subject: Revert "Revert "Fix access to FP registers when visiting stack"" This reverts commit 8ebd94ab2e0d9867a7d384f00fa4cab24235216f. Fixes StackVisitor::GetVReg to read register value in a uintptr_t local and cast it into uint32_t pointer argument. Bug: 15433097 Change-Id: I4e13ed5446e823e9ec50fbc378b16be5b17b2294 --- runtime/arch/mips/context_mips.cc | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'runtime/arch/mips/context_mips.cc') diff --git a/runtime/arch/mips/context_mips.cc b/runtime/arch/mips/context_mips.cc index ad2889135a..789dbbb6d7 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(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(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(&gZero); gprs_[V1] = const_cast(&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); } -- cgit v1.2.3-59-g8ed1b