jitgrammarrules.jcs
来自「This is a resource based on j2me embedde」· JCS 代码 · 共 1,919 行 · 第 1/5 页
JCS
1,919 行
////// @(#)jitgrammarrules.jcs 1.14 06/10/13//// 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.////// converting CVM IR subset to RISC assembler//%name CVMJITCompileExpression%type CVMJITIRNodePtr%goal root%opcode CVMJITgetMassagedIROpcode%left CVMJITirnodeGetLeftSubtree%right CVMJITirnodeGetRightSubtree%setstate IRRecordState%getstate IRGetState%leaf LOCAL32 // Java 1-word local%leaf LOCAL64 // Java 2-word local%unary STATIC32 // Java 1-word static%unary STATIC64 // Java 2-word static%unary STATIC64VOL // Java 2-word volatile static//// this represents the first evaluation of a 1-word CSE%unary IDENT32// this represents the first evaluation of a 2-word CSE%unary IDENT64//// the one word pointer that appears (in ARG1) on entry to a catch.%leaf EXCEPTION_OBJECT//// make a new object. Has a class block beneath it.%unary NEW_OBJECT// make an array of obj. Has class block of element type, and a dimension.%binary NEW_ARRAY_REF%binary MULTI_NEW_ARRAY_REF// make an array of a basic type. Has only a dimension.%unary NEW_ARRAY_BASIC// This just forces evaluation of an expression.// It is discarded.//%unary FOR_EFFECT// This just forces evaluation of an expression.// It is used as a CSE, and// forces ordering of expression evaluation in funky cases.//%unary FOR_TEMP//// this roots an expression which is the// definition of a value live across a branch.//%unary DEFINE_VALUE32%unary DEFINE_VALUE64// for loading all DEFINE values that need to be in registers%leaf LOAD_PHIS// for releasing the registers used by phi values%leaf RELEASE_PHIS// the values as they appear when used in an expression.%leaf USED32%leaf USED64//// we distinguish among a couple of constants.// This actually requires some target-dependent re-writing of// the IROpcode the first time we encounter the target// independent integer-constant nodes. This is done by// CVMJITgetMassagedIROpcode.// These are mutually exclusive, since we have to classify a constant// without context. Thus the classes for intersections. Also, of course,// all mode 3 constants are mode 2 constants, (and we may wish to constrain// mode 3 to be unsigned 8 bit values, in which case they'd also all be// mode 1's)%leaf ICONST_32 // all the others.%leaf ICONST_64 // big numbers.%leaf STRING_ICELL_CONST // StringICell pointer from cp.%leaf METHOD_BLOCK // from context, either a mb or something like it.%leaf METHOD_CONTEXT%leaf CLASS_BLOCK%binary ASSIGN // assignment//// the mechanism of Java method invocation.//%binary INVOKE32I // return type is integer (32-bits)%binary INVOKE64I // return type is integer (64-bits)%binary VINVOKE // return type is void%binary PARAMETER32%binary PARAMETER64%leaf NULL_PARAMETER%unary GET_VTBL%unary GET_ITBL%binary FETCH_MB_FROM_VTABLE%binary FETCH_MB_FROM_ITABLE// #ifdef IAI_VIRTUAL_INLINE_CB_TEST%unary FETCH_VCB%binary FETCH_MB_FROM_VTABLE_OUTOFLINE%binary MB_TEST_OUTOFLINE// #endif//// memory accesses//%unary FETCH32 // memory fetch from STATIC or INDEX or FIELDREF%unary FETCH64%binary INDEX // an array index operation%unary ALENGTH // array length, of type integer%unary NULLCHECK // null checked object%binary FIELDREFOBJ // object ref field of object%binary FIELDREF32 // one-word field of object%binary FIELDREF64 // two-word field of object%binary FIELDREF64VOL // two-word volatile field of object%binary ISEQUENCE_R%binary LSEQUENCE_R%binary VSEQUENCE_R%binary ISEQUENCE_L%binary LSEQUENCE_L%binary VSEQUENCE_L//// operations on word-sized values//%unary INEG32 // one-word integer unary -%unary NOT32 // one-word integer (x == 0)?1:0%unary INT2BIT32 // one-word integer (x != 0)?1:0%binary IADD32 // one-word integer +%binary ISUB32 // one-word integer binary -%binary IMUL32 // one-word integer *%binary IDIV32 // one-word integer /%binary IREM32 // one-word integer %%binary AND32 // one-word bitwise AND%binary OR32 // one-word bitwise OR%binary XOR32 // one-word bitwise XOR%binary SLL32 // one-word <<%binary SRL32 // one-word >>>%binary SRA32 // one-word >>//// operations on long integer//%unary INEG64 // integer unary -%binary IADD64 // integer +%binary ISUB64 // integer binary -%binary IMUL64 // integer *%binary IDIV64 // integer /%binary IREM64 // integer %%binary AND64 // bitwise AND%binary OR64 // bitwise OR%binary XOR64 // bitwise XOR%binary SLL64 // <<%binary SRL64 // >>>%binary SRA64 // >>%binary LCMP//// operations on floats//%unary FNEG // one-word float unary -%binary FADD // one-word float +%binary FSUB // one-word float binary -%binary FMUL // one-word float *%binary FDIV // one-word float /%binary FREM // one-word float %%binary FCMPL%binary FCMPG//// operations on doubles//%unary DNEG // two-word double unary -%binary DADD // two-word double +%binary DSUB // two-word double binary -%binary DMUL // two-word double *%binary DDIV // two-word double /%binary DREM // two-word double %%binary DCMPL%binary DCMPG//// some conversions%unary I2B%unary I2C%unary I2S%unary I2L%unary I2F%unary I2D%unary L2I%unary L2F%unary L2D%unary F2D%unary F2I%unary F2L%unary D2F%unary D2I%unary D2L//// control operations//%unary TABLESWITCH%unary LOOKUPSWITCH%binary BCOND_INT // conditional branch%binary BCOND_LONG // conditional branch%binary BCOND_FLOAT // conditional branch%binary BCOND_DOUBLE // conditional branch%binary BOUNDS_CHECK // array index out of bounds check%leaf GOTO%leaf RETURN%leaf JSR // a lot like goto, but is returned to%leaf JSR_RETURN_ADDRESS // binds lr to the incomming jsr return address%unary RET// Some of the following return opcodes are NOT NEEDED because they// can be handle by equivalents. The mapping is done by// CVMJITgetMassagedIROpcode() (see the case for CVMJIT_RETURN_VALUE).%unary IRETURN%unary LRETURN//%unary FRETURN // Mapped into IRETURN by CVMJITgetMassagedIROpcode().//%unary DRETURN // Mapped into LRETURN by CVMJITgetMassagedIROpcode().%unary ATHROW%binary CHECKCAST%binary INSTANCEOF//// synchronization//%unary MONITOR_ENTER%unary MONITOR_EXIT//// lazy resolution & checkinit//%leaf RESOLVE_REF%binary CHECKINIT//// mapping java pc's to compiled pc's//%leaf MAP_PC//// Inlining info//%unary BEGININLINING%leaf VENDINLINING%leaf OUTOFLINEINVOKE// Intrinsic nodes%binary VINTRINSIC%binary INTRINSIC32%binary INTRINSIC64%binary IARG%leaf NULL_IARG//// A root can be an embeddable effect//root: effect : 0 : : : : ;// Purpose: LOCAL64 = value64.//// CVM_64 : this rule might be overridden by a machine specific one//root: ASSIGN LOCAL64 reg64 : 20 : : : : { CVMRMResource * rhs = popResource(con); CVMJITLocal * lhs = CVMJITirnodeGetLocal( CVMJITirnodeGetLeftSubtree($$)); CVMRMpinResource(CVMRM_INT_REGS(con), rhs, CVMRM_ANY_SET, CVMRM_EMPTY_SET); CVMRMstoreJavaLocal(CVMRM_INT_REGS(con), rhs, 2, CVM_FALSE, lhs->localNo); CVMRMrelinquishResource(CVMRM_INT_REGS(con), rhs); };%{static voidbinaryHelper( CVMJITCompilationContext *con, void* helperAddress, CVMJITIRNodePtr thisNode, CVMBool checkZero, int argSize, /* total size in words of all arguments */ int resultSize);/* * Inlining start */static voidbeginInlining(CVMJITCompilationContext* con, CVMJITIRNodePtr thisNode){ CVMJITUnaryOp* unop = CVMJITirnodeGetUnaryOp(thisNode); CVMJITConstantAddr* constAddr; CVMJITMethodContext* mc; CVMUint16 pcStart = CVMJITcbufGetLogicalPC(con); CVMJITInliningInfoStackEntry* newEntry; /* SVMC_JIT rr 2004-02-24: (CHECK_INIT cb value) -> (SEQUENCE (FOR_EFFECT (CHECK_INIT cb)) value) * see doCheckInitOnCB() for details * * SVMC_JIT sw 2004-02-27: changed assertion because IR optimization * can change the expression to eliminate the check: * (SEQUENCE (FOR_EFFECT (CONST_JAVA_NUMERIC_32) value)) */ /* FIXME. Not compilable. */ /*CVMassert(CVMJITirnodeIsConstMC(unop->operand) || (CVMJITirnodeIsSequenceR(unop->operand) && CVMJITirnodeIsForEffect( CVMJITirnodeGetLeftSubtree(unop->operand)) && (CVMJITirnodeIsConstant32Node( CVMJITirnodeGetLeftSubtree( CVMJITirnodeGetLeftSubtree(unop->operand))) || CVMJITirnodeIsClassCheckInit( CVMJITirnodeGetLeftSubtree( CVMJITirnodeGetLeftSubtree(unop->operand))))));*/ if (CVMJITirnodeIsConstMC(unop->operand)) { constAddr = CVMJITirnodeGetConstantAddr(unop->operand); } else { constAddr = CVMJITirnodeGetConstantAddr(CVMJITirnodeGetRightSubtree(unop->operand)); } mc = constAddr->mc; /* Start a new inlining entry */ CVMassert(con->inliningDepth < con->maxInliningDepth); newEntry = &con->inliningStack[con->inliningDepth++]; /* Record the starting point and mc of this inlining record */ /* The end point will be recorded by the corresponding END_INLINING node */ newEntry->pcOffset1 = pcStart; newEntry->mc = mc; CVMJITprintCodegenComment(("Begin inlining of %C.%M (start pc=%d):", CVMmbClassBlock(mc->mb), mc->mb, pcStart));}/* * We have finished inlined code. Record this PC. */static voidendInlining(CVMJITCompilationContext* con, CVMJITIRNodePtr thisNode){
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?