blob: c30dca186a9a71aba3650f9cbceedf2009c0c6da [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"
Mathieu Chartierd8891782014-03-02 13:28:37 -080018#include "entrypoints/quick/quick_alloc_entrypoints.h"
Ian Rogers7655f292013-07-29 11:07:13 -070019#include "entrypoints/quick/quick_entrypoints.h"
20#include "entrypoints/entrypoint_utils.h"
21
22namespace art {
23
Ian Rogers7655f292013-07-29 11:07:13 -070024// Interpreter entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070025extern "C" void artInterpreterToInterpreterBridge(Thread* self, MethodHelper& mh,
26 const DexFile::CodeItem* code_item,
27 ShadowFrame* shadow_frame, JValue* result);
Dragos Sbirlea08bf1962013-08-12 08:53:04 -070028extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& mh,
Ian Rogers7655f292013-07-29 11:07:13 -070029 const DexFile::CodeItem* code_item,
30 ShadowFrame* shadow_frame, JValue* result);
31
Ian Rogers848871b2013-08-05 10:56:33 -070032// Portable entrypoints.
Brian Carlstromea46f952013-07-30 01:26:50 -070033extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*);
34extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers848871b2013-08-05 10:56:33 -070035
Ian Rogers848871b2013-08-05 10:56:33 -070036// Cast entrypoints.
37extern "C" uint32_t art_quick_is_assignable(const mirror::Class* klass,
38 const mirror::Class* ref_class);
Ian Rogers848871b2013-08-05 10:56:33 -070039extern "C" void art_quick_check_cast(void*, void*);
40
41// DexCache entrypoints.
42extern "C" void* art_quick_initialize_static_storage(uint32_t, void*);
43extern "C" void* art_quick_initialize_type(uint32_t, void*);
44extern "C" void* art_quick_initialize_type_and_verify_access(uint32_t, void*);
45extern "C" void* art_quick_resolve_string(void*, uint32_t);
46
47// Field entrypoints.
48extern "C" int art_quick_set32_instance(uint32_t, void*, int32_t);
49extern "C" int art_quick_set32_static(uint32_t, int32_t);
50extern "C" int art_quick_set64_instance(uint32_t, void*, int64_t);
51extern "C" int art_quick_set64_static(uint32_t, int64_t);
52extern "C" int art_quick_set_obj_instance(uint32_t, void*, void*);
53extern "C" int art_quick_set_obj_static(uint32_t, void*);
54extern "C" int32_t art_quick_get32_instance(uint32_t, void*);
55extern "C" int32_t art_quick_get32_static(uint32_t);
56extern "C" int64_t art_quick_get64_instance(uint32_t, void*);
57extern "C" int64_t art_quick_get64_static(uint32_t);
58extern "C" void* art_quick_get_obj_instance(uint32_t, void*);
59extern "C" void* art_quick_get_obj_static(uint32_t);
60
Ian Rogersa9a82542013-10-04 11:17:26 -070061// Array entrypoints.
62extern "C" void art_quick_aput_obj_with_null_and_bound_check(void*, uint32_t, void*);
63extern "C" void art_quick_aput_obj_with_bound_check(void*, uint32_t, void*);
64extern "C" void art_quick_aput_obj(void*, uint32_t, void*);
Ian Rogers848871b2013-08-05 10:56:33 -070065extern "C" void art_quick_handle_fill_data(void*, void*);
66
67// Lock entrypoints.
68extern "C" void art_quick_lock_object(void*);
69extern "C" void art_quick_unlock_object(void*);
70
71// Math entrypoints.
72extern "C" double art_quick_fmod(double, double);
73extern "C" float art_quick_fmodf(float, float);
Ian Rogers848871b2013-08-05 10:56:33 -070074extern "C" int64_t art_quick_d2l(double);
75extern "C" int64_t art_quick_f2l(float);
Ian Rogers848871b2013-08-05 10:56:33 -070076extern "C" int64_t art_quick_ldiv(int64_t, int64_t);
Ian Rogersa9a82542013-10-04 11:17:26 -070077extern "C" int64_t art_quick_lmod(int64_t, int64_t);
Ian Rogers848871b2013-08-05 10:56:33 -070078extern "C" int64_t art_quick_lmul(int64_t, int64_t);
79extern "C" uint64_t art_quick_lshl(uint64_t, uint32_t);
80extern "C" uint64_t art_quick_lshr(uint64_t, uint32_t);
81extern "C" uint64_t art_quick_lushr(uint64_t, uint32_t);
82
Ian Rogers7655f292013-07-29 11:07:13 -070083// Intrinsic entrypoints.
Ian Rogers7655f292013-07-29 11:07:13 -070084extern "C" int32_t art_quick_string_compareto(void*, void*);
85extern "C" void* art_quick_memcpy(void*, const void*, size_t);
86
87// Invoke entrypoints.
Jeff Hao88474b42013-10-23 16:24:40 -070088extern "C" void art_quick_imt_conflict_trampoline(mirror::ArtMethod*);
Brian Carlstromea46f952013-07-30 01:26:50 -070089extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*);
90extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers7655f292013-07-29 11:07:13 -070091extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*);
Ian Rogers7655f292013-07-29 11:07:13 -070092extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*);
93extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*);
94extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*);
95extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*);
96
97// Thread entrypoints.
98extern void CheckSuspendFromCode(Thread* thread);
99extern "C" void art_quick_test_suspend();
100
101// Throw entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -0700102extern "C" void art_quick_deliver_exception(void*);
103extern "C" void art_quick_throw_array_bounds(int32_t index, int32_t limit);
104extern "C" void art_quick_throw_div_zero();
105extern "C" void art_quick_throw_no_such_method(int32_t method_idx);
106extern "C" void art_quick_throw_null_pointer_exception();
107extern "C" void art_quick_throw_stack_overflow(void*);
Ian Rogers7655f292013-07-29 11:07:13 -0700108
Andreas Gampe2da88232014-02-27 12:26:20 -0800109// Generic JNI downcall
110extern "C" void art_quick_generic_jni_trampoline(mirror::ArtMethod*);
111
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800112extern void ResetQuickAllocEntryPoints(QuickEntryPoints* qpoints);
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700113
Ian Rogers848871b2013-08-05 10:56:33 -0700114void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints,
115 PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) {
116 // Interpreter
117 ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge;
Dragos Sbirlea08bf1962013-08-12 08:53:04 -0700118 ipoints->pInterpreterToCompiledCodeBridge = artInterpreterToCompiledCodeBridge;
Ian Rogers848871b2013-08-05 10:56:33 -0700119
120 // JNI
121 jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub;
122
123 // Portable
124 ppoints->pPortableResolutionTrampoline = art_portable_resolution_trampoline;
125 ppoints->pPortableToInterpreterBridge = art_portable_to_interpreter_bridge;
126
Ian Rogers7655f292013-07-29 11:07:13 -0700127 // Alloc
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700128 ResetQuickAllocEntryPoints(qpoints);
Ian Rogers7655f292013-07-29 11:07:13 -0700129
130 // Cast
Ian Rogers848871b2013-08-05 10:56:33 -0700131 qpoints->pInstanceofNonTrivial = art_quick_is_assignable;
Ian Rogers848871b2013-08-05 10:56:33 -0700132 qpoints->pCheckCast = art_quick_check_cast;
Ian Rogers7655f292013-07-29 11:07:13 -0700133
134 // DexCache
Ian Rogers848871b2013-08-05 10:56:33 -0700135 qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage;
136 qpoints->pInitializeTypeAndVerifyAccess = art_quick_initialize_type_and_verify_access;
137 qpoints->pInitializeType = art_quick_initialize_type;
138 qpoints->pResolveString = art_quick_resolve_string;
Ian Rogers7655f292013-07-29 11:07:13 -0700139
140 // Field
Ian Rogers848871b2013-08-05 10:56:33 -0700141 qpoints->pSet32Instance = art_quick_set32_instance;
142 qpoints->pSet32Static = art_quick_set32_static;
143 qpoints->pSet64Instance = art_quick_set64_instance;
144 qpoints->pSet64Static = art_quick_set64_static;
145 qpoints->pSetObjInstance = art_quick_set_obj_instance;
146 qpoints->pSetObjStatic = art_quick_set_obj_static;
147 qpoints->pGet32Instance = art_quick_get32_instance;
148 qpoints->pGet64Instance = art_quick_get64_instance;
149 qpoints->pGetObjInstance = art_quick_get_obj_instance;
150 qpoints->pGet32Static = art_quick_get32_static;
151 qpoints->pGet64Static = art_quick_get64_static;
152 qpoints->pGetObjStatic = art_quick_get_obj_static;
Ian Rogers7655f292013-07-29 11:07:13 -0700153
Ian Rogersa9a82542013-10-04 11:17:26 -0700154 // Array
155 qpoints->pAputObjectWithNullAndBoundCheck = art_quick_aput_obj_with_null_and_bound_check;
156 qpoints->pAputObjectWithBoundCheck = art_quick_aput_obj_with_bound_check;
157 qpoints->pAputObject = art_quick_aput_obj;
Ian Rogers848871b2013-08-05 10:56:33 -0700158 qpoints->pHandleFillArrayData = art_quick_handle_fill_data;
Ian Rogers7655f292013-07-29 11:07:13 -0700159
160 // JNI
161 qpoints->pJniMethodStart = JniMethodStart;
162 qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized;
163 qpoints->pJniMethodEnd = JniMethodEnd;
164 qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized;
165 qpoints->pJniMethodEndWithReference = JniMethodEndWithReference;
166 qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized;
Andreas Gampe2da88232014-02-27 12:26:20 -0800167 qpoints->pQuickGenericJniTrampoline = art_quick_generic_jni_trampoline;
Ian Rogers7655f292013-07-29 11:07:13 -0700168
169 // Locks
Ian Rogers848871b2013-08-05 10:56:33 -0700170 qpoints->pLockObject = art_quick_lock_object;
171 qpoints->pUnlockObject = art_quick_unlock_object;
Ian Rogers7655f292013-07-29 11:07:13 -0700172
173 // Math
174 // points->pCmpgDouble = NULL; // Not needed on x86.
175 // points->pCmpgFloat = NULL; // Not needed on x86.
176 // points->pCmplDouble = NULL; // Not needed on x86.
177 // points->pCmplFloat = NULL; // Not needed on x86.
Ian Rogers848871b2013-08-05 10:56:33 -0700178 qpoints->pFmod = art_quick_fmod;
Alexei Zavjalov1d4d7bd2014-05-23 17:51:59 +0700179 // qpoints->pL2d = NULL; // Not needed on x86.
Ian Rogers848871b2013-08-05 10:56:33 -0700180 qpoints->pFmodf = art_quick_fmodf;
Alexei Zavjalov1d4d7bd2014-05-23 17:51:59 +0700181 // qpoints->pL2f = NULL; // Not needed on x86.
Ian Rogers7655f292013-07-29 11:07:13 -0700182 // points->pD2iz = NULL; // Not needed on x86.
183 // points->pF2iz = NULL; // Not needed on x86.
Alexei Zavjalov1d4d7bd2014-05-23 17:51:59 +0700184 // qpoints->pIdivmod = NULL; // Not needed on x86.
Ian Rogers848871b2013-08-05 10:56:33 -0700185 qpoints->pD2l = art_quick_d2l;
186 qpoints->pF2l = art_quick_f2l;
187 qpoints->pLdiv = art_quick_ldiv;
Ian Rogersa9a82542013-10-04 11:17:26 -0700188 qpoints->pLmod = art_quick_lmod;
Ian Rogers848871b2013-08-05 10:56:33 -0700189 qpoints->pLmul = art_quick_lmul;
190 qpoints->pShlLong = art_quick_lshl;
191 qpoints->pShrLong = art_quick_lshr;
192 qpoints->pUshrLong = art_quick_lushr;
Ian Rogers7655f292013-07-29 11:07:13 -0700193
194 // Intrinsics
Mark Mendell4028a6c2014-02-19 20:06:20 -0800195 // qpoints->pIndexOf = nullptr; // Not needed on x86
Ian Rogers7655f292013-07-29 11:07:13 -0700196 qpoints->pStringCompareTo = art_quick_string_compareto;
197 qpoints->pMemcpy = art_quick_memcpy;
198
199 // Invocation
Jeff Hao88474b42013-10-23 16:24:40 -0700200 qpoints->pQuickImtConflictTrampoline = art_quick_imt_conflict_trampoline;
Ian Rogers848871b2013-08-05 10:56:33 -0700201 qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline;
202 qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge;
Ian Rogers7655f292013-07-29 11:07:13 -0700203 qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check;
Ian Rogers7655f292013-07-29 11:07:13 -0700204 qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check;
205 qpoints->pInvokeStaticTrampolineWithAccessCheck = art_quick_invoke_static_trampoline_with_access_check;
206 qpoints->pInvokeSuperTrampolineWithAccessCheck = art_quick_invoke_super_trampoline_with_access_check;
207 qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check;
208
209 // Thread
Ian Rogers848871b2013-08-05 10:56:33 -0700210 qpoints->pCheckSuspend = CheckSuspendFromCode;
211 qpoints->pTestSuspend = art_quick_test_suspend;
Ian Rogers7655f292013-07-29 11:07:13 -0700212
213 // Throws
Ian Rogers848871b2013-08-05 10:56:33 -0700214 qpoints->pDeliverException = art_quick_deliver_exception;
215 qpoints->pThrowArrayBounds = art_quick_throw_array_bounds;
216 qpoints->pThrowDivZero = art_quick_throw_div_zero;
217 qpoints->pThrowNoSuchMethod = art_quick_throw_no_such_method;
218 qpoints->pThrowNullPointer = art_quick_throw_null_pointer_exception;
219 qpoints->pThrowStackOverflow = art_quick_throw_stack_overflow;
Ian Rogers7655f292013-07-29 11:07:13 -0700220};
221
222} // namespace art