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/quick/quick_alloc_entrypoints.h"
20 #include "entrypoints/quick/quick_default_externs.h"
21 #include "entrypoints/quick/quick_entrypoints.h"
22 #include "entrypoints/entrypoint_utils.h"
23 #include "entrypoints/math_entrypoints.h"
24 #include "entrypoints/runtime_asm_entrypoints.h"
25 #include "interpreter/interpreter.h"
26
27 namespace art {
28
29 // Cast entrypoints.
30 extern "C" uint32_t artIsAssignableFromCode(const mirror::Class* klass,
31 const mirror::Class* ref_class);
32
33
34 // Used by soft float.
35 // Single-precision FP arithmetics.
36 extern "C" float fmodf(float a, float b); // REM_FLOAT[_2ADDR]
37 // Double-precision FP arithmetics.
38 extern "C" double fmod(double a, double b); // REM_DOUBLE[_2ADDR]
39
40 // Used by hard float.
41 extern "C" float art_quick_fmodf(float a, float b); // REM_FLOAT[_2ADDR]
42 extern "C" double art_quick_fmod(double a, double b); // REM_DOUBLE[_2ADDR]
43
44 // Integer arithmetics.
45 extern "C" int __aeabi_idivmod(int32_t, int32_t); // [DIV|REM]_INT[_2ADDR|_LIT8|_LIT16]
46
47 // Long long arithmetics - REM_LONG[_2ADDR] and DIV_LONG[_2ADDR]
48 extern "C" int64_t __aeabi_ldivmod(int64_t, int64_t);
49
InitEntryPoints(InterpreterEntryPoints * ipoints,JniEntryPoints * jpoints,QuickEntryPoints * qpoints)50 void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints,
51 QuickEntryPoints* qpoints) {
52 // Interpreter
53 ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge;
54 ipoints->pInterpreterToCompiledCodeBridge = artInterpreterToCompiledCodeBridge;
55
56 // JNI
57 jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub;
58
59 // Alloc
60 ResetQuickAllocEntryPoints(qpoints);
61
62 // Cast
63 qpoints->pInstanceofNonTrivial = artIsAssignableFromCode;
64 qpoints->pCheckCast = art_quick_check_cast;
65
66 // DexCache
67 qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage;
68 qpoints->pInitializeTypeAndVerifyAccess = art_quick_initialize_type_and_verify_access;
69 qpoints->pInitializeType = art_quick_initialize_type;
70 qpoints->pResolveString = art_quick_resolve_string;
71
72 // Field
73 qpoints->pSet8Instance = art_quick_set8_instance;
74 qpoints->pSet8Static = art_quick_set8_static;
75 qpoints->pSet16Instance = art_quick_set16_instance;
76 qpoints->pSet16Static = art_quick_set16_static;
77 qpoints->pSet32Instance = art_quick_set32_instance;
78 qpoints->pSet32Static = art_quick_set32_static;
79 qpoints->pSet64Instance = art_quick_set64_instance;
80 qpoints->pSet64Static = art_quick_set64_static;
81 qpoints->pSetObjInstance = art_quick_set_obj_instance;
82 qpoints->pSetObjStatic = art_quick_set_obj_static;
83 qpoints->pGetByteInstance = art_quick_get_byte_instance;
84 qpoints->pGetBooleanInstance = art_quick_get_boolean_instance;
85 qpoints->pGetShortInstance = art_quick_get_short_instance;
86 qpoints->pGetCharInstance = art_quick_get_char_instance;
87 qpoints->pGet32Instance = art_quick_get32_instance;
88 qpoints->pGet64Instance = art_quick_get64_instance;
89 qpoints->pGetObjInstance = art_quick_get_obj_instance;
90 qpoints->pGetByteStatic = art_quick_get_byte_static;
91 qpoints->pGetBooleanStatic = art_quick_get_boolean_static;
92 qpoints->pGetShortStatic = art_quick_get_short_static;
93 qpoints->pGetCharStatic = art_quick_get_char_static;
94 qpoints->pGet32Static = art_quick_get32_static;
95 qpoints->pGet64Static = art_quick_get64_static;
96 qpoints->pGetObjStatic = art_quick_get_obj_static;
97
98 // Array
99 qpoints->pAputObjectWithNullAndBoundCheck = art_quick_aput_obj_with_null_and_bound_check;
100 qpoints->pAputObjectWithBoundCheck = art_quick_aput_obj_with_bound_check;
101 qpoints->pAputObject = art_quick_aput_obj;
102 qpoints->pHandleFillArrayData = art_quick_handle_fill_data;
103
104 // JNI
105 qpoints->pJniMethodStart = JniMethodStart;
106 qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized;
107 qpoints->pJniMethodEnd = JniMethodEnd;
108 qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized;
109 qpoints->pJniMethodEndWithReference = JniMethodEndWithReference;
110 qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized;
111 qpoints->pQuickGenericJniTrampoline = art_quick_generic_jni_trampoline;
112
113 // Locks
114 qpoints->pLockObject = art_quick_lock_object;
115 qpoints->pUnlockObject = art_quick_unlock_object;
116
117 // Math
118 qpoints->pIdivmod = __aeabi_idivmod;
119 qpoints->pLdiv = __aeabi_ldivmod;
120 qpoints->pLmod = __aeabi_ldivmod; // result returned in r2:r3
121 qpoints->pLmul = art_quick_mul_long;
122 qpoints->pShlLong = art_quick_shl_long;
123 qpoints->pShrLong = art_quick_shr_long;
124 qpoints->pUshrLong = art_quick_ushr_long;
125 if (kArm32QuickCodeUseSoftFloat) {
126 qpoints->pFmod = fmod;
127 qpoints->pFmodf = fmodf;
128 qpoints->pD2l = art_d2l;
129 qpoints->pF2l = art_f2l;
130 } else {
131 qpoints->pFmod = art_quick_fmod;
132 qpoints->pFmodf = art_quick_fmodf;
133 qpoints->pD2l = art_quick_d2l;
134 qpoints->pF2l = art_quick_f2l;
135 }
136
137 // Intrinsics
138 qpoints->pIndexOf = art_quick_indexof;
139 qpoints->pStringCompareTo = art_quick_string_compareto;
140 qpoints->pMemcpy = memcpy;
141
142 // Invocation
143 qpoints->pQuickImtConflictTrampoline = art_quick_imt_conflict_trampoline;
144 qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline;
145 qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge;
146 qpoints->pInvokeDirectTrampolineWithAccessCheck =
147 art_quick_invoke_direct_trampoline_with_access_check;
148 qpoints->pInvokeInterfaceTrampolineWithAccessCheck =
149 art_quick_invoke_interface_trampoline_with_access_check;
150 qpoints->pInvokeStaticTrampolineWithAccessCheck =
151 art_quick_invoke_static_trampoline_with_access_check;
152 qpoints->pInvokeSuperTrampolineWithAccessCheck =
153 art_quick_invoke_super_trampoline_with_access_check;
154 qpoints->pInvokeVirtualTrampolineWithAccessCheck =
155 art_quick_invoke_virtual_trampoline_with_access_check;
156
157 // Thread
158 qpoints->pTestSuspend = art_quick_test_suspend;
159
160 // Throws
161 qpoints->pDeliverException = art_quick_deliver_exception;
162 qpoints->pThrowArrayBounds = art_quick_throw_array_bounds;
163 qpoints->pThrowDivZero = art_quick_throw_div_zero;
164 qpoints->pThrowNoSuchMethod = art_quick_throw_no_such_method;
165 qpoints->pThrowNullPointer = art_quick_throw_null_pointer_exception;
166 qpoints->pThrowStackOverflow = art_quick_throw_stack_overflow;
167
168 qpoints->pDeoptimize = art_quick_deoptimize;
169
170 // Read barrier
171 qpoints->pReadBarrierJni = ReadBarrierJni;
172 }
173
174 } // namespace art
175