1 /*
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/interpreter/interpreter_entrypoints.h"
18 #include "entrypoints/jni/jni_entrypoints.h"
19 #include "entrypoints/portable/portable_entrypoints.h"
20 #include "entrypoints/quick/quick_alloc_entrypoints.h"
21 #include "entrypoints/quick/quick_entrypoints.h"
22 #include "entrypoints/entrypoint_utils.h"
23
24 namespace art {
25
26 // Interpreter entrypoints.
27 extern "C" void artInterpreterToInterpreterBridge(Thread* self, MethodHelper& mh,
28 const DexFile::CodeItem* code_item,
29 ShadowFrame* shadow_frame, JValue* result);
30 extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& mh,
31 const DexFile::CodeItem* code_item,
32 ShadowFrame* shadow_frame, JValue* result);
33
34 // Portable entrypoints.
35 extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*);
36 extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*);
37
38 // Cast entrypoints.
39 extern "C" uint32_t art_quick_is_assignable(const mirror::Class* klass,
40 const mirror::Class* ref_class);
41 extern "C" void art_quick_check_cast(void*, void*);
42
43 // DexCache entrypoints.
44 extern "C" void* art_quick_initialize_static_storage(uint32_t, void*);
45 extern "C" void* art_quick_initialize_type(uint32_t, void*);
46 extern "C" void* art_quick_initialize_type_and_verify_access(uint32_t, void*);
47 extern "C" void* art_quick_resolve_string(void*, uint32_t);
48
49 // Field entrypoints.
50 extern "C" int art_quick_set32_instance(uint32_t, void*, int32_t);
51 extern "C" int art_quick_set32_static(uint32_t, int32_t);
52 extern "C" int art_quick_set64_instance(uint32_t, void*, int64_t);
53 extern "C" int art_quick_set64_static(uint32_t, int64_t);
54 extern "C" int art_quick_set_obj_instance(uint32_t, void*, void*);
55 extern "C" int art_quick_set_obj_static(uint32_t, void*);
56 extern "C" int32_t art_quick_get32_instance(uint32_t, void*);
57 extern "C" int32_t art_quick_get32_static(uint32_t);
58 extern "C" int64_t art_quick_get64_instance(uint32_t, void*);
59 extern "C" int64_t art_quick_get64_static(uint32_t);
60 extern "C" void* art_quick_get_obj_instance(uint32_t, void*);
61 extern "C" void* art_quick_get_obj_static(uint32_t);
62
63 // Array entrypoints.
64 extern "C" void art_quick_aput_obj_with_null_and_bound_check(void*, uint32_t, void*);
65 extern "C" void art_quick_aput_obj_with_bound_check(void*, uint32_t, void*);
66 extern "C" void art_quick_aput_obj(void*, uint32_t, void*);
67 extern "C" void art_quick_handle_fill_data(void*, void*);
68
69 // Lock entrypoints.
70 extern "C" void art_quick_lock_object(void*);
71 extern "C" void art_quick_unlock_object(void*);
72
73 // Math entrypoints.
74 extern "C" int64_t art_quick_d2l(double);
75 extern "C" int64_t art_quick_f2l(float);
76 extern "C" int64_t art_quick_ldiv(int64_t, int64_t);
77 extern "C" int64_t art_quick_lmod(int64_t, int64_t);
78 extern "C" int64_t art_quick_lmul(int64_t, int64_t);
79 extern "C" uint64_t art_quick_lshl(uint64_t, uint32_t);
80 extern "C" uint64_t art_quick_lshr(uint64_t, uint32_t);
81 extern "C" uint64_t art_quick_lushr(uint64_t, uint32_t);
82
83 // Intrinsic entrypoints.
84 extern "C" int32_t art_quick_string_compareto(void*, void*);
85 extern "C" void* art_quick_memcpy(void*, const void*, size_t);
86
87 // Invoke entrypoints.
88 extern "C" void art_quick_imt_conflict_trampoline(mirror::ArtMethod*);
89 extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*);
90 extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*);
91 extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*);
92 extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*);
93 extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*);
94 extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*);
95 extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*);
96
97 // Thread entrypoints.
98 extern "C" void art_quick_test_suspend();
99
100 // Throw entrypoints.
101 extern "C" void art_quick_deliver_exception(void*);
102 extern "C" void art_quick_throw_array_bounds(int32_t index, int32_t limit);
103 extern "C" void art_quick_throw_div_zero();
104 extern "C" void art_quick_throw_no_such_method(int32_t method_idx);
105 extern "C" void art_quick_throw_null_pointer_exception();
106 extern "C" void art_quick_throw_stack_overflow(void*);
107
108 // Generic JNI downcall
109 extern "C" void art_quick_generic_jni_trampoline(mirror::ArtMethod*);
110
111 extern void ResetQuickAllocEntryPoints(QuickEntryPoints* qpoints);
112
InitEntryPoints(InterpreterEntryPoints * ipoints,JniEntryPoints * jpoints,PortableEntryPoints * ppoints,QuickEntryPoints * qpoints)113 void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints,
114 PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) {
115 // Interpreter
116 ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge;
117 ipoints->pInterpreterToCompiledCodeBridge = artInterpreterToCompiledCodeBridge;
118
119 // JNI
120 jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub;
121
122 // Portable
123 ppoints->pPortableResolutionTrampoline = art_portable_resolution_trampoline;
124 ppoints->pPortableToInterpreterBridge = art_portable_to_interpreter_bridge;
125
126 // Alloc
127 ResetQuickAllocEntryPoints(qpoints);
128
129 // Cast
130 qpoints->pInstanceofNonTrivial = art_quick_is_assignable;
131 qpoints->pCheckCast = art_quick_check_cast;
132
133 // DexCache
134 qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage;
135 qpoints->pInitializeTypeAndVerifyAccess = art_quick_initialize_type_and_verify_access;
136 qpoints->pInitializeType = art_quick_initialize_type;
137 qpoints->pResolveString = art_quick_resolve_string;
138
139 // Field
140 qpoints->pSet32Instance = art_quick_set32_instance;
141 qpoints->pSet32Static = art_quick_set32_static;
142 qpoints->pSet64Instance = art_quick_set64_instance;
143 qpoints->pSet64Static = art_quick_set64_static;
144 qpoints->pSetObjInstance = art_quick_set_obj_instance;
145 qpoints->pSetObjStatic = art_quick_set_obj_static;
146 qpoints->pGet32Instance = art_quick_get32_instance;
147 qpoints->pGet64Instance = art_quick_get64_instance;
148 qpoints->pGetObjInstance = art_quick_get_obj_instance;
149 qpoints->pGet32Static = art_quick_get32_static;
150 qpoints->pGet64Static = art_quick_get64_static;
151 qpoints->pGetObjStatic = art_quick_get_obj_static;
152
153 // Array
154 qpoints->pAputObjectWithNullAndBoundCheck = art_quick_aput_obj_with_null_and_bound_check;
155 qpoints->pAputObjectWithBoundCheck = art_quick_aput_obj_with_bound_check;
156 qpoints->pAputObject = art_quick_aput_obj;
157 qpoints->pHandleFillArrayData = art_quick_handle_fill_data;
158
159 // JNI
160 qpoints->pJniMethodStart = JniMethodStart;
161 qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized;
162 qpoints->pJniMethodEnd = JniMethodEnd;
163 qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized;
164 qpoints->pJniMethodEndWithReference = JniMethodEndWithReference;
165 qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized;
166 qpoints->pQuickGenericJniTrampoline = art_quick_generic_jni_trampoline;
167
168 // Locks
169 qpoints->pLockObject = art_quick_lock_object;
170 qpoints->pUnlockObject = art_quick_unlock_object;
171
172 // Math
173 // points->pCmpgDouble = NULL; // Not needed on x86.
174 // points->pCmpgFloat = NULL; // Not needed on x86.
175 // points->pCmplDouble = NULL; // Not needed on x86.
176 // points->pCmplFloat = NULL; // Not needed on x86.
177 // qpoints->pFmod = NULL; // Not needed on x86.
178 // qpoints->pL2d = NULL; // Not needed on x86.
179 // qpoints->pFmodf = NULL; // Not needed on x86.
180 // qpoints->pL2f = NULL; // Not needed on x86.
181 // points->pD2iz = NULL; // Not needed on x86.
182 // points->pF2iz = NULL; // Not needed on x86.
183 // qpoints->pIdivmod = NULL; // Not needed on x86.
184 qpoints->pD2l = art_quick_d2l;
185 qpoints->pF2l = art_quick_f2l;
186 qpoints->pLdiv = art_quick_ldiv;
187 qpoints->pLmod = art_quick_lmod;
188 qpoints->pLmul = art_quick_lmul;
189 qpoints->pShlLong = art_quick_lshl;
190 qpoints->pShrLong = art_quick_lshr;
191 qpoints->pUshrLong = art_quick_lushr;
192
193 // Intrinsics
194 // qpoints->pIndexOf = nullptr; // Not needed on x86
195 qpoints->pStringCompareTo = art_quick_string_compareto;
196 qpoints->pMemcpy = art_quick_memcpy;
197
198 // Invocation
199 qpoints->pQuickImtConflictTrampoline = art_quick_imt_conflict_trampoline;
200 qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline;
201 qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge;
202 qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check;
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->pTestSuspend = art_quick_test_suspend;
210
211 // Throws
212 qpoints->pDeliverException = art_quick_deliver_exception;
213 qpoints->pThrowArrayBounds = art_quick_throw_array_bounds;
214 qpoints->pThrowDivZero = art_quick_throw_div_zero;
215 qpoints->pThrowNoSuchMethod = art_quick_throw_no_such_method;
216 qpoints->pThrowNullPointer = art_quick_throw_null_pointer_exception;
217 qpoints->pThrowStackOverflow = art_quick_throw_stack_overflow;
218 };
219
220 } // namespace art
221