blob: 6c465f6bbbb2351569852b62c55a9d449716a1cc [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"
21#include "gc_root.h"
22#include "object.h"
23#include "object_callbacks.h"
24#include "read_barrier_option.h"
25
26namespace art {
27
28struct ExecutableOffsets;
29class ArtMethod;
30
31namespace mirror {
32
33// C++ mirror of java.lang.reflect.Executable.
34class MANAGED Executable : public AccessibleObject {
Neil Fuller0e844392016-09-08 13:43:31 +010035 public:
36 // Called from Constructor::CreateFromArtMethod, Method::CreateFromArtMethod.
37 template <PointerSize kPointerSize, bool kTransactionActive>
38 bool CreateFromArtMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_)
39 REQUIRES(!Roles::uninterruptible_);
40
41 ArtMethod* GetArtMethod() REQUIRES_SHARED(Locks::mutator_lock_);
42 // Only used by the image writer.
43 template <bool kTransactionActive = false>
44 void SetArtMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_);
45 mirror::Class* GetDeclaringClass() REQUIRES_SHARED(Locks::mutator_lock_);
46
Neil Fuller16b21cd2016-08-12 09:37:02 +010047 private:
Neil Fuller60458a02016-09-01 15:32:44 +010048 uint16_t has_real_parameter_data_;
Neil Fuller0e844392016-09-08 13:43:31 +010049 HeapReference<mirror::Class> declaring_class_;
50 HeapReference<mirror::Class> declaring_class_of_overridden_method_;
Neil Fuller60458a02016-09-01 15:32:44 +010051 HeapReference<mirror::Array> parameters_;
Neil Fuller0e844392016-09-08 13:43:31 +010052 uint64_t art_method_;
53 uint32_t access_flags_;
54 uint32_t dex_method_index_;
55
56 static MemberOffset ArtMethodOffset() {
57 return MemberOffset(OFFSETOF_MEMBER(Executable, art_method_));
58 }
59 static MemberOffset DeclaringClassOffset() {
60 return MemberOffset(OFFSETOF_MEMBER(Executable, declaring_class_));
61 }
62 static MemberOffset DeclaringClassOfOverriddenMethodOffset() {
63 return MemberOffset(OFFSETOF_MEMBER(Executable, declaring_class_of_overridden_method_));
64 }
65 static MemberOffset AccessFlagsOffset() {
66 return MemberOffset(OFFSETOF_MEMBER(Executable, access_flags_));
67 }
68 static MemberOffset DexMethodIndexOffset() {
69 return MemberOffset(OFFSETOF_MEMBER(Executable, dex_method_index_));
70 }
Neil Fuller60458a02016-09-01 15:32:44 +010071
Neil Fuller16b21cd2016-08-12 09:37:02 +010072 friend struct art::ExecutableOffsets; // for verifying offset information
73 DISALLOW_IMPLICIT_CONSTRUCTORS(Executable);
74};
75
76} // namespace mirror
77} // namespace art
78
79#endif // ART_RUNTIME_MIRROR_EXECUTABLE_H_