blob: cbb2c27f6098bf3afba81bc153fed53316817074 [file] [log] [blame]
Stuart Monteithb95a5342014-03-12 13:32:32 +00001/*
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
Stuart Monteithb95a5342014-03-12 13:32:32 +000075// Single-precision FP arithmetics.
Zheng Xu0210d112014-06-17 12:25:48 +080076extern "C" float art_quick_fmodf(float a, float b); // REM_FLOAT[_2ADDR]
Stuart Monteithb95a5342014-03-12 13:32:32 +000077
78// Double-precision FP arithmetics.
Zheng Xu0210d112014-06-17 12:25:48 +080079extern "C" double art_quick_fmod(double a, double b); // REM_DOUBLE[_2ADDR]
80
81// Memcpy
82extern "C" void* art_quick_memcpy(void* __restrict, const void* __restrict, size_t);
Stuart Monteithb95a5342014-03-12 13:32:32 +000083
Stuart Monteithb95a5342014-03-12 13:32:32 +000084// Intrinsic entrypoints.
Stuart Monteithb95a5342014-03-12 13:32:32 +000085extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t);
86extern "C" int32_t art_quick_string_compareto(void*, void*);
87
88// Invoke entrypoints.
89extern "C" void art_quick_imt_conflict_trampoline(mirror::ArtMethod*);
90extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*);
91extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*);
92extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*);
93extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*);
94extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*);
95extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*);
96extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*);
97
98// Thread entrypoints.
99extern void CheckSuspendFromCode(Thread* thread);
100extern "C" void art_quick_test_suspend();
101
102// Throw entrypoints.
103extern "C" void art_quick_deliver_exception(void*);
104extern "C" void art_quick_throw_array_bounds(int32_t index, int32_t limit);
105extern "C" void art_quick_throw_div_zero();
106extern "C" void art_quick_throw_no_such_method(int32_t method_idx);
107extern "C" void art_quick_throw_null_pointer_exception();
108extern "C" void art_quick_throw_stack_overflow(void*);
109
110extern void ResetQuickAllocEntryPoints(QuickEntryPoints* qpoints);
111
112// Generic JNI downcall
113extern "C" void art_quick_generic_jni_trampoline(mirror::ArtMethod*);
114
115void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints,
116 PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) {
117 // Interpreter
118 ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge;
119 ipoints->pInterpreterToCompiledCodeBridge = artInterpreterToCompiledCodeBridge;
120
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
128 // Alloc
129 ResetQuickAllocEntryPoints(qpoints);
130
131 // Cast
132 qpoints->pInstanceofNonTrivial = artIsAssignableFromCode;
133 qpoints->pCheckCast = art_quick_check_cast;
134
135 // DexCache
136 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;
140
141 // Field
142 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;
154
155 // 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;
159 qpoints->pHandleFillArrayData = art_quick_handle_fill_data;
160
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 qpoints->pQuickGenericJniTrampoline = art_quick_generic_jni_trampoline;
169
170 // Locks
171 qpoints->pLockObject = art_quick_lock_object;
172 qpoints->pUnlockObject = art_quick_unlock_object;
173
174 // Math
Zheng Xu0210d112014-06-17 12:25:48 +0800175 // TODO nullptr entrypoints not needed for ARM64 - generate inline.
176 qpoints->pCmpgDouble = nullptr;
177 qpoints->pCmpgFloat = nullptr;
178 qpoints->pCmplDouble = nullptr;
179 qpoints->pCmplFloat = nullptr;
180 qpoints->pFmod = art_quick_fmod;
181 qpoints->pL2d = nullptr;
182 qpoints->pFmodf = art_quick_fmodf;
183 qpoints->pL2f = nullptr;
184 qpoints->pD2iz = nullptr;
185 qpoints->pF2iz = nullptr;
186 qpoints->pIdivmod = nullptr;
187 qpoints->pD2l = nullptr;
188 qpoints->pF2l = nullptr;
189 qpoints->pLdiv = nullptr;
190 qpoints->pLmod = nullptr;
191 qpoints->pLmul = nullptr;
192 qpoints->pShlLong = nullptr;
193 qpoints->pShrLong = nullptr;
194 qpoints->pUshrLong = nullptr;
Stuart Monteithb95a5342014-03-12 13:32:32 +0000195
196 // Intrinsics
197 qpoints->pIndexOf = art_quick_indexof;
Stuart Monteithb95a5342014-03-12 13:32:32 +0000198 qpoints->pStringCompareTo = art_quick_string_compareto;
Zheng Xu0210d112014-06-17 12:25:48 +0800199 qpoints->pMemcpy = art_quick_memcpy;
Stuart Monteithb95a5342014-03-12 13:32:32 +0000200
201 // Invocation
202 qpoints->pQuickImtConflictTrampoline = art_quick_imt_conflict_trampoline;
203 qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline;
204 qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge;
205 qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check;
206 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
212 qpoints->pCheckSuspend = CheckSuspendFromCode;
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};
223
224} // namespace art