quick_entrypoints.h revision 4d0589c90971e19c25894414ae7da579269e1fe2
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/macros.h"
23#include "offsets.h"
24
25#define QUICK_ENTRYPOINT_OFFSET(ptr_size, x) \
26    Thread::QuickEntryPointOffset<ptr_size>(OFFSETOF_MEMBER(QuickEntryPoints, x))
27
28namespace art {
29
30namespace mirror {
31class ArtMethod;
32class Class;
33class Object;
34}  // namespace mirror
35
36class Thread;
37
38// Pointers to functions that are called by quick compiler generated code via thread-local storage.
39struct PACKED(4) QuickEntryPoints {
40  // Alloc
41  void* (*pAllocArray)(uint32_t, void*, int32_t);
42  void* (*pAllocArrayResolved)(void*, void*, int32_t);
43  void* (*pAllocArrayWithAccessCheck)(uint32_t, void*, int32_t);
44  void* (*pAllocObject)(uint32_t, void*);
45  void* (*pAllocObjectResolved)(void*, void*);
46  void* (*pAllocObjectInitialized)(void*, void*);
47  void* (*pAllocObjectWithAccessCheck)(uint32_t, void*);
48  void* (*pCheckAndAllocArray)(uint32_t, void*, int32_t);
49  void* (*pCheckAndAllocArrayWithAccessCheck)(uint32_t, void*, int32_t);
50
51  // Cast
52  uint32_t (*pInstanceofNonTrivial)(const mirror::Class*, const mirror::Class*);
53  void (*pCheckCast)(void*, void*);
54
55  // DexCache
56  void* (*pInitializeStaticStorage)(uint32_t, void*);
57  void* (*pInitializeTypeAndVerifyAccess)(uint32_t, void*);
58  void* (*pInitializeType)(uint32_t, void*);
59  void* (*pResolveString)(void*, uint32_t);
60
61  // Field
62  int (*pSet32Instance)(uint32_t, void*, int32_t);  // field_idx, obj, src
63  int (*pSet32Static)(uint32_t, int32_t);
64  int (*pSet64Instance)(uint32_t, void*, int64_t);
65  int (*pSet64Static)(uint32_t, int64_t);
66  int (*pSetObjInstance)(uint32_t, void*, void*);
67  int (*pSetObjStatic)(uint32_t, void*);
68  int32_t (*pGet32Instance)(uint32_t, void*);
69  int32_t (*pGet32Static)(uint32_t);
70  int64_t (*pGet64Instance)(uint32_t, void*);
71  int64_t (*pGet64Static)(uint32_t);
72  void* (*pGetObjInstance)(uint32_t, void*);
73  void* (*pGetObjStatic)(uint32_t);
74
75  // Array
76  void (*pAputObjectWithNullAndBoundCheck)(void*, uint32_t, void*);  // array, index, src
77  void (*pAputObjectWithBoundCheck)(void*, uint32_t, void*);  // array, index, src
78  void (*pAputObject)(void*, uint32_t, void*);  // array, index, src
79  void (*pHandleFillArrayData)(void*, void*);
80
81  // JNI
82  uint32_t (*pJniMethodStart)(Thread*);
83  uint32_t (*pJniMethodStartSynchronized)(jobject to_lock, Thread* self);
84  void (*pJniMethodEnd)(uint32_t cookie, Thread* self);
85  void (*pJniMethodEndSynchronized)(uint32_t cookie, jobject locked, Thread* self);
86  mirror::Object* (*pJniMethodEndWithReference)(jobject result, uint32_t cookie, Thread* self);
87  mirror::Object* (*pJniMethodEndWithReferenceSynchronized)(jobject result, uint32_t cookie,
88                                                    jobject locked, Thread* self);
89  void (*pQuickGenericJniTrampoline)(mirror::ArtMethod*);
90
91  // Locks
92  void (*pLockObject)(void*);
93  void (*pUnlockObject)(void*);
94
95  // Math
96  int32_t (*pCmpgDouble)(double, double);
97  int32_t (*pCmpgFloat)(float, float);
98  int32_t (*pCmplDouble)(double, double);
99  int32_t (*pCmplFloat)(float, float);
100  double (*pFmod)(double, double);
101  double (*pL2d)(int64_t);
102  float (*pFmodf)(float, float);
103  float (*pL2f)(int64_t);
104  int32_t (*pD2iz)(double);
105  int32_t (*pF2iz)(float);
106  int32_t (*pIdivmod)(int32_t, int32_t);
107  int64_t (*pD2l)(double);
108  int64_t (*pF2l)(float);
109  int64_t (*pLdiv)(int64_t, int64_t);
110  int64_t (*pLmod)(int64_t, int64_t);
111  int64_t (*pLmul)(int64_t, int64_t);
112  uint64_t (*pShlLong)(uint64_t, uint32_t);
113  uint64_t (*pShrLong)(uint64_t, uint32_t);
114  uint64_t (*pUshrLong)(uint64_t, uint32_t);
115
116  // Intrinsics
117  int32_t (*pIndexOf)(void*, uint32_t, uint32_t, uint32_t);
118  int32_t (*pStringCompareTo)(void*, void*);
119  void* (*pMemcpy)(void*, const void*, size_t);
120
121  // Invocation
122  void (*pQuickImtConflictTrampoline)(mirror::ArtMethod*);
123  void (*pQuickResolutionTrampoline)(mirror::ArtMethod*);
124  void (*pQuickToInterpreterBridge)(mirror::ArtMethod*);
125  void (*pInvokeDirectTrampolineWithAccessCheck)(uint32_t, void*);
126  void (*pInvokeInterfaceTrampolineWithAccessCheck)(uint32_t, void*);
127  void (*pInvokeStaticTrampolineWithAccessCheck)(uint32_t, void*);
128  void (*pInvokeSuperTrampolineWithAccessCheck)(uint32_t, void*);
129  void (*pInvokeVirtualTrampolineWithAccessCheck)(uint32_t, void*);
130
131  // Thread
132  void (*pCheckSuspend)(Thread*);  // Stub that is called when the suspend count is non-zero
133  void (*pTestSuspend)();  // Stub that is periodically called to test the suspend count
134
135  // Throws
136  void (*pDeliverException)(void*);
137  void (*pThrowArrayBounds)(int32_t, int32_t);
138  void (*pThrowDivZero)();
139  void (*pThrowNoSuchMethod)(int32_t);
140  void (*pThrowNullPointer)();
141  void (*pThrowStackOverflow)(void*);
142};
143
144
145// JNI entrypoints.
146// TODO: NO_THREAD_SAFETY_ANALYSIS due to different control paths depending on fast JNI.
147extern uint32_t JniMethodStart(Thread* self) NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
148extern uint32_t JniMethodStartSynchronized(jobject to_lock, Thread* self)
149    NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
150extern void JniMethodEnd(uint32_t saved_local_ref_cookie, Thread* self)
151    NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
152extern void JniMethodEndSynchronized(uint32_t saved_local_ref_cookie, jobject locked,
153                                     Thread* self)
154    NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
155extern mirror::Object* JniMethodEndWithReference(jobject result, uint32_t saved_local_ref_cookie,
156                                                 Thread* self)
157    NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
158
159extern mirror::Object* JniMethodEndWithReferenceSynchronized(jobject result,
160                                                             uint32_t saved_local_ref_cookie,
161                                                             jobject locked, Thread* self)
162    NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
163
164}  // namespace art
165
166#endif  // ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_
167