Home | History | Annotate | Download | only in mirror
      1 /*
      2  * Copyright (C) 2011 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_MIRROR_IFTABLE_INL_H_
     18 #define ART_RUNTIME_MIRROR_IFTABLE_INL_H_
     19 
     20 #include "iftable.h"
     21 #include "obj_ptr-inl.h"
     22 #include "object_array-inl.h"
     23 
     24 namespace art {
     25 namespace mirror {
     26 
     27 template<VerifyObjectFlags kVerifyFlags,
     28          ReadBarrierOption kReadBarrierOption>
     29 inline ObjPtr<Class> IfTable::GetInterface(int32_t i) {
     30   ObjPtr<Class> interface =
     31       GetWithoutChecks<kVerifyFlags, kReadBarrierOption>((i * kMax) + kInterface)->AsClass();
     32   DCHECK(interface != nullptr);
     33   return interface;
     34 }
     35 
     36 inline void IfTable::SetInterface(int32_t i, ObjPtr<Class> interface) {
     37   DCHECK(interface != nullptr);
     38   DCHECK(interface->IsInterface());
     39   const size_t idx = i * kMax + kInterface;
     40   DCHECK(Get(idx) == nullptr);
     41   SetWithoutChecks<false>(idx, interface);
     42 }
     43 
     44 template<VerifyObjectFlags kVerifyFlags,
     45          ReadBarrierOption kReadBarrierOption>
     46 inline ObjPtr<PointerArray> IfTable::GetMethodArrayOrNull(int32_t i) {
     47   return ObjPtr<PointerArray>::DownCast(
     48       Get<kVerifyFlags, kReadBarrierOption>((i * kMax) + kMethodArray));
     49 }
     50 
     51 template<VerifyObjectFlags kVerifyFlags,
     52          ReadBarrierOption kReadBarrierOption>
     53 inline ObjPtr<PointerArray> IfTable::GetMethodArray(int32_t i) {
     54   ObjPtr<PointerArray> method_array = GetMethodArrayOrNull<kVerifyFlags, kReadBarrierOption>(i);
     55   DCHECK(method_array != nullptr);
     56   return method_array;
     57 }
     58 
     59 template<VerifyObjectFlags kVerifyFlags,
     60          ReadBarrierOption kReadBarrierOption>
     61 inline size_t IfTable::GetMethodArrayCount(int32_t i) {
     62   ObjPtr<PointerArray> method_array = GetMethodArrayOrNull<kVerifyFlags, kReadBarrierOption>(i);
     63   return method_array == nullptr ? 0u : method_array->GetLength<kVerifyFlags>();
     64 }
     65 
     66 inline void IfTable::SetMethodArray(int32_t i, ObjPtr<PointerArray> arr) {
     67   DCHECK(arr != nullptr);
     68   auto idx = i * kMax + kMethodArray;
     69   DCHECK(Get(idx) == nullptr);
     70   Set<false>(idx, arr);
     71 }
     72 
     73 }  // namespace mirror
     74 }  // namespace art
     75 
     76 #endif  // ART_RUNTIME_MIRROR_IFTABLE_INL_H_
     77