jitirnode.h
来自「This is a resource based on j2me embedde」· C头文件 代码 · 共 1,518 行 · 第 1/4 页
H
1,518 行
CVMStringICell* stringICell; /* CVMJIT_CONST_STRING_ICELL */ CVMStringObject* stringObject; /* CVMJIT_CONST_STRING_OBJECT */#ifdef CVM_LVM CVMFieldBlock* fb; /* CVMJIT_CONST_STATIC_FB */#endif CVMJITMethodContext* mc; /* CVMJIT_CONST_MC */ CVMMethodBlock* mb; /* CVMJIT_CONST_MB */ CVMClassBlock* cb; /* CVMJIT_CONST_CB */ CVMJavaVal32* staticAddress;/* CVMJIT_CONST_STATIC_FIELD_ADDRESS */} CVMJITConstantAddr;/* CVMJIT_CONST_JAVA_NUMERIC64 */typedef struct { struct { CVMAddr v[2]; } j;} CVMJITConstant64;typedef struct { CVMUint16 localNo;} CVMJITLocal;/* NOTE: operand must be the first field in CVMJITUnaryOp to coincide with firstOperand in CVMJITGenericSubNode. */typedef struct { CVMJITIRNode* operand; CVMUint8 flags; /* CVMJITUNOP_CLASSINIT_LVM|CVMJITUNOP_CLASSINIT| CVMJITUNOP_ALLOCATION|CVMJITUNOP_ARITHMETIC */} CVMJITUnaryOp;#ifdef CVM_DEBUG_ASSERTStypedef enum { CVMJIT_IDENTITY_DECORATION_RESOURCE = 0x1, CVMJIT_IDENTITY_DECORATION_SCALEDINDEX} CVMJITIdentityDecorationType;#define CVMJITidentityDecorationIs(con, expr, flag) \ ((CVMJITidentityGetDecoration(con, expr)->decorationTag & \ CVMJIT_IDENTITY_DECORATION_ ## flag) != 0)#endiftypedef struct {#ifdef CVM_DEBUG_ASSERTS CVMJITIdentityDecorationType decorationTag;#endif CVMInt32 refCount;} CVMJITIdentityDecoration;/* * First part MUST BE UnaryOp. */typedef struct { CVMJITUnaryOp uOp; CVMJITIdentityDecoration* identDec; CVMInt32 backendData;} CVMJITIdentOp;#define CVMJITidentDecoration(p) (p)->type_node.identOp.identDec#ifdef CVM_DEBUG_ASSERTS#define CVMJITidentityInitDecoration(con, dec, decType) \ { \ (dec)->decorationTag = (decType); \ (dec)->refCount = 1; \ }#else#define CVMJITidentityInitDecoration(con, dec, decType) \ { \ (dec)->refCount = 1; \ }#endif#define CVMJITidentitySetDecorationRefCount(con, dec, refc) \ { \ (dec)->refCount = (refc); \ }#define CVMJITidentityIncrementDecorationRefCount(con, dec) \ { \ (dec)->refCount++; \ }#define CVMJITidentityDecrementDecorationRefCount(con, dec) \ { \ (dec)->refCount--; \ }#define CVMJITidentityGetDecorationRefCount(con, dec) \ ((dec)->refCount) \/* * Decorate the current IDENTITY node with an IdentityDecoration */extern voidCVMJITidentitySetDecoration( CVMJITCompilationContext* con, CVMJITIdentityDecoration* dec, CVMJITIRNode* expr);/* * Get decoration of the current IDENTITY node */extern CVMJITIdentityDecoration*CVMJITidentityGetDecoration( CVMJITCompilationContext* con, CVMJITIRNode* expr);/* NOTE: lhs must be the first field in CVMJITBinaryOp to coincide with firstOperand in CVMJITGenericSubNode. */typedef struct { CVMJITIRNode* lhs; CVMJITIRNode* rhs; CVMUint16 data; /* e.g. true argsize of invoke node */ CVMUint8 data2; /* more node specific data. */ CVMUint8 flags; /* CVMJITCMPOP_UNORDERED_LT| CVMJITBINOP_ALLOCATION */} CVMJITBinaryOp;typedef struct { CVMJITIRBlock* branchLabel;} CVMJITBranchOp;/* NOTE: lhs and rhs must be the first two field in CVMJITConditionalBranch to coincide with the first two fields of in CVMJITBinaryOp. */typedef struct { CVMJITIRNode* lhs; CVMJITIRNode* rhs; CVMJITCondition condition; CVMJITIRBlock* target; CVMUint8 flags; /* CVMJITCMPOP_UNORDERED_LT */} CVMJITConditionalBranch;typedef enum { CVMJITIR_NULL_POINTER, CVMJITIR_ARRAY_INDEX_OOB, CVMJITIR_DIVIDE_BY_ZERO, CVMJITIR_NUM_TRAP_IDS} CVMJITIRTrapID;typedef struct { /* Nothing */ CVMUint16 data;} CVMJITNull;/* * Switch List */typedef struct { CVMInt32 matchValue; CVMJITIRBlock* dest;} CVMJITSwitchList;/* * lookswitch *//* NOTE: key must be the first field in CVMJITLookupSwitch to coincide with firstOperand in CVMJITGenericSubNode. */typedef struct { CVMJITIRNode* key; CVMJITIRBlock* defaultTarget; CVMUint32 nPairs; /* number of elements in array following */ CVMJITSwitchList lookupList[1];} CVMJITLookupSwitch;/* * tableswitch *//* NOTE: key must be the first field in CVMJITTableSwitch to coincide with firstOperand in CVMJITGenericSubNode. */typedef struct { CVMJITIRNode* key; CVMJITIRBlock* defaultTarget; CVMInt32 low; CVMInt32 high; CVMUint32 nElements; /* may be redundant as high-low+1 should be same.*/ CVMJITIRBlock* tableList[1]; } CVMJITTableSwitch;typedef struct { CVMInt16 spillLocation; /* location this value spills to */ CVMUint8 registerSpillOk; /* true if ok to spill to a register */ CVMRMResource* resource; /* RM resource into which it is stored */} CVMJITUsedOp;/* NOTE: operand must be the first field in CVMJITDefineOp to coincide with firstOperand in CVMJITGenericSubNode. */typedef struct { CVMJITIRNode* operand; /* stack item this define node represents */ CVMJITIRNode* usedNode; /* USED node for this define node */ CVMRMResource* resource; /* RM resource into which it is stored */} CVMJITDefineOp;typedef struct { CVMJITIRBlock* targetBlock; CVMJITIRNode** defineNodeList; /* list of define nodes. */} CVMJITPhisListOp;typedef struct { CVMJITIRNode* firstOperand; CVMJITMethodContext* mc; /* method context. */} CVMJITMethodContextOp;/* * A generic sub node type that we can cast and fetch the lhs node. */typedef struct { CVMJITIRNode* firstOperand;} CVMJITGenericSubNode;typedef union { CVMJITGenericSubNode genericSubNode; CVMJITConstant32 constant32; CVMJITConstantAddr constantAddr; CVMJITConstant64 constant64; CVMJITNull nullOp; CVMJITLocal local; CVMJITUnaryOp unOp; CVMJITIdentOp identOp; CVMJITBinaryOp binOp; CVMJITBranchOp branchOp; CVMJITConditionalBranch condBranchOp; CVMJITLookupSwitch lswitchOp; CVMJITTableSwitch tswitchOp; CVMJITUsedOp usedOp; CVMJITDefineOp defineOp; CVMJITPhisListOp phisListOp; CVMJITMapPcNode mapPcNode;} CVMJITIRSubclassNode;typedef enum { CVMJIT_NO_DECORATION, CVMJIT_REGHINT_DECORATION,#ifdef CVM_JIT_REGISTER_LOCALS CVMJIT_ASSIGN_DECORATION, CVMJIT_LOCAL_DECORATION,#endif CVMJIT_PARAMETER_DECORATION#ifdef CVM_DEBUG} CVMJITIRNodeDecorationType;#else} CVMJITIRNodeDecorationTypeValues;typedef CVMUint8 CVMJITIRNodeDecorationType;#endif/* * Tag Encoding * * IR Node tags contain up to three pieces of information: * 1) the IR Node subclass of this node: CVMJITIRNodeTag * 2) the IR Node opcode of this node: CVMJITIROpcodeTag * 3) the type associated with this node: CVMJITIRTypeTag * * Encoding of the 16-bit tag field is as follows * * a) 8 high-order bits: opcode * b) 4 next bits: subclass * c) 4 next bits: type -- use the encoding from typeid.h rather * than from basictypes.h -- it fits into 4 bits better. * * In addition to providing enough information, this * also gives us a means of type-safe extraction of subclass data. */struct CVMJITIRNode {#if defined(CVM_DEBUG) || defined(CVM_TRACE_JIT) CVMUint32 nodeID; /* for IRdump purpose */ CVMBool dumpTag; /* Each IR node is dumped only once. */#endif CVMUint16 tag; /* encodes node type, opcode, and typeid */ CVMUint16 refCount; CVMUint16 curRootCnt; /* number of nodes built in current node */ /* also used by code gen for state tag */ CVMUint16 flags; /* See CVMJITIRNodeFlags enum list below. */ CVMJITRegsRequiredType regsRequired:8; /* codegen synthesized attribute */ /* * Nodes can be decorated with some extra information so the backend can * do a better job of register allocation. For example, we like to pass * phi values in registers, but often the phi value is evaluated into * the wrong register before the backend sees its DEFINE node. The * solution is to have the creation of the DEFINE node store the stackIdx * in the value node so the backend knows which register to put it in. */ CVMJITIRNodeDecorationType decorationType:8; union { /* regHint for expr, reg to be used as phi or outgoing local */ CVMInt16 regHint; CVMUint16 argNo; /* argument # for outgoing parameter values */#ifdef CVM_JIT_REGISTER_LOCALS /* index into block's assignNodes[]. Used to get localNo that expression will be assigned to for better register targeting. */ CVMUint16 assignIdx; /* index into block's successorBlocks[]. Used for outgoing locals * so they are loaded into proper registers. */ CVMUint16 successorBlocksIdx;#endif } decorationData ; /* This field MUST BE LAST */ CVMJITIRSubclassNode type_node;};/* The values in this enum list is used to set bits in the flags field of the CVMJITIRNode: */enum CVMJITIRNodeFlags { CVMJITIRNODE_NULL_FLAGS = 0, CVMJITIRNODE_HAS_BEEN_EVALUATED = (1 << 0), /* bit 0 */ CVMJITIRNODE_IS_INITIAL_LOCAL = (1 << 1), /* bit 1 */ CVMJITIRNODE_HAS_UNDEFINED_SIDE_EFFECT = (1 << 2), /* bit 2 */ CVMJITIRNODE_THROWS_EXCEPTIONS = (1 << 3), /* bit 3 */ CVMJITIRNODE_PARENT_THROWS_EXCEPTIONS = (1 << 4), /* bit 4 */ CVMJITIRNODE_HAS_BEEN_EMITTED = (1 << 5) /* bit 5 */};/* NOTE: A node is considered to have side effects if it has an undefined side effect, or if it throws exceptions. Hence, the side effect mask is the combination of these 2 flags.*/#define CVMJITIRNODE_SIDE_EFFECT_MASK \ (CVMJITIRNODE_HAS_UNDEFINED_SIDE_EFFECT | CVMJITIRNODE_THROWS_EXCEPTIONS)struct CVMJITIRRoot { CVMJITIRRoot* next; /* see CVMJITIRListItem */ CVMJITIRRoot* prev; /* see CVMJITIRListItem */ CVMJITIRNode* expr;};/* * CVMJITIRNode interface APIs */extern CVMJITIRNode*CVMJITirnodeNewMapPcNode(CVMJITCompilationContext* con, CVMUint16 tag, CVMUint16 pc, CVMJITIRBlock* curbk);extern CVMJITIRRoot*CVMJITirnodeNewRoot(CVMJITCompilationContext* con, CVMJITIRBlock* curbk, CVMJITIRNode* expr);extern CVMJITIRNode*CVMJITirnodeNewConstant32(CVMJITCompilationContext* con, CVMUint16 tag, CVMUint32 v32); extern CVMJITIRNode*CVMJITirnodeNewConstantAddr(CVMJITCompilationContext* con, CVMUint16 tag, CVMAddr vAddr); extern CVMJITIRNode*CVMJITirnodeNewConstant64(CVMJITCompilationContext* con, CVMUint16 tag, CVMJavaVal64* v64); extern CVMJITIRNode*CVMJITirnodeNewResolveNode(CVMJITCompilationContext* con, CVMUint16 cpIndex, CVMJITIRBlock* curbk, CVMUint8 checkInitFlag, CVMUint8 opcodeTag);extern CVMJITIRNode*CVMJITirnodeNewNull(CVMJITCompilationContext* con, CVMUint16 tag);extern CVMJITIRNode*CVMJITirnodeNewLocal(CVMJITCompilationContext* con, CVMUint16 tag, CVMUint16 localNo); extern CVMJITIRNode*CVMJITirnodeNewUnaryOp(CVMJITCompilationContext* con, CVMUint16 tag, CVMJITIRNode* operand);extern CVMJITIRNode*CVMJITirnodeNewBinaryOp(CVMJITCompilationContext* con, CVMUint16 tag, CVMJITIRNode* lhs, CVMJITIRNode* rhs);extern CVMJITIRNode*CVMJITirnodeNewBranchOp(CVMJITCompilationContext* con, CVMUint16 tag, CVMJITIRBlock* target); extern CVMJITIRNode*CVMJITirnodeNewCondBranchOp(CVMJITCompilationContext* con,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?