entrypoints_init_arm.cc revision 88474b416eb257078e590bf9bc7957cee604a186
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#include "entrypoints/interpreter/interpreter_entrypoints.h" 18#include "entrypoints/portable/portable_entrypoints.h" 19#include "entrypoints/quick/quick_entrypoints.h" 20#include "entrypoints/entrypoint_utils.h" 21#include "entrypoints/math_entrypoints.h" 22 23namespace art { 24 25// Interpreter entrypoints. 26extern "C" void artInterpreterToInterpreterBridge(Thread* self, MethodHelper& mh, 27 const DexFile::CodeItem* code_item, 28 ShadowFrame* shadow_frame, JValue* result); 29extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& mh, 30 const DexFile::CodeItem* code_item, 31 ShadowFrame* shadow_frame, JValue* result); 32 33// Portable entrypoints. 34extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*); 35extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*); 36 37// Alloc entrypoints. 38extern "C" void* art_quick_alloc_array(uint32_t, void*, int32_t); 39extern "C" void* art_quick_alloc_array_with_access_check(uint32_t, void*, int32_t); 40extern "C" void* art_quick_alloc_object(uint32_t type_idx, void* method); 41extern "C" void* art_quick_alloc_object_with_access_check(uint32_t type_idx, void* method); 42extern "C" void* art_quick_check_and_alloc_array(uint32_t, void*, int32_t); 43extern "C" void* art_quick_check_and_alloc_array_with_access_check(uint32_t, void*, int32_t); 44 45extern "C" void* art_quick_alloc_array_instrumented(uint32_t, void*, int32_t); 46extern "C" void* art_quick_alloc_array_with_access_check_instrumented(uint32_t, void*, int32_t); 47extern "C" void* art_quick_alloc_object_instrumented(uint32_t type_idx, void* method); 48extern "C" void* art_quick_alloc_object_with_access_check_instrumented(uint32_t type_idx, void* method); 49extern "C" void* art_quick_check_and_alloc_array_instrumented(uint32_t, void*, int32_t); 50extern "C" void* art_quick_check_and_alloc_array_with_access_check_instrumented(uint32_t, void*, int32_t); 51 52// Cast entrypoints. 53extern "C" uint32_t artIsAssignableFromCode(const mirror::Class* klass, 54 const mirror::Class* ref_class); 55extern "C" void art_quick_check_cast(void*, void*); 56 57// DexCache entrypoints. 58extern "C" void* art_quick_initialize_static_storage(uint32_t, void*); 59extern "C" void* art_quick_initialize_type(uint32_t, void*); 60extern "C" void* art_quick_initialize_type_and_verify_access(uint32_t, void*); 61extern "C" void* art_quick_resolve_string(void*, uint32_t); 62 63// Exception entrypoints. 64extern "C" void* GetAndClearException(Thread*); 65 66// Field entrypoints. 67extern "C" int art_quick_set32_instance(uint32_t, void*, int32_t); 68extern "C" int art_quick_set32_static(uint32_t, int32_t); 69extern "C" int art_quick_set64_instance(uint32_t, void*, int64_t); 70extern "C" int art_quick_set64_static(uint32_t, int64_t); 71extern "C" int art_quick_set_obj_instance(uint32_t, void*, void*); 72extern "C" int art_quick_set_obj_static(uint32_t, void*); 73extern "C" int32_t art_quick_get32_instance(uint32_t, void*); 74extern "C" int32_t art_quick_get32_static(uint32_t); 75extern "C" int64_t art_quick_get64_instance(uint32_t, void*); 76extern "C" int64_t art_quick_get64_static(uint32_t); 77extern "C" void* art_quick_get_obj_instance(uint32_t, void*); 78extern "C" void* art_quick_get_obj_static(uint32_t); 79 80// Array entrypoints. 81extern "C" void art_quick_aput_obj_with_null_and_bound_check(void*, uint32_t, void*); 82extern "C" void art_quick_aput_obj_with_bound_check(void*, uint32_t, void*); 83extern "C" void art_quick_aput_obj(void*, uint32_t, void*); 84extern "C" void art_quick_handle_fill_data(void*, void*); 85 86// Lock entrypoints. 87extern "C" void art_quick_lock_object(void*); 88extern "C" void art_quick_unlock_object(void*); 89 90// Math entrypoints. 91extern int32_t CmpgDouble(double a, double b); 92extern int32_t CmplDouble(double a, double b); 93extern int32_t CmpgFloat(float a, float b); 94extern int32_t CmplFloat(float a, float b); 95 96// Math conversions. 97extern "C" int32_t __aeabi_f2iz(float op1); // FLOAT_TO_INT 98extern "C" int32_t __aeabi_d2iz(double op1); // DOUBLE_TO_INT 99extern "C" float __aeabi_l2f(int64_t op1); // LONG_TO_FLOAT 100extern "C" double __aeabi_l2d(int64_t op1); // LONG_TO_DOUBLE 101 102// Single-precision FP arithmetics. 103extern "C" float fmodf(float a, float b); // REM_FLOAT[_2ADDR] 104 105// Double-precision FP arithmetics. 106extern "C" double fmod(double a, double b); // REM_DOUBLE[_2ADDR] 107 108// Integer arithmetics. 109extern "C" int __aeabi_idivmod(int32_t, int32_t); // [DIV|REM]_INT[_2ADDR|_LIT8|_LIT16] 110 111// Long long arithmetics - REM_LONG[_2ADDR] and DIV_LONG[_2ADDR] 112extern "C" int64_t __aeabi_ldivmod(int64_t, int64_t); 113extern "C" int64_t art_quick_mul_long(int64_t, int64_t); 114extern "C" uint64_t art_quick_shl_long(uint64_t, uint32_t); 115extern "C" uint64_t art_quick_shr_long(uint64_t, uint32_t); 116extern "C" uint64_t art_quick_ushr_long(uint64_t, uint32_t); 117 118// Intrinsic entrypoints. 119extern "C" int32_t __memcmp16(void*, void*, int32_t); 120extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t); 121extern "C" int32_t art_quick_string_compareto(void*, void*); 122 123// Invoke entrypoints. 124extern "C" void art_quick_imt_conflict_trampoline(mirror::ArtMethod*); 125extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*); 126extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*); 127extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*); 128extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*); 129extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*); 130extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*); 131extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*); 132 133// Thread entrypoints. 134extern void CheckSuspendFromCode(Thread* thread); 135extern "C" void art_quick_test_suspend(); 136 137// Throw entrypoints. 138extern "C" void art_quick_deliver_exception(void*); 139extern "C" void art_quick_throw_array_bounds(int32_t index, int32_t limit); 140extern "C" void art_quick_throw_div_zero(); 141extern "C" void art_quick_throw_no_such_method(int32_t method_idx); 142extern "C" void art_quick_throw_null_pointer_exception(); 143extern "C" void art_quick_throw_stack_overflow(void*); 144 145static bool quick_alloc_entry_points_instrumented = false; 146 147void SetQuickAllocEntryPointsInstrumented(bool instrumented) { 148 quick_alloc_entry_points_instrumented = instrumented; 149} 150 151void ResetQuickAllocEntryPoints(QuickEntryPoints* qpoints) { 152 if (quick_alloc_entry_points_instrumented) { 153 qpoints->pAllocArray = art_quick_alloc_array_instrumented; 154 qpoints->pAllocArrayWithAccessCheck = art_quick_alloc_array_with_access_check_instrumented; 155 qpoints->pAllocObject = art_quick_alloc_object_instrumented; 156 qpoints->pAllocObjectWithAccessCheck = art_quick_alloc_object_with_access_check_instrumented; 157 qpoints->pCheckAndAllocArray = art_quick_check_and_alloc_array_instrumented; 158 qpoints->pCheckAndAllocArrayWithAccessCheck = art_quick_check_and_alloc_array_with_access_check_instrumented; 159 } else { 160 qpoints->pAllocArray = art_quick_alloc_array; 161 qpoints->pAllocArrayWithAccessCheck = art_quick_alloc_array_with_access_check; 162 qpoints->pAllocObject = art_quick_alloc_object; 163 qpoints->pAllocObjectWithAccessCheck = art_quick_alloc_object_with_access_check; 164 qpoints->pCheckAndAllocArray = art_quick_check_and_alloc_array; 165 qpoints->pCheckAndAllocArrayWithAccessCheck = art_quick_check_and_alloc_array_with_access_check; 166 } 167} 168 169void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints, 170 PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) { 171 // Interpreter 172 ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge; 173 ipoints->pInterpreterToCompiledCodeBridge = artInterpreterToCompiledCodeBridge; 174 175 // JNI 176 jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub; 177 178 // Portable 179 ppoints->pPortableResolutionTrampoline = art_portable_resolution_trampoline; 180 ppoints->pPortableToInterpreterBridge = art_portable_to_interpreter_bridge; 181 182 // Alloc 183 ResetQuickAllocEntryPoints(qpoints); 184 185 // Cast 186 qpoints->pInstanceofNonTrivial = artIsAssignableFromCode; 187 qpoints->pCheckCast = art_quick_check_cast; 188 189 // DexCache 190 qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage; 191 qpoints->pInitializeTypeAndVerifyAccess = art_quick_initialize_type_and_verify_access; 192 qpoints->pInitializeType = art_quick_initialize_type; 193 qpoints->pResolveString = art_quick_resolve_string; 194 195 // Field 196 qpoints->pSet32Instance = art_quick_set32_instance; 197 qpoints->pSet32Static = art_quick_set32_static; 198 qpoints->pSet64Instance = art_quick_set64_instance; 199 qpoints->pSet64Static = art_quick_set64_static; 200 qpoints->pSetObjInstance = art_quick_set_obj_instance; 201 qpoints->pSetObjStatic = art_quick_set_obj_static; 202 qpoints->pGet32Instance = art_quick_get32_instance; 203 qpoints->pGet64Instance = art_quick_get64_instance; 204 qpoints->pGetObjInstance = art_quick_get_obj_instance; 205 qpoints->pGet32Static = art_quick_get32_static; 206 qpoints->pGet64Static = art_quick_get64_static; 207 qpoints->pGetObjStatic = art_quick_get_obj_static; 208 209 // Array 210 qpoints->pAputObjectWithNullAndBoundCheck = art_quick_aput_obj_with_null_and_bound_check; 211 qpoints->pAputObjectWithBoundCheck = art_quick_aput_obj_with_bound_check; 212 qpoints->pAputObject = art_quick_aput_obj; 213 qpoints->pHandleFillArrayData = art_quick_handle_fill_data; 214 215 // JNI 216 qpoints->pJniMethodStart = JniMethodStart; 217 qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized; 218 qpoints->pJniMethodEnd = JniMethodEnd; 219 qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized; 220 qpoints->pJniMethodEndWithReference = JniMethodEndWithReference; 221 qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized; 222 223 // Locks 224 qpoints->pLockObject = art_quick_lock_object; 225 qpoints->pUnlockObject = art_quick_unlock_object; 226 227 // Math 228 qpoints->pCmpgDouble = CmpgDouble; 229 qpoints->pCmpgFloat = CmpgFloat; 230 qpoints->pCmplDouble = CmplDouble; 231 qpoints->pCmplFloat = CmplFloat; 232 qpoints->pFmod = fmod; 233 qpoints->pSqrt = sqrt; 234 qpoints->pL2d = __aeabi_l2d; 235 qpoints->pFmodf = fmodf; 236 qpoints->pL2f = __aeabi_l2f; 237 qpoints->pD2iz = __aeabi_d2iz; 238 qpoints->pF2iz = __aeabi_f2iz; 239 qpoints->pIdivmod = __aeabi_idivmod; 240 qpoints->pD2l = art_d2l; 241 qpoints->pF2l = art_f2l; 242 qpoints->pLdiv = __aeabi_ldivmod; 243 qpoints->pLmod = __aeabi_ldivmod; // result returned in r2:r3 244 qpoints->pLmul = art_quick_mul_long; 245 qpoints->pShlLong = art_quick_shl_long; 246 qpoints->pShrLong = art_quick_shr_long; 247 qpoints->pUshrLong = art_quick_ushr_long; 248 249 // Intrinsics 250 qpoints->pIndexOf = art_quick_indexof; 251 qpoints->pMemcmp16 = __memcmp16; 252 qpoints->pStringCompareTo = art_quick_string_compareto; 253 qpoints->pMemcpy = memcpy; 254 255 // Invocation 256 qpoints->pQuickImtConflictTrampoline = art_quick_imt_conflict_trampoline; 257 qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline; 258 qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge; 259 qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check; 260 qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check; 261 qpoints->pInvokeStaticTrampolineWithAccessCheck = art_quick_invoke_static_trampoline_with_access_check; 262 qpoints->pInvokeSuperTrampolineWithAccessCheck = art_quick_invoke_super_trampoline_with_access_check; 263 qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check; 264 265 // Thread 266 qpoints->pCheckSuspend = CheckSuspendFromCode; 267 qpoints->pTestSuspend = art_quick_test_suspend; 268 269 // Throws 270 qpoints->pDeliverException = art_quick_deliver_exception; 271 qpoints->pThrowArrayBounds = art_quick_throw_array_bounds; 272 qpoints->pThrowDivZero = art_quick_throw_div_zero; 273 qpoints->pThrowNoSuchMethod = art_quick_throw_no_such_method; 274 qpoints->pThrowNullPointer = art_quick_throw_null_pointer_exception; 275 qpoints->pThrowStackOverflow = art_quick_throw_stack_overflow; 276}; 277 278} // namespace art 279