context_arm.h revision 815873ecc312b1d231acce71e1a16f42cdaf09f2
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 "locks.h" 21#include "arch/context.h" 22#include "base/logging.h" 23#include "registers_arm.h" 24 25namespace art { 26namespace arm { 27 28class ArmContext : public Context { 29 public: 30 ArmContext() { 31 Reset(); 32 } 33 34 virtual ~ArmContext() {} 35 36 virtual void Reset(); 37 38 virtual void FillCalleeSaves(const StackVisitor& fr) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 39 40 virtual void SetSP(uintptr_t new_sp) { 41 SetGPR(SP, new_sp); 42 } 43 44 virtual void SetPC(uintptr_t new_pc) { 45 SetGPR(PC, new_pc); 46 } 47 48 virtual uintptr_t* GetGPRAddress(uint32_t reg) { 49 DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters)); 50 return gprs_[reg]; 51 } 52 53 virtual uintptr_t GetGPR(uint32_t reg) { 54 DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters)); 55 return *gprs_[reg]; 56 } 57 58 virtual void SetGPR(uint32_t reg, uintptr_t value); 59 virtual void SmashCallerSaves(); 60 virtual void DoLongJump(); 61 62 private: 63 // Pointers to register locations, initialized to NULL or the specific registers below. 64 uintptr_t* gprs_[kNumberOfCoreRegisters]; 65 uint32_t* fprs_[kNumberOfSRegisters]; 66 // Hold values for sp and pc if they are not located within a stack frame. 67 uintptr_t sp_, pc_; 68}; 69 70} // namespace arm 71} // namespace art 72 73#endif // ART_RUNTIME_ARCH_ARM_CONTEXT_ARM_H_ 74