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 "class_linker.h"
     24 #include "read_barrier-inl.h"
     25 
     26 namespace art {
     27 
     28 inline bool Runtime::IsClearedJniWeakGlobal(mirror::Object* obj) {
     29   return obj == GetClearedJniWeakGlobal();
     30 }
     31 
     32 inline mirror::Object* Runtime::GetClearedJniWeakGlobal() {
     33   mirror::Object* obj = sentinel_.Read();
     34   DCHECK(obj != nullptr);
     35   return obj;
     36 }
     37 
     38 inline QuickMethodFrameInfo Runtime::GetRuntimeMethodFrameInfo(ArtMethod* method) {
     39   DCHECK(method != nullptr);
     40   // Cannot be imt-conflict-method or resolution-method.
     41   DCHECK_NE(method, GetImtConflictMethod());
     42   DCHECK_NE(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_EQ(method, GetCalleeSaveMethodUnchecked(Runtime::kRefsOnly));
     50     return GetCalleeSaveMethodFrameInfo(Runtime::kRefsOnly);
     51   }
     52 }
     53 
     54 inline ArtMethod* Runtime::GetResolutionMethod() {
     55   CHECK(HasResolutionMethod());
     56   return resolution_method_;
     57 }
     58 
     59 inline ArtMethod* Runtime::GetImtConflictMethod() {
     60   CHECK(HasImtConflictMethod());
     61   return imt_conflict_method_;
     62 }
     63 
     64 inline ArtMethod* Runtime::GetImtUnimplementedMethod() {
     65   CHECK(imt_unimplemented_method_ != nullptr);
     66   return imt_unimplemented_method_;
     67 }
     68 
     69 inline ArtMethod* Runtime::GetCalleeSaveMethod(CalleeSaveType type)
     70     SHARED_REQUIRES(Locks::mutator_lock_) {
     71   DCHECK(HasCalleeSaveMethod(type));
     72   return GetCalleeSaveMethodUnchecked(type);
     73 }
     74 
     75 inline ArtMethod* Runtime::GetCalleeSaveMethodUnchecked(CalleeSaveType type)
     76     SHARED_REQUIRES(Locks::mutator_lock_) {
     77   return reinterpret_cast<ArtMethod*>(callee_save_methods_[type]);
     78 }
     79 
     80 }  // namespace art
     81 
     82 #endif  // ART_RUNTIME_RUNTIME_INL_H_
     83