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 HIDDEN {
31 
32 namespace mirror {
33 class Array;
34 class Class;
35 template<class MirrorType> class CompressedReference;
36 class Object;
37 class String;
38 }  // namespace mirror
39 
40 class ArtMethod;
41 template<class MirrorType> class GcRoot;
42 template<class MirrorType> class StackReference;
43 class Thread;
44 
45 // Pointers to functions that are called by quick compiler generated code via thread-local storage.
46 struct QuickEntryPoints {
47 #define ENTRYPOINT_ENUM(name, rettype, ...) \
48   void* p##name;                            \
49   void Set##name(rettype (*fn)(__VA_ARGS__)) { p##name = reinterpret_cast<void*>(fn); }
50 #include "quick_entrypoints_list.h"
51   QUICK_ENTRYPOINT_LIST(ENTRYPOINT_ENUM)
52 #undef QUICK_ENTRYPOINT_LIST
53 #undef ENTRYPOINT_ENUM
54 };
55 
56 
57 // JNI entrypoints.
58 extern "C" void artJniMethodStart(Thread* self) UNLOCK_FUNCTION(Locks::mutator_lock_) HOT_ATTR;
59 extern "C" void artJniMethodEnd(Thread* self) SHARED_LOCK_FUNCTION(Locks::mutator_lock_) HOT_ATTR;
60 extern mirror::Object* JniDecodeReferenceResult(jobject result, Thread* self)
61     REQUIRES_SHARED(Locks::mutator_lock_) HOT_ATTR;
62 extern "C" void artJniReadBarrier(ArtMethod* method)
63     REQUIRES_SHARED(Locks::mutator_lock_) HOT_ATTR;
64 extern "C" void artJniUnlockObject(mirror::Object* locked, Thread* self)
65     REQUIRES_SHARED(Locks::mutator_lock_) HOT_ATTR;
66 
67 // JNI entrypoints when monitoring entry/exit.
68 extern "C" void artJniMonitoredMethodStart(Thread* self) UNLOCK_FUNCTION(Locks::mutator_lock_);
69 extern "C" void artJniMonitoredMethodEnd(Thread* self) SHARED_LOCK_FUNCTION(Locks::mutator_lock_);
70 extern "C" void artJniMethodEntryHook(Thread* self);
71 
72 // StringAppend pattern entrypoint.
73 extern "C" mirror::String* artStringBuilderAppend(uint32_t format,
74                                                   const uint32_t* args,
75                                                   Thread* self)
76     REQUIRES_SHARED(Locks::mutator_lock_) HOT_ATTR;
77 
78 // Read barrier entrypoints.
79 //
80 // Compilers for ARM, ARM64 can insert a call to these
81 // functions directly.  For x86 and x86-64, compilers need a wrapper
82 // assembly function, to handle mismatch in ABI.
83 
84 // Mark the heap reference `obj`. This entry point is used by read
85 // barrier fast path implementations generated by the compiler to mark
86 // an object that is referenced by a field of a gray object.
87 extern "C" mirror::Object* artReadBarrierMark(mirror::Object* obj)
88     REQUIRES_SHARED(Locks::mutator_lock_) HOT_ATTR;
89 
90 // Read barrier entrypoint for heap references.
91 // This is the read barrier slow path for instance and static fields
92 // and reference type arrays.
93 extern "C" mirror::Object* artReadBarrierSlow(mirror::Object* ref,
94                                               mirror::Object* obj,
95                                               uint32_t offset)
96     REQUIRES_SHARED(Locks::mutator_lock_) HOT_ATTR;
97 
98 // Read barrier entrypoint for GC roots.
99 extern "C" mirror::Object* artReadBarrierForRootSlow(GcRoot<mirror::Object>* root)
100     REQUIRES_SHARED(Locks::mutator_lock_) HOT_ATTR;
101 
102 }  // namespace art
103 
104 #endif  // ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_
105