ccm_runtime.c
来自「This is a resource based on j2me embedde」· C语言 代码 · 共 1,826 行 · 第 1/5 页
C
1,826 行
/* Type: STATE_NOT_FLUSHED THROWS_NONE */CVMJavaLong CVMCCMruntimeI2L(CVMJavaInt value){ CVMCCMstatsInc(CVMgetEE(), CVMCCM_STATS_CVMCCMruntimeI2L); return CVMint2Long(value);}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_I2F/* Purpose: Converts an int value to a float value. *//* Type: STATE_NOT_FLUSHED THROWS_NONE */CVMUint32 CVMCCMruntimeI2F(CVMJavaInt value){ CVMJavaVal32 v32; CVMCCMstatsInc(CVMgetEE(), CVMCCM_STATS_CVMCCMruntimeI2F); v32.f = CVMint2Float(value); return v32.raw;}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_I2D/* Purpose: Converts an int value to a double value. *//* Type: STATE_NOT_FLUSHED THROWS_NONE */CVMJavaLong CVMCCMruntimeI2D(CVMJavaInt value){ CVMJavaVal64 res; CVMCCMstatsInc(CVMgetEE(), CVMCCM_STATS_CVMCCMruntimeI2D); res.d = CVMint2Double(value); return res.l;}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_L2I/* Purpose: Converts a long value to an int value. *//* Type: STATE_NOT_FLUSHED THROWS_NONE */CVMJavaInt CVMCCMruntimeL2I(CVMJavaLong value){ CVMCCMstatsInc(CVMgetEE(), CVMCCM_STATS_CVMCCMruntimeL2I); return CVMlong2Int(value); }#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_L2F/* Purpose: Converts a long value to a float value. *//* Type: STATE_NOT_FLUSHED THROWS_NONE */CVMUint32 CVMCCMruntimeL2F(CVMJavaLong value){ CVMJavaVal32 v32; CVMCCMstatsInc(CVMgetEE(), CVMCCM_STATS_CVMCCMruntimeL2F); v32.f = CVMlong2Float(value); return v32.raw; }#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_L2D/* Purpose: Converts a long value to a double value. *//* Type: STATE_NOT_FLUSHED THROWS_NONE */CVMJavaLong CVMCCMruntimeL2D(CVMJavaLong value){ CVMJavaVal64 res; CVMCCMstatsInc(CVMgetEE(), CVMCCM_STATS_CVMCCMruntimeL2D); res.d = CVMlong2Double(value); return res.l;}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_F2I/* Purpose: Converts a float value to an int value. *//* Type: STATE_NOT_FLUSHED THROWS_NONE */CVMJavaInt CVMCCMruntimeF2I(CVMUint32 value){ CVMJavaVal32 v; CVMCCMstatsInc(CVMgetEE(), CVMCCM_STATS_CVMCCMruntimeF2I); v.raw = value; return CVMfloat2Int(v.f);}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_F2L/* Purpose: Converts a float value to a long value. *//* Type: STATE_NOT_FLUSHED THROWS_NONE */CVMJavaLong CVMCCMruntimeF2L(CVMUint32 value){ CVMJavaVal32 v32; CVMCCMstatsInc(CVMgetEE(), CVMCCM_STATS_CVMCCMruntimeF2L); v32.raw = value; return CVMfloat2Long(v32.f);}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_F2D/* Purpose: Converts a float value to a double value. *//* Type: STATE_NOT_FLUSHED THROWS_NONE */CVMJavaLong CVMCCMruntimeF2D(CVMUint32 value){ CVMJavaVal32 v32; CVMJavaVal64 res; CVMCCMstatsInc(CVMgetEE(), CVMCCM_STATS_CVMCCMruntimeF2D); v32.raw = value; res.d = CVMfloat2Double(v32.f); return res.l;}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_D2I/* Purpose: Converts a double value to an int value. *//* Type: STATE_NOT_FLUSHED THROWS_NONE */CVMJavaInt CVMCCMruntimeD2I(CVMJavaLong value){ CVMJavaVal64 v; CVMCCMstatsInc(CVMgetEE(), CVMCCM_STATS_CVMCCMruntimeD2I); v.l = value; return CVMdouble2Int(v.d);}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_D2L/* Purpose: Converts a double value to a long value. *//* Type: STATE_NOT_FLUSHED THROWS_NONE */CVMJavaLong CVMCCMruntimeD2L(CVMJavaLong value){ CVMJavaVal64 v; CVMCCMstatsInc(CVMgetEE(), CVMCCM_STATS_CVMCCMruntimeD2L); v.l = value; return CVMdouble2Long(v.d);}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_D2F/* Purpose: Converts a double value to a float value. *//* Type: STATE_NOT_FLUSHED THROWS_NONE */CVMUint32 CVMCCMruntimeD2F(CVMJavaLong value){ CVMJavaVal32 v32; CVMJavaVal64 v64; CVMCCMstatsInc(CVMgetEE(), CVMCCM_STATS_CVMCCMruntimeD2F); v64.l = value; v32.f = CVMdouble2Float(v64.d); return v32.raw;}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_LCMP/* Purpose: Compares two long values. *//* Type: STATE_NOT_FLUSHED THROWS_NONE */CVMJavaInt CVMCCMruntimeLCmp(CVMJavaLong value1, CVMJavaLong value2){ CVMCCMstatsInc(CVMgetEE(), CVMCCM_STATS_CVMCCMruntimeLCmp); return CVMlongCompare(value1, value2);}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_FCMP/* Purpose: Compares value1 with value2. *//* Returns: -1 if value1 < value2, 0 if value1 == value2, 1 if value1 > value2, and nanResult if (value1 == NaN) or (value2 == Nan) *//* Type: STATE_NOT_FLUSHED THROWS_NONE */CVMJavaInt CVMCCMruntimeFCmp(CVMUint32 value1, CVMUint32 value2, CVMJavaInt nanResult){ CVMJavaVal32 v1, v2; CVMCCMstatsInc(CVMgetEE(), CVMCCM_STATS_CVMCCMruntimeFCmp); v1.raw = value1; v2.raw = value2; return CVMfloatCompare(v1.f, v2.f, nanResult);}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_DCMPL/* Purpose: Compares value1 with value2 (NaN yields a "less than" result). *//* Returns: -1 if value1 < value2, 0 if value1 == value2, 1 if value1 > value2, and -1 if (value1 == NaN) or (value2 == Nan) i.e. NaN yields a "less than" result. *//* Type: STATE_NOT_FLUSHED THROWS_NONE */CVMJavaInt CVMCCMruntimeDCmpl(CVMJavaLong value1, CVMJavaLong value2){ CVMJavaVal64 v1, v2; CVMCCMstatsInc(CVMgetEE(), CVMCCM_STATS_CVMCCMruntimeDCmpl); v1.l = value1; v2.l = value2; return CVMdoubleCompare(v1.d, v2.d, -1);}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_DCMPG/* Purpose: Compares value1 with value2 (NaN yields a "greater than" result).*//* Returns: -1 if value1 < value2, 0 if value1 == value2, 1 if value1 > value2, and 1 if (value1 == NaN) or (value2 == Nan) i.e. NaN yields a "greater than" result. *//* Type: STATE_NOT_FLUSHED THROWS_NONE */CVMJavaInt CVMCCMruntimeDCmpg(CVMJavaLong value1, CVMJavaLong value2){ CVMJavaVal64 v1, v2; CVMCCMstatsInc(CVMgetEE(), CVMCCM_STATS_CVMCCMruntimeDCmpg); v1.l = value1; v2.l = value2; return CVMdoubleCompare(v1.d, v2.d, 1);}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_THROW_CLASS/* Purpose: Throws the specified exception. *//* Type: STATE_FLUSHED THROWS_MULTIPLE */void CVMCCMruntimeThrowClass(CVMCCExecEnv *ccee, CVMExecEnv *ee, CVMClassBlock *exceptionCb, const char *exceptionString){ CVMCCMstatsInc(ee, CVMCCM_STATS_CVMCCMruntimeThrowClass); CVMsignalError(ee, exceptionCb, exceptionString); CVMCCMhandleException(ccee);}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_THROW_OBJECT/* Purpose: Throws the specified exception. *//* Type: STATE_FLUSHED THROWS_MULTIPLE */void CVMCCMruntimeThrowObject(CVMCCExecEnv *ccee, CVMExecEnv *ee, CVMObject *obj){ /* The VM spec says that we should throw a NullPointerException if the exception object is NULL. NOTE: The IR gen does not emit a NULL check for this. The CCM runtime (i.e. this function) is expected to take care of it. */ CVMCCMstatsInc(ee, CVMCCM_STATS_CVMCCMruntimeThrowObject); if (obj == NULL) { CVMthrowNullPointerException(ee, NULL); } else { CVMgcUnsafeThrowLocalException(ee, obj); /* Throw the exception. */ } CVMCCMhandleException(ccee);}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_CHECKCAST/* Purpose: Checks to see if the specified object is can be legally casted as an instance of the specified class. *//* Type: STATE_FLUSHED THROWS_MULTIPLE *//* Throws: ClassCastException, StackOverflowError. *//* NOTE: The obj is checked for NULL in the helper function. The JITed code need not check for NULL first. */void CVMCCMruntimeCheckCast(CVMCCExecEnv *ccee, CVMClassBlock *objCb, CVMClassBlock *castCb, CVMClassBlock **cachedCbPtr){ /* NOTE: The content of this function is based on the implementation of CVMgcUnsafeIsInstanceOf(), and is inlined and modified to be optimal for the needs of JITed code. */ CVMExecEnv *ee = CVMcceeGetEE(ccee);#if CVM_DEBUG /* We better not be holding a microlock */ CVMassert(ee->microLock == 0);#endif CVMCCMstatsInc(ee, CVMCCM_STATS_CVMCCMruntimeCheckCast); if (!CVMisAssignable(ee, objCb, castCb)) { /* CVMisAssignable() may have thrown StackOverflowError */ if (!CVMlocalExceptionOccurred(ee)) { /* Illegal Cast detected. Report it: */ CVMthrowClassCastException(ee, "%C", objCb); } CVMCCMhandleException(ccee); } /* NOTE: If the checkcast is successful, then we know that objCb is cast- safe with respect to castCb. We will cache objCb because we may very well check another object of the same type against castCb again when we go through this code path again. The cached ClassBlock will allow us to quickly determine cast-safety by a simple equivalence test instead of having to go through CVMisAssignable() again. */ /* Only write back the objCb for methods above codeCacheDecompileStart. * If CVM_AOT is enabled, make sure we don't write into the AOT code. */ /* Make sure cachedCbPtr is in the codecache */#ifdef CVM_AOT CVMassert(((CVMUint8*)cachedCbPtr >= CVMglobals.jit.codeCacheStart && (CVMUint8*)cachedCbPtr < CVMglobals.jit.codeCacheEnd) || ((CVMUint8*)cachedCbPtr >= CVMglobals.jit.codeCacheAOTStart && (CVMUint8*)cachedCbPtr < CVMglobals.jit.codeCacheAOTEnd));#else CVMassert(((CVMUint8*)cachedCbPtr >= CVMglobals.jit.codeCacheStart && (CVMUint8*)cachedCbPtr < CVMglobals.jit.codeCacheEnd));#endif if ((CVMUint8*)cachedCbPtr > CVMglobals.jit.codeCacheDecompileStart#ifdef CVM_AOT && !((CVMUint8*)cachedCbPtr >= CVMglobals.jit.codeCacheAOTStart && (CVMUint8*)cachedCbPtr < CVMglobals.jit.codeCacheAOTEnd)#endif ) { *cachedCbPtr = objCb; }#if 0 /* Do a dumpstack so we know who is failing a lot */ if (!((CVMUint8*)cachedCbPtr > CVMglobals.jit.codeCacheDecompileStart)) { CVMMethodBlock* mb = ee->interpreterStack.currentFrame->mb; CVMconsolePrintf("--> %C.%M\n", CVMmbClassBlock(mb), mb); CVMdumpStack(&ee->interpreterStack,0,0,0); }#endif}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_CHECK_ARRAY_ASSIGNABLE/* Purpose: Checks to see if the an element of type 'rhsCb' can be stored into an array whose element type is 'elemCb'. *//* Type: STATE_FLUSHED THROWS_MULTIPLE *//* Throws: ArrayStoreException, StackOverflowError. *//* NOTE: The obj is checked for NULL inline */void CVMCCMruntimeCheckArrayAssignable(CVMCCExecEnv *ccee, CVMExecEnv *ee, CVMClassBlock *elemCb, CVMClassBlock *rhsCb){ /* NOTE: The content of this function is based on the implementation of aastore in the interpreter loop */#if CVM_DEBUG /* We better not be holding a microlock */ CVMassert(ee->microLock == 0);#endif CVMCCMstatsInc(ee, CVMCCM_STATS_CVMCCMruntimeCheckArrayAssignable); /* We have checked for equality inline. Verify that */ CVMassert(elemCb != rhsCb); if (!CVMisAssignable(ee, rhsCb, elemCb)) { /* CVMisAssignable() may have thrown StackOverflowError */ if (!CVMlocalExceptionOccurred(ee)) { /* Illegal array assignment detected. Report it: */ CVMthrowArrayStoreException(ee, "%C", rhsCb); } CVMCCMhandleException(ccee); }}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_INSTANCEOF/* Purpose: Checks to see if the specified object is an instance of the specified class or its subclasses. *//* Type: STATE_FLUSHED THROWS_SINGLE *//* Throws: StackOverflowError. *//* NOTE: The obj is checked for NULL in the helper function. The JITed code need not check for NULL first. */CVMJavaInt CVMCCMruntimeInstanceOf(CVMCCExecEnv *ccee, CVMClassBlock *objCb, CVMClassBlock *instanceofCb, CVMClassBlock **cachedCbPtr){ CVMExecEnv *ee = CVMcceeGetEE(ccee); CVMJavaInt success;#if CVM_DEBUG /* We better not be holding a microlock */ CVMassert(ee->microLock == 0);#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?