blob: c19b79efeffc16b85c58512cbbb5bce401890ce2 [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.
Serban Constantinescu86797a72014-06-19 16:17:56 +010038extern "C" uint32_t art_quick_assignable_from_code(const mirror::Class* klass,
Stuart Monteithb95a5342014-03-12 13:32:32 +000039 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
Stuart Monteithb95a5342014-03-12 13:32:32 +000048// Field entrypoints.
49extern "C" int art_quick_set32_instance(uint32_t, void*, int32_t);
50extern "C" int art_quick_set32_static(uint32_t, int32_t);
51extern "C" int art_quick_set64_instance(uint32_t, void*, int64_t);
52extern "C" int art_quick_set64_static(uint32_t, int64_t);
53extern "C" int art_quick_set_obj_instance(uint32_t, void*, void*);
54extern "C" int art_quick_set_obj_static(uint32_t, void*);
55extern "C" int32_t art_quick_get32_instance(uint32_t, void*);
56extern "C" int32_t art_quick_get32_static(uint32_t);
57extern "C" int64_t art_quick_get64_instance(uint32_t, void*);
58extern "C" int64_t art_quick_get64_static(uint32_t);
59extern "C" void* art_quick_get_obj_instance(uint32_t, void*);
60extern "C" void* art_quick_get_obj_static(uint32_t);
61
62// Array entrypoints.
63extern "C" void art_quick_aput_obj_with_null_and_bound_check(void*, uint32_t, void*);
64extern "C" void art_quick_aput_obj_with_bound_check(void*, uint32_t, void*);
65extern "C" void art_quick_aput_obj(void*, uint32_t, void*);
66extern "C" void art_quick_handle_fill_data(void*, void*);
67
68// Lock entrypoints.
69extern "C" void art_quick_lock_object(void*);
70extern "C" void art_quick_unlock_object(void*);
71
Stuart Monteithb95a5342014-03-12 13:32:32 +000072// Single-precision FP arithmetics.
Zheng Xu0210d112014-06-17 12:25:48 +080073extern "C" float art_quick_fmodf(float a, float b); // REM_FLOAT[_2ADDR]
Stuart Monteithb95a5342014-03-12 13:32:32 +000074
75// Double-precision FP arithmetics.
Zheng Xu0210d112014-06-17 12:25:48 +080076extern "C" double art_quick_fmod(double a, double b); // REM_DOUBLE[_2ADDR]
77
78// Memcpy
79extern "C" void* art_quick_memcpy(void* __restrict, const void* __restrict, size_t);
Stuart Monteithb95a5342014-03-12 13:32:32 +000080
Stuart Monteithb95a5342014-03-12 13:32:32 +000081// Intrinsic entrypoints.
Stuart Monteithb95a5342014-03-12 13:32:32 +000082extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t);
83extern "C" int32_t art_quick_string_compareto(void*, void*);
84
85// Invoke entrypoints.
86extern "C" void art_quick_imt_conflict_trampoline(mirror::ArtMethod*);
87extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*);
88extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*);
89extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*);
90extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*);
91extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*);
92extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*);
93extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*);
94
95// Thread entrypoints.
Stuart Monteithb95a5342014-03-12 13:32:32 +000096extern "C" void art_quick_test_suspend();
97
98// Throw entrypoints.
99extern "C" void art_quick_deliver_exception(void*);
100extern "C" void art_quick_throw_array_bounds(int32_t index, int32_t limit);
101extern "C" void art_quick_throw_div_zero();
102extern "C" void art_quick_throw_no_such_method(int32_t method_idx);
103extern "C" void art_quick_throw_null_pointer_exception();
104extern "C" void art_quick_throw_stack_overflow(void*);
105
106extern void ResetQuickAllocEntryPoints(QuickEntryPoints* qpoints);
107
108// Generic JNI downcall
109extern "C" void art_quick_generic_jni_trampoline(mirror::ArtMethod*);
110
111void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints,
112 PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) {
113 // Interpreter
114 ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge;
115 ipoints->pInterpreterToCompiledCodeBridge = artInterpreterToCompiledCodeBridge;
116
117 // JNI
118 jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub;
119
120 // Portable
121 ppoints->pPortableResolutionTrampoline = art_portable_resolution_trampoline;
122 ppoints->pPortableToInterpreterBridge = art_portable_to_interpreter_bridge;
123
124 // Alloc
125 ResetQuickAllocEntryPoints(qpoints);
126
127 // Cast
Serban Constantinescu86797a72014-06-19 16:17:56 +0100128 qpoints->pInstanceofNonTrivial = art_quick_assignable_from_code;
Stuart Monteithb95a5342014-03-12 13:32:32 +0000129 qpoints->pCheckCast = art_quick_check_cast;
130
131 // DexCache
132 qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage;
133 qpoints->pInitializeTypeAndVerifyAccess = art_quick_initialize_type_and_verify_access;
134 qpoints->pInitializeType = art_quick_initialize_type;
135 qpoints->pResolveString = art_quick_resolve_string;
136
137 // Field
138 qpoints->pSet32Instance = art_quick_set32_instance;
139 qpoints->pSet32Static = art_quick_set32_static;
140 qpoints->pSet64Instance = art_quick_set64_instance;
141 qpoints->pSet64Static = art_quick_set64_static;
142 qpoints->pSetObjInstance = art_quick_set_obj_instance;
143 qpoints->pSetObjStatic = art_quick_set_obj_static;
144 qpoints->pGet32Instance = art_quick_get32_instance;
145 qpoints->pGet64Instance = art_quick_get64_instance;
146 qpoints->pGetObjInstance = art_quick_get_obj_instance;
147 qpoints->pGet32Static = art_quick_get32_static;
148 qpoints->pGet64Static = art_quick_get64_static;
149 qpoints->pGetObjStatic = art_quick_get_obj_static;
150
151 // Array
152 qpoints->pAputObjectWithNullAndBoundCheck = art_quick_aput_obj_with_null_and_bound_check;
153 qpoints->pAputObjectWithBoundCheck = art_quick_aput_obj_with_bound_check;
154 qpoints->pAputObject = art_quick_aput_obj;
155 qpoints->pHandleFillArrayData = art_quick_handle_fill_data;
156
157 // JNI
158 qpoints->pJniMethodStart = JniMethodStart;
159 qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized;
160 qpoints->pJniMethodEnd = JniMethodEnd;
161 qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized;
162 qpoints->pJniMethodEndWithReference = JniMethodEndWithReference;
163 qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized;
164 qpoints->pQuickGenericJniTrampoline = art_quick_generic_jni_trampoline;
165
166 // Locks
167 qpoints->pLockObject = art_quick_lock_object;
168 qpoints->pUnlockObject = art_quick_unlock_object;
169
170 // Math
Zheng Xu0210d112014-06-17 12:25:48 +0800171 // TODO nullptr entrypoints not needed for ARM64 - generate inline.
172 qpoints->pCmpgDouble = nullptr;
173 qpoints->pCmpgFloat = nullptr;
174 qpoints->pCmplDouble = nullptr;
175 qpoints->pCmplFloat = nullptr;
176 qpoints->pFmod = art_quick_fmod;
177 qpoints->pL2d = nullptr;
178 qpoints->pFmodf = art_quick_fmodf;
179 qpoints->pL2f = nullptr;
180 qpoints->pD2iz = nullptr;
181 qpoints->pF2iz = nullptr;
182 qpoints->pIdivmod = nullptr;
183 qpoints->pD2l = nullptr;
184 qpoints->pF2l = nullptr;
185 qpoints->pLdiv = nullptr;
186 qpoints->pLmod = nullptr;
187 qpoints->pLmul = nullptr;
188 qpoints->pShlLong = nullptr;
189 qpoints->pShrLong = nullptr;
190 qpoints->pUshrLong = nullptr;
Stuart Monteithb95a5342014-03-12 13:32:32 +0000191
192 // Intrinsics
193 qpoints->pIndexOf = art_quick_indexof;
Stuart Monteithb95a5342014-03-12 13:32:32 +0000194 qpoints->pStringCompareTo = art_quick_string_compareto;
Zheng Xu0210d112014-06-17 12:25:48 +0800195 qpoints->pMemcpy = art_quick_memcpy;
Stuart Monteithb95a5342014-03-12 13:32:32 +0000196
197 // Invocation
198 qpoints->pQuickImtConflictTrampoline = art_quick_imt_conflict_trampoline;
199 qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline;
200 qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge;
201 qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check;
202 qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check;
203 qpoints->pInvokeStaticTrampolineWithAccessCheck = art_quick_invoke_static_trampoline_with_access_check;
204 qpoints->pInvokeSuperTrampolineWithAccessCheck = art_quick_invoke_super_trampoline_with_access_check;
205 qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check;
206
207 // Thread
Stuart Monteithb95a5342014-03-12 13:32:32 +0000208 qpoints->pTestSuspend = art_quick_test_suspend;
209
210 // Throws
211 qpoints->pDeliverException = art_quick_deliver_exception;
212 qpoints->pThrowArrayBounds = art_quick_throw_array_bounds;
213 qpoints->pThrowDivZero = art_quick_throw_div_zero;
214 qpoints->pThrowNoSuchMethod = art_quick_throw_no_such_method;
215 qpoints->pThrowNullPointer = art_quick_throw_null_pointer_exception;
216 qpoints->pThrowStackOverflow = art_quick_throw_stack_overflow;
217};
218
219} // namespace art