blob: c96082f560ccc578776879533c7ed78d08784394 [file] [log] [blame]
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001/*
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 Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_RUNTIME_MIRROR_IFTABLE_INL_H_
18#define ART_RUNTIME_MIRROR_IFTABLE_INL_H_
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080019
20#include "iftable.h"
Mathieu Chartier31e88222016-10-14 18:43:19 -070021#include "obj_ptr-inl.h"
Vladimir Marko557fece2019-03-26 14:29:41 +000022#include "object_array-inl.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080023
24namespace art {
25namespace mirror {
26
Vladimir Marko557fece2019-03-26 14:29:41 +000027template<VerifyObjectFlags kVerifyFlags,
28 ReadBarrierOption kReadBarrierOption>
29inline ObjPtr<Class> IfTable::GetInterface(int32_t i) {
Vladimir Marko0984e482019-03-27 16:41:41 +000030 ObjPtr<Class> interface =
Vladimir Marko557fece2019-03-26 14:29:41 +000031 GetWithoutChecks<kVerifyFlags, kReadBarrierOption>((i * kMax) + kInterface)->AsClass();
32 DCHECK(interface != nullptr);
33 return interface;
34}
35
Mathieu Chartier31e88222016-10-14 18:43:19 -070036inline void IfTable::SetInterface(int32_t i, ObjPtr<Class> interface) {
Mathieu Chartier2cebb242015-04-21 16:50:40 -070037 DCHECK(interface != nullptr);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080038 DCHECK(interface->IsInterface());
Mathieu Chartier52e4b432014-06-10 11:22:31 -070039 const size_t idx = i * kMax + kInterface;
Vladimir Marko0984e482019-03-27 16:41:41 +000040 DCHECK(Get(idx) == nullptr);
Mathieu Chartier2d2621a2014-10-23 16:48:06 -070041 SetWithoutChecks<false>(idx, interface);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080042}
43
Vladimir Marko557fece2019-03-26 14:29:41 +000044template<VerifyObjectFlags kVerifyFlags,
45 ReadBarrierOption kReadBarrierOption>
46inline ObjPtr<PointerArray> IfTable::GetMethodArrayOrNull(int32_t i) {
Vladimir Marko423bebb2019-03-26 15:17:21 +000047 return ObjPtr<PointerArray>::DownCast(
Vladimir Marko557fece2019-03-26 14:29:41 +000048 Get<kVerifyFlags, kReadBarrierOption>((i * kMax) + kMethodArray));
49}
50
51template<VerifyObjectFlags kVerifyFlags,
52 ReadBarrierOption kReadBarrierOption>
53inline 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
59template<VerifyObjectFlags kVerifyFlags,
60 ReadBarrierOption kReadBarrierOption>
61inline 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 Chartier31e88222016-10-14 18:43:19 -070066inline 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 Rogers2dd0e2c2013-01-24 12:42:14 -080073} // namespace mirror
74} // namespace art
75
Brian Carlstromfc0e3212013-07-17 14:40:12 -070076#endif // ART_RUNTIME_MIRROR_IFTABLE_INL_H_