blob: 23dd787c800840b5b471f2895acf884d98dd5fcd [file] [log] [blame]
Neil Fuller16b21cd2016-08-12 09:37:02 +01001/*
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"
Neil Fuller16b21cd2016-08-12 09:37:02 +010021#include "object.h"
Neil Fuller16b21cd2016-08-12 09:37:02 +010022#include "read_barrier_option.h"
23
24namespace art {
25
26struct ExecutableOffsets;
27class ArtMethod;
28
29namespace mirror {
30
31// C++ mirror of java.lang.reflect.Executable.
32class MANAGED Executable : public AccessibleObject {
Neil Fuller0e844392016-09-08 13:43:31 +010033 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
39 ArtMethod* GetArtMethod() REQUIRES_SHARED(Locks::mutator_lock_);
40 // Only used by the image writer.
41 template <bool kTransactionActive = false>
42 void SetArtMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_);
43 mirror::Class* GetDeclaringClass() REQUIRES_SHARED(Locks::mutator_lock_);
44
Neil Fuller16b21cd2016-08-12 09:37:02 +010045 private:
Neil Fuller60458a02016-09-01 15:32:44 +010046 uint16_t has_real_parameter_data_;
Neil Fuller0e844392016-09-08 13:43:31 +010047 HeapReference<mirror::Class> declaring_class_;
48 HeapReference<mirror::Class> declaring_class_of_overridden_method_;
Neil Fuller60458a02016-09-01 15:32:44 +010049 HeapReference<mirror::Array> parameters_;
Neil Fuller0e844392016-09-08 13:43:31 +010050 uint64_t art_method_;
51 uint32_t access_flags_;
52 uint32_t dex_method_index_;
53
54 static MemberOffset ArtMethodOffset() {
55 return MemberOffset(OFFSETOF_MEMBER(Executable, art_method_));
56 }
57 static MemberOffset DeclaringClassOffset() {
58 return MemberOffset(OFFSETOF_MEMBER(Executable, declaring_class_));
59 }
60 static MemberOffset DeclaringClassOfOverriddenMethodOffset() {
61 return MemberOffset(OFFSETOF_MEMBER(Executable, declaring_class_of_overridden_method_));
62 }
63 static MemberOffset AccessFlagsOffset() {
64 return MemberOffset(OFFSETOF_MEMBER(Executable, access_flags_));
65 }
66 static MemberOffset DexMethodIndexOffset() {
67 return MemberOffset(OFFSETOF_MEMBER(Executable, dex_method_index_));
68 }
Neil Fuller60458a02016-09-01 15:32:44 +010069
Neil Fuller16b21cd2016-08-12 09:37:02 +010070 friend struct art::ExecutableOffsets; // for verifying offset information
71 DISALLOW_IMPLICIT_CONSTRUCTORS(Executable);
72};
73
74} // namespace mirror
75} // namespace art
76
77#endif // ART_RUNTIME_MIRROR_EXECUTABLE_H_