blob: 25e911d7650a2d6251f05fcc0384dfa9d014f701 [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
Mingyao Yang98d1cc82014-05-15 17:02:16 -070017#include "entrypoints/interpreter/interpreter_entrypoints.h"
18#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"
Douglas Leungd9cb8ae2014-07-09 14:28:35 -070024#include "atomic.h"
Ian Rogers7655f292013-07-29 11:07:13 -070025
26namespace art {
27
Ian Rogers848871b2013-08-05 10:56:33 -070028// Interpreter entrypoints.
29extern "C" void artInterpreterToInterpreterBridge(Thread* self, MethodHelper& mh,
30 const DexFile::CodeItem* code_item,
31 ShadowFrame* shadow_frame, JValue* result);
Dragos Sbirlea08bf1962013-08-12 08:53:04 -070032extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& mh,
Ian Rogers848871b2013-08-05 10:56:33 -070033 const DexFile::CodeItem* code_item,
34 ShadowFrame* shadow_frame, JValue* result);
35
36// Portable entrypoints.
Brian Carlstromea46f952013-07-30 01:26:50 -070037extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*);
38extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers848871b2013-08-05 10:56:33 -070039
Ian Rogers7655f292013-07-29 11:07:13 -070040// Cast entrypoints.
41extern "C" uint32_t artIsAssignableFromCode(const mirror::Class* klass,
42 const mirror::Class* ref_class);
Ian Rogers848871b2013-08-05 10:56:33 -070043extern "C" void art_quick_check_cast(void*, void*);
Ian Rogers7655f292013-07-29 11:07:13 -070044
45// DexCache entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070046extern "C" void* art_quick_initialize_static_storage(uint32_t, void*);
47extern "C" void* art_quick_initialize_type(uint32_t, void*);
48extern "C" void* art_quick_initialize_type_and_verify_access(uint32_t, void*);
49extern "C" void* art_quick_resolve_string(void*, uint32_t);
Ian Rogers7655f292013-07-29 11:07:13 -070050
Ian Rogers7655f292013-07-29 11:07:13 -070051// Field entrypoints.
Fred Shih37f05ef2014-07-16 18:38:08 -070052extern "C" int art_quick_set8_instance(uint32_t, void*, int8_t);
53extern "C" int art_quick_set8_static(uint32_t, int8_t);
54extern "C" int art_quick_set16_instance(uint32_t, void*, int16_t);
55extern "C" int art_quick_set16_static(uint32_t, int16_t);
Ian Rogers848871b2013-08-05 10:56:33 -070056extern "C" int art_quick_set32_instance(uint32_t, void*, int32_t);
57extern "C" int art_quick_set32_static(uint32_t, int32_t);
58extern "C" int art_quick_set64_instance(uint32_t, void*, int64_t);
59extern "C" int art_quick_set64_static(uint32_t, int64_t);
60extern "C" int art_quick_set_obj_instance(uint32_t, void*, void*);
61extern "C" int art_quick_set_obj_static(uint32_t, void*);
Fred Shih37f05ef2014-07-16 18:38:08 -070062extern "C" uint8_t art_quick_get_boolean_instance(uint32_t, void*);
63extern "C" int8_t art_quick_get_byte_instance(uint32_t, void*);
64extern "C" uint8_t art_quick_get_boolean_static(uint32_t);
65extern "C" int8_t art_quick_get_byte_static(uint32_t);
66extern "C" uint16_t art_quick_get_char_instance(uint32_t, void*);
67extern "C" int16_t art_quick_get_short_instance(uint32_t, void*);
68extern "C" uint16_t art_quick_get_char_static(uint32_t);
69extern "C" int16_t art_quick_get_short_static(uint32_t);
Ian Rogers848871b2013-08-05 10:56:33 -070070extern "C" int32_t art_quick_get32_instance(uint32_t, void*);
71extern "C" int32_t art_quick_get32_static(uint32_t);
72extern "C" int64_t art_quick_get64_instance(uint32_t, void*);
73extern "C" int64_t art_quick_get64_static(uint32_t);
74extern "C" void* art_quick_get_obj_instance(uint32_t, void*);
75extern "C" void* art_quick_get_obj_static(uint32_t);
Ian Rogers7655f292013-07-29 11:07:13 -070076
Ian Rogersa9a82542013-10-04 11:17:26 -070077// Array entrypoints.
78extern "C" void art_quick_aput_obj_with_null_and_bound_check(void*, uint32_t, void*);
79extern "C" void art_quick_aput_obj_with_bound_check(void*, uint32_t, void*);
80extern "C" void art_quick_aput_obj(void*, uint32_t, void*);
Ian Rogers848871b2013-08-05 10:56:33 -070081extern "C" void art_quick_handle_fill_data(void*, void*);
Ian Rogers7655f292013-07-29 11:07:13 -070082
83// Lock entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070084extern "C" void art_quick_lock_object(void*);
85extern "C" void art_quick_unlock_object(void*);
Ian Rogers7655f292013-07-29 11:07:13 -070086
87// Math entrypoints.
88extern int32_t CmpgDouble(double a, double b);
89extern int32_t CmplDouble(double a, double b);
90extern int32_t CmpgFloat(float a, float b);
91extern int32_t CmplFloat(float a, float b);
Ian Rogersa9a82542013-10-04 11:17:26 -070092extern "C" int64_t artLmul(int64_t a, int64_t b);
93extern "C" int64_t artLdiv(int64_t a, int64_t b);
94extern "C" int64_t artLmod(int64_t a, int64_t b);
Ian Rogers7655f292013-07-29 11:07:13 -070095
96// Math conversions.
97extern "C" int32_t __fixsfsi(float op1); // FLOAT_TO_INT
98extern "C" int32_t __fixdfsi(double op1); // DOUBLE_TO_INT
99extern "C" float __floatdisf(int64_t op1); // LONG_TO_FLOAT
100extern "C" double __floatdidf(int64_t op1); // LONG_TO_DOUBLE
101extern "C" int64_t __fixsfdi(float op1); // FLOAT_TO_LONG
102extern "C" int64_t __fixdfdi(double op1); // DOUBLE_TO_LONG
103
104// Single-precision FP arithmetics.
105extern "C" float fmodf(float a, float b); // REM_FLOAT[_2ADDR]
106
107// Double-precision FP arithmetics.
108extern "C" double fmod(double a, double b); // REM_DOUBLE[_2ADDR]
109
110// Long long arithmetics - REM_LONG[_2ADDR] and DIV_LONG[_2ADDR]
111extern "C" int64_t __divdi3(int64_t, int64_t);
112extern "C" int64_t __moddi3(int64_t, int64_t);
113extern "C" uint64_t art_quick_shl_long(uint64_t, uint32_t);
114extern "C" uint64_t art_quick_shr_long(uint64_t, uint32_t);
115extern "C" uint64_t art_quick_ushr_long(uint64_t, uint32_t);
116
Ian Rogers7655f292013-07-29 11:07:13 -0700117// Intrinsic entrypoints.
Ian Rogers7655f292013-07-29 11:07:13 -0700118extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t);
119extern "C" int32_t art_quick_string_compareto(void*, void*);
120
121// Invoke entrypoints.
Jeff Hao88474b42013-10-23 16:24:40 -0700122extern "C" void art_quick_imt_conflict_trampoline(mirror::ArtMethod*);
Brian Carlstromea46f952013-07-30 01:26:50 -0700123extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*);
124extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers7655f292013-07-29 11:07:13 -0700125extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*);
Ian Rogers7655f292013-07-29 11:07:13 -0700126extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*);
127extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*);
128extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*);
129extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*);
130
131// Thread entrypoints.
Ian Rogers7655f292013-07-29 11:07:13 -0700132extern "C" void art_quick_test_suspend();
133
134// Throw entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -0700135extern "C" void art_quick_deliver_exception(void*);
136extern "C" void art_quick_throw_array_bounds(int32_t index, int32_t limit);
137extern "C" void art_quick_throw_div_zero();
138extern "C" void art_quick_throw_no_such_method(int32_t method_idx);
139extern "C" void art_quick_throw_null_pointer_exception();
140extern "C" void art_quick_throw_stack_overflow(void*);
Ian Rogers7655f292013-07-29 11:07:13 -0700141
Andreas Gampe2da88232014-02-27 12:26:20 -0800142// Generic JNI downcall
143extern "C" void art_quick_generic_jni_trampoline(mirror::ArtMethod*);
144
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800145extern void ResetQuickAllocEntryPoints(QuickEntryPoints* qpoints);
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700146
Ian Rogers848871b2013-08-05 10:56:33 -0700147void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints,
148 PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) {
149 // Interpreter
150 ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge;
Dragos Sbirlea08bf1962013-08-12 08:53:04 -0700151 ipoints->pInterpreterToCompiledCodeBridge = artInterpreterToCompiledCodeBridge;
Ian Rogers848871b2013-08-05 10:56:33 -0700152
153 // JNI
154 jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub;
155
156 // Portable
157 ppoints->pPortableResolutionTrampoline = art_portable_resolution_trampoline;
158 ppoints->pPortableToInterpreterBridge = art_portable_to_interpreter_bridge;
159
Ian Rogers7655f292013-07-29 11:07:13 -0700160 // Alloc
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700161 ResetQuickAllocEntryPoints(qpoints);
Ian Rogers7655f292013-07-29 11:07:13 -0700162
163 // Cast
Ian Rogers848871b2013-08-05 10:56:33 -0700164 qpoints->pInstanceofNonTrivial = artIsAssignableFromCode;
Ian Rogers848871b2013-08-05 10:56:33 -0700165 qpoints->pCheckCast = art_quick_check_cast;
Ian Rogers7655f292013-07-29 11:07:13 -0700166
167 // DexCache
Ian Rogers848871b2013-08-05 10:56:33 -0700168 qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage;
169 qpoints->pInitializeTypeAndVerifyAccess = art_quick_initialize_type_and_verify_access;
170 qpoints->pInitializeType = art_quick_initialize_type;
171 qpoints->pResolveString = art_quick_resolve_string;
Ian Rogers7655f292013-07-29 11:07:13 -0700172
173 // Field
Fred Shih37f05ef2014-07-16 18:38:08 -0700174 qpoints->pSet8Instance = art_quick_set8_instance;
175 qpoints->pSet8Static = art_quick_set8_static;
176 qpoints->pSet16Instance = art_quick_set16_instance;
177 qpoints->pSet16Static = art_quick_set16_static;
Ian Rogers848871b2013-08-05 10:56:33 -0700178 qpoints->pSet32Instance = art_quick_set32_instance;
179 qpoints->pSet32Static = art_quick_set32_static;
180 qpoints->pSet64Instance = art_quick_set64_instance;
181 qpoints->pSet64Static = art_quick_set64_static;
182 qpoints->pSetObjInstance = art_quick_set_obj_instance;
183 qpoints->pSetObjStatic = art_quick_set_obj_static;
Fred Shih37f05ef2014-07-16 18:38:08 -0700184 qpoints->pGetBooleanInstance = art_quick_get_boolean_instance;
185 qpoints->pGetByteInstance = art_quick_get_byte_instance;
186 qpoints->pGetCharInstance = art_quick_get_char_instance;
187 qpoints->pGetShortInstance = art_quick_get_short_instance;
Ian Rogers848871b2013-08-05 10:56:33 -0700188 qpoints->pGet32Instance = art_quick_get32_instance;
189 qpoints->pGet64Instance = art_quick_get64_instance;
190 qpoints->pGetObjInstance = art_quick_get_obj_instance;
Fred Shih37f05ef2014-07-16 18:38:08 -0700191 qpoints->pGetBooleanStatic = art_quick_get_boolean_static;
192 qpoints->pGetByteStatic = art_quick_get_byte_static;
193 qpoints->pGetCharStatic = art_quick_get_char_static;
194 qpoints->pGetShortStatic = art_quick_get_short_static;
Ian Rogers848871b2013-08-05 10:56:33 -0700195 qpoints->pGet32Static = art_quick_get32_static;
196 qpoints->pGet64Static = art_quick_get64_static;
197 qpoints->pGetObjStatic = art_quick_get_obj_static;
Ian Rogers7655f292013-07-29 11:07:13 -0700198
Ian Rogersa9a82542013-10-04 11:17:26 -0700199 // Array
200 qpoints->pAputObjectWithNullAndBoundCheck = art_quick_aput_obj_with_null_and_bound_check;
201 qpoints->pAputObjectWithBoundCheck = art_quick_aput_obj_with_bound_check;
202 qpoints->pAputObject = art_quick_aput_obj;
Ian Rogers848871b2013-08-05 10:56:33 -0700203 qpoints->pHandleFillArrayData = art_quick_handle_fill_data;
Ian Rogers7655f292013-07-29 11:07:13 -0700204
205 // JNI
206 qpoints->pJniMethodStart = JniMethodStart;
207 qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized;
208 qpoints->pJniMethodEnd = JniMethodEnd;
209 qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized;
210 qpoints->pJniMethodEndWithReference = JniMethodEndWithReference;
211 qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized;
Andreas Gampe2da88232014-02-27 12:26:20 -0800212 qpoints->pQuickGenericJniTrampoline = art_quick_generic_jni_trampoline;
Ian Rogers7655f292013-07-29 11:07:13 -0700213
214 // Locks
Ian Rogers848871b2013-08-05 10:56:33 -0700215 qpoints->pLockObject = art_quick_lock_object;
216 qpoints->pUnlockObject = art_quick_unlock_object;
Ian Rogers7655f292013-07-29 11:07:13 -0700217
218 // Math
219 qpoints->pCmpgDouble = CmpgDouble;
220 qpoints->pCmpgFloat = CmpgFloat;
221 qpoints->pCmplDouble = CmplDouble;
222 qpoints->pCmplFloat = CmplFloat;
223 qpoints->pFmod = fmod;
Douglas Leungd9cb8ae2014-07-09 14:28:35 -0700224 qpoints->pL2d = art_l2d;
Ian Rogers7655f292013-07-29 11:07:13 -0700225 qpoints->pFmodf = fmodf;
Douglas Leungd9cb8ae2014-07-09 14:28:35 -0700226 qpoints->pL2f = art_l2f;
227 qpoints->pD2iz = art_d2i;
228 qpoints->pF2iz = art_f2i;
Ian Rogers7655f292013-07-29 11:07:13 -0700229 qpoints->pIdivmod = NULL;
230 qpoints->pD2l = art_d2l;
231 qpoints->pF2l = art_f2l;
Ian Rogersa9a82542013-10-04 11:17:26 -0700232 qpoints->pLdiv = artLdiv;
233 qpoints->pLmod = artLmod;
234 qpoints->pLmul = artLmul;
Ian Rogers7655f292013-07-29 11:07:13 -0700235 qpoints->pShlLong = art_quick_shl_long;
236 qpoints->pShrLong = art_quick_shr_long;
237 qpoints->pUshrLong = art_quick_ushr_long;
238
Ian Rogers7655f292013-07-29 11:07:13 -0700239 // Intrinsics
240 qpoints->pIndexOf = art_quick_indexof;
Ian Rogers7655f292013-07-29 11:07:13 -0700241 qpoints->pStringCompareTo = art_quick_string_compareto;
242 qpoints->pMemcpy = memcpy;
243
244 // Invocation
Jeff Hao88474b42013-10-23 16:24:40 -0700245 qpoints->pQuickImtConflictTrampoline = art_quick_imt_conflict_trampoline;
Ian Rogers848871b2013-08-05 10:56:33 -0700246 qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline;
247 qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge;
Ian Rogers7655f292013-07-29 11:07:13 -0700248 qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check;
Ian Rogers7655f292013-07-29 11:07:13 -0700249 qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check;
250 qpoints->pInvokeStaticTrampolineWithAccessCheck = art_quick_invoke_static_trampoline_with_access_check;
251 qpoints->pInvokeSuperTrampolineWithAccessCheck = art_quick_invoke_super_trampoline_with_access_check;
252 qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check;
253
254 // Thread
Ian Rogers848871b2013-08-05 10:56:33 -0700255 qpoints->pTestSuspend = art_quick_test_suspend;
Ian Rogers7655f292013-07-29 11:07:13 -0700256
257 // Throws
Ian Rogers848871b2013-08-05 10:56:33 -0700258 qpoints->pDeliverException = art_quick_deliver_exception;
259 qpoints->pThrowArrayBounds = art_quick_throw_array_bounds;
260 qpoints->pThrowDivZero = art_quick_throw_div_zero;
261 qpoints->pThrowNoSuchMethod = art_quick_throw_no_such_method;
262 qpoints->pThrowNullPointer = art_quick_throw_null_pointer_exception;
263 qpoints->pThrowStackOverflow = art_quick_throw_stack_overflow;
Douglas Leungd9cb8ae2014-07-09 14:28:35 -0700264
265 // Atomic 64-bit load/store
266 qpoints->pA64Load = QuasiAtomic::Read64;
267 qpoints->pA64Store = QuasiAtomic::Write64;
Ian Rogers7655f292013-07-29 11:07:13 -0700268};
269
270} // namespace art