jitirdump.c
来自「This is a resource based on j2me embedde」· C语言 代码 · 共 781 行 · 第 1/2 页
C
781 行
/* * @(#)jitirdump.c 1.102 06/10/10 * * Copyright 1990-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is * included at /legal/license.txt). * * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions. * */#ifdef CVM_TRACE_JIT#include "javavm/include/defs.h"#include "javavm/include/objects.h"#include "javavm/include/classes.h"#include "javavm/include/utils.h"#include "javavm/include/bcutils.h"#include "javavm/include/interpreter.h"#include "javavm/include/jit/jit.h"#include "javavm/include/jit/jitir.h"#include "javavm/include/jit/jitcontext.h"#include "javavm/include/jit/jitirnode.h"#include "javavm/include/jit/jitirlist.h"#include "javavm/include/jit/jitirblock.h"#include "javavm/include/porting/doubleword.h"#include "javavm/include/clib.h"static const char *const opcodeTagMap[] = { "CVMJITOP_INVALID", "CONST_JAVA_NUMERIC32", /* CVMJITConstant32 */ "CONST_JAVA_NUMERIC64", /* CVMJITConstant64 */ "CONST_STRING_ICELL", "CONST_STRING_OBJECT", "CONST_METHODTABLE_INDEX",#ifdef CVM_LVM "CONST_FB",#endif "CONST_MC", "CONST_MB", "CONST_CB", "CONST_FIELD_OFFSET", "CONST_STATIC_FIELD_ADDRESS", "CONST_NEW_CB_UNRESOLVED", "CONST_CB_UNRESOLVED", "CONST_ARRAY_CB_UNRESOLVED", "CONST_GETFIELD_FB_UNRESOLVED", "CONST_PUTFIELD_FB_UNRESOLVED", "CONST_GETSTATIC_FB_UNRESOLVED", "CONST_PUTSTATIC_FB_UNRESOLVED", "CONST_STATIC_MB_UNRESOLVED", "CONST_SPECIAL_MB_UNRESOLVED", "CONST_INTERFACE_MB_UNRESOLVED", "CONST_METHOD_TABLE_INDEX_UNRESOLVED", "NULL_PARAMETER", /* CVMJITNull */ "NULL_IARG", "JSR_RETURN_ADDRESS", "EXCEPTION_OBJECT", "RETURN", "LOCAL", /* CVMJITLocal */ "ARRAY_LENGTH", /* CVMJITUnaryOp */ "GET_VTBL", /* invokevirtual */ "GET_OBJECT_VTBL", /* invokevirtualobject */ "GET_ITBL", "FETCH", "NEW_OBJECT", "NULL_CHECK", "NEW_ARRAY_BOOLEAN", "NEW_ARRAY_CHAR", "NEW_ARRAY_FLOAT", "NEW_ARRAY_DOUBLE", "NEW_ARRAY_BYTE", "NEW_ARRAY_SHORT", "NEW_ARRAY_INT", "NEW_ARRAY_LONG", "CONVERT_I2B", "CONVERT_I2C", "CONVERT_I2S", "CONVERT_INTEGER", "CONVERT_LONG", "CONVERT_FLOAT", "CONVERT_DOUBLE", "NEG", "NOT", "INT2BIT", "RET", "RETURN_VALUE", "IDENTITY", "RESOLVE_CLASS", "RESOLVE_REFERENCE", "CLASS_CHECKINIT", "STATIC_FIELD_REF", "MONITOR_ENTER", "MONITOR_EXIT", "THROW", "ASSIGN", /* CVMJITBinaryOp */ "INDEX", "BOUNDS_CHECK", "INVOKE", "INTRINSIC", "CHECKCAST", "INSTANCEOF", "FETCH_MB_FROM_VTABLE",/* IAI - 20 */ "FETCH_VCB", "FETCH_MB_FROM_VTABLE_OUTOFLINE", "MB_TEST_OUTOFLINE",/* IAI - 20 */ "FETCH_MB_FROM_INTERFACETABLE", "PARAMETER", "IARG", "NEW_ARRAY_REF", "MULTIANEW_ARRAY", "FIELD_REF", "SEQUENCE_R", "SEQUENCE_L", "ADD", "SUB", "MUL", "AND", "OR", "XOR", "DIV", "REM", "SHL", "SHR", "USHR", "LCMP", "DCMPL", "DCMPG", "FCMPL", "FCMPG", "GOTO", /* CVMJITBranchOp */ "JSR", "BCOND", /* CVMJITConditionalBranch */ "LOOKUPSWITCH", /* CVMJITLookupSwitch */ "TABLESWITCH", /* CVMJITTableSwitch */ "DEFINE", "USED", "LOAD_PHIS", "RELEASE_PHIS", "MAP_PC", "BEGIN_INLINING", "END_INLINING", "OUTOFLINE_INVOKE"};static const char *const typeTagMap[] = { "(NONE)", "(NODE)", "(v)", "(int)", "(short)", "(char)", "(long)", "(byte)", "(float)", "(double)", "(boolean)", "(reference)", "(32-bit field)", "(64-bit field)", "(address field)",};static const char *const subnodeTagMap[] = { "CONSTANT_NODE", "NULL_NODE", "LOCAL_NODE", "PHI_LIST", "MAP_PC_NODE", "BRANCH_NODE", "PHI0_NODE", "UNARY_NODE", "PHI1_NODE", "LOOKUPSWITCH_NODE", "TABLESWITCH_NODE", "BINARY_NODE", "CONDBRANCH_NODE",};static const char *const conditions[] = { "LT", "LE", "EQ", "GE", "GT", "NE",};static void CVMJITirdumpConstantJavaNumeric32(CVMJavaVal32 j, CVMUint8 typeTag){ switch (typeTag) { case CVM_TYPEID_INT: CVMconsolePrintf(" (%d)", j.i); break; case CVM_TYPEID_FLOAT: CVMconsolePrintf(" (%f)", j.f); break; case CVMJIT_TYPEID_32BITS: CVMconsolePrintf(" (JavaInt:%d JavaFloat:%f)\t", j.i, j.f); break; default: CVMassert(CVM_FALSE); }}static void CVMJITirdumpConstant32(CVMJITCompilationContext* con, CVMJITIRNode* node){ CVMJITConstant32* const32 = CVMJITirnodeGetConstant32(node); switch (CVMJITgetOpcode(node) >> CVMJIT_SHIFT_OPCODE) { case CVMJIT_CONST_JAVA_NUMERIC32: CVMJITirdumpConstantJavaNumeric32(const32->j, CVMJITgetTypeTag(node)); break; case CVMJIT_CONST_METHODTABLE_INDEX: CVMconsolePrintf(" (mtIndex %d)", const32->mtIndex); break; case CVMJIT_CONST_FIELD_OFFSET: CVMconsolePrintf(" (%d)", const32->fieldOffset); break; case CVMJIT_CONST_NEW_CB_UNRESOLVED: case CVMJIT_CONST_CB_UNRESOLVED: case CVMJIT_CONST_ARRAY_CB_UNRESOLVED: case CVMJIT_CONST_GETFIELD_FB_UNRESOLVED: case CVMJIT_CONST_PUTFIELD_FB_UNRESOLVED: case CVMJIT_CONST_GETSTATIC_FB_UNRESOLVED: case CVMJIT_CONST_PUTSTATIC_FB_UNRESOLVED: case CVMJIT_CONST_STATIC_MB_UNRESOLVED: case CVMJIT_CONST_SPECIAL_MB_UNRESOLVED: case CVMJIT_CONST_INTERFACE_MB_UNRESOLVED: case CVMJIT_CONST_METHOD_TABLE_INDEX_UNRESOLVED: CVMconsolePrintf(" (cpIndex %d)", const32->cpIndex); break; default: CVMconsolePrintf("undefined Constant32"); CVMassert(CVM_FALSE); break; } }static void CVMJITirdumpConstantAddr(CVMJITCompilationContext* con, CVMJITIRNode* node){ CVMJITConstantAddr* constAddr = CVMJITirnodeGetConstantAddr(node); switch (CVMJITgetOpcode(node) >> CVMJIT_SHIFT_OPCODE) { case CVMJIT_CONST_STRING_ICELL: CVMconsolePrintf(" (stringICell 0x%x)\n", constAddr->stringICell); break; case CVMJIT_CONST_STRING_OBJECT: CVMconsolePrintf(" (stringObject 0x%x)\n", constAddr->stringObject); break;#ifdef CVM_LVM case CVMJIT_CONST_STATIC_FB: CVMconsolePrintf(" (%F)", constAddr->fb); break;#endif case CVMJIT_CONST_MC: CVMconsolePrintf(" (%C.%M)", CVMmbClassBlock(constAddr->mc->mb), constAddr->mc->mb); break; case CVMJIT_CONST_MB: CVMconsolePrintf(" (%C.%M)", CVMmbClassBlock(constAddr->mb), constAddr->mb); break; case CVMJIT_CONST_CB: CVMconsolePrintf(" (%C)", constAddr->cb); break; case CVMJIT_CONST_STATIC_FIELD_ADDRESS: CVMconsolePrintf(" (0x%x)", constAddr->staticAddress); break; default: CVMconsolePrintf("undefined ConstantAddr"); CVMassert(CVM_FALSE); break; } }static voidCVMJITirdumpConstant64(CVMJITCompilationContext* con, CVMJITIRNode* node){ /* char trBuf[30]; */ if (CVMJITgetTypeTag(node) == CVM_TYPEID_LONG || CVMJITgetTypeTag(node) == CVMJIT_TYPEID_64BITS) { CVMJavaVal64 value; CVMJavaLong highLong; CVMUint32 high, low; CVMmemCopy64(value.v, CVMJITirnodeGetConstant64(node)->j.v); highLong = CVMlongShr(value.l, 32); high = CVMlong2Int(highLong); low = CVMlong2Int(value.l); CVMconsolePrintf(" (long = 0x%08x0x%08x)\n", high, low); /* CVMconsolePrintf(" (long = %s)\n", (CVMlong2String(CVMJITirnodeGetConstant64(node)->j.l, trBuf, trBuf+sizeof(trBuf)), trBuf)); */ } if (CVMJITgetTypeTag(node) == CVM_TYPEID_DOUBLE || CVMJITgetTypeTag(node) == CVMJIT_TYPEID_64BITS) { CVMJavaVal64 value; CVMmemCopy64(value.v, CVMJITirnodeGetConstant64(node)->j.v); CVMconsolePrintf(" (double = %g)\n", value.d); /* CVMconsolePrintf(" (double = %s)\n", (CVMlong2String(CVMJITirnodeGetConstant64(node)->j.d, trBuf, trBuf+sizeof(trBuf)), trBuf)); */ }}static const char *const trapClass[] = { "Null pointer exception", /* CVMJITIR_NULL_POINTER */ "Array index out of bounds", /* CVMJITIR_ARRAY_INDEX_OOB */ "Divide by zero", /* CVMJITIR_DIVIDE_BY_ZERO */};/* Purpose: Prints the specified number of indentations. */void printIndent(const char *format, const char *prefix, int indentCount){ int i; CVMconsolePrintf(format, prefix); for (i = 0; i < indentCount; i++) { CVMconsolePrintf("%s", " "); }}static voidCVMJITirdumpIRNodeInternal(CVMJITCompilationContext* con, CVMJITIRNode* node, int indentCount, const char *prefix, CVMBool alwaysDump);void CVMJITirdumpIRNodeAlways(CVMJITCompilationContext* con, CVMJITIRNode* node, int indentCount, const char *prefix){ CVMJITirdumpIRNodeInternal(con, node, indentCount, prefix, CVM_TRUE);}void CVMJITirdumpIRNode(CVMJITCompilationContext* con, CVMJITIRNode* node, int indentCount, const char *prefix){ CVMJITirdumpIRNodeInternal(con, node, indentCount, prefix, CVM_FALSE);}static voidCVMJITirdumpIRNodeInternal(CVMJITCompilationContext* con, CVMJITIRNode* node, int indentCount, const char *prefix, CVMBool alwaysDump){
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?