Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 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 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_MIRROR_IFTABLE_INL_H_ |
| 18 | #define ART_RUNTIME_MIRROR_IFTABLE_INL_H_ |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 19 | |
| 20 | #include "iftable.h" |
Mathieu Chartier | 31e8822 | 2016-10-14 18:43:19 -0700 | [diff] [blame] | 21 | #include "obj_ptr-inl.h" |
Vladimir Marko | 557fece | 2019-03-26 14:29:41 +0000 | [diff] [blame] | 22 | #include "object_array-inl.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 23 | |
| 24 | namespace art { |
| 25 | namespace mirror { |
| 26 | |
Vladimir Marko | 557fece | 2019-03-26 14:29:41 +0000 | [diff] [blame] | 27 | template<VerifyObjectFlags kVerifyFlags, |
| 28 | ReadBarrierOption kReadBarrierOption> |
| 29 | inline ObjPtr<Class> IfTable::GetInterface(int32_t i) { |
Vladimir Marko | 0984e48 | 2019-03-27 16:41:41 +0000 | [diff] [blame] | 30 | ObjPtr<Class> interface = |
Vladimir Marko | 557fece | 2019-03-26 14:29:41 +0000 | [diff] [blame] | 31 | GetWithoutChecks<kVerifyFlags, kReadBarrierOption>((i * kMax) + kInterface)->AsClass(); |
| 32 | DCHECK(interface != nullptr); |
| 33 | return interface; |
| 34 | } |
| 35 | |
Mathieu Chartier | 31e8822 | 2016-10-14 18:43:19 -0700 | [diff] [blame] | 36 | inline void IfTable::SetInterface(int32_t i, ObjPtr<Class> interface) { |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 37 | DCHECK(interface != nullptr); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 38 | DCHECK(interface->IsInterface()); |
Mathieu Chartier | 52e4b43 | 2014-06-10 11:22:31 -0700 | [diff] [blame] | 39 | const size_t idx = i * kMax + kInterface; |
Vladimir Marko | 0984e48 | 2019-03-27 16:41:41 +0000 | [diff] [blame] | 40 | DCHECK(Get(idx) == nullptr); |
Mathieu Chartier | 2d2621a | 2014-10-23 16:48:06 -0700 | [diff] [blame] | 41 | SetWithoutChecks<false>(idx, interface); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 42 | } |
| 43 | |
Vladimir Marko | 557fece | 2019-03-26 14:29:41 +0000 | [diff] [blame] | 44 | template<VerifyObjectFlags kVerifyFlags, |
| 45 | ReadBarrierOption kReadBarrierOption> |
| 46 | inline ObjPtr<PointerArray> IfTable::GetMethodArrayOrNull(int32_t i) { |
Vladimir Marko | 423bebb | 2019-03-26 15:17:21 +0000 | [diff] [blame] | 47 | return ObjPtr<PointerArray>::DownCast( |
Vladimir Marko | 557fece | 2019-03-26 14:29:41 +0000 | [diff] [blame] | 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 | |
Mathieu Chartier | 31e8822 | 2016-10-14 18:43:19 -0700 | [diff] [blame] | 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 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 73 | } // namespace mirror |
| 74 | } // namespace art |
| 75 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 76 | #endif // ART_RUNTIME_MIRROR_IFTABLE_INL_H_ |