1 /* 2 * Copyright (C) 2012 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_ENTRYPOINTS_QUICK_CALLEE_SAVE_FRAME_H_ 18 #define ART_RUNTIME_ENTRYPOINTS_QUICK_CALLEE_SAVE_FRAME_H_ 19 20 #include "arch/instruction_set.h" 21 #include "base/callee_save_type.h" 22 #include "base/enums.h" 23 #include "base/locks.h" 24 #include "quick/quick_method_frame_info.h" 25 #include "thread-inl.h" 26 27 // Specific frame size code is in architecture-specific files. We include this to compile-time 28 // specialize the code. 29 #include "arch/arm/callee_save_frame_arm.h" 30 #include "arch/arm64/callee_save_frame_arm64.h" 31 #include "arch/riscv64/callee_save_frame_riscv64.h" 32 #include "arch/x86/callee_save_frame_x86.h" 33 #include "arch/x86_64/callee_save_frame_x86_64.h" 34 35 namespace art { 36 class ArtMethod; 37 38 class ScopedQuickEntrypointChecks { 39 public: 40 explicit ScopedQuickEntrypointChecks(Thread *self, 41 bool entry_check = kIsDebugBuild, 42 bool exit_check = kIsDebugBuild) REQUIRES_SHARED(Locks::mutator_lock_)43 REQUIRES_SHARED(Locks::mutator_lock_) : self_(self), exit_check_(exit_check) { 44 if (entry_check) { 45 TestsOnEntry(); 46 } 47 } 48 REQUIRES_SHARED(Locks::mutator_lock_)49 ~ScopedQuickEntrypointChecks() REQUIRES_SHARED(Locks::mutator_lock_) { 50 if (exit_check_) { 51 TestsOnExit(); 52 } 53 } 54 55 private: TestsOnEntry()56 void TestsOnEntry() REQUIRES_SHARED(Locks::mutator_lock_) { 57 Locks::mutator_lock_->AssertSharedHeld(self_); 58 self_->VerifyStack(); 59 } 60 TestsOnExit()61 void TestsOnExit() REQUIRES_SHARED(Locks::mutator_lock_) { 62 Locks::mutator_lock_->AssertSharedHeld(self_); 63 self_->VerifyStack(); 64 } 65 66 Thread* const self_; 67 bool exit_check_; 68 }; 69 70 namespace detail { 71 72 template <InstructionSet> 73 struct CSFSelector; // No definition for unspecialized callee save frame selector. 74 75 // Note: kThumb2 is never the kRuntimeISA. 76 template <> 77 struct CSFSelector<InstructionSet::kArm> { 78 using type = arm::ArmCalleeSaveFrame; 79 }; 80 template <> 81 struct CSFSelector<InstructionSet::kArm64> { 82 using type = arm64::Arm64CalleeSaveFrame; 83 }; 84 template <> 85 struct CSFSelector<InstructionSet::kRiscv64> { 86 using type = riscv64::Riscv64CalleeSaveFrame; 87 }; 88 template <> 89 struct CSFSelector<InstructionSet::kX86> { 90 using type = x86::X86CalleeSaveFrame; 91 }; 92 template <> 93 struct CSFSelector<InstructionSet::kX86_64> { 94 using type = x86_64::X86_64CalleeSaveFrame; 95 }; 96 97 } // namespace detail 98 99 using RuntimeCalleeSaveFrame = detail::CSFSelector<kRuntimeISA>::type; 100 101 } // namespace art 102 103 #endif // ART_RUNTIME_ENTRYPOINTS_QUICK_CALLEE_SAVE_FRAME_H_ 104