blob: 682c5021ce2da3a28f5de5773987d323ed114de0 [file] [log] [blame]
Ian Rogers7655f292013-07-29 11:07:13 -07001/*
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
Mingyao Yang98d1cc82014-05-15 17:02:16 -070017#include "entrypoints/interpreter/interpreter_entrypoints.h"
18#include "entrypoints/jni/jni_entrypoints.h"
Ian Rogers7655f292013-07-29 11:07:13 -070019#include "entrypoints/portable/portable_entrypoints.h"
Mathieu Chartierd8891782014-03-02 13:28:37 -080020#include "entrypoints/quick/quick_alloc_entrypoints.h"
Ian Rogers7655f292013-07-29 11:07:13 -070021#include "entrypoints/quick/quick_entrypoints.h"
22#include "entrypoints/entrypoint_utils.h"
23
24namespace art {
25
Ian Rogers7655f292013-07-29 11:07:13 -070026// Interpreter entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070027extern "C" void artInterpreterToInterpreterBridge(Thread* self, MethodHelper& mh,
28 const DexFile::CodeItem* code_item,
29 ShadowFrame* shadow_frame, JValue* result);
Dragos Sbirlea08bf1962013-08-12 08:53:04 -070030extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& mh,
Ian Rogers7655f292013-07-29 11:07:13 -070031 const DexFile::CodeItem* code_item,
32 ShadowFrame* shadow_frame, JValue* result);
33
Ian Rogers848871b2013-08-05 10:56:33 -070034// Portable entrypoints.
Brian Carlstromea46f952013-07-30 01:26:50 -070035extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*);
36extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers848871b2013-08-05 10:56:33 -070037
Ian Rogers848871b2013-08-05 10:56:33 -070038// Cast entrypoints.
39extern "C" uint32_t art_quick_is_assignable(const mirror::Class* klass,
40 const mirror::Class* ref_class);
Ian Rogers848871b2013-08-05 10:56:33 -070041extern "C" void art_quick_check_cast(void*, void*);
42
43// DexCache entrypoints.
44extern "C" void* art_quick_initialize_static_storage(uint32_t, void*);
45extern "C" void* art_quick_initialize_type(uint32_t, void*);
46extern "C" void* art_quick_initialize_type_and_verify_access(uint32_t, void*);
47extern "C" void* art_quick_resolve_string(void*, uint32_t);
48
49// Field entrypoints.
Fred Shih37f05ef2014-07-16 18:38:08 -070050extern "C" int art_quick_set8_instance(uint32_t, void*, int8_t);
51extern "C" int art_quick_set8_static(uint32_t, int8_t);
52extern "C" int art_quick_set16_instance(uint32_t, void*, int16_t);
53extern "C" int art_quick_set16_static(uint32_t, int16_t);
Ian Rogers848871b2013-08-05 10:56:33 -070054extern "C" int art_quick_set32_instance(uint32_t, void*, int32_t);
55extern "C" int art_quick_set32_static(uint32_t, int32_t);
56extern "C" int art_quick_set64_instance(uint32_t, void*, int64_t);
57extern "C" int art_quick_set64_static(uint32_t, int64_t);
58extern "C" int art_quick_set_obj_instance(uint32_t, void*, void*);
59extern "C" int art_quick_set_obj_static(uint32_t, void*);
Fred Shih37f05ef2014-07-16 18:38:08 -070060extern "C" int8_t art_quick_get_byte_instance(uint32_t, void*);
61extern "C" uint8_t art_quick_get_boolean_instance(uint32_t, void*);
62extern "C" int8_t art_quick_get_byte_static(uint32_t);
63extern "C" uint8_t art_quick_get_boolean_static(uint32_t);
64extern "C" int16_t art_quick_get_short_instance(uint32_t, void*);
65extern "C" uint16_t art_quick_get_char_instance(uint32_t, void*);
66extern "C" int16_t art_quick_get_short_static(uint32_t);
67extern "C" uint16_t art_quick_get_char_static(uint32_t);
Ian Rogers848871b2013-08-05 10:56:33 -070068extern "C" int32_t art_quick_get32_instance(uint32_t, void*);
69extern "C" int32_t art_quick_get32_static(uint32_t);
70extern "C" int64_t art_quick_get64_instance(uint32_t, void*);
71extern "C" int64_t art_quick_get64_static(uint32_t);
72extern "C" void* art_quick_get_obj_instance(uint32_t, void*);
73extern "C" void* art_quick_get_obj_static(uint32_t);
74
Ian Rogersa9a82542013-10-04 11:17:26 -070075// Array entrypoints.
76extern "C" void art_quick_aput_obj_with_null_and_bound_check(void*, uint32_t, void*);
77extern "C" void art_quick_aput_obj_with_bound_check(void*, uint32_t, void*);
78extern "C" void art_quick_aput_obj(void*, uint32_t, void*);
Ian Rogers848871b2013-08-05 10:56:33 -070079extern "C" void art_quick_handle_fill_data(void*, void*);
80
81// Lock entrypoints.
82extern "C" void art_quick_lock_object(void*);
83extern "C" void art_quick_unlock_object(void*);
84
85// Math entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070086extern "C" int64_t art_quick_d2l(double);
87extern "C" int64_t art_quick_f2l(float);
Ian Rogers848871b2013-08-05 10:56:33 -070088extern "C" int64_t art_quick_ldiv(int64_t, int64_t);
Ian Rogersa9a82542013-10-04 11:17:26 -070089extern "C" int64_t art_quick_lmod(int64_t, int64_t);
Ian Rogers848871b2013-08-05 10:56:33 -070090extern "C" int64_t art_quick_lmul(int64_t, int64_t);
91extern "C" uint64_t art_quick_lshl(uint64_t, uint32_t);
92extern "C" uint64_t art_quick_lshr(uint64_t, uint32_t);
93extern "C" uint64_t art_quick_lushr(uint64_t, uint32_t);
94
Ian Rogers7655f292013-07-29 11:07:13 -070095// Intrinsic entrypoints.
Ian Rogers7655f292013-07-29 11:07:13 -070096extern "C" int32_t art_quick_string_compareto(void*, void*);
97extern "C" void* art_quick_memcpy(void*, const void*, size_t);
98
99// Invoke entrypoints.
Jeff Hao88474b42013-10-23 16:24:40 -0700100extern "C" void art_quick_imt_conflict_trampoline(mirror::ArtMethod*);
Brian Carlstromea46f952013-07-30 01:26:50 -0700101extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*);
102extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers7655f292013-07-29 11:07:13 -0700103extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*);
Ian Rogers7655f292013-07-29 11:07:13 -0700104extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*);
105extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*);
106extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*);
107extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*);
108
109// Thread entrypoints.
Ian Rogers7655f292013-07-29 11:07:13 -0700110extern "C" void art_quick_test_suspend();
111
112// Throw entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -0700113extern "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*);
Ian Rogers7655f292013-07-29 11:07:13 -0700119
Andreas Gampe2da88232014-02-27 12:26:20 -0800120// Generic JNI downcall
121extern "C" void art_quick_generic_jni_trampoline(mirror::ArtMethod*);
122
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800123extern void ResetQuickAllocEntryPoints(QuickEntryPoints* qpoints);
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700124
Ian Rogers848871b2013-08-05 10:56:33 -0700125void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints,
126 PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) {
127 // Interpreter
128 ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge;
Dragos Sbirlea08bf1962013-08-12 08:53:04 -0700129 ipoints->pInterpreterToCompiledCodeBridge = artInterpreterToCompiledCodeBridge;
Ian Rogers848871b2013-08-05 10:56:33 -0700130
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
Ian Rogers7655f292013-07-29 11:07:13 -0700138 // Alloc
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700139 ResetQuickAllocEntryPoints(qpoints);
Ian Rogers7655f292013-07-29 11:07:13 -0700140
141 // Cast
Ian Rogers848871b2013-08-05 10:56:33 -0700142 qpoints->pInstanceofNonTrivial = art_quick_is_assignable;
Ian Rogers848871b2013-08-05 10:56:33 -0700143 qpoints->pCheckCast = art_quick_check_cast;
Ian Rogers7655f292013-07-29 11:07:13 -0700144
145 // DexCache
Ian Rogers848871b2013-08-05 10:56:33 -0700146 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;
Ian Rogers7655f292013-07-29 11:07:13 -0700150
151 // Field
Fred Shih37f05ef2014-07-16 18:38:08 -0700152 qpoints->pSet8Instance = art_quick_set8_instance;
153 qpoints->pSet8Static = art_quick_set8_static;
154 qpoints->pSet16Instance = art_quick_set16_instance;
155 qpoints->pSet16Static = art_quick_set16_static;
Ian Rogers848871b2013-08-05 10:56:33 -0700156 qpoints->pSet32Instance = art_quick_set32_instance;
157 qpoints->pSet32Static = art_quick_set32_static;
158 qpoints->pSet64Instance = art_quick_set64_instance;
159 qpoints->pSet64Static = art_quick_set64_static;
160 qpoints->pSetObjInstance = art_quick_set_obj_instance;
161 qpoints->pSetObjStatic = art_quick_set_obj_static;
Fred Shih37f05ef2014-07-16 18:38:08 -0700162 qpoints->pGetByteInstance = art_quick_get_byte_instance;
163 qpoints->pGetBooleanInstance = art_quick_get_boolean_instance;
164 qpoints->pGetShortInstance = art_quick_get_short_instance;
165 qpoints->pGetCharInstance = art_quick_get_char_instance;
Ian Rogers848871b2013-08-05 10:56:33 -0700166 qpoints->pGet32Instance = art_quick_get32_instance;
167 qpoints->pGet64Instance = art_quick_get64_instance;
168 qpoints->pGetObjInstance = art_quick_get_obj_instance;
Fred Shih37f05ef2014-07-16 18:38:08 -0700169 qpoints->pGetByteStatic = art_quick_get_byte_static;
170 qpoints->pGetBooleanStatic = art_quick_get_boolean_static;
171 qpoints->pGetShortStatic = art_quick_get_short_static;
172 qpoints->pGetCharStatic = art_quick_get_char_static;
Ian Rogers848871b2013-08-05 10:56:33 -0700173 qpoints->pGet32Static = art_quick_get32_static;
174 qpoints->pGet64Static = art_quick_get64_static;
175 qpoints->pGetObjStatic = art_quick_get_obj_static;
Ian Rogers7655f292013-07-29 11:07:13 -0700176
Ian Rogersa9a82542013-10-04 11:17:26 -0700177 // Array
178 qpoints->pAputObjectWithNullAndBoundCheck = art_quick_aput_obj_with_null_and_bound_check;
179 qpoints->pAputObjectWithBoundCheck = art_quick_aput_obj_with_bound_check;
180 qpoints->pAputObject = art_quick_aput_obj;
Ian Rogers848871b2013-08-05 10:56:33 -0700181 qpoints->pHandleFillArrayData = art_quick_handle_fill_data;
Ian Rogers7655f292013-07-29 11:07:13 -0700182
183 // JNI
184 qpoints->pJniMethodStart = JniMethodStart;
185 qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized;
186 qpoints->pJniMethodEnd = JniMethodEnd;
187 qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized;
188 qpoints->pJniMethodEndWithReference = JniMethodEndWithReference;
189 qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized;
Andreas Gampe2da88232014-02-27 12:26:20 -0800190 qpoints->pQuickGenericJniTrampoline = art_quick_generic_jni_trampoline;
Ian Rogers7655f292013-07-29 11:07:13 -0700191
192 // Locks
Ian Rogers848871b2013-08-05 10:56:33 -0700193 qpoints->pLockObject = art_quick_lock_object;
194 qpoints->pUnlockObject = art_quick_unlock_object;
Ian Rogers7655f292013-07-29 11:07:13 -0700195
196 // Math
197 // points->pCmpgDouble = NULL; // Not needed on x86.
198 // points->pCmpgFloat = NULL; // Not needed on x86.
199 // points->pCmplDouble = NULL; // Not needed on x86.
200 // points->pCmplFloat = NULL; // Not needed on x86.
Alexei Zavjalovbd3682e2014-06-12 03:08:01 +0700201 // qpoints->pFmod = NULL; // Not needed on x86.
Alexei Zavjalov1d4d7bd2014-05-23 17:51:59 +0700202 // qpoints->pL2d = NULL; // Not needed on x86.
Alexei Zavjalovbd3682e2014-06-12 03:08:01 +0700203 // qpoints->pFmodf = NULL; // Not needed on x86.
Alexei Zavjalov1d4d7bd2014-05-23 17:51:59 +0700204 // qpoints->pL2f = NULL; // Not needed on x86.
Ian Rogers7655f292013-07-29 11:07:13 -0700205 // points->pD2iz = NULL; // Not needed on x86.
206 // points->pF2iz = NULL; // Not needed on x86.
Alexei Zavjalov1d4d7bd2014-05-23 17:51:59 +0700207 // qpoints->pIdivmod = NULL; // Not needed on x86.
Ian Rogers848871b2013-08-05 10:56:33 -0700208 qpoints->pD2l = art_quick_d2l;
209 qpoints->pF2l = art_quick_f2l;
210 qpoints->pLdiv = art_quick_ldiv;
Ian Rogersa9a82542013-10-04 11:17:26 -0700211 qpoints->pLmod = art_quick_lmod;
Ian Rogers848871b2013-08-05 10:56:33 -0700212 qpoints->pLmul = art_quick_lmul;
213 qpoints->pShlLong = art_quick_lshl;
214 qpoints->pShrLong = art_quick_lshr;
215 qpoints->pUshrLong = art_quick_lushr;
Ian Rogers7655f292013-07-29 11:07:13 -0700216
217 // Intrinsics
Mark Mendell4028a6c2014-02-19 20:06:20 -0800218 // qpoints->pIndexOf = nullptr; // Not needed on x86
Ian Rogers7655f292013-07-29 11:07:13 -0700219 qpoints->pStringCompareTo = art_quick_string_compareto;
220 qpoints->pMemcpy = art_quick_memcpy;
221
222 // Invocation
Jeff Hao88474b42013-10-23 16:24:40 -0700223 qpoints->pQuickImtConflictTrampoline = art_quick_imt_conflict_trampoline;
Ian Rogers848871b2013-08-05 10:56:33 -0700224 qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline;
225 qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge;
Ian Rogers7655f292013-07-29 11:07:13 -0700226 qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check;
Ian Rogers7655f292013-07-29 11:07:13 -0700227 qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check;
228 qpoints->pInvokeStaticTrampolineWithAccessCheck = art_quick_invoke_static_trampoline_with_access_check;
229 qpoints->pInvokeSuperTrampolineWithAccessCheck = art_quick_invoke_super_trampoline_with_access_check;
230 qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check;
231
232 // Thread
Ian Rogers848871b2013-08-05 10:56:33 -0700233 qpoints->pTestSuspend = art_quick_test_suspend;
Ian Rogers7655f292013-07-29 11:07:13 -0700234
235 // Throws
Ian Rogers848871b2013-08-05 10:56:33 -0700236 qpoints->pDeliverException = art_quick_deliver_exception;
237 qpoints->pThrowArrayBounds = art_quick_throw_array_bounds;
238 qpoints->pThrowDivZero = art_quick_throw_div_zero;
239 qpoints->pThrowNoSuchMethod = art_quick_throw_no_such_method;
240 qpoints->pThrowNullPointer = art_quick_throw_null_pointer_exception;
241 qpoints->pThrowStackOverflow = art_quick_throw_stack_overflow;
Ian Rogers7655f292013-07-29 11:07:13 -0700242};
243
244} // namespace art