View Javadoc

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