runtime-inl.h revision 8a74117cac720239a69e60e734c7044b433fad47
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 "read_barrier-inl.h" 23 24namespace art { 25 26inline bool Runtime::IsClearedJniWeakGlobal(mirror::Object* obj) { 27 return obj == GetClearedJniWeakGlobal(); 28} 29 30inline mirror::Object* Runtime::GetClearedJniWeakGlobal() { 31 mirror::Object* obj = sentinel_.Read(); 32 DCHECK(obj != nullptr); 33 return obj; 34} 35 36inline QuickMethodFrameInfo Runtime::GetRuntimeMethodFrameInfo(mirror::ArtMethod* method) { 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. 42 if (method == GetCalleeSaveMethodUnchecked(Runtime::kRefsAndArgs)) { 43 return GetCalleeSaveMethodFrameInfo(Runtime::kRefsAndArgs); 44 } else if (method == GetCalleeSaveMethodUnchecked(Runtime::kSaveAll)) { 45 return GetCalleeSaveMethodFrameInfo(Runtime::kSaveAll); 46 } else { 47 DCHECK(method == GetCalleeSaveMethodUnchecked(Runtime::kRefsOnly)); 48 return GetCalleeSaveMethodFrameInfo(Runtime::kRefsOnly); 49 } 50} 51 52inline mirror::ArtMethod* Runtime::GetResolutionMethod() { 53 CHECK(HasResolutionMethod()); 54 return resolution_method_.Read(); 55} 56 57inline mirror::ArtMethod* Runtime::GetImtConflictMethod() { 58 CHECK(HasImtConflictMethod()); 59 return imt_conflict_method_.Read(); 60} 61 62inline mirror::ObjectArray<mirror::ArtMethod>* Runtime::GetDefaultImt() 63 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { 64 CHECK(HasDefaultImt()); 65 return default_imt_.Read(); 66} 67 68inline mirror::ArtMethod* Runtime::GetCalleeSaveMethod(CalleeSaveType type) 69 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { 70 DCHECK(HasCalleeSaveMethod(type)); 71 return callee_save_methods_[type].Read(); 72} 73 74inline mirror::ArtMethod* Runtime::GetCalleeSaveMethodUnchecked(CalleeSaveType type) 75 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { 76 return callee_save_methods_[type].Read(); 77} 78 79} // namespace art 80 81#endif // ART_RUNTIME_RUNTIME_INL_H_ 82