ccm_runtime.c
来自「This is a resource based on j2me embedde」· C语言 代码 · 共 1,826 行 · 第 1/5 页
C
1,826 行
/* Make sure cachedConstant is in the codecache */ CVMassert(((CVMUint8*)cachedConstant >= CVMglobals.jit.codeCacheStart && (CVMUint8*)cachedConstant < CVMglobals.jit.codeCacheEnd)); /* * AOT only supports ROMized classes, whose cp are always resolved. * CVMCCMruntimeResolveSpecialMethodBlock should never called for AOT code. * The above assertion covers that. */ *cachedConstant = mb; return CVM_TRUE; /* no class initialization needed */}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_RESOLVE_METHOD_TABLE_OFFSET/* Purpose: Resolves the specified method block constant pool entry into a method table offset for invokevirtual, and checks if the method has changed into a static method. *//* Result: Always returns TRUE since no class initialization is needed. *//* Type: STATE_FLUSHED_TOTALLY THROWS_MULTIPLE *//* Throws: IllegalAccessError, IncompatibleClassChangeError, NoSuchMethodError, etc. */CVMMethodBlock *CVMCCMruntimeResolveMethodTableOffset(CVMCCExecEnv *ccee, CVMExecEnv *ee, CVMUint16 cpIndex, CVMUint32 *cachedConstant){ CVMConstantPool *cp = CVMeeGetCurrentFrameCp(ee); CVMUint32 offset; CVMMethodBlock *mb; CVMCCMstatsInc(ee, CVMCCM_STATS_CVMCCMruntimeResolveMethodTableOffset); /* NOTE: CVMCCMruntimeResolveConstantPoolEntry() won't return if an exception was thrown. It will bypass all this and turn control over to the VM's exception handling mechanism. */ CVMCCMruntimeResolveConstantPoolEntry(ccee, ee, cpIndex, cp); mb = CVMcpGetMb(cp, cpIndex);#ifndef CVM_TRUSTED_CLASSLOADERS { CVMCCMruntimeLazyFixups(ee); /* Make sure that the method is not static: */ if (!CVMmethodHasNotChangeStaticState(ee, mb, CVM_FALSE)) { CVMCCMhandleException(ccee); } }#endif /* make sure its in the table! */ if (CVMmbMethodTableIndex(mb) == CVM_LIMIT_NUM_METHODTABLE_ENTRIES){ /* return mb pointer directly */ return mb; } offset = CVMmbMethodTableIndex(mb) * sizeof(CVMMethodBlock *); CVMassert(cachedConstant != NULL); /* Make sure cachedConstant is in the codecache */ CVMassert(((CVMUint8*)cachedConstant >= CVMglobals.jit.codeCacheStart && (CVMUint8*)cachedConstant < CVMglobals.jit.codeCacheEnd)); /* * AOT only supports ROMized classes, whose cp are always resolved. * CVMCCMruntimeResolveMethodTableOffset should never called for AOT code. * The above assertion covers that. */ *cachedConstant = offset; return (CVMMethodBlock*)NULL; /* vtbl entry entered in cache word */}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_RESOLVE_NEW_CLASS_BLOCK_AND_CLINIT/* Purpose: Resolves the specified class block constant pool entry, checks if it is Ok to instantiate an instance of this class, and runs the static initializer if necessary. *//* Result: Same as CVMCCMruntimeRunClassInitializer. *//* Type: STATE_FLUSHED_TOTALLY THROWS_MULTIPLE *//* Throws: IllegalAccessError, InstantiationError, etc. */CVMBoolCVMCCMruntimeResolveNewClassBlockAndClinit(CVMCCExecEnv *ccee, CVMExecEnv *ee, CVMUint16 cpIndex, CVMClassBlock **cachedConstant){ CVMConstantPool *cp = CVMeeGetCurrentFrameCp(ee); CVMClassBlock *cb; CVMCCMstatsInc(ee, CVMCCM_STATS_CVMCCMruntimeResolveNewClassBlockAndClinit); /* NOTE: CVMCCMruntimeResolveConstantPoolEntry won't return if an exception was thrown. It will bypass all this and turn control over to the VM's exception handling mechanism. */ CVMCCMruntimeResolveConstantPoolEntry(ccee, ee, cpIndex, cp); cb = CVMcpGetCb(cp, cpIndex);#ifndef CVM_TRUSTED_CLASSLOADERS CVMCCMruntimeLazyFixups(ee); /* Make sure it is OK to instantiate the specified class: */ if (!CVMclassIsOKToInstantiate(ee, cb)) { CVMCCMhandleException(ccee); }#endif CVMassert(cachedConstant != NULL); /* Make sure cachedConstant is in the codecache */ CVMassert(((CVMUint8*)cachedConstant >= CVMglobals.jit.codeCacheStart && (CVMUint8*)cachedConstant < CVMglobals.jit.codeCacheEnd)); /* * AOT only supports ROMized classes, whose cp are always resolved. * CVMCCMruntimeResolveNewClassBlockAndClinit should never called for * AOT code. The above assertion covers that. */ *cachedConstant = cb; /* Do static initialization if necessary: */ /* NOTE: CVMCCMruntimeRunClassInitializer() won't return if it needs to run the static initializer. It will bypass all this and turn control over to the VM's compiled code manager. */ return CVMCCMruntimeRunClassInitializer(ccee, ee, cb);}#endif#if !defined(CVMCCM_HAVE_PLATFORM_SPECIFIC_RESOLVE_GETSTATIC_FB_AND_CLINIT)||\ !defined(CVMCCM_HAVE_PLATFORM_SPECIFIC_RESOLVE_PUTSTATIC_FB_AND_CLINIT)/* Purpose: Resolves the specified static field constant pool entry, checks if the field has changed into a non-static field, checks if the field is final (i.e. not writable to) if necessarily, and runs the static initializer if necessary. *//* Result: Same as CVMCCMruntimeRunClassInitializer. *//* Type: STATE_FLUSHED_TOTALLY THROWS_MULTIPLE *//* Throws: IllegalAccessError, IncompatibleClassChangeError, NoSuchFieldError, etc. */static CVMBoolCVMCCMruntimeResolveStaticFieldBlockAndClinit(CVMCCExecEnv *ccee, CVMExecEnv *ee, CVMUint16 cpIndex, void **cachedConstant, CVMBool isWrite){ CVMConstantPool *cp = CVMeeGetCurrentFrameCp(ee); CVMClassBlock *cb; CVMFieldBlock *fb; void *addressOfStaticField; /* NOTE: CVMCCMruntimeResolveConstantPoolEntry() won't return if an exception was thrown. It will bypass all this and turn control over to the VM's exception handling mechanism. */ CVMCCMruntimeResolveConstantPoolEntry(ccee, ee, cpIndex, cp); fb = CVMcpGetFb(cp, cpIndex);#ifndef CVM_TRUSTED_CLASSLOADERS CVMCCMruntimeLazyFixups(ee); /* Make sure that the field is static: */ if (!CVMfieldHasNotChangeStaticState(ee, fb, CVM_TRUE)) { CVMCCMhandleException(ccee); } /* Make sure we aren't trying to store into a final field. The VM spec * says that you can only store into a final field when initializing it. * The JDK seems to interpret this as meaning that a class has write access * to its final fields, so we do the same here (see how isFinalField gets * setup in quicken.c). */ if (isWrite && !CVMfieldIsOKToWriteTo(ee, fb, CVMeeGetCurrentFrameCb(ee), CVM_TRUE)) { CVMCCMhandleException(ccee); }#endif cb = CVMfbClassBlock(fb); /* TBD: For LVM, the cachedConstant should be set to the fb instead of the address of the static field if the cb is an LVM system class. But this needs to be accompanied by changes in codegen.jcs which are not as simple. How can codegen.jcs emit the appropriate code if it does not know prior to resolution if this cb is an LVM system class or not. */ addressOfStaticField = &CVMfbStaticField(ee, fb); CVMassert(cachedConstant != NULL); /* Make sure cachedConstant is in the codecache */ CVMassert(((CVMUint8*)cachedConstant >= CVMglobals.jit.codeCacheStart && (CVMUint8*)cachedConstant < CVMglobals.jit.codeCacheEnd)); /* * AOT only supports ROMized classes, whose cp are always resolved. * CVMCCMruntimeResolveStaticFieldBlockAndClinit should never called * for AOT code. The above assertion covers that. */ *cachedConstant = addressOfStaticField; /* Do static initialization if necessary: */ /* NOTE: CVMCCMruntimeRunClassInitializer() won't return if it needs to run the static initializer. It will bypass all this and turn control over to the VM's compiled code manager. */ return CVMCCMruntimeRunClassInitializer(ccee, ee, cb);}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_RESOLVE_GETSTATIC_FB_AND_CLINIT/* Purpose: Resolves the specified static field constant pool entry, checks if the field has changed into a non-static field, and runs the static initializer if necessary. *//* Result: Same as CVMCCMruntimeRunClassInitializer. *//* Type: STATE_FLUSHED_TOTALLY THROWS_MULTIPLE *//* Throws: IllegalAccessError, IncompatibleClassChangeError, NoSuchFieldError, etc. */CVMBoolCVMCCMruntimeResolveGetstaticFieldBlockAndClinit(CVMCCExecEnv *ccee, CVMExecEnv *ee, CVMUint16 cpIndex, void **cachedConstant){ CVMCCMstatsInc(ee, CVMCCM_STATS_CVMCCMruntimeResolveGetstaticFieldBlockAndClinit); return CVMCCMruntimeResolveStaticFieldBlockAndClinit( ccee, ee, cpIndex, cachedConstant, CVM_FALSE);}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_RESOLVE_PUTSTATIC_FB_AND_CLINIT/* Purpose: Resolves the specified static field constant pool entry, checks if the field has changed into a non-static field, checks if the field is final (i.e. not writable to), and runs the static initializer if necessary. *//* Result: Same as CVMCCMruntimeRunClassInitializer. *//* Type: STATE_FLUSHED_TOTALLY THROWS_MULTIPLE *//* Throws: IllegalAccessError, IncompatibleClassChangeError, NoSuchFieldError, etc. */CVMBoolCVMCCMruntimeResolvePutstaticFieldBlockAndClinit(CVMCCExecEnv *ccee, CVMExecEnv *ee, CVMUint16 cpIndex, void **cachedConstant){ CVMCCMstatsInc(ee, CVMCCM_STATS_CVMCCMruntimeResolvePutstaticFieldBlockAndClinit); return CVMCCMruntimeResolveStaticFieldBlockAndClinit( ccee, ee, cpIndex, cachedConstant, CVM_TRUE);}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_RESOLVE_STATIC_MB_AND_CLINIT/* Purpose: Resolves the specified static method block constant pool entry, and runs the static initializer if necessary. *//* Result: Same as CVMCCMruntimeRunClassInitializer. *//* Type: STATE_FLUSHED_TOTALLY THROWS_MULTIPLE *//* Throws: IllegalAccessError, IncompatibleClassChangeError, NoSuchMethodError, etc. */CVMBoolCVMCCMruntimeResolveStaticMethodBlockAndClinit(CVMCCExecEnv *ccee, CVMExecEnv *ee, CVMUint16 cpIndex, CVMMethodBlock **cachedConstant){ CVMConstantPool *cp = CVMeeGetCurrentFrameCp(ee); CVMMethodBlock *mb; CVMClassBlock *cb; CVMCCMstatsInc(ee, CVMCCM_STATS_CVMCCMruntimeResolveStaticMethodBlockAndClinit); /* NOTE: CVMCCMruntimeResolveConstantPoolEntry() won't return if an exception was thrown. It will bypass all this and turn control over to the VM's exception handling mechanism. */ CVMCCMruntimeResolveConstantPoolEntry(ccee, ee, cpIndex, cp); mb = CVMcpGetMb(cp, cpIndex);#ifndef CVM_TRUSTED_CLASSLOADERS CVMCCMruntimeLazyFixups(ee); /* Make sure that the method is static: */ if (!CVMmethodHasNotChangeStaticState(ee, mb, CVM_TRUE)) { CVMCCMhandleException(ccee); }#endif CVMassert(cachedConstant != NULL); /* Make sure cachedConstant is in the codecache */ CVMassert(((CVMUint8*)cachedConstant >= CVMglobals.jit.codeCacheStart && (CVMUint8*)cachedConstant < CVMglobals.jit.codeCacheEnd)); /* * AOT only supports ROMized classes, whose cp are always resolved. * CVMCCMruntimeResolveStaticMethodBlockAndClinit should never called * for AOT code. The above assertion covers that. */ *cachedConstant = mb; /* Do static initialization if necessary: */ /* NOTE: CVMCCMruntimeRunClassInitializer() won't return if it needs to run the static initializer. It will bypass all this and turn control over to the VM's compiled code manager. */ cb = CVMmbClassBlock(mb); return CVMCCMruntimeRunClassInitializer(ccee, ee, cb);}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_PUTSTATIC_64_VOLATILE/* Purpose: Performs an atomic 64-bit putstatic. *//* Type: STATE_NOT_FLUSHED THROWS_NONE */void CVMCCMruntimePutstatic64Volatile(CVMJavaLong value, void *staticField){ CVMExecEnv *ee = CVMgetEE(); CVMCCMstatsInc(ee, CVMCCM_STATS_CVMCCMruntimePutstatic64Volatile); CVMassert(staticField != NULL); CVM_ACCESS_VOLATILE_LOCK(ee); CVMmemCopy64((CVMUint32*)staticField, (CVMUint32*)&value); CVM_ACCESS_VOLATILE_UNLOCK(ee);}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_GETSTATIC_64_VOLATILE/* Purpose: Performs an atomic 64-bit getstatic. *//* Type: STATE_NOT_FLUSHED THROWS_NONE */CVMJavaLong CVMCCMruntimeGetstatic64Volatile(void *staticField){ CVMExecEnv *ee = CVMgetEE(); CVMJavaLong result; CVMCCMstatsInc(ee, CVMCCM_STATS_CVMCCMruntimeGetstatic64Volatile); CVMassert(staticField != NULL); CVM_ACCESS_VOLATILE_LOCK(ee); CVMmemCopy64((CVMUint32*)&result, (CVMUint32*)staticField); CVM_ACCESS_VOLATILE_UNLOCK(ee); return result;}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_PUTFIELD_64_VOLATILE/* Purpose: Performs an atomic 64-bit putfield. *//* Type: STATE_NOT_FLUSHED THROWS_NONE */void CVMCCMruntimePutfield64Volatile(CVMJavaLong value, CVMObject *obj, CVMJavaInt fieldByteOffset){ CVMExecEnv *ee = CVMgetEE(); void *instanceField = ((CVMUint8*)obj) + fieldByteOffset; CVMCCMstatsInc(ee, CVMCCM_STATS_CVMCCMruntimePutfield64Volatile); CVMassert(obj != NULL); CVM_ACCESS_VOLATILE_LOCK(ee); CVMmemCopy64((CVMUint32*)instanceField, (CVMUint32*)&value); CVM_ACCESS_VOLATILE_UNLOCK(ee);}#endif#ifndef CVMCCM_HAVE_PLATFORM_SPECIFIC_GETFIELD_64_VOLATILE/* Purpose: Performs an atomic 64-bit getfield. *//* Type: STATE_NOT_FLUSHED THROWS_NONE */CVMJavaLong CVMCCMruntimeGetfield64Volatile(CVMObject *obj, CVMJavaInt fieldByteOffset){ CVMExecEnv *ee = CVMgetEE(); void *instanceField = ((CVMUint8*)o
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?