jit_common.h

来自「This is a resource based on j2me embedde」· C头文件 代码 · 共 693 行 · 第 1/2 页

H
693
字号
#endif/* The following are used to determine the size of the cache of hints for   virtual and interface inlining.   NOTE: CVM_MAX_INVOKE_VIRTUAL_HINTS and CVM_MAX_INVOKE_INTERFACE_HINTS must         be a number equal to some power of 2.*/#define CVM_MAX_INVOKE_VIRTUAL_HINTS    128#define CVM_MAX_INVOKE_INTERFACE_HINTS  64#define CVM_VHINT_MASK                  (CVM_MAX_INVOKE_VIRTUAL_HINTS - 1)#define CVM_IHINT_MASK                  (CVM_MAX_INVOKE_INTERFACE_HINTS - 1)/********************************************************************* * CVMJITGlobalState - where all the jit globals go. *********************************************************************/typedef struct {    /* command line options */    CVMParsedSubOptions parsedSubOptions;    CVMInt32 interpreterTransitionCost;    CVMInt32 mixedTransitionCost;    CVMInt32 backwardsBranchCost;    CVMInt32 compileThreshold;    CVMJITWhenToCompileOption whenToCompile;    CVMUint32 whatToInline;    CVMBool  registerPhis;#ifdef CVM_JIT_REGISTER_LOCALS    CVMBool  registerLocals;#endif#ifdef IAI_CODE_SCHEDULER_SCORE_BOARD#ifdef CVM_DEBUG    CVMBool  codeSchedRemoveNOP;#endif    CVMBool  codeScheduling;#endif /* IAI_CODE_SCHEDULER_SCORE_BOARD */    CVMBool  policyTriggeredDecompilations;    CVMBool  compilingCausesClassLoading;#ifdef CVM_JIT_PATCHED_METHOD_INVOCATIONS    CVMBool  pmiEnabled;#endif    CVMUint32 maxAllowedInliningDepth;    CVMUint32 maxInliningCodeLength;    CVMUint32 minInliningCodeLength;    CVMUint32 maxWorkingMemorySize;    CVMUint32 maxCompiledMethodSize;    CVMUint32 codeCacheSize;  /* Size in bytes of the code cache. */    CVMUint32 upperCodeCacheThresholdPercent; /* start decompiling */    CVMUint32 lowerCodeCacheThresholdPercent; /* stop decompiling */    CVMUint32 upperCodeCacheThreshold; /* start decompiling */    CVMInt32  lowerCodeCacheThreshold; /* stop decompiling */#ifdef CVM_JIT_ESTIMATE_COMPILATION_SPEED    CVMBool   doCSpeedMeasurement;    CVMBool   doCSpeedTest;#endif    CVMInt32  *inliningThresholds;    /* state information */    volatile CVMBool compiling; /* true if we are currently compiling */    CVMBool     destroyed;      /* true during shut after jit is destroyed */    CVMBool     csNeedDisable;  /* true if CVMcsResumeConsistentState needs				   to disable gc checkpoints */    /* the code cache */    CVMUint8*      codeCacheStart;  /* start of allocated code cache */    CVMUint8*      codeCacheEnd;    /* end of allocated code cache */    CVMUint8*      codeCacheDecompileStart; /* first method we can decompile */    CVMUint8*      codeCacheNextDecompileScanStart; /* Next location to start                                                  scanning for decompilation.*/    CVMUint8*      codeCacheGeneratedCodeStart;/* first method in code cache */    CVMJITFreeBuf* codeCacheFirstFreeBuf;      /* list of free bufferes */    CVMUint32      codeCacheBytesAllocated;    /* bytes currently allocated */    CVMUint32      codeCacheLargestFreeBuffer; /* largest free buffer */#ifdef CVM_JIT_PATCHED_METHOD_INVOCATIONS    /*     * The table that maps mb's to the list of code cache addresses that     * call the method directly. It's needed so the direct calls can be     * patched as the method is compiled, decompiled, or overridden.     * It's implemented as a hash table. See jit_common.c for details.     */    CVMJITPMICalleeRecord*      pmiCalleeRecords;    CVMUint32                   pmiNumCalleeRecords;    CVMUint32                   pmiNumUsedCalleeRecords;    CVMUint32                   pmiMaxUsedCalleeRecordsAllowed;    CVMUint32                   pmiNumDeletedCalleeRecords;    /*     * The table used by the above callee table to map callee's to     * all the code cache locations that call the callee. See jit_common.c     * for details.     */    CVMJITPMICallerRecord*      pmiCallerRecords;    CVMUint32                   pmiNumCallerRecords;    CVMUint32                   pmiNumUsedCallerRecords;    CVMInt32                    pmiFirstFreeCallerRecordIdx; /* free list */    CVMUint32                   pmiNextAvailCallerRecordIdx;#endif#ifdef CVM_AOT    /* AOT states  */    CVMBool    aotEnabled;    char*      aotFile;    CVMBool    aotCompileFailed;    CVMBool    recompileAOT;    CVMUint32  aotCodeCacheSize;  /* Code Cache Size for AOT compilation */    CVMUint8*  codeCacheAOTStart; /* start of AOT code */    CVMUint8*  codeCacheAOTEnd;   /* end of AOT code */    CVMUint8*  codeCacheAOTGeneratedCodeStart;    CVMBool    codeCacheAOTCodeExist; /* true if there are pre-compiled code */    char*      aotMethodList;     /* List of Method to be compiled ahead of time*/#endif#if defined(CVM_AOT) || defined(CVM_MTASK)    CVMBool    isPrecompiling; /* true if we are doing AOT/warmup compilation */#endif#ifdef CVM_USE_MEM_MGR    CVMMemType codeCacheMemType;#endif#ifdef CVM_JIT_PROFILE    CVMUint16* profileBuf;    char*      profile_filename;    CVMInt32   profile_fd;    CVMInt64   profileStartTime;    CVMBool    profileInstructions;#endif#ifdef CVM_JIT_COPY_CCMCODE_TO_CODECACHE    /* Address of code we copy into the start of the code cache */    CVMUint8* ccmCodeCacheCopyAddress;#if defined(CVM_JIT_HAVE_CCM_CODECACHE_COPY_ENTRIES)    /* Mapping of copied entries to function names for profiling and debug. */    CVMCCMCodeCacheCopyEntry* ccmCodeCacheCopyEntries;#endif    #endif#if 1    /*     * These are stats that are very cheap to track - we could omit them for     * optimized builds, but it's probably not necessary.     */    CVMUint32 codeCacheLowestForcedUtilization;    CVMUint32 codeCacheFailedAllocations;    CVMUint32 compilationAttempts;    CVMUint32 failedCompilationAttempts;#endif#ifdef CVMJIT_INTRINSICS    /* The following is for managing JIT intrinsics: */    CVMJITIntrinsic *intrinsics;    CVMJITIntrinsic **sortedJavaIntrinsics;    CVMJITIntrinsic **sortedNativeIntrinsics;    CVMJITIntrinsic **sortedUnknownIntrinsics;    CVMUint8 numberOfIntrinsics;    CVMUint8 numberOfJavaIntrinsics;    CVMUint8 numberOfNativeIntrinsics;    CVMUint8 numberOfUnknownIntrinsics;#endif /* CVMJIT_INTRINSICS */    /* Cache of inlining hints: */    CVMMethodBlock *invokevirtualMBTargets[CVM_MAX_INVOKE_VIRTUAL_HINTS];    CVMMethodBlock *invokeinterfaceMBTargets[CVM_MAX_INVOKE_INTERFACE_HINTS];#ifdef CVM_DEBUG_ASSERTS    /* Memory Fence Blocks list for the JIT long lived memory: */    void *longLivedMemoryBlocks;#endif /* CVM_DEBUG_ASSERTS */#ifdef CVM_JIT_ESTIMATE_COMPILATION_SPEED    CVMUint32 totalCompilationTime;    CVMUint32 numberOfByteCodeBytesCompiled;    CVMUint32 numberOfByteCodeBytesCompiledWithoutInlinedMethods;    CVMUint32 numberOfBytesOfGeneratedCode;    CVMUint32 numberOfMethodsCompiled;    CVMUint32 numberOfMethodsNotCompiled;#endif#ifdef CVM_JIT_COLLECT_STATS    CVMJITStatsToCollectOption statsToCollect;    CVMUint32 statsOptions;    CVMJITGlobalStats *globalStats;#endif#if defined(CVMJIT_PATCH_BASED_GC_CHECKS) && CVMCPU_NUM_CCM_PATCH_POINTS > 0    /* Patch points in ccm code required for gc */    CVMCCMGCPatchPoint  ccmGcPatchPoints[CVMCPU_NUM_CCM_PATCH_POINTS];#endif#ifdef CVMJIT_TRAP_BASED_GC_CHECKS    /* Max offset in words allowed when loading from gcTrapAddr */#define CVMJIT_MAX_GCTRAPADDR_WORD_OFFSET 32    void**   gcTrapAddr;  /* address that will trap when gc is requested */#endif#ifdef CVMJIT_SIMPLE_SYNC_METHODS    /* mb mappings for Simple Sync methods */    struct {	CVMMethodBlock* originalMB;	CVMMethodBlock* simpleSyncMB;    } *simpleSyncMBs;    int numSimpleSyncMBs;#ifdef CVM_DEBUG#if CVM_FASTLOCK_TYPE == CVM_FASTLOCK_MICROLOCK && \    CVM_MICROLOCK_TYPE == CVM_MICROLOCK_SWAP_SPINLOCK    /* Disabled until needed. References in jitgrammarrules.jcs       must also be enabled. */#if 0     /* The currently executing Simple Sync method and the method that       inlined the currently executing Simple Sync method. Note that these       are set every time a Simple Sync method is executed and are       never cleared, thus they can be stale.    */    CVMMethodBlock* currentSimpleSyncMB;    CVMMethodBlock* currentMB;#endif  /* 0 */#endif  /* CVM_FASTLOCK_TYPE == CVM_FASTLOCK_MICROLOCK */#endif  /* CVM_DEBUG */#endif  /* CVMJIT_SIMPLE_SYNC_METHODS */} CVMJITGlobalState;#ifdef CVM_MTASK/* * Re-initialize the JIT in the client, parsing any new JIT options * that have been passed in */extern CVMBoolCVMjitReinitialize(CVMExecEnv* ee, const char *options);#endif#if defined(CVM_DEBUG) || defined(CVM_INSPECTOR)/* Dumps info about the configuration of the JIT. */extern void CVMjitDumpSysInfo();#endif /* CVM_DEBUG || CVM_INSPECTOR */#if defined(CVM_AOT) && !defined(CVM_MTASK)/* If there is no existing AOT code, compile a list of methods. The * compiled methods will be saved as AOT code. */extern CVMBoolCVMjitCompileAOTCode(CVMExecEnv* ee);#endifextern CVMBoolCVMjitInit(CVMExecEnv* ee, CVMJITGlobalState* jgs, const char *options);extern CVMBoolCVMjitPolicyInit(CVMExecEnv* ee, CVMJITGlobalState* jgs);#if defined(CVM_AOT) || defined(CVM_MTASK)/* During AOT compilation and MTASK warmup, dynamic compilation policy * is disabled. Patched method invocation (PMI) is also disabled during * that. This is used to re-initialize JIT options and policy after  * pre-compilation. For AOT, if there is existing AOT code, this is * called after initializing the AOT code. */CVMBoolCVMjitProcessOptionsAndPolicyInit(CVMExecEnv* ee, CVMJITGlobalState* jgs);#endif/* Purpose: Set up the inlining threshold table. */CVMBoolCVMjitSetInliningThresholds(CVMExecEnv* ee, CVMJITGlobalState* jgs);extern voidCVMjitDestroy(CVMJITGlobalState* jgs);extern voidCVMjitPrintUsage();/* Purpose: Records the mb that was actually invoked from the specified pc. */extern voidCVMjitSetInvokeVirtualHint(CVMExecEnv *ee, const CVMUint8 *pc,                           CVMMethodBlock *mb);#define CVMjitSetInvokeVirtualHint(ee, pc, mb) \    (CVMglobals.jit.invokevirtualMBTargets[(CVMUint32)(pc) & CVM_VHINT_MASK] \         = (mb))/* Purpose: Gets the mb that was actually invoked from the specified pc. */extern CVMMethodBlock *CVMjitGetInvokeVirtualHint(CVMExecEnv *ee, const CVMUint8 *pc);#define CVMjitGetInvokeVirtualHint(ee, pc) \    (CVMglobals.jit.invokevirtualMBTargets[(CVMUint32)(pc) & CVM_VHINT_MASK])/* Purpose: Invalidates all mbs in the hint table. */extern voidCVMjitInvalidateInvokeVirtualHints(CVMClassBlock *cb);#define CVMjitInvalidateInvokeVirtualHints(cb) \    memset(CVMglobals.jit.invokevirtualMBTargets, 0, \           (sizeof(CVMMethodBlock *) * CVM_MAX_INVOKE_VIRTUAL_HINTS))/* Purpose: Records the mb that was actually invoked from the specified pc. */extern voidCVMjitSetInvokeInterfaceHint(CVMExecEnv *ee, const CVMUint8 *pc,                             CVMMethodBlock *mb);#define CVMjitSetInvokeInterfaceHint(ee, pc, mb) \    (CVMglobals.jit.invokeinterfaceMBTargets[(CVMUint32)(pc) & CVM_IHINT_MASK]\         = (mb))/* Purpose: Gets the mb that was actually invoked from the specified pc. */extern CVMMethodBlock *CVMjitGetInvokeInterfaceHint(CVMExecEnv *ee, const CVMUint8 *pc);#define CVMjitGetInvokeInterfaceHint(ee, pc) \    (CVMglobals.jit.invokeinterfaceMBTargets[(CVMUint32)(pc) & CVM_IHINT_MASK])/* Purpose: Invalidates all mbs in the hint table. */extern voidCVMjitInvalidateInvokeInterfaceHints(CVMClassBlock *cb);#define CVMjitInvalidateInvokeInterfaceHints(cb) \    memset(CVMglobals.jit.invokeinterfaceMBTargets, 0, \           (sizeof(CVMMethodBlock *) * CVM_MAX_INVOKE_INTERFACE_HINTS))#ifdef CVM_JIT_ESTIMATE_COMPILATION_SPEED/* The following are used to estimate the compilation speed of the dynamic   compiler.  The estimation need to be made without the interference of any   statistics gathering during the compilation cycle.  Hence, it needs its own   numberOfByteCodeBytesCompiled tracking rather than relying on the ones   collected by the JIT statistics collector.  This way, stats collection can   be turned off for an accurate estimate of compilation speed.*/extern voidCVMjitEstimateCompilationSpeed(CVMExecEnv *ee);#define CVMJIT_NUMBER_OF_COMPILATION_PASS_MEASUREMENT_REPETITIONS 10extern voidCVMjitReportCompilationSpeed();#else#define CVMjitEstimateCompilationSpeed(ee)#define CVMjitReportCompilationSpeed()#endif#define CVM_COMPILEFLAGS_LOCK(ee)   \    CVMsysMicroLock(ee, CVM_COMPILEFLAGS_MICROLOCK)#define CVM_COMPILEFLAGS_UNLOCK(ee) \    CVMsysMicroUnlock(ee, CVM_COMPILEFLAGS_MICROLOCK)#endif /* CVM_JIT */#endif /* _INCLUDED_JIT_COMMON_H */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?