1 // $Id: op.h,v 1.18 2004/01/20 04:10:26 ericb Exp $ -*- c++ -*- 2 // 3 // This software is subject to the terms of the IBM Jikes Compiler 4 // License Agreement available at the following URL: 5 // http://ibm.com/developerworks/opensource/jikes. 6 // Copyright (C) 1996, 2004 IBM Corporation and others. All Rights Reserved. 7 // You must accept the terms of that agreement to use this software. 8 // 9 10 #ifndef op_INCLUDED 11 #define op_INCLUDED 12 13 #include "platform.h" 14 #include "tuple.h" 15 16 #ifdef HAVE_JIKES_NAMESPACE 17 namespace Jikes { // Open namespace Jikes block 18 #endif 19 20 class ConstantPool; 21 22 // code dealing with describing and listing byte code 23 class Operators 24 { 25 public: 26 enum Opcode 27 { 28 OP_NOP = 0x00, 29 OP_ACONST_NULL = 0x01, 30 OP_ICONST_M1 = 0x02, 31 OP_ICONST_0 = 0x03, 32 OP_ICONST_1 = 0x04, 33 OP_ICONST_2 = 0x05, 34 OP_ICONST_3 = 0x06, 35 OP_ICONST_4 = 0x07, 36 OP_ICONST_5 = 0x08, 37 OP_LCONST_0 = 0x09, 38 OP_LCONST_1 = 0x0a, 39 OP_FCONST_0 = 0x0b, 40 OP_FCONST_1 = 0x0c, 41 OP_FCONST_2 = 0x0d, 42 OP_DCONST_0 = 0x0e, 43 OP_DCONST_1 = 0x0f, 44 OP_BIPUSH = 0x10, 45 OP_SIPUSH = 0x11, 46 OP_LDC = 0x12, 47 OP_LDC_W = 0x13, 48 OP_LDC2_W = 0x14, 49 OP_ILOAD = 0x15, 50 OP_LLOAD = 0x16, 51 OP_FLOAD = 0x17, 52 OP_DLOAD = 0x18, 53 OP_ALOAD = 0x19, 54 OP_ILOAD_0 = 0x1a, 55 OP_ILOAD_1 = 0x1b, 56 OP_ILOAD_2 = 0x1c, 57 OP_ILOAD_3 = 0x1d, 58 OP_LLOAD_0 = 0x1e, 59 OP_LLOAD_1 = 0x1f, 60 OP_LLOAD_2 = 0x20, 61 OP_LLOAD_3 = 0x21, 62 OP_FLOAD_0 = 0x22, 63 OP_FLOAD_1 = 0x23, 64 OP_FLOAD_2 = 0x24, 65 OP_FLOAD_3 = 0x25, 66 OP_DLOAD_0 = 0x26, 67 OP_DLOAD_1 = 0x27, 68 OP_DLOAD_2 = 0x28, 69 OP_DLOAD_3 = 0x29, 70 OP_ALOAD_0 = 0x2a, 71 OP_ALOAD_1 = 0x2b, 72 OP_ALOAD_2 = 0x2c, 73 OP_ALOAD_3 = 0x2d, 74 OP_IALOAD = 0x2e, 75 OP_LALOAD = 0x2f, 76 OP_FALOAD = 0x30, 77 OP_DALOAD = 0x31, 78 OP_AALOAD = 0x32, 79 OP_BALOAD = 0x33, 80 OP_CALOAD = 0x34, 81 OP_SALOAD = 0x35, 82 OP_ISTORE = 0x36, 83 OP_LSTORE = 0x37, 84 OP_FSTORE = 0x38, 85 OP_DSTORE = 0x39, 86 OP_ASTORE = 0x3a, 87 OP_ISTORE_0 = 0x3b, 88 OP_ISTORE_1 = 0x3c, 89 OP_ISTORE_2 = 0x3d, 90 OP_ISTORE_3 = 0x3e, 91 OP_LSTORE_0 = 0x3f, 92 OP_LSTORE_1 = 0x40, 93 OP_LSTORE_2 = 0x41, 94 OP_LSTORE_3 = 0x42, 95 OP_FSTORE_0 = 0x43, 96 OP_FSTORE_1 = 0x44, 97 OP_FSTORE_2 = 0x45, 98 OP_FSTORE_3 = 0x46, 99 OP_DSTORE_0 = 0x47, 100 OP_DSTORE_1 = 0x48, 101 OP_DSTORE_2 = 0x49, 102 OP_DSTORE_3 = 0x4a, 103 OP_ASTORE_0 = 0x4b, 104 OP_ASTORE_1 = 0x4c, 105 OP_ASTORE_2 = 0x4d, 106 OP_ASTORE_3 = 0x4e, 107 OP_IASTORE = 0x4f, 108 OP_LASTORE = 0x50, 109 OP_FASTORE = 0x51, 110 OP_DASTORE = 0x52, 111 OP_AASTORE = 0x53, 112 OP_BASTORE = 0x54, 113 OP_CASTORE = 0x55, 114 OP_SASTORE = 0x56, 115 OP_POP = 0x57, 116 OP_POP2 = 0x58, 117 OP_DUP = 0x59, 118 OP_DUP_X1 = 0x5a, 119 OP_DUP_X2 = 0x5b, 120 OP_DUP2 = 0x5c, 121 OP_DUP2_X1 = 0x5d, 122 OP_DUP2_X2 = 0x5e, 123 OP_SWAP = 0x5f, 124 OP_IADD = 0x60, 125 OP_LADD = 0x61, 126 OP_FADD = 0x62, 127 OP_DADD = 0x63, 128 OP_ISUB = 0x64, 129 OP_LSUB = 0x65, 130 OP_FSUB = 0x66, 131 OP_DSUB = 0x67, 132 OP_IMUL = 0x68, 133 OP_LMUL = 0x69, 134 OP_FMUL = 0x6a, 135 OP_DMUL = 0x6b, 136 OP_IDIV = 0x6c, 137 OP_LDIV = 0x6d, 138 OP_FDIV = 0x6e, 139 OP_DDIV = 0x6f, 140 OP_IREM = 0x70, 141 OP_LREM = 0x71, 142 OP_FREM = 0x72, 143 OP_DREM = 0x73, 144 OP_INEG = 0x74, 145 OP_LNEG = 0x75, 146 OP_FNEG = 0x76, 147 OP_DNEG = 0x77, 148 OP_ISHL = 0x78, 149 OP_LSHL = 0x79, 150 OP_ISHR = 0x7a, 151 OP_LSHR = 0x7b, 152 OP_IUSHR = 0x7c, 153 OP_LUSHR = 0x7d, 154 OP_IAND = 0x7e, 155 OP_LAND = 0x7f, 156 OP_IOR = 0x80, 157 OP_LOR = 0x81, 158 OP_IXOR = 0x82, 159 OP_LXOR = 0x83, 160 OP_IINC = 0x84, 161 OP_I2L = 0x85, 162 OP_I2F = 0x86, 163 OP_I2D = 0x87, 164 OP_L2I = 0x88, 165 OP_L2F = 0x89, 166 OP_L2D = 0x8a, 167 OP_F2I = 0x8b, 168 OP_F2L = 0x8c, 169 OP_F2D = 0x8d, 170 OP_D2I = 0x8e, 171 OP_D2L = 0x8f, 172 OP_D2F = 0x90, 173 OP_I2B = 0x91, 174 OP_I2C = 0x92, 175 OP_I2S = 0x93, 176 OP_LCMP = 0x94, 177 OP_FCMPL = 0x95, 178 OP_FCMPG = 0x96, 179 OP_DCMPL = 0x97, 180 OP_DCMPG = 0x98, 181 OP_IFEQ = 0x99, 182 OP_IFNE = 0x9a, 183 OP_IFLT = 0x9b, 184 OP_IFGE = 0x9c, 185 OP_IFGT = 0x9d, 186 OP_IFLE = 0x9e, 187 OP_IF_ICMPEQ = 0x9f, 188 OP_IF_ICMPNE = 0xa0, 189 OP_IF_ICMPLT = 0xa1, 190 OP_IF_ICMPGE = 0xa2, 191 OP_IF_ICMPGT = 0xa3, 192 OP_IF_ICMPLE = 0xa4, 193 OP_IF_ACMPEQ = 0xa5, 194 OP_IF_ACMPNE = 0xa6, 195 OP_GOTO = 0xa7, 196 OP_JSR = 0xa8, 197 OP_RET = 0xa9, 198 OP_TABLESWITCH = 0xaa, 199 OP_LOOKUPSWITCH = 0xab, 200 OP_IRETURN = 0xac, 201 OP_LRETURN = 0xad, 202 OP_FRETURN = 0xae, 203 OP_DRETURN = 0xaf, 204 OP_ARETURN = 0xb0, 205 OP_RETURN = 0xb1, 206 OP_GETSTATIC = 0xb2, 207 OP_PUTSTATIC = 0xb3, 208 OP_GETFIELD = 0xb4, 209 OP_PUTFIELD = 0xb5, 210 OP_INVOKEVIRTUAL = 0xb6, 211 OP_INVOKESPECIAL = 0xb7, 212 OP_INVOKESTATIC = 0xb8, 213 OP_INVOKEINTERFACE = 0xb9, 214 OP_XXXUNUSEDXXX = 0xba, 215 OP_NEW = 0xbb, 216 OP_NEWARRAY = 0xbc, 217 OP_ANEWARRAY = 0xbd, 218 OP_ARRAYLENGTH = 0xbe, 219 OP_ATHROW = 0xbf, 220 OP_CHECKCAST = 0xc0, 221 OP_INSTANCEOF = 0xc1, 222 OP_MONITORENTER = 0xc2, 223 OP_MONITOREXIT = 0xc3, 224 OP_WIDE = 0xc4, 225 OP_MULTIANEWARRAY = 0xc5, 226 OP_IFNULL = 0xc6, 227 OP_IFNONNULL = 0xc7, 228 OP_GOTO_W = 0xc8, 229 OP_JSR_W = 0xc9, 230 OP_SOFTWARE = 0xfe, 231 OP_HARDWARE = 0xff 232 }; 233 234 protected: 235 static int stack_effect[]; 236 237 #ifdef JIKES_DEBUG 238 public: 239 static void OpDmp(const ConstantPool&, const Tuple<u1>&); 240 static int OpDesc(Opcode, const char** name, const char** desc); 241 242 private: 243 enum OpInfo 244 { 245 INFO_NONE, 246 INFO_LOCAL, 247 INFO_CONST, 248 INFO_DONE, 249 INFO_WIDE 250 }; 251 GetAndSkipI1(const Tuple<u1> & code,unsigned & pc)252 inline static i1 GetAndSkipI1(const Tuple<u1>& code, unsigned& pc) 253 { 254 return (i1) code[pc++]; 255 } 256 GetAndSkipI2(const Tuple<u1> & code,unsigned & pc)257 inline static i2 GetAndSkipI2(const Tuple<u1>& code, unsigned& pc) 258 { 259 i2 s = code[pc++] << 8; 260 return s | code[pc++]; 261 } 262 GetAndSkipI4(const Tuple<u1> & code,unsigned & pc)263 inline static i4 GetAndSkipI4(const Tuple<u1>& code, unsigned& pc) 264 { 265 i4 i = code[pc++] << 24; 266 i |= code[pc++] << 16; 267 i |= code[pc++] << 8; 268 return i | code[pc++]; 269 } 270 GetAndSkipU1(const Tuple<u1> & code,unsigned & pc)271 inline static u1 GetAndSkipU1(const Tuple<u1>& code, unsigned& pc) 272 { 273 return code[pc++]; 274 } 275 GetAndSkipU2(const Tuple<u1> & code,unsigned & pc)276 inline static u2 GetAndSkipU2(const Tuple<u1>& code, unsigned& pc) 277 { 278 u2 u = code[pc++] << 8; 279 return u | code[pc++]; 280 } 281 GetAndSkipU4(const Tuple<u1> & code,unsigned & pc)282 inline static u4 GetAndSkipU4(const Tuple<u1>& code, unsigned& pc) 283 { 284 u4 u = code[pc++] << 24; 285 u |= code[pc++] << 16; 286 u |= code[pc++] << 8; 287 return u | code[pc++]; 288 } 289 290 static void OpLine(const ConstantPool&, char, int, const char*, 291 char*, const char*, OpInfo, unsigned); 292 #endif // JIKES_DEBUG 293 }; 294 295 #ifdef HAVE_JIKES_NAMESPACE 296 } // Close namespace Jikes block 297 #endif 298 299 #endif // op_INCLUDED 300