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