executejava_aligned.c

来自「This is a resource based on j2me embedde」· C语言 代码 · 共 1,990 行 · 第 1/5 页

C
1,990
字号
    /*     * Traverse information node tree, creating nodes as needed.     */    for (i = 1; i < CVM_SEQ_DEPTH; i++) {	CVMUint32   theIdx;	CVMRunInfo* nextRecord;	record->incidence[currOpcode]++;	nextRecord = record->followers[currOpcode];	if (nextRecord == 0) {	    nextRecord = calloc(1, sizeof(CVMRunInfo));	    record->followers[currOpcode] = nextRecord;	}	record = nextRecord;	theIdx = (idx + i) % CVM_SEQ_DEPTH;	currOpcode = CVMopcodeWindow[theIdx];    }    /*     * We are now at the right level. Record this opcode.     */    record->incidence[currOpcode]++;}static voidCVMupdateStats(CVMOpcode opcode){    CVMopcodeWindow[CVMopcodeWindowIdx] = CVMopcodeSimplification[opcode];    CVMopcodeWindowIdx++;    CVMopcodeWindowIdx %= CVM_SEQ_DEPTH;    CVMrecordWindow(CVMopcodeWindowIdx);}void CVMinitStats(){    CVMopcodeWindowIdx = 0;    CVMseqInfo = calloc(1, sizeof(CVMRunInfo));}static voidCVMdumpStats2(){    CVMOpcode opcode1, opcode2;    CVMconsolePrintf("Instruction count=%dM[,%d]\n",		     CVMbigCount, CVMsmallCount);    printf("\n\n\n\nSequences:\n");    for (opcode1 = 0; opcode1 < 255; opcode1++) {	for (opcode2 = 0; opcode2 < 255; opcode2++) {	    CVMRunInfo* info = CVMseqInfo->followers[opcode1];	    if (info != 0) {		if (info->incidence[opcode2] != 0) {		    printf("%d Seq: <%s>,<%s>\n",			       info->incidence[opcode2],			       CVMopnames[opcode1],			       CVMopnames[opcode2]);		}	    }	}    }}static voidCVMdumpStats3(){    CVMOpcode opcode1, opcode2, opcode3;    CVMconsolePrintf("Instruction count=%dM[,%d]\n",		     CVMbigCount, CVMsmallCount);    printf("\n\n\n\nSequences:\n");    for (opcode1 = 0; opcode1 < 255; opcode1++) {	for (opcode2 = 0; opcode2 < 255; opcode2++) {	    for (opcode3 = 0; opcode3 < 255; opcode3++) {		CVMRunInfo* info = CVMseqInfo->followers[opcode1];		if (info != 0) {		    info = info->followers[opcode2];		    if (info != 0) {			if (info->incidence[opcode3] != 0) {			    printf("%d Seq: <%s>,<%s>,<%s>\n",				       info->incidence[opcode3],				       CVMopnames[opcode1],				       CVMopnames[opcode2],				       CVMopnames[opcode3]);			}		    }		}	    }	}    }}static voidCVMdumpStats4(){    CVMOpcode opcode1, opcode2, opcode3, opcode4;    CVMconsolePrintf("Instruction count=%dM[,%d]\n",		     CVMbigCount, CVMsmallCount);    printf("\n\n\n\nSequences:\n");    for (opcode1 = 0; opcode1 < 255; opcode1++) {	for (opcode2 = 0; opcode2 < 255; opcode2++) {	    for (opcode3 = 0; opcode3 < 255; opcode3++) {		for (opcode4 = 0; opcode4 < 255; opcode4++) {		    CVMRunInfo* info = CVMseqInfo->followers[opcode1];		    if (info != 0) {			info = info->followers[opcode2];			if (info != 0) {			    info = info->followers[opcode3];			    if (info != 0) {				if (info->incidence[opcode4] != 0) {				    printf("%d Seq: <%s>,<%s>,<%s>,<%s>\n",					       info->incidence[opcode4],					       CVMopnames[opcode1],					       CVMopnames[opcode2],					       CVMopnames[opcode3],					       CVMopnames[opcode4]);				}			    }			}		    }		}	    }	}    }}voidCVMdumpStats(){    CVMdumpStats2();    CVMdumpStats3();/*      CVMdumpStats4(); */}#define UPDATE_INSTRUCTION_COUNT(opcode)		\{							\    CVMsmallCount++;					\    if (CVMsmallCount % 1000000 == 0) {			\	CVMbigCount++;					\        CVMsmallCount = 0;				\    }							\    CVMupdateStats(opcode);				\}#else#define UPDATE_INSTRUCTION_COUNT(opcode)#endif#ifdef CVM_JVMTI/* NOTE: This macro must be called AFTER the PC has been   incremented. CVMjvmtiNotifyDebuggerOfSingleStep may cause a   breakpoint opcode to get inserted at the current PC to allow the   debugger to coalesce single-step events. Therefore, we need to   refetch the opcode after calling out to JVMTI. */#define JVMTI_SINGLE_STEPPING()					   \{									\    if (ee->jvmtiSingleStepping && CVMjvmtiThreadEventsEnabled(ee)) {	\	DECACHE_PC();						   	\	DECACHE_TOS();						   	\	CVMD_gcSafeExec(ee, {					   	\	    CVMjvmtiPostSingleStepEvent(ee, pc);			\	});								\	/* Refetch opcode. See above. */				\	FETCH_NEXT_OPCODE(0);      					\    }									\}#define JVMTI_WATCHING_FIELD_ACCESS(location)				\    if (CVMglobals.jvmtiWatchingFieldAccess) {				\	DECACHE_PC();							\	DECACHE_TOS();							\	CVMD_gcSafeExec(ee, {						\		CVMjvmtiPostFieldAccessEvent(ee, location, fb);		\	});								\    }#define JVMTI_WATCHING_FIELD_MODIFICATION(location, isDoubleWord, isRef)      \   if (CVMglobals.jvmtiWatchingFieldModification) {			      \       jvalue val;							      \       DECACHE_PC();							      \       DECACHE_TOS();							      \       if (isDoubleWord) {						      \	   CVMassert(CVMfbIsDoubleWord(fb));				      \	   if (CVMtypeidGetType(CVMfbNameAndTypeID(fb)) == CVM_TYPEID_LONG) { \	       val.j = CVMjvm2Long(&STACK_INFO(-2).raw);		      \	   } else /* CVM_TYPEID_DOUBLE */ {				      \	       val.d = CVMjvm2Double(&STACK_INFO(-2).raw);		      \	   }								      \       } else if (isRef) {						      \	   val.l = &STACK_ICELL(-1);					      \       } else {								      \	   val.i = STACK_INT(-1);					      \       }								      \       CVMD_gcSafeExec(ee, {						      \	       CVMjvmtiPostFieldModificationEvent(ee, location, fb, val); \       });								      \   }#else#define JVMTI_SINGLE_STEPPING()#define JVMTI_WATCHING_FIELD_ACCESS(location)#define JVMTI_WATCHING_FIELD_MODIFICATION(location, isDoubleWord, isRef)#endif#ifdef CVM_JVMPI#define JVMPI_CHECK_FOR_DATA_DUMP_REQUEST(ee) \    if (CVMjvmpiDataDumpWasRequested()) {     \        DECACHE_PC();                         \        DECACHE_TOS();                        \        CVMD_gcSafeExec(ee, {                 \            CVMjvmpiPostDataDumpRequest();    \        });                                   \    }#else#define JVMPI_CHECK_FOR_DATA_DUMP_REQUEST(ee)#endif#ifdef CVM_JVMPI_TRACE_INSTRUCTION/* The following macros are for posting the JVMPI_EVENT_INSTRUCTION_START * event for JVMPI support of tracing bytecode execution: */#define JVMPI_TRACE_INSTRUCTION() {                     \    if (CVMjvmpiEventInstructionStartIsEnabled()) {     \        DECACHE_PC();                                   \        DECACHE_TOS();                                  \        CVMjvmpiPostInstructionStartEvent(ee, pc);      \    }                                                   \}#define JVMPI_TRACE_IF(isTrue) {                                \    if (CVMjvmpiEventInstructionStartIsEnabled()) {             \        DECACHE_PC();                                           \        DECACHE_TOS();                                          \        CVMjvmpiPostInstructionStartEvent4If(ee, pc, isTrue);   \    }                                                           \}#define JVMPI_TRACE_TABLESWITCH(key, low, hi) {                      \    if (CVMjvmpiEventInstructionStartIsEnabled()) {                  \        DECACHE_PC();                                                \        DECACHE_TOS();                                               \        CVMjvmpiPostInstructionStartEvent4Tableswitch(ee, pc, key,   \                                                      low, hi);      \    }                                                                \}#define JVMPI_TRACE_LOOKUPSWITCH(chosenPairIndex, pairsTotal) { \    if (CVMjvmpiEventInstructionStartIsEnabled()) {             \        DECACHE_PC();                                           \        DECACHE_TOS();                                          \        CVMjvmpiPostInstructionStartEvent4Lookupswitch(ee, pc,  \                                chosenPairIndex, pairsTotal);   \    }                                                           \}#else /* !CVM_JVMPI_TRACE_INSTRUCTION */#define JVMPI_TRACE_INSTRUCTION()#define JVMPI_TRACE_IF(isTrue)#define JVMPI_TRACE_TABLESWITCH(key, low, hi)#define JVMPI_TRACE_LOOKUPSWITCH(chosenPairIndex, pairsTotal)#endif /* CVM_JVMPI_TRACE_INSTRUCTION *//* * GCC macro for adding an assembler label so the .s file is easier to read. */#undef ASMLABEL#if defined(__GNUC__) && defined(CVM_GENERATE_ASM_LABELS)#define ASMLABEL(name) \    __asm__ __volatile__ ("LL_" #name ":");#else#define ASMLABEL(name)#endif/* * FETCH_NEXT_OPCODE() - macro for fetching to the next opcode or the next * opcode goto label if we are using gcc first class labels. */#undef FETCH_NEXT_OPCODE#if defined(CVM_ALIGNMENT_BASED_DISPATCHING)#define FETCH_NEXT_OPCODE(opsize)		\    nextOpcodeImpl = (void*)(firstOpcodeImplPtr + pc[opsize]);#elif defined(CVM_PREFETCH_OPCODE)#define FETCH_NEXT_OPCODE(opsize) \    opcode = pc[opsize];#else#define FETCH_NEXT_OPCODE(opsize) #endif/* * DISPATCH_OPCODE - macro for dispatching to the next opcode implementation. */#undef DISPATCH_OPCODE#if defined(CVM_ALIGNMENT_BASED_DISPATCHING)#define DISPATCH_OPCODE() goto *nextOpcodeImpl;#elif defined(CVM_USELABELS)#define DISPATCH_OPCODE() goto *opclabels[opcode];#else#define DISPATCH_OPCODE() continue;#endif/* * REEXECUTE_BYTECODE - Macro for reexecuting the opcode. */#undef REEXECUTE_BYTECODE#ifdef CVM_JVMTI#ifdef CVM_ALIGNMENT_BASED_DISPATCHING/* #define REEXECUTE_BYTECODE() goto *nextOpcodeImpl; */#error "Not currently supported"#elif defined(CVM_USELABELS)#define REEXECUTE_BYTECODE() goto *opclabels[opcode];#elif defined(CVM_PREFETCH_OPCODE)#define REEXECUTE_BYTECODE() goto opcode_switch;#else#define REEXECUTE_BYTECODE() goto opcode_switch;#endif#endif /* CVM_JVMTI *//* * CASE - Macro for setting up an opcode case or goto label. * DEFAULT - Macro for setting up the default case or goto label. */#undef CASE#undef DEFAULT#undef CASE_KEYWORD#undef DEFAULT_KEYWORD#ifdef CVM_USELABELS#define CASE_KEYWORD#define DEFAULT_KEYWORD opc_DEFAULT#else#define CASE_KEYWORD    case#define DEFAULT_KEYWORD default#endif#define CASE(opcode_, opsize)			\    CASE_KEYWORD opcode_:		       	\    CVM_ALIGN_OPCODE;				\    ASMLABEL(opcode_);				\    if (opsize != 0) {				\        JVMPI_TRACE_INSTRUCTION();		\        FETCH_NEXT_OPCODE(opsize);		\    }#define DEFAULT					\    DEFAULT_KEYWORD:				\    ASMLABEL(opc_DEFAULT);/* * CONTINUE - Macro for executing the next opcode. */#undef CONTINUE#define CONTINUE {				\        FETCH_NEXT_OPCODE(0);			\	UPDATE_INSTRUCTION_COUNT(*pc);		\        JVMTI_SINGLE_STEPPING();		\        DISPATCH_OPCODE();   			\    }/* * UPDATE_PC_AND_TOS - Macro for updating the pc and topOfStack. */#undef UPDATE_PC_AND_TOS#define UPDATE_PC_AND_TOS(opsize, stack) {	\        pc += opsize;				\        topOfStack += stack;			\	UPDATE_INSTRUCTION_COUNT(*pc);		\        JVMTI_SINGLE_STEPPING();		\    }/* * UPDATE_PC_AND_TOS_AND_CONTINUE - Macro for updating the pc and topOfStack, * and executing the next opcode. It's somewhat similar to the combination * of UPDATE_PC_AND_TOS and CONTINUE, but with some minor optimizations. */#undef UPDATE_PC_AND_TOS_AND_CONTINUE#define UPDATE_PC_AND_TOS_AND_CONTINUE(opsize, stack) {		\	UPDATE_PC_AND_TOS(opsize, stack);			\        DISPATCH_OPCODE();					\    }/* * CHECK_PENDING_REQUESTS - Macro for checking pending requests which need * to be checked periodically in the interpreter loop. */#undef CHECK_PENDING_REQUESTS#ifdef CVM_REMOTE_EXCEPTIONS_SUPPORTED/* %comment h001 */#define CHECK_PENDING_REQUESTS(ee) \	(CVMD_gcSafeCheckRequest(ee) || CVMremoteExceptionOccurred(ee))#else#define CHECK_PENDING_REQUESTS(ee) \	(CVMD_gcSafeCheckRequest(ee))#endif/* * For those opcodes that need to have a GC point on a backwards branch */#undef UPDATE_PC_AND_TOS_AND_CONTINUE_WITH_BACKWARDS_CHECK#define UPDATE_PC_AND_TOS_AND_CONTINUE_WITH_BACKWARDS_CHECK(skip, stack) { \    FETCH_NEXT_OPCODE(skip);						   \    if ((skip) <= 0 && CHECK_PENDING_REQUESTS(ee)) {			   \

⌨️ 快捷键说明

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