quick_entrypoints.h revision be1ca55db3362f5b100c4c65da5342fd299520bb
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(x) \
26    ThreadOffset(static_cast<uintptr_t>(OFFSETOF_MEMBER(Thread, quick_entrypoints_)) + \
27                 static_cast<uintptr_t>(OFFSETOF_MEMBER(QuickEntryPoints, x)))
28
29namespace art {
30
31namespace mirror {
32class ArtMethod;
33class Class;
34class Object;
35}  // namespace mirror
36
37class Thread;
38
39// Pointers to functions that are called by quick compiler generated code via thread-local storage.
40struct PACKED(4) QuickEntryPoints {
41  // Alloc
42  void* (*pAllocArray)(uint32_t, 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
90  // Locks
91  void (*pLockObject)(void*);
92  void (*pUnlockObject)(void*);
93
94  // Math
95  int32_t (*pCmpgDouble)(double, double);
96  int32_t (*pCmpgFloat)(float, float);
97  int32_t (*pCmplDouble)(double, double);
98  int32_t (*pCmplFloat)(float, float);
99  double (*pFmod)(double, double);
100  double (*pSqrt)(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 (*pMemcmp16)(void*, void*, int32_t);
119  int32_t (*pStringCompareTo)(void*, void*);
120  void* (*pMemcpy)(void*, const void*, size_t);
121
122  // Invocation
123  void (*pQuickImtConflictTrampoline)(mirror::ArtMethod*);
124  void (*pQuickResolutionTrampoline)(mirror::ArtMethod*);
125  void (*pQuickToInterpreterBridge)(mirror::ArtMethod*);
126  void (*pInvokeDirectTrampolineWithAccessCheck)(uint32_t, void*);
127  void (*pInvokeInterfaceTrampolineWithAccessCheck)(uint32_t, void*);
128  void (*pInvokeStaticTrampolineWithAccessCheck)(uint32_t, void*);
129  void (*pInvokeSuperTrampolineWithAccessCheck)(uint32_t, void*);
130  void (*pInvokeVirtualTrampolineWithAccessCheck)(uint32_t, void*);
131
132  // Thread
133  void (*pCheckSuspend)(Thread*);  // Stub that is called when the suspend count is non-zero
134  void (*pTestSuspend)();  // Stub that is periodically called to test the suspend count
135
136  // Throws
137  void (*pDeliverException)(void*);
138  void (*pThrowArrayBounds)(int32_t, int32_t);
139  void (*pThrowDivZero)();
140  void (*pThrowNoSuchMethod)(int32_t);
141  void (*pThrowNullPointer)();
142  void (*pThrowStackOverflow)(void*);
143};
144
145
146// JNI entrypoints.
147// TODO: NO_THREAD_SAFETY_ANALYSIS due to different control paths depending on fast JNI.
148extern uint32_t JniMethodStart(Thread* self) NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
149extern uint32_t JniMethodStartSynchronized(jobject to_lock, Thread* self)
150    NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
151extern void JniMethodEnd(uint32_t saved_local_ref_cookie, Thread* self)
152    NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
153extern void JniMethodEndSynchronized(uint32_t saved_local_ref_cookie, jobject locked,
154                                     Thread* self)
155    NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
156extern mirror::Object* JniMethodEndWithReference(jobject result, uint32_t saved_local_ref_cookie,
157                                                 Thread* self)
158    NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
159
160extern mirror::Object* JniMethodEndWithReferenceSynchronized(jobject result,
161                                                             uint32_t saved_local_ref_cookie,
162                                                             jobject locked, Thread* self)
163    NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
164
165}  // namespace art
166
167#endif  // ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_
168