Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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_RUNTIME_INL_H_ |
| 18 | #define ART_RUNTIME_RUNTIME_INL_H_ |
| 19 | |
| 20 | #include "runtime.h" |
| 21 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 22 | #include "art_method.h" |
Andreas Gampe | 8228cdf | 2017-05-30 15:03:54 -0700 | [diff] [blame] | 23 | #include "base/callee_save_type.h" |
Andreas Gampe | c15a2f4 | 2017-04-21 12:09:39 -0700 | [diff] [blame] | 24 | #include "gc_root-inl.h" |
Mathieu Chartier | 8778c52 | 2016-10-04 19:06:30 -0700 | [diff] [blame] | 25 | #include "obj_ptr-inl.h" |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 26 | |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 27 | namespace art { |
| 28 | |
Mathieu Chartier | 8778c52 | 2016-10-04 19:06:30 -0700 | [diff] [blame] | 29 | inline bool Runtime::IsClearedJniWeakGlobal(ObjPtr<mirror::Object> obj) { |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 30 | return obj == GetClearedJniWeakGlobal(); |
| 31 | } |
| 32 | |
| 33 | inline mirror::Object* Runtime::GetClearedJniWeakGlobal() { |
| 34 | mirror::Object* obj = sentinel_.Read(); |
Hiroshi Yamauchi | 8a74117 | 2014-09-08 13:22:56 -0700 | [diff] [blame] | 35 | DCHECK(obj != nullptr); |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 36 | return obj; |
| 37 | } |
| 38 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 39 | inline QuickMethodFrameInfo Runtime::GetRuntimeMethodFrameInfo(ArtMethod* method) { |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 40 | DCHECK(method != nullptr); |
| 41 | // Cannot be imt-conflict-method or resolution-method. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 42 | DCHECK_NE(method, GetImtConflictMethod()); |
| 43 | DCHECK_NE(method, GetResolutionMethod()); |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 44 | // Don't use GetCalleeSaveMethod(), some tests don't set all callee save methods. |
Andreas Gampe | 8228cdf | 2017-05-30 15:03:54 -0700 | [diff] [blame] | 45 | if (method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveRefsAndArgs)) { |
| 46 | return GetCalleeSaveMethodFrameInfo(CalleeSaveType::kSaveRefsAndArgs); |
| 47 | } else if (method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveAllCalleeSaves)) { |
| 48 | return GetCalleeSaveMethodFrameInfo(CalleeSaveType::kSaveAllCalleeSaves); |
| 49 | } else if (method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveRefsOnly)) { |
| 50 | return GetCalleeSaveMethodFrameInfo(CalleeSaveType::kSaveRefsOnly); |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 51 | } else { |
Mingyao Yang | 0a87a65 | 2017-04-12 13:43:15 -0700 | [diff] [blame] | 52 | DCHECK(method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveEverything) || |
| 53 | method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveEverythingForClinit) || |
| 54 | method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveEverythingForSuspendCheck)); |
Andreas Gampe | 8228cdf | 2017-05-30 15:03:54 -0700 | [diff] [blame] | 55 | return GetCalleeSaveMethodFrameInfo(CalleeSaveType::kSaveEverything); |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 56 | } |
| 57 | } |
| 58 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 59 | inline ArtMethod* Runtime::GetResolutionMethod() { |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 60 | CHECK(HasResolutionMethod()); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 61 | return resolution_method_; |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 62 | } |
| 63 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 64 | inline ArtMethod* Runtime::GetImtConflictMethod() { |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 65 | CHECK(HasImtConflictMethod()); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 66 | return imt_conflict_method_; |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 67 | } |
| 68 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 69 | inline ArtMethod* Runtime::GetImtUnimplementedMethod() { |
| 70 | CHECK(imt_unimplemented_method_ != nullptr); |
| 71 | return imt_unimplemented_method_; |
Mathieu Chartier | 2d2621a | 2014-10-23 16:48:06 -0700 | [diff] [blame] | 72 | } |
| 73 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 74 | inline ArtMethod* Runtime::GetCalleeSaveMethod(CalleeSaveType type) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 75 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 76 | DCHECK(HasCalleeSaveMethod(type)); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 77 | return GetCalleeSaveMethodUnchecked(type); |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 78 | } |
| 79 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 80 | inline ArtMethod* Runtime::GetCalleeSaveMethodUnchecked(CalleeSaveType type) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 81 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Andreas Gampe | 8228cdf | 2017-05-30 15:03:54 -0700 | [diff] [blame] | 82 | return reinterpret_cast<ArtMethod*>(callee_save_methods_[static_cast<size_t>(type)]); |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 83 | } |
| 84 | |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 85 | } // namespace art |
| 86 | |
| 87 | #endif // ART_RUNTIME_RUNTIME_INL_H_ |