blob: 4c87e07608008642653ce4c321eaa286669e087e [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);
53extern "C" void art_quick_can_put_array_element(void*, void*);
54extern "C" void art_quick_check_cast(void*, void*);
55
56// DexCache entrypoints.
57extern "C" void* art_quick_initialize_static_storage(uint32_t, void*);
58extern "C" void* art_quick_initialize_type(uint32_t, void*);
59extern "C" void* art_quick_initialize_type_and_verify_access(uint32_t, void*);
60extern "C" void* art_quick_resolve_string(void*, uint32_t);
61
62// Field entrypoints.
63extern "C" int art_quick_set32_instance(uint32_t, void*, int32_t);
64extern "C" int art_quick_set32_static(uint32_t, int32_t);
65extern "C" int art_quick_set64_instance(uint32_t, void*, int64_t);
66extern "C" int art_quick_set64_static(uint32_t, int64_t);
67extern "C" int art_quick_set_obj_instance(uint32_t, void*, void*);
68extern "C" int art_quick_set_obj_static(uint32_t, void*);
69extern "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);
75
76// FillArray entrypoint.
77extern "C" void art_quick_handle_fill_data(void*, void*);
78
79// Lock entrypoints.
80extern "C" void art_quick_lock_object(void*);
81extern "C" void art_quick_unlock_object(void*);
82
83// Math entrypoints.
84extern "C" double art_quick_fmod(double, double);
85extern "C" float art_quick_fmodf(float, float);
86extern "C" double art_quick_l2d(int64_t);
87extern "C" float art_quick_l2f(int64_t);
88extern "C" int64_t art_quick_d2l(double);
89extern "C" int64_t art_quick_f2l(float);
90extern "C" int32_t art_quick_idivmod(int32_t, int32_t);
91extern "C" int64_t art_quick_ldiv(int64_t, int64_t);
92extern "C" int64_t art_quick_ldivmod(int64_t, int64_t);
93extern "C" int64_t art_quick_lmul(int64_t, int64_t);
94extern "C" uint64_t art_quick_lshl(uint64_t, uint32_t);
95extern "C" uint64_t art_quick_lshr(uint64_t, uint32_t);
96extern "C" uint64_t art_quick_lushr(uint64_t, uint32_t);
97
Ian Rogers7655f292013-07-29 11:07:13 -070098// Intrinsic entrypoints.
99extern "C" int32_t art_quick_memcmp16(void*, void*, int32_t);
100extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t);
101extern "C" int32_t art_quick_string_compareto(void*, void*);
102extern "C" void* art_quick_memcpy(void*, const void*, size_t);
103
104// Invoke entrypoints.
Brian Carlstromea46f952013-07-30 01:26:50 -0700105extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*);
106extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers7655f292013-07-29 11:07:13 -0700107extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*);
108extern "C" void art_quick_invoke_interface_trampoline(uint32_t, void*);
109extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*);
110extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*);
111extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*);
112extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*);
113
114// Thread entrypoints.
115extern void CheckSuspendFromCode(Thread* thread);
116extern "C" void art_quick_test_suspend();
117
118// Throw entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -0700119extern "C" void art_quick_deliver_exception(void*);
120extern "C" void art_quick_throw_array_bounds(int32_t index, int32_t limit);
121extern "C" void art_quick_throw_div_zero();
122extern "C" void art_quick_throw_no_such_method(int32_t method_idx);
123extern "C" void art_quick_throw_null_pointer_exception();
124extern "C" void art_quick_throw_stack_overflow(void*);
Ian Rogers7655f292013-07-29 11:07:13 -0700125
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700126static bool quick_alloc_entry_points_instrumented = false;
127
128void SetQuickAllocEntryPointsInstrumented(bool instrumented) {
129 quick_alloc_entry_points_instrumented = instrumented;
130}
131
132void ResetQuickAllocEntryPoints(QuickEntryPoints* qpoints) {
133 if (quick_alloc_entry_points_instrumented) {
134 qpoints->pAllocArray = art_quick_alloc_array_instrumented;
135 qpoints->pAllocArrayWithAccessCheck = art_quick_alloc_array_with_access_check_instrumented;
136 qpoints->pAllocObject = art_quick_alloc_object_instrumented;
137 qpoints->pAllocObjectWithAccessCheck = art_quick_alloc_object_with_access_check_instrumented;
138 qpoints->pCheckAndAllocArray = art_quick_check_and_alloc_array_instrumented;
139 qpoints->pCheckAndAllocArrayWithAccessCheck = art_quick_check_and_alloc_array_with_access_check_instrumented;
140 } else {
141 qpoints->pAllocArray = art_quick_alloc_array;
142 qpoints->pAllocArrayWithAccessCheck = art_quick_alloc_array_with_access_check;
143 qpoints->pAllocObject = art_quick_alloc_object;
144 qpoints->pAllocObjectWithAccessCheck = art_quick_alloc_object_with_access_check;
145 qpoints->pCheckAndAllocArray = art_quick_check_and_alloc_array;
146 qpoints->pCheckAndAllocArrayWithAccessCheck = art_quick_check_and_alloc_array_with_access_check;
147 }
148}
149
Ian Rogers848871b2013-08-05 10:56:33 -0700150void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints,
151 PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) {
152 // Interpreter
153 ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge;
Dragos Sbirlea08bf1962013-08-12 08:53:04 -0700154 ipoints->pInterpreterToCompiledCodeBridge = artInterpreterToCompiledCodeBridge;
Ian Rogers848871b2013-08-05 10:56:33 -0700155
156 // JNI
157 jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub;
158
159 // Portable
160 ppoints->pPortableResolutionTrampoline = art_portable_resolution_trampoline;
161 ppoints->pPortableToInterpreterBridge = art_portable_to_interpreter_bridge;
162
Ian Rogers7655f292013-07-29 11:07:13 -0700163 // Alloc
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700164 ResetQuickAllocEntryPoints(qpoints);
Ian Rogers7655f292013-07-29 11:07:13 -0700165
166 // Cast
Ian Rogers848871b2013-08-05 10:56:33 -0700167 qpoints->pInstanceofNonTrivial = art_quick_is_assignable;
168 qpoints->pCanPutArrayElement = art_quick_can_put_array_element;
169 qpoints->pCheckCast = art_quick_check_cast;
Ian Rogers7655f292013-07-29 11:07:13 -0700170
171 // DexCache
Ian Rogers848871b2013-08-05 10:56:33 -0700172 qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage;
173 qpoints->pInitializeTypeAndVerifyAccess = art_quick_initialize_type_and_verify_access;
174 qpoints->pInitializeType = art_quick_initialize_type;
175 qpoints->pResolveString = art_quick_resolve_string;
Ian Rogers7655f292013-07-29 11:07:13 -0700176
177 // Field
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;
184 qpoints->pGet32Instance = art_quick_get32_instance;
185 qpoints->pGet64Instance = art_quick_get64_instance;
186 qpoints->pGetObjInstance = art_quick_get_obj_instance;
187 qpoints->pGet32Static = art_quick_get32_static;
188 qpoints->pGet64Static = art_quick_get64_static;
189 qpoints->pGetObjStatic = art_quick_get_obj_static;
Ian Rogers7655f292013-07-29 11:07:13 -0700190
191 // FillArray
Ian Rogers848871b2013-08-05 10:56:33 -0700192 qpoints->pHandleFillArrayData = art_quick_handle_fill_data;
Ian Rogers7655f292013-07-29 11:07:13 -0700193
194 // JNI
195 qpoints->pJniMethodStart = JniMethodStart;
196 qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized;
197 qpoints->pJniMethodEnd = JniMethodEnd;
198 qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized;
199 qpoints->pJniMethodEndWithReference = JniMethodEndWithReference;
200 qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized;
201
202 // Locks
Ian Rogers848871b2013-08-05 10:56:33 -0700203 qpoints->pLockObject = art_quick_lock_object;
204 qpoints->pUnlockObject = art_quick_unlock_object;
Ian Rogers7655f292013-07-29 11:07:13 -0700205
206 // Math
207 // points->pCmpgDouble = NULL; // Not needed on x86.
208 // points->pCmpgFloat = NULL; // Not needed on x86.
209 // points->pCmplDouble = NULL; // Not needed on x86.
210 // points->pCmplFloat = NULL; // Not needed on x86.
Ian Rogers848871b2013-08-05 10:56:33 -0700211 qpoints->pFmod = art_quick_fmod;
212 qpoints->pL2d = art_quick_l2d;
213 qpoints->pFmodf = art_quick_fmodf;
214 qpoints->pL2f = art_quick_l2f;
Ian Rogers7655f292013-07-29 11:07:13 -0700215 // points->pD2iz = NULL; // Not needed on x86.
216 // points->pF2iz = NULL; // Not needed on x86.
Ian Rogers848871b2013-08-05 10:56:33 -0700217 qpoints->pIdivmod = art_quick_idivmod;
218 qpoints->pD2l = art_quick_d2l;
219 qpoints->pF2l = art_quick_f2l;
220 qpoints->pLdiv = art_quick_ldiv;
221 qpoints->pLdivmod = art_quick_ldivmod;
222 qpoints->pLmul = art_quick_lmul;
223 qpoints->pShlLong = art_quick_lshl;
224 qpoints->pShrLong = art_quick_lshr;
225 qpoints->pUshrLong = art_quick_lushr;
Ian Rogers7655f292013-07-29 11:07:13 -0700226
227 // Intrinsics
228 qpoints->pIndexOf = art_quick_indexof;
229 qpoints->pMemcmp16 = art_quick_memcmp16;
230 qpoints->pStringCompareTo = art_quick_string_compareto;
231 qpoints->pMemcpy = art_quick_memcpy;
232
233 // Invocation
Ian Rogers848871b2013-08-05 10:56:33 -0700234 qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline;
235 qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge;
Ian Rogers7655f292013-07-29 11:07:13 -0700236 qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check;
237 qpoints->pInvokeInterfaceTrampoline = art_quick_invoke_interface_trampoline;
238 qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check;
239 qpoints->pInvokeStaticTrampolineWithAccessCheck = art_quick_invoke_static_trampoline_with_access_check;
240 qpoints->pInvokeSuperTrampolineWithAccessCheck = art_quick_invoke_super_trampoline_with_access_check;
241 qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check;
242
243 // Thread
Ian Rogers848871b2013-08-05 10:56:33 -0700244 qpoints->pCheckSuspend = CheckSuspendFromCode;
245 qpoints->pTestSuspend = art_quick_test_suspend;
Ian Rogers7655f292013-07-29 11:07:13 -0700246
247 // Throws
Ian Rogers848871b2013-08-05 10:56:33 -0700248 qpoints->pDeliverException = art_quick_deliver_exception;
249 qpoints->pThrowArrayBounds = art_quick_throw_array_bounds;
250 qpoints->pThrowDivZero = art_quick_throw_div_zero;
251 qpoints->pThrowNoSuchMethod = art_quick_throw_no_such_method;
252 qpoints->pThrowNullPointer = art_quick_throw_null_pointer_exception;
253 qpoints->pThrowStackOverflow = art_quick_throw_stack_overflow;
Ian Rogers7655f292013-07-29 11:07:13 -0700254};
255
256} // namespace art