blob: d7d13c22236d31a1c071dab5761e52758ace2ff6 [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 "interpreter/interpreter.h"
Ian Rogers7655f292013-07-29 11:07:13 -070025
26namespace art {
27
Ian Rogers848871b2013-08-05 10:56:33 -070028// Portable entrypoints.
Brian Carlstromea46f952013-07-30 01:26:50 -070029extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*);
30extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers848871b2013-08-05 10:56:33 -070031
Ian Rogers7655f292013-07-29 11:07:13 -070032// Cast entrypoints.
33extern "C" uint32_t artIsAssignableFromCode(const mirror::Class* klass,
34 const mirror::Class* ref_class);
Ian Rogers848871b2013-08-05 10:56:33 -070035extern "C" void art_quick_check_cast(void*, void*);
Ian Rogers7655f292013-07-29 11:07:13 -070036
37// DexCache entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070038extern "C" void* art_quick_initialize_static_storage(uint32_t, void*);
39extern "C" void* art_quick_initialize_type(uint32_t, void*);
40extern "C" void* art_quick_initialize_type_and_verify_access(uint32_t, void*);
41extern "C" void* art_quick_resolve_string(void*, uint32_t);
Ian Rogers7655f292013-07-29 11:07:13 -070042
Ian Rogers7655f292013-07-29 11:07:13 -070043// Field entrypoints.
Fred Shih37f05ef2014-07-16 18:38:08 -070044extern "C" int art_quick_set8_instance(uint32_t, void*, int8_t);
45extern "C" int art_quick_set8_static(uint32_t, int8_t);
46extern "C" int art_quick_set16_instance(uint32_t, void*, int16_t);
47extern "C" int art_quick_set16_static(uint32_t, int16_t);
Ian Rogers848871b2013-08-05 10:56:33 -070048extern "C" int art_quick_set32_instance(uint32_t, void*, int32_t);
49extern "C" int art_quick_set32_static(uint32_t, int32_t);
50extern "C" int art_quick_set64_instance(uint32_t, void*, int64_t);
51extern "C" int art_quick_set64_static(uint32_t, int64_t);
52extern "C" int art_quick_set_obj_instance(uint32_t, void*, void*);
53extern "C" int art_quick_set_obj_static(uint32_t, void*);
Fred Shih37f05ef2014-07-16 18:38:08 -070054extern "C" int8_t art_quick_get_byte_instance(uint32_t, void*);
55extern "C" uint8_t art_quick_get_boolean_instance(uint32_t, void*);
56extern "C" int8_t art_quick_get_byte_static(uint32_t);
57extern "C" uint8_t art_quick_get_boolean_static(uint32_t);
58extern "C" int16_t art_quick_get_short_instance(uint32_t, void*);
59extern "C" uint16_t art_quick_get_char_instance(uint32_t, void*);
60extern "C" int16_t art_quick_get_short_static(uint32_t);
61extern "C" uint16_t art_quick_get_char_static(uint32_t);
Ian Rogers848871b2013-08-05 10:56:33 -070062extern "C" int32_t art_quick_get32_instance(uint32_t, void*);
63extern "C" int32_t art_quick_get32_static(uint32_t);
64extern "C" int64_t art_quick_get64_instance(uint32_t, void*);
65extern "C" int64_t art_quick_get64_static(uint32_t);
66extern "C" void* art_quick_get_obj_instance(uint32_t, void*);
67extern "C" void* art_quick_get_obj_static(uint32_t);
Ian Rogers7655f292013-07-29 11:07:13 -070068
Ian Rogersa9a82542013-10-04 11:17:26 -070069// Array entrypoints.
70extern "C" void art_quick_aput_obj_with_null_and_bound_check(void*, uint32_t, void*);
71extern "C" void art_quick_aput_obj_with_bound_check(void*, uint32_t, void*);
72extern "C" void art_quick_aput_obj(void*, uint32_t, void*);
Ian Rogers848871b2013-08-05 10:56:33 -070073extern "C" void art_quick_handle_fill_data(void*, void*);
Ian Rogers7655f292013-07-29 11:07:13 -070074
75// Lock entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070076extern "C" void art_quick_lock_object(void*);
77extern "C" void art_quick_unlock_object(void*);
Ian Rogers7655f292013-07-29 11:07:13 -070078
Zheng Xu5667fdb2014-10-23 18:29:55 +080079// Used by soft float.
Ian Rogers7655f292013-07-29 11:07:13 -070080// Single-precision FP arithmetics.
Zheng Xu5667fdb2014-10-23 18:29:55 +080081extern "C" float fmodf(float a, float b); // REM_FLOAT[_2ADDR]
Ian Rogers7655f292013-07-29 11:07:13 -070082// Double-precision FP arithmetics.
Zheng Xu5667fdb2014-10-23 18:29:55 +080083extern "C" double fmod(double a, double b); // REM_DOUBLE[_2ADDR]
84
85// Used by hard float.
86extern "C" int64_t art_quick_f2l(float f); // FLOAT_TO_LONG
87extern "C" int64_t art_quick_d2l(double d); // DOUBLE_TO_LONG
88extern "C" float art_quick_fmodf(float a, float b); // REM_FLOAT[_2ADDR]
89extern "C" double art_quick_fmod(double a, double b); // REM_DOUBLE[_2ADDR]
Ian Rogers7655f292013-07-29 11:07:13 -070090
91// Integer arithmetics.
92extern "C" int __aeabi_idivmod(int32_t, int32_t); // [DIV|REM]_INT[_2ADDR|_LIT8|_LIT16]
93
94// Long long arithmetics - REM_LONG[_2ADDR] and DIV_LONG[_2ADDR]
95extern "C" int64_t __aeabi_ldivmod(int64_t, int64_t);
96extern "C" int64_t art_quick_mul_long(int64_t, int64_t);
97extern "C" uint64_t art_quick_shl_long(uint64_t, uint32_t);
98extern "C" uint64_t art_quick_shr_long(uint64_t, uint32_t);
99extern "C" uint64_t art_quick_ushr_long(uint64_t, uint32_t);
100
Ian Rogers7655f292013-07-29 11:07:13 -0700101// Intrinsic entrypoints.
Ian Rogers7655f292013-07-29 11:07:13 -0700102extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t);
103extern "C" int32_t art_quick_string_compareto(void*, void*);
104
105// Invoke entrypoints.
Jeff Hao88474b42013-10-23 16:24:40 -0700106extern "C" void art_quick_imt_conflict_trampoline(mirror::ArtMethod*);
Brian Carlstromea46f952013-07-30 01:26:50 -0700107extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*);
108extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers7655f292013-07-29 11:07:13 -0700109extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*);
Ian Rogers7655f292013-07-29 11:07:13 -0700110extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*);
111extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*);
112extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*);
113extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*);
114
115// Thread entrypoints.
Ian Rogers7655f292013-07-29 11:07:13 -0700116extern "C" void art_quick_test_suspend();
117
118// Throw entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -0700119extern "C" void art_quick_deliver_exception(void*);
120extern "C" void art_quick_throw_array_bounds(int32_t index, int32_t limit);
121extern "C" void art_quick_throw_div_zero();
122extern "C" void art_quick_throw_no_such_method(int32_t method_idx);
123extern "C" void art_quick_throw_null_pointer_exception();
124extern "C" void art_quick_throw_stack_overflow(void*);
Ian Rogers7655f292013-07-29 11:07:13 -0700125
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800126// Generic JNI downcall.
Andreas Gampe2da88232014-02-27 12:26:20 -0800127extern "C" void art_quick_generic_jni_trampoline(mirror::ArtMethod*);
128
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800129// JNI resolution.
130extern "C" void* art_jni_dlsym_lookup_stub(JNIEnv*, jobject);
131
Ian Rogers848871b2013-08-05 10:56:33 -0700132void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints,
133 PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) {
134 // Interpreter
135 ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge;
Dragos Sbirlea08bf1962013-08-12 08:53:04 -0700136 ipoints->pInterpreterToCompiledCodeBridge = artInterpreterToCompiledCodeBridge;
Ian Rogers848871b2013-08-05 10:56:33 -0700137
138 // JNI
139 jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub;
140
141 // Portable
142 ppoints->pPortableResolutionTrampoline = art_portable_resolution_trampoline;
143 ppoints->pPortableToInterpreterBridge = art_portable_to_interpreter_bridge;
144
Ian Rogers7655f292013-07-29 11:07:13 -0700145 // Alloc
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700146 ResetQuickAllocEntryPoints(qpoints);
Ian Rogers7655f292013-07-29 11:07:13 -0700147
148 // Cast
Ian Rogers848871b2013-08-05 10:56:33 -0700149 qpoints->pInstanceofNonTrivial = artIsAssignableFromCode;
Ian Rogers848871b2013-08-05 10:56:33 -0700150 qpoints->pCheckCast = art_quick_check_cast;
Ian Rogers7655f292013-07-29 11:07:13 -0700151
152 // DexCache
Ian Rogers848871b2013-08-05 10:56:33 -0700153 qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage;
154 qpoints->pInitializeTypeAndVerifyAccess = art_quick_initialize_type_and_verify_access;
155 qpoints->pInitializeType = art_quick_initialize_type;
156 qpoints->pResolveString = art_quick_resolve_string;
Ian Rogers7655f292013-07-29 11:07:13 -0700157
158 // Field
Fred Shih37f05ef2014-07-16 18:38:08 -0700159 qpoints->pSet8Instance = art_quick_set8_instance;
160 qpoints->pSet8Static = art_quick_set8_static;
161 qpoints->pSet16Instance = art_quick_set16_instance;
162 qpoints->pSet16Static = art_quick_set16_static;
Ian Rogers848871b2013-08-05 10:56:33 -0700163 qpoints->pSet32Instance = art_quick_set32_instance;
164 qpoints->pSet32Static = art_quick_set32_static;
165 qpoints->pSet64Instance = art_quick_set64_instance;
166 qpoints->pSet64Static = art_quick_set64_static;
167 qpoints->pSetObjInstance = art_quick_set_obj_instance;
168 qpoints->pSetObjStatic = art_quick_set_obj_static;
Fred Shih37f05ef2014-07-16 18:38:08 -0700169 qpoints->pGetByteInstance = art_quick_get_byte_instance;
170 qpoints->pGetBooleanInstance = art_quick_get_boolean_instance;
171 qpoints->pGetShortInstance = art_quick_get_short_instance;
172 qpoints->pGetCharInstance = art_quick_get_char_instance;
Ian Rogers848871b2013-08-05 10:56:33 -0700173 qpoints->pGet32Instance = art_quick_get32_instance;
174 qpoints->pGet64Instance = art_quick_get64_instance;
175 qpoints->pGetObjInstance = art_quick_get_obj_instance;
Fred Shih37f05ef2014-07-16 18:38:08 -0700176 qpoints->pGetByteStatic = art_quick_get_byte_static;
177 qpoints->pGetBooleanStatic = art_quick_get_boolean_static;
178 qpoints->pGetShortStatic = art_quick_get_short_static;
179 qpoints->pGetCharStatic = art_quick_get_char_static;
Ian Rogers848871b2013-08-05 10:56:33 -0700180 qpoints->pGet32Static = art_quick_get32_static;
181 qpoints->pGet64Static = art_quick_get64_static;
182 qpoints->pGetObjStatic = art_quick_get_obj_static;
Ian Rogers7655f292013-07-29 11:07:13 -0700183
Ian Rogersa9a82542013-10-04 11:17:26 -0700184 // Array
185 qpoints->pAputObjectWithNullAndBoundCheck = art_quick_aput_obj_with_null_and_bound_check;
186 qpoints->pAputObjectWithBoundCheck = art_quick_aput_obj_with_bound_check;
187 qpoints->pAputObject = art_quick_aput_obj;
Ian Rogers848871b2013-08-05 10:56:33 -0700188 qpoints->pHandleFillArrayData = art_quick_handle_fill_data;
Ian Rogers7655f292013-07-29 11:07:13 -0700189
190 // JNI
191 qpoints->pJniMethodStart = JniMethodStart;
192 qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized;
193 qpoints->pJniMethodEnd = JniMethodEnd;
194 qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized;
195 qpoints->pJniMethodEndWithReference = JniMethodEndWithReference;
196 qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized;
Andreas Gampe2da88232014-02-27 12:26:20 -0800197 qpoints->pQuickGenericJniTrampoline = art_quick_generic_jni_trampoline;
Ian Rogers7655f292013-07-29 11:07:13 -0700198
199 // Locks
Ian Rogers848871b2013-08-05 10:56:33 -0700200 qpoints->pLockObject = art_quick_lock_object;
201 qpoints->pUnlockObject = art_quick_unlock_object;
Ian Rogers7655f292013-07-29 11:07:13 -0700202
203 // Math
Ian Rogers7655f292013-07-29 11:07:13 -0700204 qpoints->pIdivmod = __aeabi_idivmod;
Ian Rogers7655f292013-07-29 11:07:13 -0700205 qpoints->pLdiv = __aeabi_ldivmod;
Ian Rogersa9a82542013-10-04 11:17:26 -0700206 qpoints->pLmod = __aeabi_ldivmod; // result returned in r2:r3
Ian Rogers7655f292013-07-29 11:07:13 -0700207 qpoints->pLmul = art_quick_mul_long;
208 qpoints->pShlLong = art_quick_shl_long;
209 qpoints->pShrLong = art_quick_shr_long;
210 qpoints->pUshrLong = art_quick_ushr_long;
Zheng Xu5667fdb2014-10-23 18:29:55 +0800211 if (kArm32QuickCodeUseSoftFloat) {
212 qpoints->pFmod = fmod;
213 qpoints->pFmodf = fmodf;
214 qpoints->pD2l = art_d2l;
215 qpoints->pF2l = art_f2l;
216 } else {
217 qpoints->pFmod = art_quick_fmod;
218 qpoints->pFmodf = art_quick_fmodf;
219 qpoints->pD2l = art_quick_d2l;
220 qpoints->pF2l = art_quick_f2l;
221 }
Ian Rogers7655f292013-07-29 11:07:13 -0700222
Ian Rogers7655f292013-07-29 11:07:13 -0700223 // Intrinsics
224 qpoints->pIndexOf = art_quick_indexof;
Ian Rogers7655f292013-07-29 11:07:13 -0700225 qpoints->pStringCompareTo = art_quick_string_compareto;
226 qpoints->pMemcpy = memcpy;
227
228 // Invocation
Jeff Hao88474b42013-10-23 16:24:40 -0700229 qpoints->pQuickImtConflictTrampoline = art_quick_imt_conflict_trampoline;
Ian Rogers848871b2013-08-05 10:56:33 -0700230 qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline;
231 qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge;
Ian Rogers7655f292013-07-29 11:07:13 -0700232 qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check;
Ian Rogers7655f292013-07-29 11:07:13 -0700233 qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check;
234 qpoints->pInvokeStaticTrampolineWithAccessCheck = art_quick_invoke_static_trampoline_with_access_check;
235 qpoints->pInvokeSuperTrampolineWithAccessCheck = art_quick_invoke_super_trampoline_with_access_check;
236 qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check;
237
238 // Thread
Ian Rogers848871b2013-08-05 10:56:33 -0700239 qpoints->pTestSuspend = art_quick_test_suspend;
Ian Rogers7655f292013-07-29 11:07:13 -0700240
241 // Throws
Ian Rogers848871b2013-08-05 10:56:33 -0700242 qpoints->pDeliverException = art_quick_deliver_exception;
243 qpoints->pThrowArrayBounds = art_quick_throw_array_bounds;
244 qpoints->pThrowDivZero = art_quick_throw_div_zero;
245 qpoints->pThrowNoSuchMethod = art_quick_throw_no_such_method;
246 qpoints->pThrowNullPointer = art_quick_throw_null_pointer_exception;
247 qpoints->pThrowStackOverflow = art_quick_throw_stack_overflow;
Andreas Gampec8ccf682014-09-29 20:07:43 -0700248}
Ian Rogers7655f292013-07-29 11:07:13 -0700249
250} // namespace art