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