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