blob: fc85ae370c3924b5bd7ec90f4cb18b83cc05db29 [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"
Ian Rogers7655f292013-07-29 11:07:13 -070018#include "entrypoints/portable/portable_entrypoints.h"
19#include "entrypoints/quick/quick_entrypoints.h"
20#include "entrypoints/entrypoint_utils.h"
21#include "entrypoints/math_entrypoints.h"
22
23namespace art {
24
Ian Rogers848871b2013-08-05 10:56:33 -070025// Interpreter entrypoints.
26extern "C" void artInterpreterToInterpreterBridge(Thread* self, MethodHelper& mh,
27 const DexFile::CodeItem* code_item,
28 ShadowFrame* shadow_frame, JValue* result);
Dragos Sbirlea08bf1962013-08-12 08:53:04 -070029extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& mh,
Ian Rogers848871b2013-08-05 10:56:33 -070030 const DexFile::CodeItem* code_item,
31 ShadowFrame* shadow_frame, JValue* result);
32
33// Portable entrypoints.
Brian Carlstromea46f952013-07-30 01:26:50 -070034extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*);
35extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers848871b2013-08-05 10:56:33 -070036
Ian Rogers7655f292013-07-29 11:07:13 -070037// Cast entrypoints.
38extern "C" uint32_t artIsAssignableFromCode(const mirror::Class* klass,
39 const mirror::Class* ref_class);
Ian Rogers848871b2013-08-05 10:56:33 -070040extern "C" void art_quick_check_cast(void*, void*);
Ian Rogers7655f292013-07-29 11:07:13 -070041
42// DexCache entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070043extern "C" void* art_quick_initialize_static_storage(uint32_t, void*);
44extern "C" void* art_quick_initialize_type(uint32_t, void*);
45extern "C" void* art_quick_initialize_type_and_verify_access(uint32_t, void*);
46extern "C" void* art_quick_resolve_string(void*, uint32_t);
Ian Rogers7655f292013-07-29 11:07:13 -070047
48// Exception entrypoints.
49extern "C" void* GetAndClearException(Thread*);
50
51// Field entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070052extern "C" int art_quick_set32_instance(uint32_t, void*, int32_t);
53extern "C" int art_quick_set32_static(uint32_t, int32_t);
54extern "C" int art_quick_set64_instance(uint32_t, void*, int64_t);
55extern "C" int art_quick_set64_static(uint32_t, int64_t);
56extern "C" int art_quick_set_obj_instance(uint32_t, void*, void*);
57extern "C" int art_quick_set_obj_static(uint32_t, void*);
58extern "C" int32_t art_quick_get32_instance(uint32_t, void*);
59extern "C" int32_t art_quick_get32_static(uint32_t);
60extern "C" int64_t art_quick_get64_instance(uint32_t, void*);
61extern "C" int64_t art_quick_get64_static(uint32_t);
62extern "C" void* art_quick_get_obj_instance(uint32_t, void*);
63extern "C" void* art_quick_get_obj_static(uint32_t);
Ian Rogers7655f292013-07-29 11:07:13 -070064
Ian Rogersa9a82542013-10-04 11:17:26 -070065// Array entrypoints.
66extern "C" void art_quick_aput_obj_with_null_and_bound_check(void*, uint32_t, void*);
67extern "C" void art_quick_aput_obj_with_bound_check(void*, uint32_t, void*);
68extern "C" void art_quick_aput_obj(void*, uint32_t, void*);
Ian Rogers848871b2013-08-05 10:56:33 -070069extern "C" void art_quick_handle_fill_data(void*, void*);
Ian Rogers7655f292013-07-29 11:07:13 -070070
71// Lock entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070072extern "C" void art_quick_lock_object(void*);
73extern "C" void art_quick_unlock_object(void*);
Ian Rogers7655f292013-07-29 11:07:13 -070074
75// Math entrypoints.
76extern int32_t CmpgDouble(double a, double b);
77extern int32_t CmplDouble(double a, double b);
78extern int32_t CmpgFloat(float a, float b);
79extern int32_t CmplFloat(float a, float b);
80
81// Math conversions.
82extern "C" int32_t __aeabi_f2iz(float op1); // FLOAT_TO_INT
83extern "C" int32_t __aeabi_d2iz(double op1); // DOUBLE_TO_INT
84extern "C" float __aeabi_l2f(int64_t op1); // LONG_TO_FLOAT
85extern "C" double __aeabi_l2d(int64_t op1); // LONG_TO_DOUBLE
86
87// Single-precision FP arithmetics.
88extern "C" float fmodf(float a, float b); // REM_FLOAT[_2ADDR]
89
90// Double-precision FP arithmetics.
91extern "C" double fmod(double a, double b); // REM_DOUBLE[_2ADDR]
92
93// Integer arithmetics.
94extern "C" int __aeabi_idivmod(int32_t, int32_t); // [DIV|REM]_INT[_2ADDR|_LIT8|_LIT16]
95
96// Long long arithmetics - REM_LONG[_2ADDR] and DIV_LONG[_2ADDR]
97extern "C" int64_t __aeabi_ldivmod(int64_t, int64_t);
98extern "C" int64_t art_quick_mul_long(int64_t, int64_t);
99extern "C" uint64_t art_quick_shl_long(uint64_t, uint32_t);
100extern "C" uint64_t art_quick_shr_long(uint64_t, uint32_t);
101extern "C" uint64_t art_quick_ushr_long(uint64_t, uint32_t);
102
Ian Rogers7655f292013-07-29 11:07:13 -0700103// Intrinsic entrypoints.
104extern "C" int32_t __memcmp16(void*, void*, int32_t);
105extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t);
106extern "C" int32_t art_quick_string_compareto(void*, void*);
107
108// Invoke entrypoints.
Jeff Hao88474b42013-10-23 16:24:40 -0700109extern "C" void art_quick_imt_conflict_trampoline(mirror::ArtMethod*);
Brian Carlstromea46f952013-07-30 01:26:50 -0700110extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*);
111extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers7655f292013-07-29 11:07:13 -0700112extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*);
Ian Rogers7655f292013-07-29 11:07:13 -0700113extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*);
114extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*);
115extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*);
116extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*);
117
118// Thread entrypoints.
119extern void CheckSuspendFromCode(Thread* thread);
120extern "C" void art_quick_test_suspend();
121
122// Throw entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -0700123extern "C" void art_quick_deliver_exception(void*);
124extern "C" void art_quick_throw_array_bounds(int32_t index, int32_t limit);
125extern "C" void art_quick_throw_div_zero();
126extern "C" void art_quick_throw_no_such_method(int32_t method_idx);
127extern "C" void art_quick_throw_null_pointer_exception();
128extern "C" void art_quick_throw_stack_overflow(void*);
Ian Rogers7655f292013-07-29 11:07:13 -0700129
Andreas Gampe2da88232014-02-27 12:26:20 -0800130// Generic JNI downcall
131extern "C" void art_quick_generic_jni_trampoline(mirror::ArtMethod*);
132
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800133extern void ResetQuickAllocEntryPoints(QuickEntryPoints* qpoints);
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700134
Ian Rogers848871b2013-08-05 10:56:33 -0700135void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints,
136 PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) {
137 // Interpreter
138 ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge;
Dragos Sbirlea08bf1962013-08-12 08:53:04 -0700139 ipoints->pInterpreterToCompiledCodeBridge = artInterpreterToCompiledCodeBridge;
Ian Rogers848871b2013-08-05 10:56:33 -0700140
141 // JNI
142 jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub;
143
144 // Portable
145 ppoints->pPortableResolutionTrampoline = art_portable_resolution_trampoline;
146 ppoints->pPortableToInterpreterBridge = art_portable_to_interpreter_bridge;
147
Ian Rogers7655f292013-07-29 11:07:13 -0700148 // Alloc
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700149 ResetQuickAllocEntryPoints(qpoints);
Ian Rogers7655f292013-07-29 11:07:13 -0700150
151 // Cast
Ian Rogers848871b2013-08-05 10:56:33 -0700152 qpoints->pInstanceofNonTrivial = artIsAssignableFromCode;
Ian Rogers848871b2013-08-05 10:56:33 -0700153 qpoints->pCheckCast = art_quick_check_cast;
Ian Rogers7655f292013-07-29 11:07:13 -0700154
155 // DexCache
Ian Rogers848871b2013-08-05 10:56:33 -0700156 qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage;
157 qpoints->pInitializeTypeAndVerifyAccess = art_quick_initialize_type_and_verify_access;
158 qpoints->pInitializeType = art_quick_initialize_type;
159 qpoints->pResolveString = art_quick_resolve_string;
Ian Rogers7655f292013-07-29 11:07:13 -0700160
161 // Field
Ian Rogers848871b2013-08-05 10:56:33 -0700162 qpoints->pSet32Instance = art_quick_set32_instance;
163 qpoints->pSet32Static = art_quick_set32_static;
164 qpoints->pSet64Instance = art_quick_set64_instance;
165 qpoints->pSet64Static = art_quick_set64_static;
166 qpoints->pSetObjInstance = art_quick_set_obj_instance;
167 qpoints->pSetObjStatic = art_quick_set_obj_static;
168 qpoints->pGet32Instance = art_quick_get32_instance;
169 qpoints->pGet64Instance = art_quick_get64_instance;
170 qpoints->pGetObjInstance = art_quick_get_obj_instance;
171 qpoints->pGet32Static = art_quick_get32_static;
172 qpoints->pGet64Static = art_quick_get64_static;
173 qpoints->pGetObjStatic = art_quick_get_obj_static;
Ian Rogers7655f292013-07-29 11:07:13 -0700174
Ian Rogersa9a82542013-10-04 11:17:26 -0700175 // Array
176 qpoints->pAputObjectWithNullAndBoundCheck = art_quick_aput_obj_with_null_and_bound_check;
177 qpoints->pAputObjectWithBoundCheck = art_quick_aput_obj_with_bound_check;
178 qpoints->pAputObject = art_quick_aput_obj;
Ian Rogers848871b2013-08-05 10:56:33 -0700179 qpoints->pHandleFillArrayData = art_quick_handle_fill_data;
Ian Rogers7655f292013-07-29 11:07:13 -0700180
181 // JNI
182 qpoints->pJniMethodStart = JniMethodStart;
183 qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized;
184 qpoints->pJniMethodEnd = JniMethodEnd;
185 qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized;
186 qpoints->pJniMethodEndWithReference = JniMethodEndWithReference;
187 qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized;
Andreas Gampe2da88232014-02-27 12:26:20 -0800188 qpoints->pQuickGenericJniTrampoline = art_quick_generic_jni_trampoline;
Ian Rogers7655f292013-07-29 11:07:13 -0700189
190 // Locks
Ian Rogers848871b2013-08-05 10:56:33 -0700191 qpoints->pLockObject = art_quick_lock_object;
192 qpoints->pUnlockObject = art_quick_unlock_object;
Ian Rogers7655f292013-07-29 11:07:13 -0700193
194 // Math
195 qpoints->pCmpgDouble = CmpgDouble;
196 qpoints->pCmpgFloat = CmpgFloat;
197 qpoints->pCmplDouble = CmplDouble;
198 qpoints->pCmplFloat = CmplFloat;
199 qpoints->pFmod = fmod;
200 qpoints->pSqrt = sqrt;
201 qpoints->pL2d = __aeabi_l2d;
202 qpoints->pFmodf = fmodf;
203 qpoints->pL2f = __aeabi_l2f;
204 qpoints->pD2iz = __aeabi_d2iz;
205 qpoints->pF2iz = __aeabi_f2iz;
206 qpoints->pIdivmod = __aeabi_idivmod;
207 qpoints->pD2l = art_d2l;
208 qpoints->pF2l = art_f2l;
209 qpoints->pLdiv = __aeabi_ldivmod;
Ian Rogersa9a82542013-10-04 11:17:26 -0700210 qpoints->pLmod = __aeabi_ldivmod; // result returned in r2:r3
Ian Rogers7655f292013-07-29 11:07:13 -0700211 qpoints->pLmul = art_quick_mul_long;
212 qpoints->pShlLong = art_quick_shl_long;
213 qpoints->pShrLong = art_quick_shr_long;
214 qpoints->pUshrLong = art_quick_ushr_long;
215
Ian Rogers7655f292013-07-29 11:07:13 -0700216 // Intrinsics
217 qpoints->pIndexOf = art_quick_indexof;
218 qpoints->pMemcmp16 = __memcmp16;
219 qpoints->pStringCompareTo = art_quick_string_compareto;
220 qpoints->pMemcpy = memcpy;
221
222 // Invocation
Jeff Hao88474b42013-10-23 16:24:40 -0700223 qpoints->pQuickImtConflictTrampoline = art_quick_imt_conflict_trampoline;
Ian Rogers848871b2013-08-05 10:56:33 -0700224 qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline;
225 qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge;
Ian Rogers7655f292013-07-29 11:07:13 -0700226 qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check;
Ian Rogers7655f292013-07-29 11:07:13 -0700227 qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check;
228 qpoints->pInvokeStaticTrampolineWithAccessCheck = art_quick_invoke_static_trampoline_with_access_check;
229 qpoints->pInvokeSuperTrampolineWithAccessCheck = art_quick_invoke_super_trampoline_with_access_check;
230 qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check;
231
232 // Thread
Ian Rogers848871b2013-08-05 10:56:33 -0700233 qpoints->pCheckSuspend = CheckSuspendFromCode;
234 qpoints->pTestSuspend = art_quick_test_suspend;
Ian Rogers7655f292013-07-29 11:07:13 -0700235
236 // Throws
Ian Rogers848871b2013-08-05 10:56:33 -0700237 qpoints->pDeliverException = art_quick_deliver_exception;
238 qpoints->pThrowArrayBounds = art_quick_throw_array_bounds;
239 qpoints->pThrowDivZero = art_quick_throw_div_zero;
240 qpoints->pThrowNoSuchMethod = art_quick_throw_no_such_method;
241 qpoints->pThrowNullPointer = art_quick_throw_null_pointer_exception;
242 qpoints->pThrowStackOverflow = art_quick_throw_stack_overflow;
Ian Rogers7655f292013-07-29 11:07:13 -0700243};
244
245} // namespace art