1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ART_RUNTIME_ARCH_ARM_CONTEXT_ARM_H_ 18 #define ART_RUNTIME_ARCH_ARM_CONTEXT_ARM_H_ 19 20 #include <android-base/logging.h> 21 22 #include "arch/context.h" 23 #include "base/macros.h" 24 #include "registers_arm.h" 25 26 namespace art HIDDEN { 27 namespace arm { 28 29 class ArmContext final : public Context { 30 public: ArmContext()31 ArmContext() { 32 Reset(); 33 } 34 ~ArmContext()35 virtual ~ArmContext() {} 36 37 void Reset() override; 38 39 void FillCalleeSaves(uint8_t* frame, const QuickMethodFrameInfo& fr) override; 40 SetSP(uintptr_t new_sp)41 void SetSP(uintptr_t new_sp) override { 42 SetGPR(SP, new_sp); 43 } 44 SetPC(uintptr_t new_pc)45 void SetPC(uintptr_t new_pc) override { 46 SetGPR(PC, new_pc); 47 } 48 SetNterpDexPC(uintptr_t dex_pc_ptr)49 void SetNterpDexPC(uintptr_t dex_pc_ptr) override { 50 SetGPR(R11, dex_pc_ptr); 51 } 52 SetArg0(uintptr_t new_arg0_value)53 void SetArg0(uintptr_t new_arg0_value) override { 54 SetGPR(R0, new_arg0_value); 55 } 56 IsAccessibleGPR(uint32_t reg)57 bool IsAccessibleGPR(uint32_t reg) override { 58 DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters)); 59 return gprs_[reg] != nullptr; 60 } 61 GetGPRAddress(uint32_t reg)62 uintptr_t* GetGPRAddress(uint32_t reg) override { 63 DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters)); 64 return gprs_[reg]; 65 } 66 GetGPR(uint32_t reg)67 uintptr_t GetGPR(uint32_t reg) override { 68 DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters)); 69 DCHECK(IsAccessibleGPR(reg)); 70 return *gprs_[reg]; 71 } 72 73 void SetGPR(uint32_t reg, uintptr_t value) override; 74 IsAccessibleFPR(uint32_t reg)75 bool IsAccessibleFPR(uint32_t reg) override { 76 DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfSRegisters)); 77 return fprs_[reg] != nullptr; 78 } 79 GetFPR(uint32_t reg)80 uintptr_t GetFPR(uint32_t reg) override { 81 DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfSRegisters)); 82 DCHECK(IsAccessibleFPR(reg)); 83 return *fprs_[reg]; 84 } 85 86 void SetFPR(uint32_t reg, uintptr_t value) override; 87 88 void SmashCallerSaves() override; 89 NO_RETURN void DoLongJump() override; 90 91 private: 92 // Pointers to register locations, initialized to null or the specific registers below. 93 uintptr_t* gprs_[kNumberOfCoreRegisters]; 94 uint32_t* fprs_[kNumberOfSRegisters]; 95 // Hold values for sp and pc if they are not located within a stack frame. 96 uintptr_t sp_, pc_, arg0_; 97 }; 98 99 } // namespace arm 100 } // namespace art 101 102 #endif // ART_RUNTIME_ARCH_ARM_CONTEXT_ARM_H_ 103