📄 jitgrammarrules.jcs
字号:
reg32: FETCH32 STATIC32 reg32 : 20 : : : : { CVMBool isVolatile; CVMJITprintCodegenComment(("Do getstatic:")); CVMJITaddCodegenComment((con, "value{I|F|O} = getstatic(staticFieldAddr);")); isVolatile = ((CVMJITirnodeGetUnaryNodeFlag(CVMJITirnodeGetLeftSubtree($$)) & CVMJITUNOP_VOLATILE_FIELD) != 0); getStaticField(con, CVMRM_INT_REGS(con), $$, GET_REGISTER_GOALS, CVMCPU_LDR32_OPCODE, 1, isVolatile); };// Purpose: value64 = FETCH64(STATIC64(staticFieldSpec))reg64: FETCH64 STATIC64 reg32 : 20 : : : : { CVMJITprintCodegenComment(("Do getstatic:")); CVMJITaddCodegenComment((con, "value{L|D} = getstatic(staticFieldAddr);")); getStaticField(con, CVMRM_INT_REGS(con), $$, GET_REGISTER_GOALS, CVMCPU_LDR64_OPCODE, 2, CVM_FALSE); };// Purpose: value64 = FETCH64(STATIC64VOL(staticFieldSpec))reg64: FETCH64 STATIC64VOL reg32 : 90 : SET_AVOID_C_CALL($$); : SET_TARGET1($$, ARG1); : : { CVMJITprintCodegenComment(("Do volatile getstatic:")); CVMJITaddCodegenComment((con, "call CVMCCMruntimeGetstatic64Volatile")); CVMJITsetSymbolName((con, "CVMCCMruntimeGetstatic64Volatile")); CVMJITstatsRecordInc(con, CVMJIT_STATS_CVMCCMruntimeGetstatic64Volatile); unaryHelper(con, (void*)CVMCCMruntimeGetstatic64Volatile, $$, ARG1, 2); };reg32: EXCEPTION_OBJECT : 0 : : : : { /* It appears in ARG1, so we initially bind it to ARG1. Note that * the front end guarantees that the first thing done is an * ASSIGN of the exception object, so we don't need to worry * about it being trashed before we get here. */ CVMRMResource* dest = CVMRMgetResourceSpecific(CVMRM_INT_REGS(con), CVMCPU_ARG1_REG, 1); CVMRMoccupyAndUnpinResource(CVMRM_INT_REGS(con), dest, $$); pushResource(con, dest); };// Purpose: valueRef = NEW_OBJECT(classBlock)reg32: NEW_OBJECT reg32 : 90 : SET_AVOID_C_CALL($$); : SET_TARGET1($$, ARG2); : : { CVMRMResource* cbRes = popResource(con); CVMRMResource* dest;#ifndef CVMCPU_HAS_POSTINCREMENT_STORE /* Make JSP point just past the last argument currently on the stack */ CVMSMadjustJSP(con);#endif CVMJITprintCodegenComment(("Do new:")); cbRes = CVMRMpinResourceSpecific(CVMRM_INT_REGS(con), cbRes, CVMCPU_ARG2_REG); CVMRMmajorSpill(con, ARG2, CVMRM_SAFE_SET); dest = CVMRMgetResourceSpecific(CVMRM_INT_REGS(con), CVMCPU_RESULT1_REG, 1);#ifdef CVM_TRACE_JIT if (CVMRMisConstant(cbRes)) { CVMJITprintCodegenComment(("cb: %C", cbRes->constant)); }#endif#ifdef IAI_NEW_GLUE_CALLING_CONVENTION_IMPROVEMENT /* Load the class instanceSize and accessFlags into ARG3 and ARG4. * If the class is resolved and linked, then these are known at * compile time and can be treated as constants. Otherwise they * are loaded from the cb. */ if (CVMRMisConstant(cbRes) && CVMcbCheckRuntimeFlag((CVMClassBlock*)(cbRes->constant), LINKED)) { CVMClassBlock* cb = (CVMClassBlock*)(cbRes->constant); /* get class instanceSize into ARG3 */ CVMJITaddCodegenComment((con, "CVMcbInstanceSize(cb)")); CVMCPUemitLoadConstant(con, CVMCPU_ARG3_REG, CVMcbInstanceSize(cb)); /* get class accessFlags into ARG4 */ CVMJITaddCodegenComment((con, "CVMcbAccessFlags(cb)")); CVMCPUemitLoadConstant(con, CVMCPU_ARG4_REG, CVMcbAccessFlags(cb)); } else { /* load class instanceSize from cb into ARG3 */ CVMJITaddCodegenComment((con, "CVMcbInstanceSize(cb)")); CVMCPUemitMemoryReferenceImmediate(con, CVMCPU_LDR16U_OPCODE, CVMCPU_ARG3_REG, CVMCPU_ARG2_REG, offsetof(CVMClassBlock, instanceSizeX)); /* load class accessFlags from cb into ARG4 */ CVMJITaddCodegenComment((con, "CVMcbAccessFlags(cb)")); CVMCPUemitMemoryReferenceImmediate(con, CVMCPU_LDR8_OPCODE, CVMCPU_ARG4_REG, CVMCPU_ARG2_REG, offsetof(CVMClassBlock, accessFlagsX)); }#endif CVMJITaddCodegenComment((con, "call CVMCCMruntimeNewGlue")); CVMJITsetSymbolName((con, "CVMCCMruntimeNewGlue")); CVMJITstatsRecordInc(con, CVMJIT_STATS_CVMCCMruntimeNew); CVMCPUemitAbsoluteCall(con, (void*)CVMCCMruntimeNewGlue, CVMJIT_CPDUMPOK, CVMJIT_NOCPBRANCH); CVMJITcsBeginBlock(con); CVMJITcaptureStackmap(con, 0); /* * Return value is RESULT1 */ CVMRMoccupyAndUnpinResource(CVMRM_INT_REGS(con), dest, $$); CVMRMrelinquishResource(CVMRM_INT_REGS(con), cbRes); pushResource(con, dest); };// Purpose: valueRef = NEW_ARRAY_REF(elementClassBlock, dimension)reg32: NEW_ARRAY_REF reg32 reg32 : 90 : SET_AVOID_C_CALL($$); : SET_TARGET2($$, ARG3, ARG2); : : { CVMRMResource *dest; CVMRMResource *dimension = popResource(con); CVMRMResource *cbRes = popResource(con);#ifndef CVMCPU_HAS_POSTINCREMENT_STORE /* Make JSP point just past the last argument currently on the stack */ CVMSMadjustJSP(con);#endif CVMJITprintCodegenComment(("Do anewarray:")); cbRes = CVMRMpinResourceSpecific(CVMRM_INT_REGS(con), cbRes, CVMCPU_ARG3_REG); dimension = CVMRMpinResourceSpecific(CVMRM_INT_REGS(con), dimension, CVMCPU_ARG2_REG); CVMRMmajorSpill(con, ARG2|ARG3, CVMRM_SAFE_SET); dest = CVMRMgetResourceSpecific(CVMRM_INT_REGS(con), CVMCPU_RESULT1_REG, 1); CVMJITaddCodegenComment((con, "call CVMCCMruntimeANewArrayGlue")); CVMJITsetSymbolName((con, "CVMCCMruntimeANewArrayGlue")); CVMJITstatsRecordInc(con, CVMJIT_STATS_CVMCCMruntimeANewArray); CVMCPUemitAbsoluteCall(con, (void*)CVMCCMruntimeANewArrayGlue, CVMJIT_CPDUMPOK, CVMJIT_NOCPBRANCH); CVMJITcsBeginBlock(con); CVMJITcaptureStackmap(con, 0); /* Return value is in RESULT1 */ CVMRMoccupyAndUnpinResource(CVMRM_INT_REGS(con), dest, $$); CVMRMrelinquishResource(CVMRM_INT_REGS(con), cbRes); CVMRMrelinquishResource(CVMRM_INT_REGS(con), dimension); pushResource(con, dest); };// Purpose: valueRef = MULTI_NEW_ARRAY_REF(basicElementClassBlock, dimensions)reg32: MULTI_NEW_ARRAY_REF reg32 parameters : 90 : SET_AVOID_C_CALL($$); : SET_TARGET2_0($$, ARG3); : : { CVMRMResource* dest; CVMJITIRNode* paramnode; int nDimensions; CVMRMResource *cbRes = popResource(con); CVMRMResource *dimensionsDepth;#ifndef CVMCPU_HAS_POSTINCREMENT_STORE /* Make JSP point just past the last argument currently on the stack */ CVMSMadjustJSP(con);#endif CVMJITprintCodegenComment(("Do multianewarray:")); cbRes = CVMRMpinResourceSpecific(CVMRM_INT_REGS(con), cbRes, CVMCPU_ARG3_REG); CVMRMmajorSpill(con, ARG3, CVMRM_SAFE_SET); dest = CVMRMgetResourceSpecific(CVMRM_INT_REGS(con), CVMCPU_RESULT1_REG, 1); /* * number of dimensions is simply the number of PARAMETER nodes * stacked under this one. */ paramnode = CVMJITirnodeGetRightSubtree($$); nDimensions = CVMJITirnodeGetBinaryOp($$)->data; /* Load the number of dimensions into ARG2: */ CVMJITaddCodegenComment((con, "number of dimensions")); dimensionsDepth = CVMRMgetResourceSpecific(CVMRM_INT_REGS(con), CVMCPU_ARG2_REG, 1); CVMCPUemitLoadConstant(con, CVMCPU_ARG2_REG, nDimensions); /* Address of the first of them is JSP-4*nDimensions: */ CVMJITaddCodegenComment((con, "&dimensions")); /* arg4 = jsp - (dimensionsDepth << 2): */ CVMCPUemitComputeAddressOfArrayElement(con, CVMCPU_SUB_OPCODE, CVMCPU_ARG4_REG, CVMCPU_JSP_REG, CVMRMgetRegisterNumber(dimensionsDepth), CVMCPU_SLL_OPCODE, 2); CVMJITaddCodegenComment((con, "call CVMCCMruntimeMultiANewArrayGlue")); CVMJITsetSymbolName((con, "CVMCCMruntimeMultiANewArrayGlue")); CVMJITstatsRecordInc(con, CVMJIT_STATS_CVMCCMruntimeMultiANewArray); CVMCPUemitAbsoluteCall(con, (void*)CVMCCMruntimeMultiANewArrayGlue, CVMJIT_CPDUMPOK, CVMJIT_NOCPBRANCH); CVMJITcsBeginBlock(con); CVMJITcaptureStackmap(con, 0); /* pop dimensions from operand stack */ CVMJITaddCodegenComment((con, "pop dimensions off the stack")); CVMCPUemitBinaryALUConstant(con, CVMCPU_SUB_OPCODE, CVMCPU_JSP_REG, CVMCPU_JSP_REG, 4*nDimensions, CVMJIT_NOSETCC); /* Tell stackman to pop the dimensions: */ CVMSMpopParameters(con, nDimensions); /* Return value is in RESULT1 */ CVMRMoccupyAndUnpinResource(CVMRM_INT_REGS(con), dest, $$); CVMRMrelinquishResource(CVMRM_INT_REGS(con), cbRes); CVMRMrelinquishResource(CVMRM_INT_REGS(con), dimensionsDepth); pushResource(con, dest); };// Purpose: valueRef = NEW_ARRAY_BASIC(dimension)reg32: NEW_ARRAY_BASIC reg32 : 90 : SET_AVOID_C_CALL($$); : SET_TARGET1($$, ARG2); : : { CVMRMResource* dest; CVMRMResource* dimension = popResource(con); CVMBasicType typeCode; CVMClassBlock* arrCB; CVMUint32 elementSize; #ifndef CVMCPU_HAS_POSTINCREMENT_STORE /* Make JSP point just past the last argument currently on the stack */ CVMSMadjustJSP(con);#endif /* Map the IR node opcode to the type code: */ typeCode = (CVMJITgetOpcode($$) >> CVMJIT_SHIFT_OPCODE) - CVMJIT_NEW_ARRAY_BOOLEAN + CVM_T_BOOLEAN; /* This is known at compile time for arrays of basic types */ arrCB = (CVMClassBlock*)CVMbasicTypeArrayClassblocks[typeCode]; elementSize = CVMbasicTypeSizes[typeCode]; CVMJITprintCodegenComment(("Do newarray:")); dimension = CVMRMpinResourceSpecific(CVMRM_INT_REGS(con), dimension, CVMCPU_ARG2_REG); CVMRMmajorSpill(con, ARG2, CVMRM_SAFE_SET); dest = CVMRMgetResourceSpecific(CVMRM_INT_REGS(con), CVMCPU_RESULT1_REG, 1); CVMJITaddCodegenComment((con, "%C", arrCB)); CVMJITsetSymbolName((con, "cb %C", arrCB)); CVMCPUemitLoadConstant(con, CVMCPU_ARG3_REG, (int)arrCB); CVMJITaddCodegenComment((con, "array element size")); CVMCPUemitLoadConstant(con, CVMCPU_ARG1_REG, elementSize); CVMJITaddCodegenComment((con, "call CVMCCMruntimeNewArrayGlue")); CVMJITsetSymbolName((con, "CVMCCMruntimeNewArrayGlue")); CVMJITstatsRecordInc(con, CVMJIT_STATS_CVMCCMruntimeNewArray); CVMCPUemitAbsoluteCall(con, (void*)CVMCCMruntimeNewArrayGlue, CVMJIT_CPDUMPOK, CVMJIT_NOCPBRANCH); CVMJITcsBeginBlock(con); CVMJITcaptureStackmap(con, 0); /* Return value is in RESULT1 */ CVMRMoccupyAndUnpinResource(CVMRM_INT_REGS(con), dest, $$); CVMRMrelinquishResource(CVMRM_INT_REGS(con), dimension); pushResource(con, dest); };%{/* Purpose: Converts a constant into reg32 value. */static voidconst2Reg32(CVMJITCompilationContext *con, CVMJITRMContext *rc, CVMJITIRNodePtr thisNode, int target, int avoid){ CVMInt32 constant; CVMRMResource *dest; if (CVMJITirnodeIsConstant32Node(thisNode)) { constant = CVMJITirnodeGetConstant32(thisNode)->j.i; } else { constant = CVMJITirnodeGetConstantAddr(thisNode)->vAddr; } dest = CVMRMbindResourceForConstant32(rc, constant); /* only pin eagerly if constant cannot be treated as an immediate */ if (!CVMCPUalurhsIsEncodableAsImmediate(CVMCPU_ADD_OPCODE, constant) && !CVMCPUalurhsIsEncodableAsImmediate(CVMCPU_SUB_OPCODE, constant)) { CVMRMpinResourceEagerlyIfDesireable(rc, dest, target, avoid); } /* Need this in case this constant is a CSE */ CVMRMoccupyAndUnpinResource(rc, dest, thisNode); pushResource(con, dest);}%}reg32: ICONST_32 : 20 : : : : const2Reg32(con, CVMRM_INT_REGS(con), $$, GET_REGISTER_GOALS);reg32: STRING_ICELL_CONST : 20 : : : : { CVMRMResource* stringICellResource; CVMUint32 stringICellReg; CVMRMResource* stringObjectResource = CVMRMgetResource(CVMRM_INT_REGS(con), GET_REGISTER_GOALS, 1); CVMUint32 stringObjectReg = CVMRMgetRegisterNumber(stringObjectResource); CVMStringICell* stringICell = CVMJITirnodeGetConstantAddr($$)->stringICell; CVMJITsetSymbolName((con, "StringICell")); stringICellResource = CVMRMgetResourceForConstant32(CVMRM_INT_REGS(con), CVMRM_ANY_SET, CVMRM_EMPTY_SET, (CVMUint32)stringICell); stringICellReg = CVMRMgetRegisterNumber(stringICellResource); CVMJITaddCodegenComment((con, "StringObject from StringICell")); CVMCPUemitMemoryReferenceImmediate(con, CVMCPU_LDR32_OPCODE, stringObjectReg, stringICellReg, 0); CVMRMoccupyAndUnpinResource(CVMRM_INT_REGS(con), stringObjectResource, $$); pushResource(con, stringObjectResource); CVMRMrelinquishResource(CVMRM_INT_REGS(con), stringICellResource); };reg32: CLASS_BLOCK : 20 : : : : { CVMRMResource *dest; CVMClassBlock *cb = CVMJITirnodeGetConstantAddr($$)->cb; CVMJITsetSymbolName((con, "cb %C", cb)); dest = CVMRMbindResourceForConstant32(CVMRM_INT_REGS(con), (CVMInt32)cb); CVMRMpinResourceEagerlyIfDesireable(CVMRM_INT_REGS(con), dest, GET_REGISTER_GOALS); /* Need this in case this constant is a CSE */ CVMRMoccupyAndUnpinResource(CVMRM_INT_REGS(con), dest, $$); pushResource(con, dest); };%{#define IDENT_SYNTHESIS(con, thisNode) \{ \ if (!CVMJIT_JCS_DID_PHASE(IRGetState(thisNode), \ CVMJIT_JCS_STATE_SYNTHED)) \ { \ /* same as DEFAULT_SYNTHESIS_CHAIN */ \ DEFAULT_SYNTHESIS1(con, thisNode); \ } else { \ /* Leaf node */ \ } \}#define IDENT_INHERITANCE(con, thisNode) \{ \ CVMassert(!CVMJIT_DID_SEMANTIC_ACTION(thisNode)); \ DEFAULT_INHERITANCE_CHAIN(con, thisNode); \}%}%dag reg32: IDENT32 reg32 : 0 : IDENT_SYNTHESIS(con, $$); : IDENT_INHERITANCE(con, $$); : : { CVMRMResource* src; if (!CVMJIT_DID_SEMANTIC_ACTION($$)){ src = popResource(con); CVMRMoccupyAndUnpinResource(CVMRM_INT_REGS(con), src, $$); /* CVMconsolePrintf("Initial evaluation of "); */ } else { src = CVMRMfindResource(CVMRM_INT_REGS(con), $$); /* CVMconsolePrintf("Reiteration of "); */ CVMassert(src != NULL); } /* CVMconsolePrintf("Fixed IDENT32 ID %d, resource 0x%x\n", $$->nodeID, src); */ pushResource(con, src); };// This handles IDENT32 over a BOUNDS_CHECK with a constant index%dag iconst32Index: IDENT32 iconst32Index : 0 : IDENT_SYNTHESIS(con, $$); : IDENT_INHERITANCE(con, $$); : : { CVMInt32 idx; if (!CVMJIT_DID_SEMANTIC_ACTION($$)){ idx = popIConst32(con); CVMJITirnodeGetIdentOp($$)->backendData = idx; } else { idx = CVMJITirnodeGetIdentOp($$)->backendData;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -