Home | History | Annotate | Download | only in arm
      1 /*
      2  * Copyright (C) 2010 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 "Dalvik.h"
     18 
     19 #ifndef _DALVIK_VM_COMPILER_CODEGEN_ARM_CALLOUT_HELPER_H
     20 #define _DALVIK_VM_COMPILER_CODEGEN_ARM_CALLOUT_HELPER_H
     21 
     22 /*
     23  * Declare/comment prototypes of all native callout functions invoked by the
     24  * JIT'ed code here and use the LOAD_FUNC_ADDR macro to load the address into
     25  * a register. In this way we have a centralized place to find out all native
     26  * helper functions and we can grep for LOAD_FUNC_ADDR to find out all the
     27  * callsites.
     28  */
     29 
     30 /* Load a statically compiled function address as a constant */
     31 #define LOAD_FUNC_ADDR(cUnit, reg, addr) loadConstant(cUnit, reg, addr)
     32 
     33 /* Conversions */
     34 float __aeabi_i2f(int op1);             // OP_INT_TO_FLOAT
     35 int __aeabi_f2iz(float op1);            // OP_FLOAT_TO_INT
     36 float __aeabi_d2f(double op1);          // OP_DOUBLE_TO_FLOAT
     37 double __aeabi_f2d(float op1);          // OP_FLOAT_TO_DOUBLE
     38 double __aeabi_i2d(int op1);            // OP_INT_TO_DOUBLE
     39 int __aeabi_d2iz(double op1);           // OP_DOUBLE_TO_INT
     40 float __aeabi_l2f(long op1);            // OP_LONG_TO_FLOAT
     41 double __aeabi_l2d(long op1);           // OP_LONG_TO_DOUBLE
     42 s8 dvmJitf2l(float op1);                // OP_FLOAT_TO_LONG
     43 s8 dvmJitd2l(double op1);               // OP_DOUBLE_TO_LONG
     44 
     45 /* Single-precision FP arithmetics */
     46 float __aeabi_fadd(float a, float b);   // OP_ADD_FLOAT[_2ADDR]
     47 float __aeabi_fsub(float a, float b);   // OP_SUB_FLOAT[_2ADDR]
     48 float __aeabi_fdiv(float a, float b);   // OP_DIV_FLOAT[_2ADDR]
     49 float __aeabi_fmul(float a, float b);   // OP_MUL_FLOAT[_2ADDR]
     50 float fmodf(float a, float b);          // OP_REM_FLOAT[_2ADDR]
     51 
     52 /* Double-precision FP arithmetics */
     53 double __aeabi_dadd(double a, double b); // OP_ADD_DOUBLE[_2ADDR]
     54 double __aeabi_dsub(double a, double b); // OP_SUB_DOUBLE[_2ADDR]
     55 double __aeabi_ddiv(double a, double b); // OP_DIV_DOUBLE[_2ADDR]
     56 double __aeabi_dmul(double a, double b); // OP_MUL_DOUBLE[_2ADDR]
     57 double fmod(double a, double b);         // OP_REM_DOUBLE[_2ADDR]
     58 
     59 /* Integer arithmetics */
     60 int __aeabi_idivmod(int op1, int op2);  // OP_REM_INT[_2ADDR|_LIT8|_LIT16]
     61 int __aeabi_idiv(int op1, int op2);     // OP_DIV_INT[_2ADDR|_LIT8|_LIT16]
     62 
     63 /* Long long arithmetics - OP_REM_LONG[_2ADDR] & OP_DIV_LONG[_2ADDR] */
     64 long long __aeabi_ldivmod(long long op1, long long op2);
     65 
     66 /* Originally declared in Sync.h */
     67 bool dvmUnlockObject(struct Thread* self, struct Object* obj); //OP_MONITOR_EXIT
     68 
     69 /* Originally declared in oo/TypeCheck.h */
     70 bool dvmCanPutArrayElement(const ClassObject* elemClass,   // OP_APUT_OBJECT
     71                            const ClassObject* arrayClass);
     72 int dvmInstanceofNonTrivial(const ClassObject* instance,   // OP_CHECK_CAST &&
     73                             const ClassObject* clazz);     // OP_INSTANCE_OF
     74 
     75 /* Originally declared in oo/Array.h */
     76 ArrayObject* dvmAllocArrayByClass(ClassObject* arrayClass, // OP_NEW_ARRAY
     77                                   size_t length, int allocFlags);
     78 
     79 /* Originally declared in interp/InterpDefs.h */
     80 bool dvmInterpHandleFillArrayData(ArrayObject* arrayObject,// OP_FILL_ARRAY_DATA
     81                                   const u2* arrayData);
     82 
     83 /* Switch dispatch offset calculation for OP_PACKED_SWITCH & OP_SPARSE_SWITCH */
     84 static s8 findPackedSwitchIndex(const u2* switchData, int testVal, int pc);
     85 static s8 findSparseSwitchIndex(const u2* switchData, int testVal, int pc);
     86 
     87 /*
     88  * Resolve interface callsites - OP_INVOKE_INTERFACE & OP_INVOKE_INTERFACE_RANGE
     89  *
     90  * Originally declared in mterp/common/FindInterface.h and only comment it here
     91  * due to the INLINE attribute.
     92  *
     93  * INLINE Method* dvmFindInterfaceMethodInCache(ClassObject* thisClass,
     94  *  u4 methodIdx, const Method* method, DvmDex* methodClassDex)
     95  */
     96 
     97 /* Originally declared in alloc/Alloc.h */
     98 Object* dvmAllocObject(ClassObject* clazz, int flags);  // OP_NEW_INSTANCE
     99 
    100 /*
    101  * Functions declared in gDvmInlineOpsTable[] are used for
    102  * OP_EXECUTE_INLINE & OP_EXECUTE_INLINE_RANGE.
    103  *
    104  *      org_apache_harmony_dalvik_NativeTestTarget_emptyInlineMethod
    105  *      javaLangString_charAt
    106  *      javaLangString_compareTo
    107  *      javaLangString_equals
    108  *      javaLangString_indexOf_I
    109  *      javaLangString_indexOf_II
    110  *      javaLangString_length
    111  *      javaLangMath_abs_int
    112  *      javaLangMath_abs_long
    113  *      javaLangMath_abs_float
    114  *      javaLangMath_abs_double
    115  *      javaLangMath_min_int
    116  *      javaLangMath_max_int
    117  *      javaLangMath_sqrt
    118  *      javaLangMath_cos
    119  *      javaLangMath_sin
    120  */
    121 double sqrt(double x);  // INLINE_MATH_SQRT
    122 
    123 /*
    124  * The following functions are invoked through the compiler templates (declared
    125  * in compiler/template/armv5te/footer.S:
    126  *
    127  *      __aeabi_cdcmple         // CMPG_DOUBLE
    128  *      __aeabi_cfcmple         // CMPG_FLOAT
    129  *      dvmLockObject           // MONITOR_ENTER
    130  */
    131 
    132 #endif /* _DALVIK_VM_COMPILER_CODEGEN_ARM_CALLOUT_HELPER_H */
    133