blob: 89dd1b8f8caa00eeda4225643fe16463017e6bc3 [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
Ian Rogers7655f292013-07-29 11:07:13 -070023// Interpreter entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070024extern "C" void artInterpreterToInterpreterBridge(Thread* self, MethodHelper& mh,
25 const DexFile::CodeItem* code_item,
26 ShadowFrame* shadow_frame, JValue* result);
Dragos Sbirlea08bf1962013-08-12 08:53:04 -070027extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& mh,
Ian Rogers7655f292013-07-29 11:07:13 -070028 const DexFile::CodeItem* code_item,
29 ShadowFrame* shadow_frame, JValue* result);
30
Ian Rogers848871b2013-08-05 10:56:33 -070031// Portable entrypoints.
Brian Carlstromea46f952013-07-30 01:26:50 -070032extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*);
33extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers848871b2013-08-05 10:56:33 -070034
35// Alloc entrypoints.
36extern "C" void* art_quick_alloc_array(uint32_t, void*, int32_t);
37extern "C" void* art_quick_alloc_array_with_access_check(uint32_t, void*, int32_t);
38extern "C" void* art_quick_alloc_object(uint32_t type_idx, void* method);
39extern "C" void* art_quick_alloc_object_with_access_check(uint32_t type_idx, void* method);
40extern "C" void* art_quick_check_and_alloc_array(uint32_t, void*, int32_t);
41extern "C" void* art_quick_check_and_alloc_array_with_access_check(uint32_t, void*, int32_t);
42
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -070043extern "C" void* art_quick_alloc_array_instrumented(uint32_t, void*, int32_t);
44extern "C" void* art_quick_alloc_array_with_access_check_instrumented(uint32_t, void*, int32_t);
45extern "C" void* art_quick_alloc_object_instrumented(uint32_t type_idx, void* method);
46extern "C" void* art_quick_alloc_object_with_access_check_instrumented(uint32_t type_idx, void* method);
47extern "C" void* art_quick_check_and_alloc_array_instrumented(uint32_t, void*, int32_t);
48extern "C" void* art_quick_check_and_alloc_array_with_access_check_instrumented(uint32_t, void*, int32_t);
49
Ian Rogers848871b2013-08-05 10:56:33 -070050// Cast entrypoints.
51extern "C" uint32_t art_quick_is_assignable(const mirror::Class* klass,
52 const mirror::Class* ref_class);
Ian Rogers848871b2013-08-05 10:56:33 -070053extern "C" void art_quick_check_cast(void*, void*);
54
55// DexCache entrypoints.
56extern "C" void* art_quick_initialize_static_storage(uint32_t, void*);
57extern "C" void* art_quick_initialize_type(uint32_t, void*);
58extern "C" void* art_quick_initialize_type_and_verify_access(uint32_t, void*);
59extern "C" void* art_quick_resolve_string(void*, uint32_t);
60
61// Field entrypoints.
62extern "C" int art_quick_set32_instance(uint32_t, void*, int32_t);
63extern "C" int art_quick_set32_static(uint32_t, int32_t);
64extern "C" int art_quick_set64_instance(uint32_t, void*, int64_t);
65extern "C" int art_quick_set64_static(uint32_t, int64_t);
66extern "C" int art_quick_set_obj_instance(uint32_t, void*, void*);
67extern "C" int art_quick_set_obj_static(uint32_t, void*);
68extern "C" int32_t art_quick_get32_instance(uint32_t, void*);
69extern "C" int32_t art_quick_get32_static(uint32_t);
70extern "C" int64_t art_quick_get64_instance(uint32_t, void*);
71extern "C" int64_t art_quick_get64_static(uint32_t);
72extern "C" void* art_quick_get_obj_instance(uint32_t, void*);
73extern "C" void* art_quick_get_obj_static(uint32_t);
74
Ian Rogersa9a82542013-10-04 11:17:26 -070075// Array entrypoints.
76extern "C" void art_quick_aput_obj_with_null_and_bound_check(void*, uint32_t, void*);
77extern "C" void art_quick_aput_obj_with_bound_check(void*, uint32_t, void*);
78extern "C" void art_quick_aput_obj(void*, uint32_t, void*);
Ian Rogers848871b2013-08-05 10:56:33 -070079extern "C" void art_quick_handle_fill_data(void*, void*);
80
81// Lock entrypoints.
82extern "C" void art_quick_lock_object(void*);
83extern "C" void art_quick_unlock_object(void*);
84
85// Math entrypoints.
86extern "C" double art_quick_fmod(double, double);
87extern "C" float art_quick_fmodf(float, float);
88extern "C" double art_quick_l2d(int64_t);
89extern "C" float art_quick_l2f(int64_t);
90extern "C" int64_t art_quick_d2l(double);
91extern "C" int64_t art_quick_f2l(float);
92extern "C" int32_t art_quick_idivmod(int32_t, int32_t);
93extern "C" int64_t art_quick_ldiv(int64_t, int64_t);
Ian Rogersa9a82542013-10-04 11:17:26 -070094extern "C" int64_t art_quick_lmod(int64_t, int64_t);
Ian Rogers848871b2013-08-05 10:56:33 -070095extern "C" int64_t art_quick_lmul(int64_t, int64_t);
96extern "C" uint64_t art_quick_lshl(uint64_t, uint32_t);
97extern "C" uint64_t art_quick_lshr(uint64_t, uint32_t);
98extern "C" uint64_t art_quick_lushr(uint64_t, uint32_t);
99
Ian Rogers7655f292013-07-29 11:07:13 -0700100// Intrinsic entrypoints.
101extern "C" int32_t art_quick_memcmp16(void*, void*, int32_t);
102extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t);
103extern "C" int32_t art_quick_string_compareto(void*, void*);
104extern "C" void* art_quick_memcpy(void*, const void*, size_t);
105
106// Invoke entrypoints.
Brian Carlstromea46f952013-07-30 01:26:50 -0700107extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*);
108extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers7655f292013-07-29 11:07:13 -0700109extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*);
110extern "C" void art_quick_invoke_interface_trampoline(uint32_t, void*);
111extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*);
112extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*);
113extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*);
114extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*);
115
116// Thread entrypoints.
117extern void CheckSuspendFromCode(Thread* thread);
118extern "C" void art_quick_test_suspend();
119
120// Throw entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -0700121extern "C" void art_quick_deliver_exception(void*);
122extern "C" void art_quick_throw_array_bounds(int32_t index, int32_t limit);
123extern "C" void art_quick_throw_div_zero();
124extern "C" void art_quick_throw_no_such_method(int32_t method_idx);
125extern "C" void art_quick_throw_null_pointer_exception();
126extern "C" void art_quick_throw_stack_overflow(void*);
Ian Rogers7655f292013-07-29 11:07:13 -0700127
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700128static bool quick_alloc_entry_points_instrumented = false;
129
130void SetQuickAllocEntryPointsInstrumented(bool instrumented) {
131 quick_alloc_entry_points_instrumented = instrumented;
132}
133
134void ResetQuickAllocEntryPoints(QuickEntryPoints* qpoints) {
135 if (quick_alloc_entry_points_instrumented) {
136 qpoints->pAllocArray = art_quick_alloc_array_instrumented;
137 qpoints->pAllocArrayWithAccessCheck = art_quick_alloc_array_with_access_check_instrumented;
138 qpoints->pAllocObject = art_quick_alloc_object_instrumented;
139 qpoints->pAllocObjectWithAccessCheck = art_quick_alloc_object_with_access_check_instrumented;
140 qpoints->pCheckAndAllocArray = art_quick_check_and_alloc_array_instrumented;
141 qpoints->pCheckAndAllocArrayWithAccessCheck = art_quick_check_and_alloc_array_with_access_check_instrumented;
142 } else {
143 qpoints->pAllocArray = art_quick_alloc_array;
144 qpoints->pAllocArrayWithAccessCheck = art_quick_alloc_array_with_access_check;
145 qpoints->pAllocObject = art_quick_alloc_object;
146 qpoints->pAllocObjectWithAccessCheck = art_quick_alloc_object_with_access_check;
147 qpoints->pCheckAndAllocArray = art_quick_check_and_alloc_array;
148 qpoints->pCheckAndAllocArrayWithAccessCheck = art_quick_check_and_alloc_array_with_access_check;
149 }
150}
151
Ian Rogers848871b2013-08-05 10:56:33 -0700152void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints,
153 PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) {
154 // Interpreter
155 ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge;
Dragos Sbirlea08bf1962013-08-12 08:53:04 -0700156 ipoints->pInterpreterToCompiledCodeBridge = artInterpreterToCompiledCodeBridge;
Ian Rogers848871b2013-08-05 10:56:33 -0700157
158 // JNI
159 jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub;
160
161 // Portable
162 ppoints->pPortableResolutionTrampoline = art_portable_resolution_trampoline;
163 ppoints->pPortableToInterpreterBridge = art_portable_to_interpreter_bridge;
164
Ian Rogers7655f292013-07-29 11:07:13 -0700165 // Alloc
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700166 ResetQuickAllocEntryPoints(qpoints);
Ian Rogers7655f292013-07-29 11:07:13 -0700167
168 // Cast
Ian Rogers848871b2013-08-05 10:56:33 -0700169 qpoints->pInstanceofNonTrivial = art_quick_is_assignable;
Ian Rogers848871b2013-08-05 10:56:33 -0700170 qpoints->pCheckCast = art_quick_check_cast;
Ian Rogers7655f292013-07-29 11:07:13 -0700171
172 // DexCache
Ian Rogers848871b2013-08-05 10:56:33 -0700173 qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage;
174 qpoints->pInitializeTypeAndVerifyAccess = art_quick_initialize_type_and_verify_access;
175 qpoints->pInitializeType = art_quick_initialize_type;
176 qpoints->pResolveString = art_quick_resolve_string;
Ian Rogers7655f292013-07-29 11:07:13 -0700177
178 // Field
Ian Rogers848871b2013-08-05 10:56:33 -0700179 qpoints->pSet32Instance = art_quick_set32_instance;
180 qpoints->pSet32Static = art_quick_set32_static;
181 qpoints->pSet64Instance = art_quick_set64_instance;
182 qpoints->pSet64Static = art_quick_set64_static;
183 qpoints->pSetObjInstance = art_quick_set_obj_instance;
184 qpoints->pSetObjStatic = art_quick_set_obj_static;
185 qpoints->pGet32Instance = art_quick_get32_instance;
186 qpoints->pGet64Instance = art_quick_get64_instance;
187 qpoints->pGetObjInstance = art_quick_get_obj_instance;
188 qpoints->pGet32Static = art_quick_get32_static;
189 qpoints->pGet64Static = art_quick_get64_static;
190 qpoints->pGetObjStatic = art_quick_get_obj_static;
Ian Rogers7655f292013-07-29 11:07:13 -0700191
Ian Rogersa9a82542013-10-04 11:17:26 -0700192 // Array
193 qpoints->pAputObjectWithNullAndBoundCheck = art_quick_aput_obj_with_null_and_bound_check;
194 qpoints->pAputObjectWithBoundCheck = art_quick_aput_obj_with_bound_check;
195 qpoints->pAputObject = art_quick_aput_obj;
Ian Rogers848871b2013-08-05 10:56:33 -0700196 qpoints->pHandleFillArrayData = art_quick_handle_fill_data;
Ian Rogers7655f292013-07-29 11:07:13 -0700197
198 // JNI
199 qpoints->pJniMethodStart = JniMethodStart;
200 qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized;
201 qpoints->pJniMethodEnd = JniMethodEnd;
202 qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized;
203 qpoints->pJniMethodEndWithReference = JniMethodEndWithReference;
204 qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized;
205
206 // Locks
Ian Rogers848871b2013-08-05 10:56:33 -0700207 qpoints->pLockObject = art_quick_lock_object;
208 qpoints->pUnlockObject = art_quick_unlock_object;
Ian Rogers7655f292013-07-29 11:07:13 -0700209
210 // Math
211 // points->pCmpgDouble = NULL; // Not needed on x86.
212 // points->pCmpgFloat = NULL; // Not needed on x86.
213 // points->pCmplDouble = NULL; // Not needed on x86.
214 // points->pCmplFloat = NULL; // Not needed on x86.
Ian Rogers848871b2013-08-05 10:56:33 -0700215 qpoints->pFmod = art_quick_fmod;
216 qpoints->pL2d = art_quick_l2d;
217 qpoints->pFmodf = art_quick_fmodf;
218 qpoints->pL2f = art_quick_l2f;
Ian Rogers7655f292013-07-29 11:07:13 -0700219 // points->pD2iz = NULL; // Not needed on x86.
220 // points->pF2iz = NULL; // Not needed on x86.
Ian Rogers848871b2013-08-05 10:56:33 -0700221 qpoints->pIdivmod = art_quick_idivmod;
222 qpoints->pD2l = art_quick_d2l;
223 qpoints->pF2l = art_quick_f2l;
224 qpoints->pLdiv = art_quick_ldiv;
Ian Rogersa9a82542013-10-04 11:17:26 -0700225 qpoints->pLmod = art_quick_lmod;
Ian Rogers848871b2013-08-05 10:56:33 -0700226 qpoints->pLmul = art_quick_lmul;
227 qpoints->pShlLong = art_quick_lshl;
228 qpoints->pShrLong = art_quick_lshr;
229 qpoints->pUshrLong = art_quick_lushr;
Ian Rogers7655f292013-07-29 11:07:13 -0700230
231 // Intrinsics
232 qpoints->pIndexOf = art_quick_indexof;
233 qpoints->pMemcmp16 = art_quick_memcmp16;
234 qpoints->pStringCompareTo = art_quick_string_compareto;
235 qpoints->pMemcpy = art_quick_memcpy;
236
237 // Invocation
Ian Rogers848871b2013-08-05 10:56:33 -0700238 qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline;
239 qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge;
Ian Rogers7655f292013-07-29 11:07:13 -0700240 qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check;
241 qpoints->pInvokeInterfaceTrampoline = art_quick_invoke_interface_trampoline;
242 qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check;
243 qpoints->pInvokeStaticTrampolineWithAccessCheck = art_quick_invoke_static_trampoline_with_access_check;
244 qpoints->pInvokeSuperTrampolineWithAccessCheck = art_quick_invoke_super_trampoline_with_access_check;
245 qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check;
246
247 // Thread
Ian Rogers848871b2013-08-05 10:56:33 -0700248 qpoints->pCheckSuspend = CheckSuspendFromCode;
249 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;
Ian Rogers7655f292013-07-29 11:07:13 -0700258};
259
260} // namespace art