Mon, 30 Mar 2009 15:08:09 -0700
6819246: improve support for decoding instructions in classfile library
Reviewed-by: ksrini
1.1 --- a/src/share/classes/com/sun/tools/classfile/Code_attribute.java Wed Mar 25 10:29:28 2009 +0000 1.2 +++ b/src/share/classes/com/sun/tools/classfile/Code_attribute.java Mon Mar 30 15:08:09 2009 -0700 1.3 @@ -26,6 +26,8 @@ 1.4 package com.sun.tools.classfile; 1.5 1.6 import java.io.IOException; 1.7 +import java.util.Iterator; 1.8 +import java.util.NoSuchElementException; 1.9 1.10 /** 1.11 * See JVMS3, section 4.8.3. 1.12 @@ -100,6 +102,39 @@ 1.13 return visitor.visitCode(this, data); 1.14 } 1.15 1.16 + public Iterable<Instruction> getInstructions() { 1.17 + return new Iterable<Instruction>() { 1.18 + public Iterator<Instruction> iterator() { 1.19 + return new Iterator<Instruction>() { 1.20 + 1.21 + public boolean hasNext() { 1.22 + return (next != null); 1.23 + } 1.24 + 1.25 + public Instruction next() { 1.26 + if (next == null) 1.27 + throw new NoSuchElementException(); 1.28 + 1.29 + current = next; 1.30 + pc += current.length(); 1.31 + next = (pc < code.length ? new Instruction(code, pc) : null); 1.32 + return current; 1.33 + } 1.34 + 1.35 + public void remove() { 1.36 + throw new UnsupportedOperationException("Not supported."); 1.37 + } 1.38 + 1.39 + Instruction current = null; 1.40 + int pc = 0; 1.41 + Instruction next = new Instruction(code, pc); 1.42 + 1.43 + }; 1.44 + } 1.45 + 1.46 + }; 1.47 + } 1.48 + 1.49 public final int max_stack; 1.50 public final int max_locals; 1.51 public final int code_length;
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/src/share/classes/com/sun/tools/classfile/Instruction.java Mon Mar 30 15:08:09 2009 -0700 2.3 @@ -0,0 +1,339 @@ 2.4 +/* 2.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.7 + * 2.8 + * This code is free software; you can redistribute it and/or modify it 2.9 + * under the terms of the GNU General Public License version 2 only, as 2.10 + * published by the Free Software Foundation. Sun designates this 2.11 + * particular file as subject to the "Classpath" exception as provided 2.12 + * by Sun in the LICENSE file that accompanied this code. 2.13 + * 2.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 2.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.17 + * version 2 for more details (a copy is included in the LICENSE file that 2.18 + * accompanied this code). 2.19 + * 2.20 + * You should have received a copy of the GNU General Public License version 2.21 + * 2 along with this work; if not, write to the Free Software Foundation, 2.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.23 + * 2.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 2.25 + * CA 95054 USA or visit www.sun.com if you need additional information or 2.26 + * have any questions. 2.27 + */ 2.28 + 2.29 +package com.sun.tools.classfile; 2.30 + 2.31 +/** 2.32 + * See JVMS3, chapter 6. 2.33 + * 2.34 + * <p><b>This is NOT part of any API supported by Sun Microsystems. If 2.35 + * you write code that depends on this, you do so at your own risk. 2.36 + * This code and its internal interfaces are subject to change or 2.37 + * deletion without notice.</b> 2.38 + * 2.39 + * @see Code_attribute#getInstructions 2.40 + */ 2.41 +public class Instruction { 2.42 + /** The kind of an instruction, as determined by the position, size and 2.43 + * types of its operands. */ 2.44 + public static enum Kind { 2.45 + /** Opcode is not followed by any operands. */ 2.46 + NO_OPERANDS(1), 2.47 + /** Opcode is followed by a byte indicating a type. */ 2.48 + ATYPE(2), 2.49 + /** Opcode is followed by a 2-byte branch offset. */ 2.50 + BRANCH(3), 2.51 + /** Opcode is followed by a 4-byte branch offset. */ 2.52 + BRANCH_W(5), 2.53 + /** Opcode is followed by a signed byte value. */ 2.54 + BYTE(2), 2.55 + /** Opcode is followed by a 1-byte index into the constant pool. */ 2.56 + CPREF(2), 2.57 + /** Opcode is followed by a 2-byte index into the constant pool. */ 2.58 + CPREF_W(3), 2.59 + /** Opcode is followed by a 2-byte index into the constant pool, 2.60 + * an unsigned byte value. */ 2.61 + CPREF_W_UBYTE(4), 2.62 + /** Opcode is followed by a 2-byte index into the constant pool., 2.63 + * an unsigned byte value, and a zero byte. */ 2.64 + CPREF_W_UBYTE_ZERO(5), 2.65 + /** Opcode is followed by variable number of operands, depending 2.66 + * on the instruction.*/ 2.67 + DYNAMIC(-1), 2.68 + /** Opcode is followed by a 1-byte reference to a local variable. */ 2.69 + LOCAL(2), 2.70 + /** Opcode is followed by a 1-byte reference to a local variable, 2.71 + * and a signed byte value. */ 2.72 + LOCAL_BYTE(3), 2.73 + /** Opcode is followed by a signed short value. */ 2.74 + SHORT(3), 2.75 + /** Wide opcode is not followed by any operands. */ 2.76 + WIDE_NO_OPERANDS(2), 2.77 + /** Wide opcode is followed by a 2-byte index into the constant pool. */ 2.78 + WIDE_CPREF_W(4), 2.79 + /** Wide opcode is followed by a 2-byte index into the constant pool, 2.80 + * and a signed short value. */ 2.81 + WIDE_CPREF_W_SHORT(6), 2.82 + /** Opcode was not recognized. */ 2.83 + UNKNOWN(1); 2.84 + 2.85 + Kind(int length) { 2.86 + this.length = length; 2.87 + } 2.88 + 2.89 + /** The length, in bytes, of this kind of instruction, or -1 is the 2.90 + * length depends on the specific instruction. */ 2.91 + public final int length; 2.92 + }; 2.93 + 2.94 + /** A utility visitor to help decode the operands of an instruction. 2.95 + * @see Instruction#accept */ 2.96 + public interface KindVisitor<R,P> { 2.97 + /** See {@link Kind#NO_OPERANDS}, {@link Kind#WIDE_NO_OPERANDS}. */ 2.98 + R visitNoOperands(Instruction instr, P p); 2.99 + /** See {@link Kind#ATYPE}. */ 2.100 + R visitArrayType(Instruction instr, TypeKind kind, P p); 2.101 + /** See {@link Kind#BRANCH}, {@link Kind#BRANCH_W}. */ 2.102 + R visitBranch(Instruction instr, int offset, P p); 2.103 + /** See {@link Kind#CPREF}, {@link Kind#CPREF_W}, {@link Kind#WIDE_CPREF_W}. */ 2.104 + R visitConstantPoolRef(Instruction instr, int index, P p); 2.105 + /** See {@link Kind#CPREF_W_UBYTE}, {@link Kind#CPREF_W_UBYTE_ZERO}, {@link Kind#WIDE_CPREF_W_SHORT}. */ 2.106 + R visitConstantPoolRefAndValue(Instruction instr, int index, int value, P p); 2.107 + /** See {@link Kind#LOCAL}. */ 2.108 + R visitLocal(Instruction instr, int index, P p); 2.109 + /** See {@link Kind#LOCAL_UBYTE}. */ 2.110 + R visitLocalAndValue(Instruction instr, int index, int value, P p); 2.111 + /** See {@link Kind#DYNAMIC}. */ 2.112 + R visitLookupSwitch(Instruction instr, int default_, int npairs, int[] matches, int[] offsets); 2.113 + /** See {@link Kind#DYNAMIC}. */ 2.114 + R visitTableSwitch(Instruction instr, int default_, int low, int high, int[] offsets); 2.115 + /** See {@link Kind#BYTE}, {@link Kind#SHORT}. */ 2.116 + R visitValue(Instruction instr, int value, P p); 2.117 + /** Instruction is unrecognized. */ 2.118 + R visitUnknown(Instruction instr, P p); 2.119 + 2.120 + } 2.121 + 2.122 + /** The kind of primitive array type to create. 2.123 + * See JVMS chapter 6, newarray. */ 2.124 + public static enum TypeKind { 2.125 + T_BOOLEAN(4, "boolean"), 2.126 + T_CHAR(5, "char"), 2.127 + T_FLOAT(6, "float"), 2.128 + T_DOUBLE(7, "double"), 2.129 + T_BYTE(8, "byte"), 2.130 + T_SHORT(9, "short"), 2.131 + T_INT (10, "int"), 2.132 + T_LONG (11, "long"); 2.133 + TypeKind(int value, String name) { 2.134 + this.value = value; 2.135 + this.name = name; 2.136 + } 2.137 + 2.138 + public static TypeKind get(int value) { 2.139 + switch (value) { 2.140 + case 4: return T_BOOLEAN; 2.141 + case 5: return T_CHAR; 2.142 + case 6: return T_FLOAT; 2.143 + case 7: return T_DOUBLE; 2.144 + case 8: return T_BYTE; 2.145 + case 9: return T_SHORT; 2.146 + case 10: return T_INT; 2.147 + case 11: return T_LONG; 2.148 + default: return null; 2.149 + } 2.150 + } 2.151 + 2.152 + public final int value; 2.153 + public final String name; 2.154 + } 2.155 + 2.156 + /** An instruction is defined by its position in a bytecode array. */ 2.157 + public Instruction(byte[] bytes, int pc) { 2.158 + this.bytes = bytes; 2.159 + this.pc = pc; 2.160 + } 2.161 + 2.162 + /** Get the position of the instruction within the bytecode array. */ 2.163 + public int getPC() { 2.164 + return pc; 2.165 + } 2.166 + 2.167 + /** Get a byte value, relative to the start of this instruction. */ 2.168 + public int getByte(int offset) { 2.169 + return bytes[pc + offset]; 2.170 + } 2.171 + 2.172 + /** Get an unsigned byte value, relative to the start of this instruction. */ 2.173 + public int getUnsignedByte(int offset) { 2.174 + return getByte(offset) & 0xff; 2.175 + } 2.176 + 2.177 + /** Get a 2-byte value, relative to the start of this instruction. */ 2.178 + public int getShort(int offset) { 2.179 + return (getByte(offset) << 8) | getUnsignedByte(offset + 1); 2.180 + } 2.181 + 2.182 + /** Get a unsigned 2-byte value, relative to the start of this instruction. */ 2.183 + public int getUnsignedShort(int offset) { 2.184 + return getShort(offset) & 0xFFFF; 2.185 + } 2.186 + 2.187 + /** Get a 4-byte value, relative to the start of this instruction. */ 2.188 + public int getInt(int offset) { 2.189 + return (getShort(offset) << 16) | (getUnsignedShort(offset + 2)); 2.190 + } 2.191 + 2.192 + /** Get the Opcode for this instruction, or null if the instruction is 2.193 + * unrecognized. */ 2.194 + public Opcode getOpcode() { 2.195 + int b = getUnsignedByte(0); 2.196 + switch (b) { 2.197 + case Opcode.NONPRIV: 2.198 + case Opcode.PRIV: 2.199 + case Opcode.WIDE: 2.200 + return Opcode.get(b, getUnsignedByte(1)); 2.201 + } 2.202 + return Opcode.get(b); 2.203 + } 2.204 + 2.205 + /** Get the mnemonic for this instruction, or a default string if the 2.206 + * instruction is unrecognized. */ 2.207 + public String getMnemonic() { 2.208 + Opcode opcode = getOpcode(); 2.209 + if (opcode == null) 2.210 + return "bytecode " + getUnsignedByte(0); 2.211 + else 2.212 + return opcode.toString().toLowerCase(); 2.213 + } 2.214 + 2.215 + /** Get the length, in bytes, of this instruction, including the opcode 2.216 + * and all its operands. */ 2.217 + public int length() { 2.218 + Opcode opcode = getOpcode(); 2.219 + if (opcode == null) 2.220 + return 1; 2.221 + 2.222 + switch (opcode) { 2.223 + case TABLESWITCH: { 2.224 + int pad = align(pc + 1) - pc; 2.225 + int low = getInt(pad + 4); 2.226 + int high = getInt(pad + 8); 2.227 + return pad + 12 + 4 * (high - low + 1); 2.228 + } 2.229 + case LOOKUPSWITCH: { 2.230 + int pad = align(pc + 1) - pc; 2.231 + int npairs = getInt(pad + 4); 2.232 + return pad + 8 + 8 * npairs; 2.233 + 2.234 + } 2.235 + default: 2.236 + return opcode.kind.length; 2.237 + } 2.238 + } 2.239 + 2.240 + /** Get the {@link Kind} of this instruction. */ 2.241 + public Kind getKind() { 2.242 + Opcode opcode = getOpcode(); 2.243 + return (opcode != null ? opcode.kind : Kind.UNKNOWN); 2.244 + } 2.245 + 2.246 + /** Invoke a method on the visitor according to the kind of this 2.247 + * instruction, passing in the decoded operands for the instruction. */ 2.248 + public <R,P> R accept(KindVisitor<R,P> visitor, P p) { 2.249 + switch (getKind()) { 2.250 + case NO_OPERANDS: 2.251 + return visitor.visitNoOperands(this, p); 2.252 + 2.253 + case ATYPE: 2.254 + return visitor.visitArrayType( 2.255 + this, TypeKind.get(getUnsignedByte(1)), p); 2.256 + 2.257 + case BRANCH: 2.258 + return visitor.visitBranch(this, getShort(1), p); 2.259 + 2.260 + case BRANCH_W: 2.261 + return visitor.visitBranch(this, getInt(1), p); 2.262 + 2.263 + case BYTE: 2.264 + return visitor.visitValue(this, getByte(1), p); 2.265 + 2.266 + case CPREF: 2.267 + return visitor.visitConstantPoolRef(this, getUnsignedByte(1), p); 2.268 + 2.269 + case CPREF_W: 2.270 + return visitor.visitConstantPoolRef(this, getUnsignedShort(1), p); 2.271 + 2.272 + case CPREF_W_UBYTE: 2.273 + case CPREF_W_UBYTE_ZERO: 2.274 + return visitor.visitConstantPoolRefAndValue( 2.275 + this, getUnsignedShort(1), getUnsignedByte(3), p); 2.276 + 2.277 + case DYNAMIC: { 2.278 + switch (getOpcode()) { 2.279 + case TABLESWITCH: { 2.280 + int pad = align(pc + 1) - pc; 2.281 + int default_ = getInt(pad); 2.282 + int low = getInt(pad + 4); 2.283 + int high = getInt(pad + 8); 2.284 + int[] values = new int[high - low + 1]; 2.285 + for (int i = 0; i < values.length; i++) 2.286 + values[i] = getInt(pad + 12 + 4 * i); 2.287 + return visitor.visitTableSwitch( 2.288 + this, default_, low, high, values); 2.289 + } 2.290 + case LOOKUPSWITCH: { 2.291 + int pad = align(pc + 1) - pc; 2.292 + int default_ = getInt(pad); 2.293 + int npairs = getInt(pad + 4); 2.294 + int[] matches = new int[npairs]; 2.295 + int[] offsets = new int[npairs]; 2.296 + for (int i = 0; i < npairs; i++) { 2.297 + matches[i] = getInt(pad + 8 + i * 8); 2.298 + offsets[i] = getInt(pad + 12 + i * 8); 2.299 + } 2.300 + return visitor.visitLookupSwitch( 2.301 + this, default_, npairs, matches, offsets); 2.302 + } 2.303 + default: 2.304 + throw new IllegalStateException(); 2.305 + } 2.306 + } 2.307 + 2.308 + case LOCAL: 2.309 + return visitor.visitLocal(this, getUnsignedByte(1), p); 2.310 + 2.311 + case LOCAL_BYTE: 2.312 + return visitor.visitLocalAndValue( 2.313 + this, getUnsignedByte(1), getByte(2), p); 2.314 + 2.315 + case SHORT: 2.316 + return visitor.visitValue(this, getShort(1), p); 2.317 + 2.318 + case WIDE_NO_OPERANDS: 2.319 + return visitor.visitNoOperands(this, p); 2.320 + 2.321 + case WIDE_CPREF_W: 2.322 + return visitor.visitConstantPoolRef(this, getUnsignedShort(2), p); 2.323 + 2.324 + case WIDE_CPREF_W_SHORT: 2.325 + return visitor.visitConstantPoolRefAndValue( 2.326 + this, getUnsignedShort(2), getUnsignedByte(4), p); 2.327 + 2.328 + case UNKNOWN: 2.329 + return visitor.visitUnknown(this, p); 2.330 + 2.331 + default: 2.332 + throw new IllegalStateException(); 2.333 + } 2.334 + } 2.335 + 2.336 + private static int align(int n) { 2.337 + return (n + 3) & ~3; 2.338 + } 2.339 + 2.340 + private byte[] bytes; 2.341 + private int pc; 2.342 +}
3.1 --- a/src/share/classes/com/sun/tools/classfile/OpCodes.java Wed Mar 25 10:29:28 2009 +0000 3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 3.3 @@ -1,868 +0,0 @@ 3.4 -/* 3.5 - * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. 3.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.7 - * 3.8 - * This code is free software; you can redistribute it and/or modify it 3.9 - * under the terms of the GNU General Public License version 2 only, as 3.10 - * published by the Free Software Foundation. Sun designates this 3.11 - * particular file as subject to the "Classpath" exception as provided 3.12 - * by Sun in the LICENSE file that accompanied this code. 3.13 - * 3.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 3.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3.17 - * version 2 for more details (a copy is included in the LICENSE file that 3.18 - * accompanied this code). 3.19 - * 3.20 - * You should have received a copy of the GNU General Public License version 3.21 - * 2 along with this work; if not, write to the Free Software Foundation, 3.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3.23 - * 3.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 3.25 - * CA 95054 USA or visit www.sun.com if you need additional information or 3.26 - * have any questions. 3.27 - */ 3.28 - 3.29 -package com.sun.tools.classfile; 3.30 - 3.31 -import java.util.HashMap; 3.32 - 3.33 -/** 3.34 - * See JVMS3, section 6. 3.35 - * 3.36 - * <p><b>This is NOT part of any API supported by Sun Microsystems. If 3.37 - * you write code that depends on this, you do so at your own risk. 3.38 - * This code and its internal interfaces are subject to change or 3.39 - * deletion without notice.</b> 3.40 - */ 3.41 -public class OpCodes { 3.42 - 3.43 - public static int opcLength(int opc) throws IllegalArgumentException { 3.44 - switch (opc >> 8) { 3.45 - case 0: 3.46 - return opcLengthsTab[opc]; 3.47 - case opc_wide: 3.48 - switch (opc & 0xFF) { 3.49 - case opc_aload: 3.50 - case opc_astore: 3.51 - case opc_fload: 3.52 - case opc_fstore: 3.53 - case opc_iload: 3.54 - case opc_istore: 3.55 - case opc_lload: 3.56 - case opc_lstore: 3.57 - case opc_dload: 3.58 - case opc_dstore: 3.59 - case opc_ret: 3.60 - return 4; 3.61 - case opc_iinc: 3.62 - return 6; 3.63 - default: 3.64 - throw new IllegalArgumentException(); 3.65 - } 3.66 - case opc_nonpriv: 3.67 - case opc_priv: 3.68 - return 2; 3.69 - default: 3.70 - throw new IllegalArgumentException(); 3.71 - } 3.72 - } 3.73 - 3.74 - public static String opcName(int opc) { 3.75 - try { 3.76 - switch (opc >> 8) { 3.77 - case 0: 3.78 - return opcNamesTab[opc]; 3.79 - case opc_wide: 3.80 - { 3.81 - String mnem = opcNamesTab[opc & 0xFF] + "_w"; 3.82 - if (mnemocodes.get(mnem) == null) { 3.83 - return null; // non-existent opcode 3.84 - } 3.85 - return mnem; 3.86 - } 3.87 - case opc_nonpriv: 3.88 - return opcExtNamesTab[opc & 0xFF]; 3.89 - case opc_priv: 3.90 - return opcPrivExtNamesTab[opc & 0xFF]; 3.91 - default: 3.92 - return null; 3.93 - } 3.94 - } catch (ArrayIndexOutOfBoundsException e) { 3.95 - switch (opc) { 3.96 - case opc_nonpriv: 3.97 - return "nonpriv"; 3.98 - case opc_priv: 3.99 - return "priv"; 3.100 - default: 3.101 - return null; 3.102 - } 3.103 - } 3.104 - } 3.105 - 3.106 - /* Opcodes */ 3.107 - public static final int opc_dead = -2; 3.108 - public static final int opc_label = -1; 3.109 - public static final int opc_nop = 0; 3.110 - public static final int opc_aconst_null = 1; 3.111 - public static final int opc_iconst_m1 = 2; 3.112 - public static final int opc_iconst_0 = 3; 3.113 - public static final int opc_iconst_1 = 4; 3.114 - public static final int opc_iconst_2 = 5; 3.115 - public static final int opc_iconst_3 = 6; 3.116 - public static final int opc_iconst_4 = 7; 3.117 - public static final int opc_iconst_5 = 8; 3.118 - public static final int opc_lconst_0 = 9; 3.119 - public static final int opc_lconst_1 = 10; 3.120 - public static final int opc_fconst_0 = 11; 3.121 - public static final int opc_fconst_1 = 12; 3.122 - public static final int opc_fconst_2 = 13; 3.123 - public static final int opc_dconst_0 = 14; 3.124 - public static final int opc_dconst_1 = 15; 3.125 - public static final int opc_bipush = 16; 3.126 - public static final int opc_sipush = 17; 3.127 - public static final int opc_ldc = 18; 3.128 - public static final int opc_ldc_w = 19; 3.129 - public static final int opc_ldc2_w = 20; 3.130 - public static final int opc_iload = 21; 3.131 - public static final int opc_lload = 22; 3.132 - public static final int opc_fload = 23; 3.133 - public static final int opc_dload = 24; 3.134 - public static final int opc_aload = 25; 3.135 - public static final int opc_iload_0 = 26; 3.136 - public static final int opc_iload_1 = 27; 3.137 - public static final int opc_iload_2 = 28; 3.138 - public static final int opc_iload_3 = 29; 3.139 - public static final int opc_lload_0 = 30; 3.140 - public static final int opc_lload_1 = 31; 3.141 - public static final int opc_lload_2 = 32; 3.142 - public static final int opc_lload_3 = 33; 3.143 - public static final int opc_fload_0 = 34; 3.144 - public static final int opc_fload_1 = 35; 3.145 - public static final int opc_fload_2 = 36; 3.146 - public static final int opc_fload_3 = 37; 3.147 - public static final int opc_dload_0 = 38; 3.148 - public static final int opc_dload_1 = 39; 3.149 - public static final int opc_dload_2 = 40; 3.150 - public static final int opc_dload_3 = 41; 3.151 - public static final int opc_aload_0 = 42; 3.152 - public static final int opc_aload_1 = 43; 3.153 - public static final int opc_aload_2 = 44; 3.154 - public static final int opc_aload_3 = 45; 3.155 - public static final int opc_iaload = 46; 3.156 - public static final int opc_laload = 47; 3.157 - public static final int opc_faload = 48; 3.158 - public static final int opc_daload = 49; 3.159 - public static final int opc_aaload = 50; 3.160 - public static final int opc_baload = 51; 3.161 - public static final int opc_caload = 52; 3.162 - public static final int opc_saload = 53; 3.163 - public static final int opc_istore = 54; 3.164 - public static final int opc_lstore = 55; 3.165 - public static final int opc_fstore = 56; 3.166 - public static final int opc_dstore = 57; 3.167 - public static final int opc_astore = 58; 3.168 - public static final int opc_istore_0 = 59; 3.169 - public static final int opc_istore_1 = 60; 3.170 - public static final int opc_istore_2 = 61; 3.171 - public static final int opc_istore_3 = 62; 3.172 - public static final int opc_lstore_0 = 63; 3.173 - public static final int opc_lstore_1 = 64; 3.174 - public static final int opc_lstore_2 = 65; 3.175 - public static final int opc_lstore_3 = 66; 3.176 - public static final int opc_fstore_0 = 67; 3.177 - public static final int opc_fstore_1 = 68; 3.178 - public static final int opc_fstore_2 = 69; 3.179 - public static final int opc_fstore_3 = 70; 3.180 - public static final int opc_dstore_0 = 71; 3.181 - public static final int opc_dstore_1 = 72; 3.182 - public static final int opc_dstore_2 = 73; 3.183 - public static final int opc_dstore_3 = 74; 3.184 - public static final int opc_astore_0 = 75; 3.185 - public static final int opc_astore_1 = 76; 3.186 - public static final int opc_astore_2 = 77; 3.187 - public static final int opc_astore_3 = 78; 3.188 - public static final int opc_iastore = 79; 3.189 - public static final int opc_lastore = 80; 3.190 - public static final int opc_fastore = 81; 3.191 - public static final int opc_dastore = 82; 3.192 - public static final int opc_aastore = 83; 3.193 - public static final int opc_bastore = 84; 3.194 - public static final int opc_castore = 85; 3.195 - public static final int opc_sastore = 86; 3.196 - public static final int opc_pop = 87; 3.197 - public static final int opc_pop2 = 88; 3.198 - public static final int opc_dup = 89; 3.199 - public static final int opc_dup_x1 = 90; 3.200 - public static final int opc_dup_x2 = 91; 3.201 - public static final int opc_dup2 = 92; 3.202 - public static final int opc_dup2_x1 = 93; 3.203 - public static final int opc_dup2_x2 = 94; 3.204 - public static final int opc_swap = 95; 3.205 - public static final int opc_iadd = 96; 3.206 - public static final int opc_ladd = 97; 3.207 - public static final int opc_fadd = 98; 3.208 - public static final int opc_dadd = 99; 3.209 - public static final int opc_isub = 100; 3.210 - public static final int opc_lsub = 101; 3.211 - public static final int opc_fsub = 102; 3.212 - public static final int opc_dsub = 103; 3.213 - public static final int opc_imul = 104; 3.214 - public static final int opc_lmul = 105; 3.215 - public static final int opc_fmul = 106; 3.216 - public static final int opc_dmul = 107; 3.217 - public static final int opc_idiv = 108; 3.218 - public static final int opc_ldiv = 109; 3.219 - public static final int opc_fdiv = 110; 3.220 - public static final int opc_ddiv = 111; 3.221 - public static final int opc_irem = 112; 3.222 - public static final int opc_lrem = 113; 3.223 - public static final int opc_frem = 114; 3.224 - public static final int opc_drem = 115; 3.225 - public static final int opc_ineg = 116; 3.226 - public static final int opc_lneg = 117; 3.227 - public static final int opc_fneg = 118; 3.228 - public static final int opc_dneg = 119; 3.229 - public static final int opc_ishl = 120; 3.230 - public static final int opc_lshl = 121; 3.231 - public static final int opc_ishr = 122; 3.232 - public static final int opc_lshr = 123; 3.233 - public static final int opc_iushr = 124; 3.234 - public static final int opc_lushr = 125; 3.235 - public static final int opc_iand = 126; 3.236 - public static final int opc_land = 127; 3.237 - public static final int opc_ior = 128; 3.238 - public static final int opc_lor = 129; 3.239 - public static final int opc_ixor = 130; 3.240 - public static final int opc_lxor = 131; 3.241 - public static final int opc_iinc = 132; 3.242 - public static final int opc_i2l = 133; 3.243 - public static final int opc_i2f = 134; 3.244 - public static final int opc_i2d = 135; 3.245 - public static final int opc_l2i = 136; 3.246 - public static final int opc_l2f = 137; 3.247 - public static final int opc_l2d = 138; 3.248 - public static final int opc_f2i = 139; 3.249 - public static final int opc_f2l = 140; 3.250 - public static final int opc_f2d = 141; 3.251 - public static final int opc_d2i = 142; 3.252 - public static final int opc_d2l = 143; 3.253 - public static final int opc_d2f = 144; 3.254 - public static final int opc_i2b = 145; 3.255 - public static final int opc_int2byte = 145; 3.256 - public static final int opc_i2c = 146; 3.257 - public static final int opc_int2char = 146; 3.258 - public static final int opc_i2s = 147; 3.259 - public static final int opc_int2short = 147; 3.260 - public static final int opc_lcmp = 148; 3.261 - public static final int opc_fcmpl = 149; 3.262 - public static final int opc_fcmpg = 150; 3.263 - public static final int opc_dcmpl = 151; 3.264 - public static final int opc_dcmpg = 152; 3.265 - public static final int opc_ifeq = 153; 3.266 - public static final int opc_ifne = 154; 3.267 - public static final int opc_iflt = 155; 3.268 - public static final int opc_ifge = 156; 3.269 - public static final int opc_ifgt = 157; 3.270 - public static final int opc_ifle = 158; 3.271 - public static final int opc_if_icmpeq = 159; 3.272 - public static final int opc_if_icmpne = 160; 3.273 - public static final int opc_if_icmplt = 161; 3.274 - public static final int opc_if_icmpge = 162; 3.275 - public static final int opc_if_icmpgt = 163; 3.276 - public static final int opc_if_icmple = 164; 3.277 - public static final int opc_if_acmpeq = 165; 3.278 - public static final int opc_if_acmpne = 166; 3.279 - public static final int opc_goto = 167; 3.280 - public static final int opc_jsr = 168; 3.281 - public static final int opc_ret = 169; 3.282 - public static final int opc_tableswitch = 170; 3.283 - public static final int opc_lookupswitch = 171; 3.284 - public static final int opc_ireturn = 172; 3.285 - public static final int opc_lreturn = 173; 3.286 - public static final int opc_freturn = 174; 3.287 - public static final int opc_dreturn = 175; 3.288 - public static final int opc_areturn = 176; 3.289 - public static final int opc_return = 177; 3.290 - public static final int opc_getstatic = 178; 3.291 - public static final int opc_putstatic = 179; 3.292 - public static final int opc_getfield = 180; 3.293 - public static final int opc_putfield = 181; 3.294 - public static final int opc_invokevirtual = 182; 3.295 - public static final int opc_invokenonvirtual = 183; 3.296 - public static final int opc_invokespecial = 183; 3.297 - public static final int opc_invokestatic = 184; 3.298 - public static final int opc_invokeinterface = 185; 3.299 -// public static final int opc_xxxunusedxxx = 186; 3.300 - public static final int opc_new = 187; 3.301 - public static final int opc_newarray = 188; 3.302 - public static final int opc_anewarray = 189; 3.303 - public static final int opc_arraylength = 190; 3.304 - public static final int opc_athrow = 191; 3.305 - public static final int opc_checkcast = 192; 3.306 - public static final int opc_instanceof = 193; 3.307 - public static final int opc_monitorenter = 194; 3.308 - public static final int opc_monitorexit = 195; 3.309 - public static final int opc_wide = 196; 3.310 - public static final int opc_multianewarray = 197; 3.311 - public static final int opc_ifnull = 198; 3.312 - public static final int opc_ifnonnull = 199; 3.313 - public static final int opc_goto_w = 200; 3.314 - public static final int opc_jsr_w = 201; 3.315 - 3.316 - /* Pseudo-instructions */ 3.317 - public static final int opc_bytecode = 203; 3.318 - public static final int opc_try = 204; 3.319 - public static final int opc_endtry = 205; 3.320 - public static final int opc_catch = 206; 3.321 - public static final int opc_var = 207; 3.322 - public static final int opc_endvar = 208; 3.323 - public static final int opc_localsmap = 209; 3.324 - public static final int opc_stackmap = 210; 3.325 - 3.326 - /* PicoJava prefixes */ 3.327 - public static final int opc_nonpriv = 254; 3.328 - public static final int opc_priv = 255; 3.329 - 3.330 - /* Wide instructions */ 3.331 - public static final int opc_iload_w = (opc_wide << 8 ) | opc_iload; 3.332 - public static final int opc_lload_w = (opc_wide << 8 ) | opc_lload; 3.333 - public static final int opc_fload_w = (opc_wide << 8 ) | opc_fload; 3.334 - public static final int opc_dload_w = (opc_wide << 8 ) | opc_dload; 3.335 - public static final int opc_aload_w = (opc_wide << 8 ) | opc_aload; 3.336 - public static final int opc_istore_w = (opc_wide << 8 ) | opc_istore; 3.337 - public static final int opc_lstore_w = (opc_wide << 8 ) | opc_lstore; 3.338 - public static final int opc_fstore_w = (opc_wide << 8 ) | opc_fstore; 3.339 - public static final int opc_dstore_w = (opc_wide << 8 ) | opc_dstore; 3.340 - public static final int opc_astore_w = (opc_wide << 8 ) | opc_astore; 3.341 - public static final int opc_ret_w = (opc_wide << 8 ) | opc_ret; 3.342 - public static final int opc_iinc_w = (opc_wide << 8 ) | opc_iinc; 3.343 - 3.344 - /* Opcode Names */ 3.345 - private static final String opcNamesTab[] = { 3.346 - "nop", 3.347 - "aconst_null", 3.348 - "iconst_m1", 3.349 - "iconst_0", 3.350 - "iconst_1", 3.351 - "iconst_2", 3.352 - "iconst_3", 3.353 - "iconst_4", 3.354 - "iconst_5", 3.355 - "lconst_0", 3.356 - "lconst_1", 3.357 - "fconst_0", 3.358 - "fconst_1", 3.359 - "fconst_2", 3.360 - "dconst_0", 3.361 - "dconst_1", 3.362 - "bipush", 3.363 - "sipush", 3.364 - "ldc", 3.365 - "ldc_w", 3.366 - "ldc2_w", 3.367 - "iload", 3.368 - "lload", 3.369 - "fload", 3.370 - "dload", 3.371 - "aload", 3.372 - "iload_0", 3.373 - "iload_1", 3.374 - "iload_2", 3.375 - "iload_3", 3.376 - "lload_0", 3.377 - "lload_1", 3.378 - "lload_2", 3.379 - "lload_3", 3.380 - "fload_0", 3.381 - "fload_1", 3.382 - "fload_2", 3.383 - "fload_3", 3.384 - "dload_0", 3.385 - "dload_1", 3.386 - "dload_2", 3.387 - "dload_3", 3.388 - "aload_0", 3.389 - "aload_1", 3.390 - "aload_2", 3.391 - "aload_3", 3.392 - "iaload", 3.393 - "laload", 3.394 - "faload", 3.395 - "daload", 3.396 - "aaload", 3.397 - "baload", 3.398 - "caload", 3.399 - "saload", 3.400 - "istore", 3.401 - "lstore", 3.402 - "fstore", 3.403 - "dstore", 3.404 - "astore", 3.405 - "istore_0", 3.406 - "istore_1", 3.407 - "istore_2", 3.408 - "istore_3", 3.409 - "lstore_0", 3.410 - "lstore_1", 3.411 - "lstore_2", 3.412 - "lstore_3", 3.413 - "fstore_0", 3.414 - "fstore_1", 3.415 - "fstore_2", 3.416 - "fstore_3", 3.417 - "dstore_0", 3.418 - "dstore_1", 3.419 - "dstore_2", 3.420 - "dstore_3", 3.421 - "astore_0", 3.422 - "astore_1", 3.423 - "astore_2", 3.424 - "astore_3", 3.425 - "iastore", 3.426 - "lastore", 3.427 - "fastore", 3.428 - "dastore", 3.429 - "aastore", 3.430 - "bastore", 3.431 - "castore", 3.432 - "sastore", 3.433 - "pop", 3.434 - "pop2", 3.435 - "dup", 3.436 - "dup_x1", 3.437 - "dup_x2", 3.438 - "dup2", 3.439 - "dup2_x1", 3.440 - "dup2_x2", 3.441 - "swap", 3.442 - "iadd", 3.443 - "ladd", 3.444 - "fadd", 3.445 - "dadd", 3.446 - "isub", 3.447 - "lsub", 3.448 - "fsub", 3.449 - "dsub", 3.450 - "imul", 3.451 - "lmul", 3.452 - "fmul", 3.453 - "dmul", 3.454 - "idiv", 3.455 - "ldiv", 3.456 - "fdiv", 3.457 - "ddiv", 3.458 - "irem", 3.459 - "lrem", 3.460 - "frem", 3.461 - "drem", 3.462 - "ineg", 3.463 - "lneg", 3.464 - "fneg", 3.465 - "dneg", 3.466 - "ishl", 3.467 - "lshl", 3.468 - "ishr", 3.469 - "lshr", 3.470 - "iushr", 3.471 - "lushr", 3.472 - "iand", 3.473 - "land", 3.474 - "ior", 3.475 - "lor", 3.476 - "ixor", 3.477 - "lxor", 3.478 - "iinc", 3.479 - "i2l", 3.480 - "i2f", 3.481 - "i2d", 3.482 - "l2i", 3.483 - "l2f", 3.484 - "l2d", 3.485 - "f2i", 3.486 - "f2l", 3.487 - "f2d", 3.488 - "d2i", 3.489 - "d2l", 3.490 - "d2f", 3.491 - "i2b", 3.492 - "i2c", 3.493 - "i2s", 3.494 - "lcmp", 3.495 - "fcmpl", 3.496 - "fcmpg", 3.497 - "dcmpl", 3.498 - "dcmpg", 3.499 - "ifeq", 3.500 - "ifne", 3.501 - "iflt", 3.502 - "ifge", 3.503 - "ifgt", 3.504 - "ifle", 3.505 - "if_icmpeq", 3.506 - "if_icmpne", 3.507 - "if_icmplt", 3.508 - "if_icmpge", 3.509 - "if_icmpgt", 3.510 - "if_icmple", 3.511 - "if_acmpeq", 3.512 - "if_acmpne", 3.513 - "goto", 3.514 - "jsr", 3.515 - "ret", 3.516 - "tableswitch", 3.517 - "lookupswitch", 3.518 - "ireturn", 3.519 - "lreturn", 3.520 - "freturn", 3.521 - "dreturn", 3.522 - "areturn", 3.523 - "return", 3.524 - "getstatic", 3.525 - "putstatic", 3.526 - "getfield", 3.527 - "putfield", 3.528 - "invokevirtual", 3.529 - "invokespecial", // was "invokenonvirtual", 3.530 - "invokestatic", 3.531 - "invokeinterface", 3.532 - "bytecode 186", //"xxxunusedxxx", 3.533 - "new", 3.534 - "newarray", 3.535 - "anewarray", 3.536 - "arraylength", 3.537 - "athrow", 3.538 - "checkcast", 3.539 - "instanceof", 3.540 - "monitorenter", 3.541 - "monitorexit", 3.542 - null, // "wide", 3.543 - "multianewarray", 3.544 - "ifnull", 3.545 - "ifnonnull", 3.546 - "goto_w", 3.547 - "jsr_w", 3.548 - "bytecode 202", // "breakpoint", 3.549 - "bytecode", 3.550 - "try", 3.551 - "endtry", 3.552 - "catch", 3.553 - "var", 3.554 - "endvar", 3.555 - "locals_map", 3.556 - "stack_map" 3.557 - }; 3.558 - 3.559 - /* Opcode Lengths */ 3.560 - private static final int opcLengthsTab[] = { 3.561 - 1, 3.562 - 1, 3.563 - 1, 3.564 - 1, 3.565 - 1, 3.566 - 1, 3.567 - 1, 3.568 - 1, 3.569 - 1, 3.570 - 1, 3.571 - 1, 3.572 - 1, 3.573 - 1, 3.574 - 1, 3.575 - 1, 3.576 - 1, 3.577 - 2, 3.578 - 3, 3.579 - 2, 3.580 - 3, 3.581 - 3, 3.582 - 2, 3.583 - 2, 3.584 - 2, 3.585 - 2, 3.586 - 2, 3.587 - 1, 3.588 - 1, 3.589 - 1, 3.590 - 1, 3.591 - 1, 3.592 - 1, 3.593 - 1, 3.594 - 1, 3.595 - 1, 3.596 - 1, 3.597 - 1, 3.598 - 1, 3.599 - 1, 3.600 - 1, 3.601 - 1, 3.602 - 1, 3.603 - 1, 3.604 - 1, 3.605 - 1, 3.606 - 1, 3.607 - 1, 3.608 - 1, 3.609 - 1, 3.610 - 1, 3.611 - 1, 3.612 - 1, 3.613 - 1, 3.614 - 1, 3.615 - 2, 3.616 - 2, 3.617 - 2, 3.618 - 2, 3.619 - 2, 3.620 - 1, 3.621 - 1, 3.622 - 1, 3.623 - 1, 3.624 - 1, 3.625 - 1, 3.626 - 1, 3.627 - 1, 3.628 - 1, 3.629 - 1, 3.630 - 1, 3.631 - 1, 3.632 - 1, 3.633 - 1, 3.634 - 1, 3.635 - 1, 3.636 - 1, 3.637 - 1, 3.638 - 1, 3.639 - 1, 3.640 - 1, 3.641 - 1, 3.642 - 1, 3.643 - 1, 3.644 - 1, 3.645 - 1, 3.646 - 1, 3.647 - 1, 3.648 - 1, 3.649 - 1, 3.650 - 1, 3.651 - 1, 3.652 - 1, 3.653 - 1, 3.654 - 1, 3.655 - 1, 3.656 - 1, 3.657 - 1, 3.658 - 1, 3.659 - 1, 3.660 - 1, 3.661 - 1, 3.662 - 1, 3.663 - 1, 3.664 - 1, 3.665 - 1, 3.666 - 1, 3.667 - 1, 3.668 - 1, 3.669 - 1, 3.670 - 1, 3.671 - 1, 3.672 - 1, 3.673 - 1, 3.674 - 1, 3.675 - 1, 3.676 - 1, 3.677 - 1, 3.678 - 1, 3.679 - 1, 3.680 - 1, 3.681 - 1, 3.682 - 1, 3.683 - 1, 3.684 - 1, 3.685 - 1, 3.686 - 1, 3.687 - 1, 3.688 - 1, 3.689 - 1, 3.690 - 1, 3.691 - 1, 3.692 - 1, 3.693 - 3, 3.694 - 1, 3.695 - 1, 3.696 - 1, 3.697 - 1, 3.698 - 1, 3.699 - 1, 3.700 - 1, 3.701 - 1, 3.702 - 1, 3.703 - 1, 3.704 - 1, 3.705 - 1, 3.706 - 1, 3.707 - 1, 3.708 - 1, 3.709 - 1, 3.710 - 1, 3.711 - 1, 3.712 - 1, 3.713 - 1, 3.714 - 3, 3.715 - 3, 3.716 - 3, 3.717 - 3, 3.718 - 3, 3.719 - 3, 3.720 - 3, 3.721 - 3, 3.722 - 3, 3.723 - 3, 3.724 - 3, 3.725 - 3, 3.726 - 3, 3.727 - 3, 3.728 - 3, 3.729 - 3, 3.730 - 2, 3.731 - 99, 3.732 - 99, 3.733 - 1, 3.734 - 1, 3.735 - 1, 3.736 - 1, 3.737 - 1, 3.738 - 1, 3.739 - 3, 3.740 - 3, 3.741 - 3, 3.742 - 3, 3.743 - 3, 3.744 - 3, 3.745 - 3, 3.746 - 5, 3.747 - 0, 3.748 - 3, 3.749 - 2, 3.750 - 3, 3.751 - 1, 3.752 - 1, 3.753 - 3, 3.754 - 3, 3.755 - 1, 3.756 - 1, 3.757 - 0, // wide 3.758 - 4, 3.759 - 3, 3.760 - 3, 3.761 - 5, 3.762 - 5, 3.763 - 1, 3.764 - 1, 0, 0, 0, 0, 0 // pseudo 3.765 - }; 3.766 - 3.767 - /* Type codes, used in newarray opcode */ 3.768 - public static final int T_CLASS = 0x00000002; 3.769 - public static final int T_BOOLEAN = 0x00000004; 3.770 - public static final int T_CHAR = 0x00000005; 3.771 - public static final int T_FLOAT = 0x00000006; 3.772 - public static final int T_DOUBLE = 0x00000007; 3.773 - public static final int T_BYTE = 0x00000008; 3.774 - public static final int T_SHORT = 0x00000009; 3.775 - public static final int T_INT = 0x0000000a; 3.776 - public static final int T_LONG = 0x0000000b; 3.777 - 3.778 - private static HashMap<String,Integer> mnemocodes = new HashMap<String,Integer>(301, 0.5f); 3.779 - private static String opcExtNamesTab[]=new String[128]; 3.780 - private static String opcPrivExtNamesTab[]=new String[128]; 3.781 - 3.782 - private static void defineNonPriv(int opc, String mnem) { 3.783 - mnemocodes.put(opcExtNamesTab[opc] = mnem, opc_nonpriv * 256 + opc); 3.784 - } 3.785 - 3.786 - private static void definePriv(int opc, String mnem) { 3.787 - mnemocodes.put(opcPrivExtNamesTab[opc] = "priv_" + mnem, opc_priv * 256 + opc); 3.788 - } 3.789 - 3.790 - private static void defineExt(int opc, String mnem) { 3.791 - defineNonPriv(opc, mnem); 3.792 - definePriv(opc, mnem); 3.793 - } 3.794 - 3.795 - static { 3.796 - for (int i = 0; i < opc_wide; i++) { 3.797 - mnemocodes.put(opcNamesTab[i], i); 3.798 - } 3.799 - for (int i = opc_wide + 1; i < opcNamesTab.length; i++) { 3.800 - mnemocodes.put(opcNamesTab[i], i); 3.801 - } 3.802 - mnemocodes.put("invokenonvirtual", opc_invokespecial); 3.803 - 3.804 - mnemocodes.put("iload_w", opc_iload_w); 3.805 - mnemocodes.put("lload_w", opc_lload_w); 3.806 - mnemocodes.put("fload_w", opc_fload_w); 3.807 - mnemocodes.put("dload_w", opc_dload_w); 3.808 - mnemocodes.put("aload_w", opc_aload_w); 3.809 - mnemocodes.put("istore_w", opc_istore_w); 3.810 - mnemocodes.put("lstore_w", opc_lstore_w); 3.811 - mnemocodes.put("fstore_w", opc_fstore_w); 3.812 - mnemocodes.put("dstore_w", opc_dstore_w); 3.813 - mnemocodes.put("astore_w", opc_astore_w); 3.814 - mnemocodes.put("ret_w", opc_ret_w); 3.815 - mnemocodes.put("iinc_w", opc_iinc_w); 3.816 - 3.817 - mnemocodes.put("nonpriv", opc_nonpriv); 3.818 - mnemocodes.put("priv", opc_priv); 3.819 - 3.820 - defineExt(0, "load_ubyte"); 3.821 - defineExt(1, "load_byte"); 3.822 - defineExt(2, "load_char"); 3.823 - defineExt(3, "load_short"); 3.824 - defineExt(4, "load_word"); 3.825 - defineExt(10, "load_char_oe"); 3.826 - defineExt(11, "load_short_oe"); 3.827 - defineExt(12, "load_word_oe"); 3.828 - defineExt(16, "ncload_ubyte"); 3.829 - defineExt(17, "ncload_byte"); 3.830 - defineExt(18, "ncload_char"); 3.831 - defineExt(19, "ncload_short"); 3.832 - defineExt(20, "ncload_word"); 3.833 - defineExt(26, "ncload_char_oe"); 3.834 - defineExt(27, "ncload_short_oe"); 3.835 - defineExt(28, "ncload_word_oe"); 3.836 - defineExt(30, "cache_flush"); 3.837 - defineExt(32, "store_byte"); 3.838 - defineExt(34, "store_short"); 3.839 - defineExt(36, "store_word"); 3.840 - defineExt(42, "store_short_oe"); 3.841 - defineExt(44, "store_word_oe"); 3.842 - defineExt(48, "ncstore_byte"); 3.843 - defineExt(50, "ncstore_short"); 3.844 - defineExt(52, "ncstore_word"); 3.845 - defineExt(58, "ncstore_short_oe"); 3.846 - defineExt(60, "ncstore_word_oe"); 3.847 - defineExt(62, "zero_line"); 3.848 - defineNonPriv(5, "ret_from_sub"); 3.849 - defineNonPriv(63, "enter_sync_method"); 3.850 - definePriv(5, "ret_from_trap"); 3.851 - definePriv(6, "read_dcache_tag"); 3.852 - definePriv(7, "read_dcache_data"); 3.853 - definePriv(14, "read_icache_tag"); 3.854 - definePriv(15, "read_icache_data"); 3.855 - definePriv(22, "powerdown"); 3.856 - definePriv(23, "read_scache_data"); 3.857 - definePriv(31, "cache_index_flush"); 3.858 - definePriv(38, "write_dcache_tag"); 3.859 - definePriv(39, "write_dcache_data"); 3.860 - definePriv(46, "write_icache_tag"); 3.861 - definePriv(47, "write_icache_data"); 3.862 - definePriv(54, "reset"); 3.863 - definePriv(55, "write_scache_data"); 3.864 - for (int i = 0; i < 32; i++) { 3.865 - definePriv(i + 64, "read_reg_" + i); 3.866 - } 3.867 - for (int i = 0; i < 32; i++) { 3.868 - definePriv(i + 96, "write_reg_" + i); 3.869 - } 3.870 - } 3.871 -}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/src/share/classes/com/sun/tools/classfile/Opcode.java Mon Mar 30 15:08:09 2009 -0700 4.3 @@ -0,0 +1,472 @@ 4.4 +/* 4.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.7 + * 4.8 + * This code is free software; you can redistribute it and/or modify it 4.9 + * under the terms of the GNU General Public License version 2 only, as 4.10 + * published by the Free Software Foundation. Sun designates this 4.11 + * particular file as subject to the "Classpath" exception as provided 4.12 + * by Sun in the LICENSE file that accompanied this code. 4.13 + * 4.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 4.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4.17 + * version 2 for more details (a copy is included in the LICENSE file that 4.18 + * accompanied this code). 4.19 + * 4.20 + * You should have received a copy of the GNU General Public License version 4.21 + * 2 along with this work; if not, write to the Free Software Foundation, 4.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4.23 + * 4.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 4.25 + * CA 95054 USA or visit www.sun.com if you need additional information or 4.26 + * have any questions. 4.27 + */ 4.28 + 4.29 +package com.sun.tools.classfile; 4.30 + 4.31 +import static com.sun.tools.classfile.Instruction.Kind.*; 4.32 +import static com.sun.tools.classfile.Opcode.Set.*; 4.33 + 4.34 +/** 4.35 + * See JVMS3, chapter 6. 4.36 + * 4.37 + * <p>In addition to providing all the standard opcodes defined in JVMS, 4.38 + * this class also provides legacy support for the PicoJava extensions. 4.39 + * 4.40 + * <p><b>This is NOT part of any API supported by Sun Microsystems. If 4.41 + * you write code that depends on this, you do so at your own risk. 4.42 + * This code and its internal interfaces are subject to change or 4.43 + * deletion without notice.</b> 4.44 + */ 4.45 +public enum Opcode { 4.46 + NOP(0x0), 4.47 + ACONST_NULL(0x1), 4.48 + ICONST_M1(0x2), 4.49 + ICONST_0(0x3), 4.50 + ICONST_1(0x4), 4.51 + ICONST_2(0x5), 4.52 + ICONST_3(0x6), 4.53 + ICONST_4(0x7), 4.54 + ICONST_5(0x8), 4.55 + LCONST_0(0x9), 4.56 + LCONST_1(0xa), 4.57 + FCONST_0(0xb), 4.58 + FCONST_1(0xc), 4.59 + FCONST_2(0xd), 4.60 + DCONST_0(0xe), 4.61 + DCONST_1(0xf), 4.62 + BIPUSH(0x10, BYTE), 4.63 + SIPUSH(0x11, SHORT), 4.64 + LDC(0x12, CPREF), 4.65 + LDC_W(0x13, CPREF_W), 4.66 + LDC2_W(0x14, CPREF_W), 4.67 + ILOAD(0x15, LOCAL), 4.68 + LLOAD(0x16, LOCAL), 4.69 + FLOAD(0x17, LOCAL), 4.70 + DLOAD(0x18, LOCAL), 4.71 + ALOAD(0x19, LOCAL), 4.72 + ILOAD_0(0x1a), 4.73 + ILOAD_1(0x1b), 4.74 + ILOAD_2(0x1c), 4.75 + ILOAD_3(0x1d), 4.76 + LLOAD_0(0x1e), 4.77 + LLOAD_1(0x1f), 4.78 + LLOAD_2(0x20), 4.79 + LLOAD_3(0x21), 4.80 + FLOAD_0(0x22), 4.81 + FLOAD_1(0x23), 4.82 + FLOAD_2(0x24), 4.83 + FLOAD_3(0x25), 4.84 + DLOAD_0(0x26), 4.85 + DLOAD_1(0x27), 4.86 + DLOAD_2(0x28), 4.87 + DLOAD_3(0x29), 4.88 + ALOAD_0(0x2a), 4.89 + ALOAD_1(0x2b), 4.90 + ALOAD_2(0x2c), 4.91 + ALOAD_3(0x2d), 4.92 + IALOAD(0x2e), 4.93 + LALOAD(0x2f), 4.94 + FALOAD(0x30), 4.95 + DALOAD(0x31), 4.96 + AALOAD(0x32), 4.97 + BALOAD(0x33), 4.98 + CALOAD(0x34), 4.99 + SALOAD(0x35), 4.100 + ISTORE(0x36, LOCAL), 4.101 + LSTORE(0x37, LOCAL), 4.102 + FSTORE(0x38, LOCAL), 4.103 + DSTORE(0x39, LOCAL), 4.104 + ASTORE(0x3a, LOCAL), 4.105 + ISTORE_0(0x3b), 4.106 + ISTORE_1(0x3c), 4.107 + ISTORE_2(0x3d), 4.108 + ISTORE_3(0x3e), 4.109 + LSTORE_0(0x3f), 4.110 + LSTORE_1(0x40), 4.111 + LSTORE_2(0x41), 4.112 + LSTORE_3(0x42), 4.113 + FSTORE_0(0x43), 4.114 + FSTORE_1(0x44), 4.115 + FSTORE_2(0x45), 4.116 + FSTORE_3(0x46), 4.117 + DSTORE_0(0x47), 4.118 + DSTORE_1(0x48), 4.119 + DSTORE_2(0x49), 4.120 + DSTORE_3(0x4a), 4.121 + ASTORE_0(0x4b), 4.122 + ASTORE_1(0x4c), 4.123 + ASTORE_2(0x4d), 4.124 + ASTORE_3(0x4e), 4.125 + IASTORE(0x4f), 4.126 + LASTORE(0x50), 4.127 + FASTORE(0x51), 4.128 + DASTORE(0x52), 4.129 + AASTORE(0x53), 4.130 + BASTORE(0x54), 4.131 + CASTORE(0x55), 4.132 + SASTORE(0x56), 4.133 + POP(0x57), 4.134 + POP2(0x58), 4.135 + DUP(0x59), 4.136 + DUP_X1(0x5a), 4.137 + DUP_X2(0x5b), 4.138 + DUP2(0x5c), 4.139 + DUP2_X1(0x5d), 4.140 + DUP2_X2(0x5e), 4.141 + SWAP(0x5f), 4.142 + IADD(0x60), 4.143 + LADD(0x61), 4.144 + FADD(0x62), 4.145 + DADD(0x63), 4.146 + ISUB(0x64), 4.147 + LSUB(0x65), 4.148 + FSUB(0x66), 4.149 + DSUB(0x67), 4.150 + IMUL(0x68), 4.151 + LMUL(0x69), 4.152 + FMUL(0x6a), 4.153 + DMUL(0x6b), 4.154 + IDIV(0x6c), 4.155 + LDIV(0x6d), 4.156 + FDIV(0x6e), 4.157 + DDIV(0x6f), 4.158 + IREM(0x70), 4.159 + LREM(0x71), 4.160 + FREM(0x72), 4.161 + DREM(0x73), 4.162 + INEG(0x74), 4.163 + LNEG(0x75), 4.164 + FNEG(0x76), 4.165 + DNEG(0x77), 4.166 + ISHL(0x78), 4.167 + LSHL(0x79), 4.168 + ISHR(0x7a), 4.169 + LSHR(0x7b), 4.170 + IUSHR(0x7c), 4.171 + LUSHR(0x7d), 4.172 + IAND(0x7e), 4.173 + LAND(0x7f), 4.174 + IOR(0x80), 4.175 + LOR(0x81), 4.176 + IXOR(0x82), 4.177 + LXOR(0x83), 4.178 + IINC(0x84, LOCAL_BYTE), 4.179 + I2L(0x85), 4.180 + I2F(0x86), 4.181 + I2D(0x87), 4.182 + L2I(0x88), 4.183 + L2F(0x89), 4.184 + L2D(0x8a), 4.185 + F2I(0x8b), 4.186 + F2L(0x8c), 4.187 + F2D(0x8d), 4.188 + D2I(0x8e), 4.189 + D2L(0x8f), 4.190 + D2F(0x90), 4.191 + I2B(0x91), 4.192 + I2C(0x92), 4.193 + I2S(0x93), 4.194 + LCMP(0x94), 4.195 + FCMPL(0x95), 4.196 + FCMPG(0x96), 4.197 + DCMPL(0x97), 4.198 + DCMPG(0x98), 4.199 + IFEQ(0x99, BRANCH), 4.200 + IFNE(0x9a, BRANCH), 4.201 + IFLT(0x9b, BRANCH), 4.202 + IFGE(0x9c, BRANCH), 4.203 + IFGT(0x9d, BRANCH), 4.204 + IFLE(0x9e, BRANCH), 4.205 + IF_ICMPEQ(0x9f, BRANCH), 4.206 + IF_ICMPNE(0xa0, BRANCH), 4.207 + IF_ICMPLT(0xa1, BRANCH), 4.208 + IF_ICMPGE(0xa2, BRANCH), 4.209 + IF_ICMPGT(0xa3, BRANCH), 4.210 + IF_ICMPLE(0xa4, BRANCH), 4.211 + IF_ACMPEQ(0xa5, BRANCH), 4.212 + IF_ACMPNE(0xa6, BRANCH), 4.213 + GOTO(0xa7, BRANCH), 4.214 + JSR(0xa8, BRANCH), 4.215 + RET(0xa9, LOCAL), 4.216 + TABLESWITCH(0xaa, DYNAMIC), 4.217 + LOOKUPSWITCH(0xab, DYNAMIC), 4.218 + IRETURN(0xac), 4.219 + LRETURN(0xad), 4.220 + FRETURN(0xae), 4.221 + DRETURN(0xaf), 4.222 + ARETURN(0xb0), 4.223 + RETURN(0xb1), 4.224 + GETSTATIC(0xb2, CPREF_W), 4.225 + PUTSTATIC(0xb3, CPREF_W), 4.226 + GETFIELD(0xb4, CPREF_W), 4.227 + PUTFIELD(0xb5, CPREF_W), 4.228 + INVOKEVIRTUAL(0xb6, CPREF_W), 4.229 + INVOKESPECIAL(0xb7, CPREF_W), 4.230 + INVOKESTATIC(0xb8, CPREF_W), 4.231 + INVOKEINTERFACE(0xb9, CPREF_W_UBYTE_ZERO), 4.232 + // unused 0xba 4.233 + NEW(0xbb, CPREF_W), 4.234 + NEWARRAY(0xbc, ATYPE), 4.235 + ANEWARRAY(0xbd, CPREF_W), 4.236 + ARRAYLENGTH(0xbe), 4.237 + ATHROW(0xbf), 4.238 + CHECKCAST(0xc0, CPREF_W), 4.239 + INSTANCEOF(0xc1, CPREF_W), 4.240 + MONITORENTER(0xc2), 4.241 + MONITOREXIT(0xc3), 4.242 + // wide 0xc4 4.243 + MULTIANEWARRAY(0xc5, CPREF_W_UBYTE), 4.244 + IFNULL(0xc6, BRANCH), 4.245 + IFNONNULL(0xc7, BRANCH), 4.246 + GOTO_W(0xc8, BRANCH_W), 4.247 + JSR_W(0xc9, BRANCH_W), 4.248 + // impdep 0xfe: PicoJava nonpriv 4.249 + // impdep 0xff: Picojava priv 4.250 + 4.251 + // wide opcodes 4.252 + ILOAD_W(0xc415, WIDE_CPREF_W), 4.253 + LLOAD_W(0xc416, WIDE_CPREF_W), 4.254 + FLOAD_W(0xc417, WIDE_CPREF_W), 4.255 + DLOAD_W(0xc418, WIDE_CPREF_W), 4.256 + ALOAD_W(0xc419, WIDE_CPREF_W), 4.257 + ISTORE_W(0xc436, WIDE_CPREF_W), 4.258 + LSTORE_W(0xc437, WIDE_CPREF_W), 4.259 + FSTORE_W(0xc438, WIDE_CPREF_W), 4.260 + DSTORE_W(0xc439, WIDE_CPREF_W), 4.261 + ASTORE_W(0xc43a, WIDE_CPREF_W), 4.262 + IINC_W(0xc484, WIDE_CPREF_W_SHORT), 4.263 + RET_W(0xc4a9, WIDE_CPREF_W), 4.264 + 4.265 + // PicoJava nonpriv instructions 4.266 + LOAD_UBYTE(PICOJAVA, 0xfe00), 4.267 + LOAD_BYTE(PICOJAVA, 0xfe01), 4.268 + LOAD_CHAR(PICOJAVA, 0xfe02), 4.269 + LOAD_SHORT(PICOJAVA, 0xfe03), 4.270 + LOAD_WORD(PICOJAVA, 0xfe04), 4.271 + RET_FROM_SUB(PICOJAVA, 0xfe05), 4.272 + LOAD_CHAR_OE(PICOJAVA, 0xfe0a), 4.273 + LOAD_SHORT_OE(PICOJAVA, 0xfe0b), 4.274 + LOAD_WORD_OE(PICOJAVA, 0xfe0c), 4.275 + NCLOAD_UBYTE(PICOJAVA, 0xfe10), 4.276 + NCLOAD_BYTE(PICOJAVA, 0xfe11), 4.277 + NCLOAD_CHAR(PICOJAVA, 0xfe12), 4.278 + NCLOAD_SHORT(PICOJAVA, 0xfe13), 4.279 + NCLOAD_WORD(PICOJAVA, 0xfe14), 4.280 + NCLOAD_CHAR_OE(PICOJAVA, 0xfe1a), 4.281 + NCLOAD_SHORT_OE(PICOJAVA, 0xfe1b), 4.282 + NCLOAD_WORD_OE(PICOJAVA, 0xfe1c), 4.283 + CACHE_FLUSH(PICOJAVA, 0xfe1e), 4.284 + STORE_BYTE(PICOJAVA, 0xfe20), 4.285 + STORE_SHORT(PICOJAVA, 0xfe22), 4.286 + STORE_WORD(PICOJAVA, 0xfe24), 4.287 + STORE_SHORT_OE(PICOJAVA, 0xfe2a), 4.288 + STORE_WORD_OE(PICOJAVA, 0xfe2c), 4.289 + NCSTORE_BYTE(PICOJAVA, 0xfe30), 4.290 + NCSTORE_SHORT(PICOJAVA, 0xfe32), 4.291 + NCSTORE_WORD(PICOJAVA, 0xfe34), 4.292 + NCSTORE_SHORT_OE(PICOJAVA, 0xfe3a), 4.293 + NCSTORE_WORD_OE(PICOJAVA, 0xfe3c), 4.294 + ZERO_LINE(PICOJAVA, 0xfe3e), 4.295 + ENTER_SYNC_METHOD(PICOJAVA, 0xfe3f), 4.296 + 4.297 + // PicoJava priv instructions 4.298 + PRIV_LOAD_UBYTE(PICOJAVA, 0xff00), 4.299 + PRIV_LOAD_BYTE(PICOJAVA, 0xff01), 4.300 + PRIV_LOAD_CHAR(PICOJAVA, 0xff02), 4.301 + PRIV_LOAD_SHORT(PICOJAVA, 0xff03), 4.302 + PRIV_LOAD_WORD(PICOJAVA, 0xff04), 4.303 + PRIV_RET_FROM_TRAP(PICOJAVA, 0xff05), 4.304 + PRIV_READ_DCACHE_TAG(PICOJAVA, 0xff06), 4.305 + PRIV_READ_DCACHE_DATA(PICOJAVA, 0xff07), 4.306 + PRIV_LOAD_CHAR_OE(PICOJAVA, 0xff0a), 4.307 + PRIV_LOAD_SHORT_OE(PICOJAVA, 0xff0b), 4.308 + PRIV_LOAD_WORD_OE(PICOJAVA, 0xff0c), 4.309 + PRIV_READ_ICACHE_TAG(PICOJAVA, 0xff0e), 4.310 + PRIV_READ_ICACHE_DATA(PICOJAVA, 0xff0f), 4.311 + PRIV_NCLOAD_UBYTE(PICOJAVA, 0xff10), 4.312 + PRIV_NCLOAD_BYTE(PICOJAVA, 0xff11), 4.313 + PRIV_NCLOAD_CHAR(PICOJAVA, 0xff12), 4.314 + PRIV_NCLOAD_SHORT(PICOJAVA, 0xff13), 4.315 + PRIV_NCLOAD_WORD(PICOJAVA, 0xff14), 4.316 + PRIV_POWERDOWN(PICOJAVA, 0xff16), 4.317 + PRIV_READ_SCACHE_DATA(PICOJAVA, 0xff17), 4.318 + PRIV_NCLOAD_CHAR_OE(PICOJAVA, 0xff1a), 4.319 + PRIV_NCLOAD_SHORT_OE(PICOJAVA, 0xff1b), 4.320 + PRIV_NCLOAD_WORD_OE(PICOJAVA, 0xff1c), 4.321 + PRIV_CACHE_FLUSH(PICOJAVA, 0xff1e), 4.322 + PRIV_CACHE_INDEX_FLUSH(PICOJAVA, 0xff1f), 4.323 + PRIV_STORE_BYTE(PICOJAVA, 0xff20), 4.324 + PRIV_STORE_SHORT(PICOJAVA, 0xff22), 4.325 + PRIV_STORE_WORD(PICOJAVA, 0xff24), 4.326 + PRIV_WRITE_DCACHE_TAG(PICOJAVA, 0xff26), 4.327 + PRIV_WRITE_DCACHE_DATA(PICOJAVA, 0xff27), 4.328 + PRIV_STORE_SHORT_OE(PICOJAVA, 0xff2a), 4.329 + PRIV_STORE_WORD_OE(PICOJAVA, 0xff2c), 4.330 + PRIV_WRITE_ICACHE_TAG(PICOJAVA, 0xff2e), 4.331 + PRIV_WRITE_ICACHE_DATA(PICOJAVA, 0xff2f), 4.332 + PRIV_NCSTORE_BYTE(PICOJAVA, 0xff30), 4.333 + PRIV_NCSTORE_SHORT(PICOJAVA, 0xff32), 4.334 + PRIV_NCSTORE_WORD(PICOJAVA, 0xff34), 4.335 + PRIV_RESET(PICOJAVA, 0xff36), 4.336 + PRIV_WRITE_SCACHE_DATA(PICOJAVA, 0xff37), 4.337 + PRIV_NCSTORE_SHORT_OE(PICOJAVA, 0xff3a), 4.338 + PRIV_NCSTORE_WORD_OE(PICOJAVA, 0xff3c), 4.339 + PRIV_ZERO_LINE(PICOJAVA, 0xff3e), 4.340 + PRIV_READ_REG_0(PICOJAVA, 0xff40), 4.341 + PRIV_READ_REG_1(PICOJAVA, 0xff41), 4.342 + PRIV_READ_REG_2(PICOJAVA, 0xff42), 4.343 + PRIV_READ_REG_3(PICOJAVA, 0xff43), 4.344 + PRIV_READ_REG_4(PICOJAVA, 0xff44), 4.345 + PRIV_READ_REG_5(PICOJAVA, 0xff45), 4.346 + PRIV_READ_REG_6(PICOJAVA, 0xff46), 4.347 + PRIV_READ_REG_7(PICOJAVA, 0xff47), 4.348 + PRIV_READ_REG_8(PICOJAVA, 0xff48), 4.349 + PRIV_READ_REG_9(PICOJAVA, 0xff49), 4.350 + PRIV_READ_REG_10(PICOJAVA, 0xff4a), 4.351 + PRIV_READ_REG_11(PICOJAVA, 0xff4b), 4.352 + PRIV_READ_REG_12(PICOJAVA, 0xff4c), 4.353 + PRIV_READ_REG_13(PICOJAVA, 0xff4d), 4.354 + PRIV_READ_REG_14(PICOJAVA, 0xff4e), 4.355 + PRIV_READ_REG_15(PICOJAVA, 0xff4f), 4.356 + PRIV_READ_REG_16(PICOJAVA, 0xff50), 4.357 + PRIV_READ_REG_17(PICOJAVA, 0xff51), 4.358 + PRIV_READ_REG_18(PICOJAVA, 0xff52), 4.359 + PRIV_READ_REG_19(PICOJAVA, 0xff53), 4.360 + PRIV_READ_REG_20(PICOJAVA, 0xff54), 4.361 + PRIV_READ_REG_21(PICOJAVA, 0xff55), 4.362 + PRIV_READ_REG_22(PICOJAVA, 0xff56), 4.363 + PRIV_READ_REG_23(PICOJAVA, 0xff57), 4.364 + PRIV_READ_REG_24(PICOJAVA, 0xff58), 4.365 + PRIV_READ_REG_25(PICOJAVA, 0xff59), 4.366 + PRIV_READ_REG_26(PICOJAVA, 0xff5a), 4.367 + PRIV_READ_REG_27(PICOJAVA, 0xff5b), 4.368 + PRIV_READ_REG_28(PICOJAVA, 0xff5c), 4.369 + PRIV_READ_REG_29(PICOJAVA, 0xff5d), 4.370 + PRIV_READ_REG_30(PICOJAVA, 0xff5e), 4.371 + PRIV_READ_REG_31(PICOJAVA, 0xff5f), 4.372 + PRIV_WRITE_REG_0(PICOJAVA, 0xff60), 4.373 + PRIV_WRITE_REG_1(PICOJAVA, 0xff61), 4.374 + PRIV_WRITE_REG_2(PICOJAVA, 0xff62), 4.375 + PRIV_WRITE_REG_3(PICOJAVA, 0xff63), 4.376 + PRIV_WRITE_REG_4(PICOJAVA, 0xff64), 4.377 + PRIV_WRITE_REG_5(PICOJAVA, 0xff65), 4.378 + PRIV_WRITE_REG_6(PICOJAVA, 0xff66), 4.379 + PRIV_WRITE_REG_7(PICOJAVA, 0xff67), 4.380 + PRIV_WRITE_REG_8(PICOJAVA, 0xff68), 4.381 + PRIV_WRITE_REG_9(PICOJAVA, 0xff69), 4.382 + PRIV_WRITE_REG_10(PICOJAVA, 0xff6a), 4.383 + PRIV_WRITE_REG_11(PICOJAVA, 0xff6b), 4.384 + PRIV_WRITE_REG_12(PICOJAVA, 0xff6c), 4.385 + PRIV_WRITE_REG_13(PICOJAVA, 0xff6d), 4.386 + PRIV_WRITE_REG_14(PICOJAVA, 0xff6e), 4.387 + PRIV_WRITE_REG_15(PICOJAVA, 0xff6f), 4.388 + PRIV_WRITE_REG_16(PICOJAVA, 0xff70), 4.389 + PRIV_WRITE_REG_17(PICOJAVA, 0xff71), 4.390 + PRIV_WRITE_REG_18(PICOJAVA, 0xff72), 4.391 + PRIV_WRITE_REG_19(PICOJAVA, 0xff73), 4.392 + PRIV_WRITE_REG_20(PICOJAVA, 0xff74), 4.393 + PRIV_WRITE_REG_21(PICOJAVA, 0xff75), 4.394 + PRIV_WRITE_REG_22(PICOJAVA, 0xff76), 4.395 + PRIV_WRITE_REG_23(PICOJAVA, 0xff77), 4.396 + PRIV_WRITE_REG_24(PICOJAVA, 0xff78), 4.397 + PRIV_WRITE_REG_25(PICOJAVA, 0xff79), 4.398 + PRIV_WRITE_REG_26(PICOJAVA, 0xff7a), 4.399 + PRIV_WRITE_REG_27(PICOJAVA, 0xff7b), 4.400 + PRIV_WRITE_REG_28(PICOJAVA, 0xff7c), 4.401 + PRIV_WRITE_REG_29(PICOJAVA, 0xff7d), 4.402 + PRIV_WRITE_REG_30(PICOJAVA, 0xff7e), 4.403 + PRIV_WRITE_REG_31(PICOJAVA, 0xff7f); 4.404 + 4.405 + Opcode(int opcode) { 4.406 + this(STANDARD, opcode, NO_OPERANDS); 4.407 + } 4.408 + 4.409 + Opcode(int opcode, Instruction.Kind kind) { 4.410 + this(STANDARD, opcode, kind); 4.411 + } 4.412 + 4.413 + Opcode(Set set, int opcode) { 4.414 + this(set, opcode, (set == STANDARD ? NO_OPERANDS : WIDE_NO_OPERANDS)); 4.415 + } 4.416 + 4.417 + Opcode(Set set, int opcode, Instruction.Kind kind) { 4.418 + this.set = set; 4.419 + this.opcode = opcode; 4.420 + this.kind = kind; 4.421 + } 4.422 + 4.423 + public final Set set; 4.424 + public final int opcode; 4.425 + public final Instruction.Kind kind; 4.426 + 4.427 + /** Get the Opcode for a simple standard 1-byte opcode. */ 4.428 + public static Opcode get(int opcode) { 4.429 + return stdOpcodes[opcode]; 4.430 + } 4.431 + 4.432 + /** Get the Opcode for 1- or 2-byte opcode. */ 4.433 + public static Opcode get(int opcodePrefix, int opcode) { 4.434 + Opcode[] block = getOpcodeBlock(opcodePrefix); 4.435 + return (block == null ? null : block[opcode]); 4.436 + } 4.437 + 4.438 + private static Opcode[] getOpcodeBlock(int opcodePrefix) { 4.439 + switch (opcodePrefix) { 4.440 + case 0: 4.441 + return stdOpcodes; 4.442 + case WIDE: 4.443 + return wideOpcodes; 4.444 + case NONPRIV: 4.445 + return nonPrivOpcodes; 4.446 + case PRIV: 4.447 + return privOpcodes; 4.448 + default: 4.449 + return null; 4.450 + } 4.451 + 4.452 + } 4.453 + 4.454 + private static Opcode[] stdOpcodes = new Opcode[256]; 4.455 + private static Opcode[] wideOpcodes = new Opcode[256]; 4.456 + private static Opcode[] nonPrivOpcodes = new Opcode[256]; 4.457 + private static Opcode[] privOpcodes = new Opcode[256]; 4.458 + static { 4.459 + for (Opcode o: values()) 4.460 + getOpcodeBlock(o.opcode >> 8)[o.opcode & 0xff] = o; 4.461 + } 4.462 + 4.463 + /** The byte prefix for the wide instructions. */ 4.464 + public static final int WIDE = 0xc4; 4.465 + /** The byte prefix for the PicoJava nonpriv instructions. */ 4.466 + public static final int NONPRIV = 0xfe; 4.467 + /** The byte prefix for the PicoJava priv instructions. */ 4.468 + public static final int PRIV = 0xff; 4.469 + 4.470 + public enum Set { 4.471 + /** Standard opcodes. */ 4.472 + STANDARD, 4.473 + /** Legacy support for PicoJava opcodes. */ 4.474 + PICOJAVA }; 4.475 +}
5.1 --- a/src/share/classes/com/sun/tools/javap/CodeWriter.java Wed Mar 25 10:29:28 2009 +0000 5.2 +++ b/src/share/classes/com/sun/tools/javap/CodeWriter.java Mon Mar 30 15:08:09 2009 -0700 5.3 @@ -30,9 +30,12 @@ 5.4 import com.sun.tools.classfile.ConstantPool; 5.5 import com.sun.tools.classfile.ConstantPoolException; 5.6 import com.sun.tools.classfile.DescriptorException; 5.7 +import com.sun.tools.classfile.Instruction; 5.8 +import com.sun.tools.classfile.Instruction.TypeKind; 5.9 import com.sun.tools.classfile.Method; 5.10 +import com.sun.tools.classfile.Opcode; 5.11 5.12 -import static com.sun.tools.classfile.OpCodes.*; 5.13 +//import static com.sun.tools.classfile.OpCodes.*; 5.14 5.15 /* 5.16 * Write the contents of a Code attribute. 5.17 @@ -87,218 +90,92 @@ 5.18 } 5.19 5.20 public void writeInstrs(Code_attribute attr) { 5.21 - try { 5.22 - for (int pc = 0; pc < attr.code_length;) { 5.23 - print(" " + pc + ":\t"); 5.24 - pc += writeInstr(attr, pc); 5.25 - println(); 5.26 + for (Instruction instr: attr.getInstructions()) { 5.27 + try { 5.28 + writeInstr(instr); 5.29 + } catch (ArrayIndexOutOfBoundsException e) { 5.30 + println(report("error at or after byte " + instr.getPC())); 5.31 + break; 5.32 } 5.33 - } catch (Code_attribute.InvalidIndex e) { 5.34 - println(report(e)); 5.35 } 5.36 } 5.37 5.38 - public int writeInstr(Code_attribute attr, int pc) 5.39 - throws Code_attribute.InvalidIndex { 5.40 - String lP = ""; 5.41 - int opcode = attr.getUnsignedByte(pc); 5.42 - int opcode2; 5.43 - String mnem; 5.44 - switch (opcode) { 5.45 - case opc_nonpriv: 5.46 - case opc_priv: { 5.47 - opcode2 = attr.getUnsignedByte(pc + 1); 5.48 - mnem = opcName((opcode << 8) + opcode2); 5.49 - if (mnem == null) { 5.50 - mnem = opcName(opcode) + " " + opcode2; 5.51 - } 5.52 - print(mnem); 5.53 - return 2; 5.54 + public void writeInstr(Instruction instr) { 5.55 + print(" " + instr.getPC() + ":\t"); 5.56 + print(instr.getMnemonic()); 5.57 + instr.accept(instructionPrinter, null); 5.58 + println(); 5.59 + } 5.60 + // where 5.61 + Instruction.KindVisitor<Void,Void> instructionPrinter = 5.62 + new Instruction.KindVisitor<Void,Void>() { 5.63 + 5.64 + public Void visitNoOperands(Instruction instr, Void p) { 5.65 + return null; 5.66 + } 5.67 + 5.68 + public Void visitArrayType(Instruction instr, TypeKind kind, Void p) { 5.69 + print(" " + kind.name); 5.70 + return null; 5.71 + } 5.72 + 5.73 + public Void visitBranch(Instruction instr, int offset, Void p) { 5.74 + print("\t" + (instr.getPC() + offset)); 5.75 + return null; 5.76 + } 5.77 + 5.78 + public Void visitConstantPoolRef(Instruction instr, int index, Void p) { 5.79 + print("\t#" + index + "; //"); 5.80 + printConstant(index); 5.81 + return null; 5.82 + } 5.83 + 5.84 + public Void visitConstantPoolRefAndValue(Instruction instr, int index, int value, Void p) { 5.85 + print("\t#" + index + ", " + value + "; //"); 5.86 + printConstant(index); 5.87 + return null; 5.88 + } 5.89 + 5.90 + public Void visitLocal(Instruction instr, int index, Void p) { 5.91 + print("\t" + index); 5.92 + return null; 5.93 + } 5.94 + 5.95 + public Void visitLocalAndValue(Instruction instr, int index, int value, Void p) { 5.96 + print("\t" + index + ", " + value); 5.97 + return null; 5.98 + } 5.99 + 5.100 + public Void visitLookupSwitch(Instruction instr, int default_, int npairs, int[] matches, int[] offsets) { 5.101 + int pc = instr.getPC(); 5.102 + print("{ //" + npairs); 5.103 + for (int i = 0; i < npairs; i++) { 5.104 + print("\n\t\t" + matches[i] + ": " + (pc + offsets[i]) + ";"); 5.105 } 5.106 - case opc_wide: { 5.107 - opcode2 = attr.getUnsignedByte(pc + 1); 5.108 - mnem = opcName((opcode << 8) + opcode2); 5.109 - if (mnem == null) { 5.110 - print("bytecode " + opcode); 5.111 - return 1; 5.112 - } 5.113 - print(mnem + " " + attr.getUnsignedShort(pc + 2)); 5.114 - if (opcode2 == opc_iinc) { 5.115 - print(", " + attr.getShort(pc + 4)); 5.116 - return 6; 5.117 - } 5.118 - return 4; 5.119 + print("\n\t\tdefault: " + (pc + default_) + " }"); 5.120 + return null; 5.121 + } 5.122 + 5.123 + public Void visitTableSwitch(Instruction instr, int default_, int low, int high, int[] offsets) { 5.124 + int pc = instr.getPC(); 5.125 + print("{ //" + low + " to " + high); 5.126 + for (int i = 0; i < offsets.length; i++) { 5.127 + print("\n\t\t" + (low + i) + ": " + (pc + offsets[i]) + ";"); 5.128 } 5.129 + print("\n\t\tdefault: " + (pc + default_) + " }"); 5.130 + return null; 5.131 } 5.132 - mnem = opcName(opcode); 5.133 - if (mnem == null) { 5.134 - print("bytecode " + opcode); 5.135 - return 1; 5.136 + 5.137 + public Void visitValue(Instruction instr, int value, Void p) { 5.138 + print("\t" + value); 5.139 + return null; 5.140 } 5.141 - if (opcode > opc_jsr_w) { 5.142 - print("bytecode " + opcode); 5.143 - return 1; 5.144 + 5.145 + public Void visitUnknown(Instruction instr, Void p) { 5.146 + return null; 5.147 } 5.148 - print(opcName(opcode)); 5.149 - switch (opcode) { 5.150 - case opc_aload: 5.151 - case opc_astore: 5.152 - case opc_fload: 5.153 - case opc_fstore: 5.154 - case opc_iload: 5.155 - case opc_istore: 5.156 - case opc_lload: 5.157 - case opc_lstore: 5.158 - case opc_dload: 5.159 - case opc_dstore: 5.160 - case opc_ret: 5.161 - print("\t" + attr.getUnsignedByte(pc + 1)); 5.162 - return 2; 5.163 - case opc_iinc: 5.164 - print("\t" + attr.getUnsignedByte(pc + 1) + ", " + attr.getByte(pc + 2)); 5.165 - return 3; 5.166 - case opc_tableswitch: 5.167 - { 5.168 - int tb = align(pc + 1); 5.169 - int default_skip = attr.getInt(tb); 5.170 - int low = attr.getInt(tb + 4); 5.171 - int high = attr.getInt(tb + 8); 5.172 - int count = high - low; 5.173 - print("{ //" + low + " to " + high); 5.174 - for (int i = 0; i <= count; i++) { 5.175 - print("\n\t\t" + (i + low) + ": " + lP + (pc + attr.getInt(tb + 12 + 4 * i)) + ";"); 5.176 - } 5.177 - print("\n\t\tdefault: " + lP + (default_skip + pc) + " }"); 5.178 - return tb - pc + 16 + count * 4; 5.179 - } 5.180 - case opc_lookupswitch: 5.181 - { 5.182 - int tb = align(pc + 1); 5.183 - int default_skip = attr.getInt(tb); 5.184 - int npairs = attr.getInt(tb + 4); 5.185 - print("{ //" + npairs); 5.186 - for (int i = 1; i <= npairs; i++) { 5.187 - print("\n\t\t" + attr.getInt(tb + i * 8) + ": " + lP + (pc + attr.getInt(tb + 4 + i * 8)) + ";"); 5.188 - } 5.189 - print("\n\t\tdefault: " + lP + (default_skip + pc) + " }"); 5.190 - return tb - pc + (npairs + 1) * 8; 5.191 - } 5.192 - case opc_newarray: 5.193 - int type = attr.getUnsignedByte(pc + 1); 5.194 - switch (type) { 5.195 - case T_BOOLEAN: 5.196 - print(" boolean"); 5.197 - break; 5.198 - case T_BYTE: 5.199 - print(" byte"); 5.200 - break; 5.201 - case T_CHAR: 5.202 - print(" char"); 5.203 - break; 5.204 - case T_SHORT: 5.205 - print(" short"); 5.206 - break; 5.207 - case T_INT: 5.208 - print(" int"); 5.209 - break; 5.210 - case T_LONG: 5.211 - print(" long"); 5.212 - break; 5.213 - case T_FLOAT: 5.214 - print(" float"); 5.215 - break; 5.216 - case T_DOUBLE: 5.217 - print(" double"); 5.218 - break; 5.219 - case T_CLASS: 5.220 - print(" class"); 5.221 - break; 5.222 - default: 5.223 - print(" BOGUS TYPE:" + type); 5.224 - } 5.225 - return 2; 5.226 - case opc_anewarray: 5.227 - { 5.228 - int index = attr.getUnsignedShort(pc + 1); 5.229 - print("\t#" + index + "; //"); 5.230 - printConstant(index); 5.231 - return 3; 5.232 - } 5.233 - case opc_sipush: 5.234 - print("\t" + attr.getShort(pc + 1)); 5.235 - return 3; 5.236 - case opc_bipush: 5.237 - print("\t" + attr.getByte(pc + 1)); 5.238 - return 2; 5.239 - case opc_ldc: 5.240 - { 5.241 - int index = attr.getUnsignedByte(pc + 1); 5.242 - print("\t#" + index + "; //"); 5.243 - printConstant(index); 5.244 - return 2; 5.245 - } 5.246 - case opc_ldc_w: 5.247 - case opc_ldc2_w: 5.248 - case opc_instanceof: 5.249 - case opc_checkcast: 5.250 - case opc_new: 5.251 - case opc_putstatic: 5.252 - case opc_getstatic: 5.253 - case opc_putfield: 5.254 - case opc_getfield: 5.255 - case opc_invokevirtual: 5.256 - case opc_invokespecial: 5.257 - case opc_invokestatic: 5.258 - { 5.259 - int index = attr.getUnsignedShort(pc + 1); 5.260 - print("\t#" + index + "; //"); 5.261 - printConstant(index); 5.262 - return 3; 5.263 - } 5.264 - case opc_invokeinterface: 5.265 - { 5.266 - int index = attr.getUnsignedShort(pc + 1); 5.267 - int nargs = attr.getUnsignedByte(pc + 3); 5.268 - print("\t#" + index + ", " + nargs + "; //"); 5.269 - printConstant(index); 5.270 - return 5; 5.271 - } 5.272 - case opc_multianewarray: 5.273 - { 5.274 - int index = attr.getUnsignedShort(pc + 1); 5.275 - int dimensions = attr.getUnsignedByte(pc + 3); 5.276 - print("\t#" + index + ", " + dimensions + "; //"); 5.277 - printConstant(index); 5.278 - return 4; 5.279 - } 5.280 - case opc_jsr: 5.281 - case opc_goto: 5.282 - case opc_ifeq: 5.283 - case opc_ifge: 5.284 - case opc_ifgt: 5.285 - case opc_ifle: 5.286 - case opc_iflt: 5.287 - case opc_ifne: 5.288 - case opc_if_icmpeq: 5.289 - case opc_if_icmpne: 5.290 - case opc_if_icmpge: 5.291 - case opc_if_icmpgt: 5.292 - case opc_if_icmple: 5.293 - case opc_if_icmplt: 5.294 - case opc_if_acmpeq: 5.295 - case opc_if_acmpne: 5.296 - case opc_ifnull: 5.297 - case opc_ifnonnull: 5.298 - print("\t" + lP + (pc + attr.getShort(pc + 1))); 5.299 - return 3; 5.300 - case opc_jsr_w: 5.301 - case opc_goto_w: 5.302 - print("\t" + lP + (pc + attr.getInt(pc + 1))); 5.303 - return 5; 5.304 - default: 5.305 - return 1; 5.306 - } 5.307 - } 5.308 + }; 5.309 + 5.310 5.311 public void writeExceptionTable(Code_attribute attr) { 5.312 if (attr.exception_table_langth > 0) {