Home | History | Annotate | Download | only in runtime
      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 
     29 inline bool Runtime::IsClearedJniWeakGlobal(ObjPtr<mirror::Object> obj) {
     30   return obj == GetClearedJniWeakGlobal();
     31 }
     32 
     33 inline mirror::Object* Runtime::GetClearedJniWeakGlobal() {
     34   mirror::Object* obj = sentinel_.Read();
     35   DCHECK(obj != nullptr);
     36   return obj;
     37 }
     38 
     39 inline 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_EQ(method, GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveEverything));
     53     return GetCalleeSaveMethodFrameInfo(CalleeSaveType::kSaveEverything);
     54   }
     55 }
     56 
     57 inline ArtMethod* Runtime::GetResolutionMethod() {
     58   CHECK(HasResolutionMethod());
     59   return resolution_method_;
     60 }
     61 
     62 inline ArtMethod* Runtime::GetImtConflictMethod() {
     63   CHECK(HasImtConflictMethod());
     64   return imt_conflict_method_;
     65 }
     66 
     67 inline ArtMethod* Runtime::GetImtUnimplementedMethod() {
     68   CHECK(imt_unimplemented_method_ != nullptr);
     69   return imt_unimplemented_method_;
     70 }
     71 
     72 inline ArtMethod* Runtime::GetCalleeSaveMethod(CalleeSaveType type)
     73     REQUIRES_SHARED(Locks::mutator_lock_) {
     74   DCHECK(HasCalleeSaveMethod(type));
     75   return GetCalleeSaveMethodUnchecked(type);
     76 }
     77 
     78 inline ArtMethod* Runtime::GetCalleeSaveMethodUnchecked(CalleeSaveType type)
     79     REQUIRES_SHARED(Locks::mutator_lock_) {
     80   return reinterpret_cast<ArtMethod*>(callee_save_methods_[static_cast<size_t>(type)]);
     81 }
     82 
     83 }  // namespace art
     84 
     85 #endif  // ART_RUNTIME_RUNTIME_INL_H_
     86