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