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