blob: 2780d1b5c931ac7898fccf0e6aaa8f3441e17669 [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"
24
25namespace art {
26
Ian Rogers848871b2013-08-05 10:56:33 -070027// Interpreter entrypoints.
28extern "C" void artInterpreterToInterpreterBridge(Thread* self, MethodHelper& mh,
Ian Rogerse63db272014-07-15 15:36:11 -070029 const DexFile::CodeItem* code_item,
30 ShadowFrame* shadow_frame, JValue* result);
Dragos Sbirlea08bf1962013-08-12 08:53:04 -070031extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& mh,
Ian Rogerse63db272014-07-15 15:36:11 -070032 const DexFile::CodeItem* code_item,
33 ShadowFrame* shadow_frame, JValue* result);
Ian Rogers848871b2013-08-05 10:56:33 -070034
35// Portable entrypoints.
Brian Carlstromea46f952013-07-30 01:26:50 -070036extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*);
37extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers848871b2013-08-05 10:56:33 -070038
Ian Rogers7655f292013-07-29 11:07:13 -070039// Cast entrypoints.
40extern "C" uint32_t artIsAssignableFromCode(const mirror::Class* klass,
41 const mirror::Class* ref_class);
Ian Rogers848871b2013-08-05 10:56:33 -070042extern "C" void art_quick_check_cast(void*, void*);
Ian Rogers7655f292013-07-29 11:07:13 -070043
44// DexCache entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070045extern "C" void* art_quick_initialize_static_storage(uint32_t, void*);
46extern "C" void* art_quick_initialize_type(uint32_t, void*);
47extern "C" void* art_quick_initialize_type_and_verify_access(uint32_t, void*);
48extern "C" void* art_quick_resolve_string(void*, uint32_t);
Ian Rogers7655f292013-07-29 11:07:13 -070049
Ian Rogers7655f292013-07-29 11:07:13 -070050// Field entrypoints.
Fred Shih37f05ef2014-07-16 18:38:08 -070051extern "C" int art_quick_set8_instance(uint32_t, void*, int8_t);
52extern "C" int art_quick_set8_static(uint32_t, int8_t);
53extern "C" int art_quick_set16_instance(uint32_t, void*, int16_t);
54extern "C" int art_quick_set16_static(uint32_t, int16_t);
Ian Rogers848871b2013-08-05 10:56:33 -070055extern "C" int art_quick_set32_instance(uint32_t, void*, int32_t);
56extern "C" int art_quick_set32_static(uint32_t, int32_t);
57extern "C" int art_quick_set64_instance(uint32_t, void*, int64_t);
58extern "C" int art_quick_set64_static(uint32_t, int64_t);
59extern "C" int art_quick_set_obj_instance(uint32_t, void*, void*);
60extern "C" int art_quick_set_obj_static(uint32_t, void*);
Fred Shih37f05ef2014-07-16 18:38:08 -070061extern "C" int8_t art_quick_get_byte_instance(uint32_t, void*);
62extern "C" uint8_t art_quick_get_boolean_instance(uint32_t, void*);
63extern "C" int8_t art_quick_get_byte_static(uint32_t);
64extern "C" uint8_t art_quick_get_boolean_static(uint32_t);
65extern "C" int16_t art_quick_get_short_instance(uint32_t, void*);
66extern "C" uint16_t art_quick_get_char_instance(uint32_t, void*);
67extern "C" int16_t art_quick_get_short_static(uint32_t);
68extern "C" uint16_t art_quick_get_char_static(uint32_t);
Ian Rogers848871b2013-08-05 10:56:33 -070069extern "C" int32_t art_quick_get32_instance(uint32_t, void*);
70extern "C" int32_t art_quick_get32_static(uint32_t);
71extern "C" int64_t art_quick_get64_instance(uint32_t, void*);
72extern "C" int64_t art_quick_get64_static(uint32_t);
73extern "C" void* art_quick_get_obj_instance(uint32_t, void*);
74extern "C" void* art_quick_get_obj_static(uint32_t);
Ian Rogers7655f292013-07-29 11:07:13 -070075
Ian Rogersa9a82542013-10-04 11:17:26 -070076// Array entrypoints.
77extern "C" void art_quick_aput_obj_with_null_and_bound_check(void*, uint32_t, void*);
78extern "C" void art_quick_aput_obj_with_bound_check(void*, uint32_t, void*);
79extern "C" void art_quick_aput_obj(void*, uint32_t, void*);
Ian Rogers848871b2013-08-05 10:56:33 -070080extern "C" void art_quick_handle_fill_data(void*, void*);
Ian Rogers7655f292013-07-29 11:07:13 -070081
82// Lock entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070083extern "C" void art_quick_lock_object(void*);
84extern "C" void art_quick_unlock_object(void*);
Ian Rogers7655f292013-07-29 11:07:13 -070085
86// Math entrypoints.
87extern int32_t CmpgDouble(double a, double b);
88extern int32_t CmplDouble(double a, double b);
89extern int32_t CmpgFloat(float a, float b);
90extern int32_t CmplFloat(float a, float b);
91
92// Math conversions.
93extern "C" int32_t __aeabi_f2iz(float op1); // FLOAT_TO_INT
94extern "C" int32_t __aeabi_d2iz(double op1); // DOUBLE_TO_INT
95extern "C" float __aeabi_l2f(int64_t op1); // LONG_TO_FLOAT
96extern "C" double __aeabi_l2d(int64_t op1); // LONG_TO_DOUBLE
97
98// Single-precision FP arithmetics.
99extern "C" float fmodf(float a, float b); // REM_FLOAT[_2ADDR]
100
101// Double-precision FP arithmetics.
102extern "C" double fmod(double a, double b); // REM_DOUBLE[_2ADDR]
103
104// Integer arithmetics.
105extern "C" int __aeabi_idivmod(int32_t, int32_t); // [DIV|REM]_INT[_2ADDR|_LIT8|_LIT16]
106
107// Long long arithmetics - REM_LONG[_2ADDR] and DIV_LONG[_2ADDR]
108extern "C" int64_t __aeabi_ldivmod(int64_t, int64_t);
109extern "C" int64_t art_quick_mul_long(int64_t, int64_t);
110extern "C" uint64_t art_quick_shl_long(uint64_t, uint32_t);
111extern "C" uint64_t art_quick_shr_long(uint64_t, uint32_t);
112extern "C" uint64_t art_quick_ushr_long(uint64_t, uint32_t);
113
Ian Rogers7655f292013-07-29 11:07:13 -0700114// Intrinsic entrypoints.
Ian Rogers7655f292013-07-29 11:07:13 -0700115extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t);
116extern "C" int32_t art_quick_string_compareto(void*, void*);
117
118// Invoke entrypoints.
Jeff Hao88474b42013-10-23 16:24:40 -0700119extern "C" void art_quick_imt_conflict_trampoline(mirror::ArtMethod*);
Brian Carlstromea46f952013-07-30 01:26:50 -0700120extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*);
121extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers7655f292013-07-29 11:07:13 -0700122extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*);
Ian Rogers7655f292013-07-29 11:07:13 -0700123extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*);
124extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*);
125extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*);
126extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*);
127
128// Thread entrypoints.
Ian Rogers7655f292013-07-29 11:07:13 -0700129extern "C" void art_quick_test_suspend();
130
131// Throw entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -0700132extern "C" void art_quick_deliver_exception(void*);
133extern "C" void art_quick_throw_array_bounds(int32_t index, int32_t limit);
134extern "C" void art_quick_throw_div_zero();
135extern "C" void art_quick_throw_no_such_method(int32_t method_idx);
136extern "C" void art_quick_throw_null_pointer_exception();
137extern "C" void art_quick_throw_stack_overflow(void*);
Ian Rogers7655f292013-07-29 11:07:13 -0700138
Andreas Gampe2da88232014-02-27 12:26:20 -0800139// Generic JNI downcall
140extern "C" void art_quick_generic_jni_trampoline(mirror::ArtMethod*);
141
Ian Rogers848871b2013-08-05 10:56:33 -0700142void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints,
143 PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) {
144 // Interpreter
145 ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge;
Dragos Sbirlea08bf1962013-08-12 08:53:04 -0700146 ipoints->pInterpreterToCompiledCodeBridge = artInterpreterToCompiledCodeBridge;
Ian Rogers848871b2013-08-05 10:56:33 -0700147
148 // JNI
149 jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub;
150
151 // Portable
152 ppoints->pPortableResolutionTrampoline = art_portable_resolution_trampoline;
153 ppoints->pPortableToInterpreterBridge = art_portable_to_interpreter_bridge;
154
Ian Rogers7655f292013-07-29 11:07:13 -0700155 // Alloc
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700156 ResetQuickAllocEntryPoints(qpoints);
Ian Rogers7655f292013-07-29 11:07:13 -0700157
158 // Cast
Ian Rogers848871b2013-08-05 10:56:33 -0700159 qpoints->pInstanceofNonTrivial = artIsAssignableFromCode;
Ian Rogers848871b2013-08-05 10:56:33 -0700160 qpoints->pCheckCast = art_quick_check_cast;
Ian Rogers7655f292013-07-29 11:07:13 -0700161
162 // DexCache
Ian Rogers848871b2013-08-05 10:56:33 -0700163 qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage;
164 qpoints->pInitializeTypeAndVerifyAccess = art_quick_initialize_type_and_verify_access;
165 qpoints->pInitializeType = art_quick_initialize_type;
166 qpoints->pResolveString = art_quick_resolve_string;
Ian Rogers7655f292013-07-29 11:07:13 -0700167
168 // Field
Fred Shih37f05ef2014-07-16 18:38:08 -0700169 qpoints->pSet8Instance = art_quick_set8_instance;
170 qpoints->pSet8Static = art_quick_set8_static;
171 qpoints->pSet16Instance = art_quick_set16_instance;
172 qpoints->pSet16Static = art_quick_set16_static;
Ian Rogers848871b2013-08-05 10:56:33 -0700173 qpoints->pSet32Instance = art_quick_set32_instance;
174 qpoints->pSet32Static = art_quick_set32_static;
175 qpoints->pSet64Instance = art_quick_set64_instance;
176 qpoints->pSet64Static = art_quick_set64_static;
177 qpoints->pSetObjInstance = art_quick_set_obj_instance;
178 qpoints->pSetObjStatic = art_quick_set_obj_static;
Fred Shih37f05ef2014-07-16 18:38:08 -0700179 qpoints->pGetByteInstance = art_quick_get_byte_instance;
180 qpoints->pGetBooleanInstance = art_quick_get_boolean_instance;
181 qpoints->pGetShortInstance = art_quick_get_short_instance;
182 qpoints->pGetCharInstance = art_quick_get_char_instance;
Ian Rogers848871b2013-08-05 10:56:33 -0700183 qpoints->pGet32Instance = art_quick_get32_instance;
184 qpoints->pGet64Instance = art_quick_get64_instance;
185 qpoints->pGetObjInstance = art_quick_get_obj_instance;
Fred Shih37f05ef2014-07-16 18:38:08 -0700186 qpoints->pGetByteStatic = art_quick_get_byte_static;
187 qpoints->pGetBooleanStatic = art_quick_get_boolean_static;
188 qpoints->pGetShortStatic = art_quick_get_short_static;
189 qpoints->pGetCharStatic = art_quick_get_char_static;
Ian Rogers848871b2013-08-05 10:56:33 -0700190 qpoints->pGet32Static = art_quick_get32_static;
191 qpoints->pGet64Static = art_quick_get64_static;
192 qpoints->pGetObjStatic = art_quick_get_obj_static;
Ian Rogers7655f292013-07-29 11:07:13 -0700193
Ian Rogersa9a82542013-10-04 11:17:26 -0700194 // Array
195 qpoints->pAputObjectWithNullAndBoundCheck = art_quick_aput_obj_with_null_and_bound_check;
196 qpoints->pAputObjectWithBoundCheck = art_quick_aput_obj_with_bound_check;
197 qpoints->pAputObject = art_quick_aput_obj;
Ian Rogers848871b2013-08-05 10:56:33 -0700198 qpoints->pHandleFillArrayData = art_quick_handle_fill_data;
Ian Rogers7655f292013-07-29 11:07:13 -0700199
200 // JNI
201 qpoints->pJniMethodStart = JniMethodStart;
202 qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized;
203 qpoints->pJniMethodEnd = JniMethodEnd;
204 qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized;
205 qpoints->pJniMethodEndWithReference = JniMethodEndWithReference;
206 qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized;
Andreas Gampe2da88232014-02-27 12:26:20 -0800207 qpoints->pQuickGenericJniTrampoline = art_quick_generic_jni_trampoline;
Ian Rogers7655f292013-07-29 11:07:13 -0700208
209 // Locks
Ian Rogers848871b2013-08-05 10:56:33 -0700210 qpoints->pLockObject = art_quick_lock_object;
211 qpoints->pUnlockObject = art_quick_unlock_object;
Ian Rogers7655f292013-07-29 11:07:13 -0700212
213 // Math
214 qpoints->pCmpgDouble = CmpgDouble;
215 qpoints->pCmpgFloat = CmpgFloat;
216 qpoints->pCmplDouble = CmplDouble;
217 qpoints->pCmplFloat = CmplFloat;
218 qpoints->pFmod = fmod;
Ian Rogers7655f292013-07-29 11:07:13 -0700219 qpoints->pL2d = __aeabi_l2d;
220 qpoints->pFmodf = fmodf;
221 qpoints->pL2f = __aeabi_l2f;
222 qpoints->pD2iz = __aeabi_d2iz;
223 qpoints->pF2iz = __aeabi_f2iz;
224 qpoints->pIdivmod = __aeabi_idivmod;
225 qpoints->pD2l = art_d2l;
226 qpoints->pF2l = art_f2l;
227 qpoints->pLdiv = __aeabi_ldivmod;
Ian Rogersa9a82542013-10-04 11:17:26 -0700228 qpoints->pLmod = __aeabi_ldivmod; // result returned in r2:r3
Ian Rogers7655f292013-07-29 11:07:13 -0700229 qpoints->pLmul = art_quick_mul_long;
230 qpoints->pShlLong = art_quick_shl_long;
231 qpoints->pShrLong = art_quick_shr_long;
232 qpoints->pUshrLong = art_quick_ushr_long;
233
Ian Rogers7655f292013-07-29 11:07:13 -0700234 // Intrinsics
235 qpoints->pIndexOf = art_quick_indexof;
Ian Rogers7655f292013-07-29 11:07:13 -0700236 qpoints->pStringCompareTo = art_quick_string_compareto;
237 qpoints->pMemcpy = memcpy;
238
239 // Invocation
Jeff Hao88474b42013-10-23 16:24:40 -0700240 qpoints->pQuickImtConflictTrampoline = art_quick_imt_conflict_trampoline;
Ian Rogers848871b2013-08-05 10:56:33 -0700241 qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline;
242 qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge;
Ian Rogers7655f292013-07-29 11:07:13 -0700243 qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check;
Ian Rogers7655f292013-07-29 11:07:13 -0700244 qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check;
245 qpoints->pInvokeStaticTrampolineWithAccessCheck = art_quick_invoke_static_trampoline_with_access_check;
246 qpoints->pInvokeSuperTrampolineWithAccessCheck = art_quick_invoke_super_trampoline_with_access_check;
247 qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check;
248
249 // Thread
Ian Rogers848871b2013-08-05 10:56:33 -0700250 qpoints->pTestSuspend = art_quick_test_suspend;
Ian Rogers7655f292013-07-29 11:07:13 -0700251
252 // Throws
Ian Rogers848871b2013-08-05 10:56:33 -0700253 qpoints->pDeliverException = art_quick_deliver_exception;
254 qpoints->pThrowArrayBounds = art_quick_throw_array_bounds;
255 qpoints->pThrowDivZero = art_quick_throw_div_zero;
256 qpoints->pThrowNoSuchMethod = art_quick_throw_no_such_method;
257 qpoints->pThrowNullPointer = art_quick_throw_null_pointer_exception;
258 qpoints->pThrowStackOverflow = art_quick_throw_stack_overflow;
Andreas Gampec8ccf682014-09-29 20:07:43 -0700259}
Ian Rogers7655f292013-07-29 11:07:13 -0700260
261} // namespace art