context_arm.h revision 6702243ea2332b566d8e8b871cc9db0906d835ad
12faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes/* 22faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Copyright (C) 2011 The Android Open Source Project 32faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 42faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 52faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * you may not use this file except in compliance with the License. 62faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * You may obtain a copy of the License at 72faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 82faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 92faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 102faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Unless required by applicable law or agreed to in writing, software 112faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 122faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 132faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * See the License for the specific language governing permissions and 142faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * limitations under the License. 152faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes */ 16bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers 1757b86d47b66322693a070185fadfb43cb9c12eabIan Rogers#ifndef ART_SRC_OAT_RUNTIME_ARM_CONTEXT_ARM_H_ 1857b86d47b66322693a070185fadfb43cb9c12eabIan Rogers#define ART_SRC_OAT_RUNTIME_ARM_CONTEXT_ARM_H_ 19bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers 206702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier#include "locks.h" 21bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers#include "constants_arm.h" 2257b86d47b66322693a070185fadfb43cb9c12eabIan Rogers#include "oat/runtime/context.h" 23bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers 24bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogersnamespace art { 25bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogersnamespace arm { 26bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers 27bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogersclass ArmContext : public Context { 28bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers public: 296702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier ArmContext() { 306702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier Reset(); 316702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier } 326702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier 33bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers virtual ~ArmContext() {} 34bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers 356702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier virtual void Reset(); 366702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier 370399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers virtual void FillCalleeSaves(const StackVisitor& fr); 38bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers 39bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers virtual void SetSP(uintptr_t new_sp) { 406702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier SetGPR(SP, new_sp); 41bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers } 42bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers 43bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers virtual void SetPC(uintptr_t new_pc) { 446702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier SetGPR(PC, new_pc); 45bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers } 46bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers 47d6b1f6190c8ec42facb08aca34b093244774b318Ian Rogers virtual uintptr_t GetGPR(uint32_t reg) { 486702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier CHECK_LT(reg, kNumberOfCoreRegisters); 496702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier return *gprs_[reg]; 50d6b1f6190c8ec42facb08aca34b093244774b318Ian Rogers } 51d6b1f6190c8ec42facb08aca34b093244774b318Ian Rogers 526702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier virtual void SetGPR(uint32_t reg, uintptr_t value); 539c750f9b6283f62b3e6a93c0c6b2838abde5000eElliott Hughes virtual void SmashCallerSaves(); 54bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers virtual void DoLongJump(); 55bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers 56bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers private: 576702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier // Pointers to register locations, initialized to NULL or the specific registers below. 586702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier uintptr_t* gprs_[kNumberOfCoreRegisters]; 596702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier uint32_t* fprs_[kNumberOfSRegisters]; 606702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier // Hold values for sp and pc if they are not located within a stack frame. 616702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier uintptr_t sp_, pc_; 62bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers}; 63bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers 64bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers} // namespace arm 65bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers} // namespace art 66bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers 6757b86d47b66322693a070185fadfb43cb9c12eabIan Rogers#endif // ART_SRC_OAT_RUNTIME_ARM_CONTEXT_ARM_H_ 68