blob: d47dfef047a5263a07e0f8f4fec9818d5fff6a31 [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
17#include "entrypoints/portable/portable_entrypoints.h"
18#include "entrypoints/quick/quick_entrypoints.h"
19#include "entrypoints/entrypoint_utils.h"
20
21namespace art {
22
23// Alloc entrypoints.
24extern "C" void* art_quick_alloc_array_from_code(uint32_t, void*, int32_t);
25extern "C" void* art_quick_alloc_array_from_code_with_access_check(uint32_t, void*, int32_t);
26extern "C" void* art_quick_alloc_object_from_code(uint32_t type_idx, void* method);
27extern "C" void* art_quick_alloc_object_from_code_with_access_check(uint32_t type_idx, void* method);
28extern "C" void* art_quick_check_and_alloc_array_from_code(uint32_t, void*, int32_t);
29extern "C" void* art_quick_check_and_alloc_array_from_code_with_access_check(uint32_t, void*, int32_t);
30
31// Cast entrypoints.
32extern "C" uint32_t art_quick_is_assignable_from_code(const mirror::Class* klass,
33 const mirror::Class* ref_class);
34extern "C" void art_quick_can_put_array_element_from_code(void*, void*);
35extern "C" void art_quick_check_cast_from_code(void*, void*);
36
37// DexCache entrypoints.
38extern "C" void* art_quick_initialize_static_storage_from_code(uint32_t, void*);
39extern "C" void* art_quick_initialize_type_from_code(uint32_t, void*);
40extern "C" void* art_quick_initialize_type_and_verify_access_from_code(uint32_t, void*);
41extern "C" void* art_quick_resolve_string_from_code(void*, uint32_t);
42
43// Field entrypoints.
44extern "C" int art_quick_set32_instance_from_code(uint32_t, void*, int32_t);
45extern "C" int art_quick_set32_static_from_code(uint32_t, int32_t);
46extern "C" int art_quick_set64_instance_from_code(uint32_t, void*, int64_t);
47extern "C" int art_quick_set64_static_from_code(uint32_t, int64_t);
48extern "C" int art_quick_set_obj_instance_from_code(uint32_t, void*, void*);
49extern "C" int art_quick_set_obj_static_from_code(uint32_t, void*);
50extern "C" int32_t art_quick_get32_instance_from_code(uint32_t, void*);
51extern "C" int32_t art_quick_get32_static_from_code(uint32_t);
52extern "C" int64_t art_quick_get64_instance_from_code(uint32_t, void*);
53extern "C" int64_t art_quick_get64_static_from_code(uint32_t);
54extern "C" void* art_quick_get_obj_instance_from_code(uint32_t, void*);
55extern "C" void* art_quick_get_obj_static_from_code(uint32_t);
56
57// FillArray entrypoint.
58extern "C" void art_quick_handle_fill_data_from_code(void*, void*);
59
60// Lock entrypoints.
61extern "C" void art_quick_lock_object_from_code(void*);
62extern "C" void art_quick_unlock_object_from_code(void*);
63
64// Math entrypoints.
65extern "C" double art_quick_fmod_from_code(double, double);
66extern "C" float art_quick_fmodf_from_code(float, float);
67extern "C" double art_quick_l2d_from_code(int64_t);
68extern "C" float art_quick_l2f_from_code(int64_t);
69extern "C" int64_t art_quick_d2l_from_code(double);
70extern "C" int64_t art_quick_f2l_from_code(float);
71extern "C" int32_t art_quick_idivmod_from_code(int32_t, int32_t);
72extern "C" int64_t art_quick_ldiv_from_code(int64_t, int64_t);
73extern "C" int64_t art_quick_ldivmod_from_code(int64_t, int64_t);
74extern "C" int64_t art_quick_lmul_from_code(int64_t, int64_t);
75extern "C" uint64_t art_quick_lshl_from_code(uint64_t, uint32_t);
76extern "C" uint64_t art_quick_lshr_from_code(uint64_t, uint32_t);
77extern "C" uint64_t art_quick_lushr_from_code(uint64_t, uint32_t);
78
79// Interpreter entrypoints.
80extern "C" void artInterpreterToInterpreterEntry(Thread* self, MethodHelper& mh,
81 const DexFile::CodeItem* code_item,
82 ShadowFrame* shadow_frame, JValue* result);
83extern "C" void artInterpreterToQuickEntry(Thread* self, MethodHelper& mh,
84 const DexFile::CodeItem* code_item,
85 ShadowFrame* shadow_frame, JValue* result);
86
87// Intrinsic entrypoints.
88extern "C" int32_t art_quick_memcmp16(void*, void*, int32_t);
89extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t);
90extern "C" int32_t art_quick_string_compareto(void*, void*);
91extern "C" void* art_quick_memcpy(void*, const void*, size_t);
92
93// Invoke entrypoints.
94extern "C" const void* artPortableResolutionTrampoline(mirror::AbstractMethod* called,
95 mirror::Object* receiver,
96 mirror::AbstractMethod** sp, Thread* thread);
97extern "C" const void* artQuickResolutionTrampoline(mirror::AbstractMethod* called,
98 mirror::Object* receiver,
99 mirror::AbstractMethod** sp, Thread* thread);
100extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*);
101extern "C" void art_quick_invoke_interface_trampoline(uint32_t, void*);
102extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*);
103extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*);
104extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*);
105extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*);
106
107// Thread entrypoints.
108extern void CheckSuspendFromCode(Thread* thread);
109extern "C" void art_quick_test_suspend();
110
111// Throw entrypoints.
112extern "C" void art_quick_deliver_exception_from_code(void*);
113extern "C" void art_quick_throw_array_bounds_from_code(int32_t index, int32_t limit);
114extern "C" void art_quick_throw_div_zero_from_code();
115extern "C" void art_quick_throw_no_such_method_from_code(int32_t method_idx);
116extern "C" void art_quick_throw_null_pointer_exception_from_code();
117extern "C" void art_quick_throw_stack_overflow_from_code(void*);
118
119void InitEntryPoints(QuickEntryPoints* qpoints, PortableEntryPoints* ppoints) {
120 // Alloc
121 qpoints->pAllocArrayFromCode = art_quick_alloc_array_from_code;
122 qpoints->pAllocArrayFromCodeWithAccessCheck = art_quick_alloc_array_from_code_with_access_check;
123 qpoints->pAllocObjectFromCode = art_quick_alloc_object_from_code;
124 qpoints->pAllocObjectFromCodeWithAccessCheck = art_quick_alloc_object_from_code_with_access_check;
125 qpoints->pCheckAndAllocArrayFromCode = art_quick_check_and_alloc_array_from_code;
126 qpoints->pCheckAndAllocArrayFromCodeWithAccessCheck = art_quick_check_and_alloc_array_from_code_with_access_check;
127
128 // Cast
129 qpoints->pInstanceofNonTrivialFromCode = art_quick_is_assignable_from_code;
130 qpoints->pCanPutArrayElementFromCode = art_quick_can_put_array_element_from_code;
131 qpoints->pCheckCastFromCode = art_quick_check_cast_from_code;
132
133 // DexCache
134 qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage_from_code;
135 qpoints->pInitializeTypeAndVerifyAccessFromCode = art_quick_initialize_type_and_verify_access_from_code;
136 qpoints->pInitializeTypeFromCode = art_quick_initialize_type_from_code;
137 qpoints->pResolveStringFromCode = art_quick_resolve_string_from_code;
138
139 // Field
140 qpoints->pSet32Instance = art_quick_set32_instance_from_code;
141 qpoints->pSet32Static = art_quick_set32_static_from_code;
142 qpoints->pSet64Instance = art_quick_set64_instance_from_code;
143 qpoints->pSet64Static = art_quick_set64_static_from_code;
144 qpoints->pSetObjInstance = art_quick_set_obj_instance_from_code;
145 qpoints->pSetObjStatic = art_quick_set_obj_static_from_code;
146 qpoints->pGet32Instance = art_quick_get32_instance_from_code;
147 qpoints->pGet64Instance = art_quick_get64_instance_from_code;
148 qpoints->pGetObjInstance = art_quick_get_obj_instance_from_code;
149 qpoints->pGet32Static = art_quick_get32_static_from_code;
150 qpoints->pGet64Static = art_quick_get64_static_from_code;
151 qpoints->pGetObjStatic = art_quick_get_obj_static_from_code;
152
153 // FillArray
154 qpoints->pHandleFillArrayDataFromCode = art_quick_handle_fill_data_from_code;
155
156 // JNI
157 qpoints->pJniMethodStart = JniMethodStart;
158 qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized;
159 qpoints->pJniMethodEnd = JniMethodEnd;
160 qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized;
161 qpoints->pJniMethodEndWithReference = JniMethodEndWithReference;
162 qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized;
163
164 // Locks
165 qpoints->pLockObjectFromCode = art_quick_lock_object_from_code;
166 qpoints->pUnlockObjectFromCode = art_quick_unlock_object_from_code;
167
168 // Math
169 // points->pCmpgDouble = NULL; // Not needed on x86.
170 // points->pCmpgFloat = NULL; // Not needed on x86.
171 // points->pCmplDouble = NULL; // Not needed on x86.
172 // points->pCmplFloat = NULL; // Not needed on x86.
173 qpoints->pFmod = art_quick_fmod_from_code;
174 qpoints->pL2d = art_quick_l2d_from_code;
175 qpoints->pFmodf = art_quick_fmodf_from_code;
176 qpoints->pL2f = art_quick_l2f_from_code;
177 // points->pD2iz = NULL; // Not needed on x86.
178 // points->pF2iz = NULL; // Not needed on x86.
179 qpoints->pIdivmod = art_quick_idivmod_from_code;
180 qpoints->pD2l = art_quick_d2l_from_code;
181 qpoints->pF2l = art_quick_f2l_from_code;
182 qpoints->pLdiv = art_quick_ldiv_from_code;
183 qpoints->pLdivmod = art_quick_ldivmod_from_code;
184 qpoints->pLmul = art_quick_lmul_from_code;
185 qpoints->pShlLong = art_quick_lshl_from_code;
186 qpoints->pShrLong = art_quick_lshr_from_code;
187 qpoints->pUshrLong = art_quick_lushr_from_code;
188
189 // Interpreter
190 qpoints->pInterpreterToInterpreterEntry = artInterpreterToInterpreterEntry;
191 qpoints->pInterpreterToQuickEntry = artInterpreterToQuickEntry;
192
193 // Intrinsics
194 qpoints->pIndexOf = art_quick_indexof;
195 qpoints->pMemcmp16 = art_quick_memcmp16;
196 qpoints->pStringCompareTo = art_quick_string_compareto;
197 qpoints->pMemcpy = art_quick_memcpy;
198
199 // Invocation
200 qpoints->pQuickResolutionTrampolineFromCode = artQuickResolutionTrampoline;
201 qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check;
202 qpoints->pInvokeInterfaceTrampoline = art_quick_invoke_interface_trampoline;
203 qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check;
204 qpoints->pInvokeStaticTrampolineWithAccessCheck = art_quick_invoke_static_trampoline_with_access_check;
205 qpoints->pInvokeSuperTrampolineWithAccessCheck = art_quick_invoke_super_trampoline_with_access_check;
206 qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check;
207
208 // Thread
209 qpoints->pCheckSuspendFromCode = CheckSuspendFromCode;
210 qpoints->pTestSuspendFromCode = art_quick_test_suspend;
211
212 // Throws
213 qpoints->pDeliverException = art_quick_deliver_exception_from_code;
214 qpoints->pThrowArrayBoundsFromCode = art_quick_throw_array_bounds_from_code;
215 qpoints->pThrowDivZeroFromCode = art_quick_throw_div_zero_from_code;
216 qpoints->pThrowNoSuchMethodFromCode = art_quick_throw_no_such_method_from_code;
217 qpoints->pThrowNullPointerFromCode = art_quick_throw_null_pointer_exception_from_code;
218 qpoints->pThrowStackOverflowFromCode = art_quick_throw_stack_overflow_from_code;
219
220 // Portable
221 ppoints->pPortableResolutionTrampolineFromCode = artPortableResolutionTrampoline;
222};
223
224} // namespace art