Home | History | Annotate | Download | only in arm
      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/portable/portable_entrypoints.h"
     20 #include "entrypoints/quick/quick_alloc_entrypoints.h"
     21 #include "entrypoints/quick/quick_entrypoints.h"
     22 #include "entrypoints/entrypoint_utils.h"
     23 #include "entrypoints/math_entrypoints.h"
     24 
     25 namespace art {
     26 
     27 // Interpreter entrypoints.
     28 extern "C" void artInterpreterToInterpreterBridge(Thread* self, MethodHelper& mh,
     29                                                   const DexFile::CodeItem* code_item,
     30                                                   ShadowFrame* shadow_frame, JValue* result);
     31 extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& mh,
     32                                                    const DexFile::CodeItem* code_item,
     33                                                    ShadowFrame* shadow_frame, JValue* result);
     34 
     35 // Portable entrypoints.
     36 extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*);
     37 extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*);
     38 
     39 // Cast entrypoints.
     40 extern "C" uint32_t artIsAssignableFromCode(const mirror::Class* klass,
     41                                             const mirror::Class* ref_class);
     42 extern "C" void art_quick_check_cast(void*, void*);
     43 
     44 // DexCache entrypoints.
     45 extern "C" void* art_quick_initialize_static_storage(uint32_t, void*);
     46 extern "C" void* art_quick_initialize_type(uint32_t, void*);
     47 extern "C" void* art_quick_initialize_type_and_verify_access(uint32_t, void*);
     48 extern "C" void* art_quick_resolve_string(void*, uint32_t);
     49 
     50 // Field entrypoints.
     51 extern "C" int art_quick_set32_instance(uint32_t, void*, int32_t);
     52 extern "C" int art_quick_set32_static(uint32_t, int32_t);
     53 extern "C" int art_quick_set64_instance(uint32_t, void*, int64_t);
     54 extern "C" int art_quick_set64_static(uint32_t, int64_t);
     55 extern "C" int art_quick_set_obj_instance(uint32_t, void*, void*);
     56 extern "C" int art_quick_set_obj_static(uint32_t, void*);
     57 extern "C" int32_t art_quick_get32_instance(uint32_t, void*);
     58 extern "C" int32_t art_quick_get32_static(uint32_t);
     59 extern "C" int64_t art_quick_get64_instance(uint32_t, void*);
     60 extern "C" int64_t art_quick_get64_static(uint32_t);
     61 extern "C" void* art_quick_get_obj_instance(uint32_t, void*);
     62 extern "C" void* art_quick_get_obj_static(uint32_t);
     63 
     64 // Array entrypoints.
     65 extern "C" void art_quick_aput_obj_with_null_and_bound_check(void*, uint32_t, void*);
     66 extern "C" void art_quick_aput_obj_with_bound_check(void*, uint32_t, void*);
     67 extern "C" void art_quick_aput_obj(void*, uint32_t, void*);
     68 extern "C" void art_quick_handle_fill_data(void*, void*);
     69 
     70 // Lock entrypoints.
     71 extern "C" void art_quick_lock_object(void*);
     72 extern "C" void art_quick_unlock_object(void*);
     73 
     74 // Math entrypoints.
     75 extern int32_t CmpgDouble(double a, double b);
     76 extern int32_t CmplDouble(double a, double b);
     77 extern int32_t CmpgFloat(float a, float b);
     78 extern int32_t CmplFloat(float a, float b);
     79 
     80 // Math conversions.
     81 extern "C" int32_t __aeabi_f2iz(float op1);        // FLOAT_TO_INT
     82 extern "C" int32_t __aeabi_d2iz(double op1);       // DOUBLE_TO_INT
     83 extern "C" float __aeabi_l2f(int64_t op1);         // LONG_TO_FLOAT
     84 extern "C" double __aeabi_l2d(int64_t op1);        // LONG_TO_DOUBLE
     85 
     86 // Single-precision FP arithmetics.
     87 extern "C" float fmodf(float a, float b);          // REM_FLOAT[_2ADDR]
     88 
     89 // Double-precision FP arithmetics.
     90 extern "C" double fmod(double a, double b);         // REM_DOUBLE[_2ADDR]
     91 
     92 // Integer arithmetics.
     93 extern "C" int __aeabi_idivmod(int32_t, int32_t);  // [DIV|REM]_INT[_2ADDR|_LIT8|_LIT16]
     94 
     95 // Long long arithmetics - REM_LONG[_2ADDR] and DIV_LONG[_2ADDR]
     96 extern "C" int64_t __aeabi_ldivmod(int64_t, int64_t);
     97 extern "C" int64_t art_quick_mul_long(int64_t, int64_t);
     98 extern "C" uint64_t art_quick_shl_long(uint64_t, uint32_t);
     99 extern "C" uint64_t art_quick_shr_long(uint64_t, uint32_t);
    100 extern "C" uint64_t art_quick_ushr_long(uint64_t, uint32_t);
    101 
    102 // Intrinsic entrypoints.
    103 extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t);
    104 extern "C" int32_t art_quick_string_compareto(void*, void*);
    105 
    106 // Invoke entrypoints.
    107 extern "C" void art_quick_imt_conflict_trampoline(mirror::ArtMethod*);
    108 extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*);
    109 extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*);
    110 extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*);
    111 extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*);
    112 extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*);
    113 extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*);
    114 extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*);
    115 
    116 // Thread entrypoints.
    117 extern "C" void art_quick_test_suspend();
    118 
    119 // Throw entrypoints.
    120 extern "C" void art_quick_deliver_exception(void*);
    121 extern "C" void art_quick_throw_array_bounds(int32_t index, int32_t limit);
    122 extern "C" void art_quick_throw_div_zero();
    123 extern "C" void art_quick_throw_no_such_method(int32_t method_idx);
    124 extern "C" void art_quick_throw_null_pointer_exception();
    125 extern "C" void art_quick_throw_stack_overflow(void*);
    126 
    127 // Generic JNI downcall
    128 extern "C" void art_quick_generic_jni_trampoline(mirror::ArtMethod*);
    129 
    130 void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints,
    131                      PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) {
    132   // Interpreter
    133   ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge;
    134   ipoints->pInterpreterToCompiledCodeBridge = artInterpreterToCompiledCodeBridge;
    135 
    136   // JNI
    137   jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub;
    138 
    139   // Portable
    140   ppoints->pPortableResolutionTrampoline = art_portable_resolution_trampoline;
    141   ppoints->pPortableToInterpreterBridge = art_portable_to_interpreter_bridge;
    142 
    143   // Alloc
    144   ResetQuickAllocEntryPoints(qpoints);
    145 
    146   // Cast
    147   qpoints->pInstanceofNonTrivial = artIsAssignableFromCode;
    148   qpoints->pCheckCast = art_quick_check_cast;
    149 
    150   // DexCache
    151   qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage;
    152   qpoints->pInitializeTypeAndVerifyAccess = art_quick_initialize_type_and_verify_access;
    153   qpoints->pInitializeType = art_quick_initialize_type;
    154   qpoints->pResolveString = art_quick_resolve_string;
    155 
    156   // Field
    157   qpoints->pSet32Instance = art_quick_set32_instance;
    158   qpoints->pSet32Static = art_quick_set32_static;
    159   qpoints->pSet64Instance = art_quick_set64_instance;
    160   qpoints->pSet64Static = art_quick_set64_static;
    161   qpoints->pSetObjInstance = art_quick_set_obj_instance;
    162   qpoints->pSetObjStatic = art_quick_set_obj_static;
    163   qpoints->pGet32Instance = art_quick_get32_instance;
    164   qpoints->pGet64Instance = art_quick_get64_instance;
    165   qpoints->pGetObjInstance = art_quick_get_obj_instance;
    166   qpoints->pGet32Static = art_quick_get32_static;
    167   qpoints->pGet64Static = art_quick_get64_static;
    168   qpoints->pGetObjStatic = art_quick_get_obj_static;
    169 
    170   // Array
    171   qpoints->pAputObjectWithNullAndBoundCheck = art_quick_aput_obj_with_null_and_bound_check;
    172   qpoints->pAputObjectWithBoundCheck = art_quick_aput_obj_with_bound_check;
    173   qpoints->pAputObject = art_quick_aput_obj;
    174   qpoints->pHandleFillArrayData = art_quick_handle_fill_data;
    175 
    176   // JNI
    177   qpoints->pJniMethodStart = JniMethodStart;
    178   qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized;
    179   qpoints->pJniMethodEnd = JniMethodEnd;
    180   qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized;
    181   qpoints->pJniMethodEndWithReference = JniMethodEndWithReference;
    182   qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized;
    183   qpoints->pQuickGenericJniTrampoline = art_quick_generic_jni_trampoline;
    184 
    185   // Locks
    186   qpoints->pLockObject = art_quick_lock_object;
    187   qpoints->pUnlockObject = art_quick_unlock_object;
    188 
    189   // Math
    190   qpoints->pCmpgDouble = CmpgDouble;
    191   qpoints->pCmpgFloat = CmpgFloat;
    192   qpoints->pCmplDouble = CmplDouble;
    193   qpoints->pCmplFloat = CmplFloat;
    194   qpoints->pFmod = fmod;
    195   qpoints->pL2d = __aeabi_l2d;
    196   qpoints->pFmodf = fmodf;
    197   qpoints->pL2f = __aeabi_l2f;
    198   qpoints->pD2iz = __aeabi_d2iz;
    199   qpoints->pF2iz = __aeabi_f2iz;
    200   qpoints->pIdivmod = __aeabi_idivmod;
    201   qpoints->pD2l = art_d2l;
    202   qpoints->pF2l = art_f2l;
    203   qpoints->pLdiv = __aeabi_ldivmod;
    204   qpoints->pLmod = __aeabi_ldivmod;  // result returned in r2:r3
    205   qpoints->pLmul = art_quick_mul_long;
    206   qpoints->pShlLong = art_quick_shl_long;
    207   qpoints->pShrLong = art_quick_shr_long;
    208   qpoints->pUshrLong = art_quick_ushr_long;
    209 
    210   // Intrinsics
    211   qpoints->pIndexOf = art_quick_indexof;
    212   qpoints->pStringCompareTo = art_quick_string_compareto;
    213   qpoints->pMemcpy = memcpy;
    214 
    215   // Invocation
    216   qpoints->pQuickImtConflictTrampoline = art_quick_imt_conflict_trampoline;
    217   qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline;
    218   qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge;
    219   qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check;
    220   qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check;
    221   qpoints->pInvokeStaticTrampolineWithAccessCheck = art_quick_invoke_static_trampoline_with_access_check;
    222   qpoints->pInvokeSuperTrampolineWithAccessCheck = art_quick_invoke_super_trampoline_with_access_check;
    223   qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check;
    224 
    225   // Thread
    226   qpoints->pTestSuspend = art_quick_test_suspend;
    227 
    228   // Throws
    229   qpoints->pDeliverException = art_quick_deliver_exception;
    230   qpoints->pThrowArrayBounds = art_quick_throw_array_bounds;
    231   qpoints->pThrowDivZero = art_quick_throw_div_zero;
    232   qpoints->pThrowNoSuchMethod = art_quick_throw_no_such_method;
    233   qpoints->pThrowNullPointer = art_quick_throw_null_pointer_exception;
    234   qpoints->pThrowStackOverflow = art_quick_throw_stack_overflow;
    235 };
    236 
    237 }  // namespace art
    238