1 /* 2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.tools.javac.jvm; 27 28 29 /** Bytecode instruction codes, as well as typecodes used as 30 * instruction modifiers. 31 * 32 * <p><b>This is NOT part of any supported API. 33 * If you write code that depends on this, you do so at your own risk. 34 * This code and its internal interfaces are subject to change or 35 * deletion without notice.</b> 36 */ 37 public interface ByteCodes { 38 39 /** Byte code instruction codes. 40 */ 41 int illegal = -1, 42 nop = 0, 43 aconst_null = 1, 44 iconst_m1 = 2, 45 iconst_0 = 3, 46 iconst_1 = 4, 47 iconst_2 = 5, 48 iconst_3 = 6, 49 iconst_4 = 7, 50 iconst_5 = 8, 51 lconst_0 = 9, 52 lconst_1 = 10, 53 fconst_0 = 11, 54 fconst_1 = 12, 55 fconst_2 = 13, 56 dconst_0 = 14, 57 dconst_1 = 15, 58 bipush = 16, 59 sipush = 17, 60 ldc1 = 18, 61 ldc2 = 19, 62 ldc2w = 20, 63 iload = 21, 64 lload = 22, 65 fload = 23, 66 dload = 24, 67 aload = 25, 68 iload_0 = 26, 69 iload_1 = 27, 70 iload_2 = 28, 71 iload_3 = 29, 72 lload_0 = 30, 73 lload_1 = 31, 74 lload_2 = 32, 75 lload_3 = 33, 76 fload_0 = 34, 77 fload_1 = 35, 78 fload_2 = 36, 79 fload_3 = 37, 80 dload_0 = 38, 81 dload_1 = 39, 82 dload_2 = 40, 83 dload_3 = 41, 84 aload_0 = 42, 85 aload_1 = 43, 86 aload_2 = 44, 87 aload_3 = 45, 88 iaload = 46, 89 laload = 47, 90 faload = 48, 91 daload = 49, 92 aaload = 50, 93 baload = 51, 94 caload = 52, 95 saload = 53, 96 istore = 54, 97 lstore = 55, 98 fstore = 56, 99 dstore = 57, 100 astore = 58, 101 istore_0 = 59, 102 istore_1 = 60, 103 istore_2 = 61, 104 istore_3 = 62, 105 lstore_0 = 63, 106 lstore_1 = 64, 107 lstore_2 = 65, 108 lstore_3 = 66, 109 fstore_0 = 67, 110 fstore_1 = 68, 111 fstore_2 = 69, 112 fstore_3 = 70, 113 dstore_0 = 71, 114 dstore_1 = 72, 115 dstore_2 = 73, 116 dstore_3 = 74, 117 astore_0 = 75, 118 astore_1 = 76, 119 astore_2 = 77, 120 astore_3 = 78, 121 iastore = 79, 122 lastore = 80, 123 fastore = 81, 124 dastore = 82, 125 aastore = 83, 126 bastore = 84, 127 castore = 85, 128 sastore = 86, 129 pop = 87, 130 pop2 = 88, 131 dup = 89, 132 dup_x1 = 90, 133 dup_x2 = 91, 134 dup2 = 92, 135 dup2_x1 = 93, 136 dup2_x2 = 94, 137 swap = 95, 138 iadd = 96, 139 ladd = 97, 140 fadd = 98, 141 dadd = 99, 142 isub = 100, 143 lsub = 101, 144 fsub = 102, 145 dsub = 103, 146 imul = 104, 147 lmul = 105, 148 fmul = 106, 149 dmul = 107, 150 idiv = 108, 151 ldiv = 109, 152 fdiv = 110, 153 ddiv = 111, 154 imod = 112, 155 lmod = 113, 156 fmod = 114, 157 dmod = 115, 158 ineg = 116, 159 lneg = 117, 160 fneg = 118, 161 dneg = 119, 162 ishl = 120, 163 lshl = 121, 164 ishr = 122, 165 lshr = 123, 166 iushr = 124, 167 lushr = 125, 168 iand = 126, 169 land = 127, 170 ior = 128, 171 lor = 129, 172 ixor = 130, 173 lxor = 131, 174 iinc = 132, 175 i2l = 133, 176 i2f = 134, 177 i2d = 135, 178 l2i = 136, 179 l2f = 137, 180 l2d = 138, 181 f2i = 139, 182 f2l = 140, 183 f2d = 141, 184 d2i = 142, 185 d2l = 143, 186 d2f = 144, 187 int2byte = 145, 188 int2char = 146, 189 int2short = 147, 190 lcmp = 148, 191 fcmpl = 149, 192 fcmpg = 150, 193 dcmpl = 151, 194 dcmpg = 152, 195 ifeq = 153, 196 ifne = 154, 197 iflt = 155, 198 ifge = 156, 199 ifgt = 157, 200 ifle = 158, 201 if_icmpeq = 159, 202 if_icmpne = 160, 203 if_icmplt = 161, 204 if_icmpge = 162, 205 if_icmpgt = 163, 206 if_icmple = 164, 207 if_acmpeq = 165, 208 if_acmpne = 166, 209 goto_ = 167, 210 jsr = 168, 211 ret = 169, 212 tableswitch = 170, 213 lookupswitch = 171, 214 ireturn = 172, 215 lreturn = 173, 216 freturn = 174, 217 dreturn = 175, 218 areturn = 176, 219 return_ = 177, 220 getstatic = 178, 221 putstatic = 179, 222 getfield = 180, 223 putfield = 181, 224 invokevirtual = 182, 225 invokespecial = 183, 226 invokestatic = 184, 227 invokeinterface = 185, 228 invokedynamic = 186, 229 new_ = 187, 230 newarray = 188, 231 anewarray = 189, 232 arraylength = 190, 233 athrow = 191, 234 checkcast = 192, 235 instanceof_ = 193, 236 monitorenter = 194, 237 monitorexit = 195, 238 wide = 196, 239 multianewarray = 197, 240 if_acmp_null = 198, 241 if_acmp_nonnull = 199, 242 goto_w = 200, 243 jsr_w = 201, 244 breakpoint = 202, 245 246 // value-type bytecodes 247 vload = 203, 248 vstore = 204, 249 vaload = 205, 250 vastore = 206, 251 vreturn = 207, 252 vdefault = 208, 253 vwithfield = 209, 254 255 ByteCodeCount = 210; 256 257 /** Virtual instruction codes; used for constant folding. 258 */ 259 int string_add = 256, // string + 260 bool_not = 257, // boolean ! 261 bool_and = 258, // boolean && 262 bool_or = 259; // boolean || 263 264 /** Virtual opcodes; used for shifts with long shiftcount 265 */ 266 int ishll = 270, // int shift left with long count 267 lshll = 271, // long shift left with long count 268 ishrl = 272, // int shift right with long count 269 lshrl = 273, // long shift right with long count 270 iushrl = 274, // int unsigned shift right with long count 271 lushrl = 275; // long unsigned shift right with long count 272 273 /** Virtual opcode for null reference checks 274 */ 275 int nullchk = 276; // return operand if non-null, 276 // otherwise throw NullPointerException. 277 278 /** Virtual opcode for disallowed operations. 279 */ 280 int error = 277; 281 282 /** All conditional jumps come in pairs. To streamline the 283 * treatment of jumps, we also introduce a negation of an 284 * unconditional jump. That opcode happens to be jsr. 285 */ 286 int dontgoto = jsr; 287 288 /** Shift and mask constants for shifting prefix instructions. 289 * a pair of instruction codes such as LCMP ; IFEQ is encoded 290 * in Symtab as {@literal (LCMP << preShift) + IFEQ }. 291 */ 292 int preShift = 9; 293 int preMask = (1 << preShift) - 1; 294 295 /** Type codes. 296 */ 297 int INTcode = 0, 298 LONGcode = 1, 299 FLOATcode = 2, 300 DOUBLEcode = 3, 301 OBJECTcode = 4, 302 BYTEcode = 5, 303 CHARcode = 6, 304 SHORTcode = 7, 305 VOIDcode = 8, 306 TypeCodeCount = 9; 307 308 static final String[] typecodeNames = { 309 "int", 310 "long", 311 "float", 312 "double", 313 "object", 314 "byte", 315 "char", 316 "short", 317 "void", 318 "oops" 319 }; 320 }