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