blob: 589c7d9dc9c1d8ff300c71b02dfe977e3d91f8e6 [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
Ian Rogers848871b2013-08-05 10:56:33 -070035// Cast entrypoints.
36extern "C" uint32_t art_quick_is_assignable(const mirror::Class* klass,
37 const mirror::Class* ref_class);
Ian Rogers848871b2013-08-05 10:56:33 -070038extern "C" void art_quick_check_cast(void*, void*);
39
40// DexCache entrypoints.
41extern "C" void* art_quick_initialize_static_storage(uint32_t, void*);
42extern "C" void* art_quick_initialize_type(uint32_t, void*);
43extern "C" void* art_quick_initialize_type_and_verify_access(uint32_t, void*);
44extern "C" void* art_quick_resolve_string(void*, uint32_t);
45
46// Field entrypoints.
47extern "C" int art_quick_set32_instance(uint32_t, void*, int32_t);
48extern "C" int art_quick_set32_static(uint32_t, int32_t);
49extern "C" int art_quick_set64_instance(uint32_t, void*, int64_t);
50extern "C" int art_quick_set64_static(uint32_t, int64_t);
51extern "C" int art_quick_set_obj_instance(uint32_t, void*, void*);
52extern "C" int art_quick_set_obj_static(uint32_t, void*);
53extern "C" int32_t art_quick_get32_instance(uint32_t, void*);
54extern "C" int32_t art_quick_get32_static(uint32_t);
55extern "C" int64_t art_quick_get64_instance(uint32_t, void*);
56extern "C" int64_t art_quick_get64_static(uint32_t);
57extern "C" void* art_quick_get_obj_instance(uint32_t, void*);
58extern "C" void* art_quick_get_obj_static(uint32_t);
59
Ian Rogersa9a82542013-10-04 11:17:26 -070060// Array entrypoints.
61extern "C" void art_quick_aput_obj_with_null_and_bound_check(void*, uint32_t, void*);
62extern "C" void art_quick_aput_obj_with_bound_check(void*, uint32_t, void*);
63extern "C" void art_quick_aput_obj(void*, uint32_t, void*);
Ian Rogers848871b2013-08-05 10:56:33 -070064extern "C" void art_quick_handle_fill_data(void*, void*);
65
66// Lock entrypoints.
67extern "C" void art_quick_lock_object(void*);
68extern "C" void art_quick_unlock_object(void*);
69
70// Math entrypoints.
71extern "C" double art_quick_fmod(double, double);
72extern "C" float art_quick_fmodf(float, float);
73extern "C" double art_quick_l2d(int64_t);
74extern "C" float art_quick_l2f(int64_t);
75extern "C" int64_t art_quick_d2l(double);
76extern "C" int64_t art_quick_f2l(float);
77extern "C" int32_t art_quick_idivmod(int32_t, int32_t);
78extern "C" int64_t art_quick_ldiv(int64_t, int64_t);
Ian Rogersa9a82542013-10-04 11:17:26 -070079extern "C" int64_t art_quick_lmod(int64_t, int64_t);
Ian Rogers848871b2013-08-05 10:56:33 -070080extern "C" int64_t art_quick_lmul(int64_t, int64_t);
81extern "C" uint64_t art_quick_lshl(uint64_t, uint32_t);
82extern "C" uint64_t art_quick_lshr(uint64_t, uint32_t);
83extern "C" uint64_t art_quick_lushr(uint64_t, uint32_t);
84
Ian Rogers7655f292013-07-29 11:07:13 -070085// Intrinsic entrypoints.
86extern "C" int32_t art_quick_memcmp16(void*, void*, int32_t);
87extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t);
88extern "C" int32_t art_quick_string_compareto(void*, void*);
89extern "C" void* art_quick_memcpy(void*, const void*, size_t);
90
91// Invoke entrypoints.
Jeff Hao88474b42013-10-23 16:24:40 -070092extern "C" void art_quick_imt_conflict_trampoline(mirror::ArtMethod*);
Brian Carlstromea46f952013-07-30 01:26:50 -070093extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*);
94extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers7655f292013-07-29 11:07:13 -070095extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*);
Ian Rogers7655f292013-07-29 11:07:13 -070096extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*);
97extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*);
98extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*);
99extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*);
100
101// Thread entrypoints.
102extern void CheckSuspendFromCode(Thread* thread);
103extern "C" void art_quick_test_suspend();
104
105// Throw entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -0700106extern "C" void art_quick_deliver_exception(void*);
107extern "C" void art_quick_throw_array_bounds(int32_t index, int32_t limit);
108extern "C" void art_quick_throw_div_zero();
109extern "C" void art_quick_throw_no_such_method(int32_t method_idx);
110extern "C" void art_quick_throw_null_pointer_exception();
111extern "C" void art_quick_throw_stack_overflow(void*);
Ian Rogers7655f292013-07-29 11:07:13 -0700112
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800113extern void ResetQuickAllocEntryPoints(QuickEntryPoints* qpoints);
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700114
Ian Rogers848871b2013-08-05 10:56:33 -0700115void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints,
116 PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) {
117 // Interpreter
118 ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge;
Dragos Sbirlea08bf1962013-08-12 08:53:04 -0700119 ipoints->pInterpreterToCompiledCodeBridge = artInterpreterToCompiledCodeBridge;
Ian Rogers848871b2013-08-05 10:56:33 -0700120
121 // JNI
122 jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub;
123
124 // Portable
125 ppoints->pPortableResolutionTrampoline = art_portable_resolution_trampoline;
126 ppoints->pPortableToInterpreterBridge = art_portable_to_interpreter_bridge;
127
Ian Rogers7655f292013-07-29 11:07:13 -0700128 // Alloc
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700129 ResetQuickAllocEntryPoints(qpoints);
Ian Rogers7655f292013-07-29 11:07:13 -0700130
131 // Cast
Ian Rogers848871b2013-08-05 10:56:33 -0700132 qpoints->pInstanceofNonTrivial = art_quick_is_assignable;
Ian Rogers848871b2013-08-05 10:56:33 -0700133 qpoints->pCheckCast = art_quick_check_cast;
Ian Rogers7655f292013-07-29 11:07:13 -0700134
135 // DexCache
Ian Rogers848871b2013-08-05 10:56:33 -0700136 qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage;
137 qpoints->pInitializeTypeAndVerifyAccess = art_quick_initialize_type_and_verify_access;
138 qpoints->pInitializeType = art_quick_initialize_type;
139 qpoints->pResolveString = art_quick_resolve_string;
Ian Rogers7655f292013-07-29 11:07:13 -0700140
141 // Field
Ian Rogers848871b2013-08-05 10:56:33 -0700142 qpoints->pSet32Instance = art_quick_set32_instance;
143 qpoints->pSet32Static = art_quick_set32_static;
144 qpoints->pSet64Instance = art_quick_set64_instance;
145 qpoints->pSet64Static = art_quick_set64_static;
146 qpoints->pSetObjInstance = art_quick_set_obj_instance;
147 qpoints->pSetObjStatic = art_quick_set_obj_static;
148 qpoints->pGet32Instance = art_quick_get32_instance;
149 qpoints->pGet64Instance = art_quick_get64_instance;
150 qpoints->pGetObjInstance = art_quick_get_obj_instance;
151 qpoints->pGet32Static = art_quick_get32_static;
152 qpoints->pGet64Static = art_quick_get64_static;
153 qpoints->pGetObjStatic = art_quick_get_obj_static;
Ian Rogers7655f292013-07-29 11:07:13 -0700154
Ian Rogersa9a82542013-10-04 11:17:26 -0700155 // Array
156 qpoints->pAputObjectWithNullAndBoundCheck = art_quick_aput_obj_with_null_and_bound_check;
157 qpoints->pAputObjectWithBoundCheck = art_quick_aput_obj_with_bound_check;
158 qpoints->pAputObject = art_quick_aput_obj;
Ian Rogers848871b2013-08-05 10:56:33 -0700159 qpoints->pHandleFillArrayData = art_quick_handle_fill_data;
Ian Rogers7655f292013-07-29 11:07:13 -0700160
161 // JNI
162 qpoints->pJniMethodStart = JniMethodStart;
163 qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized;
164 qpoints->pJniMethodEnd = JniMethodEnd;
165 qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized;
166 qpoints->pJniMethodEndWithReference = JniMethodEndWithReference;
167 qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized;
168
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;
Vladimir Marko12f96282013-12-16 14:44:03 +0000179 // qpoints->pSqrt = NULL; // Not needed on x86.
Ian Rogers848871b2013-08-05 10:56:33 -0700180 qpoints->pL2d = art_quick_l2d;
181 qpoints->pFmodf = art_quick_fmodf;
182 qpoints->pL2f = art_quick_l2f;
Ian Rogers7655f292013-07-29 11:07:13 -0700183 // points->pD2iz = NULL; // Not needed on x86.
184 // points->pF2iz = NULL; // Not needed on x86.
Ian Rogers848871b2013-08-05 10:56:33 -0700185 qpoints->pIdivmod = art_quick_idivmod;
186 qpoints->pD2l = art_quick_d2l;
187 qpoints->pF2l = art_quick_f2l;
188 qpoints->pLdiv = art_quick_ldiv;
Ian Rogersa9a82542013-10-04 11:17:26 -0700189 qpoints->pLmod = art_quick_lmod;
Ian Rogers848871b2013-08-05 10:56:33 -0700190 qpoints->pLmul = art_quick_lmul;
191 qpoints->pShlLong = art_quick_lshl;
192 qpoints->pShrLong = art_quick_lshr;
193 qpoints->pUshrLong = art_quick_lushr;
Ian Rogers7655f292013-07-29 11:07:13 -0700194
195 // Intrinsics
196 qpoints->pIndexOf = art_quick_indexof;
197 qpoints->pMemcmp16 = art_quick_memcmp16;
198 qpoints->pStringCompareTo = art_quick_string_compareto;
199 qpoints->pMemcpy = art_quick_memcpy;
200
201 // Invocation
Jeff Hao88474b42013-10-23 16:24:40 -0700202 qpoints->pQuickImtConflictTrampoline = art_quick_imt_conflict_trampoline;
Ian Rogers848871b2013-08-05 10:56:33 -0700203 qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline;
204 qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge;
Ian Rogers7655f292013-07-29 11:07:13 -0700205 qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check;
Ian Rogers7655f292013-07-29 11:07:13 -0700206 qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check;
207 qpoints->pInvokeStaticTrampolineWithAccessCheck = art_quick_invoke_static_trampoline_with_access_check;
208 qpoints->pInvokeSuperTrampolineWithAccessCheck = art_quick_invoke_super_trampoline_with_access_check;
209 qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check;
210
211 // Thread
Ian Rogers848871b2013-08-05 10:56:33 -0700212 qpoints->pCheckSuspend = CheckSuspendFromCode;
213 qpoints->pTestSuspend = art_quick_test_suspend;
Ian Rogers7655f292013-07-29 11:07:13 -0700214
215 // Throws
Ian Rogers848871b2013-08-05 10:56:33 -0700216 qpoints->pDeliverException = art_quick_deliver_exception;
217 qpoints->pThrowArrayBounds = art_quick_throw_array_bounds;
218 qpoints->pThrowDivZero = art_quick_throw_div_zero;
219 qpoints->pThrowNoSuchMethod = art_quick_throw_no_such_method;
220 qpoints->pThrowNullPointer = art_quick_throw_null_pointer_exception;
221 qpoints->pThrowStackOverflow = art_quick_throw_stack_overflow;
Ian Rogers7655f292013-07-29 11:07:13 -0700222};
223
224} // namespace art