jitirdump.c
来自「This is a resource based on j2me embedde」· C语言 代码 · 共 781 行 · 第 1/2 页
C
781 行
CVMJITIRBlock* bk = NULL; CVMJITIRNodeTag nodeTag; /* C stack redzone check */ if (!CVMCstackCheckSize(con->ee, CVM_REDZONE_CVMJITirdumpIRNode, "CVMJITirdumpIRNode", CVM_FALSE)) { return; } /* The following assertions are done here because the arrays being asserted on are defined in this file. The assertions need the size info of the arrays and this size info is only available in this file. */#undef ARRAY_ELEMENTS#define ARRAY_ELEMENTS(x) (sizeof(x)/sizeof(x[0])) /* Make sure we have as many opcodeTagMap strings as there are CVMJITIROpcodeTag: */ CVMassert(ARRAY_ELEMENTS(opcodeTagMap) == CVMJIT_TOTAL_IR_OPCODE_TAGS); /* Make sure we have as many subnodeTagMap strings as there are CVMJITIRNodeTag: */ CVMassert(ARRAY_ELEMENTS(subnodeTagMap) == CVMJIT_TOTAL_IR_NODE_TAGS);#undef ARRAY_ELEMENTS /* Print the prefix and indentation first: */ printIndent("%s", prefix, indentCount); /* Print the header: */ CVMconsolePrintf("<(ID: %d) %s %s ", CVMJITirnodeGetID(node), opcodeTagMap[CVMJITgetOpcode(node) >> CVMJIT_SHIFT_OPCODE], typeTagMap[CVMJITgetTypeTag(node)]); nodeTag = CVMJITgetNodeTag(node) >> CVMJIT_SHIFT_NODETAG; if (nodeTag == CVMJIT_UNARY_NODE) { if (CVMJITirnodeUnaryNodeIs(node, VOLATILE_FIELD)){ CVMconsolePrintf("volatile "); } } else if (nodeTag == CVMJIT_BINARY_NODE) { if (CVMJITirnodeBinaryNodeIs(node, VOLATILE_FIELD)){ CVMconsolePrintf("volatile "); } }#ifdef CVM_JIT_REGISTER_LOCALS switch (node->decorationType) { case CVMJIT_ASSIGN_DECORATION: { CVMconsolePrintf(" (assignIdx: %d)", node->decorationData.assignIdx); break; } default: break; }#endif /* Only dump the refCount if it is not obvious. We're interested in 0 and negative refCounts as well because these could be (though not necessarily) signs of a bug if they occur: */ if (CVMJITirnodeGetRefCount(node) != 1) { CVMconsolePrintf(" (ref count: %d)", CVMJITirnodeGetRefCount(node)); } /* Dump identical nodes once. */ if (!CVMJITirnodeIsDumpNeeded(node) && !CVMJITirnodeIsLocalNode(node) && !alwaysDump) { return; } if (CVMJITirnodeIsConstant32Node(node)) { CVMJITirdumpConstant32(con, node); } else if (CVMJITirnodeIsConstantAddrNode(node)) { CVMJITirdumpConstantAddr(con, node); } else if (CVMJITirnodeIsConstant64Node(node)) { CVMJITirdumpConstant64(con, node); } else if (CVMJITirnodeIsLocalNode(node)) { CVMconsolePrintf(" %d>", CVMJITirnodeGetLocal(node)->localNo); } else if (CVMJITirnodeIsEndInlining(node)) { CVMconsolePrintf(" count:%d>", CVMJITirnodeGetNull(node)->data); } else if (CVMJITirnodeIsNullNode(node)) { } else if (CVMJITirnodeIsMapPcNode(node)) { CVMconsolePrintf(" %d>", node->type_node.mapPcNode.javaPcToMap); } else if (CVMJITirnodeIsBeginInlining(node)) { CVMJITUnaryOp* iNode = CVMJITirnodeGetUnaryOp(node); CVMconsolePrintf("\n"); CVMJITirdumpIRNodeInternal(con, iNode->operand, indentCount+1, prefix, alwaysDump); CVMconsolePrintf("\n"); CVMassert(CVMJITgetOpcode(iNode->operand) == CVMJIT_CONST_MC << CVMJIT_SHIFT_OPCODE); } else if (CVMJITirnodeIsBinaryNode(node)) { CVMJITBinaryOp *typeNode = CVMJITirnodeGetBinaryOp(node); CVMconsolePrintf("\n"); CVMJITirdumpIRNodeInternal(con, typeNode->lhs, indentCount+1, prefix, alwaysDump); CVMconsolePrintf("\n"); CVMJITirdumpIRNodeInternal(con, typeNode->rhs, indentCount+1, prefix, alwaysDump); } else if (CVMJITirnodeIsUnaryNode(node)) { CVMconsolePrintf("\n"); CVMJITirdumpIRNodeInternal(con, CVMJITirnodeGetUnaryOp(node)->operand, indentCount+1, prefix, alwaysDump); } else if (CVMJITirnodeIsBranchNode(node)) { bk = (CVMJITirnodeGetBranchOp(node)->branchLabel); printIndent("\n%s", prefix, indentCount); CVMconsolePrintf("target: (BlockID: %d BlockPC: %d)", CVMJITirblockGetBlockID(bk), CVMJITirblockGetBlockPC(bk)); } else if (CVMJITirnodeIsCondBranchNode(node)) { CVMJITConditionalBranch *typeNode = CVMJITirnodeGetCondBranchOp(node); bk = typeNode->target; printIndent("\n%s", prefix, indentCount); CVMconsolePrintf("target: (BlockID: %d BlockPC: %d)", CVMJITirblockGetBlockID(bk), CVMJITirblockGetBlockPC(bk)); printIndent("\n%s", prefix, indentCount); CVMconsolePrintf("condition: %s", conditions[typeNode->condition]); printIndent("\n%s", prefix, indentCount); CVMconsolePrintf("flags: %d", typeNode->flags); CVMconsolePrintf("\n"); CVMJITirdumpIRNodeInternal(con, typeNode->lhs, indentCount+1, prefix, alwaysDump); CVMconsolePrintf("\n"); CVMJITirdumpIRNodeInternal(con, typeNode->rhs, indentCount+1, prefix, alwaysDump); CVMconsolePrintf("\n"); } else if (CVMJITirnodeIsDefineNode(node)) { CVMJITDefineOp* typeNode = CVMJITirnodeGetDefineOp(node); CVMJITIRNode* defineOperandNode = typeNode->operand; CVMJITIRNode* usedNode = CVMJITirnodeValueOf(typeNode->usedNode); CVMJITUsedOp* usedOp = CVMJITirnodeGetUsedOp(usedNode); CVMassert(defineOperandNode != NULL); printIndent("\n%s", prefix, indentCount); CVMconsolePrintf("spillLocation: %d", usedOp->spillLocation); printIndent("\n%s", prefix, indentCount); CVMconsolePrintf("registerSpillOk: %d", usedOp->registerSpillOk); printIndent("\n%s", prefix, indentCount); CVMconsolePrintf("operand: "); CVMJITirdumpIRNodeInternal(con, defineOperandNode, indentCount+1, prefix, alwaysDump); CVMconsolePrintf("\n"); } else if (CVMJITirnodeIsUsedNode(node)) { CVMJITUsedOp* typeNode = CVMJITirnodeGetUsedOp(node); printIndent("\n%s", prefix, indentCount); CVMconsolePrintf("spillLocation: %d", typeNode->spillLocation); printIndent("\n%s", prefix, indentCount); CVMconsolePrintf("registerSpillOk: %d\n", typeNode->registerSpillOk); } else if (CVMJITnodeTagIs(node, PHI_LIST)) { } else if (CVMJITirnodeIsTableSwitchNode(node)) { int cnt; CVMJITTableSwitch* typeNode = CVMJITirnodeGetTableSwitchOp(node); bk = typeNode->defaultTarget; printIndent("\n%s", prefix, indentCount); CVMconsolePrintf("Key:\n"); CVMJITirdumpIRNodeInternal(con, typeNode->key, indentCount+1, prefix, alwaysDump); printIndent("\n%s", prefix, indentCount); CVMassert(bk != NULL); CVMconsolePrintf("default target: (BlockID: %d BlockPC: %d)", CVMJITirblockGetBlockID(bk), CVMJITirblockGetBlockPC(bk)); printIndent("\n%s", prefix, indentCount); CVMconsolePrintf("\tlow: %d", typeNode->low); printIndent("\n%s", prefix, indentCount); CVMconsolePrintf("\thigh: %d", typeNode->high); printIndent("\n%s", prefix, indentCount); CVMconsolePrintf("\tnElements: %d", typeNode->nElements); printIndent("\n%s", prefix, indentCount); CVMconsolePrintf("\ttableList blocks:"); for (cnt = typeNode->low; cnt <= typeNode->high; cnt++) { bk = typeNode->tableList[cnt-typeNode->low]; printIndent("\n%s", prefix, indentCount+1); CVMconsolePrintf("jump offset %d: (BlockID: %d BlockPC: %d)", cnt, CVMJITirblockGetBlockID(bk), CVMJITirblockGetBlockPC(bk)); } } else if (CVMJITirnodeIsLookupSwitchNode(node)) { int cnt = 0; CVMJITLookupSwitch* typeNode = CVMJITirnodeGetLookupSwitchOp(node); CVMJITSwitchList* sl = typeNode->lookupList; bk = typeNode->defaultTarget; printIndent("\n%s", prefix, indentCount); CVMconsolePrintf("Key:\n"); CVMJITirdumpIRNodeInternal(con, typeNode->key, indentCount+1, prefix, alwaysDump); printIndent("\n%s", prefix, indentCount); CVMassert(bk != NULL); CVMconsolePrintf("default target: (BlockID: %d BlockPC: %d)", CVMJITirblockGetBlockID(bk), CVMJITirblockGetBlockPC(bk)); printIndent("\n%s", prefix, indentCount); CVMconsolePrintf("\tnElements: %d", typeNode->nPairs); printIndent("\n%s", prefix, indentCount); CVMconsolePrintf("\tlookupList blocks:"); for (;cnt < typeNode->nPairs; cnt++) { int match = sl[cnt].matchValue; bk = sl[cnt].dest; printIndent("\n%s", prefix, indentCount+1); CVMconsolePrintf("match %d: (BlockID: %d BlockPC: %d)", match, CVMJITirblockGetBlockID(bk), CVMJITirblockGetBlockPC(bk)); } } else { CVMassert(CVM_FALSE); /* unknown or unexpected node type */ return; } /* Set the dumpTag to CVM_FALSE */ if (!alwaysDump) { CVMJITirnodeSetDumpTag(node, CVM_FALSE); }}voidCVMJITirdumpIRRootList(CVMJITCompilationContext* con, CVMJITIRBlock* bk){ CVMJITIRRoot* rootNode = (CVMJITIRRoot*)CVMJITirlistGetHead(CVMJITirblockGetRootList(bk)); CVMJITIRNode* expr = NULL; while (rootNode != NULL) { expr = CVMJITirnodeGetRootOperand(rootNode); CVMJITirdumpIRNode(con, expr, 0, " "); CVMconsolePrintf("\n\n"); rootNode = CVMJITirnodeGetRootNext(rootNode); }/* end of while loop */}voidCVMJITirdumpIRBlock(CVMJITCompilationContext* con, CVMJITIRBlock* bk){ CVMJITIRList* blockRootList = CVMJITirblockGetRootList(bk); CVMconsolePrintf("\n************************" "*************************\n"); CVMconsolePrintf("*\n"); CVMconsolePrintf("* (block ID:%d block PC:%d )\n", CVMJITirblockGetBlockID(bk), CVMJITirblockGetBlockPC(bk)); CVMconsolePrintf("* IR root list contains %d root nodes: in block \n", CVMJITirlistGetCnt(blockRootList)); CVMconsolePrintf("* flags: 0x%x\n", bk->flags);#ifdef CVM_JIT_REGISTER_LOCALS CVMconsolePrintf("* noMoreIncomingLocals: 0x%x\n", bk->noMoreIncomingLocals); CVMconsolePrintf("* noMoreIncomingRefLocals: 0x%x\n", bk->noMoreIncomingRefLocals); CVMconsolePrintf("* orderedIncomingLocals: 0x%x\n", bk->orderedIncomingLocals);#endif if (!CVMJITirblockIsArtificial(bk)) { CVMJITIRRange *r = bk->firstRange; while (r != NULL) { CVMJITMethodContext* mc = r->mc; CVMJavaMethodDescriptor* jmd = mc->jmd; CVMUint8* code = CVMjmdCode(jmd); char buf[256]; /* Print the source file name and line number info: */ CVMpc2string(code + r->startPC, mc->mb, CVM_FALSE, CVM_FALSE, buf, buf + sizeof(buf)); CVMconsolePrintf("* Source: %s\n", buf); CVMconsolePrintf("* Compilation depth: %d locals : ", mc->compilationDepth); if (mc->firstLocal < mc->currLocalWords) { CVMconsolePrintf("%d .. %d\n", mc->firstLocal, mc->currLocalWords - 1); } else { CVMconsolePrintf("(none)\n"); } /* Disassemble the byte codes for the block: */ CVMconsolePrintf("* Byte-codes for block:\n");#ifdef CVM_DEBUG CVMbcDisassembleRange(mc->mb, code + r->startPC, code + r->endPC);#endif r = r->next; } } else { CVMconsolePrintf("* SPECIAL BLOCK FOR OUT OF LINE INVOKES\n"); } CVMconsolePrintf("LOCALS MERGE INFO AT HEAD OF BLOCK: "); CVMJITlocalrefsDumpRefs(con, &bk->localRefs); CVMconsolePrintf("\n"); CVMconsolePrintf("*************************************************\n"); CVMconsolePrintf("\nNumber and size of USED nodes in phi array: %d %d\n\n", bk->phiCount, bk->phiSize); #ifdef CVM_JIT_REGISTER_LOCALS if (bk->originalIncomingLocalsCount > 0) { int i; CVMconsolePrintf("Original Incoming Locals(%d): \n", bk->originalIncomingLocalsCount); for (i = 0; i < bk->originalIncomingLocalsCount; i++) { if (bk->originalIncomingLocals[i] == NULL) { CVMconsolePrintf("\t<null>\n"); } else { CVMconsolePrintf("\tlocal(%d)\tID(%d)\n ", CVMJITirnodeGetLocal(CVMJITirnodeValueOf( bk->originalIncomingLocals[i]))->localNo, CVMJITirnodeGetID(bk->originalIncomingLocals[i])); } } CVMconsolePrintf("\n"); } if (bk->incomingLocalsCount > 0) { int i; CVMconsolePrintf("Incoming Locals(%d): \n", bk->incomingLocalsCount); for (i = 0; i < bk->incomingLocalsCount; i++) { if (bk->incomingLocals[i] == NULL) { CVMconsolePrintf("\t<null>\n"); } else { CVMconsolePrintf("\tlocal(%d)\tID(%d)\n ", CVMJITirnodeGetLocal(CVMJITirnodeValueOf( bk->incomingLocals[i]))->localNo, CVMJITirnodeGetID(bk->incomingLocals[i])); } } CVMconsolePrintf("\n"); } if (bk->assignNodesCount > 0) { int i; CVMconsolePrintf("Assigned Locals(%d): \n", bk->assignNodesCount); for (i = 0; i < bk->assignNodesCount; i++) { CVMJITIRNode* assignNode = bk->assignNodes[i]; CVMJITIRNode* localNode = CVMJITirnodeGetLeftSubtree(assignNode); CVMUint16 localNo = CVMJITirnodeGetLocal(localNode)->localNo; CVMconsolePrintf("\tASSIGN(%d): local(%d)\tID(%d)\trhsID(%d)\n ", CVMJITirnodeGetID(bk->assignNodes[i]), localNo, CVMJITirnodeGetID(localNode), CVMJITirnodeGetID(CVMJITirnodeGetRightSubtree(assignNode))); } CVMconsolePrintf("\n"); } if (bk->successorBlocksCount > 0) { int i; CVMconsolePrintf("Successor Blocks(%d): \n", bk->successorBlocksCount); for (i = 0; i < bk->successorBlocksCount; i++) { CVMJITIRBlock* successorBk = bk->successorBlocks[i]; int j; CVMconsolePrintf("\tID(%d) LocalOrder(%d) AssignOrder(%d)" " RefsOK(%d) Locals(", CVMJITirblockGetBlockID(successorBk), bk->successorBlocksLocalOrder[i], bk->successorBlocksAssignOrder[i], bk->okToMergeSuccessorBlockRefs[i]); for (j = 0; j < successorBk->incomingLocalsCount; j++) { if (successorBk->incomingLocals[j] == NULL) { CVMconsolePrintf("<null>"); } else { CVMconsolePrintf("%d", CVMJITirnodeGetLocal(CVMJITirnodeValueOf( successorBk->incomingLocals[j]))->localNo); } if (j != successorBk->incomingLocalsCount - 1) { CVMconsolePrintf(" "); } } CVMconsolePrintf(")\n"); } CVMconsolePrintf("\n"); }#endif /* CVM_JIT_REGISTER_LOCALS */ CVMJITirdumpIRRootList(con, bk);}voidCVMJITirdumpIRBlockList(CVMJITCompilationContext* con, CVMJITIRList* bkList){ CVMJITIRBlock* rootbk = (CVMJITIRBlock*)CVMJITirlistGetHead(bkList); CVMJITIRBlock* bk = NULL; CVMconsolePrintf("\n#################################################\n"); CVMconsolePrintf("\nThe maximum node counts per root node are %d\n", con->saveRootCnt); CVMconsolePrintf("IR block list contains %d blocks in method\n", CVMJITirlistGetCnt(bkList)); CVMconsolePrintf("#################################################\n"); for (bk = rootbk; bk != NULL; bk = CVMJITirblockGetNext(bk)) { CVMJITirdumpIRBlock(con, bk); } CVMconsolePrintf("\n");}voidCVMJITirdumpIRListPrint(CVMJITCompilationContext* con, CVMJITIRList* rlst){ CVMJITirdumpIRBlockList(con, rlst); }#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?