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