Home | History | Annotate | Download | only in x86
      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/portable/portable_entrypoints.h"
     18 #include "entrypoints/quick/quick_entrypoints.h"
     19 #include "entrypoints/entrypoint_utils.h"
     20 
     21 namespace art {
     22 
     23 // Interpreter entrypoints.
     24 extern "C" void artInterpreterToInterpreterBridge(Thread* self, MethodHelper& mh,
     25                                                   const DexFile::CodeItem* code_item,
     26                                                   ShadowFrame* shadow_frame, JValue* result);
     27 extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& mh,
     28                                            const DexFile::CodeItem* code_item,
     29                                            ShadowFrame* shadow_frame, JValue* result);
     30 
     31 // Portable entrypoints.
     32 extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*);
     33 extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*);
     34 
     35 // Alloc entrypoints.
     36 extern "C" void* art_quick_alloc_array(uint32_t, void*, int32_t);
     37 extern "C" void* art_quick_alloc_array_with_access_check(uint32_t, void*, int32_t);
     38 extern "C" void* art_quick_alloc_object(uint32_t type_idx, void* method);
     39 extern "C" void* art_quick_alloc_object_with_access_check(uint32_t type_idx, void* method);
     40 extern "C" void* art_quick_check_and_alloc_array(uint32_t, void*, int32_t);
     41 extern "C" void* art_quick_check_and_alloc_array_with_access_check(uint32_t, void*, int32_t);
     42 
     43 // Cast entrypoints.
     44 extern "C" uint32_t art_quick_is_assignable(const mirror::Class* klass,
     45                                                 const mirror::Class* ref_class);
     46 extern "C" void art_quick_can_put_array_element(void*, void*);
     47 extern "C" void art_quick_check_cast(void*, void*);
     48 
     49 // DexCache entrypoints.
     50 extern "C" void* art_quick_initialize_static_storage(uint32_t, void*);
     51 extern "C" void* art_quick_initialize_type(uint32_t, void*);
     52 extern "C" void* art_quick_initialize_type_and_verify_access(uint32_t, void*);
     53 extern "C" void* art_quick_resolve_string(void*, uint32_t);
     54 
     55 // Field entrypoints.
     56 extern "C" int art_quick_set32_instance(uint32_t, void*, int32_t);
     57 extern "C" int art_quick_set32_static(uint32_t, int32_t);
     58 extern "C" int art_quick_set64_instance(uint32_t, void*, int64_t);
     59 extern "C" int art_quick_set64_static(uint32_t, int64_t);
     60 extern "C" int art_quick_set_obj_instance(uint32_t, void*, void*);
     61 extern "C" int art_quick_set_obj_static(uint32_t, void*);
     62 extern "C" int32_t art_quick_get32_instance(uint32_t, void*);
     63 extern "C" int32_t art_quick_get32_static(uint32_t);
     64 extern "C" int64_t art_quick_get64_instance(uint32_t, void*);
     65 extern "C" int64_t art_quick_get64_static(uint32_t);
     66 extern "C" void* art_quick_get_obj_instance(uint32_t, void*);
     67 extern "C" void* art_quick_get_obj_static(uint32_t);
     68 
     69 // FillArray entrypoint.
     70 extern "C" void art_quick_handle_fill_data(void*, void*);
     71 
     72 // Lock entrypoints.
     73 extern "C" void art_quick_lock_object(void*);
     74 extern "C" void art_quick_unlock_object(void*);
     75 
     76 // Math entrypoints.
     77 extern "C" double art_quick_fmod(double, double);
     78 extern "C" float art_quick_fmodf(float, float);
     79 extern "C" double art_quick_l2d(int64_t);
     80 extern "C" float art_quick_l2f(int64_t);
     81 extern "C" int64_t art_quick_d2l(double);
     82 extern "C" int64_t art_quick_f2l(float);
     83 extern "C" int32_t art_quick_idivmod(int32_t, int32_t);
     84 extern "C" int64_t art_quick_ldiv(int64_t, int64_t);
     85 extern "C" int64_t art_quick_ldivmod(int64_t, int64_t);
     86 extern "C" int64_t art_quick_lmul(int64_t, int64_t);
     87 extern "C" uint64_t art_quick_lshl(uint64_t, uint32_t);
     88 extern "C" uint64_t art_quick_lshr(uint64_t, uint32_t);
     89 extern "C" uint64_t art_quick_lushr(uint64_t, uint32_t);
     90 
     91 // Intrinsic entrypoints.
     92 extern "C" int32_t art_quick_memcmp16(void*, void*, int32_t);
     93 extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t);
     94 extern "C" int32_t art_quick_string_compareto(void*, void*);
     95 extern "C" void* art_quick_memcpy(void*, const void*, size_t);
     96 
     97 // Invoke entrypoints.
     98 extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*);
     99 extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*);
    100 extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*);
    101 extern "C" void art_quick_invoke_interface_trampoline(uint32_t, void*);
    102 extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*);
    103 extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*);
    104 extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*);
    105 extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*);
    106 
    107 // Thread entrypoints.
    108 extern void CheckSuspendFromCode(Thread* thread);
    109 extern "C" void art_quick_test_suspend();
    110 
    111 // Throw entrypoints.
    112 extern "C" void art_quick_deliver_exception(void*);
    113 extern "C" void art_quick_throw_array_bounds(int32_t index, int32_t limit);
    114 extern "C" void art_quick_throw_div_zero();
    115 extern "C" void art_quick_throw_no_such_method(int32_t method_idx);
    116 extern "C" void art_quick_throw_null_pointer_exception();
    117 extern "C" void art_quick_throw_stack_overflow(void*);
    118 
    119 void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints,
    120                      PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) {
    121   // Interpreter
    122   ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge;
    123   ipoints->pInterpreterToCompiledCodeBridge = artInterpreterToCompiledCodeBridge;
    124 
    125   // JNI
    126   jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub;
    127 
    128   // Portable
    129   ppoints->pPortableResolutionTrampoline = art_portable_resolution_trampoline;
    130   ppoints->pPortableToInterpreterBridge = art_portable_to_interpreter_bridge;
    131 
    132   // Alloc
    133   qpoints->pAllocArray = art_quick_alloc_array;
    134   qpoints->pAllocArrayWithAccessCheck = art_quick_alloc_array_with_access_check;
    135   qpoints->pAllocObject = art_quick_alloc_object;
    136   qpoints->pAllocObjectWithAccessCheck = art_quick_alloc_object_with_access_check;
    137   qpoints->pCheckAndAllocArray = art_quick_check_and_alloc_array;
    138   qpoints->pCheckAndAllocArrayWithAccessCheck = art_quick_check_and_alloc_array_with_access_check;
    139 
    140   // Cast
    141   qpoints->pInstanceofNonTrivial = art_quick_is_assignable;
    142   qpoints->pCanPutArrayElement = art_quick_can_put_array_element;
    143   qpoints->pCheckCast = art_quick_check_cast;
    144 
    145   // DexCache
    146   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;
    150 
    151   // Field
    152   qpoints->pSet32Instance = art_quick_set32_instance;
    153   qpoints->pSet32Static = art_quick_set32_static;
    154   qpoints->pSet64Instance = art_quick_set64_instance;
    155   qpoints->pSet64Static = art_quick_set64_static;
    156   qpoints->pSetObjInstance = art_quick_set_obj_instance;
    157   qpoints->pSetObjStatic = art_quick_set_obj_static;
    158   qpoints->pGet32Instance = art_quick_get32_instance;
    159   qpoints->pGet64Instance = art_quick_get64_instance;
    160   qpoints->pGetObjInstance = art_quick_get_obj_instance;
    161   qpoints->pGet32Static = art_quick_get32_static;
    162   qpoints->pGet64Static = art_quick_get64_static;
    163   qpoints->pGetObjStatic = art_quick_get_obj_static;
    164 
    165   // FillArray
    166   qpoints->pHandleFillArrayData = art_quick_handle_fill_data;
    167 
    168   // JNI
    169   qpoints->pJniMethodStart = JniMethodStart;
    170   qpoints->pJniMethodStartSynchronized = JniMethodStartSynchronized;
    171   qpoints->pJniMethodEnd = JniMethodEnd;
    172   qpoints->pJniMethodEndSynchronized = JniMethodEndSynchronized;
    173   qpoints->pJniMethodEndWithReference = JniMethodEndWithReference;
    174   qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized;
    175 
    176   // Locks
    177   qpoints->pLockObject = art_quick_lock_object;
    178   qpoints->pUnlockObject = art_quick_unlock_object;
    179 
    180   // Math
    181   // points->pCmpgDouble = NULL;  // Not needed on x86.
    182   // points->pCmpgFloat = NULL;  // Not needed on x86.
    183   // points->pCmplDouble = NULL;  // Not needed on x86.
    184   // points->pCmplFloat = NULL;  // Not needed on x86.
    185   qpoints->pFmod = art_quick_fmod;
    186   qpoints->pL2d = art_quick_l2d;
    187   qpoints->pFmodf = art_quick_fmodf;
    188   qpoints->pL2f = art_quick_l2f;
    189   // points->pD2iz = NULL;  // Not needed on x86.
    190   // points->pF2iz = NULL;  // Not needed on x86.
    191   qpoints->pIdivmod = art_quick_idivmod;
    192   qpoints->pD2l = art_quick_d2l;
    193   qpoints->pF2l = art_quick_f2l;
    194   qpoints->pLdiv = art_quick_ldiv;
    195   qpoints->pLdivmod = art_quick_ldivmod;
    196   qpoints->pLmul = art_quick_lmul;
    197   qpoints->pShlLong = art_quick_lshl;
    198   qpoints->pShrLong = art_quick_lshr;
    199   qpoints->pUshrLong = art_quick_lushr;
    200 
    201   // Intrinsics
    202   qpoints->pIndexOf = art_quick_indexof;
    203   qpoints->pMemcmp16 = art_quick_memcmp16;
    204   qpoints->pStringCompareTo = art_quick_string_compareto;
    205   qpoints->pMemcpy = art_quick_memcpy;
    206 
    207   // Invocation
    208   qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline;
    209   qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge;
    210   qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check;
    211   qpoints->pInvokeInterfaceTrampoline = art_quick_invoke_interface_trampoline;
    212   qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check;
    213   qpoints->pInvokeStaticTrampolineWithAccessCheck = art_quick_invoke_static_trampoline_with_access_check;
    214   qpoints->pInvokeSuperTrampolineWithAccessCheck = art_quick_invoke_super_trampoline_with_access_check;
    215   qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check;
    216 
    217   // Thread
    218   qpoints->pCheckSuspend = CheckSuspendFromCode;
    219   qpoints->pTestSuspend = art_quick_test_suspend;
    220 
    221   // Throws
    222   qpoints->pDeliverException = art_quick_deliver_exception;
    223   qpoints->pThrowArrayBounds = art_quick_throw_array_bounds;
    224   qpoints->pThrowDivZero = art_quick_throw_div_zero;
    225   qpoints->pThrowNoSuchMethod = art_quick_throw_no_such_method;
    226   qpoints->pThrowNullPointer = art_quick_throw_null_pointer_exception;
    227   qpoints->pThrowStackOverflow = art_quick_throw_stack_overflow;
    228 };
    229 
    230 }  // namespace art
    231