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