View Javadoc

1   /*
2    * Copyright 2005 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at 
7    * 
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software 
11   * distributed under the License is distributed on an "AS IS" BASIS, 
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
13   * See the License for the specific language governing permissions and 
14   * limitations under the License.
15   */
16  
17  
18  package org.apache.jdo.impl.enhancer.classfile;
19  
20  /***
21   * Description of the VM opcodes
22   */
23  public class VMOp implements VMConstants {
24      /* The opcode value */
25      private int opcodeValue;
26  
27      /* The name of the opcode */
28      private String opcodeName;
29  
30      /* The number of stack argument words */
31      private int stackArgs;
32  
33      /* The number of stack result words */
34      private int stackResults;
35  
36      /* The "type" signature of the stack argument words */
37      private String stackArgTypes;
38  
39      /* The "type" signature of the stack result words */
40      private String stackResultTypes;
41  
42      /* public accessors */
43  
44      /***
45       * Return the opcode value 
46       */
47      final public int opcode() {
48          return opcodeValue;
49      }
50  
51      /***
52       * Return the opcode name
53       */
54      final public String name() {
55          return opcodeName;
56      }
57  
58      /***
59       * Return the number of words of stack arguments expected by this operation.
60       * If the number is not a fixed value, return -1;
61       */
62      final public int nStackArgs() {
63          return stackArgs;
64      }
65  
66      /***
67       * Return the number of words of stack results produced by this operation.
68       * If the number is not a fixed value, return -1;
69       */
70      final public int nStackResults() {
71          return stackResults;
72      }
73  
74      /***
75       * Return the type descriptor for the stack arguments to the operation.
76       */
77      final public String argTypes() {
78          return stackArgTypes;
79      }
80  
81      /***
82       * Return the type descriptor for the stack results of the operation.
83       */
84      final public String resultTypes() {
85          return stackResultTypes;
86      }
87  
88      /***
89       * constructor for a VMOp
90       */
91     
92      public VMOp(int theOpcode, String theOpcodeName, int nArgs, int nResults,
93                  String argDescr, String resultDescr) {
94          opcodeValue = theOpcode;
95          opcodeName = theOpcodeName;
96          stackArgs = nArgs;
97          stackResults = nResults;
98          stackArgTypes = argDescr;
99          stackResultTypes = resultDescr;
100     }
101 
102     /* package local methods *//package-summary/html">class="comment"> package local methods *//package-summary.html">/* package local methods *//package-summary.html">class="comment"> package local methods */
103 
104     static VMOp[] ops =  {
105         /* | no change*/
106         new VMOp(opc_nop, "nop", 0, 0, "", ""),
107         /* | ... -> ..., null */
108         new VMOp(opc_aconst_null, "aconst_null", 0, 1, "", "A"),
109         /* | ... -> ..., -1 */
110         new VMOp(opc_iconst_m1, "iconst_m1", 0, 1, "", "I"),
111         /* | ... -> ..., 0 */
112         new VMOp(opc_iconst_0, "iconst_0", 0, 1, "", "I"),
113         /* | ... -> ..., 1 */
114         new VMOp(opc_iconst_1, "iconst_1", 0, 1, "", "I"),
115         /* | ... -> ..., 2 */
116         new VMOp(opc_iconst_2, "iconst_2", 0, 1, "", "I"),
117         /* | ... -> ..., 3 */
118         new VMOp(opc_iconst_3, "iconst_3", 0, 1, "", "I"),
119         /* | ... -> ..., 4 */
120         new VMOp(opc_iconst_4, "iconst_4", 0, 1, "", "I"),
121         /* | ... -> ..., 5 */
122         new VMOp(opc_iconst_5, "iconst_5", 0, 1, "", "I"),
123         /* | ... -> ..., 0<high/low>, 0<high/low> */
124         new VMOp(opc_lconst_0, "lconst_0", 0, 2, "", "J"),
125         /* | ... -> ..., 1<high/low>, 1<high/low> */
126         new VMOp(opc_lconst_1, "lconst_1", 0, 2, "", "J"),
127         /* | ... -> ..., 0.0f */
128         new VMOp(opc_fconst_0, "fconst_0", 0, 1, "", "F"),
129         /* | ... -> ..., 1.0f */
130         new VMOp(opc_fconst_1, "fconst_1", 0, 1, "", "F"),
131         /* | ... -> ..., 2.0f */
132         new VMOp(opc_fconst_2, "fconst_2", 0, 1, "", "F"),
133         /* | ... -> ..., 0.0<high/low>, 0.0<high/low> */
134         new VMOp(opc_dconst_0, "dconst_0", 0, 2, "", "D"),
135         /* | ... -> ..., 1.0<high/low>, 1.0<high/low> */
136         new VMOp(opc_dconst_1, "dconst_1", 0, 2, "", "D"),
137         /* byte1 | ... => ..., value */
138         new VMOp(opc_bipush, "bipush", 0, 1, "", "I"),
139         /* byte1 byte2 | ... => ..., value */
140         new VMOp(opc_sipush, "sipush", 0, 1, "", "I"),
141         /* indexbyte1 | ... => ..., item */
142         new VMOp(opc_ldc, "ldc", 0, 1, "", "W"),
143         /* indexbyte1 indexbyte2 | ... => ..., item */
144         new VMOp(opc_ldc_w, "ldc_w", 0, 1, "", "W"),
145         /* indexbyte1 indexbyte2 | ... => ..., item1, item2 */
146         new VMOp(opc_ldc2_w, "ldc2_w", 0, 2, "", "X"),
147         /* vindex | ... => ..., value<vindex> */
148         new VMOp(opc_iload, "iload", 0, 1, "", "I"),
149         /* vindex | ... => ..., value<vindex><h/l>, value<vindex><h/l> */
150         new VMOp(opc_lload, "lload", 0, 2, "", "J"),
151         /* vindex | ... => ..., value<vindex> */
152         new VMOp(opc_fload, "fload", 0, 1, "", "F"),
153         /* vindex | ... => ..., value<vindex><h/l>, value<vindex><h/l> */
154         new VMOp(opc_dload, "dload", 0, 2, "", "D"),
155         /* vindex | ... => ..., value<vindex> */
156         new VMOp(opc_aload, "aload", 0, 1, "", "A"),
157         /* | ... => ..., value<0> */
158         new VMOp(opc_iload_0, "iload_0", 0, 1, "", "I"),
159         /* | ... => ..., value<1> */
160         new VMOp(opc_iload_1, "iload_1", 0, 1, "", "I"),
161         /* | ... => ..., value<2> */
162         new VMOp(opc_iload_2, "iload_2", 0, 1, "", "I"),
163         /* | ... => ..., value<3> */
164         new VMOp(opc_iload_3, "iload_3", 0, 1, "", "I"),
165         /* | ... => ..., value<0><h/l>, value<0><h/l> */
166         new VMOp(opc_lload_0, "lload_0", 0, 2, "", "J"),
167         /* | ... => ..., value<1><h/l>, value<1><h/l> */
168         new VMOp(opc_lload_1, "lload_1", 0, 2, "", "J"),
169         /* | ... => ..., value<2><h/l>, value<2><h/l> */
170         new VMOp(opc_lload_2, "lload_2", 0, 2, "", "J"),
171         /* | ... => ..., value<3><h/l>, value<3><h/l> */
172         new VMOp(opc_lload_3, "lload_3", 0, 2, "", "J"),
173         /* | ... => ..., value<0> */
174         new VMOp(opc_fload_0, "fload_0", 0, 1, "", "F"),
175         /* | ... => ..., value<1> */
176         new VMOp(opc_fload_1, "fload_1", 0, 1, "", "F"),
177         /* | ... => ..., value<2> */
178         new VMOp(opc_fload_2, "fload_2", 0, 1, "", "F"),
179         /* | ... => ..., value<3> */
180         new VMOp(opc_fload_3, "fload_3", 0, 1, "", "F"),
181         /* | ... => ..., value<0><h/l>, value<0><h/l> */
182         new VMOp(opc_dload_0, "dload_0", 0, 2, "", "D"),
183         /* | ... => ..., value<1><h/l>, value<1><h/l> */
184         new VMOp(opc_dload_1, "dload_1", 0, 2, "", "D"),
185         /* | ... => ..., value<2><h/l>, value<2><h/l> */
186         new VMOp(opc_dload_2, "dload_2", 0, 2, "", "D"),
187         /* | ... => ..., value<3><h/l>, value<3><h/l> */
188         new VMOp(opc_dload_3, "dload_3", 0, 2, "", "D"),
189         /* | ... => ..., value<0> */
190         new VMOp(opc_aload_0, "aload_0", 0, 1, "", "A"),
191         /* | ... => ..., value<1> */
192         new VMOp(opc_aload_1, "aload_1", 0, 1, "", "A"),
193         /* | ... => ..., value<2> */
194         new VMOp(opc_aload_2, "aload_2", 0, 1, "", "A"),
195         /* | ... => ..., value<3> */
196         new VMOp(opc_aload_3, "aload_3", 0, 1, "", "A"),
197         /* | ..., arrayref, index => ..., value */
198         new VMOp(opc_iaload, "iaload", 2, 1, "AI", "I"),
199         /* | ..., arrayref, index => ..., value<h/l>, value<h/l> */
200         new VMOp(opc_laload, "laload", 2, 2, "AI", "J"),
201         /* | ..., arrayref, index => ..., value */
202         new VMOp(opc_faload, "faload", 2, 1, "AI", "F"),
203         /* | ..., arrayref, index => ..., value<h/l>, value<h/l> */
204         new VMOp(opc_daload, "daload", 2, 2, "AI", "D"),
205         /* | ..., arrayref, index => ..., value */
206         new VMOp(opc_aaload, "aaload", 2, 1, "AI", "A"),
207         /* | ..., arrayref, index => ..., value */
208         new VMOp(opc_baload, "baload", 2, 1, "AI", "I"),
209         /* | ..., arrayref, index => ..., value */
210         new VMOp(opc_caload, "caload", 2, 1, "AI", "I"),
211         /* | ..., arrayref, index => ..., value */
212         new VMOp(opc_saload, "saload", 2, 1, "AI", "I"),
213         /* vindex | ..., value => ... */
214         new VMOp(opc_istore, "istore", 1, 0, "I", ""),
215         /* vindex | ..., value<h/l>, value<h/l> => ... */
216         new VMOp(opc_lstore, "lstore", 2, 0, "J", ""),
217         /* vindex | ..., value => ... */
218         new VMOp(opc_fstore, "fstore", 1, 0, "F", ""),
219         /* vindex | ..., value<h/l>, value<h/l> => ... */
220         new VMOp(opc_dstore, "dstore", 2, 0, "D", ""),
221         /* vindex | ..., value => ... */
222         new VMOp(opc_astore, "astore", 1, 0, "A", ""),
223         /* | ..., value => ... */
224         new VMOp(opc_istore_0, "istore_0", 1, 0, "I", ""),
225         /* | ..., value => ... */
226         new VMOp(opc_istore_1, "istore_1", 1, 0, "I", ""),
227         /* | ..., value => ... */
228         new VMOp(opc_istore_2, "istore_2", 1, 0, "I", ""),
229         /* | ..., value => ... */
230         new VMOp(opc_istore_3, "istore_3", 1, 0, "I", ""),
231         /* | ..., value<h/l>, value<h/l> => ... */
232         new VMOp(opc_lstore_0, "lstore_0", 2, 0, "J", ""),
233         /* | ..., value<h/l>, value<h/l> => ... */
234         new VMOp(opc_lstore_1, "lstore_1", 2, 0, "J", ""),
235         /* | ..., value<h/l>, value<h/l> => ... */
236         new VMOp(opc_lstore_2, "lstore_2", 2, 0, "J", ""),
237         /* | ..., value<h/l>, value<h/l> => ... */
238         new VMOp(opc_lstore_3, "lstore_3", 2, 0, "J", ""),
239         /* | ..., value => ... */
240         new VMOp(opc_fstore_0, "fstore_0", 1, 0, "F", ""),
241         /* | ..., value => ... */
242         new VMOp(opc_fstore_1, "fstore_1", 1, 0, "F", ""),
243         /* | ..., value => ... */
244         new VMOp(opc_fstore_2, "fstore_2", 1, 0, "F", ""),
245         /* | ..., value => ... */
246         new VMOp(opc_fstore_3, "fstore_3", 1, 0, "F", ""),
247         /* | ..., value<h/l>, value<h/l> => ... */
248         new VMOp(opc_dstore_0, "dstore_0", 2, 0, "D", ""),
249         /* | ..., value<h/l>, value<h/l> => ... */
250         new VMOp(opc_dstore_1, "dstore_1", 2, 0, "D", ""),
251         /* | ..., value<h/l>, value<h/l> => ... */
252         new VMOp(opc_dstore_2, "dstore_2", 2, 0, "D", ""),
253         /* | ..., value<h/l>, value<h/l> => ... */
254         new VMOp(opc_dstore_3, "dstore_3", 2, 0, "D", ""),
255         /* | ..., value => ... */
256         new VMOp(opc_astore_0, "astore_0", 1, 0, "A", ""),
257         /* | ..., value => ... */
258         new VMOp(opc_astore_1, "astore_1", 1, 0, "A", ""),
259         /* | ..., value => ... */
260         new VMOp(opc_astore_2, "astore_2", 1, 0, "A", ""),
261         /* | ..., value => ... */
262         new VMOp(opc_astore_3, "astore_3", 1, 0, "A", ""),
263         /* | ..., arrayref, index, value => ... */
264         new VMOp(opc_iastore, "iastore", 3, 0, "AII", ""),
265         /* | ..., arrayref, index, value<h/l>, value<h/l> => ... */
266         new VMOp(opc_lastore, "lastore", 4, 0, "AIJ", ""),
267         /* | ..., arrayref, index, value => ... */
268         new VMOp(opc_fastore, "fastore", 3, 0, "AIF", ""),
269         /* | ..., arrayref, index, value<h/l>, value<h/l> => ... */
270         new VMOp(opc_dastore, "dastore", 4, 0, "AID", ""),
271         /* | ..., arrayref, index, value => ... */
272         new VMOp(opc_aastore, "aastore", 3, 0, "AIA", ""),
273         /* | ..., arrayref, index, value => ... */
274         new VMOp(opc_bastore, "bastore", 3, 0, "AII", ""),
275         /* | ..., arrayref, index, value => ... */
276         new VMOp(opc_castore, "castore", 3, 0, "AII", ""),
277         /* | ..., arrayref, index, value => ... */
278         new VMOp(opc_sastore, "sastore", 3, 0, "AII", ""),
279         /* | ..., any => ... */
280         new VMOp(opc_pop, "pop", 1, 0, "W", ""),
281         /* | ..., any1, any2 => ... */
282         new VMOp(opc_pop2, "pop2", 2, 0, "WW", ""),
283         /* | ..., any => ..., any, any */
284         new VMOp(opc_dup, "dup", 1, 2, "W", "WW"),
285         /* | ..., any1, any2 => ..., any2, any1, any2 */
286         new VMOp(opc_dup_x1, "dup_x1", 2, 3, "WW", "WWW"),
287         /* | ..., any1, any2, any3 => ..., any3, any1, any2, any3 */
288         new VMOp(opc_dup_x2, "dup_x2", 3, 4, "WWW", "WWWW"),
289         /* | ..., any1, any2 => ..., any1, any2, any1, any2 */
290         new VMOp(opc_dup2, "dup2", 2, 4, "WW", "WWWW"),
291         /* | ..., any1, any2, any3 => ..., any2, any3, any1, any2, any3 */
292         new VMOp(opc_dup2_x1, "dup2_x1", 3, 5, "WWW", "WWWWW"),
293         /* | ..., any1, any2, any3, any4 => ..., any3, any4, any1, any2, any3, any4 */
294         new VMOp(opc_dup2_x2, "dup2_x2", 4, 6, "WWWW", "WWWWWW"),
295         /* | ..., any1, any2 => ..., any2, any1 */
296         new VMOp(opc_swap, "swap", 2, 2, "WW", "WW"),
297         /* | ..., value1, value2 => ..., result */
298         new VMOp(opc_iadd, "iadd", 2, 1, "II", "I"),
299         /* | ..., value1<h/l>, value1<h/l>, value2<h/l>, value2<h/l> => ..., result<h/l>, result<h/l> */
300         new VMOp(opc_ladd, "ladd", 4, 2, "JJ", "J"),
301         /* | ..., value1, value2 => ..., result */
302         new VMOp(opc_fadd, "fadd", 2, 1, "FF", "F"),
303         /* | ..., value1<h/l>, value1<h/l>, value2<h/l>, value2<h/l> => ..., result<h/l>, result<h/l> */
304         new VMOp(opc_dadd, "dadd", 4, 2, "DD", "D"),
305         /* | ..., value1, value2 => ..., result */
306         new VMOp(opc_isub, "isub", 2, 1, "II", "I"),
307         /* | ..., value1<h/l>, value1<h/l>, value2<h/l>, value2<h/l> => ..., result<h/l>, result<h/l> */
308         new VMOp(opc_lsub, "lsub", 4, 2, "JJ", "J"),
309         /* | ..., value1, value2 => ..., result */
310         new VMOp(opc_fsub, "fsub", 2, 1, "FF", "F"),
311         /* | ..., value1<h/l>, value1<h/l>, value2<h/l>, value2<h/l> => ..., result<h/l>, result<h/l> */
312         new VMOp(opc_dsub, "dsub", 4, 2, "DD", "D"),
313         /* | ..., value1, value2 => ..., result */
314         new VMOp(opc_imul, "imul", 2, 1, "II", "I"),
315         /* | ..., value1<h/l>, value1<h/l>, value2<h/l>, value2<h/l> => ..., result<h/l>, result<h/l> */
316         new VMOp(opc_lmul, "lmul", 4, 2, "JJ", "J"),
317         /* | ..., value1, value2 => ..., result */
318         new VMOp(opc_fmul, "fmul", 2, 1, "FF", "F"),
319         /* | ..., value1<h/l>, value1<h/l>, value2<h/l>, value2<h/l> => ..., result<h/l>, result<h/l> */
320         new VMOp(opc_dmul, "dmul", 4, 2, "DD", "D"),
321         /* | ..., value1, value2 => ..., result */
322         new VMOp(opc_idiv, "idiv", 2, 1, "II", "I"),
323         /* | ..., value1<h/l>, value1<h/l>, value2<h/l>, value2<h/l> => ..., result<h/l>, result<h/l> */
324         new VMOp(opc_ldiv, "ldiv", 4, 2, "JJ", "J"),
325         /* | ..., value1, value2 => ..., result */
326         new VMOp(opc_fdiv, "fdiv", 2, 1, "FF", "F"),
327         /* | ..., value1<h/l>, value1<h/l>, value2<h/l>, value2<h/l> => ..., result<h/l>, result<h/l> */
328         new VMOp(opc_ddiv, "ddiv", 4, 2, "DD", "D"),
329         /* | ..., value1, value2 => ..., result */
330         new VMOp(opc_irem, "irem", 2, 1, "II", "I"),
331         /* | ..., value1<h/l>, value1<h/l>, value2<h/l>, value2<h/l> => ..., result<h/l>, result<h/l> */
332         new VMOp(opc_lrem, "lrem", 4, 2, "JJ", "J"),
333         /* | ..., value1, value2 => ..., result */
334         new VMOp(opc_frem, "frem", 2, 1, "FF", "F"),
335         /* | ..., value1<h/l>, value1<h/l>, value2<h/l>, value2<h/l> => ..., result<h/l>, result<h/l> */
336         new VMOp(opc_drem, "drem", 4, 2, "DD", "D"),
337         /* | ..., value => ..., result */
338         new VMOp(opc_ineg, "ineg", 1, 1, "I", "I"),
339         /* | ..., value<h/l>, value<h/l> => ..., result<h/l>, result<h/l> */
340         new VMOp(opc_lneg, "lneg", 2, 2, "J", "J"),
341         /* | ..., value => ..., result */
342         new VMOp(opc_fneg, "fneg", 1, 1, "F", "F"),
343         /* | ..., value<h/l>, value<h/l> => ..., result<h/l>, result<h/l> */
344         new VMOp(opc_dneg, "dneg", 2, 2, "D", "D"),
345         /* | ..., value1, value2 => ..., result */
346         new VMOp(opc_ishl, "ishl", 2, 1, "II", "I"),
347         /* | ..., value1<h/l>, value1<h/l>, value2 => ..., result */
348         new VMOp(opc_lshl, "lshl", 3, 2, "JI", "J"),
349         /* | ..., value1, value2 => ..., result */
350         new VMOp(opc_ishr, "ishr", 2, 1, "II", "I"),
351         /* | ..., value1<h/l>, value1<h/l>, value2 => ..., result<h/l>, result<h/l> */
352         new VMOp(opc_lshr, "lshr", 3, 2, "JI", "J"),
353         /* | ..., value1, value2 => ..., result */
354         new VMOp(opc_iushr, "iushr", 2, 1, "II", "I"),
355         /* | ..., value1<h/l>, value1<h/l>, value2 => ..., result<h/l>, result<h/l> */
356         new VMOp(opc_lushr, "lushr", 3, 2, "JI", "J"),
357         /* | ..., value1, value2 => ..., result */
358         new VMOp(opc_iand, "iand", 2, 1, "II", "I"),
359         /* | ..., value1<h/l>, value1<h/l>, value2<h/l>, value2<h/l> => ..., result<h/l>, result<h/l> */
360         new VMOp(opc_land, "land", 4, 2, "JJ", "J"),
361         /* | ..., value1, value2 => ..., result */
362         new VMOp(opc_ior, "ior", 2, 1, "II", "I"),
363         /* | ..., value1<h/l>, value1<h/l>, value2<h/l>, value2<h/l> => ..., result<h/l>, result<h/l> */
364         new VMOp(opc_lor, "lor", 4, 2, "JJ", "J"),
365         /* | ..., value1, value2 => ..., result */
366         new VMOp(opc_ixor, "ixor", 2, 1, "II", "I"),
367         /* | ..., value1<h/l>, value1<h/l>, value2<h/l>, value2<h/l> => ..., result<h/l>, result<h/l> */
368         new VMOp(opc_lxor, "lxor", 4, 2, "JJ", "J"),
369         /* vindex, const | no change */
370         new VMOp(opc_iinc, "iinc", 0, 0, "", ""),
371         /* | ..., value => ..., value<h/l>, value<h/l> */
372         new VMOp(opc_i2l, "i2l", 1, 2, "I", "J"),
373         /* | ..., value => ..., value */
374         new VMOp(opc_i2f, "i2f", 1, 1, "I", "F"),
375         /* | ..., value => ..., value<h/l>, value<h/l> */
376         new VMOp(opc_i2d, "i2d", 1, 2, "I", "D"),
377         /* | ..., value<h/l>, value<h/l> => ..., value */
378         new VMOp(opc_l2i, "l2i", 2, 1, "J", "I"),
379         /* | ..., value<h/l>, value<h/l> => ..., value */
380         new VMOp(opc_l2f, "l2f", 2, 1, "J", "F"),
381         /* | ..., value<h/l>, value<h/l> => ..., value<h/l>, value<h/l> */
382         new VMOp(opc_l2d, "l2d", 2, 2, "J", "D"),
383         /* | ..., value => ..., value */
384         new VMOp(opc_f2i, "f2i", 1, 1, "F", "I"),
385         /* | ..., value => ..., value<h/l>, value<h/l> */
386         new VMOp(opc_f2l, "f2l", 1, 2, "F", "J"),
387         /* | ..., value => ..., value<h/l>, value<h/l> */
388         new VMOp(opc_f2d, "f2d", 1, 2, "F", "D"),
389         /* | ..., value<h/l>, value<h/l> => ..., value */
390         new VMOp(opc_d2i, "d2i", 2, 1, "D", "I"),
391         /* | ..., value<h/l>, value<h/l> => ..., value<h/l>, value<h/l> */
392         new VMOp(opc_d2l, "d2l", 2, 2, "D", "J"),
393         /* | ..., value<h/l>, value<h/l> => ..., value */
394         new VMOp(opc_d2f, "d2f", 2, 1, "D", "F"),
395         /* | ..., value => ..., result */
396         new VMOp(opc_i2b, "i2b", 1, 1, "I", "I"),
397         /* | ..., value => ..., result */
398         new VMOp(opc_i2c, "i2c", 1, 1, "I", "I"),
399         /* | ..., value => ..., result */
400         new VMOp(opc_i2s, "i2s", 1, 1, "I", "I"),
401         /* | ..., v1<h/l>, v1<h/l>, v2<h/l>, v2<h/l> => ..., result */
402         new VMOp(opc_lcmp, "lcmp", 4, 1, "JJ", "I"),
403         /*  | ..., v1<h/l>, v1<h/l>, v2<h/l>, v2<h/l> => ..., result */
404         new VMOp(opc_fcmpl, "fcmpl", 2, 1, "FF", "I"),
405         /*  | ..., v1, v2 => ..., result */
406         new VMOp(opc_fcmpg, "fcmpg", 2, 1, "FF", "I"),
407         /* | ..., v1<h/l>, v1<h/l>, v2<h/l>, v2<h/l> => ..., result */
408         new VMOp(opc_dcmpl, "dcmpl", 4, 1, "DD", "I"),
409         /* | ..., v1<h/l>, v1<h/l>, v2<h/l>, v2<h/l> => ..., result */
410         new VMOp(opc_dcmpg, "dcmpg", 4, 1, "DD", "I"),
411         /* brbyte1, brbyte2 | ..., value => ... */
412         new VMOp(opc_ifeq, "ifeq", 1, 0, "I", ""),
413         /* brbyte1, brbyte2 | ..., value => ... */
414         new VMOp(opc_ifne, "ifne", 1, 0, "I", ""),
415         /* brbyte1, brbyte2 | ..., value => ... */
416         new VMOp(opc_iflt, "iflt", 1, 0, "I", ""),
417         /* brbyte1, brbyte2 | ..., value => ... */
418         new VMOp(opc_ifge, "ifge", 1, 0, "I", ""),
419         /* brbyte1, brbyte2 | ..., value => ... */
420         new VMOp(opc_ifgt, "ifgt", 1, 0, "I", ""),
421         /* brbyte1, brbyte2 | ..., value => ... */
422         new VMOp(opc_ifle, "ifle", 1, 0, "I", ""),
423         /* brbyte1, brbyte2 | ..., value1, value2 => ... */
424         new VMOp(opc_if_icmpeq, "if_icmpeq", 2, 0, "II", ""),
425         /* brbyte1, brbyte2 | ..., value1, value2 => ... */
426         new VMOp(opc_if_icmpne, "if_icmpne", 2, 0, "II", ""),
427         /* brbyte1, brbyte2 | ..., value1, value2 => ... */
428         new VMOp(opc_if_icmplt, "if_icmplt", 2, 0, "II", ""),
429         /* brbyte1, brbyte2 | ..., value1, value2 => ... */
430         new VMOp(opc_if_icmpge, "if_icmpge", 2, 0, "II", ""),
431         /* brbyte1, brbyte2 | ..., value1, value2 => ... */
432         new VMOp(opc_if_icmpgt, "if_icmpgt", 2, 0, "II", ""),
433         /* brbyte1, brbyte2 | ..., value1, value2 => ... */
434         new VMOp(opc_if_icmple, "if_icmple", 2, 0, "II", ""),
435         /* brbyte1, brbyte2 | ..., value1, value2 => ... */
436         new VMOp(opc_if_acmpeq, "if_acmpeq", 2, 0, "AA", ""),
437         /* brbyte1, brbyte2 | ..., value1, value2 => ... */
438         new VMOp(opc_if_acmpne, "if_acmpne", 2, 0, "AA", ""),
439         /* brbyte1, brbyte2 | no change */
440         new VMOp(opc_goto, "goto", 0, 0, "", ""),
441         /* brbyte1, brbyte2 | ... => ..., return_addr */
442         new VMOp(opc_jsr, "jsr", 0, 1, "", "W"),
443         /* vindex | no change */
444         new VMOp(opc_ret, "ret", 0, 0, "", ""),
445         /* ??? | ..., index => ... */
446         new VMOp(opc_tableswitch, "tableswitch", 1, 0, "I", ""),
447         /* ??? | ..., key => ... */
448         new VMOp(opc_lookupswitch, "lookupswitch", 1, 0, "I", ""),
449         /* | ..., value => [empty] */
450         new VMOp(opc_ireturn, "ireturn", 1, 0, "I", ""),
451         /* | ..., value<h/l>, value<h/l> => [empty] */
452         new VMOp(opc_lreturn, "lreturn", 2, 0, "J", ""),
453         /* | ..., value => [empty] */
454         new VMOp(opc_freturn, "freturn", 1, 0, "F", ""),
455         /* | ..., value<h/l>, value<h/l> => [empty] */
456         new VMOp(opc_dreturn, "dreturn", 2, 0, "D", ""),
457         /* | ..., value => [empty] */
458         new VMOp(opc_areturn, "areturn", 1, 0, "A", ""),
459         /* | ... => [empty] */
460         new VMOp(opc_return, "return", 0, 0, "", ""),
461         /* idxbyte1, idxbyte2 | ... => ..., value [ value2 ] */
462         new VMOp(opc_getstatic, "getstatic", 0, -1, "", "?"),
463         /* idxbyte1, idxbyte2 | ..., value [ value2 ] => ... */
464         new VMOp(opc_putstatic, "putstatic", -1, 0, "?", ""),
465         /* idxbyte1, idxbyte2 | ..., objectref => ..., value [ value2 ] */
466         new VMOp(opc_getfield, "getfield", 1, -1, "A", "?"),
467         /* idxbyte1, idxbyte2 | ..., objectref, value [ value2 ] => ... */
468         new VMOp(opc_putfield, "putfield", -1, 0, "A?", ""),
469         /* idxbyte1, idxbyte2 | ..., objectref, [args] => ... */
470         new VMOp(opc_invokevirtual, "invokevirtual", -1, -1, "A?", "?"),
471         /* idxbyte1, idxbyte2 | ..., objectref, [args] => ... */
472         new VMOp(opc_invokespecial, "invokespecial", -1, -1, "A?", "?"),
473         /* idxbyte1, idxbyte2 | ..., [args] => ... */
474         new VMOp(opc_invokestatic, "invokestatic", -1, -1, "?", "?"),
475         /* idxbyte1, idxbyte2, nargs, rsvd | ..., objectref, [args] => ... */
476         new VMOp(opc_invokeinterface, "invokeinterface", -1, -1, "A?", "?"),
477         /* */
478         new VMOp(opc_xxxunusedxxx, "xxxunusedxxx", 0, 0, "", ""),
479         /* idxbyte1, idxbyte2 | ... => ..., objectref */
480         new VMOp(opc_new, "new", 0, 1, "", "A"),
481         /* atype | ..., size => ..., result */
482         new VMOp(opc_newarray, "newarray", 1, 1, "I", "A"),
483         /* indexbyte1, indexbyte2 | ..., size => ..., result */
484         new VMOp(opc_anewarray, "anewarray", 1, 1, "I", "A"),
485         /* | ..., objectref => ..., length */
486         new VMOp(opc_arraylength, "arraylength", 1, 1, "A", "I"),
487         /* | ..., objectref => [undefined] */
488         new VMOp(opc_athrow, "athrow", 1, 0, "A", "?"),
489         /* idxbyte1, idxbyte2 | ..., objectref => ..., objectref */
490         new VMOp(opc_checkcast, "checkcast", 1, 1, "A", "A"),
491         /* idxbyte1, idxbyte2 | ..., objectref => ..., result */
492         new VMOp(opc_instanceof, "instanceof", 1, 1, "A", "I"),
493         /* | ..., objectref => ... */
494         new VMOp(opc_monitorenter, "monitorenter", 1, 0, "A", ""),
495         /* | ..., objectref => ... */
496         new VMOp(opc_monitorexit, "monitorexit", 1, 0, "A", ""),
497         /* an instruction | special */
498         new VMOp(opc_wide, "wide", 0, 0, "", ""),
499         /* indexbyte1, indexbyte2, dimensions | ..., size1, ..., sizen => ..., result*/
500         new VMOp(opc_multianewarray, "multianewarray", -1, 1, "?", "A"),
501         /* brbyte1, brbyte2 | ..., value => ... */
502         new VMOp(opc_ifnull, "ifnull", 1, 0, "A", ""),
503         /* brbyte1, brbyte2 | ..., value => ... */
504         new VMOp(opc_ifnonnull, "ifnonnull", 1, 0, "A", ""),
505         /* brbyte1, brbyte2, brbyte3, brbyte4 | no change */
506         new VMOp(opc_goto_w, "goto_w", 0, 0, "", ""),
507         /* brbyte1, brbyte2, brbyte3, brbyte4 | ... => ..., return_addr */
508         new VMOp(opc_jsr_w, "jsr_w", 0, 1, "", "W") };
509 
510     /***
511      * Check that each entry in the ops array has a valid VMOp entry
512      */
513     private static void check() {
514         for (int i=0; i<=opc_jsr_w; i++) {
515             VMOp op = ops[i];
516             if (op == null)
517                 throw new InsnError ("null VMOp for " + i);
518             if (op.opcode() != i)
519                 throw new InsnError ("bad opcode for " + i);
520 
521             if (1 == 0) {
522                 /* check arg/result data */
523                 checkTypes(op.argTypes(), op.nStackArgs(), op);
524                 checkTypes(op.resultTypes(), op.nStackResults(), op);
525             }
526         }
527     }
528 
529     private static void checkTypes(String types, int n, VMOp op) {
530         for (int i=0; i<types.length(); i++) {
531             char c = types.charAt(i);
532             if (c == '?')
533                 return;
534             if (c == 'J' || c == 'X' || c == 'D')
535                 n -= 2;
536             else
537                 n -= 1;
538         }
539         if (n != 0)
540             throw new InsnError ("Bad arg/result for VMOp " + op.opcodeName);
541     }
542 
543     static {
544         check();
545     }
546 }