📄 interpret.h
字号:
/*0001*//*
/*0002./ * Copyright (c) 1998-2001 Sun Microsystems, Inc. All Rights Reserved.
/*0003./ *
/*0004./ * This software is the confidential and proprietary information of Sun
/*0005./ * Microsystems, Inc. ("Confidential Information"). You shall not
/*0006./ * disclose such Confidential Information and shall use it only in
/*0007./ * accordance with the terms of the license agreement you entered into
/*0008./ * with Sun.
/*0009./ *
/*0010./ * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
/*0011./ * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
/*0012./ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
/*0013./ * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
/*0014./ * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
/*0015./ * THIS SOFTWARE OR ITS DERIVATIVES.
/*0016./ *
/*0017./ */
/*0018*/
/*0019*//*=========================================================================
/*0020./ * SYSTEM: KVM
/*0021./ * SUBSYSTEM: Bytecode interpreter
/*0022./ * FILE: interpret.h
/*0023./ * OVERVIEW: This file defines the general routines used by the
/*0024./ * Java bytecode interpreter.
/*0025./ * AUTHOR: Antero Taivalsaari, Sun Labs
/*0026./ * Major reorganization by Nik Shaylor 9/5/2000
/*0027./ * NOTE: In KVM 1.0.2, the interpreter was restructured for
/*0028./ * better performance, but without sacrificing portability.
/*0029./ * The high-level interpreter loop is now defined in file
/*0030./ * execute.c. Actual bytecode definitions are in file
/*0031./ * bytecodes.c. Various high-level compilation flags
/*0032./ * for the interpreter have been documented in main.h
/*0033./ * and in the KVM Porting Guide.
/*0034./ *=======================================================================*/
/*0035*/
/*0036*//*=========================================================================
/*0037./ * Include files
/*0038./ *=======================================================================*/
/*0039*/
/*0040*//*=========================================================================
/*0041./ * Virtual machine global registers
/*0042./ *=======================================================================*/
/*0043*/
/*0044*//*=========================================================================
/*0045./ * These variables form the heart of the virtual machine. UP holds
/*0046./ * a pointer to the currently executing VM thread, IP holds the current
/*0047./ * instruction pointer (next bytecode to be executed), FP holds a
/*0048./ * pointer to the currently active stack frame, LP holds a pointer
/*0049./ * to the local variables of the current stack frame and SP holds a
/*0050./ * pointer to the top of the execution stack.
/*0051./ *
/*0052./ * Note that IP, FP, LP and SP are thread-specific, i.e., their
/*0053./ * values are changed every time a thread switch takes place.
/*0054./ *=========================================================================
/*0055./ * GENERAL COMMENT:
/*0056./ * The main reason why virtual machines written in high-level languages
/*0057./ * such as C/C++ are inherently slower than machine-coded ones is that
/*0058./ * C/C++ does not provide any mechanism to allocate global variables
/*0059./ * in hardware registers. KVM provides a compilation option
/*0060./ * (LOCALVMREGISTERS, see main.h) to accomplish this in a portable
/*0061./ * fashion.
/*0062./ *=======================================================================*/
/*0063*/
/*0064*/extern BYTE* ip_global; /* Instruction pointer */
/*0065*/extern FRAME fp_global; /* Current frame pointer */
/*0066*/extern cell* sp_global; /* Execution stack pointer */
/*0067*/extern cell* lp_global; /* Local variable pointer */
/*0068*/extern CONSTANTPOOL cp_global; /* Constant pool pointer */
/*0069*/
/*0070*//* These get and set macros provide better control */
/*0071*//* over the way VM registers are accessed. */
/*0072*/
/*0073*/#define getIP() (ip_global)
/*0074*/#define getFP() (fp_global)
/*0075*/#define getSP() (sp_global)
/*0076*/#define getLP() (lp_global)
/*0077*/#define getCP() (cp_global)
/*0078*/
/*0079*/#define setIP(x) (ip_global = (x))
/*0080*/#define setFP(x) (fp_global = (x))
/*0081*/#define setSP(x) (sp_global = (x))
/*0082*/#define setLP(x) (lp_global = (x))
/*0083*/#define setCP(x) (cp_global = (x))
/*0084*/
/*0085*//*=========================================================================
/*0086./ * Bytecode declarations
/*0087./ *=======================================================================*/
/*0088*/
/*0089*/typedef enum {
/*0090*/ NOP = 0x00,
/*0091*/ ACONST_NULL = 0x01,
/*0092*/ ICONST_M1 = 0x02,
/*0093*/ ICONST_0 = 0x03,
/*0094*/ ICONST_1 = 0x04,
/*0095*/ ICONST_2 = 0x05,
/*0096*/ ICONST_3 = 0x06,
/*0097*/ ICONST_4 = 0x07,
/*0098*/
/*0099*/ ICONST_5 = 0x08,
/*0100*/ LCONST_0 = 0x09,
/*0101*/ LCONST_1 = 0x0A,
/*0102*/ FCONST_0 = 0x0B,
/*0103*/ FCONST_1 = 0x0C,
/*0104*/ FCONST_2 = 0x0D,
/*0105*/ DCONST_0 = 0x0E,
/*0106*/ DCONST_1 = 0x0F,
/*0107*/
/*0108*/ BIPUSH = 0x10,
/*0109*/ SIPUSH = 0x11,
/*0110*/ LDC = 0x12,
/*0111*/ LDC_W = 0x13,
/*0112*/ LDC2_W = 0x14,
/*0113*/ ILOAD = 0x15,
/*0114*/ LLOAD = 0x16,
/*0115*/ FLOAD = 0x17,
/*0116*/
/*0117*/ DLOAD = 0x18,
/*0118*/ ALOAD = 0x19,
/*0119*/ ILOAD_0 = 0x1A,
/*0120*/ ILOAD_1 = 0x1B,
/*0121*/ ILOAD_2 = 0x1C,
/*0122*/ ILOAD_3 = 0x1D,
/*0123*/ LLOAD_0 = 0x1E,
/*0124*/ LLOAD_1 = 0x1F,
/*0125*/
/*0126*/ LLOAD_2 = 0x20,
/*0127*/ LLOAD_3 = 0x21,
/*0128*/ FLOAD_0 = 0x22,
/*0129*/ FLOAD_1 = 0x23,
/*0130*/ FLOAD_2 = 0x24,
/*0131*/ FLOAD_3 = 0x25,
/*0132*/ DLOAD_0 = 0x26,
/*0133*/ DLOAD_1 = 0x27,
/*0134*/
/*0135*/ DLOAD_2 = 0x28,
/*0136*/ DLOAD_3 = 0x29,
/*0137*/ ALOAD_0 = 0x2A,
/*0138*/ ALOAD_1 = 0x2B,
/*0139*/ ALOAD_2 = 0x2C,
/*0140*/ ALOAD_3 = 0x2D,
/*0141*/ IALOAD = 0x2E,
/*0142*/ LALOAD = 0x2F,
/*0143*/
/*0144*/ FALOAD = 0x30,
/*0145*/ DALOAD = 0x31,
/*0146*/ AALOAD = 0x32,
/*0147*/ BALOAD = 0x33,
/*0148*/ CALOAD = 0x34,
/*0149*/ SALOAD = 0x35,
/*0150*/ ISTORE = 0x36,
/*0151*/ LSTORE = 0x37,
/*0152*/
/*0153*/ FSTORE = 0x38,
/*0154*/ DSTORE = 0x39,
/*0155*/ ASTORE = 0x3A,
/*0156*/ ISTORE_0 = 0x3B,
/*0157*/ ISTORE_1 = 0x3C,
/*0158*/ ISTORE_2 = 0x3D,
/*0159*/ ISTORE_3 = 0x3E,
/*0160*/ LSTORE_0 = 0x3F,
/*0161*/
/*0162*/ LSTORE_1 = 0x40,
/*0163*/ LSTORE_2 = 0x41,
/*0164*/ LSTORE_3 = 0x42,
/*0165*/ FSTORE_0 = 0x43,
/*0166*/ FSTORE_1 = 0x44,
/*0167*/ FSTORE_2 = 0x45,
/*0168*/ FSTORE_3 = 0x46,
/*0169*/ DSTORE_0 = 0x47,
/*0170*/
/*0171*/ DSTORE_1 = 0x48,
/*0172*/ DSTORE_2 = 0x49,
/*0173*/ DSTORE_3 = 0x4A,
/*0174*/ ASTORE_0 = 0x4B,
/*0175*/ ASTORE_1 = 0x4C,
/*0176*/ ASTORE_2 = 0x4D,
/*0177*/ ASTORE_3 = 0x4E,
/*0178*/ IASTORE = 0x4F,
/*0179*/
/*0180*/ LASTORE = 0x50,
/*0181*/ FASTORE = 0x51,
/*0182*/ DASTORE = 0x52,
/*0183*/ AASTORE = 0x53,
/*0184*/ BASTORE = 0x54,
/*0185*/ CASTORE = 0x55,
/*0186*/ SASTORE = 0x56,
/*0187*/ POP = 0x57,
/*0188*/
/*0189*/ POP2 = 0x58,
/*0190*/ DUP = 0x59,
/*0191*/ DUP_X1 = 0x5A,
/*0192*/ DUP_X2 = 0x5B,
/*0193*/ DUP2 = 0x5C,
/*0194*/ DUP2_X1 = 0x5D,
/*0195*/ DUP2_X2 = 0x5E,
/*0196*/ SWAP = 0x5F,
/*0197*/
/*0198*/ IADD = 0x60,
/*0199*/ LADD = 0x61,
/*0200*/ FADD = 0x62,
/*0201*/ DADD = 0x63,
/*0202*/ ISUB = 0x64,
/*0203*/ LSUB = 0x65,
/*0204*/ FSUB = 0x66,
/*0205*/ DSUB = 0x67,
/*0206*/
/*0207*/ IMUL = 0x68,
/*0208*/ LMUL = 0x69,
/*0209*/ FMUL = 0x6A,
/*0210*/ DMUL = 0x6B,
/*0211*/ IDIV = 0x6C,
/*0212*/ LDIV = 0x6D,
/*0213*/ FDIV = 0x6E,
/*0214*/ DDIV = 0x6F,
/*0215*/
/*0216*/ IREM = 0x70,
/*0217*/ LREM = 0x71,
/*0218*/ FREM = 0x72,
/*0219*/ DREM = 0x73,
/*0220*/ INEG = 0x74,
/*0221*/ LNEG = 0x75,
/*0222*/ FNEG = 0x76,
/*0223*/ DNEG = 0x77,
/*0224*/
/*0225*/ ISHL = 0x78,
/*0226*/ LSHL = 0x79,
/*0227*/ ISHR = 0x7A,
/*0228*/ LSHR = 0x7B,
/*0229*/ IUSHR = 0x7C,
/*0230*/ LUSHR = 0x7D,
/*0231*/ IAND = 0x7E,
/*0232*/ LAND = 0x7F,
/*0233*/
/*0234*/ IOR = 0x80,
/*0235*/ LOR = 0x81,
/*0236*/ IXOR = 0x82,
/*0237*/ LXOR = 0x83,
/*0238*/ IINC = 0x84,
/*0239*/ I2L = 0x85,
/*0240*/ I2F = 0x86,
/*0241*/ I2D = 0x87,
/*0242*/
/*0243*/ L2I = 0x88,
/*0244*/ L2F = 0x89,
/*0245*/ L2D = 0x8A,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -