quick_entrypoints.h revision 834b394ee759ed31c5371d8093d7cd8cd90014a8
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 "dex_file-inl.h" 21#include "runtime.h" 22 23#define QUICK_ENTRYPOINT_OFFSET(x) \ 24 (static_cast<uintptr_t>(OFFSETOF_MEMBER(Thread, quick_entrypoints_)) + \ 25 static_cast<uintptr_t>(OFFSETOF_MEMBER(QuickEntryPoints, x))) 26 27namespace art { 28namespace mirror { 29 class AbstractMethod; 30 class Class; 31 class Object; 32} // namespace mirror 33class DvmDex; 34class MethodHelper; 35class ShadowFrame; 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* (*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 49 uint32_t (*pInstanceofNonTrivialFromCode)(const mirror::Class*, const mirror::Class*); 50 void (*pCanPutArrayElementFromCode)(void*, void*); 51 void (*pCheckCastFromCode)(void*, void*); 52 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 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); 81 mirror::Object* (*pJniMethodEndWithReference)(jobject result, uint32_t cookie, Thread* self); 82 mirror::Object* (*pJniMethodEndWithReferenceSynchronized)(jobject result, uint32_t cookie, 83 jobject locked, Thread* self); 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); 94 double (*pFmod)(double, double); 95 double (*pSqrt)(double); 96 double (*pL2d)(int64_t); 97 float (*pFmodf)(float, float); 98 float (*pL2f)(int64_t); 99 int32_t (*pD2iz)(double); 100 int32_t (*pF2iz)(float); 101 int32_t (*pIdivmod)(int32_t, int32_t); 102 int64_t (*pD2l)(double); 103 int64_t (*pF2l)(float); 104 int64_t (*pLdiv)(int64_t, int64_t); 105 int64_t (*pLdivmod)(int64_t, int64_t); 106 int64_t (*pLmul)(int64_t, int64_t); 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 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 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 126 const void* (*pQuickResolutionTrampolineFromCode)(mirror::AbstractMethod*, mirror::Object*, 127 mirror::AbstractMethod**, Thread*); 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*); 141 void (*pThrowArrayBoundsFromCode)(int32_t, int32_t); 142 void (*pThrowDivZeroFromCode)(); 143 void (*pThrowNoSuchMethodFromCode)(int32_t); 144 void (*pThrowNullPointerFromCode)(); 145 void (*pThrowStackOverflowFromCode)(void*); 146}; 147 148 149// JNI entrypoints. 150extern uint32_t JniMethodStart(Thread* self) 151 UNLOCK_FUNCTION(Locks::mutator_lock_) HOT_ATTR; 152extern uint32_t JniMethodStartSynchronized(jobject to_lock, Thread* self) 153 UNLOCK_FUNCTION(Locks::mutator_lock_) HOT_ATTR; 154extern void JniMethodEnd(uint32_t saved_local_ref_cookie, Thread* self) 155 SHARED_LOCK_FUNCTION(Locks::mutator_lock_) HOT_ATTR; 156extern void JniMethodEndSynchronized(uint32_t saved_local_ref_cookie, jobject locked, 157 Thread* self) 158 SHARED_LOCK_FUNCTION(Locks::mutator_lock_) HOT_ATTR; 159extern mirror::Object* JniMethodEndWithReference(jobject result, uint32_t saved_local_ref_cookie, 160 Thread* self) 161 SHARED_LOCK_FUNCTION(Locks::mutator_lock_) HOT_ATTR; 162 163extern mirror::Object* JniMethodEndWithReferenceSynchronized(jobject result, 164 uint32_t saved_local_ref_cookie, 165 jobject locked, Thread* self) 166 SHARED_LOCK_FUNCTION(Locks::mutator_lock_) HOT_ATTR; 167 168} // namespace art 169 170#endif // ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_ 171