• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 {
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 
SetArg0(uintptr_t new_arg0_value)49   void SetArg0(uintptr_t new_arg0_value) override {
50     SetGPR(R0, new_arg0_value);
51   }
52 
IsAccessibleGPR(uint32_t reg)53   bool IsAccessibleGPR(uint32_t reg) override {
54     DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters));
55     return gprs_[reg] != nullptr;
56   }
57 
GetGPRAddress(uint32_t reg)58   uintptr_t* GetGPRAddress(uint32_t reg) override {
59     DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters));
60     return gprs_[reg];
61   }
62 
GetGPR(uint32_t reg)63   uintptr_t GetGPR(uint32_t reg) override {
64     DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters));
65     DCHECK(IsAccessibleGPR(reg));
66     return *gprs_[reg];
67   }
68 
69   void SetGPR(uint32_t reg, uintptr_t value) override;
70 
IsAccessibleFPR(uint32_t reg)71   bool IsAccessibleFPR(uint32_t reg) override {
72     DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfSRegisters));
73     return fprs_[reg] != nullptr;
74   }
75 
GetFPR(uint32_t reg)76   uintptr_t GetFPR(uint32_t reg) override {
77     DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfSRegisters));
78     DCHECK(IsAccessibleFPR(reg));
79     return *fprs_[reg];
80   }
81 
82   void SetFPR(uint32_t reg, uintptr_t value) override;
83 
84   void SmashCallerSaves() override;
85   NO_RETURN void DoLongJump() override;
86 
87  private:
88   // Pointers to register locations, initialized to null or the specific registers below.
89   uintptr_t* gprs_[kNumberOfCoreRegisters];
90   uint32_t* fprs_[kNumberOfSRegisters];
91   // Hold values for sp and pc if they are not located within a stack frame.
92   uintptr_t sp_, pc_, arg0_;
93 };
94 
95 }  // namespace arm
96 }  // namespace art
97 
98 #endif  // ART_RUNTIME_ARCH_ARM_CONTEXT_ARM_H_
99