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 22 #include "art_method.h" 23 #include "class_linker.h" 24 #include "gc_root-inl.h" 25 #include "obj_ptr-inl.h" 26 #include "read_barrier-inl.h" 27 28 namespace art { 29 30 inline bool Runtime::IsClearedJniWeakGlobal(ObjPtr<mirror::Object> obj) { 31 return obj == GetClearedJniWeakGlobal(); 32 } 33 34 inline mirror::Object* Runtime::GetClearedJniWeakGlobal() { 35 mirror::Object* obj = sentinel_.Read(); 36 DCHECK(obj != nullptr); 37 return obj; 38 } 39 40 inline QuickMethodFrameInfo Runtime::GetRuntimeMethodFrameInfo(ArtMethod* method) { 41 DCHECK(method != nullptr); 42 // Cannot be imt-conflict-method or resolution-method. 43 DCHECK_NE(method, GetImtConflictMethod()); 44 DCHECK_NE(method, GetResolutionMethod()); 45 // Don't use GetCalleeSaveMethod(), some tests don't set all callee save methods. 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); 52 } else { 53 DCHECK_EQ(method, GetCalleeSaveMethodUnchecked(Runtime::kSaveEverything)); 54 return GetCalleeSaveMethodFrameInfo(Runtime::kSaveEverything); 55 } 56 } 57 58 inline ArtMethod* Runtime::GetResolutionMethod() { 59 CHECK(HasResolutionMethod()); 60 return resolution_method_; 61 } 62 63 inline ArtMethod* Runtime::GetImtConflictMethod() { 64 CHECK(HasImtConflictMethod()); 65 return imt_conflict_method_; 66 } 67 68 inline ArtMethod* Runtime::GetImtUnimplementedMethod() { 69 CHECK(imt_unimplemented_method_ != nullptr); 70 return imt_unimplemented_method_; 71 } 72 73 inline ArtMethod* Runtime::GetCalleeSaveMethod(CalleeSaveType type) 74 REQUIRES_SHARED(Locks::mutator_lock_) { 75 DCHECK(HasCalleeSaveMethod(type)); 76 return GetCalleeSaveMethodUnchecked(type); 77 } 78 79 inline ArtMethod* Runtime::GetCalleeSaveMethodUnchecked(CalleeSaveType type) 80 REQUIRES_SHARED(Locks::mutator_lock_) { 81 return reinterpret_cast<ArtMethod*>(callee_save_methods_[type]); 82 } 83 84 } // namespace art 85 86 #endif // ART_RUNTIME_RUNTIME_INL_H_ 87