diff options
author | Sebastien Hertz <shertz@google.com> | 2014-06-17 09:49:21 +0000 |
---|---|---|
committer | Sebastien Hertz <shertz@google.com> | 2014-06-17 09:49:21 +0000 |
commit | 8ebd94ab2e0d9867a7d384f00fa4cab24235216f (patch) | |
tree | 5fc48d8179f6ec6942ebada59bc88c4626608410 /runtime | |
parent | aa9b3aee1e06f922e4518713f9b3dff00a0b2597 (diff) | |
download | art-8ebd94ab2e0d9867a7d384f00fa4cab24235216f.zip art-8ebd94ab2e0d9867a7d384f00fa4cab24235216f.tar.gz art-8ebd94ab2e0d9867a7d384f00fa4cab24235216f.tar.bz2 |
Revert "Fix access to FP registers when visiting stack"
This reverts commit aa9b3aee1e06f922e4518713f9b3dff00a0b2597.
Change-Id: Ied27deb89cca5ec9094d391374e03f83fcb76c33
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/arch/arm/context_arm.cc | 39 | ||||
-rw-r--r-- | runtime/arch/arm/context_arm.h | 46 | ||||
-rw-r--r-- | runtime/arch/arm64/context_arm64.cc | 113 | ||||
-rw-r--r-- | runtime/arch/arm64/context_arm64.h | 46 | ||||
-rw-r--r-- | runtime/arch/context.h | 28 | ||||
-rw-r--r-- | runtime/arch/mips/context_mips.cc | 37 | ||||
-rw-r--r-- | runtime/arch/mips/context_mips.h | 46 | ||||
-rw-r--r-- | runtime/arch/x86/context_x86.cc | 20 | ||||
-rw-r--r-- | runtime/arch/x86/context_x86.h | 39 | ||||
-rw-r--r-- | runtime/arch/x86_64/context_x86_64.cc | 25 | ||||
-rw-r--r-- | runtime/arch/x86_64/context_x86_64.h | 42 | ||||
-rw-r--r-- | runtime/debugger.cc | 246 | ||||
-rw-r--r-- | runtime/stack.cc | 48 | ||||
-rw-r--r-- | runtime/stack.h | 19 |
14 files changed, 258 insertions, 536 deletions
diff --git a/runtime/arch/arm/context_arm.cc b/runtime/arch/arm/context_arm.cc index 96ffc93..6a337b3 100644 --- a/runtime/arch/arm/context_arm.cc +++ b/runtime/arch/arm/context_arm.cc @@ -25,14 +25,14 @@ namespace art { namespace arm { -static constexpr uint32_t gZero = 0; +static const uint32_t gZero = 0; void ArmContext::Reset() { for (size_t i = 0; i < kNumberOfCoreRegisters; i++) { - gprs_[i] = nullptr; + gprs_[i] = NULL; } for (size_t i = 0; i < kNumberOfSRegisters; i++) { - fprs_[i] = nullptr; + fprs_[i] = NULL; } gprs_[SP] = &sp_; gprs_[PC] = &pc_; @@ -69,46 +69,31 @@ void ArmContext::FillCalleeSaves(const StackVisitor& fr) { } } -bool ArmContext::SetGPR(uint32_t reg, uintptr_t value) { +void ArmContext::SetGPR(uint32_t reg, uintptr_t value) { DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters)); DCHECK_NE(gprs_[reg], &gZero); // Can't overwrite this static value since they are never reset. - if (gprs_[reg] != nullptr) { - *gprs_[reg] = value; - return true; - } else { - return false; - } -} - -bool ArmContext::SetFPR(uint32_t reg, uintptr_t value) { - DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfSRegisters)); - DCHECK_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; - } + DCHECK(gprs_[reg] != NULL); + *gprs_[reg] = value; } void ArmContext::SmashCallerSaves() { // This needs to be 0 because we want a null/zero return value. gprs_[R0] = const_cast<uint32_t*>(&gZero); gprs_[R1] = const_cast<uint32_t*>(&gZero); - gprs_[R2] = nullptr; - gprs_[R3] = nullptr; + gprs_[R2] = NULL; + gprs_[R3] = NULL; } extern "C" void art_quick_do_long_jump(uint32_t*, uint32_t*); void ArmContext::DoLongJump() { - uintptr_t gprs[kNumberOfCoreRegisters]; - uint32_t fprs[kNumberOfSRegisters]; + uintptr_t gprs[16]; + uint32_t fprs[32]; for (size_t i = 0; i < kNumberOfCoreRegisters; ++i) { - gprs[i] = gprs_[i] != nullptr ? *gprs_[i] : ArmContext::kBadGprBase + i; + gprs[i] = gprs_[i] != NULL ? *gprs_[i] : ArmContext::kBadGprBase + i; } for (size_t i = 0; i < kNumberOfSRegisters; ++i) { - fprs[i] = fprs_[i] != nullptr ? *fprs_[i] : ArmContext::kBadFprBase + i; + fprs[i] = fprs_[i] != NULL ? *fprs_[i] : ArmContext::kBadGprBase + i; } DCHECK_EQ(reinterpret_cast<uintptr_t>(Thread::Current()), gprs[TR]); art_quick_do_long_jump(gprs, fprs); diff --git a/runtime/arch/arm/context_arm.h b/runtime/arch/arm/context_arm.h index e894f16..2ccce8d 100644 --- a/runtime/arch/arm/context_arm.h +++ b/runtime/arch/arm/context_arm.h @@ -32,53 +32,31 @@ class ArmContext : public Context { virtual ~ArmContext() {} - void Reset() OVERRIDE; + virtual void Reset(); - void FillCalleeSaves(const StackVisitor& fr) OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + virtual void FillCalleeSaves(const StackVisitor& fr) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetSP(uintptr_t new_sp) OVERRIDE { - bool success = SetGPR(SP, new_sp); - CHECK(success) << "Failed to set SP register"; + virtual void SetSP(uintptr_t new_sp) { + SetGPR(SP, new_sp); } - void SetPC(uintptr_t new_pc) OVERRIDE { - bool success = SetGPR(PC, new_pc); - CHECK(success) << "Failed to set PC register"; + virtual void SetPC(uintptr_t new_pc) { + SetGPR(PC, new_pc); } - uintptr_t* GetGPRAddress(uint32_t reg) OVERRIDE { + virtual uintptr_t* GetGPRAddress(uint32_t reg) { DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters)); return gprs_[reg]; } - bool GetGPR(uint32_t reg, uintptr_t* val) OVERRIDE { + virtual uintptr_t GetGPR(uint32_t reg) { DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters)); - if (gprs_[reg] == nullptr) { - return false; - } else { - DCHECK(val != nullptr); - *val = *gprs_[reg]; - return true; - } + return *gprs_[reg]; } - bool SetGPR(uint32_t reg, uintptr_t value) OVERRIDE; - - bool GetFPR(uint32_t reg, uintptr_t* val) OVERRIDE { - DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfSRegisters)); - if (fprs_[reg] == nullptr) { - return false; - } else { - DCHECK(val != nullptr); - *val = *fprs_[reg]; - return true; - } - } - - bool SetFPR(uint32_t reg, uintptr_t value) OVERRIDE; - - void SmashCallerSaves() OVERRIDE; - void DoLongJump() OVERRIDE; + virtual void SetGPR(uint32_t reg, uintptr_t value); + virtual void SmashCallerSaves(); + virtual void DoLongJump(); private: // Pointers to register locations, initialized to NULL or the specific registers below. diff --git a/runtime/arch/arm64/context_arm64.cc b/runtime/arch/arm64/context_arm64.cc index 3eb92c8..09e8b59 100644 --- a/runtime/arch/arm64/context_arm64.cc +++ b/runtime/arch/arm64/context_arm64.cc @@ -28,14 +28,14 @@ namespace art { namespace arm64 { -static constexpr uint64_t gZero = 0; +static const uint64_t gZero = 0; void Arm64Context::Reset() { for (size_t i = 0; i < kNumberOfCoreRegisters; i++) { - gprs_[i] = nullptr; + gprs_[i] = NULL; } for (size_t i = 0; i < kNumberOfDRegisters; i++) { - fprs_[i] = nullptr; + fprs_[i] = NULL; } gprs_[SP] = &sp_; gprs_[LR] = &pc_; @@ -73,88 +73,73 @@ void Arm64Context::FillCalleeSaves(const StackVisitor& fr) { } } -bool Arm64Context::SetGPR(uint32_t reg, uintptr_t value) { +void Arm64Context::SetGPR(uint32_t reg, uintptr_t value) { DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters)); DCHECK_NE(gprs_[reg], &gZero); // Can't overwrite this static value since they are never reset. - if (gprs_[reg] != nullptr) { - *gprs_[reg] = value; - return true; - } else { - return false; - } -} - -bool Arm64Context::SetFPR(uint32_t reg, uintptr_t value) { - DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfDRegisters)); - DCHECK_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; - } + DCHECK(gprs_[reg] != NULL); + *gprs_[reg] = value; } void Arm64Context::SmashCallerSaves() { // This needs to be 0 because we want a null/zero return value. gprs_[X0] = const_cast<uint64_t*>(&gZero); - gprs_[X1] = nullptr; - gprs_[X2] = nullptr; - gprs_[X3] = nullptr; - gprs_[X4] = nullptr; - gprs_[X5] = nullptr; - gprs_[X6] = nullptr; - gprs_[X7] = nullptr; - gprs_[X8] = nullptr; - gprs_[X9] = nullptr; - gprs_[X10] = nullptr; - gprs_[X11] = nullptr; - gprs_[X12] = nullptr; - gprs_[X13] = nullptr; - gprs_[X14] = nullptr; - gprs_[X15] = nullptr; + gprs_[X1] = NULL; + gprs_[X2] = NULL; + gprs_[X3] = NULL; + gprs_[X4] = NULL; + gprs_[X5] = NULL; + gprs_[X6] = NULL; + gprs_[X7] = NULL; + gprs_[X8] = NULL; + gprs_[X9] = NULL; + gprs_[X10] = NULL; + gprs_[X11] = NULL; + gprs_[X12] = NULL; + gprs_[X13] = NULL; + gprs_[X14] = NULL; + gprs_[X15] = NULL; // d0-d7, d16-d31 are caller-saved; d8-d15 are callee-saved. - fprs_[D0] = nullptr; - fprs_[D1] = nullptr; - fprs_[D2] = nullptr; - fprs_[D3] = nullptr; - fprs_[D4] = nullptr; - fprs_[D5] = nullptr; - fprs_[D6] = nullptr; - fprs_[D7] = nullptr; - - fprs_[D16] = nullptr; - fprs_[D17] = nullptr; - fprs_[D18] = nullptr; - fprs_[D19] = nullptr; - fprs_[D20] = nullptr; - fprs_[D21] = nullptr; - fprs_[D22] = nullptr; - fprs_[D23] = nullptr; - fprs_[D24] = nullptr; - fprs_[D25] = nullptr; - fprs_[D26] = nullptr; - fprs_[D27] = nullptr; - fprs_[D28] = nullptr; - fprs_[D29] = nullptr; - fprs_[D30] = nullptr; - fprs_[D31] = nullptr; + fprs_[D0] = NULL; + fprs_[D1] = NULL; + fprs_[D2] = NULL; + fprs_[D3] = NULL; + fprs_[D4] = NULL; + fprs_[D5] = NULL; + fprs_[D6] = NULL; + fprs_[D7] = NULL; + + fprs_[D16] = NULL; + fprs_[D17] = NULL; + fprs_[D18] = NULL; + fprs_[D19] = NULL; + fprs_[D20] = NULL; + fprs_[D21] = NULL; + fprs_[D22] = NULL; + fprs_[D23] = NULL; + fprs_[D24] = NULL; + fprs_[D25] = NULL; + fprs_[D26] = NULL; + fprs_[D27] = NULL; + fprs_[D28] = NULL; + fprs_[D29] = NULL; + fprs_[D30] = NULL; + fprs_[D31] = NULL; } extern "C" void art_quick_do_long_jump(uint64_t*, uint64_t*); void Arm64Context::DoLongJump() { uint64_t gprs[32]; - uint64_t fprs[kNumberOfDRegisters]; + uint64_t fprs[32]; // Do not use kNumberOfCoreRegisters, as this is with the distinction of SP and XZR for (size_t i = 0; i < 32; ++i) { - gprs[i] = gprs_[i] != nullptr ? *gprs_[i] : Arm64Context::kBadGprBase + i; + gprs[i] = gprs_[i] != NULL ? *gprs_[i] : Arm64Context::kBadGprBase + i; } for (size_t i = 0; i < kNumberOfDRegisters; ++i) { - fprs[i] = fprs_[i] != nullptr ? *fprs_[i] : Arm64Context::kBadGprBase + i; + fprs[i] = fprs_[i] != NULL ? *fprs_[i] : Arm64Context::kBadGprBase + i; } DCHECK_EQ(reinterpret_cast<uintptr_t>(Thread::Current()), gprs[TR]); art_quick_do_long_jump(gprs, fprs); diff --git a/runtime/arch/arm64/context_arm64.h b/runtime/arch/arm64/context_arm64.h index 1f69869..d40e291 100644 --- a/runtime/arch/arm64/context_arm64.h +++ b/runtime/arch/arm64/context_arm64.h @@ -32,53 +32,31 @@ class Arm64Context : public Context { ~Arm64Context() {} - void Reset() OVERRIDE; + void Reset(); - void FillCalleeSaves(const StackVisitor& fr) OVERRIDE; + void FillCalleeSaves(const StackVisitor& fr); - void SetSP(uintptr_t new_sp) OVERRIDE { - bool success = SetGPR(SP, new_sp); - CHECK(success) << "Failed to set SP register"; + void SetSP(uintptr_t new_sp) { + SetGPR(SP, new_sp); } - void SetPC(uintptr_t new_lr) OVERRIDE { - bool success = SetGPR(LR, new_lr); - CHECK(success) << "Failed to set LR register"; + void SetPC(uintptr_t new_lr) { + SetGPR(LR, new_lr); } - uintptr_t* GetGPRAddress(uint32_t reg) OVERRIDE { + virtual uintptr_t* GetGPRAddress(uint32_t reg) { DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters)); return gprs_[reg]; } - bool GetGPR(uint32_t reg, uintptr_t* val) OVERRIDE { + uintptr_t GetGPR(uint32_t reg) { DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters)); - if (gprs_[reg] == nullptr) { - return false; - } else { - DCHECK(val != nullptr); - *val = *gprs_[reg]; - return true; - } + return *gprs_[reg]; } - bool SetGPR(uint32_t reg, uintptr_t value) OVERRIDE; - - bool GetFPR(uint32_t reg, uintptr_t* val) OVERRIDE { - DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfDRegisters)); - if (fprs_[reg] == nullptr) { - return false; - } else { - DCHECK(val != nullptr); - *val = *fprs_[reg]; - return true; - } - } - - bool SetFPR(uint32_t reg, uintptr_t value) OVERRIDE; - - void SmashCallerSaves() OVERRIDE; - void DoLongJump() OVERRIDE; + void SetGPR(uint32_t reg, uintptr_t value); + void SmashCallerSaves(); + void DoLongJump(); private: // Pointers to register locations, initialized to NULL or the specific registers below. diff --git a/runtime/arch/context.h b/runtime/arch/context.h index 20a84dd..f7b7835 100644 --- a/runtime/arch/context.h +++ b/runtime/arch/context.h @@ -38,40 +38,30 @@ class Context { // Re-initializes the registers for context re-use. virtual void Reset() = 0; - // Reads values from callee saves in the given frame. The frame also holds + // Read values from callee saves in the given frame. The frame also holds // the method that holds the layout. virtual void FillCalleeSaves(const StackVisitor& fr) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0; - // Sets the stack pointer value. + // Set the stack pointer value virtual void SetSP(uintptr_t new_sp) = 0; - // Sets the program counter value. + // Set the program counter value virtual void SetPC(uintptr_t new_pc) = 0; // Gets the given GPRs address. virtual uintptr_t* GetGPRAddress(uint32_t reg) = 0; - // Reads the given GPR. Returns true if we successfully read the register and - // set its value into 'val', returns false otherwise. - virtual bool GetGPR(uint32_t reg, uintptr_t* val) = 0; + // Read the given GPR + virtual uintptr_t GetGPR(uint32_t reg) = 0; - // Sets the given GPR. Returns true if we successfully write the given value - // into the register, returns false otherwise. - virtual bool SetGPR(uint32_t reg, uintptr_t value) = 0; + // Set the given GPR. + virtual void SetGPR(uint32_t reg, uintptr_t value) = 0; - // Reads the given FPR. Returns true if we successfully read the register and - // set its value into 'val', returns false otherwise. - virtual bool GetFPR(uint32_t reg, uintptr_t* val) = 0; - - // Sets the given FPR. Returns true if we successfully write the given value - // into the register, returns false otherwise. - virtual bool SetFPR(uint32_t reg, uintptr_t value) = 0; - - // Smashes the caller save registers. If we're throwing, we don't want to return bogus values. + // Smash the caller save registers. If we're throwing, we don't want to return bogus values. virtual void SmashCallerSaves() = 0; - // Switches execution of the executing context to this context + // Switch execution of the executing context to this context virtual void DoLongJump() = 0; protected: diff --git a/runtime/arch/mips/context_mips.cc b/runtime/arch/mips/context_mips.cc index 789dbbb..ad28891 100644 --- a/runtime/arch/mips/context_mips.cc +++ b/runtime/arch/mips/context_mips.cc @@ -24,14 +24,14 @@ namespace art { namespace mips { -static constexpr uint32_t gZero = 0; +static const uint32_t gZero = 0; void MipsContext::Reset() { for (size_t i = 0; i < kNumberOfCoreRegisters; i++) { - gprs_[i] = nullptr; + gprs_[i] = NULL; } for (size_t i = 0; i < kNumberOfFRegisters; i++) { - fprs_[i] = nullptr; + fprs_[i] = NULL; } gprs_[SP] = &sp_; gprs_[RA] = &ra_; @@ -68,35 +68,20 @@ void MipsContext::FillCalleeSaves(const StackVisitor& fr) { } } -bool MipsContext::SetGPR(uint32_t reg, uintptr_t value) { +void 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. - 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; - } + CHECK(gprs_[reg] != NULL); + *gprs_[reg] = value; } 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] = nullptr; - gprs_[A2] = nullptr; - gprs_[A3] = nullptr; + gprs_[A1] = NULL; + gprs_[A2] = NULL; + gprs_[A3] = NULL; } extern "C" void art_quick_do_long_jump(uint32_t*, uint32_t*); @@ -105,10 +90,10 @@ void MipsContext::DoLongJump() { uintptr_t gprs[kNumberOfCoreRegisters]; uint32_t fprs[kNumberOfFRegisters]; for (size_t i = 0; i < kNumberOfCoreRegisters; ++i) { - gprs[i] = gprs_[i] != nullptr ? *gprs_[i] : MipsContext::kBadGprBase + i; + gprs[i] = gprs_[i] != NULL ? *gprs_[i] : MipsContext::kBadGprBase + i; } for (size_t i = 0; i < kNumberOfFRegisters; ++i) { - fprs[i] = fprs_[i] != nullptr ? *fprs_[i] : MipsContext::kBadGprBase + i; + fprs[i] = fprs_[i] != NULL ? *fprs_[i] : MipsContext::kBadGprBase + i; } art_quick_do_long_jump(gprs, fprs); } diff --git a/runtime/arch/mips/context_mips.h b/runtime/arch/mips/context_mips.h index f2ee335..d5f27ae 100644 --- a/runtime/arch/mips/context_mips.h +++ b/runtime/arch/mips/context_mips.h @@ -31,53 +31,31 @@ class MipsContext : public Context { } virtual ~MipsContext() {} - void Reset() OVERRIDE; + virtual void Reset(); - void FillCalleeSaves(const StackVisitor& fr) OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + virtual void FillCalleeSaves(const StackVisitor& fr) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetSP(uintptr_t new_sp) OVERRIDE { - bool success = SetGPR(SP, new_sp); - CHECK(success) << "Failed to set SP register"; + virtual void SetSP(uintptr_t new_sp) { + SetGPR(SP, new_sp); } - void SetPC(uintptr_t new_pc) OVERRIDE { - bool success = SetGPR(RA, new_pc); - CHECK(success) << "Failed to set RA register"; + virtual void SetPC(uintptr_t new_pc) { + SetGPR(RA, new_pc); } - uintptr_t* GetGPRAddress(uint32_t reg) OVERRIDE { + virtual uintptr_t* GetGPRAddress(uint32_t reg) { DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters)); return gprs_[reg]; } - bool GetGPR(uint32_t reg, uintptr_t* val) OVERRIDE { + virtual uintptr_t GetGPR(uint32_t reg) { CHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters)); - if (gprs_[reg] == nullptr) { - return false; - } else { - DCHECK(val != nullptr); - *val = *gprs_[reg]; - return true; - } + return *gprs_[reg]; } - bool SetGPR(uint32_t reg, uintptr_t value) OVERRIDE; - - bool GetFPR(uint32_t reg, uintptr_t* val) OVERRIDE { - CHECK_LT(reg, static_cast<uint32_t>(kNumberOfFRegisters)); - if (fprs_[reg] == nullptr) { - return false; - } else { - DCHECK(val != nullptr); - *val = *fprs_[reg]; - return true; - } - } - - bool SetFPR(uint32_t reg, uintptr_t value) OVERRIDE; - - void SmashCallerSaves() OVERRIDE; - void DoLongJump() OVERRIDE; + virtual void SetGPR(uint32_t reg, uintptr_t value); + virtual void SmashCallerSaves(); + virtual void DoLongJump(); private: // Pointers to registers in the stack, initialized to NULL except for the special cases below. diff --git a/runtime/arch/x86/context_x86.cc b/runtime/arch/x86/context_x86.cc index 37049cf..8c98d91 100644 --- a/runtime/arch/x86/context_x86.cc +++ b/runtime/arch/x86/context_x86.cc @@ -24,11 +24,11 @@ namespace art { namespace x86 { -static constexpr uintptr_t gZero = 0; +static const uintptr_t gZero = 0; void X86Context::Reset() { for (size_t i = 0; i < kNumberOfCpuRegisters; i++) { - gprs_[i] = nullptr; + gprs_[i] = NULL; } gprs_[ESP] = &esp_; // Initialize registers with easy to spot debug values. @@ -57,19 +57,15 @@ 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] = nullptr; - gprs_[EBX] = nullptr; + gprs_[ECX] = NULL; + gprs_[EBX] = NULL; } -bool X86Context::SetGPR(uint32_t reg, uintptr_t value) { +void X86Context::SetGPR(uint32_t reg, uintptr_t value) { CHECK_LT(reg, static_cast<uint32_t>(kNumberOfCpuRegisters)); CHECK_NE(gprs_[reg], &gZero); - if (gprs_[reg] != nullptr) { - *gprs_[reg] = value; - return true; - } else { - return false; - } + CHECK(gprs_[reg] != NULL); + *gprs_[reg] = value; } void X86Context::DoLongJump() { @@ -78,7 +74,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] != nullptr ? *gprs_[i] : X86Context::kBadGprBase + i; + gprs[kNumberOfCpuRegisters - i - 1] = gprs_[i] != NULL ? *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 a350b25..1c51026 100644 --- a/runtime/arch/x86/context_x86.h +++ b/runtime/arch/x86/context_x86.h @@ -31,49 +31,32 @@ class X86Context : public Context { } virtual ~X86Context() {} - void Reset() OVERRIDE; + virtual void Reset(); - void FillCalleeSaves(const StackVisitor& fr) OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + virtual void FillCalleeSaves(const StackVisitor& fr) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetSP(uintptr_t new_sp) OVERRIDE { - bool success = SetGPR(ESP, new_sp); - CHECK(success) << "Failed to set ESP register"; + virtual void SetSP(uintptr_t new_sp) { + SetGPR(ESP, new_sp); } - void SetPC(uintptr_t new_pc) OVERRIDE { + virtual void SetPC(uintptr_t new_pc) { eip_ = new_pc; } - uintptr_t* GetGPRAddress(uint32_t reg) OVERRIDE { + virtual uintptr_t* GetGPRAddress(uint32_t reg) { DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCpuRegisters)); return gprs_[reg]; } - bool GetGPR(uint32_t reg, uintptr_t* val) OVERRIDE { + virtual uintptr_t GetGPR(uint32_t reg) { DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCpuRegisters)); - if (gprs_[reg] == nullptr) { - return false; - } else { - DCHECK(val != nullptr); - *val = *gprs_[reg]; - return true; - } + return *gprs_[reg]; } - bool SetGPR(uint32_t reg, uintptr_t value) OVERRIDE; + virtual void SetGPR(uint32_t reg, uintptr_t value); - 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; + virtual void SmashCallerSaves(); + virtual void DoLongJump(); private: // Pointers to register locations, floating point registers are all caller save. Values are diff --git a/runtime/arch/x86_64/context_x86_64.cc b/runtime/arch/x86_64/context_x86_64.cc index 0ccbd27..810ef94 100644 --- a/runtime/arch/x86_64/context_x86_64.cc +++ b/runtime/arch/x86_64/context_x86_64.cc @@ -24,7 +24,7 @@ namespace art { namespace x86_64 { -static constexpr uintptr_t gZero = 0; +static const uintptr_t gZero = 0; void X86_64Context::Reset() { for (size_t i = 0; i < kNumberOfCpuRegisters; ++i) { @@ -80,26 +80,11 @@ void X86_64Context::SmashCallerSaves() { gprs_[R11] = nullptr; } -bool X86_64Context::SetGPR(uint32_t reg, uintptr_t value) { +void X86_64Context::SetGPR(uint32_t reg, uintptr_t value) { CHECK_LT(reg, static_cast<uint32_t>(kNumberOfCpuRegisters)); CHECK_NE(gprs_[reg], &gZero); - if (gprs_[reg] != nullptr) { - *gprs_[reg] = value; - return true; - } else { - return false; - } -} - -bool X86_64Context::SetFPR(uint32_t reg, uintptr_t value) { - CHECK_LT(reg, static_cast<uint32_t>(kNumberOfFloatRegisters)); - CHECK_NE(fprs_[reg], &gZero); - if (fprs_[reg] != nullptr) { - *fprs_[reg] = value; - return true; - } else { - return false; - } + CHECK(gprs_[reg] != NULL); + *gprs_[reg] = value; } void X86_64Context::DoLongJump() { @@ -108,7 +93,7 @@ void X86_64Context::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] != nullptr ? *gprs_[i] : X86_64Context::kBadGprBase + i; + gprs[kNumberOfCpuRegisters - i - 1] = gprs_[i] != NULL ? *gprs_[i] : X86_64Context::kBadGprBase + i; } // We want to load the stack pointer one slot below so that the ret will pop eip. uintptr_t rsp = gprs[kNumberOfCpuRegisters - RSP - 1] - kWordSize; diff --git a/runtime/arch/x86_64/context_x86_64.h b/runtime/arch/x86_64/context_x86_64.h index 902c3b9..055df61 100644 --- a/runtime/arch/x86_64/context_x86_64.h +++ b/runtime/arch/x86_64/context_x86_64.h @@ -31,52 +31,32 @@ class X86_64Context : public Context { } virtual ~X86_64Context() {} - void Reset() OVERRIDE; + virtual void Reset(); - void FillCalleeSaves(const StackVisitor& fr) OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + virtual void FillCalleeSaves(const StackVisitor& fr) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetSP(uintptr_t new_sp) OVERRIDE { - bool success = SetGPR(RSP, new_sp); - CHECK(success) << "Failed to set RSP register"; + virtual void SetSP(uintptr_t new_sp) { + SetGPR(RSP, new_sp); } - void SetPC(uintptr_t new_pc) OVERRIDE { + virtual void SetPC(uintptr_t new_pc) { rip_ = new_pc; } - uintptr_t* GetGPRAddress(uint32_t reg) OVERRIDE { + virtual uintptr_t* GetGPRAddress(uint32_t reg) { DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCpuRegisters)); return gprs_[reg]; } - bool GetGPR(uint32_t reg, uintptr_t* val) OVERRIDE { + virtual uintptr_t GetGPR(uint32_t reg) { DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCpuRegisters)); - if (gprs_[reg] == nullptr) { - return false; - } else { - DCHECK(val != nullptr); - *val = *gprs_[reg]; - return true; - } + return *gprs_[reg]; } - bool SetGPR(uint32_t reg, uintptr_t value) OVERRIDE; + virtual void SetGPR(uint32_t reg, uintptr_t value); - bool GetFPR(uint32_t reg, uintptr_t* val) OVERRIDE { - DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfFloatRegisters)); - if (fprs_[reg] == nullptr) { - return false; - } else { - DCHECK(val != nullptr); - *val = *fprs_[reg]; - return true; - } - } - - bool SetFPR(uint32_t reg, uintptr_t value) OVERRIDE; - - void SmashCallerSaves() OVERRIDE; - void DoLongJump() OVERRIDE; + virtual void SmashCallerSaves(); + virtual void DoLongJump(); private: // Pointers to register locations. Values are initialized to NULL or the special registers below. diff --git a/runtime/debugger.cc b/runtime/debugger.cc index 4b3d3b9..73ed590 100644 --- a/runtime/debugger.cc +++ b/runtime/debugger.cc @@ -2286,125 +2286,100 @@ JDWP::JdwpError Dbg::GetLocalValue(JDWP::ObjectId thread_id, JDWP::FrameId frame return false; } uint16_t reg = DemangleSlot(slot_, m); - constexpr JDWP::JdwpError kFailureErrorCode = JDWP::ERR_ABSENT_INFORMATION; + switch (tag_) { - case JDWP::JT_BOOLEAN: { + case JDWP::JT_BOOLEAN: + { CHECK_EQ(width_, 1U); - uint32_t intVal; - if (GetVReg(m, reg, kIntVReg, &intVal)) { - VLOG(jdwp) << "get boolean local " << reg << " = " << intVal; - JDWP::Set1(buf_+1, intVal != 0); - } else { - VLOG(jdwp) << "failed to get boolean local " << reg; - error_ = kFailureErrorCode; - } - break; + uint32_t intVal = GetVReg(m, reg, kIntVReg); + VLOG(jdwp) << "get boolean local " << reg << " = " << intVal; + JDWP::Set1(buf_+1, intVal != 0); } - case JDWP::JT_BYTE: { + break; + case JDWP::JT_BYTE: + { CHECK_EQ(width_, 1U); - uint32_t intVal; - if (GetVReg(m, reg, kIntVReg, &intVal)) { - VLOG(jdwp) << "get byte local " << reg << " = " << intVal; - JDWP::Set1(buf_+1, intVal); - } else { - VLOG(jdwp) << "failed to get byte local " << reg; - error_ = kFailureErrorCode; - } - break; + uint32_t intVal = GetVReg(m, reg, kIntVReg); + VLOG(jdwp) << "get byte local " << reg << " = " << intVal; + JDWP::Set1(buf_+1, intVal); } - case JDWP::JT_SHORT: - case JDWP::JT_CHAR: { + break; + case JDWP::JT_SHORT: + case JDWP::JT_CHAR: + { CHECK_EQ(width_, 2U); - uint32_t intVal; - if (GetVReg(m, reg, kIntVReg, &intVal)) { - VLOG(jdwp) << "get short/char local " << reg << " = " << intVal; - JDWP::Set2BE(buf_+1, intVal); - } else { - VLOG(jdwp) << "failed to get short/char local " << reg; - error_ = kFailureErrorCode; - } - break; + uint32_t intVal = GetVReg(m, reg, kIntVReg); + VLOG(jdwp) << "get short/char local " << reg << " = " << intVal; + JDWP::Set2BE(buf_+1, intVal); } - case JDWP::JT_INT: { + break; + case JDWP::JT_INT: + { CHECK_EQ(width_, 4U); - uint32_t intVal; - if (GetVReg(m, reg, kIntVReg, &intVal)) { - VLOG(jdwp) << "get int local " << reg << " = " << intVal; - JDWP::Set4BE(buf_+1, intVal); - } else { - VLOG(jdwp) << "failed to get int local " << reg; - error_ = kFailureErrorCode; - } - break; + uint32_t intVal = GetVReg(m, reg, kIntVReg); + VLOG(jdwp) << "get int local " << reg << " = " << intVal; + JDWP::Set4BE(buf_+1, intVal); } - case JDWP::JT_FLOAT: { + break; + case JDWP::JT_FLOAT: + { CHECK_EQ(width_, 4U); - uint32_t intVal; - if (GetVReg(m, reg, kFloatVReg, &intVal)) { - VLOG(jdwp) << "get float local " << reg << " = " << intVal; - JDWP::Set4BE(buf_+1, intVal); - } else { - VLOG(jdwp) << "failed to get float local " << reg; - error_ = kFailureErrorCode; + uint32_t intVal = GetVReg(m, reg, kFloatVReg); + VLOG(jdwp) << "get int/float local " << reg << " = " << intVal; + JDWP::Set4BE(buf_+1, intVal); + } + break; + case JDWP::JT_ARRAY: + { + CHECK_EQ(width_, sizeof(JDWP::ObjectId)); + mirror::Object* o = reinterpret_cast<mirror::Object*>(GetVReg(m, reg, kReferenceVReg)); + VLOG(jdwp) << "get array local " << reg << " = " << o; + if (!Runtime::Current()->GetHeap()->IsValidObjectAddress(o)) { + LOG(FATAL) << "Register " << reg << " expected to hold array: " << o; } - break; + JDWP::SetObjectId(buf_+1, gRegistry->Add(o)); } - case JDWP::JT_ARRAY: - case JDWP::JT_CLASS_LOADER: - case JDWP::JT_CLASS_OBJECT: - case JDWP::JT_OBJECT: - case JDWP::JT_STRING: - case JDWP::JT_THREAD: - case JDWP::JT_THREAD_GROUP: { + break; + case JDWP::JT_CLASS_LOADER: + case JDWP::JT_CLASS_OBJECT: + case JDWP::JT_OBJECT: + case JDWP::JT_STRING: + case JDWP::JT_THREAD: + case JDWP::JT_THREAD_GROUP: + { CHECK_EQ(width_, sizeof(JDWP::ObjectId)); - uint32_t intVal; - if (GetVReg(m, reg, kReferenceVReg, &intVal)) { - mirror::Object* o = reinterpret_cast<mirror::Object*>(intVal); - VLOG(jdwp) << "get " << tag_ << " object local " << reg << " = " << o; - if (!Runtime::Current()->GetHeap()->IsValidObjectAddress(o)) { - LOG(FATAL) << "Register " << reg << " expected to hold " << tag_ << " object: " << o; - } - tag_ = TagFromObject(soa_, o); - JDWP::SetObjectId(buf_+1, gRegistry->Add(o)); - } else { - VLOG(jdwp) << "failed to get " << tag_ << " object local " << reg; - error_ = kFailureErrorCode; + mirror::Object* o = reinterpret_cast<mirror::Object*>(GetVReg(m, reg, kReferenceVReg)); + VLOG(jdwp) << "get object local " << reg << " = " << o; + if (!Runtime::Current()->GetHeap()->IsValidObjectAddress(o)) { + LOG(FATAL) << "Register " << reg << " expected to hold object: " << o; } - break; + tag_ = TagFromObject(soa_, o); + JDWP::SetObjectId(buf_+1, gRegistry->Add(o)); } - case JDWP::JT_DOUBLE: { + break; + case JDWP::JT_DOUBLE: + { CHECK_EQ(width_, 8U); - uint32_t lo; - uint32_t hi; - if (GetVReg(m, reg, kDoubleLoVReg, &lo) && GetVReg(m, reg + 1, kDoubleHiVReg, &hi)) { - uint64_t longVal = (static_cast<uint64_t>(hi) << 32) | lo; - VLOG(jdwp) << "get double local " << reg << " = " - << hi << ":" << lo << " = " << longVal; - JDWP::Set8BE(buf_+1, longVal); - } else { - VLOG(jdwp) << "failed to get double local " << reg; - error_ = kFailureErrorCode; - } - break; + uint32_t lo = GetVReg(m, reg, kDoubleLoVReg); + uint64_t hi = GetVReg(m, reg + 1, kDoubleHiVReg); + uint64_t longVal = (hi << 32) | lo; + VLOG(jdwp) << "get double/long local " << hi << ":" << lo << " = " << longVal; + JDWP::Set8BE(buf_+1, longVal); } - case JDWP::JT_LONG: { + break; + case JDWP::JT_LONG: + { CHECK_EQ(width_, 8U); - uint32_t lo; - uint32_t hi; - if (GetVReg(m, reg, kLongLoVReg, &lo) && GetVReg(m, reg + 1, kLongHiVReg, &hi)) { - uint64_t longVal = (static_cast<uint64_t>(hi) << 32) | lo; - VLOG(jdwp) << "get long local " << reg << " = " - << hi << ":" << lo << " = " << longVal; - JDWP::Set8BE(buf_+1, longVal); - } else { - VLOG(jdwp) << "failed to get long local " << reg; - error_ = kFailureErrorCode; - } - break; + uint32_t lo = GetVReg(m, reg, kLongLoVReg); + uint64_t hi = GetVReg(m, reg + 1, kLongHiVReg); + uint64_t longVal = (hi << 32) | lo; + VLOG(jdwp) << "get double/long local " << hi << ":" << lo << " = " << longVal; + JDWP::Set8BE(buf_+1, longVal); } - default: - LOG(FATAL) << "Unknown tag " << tag_; - break; + break; + default: + LOG(FATAL) << "Unknown tag " << tag_; + break; } // Prepend tag, which may have been updated. @@ -2460,89 +2435,48 @@ JDWP::JdwpError Dbg::SetLocalValue(JDWP::ObjectId thread_id, JDWP::FrameId frame return false; } uint16_t reg = DemangleSlot(slot_, m); - constexpr JDWP::JdwpError kFailureErrorCode = JDWP::ERR_ABSENT_INFORMATION; + switch (tag_) { case JDWP::JT_BOOLEAN: case JDWP::JT_BYTE: CHECK_EQ(width_, 1U); - if (!SetVReg(m, reg, static_cast<uint32_t>(value_), kIntVReg)) { - VLOG(jdwp) << "failed to set boolean/byte local " << reg << " = " - << static_cast<uint32_t>(value_); - error_ = kFailureErrorCode; - } + SetVReg(m, reg, static_cast<uint32_t>(value_), kIntVReg); break; case JDWP::JT_SHORT: case JDWP::JT_CHAR: CHECK_EQ(width_, 2U); - if (!SetVReg(m, reg, static_cast<uint32_t>(value_), kIntVReg)) { - VLOG(jdwp) << "failed to set short/char local " << reg << " = " - << static_cast<uint32_t>(value_); - error_ = kFailureErrorCode; - } + SetVReg(m, reg, static_cast<uint32_t>(value_), kIntVReg); break; case JDWP::JT_INT: CHECK_EQ(width_, 4U); - if (!SetVReg(m, reg, static_cast<uint32_t>(value_), kIntVReg)) { - VLOG(jdwp) << "failed to set int local " << reg << " = " - << static_cast<uint32_t>(value_); - error_ = kFailureErrorCode; - } + SetVReg(m, reg, static_cast<uint32_t>(value_), kIntVReg); break; case JDWP::JT_FLOAT: CHECK_EQ(width_, 4U); - if (!SetVReg(m, reg, static_cast<uint32_t>(value_), kFloatVReg)) { - VLOG(jdwp) << "failed to set float local " << reg << " = " - << static_cast<uint32_t>(value_); - error_ = kFailureErrorCode; - } + SetVReg(m, reg, static_cast<uint32_t>(value_), kFloatVReg); break; case JDWP::JT_ARRAY: - case JDWP::JT_CLASS_LOADER: - case JDWP::JT_CLASS_OBJECT: case JDWP::JT_OBJECT: case JDWP::JT_STRING: - case JDWP::JT_THREAD: - case JDWP::JT_THREAD_GROUP: { + { CHECK_EQ(width_, sizeof(JDWP::ObjectId)); mirror::Object* o = gRegistry->Get<mirror::Object*>(static_cast<JDWP::ObjectId>(value_)); if (o == ObjectRegistry::kInvalidObject) { - VLOG(jdwp) << tag_ << " object " << o << " is an invalid object"; - error_ = JDWP::ERR_INVALID_OBJECT; - } else if (!SetVReg(m, reg, static_cast<uint32_t>(reinterpret_cast<uintptr_t>(o)), - kReferenceVReg)) { - VLOG(jdwp) << "failed to set " << tag_ << " object local " << reg << " = " << o; - error_ = kFailureErrorCode; + UNIMPLEMENTED(FATAL) << "return an error code when given an invalid object to store"; } - break; + SetVReg(m, reg, static_cast<uint32_t>(reinterpret_cast<uintptr_t>(o)), kReferenceVReg); } - case JDWP::JT_DOUBLE: { + break; + case JDWP::JT_DOUBLE: CHECK_EQ(width_, 8U); - const uint32_t lo = static_cast<uint32_t>(value_); - const uint32_t hi = static_cast<uint32_t>(value_ >> 32); - bool success = SetVReg(m, reg, lo, kDoubleLoVReg); - success &= SetVReg(m, reg + 1, hi, kDoubleHiVReg); - if (!success) { - uint64_t longVal = (static_cast<uint64_t>(hi) << 32) | lo; - VLOG(jdwp) << "failed to set double local " << reg << " = " - << hi << ":" << lo << " = " << longVal; - error_ = kFailureErrorCode; - } + SetVReg(m, reg, static_cast<uint32_t>(value_), kDoubleLoVReg); + SetVReg(m, reg + 1, static_cast<uint32_t>(value_ >> 32), kDoubleHiVReg); break; - } - case JDWP::JT_LONG: { + case JDWP::JT_LONG: CHECK_EQ(width_, 8U); - const uint32_t lo = static_cast<uint32_t>(value_); - const uint32_t hi = static_cast<uint32_t>(value_ >> 32); - bool success = SetVReg(m, reg, lo, kLongLoVReg); - success &= SetVReg(m, reg + 1, hi, kLongHiVReg); - if (!success) { - uint64_t longVal = (static_cast<uint64_t>(hi) << 32) | lo; - VLOG(jdwp) << "failed to set double local " << reg << " = " - << hi << ":" << lo << " = " << longVal; - error_ = kFailureErrorCode; - } + SetVReg(m, reg, static_cast<uint32_t>(value_), kLongLoVReg); + SetVReg(m, reg + 1, static_cast<uint32_t>(value_ >> 32), kLongHiVReg); break; - } default: LOG(FATAL) << "Unknown tag " << tag_; break; diff --git a/runtime/stack.cc b/runtime/stack.cc index 8d242cd..7e922c5 100644 --- a/runtime/stack.cc +++ b/runtime/stack.cc @@ -142,8 +142,7 @@ size_t StackVisitor::GetNativePcOffset() const { return GetMethod()->NativePcOffset(cur_quick_frame_pc_); } -bool StackVisitor::GetVReg(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind, - uint32_t* val) const { +uint32_t StackVisitor::GetVReg(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind) const { if (cur_quick_frame_ != NULL) { DCHECK(context_ != NULL); // You can't reliably read registers without a context. DCHECK(m == GetMethod()); @@ -156,26 +155,19 @@ bool StackVisitor::GetVReg(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind, if (vmap_table.IsInContext(vreg, kind, &vmap_offset)) { bool is_float = (kind == kFloatVReg) || (kind == kDoubleLoVReg) || (kind == kDoubleHiVReg); uint32_t spill_mask = is_float ? frame_info.FpSpillMask() : frame_info.CoreSpillMask(); - uint32_t reg = vmap_table.ComputeRegister(spill_mask, vmap_offset, kind); - if (is_float) { - return GetFPR(reg, val); - } else { - return GetGPR(reg, val); - } + return GetGPR(vmap_table.ComputeRegister(spill_mask, vmap_offset, kind)); } else { const DexFile::CodeItem* code_item = m->GetCodeItem(); DCHECK(code_item != NULL) << PrettyMethod(m); // Can't be NULL or how would we compile its instructions? - *val = *GetVRegAddr(cur_quick_frame_, code_item, frame_info.CoreSpillMask(), + return *GetVRegAddr(cur_quick_frame_, code_item, frame_info.CoreSpillMask(), frame_info.FpSpillMask(), frame_info.FrameSizeInBytes(), vreg); - return true; } } else { - *val = cur_shadow_frame_->GetVReg(vreg); - return true; + return cur_shadow_frame_->GetVReg(vreg); } } -bool StackVisitor::SetVReg(mirror::ArtMethod* m, uint16_t vreg, uint32_t new_value, +void StackVisitor::SetVReg(mirror::ArtMethod* m, uint16_t vreg, uint32_t new_value, VRegKind kind) { if (cur_quick_frame_ != NULL) { DCHECK(context_ != NULL); // You can't reliably write registers without a context. @@ -189,12 +181,8 @@ bool StackVisitor::SetVReg(mirror::ArtMethod* m, uint16_t vreg, uint32_t new_val if (vmap_table.IsInContext(vreg, kind, &vmap_offset)) { bool is_float = (kind == kFloatVReg) || (kind == kDoubleLoVReg) || (kind == kDoubleHiVReg); uint32_t spill_mask = is_float ? frame_info.FpSpillMask() : frame_info.CoreSpillMask(); - const uint32_t reg = vmap_table.ComputeRegister(spill_mask, vmap_offset, kind); - if (is_float) { - return SetFPR(reg, new_value); - } else { - return SetGPR(reg, new_value); - } + const uint32_t reg = vmap_table.ComputeRegister(spill_mask, vmap_offset, kReferenceVReg); + SetGPR(reg, new_value); } else { const DexFile::CodeItem* code_item = m->GetCodeItem(); DCHECK(code_item != NULL) << PrettyMethod(m); // Can't be NULL or how would we compile its instructions? @@ -202,11 +190,9 @@ bool StackVisitor::SetVReg(mirror::ArtMethod* m, uint16_t vreg, uint32_t new_val frame_info.FrameSizeInBytes(), vreg, kRuntimeISA); byte* vreg_addr = reinterpret_cast<byte*>(GetCurrentQuickFrame()) + offset; *reinterpret_cast<uint32_t*>(vreg_addr) = new_value; - return true; } } else { - cur_shadow_frame_->SetVReg(vreg, new_value); - return true; + return cur_shadow_frame_->SetVReg(vreg, new_value); } } @@ -215,24 +201,14 @@ uintptr_t* StackVisitor::GetGPRAddress(uint32_t reg) const { return context_->GetGPRAddress(reg); } -bool StackVisitor::GetGPR(uint32_t reg, uintptr_t* val) const { - DCHECK(cur_quick_frame_ != NULL) << "This is a quick frame routine"; - return context_->GetGPR(reg, val); -} - -bool StackVisitor::SetGPR(uint32_t reg, uintptr_t value) { - DCHECK(cur_quick_frame_ != NULL) << "This is a quick frame routine"; - return context_->SetGPR(reg, value); -} - -bool StackVisitor::GetFPR(uint32_t reg, uintptr_t* val) const { +uintptr_t StackVisitor::GetGPR(uint32_t reg) const { DCHECK(cur_quick_frame_ != NULL) << "This is a quick frame routine"; - return context_->GetFPR(reg, val); + return context_->GetGPR(reg); } -bool StackVisitor::SetFPR(uint32_t reg, uintptr_t value) { +void StackVisitor::SetGPR(uint32_t reg, uintptr_t value) { DCHECK(cur_quick_frame_ != NULL) << "This is a quick frame routine"; - return context_->SetFPR(reg, value); + context_->SetGPR(reg, value); } uintptr_t StackVisitor::GetReturnPc() const { diff --git a/runtime/stack.h b/runtime/stack.h index 9402cdd..1991115 100644 --- a/runtime/stack.h +++ b/runtime/stack.h @@ -561,21 +561,15 @@ class StackVisitor { bool GetNextMethodAndDexPc(mirror::ArtMethod** next_method, uint32_t* next_dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - bool GetVReg(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind, uint32_t* val) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - uint32_t GetVReg(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - uint32_t val; - bool success = GetVReg(m, vreg, kind, &val); - CHECK(success) << "Failed to read vreg " << vreg << " of kind " << kind; - return val; - } + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - bool SetVReg(mirror::ArtMethod* m, uint16_t vreg, uint32_t new_value, VRegKind kind) + void SetVReg(mirror::ArtMethod* m, uint16_t vreg, uint32_t new_value, VRegKind kind) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); uintptr_t* GetGPRAddress(uint32_t reg) const; + uintptr_t GetGPR(uint32_t reg) const; + void SetGPR(uint32_t reg, uintptr_t value); // This is a fast-path for getting/setting values in a quick frame. uint32_t* GetVRegAddr(StackReference<mirror::ArtMethod>* cur_quick_frame, @@ -706,11 +700,6 @@ class StackVisitor { StackVisitor(Thread* thread, Context* context, size_t num_frames) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - bool GetGPR(uint32_t reg, uintptr_t* val) const; - bool SetGPR(uint32_t reg, uintptr_t value); - bool GetFPR(uint32_t reg, uintptr_t* val) const; - bool SetFPR(uint32_t reg, uintptr_t value); - instrumentation::InstrumentationStackFrame& GetInstrumentationStackFrame(uint32_t depth) const; void SanityCheckFrame() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |