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" |
| 18 | #include "entrypoints/quick/quick_entrypoints.h" |
| 19 | #include "entrypoints/entrypoint_utils.h" |
| 20 | |
| 21 | namespace art { |
| 22 | |
| 23 | // Alloc entrypoints. |
| 24 | extern "C" void* art_quick_alloc_array_from_code(uint32_t, void*, int32_t); |
| 25 | extern "C" void* art_quick_alloc_array_from_code_with_access_check(uint32_t, void*, int32_t); |
| 26 | extern "C" void* art_quick_alloc_object_from_code(uint32_t type_idx, void* method); |
| 27 | extern "C" void* art_quick_alloc_object_from_code_with_access_check(uint32_t type_idx, void* method); |
| 28 | extern "C" void* art_quick_check_and_alloc_array_from_code(uint32_t, void*, int32_t); |
| 29 | extern "C" void* art_quick_check_and_alloc_array_from_code_with_access_check(uint32_t, void*, int32_t); |
| 30 | |
| 31 | // Cast entrypoints. |
| 32 | extern "C" uint32_t art_quick_is_assignable_from_code(const mirror::Class* klass, |
| 33 | const mirror::Class* ref_class); |
| 34 | extern "C" void art_quick_can_put_array_element_from_code(void*, void*); |
| 35 | extern "C" void art_quick_check_cast_from_code(void*, void*); |
| 36 | |
| 37 | // DexCache entrypoints. |
| 38 | extern "C" void* art_quick_initialize_static_storage_from_code(uint32_t, void*); |
| 39 | extern "C" void* art_quick_initialize_type_from_code(uint32_t, void*); |
| 40 | extern "C" void* art_quick_initialize_type_and_verify_access_from_code(uint32_t, void*); |
| 41 | extern "C" void* art_quick_resolve_string_from_code(void*, uint32_t); |
| 42 | |
| 43 | // Field entrypoints. |
| 44 | extern "C" int art_quick_set32_instance_from_code(uint32_t, void*, int32_t); |
| 45 | extern "C" int art_quick_set32_static_from_code(uint32_t, int32_t); |
| 46 | extern "C" int art_quick_set64_instance_from_code(uint32_t, void*, int64_t); |
| 47 | extern "C" int art_quick_set64_static_from_code(uint32_t, int64_t); |
| 48 | extern "C" int art_quick_set_obj_instance_from_code(uint32_t, void*, void*); |
| 49 | extern "C" int art_quick_set_obj_static_from_code(uint32_t, void*); |
| 50 | extern "C" int32_t art_quick_get32_instance_from_code(uint32_t, void*); |
| 51 | extern "C" int32_t art_quick_get32_static_from_code(uint32_t); |
| 52 | extern "C" int64_t art_quick_get64_instance_from_code(uint32_t, void*); |
| 53 | extern "C" int64_t art_quick_get64_static_from_code(uint32_t); |
| 54 | extern "C" void* art_quick_get_obj_instance_from_code(uint32_t, void*); |
| 55 | extern "C" void* art_quick_get_obj_static_from_code(uint32_t); |
| 56 | |
| 57 | // FillArray entrypoint. |
| 58 | extern "C" void art_quick_handle_fill_data_from_code(void*, void*); |
| 59 | |
| 60 | // Lock entrypoints. |
| 61 | extern "C" void art_quick_lock_object_from_code(void*); |
| 62 | extern "C" void art_quick_unlock_object_from_code(void*); |
| 63 | |
| 64 | // Math entrypoints. |
| 65 | extern "C" double art_quick_fmod_from_code(double, double); |
| 66 | extern "C" float art_quick_fmodf_from_code(float, float); |
| 67 | extern "C" double art_quick_l2d_from_code(int64_t); |
| 68 | extern "C" float art_quick_l2f_from_code(int64_t); |
| 69 | extern "C" int64_t art_quick_d2l_from_code(double); |
| 70 | extern "C" int64_t art_quick_f2l_from_code(float); |
| 71 | extern "C" int32_t art_quick_idivmod_from_code(int32_t, int32_t); |
| 72 | extern "C" int64_t art_quick_ldiv_from_code(int64_t, int64_t); |
| 73 | extern "C" int64_t art_quick_ldivmod_from_code(int64_t, int64_t); |
| 74 | extern "C" int64_t art_quick_lmul_from_code(int64_t, int64_t); |
| 75 | extern "C" uint64_t art_quick_lshl_from_code(uint64_t, uint32_t); |
| 76 | extern "C" uint64_t art_quick_lshr_from_code(uint64_t, uint32_t); |
| 77 | extern "C" uint64_t art_quick_lushr_from_code(uint64_t, uint32_t); |
| 78 | |
| 79 | // Interpreter entrypoints. |
| 80 | extern "C" void artInterpreterToInterpreterEntry(Thread* self, MethodHelper& mh, |
| 81 | const DexFile::CodeItem* code_item, |
| 82 | ShadowFrame* shadow_frame, JValue* result); |
| 83 | extern "C" void artInterpreterToQuickEntry(Thread* self, MethodHelper& mh, |
| 84 | const DexFile::CodeItem* code_item, |
| 85 | ShadowFrame* shadow_frame, JValue* result); |
| 86 | |
| 87 | // Intrinsic entrypoints. |
| 88 | extern "C" int32_t art_quick_memcmp16(void*, void*, int32_t); |
| 89 | extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t); |
| 90 | extern "C" int32_t art_quick_string_compareto(void*, void*); |
| 91 | extern "C" void* art_quick_memcpy(void*, const void*, size_t); |
| 92 | |
| 93 | // Invoke entrypoints. |
| 94 | extern "C" const void* artPortableResolutionTrampoline(mirror::AbstractMethod* called, |
| 95 | mirror::Object* receiver, |
| 96 | mirror::AbstractMethod** sp, Thread* thread); |
| 97 | extern "C" const void* artQuickResolutionTrampoline(mirror::AbstractMethod* called, |
| 98 | mirror::Object* receiver, |
| 99 | mirror::AbstractMethod** sp, Thread* thread); |
| 100 | extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*); |
| 101 | extern "C" void art_quick_invoke_interface_trampoline(uint32_t, void*); |
| 102 | extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*); |
| 103 | extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*); |
| 104 | extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*); |
| 105 | extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*); |
| 106 | |
| 107 | // Thread entrypoints. |
| 108 | extern void CheckSuspendFromCode(Thread* thread); |
| 109 | extern "C" void art_quick_test_suspend(); |
| 110 | |
| 111 | // Throw entrypoints. |
| 112 | extern "C" void art_quick_deliver_exception_from_code(void*); |
| 113 | extern "C" void art_quick_throw_array_bounds_from_code(int32_t index, int32_t limit); |
| 114 | extern "C" void art_quick_throw_div_zero_from_code(); |
| 115 | extern "C" void art_quick_throw_no_such_method_from_code(int32_t method_idx); |
| 116 | extern "C" void art_quick_throw_null_pointer_exception_from_code(); |
| 117 | extern "C" void art_quick_throw_stack_overflow_from_code(void*); |
| 118 | |
| 119 | void InitEntryPoints(QuickEntryPoints* qpoints, PortableEntryPoints* ppoints) { |
| 120 | // Alloc |
| 121 | qpoints->pAllocArrayFromCode = art_quick_alloc_array_from_code; |
| 122 | qpoints->pAllocArrayFromCodeWithAccessCheck = art_quick_alloc_array_from_code_with_access_check; |
| 123 | qpoints->pAllocObjectFromCode = art_quick_alloc_object_from_code; |
| 124 | qpoints->pAllocObjectFromCodeWithAccessCheck = art_quick_alloc_object_from_code_with_access_check; |
| 125 | qpoints->pCheckAndAllocArrayFromCode = art_quick_check_and_alloc_array_from_code; |
| 126 | qpoints->pCheckAndAllocArrayFromCodeWithAccessCheck = art_quick_check_and_alloc_array_from_code_with_access_check; |
| 127 | |
| 128 | // Cast |
| 129 | qpoints->pInstanceofNonTrivialFromCode = art_quick_is_assignable_from_code; |
| 130 | qpoints->pCanPutArrayElementFromCode = art_quick_can_put_array_element_from_code; |
| 131 | qpoints->pCheckCastFromCode = art_quick_check_cast_from_code; |
| 132 | |
| 133 | // DexCache |
| 134 | qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage_from_code; |
| 135 | qpoints->pInitializeTypeAndVerifyAccessFromCode = art_quick_initialize_type_and_verify_access_from_code; |
| 136 | qpoints->pInitializeTypeFromCode = art_quick_initialize_type_from_code; |
| 137 | qpoints->pResolveStringFromCode = art_quick_resolve_string_from_code; |
| 138 | |
| 139 | // Field |
| 140 | qpoints->pSet32Instance = art_quick_set32_instance_from_code; |
| 141 | qpoints->pSet32Static = art_quick_set32_static_from_code; |
| 142 | qpoints->pSet64Instance = art_quick_set64_instance_from_code; |
| 143 | qpoints->pSet64Static = art_quick_set64_static_from_code; |
| 144 | qpoints->pSetObjInstance = art_quick_set_obj_instance_from_code; |
| 145 | qpoints->pSetObjStatic = art_quick_set_obj_static_from_code; |
| 146 | qpoints->pGet32Instance = art_quick_get32_instance_from_code; |
| 147 | qpoints->pGet64Instance = art_quick_get64_instance_from_code; |
| 148 | qpoints->pGetObjInstance = art_quick_get_obj_instance_from_code; |
| 149 | qpoints->pGet32Static = art_quick_get32_static_from_code; |
| 150 | qpoints->pGet64Static = art_quick_get64_static_from_code; |
| 151 | qpoints->pGetObjStatic = art_quick_get_obj_static_from_code; |
| 152 | |
| 153 | // FillArray |
| 154 | qpoints->pHandleFillArrayDataFromCode = art_quick_handle_fill_data_from_code; |
| 155 | |
| 156 | // JNI |
| 157 | qpoints->pJniMethodStart = JniMethodStart; |
| 158 | qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized; |
| 159 | qpoints->pJniMethodEnd = JniMethodEnd; |
| 160 | qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized; |
| 161 | qpoints->pJniMethodEndWithReference = JniMethodEndWithReference; |
| 162 | qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized; |
| 163 | |
| 164 | // Locks |
| 165 | qpoints->pLockObjectFromCode = art_quick_lock_object_from_code; |
| 166 | qpoints->pUnlockObjectFromCode = art_quick_unlock_object_from_code; |
| 167 | |
| 168 | // Math |
| 169 | // points->pCmpgDouble = NULL; // Not needed on x86. |
| 170 | // points->pCmpgFloat = NULL; // Not needed on x86. |
| 171 | // points->pCmplDouble = NULL; // Not needed on x86. |
| 172 | // points->pCmplFloat = NULL; // Not needed on x86. |
| 173 | qpoints->pFmod = art_quick_fmod_from_code; |
| 174 | qpoints->pL2d = art_quick_l2d_from_code; |
| 175 | qpoints->pFmodf = art_quick_fmodf_from_code; |
| 176 | qpoints->pL2f = art_quick_l2f_from_code; |
| 177 | // points->pD2iz = NULL; // Not needed on x86. |
| 178 | // points->pF2iz = NULL; // Not needed on x86. |
| 179 | qpoints->pIdivmod = art_quick_idivmod_from_code; |
| 180 | qpoints->pD2l = art_quick_d2l_from_code; |
| 181 | qpoints->pF2l = art_quick_f2l_from_code; |
| 182 | qpoints->pLdiv = art_quick_ldiv_from_code; |
| 183 | qpoints->pLdivmod = art_quick_ldivmod_from_code; |
| 184 | qpoints->pLmul = art_quick_lmul_from_code; |
| 185 | qpoints->pShlLong = art_quick_lshl_from_code; |
| 186 | qpoints->pShrLong = art_quick_lshr_from_code; |
| 187 | qpoints->pUshrLong = art_quick_lushr_from_code; |
| 188 | |
| 189 | // Interpreter |
| 190 | qpoints->pInterpreterToInterpreterEntry = artInterpreterToInterpreterEntry; |
| 191 | qpoints->pInterpreterToQuickEntry = artInterpreterToQuickEntry; |
| 192 | |
| 193 | // Intrinsics |
| 194 | qpoints->pIndexOf = art_quick_indexof; |
| 195 | qpoints->pMemcmp16 = art_quick_memcmp16; |
| 196 | qpoints->pStringCompareTo = art_quick_string_compareto; |
| 197 | qpoints->pMemcpy = art_quick_memcpy; |
| 198 | |
| 199 | // Invocation |
| 200 | qpoints->pQuickResolutionTrampolineFromCode = artQuickResolutionTrampoline; |
| 201 | qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check; |
| 202 | qpoints->pInvokeInterfaceTrampoline = art_quick_invoke_interface_trampoline; |
| 203 | qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check; |
| 204 | qpoints->pInvokeStaticTrampolineWithAccessCheck = art_quick_invoke_static_trampoline_with_access_check; |
| 205 | qpoints->pInvokeSuperTrampolineWithAccessCheck = art_quick_invoke_super_trampoline_with_access_check; |
| 206 | qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check; |
| 207 | |
| 208 | // Thread |
| 209 | qpoints->pCheckSuspendFromCode = CheckSuspendFromCode; |
| 210 | qpoints->pTestSuspendFromCode = art_quick_test_suspend; |
| 211 | |
| 212 | // Throws |
| 213 | qpoints->pDeliverException = art_quick_deliver_exception_from_code; |
| 214 | qpoints->pThrowArrayBoundsFromCode = art_quick_throw_array_bounds_from_code; |
| 215 | qpoints->pThrowDivZeroFromCode = art_quick_throw_div_zero_from_code; |
| 216 | qpoints->pThrowNoSuchMethodFromCode = art_quick_throw_no_such_method_from_code; |
| 217 | qpoints->pThrowNullPointerFromCode = art_quick_throw_null_pointer_exception_from_code; |
| 218 | qpoints->pThrowStackOverflowFromCode = art_quick_throw_stack_overflow_from_code; |
| 219 | |
| 220 | // Portable |
| 221 | ppoints->pPortableResolutionTrampolineFromCode = artPortableResolutionTrampoline; |
| 222 | }; |
| 223 | |
| 224 | } // namespace art |