CalloutHelper.h revision 2d0c1c2dbe44458ebb199c47ce1047f266db5349
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#ifndef DALVIK_VM_COMPILER_CODEGEN_MIPS_CALLOUT_HELPER_H_
18#define DALVIK_VM_COMPILER_CODEGEN_MIPS_CALLOUT_HELPER_H_
19
20#include "Dalvik.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 */
34extern "C" float __floatsisf(int op1);             // OP_INT_TO_FLOAT
35extern "C" int __fixsfsi(float op1);               // OP_FLOAT_TO_INT
36extern "C" float __truncdfsf2(double op1);         // OP_DOUBLE_TO_FLOAT
37extern "C" double __extendsfdf2(float op1);        // OP_FLOAT_TO_DOUBLE
38extern "C" double __floatsidf(int op1);            // OP_INT_TO_DOUBLE
39extern "C" int __fixdfsi(double op1);              // OP_DOUBLE_TO_INT
40extern "C" float __floatdisf(long long op1);       // OP_LONG_TO_FLOAT
41extern "C" double __floatdidf(long long op1);      // OP_LONG_TO_DOUBLE
42extern "C" long long __fixsfdi(float op1);         // OP_FLOAT_TO_LONG
43extern "C" long long __fixdfdi(double op1);        // OP_DOUBLE_TO_LONG
44
45/* Single-precision FP arithmetics */
46extern "C" float __addsf3(float a, float b);   // OP_ADD_FLOAT[_2ADDR]
47extern "C" float __subsf3(float a, float b);   // OP_SUB_FLOAT[_2ADDR]
48extern "C" float __divsf3(float a, float b);   // OP_DIV_FLOAT[_2ADDR]
49extern "C" float __mulsf3(float a, float b);   // OP_MUL_FLOAT[_2ADDR]
50extern "C" float fmodf(float a, float b);          // OP_REM_FLOAT[_2ADDR]
51
52/* Double-precision FP arithmetics */
53extern "C" double __adddf3(double a, double b); // OP_ADD_DOUBLE[_2ADDR]
54extern "C" double __subdf3(double a, double b); // OP_SUB_DOUBLE[_2ADDR]
55extern "C" double __divdf3(double a, double b); // OP_DIV_DOUBLE[_2ADDR]
56extern "C" double __muldf3(double a, double b); // OP_MUL_DOUBLE[_2ADDR]
57extern "C" double fmod(double a, double b);         // OP_REM_DOUBLE[_2ADDR]
58
59/* Long long arithmetics - OP_REM_LONG[_2ADDR] & OP_DIV_LONG[_2ADDR] */
60extern "C" long long __divdi3(long long op1, long long op2);
61extern "C" long long __moddi3(long long op1, long long op2);
62
63/* Originally declared in Sync.h */
64bool dvmUnlockObject(struct Thread* self, struct Object* obj); //OP_MONITOR_EXIT
65
66/* Originally declared in oo/TypeCheck.h */
67bool dvmCanPutArrayElement(const ClassObject* elemClass,   // OP_APUT_OBJECT
68                           const ClassObject* arrayClass);
69int dvmInstanceofNonTrivial(const ClassObject* instance,   // OP_CHECK_CAST &&
70                            const ClassObject* clazz);     // OP_INSTANCE_OF
71
72/* Originally declared in oo/Array.h */
73ArrayObject* dvmAllocArrayByClass(ClassObject* arrayClass, // OP_NEW_ARRAY
74                                  size_t length, int allocFlags);
75
76/* Originally declared in interp/InterpDefs.h */
77bool dvmInterpHandleFillArrayData(ArrayObject* arrayObject,// OP_FILL_ARRAY_DATA
78                                  const u2* arrayData);
79
80/* Originally declared in compiler/codegen/mips/Assemble.c */
81const Method *dvmJitToPatchPredictedChain(const Method *method,
82                                          Thread *self,
83                                          PredictedChainingCell *cell,
84                                          const ClassObject *clazz);
85
86/*
87 * Resolve interface callsites - OP_INVOKE_INTERFACE & OP_INVOKE_INTERFACE_RANGE
88 *
89 * Originally declared in mterp/common/FindInterface.h and only comment it here
90 * due to the INLINE attribute.
91 *
92 * INLINE Method* dvmFindInterfaceMethodInCache(ClassObject* thisClass,
93 *  u4 methodIdx, const Method* method, DvmDex* methodClassDex)
94 */
95
96/* Originally declared in alloc/Alloc.h */
97Object* dvmAllocObject(ClassObject* clazz, int flags);  // OP_NEW_INSTANCE
98
99/*
100 * Functions declared in gDvmInlineOpsTable[] are used for
101 * OP_EXECUTE_INLINE & OP_EXECUTE_INLINE_RANGE.
102 */
103extern "C" double sqrt(double x);  // INLINE_MATH_SQRT
104
105/*
106 * The following functions are invoked through the compiler templates (declared
107 * in compiler/template/armv5te/footer.S:
108 *
109 *      __aeabi_cdcmple         // CMPG_DOUBLE
110 *      __aeabi_cfcmple         // CMPG_FLOAT
111 *      dvmLockObject           // MONITOR_ENTER
112 */
113
114#endif  // DALVIK_VM_COMPILER_CODEGEN_MIPS_CALLOUT_HELPER_H_
115