runtime-inl.h revision c0542af3e2170143ba40d89136e284997e16bf64
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 if (obj == nullptr) { 33 LOG(ERROR) << "Failed to return cleared JNI weak global sentinel"; 34 } 35 return obj; 36} 37 38inline QuickMethodFrameInfo Runtime::GetRuntimeMethodFrameInfo(mirror::ArtMethod* method) { 39 DCHECK(method != nullptr); 40 // Cannot be imt-conflict-method or resolution-method. 41 DCHECK(method != GetImtConflictMethod()); 42 DCHECK(method != GetResolutionMethod()); 43 // Don't use GetCalleeSaveMethod(), some tests don't set all callee save methods. 44 if (method == GetCalleeSaveMethodUnchecked(Runtime::kRefsAndArgs)) { 45 return GetCalleeSaveMethodFrameInfo(Runtime::kRefsAndArgs); 46 } else if (method == GetCalleeSaveMethodUnchecked(Runtime::kSaveAll)) { 47 return GetCalleeSaveMethodFrameInfo(Runtime::kSaveAll); 48 } else { 49 DCHECK(method == GetCalleeSaveMethodUnchecked(Runtime::kRefsOnly)); 50 return GetCalleeSaveMethodFrameInfo(Runtime::kRefsOnly); 51 } 52} 53 54inline mirror::ArtMethod* Runtime::GetResolutionMethod() { 55 CHECK(HasResolutionMethod()); 56 return resolution_method_.Read(); 57} 58 59inline mirror::ArtMethod* Runtime::GetImtConflictMethod() { 60 CHECK(HasImtConflictMethod()); 61 return imt_conflict_method_.Read(); 62} 63 64inline mirror::ObjectArray<mirror::ArtMethod>* Runtime::GetDefaultImt() 65 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { 66 CHECK(HasDefaultImt()); 67 return default_imt_.Read(); 68} 69 70inline mirror::ArtMethod* Runtime::GetCalleeSaveMethod(CalleeSaveType type) 71 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { 72 DCHECK(HasCalleeSaveMethod(type)); 73 return callee_save_methods_[type].Read(); 74} 75 76inline mirror::ArtMethod* Runtime::GetCalleeSaveMethodUnchecked(CalleeSaveType type) 77 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { 78 return callee_save_methods_[type].Read(); 79} 80 81} // namespace art 82 83#endif // ART_RUNTIME_RUNTIME_INL_H_ 84