Alex Light | d625158 | 2016-10-31 11:12:30 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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_CLASS_EXT_H_ |
| 18 | #define ART_RUNTIME_MIRROR_CLASS_EXT_H_ |
| 19 | |
| 20 | #include "class-inl.h" |
| 21 | |
Alex Light | a01de59 | 2016-11-15 10:43:06 -0800 | [diff] [blame] | 22 | #include "array.h" |
| 23 | #include "dex_cache.h" |
Alex Light | d625158 | 2016-10-31 11:12:30 -0700 | [diff] [blame] | 24 | #include "gc_root.h" |
| 25 | #include "object.h" |
Alex Light | a01de59 | 2016-11-15 10:43:06 -0800 | [diff] [blame] | 26 | #include "object_array.h" |
Alex Light | d625158 | 2016-10-31 11:12:30 -0700 | [diff] [blame] | 27 | #include "object_callbacks.h" |
| 28 | #include "string.h" |
| 29 | |
| 30 | namespace art { |
| 31 | |
| 32 | struct ClassExtOffsets; |
| 33 | |
| 34 | namespace mirror { |
| 35 | |
| 36 | // C++ mirror of dalvik.system.ClassExt |
| 37 | class MANAGED ClassExt : public Object { |
| 38 | public: |
| 39 | static uint32_t ClassSize(PointerSize pointer_size) { |
| 40 | uint32_t vtable_entries = Object::kVTableLength; |
| 41 | return Class::ComputeClassSize(true, vtable_entries, 0, 0, 0, 0, 0, pointer_size); |
| 42 | } |
| 43 | |
| 44 | // Size of an instance of dalvik.system.ClassExt. |
| 45 | static constexpr uint32_t InstanceSize() { |
| 46 | return sizeof(ClassExt); |
| 47 | } |
| 48 | |
| 49 | void SetVerifyError(ObjPtr<Object> obj) REQUIRES_SHARED(Locks::mutator_lock_); |
| 50 | |
| 51 | Object* GetVerifyError() REQUIRES_SHARED(Locks::mutator_lock_) { |
| 52 | return GetFieldObject<ClassExt>(OFFSET_OF_OBJECT_MEMBER(ClassExt, verify_error_)); |
| 53 | } |
| 54 | |
Alex Light | a01de59 | 2016-11-15 10:43:06 -0800 | [diff] [blame] | 55 | ObjectArray<DexCache>* GetObsoleteDexCaches() REQUIRES_SHARED(Locks::mutator_lock_) { |
| 56 | return GetFieldObject<ObjectArray<DexCache>>( |
| 57 | OFFSET_OF_OBJECT_MEMBER(ClassExt, obsolete_dex_caches_)); |
| 58 | } |
| 59 | |
| 60 | PointerArray* GetObsoleteMethods() REQUIRES_SHARED(Locks::mutator_lock_) { |
| 61 | return GetFieldObject<PointerArray>(OFFSET_OF_OBJECT_MEMBER(ClassExt, obsolete_methods_)); |
| 62 | } |
| 63 | |
Alex Light | a7e38d8 | 2017-01-19 14:57:28 -0800 | [diff] [blame^] | 64 | ByteArray* GetOriginalDexFileBytes() REQUIRES_SHARED(Locks::mutator_lock_) { |
| 65 | return GetFieldObject<ByteArray>(OFFSET_OF_OBJECT_MEMBER(ClassExt, original_dex_file_bytes_)); |
| 66 | } |
| 67 | |
| 68 | void SetOriginalDexFileBytes(ObjPtr<ByteArray> bytes) REQUIRES_SHARED(Locks::mutator_lock_); |
| 69 | |
Alex Light | a01de59 | 2016-11-15 10:43:06 -0800 | [diff] [blame] | 70 | void SetObsoleteArrays(ObjPtr<PointerArray> methods, ObjPtr<ObjectArray<DexCache>> dex_caches) |
| 71 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 72 | |
| 73 | // Extend the obsolete arrays by the given amount. |
| 74 | bool ExtendObsoleteArrays(Thread* self, uint32_t increase) |
| 75 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 76 | |
Alex Light | d625158 | 2016-10-31 11:12:30 -0700 | [diff] [blame] | 77 | static void SetClass(ObjPtr<Class> dalvik_system_ClassExt); |
| 78 | static void ResetClass(); |
| 79 | static void VisitRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_); |
| 80 | |
| 81 | static ClassExt* Alloc(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_); |
| 82 | |
| 83 | private: |
| 84 | // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". |
Alex Light | a01de59 | 2016-11-15 10:43:06 -0800 | [diff] [blame] | 85 | HeapReference<ObjectArray<DexCache>> obsolete_dex_caches_; |
| 86 | |
| 87 | HeapReference<PointerArray> obsolete_methods_; |
| 88 | |
Alex Light | a7e38d8 | 2017-01-19 14:57:28 -0800 | [diff] [blame^] | 89 | HeapReference<ByteArray> original_dex_file_bytes_; |
Alex Light | a01de59 | 2016-11-15 10:43:06 -0800 | [diff] [blame] | 90 | |
| 91 | // The saved verification error of this class. |
Alex Light | d625158 | 2016-10-31 11:12:30 -0700 | [diff] [blame] | 92 | HeapReference<Object> verify_error_; |
| 93 | |
| 94 | static GcRoot<Class> dalvik_system_ClassExt_; |
| 95 | |
| 96 | friend struct art::ClassExtOffsets; // for verifying offset information |
| 97 | DISALLOW_IMPLICIT_CONSTRUCTORS(ClassExt); |
| 98 | }; |
| 99 | |
| 100 | } // namespace mirror |
| 101 | } // namespace art |
| 102 | |
| 103 | #endif // ART_RUNTIME_MIRROR_CLASS_EXT_H_ |