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 | |
Alex Light | a01de59 | 2016-11-15 10:43:06 -0800 | [diff] [blame] | 20 | #include "array.h" |
Alex Light | 4f2e957 | 2017-03-16 13:13:31 -0700 | [diff] [blame] | 21 | #include "class.h" |
Alex Light | a01de59 | 2016-11-15 10:43:06 -0800 | [diff] [blame] | 22 | #include "dex_cache.h" |
Alex Light | d625158 | 2016-10-31 11:12:30 -0700 | [diff] [blame] | 23 | #include "object.h" |
Alex Light | a01de59 | 2016-11-15 10:43:06 -0800 | [diff] [blame] | 24 | #include "object_array.h" |
Alex Light | d625158 | 2016-10-31 11:12:30 -0700 | [diff] [blame] | 25 | #include "string.h" |
| 26 | |
| 27 | namespace art { |
| 28 | |
| 29 | struct ClassExtOffsets; |
| 30 | |
| 31 | namespace mirror { |
| 32 | |
| 33 | // C++ mirror of dalvik.system.ClassExt |
| 34 | class MANAGED ClassExt : public Object { |
| 35 | public: |
Alex Light | 4f2e957 | 2017-03-16 13:13:31 -0700 | [diff] [blame] | 36 | static uint32_t ClassSize(PointerSize pointer_size); |
Alex Light | d625158 | 2016-10-31 11:12:30 -0700 | [diff] [blame] | 37 | |
| 38 | // Size of an instance of dalvik.system.ClassExt. |
| 39 | static constexpr uint32_t InstanceSize() { |
| 40 | return sizeof(ClassExt); |
| 41 | } |
| 42 | |
| 43 | void SetVerifyError(ObjPtr<Object> obj) REQUIRES_SHARED(Locks::mutator_lock_); |
| 44 | |
Vladimir Marko | bb206de | 2019-03-28 10:30:32 +0000 | [diff] [blame] | 45 | ObjPtr<Object> GetVerifyError() REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | d625158 | 2016-10-31 11:12:30 -0700 | [diff] [blame] | 46 | |
Vladimir Marko | bb206de | 2019-03-28 10:30:32 +0000 | [diff] [blame] | 47 | ObjPtr<ObjectArray<DexCache>> GetObsoleteDexCaches() REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | a01de59 | 2016-11-15 10:43:06 -0800 | [diff] [blame] | 48 | |
Alex Light | 4f2e957 | 2017-03-16 13:13:31 -0700 | [diff] [blame] | 49 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 50 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Vladimir Marko | bb206de | 2019-03-28 10:30:32 +0000 | [diff] [blame] | 51 | ObjPtr<PointerArray> GetObsoleteMethods() REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | a01de59 | 2016-11-15 10:43:06 -0800 | [diff] [blame] | 52 | |
Vladimir Marko | bb206de | 2019-03-28 10:30:32 +0000 | [diff] [blame] | 53 | ObjPtr<Object> GetOriginalDexFile() REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | a7e38d8 | 2017-01-19 14:57:28 -0800 | [diff] [blame] | 54 | |
Alex Light | 2f814aa | 2017-03-24 15:21:34 +0000 | [diff] [blame] | 55 | void SetOriginalDexFile(ObjPtr<Object> bytes) REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | a7e38d8 | 2017-01-19 14:57:28 -0800 | [diff] [blame] | 56 | |
David Brazdil | 1a65863 | 2018-12-01 17:54:26 +0000 | [diff] [blame] | 57 | uint16_t GetPreRedefineClassDefIndex() REQUIRES_SHARED(Locks::mutator_lock_) { |
| 58 | return static_cast<uint16_t>( |
| 59 | GetField32(OFFSET_OF_OBJECT_MEMBER(ClassExt, pre_redefine_class_def_index_))); |
| 60 | } |
| 61 | |
| 62 | void SetPreRedefineClassDefIndex(uint16_t index) REQUIRES_SHARED(Locks::mutator_lock_); |
| 63 | |
| 64 | const DexFile* GetPreRedefineDexFile() REQUIRES_SHARED(Locks::mutator_lock_) { |
| 65 | return reinterpret_cast<const DexFile*>(static_cast<uintptr_t>( |
| 66 | GetField64(OFFSET_OF_OBJECT_MEMBER(ClassExt, pre_redefine_dex_file_ptr_)))); |
| 67 | } |
| 68 | |
| 69 | void SetPreRedefineDexFile(const DexFile* dex_file) REQUIRES_SHARED(Locks::mutator_lock_); |
| 70 | |
Alex Light | a01de59 | 2016-11-15 10:43:06 -0800 | [diff] [blame] | 71 | void SetObsoleteArrays(ObjPtr<PointerArray> methods, ObjPtr<ObjectArray<DexCache>> dex_caches) |
| 72 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 73 | |
| 74 | // Extend the obsolete arrays by the given amount. |
Vladimir Marko | 3068d58 | 2019-05-28 16:39:29 +0100 | [diff] [blame] | 75 | static bool ExtendObsoleteArrays(Handle<ClassExt> h_this, Thread* self, uint32_t increase) |
Alex Light | a01de59 | 2016-11-15 10:43:06 -0800 | [diff] [blame] | 76 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 77 | |
Alex Light | 4f2e957 | 2017-03-16 13:13:31 -0700 | [diff] [blame] | 78 | template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier, class Visitor> |
| 79 | inline void VisitNativeRoots(Visitor& visitor, PointerSize pointer_size) |
| 80 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 81 | |
Vladimir Marko | bb206de | 2019-03-28 10:30:32 +0000 | [diff] [blame] | 82 | static ObjPtr<ClassExt> Alloc(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | d625158 | 2016-10-31 11:12:30 -0700 | [diff] [blame] | 83 | |
| 84 | private: |
| 85 | // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". |
Alex Light | a01de59 | 2016-11-15 10:43:06 -0800 | [diff] [blame] | 86 | HeapReference<ObjectArray<DexCache>> obsolete_dex_caches_; |
| 87 | |
| 88 | HeapReference<PointerArray> obsolete_methods_; |
| 89 | |
Alex Light | 2f814aa | 2017-03-24 15:21:34 +0000 | [diff] [blame] | 90 | HeapReference<Object> original_dex_file_; |
Alex Light | a01de59 | 2016-11-15 10:43:06 -0800 | [diff] [blame] | 91 | |
| 92 | // The saved verification error of this class. |
Alex Light | d625158 | 2016-10-31 11:12:30 -0700 | [diff] [blame] | 93 | HeapReference<Object> verify_error_; |
| 94 | |
David Brazdil | 1a65863 | 2018-12-01 17:54:26 +0000 | [diff] [blame] | 95 | // Native pointer to DexFile and ClassDef index of this class before it was JVMTI-redefined. |
Alex Light | 21d5994 | 2019-06-19 12:58:22 -0700 | [diff] [blame] | 96 | int64_t pre_redefine_dex_file_ptr_; |
Nicolas Geoffray | b476a29 | 2019-06-27 07:54:48 +0000 | [diff] [blame] | 97 | int32_t pre_redefine_class_def_index_; |
David Brazdil | 1a65863 | 2018-12-01 17:54:26 +0000 | [diff] [blame] | 98 | |
Alex Light | d625158 | 2016-10-31 11:12:30 -0700 | [diff] [blame] | 99 | friend struct art::ClassExtOffsets; // for verifying offset information |
| 100 | DISALLOW_IMPLICIT_CONSTRUCTORS(ClassExt); |
| 101 | }; |
| 102 | |
| 103 | } // namespace mirror |
| 104 | } // namespace art |
| 105 | |
| 106 | #endif // ART_RUNTIME_MIRROR_CLASS_EXT_H_ |