blob: 40d7cd913c167fed7e2156010ce60a5ce57a84a1 [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"
18#include "entrypoints/quick/quick_entrypoints.h"
19#include "entrypoints/entrypoint_utils.h"
20#include "entrypoints/math_entrypoints.h"
21
22namespace art {
23
Ian Rogers848871b2013-08-05 10:56:33 -070024// Interpreter entrypoints.
25extern "C" void artInterpreterToInterpreterBridge(Thread* self, MethodHelper& mh,
26 const DexFile::CodeItem* code_item,
27 ShadowFrame* shadow_frame, JValue* result);
Dragos Sbirlea08bf1962013-08-12 08:53:04 -070028extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& mh,
Ian Rogers848871b2013-08-05 10:56:33 -070029 const DexFile::CodeItem* code_item,
30 ShadowFrame* shadow_frame, JValue* result);
31
32// Portable entrypoints.
Brian Carlstromea46f952013-07-30 01:26:50 -070033extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*);
34extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers848871b2013-08-05 10:56:33 -070035
Ian Rogers7655f292013-07-29 11:07:13 -070036// Alloc entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070037extern "C" void* art_quick_alloc_array(uint32_t, void*, int32_t);
38extern "C" void* art_quick_alloc_array_with_access_check(uint32_t, void*, int32_t);
39extern "C" void* art_quick_alloc_object(uint32_t type_idx, void* method);
40extern "C" void* art_quick_alloc_object_with_access_check(uint32_t type_idx, void* method);
41extern "C" void* art_quick_check_and_alloc_array(uint32_t, void*, int32_t);
42extern "C" void* art_quick_check_and_alloc_array_with_access_check(uint32_t, void*, int32_t);
Ian Rogers7655f292013-07-29 11:07:13 -070043
44// Cast entrypoints.
45extern "C" uint32_t artIsAssignableFromCode(const mirror::Class* klass,
46 const mirror::Class* ref_class);
Ian Rogers848871b2013-08-05 10:56:33 -070047extern "C" void art_quick_can_put_array_element(void*, void*);
48extern "C" void art_quick_check_cast(void*, void*);
Ian Rogers7655f292013-07-29 11:07:13 -070049
50// DexCache entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070051extern "C" void* art_quick_initialize_static_storage(uint32_t, void*);
52extern "C" void* art_quick_initialize_type(uint32_t, void*);
53extern "C" void* art_quick_initialize_type_and_verify_access(uint32_t, void*);
54extern "C" void* art_quick_resolve_string(void*, uint32_t);
Ian Rogers7655f292013-07-29 11:07:13 -070055
56// Exception entrypoints.
57extern "C" void* GetAndClearException(Thread*);
58
59// Field entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070060extern "C" int art_quick_set32_instance(uint32_t, void*, int32_t);
61extern "C" int art_quick_set32_static(uint32_t, int32_t);
62extern "C" int art_quick_set64_instance(uint32_t, void*, int64_t);
63extern "C" int art_quick_set64_static(uint32_t, int64_t);
64extern "C" int art_quick_set_obj_instance(uint32_t, void*, void*);
65extern "C" int art_quick_set_obj_static(uint32_t, void*);
66extern "C" int32_t art_quick_get32_instance(uint32_t, void*);
67extern "C" int32_t art_quick_get32_static(uint32_t);
68extern "C" int64_t art_quick_get64_instance(uint32_t, void*);
69extern "C" int64_t art_quick_get64_static(uint32_t);
70extern "C" void* art_quick_get_obj_instance(uint32_t, void*);
71extern "C" void* art_quick_get_obj_static(uint32_t);
Ian Rogers7655f292013-07-29 11:07:13 -070072
73// FillArray entrypoint.
Ian Rogers848871b2013-08-05 10:56:33 -070074extern "C" void art_quick_handle_fill_data(void*, void*);
Ian Rogers7655f292013-07-29 11:07:13 -070075
76// Lock entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -070077extern "C" void art_quick_lock_object(void*);
78extern "C" void art_quick_unlock_object(void*);
Ian Rogers7655f292013-07-29 11:07:13 -070079
80// Math entrypoints.
81extern int32_t CmpgDouble(double a, double b);
82extern int32_t CmplDouble(double a, double b);
83extern int32_t CmpgFloat(float a, float b);
84extern int32_t CmplFloat(float a, float b);
85extern "C" int64_t artLmulFromCode(int64_t a, int64_t b);
86extern "C" int64_t artLdivFromCode(int64_t a, int64_t b);
87extern "C" int64_t artLdivmodFromCode(int64_t a, int64_t b);
88
89// Math conversions.
90extern "C" int32_t __fixsfsi(float op1); // FLOAT_TO_INT
91extern "C" int32_t __fixdfsi(double op1); // DOUBLE_TO_INT
92extern "C" float __floatdisf(int64_t op1); // LONG_TO_FLOAT
93extern "C" double __floatdidf(int64_t op1); // LONG_TO_DOUBLE
94extern "C" int64_t __fixsfdi(float op1); // FLOAT_TO_LONG
95extern "C" int64_t __fixdfdi(double op1); // DOUBLE_TO_LONG
96
97// Single-precision FP arithmetics.
98extern "C" float fmodf(float a, float b); // REM_FLOAT[_2ADDR]
99
100// Double-precision FP arithmetics.
101extern "C" double fmod(double a, double b); // REM_DOUBLE[_2ADDR]
102
103// Long long arithmetics - REM_LONG[_2ADDR] and DIV_LONG[_2ADDR]
104extern "C" int64_t __divdi3(int64_t, int64_t);
105extern "C" int64_t __moddi3(int64_t, int64_t);
106extern "C" uint64_t art_quick_shl_long(uint64_t, uint32_t);
107extern "C" uint64_t art_quick_shr_long(uint64_t, uint32_t);
108extern "C" uint64_t art_quick_ushr_long(uint64_t, uint32_t);
109
Ian Rogers7655f292013-07-29 11:07:13 -0700110// Intrinsic entrypoints.
111extern "C" int32_t __memcmp16(void*, void*, int32_t);
112extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t);
113extern "C" int32_t art_quick_string_compareto(void*, void*);
114
115// Invoke entrypoints.
Brian Carlstromea46f952013-07-30 01:26:50 -0700116extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*);
117extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*);
Ian Rogers7655f292013-07-29 11:07:13 -0700118extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*);
119extern "C" void art_quick_invoke_interface_trampoline(uint32_t, void*);
120extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*);
121extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*);
122extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*);
123extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*);
124
125// Thread entrypoints.
126extern void CheckSuspendFromCode(Thread* thread);
127extern "C" void art_quick_test_suspend();
128
129// Throw entrypoints.
Ian Rogers848871b2013-08-05 10:56:33 -0700130extern "C" void art_quick_deliver_exception(void*);
131extern "C" void art_quick_throw_array_bounds(int32_t index, int32_t limit);
132extern "C" void art_quick_throw_div_zero();
133extern "C" void art_quick_throw_no_such_method(int32_t method_idx);
134extern "C" void art_quick_throw_null_pointer_exception();
135extern "C" void art_quick_throw_stack_overflow(void*);
Ian Rogers7655f292013-07-29 11:07:13 -0700136
Ian Rogers848871b2013-08-05 10:56:33 -0700137void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints,
138 PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) {
139 // Interpreter
140 ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge;
Dragos Sbirlea08bf1962013-08-12 08:53:04 -0700141 ipoints->pInterpreterToCompiledCodeBridge = artInterpreterToCompiledCodeBridge;
Ian Rogers848871b2013-08-05 10:56:33 -0700142
143 // JNI
144 jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub;
145
146 // Portable
147 ppoints->pPortableResolutionTrampoline = art_portable_resolution_trampoline;
148 ppoints->pPortableToInterpreterBridge = art_portable_to_interpreter_bridge;
149
Ian Rogers7655f292013-07-29 11:07:13 -0700150 // Alloc
Ian Rogers848871b2013-08-05 10:56:33 -0700151 qpoints->pAllocArray = art_quick_alloc_array;
152 qpoints->pAllocArrayWithAccessCheck = art_quick_alloc_array_with_access_check;
153 qpoints->pAllocObject = art_quick_alloc_object;
154 qpoints->pAllocObjectWithAccessCheck = art_quick_alloc_object_with_access_check;
155 qpoints->pCheckAndAllocArray = art_quick_check_and_alloc_array;
156 qpoints->pCheckAndAllocArrayWithAccessCheck = art_quick_check_and_alloc_array_with_access_check;
Ian Rogers7655f292013-07-29 11:07:13 -0700157
158 // Cast
Ian Rogers848871b2013-08-05 10:56:33 -0700159 qpoints->pInstanceofNonTrivial = artIsAssignableFromCode;
160 qpoints->pCanPutArrayElement = art_quick_can_put_array_element;
161 qpoints->pCheckCast = art_quick_check_cast;
Ian Rogers7655f292013-07-29 11:07:13 -0700162
163 // DexCache
Ian Rogers848871b2013-08-05 10:56:33 -0700164 qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage;
165 qpoints->pInitializeTypeAndVerifyAccess = art_quick_initialize_type_and_verify_access;
166 qpoints->pInitializeType = art_quick_initialize_type;
167 qpoints->pResolveString = art_quick_resolve_string;
Ian Rogers7655f292013-07-29 11:07:13 -0700168
169 // Field
Ian Rogers848871b2013-08-05 10:56:33 -0700170 qpoints->pSet32Instance = art_quick_set32_instance;
171 qpoints->pSet32Static = art_quick_set32_static;
172 qpoints->pSet64Instance = art_quick_set64_instance;
173 qpoints->pSet64Static = art_quick_set64_static;
174 qpoints->pSetObjInstance = art_quick_set_obj_instance;
175 qpoints->pSetObjStatic = art_quick_set_obj_static;
176 qpoints->pGet32Instance = art_quick_get32_instance;
177 qpoints->pGet64Instance = art_quick_get64_instance;
178 qpoints->pGetObjInstance = art_quick_get_obj_instance;
179 qpoints->pGet32Static = art_quick_get32_static;
180 qpoints->pGet64Static = art_quick_get64_static;
181 qpoints->pGetObjStatic = art_quick_get_obj_static;
Ian Rogers7655f292013-07-29 11:07:13 -0700182
183 // FillArray
Ian Rogers848871b2013-08-05 10:56:33 -0700184 qpoints->pHandleFillArrayData = art_quick_handle_fill_data;
Ian Rogers7655f292013-07-29 11:07:13 -0700185
186 // JNI
187 qpoints->pJniMethodStart = JniMethodStart;
188 qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized;
189 qpoints->pJniMethodEnd = JniMethodEnd;
190 qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized;
191 qpoints->pJniMethodEndWithReference = JniMethodEndWithReference;
192 qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized;
193
194 // Locks
Ian Rogers848871b2013-08-05 10:56:33 -0700195 qpoints->pLockObject = art_quick_lock_object;
196 qpoints->pUnlockObject = art_quick_unlock_object;
Ian Rogers7655f292013-07-29 11:07:13 -0700197
198 // Math
199 qpoints->pCmpgDouble = CmpgDouble;
200 qpoints->pCmpgFloat = CmpgFloat;
201 qpoints->pCmplDouble = CmplDouble;
202 qpoints->pCmplFloat = CmplFloat;
203 qpoints->pFmod = fmod;
204 qpoints->pL2d = __floatdidf;
205 qpoints->pFmodf = fmodf;
206 qpoints->pL2f = __floatdisf;
207 qpoints->pD2iz = __fixdfsi;
208 qpoints->pF2iz = __fixsfsi;
209 qpoints->pIdivmod = NULL;
210 qpoints->pD2l = art_d2l;
211 qpoints->pF2l = art_f2l;
212 qpoints->pLdiv = artLdivFromCode;
213 qpoints->pLdivmod = artLdivmodFromCode;
214 qpoints->pLmul = artLmulFromCode;
215 qpoints->pShlLong = art_quick_shl_long;
216 qpoints->pShrLong = art_quick_shr_long;
217 qpoints->pUshrLong = art_quick_ushr_long;
218
Ian Rogers7655f292013-07-29 11:07:13 -0700219 // Intrinsics
220 qpoints->pIndexOf = art_quick_indexof;
221 qpoints->pMemcmp16 = __memcmp16;
222 qpoints->pStringCompareTo = art_quick_string_compareto;
223 qpoints->pMemcpy = memcpy;
224
225 // Invocation
Ian Rogers848871b2013-08-05 10:56:33 -0700226 qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline;
227 qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge;
Ian Rogers7655f292013-07-29 11:07:13 -0700228 qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check;
229 qpoints->pInvokeInterfaceTrampoline = art_quick_invoke_interface_trampoline;
230 qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check;
231 qpoints->pInvokeStaticTrampolineWithAccessCheck = art_quick_invoke_static_trampoline_with_access_check;
232 qpoints->pInvokeSuperTrampolineWithAccessCheck = art_quick_invoke_super_trampoline_with_access_check;
233 qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check;
234
235 // Thread
Ian Rogers848871b2013-08-05 10:56:33 -0700236 qpoints->pCheckSuspend = CheckSuspendFromCode;
237 qpoints->pTestSuspend = art_quick_test_suspend;
Ian Rogers7655f292013-07-29 11:07:13 -0700238
239 // Throws
Ian Rogers848871b2013-08-05 10:56:33 -0700240 qpoints->pDeliverException = art_quick_deliver_exception;
241 qpoints->pThrowArrayBounds = art_quick_throw_array_bounds;
242 qpoints->pThrowDivZero = art_quick_throw_div_zero;
243 qpoints->pThrowNoSuchMethod = art_quick_throw_no_such_method;
244 qpoints->pThrowNullPointer = art_quick_throw_null_pointer_exception;
245 qpoints->pThrowStackOverflow = art_quick_throw_stack_overflow;
Ian Rogers7655f292013-07-29 11:07:13 -0700246};
247
248} // namespace art