diff options
Diffstat (limited to 'runtime/arch/x86')
| -rw-r--r-- | runtime/arch/x86/context_x86.cc | 20 | ||||
| -rw-r--r-- | runtime/arch/x86/context_x86.h | 39 |
2 files changed, 40 insertions, 19 deletions
diff --git a/runtime/arch/x86/context_x86.cc b/runtime/arch/x86/context_x86.cc index 8c98d910c5..37049cfd7b 100644 --- a/runtime/arch/x86/context_x86.cc +++ b/runtime/arch/x86/context_x86.cc @@ -24,11 +24,11 @@ namespace art { namespace x86 { -static const uintptr_t gZero = 0; +static constexpr uintptr_t gZero = 0; void X86Context::Reset() { for (size_t i = 0; i < kNumberOfCpuRegisters; i++) { - gprs_[i] = NULL; + gprs_[i] = nullptr; } gprs_[ESP] = &esp_; // Initialize registers with easy to spot debug values. @@ -57,15 +57,19 @@ void X86Context::SmashCallerSaves() { // This needs to be 0 because we want a null/zero return value. gprs_[EAX] = const_cast<uintptr_t*>(&gZero); gprs_[EDX] = const_cast<uintptr_t*>(&gZero); - gprs_[ECX] = NULL; - gprs_[EBX] = NULL; + gprs_[ECX] = nullptr; + gprs_[EBX] = nullptr; } -void X86Context::SetGPR(uint32_t reg, uintptr_t value) { +bool X86Context::SetGPR(uint32_t reg, uintptr_t value) { CHECK_LT(reg, static_cast<uint32_t>(kNumberOfCpuRegisters)); CHECK_NE(gprs_[reg], &gZero); - CHECK(gprs_[reg] != NULL); - *gprs_[reg] = value; + if (gprs_[reg] != nullptr) { + *gprs_[reg] = value; + return true; + } else { + return false; + } } void X86Context::DoLongJump() { @@ -74,7 +78,7 @@ void X86Context::DoLongJump() { // the top for the stack pointer that doesn't get popped in a pop-all. volatile uintptr_t gprs[kNumberOfCpuRegisters + 1]; for (size_t i = 0; i < kNumberOfCpuRegisters; ++i) { - gprs[kNumberOfCpuRegisters - i - 1] = gprs_[i] != NULL ? *gprs_[i] : X86Context::kBadGprBase + i; + gprs[kNumberOfCpuRegisters - i - 1] = gprs_[i] != nullptr ? *gprs_[i] : X86Context::kBadGprBase + i; } // We want to load the stack pointer one slot below so that the ret will pop eip. uintptr_t esp = gprs[kNumberOfCpuRegisters - ESP - 1] - kWordSize; diff --git a/runtime/arch/x86/context_x86.h b/runtime/arch/x86/context_x86.h index 1c510265f9..a350b2500f 100644 --- a/runtime/arch/x86/context_x86.h +++ b/runtime/arch/x86/context_x86.h @@ -31,32 +31,49 @@ class X86Context : public Context { } virtual ~X86Context() {} - virtual void Reset(); + void Reset() OVERRIDE; - virtual void FillCalleeSaves(const StackVisitor& fr) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void FillCalleeSaves(const StackVisitor& fr) OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - virtual void SetSP(uintptr_t new_sp) { - SetGPR(ESP, new_sp); + void SetSP(uintptr_t new_sp) OVERRIDE { + bool success = SetGPR(ESP, new_sp); + CHECK(success) << "Failed to set ESP register"; } - virtual void SetPC(uintptr_t new_pc) { + void SetPC(uintptr_t new_pc) OVERRIDE { eip_ = new_pc; } - virtual uintptr_t* GetGPRAddress(uint32_t reg) { + uintptr_t* GetGPRAddress(uint32_t reg) OVERRIDE { DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCpuRegisters)); return gprs_[reg]; } - virtual uintptr_t GetGPR(uint32_t reg) { + bool GetGPR(uint32_t reg, uintptr_t* val) OVERRIDE { DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCpuRegisters)); - return *gprs_[reg]; + if (gprs_[reg] == nullptr) { + return false; + } else { + DCHECK(val != nullptr); + *val = *gprs_[reg]; + return true; + } } - virtual void SetGPR(uint32_t reg, uintptr_t value); + bool SetGPR(uint32_t reg, uintptr_t value) OVERRIDE; - virtual void SmashCallerSaves(); - virtual void DoLongJump(); + bool GetFPR(uint32_t reg, uintptr_t* val) OVERRIDE { + LOG(FATAL) << "Floating-point registers are all caller save in X86"; + return false; + } + + bool SetFPR(uint32_t reg, uintptr_t value) OVERRIDE { + LOG(FATAL) << "Floating-point registers are all caller save in X86"; + return false; + } + + void SmashCallerSaves() OVERRIDE; + void DoLongJump() OVERRIDE; private: // Pointers to register locations, floating point registers are all caller save. Values are |