Neil Fuller | 16b21cd | 2016-08-12 09:37:02 +0100 | [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_EXECUTABLE_H_ |
| 18 | #define ART_RUNTIME_MIRROR_EXECUTABLE_H_ |
| 19 | |
| 20 | #include "accessible_object.h" |
Vladimir Marko | 0eefb9b | 2019-03-27 15:04:31 +0000 | [diff] [blame] | 21 | #include "object.h" |
Neil Fuller | 16b21cd | 2016-08-12 09:37:02 +0100 | [diff] [blame] | 22 | #include "read_barrier_option.h" |
| 23 | |
| 24 | namespace art { |
| 25 | |
| 26 | struct ExecutableOffsets; |
| 27 | class ArtMethod; |
| 28 | |
| 29 | namespace mirror { |
| 30 | |
| 31 | // C++ mirror of java.lang.reflect.Executable. |
| 32 | class MANAGED Executable : public AccessibleObject { |
Neil Fuller | 0e84439 | 2016-09-08 13:43:31 +0100 | [diff] [blame] | 33 | public: |
| 34 | // Called from Constructor::CreateFromArtMethod, Method::CreateFromArtMethod. |
| 35 | template <PointerSize kPointerSize, bool kTransactionActive> |
| 36 | bool CreateFromArtMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_) |
| 37 | REQUIRES(!Roles::uninterruptible_); |
| 38 | |
Vladimir Marko | 4df2d80 | 2018-09-27 16:42:44 +0000 | [diff] [blame] | 39 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 40 | ArtMethod* GetArtMethod() REQUIRES_SHARED(Locks::mutator_lock_) { |
| 41 | return reinterpret_cast64<ArtMethod*>(GetField64<kVerifyFlags>(ArtMethodOffset())); |
| 42 | } |
| 43 | |
| 44 | template <bool kTransactionActive = false, |
| 45 | bool kCheckTransaction = true, |
| 46 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Vladimir Marko | 0eefb9b | 2019-03-27 15:04:31 +0000 | [diff] [blame] | 47 | void SetArtMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_); |
Vladimir Marko | 4df2d80 | 2018-09-27 16:42:44 +0000 | [diff] [blame] | 48 | |
Vladimir Marko | 0eefb9b | 2019-03-27 15:04:31 +0000 | [diff] [blame] | 49 | ObjPtr<mirror::Class> GetDeclaringClass() REQUIRES_SHARED(Locks::mutator_lock_); |
Neil Fuller | 0e84439 | 2016-09-08 13:43:31 +0100 | [diff] [blame] | 50 | |
Vladimir Marko | ca8de0a | 2018-07-04 11:56:08 +0100 | [diff] [blame] | 51 | static MemberOffset ArtMethodOffset() { |
| 52 | return MemberOffset(OFFSETOF_MEMBER(Executable, art_method_)); |
| 53 | } |
| 54 | |
Neil Fuller | 16b21cd | 2016-08-12 09:37:02 +0100 | [diff] [blame] | 55 | private: |
Neil Fuller | 60458a0 | 2016-09-01 15:32:44 +0100 | [diff] [blame] | 56 | uint16_t has_real_parameter_data_; |
Neil Fuller | 0e84439 | 2016-09-08 13:43:31 +0100 | [diff] [blame] | 57 | HeapReference<mirror::Class> declaring_class_; |
| 58 | HeapReference<mirror::Class> declaring_class_of_overridden_method_; |
Neil Fuller | 60458a0 | 2016-09-01 15:32:44 +0100 | [diff] [blame] | 59 | HeapReference<mirror::Array> parameters_; |
Neil Fuller | 0e84439 | 2016-09-08 13:43:31 +0100 | [diff] [blame] | 60 | uint64_t art_method_; |
| 61 | uint32_t access_flags_; |
| 62 | uint32_t dex_method_index_; |
| 63 | |
Neil Fuller | 0e84439 | 2016-09-08 13:43:31 +0100 | [diff] [blame] | 64 | static MemberOffset DeclaringClassOffset() { |
| 65 | return MemberOffset(OFFSETOF_MEMBER(Executable, declaring_class_)); |
| 66 | } |
| 67 | static MemberOffset DeclaringClassOfOverriddenMethodOffset() { |
| 68 | return MemberOffset(OFFSETOF_MEMBER(Executable, declaring_class_of_overridden_method_)); |
| 69 | } |
| 70 | static MemberOffset AccessFlagsOffset() { |
| 71 | return MemberOffset(OFFSETOF_MEMBER(Executable, access_flags_)); |
| 72 | } |
| 73 | static MemberOffset DexMethodIndexOffset() { |
| 74 | return MemberOffset(OFFSETOF_MEMBER(Executable, dex_method_index_)); |
| 75 | } |
Neil Fuller | 60458a0 | 2016-09-01 15:32:44 +0100 | [diff] [blame] | 76 | |
Neil Fuller | 16b21cd | 2016-08-12 09:37:02 +0100 | [diff] [blame] | 77 | friend struct art::ExecutableOffsets; // for verifying offset information |
| 78 | DISALLOW_IMPLICIT_CONSTRUCTORS(Executable); |
| 79 | }; |
| 80 | |
| 81 | } // namespace mirror |
| 82 | } // namespace art |
| 83 | |
| 84 | #endif // ART_RUNTIME_MIRROR_EXECUTABLE_H_ |