author | mikael |
Tue, 22 Dec 2015 20:47:40 -0800 | |
changeset 35023 | ee10ca0129b2 |
parent 30846 | 2b3f379840f0 |
permissions | -rw-r--r-- |
2512
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
1 |
/* |
22153
f9f06fcca59d
8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents:
14717
diff
changeset
|
2 |
* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. |
2512
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
4 |
* |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2512
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2512
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
10 |
* |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
15 |
* accompanied this code). |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
16 |
* |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
20 |
* |
5520 | 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. |
|
2512
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
24 |
*/ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
25 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
26 |
package com.sun.tools.classfile; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
27 |
|
22153
f9f06fcca59d
8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents:
14717
diff
changeset
|
28 |
import java.util.Locale; |
f9f06fcca59d
8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents:
14717
diff
changeset
|
29 |
|
2512
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
30 |
/** |
9303
eae35c201e19
7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents:
5847
diff
changeset
|
31 |
* See JVMS, chapter 6. |
2512
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
32 |
* |
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
33 |
* <p><b>This is NOT part of any supported API. |
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
34 |
* If you write code that depends on this, you do so at your own risk. |
2512
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
35 |
* This code and its internal interfaces are subject to change or |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
36 |
* deletion without notice.</b> |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
37 |
* |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
38 |
* @see Code_attribute#getInstructions |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
39 |
*/ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
40 |
public class Instruction { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
41 |
/** The kind of an instruction, as determined by the position, size and |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
42 |
* types of its operands. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
43 |
public static enum Kind { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
44 |
/** Opcode is not followed by any operands. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
45 |
NO_OPERANDS(1), |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
46 |
/** Opcode is followed by a byte indicating a type. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
47 |
ATYPE(2), |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
48 |
/** Opcode is followed by a 2-byte branch offset. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
49 |
BRANCH(3), |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
50 |
/** Opcode is followed by a 4-byte branch offset. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
51 |
BRANCH_W(5), |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
52 |
/** Opcode is followed by a signed byte value. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
53 |
BYTE(2), |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
54 |
/** Opcode is followed by a 1-byte index into the constant pool. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
55 |
CPREF(2), |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
56 |
/** Opcode is followed by a 2-byte index into the constant pool. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
57 |
CPREF_W(3), |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
58 |
/** Opcode is followed by a 2-byte index into the constant pool, |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
59 |
* an unsigned byte value. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
60 |
CPREF_W_UBYTE(4), |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
61 |
/** Opcode is followed by a 2-byte index into the constant pool., |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
62 |
* an unsigned byte value, and a zero byte. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
63 |
CPREF_W_UBYTE_ZERO(5), |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
64 |
/** Opcode is followed by variable number of operands, depending |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
65 |
* on the instruction.*/ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
66 |
DYNAMIC(-1), |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
67 |
/** Opcode is followed by a 1-byte reference to a local variable. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
68 |
LOCAL(2), |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
69 |
/** Opcode is followed by a 1-byte reference to a local variable, |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
70 |
* and a signed byte value. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
71 |
LOCAL_BYTE(3), |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
72 |
/** Opcode is followed by a signed short value. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
73 |
SHORT(3), |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
74 |
/** Wide opcode is not followed by any operands. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
75 |
WIDE_NO_OPERANDS(2), |
14717
641fdce05089
7190862: javap shows an incorrect type for operands if the 'wide' prefix is used
vromero
parents:
14259
diff
changeset
|
76 |
/** Wide opcode is followed by a 2-byte index into the local variables array. */ |
641fdce05089
7190862: javap shows an incorrect type for operands if the 'wide' prefix is used
vromero
parents:
14259
diff
changeset
|
77 |
WIDE_LOCAL(4), |
2512
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
78 |
/** Wide opcode is followed by a 2-byte index into the constant pool. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
79 |
WIDE_CPREF_W(4), |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
80 |
/** Wide opcode is followed by a 2-byte index into the constant pool, |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
81 |
* and a signed short value. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
82 |
WIDE_CPREF_W_SHORT(6), |
14717
641fdce05089
7190862: javap shows an incorrect type for operands if the 'wide' prefix is used
vromero
parents:
14259
diff
changeset
|
83 |
/** Wide opcode is followed by a 2-byte reference to a local variable, |
641fdce05089
7190862: javap shows an incorrect type for operands if the 'wide' prefix is used
vromero
parents:
14259
diff
changeset
|
84 |
* and a signed short value. */ |
641fdce05089
7190862: javap shows an incorrect type for operands if the 'wide' prefix is used
vromero
parents:
14259
diff
changeset
|
85 |
WIDE_LOCAL_SHORT(6), |
2512
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
86 |
/** Opcode was not recognized. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
87 |
UNKNOWN(1); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
88 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
89 |
Kind(int length) { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
90 |
this.length = length; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
91 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
92 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
93 |
/** The length, in bytes, of this kind of instruction, or -1 is the |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
94 |
* length depends on the specific instruction. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
95 |
public final int length; |
22163 | 96 |
} |
2512
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
97 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
98 |
/** A utility visitor to help decode the operands of an instruction. |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
99 |
* @see Instruction#accept */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
100 |
public interface KindVisitor<R,P> { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
101 |
/** See {@link Kind#NO_OPERANDS}, {@link Kind#WIDE_NO_OPERANDS}. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
102 |
R visitNoOperands(Instruction instr, P p); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
103 |
/** See {@link Kind#ATYPE}. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
104 |
R visitArrayType(Instruction instr, TypeKind kind, P p); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
105 |
/** See {@link Kind#BRANCH}, {@link Kind#BRANCH_W}. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
106 |
R visitBranch(Instruction instr, int offset, P p); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
107 |
/** See {@link Kind#CPREF}, {@link Kind#CPREF_W}, {@link Kind#WIDE_CPREF_W}. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
108 |
R visitConstantPoolRef(Instruction instr, int index, P p); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
109 |
/** See {@link Kind#CPREF_W_UBYTE}, {@link Kind#CPREF_W_UBYTE_ZERO}, {@link Kind#WIDE_CPREF_W_SHORT}. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
110 |
R visitConstantPoolRefAndValue(Instruction instr, int index, int value, P p); |
14717
641fdce05089
7190862: javap shows an incorrect type for operands if the 'wide' prefix is used
vromero
parents:
14259
diff
changeset
|
111 |
/** See {@link Kind#LOCAL}, {@link Kind#WIDE_LOCAL}. */ |
2512
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
112 |
R visitLocal(Instruction instr, int index, P p); |
14259 | 113 |
/** See {@link Kind#LOCAL_BYTE}. */ |
2512
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
114 |
R visitLocalAndValue(Instruction instr, int index, int value, P p); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
115 |
/** See {@link Kind#DYNAMIC}. */ |
4411
84c397e2ee67
6902264: fix indentation of tableswitch and lookupswitch
jjg
parents:
2512
diff
changeset
|
116 |
R visitLookupSwitch(Instruction instr, int default_, int npairs, int[] matches, int[] offsets, P p); |
2512
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
117 |
/** See {@link Kind#DYNAMIC}. */ |
4411
84c397e2ee67
6902264: fix indentation of tableswitch and lookupswitch
jjg
parents:
2512
diff
changeset
|
118 |
R visitTableSwitch(Instruction instr, int default_, int low, int high, int[] offsets, P p); |
2512
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
119 |
/** See {@link Kind#BYTE}, {@link Kind#SHORT}. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
120 |
R visitValue(Instruction instr, int value, P p); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
121 |
/** Instruction is unrecognized. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
122 |
R visitUnknown(Instruction instr, P p); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
123 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
124 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
125 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
126 |
/** The kind of primitive array type to create. |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
127 |
* See JVMS chapter 6, newarray. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
128 |
public static enum TypeKind { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
129 |
T_BOOLEAN(4, "boolean"), |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
130 |
T_CHAR(5, "char"), |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
131 |
T_FLOAT(6, "float"), |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
132 |
T_DOUBLE(7, "double"), |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
133 |
T_BYTE(8, "byte"), |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
134 |
T_SHORT(9, "short"), |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
135 |
T_INT (10, "int"), |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
136 |
T_LONG (11, "long"); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
137 |
TypeKind(int value, String name) { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
138 |
this.value = value; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
139 |
this.name = name; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
140 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
141 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
142 |
public static TypeKind get(int value) { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
143 |
switch (value) { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
144 |
case 4: return T_BOOLEAN; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
145 |
case 5: return T_CHAR; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
146 |
case 6: return T_FLOAT; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
147 |
case 7: return T_DOUBLE; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
148 |
case 8: return T_BYTE; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
149 |
case 9: return T_SHORT; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
150 |
case 10: return T_INT; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
151 |
case 11: return T_LONG; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
152 |
default: return null; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
153 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
154 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
155 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
156 |
public final int value; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
157 |
public final String name; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
158 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
159 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
160 |
/** An instruction is defined by its position in a bytecode array. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
161 |
public Instruction(byte[] bytes, int pc) { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
162 |
this.bytes = bytes; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
163 |
this.pc = pc; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
164 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
165 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
166 |
/** Get the position of the instruction within the bytecode array. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
167 |
public int getPC() { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
168 |
return pc; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
169 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
170 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
171 |
/** Get a byte value, relative to the start of this instruction. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
172 |
public int getByte(int offset) { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
173 |
return bytes[pc + offset]; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
174 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
175 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
176 |
/** Get an unsigned byte value, relative to the start of this instruction. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
177 |
public int getUnsignedByte(int offset) { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
178 |
return getByte(offset) & 0xff; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
179 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
180 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
181 |
/** Get a 2-byte value, relative to the start of this instruction. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
182 |
public int getShort(int offset) { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
183 |
return (getByte(offset) << 8) | getUnsignedByte(offset + 1); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
184 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
185 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
186 |
/** Get a unsigned 2-byte value, relative to the start of this instruction. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
187 |
public int getUnsignedShort(int offset) { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
188 |
return getShort(offset) & 0xFFFF; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
189 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
190 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
191 |
/** Get a 4-byte value, relative to the start of this instruction. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
192 |
public int getInt(int offset) { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
193 |
return (getShort(offset) << 16) | (getUnsignedShort(offset + 2)); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
194 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
195 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
196 |
/** Get the Opcode for this instruction, or null if the instruction is |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
197 |
* unrecognized. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
198 |
public Opcode getOpcode() { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
199 |
int b = getUnsignedByte(0); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
200 |
switch (b) { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
201 |
case Opcode.NONPRIV: |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
202 |
case Opcode.PRIV: |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
203 |
case Opcode.WIDE: |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
204 |
return Opcode.get(b, getUnsignedByte(1)); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
205 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
206 |
return Opcode.get(b); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
207 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
208 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
209 |
/** Get the mnemonic for this instruction, or a default string if the |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
210 |
* instruction is unrecognized. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
211 |
public String getMnemonic() { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
212 |
Opcode opcode = getOpcode(); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
213 |
if (opcode == null) |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
214 |
return "bytecode " + getUnsignedByte(0); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
215 |
else |
22153
f9f06fcca59d
8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents:
14717
diff
changeset
|
216 |
return opcode.toString().toLowerCase(Locale.US); |
2512
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
217 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
218 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
219 |
/** Get the length, in bytes, of this instruction, including the opcode |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
220 |
* and all its operands. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
221 |
public int length() { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
222 |
Opcode opcode = getOpcode(); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
223 |
if (opcode == null) |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
224 |
return 1; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
225 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
226 |
switch (opcode) { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
227 |
case TABLESWITCH: { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
228 |
int pad = align(pc + 1) - pc; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
229 |
int low = getInt(pad + 4); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
230 |
int high = getInt(pad + 8); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
231 |
return pad + 12 + 4 * (high - low + 1); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
232 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
233 |
case LOOKUPSWITCH: { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
234 |
int pad = align(pc + 1) - pc; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
235 |
int npairs = getInt(pad + 4); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
236 |
return pad + 8 + 8 * npairs; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
237 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
238 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
239 |
default: |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
240 |
return opcode.kind.length; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
241 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
242 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
243 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
244 |
/** Get the {@link Kind} of this instruction. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
245 |
public Kind getKind() { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
246 |
Opcode opcode = getOpcode(); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
247 |
return (opcode != null ? opcode.kind : Kind.UNKNOWN); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
248 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
249 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
250 |
/** Invoke a method on the visitor according to the kind of this |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
251 |
* instruction, passing in the decoded operands for the instruction. */ |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
252 |
public <R,P> R accept(KindVisitor<R,P> visitor, P p) { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
253 |
switch (getKind()) { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
254 |
case NO_OPERANDS: |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
255 |
return visitor.visitNoOperands(this, p); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
256 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
257 |
case ATYPE: |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
258 |
return visitor.visitArrayType( |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
259 |
this, TypeKind.get(getUnsignedByte(1)), p); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
260 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
261 |
case BRANCH: |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
262 |
return visitor.visitBranch(this, getShort(1), p); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
263 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
264 |
case BRANCH_W: |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
265 |
return visitor.visitBranch(this, getInt(1), p); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
266 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
267 |
case BYTE: |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
268 |
return visitor.visitValue(this, getByte(1), p); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
269 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
270 |
case CPREF: |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
271 |
return visitor.visitConstantPoolRef(this, getUnsignedByte(1), p); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
272 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
273 |
case CPREF_W: |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
274 |
return visitor.visitConstantPoolRef(this, getUnsignedShort(1), p); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
275 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
276 |
case CPREF_W_UBYTE: |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
277 |
case CPREF_W_UBYTE_ZERO: |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
278 |
return visitor.visitConstantPoolRefAndValue( |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
279 |
this, getUnsignedShort(1), getUnsignedByte(3), p); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
280 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
281 |
case DYNAMIC: { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
282 |
switch (getOpcode()) { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
283 |
case TABLESWITCH: { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
284 |
int pad = align(pc + 1) - pc; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
285 |
int default_ = getInt(pad); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
286 |
int low = getInt(pad + 4); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
287 |
int high = getInt(pad + 8); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
288 |
int[] values = new int[high - low + 1]; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
289 |
for (int i = 0; i < values.length; i++) |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
290 |
values[i] = getInt(pad + 12 + 4 * i); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
291 |
return visitor.visitTableSwitch( |
4411
84c397e2ee67
6902264: fix indentation of tableswitch and lookupswitch
jjg
parents:
2512
diff
changeset
|
292 |
this, default_, low, high, values, p); |
2512
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
293 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
294 |
case LOOKUPSWITCH: { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
295 |
int pad = align(pc + 1) - pc; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
296 |
int default_ = getInt(pad); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
297 |
int npairs = getInt(pad + 4); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
298 |
int[] matches = new int[npairs]; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
299 |
int[] offsets = new int[npairs]; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
300 |
for (int i = 0; i < npairs; i++) { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
301 |
matches[i] = getInt(pad + 8 + i * 8); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
302 |
offsets[i] = getInt(pad + 12 + i * 8); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
303 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
304 |
return visitor.visitLookupSwitch( |
4411
84c397e2ee67
6902264: fix indentation of tableswitch and lookupswitch
jjg
parents:
2512
diff
changeset
|
305 |
this, default_, npairs, matches, offsets, p); |
2512
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
306 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
307 |
default: |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
308 |
throw new IllegalStateException(); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
309 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
310 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
311 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
312 |
case LOCAL: |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
313 |
return visitor.visitLocal(this, getUnsignedByte(1), p); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
314 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
315 |
case LOCAL_BYTE: |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
316 |
return visitor.visitLocalAndValue( |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
317 |
this, getUnsignedByte(1), getByte(2), p); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
318 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
319 |
case SHORT: |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
320 |
return visitor.visitValue(this, getShort(1), p); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
321 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
322 |
case WIDE_NO_OPERANDS: |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
323 |
return visitor.visitNoOperands(this, p); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
324 |
|
14717
641fdce05089
7190862: javap shows an incorrect type for operands if the 'wide' prefix is used
vromero
parents:
14259
diff
changeset
|
325 |
case WIDE_LOCAL: |
641fdce05089
7190862: javap shows an incorrect type for operands if the 'wide' prefix is used
vromero
parents:
14259
diff
changeset
|
326 |
return visitor.visitLocal(this, getUnsignedShort(2), p); |
641fdce05089
7190862: javap shows an incorrect type for operands if the 'wide' prefix is used
vromero
parents:
14259
diff
changeset
|
327 |
|
2512
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
328 |
case WIDE_CPREF_W: |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
329 |
return visitor.visitConstantPoolRef(this, getUnsignedShort(2), p); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
330 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
331 |
case WIDE_CPREF_W_SHORT: |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
332 |
return visitor.visitConstantPoolRefAndValue( |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
333 |
this, getUnsignedShort(2), getUnsignedByte(4), p); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
334 |
|
14717
641fdce05089
7190862: javap shows an incorrect type for operands if the 'wide' prefix is used
vromero
parents:
14259
diff
changeset
|
335 |
case WIDE_LOCAL_SHORT: |
641fdce05089
7190862: javap shows an incorrect type for operands if the 'wide' prefix is used
vromero
parents:
14259
diff
changeset
|
336 |
return visitor.visitLocalAndValue( |
641fdce05089
7190862: javap shows an incorrect type for operands if the 'wide' prefix is used
vromero
parents:
14259
diff
changeset
|
337 |
this, getUnsignedShort(2), getShort(4), p); |
641fdce05089
7190862: javap shows an incorrect type for operands if the 'wide' prefix is used
vromero
parents:
14259
diff
changeset
|
338 |
|
2512
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
339 |
case UNKNOWN: |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
340 |
return visitor.visitUnknown(this, p); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
341 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
342 |
default: |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
343 |
throw new IllegalStateException(); |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
344 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
345 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
346 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
347 |
private static int align(int n) { |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
348 |
return (n + 3) & ~3; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
349 |
} |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
350 |
|
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
351 |
private byte[] bytes; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
352 |
private int pc; |
70eb5f17c5f8
6819246: improve support for decoding instructions in classfile library
jjg
parents:
diff
changeset
|
353 |
} |