blob: db0f71fa374e5a203c4dc1a21e35b297244d3a59 [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 Rogers6f3dbba2014-10-14 17:41:57 -070017#include "atomic.h"
Mingyao Yang98d1cc82014-05-15 17:02:16 -070018#include "entrypoints/interpreter/interpreter_entrypoints.h"
19#include "entrypoints/jni/jni_entrypoints.h"
Ian Rogers7655f292013-07-29 11:07:13 -070020#include "entrypoints/portable/portable_entrypoints.h"
Mathieu Chartierd8891782014-03-02 13:28:37 -080021#include "entrypoints/quick/quick_alloc_entrypoints.h"
Ian Rogers7655f292013-07-29 11:07:13 -070022#include "entrypoints/quick/quick_entrypoints.h"
23#include "entrypoints/entrypoint_utils.h"
24#include "entrypoints/math_entrypoints.h"
Ian Rogers6f3dbba2014-10-14 17:41:57 -070025#include "entrypoints/runtime_asm_entrypoints.h"
26#include "interpreter/interpreter.h"
Ian Rogers7655f292013-07-29 11:07:13 -070027
28namespace art {
29
Ian Rogers848871b2013-08-05 10:56:33 -070030// Portable entrypoints.
Brian Carlstromea46f952013-07-30 01:26:50 -070031extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*);
32extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers848871b2013-08-05 10:56:33 -070033
Ian Rogers7655f292013-07-29 11:07:13 -070034// Cast entrypoints.
35extern "C" uint32_t artIsAssignableFromCode(const mirror::Class* klass,
36 const mirror::Class* ref_class);
Ian Rogers848871b2013-08-05 10:56:33 -070037extern "C" void art_quick_check_cast(void*, void*);
Ian Rogers7655f292013-07-29 11:07:13 -070038
39// DexCache entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070040extern "C" void* art_quick_initialize_static_storage(uint32_t, void*);
41extern "C" void* art_quick_initialize_type(uint32_t, void*);
42extern "C" void* art_quick_initialize_type_and_verify_access(uint32_t, void*);
43extern "C" void* art_quick_resolve_string(void*, uint32_t);
Ian Rogers7655f292013-07-29 11:07:13 -070044
Ian Rogers7655f292013-07-29 11:07:13 -070045// Field entrypoints.
Fred Shih37f05ef2014-07-16 18:38:08 -070046extern "C" int art_quick_set8_instance(uint32_t, void*, int8_t);
47extern "C" int art_quick_set8_static(uint32_t, int8_t);
48extern "C" int art_quick_set16_instance(uint32_t, void*, int16_t);
49extern "C" int art_quick_set16_static(uint32_t, int16_t);
Ian Rogers848871b2013-08-05 10:56:33 -070050extern "C" int art_quick_set32_instance(uint32_t, void*, int32_t);
51extern "C" int art_quick_set32_static(uint32_t, int32_t);
52extern "C" int art_quick_set64_instance(uint32_t, void*, int64_t);
53extern "C" int art_quick_set64_static(uint32_t, int64_t);
54extern "C" int art_quick_set_obj_instance(uint32_t, void*, void*);
55extern "C" int art_quick_set_obj_static(uint32_t, void*);
Fred Shih37f05ef2014-07-16 18:38:08 -070056extern "C" uint8_t art_quick_get_boolean_instance(uint32_t, void*);
57extern "C" int8_t art_quick_get_byte_instance(uint32_t, void*);
58extern "C" uint8_t art_quick_get_boolean_static(uint32_t);
59extern "C" int8_t art_quick_get_byte_static(uint32_t);
60extern "C" uint16_t art_quick_get_char_instance(uint32_t, void*);
61extern "C" int16_t art_quick_get_short_instance(uint32_t, void*);
62extern "C" uint16_t art_quick_get_char_static(uint32_t);
63extern "C" int16_t art_quick_get_short_static(uint32_t);
Ian Rogers848871b2013-08-05 10:56:33 -070064extern "C" int32_t art_quick_get32_instance(uint32_t, void*);
65extern "C" int32_t art_quick_get32_static(uint32_t);
66extern "C" int64_t art_quick_get64_instance(uint32_t, void*);
67extern "C" int64_t art_quick_get64_static(uint32_t);
68extern "C" void* art_quick_get_obj_instance(uint32_t, void*);
69extern "C" void* art_quick_get_obj_static(uint32_t);
Ian Rogers7655f292013-07-29 11:07:13 -070070
Ian Rogersa9a82542013-10-04 11:17:26 -070071// Array entrypoints.
72extern "C" void art_quick_aput_obj_with_null_and_bound_check(void*, uint32_t, void*);
73extern "C" void art_quick_aput_obj_with_bound_check(void*, uint32_t, void*);
74extern "C" void art_quick_aput_obj(void*, uint32_t, void*);
Ian Rogers848871b2013-08-05 10:56:33 -070075extern "C" void art_quick_handle_fill_data(void*, void*);
Ian Rogers7655f292013-07-29 11:07:13 -070076
77// Lock entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070078extern "C" void art_quick_lock_object(void*);
79extern "C" void art_quick_unlock_object(void*);
Ian Rogers7655f292013-07-29 11:07:13 -070080
81// Math entrypoints.
82extern int32_t CmpgDouble(double a, double b);
83extern int32_t CmplDouble(double a, double b);
84extern int32_t CmpgFloat(float a, float b);
85extern int32_t CmplFloat(float a, float b);
Ian Rogersa9a82542013-10-04 11:17:26 -070086extern "C" int64_t artLmul(int64_t a, int64_t b);
87extern "C" int64_t artLdiv(int64_t a, int64_t b);
88extern "C" int64_t artLmod(int64_t a, int64_t b);
Ian Rogers7655f292013-07-29 11:07:13 -070089
90// Math conversions.
91extern "C" int32_t __fixsfsi(float op1); // FLOAT_TO_INT
92extern "C" int32_t __fixdfsi(double op1); // DOUBLE_TO_INT
93extern "C" float __floatdisf(int64_t op1); // LONG_TO_FLOAT
94extern "C" double __floatdidf(int64_t op1); // LONG_TO_DOUBLE
95extern "C" int64_t __fixsfdi(float op1); // FLOAT_TO_LONG
96extern "C" int64_t __fixdfdi(double op1); // DOUBLE_TO_LONG
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// Long long arithmetics - REM_LONG[_2ADDR] and DIV_LONG[_2ADDR]
105extern "C" int64_t __divdi3(int64_t, int64_t);
106extern "C" int64_t __moddi3(int64_t, int64_t);
107extern "C" uint64_t art_quick_shl_long(uint64_t, uint32_t);
108extern "C" uint64_t art_quick_shr_long(uint64_t, uint32_t);
109extern "C" uint64_t art_quick_ushr_long(uint64_t, uint32_t);
110
Ian Rogers7655f292013-07-29 11:07:13 -0700111// Intrinsic entrypoints.
Ian Rogers7655f292013-07-29 11:07:13 -0700112extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t);
113extern "C" int32_t art_quick_string_compareto(void*, void*);
114
115// Invoke entrypoints.
Jeff Hao88474b42013-10-23 16:24:40 -0700116extern "C" void art_quick_imt_conflict_trampoline(mirror::ArtMethod*);
Brian Carlstromea46f952013-07-30 01:26:50 -0700117extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*);
118extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers7655f292013-07-29 11:07:13 -0700119extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*);
Ian Rogers7655f292013-07-29 11:07:13 -0700120extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*);
121extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*);
122extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*);
123extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*);
124
125// Thread entrypoints.
Ian Rogers7655f292013-07-29 11:07:13 -0700126extern "C" void art_quick_test_suspend();
127
128// Throw entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -0700129extern "C" void art_quick_deliver_exception(void*);
130extern "C" void art_quick_throw_array_bounds(int32_t index, int32_t limit);
131extern "C" void art_quick_throw_div_zero();
132extern "C" void art_quick_throw_no_such_method(int32_t method_idx);
133extern "C" void art_quick_throw_null_pointer_exception();
134extern "C" void art_quick_throw_stack_overflow(void*);
Ian Rogers7655f292013-07-29 11:07:13 -0700135
Andreas Gampe2da88232014-02-27 12:26:20 -0800136// Generic JNI downcall
137extern "C" void art_quick_generic_jni_trampoline(mirror::ArtMethod*);
138
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800139extern void ResetQuickAllocEntryPoints(QuickEntryPoints* qpoints);
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700140
Ian Rogers848871b2013-08-05 10:56:33 -0700141void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints,
142 PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) {
143 // Interpreter
144 ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge;
Dragos Sbirlea08bf1962013-08-12 08:53:04 -0700145 ipoints->pInterpreterToCompiledCodeBridge = artInterpreterToCompiledCodeBridge;
Ian Rogers848871b2013-08-05 10:56:33 -0700146
147 // JNI
148 jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub;
149
150 // Portable
151 ppoints->pPortableResolutionTrampoline = art_portable_resolution_trampoline;
152 ppoints->pPortableToInterpreterBridge = art_portable_to_interpreter_bridge;
153
Ian Rogers7655f292013-07-29 11:07:13 -0700154 // Alloc
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700155 ResetQuickAllocEntryPoints(qpoints);
Ian Rogers7655f292013-07-29 11:07:13 -0700156
157 // Cast
Ian Rogers848871b2013-08-05 10:56:33 -0700158 qpoints->pInstanceofNonTrivial = artIsAssignableFromCode;
Ian Rogers848871b2013-08-05 10:56:33 -0700159 qpoints->pCheckCast = art_quick_check_cast;
Ian Rogers7655f292013-07-29 11:07:13 -0700160
161 // DexCache
Ian Rogers848871b2013-08-05 10:56:33 -0700162 qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage;
163 qpoints->pInitializeTypeAndVerifyAccess = art_quick_initialize_type_and_verify_access;
164 qpoints->pInitializeType = art_quick_initialize_type;
165 qpoints->pResolveString = art_quick_resolve_string;
Ian Rogers7655f292013-07-29 11:07:13 -0700166
167 // Field
Fred Shih37f05ef2014-07-16 18:38:08 -0700168 qpoints->pSet8Instance = art_quick_set8_instance;
169 qpoints->pSet8Static = art_quick_set8_static;
170 qpoints->pSet16Instance = art_quick_set16_instance;
171 qpoints->pSet16Static = art_quick_set16_static;
Ian Rogers848871b2013-08-05 10:56:33 -0700172 qpoints->pSet32Instance = art_quick_set32_instance;
173 qpoints->pSet32Static = art_quick_set32_static;
174 qpoints->pSet64Instance = art_quick_set64_instance;
175 qpoints->pSet64Static = art_quick_set64_static;
176 qpoints->pSetObjInstance = art_quick_set_obj_instance;
177 qpoints->pSetObjStatic = art_quick_set_obj_static;
Fred Shih37f05ef2014-07-16 18:38:08 -0700178 qpoints->pGetBooleanInstance = art_quick_get_boolean_instance;
179 qpoints->pGetByteInstance = art_quick_get_byte_instance;
180 qpoints->pGetCharInstance = art_quick_get_char_instance;
181 qpoints->pGetShortInstance = art_quick_get_short_instance;
Ian Rogers848871b2013-08-05 10:56:33 -0700182 qpoints->pGet32Instance = art_quick_get32_instance;
183 qpoints->pGet64Instance = art_quick_get64_instance;
184 qpoints->pGetObjInstance = art_quick_get_obj_instance;
Fred Shih37f05ef2014-07-16 18:38:08 -0700185 qpoints->pGetBooleanStatic = art_quick_get_boolean_static;
186 qpoints->pGetByteStatic = art_quick_get_byte_static;
187 qpoints->pGetCharStatic = art_quick_get_char_static;
188 qpoints->pGetShortStatic = art_quick_get_short_static;
Ian Rogers848871b2013-08-05 10:56:33 -0700189 qpoints->pGet32Static = art_quick_get32_static;
190 qpoints->pGet64Static = art_quick_get64_static;
191 qpoints->pGetObjStatic = art_quick_get_obj_static;
Ian Rogers7655f292013-07-29 11:07:13 -0700192
Ian Rogersa9a82542013-10-04 11:17:26 -0700193 // Array
194 qpoints->pAputObjectWithNullAndBoundCheck = art_quick_aput_obj_with_null_and_bound_check;
195 qpoints->pAputObjectWithBoundCheck = art_quick_aput_obj_with_bound_check;
196 qpoints->pAputObject = art_quick_aput_obj;
Ian Rogers848871b2013-08-05 10:56:33 -0700197 qpoints->pHandleFillArrayData = art_quick_handle_fill_data;
Ian Rogers7655f292013-07-29 11:07:13 -0700198
199 // JNI
200 qpoints->pJniMethodStart = JniMethodStart;
201 qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized;
202 qpoints->pJniMethodEnd = JniMethodEnd;
203 qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized;
204 qpoints->pJniMethodEndWithReference = JniMethodEndWithReference;
205 qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized;
Andreas Gampe2da88232014-02-27 12:26:20 -0800206 qpoints->pQuickGenericJniTrampoline = art_quick_generic_jni_trampoline;
Ian Rogers7655f292013-07-29 11:07:13 -0700207
208 // Locks
Ian Rogers848871b2013-08-05 10:56:33 -0700209 qpoints->pLockObject = art_quick_lock_object;
210 qpoints->pUnlockObject = art_quick_unlock_object;
Ian Rogers7655f292013-07-29 11:07:13 -0700211
212 // Math
213 qpoints->pCmpgDouble = CmpgDouble;
214 qpoints->pCmpgFloat = CmpgFloat;
215 qpoints->pCmplDouble = CmplDouble;
216 qpoints->pCmplFloat = CmplFloat;
217 qpoints->pFmod = fmod;
Douglas Leungd9cb8ae2014-07-09 14:28:35 -0700218 qpoints->pL2d = art_l2d;
Ian Rogers7655f292013-07-29 11:07:13 -0700219 qpoints->pFmodf = fmodf;
Douglas Leungd9cb8ae2014-07-09 14:28:35 -0700220 qpoints->pL2f = art_l2f;
221 qpoints->pD2iz = art_d2i;
222 qpoints->pF2iz = art_f2i;
Ian Rogers7655f292013-07-29 11:07:13 -0700223 qpoints->pIdivmod = NULL;
224 qpoints->pD2l = art_d2l;
225 qpoints->pF2l = art_f2l;
Ian Rogersa9a82542013-10-04 11:17:26 -0700226 qpoints->pLdiv = artLdiv;
227 qpoints->pLmod = artLmod;
228 qpoints->pLmul = artLmul;
Ian Rogers7655f292013-07-29 11:07:13 -0700229 qpoints->pShlLong = art_quick_shl_long;
230 qpoints->pShrLong = art_quick_shr_long;
231 qpoints->pUshrLong = art_quick_ushr_long;
232
Ian Rogers7655f292013-07-29 11:07:13 -0700233 // Intrinsics
234 qpoints->pIndexOf = art_quick_indexof;
Ian Rogers7655f292013-07-29 11:07:13 -0700235 qpoints->pStringCompareTo = art_quick_string_compareto;
236 qpoints->pMemcpy = memcpy;
237
238 // Invocation
Jeff Hao88474b42013-10-23 16:24:40 -0700239 qpoints->pQuickImtConflictTrampoline = art_quick_imt_conflict_trampoline;
Ian Rogers848871b2013-08-05 10:56:33 -0700240 qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline;
241 qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge;
Ian Rogers7655f292013-07-29 11:07:13 -0700242 qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check;
Ian Rogers7655f292013-07-29 11:07:13 -0700243 qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check;
244 qpoints->pInvokeStaticTrampolineWithAccessCheck = art_quick_invoke_static_trampoline_with_access_check;
245 qpoints->pInvokeSuperTrampolineWithAccessCheck = art_quick_invoke_super_trampoline_with_access_check;
246 qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check;
247
248 // Thread
Ian Rogers848871b2013-08-05 10:56:33 -0700249 qpoints->pTestSuspend = art_quick_test_suspend;
Ian Rogers7655f292013-07-29 11:07:13 -0700250
251 // Throws
Ian Rogers848871b2013-08-05 10:56:33 -0700252 qpoints->pDeliverException = art_quick_deliver_exception;
253 qpoints->pThrowArrayBounds = art_quick_throw_array_bounds;
254 qpoints->pThrowDivZero = art_quick_throw_div_zero;
255 qpoints->pThrowNoSuchMethod = art_quick_throw_no_such_method;
256 qpoints->pThrowNullPointer = art_quick_throw_null_pointer_exception;
257 qpoints->pThrowStackOverflow = art_quick_throw_stack_overflow;
Douglas Leungd9cb8ae2014-07-09 14:28:35 -0700258
259 // Atomic 64-bit load/store
260 qpoints->pA64Load = QuasiAtomic::Read64;
261 qpoints->pA64Store = QuasiAtomic::Write64;
Ian Rogers7655f292013-07-29 11:07:13 -0700262};
263
264} // namespace art