📄 jitgrammarrules.jcs
字号:
//// @(#)jitgrammarrules.jcs 1.348 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.////// Copyright 2005 Intel Corporation. All rights reserved.////// 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 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 CLASS_BLOCK%binary ASSIGN // assignment//// the mechanism of Java method invocation.//%binary IINVOKE // return type is 32-bits%binary LINVOKE // return type is 64-bits%binary VINVOKE // return type is void%binary IPARAMETER // 32-bit parameter%binary LPARAMETER // 64-bit parameter%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 ! i.e. (x == 0)?1:0%unary INT2BIT32 // one-word integer !! i.e. (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// NOTE: Some of the following return opcodes are NOT NEEDED because they// can be handle by equivalents. FRETURN and ARETURN are mapped into// IRETURN, and DRETURN is mapped into LRETURN. The mapping is done// by CVMJITgetMassagedIROpcode() (see the case for// CVMJIT_RETURN_VALUE).%unary IRETURN//%unary FRETURN // Mapped into IRETURN by CVMJITgetMassagedIROpcode().//%unary ARETURN // Mapped into IRETURN by CVMJITgetMassagedIROpcode().%unary LRETURN//%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//%leaf 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 : : : : ;//// // The goal for grammatical purposes will be called "root";// The only root rules for now are assignment and control ops.// The universal nonterminal here is reg32, i.e. a single processor register.// Purpose: LOCAL32 = value32.root: ASSIGN LOCAL32 reg32 : 10 : : ASSIGN_INHERITANCE(con, $$) : : { CVMRMResource* rhs = popResource(con); CVMJITIRNode* localNode = CVMJITirnodeGetLeftSubtree($$); CVMJITIRNode* rhsNode = CVMJITirnodeGetRightSubtree($$); CVMJITLocal* lhs = CVMJITirnodeGetLocal(localNode); CVMBool isRef = CVMJITirnodeIsReferenceType($$); int target; if (rhsNode->decorationType == CVMJIT_REGHINT_DECORATION) { target = 1U << rhsNode->decorationData.regHint; } else { target = CVMRM_ANY_SET; } CVMRMpinResource(CVMRM_INT_REGS(con), rhs, target, CVMRM_EMPTY_SET); CVMRMstoreJavaLocal(CVMRM_INT_REGS(con), rhs, 1, isRef, lhs->localNo); CVMRMrelinquishResource(CVMRM_INT_REGS(con), rhs); };// Purpose: LOCAL64 = value32.root: ASSIGN LOCAL64 reg64 : 10 : : ASSIGN_INHERITANCE(con, $$) : : { 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); };%{/* Purpose: Sets a value to a static field of an object. */static void setStaticField(CVMJITCompilationContext *con, CVMJITRMContext* rc, CVMInt32 opcode, CVMBool isVolatile){ /* NOTE: For a non-LVM build, the staticFieldSpec is the staticFieldAddress. For an LVM build, the staticFieldSpec is the fieldblock of the static field. */ /* store over static-field-ref over static field address */ CVMRMResource *src = popResource(con); /* Right Hand Side first. */ CVMRMResource *staticField = popResource(con); /* lhs next.*/ /* %comment l024 */ if (isVolatile) { CVMCPUemitMemBarRelease(con); } CVMRMpinResource(CVMRM_INT_REGS(con), staticField, CVMRM_ANY_SET, CVMRM_EMPTY_SET); CVMRMpinResource(rc, src, rc->anySet, CVMRM_EMPTY_SET); CVMJITcsSetPutStaticFieldInstruction(con); CVMCPUemitMemoryReferenceImmediate(con, opcode, CVMRMgetRegisterNumber(src), CVMRMgetRegisterNumber(staticField), 0); if (isVolatile) { CVMCPUemitMemBar(con); } CVMRMrelinquishResource(CVMRM_INT_REGS(con), staticField); CVMRMrelinquishResource(rc, src);}%}// Purpose: STATIC32(staticFieldSpec) = value32.root: ASSIGN STATIC32 reg32 reg32 : 20 : : : : { CVMBool isVolatile; CVMJITprintCodegenComment(("Do putstatic:")); CVMJITaddCodegenComment((con, "putstatic(staticFieldAddr, value{I|F|O})")); isVolatile = ((CVMJITirnodeGetUnaryNodeFlag(CVMJITirnodeGetLeftSubtree($$)) & CVMJITUNOP_VOLATILE_FIELD) != 0); setStaticField(con, CVMRM_INT_REGS(con), CVMCPU_STR32_OPCODE,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -