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