1 /*
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/interpreter/interpreter_entrypoints.h"
18 #include "entrypoints/jni/jni_entrypoints.h"
19 #include "entrypoints/quick/quick_alloc_entrypoints.h"
20 #include "entrypoints/quick/quick_default_externs.h"
21 #include "entrypoints/quick/quick_entrypoints.h"
22 #include "entrypoints/runtime_asm_entrypoints.h"
23 #include "interpreter/interpreter.h"
24 
25 namespace art {
26 
27 // Cast entrypoints.
28 extern "C" uint32_t art_quick_is_assignable(const mirror::Class* klass,
29                                             const mirror::Class* ref_class);
30 
InitEntryPoints(InterpreterEntryPoints * ipoints,JniEntryPoints * jpoints,QuickEntryPoints * qpoints)31 void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints,
32                      QuickEntryPoints* qpoints) {
33   // Interpreter
34   ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge;
35   ipoints->pInterpreterToCompiledCodeBridge = artInterpreterToCompiledCodeBridge;
36 
37   // JNI
38   jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub;
39 
40   // Alloc
41   ResetQuickAllocEntryPoints(qpoints);
42 
43   // Cast
44   qpoints->pInstanceofNonTrivial = art_quick_is_assignable;
45   qpoints->pCheckCast = art_quick_check_cast;
46 
47   // DexCache
48   qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage;
49   qpoints->pInitializeTypeAndVerifyAccess = art_quick_initialize_type_and_verify_access;
50   qpoints->pInitializeType = art_quick_initialize_type;
51   qpoints->pResolveString = art_quick_resolve_string;
52 
53   // Field
54   qpoints->pSet8Instance = art_quick_set8_instance;
55   qpoints->pSet8Static = art_quick_set8_static;
56   qpoints->pSet16Instance = art_quick_set16_instance;
57   qpoints->pSet16Static = art_quick_set16_static;
58   qpoints->pSet32Instance = art_quick_set32_instance;
59   qpoints->pSet32Static = art_quick_set32_static;
60   qpoints->pSet64Instance = art_quick_set64_instance;
61   qpoints->pSet64Static = art_quick_set64_static;
62   qpoints->pSetObjInstance = art_quick_set_obj_instance;
63   qpoints->pSetObjStatic = art_quick_set_obj_static;
64   qpoints->pGetByteInstance = art_quick_get_byte_instance;
65   qpoints->pGetBooleanInstance = art_quick_get_boolean_instance;
66   qpoints->pGetShortInstance = art_quick_get_short_instance;
67   qpoints->pGetCharInstance = art_quick_get_char_instance;
68   qpoints->pGet32Instance = art_quick_get32_instance;
69   qpoints->pGet64Instance = art_quick_get64_instance;
70   qpoints->pGetObjInstance = art_quick_get_obj_instance;
71   qpoints->pGetByteStatic = art_quick_get_byte_static;
72   qpoints->pGetBooleanStatic = art_quick_get_boolean_static;
73   qpoints->pGetShortStatic = art_quick_get_short_static;
74   qpoints->pGetCharStatic = art_quick_get_char_static;
75   qpoints->pGet32Static = art_quick_get32_static;
76   qpoints->pGet64Static = art_quick_get64_static;
77   qpoints->pGetObjStatic = art_quick_get_obj_static;
78 
79   // Array
80   qpoints->pAputObjectWithNullAndBoundCheck = art_quick_aput_obj_with_null_and_bound_check;
81   qpoints->pAputObjectWithBoundCheck = art_quick_aput_obj_with_bound_check;
82   qpoints->pAputObject = art_quick_aput_obj;
83   qpoints->pHandleFillArrayData = art_quick_handle_fill_data;
84 
85   // JNI
86   qpoints->pJniMethodStart = JniMethodStart;
87   qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized;
88   qpoints->pJniMethodEnd = JniMethodEnd;
89   qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized;
90   qpoints->pJniMethodEndWithReference = JniMethodEndWithReference;
91   qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized;
92   qpoints->pQuickGenericJniTrampoline = art_quick_generic_jni_trampoline;
93 
94   // Locks
95   qpoints->pLockObject = art_quick_lock_object;
96   qpoints->pUnlockObject = art_quick_unlock_object;
97 
98   // Math
99   qpoints->pD2l = art_quick_d2l;
100   qpoints->pF2l = art_quick_f2l;
101   qpoints->pLdiv = art_quick_ldiv;
102   qpoints->pLmod = art_quick_lmod;
103   qpoints->pLmul = art_quick_lmul;
104   qpoints->pShlLong = art_quick_lshl;
105   qpoints->pShrLong = art_quick_lshr;
106   qpoints->pUshrLong = art_quick_lushr;
107 
108   // Intrinsics
109   // qpoints->pIndexOf = nullptr;  // Not needed on x86
110   qpoints->pStringCompareTo = art_quick_string_compareto;
111   qpoints->pMemcpy = art_quick_memcpy;
112 
113   // Invocation
114   qpoints->pQuickImtConflictTrampoline = art_quick_imt_conflict_trampoline;
115   qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline;
116   qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge;
117   qpoints->pInvokeDirectTrampolineWithAccessCheck =
118       art_quick_invoke_direct_trampoline_with_access_check;
119   qpoints->pInvokeInterfaceTrampolineWithAccessCheck =
120       art_quick_invoke_interface_trampoline_with_access_check;
121   qpoints->pInvokeStaticTrampolineWithAccessCheck =
122       art_quick_invoke_static_trampoline_with_access_check;
123   qpoints->pInvokeSuperTrampolineWithAccessCheck =
124       art_quick_invoke_super_trampoline_with_access_check;
125   qpoints->pInvokeVirtualTrampolineWithAccessCheck =
126       art_quick_invoke_virtual_trampoline_with_access_check;
127 
128   // Thread
129   qpoints->pTestSuspend = art_quick_test_suspend;
130 
131   // Throws
132   qpoints->pDeliverException = art_quick_deliver_exception;
133   qpoints->pThrowArrayBounds = art_quick_throw_array_bounds;
134   qpoints->pThrowDivZero = art_quick_throw_div_zero;
135   qpoints->pThrowNoSuchMethod = art_quick_throw_no_such_method;
136   qpoints->pThrowNullPointer = art_quick_throw_null_pointer_exception;
137   qpoints->pThrowStackOverflow = art_quick_throw_stack_overflow;
138 
139   // Deoptimize
140   qpoints->pDeoptimize = art_quick_deoptimize_from_compiled_slow_path;
141 
142   // Read barrier
143   qpoints->pReadBarrierJni = ReadBarrierJni;
144 };
145 
146 }  // namespace art
147