Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 1 | /* |
Elliott Hughes | 0f3c553 | 2012-03-30 14:51:51 -0700 | [diff] [blame] | 2 | * Copyright (C) 2012 The Android Open Source Project |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 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 | |
Ian Rogers | 166db04 | 2013-07-26 12:05:57 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_ENTRYPOINTS_QUICK_CALLEE_SAVE_FRAME_H_ |
| 18 | #define ART_RUNTIME_ENTRYPOINTS_QUICK_CALLEE_SAVE_FRAME_H_ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 19 | |
Ian Rogers | d582fa4 | 2014-11-05 23:46:43 -0800 | [diff] [blame] | 20 | #include "arch/instruction_set.h" |
Andreas Gampe | 8228cdf | 2017-05-30 15:03:54 -0700 | [diff] [blame] | 21 | #include "base/callee_save_type.h" |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 22 | #include "base/enums.h" |
Elliott Hughes | 76b6167 | 2012-12-12 17:47:30 -0800 | [diff] [blame] | 23 | #include "base/mutex.h" |
Vladimir Marko | d3083dd | 2018-05-17 08:43:47 +0100 | [diff] [blame] | 24 | #include "quick/quick_method_frame_info.h" |
Andreas Gampe | 8228cdf | 2017-05-30 15:03:54 -0700 | [diff] [blame] | 25 | #include "thread-inl.h" |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 26 | |
Alexei Zavjalov | 41c507a | 2014-05-15 16:02:46 +0700 | [diff] [blame] | 27 | // Specific frame size code is in architecture-specific files. We include this to compile-time |
| 28 | // specialize the code. |
Vladimir Marko | d3083dd | 2018-05-17 08:43:47 +0100 | [diff] [blame] | 29 | #include "arch/arm/callee_save_frame_arm.h" |
| 30 | #include "arch/arm64/callee_save_frame_arm64.h" |
| 31 | #include "arch/mips/callee_save_frame_mips.h" |
| 32 | #include "arch/mips64/callee_save_frame_mips64.h" |
| 33 | #include "arch/x86/callee_save_frame_x86.h" |
| 34 | #include "arch/x86_64/callee_save_frame_x86_64.h" |
Alexei Zavjalov | 41c507a | 2014-05-15 16:02:46 +0700 | [diff] [blame] | 35 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 36 | namespace art { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 37 | class ArtMethod; |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 38 | |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 39 | class ScopedQuickEntrypointChecks { |
| 40 | public: |
Andreas Gampe | 3b45ef2 | 2015-05-26 21:34:09 -0700 | [diff] [blame] | 41 | explicit ScopedQuickEntrypointChecks(Thread *self, |
| 42 | bool entry_check = kIsDebugBuild, |
| 43 | bool exit_check = kIsDebugBuild) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 44 | REQUIRES_SHARED(Locks::mutator_lock_) : self_(self), exit_check_(exit_check) { |
Andreas Gampe | 3b45ef2 | 2015-05-26 21:34:09 -0700 | [diff] [blame] | 45 | if (entry_check) { |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 46 | TestsOnEntry(); |
| 47 | } |
| 48 | } |
| 49 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 50 | ~ScopedQuickEntrypointChecks() REQUIRES_SHARED(Locks::mutator_lock_) { |
Andreas Gampe | 3b45ef2 | 2015-05-26 21:34:09 -0700 | [diff] [blame] | 51 | if (exit_check_) { |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 52 | TestsOnExit(); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | private: |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 57 | void TestsOnEntry() REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 58 | Locks::mutator_lock_->AssertSharedHeld(self_); |
| 59 | self_->VerifyStack(); |
| 60 | } |
| 61 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 62 | void TestsOnExit() REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 63 | Locks::mutator_lock_->AssertSharedHeld(self_); |
| 64 | self_->VerifyStack(); |
| 65 | } |
| 66 | |
| 67 | Thread* const self_; |
Andreas Gampe | 3b45ef2 | 2015-05-26 21:34:09 -0700 | [diff] [blame] | 68 | bool exit_check_; |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 69 | }; |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 70 | |
Vladimir Marko | b4eb1b1 | 2018-05-24 11:09:38 +0100 | [diff] [blame] | 71 | namespace detail { |
Alexei Zavjalov | 41c507a | 2014-05-15 16:02:46 +0700 | [diff] [blame] | 72 | |
Vladimir Marko | d3083dd | 2018-05-17 08:43:47 +0100 | [diff] [blame] | 73 | template <InstructionSet> |
| 74 | struct CSFSelector; // No definition for unspecialized callee save frame selector. |
Alexei Zavjalov | 41c507a | 2014-05-15 16:02:46 +0700 | [diff] [blame] | 75 | |
Vladimir Marko | d3083dd | 2018-05-17 08:43:47 +0100 | [diff] [blame] | 76 | // Note: kThumb2 is never the kRuntimeISA. |
| 77 | template <> |
| 78 | struct CSFSelector<InstructionSet::kArm> { using type = arm::ArmCalleeSaveFrame; }; |
| 79 | template <> |
| 80 | struct CSFSelector<InstructionSet::kArm64> { using type = arm64::Arm64CalleeSaveFrame; }; |
| 81 | template <> |
| 82 | struct CSFSelector<InstructionSet::kMips> { using type = mips::MipsCalleeSaveFrame; }; |
| 83 | template <> |
| 84 | struct CSFSelector<InstructionSet::kMips64> { using type = mips64::Mips64CalleeSaveFrame; }; |
| 85 | template <> |
| 86 | struct CSFSelector<InstructionSet::kX86> { using type = x86::X86CalleeSaveFrame; }; |
| 87 | template <> |
| 88 | struct CSFSelector<InstructionSet::kX86_64> { using type = x86_64::X86_64CalleeSaveFrame; }; |
| 89 | |
Vladimir Marko | b4eb1b1 | 2018-05-24 11:09:38 +0100 | [diff] [blame] | 90 | } // namespace detail |
Vladimir Marko | d3083dd | 2018-05-17 08:43:47 +0100 | [diff] [blame] | 91 | |
Vladimir Marko | b4eb1b1 | 2018-05-24 11:09:38 +0100 | [diff] [blame] | 92 | using RuntimeCalleeSaveFrame = detail::CSFSelector<kRuntimeISA>::type; |
Alexei Zavjalov | 41c507a | 2014-05-15 16:02:46 +0700 | [diff] [blame] | 93 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 94 | } // namespace art |
| 95 | |
Ian Rogers | 166db04 | 2013-07-26 12:05:57 -0700 | [diff] [blame] | 96 | #endif // ART_RUNTIME_ENTRYPOINTS_QUICK_CALLEE_SAVE_FRAME_H_ |