blob: 70a9619447ed2c07463647074eef1b6cde141e0b [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
17#include "entrypoints/portable/portable_entrypoints.h"
Mathieu Chartierd8891782014-03-02 13:28:37 -080018#include "entrypoints/quick/quick_alloc_entrypoints.h"
Ian Rogers7655f292013-07-29 11:07:13 -070019#include "entrypoints/quick/quick_entrypoints.h"
20#include "entrypoints/entrypoint_utils.h"
21#include "entrypoints/math_entrypoints.h"
22
23namespace art {
24
Ian Rogers848871b2013-08-05 10:56:33 -070025// Interpreter entrypoints.
26extern "C" void artInterpreterToInterpreterBridge(Thread* self, MethodHelper& mh,
27 const DexFile::CodeItem* code_item,
28 ShadowFrame* shadow_frame, JValue* result);
Dragos Sbirlea08bf1962013-08-12 08:53:04 -070029extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& mh,
Ian Rogers848871b2013-08-05 10:56:33 -070030 const DexFile::CodeItem* code_item,
31 ShadowFrame* shadow_frame, JValue* result);
32
33// Portable entrypoints.
Brian Carlstromea46f952013-07-30 01:26:50 -070034extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*);
35extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers848871b2013-08-05 10:56:33 -070036
Ian Rogers7655f292013-07-29 11:07:13 -070037// Cast entrypoints.
38extern "C" uint32_t artIsAssignableFromCode(const mirror::Class* klass,
39 const mirror::Class* ref_class);
Ian Rogers848871b2013-08-05 10:56:33 -070040extern "C" void art_quick_check_cast(void*, void*);
Ian Rogers7655f292013-07-29 11:07:13 -070041
42// DexCache entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070043extern "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);
Ian Rogers7655f292013-07-29 11:07:13 -070047
Ian Rogers7655f292013-07-29 11:07:13 -070048// Field entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070049extern "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);
Ian Rogers7655f292013-07-29 11:07:13 -070061
Ian Rogersa9a82542013-10-04 11:17:26 -070062// 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*);
Ian Rogers848871b2013-08-05 10:56:33 -070066extern "C" void art_quick_handle_fill_data(void*, void*);
Ian Rogers7655f292013-07-29 11:07:13 -070067
68// Lock entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070069extern "C" void art_quick_lock_object(void*);
70extern "C" void art_quick_unlock_object(void*);
Ian Rogers7655f292013-07-29 11:07:13 -070071
72// Math entrypoints.
73extern int32_t CmpgDouble(double a, double b);
74extern int32_t CmplDouble(double a, double b);
75extern int32_t CmpgFloat(float a, float b);
76extern int32_t CmplFloat(float a, float b);
Ian Rogersa9a82542013-10-04 11:17:26 -070077extern "C" int64_t artLmul(int64_t a, int64_t b);
78extern "C" int64_t artLdiv(int64_t a, int64_t b);
79extern "C" int64_t artLmod(int64_t a, int64_t b);
Ian Rogers7655f292013-07-29 11:07:13 -070080
81// Math conversions.
82extern "C" int32_t __fixsfsi(float op1); // FLOAT_TO_INT
83extern "C" int32_t __fixdfsi(double op1); // DOUBLE_TO_INT
84extern "C" float __floatdisf(int64_t op1); // LONG_TO_FLOAT
85extern "C" double __floatdidf(int64_t op1); // LONG_TO_DOUBLE
86extern "C" int64_t __fixsfdi(float op1); // FLOAT_TO_LONG
87extern "C" int64_t __fixdfdi(double op1); // DOUBLE_TO_LONG
88
89// Single-precision FP arithmetics.
90extern "C" float fmodf(float a, float b); // REM_FLOAT[_2ADDR]
91
92// Double-precision FP arithmetics.
93extern "C" double fmod(double a, double b); // REM_DOUBLE[_2ADDR]
94
95// Long long arithmetics - REM_LONG[_2ADDR] and DIV_LONG[_2ADDR]
96extern "C" int64_t __divdi3(int64_t, int64_t);
97extern "C" int64_t __moddi3(int64_t, int64_t);
98extern "C" uint64_t art_quick_shl_long(uint64_t, uint32_t);
99extern "C" uint64_t art_quick_shr_long(uint64_t, uint32_t);
100extern "C" uint64_t art_quick_ushr_long(uint64_t, uint32_t);
101
Ian Rogers7655f292013-07-29 11:07:13 -0700102// Intrinsic entrypoints.
Ian Rogers7655f292013-07-29 11:07:13 -0700103extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t);
104extern "C" int32_t art_quick_string_compareto(void*, void*);
105
106// Invoke entrypoints.
Jeff Hao88474b42013-10-23 16:24:40 -0700107extern "C" void art_quick_imt_conflict_trampoline(mirror::ArtMethod*);
Brian Carlstromea46f952013-07-30 01:26:50 -0700108extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*);
109extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers7655f292013-07-29 11:07:13 -0700110extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*);
Ian Rogers7655f292013-07-29 11:07:13 -0700111extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*);
112extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*);
113extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*);
114extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*);
115
116// Thread entrypoints.
Ian Rogers7655f292013-07-29 11:07:13 -0700117extern "C" void art_quick_test_suspend();
118
119// Throw entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -0700120extern "C" void art_quick_deliver_exception(void*);
121extern "C" void art_quick_throw_array_bounds(int32_t index, int32_t limit);
122extern "C" void art_quick_throw_div_zero();
123extern "C" void art_quick_throw_no_such_method(int32_t method_idx);
124extern "C" void art_quick_throw_null_pointer_exception();
125extern "C" void art_quick_throw_stack_overflow(void*);
Ian Rogers7655f292013-07-29 11:07:13 -0700126
Andreas Gampe2da88232014-02-27 12:26:20 -0800127// Generic JNI downcall
128extern "C" void art_quick_generic_jni_trampoline(mirror::ArtMethod*);
129
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800130extern void ResetQuickAllocEntryPoints(QuickEntryPoints* qpoints);
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700131
Ian Rogers848871b2013-08-05 10:56:33 -0700132void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints,
133 PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) {
134 // Interpreter
135 ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge;
Dragos Sbirlea08bf1962013-08-12 08:53:04 -0700136 ipoints->pInterpreterToCompiledCodeBridge = artInterpreterToCompiledCodeBridge;
Ian Rogers848871b2013-08-05 10:56:33 -0700137
138 // JNI
139 jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub;
140
141 // Portable
142 ppoints->pPortableResolutionTrampoline = art_portable_resolution_trampoline;
143 ppoints->pPortableToInterpreterBridge = art_portable_to_interpreter_bridge;
144
Ian Rogers7655f292013-07-29 11:07:13 -0700145 // Alloc
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700146 ResetQuickAllocEntryPoints(qpoints);
Ian Rogers7655f292013-07-29 11:07:13 -0700147
148 // Cast
Ian Rogers848871b2013-08-05 10:56:33 -0700149 qpoints->pInstanceofNonTrivial = artIsAssignableFromCode;
Ian Rogers848871b2013-08-05 10:56:33 -0700150 qpoints->pCheckCast = art_quick_check_cast;
Ian Rogers7655f292013-07-29 11:07:13 -0700151
152 // DexCache
Ian Rogers848871b2013-08-05 10:56:33 -0700153 qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage;
154 qpoints->pInitializeTypeAndVerifyAccess = art_quick_initialize_type_and_verify_access;
155 qpoints->pInitializeType = art_quick_initialize_type;
156 qpoints->pResolveString = art_quick_resolve_string;
Ian Rogers7655f292013-07-29 11:07:13 -0700157
158 // Field
Ian Rogers848871b2013-08-05 10:56:33 -0700159 qpoints->pSet32Instance = art_quick_set32_instance;
160 qpoints->pSet32Static = art_quick_set32_static;
161 qpoints->pSet64Instance = art_quick_set64_instance;
162 qpoints->pSet64Static = art_quick_set64_static;
163 qpoints->pSetObjInstance = art_quick_set_obj_instance;
164 qpoints->pSetObjStatic = art_quick_set_obj_static;
165 qpoints->pGet32Instance = art_quick_get32_instance;
166 qpoints->pGet64Instance = art_quick_get64_instance;
167 qpoints->pGetObjInstance = art_quick_get_obj_instance;
168 qpoints->pGet32Static = art_quick_get32_static;
169 qpoints->pGet64Static = art_quick_get64_static;
170 qpoints->pGetObjStatic = art_quick_get_obj_static;
Ian Rogers7655f292013-07-29 11:07:13 -0700171
Ian Rogersa9a82542013-10-04 11:17:26 -0700172 // Array
173 qpoints->pAputObjectWithNullAndBoundCheck = art_quick_aput_obj_with_null_and_bound_check;
174 qpoints->pAputObjectWithBoundCheck = art_quick_aput_obj_with_bound_check;
175 qpoints->pAputObject = art_quick_aput_obj;
Ian Rogers848871b2013-08-05 10:56:33 -0700176 qpoints->pHandleFillArrayData = art_quick_handle_fill_data;
Ian Rogers7655f292013-07-29 11:07:13 -0700177
178 // JNI
179 qpoints->pJniMethodStart = JniMethodStart;
180 qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized;
181 qpoints->pJniMethodEnd = JniMethodEnd;
182 qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized;
183 qpoints->pJniMethodEndWithReference = JniMethodEndWithReference;
184 qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized;
Andreas Gampe2da88232014-02-27 12:26:20 -0800185 qpoints->pQuickGenericJniTrampoline = art_quick_generic_jni_trampoline;
Ian Rogers7655f292013-07-29 11:07:13 -0700186
187 // Locks
Ian Rogers848871b2013-08-05 10:56:33 -0700188 qpoints->pLockObject = art_quick_lock_object;
189 qpoints->pUnlockObject = art_quick_unlock_object;
Ian Rogers7655f292013-07-29 11:07:13 -0700190
191 // Math
192 qpoints->pCmpgDouble = CmpgDouble;
193 qpoints->pCmpgFloat = CmpgFloat;
194 qpoints->pCmplDouble = CmplDouble;
195 qpoints->pCmplFloat = CmplFloat;
196 qpoints->pFmod = fmod;
197 qpoints->pL2d = __floatdidf;
198 qpoints->pFmodf = fmodf;
199 qpoints->pL2f = __floatdisf;
200 qpoints->pD2iz = __fixdfsi;
201 qpoints->pF2iz = __fixsfsi;
202 qpoints->pIdivmod = NULL;
203 qpoints->pD2l = art_d2l;
204 qpoints->pF2l = art_f2l;
Ian Rogersa9a82542013-10-04 11:17:26 -0700205 qpoints->pLdiv = artLdiv;
206 qpoints->pLmod = artLmod;
207 qpoints->pLmul = artLmul;
Ian Rogers7655f292013-07-29 11:07:13 -0700208 qpoints->pShlLong = art_quick_shl_long;
209 qpoints->pShrLong = art_quick_shr_long;
210 qpoints->pUshrLong = art_quick_ushr_long;
211
Ian Rogers7655f292013-07-29 11:07:13 -0700212 // Intrinsics
213 qpoints->pIndexOf = art_quick_indexof;
Ian Rogers7655f292013-07-29 11:07:13 -0700214 qpoints->pStringCompareTo = art_quick_string_compareto;
215 qpoints->pMemcpy = memcpy;
216
217 // Invocation
Jeff Hao88474b42013-10-23 16:24:40 -0700218 qpoints->pQuickImtConflictTrampoline = art_quick_imt_conflict_trampoline;
Ian Rogers848871b2013-08-05 10:56:33 -0700219 qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline;
220 qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge;
Ian Rogers7655f292013-07-29 11:07:13 -0700221 qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check;
Ian Rogers7655f292013-07-29 11:07:13 -0700222 qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check;
223 qpoints->pInvokeStaticTrampolineWithAccessCheck = art_quick_invoke_static_trampoline_with_access_check;
224 qpoints->pInvokeSuperTrampolineWithAccessCheck = art_quick_invoke_super_trampoline_with_access_check;
225 qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check;
226
227 // Thread
Ian Rogers848871b2013-08-05 10:56:33 -0700228 qpoints->pTestSuspend = art_quick_test_suspend;
Ian Rogers7655f292013-07-29 11:07:13 -0700229
230 // Throws
Ian Rogers848871b2013-08-05 10:56:33 -0700231 qpoints->pDeliverException = art_quick_deliver_exception;
232 qpoints->pThrowArrayBounds = art_quick_throw_array_bounds;
233 qpoints->pThrowDivZero = art_quick_throw_div_zero;
234 qpoints->pThrowNoSuchMethod = art_quick_throw_no_such_method;
235 qpoints->pThrowNullPointer = art_quick_throw_null_pointer_exception;
236 qpoints->pThrowStackOverflow = art_quick_throw_stack_overflow;
Ian Rogers7655f292013-07-29 11:07:13 -0700237};
238
239} // namespace art