blob: 24e9b1d3e4451e72b4f13059af87072e96f04bc0 [file] [log] [blame]
Ian Rogers7655f292013-07-29 11:07:13 -07001/*
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 Rogers848871b2013-08-05 10:56:33 -070017#include "entrypoints/interpreter/interpreter_entrypoints.h"
Mingyao Yang98d1cc82014-05-15 17:02:16 -070018#include "entrypoints/jni/jni_entrypoints.h"
Ian Rogers7655f292013-07-29 11:07:13 -070019#include "entrypoints/portable/portable_entrypoints.h"
Mathieu Chartierd8891782014-03-02 13:28:37 -080020#include "entrypoints/quick/quick_alloc_entrypoints.h"
Ian Rogers7655f292013-07-29 11:07:13 -070021#include "entrypoints/quick/quick_entrypoints.h"
22#include "entrypoints/entrypoint_utils.h"
23#include "entrypoints/math_entrypoints.h"
Ian Rogers6f3dbba2014-10-14 17:41:57 -070024#include "entrypoints/runtime_asm_entrypoints.h"
25#include "interpreter/interpreter.h"
Ian Rogers7655f292013-07-29 11:07:13 -070026
27namespace art {
28
Ian Rogers848871b2013-08-05 10:56:33 -070029// Portable entrypoints.
Brian Carlstromea46f952013-07-30 01:26:50 -070030extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*);
31extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers848871b2013-08-05 10:56:33 -070032
Ian Rogers7655f292013-07-29 11:07:13 -070033// Cast entrypoints.
34extern "C" uint32_t artIsAssignableFromCode(const mirror::Class* klass,
35 const mirror::Class* ref_class);
Ian Rogers848871b2013-08-05 10:56:33 -070036extern "C" void art_quick_check_cast(void*, void*);
Ian Rogers7655f292013-07-29 11:07:13 -070037
38// DexCache entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070039extern "C" void* art_quick_initialize_static_storage(uint32_t, void*);
40extern "C" void* art_quick_initialize_type(uint32_t, void*);
41extern "C" void* art_quick_initialize_type_and_verify_access(uint32_t, void*);
42extern "C" void* art_quick_resolve_string(void*, uint32_t);
Ian Rogers7655f292013-07-29 11:07:13 -070043
Ian Rogers7655f292013-07-29 11:07:13 -070044// Field entrypoints.
Fred Shih37f05ef2014-07-16 18:38:08 -070045extern "C" int art_quick_set8_instance(uint32_t, void*, int8_t);
46extern "C" int art_quick_set8_static(uint32_t, int8_t);
47extern "C" int art_quick_set16_instance(uint32_t, void*, int16_t);
48extern "C" int art_quick_set16_static(uint32_t, int16_t);
Ian Rogers848871b2013-08-05 10:56:33 -070049extern "C" int art_quick_set32_instance(uint32_t, void*, int32_t);
50extern "C" int art_quick_set32_static(uint32_t, int32_t);
51extern "C" int art_quick_set64_instance(uint32_t, void*, int64_t);
52extern "C" int art_quick_set64_static(uint32_t, int64_t);
53extern "C" int art_quick_set_obj_instance(uint32_t, void*, void*);
54extern "C" int art_quick_set_obj_static(uint32_t, void*);
Fred Shih37f05ef2014-07-16 18:38:08 -070055extern "C" int8_t art_quick_get_byte_instance(uint32_t, void*);
56extern "C" uint8_t art_quick_get_boolean_instance(uint32_t, void*);
57extern "C" int8_t art_quick_get_byte_static(uint32_t);
58extern "C" uint8_t art_quick_get_boolean_static(uint32_t);
59extern "C" int16_t art_quick_get_short_instance(uint32_t, void*);
60extern "C" uint16_t art_quick_get_char_instance(uint32_t, void*);
61extern "C" int16_t art_quick_get_short_static(uint32_t);
62extern "C" uint16_t art_quick_get_char_static(uint32_t);
Ian Rogers848871b2013-08-05 10:56:33 -070063extern "C" int32_t art_quick_get32_instance(uint32_t, void*);
64extern "C" int32_t art_quick_get32_static(uint32_t);
65extern "C" int64_t art_quick_get64_instance(uint32_t, void*);
66extern "C" int64_t art_quick_get64_static(uint32_t);
67extern "C" void* art_quick_get_obj_instance(uint32_t, void*);
68extern "C" void* art_quick_get_obj_static(uint32_t);
Ian Rogers7655f292013-07-29 11:07:13 -070069
Ian Rogersa9a82542013-10-04 11:17:26 -070070// Array entrypoints.
71extern "C" void art_quick_aput_obj_with_null_and_bound_check(void*, uint32_t, void*);
72extern "C" void art_quick_aput_obj_with_bound_check(void*, uint32_t, void*);
73extern "C" void art_quick_aput_obj(void*, uint32_t, void*);
Ian Rogers848871b2013-08-05 10:56:33 -070074extern "C" void art_quick_handle_fill_data(void*, void*);
Ian Rogers7655f292013-07-29 11:07:13 -070075
76// Lock entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070077extern "C" void art_quick_lock_object(void*);
78extern "C" void art_quick_unlock_object(void*);
Ian Rogers7655f292013-07-29 11:07:13 -070079
Zheng Xu5667fdb2014-10-23 18:29:55 +080080// Used by soft float.
Ian Rogers7655f292013-07-29 11:07:13 -070081// Single-precision FP arithmetics.
Zheng Xu5667fdb2014-10-23 18:29:55 +080082extern "C" float fmodf(float a, float b); // REM_FLOAT[_2ADDR]
Ian Rogers7655f292013-07-29 11:07:13 -070083// Double-precision FP arithmetics.
Zheng Xu5667fdb2014-10-23 18:29:55 +080084extern "C" double fmod(double a, double b); // REM_DOUBLE[_2ADDR]
85
86// Used by hard float.
87extern "C" int64_t art_quick_f2l(float f); // FLOAT_TO_LONG
88extern "C" int64_t art_quick_d2l(double d); // DOUBLE_TO_LONG
89extern "C" float art_quick_fmodf(float a, float b); // REM_FLOAT[_2ADDR]
90extern "C" double art_quick_fmod(double a, double b); // REM_DOUBLE[_2ADDR]
Ian Rogers7655f292013-07-29 11:07:13 -070091
92// Integer arithmetics.
93extern "C" int __aeabi_idivmod(int32_t, int32_t); // [DIV|REM]_INT[_2ADDR|_LIT8|_LIT16]
94
95// Long long arithmetics - REM_LONG[_2ADDR] and DIV_LONG[_2ADDR]
96extern "C" int64_t __aeabi_ldivmod(int64_t, int64_t);
97extern "C" int64_t art_quick_mul_long(int64_t, int64_t);
98extern "C" uint64_t art_quick_shl_long(uint64_t, uint32_t);
99extern "C" uint64_t art_quick_shr_long(uint64_t, uint32_t);
100extern "C" uint64_t art_quick_ushr_long(uint64_t, uint32_t);
101
Ian Rogers7655f292013-07-29 11:07:13 -0700102// Intrinsic entrypoints.
Ian Rogers7655f292013-07-29 11:07:13 -0700103extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t);
104extern "C" int32_t art_quick_string_compareto(void*, void*);
105
106// Invoke entrypoints.
Jeff Hao88474b42013-10-23 16:24:40 -0700107extern "C" void art_quick_imt_conflict_trampoline(mirror::ArtMethod*);
Brian Carlstromea46f952013-07-30 01:26:50 -0700108extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*);
109extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers7655f292013-07-29 11:07:13 -0700110extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*);
Ian Rogers7655f292013-07-29 11:07:13 -0700111extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*);
112extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*);
113extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*);
114extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*);
115
116// Thread entrypoints.
Ian Rogers7655f292013-07-29 11:07:13 -0700117extern "C" void art_quick_test_suspend();
118
119// Throw entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -0700120extern "C" void art_quick_deliver_exception(void*);
121extern "C" void art_quick_throw_array_bounds(int32_t index, int32_t limit);
122extern "C" void art_quick_throw_div_zero();
123extern "C" void art_quick_throw_no_such_method(int32_t method_idx);
124extern "C" void art_quick_throw_null_pointer_exception();
125extern "C" void art_quick_throw_stack_overflow(void*);
Ian Rogers7655f292013-07-29 11:07:13 -0700126
Andreas Gampe2da88232014-02-27 12:26:20 -0800127// Generic JNI downcall
128extern "C" void art_quick_generic_jni_trampoline(mirror::ArtMethod*);
129
Ian Rogers848871b2013-08-05 10:56:33 -0700130void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints,
131 PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) {
132 // Interpreter
133 ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge;
Dragos Sbirlea08bf1962013-08-12 08:53:04 -0700134 ipoints->pInterpreterToCompiledCodeBridge = artInterpreterToCompiledCodeBridge;
Ian Rogers848871b2013-08-05 10:56:33 -0700135
136 // JNI
137 jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub;
138
139 // Portable
140 ppoints->pPortableResolutionTrampoline = art_portable_resolution_trampoline;
141 ppoints->pPortableToInterpreterBridge = art_portable_to_interpreter_bridge;
142
Ian Rogers7655f292013-07-29 11:07:13 -0700143 // Alloc
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700144 ResetQuickAllocEntryPoints(qpoints);
Ian Rogers7655f292013-07-29 11:07:13 -0700145
146 // Cast
Ian Rogers848871b2013-08-05 10:56:33 -0700147 qpoints->pInstanceofNonTrivial = artIsAssignableFromCode;
Ian Rogers848871b2013-08-05 10:56:33 -0700148 qpoints->pCheckCast = art_quick_check_cast;
Ian Rogers7655f292013-07-29 11:07:13 -0700149
150 // DexCache
Ian Rogers848871b2013-08-05 10:56:33 -0700151 qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage;
152 qpoints->pInitializeTypeAndVerifyAccess = art_quick_initialize_type_and_verify_access;
153 qpoints->pInitializeType = art_quick_initialize_type;
154 qpoints->pResolveString = art_quick_resolve_string;
Ian Rogers7655f292013-07-29 11:07:13 -0700155
156 // Field
Fred Shih37f05ef2014-07-16 18:38:08 -0700157 qpoints->pSet8Instance = art_quick_set8_instance;
158 qpoints->pSet8Static = art_quick_set8_static;
159 qpoints->pSet16Instance = art_quick_set16_instance;
160 qpoints->pSet16Static = art_quick_set16_static;
Ian Rogers848871b2013-08-05 10:56:33 -0700161 qpoints->pSet32Instance = art_quick_set32_instance;
162 qpoints->pSet32Static = art_quick_set32_static;
163 qpoints->pSet64Instance = art_quick_set64_instance;
164 qpoints->pSet64Static = art_quick_set64_static;
165 qpoints->pSetObjInstance = art_quick_set_obj_instance;
166 qpoints->pSetObjStatic = art_quick_set_obj_static;
Fred Shih37f05ef2014-07-16 18:38:08 -0700167 qpoints->pGetByteInstance = art_quick_get_byte_instance;
168 qpoints->pGetBooleanInstance = art_quick_get_boolean_instance;
169 qpoints->pGetShortInstance = art_quick_get_short_instance;
170 qpoints->pGetCharInstance = art_quick_get_char_instance;
Ian Rogers848871b2013-08-05 10:56:33 -0700171 qpoints->pGet32Instance = art_quick_get32_instance;
172 qpoints->pGet64Instance = art_quick_get64_instance;
173 qpoints->pGetObjInstance = art_quick_get_obj_instance;
Fred Shih37f05ef2014-07-16 18:38:08 -0700174 qpoints->pGetByteStatic = art_quick_get_byte_static;
175 qpoints->pGetBooleanStatic = art_quick_get_boolean_static;
176 qpoints->pGetShortStatic = art_quick_get_short_static;
177 qpoints->pGetCharStatic = art_quick_get_char_static;
Ian Rogers848871b2013-08-05 10:56:33 -0700178 qpoints->pGet32Static = art_quick_get32_static;
179 qpoints->pGet64Static = art_quick_get64_static;
180 qpoints->pGetObjStatic = art_quick_get_obj_static;
Ian Rogers7655f292013-07-29 11:07:13 -0700181
Ian Rogersa9a82542013-10-04 11:17:26 -0700182 // Array
183 qpoints->pAputObjectWithNullAndBoundCheck = art_quick_aput_obj_with_null_and_bound_check;
184 qpoints->pAputObjectWithBoundCheck = art_quick_aput_obj_with_bound_check;
185 qpoints->pAputObject = art_quick_aput_obj;
Ian Rogers848871b2013-08-05 10:56:33 -0700186 qpoints->pHandleFillArrayData = art_quick_handle_fill_data;
Ian Rogers7655f292013-07-29 11:07:13 -0700187
188 // JNI
189 qpoints->pJniMethodStart = JniMethodStart;
190 qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized;
191 qpoints->pJniMethodEnd = JniMethodEnd;
192 qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized;
193 qpoints->pJniMethodEndWithReference = JniMethodEndWithReference;
194 qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized;
Andreas Gampe2da88232014-02-27 12:26:20 -0800195 qpoints->pQuickGenericJniTrampoline = art_quick_generic_jni_trampoline;
Ian Rogers7655f292013-07-29 11:07:13 -0700196
197 // Locks
Ian Rogers848871b2013-08-05 10:56:33 -0700198 qpoints->pLockObject = art_quick_lock_object;
199 qpoints->pUnlockObject = art_quick_unlock_object;
Ian Rogers7655f292013-07-29 11:07:13 -0700200
201 // Math
Ian Rogers7655f292013-07-29 11:07:13 -0700202 qpoints->pIdivmod = __aeabi_idivmod;
Ian Rogers7655f292013-07-29 11:07:13 -0700203 qpoints->pLdiv = __aeabi_ldivmod;
Ian Rogersa9a82542013-10-04 11:17:26 -0700204 qpoints->pLmod = __aeabi_ldivmod; // result returned in r2:r3
Ian Rogers7655f292013-07-29 11:07:13 -0700205 qpoints->pLmul = art_quick_mul_long;
206 qpoints->pShlLong = art_quick_shl_long;
207 qpoints->pShrLong = art_quick_shr_long;
208 qpoints->pUshrLong = art_quick_ushr_long;
Zheng Xu5667fdb2014-10-23 18:29:55 +0800209 if (kArm32QuickCodeUseSoftFloat) {
210 qpoints->pFmod = fmod;
211 qpoints->pFmodf = fmodf;
212 qpoints->pD2l = art_d2l;
213 qpoints->pF2l = art_f2l;
214 } else {
215 qpoints->pFmod = art_quick_fmod;
216 qpoints->pFmodf = art_quick_fmodf;
217 qpoints->pD2l = art_quick_d2l;
218 qpoints->pF2l = art_quick_f2l;
219 }
Ian Rogers7655f292013-07-29 11:07:13 -0700220
Ian Rogers7655f292013-07-29 11:07:13 -0700221 // Intrinsics
222 qpoints->pIndexOf = art_quick_indexof;
Ian Rogers7655f292013-07-29 11:07:13 -0700223 qpoints->pStringCompareTo = art_quick_string_compareto;
224 qpoints->pMemcpy = memcpy;
225
226 // Invocation
Jeff Hao88474b42013-10-23 16:24:40 -0700227 qpoints->pQuickImtConflictTrampoline = art_quick_imt_conflict_trampoline;
Ian Rogers848871b2013-08-05 10:56:33 -0700228 qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline;
229 qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge;
Ian Rogers7655f292013-07-29 11:07:13 -0700230 qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check;
Ian Rogers7655f292013-07-29 11:07:13 -0700231 qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check;
232 qpoints->pInvokeStaticTrampolineWithAccessCheck = art_quick_invoke_static_trampoline_with_access_check;
233 qpoints->pInvokeSuperTrampolineWithAccessCheck = art_quick_invoke_super_trampoline_with_access_check;
234 qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check;
235
236 // Thread
Ian Rogers848871b2013-08-05 10:56:33 -0700237 qpoints->pTestSuspend = art_quick_test_suspend;
Ian Rogers7655f292013-07-29 11:07:13 -0700238
239 // Throws
Ian Rogers848871b2013-08-05 10:56:33 -0700240 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;
Andreas Gampec8ccf682014-09-29 20:07:43 -0700246}
Ian Rogers7655f292013-07-29 11:07:13 -0700247
248} // namespace art