blob: 1ba206629e4fcf0acf00fd9404546b8bb26f9112 [file] [log] [blame]
Ian Rogers57b86d42012-03-27 16:05:41 -07001/*
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
Ian Rogers166db042013-07-26 12:05:57 -070017#ifndef ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_
18#define ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_
Ian Rogers57b86d42012-03-27 16:05:41 -070019
Ian Rogers848871b2013-08-05 10:56:33 -070020#include <jni.h>
21
22#include "base/macros.h"
23#include "offsets.h"
Ian Rogers57b86d42012-03-27 16:05:41 -070024
Ian Rogers7655f292013-07-29 11:07:13 -070025#define QUICK_ENTRYPOINT_OFFSET(x) \
Ian Rogers848871b2013-08-05 10:56:33 -070026 ThreadOffset(static_cast<uintptr_t>(OFFSETOF_MEMBER(Thread, quick_entrypoints_)) + \
27 static_cast<uintptr_t>(OFFSETOF_MEMBER(QuickEntryPoints, x)))
Ian Rogers57b86d42012-03-27 16:05:41 -070028
29namespace art {
Ian Rogers848871b2013-08-05 10:56:33 -070030
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080031namespace mirror {
Brian Carlstromea46f952013-07-30 01:26:50 -070032class ArtMethod;
33class Class;
34class Object;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080035} // namespace mirror
Ian Rogers848871b2013-08-05 10:56:33 -070036
Ian Rogers57b86d42012-03-27 16:05:41 -070037class Thread;
38
Ian Rogers166db042013-07-26 12:05:57 -070039// Pointers to functions that are called by quick compiler generated code via thread-local storage.
40struct PACKED(4) QuickEntryPoints {
Ian Rogers57b86d42012-03-27 16:05:41 -070041 // Alloc
Ian Rogers848871b2013-08-05 10:56:33 -070042 void* (*pAllocArray)(uint32_t, void*, int32_t);
43 void* (*pAllocArrayWithAccessCheck)(uint32_t, void*, int32_t);
44 void* (*pAllocObject)(uint32_t, void*);
45 void* (*pAllocObjectWithAccessCheck)(uint32_t, void*);
46 void* (*pCheckAndAllocArray)(uint32_t, void*, int32_t);
47 void* (*pCheckAndAllocArrayWithAccessCheck)(uint32_t, void*, int32_t);
Ian Rogers57b86d42012-03-27 16:05:41 -070048
49 // Cast
Ian Rogers848871b2013-08-05 10:56:33 -070050 uint32_t (*pInstanceofNonTrivial)(const mirror::Class*, const mirror::Class*);
Ian Rogers848871b2013-08-05 10:56:33 -070051 void (*pCheckCast)(void*, void*);
Ian Rogers57b86d42012-03-27 16:05:41 -070052
Ian Rogers57b86d42012-03-27 16:05:41 -070053 // DexCache
54 void* (*pInitializeStaticStorage)(uint32_t, void*);
Ian Rogers848871b2013-08-05 10:56:33 -070055 void* (*pInitializeTypeAndVerifyAccess)(uint32_t, void*);
56 void* (*pInitializeType)(uint32_t, void*);
57 void* (*pResolveString)(void*, uint32_t);
Ian Rogers57b86d42012-03-27 16:05:41 -070058
59 // Field
60 int (*pSet32Instance)(uint32_t, void*, int32_t); // field_idx, obj, src
61 int (*pSet32Static)(uint32_t, int32_t);
62 int (*pSet64Instance)(uint32_t, void*, int64_t);
63 int (*pSet64Static)(uint32_t, int64_t);
64 int (*pSetObjInstance)(uint32_t, void*, void*);
65 int (*pSetObjStatic)(uint32_t, void*);
66 int32_t (*pGet32Instance)(uint32_t, void*);
67 int32_t (*pGet32Static)(uint32_t);
68 int64_t (*pGet64Instance)(uint32_t, void*);
69 int64_t (*pGet64Static)(uint32_t);
70 void* (*pGetObjInstance)(uint32_t, void*);
71 void* (*pGetObjStatic)(uint32_t);
72
Ian Rogersa9a82542013-10-04 11:17:26 -070073 // Array
74 void (*pAputObjectWithNullAndBoundCheck)(void*, uint32_t, void*); // array, index, src
75 void (*pAputObjectWithBoundCheck)(void*, uint32_t, void*); // array, index, src
76 void (*pAputObject)(void*, uint32_t, void*); // array, index, src
Ian Rogers848871b2013-08-05 10:56:33 -070077 void (*pHandleFillArrayData)(void*, void*);
Ian Rogers57b86d42012-03-27 16:05:41 -070078
79 // JNI
Ian Rogers00f7d0e2012-07-19 15:28:27 -070080 uint32_t (*pJniMethodStart)(Thread*);
81 uint32_t (*pJniMethodStartSynchronized)(jobject to_lock, Thread* self);
82 void (*pJniMethodEnd)(uint32_t cookie, Thread* self);
83 void (*pJniMethodEndSynchronized)(uint32_t cookie, jobject locked, Thread* self);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080084 mirror::Object* (*pJniMethodEndWithReference)(jobject result, uint32_t cookie, Thread* self);
85 mirror::Object* (*pJniMethodEndWithReferenceSynchronized)(jobject result, uint32_t cookie,
Ian Rogers00f7d0e2012-07-19 15:28:27 -070086 jobject locked, Thread* self);
Ian Rogers57b86d42012-03-27 16:05:41 -070087
88 // Locks
Ian Rogers848871b2013-08-05 10:56:33 -070089 void (*pLockObject)(void*);
90 void (*pUnlockObject)(void*);
Ian Rogers57b86d42012-03-27 16:05:41 -070091
92 // Math
93 int32_t (*pCmpgDouble)(double, double);
94 int32_t (*pCmpgFloat)(float, float);
95 int32_t (*pCmplDouble)(double, double);
96 int32_t (*pCmplFloat)(float, float);
Ian Rogers57b86d42012-03-27 16:05:41 -070097 double (*pFmod)(double, double);
Ian Rogers0183dd72012-09-17 23:06:51 -070098 double (*pSqrt)(double);
Ian Rogers57b86d42012-03-27 16:05:41 -070099 double (*pL2d)(int64_t);
Ian Rogers57b86d42012-03-27 16:05:41 -0700100 float (*pFmodf)(float, float);
Ian Rogers57b86d42012-03-27 16:05:41 -0700101 float (*pL2f)(int64_t);
102 int32_t (*pD2iz)(double);
103 int32_t (*pF2iz)(float);
Ian Rogers57b86d42012-03-27 16:05:41 -0700104 int32_t (*pIdivmod)(int32_t, int32_t);
105 int64_t (*pD2l)(double);
106 int64_t (*pF2l)(float);
Ian Rogers55bd45f2012-04-04 17:31:20 -0700107 int64_t (*pLdiv)(int64_t, int64_t);
Ian Rogersa9a82542013-10-04 11:17:26 -0700108 int64_t (*pLmod)(int64_t, int64_t);
Ian Rogers57b86d42012-03-27 16:05:41 -0700109 int64_t (*pLmul)(int64_t, int64_t);
Ian Rogers57b86d42012-03-27 16:05:41 -0700110 uint64_t (*pShlLong)(uint64_t, uint32_t);
111 uint64_t (*pShrLong)(uint64_t, uint32_t);
112 uint64_t (*pUshrLong)(uint64_t, uint32_t);
113
114 // Intrinsics
115 int32_t (*pIndexOf)(void*, uint32_t, uint32_t, uint32_t);
116 int32_t (*pMemcmp16)(void*, void*, int32_t);
117 int32_t (*pStringCompareTo)(void*, void*);
118 void* (*pMemcpy)(void*, const void*, size_t);
119
120 // Invocation
Jeff Hao88474b42013-10-23 16:24:40 -0700121 void (*pQuickImtConflictTrampoline)(mirror::ArtMethod*);
Brian Carlstromea46f952013-07-30 01:26:50 -0700122 void (*pQuickResolutionTrampoline)(mirror::ArtMethod*);
123 void (*pQuickToInterpreterBridge)(mirror::ArtMethod*);
Ian Rogers57b86d42012-03-27 16:05:41 -0700124 void (*pInvokeDirectTrampolineWithAccessCheck)(uint32_t, void*);
Ian Rogers57b86d42012-03-27 16:05:41 -0700125 void (*pInvokeInterfaceTrampolineWithAccessCheck)(uint32_t, void*);
126 void (*pInvokeStaticTrampolineWithAccessCheck)(uint32_t, void*);
127 void (*pInvokeSuperTrampolineWithAccessCheck)(uint32_t, void*);
128 void (*pInvokeVirtualTrampolineWithAccessCheck)(uint32_t, void*);
129
130 // Thread
Ian Rogers848871b2013-08-05 10:56:33 -0700131 void (*pCheckSuspend)(Thread*); // Stub that is called when the suspend count is non-zero
132 void (*pTestSuspend)(); // Stub that is periodically called to test the suspend count
Ian Rogers57b86d42012-03-27 16:05:41 -0700133
134 // Throws
135 void (*pDeliverException)(void*);
Ian Rogers848871b2013-08-05 10:56:33 -0700136 void (*pThrowArrayBounds)(int32_t, int32_t);
137 void (*pThrowDivZero)();
138 void (*pThrowNoSuchMethod)(int32_t);
139 void (*pThrowNullPointer)();
140 void (*pThrowStackOverflow)(void*);
Ian Rogers57b86d42012-03-27 16:05:41 -0700141};
142
Anwar Ghuloum63937db2013-05-24 09:08:32 -0700143
Ian Rogers693ff612013-02-01 10:56:12 -0800144// JNI entrypoints.
Ian Rogers1eb512d2013-10-18 15:42:20 -0700145// TODO: NO_THREAD_SAFETY_ANALYSIS due to different control paths depending on fast JNI.
146extern uint32_t JniMethodStart(Thread* self) NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
Ian Rogers693ff612013-02-01 10:56:12 -0800147extern uint32_t JniMethodStartSynchronized(jobject to_lock, Thread* self)
Ian Rogers1eb512d2013-10-18 15:42:20 -0700148 NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
Ian Rogers693ff612013-02-01 10:56:12 -0800149extern void JniMethodEnd(uint32_t saved_local_ref_cookie, Thread* self)
Ian Rogers1eb512d2013-10-18 15:42:20 -0700150 NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
Ian Rogers693ff612013-02-01 10:56:12 -0800151extern void JniMethodEndSynchronized(uint32_t saved_local_ref_cookie, jobject locked,
152 Thread* self)
Ian Rogers1eb512d2013-10-18 15:42:20 -0700153 NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
Ian Rogers693ff612013-02-01 10:56:12 -0800154extern mirror::Object* JniMethodEndWithReference(jobject result, uint32_t saved_local_ref_cookie,
155 Thread* self)
Ian Rogers1eb512d2013-10-18 15:42:20 -0700156 NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
Ian Rogers693ff612013-02-01 10:56:12 -0800157
158extern mirror::Object* JniMethodEndWithReferenceSynchronized(jobject result,
159 uint32_t saved_local_ref_cookie,
160 jobject locked, Thread* self)
Ian Rogers1eb512d2013-10-18 15:42:20 -0700161 NO_THREAD_SAFETY_ANALYSIS HOT_ATTR;
Ian Rogers693ff612013-02-01 10:56:12 -0800162
Ian Rogers57b86d42012-03-27 16:05:41 -0700163} // namespace art
164
Ian Rogers166db042013-07-26 12:05:57 -0700165#endif // ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_