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