• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 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_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_
18 #define ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_
19 
20 #include <jni.h>
21 
22 #include "base/locks.h"
23 #include "base/macros.h"
24 #include "deoptimization_kind.h"
25 #include "offsets.h"
26 
27 #define QUICK_ENTRYPOINT_OFFSET(ptr_size, x) \
28     Thread::QuickEntryPointOffset<ptr_size>(OFFSETOF_MEMBER(QuickEntryPoints, x))
29 
30 namespace art {
31 
32 namespace mirror {
33 class Array;
34 class Class;
35 template<class MirrorType> class CompressedReference;
36 class Object;
37 }  // namespace mirror
38 
39 class ArtMethod;
40 template<class MirrorType> class GcRoot;
41 template<class MirrorType> class StackReference;
42 class Thread;
43 
44 // Pointers to functions that are called by quick compiler generated code via thread-local storage.
45 struct PACKED(4) QuickEntryPoints {
46 #define ENTRYPOINT_ENUM(name, rettype, ...) rettype ( * p ## name )( __VA_ARGS__ );
47 #include "quick_entrypoints_list.h"
48   QUICK_ENTRYPOINT_LIST(ENTRYPOINT_ENUM)
49 #undef QUICK_ENTRYPOINT_LIST
50 #undef ENTRYPOINT_ENUM
51 };
52 
53 
54 // JNI entrypoints.
55 // TODO: NO_THREAD_SAFETY_ANALYSIS due to different control paths depending on fast JNI.
56 extern uint32_t JniMethodStart(Thread* self) NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
57 extern uint32_t JniMethodFastStart(Thread* self) NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
58 extern uint32_t JniMethodStartSynchronized(jobject to_lock, Thread* self)
59     NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
60 extern void JniMethodEnd(uint32_t saved_local_ref_cookie, Thread* self)
61     NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
62 extern void JniMethodFastEnd(uint32_t saved_local_ref_cookie, Thread* self)
63     NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
64 extern void JniMethodEndSynchronized(uint32_t saved_local_ref_cookie, jobject locked,
65                                      Thread* self)
66     NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
67 extern mirror::Object* JniMethodEndWithReference(jobject result, uint32_t saved_local_ref_cookie,
68                                                  Thread* self)
69     NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
70 extern mirror::Object* JniMethodFastEndWithReference(jobject result,
71                                                      uint32_t saved_local_ref_cookie,
72                                                      Thread* self)
73     NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
74 
75 
76 extern mirror::Object* JniMethodEndWithReferenceSynchronized(jobject result,
77                                                              uint32_t saved_local_ref_cookie,
78                                                              jobject locked, Thread* self)
79     NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
80 
81 extern void ReadBarrierJni(mirror::CompressedReference<mirror::Object>* handle_on_stack,
82                            Thread* self)
83     NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
84 
85 
86 // Read barrier entrypoints.
87 //
88 // Compilers for ARM, ARM64, MIPS, MIPS64 can insert a call to these
89 // functions directly.  For x86 and x86-64, compilers need a wrapper
90 // assembly function, to handle mismatch in ABI.
91 
92 // Mark the heap reference `obj`. This entry point is used by read
93 // barrier fast path implementations generated by the compiler to mark
94 // an object that is referenced by a field of a gray object.
95 extern "C" mirror::Object* artReadBarrierMark(mirror::Object* obj)
96     REQUIRES_SHARED(Locks::mutator_lock_) HOT_ATTR;
97 
98 // Read barrier entrypoint for heap references.
99 // This is the read barrier slow path for instance and static fields
100 // and reference type arrays.
101 extern "C" mirror::Object* artReadBarrierSlow(mirror::Object* ref,
102                                               mirror::Object* obj,
103                                               uint32_t offset)
104     REQUIRES_SHARED(Locks::mutator_lock_) HOT_ATTR;
105 
106 // Read barrier entrypoint for GC roots.
107 extern "C" mirror::Object* artReadBarrierForRootSlow(GcRoot<mirror::Object>* root)
108     REQUIRES_SHARED(Locks::mutator_lock_) HOT_ATTR;
109 
110 }  // namespace art
111 
112 #endif  // ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_
113