⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cvm.c

📁 This is a resource based on j2me embedded,if you dont understand,you can connection with me .
💻 C
📖 第 1 页 / 共 3 页
字号:
/* * executeLoadSuperClasses is responsible for getting the * Class.loadSuperClasses() executed for * Launcher.defineClassPrivate(), which doesn't have access to it from * java. It could do this by just using JNI to invoke * theClass.loadSuperClasses() method, but this causes undesireable C * recursion in the interpreter. Instead we just store the mb of the * Class.loadSuperClasses() method in *p_mb, and return CVM_NEW_MB to the * interpreter. This signals the interpreter to invoke the method * stored in *p_mb.  */CNIEXPORT CNIResultCodeCNIsun_misc_CVM_executeLoadSuperClasses(    CVMExecEnv* ee, CVMStackVal32 *arguments, CVMMethodBlock **p_mb){    /* Return the new mb */    *p_mb = CVMglobals.java_lang_Class_loadSuperClasses;    return CNI_NEW_MB;}#ifdef FOR_EXAMPLECNIEXPORT CNIResultCodeCNIsun_misc_CVM_arraycopy(CVMExecEnv* ee, CVMStackVal32 *arguments,			  CVMMethodBlock **p_mb){    CVMObjectICell *src = &arguments[0].j.r;    CVMJavaInt src_position = arguments[1].j.i;    CVMObjectICell *dst = &arguments[2].j.r;    CVMJavaInt dst_position = arguments[3].j.i;    CVMJavaInt length = arguments[4].j.i;    /* For now, until we have an optimized, unsafe version of arraycopy */    CVMD_gcSafeExec(ee, {	JNIEnv *env = CVMexecEnv2JniEnv(ee);	JVM_ArrayCopy(env, NULL, src, src_position, dst, dst_position, length);    });    return CNI_VOID;}#endifCNIEXPORT CNIResultCodeCNIsun_misc_CVM_disableRemoteExceptions(CVMExecEnv* ee,					CVMStackVal32 *arguments,					CVMMethodBlock **p_mb){    CVMdisableRemoteExceptions(ee);    return CNI_VOID;}CNIEXPORT CNIResultCodeCNIsun_misc_CVM_enableRemoteExceptions(CVMExecEnv* ee,				       CVMStackVal32 *arguments,				       CVMMethodBlock **p_mb){    CVMenableRemoteExceptions(ee);    /* Check if remote exception have thrown */    if (CVMexceptionOccurred(ee)) {	return CNI_EXCEPTION;    } else {	return CNI_VOID;    }}CNIEXPORT CNIResultCodeCNIsun_misc_CVM_throwRemoteException(CVMExecEnv* ee,				     CVMStackVal32 *arguments,				     CVMMethodBlock **p_mb){#ifdef CVM_REMOTE_EXCEPTIONS_SUPPORTED    CVMObjectICell *threadICell = &arguments[0].j.r;    CVMObjectICell *exceptionICell = &arguments[1].j.r;    CVMJavaLong eetop;    CVMExecEnv *targetEE;    CVMD_fieldReadLong(CVMID_icellDirect(ee, threadICell),		       CVMoffsetOfjava_lang_Thread_eetop,		       eetop);    targetEE = (CVMExecEnv *)CVMlong2VoidPtr(eetop);    /* Have to be invoked through Thread.stop1() that ensures ee != NULL */    CVMassert(ee != NULL);    CVMgcUnsafeThrowRemoteException(ee, targetEE, 				    CVMID_icellDirect(ee, exceptionICell));    /* %comment: rt037 */#else    CVMassert(CVM_FALSE);#endif    return CNI_VOID;}CNIEXPORT CNIResultCodeCNIsun_misc_CVM_throwLocalException(CVMExecEnv* ee,				    CVMStackVal32 *arguments,				    CVMMethodBlock **p_mb){    CVMObjectICell *exceptionICell = &arguments[0].j.r;    CVMgcUnsafeThrowLocalException(ee, CVMID_icellDirect(ee, exceptionICell));    return CNI_EXCEPTION;}CNIEXPORT CNIResultCodeCNIsun_misc_CVM_callerCLIsMIDCLs(CVMExecEnv* ee,                                   CVMStackVal32 *arguments,                                   CVMMethodBlock **p_mb){#ifndef CVM_DUAL_STACK    arguments[0].j.i = CVM_FALSE;#else    CVMClassBlock* cb;    CVMClassLoaderICell* loaderICell;     /*      * Get the caller. Note we only look one frame up here because     * there is no frame pushed for the CNI method.     */    cb = CVMgetCallerClass(ee, 1);    loaderICell = (cb == NULL) ? NULL : CVMcbClassLoader(cb);        arguments[0].j.i = CVMclassloaderIsMIDPClassLoader(        ee, loaderICell, CVM_TRUE);#endif    return CNI_SINGLE;}CNIEXPORT CNIResultCodeCNIsun_misc_CVM_isMIDPContext(CVMExecEnv* ee,                              CVMStackVal32 *arguments,                              CVMMethodBlock **p_mb){#ifndef CVM_DUAL_STACK   arguments[0].j.i = CVM_FALSE;#else    CVMBool result = CVM_FALSE;    int i;    /*      * Check each caller on the stack to if it is was loaded by a MIDP class     * class loader. Note we start one frame up here because     * there is no frame pushed for the CNI method.     */    for (i = 1; ; i++) {        CVMClassBlock* cb;        CVMClassLoaderICell* loaderICell;         cb = CVMgetCallerClass(ee, i);        if (NULL == cb) {            break;        }        loaderICell = CVMcbClassLoader(cb);        if (NULL == loaderICell) {            continue;        }        result = CVMclassloaderIsMIDPClassLoader(ee, loaderICell, CVM_TRUE);        if (result) {            break;        }    }    arguments[0].j.i = result;#endif    return CNI_SINGLE;}/* %begin lvm */CNIEXPORT CNIResultCodeCNIsun_misc_CVM_inMainLVM(CVMExecEnv* ee,			  CVMStackVal32 *arguments,			  CVMMethodBlock **p_mb){#ifdef CVM_LVM    CVMD_gcSafeExec(ee, {	arguments[0].j.i = (CVMLVMinMainLVM(ee))?(JNI_TRUE):(JNI_FALSE);    });#else    arguments[0].j.i = JNI_TRUE;#endif    return CNI_SINGLE;}/* %end lvm */CNIEXPORT CNIResultCodeCNIsun_misc_CVM_gcDumpHeapSimple(CVMExecEnv* ee,				 CVMStackVal32 *arguments,				 CVMMethodBlock **p_mb){#ifdef CVM_INSPECTOR    CVMD_gcSafeExec(ee, {	CVMgcDumpHeapSimple();    });#endif    return CNI_VOID;}CNIEXPORT CNIResultCodeCNIsun_misc_CVM_gcDumpHeapVerbose(CVMExecEnv* ee,				  CVMStackVal32 *arguments,				  CVMMethodBlock **p_mb){#ifdef CVM_INSPECTOR    CVMD_gcSafeExec(ee, {	CVMgcDumpHeapVerbose();    });#endif    return CNI_VOID;}CNIEXPORT CNIResultCodeCNIsun_misc_CVM_gcDumpHeapStats(CVMExecEnv* ee,				CVMStackVal32 *arguments,				CVMMethodBlock **p_mb){#ifdef CVM_INSPECTOR    CVMD_gcSafeExec(ee, {	CVMgcDumpHeapStats();    });#endif    return CNI_VOID;}#ifdef CVM_DEBUG#include "javavm/include/porting/system.h"#include "javavm/include/porting/time.h"#define TRACE_SIZE 1000static CVMInt64 millis[TRACE_SIZE];static int id[TRACE_SIZE];static int indx;CNIEXPORT CNIResultCodeCNIsun_misc_CVM_trace(CVMExecEnv *ee,		      CVMStackVal32 *arguments,		      CVMMethodBlock **p_mb){    CVMJavaInt i = arguments[0].j.i;    CVMInt64 l = CVMtimeMillis();    if (i < 0) {	if (indx > 0) {	    int j;	    for (j = 1; j < indx; ++j) {		CVMconsolePrintf("t%d - t%d--> %dms\n", id[j], id[j-1],		    CVMlong2Int(CVMlongSub(millis[j], millis[j-1])));	    }	}	indx = 0;	i = -i;    }    if (indx < TRACE_SIZE) {	millis[indx] = l;	id[indx] = i;	++indx;    }    return CNI_VOID;}#elseCNIEXPORT CNIResultCodeCNIsun_misc_CVM_trace(CVMExecEnv *ee,		      CVMStackVal32 *arguments,		      CVMMethodBlock **p_mb){    return CNI_VOID;}#endif /* !DEBUG */CNIEXPORT CNIResultCodeCNIsun_misc_CVM_setDebugEvents(CVMExecEnv* ee, CVMStackVal32 *arguments,			       CVMMethodBlock **p_mb){#ifdef CVM_JVMTI    if (CVMjvmtiIsEnabled()) {	CVMjvmtiDebugEventsEnabled(ee) = arguments[0].j.i;    }#endif    return CNI_VOID;}CNIEXPORT CNIResultCodeCNIsun_misc_CVM_postThreadExit(CVMExecEnv* ee, CVMStackVal32 *arguments,			       CVMMethodBlock **p_mb){    CVMD_gcSafeExec(ee, {	CVMpostThreadExitEvents(ee);    });    return CNI_VOID;}CNIEXPORT CNIResultCodeCNIsun_misc_CVM_setContextArtificial(CVMExecEnv* ee, CVMStackVal32 *arguments,				     CVMMethodBlock **p_mb){    CVMframeSetContextArtificial(ee);    return CNI_VOID;}/* * Inflates an object's monitor and marks it sticky so it's never freed. */CNIEXPORT CNIResultCodeCNIsun_misc_CVM_objectInflatePermanently(CVMExecEnv* ee,					 CVMStackVal32 *arguments,					 CVMMethodBlock **p_mb){    CVMObjectICell *indirectObj = &arguments[0].j.r;    CVMObjMonitor *mon;    mon = CVMobjectInflatePermanently(ee, indirectObj);    if (mon != NULL) {	arguments[0].j.i = CVM_TRUE;    } else {	arguments[0].j.i = CVM_FALSE;    }    return CNI_SINGLE;}/* * enable/disable compilations by current thread */CNIEXPORT CNIResultCode CNIsun_misc_CVM_setThreadNoCompilationsFlag(CVMExecEnv* ee,					    CVMStackVal32 *arguments,					    CVMMethodBlock **p_mb){#ifdef CVM_JIT    CVMBool noCompilations = arguments[0].j.i;    ee->noCompilations = noCompilations;#endif        return CNI_VOID;}CNIEXPORT CNIResultCodeCNIsun_misc_CVM_getCallerClass(CVMExecEnv* ee, CVMStackVal32 *arguments,			       CVMMethodBlock **p_mb){    CVMJavaInt skip = arguments[0].j.i;    CVMClassBlock* cb = CVMgetCallerClass(ee, skip);    CVMObject* result;    if (cb == NULL) {        result = NULL;    } else {        result = CVMID_icellDirect(ee, CVMcbJavaInstance(cb));    }    CVMID_icellSetDirect(ee, &arguments[0].j.r, result);    return CNI_SINGLE;}/* * Is the compiler built in? */CNIEXPORT CNIResultCodeCNIsun_misc_CVM_isCompilerSupported(CVMExecEnv* ee,				    CVMStackVal32 *arguments,				    CVMMethodBlock **p_mb){#ifdef CVM_JIT    arguments[0].j.i = CVM_TRUE;#else    arguments[0].j.i = CVM_FALSE;#endif    return CNI_SINGLE;}/* * Request a dump of the profiling data collected by the compiler if available. */CNIEXPORT CNIResultCodeCNIsun_misc_CVM_dumpCompilerProfileData(CVMExecEnv* ee,				        CVMStackVal32 *arguments,				        CVMMethodBlock **p_mb){#if defined(CVM_JIT) && defined(CVM_JIT_PROFILE)    CVMD_gcSafeExec(ee, {        CVMJITcodeCacheDumpProfileData();    });#endif    return CNI_VOID;}/* * Dump misc. stats */CNIEXPORT CNIResultCodeCNIsun_misc_CVM_dumpStats(CVMExecEnv* ee,			  CVMStackVal32 *arguments,			  CVMMethodBlock **p_mb){    /* Insert any stats you want here */#ifdef CVM_USE_MEM_MGR    /* Dump the dirty page info that the Memory Manager collected     * for the monitored regions.     */    CVMmemManagerDumpStats();#endif    return CNI_VOID;}/* * Mark the code buffer */CNIEXPORT CNIResultCodeCNIsun_misc_CVM_markCodeBuffer(CVMExecEnv* ee,			       CVMStackVal32 *arguments,			       CVMMethodBlock **p_mb){#ifdef CVM_JIT    CVMJITmarkCodeBuffer();#if 0    CVMconsolePrintf("MARKED THIS JITBUFFER SPOT, %d BYTES IN USE\n",		     CVMglobals.jit.codeCacheBytesAllocated);#endif#endif#ifdef CVM_USE_MEM_MGR    /* the .bss region */    CVMmemRegisterBSS();#endif /* CVM_USE_MEM_MGR */    return CNI_VOID;}/* * Enable compilation */CNIEXPORT CNIResultCodeCNIsun_misc_CVM_initializeJITPolicy(CVMExecEnv* ee,			          CVMStackVal32 *arguments,			          CVMMethodBlock **p_m){#ifdef CVM_JIT#if defined(CVM_AOT) || defined(CVM_MTASK)    CVMjitProcessOptionsAndPolicyInit(ee, &CVMglobals.jit);#endif#endif    return CNI_VOID;}/* * Initialize pre-compiled code. */CNIEXPORT CNIResultCodeCNIsun_misc_CVM_initializeAOTCode(CVMExecEnv* ee,                                  CVMStackVal32 *arguments,                                  CVMMethodBlock **p_m){#ifdef CVM_AOT    CVMD_gcSafeExec(ee, {        arguments[0].j.i = CVMJITinitializeAOTCode();    });#else    CVMD_gcSafeExec(ee, {        arguments[0].j.i = CVM_TRUE;    });#endif    return CNI_SINGLE;}CNIEXPORT CNIResultCodeCNIsun_misc_CVM_maskInterrupts(CVMExecEnv* ee,			       CVMStackVal32 *arguments,			       CVMMethodBlock **p_mb){    CVMD_gcSafeExec(ee, {	arguments[0].j.i = CVMmaskInterrupts(ee);    });    return CNI_SINGLE;}CNIEXPORT CNIResultCodeCNIsun_misc_CVM_unmaskInterrupts(CVMExecEnv* ee,			       CVMStackVal32 *arguments,			       CVMMethodBlock **p_mb){    CVMD_gcSafeExec(ee, {	CVMunmaskInterrupts(ee);    });    return CNI_VOID;}CNIEXPORT CNIResultCodeCNIsun_misc_CVM_parseVerifyOptions(CVMExecEnv* ee, CVMStackVal32 *arguments,				   CVMMethodBlock **p_mb){    jobject opts  = &arguments[0].j.r;    char* kind = CVMconvertJavaStringToCString(ee, opts);    CVMBool result;    if (kind == NULL) {	result = CVM_FALSE;    } else {	int verification = CVMclassVerificationSpecToEncoding(kind);	if (verification != CVM_VERIFY_UNRECOGNIZED) {	    CVMglobals.classVerificationLevel = verification;	    result = CVM_TRUE;	} else {	    result = CVM_FALSE;	}	free(kind);    }    arguments[0].j.i = result;    return CNI_SINGLE;

⌨️ 快捷键说明

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