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 | |
| 17 | #include "entrypoints/portable/portable_entrypoints.h" |
Mathieu Chartier | d889178 | 2014-03-02 13:28:37 -0800 | [diff] [blame^] | 18 | #include "entrypoints/quick/quick_alloc_entrypoints.h" |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 19 | #include "entrypoints/quick/quick_entrypoints.h" |
| 20 | #include "entrypoints/entrypoint_utils.h" |
| 21 | |
| 22 | namespace art { |
| 23 | |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 24 | // Interpreter entrypoints. |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 25 | extern "C" void artInterpreterToInterpreterBridge(Thread* self, MethodHelper& mh, |
| 26 | const DexFile::CodeItem* code_item, |
| 27 | ShadowFrame* shadow_frame, JValue* result); |
Dragos Sbirlea | 08bf196 | 2013-08-12 08:53:04 -0700 | [diff] [blame] | 28 | extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& mh, |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 29 | const DexFile::CodeItem* code_item, |
| 30 | ShadowFrame* shadow_frame, JValue* result); |
| 31 | |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 32 | // Portable entrypoints. |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 33 | extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*); |
| 34 | extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*); |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 35 | |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 36 | // Cast entrypoints. |
| 37 | extern "C" uint32_t art_quick_is_assignable(const mirror::Class* klass, |
| 38 | const mirror::Class* ref_class); |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 39 | extern "C" void art_quick_check_cast(void*, void*); |
| 40 | |
| 41 | // DexCache entrypoints. |
| 42 | extern "C" void* art_quick_initialize_static_storage(uint32_t, void*); |
| 43 | extern "C" void* art_quick_initialize_type(uint32_t, void*); |
| 44 | extern "C" void* art_quick_initialize_type_and_verify_access(uint32_t, void*); |
| 45 | extern "C" void* art_quick_resolve_string(void*, uint32_t); |
| 46 | |
| 47 | // Field entrypoints. |
| 48 | extern "C" int art_quick_set32_instance(uint32_t, void*, int32_t); |
| 49 | extern "C" int art_quick_set32_static(uint32_t, int32_t); |
| 50 | extern "C" int art_quick_set64_instance(uint32_t, void*, int64_t); |
| 51 | extern "C" int art_quick_set64_static(uint32_t, int64_t); |
| 52 | extern "C" int art_quick_set_obj_instance(uint32_t, void*, void*); |
| 53 | extern "C" int art_quick_set_obj_static(uint32_t, void*); |
| 54 | extern "C" int32_t art_quick_get32_instance(uint32_t, void*); |
| 55 | extern "C" int32_t art_quick_get32_static(uint32_t); |
| 56 | extern "C" int64_t art_quick_get64_instance(uint32_t, void*); |
| 57 | extern "C" int64_t art_quick_get64_static(uint32_t); |
| 58 | extern "C" void* art_quick_get_obj_instance(uint32_t, void*); |
| 59 | extern "C" void* art_quick_get_obj_static(uint32_t); |
| 60 | |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 61 | // Array entrypoints. |
| 62 | extern "C" void art_quick_aput_obj_with_null_and_bound_check(void*, uint32_t, void*); |
| 63 | extern "C" void art_quick_aput_obj_with_bound_check(void*, uint32_t, void*); |
| 64 | extern "C" void art_quick_aput_obj(void*, uint32_t, void*); |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 65 | extern "C" void art_quick_handle_fill_data(void*, void*); |
| 66 | |
| 67 | // Lock entrypoints. |
| 68 | extern "C" void art_quick_lock_object(void*); |
| 69 | extern "C" void art_quick_unlock_object(void*); |
| 70 | |
| 71 | // Math entrypoints. |
| 72 | extern "C" double art_quick_fmod(double, double); |
| 73 | extern "C" float art_quick_fmodf(float, float); |
| 74 | extern "C" double art_quick_l2d(int64_t); |
| 75 | extern "C" float art_quick_l2f(int64_t); |
| 76 | extern "C" int64_t art_quick_d2l(double); |
| 77 | extern "C" int64_t art_quick_f2l(float); |
| 78 | extern "C" int32_t art_quick_idivmod(int32_t, int32_t); |
| 79 | extern "C" int64_t art_quick_ldiv(int64_t, int64_t); |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 80 | extern "C" int64_t art_quick_lmod(int64_t, int64_t); |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 81 | extern "C" int64_t art_quick_lmul(int64_t, int64_t); |
| 82 | extern "C" uint64_t art_quick_lshl(uint64_t, uint32_t); |
| 83 | extern "C" uint64_t art_quick_lshr(uint64_t, uint32_t); |
| 84 | extern "C" uint64_t art_quick_lushr(uint64_t, uint32_t); |
| 85 | |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 86 | // Intrinsic entrypoints. |
| 87 | extern "C" int32_t art_quick_memcmp16(void*, void*, int32_t); |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 88 | extern "C" int32_t art_quick_string_compareto(void*, void*); |
| 89 | extern "C" void* art_quick_memcpy(void*, const void*, size_t); |
| 90 | |
| 91 | // Invoke entrypoints. |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 92 | extern "C" void art_quick_imt_conflict_trampoline(mirror::ArtMethod*); |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 93 | extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*); |
| 94 | extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*); |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 95 | extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*); |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 96 | extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*); |
| 97 | extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*); |
| 98 | extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*); |
| 99 | extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*); |
| 100 | |
| 101 | // Thread entrypoints. |
| 102 | extern void CheckSuspendFromCode(Thread* thread); |
| 103 | extern "C" void art_quick_test_suspend(); |
| 104 | |
| 105 | // Throw entrypoints. |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 106 | extern "C" void art_quick_deliver_exception(void*); |
| 107 | extern "C" void art_quick_throw_array_bounds(int32_t index, int32_t limit); |
| 108 | extern "C" void art_quick_throw_div_zero(); |
| 109 | extern "C" void art_quick_throw_no_such_method(int32_t method_idx); |
| 110 | extern "C" void art_quick_throw_null_pointer_exception(); |
| 111 | extern "C" void art_quick_throw_stack_overflow(void*); |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 112 | |
Andreas Gampe | 2da8823 | 2014-02-27 12:26:20 -0800 | [diff] [blame] | 113 | // Generic JNI downcall |
| 114 | extern "C" void art_quick_generic_jni_trampoline(mirror::ArtMethod*); |
| 115 | |
Mathieu Chartier | cbb2d20 | 2013-11-14 17:45:16 -0800 | [diff] [blame] | 116 | extern void ResetQuickAllocEntryPoints(QuickEntryPoints* qpoints); |
Hiroshi Yamauchi | 3b4c189 | 2013-09-12 21:33:12 -0700 | [diff] [blame] | 117 | |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 118 | void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints, |
| 119 | PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) { |
| 120 | // Interpreter |
| 121 | ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge; |
Dragos Sbirlea | 08bf196 | 2013-08-12 08:53:04 -0700 | [diff] [blame] | 122 | ipoints->pInterpreterToCompiledCodeBridge = artInterpreterToCompiledCodeBridge; |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 123 | |
| 124 | // JNI |
| 125 | jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub; |
| 126 | |
| 127 | // Portable |
| 128 | ppoints->pPortableResolutionTrampoline = art_portable_resolution_trampoline; |
| 129 | ppoints->pPortableToInterpreterBridge = art_portable_to_interpreter_bridge; |
| 130 | |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 131 | // Alloc |
Hiroshi Yamauchi | 3b4c189 | 2013-09-12 21:33:12 -0700 | [diff] [blame] | 132 | ResetQuickAllocEntryPoints(qpoints); |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 133 | |
| 134 | // Cast |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 135 | qpoints->pInstanceofNonTrivial = art_quick_is_assignable; |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 136 | qpoints->pCheckCast = art_quick_check_cast; |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 137 | |
| 138 | // DexCache |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 139 | qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage; |
| 140 | qpoints->pInitializeTypeAndVerifyAccess = art_quick_initialize_type_and_verify_access; |
| 141 | qpoints->pInitializeType = art_quick_initialize_type; |
| 142 | qpoints->pResolveString = art_quick_resolve_string; |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 143 | |
| 144 | // Field |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 145 | qpoints->pSet32Instance = art_quick_set32_instance; |
| 146 | qpoints->pSet32Static = art_quick_set32_static; |
| 147 | qpoints->pSet64Instance = art_quick_set64_instance; |
| 148 | qpoints->pSet64Static = art_quick_set64_static; |
| 149 | qpoints->pSetObjInstance = art_quick_set_obj_instance; |
| 150 | qpoints->pSetObjStatic = art_quick_set_obj_static; |
| 151 | qpoints->pGet32Instance = art_quick_get32_instance; |
| 152 | qpoints->pGet64Instance = art_quick_get64_instance; |
| 153 | qpoints->pGetObjInstance = art_quick_get_obj_instance; |
| 154 | qpoints->pGet32Static = art_quick_get32_static; |
| 155 | qpoints->pGet64Static = art_quick_get64_static; |
| 156 | qpoints->pGetObjStatic = art_quick_get_obj_static; |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 157 | |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 158 | // Array |
| 159 | qpoints->pAputObjectWithNullAndBoundCheck = art_quick_aput_obj_with_null_and_bound_check; |
| 160 | qpoints->pAputObjectWithBoundCheck = art_quick_aput_obj_with_bound_check; |
| 161 | qpoints->pAputObject = art_quick_aput_obj; |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 162 | qpoints->pHandleFillArrayData = art_quick_handle_fill_data; |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 163 | |
| 164 | // JNI |
| 165 | qpoints->pJniMethodStart = JniMethodStart; |
| 166 | qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized; |
| 167 | qpoints->pJniMethodEnd = JniMethodEnd; |
| 168 | qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized; |
| 169 | qpoints->pJniMethodEndWithReference = JniMethodEndWithReference; |
| 170 | qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized; |
Andreas Gampe | 2da8823 | 2014-02-27 12:26:20 -0800 | [diff] [blame] | 171 | qpoints->pQuickGenericJniTrampoline = art_quick_generic_jni_trampoline; |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 172 | |
| 173 | // Locks |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 174 | qpoints->pLockObject = art_quick_lock_object; |
| 175 | qpoints->pUnlockObject = art_quick_unlock_object; |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 176 | |
| 177 | // Math |
| 178 | // points->pCmpgDouble = NULL; // Not needed on x86. |
| 179 | // points->pCmpgFloat = NULL; // Not needed on x86. |
| 180 | // points->pCmplDouble = NULL; // Not needed on x86. |
| 181 | // points->pCmplFloat = NULL; // Not needed on x86. |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 182 | qpoints->pFmod = art_quick_fmod; |
Vladimir Marko | 12f9628 | 2013-12-16 14:44:03 +0000 | [diff] [blame] | 183 | // qpoints->pSqrt = NULL; // Not needed on x86. |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 184 | qpoints->pL2d = art_quick_l2d; |
| 185 | qpoints->pFmodf = art_quick_fmodf; |
| 186 | qpoints->pL2f = art_quick_l2f; |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 187 | // points->pD2iz = NULL; // Not needed on x86. |
| 188 | // points->pF2iz = NULL; // Not needed on x86. |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 189 | qpoints->pIdivmod = art_quick_idivmod; |
| 190 | qpoints->pD2l = art_quick_d2l; |
| 191 | qpoints->pF2l = art_quick_f2l; |
| 192 | qpoints->pLdiv = art_quick_ldiv; |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 193 | qpoints->pLmod = art_quick_lmod; |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 194 | qpoints->pLmul = art_quick_lmul; |
| 195 | qpoints->pShlLong = art_quick_lshl; |
| 196 | qpoints->pShrLong = art_quick_lshr; |
| 197 | qpoints->pUshrLong = art_quick_lushr; |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 198 | |
| 199 | // Intrinsics |
Mark Mendell | 4028a6c | 2014-02-19 20:06:20 -0800 | [diff] [blame] | 200 | // qpoints->pIndexOf = nullptr; // Not needed on x86 |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 201 | qpoints->pMemcmp16 = art_quick_memcmp16; |
| 202 | qpoints->pStringCompareTo = art_quick_string_compareto; |
| 203 | qpoints->pMemcpy = art_quick_memcpy; |
| 204 | |
| 205 | // Invocation |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 206 | qpoints->pQuickImtConflictTrampoline = art_quick_imt_conflict_trampoline; |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 207 | qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline; |
| 208 | qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge; |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 209 | qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check; |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 210 | qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check; |
| 211 | qpoints->pInvokeStaticTrampolineWithAccessCheck = art_quick_invoke_static_trampoline_with_access_check; |
| 212 | qpoints->pInvokeSuperTrampolineWithAccessCheck = art_quick_invoke_super_trampoline_with_access_check; |
| 213 | qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check; |
| 214 | |
| 215 | // Thread |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 216 | qpoints->pCheckSuspend = CheckSuspendFromCode; |
| 217 | qpoints->pTestSuspend = art_quick_test_suspend; |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 218 | |
| 219 | // Throws |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 220 | qpoints->pDeliverException = art_quick_deliver_exception; |
| 221 | qpoints->pThrowArrayBounds = art_quick_throw_array_bounds; |
| 222 | qpoints->pThrowDivZero = art_quick_throw_div_zero; |
| 223 | qpoints->pThrowNoSuchMethod = art_quick_throw_no_such_method; |
| 224 | qpoints->pThrowNullPointer = art_quick_throw_null_pointer_exception; |
| 225 | qpoints->pThrowStackOverflow = art_quick_throw_stack_overflow; |
Ian Rogers | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 226 | }; |
| 227 | |
| 228 | } // namespace art |