jitopcodes.c
来自「This is a resource based on j2me embedde」· C语言 代码 · 共 250 行
C
250 行
/* * @(#)jitopcodes.c 1.22 03/11/14 * * Portions Copyright 2000-2008 Sun Microsystems, Inc. All Rights * Reserved. Use is subject to license terms. * 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. */#include "javavm/include/jit/jit.h"#include "javavm/include/jit/jitir.h"#include "javavm/include/jit/jitirnode.h"/* SVMC_JIT */#include "javavm/include/jit/jitopcodes.h"#include "javavm/include/jit/jitarchemitter.h"intCVMJITgetMassagedIROpcode(CVMJITCompilationContext *con, CVMJITIRNode* ip){ int fulltag = ip->tag; int typetag = CVMJITgetTypeTag(ip); switch (CVMJITgetOpcode(ip) >> CVMJIT_SHIFT_OPCODE) { case CVMJIT_GET_OBJECT_VTBL: /* for our purposes, these are identical */ return GET_VTBL; case CVMJIT_NEW_ARRAY_BOOLEAN: case CVMJIT_NEW_ARRAY_CHAR: case CVMJIT_NEW_ARRAY_FLOAT: case CVMJIT_NEW_ARRAY_DOUBLE: case CVMJIT_NEW_ARRAY_BYTE: case CVMJIT_NEW_ARRAY_SHORT: case CVMJIT_NEW_ARRAY_INT: case CVMJIT_NEW_ARRAY_LONG: /* for our purposes, these are identical */ /* codegen will extract true type after pattern match */ return NEW_ARRAY_BASIC; case CVMJIT_ASSIGN:#ifdef CVM_JIT_REGISTER_LOCALS if (ip->decorationType == CVMJIT_ASSIGN_DECORATION) { CVMRMsetAssignTarget(con, ip); }#endif return ASSIGN; case CVMJIT_INDEX: /* fold all 16-bit operations into the short type */ /* (this may apply for some of the below, too, but we haven't * analyzed yet.) */ switch (typetag){ case CVM_TYPEID_SHORT: case CVM_TYPEID_CHAR: case CVM_TYPEID_BYTE: case CVM_TYPEID_OBJ: return fulltag; /* don't fall through for these one */ } goto doFoldingIntoInt; case CVMJIT_BCOND: return fulltag; case CVMJIT_DEFINE: CVMRMsetDefineTarget(con, ip); case CVMJIT_USED: case CVMJIT_IDENTITY: case CVMJIT_PARAMETER:#ifdef CVM_JIT_USE_FP_HARDWARE switch (typetag){ case CVM_TYPEID_FLOAT: case CVM_TYPEID_DOUBLE: return fulltag; } /* else fall thru */#endif goto doFoldingIntoInt; case CVMJIT_LOCAL:#ifdef CVM_JIT_REGISTER_LOCALS if (ip->decorationType == CVMJIT_LOCAL_DECORATION) { CVMRMsetLocalTarget(con, ip); }#endif case CVMJIT_FETCH: /* SVMC_JIT */#ifndef CVM_JIT_USE_FP_HARDWARE case CVMJIT_INVOKE:#endif case CVMJIT_INTRINSIC: case CVMJIT_RETURN_VALUE: doFoldingIntoInt: /* cases where we fold all 32-bit operations into the int type */ switch (typetag){ case CVM_TYPEID_SHORT: case CVM_TYPEID_CHAR: case CVM_TYPEID_BYTE: case CVM_TYPEID_BOOLEAN: /* * We should never see the above because they are converted by * the IR generator to INT. */ CVMassert(CVM_FALSE); case CVM_TYPEID_INT: case CVM_TYPEID_FLOAT: case CVMJIT_TYPEID_32BITS: fulltag = fulltag & ~CVMJIT_TYPE_MASK; return fulltag | CVM_TYPEID_INT; /* cases where we fold all 64-bit operations into the long type */ case CVM_TYPEID_LONG: case CVM_TYPEID_DOUBLE: case CVMJIT_TYPEID_64BITS: fulltag = fulltag & ~CVMJIT_TYPE_MASK; return fulltag | CVM_TYPEID_LONG; case CVMJIT_TYPEID_ADDRESS: case CVM_TYPEID_OBJ: case CVM_TYPEID_VOID: break; default: CVMassert(CVM_FALSE); } return fulltag; /* SVMC_JIT */#ifdef CVM_JIT_USE_FP_HARDWARE case CVMJIT_INVOKE: switch (typetag){ case CVM_TYPEID_SHORT: case CVM_TYPEID_CHAR: case CVM_TYPEID_BYTE: case CVM_TYPEID_BOOLEAN: /* converted by the IR generator to INT. */ CVMassert(CVM_FALSE); case CVMJIT_TYPEID_32BITS: fulltag = fulltag & ~CVMJIT_TYPE_MASK; return fulltag | CVM_TYPEID_INT; /* cases where we fold all 64-bit operations into the long type */ case CVMJIT_TYPEID_64BITS: fulltag = fulltag & ~CVMJIT_TYPE_MASK; return fulltag | CVM_TYPEID_LONG; case CVM_TYPEID_INT: case CVM_TYPEID_LONG: case CVM_TYPEID_FLOAT: case CVM_TYPEID_DOUBLE: case CVM_TYPEID_VOID: case CVM_TYPEID_OBJ: case CVMJIT_TYPEID_ADDRESS: break; default: CVMassert(CVM_FALSE); } return fulltag;#endif /* CVM_JIT_USE_FP_HARDWARE */ case CVMJIT_IARG: fulltag = fulltag & ~CVMJIT_TYPE_MASK; return fulltag | CVM_TYPEID_VOID; case CVMJIT_SEQUENCE_R: case CVMJIT_SEQUENCE_L:#ifdef CVM_JIT_USE_FP_HARDWARE /* We have rules for these when FP is supported */ if (typetag == CVM_TYPEID_DOUBLE || typetag == CVM_TYPEID_FLOAT) { return fulltag; }#endif#if 0 case CVMJIT_FOR_EFFECT:#endif /* Keep "untyped" SEQUENCE, FOR_EFFECT and END_INLINING as is. */ if (typetag != CVM_TYPEID_NONE) { goto doFoldingIntoInt; } return fulltag; case CVMJIT_STATIC_FIELD_REF: /* We fold volatile 64-bit field refs into special nodes in order to ensure the atomicity of 64-bit accesses: */ if (typetag == CVM_TYPEID_LONG || typetag == CVM_TYPEID_DOUBLE) { if (CVMJITirnodeUnaryNodeIs(ip, VOLATILE_FIELD)) { fulltag = fulltag & ~CVMJIT_TYPE_MASK; return fulltag | CVMJITCG_TYPEID_64BITS_VOLATILE; } } goto doFoldingIntoInt; case CVMJIT_FIELD_REF: /* We fold volatile 64-bit field refs into special nodes in order to ensure the atomicity of 64-bit accesses: */ if (typetag == CVM_TYPEID_LONG || typetag == CVM_TYPEID_DOUBLE) { if (CVMJITirnodeBinaryNodeIs(ip, VOLATILE_FIELD)) { fulltag = fulltag & ~CVMJIT_TYPE_MASK; return fulltag | CVMJITCG_TYPEID_64BITS_VOLATILE; } } /* We do not fold object ref fields because they need special treatment e.g. memory write barriers: */ if (typetag != CVM_TYPEID_OBJ) { goto doFoldingIntoInt; } return fulltag; case CVMJIT_CONST_JAVA_NUMERIC64: CVMassert(typetag == CVM_TYPEID_LONG || typetag == CVM_TYPEID_DOUBLE || typetag == CVMJIT_TYPEID_64BITS); return ICONST_64; case CVMJIT_CONST_METHODTABLE_INDEX: { CVMJITConstant32 *constant32 = CVMJITirnodeGetConstant32(ip); /* Adjust the method index into an offset into the method table: */ constant32->v32 = constant32->v32 * sizeof(CVMMethodBlock *); return ICONST_32; } case CVMJIT_CONST_FIELD_OFFSET: { CVMJITConstant32 *constant32 = CVMJITirnodeGetConstant32(ip); /* Adjust the field offset (which is specified in words) into a byte offset: */ constant32->v32 = constant32->v32 * sizeof(CVMJavaVal32); return ICONST_32; } case CVMJIT_CONST_JAVA_NUMERIC32: CVMassert(typetag == CVM_TYPEID_INT || typetag == CVM_TYPEID_FLOAT || typetag == CVMJIT_TYPEID_32BITS); return ICONST_32; case CVMJIT_CONST_STRING_OBJECT: return CVMJIT_ENCODE_CONST_STRING_OBJECT; case CVMJIT_CONST_STATIC_FIELD_ADDRESS: return CVMJIT_ENCODE_CONST_STATIC_FIELD_ADDRESS; default: return fulltag; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?