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_H_ 18 #define ART_RUNTIME_MIRROR_IFTABLE_H_ 19 20 #include "base/casts.h" 21 #include "base/macros.h" 22 #include "object_array.h" 23 24 namespace art HIDDEN { 25 namespace mirror { 26 27 class MANAGED IfTable final : public ObjectArray<Object> { 28 public: 29 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, 30 ReadBarrierOption kReadBarrierOption = kWithReadBarrier> 31 ALWAYS_INLINE ObjPtr<Class> GetInterface(int32_t i) REQUIRES_SHARED(Locks::mutator_lock_); 32 33 ALWAYS_INLINE void SetInterface(int32_t i, ObjPtr<Class> interface) 34 REQUIRES_SHARED(Locks::mutator_lock_); 35 36 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, 37 ReadBarrierOption kReadBarrierOption = kWithReadBarrier> 38 ObjPtr<PointerArray> GetMethodArrayOrNull(int32_t i) REQUIRES_SHARED(Locks::mutator_lock_); 39 40 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, 41 ReadBarrierOption kReadBarrierOption = kWithReadBarrier> 42 ObjPtr<PointerArray> GetMethodArray(int32_t i) REQUIRES_SHARED(Locks::mutator_lock_); 43 44 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, 45 ReadBarrierOption kReadBarrierOption = kWithReadBarrier> 46 size_t GetMethodArrayCount(int32_t i) REQUIRES_SHARED(Locks::mutator_lock_); 47 48 void SetMethodArray(int32_t i, ObjPtr<PointerArray> arr) REQUIRES_SHARED(Locks::mutator_lock_); 49 50 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> Count()51 ALWAYS_INLINE size_t Count() REQUIRES_SHARED(Locks::mutator_lock_) { 52 return GetLength<kVerifyFlags>() / kMax; 53 } 54 55 enum { 56 // Points to the interface class. 57 kInterface = 0, 58 // Method pointers into the vtable, allow fast map from interface method index to concrete 59 // instance method. 60 kMethodArray = 1, 61 kMax = 2, 62 }; 63 64 private: 65 DISALLOW_IMPLICIT_CONSTRUCTORS(IfTable); 66 }; 67 68 } // namespace mirror 69 } // namespace art 70 71 #endif // ART_RUNTIME_MIRROR_IFTABLE_H_ 72