Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 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 | |
Ian Rogers | 166db04 | 2013-07-26 12:05:57 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_ |
| 18 | #define ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_ |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 19 | |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 20 | #include "dex_file-inl.h" |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 21 | #include "runtime.h" |
| 22 | |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame^] | 23 | #define QUICK_ENTRYPOINT_OFFSET(x) \ |
| 24 | (static_cast<uintptr_t>(OFFSETOF_MEMBER(Thread, quick_entrypoints_)) + \ |
Ian Rogers | 166db04 | 2013-07-26 12:05:57 -0700 | [diff] [blame] | 25 | static_cast<uintptr_t>(OFFSETOF_MEMBER(QuickEntryPoints, x))) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 26 | |
| 27 | namespace art { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 28 | namespace mirror { |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame^] | 29 | class AbstractMethod; |
| 30 | class Class; |
| 31 | class Object; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 32 | } // namespace mirror |
| 33 | class DvmDex; |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 34 | class MethodHelper; |
| 35 | class ShadowFrame; |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 36 | class Thread; |
| 37 | |
Ian Rogers | 166db04 | 2013-07-26 12:05:57 -0700 | [diff] [blame] | 38 | // Pointers to functions that are called by quick compiler generated code via thread-local storage. |
| 39 | struct PACKED(4) QuickEntryPoints { |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 40 | // Alloc |
| 41 | void* (*pAllocArrayFromCode)(uint32_t, void*, int32_t); |
| 42 | void* (*pAllocArrayFromCodeWithAccessCheck)(uint32_t, void*, int32_t); |
| 43 | void* (*pAllocObjectFromCode)(uint32_t, void*); |
| 44 | void* (*pAllocObjectFromCodeWithAccessCheck)(uint32_t, void*); |
| 45 | void* (*pCheckAndAllocArrayFromCode)(uint32_t, void*, int32_t); |
| 46 | void* (*pCheckAndAllocArrayFromCodeWithAccessCheck)(uint32_t, void*, int32_t); |
| 47 | |
| 48 | // Cast |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 49 | uint32_t (*pInstanceofNonTrivialFromCode)(const mirror::Class*, const mirror::Class*); |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 50 | void (*pCanPutArrayElementFromCode)(void*, void*); |
| 51 | void (*pCheckCastFromCode)(void*, void*); |
| 52 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 53 | // DexCache |
| 54 | void* (*pInitializeStaticStorage)(uint32_t, void*); |
| 55 | void* (*pInitializeTypeAndVerifyAccessFromCode)(uint32_t, void*); |
| 56 | void* (*pInitializeTypeFromCode)(uint32_t, void*); |
| 57 | void* (*pResolveStringFromCode)(void*, uint32_t); |
| 58 | |
| 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 | |
| 73 | // FillArray |
| 74 | void (*pHandleFillArrayDataFromCode)(void*, void*); |
| 75 | |
| 76 | // JNI |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 77 | uint32_t (*pJniMethodStart)(Thread*); |
| 78 | uint32_t (*pJniMethodStartSynchronized)(jobject to_lock, Thread* self); |
| 79 | void (*pJniMethodEnd)(uint32_t cookie, Thread* self); |
| 80 | void (*pJniMethodEndSynchronized)(uint32_t cookie, jobject locked, Thread* self); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 81 | mirror::Object* (*pJniMethodEndWithReference)(jobject result, uint32_t cookie, Thread* self); |
| 82 | mirror::Object* (*pJniMethodEndWithReferenceSynchronized)(jobject result, uint32_t cookie, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 83 | jobject locked, Thread* self); |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 84 | |
| 85 | // Locks |
| 86 | void (*pLockObjectFromCode)(void*); |
| 87 | void (*pUnlockObjectFromCode)(void*); |
| 88 | |
| 89 | // Math |
| 90 | int32_t (*pCmpgDouble)(double, double); |
| 91 | int32_t (*pCmpgFloat)(float, float); |
| 92 | int32_t (*pCmplDouble)(double, double); |
| 93 | int32_t (*pCmplFloat)(float, float); |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 94 | double (*pFmod)(double, double); |
Ian Rogers | 0183dd7 | 2012-09-17 23:06:51 -0700 | [diff] [blame] | 95 | double (*pSqrt)(double); |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 96 | double (*pL2d)(int64_t); |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 97 | float (*pFmodf)(float, float); |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 98 | float (*pL2f)(int64_t); |
| 99 | int32_t (*pD2iz)(double); |
| 100 | int32_t (*pF2iz)(float); |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 101 | int32_t (*pIdivmod)(int32_t, int32_t); |
| 102 | int64_t (*pD2l)(double); |
| 103 | int64_t (*pF2l)(float); |
Ian Rogers | 55bd45f | 2012-04-04 17:31:20 -0700 | [diff] [blame] | 104 | int64_t (*pLdiv)(int64_t, int64_t); |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 105 | int64_t (*pLdivmod)(int64_t, int64_t); |
| 106 | int64_t (*pLmul)(int64_t, int64_t); |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 107 | uint64_t (*pShlLong)(uint64_t, uint32_t); |
| 108 | uint64_t (*pShrLong)(uint64_t, uint32_t); |
| 109 | uint64_t (*pUshrLong)(uint64_t, uint32_t); |
| 110 | |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 111 | // Interpreter |
| 112 | void (*pInterpreterToInterpreterEntry)(Thread* self, MethodHelper& mh, |
| 113 | const DexFile::CodeItem* code_item, |
| 114 | ShadowFrame* shadow_frame, JValue* result); |
| 115 | void (*pInterpreterToQuickEntry)(Thread* self, MethodHelper& mh, |
| 116 | const DexFile::CodeItem* code_item, |
| 117 | ShadowFrame* shadow_frame, JValue* result); |
| 118 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 119 | // Intrinsics |
| 120 | int32_t (*pIndexOf)(void*, uint32_t, uint32_t, uint32_t); |
| 121 | int32_t (*pMemcmp16)(void*, void*, int32_t); |
| 122 | int32_t (*pStringCompareTo)(void*, void*); |
| 123 | void* (*pMemcpy)(void*, const void*, size_t); |
| 124 | |
| 125 | // Invocation |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 126 | const void* (*pQuickResolutionTrampolineFromCode)(mirror::AbstractMethod*, mirror::Object*, |
| 127 | mirror::AbstractMethod**, Thread*); |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 128 | void (*pInvokeDirectTrampolineWithAccessCheck)(uint32_t, void*); |
| 129 | void (*pInvokeInterfaceTrampoline)(uint32_t, void*); |
| 130 | void (*pInvokeInterfaceTrampolineWithAccessCheck)(uint32_t, void*); |
| 131 | void (*pInvokeStaticTrampolineWithAccessCheck)(uint32_t, void*); |
| 132 | void (*pInvokeSuperTrampolineWithAccessCheck)(uint32_t, void*); |
| 133 | void (*pInvokeVirtualTrampolineWithAccessCheck)(uint32_t, void*); |
| 134 | |
| 135 | // Thread |
| 136 | void (*pCheckSuspendFromCode)(Thread*); // Stub that is called when the suspend count is non-zero |
| 137 | void (*pTestSuspendFromCode)(); // Stub that is periodically called to test the suspend count |
| 138 | |
| 139 | // Throws |
| 140 | void (*pDeliverException)(void*); |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 141 | void (*pThrowArrayBoundsFromCode)(int32_t, int32_t); |
| 142 | void (*pThrowDivZeroFromCode)(); |
| 143 | void (*pThrowNoSuchMethodFromCode)(int32_t); |
| 144 | void (*pThrowNullPointerFromCode)(); |
| 145 | void (*pThrowStackOverflowFromCode)(void*); |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 146 | }; |
| 147 | |
Anwar Ghuloum | 63937db | 2013-05-24 09:08:32 -0700 | [diff] [blame] | 148 | |
Ian Rogers | 693ff61 | 2013-02-01 10:56:12 -0800 | [diff] [blame] | 149 | // JNI entrypoints. |
Ian Rogers | 693ff61 | 2013-02-01 10:56:12 -0800 | [diff] [blame] | 150 | extern uint32_t JniMethodStart(Thread* self) |
Anwar Ghuloum | 63937db | 2013-05-24 09:08:32 -0700 | [diff] [blame] | 151 | UNLOCK_FUNCTION(Locks::mutator_lock_) HOT_ATTR; |
Ian Rogers | 693ff61 | 2013-02-01 10:56:12 -0800 | [diff] [blame] | 152 | extern uint32_t JniMethodStartSynchronized(jobject to_lock, Thread* self) |
Anwar Ghuloum | 63937db | 2013-05-24 09:08:32 -0700 | [diff] [blame] | 153 | UNLOCK_FUNCTION(Locks::mutator_lock_) HOT_ATTR; |
Ian Rogers | 693ff61 | 2013-02-01 10:56:12 -0800 | [diff] [blame] | 154 | extern void JniMethodEnd(uint32_t saved_local_ref_cookie, Thread* self) |
Anwar Ghuloum | 63937db | 2013-05-24 09:08:32 -0700 | [diff] [blame] | 155 | SHARED_LOCK_FUNCTION(Locks::mutator_lock_) HOT_ATTR; |
Ian Rogers | 693ff61 | 2013-02-01 10:56:12 -0800 | [diff] [blame] | 156 | extern void JniMethodEndSynchronized(uint32_t saved_local_ref_cookie, jobject locked, |
| 157 | Thread* self) |
Anwar Ghuloum | 63937db | 2013-05-24 09:08:32 -0700 | [diff] [blame] | 158 | SHARED_LOCK_FUNCTION(Locks::mutator_lock_) HOT_ATTR; |
Ian Rogers | 693ff61 | 2013-02-01 10:56:12 -0800 | [diff] [blame] | 159 | extern mirror::Object* JniMethodEndWithReference(jobject result, uint32_t saved_local_ref_cookie, |
| 160 | Thread* self) |
Anwar Ghuloum | 63937db | 2013-05-24 09:08:32 -0700 | [diff] [blame] | 161 | SHARED_LOCK_FUNCTION(Locks::mutator_lock_) HOT_ATTR; |
Ian Rogers | 693ff61 | 2013-02-01 10:56:12 -0800 | [diff] [blame] | 162 | |
| 163 | extern mirror::Object* JniMethodEndWithReferenceSynchronized(jobject result, |
| 164 | uint32_t saved_local_ref_cookie, |
| 165 | jobject locked, Thread* self) |
Anwar Ghuloum | 63937db | 2013-05-24 09:08:32 -0700 | [diff] [blame] | 166 | SHARED_LOCK_FUNCTION(Locks::mutator_lock_) HOT_ATTR; |
Ian Rogers | 693ff61 | 2013-02-01 10:56:12 -0800 | [diff] [blame] | 167 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 168 | } // namespace art |
| 169 | |
Ian Rogers | 166db04 | 2013-07-26 12:05:57 -0700 | [diff] [blame] | 170 | #endif // ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_ |