1 /* |
|
2 * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. Sun designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Sun in the LICENSE file that accompanied this code. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
|
15 * accompanied this code). |
|
16 * |
|
17 * You should have received a copy of the GNU General Public License version |
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 * |
|
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 * CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 * have any questions. |
|
24 */ |
|
25 |
|
26 package com.sun.tools.classfile; |
|
27 |
|
28 import java.util.HashMap; |
|
29 |
|
30 /** |
|
31 * See JVMS3, section 6. |
|
32 * |
|
33 * <p><b>This is NOT part of any API supported by Sun Microsystems. If |
|
34 * you write code that depends on this, you do so at your own risk. |
|
35 * This code and its internal interfaces are subject to change or |
|
36 * deletion without notice.</b> |
|
37 */ |
|
38 public class OpCodes { |
|
39 |
|
40 public static int opcLength(int opc) throws IllegalArgumentException { |
|
41 switch (opc >> 8) { |
|
42 case 0: |
|
43 return opcLengthsTab[opc]; |
|
44 case opc_wide: |
|
45 switch (opc & 0xFF) { |
|
46 case opc_aload: |
|
47 case opc_astore: |
|
48 case opc_fload: |
|
49 case opc_fstore: |
|
50 case opc_iload: |
|
51 case opc_istore: |
|
52 case opc_lload: |
|
53 case opc_lstore: |
|
54 case opc_dload: |
|
55 case opc_dstore: |
|
56 case opc_ret: |
|
57 return 4; |
|
58 case opc_iinc: |
|
59 return 6; |
|
60 default: |
|
61 throw new IllegalArgumentException(); |
|
62 } |
|
63 case opc_nonpriv: |
|
64 case opc_priv: |
|
65 return 2; |
|
66 default: |
|
67 throw new IllegalArgumentException(); |
|
68 } |
|
69 } |
|
70 |
|
71 public static String opcName(int opc) { |
|
72 try { |
|
73 switch (opc >> 8) { |
|
74 case 0: |
|
75 return opcNamesTab[opc]; |
|
76 case opc_wide: |
|
77 { |
|
78 String mnem = opcNamesTab[opc & 0xFF] + "_w"; |
|
79 if (mnemocodes.get(mnem) == null) { |
|
80 return null; // non-existent opcode |
|
81 } |
|
82 return mnem; |
|
83 } |
|
84 case opc_nonpriv: |
|
85 return opcExtNamesTab[opc & 0xFF]; |
|
86 case opc_priv: |
|
87 return opcPrivExtNamesTab[opc & 0xFF]; |
|
88 default: |
|
89 return null; |
|
90 } |
|
91 } catch (ArrayIndexOutOfBoundsException e) { |
|
92 switch (opc) { |
|
93 case opc_nonpriv: |
|
94 return "nonpriv"; |
|
95 case opc_priv: |
|
96 return "priv"; |
|
97 default: |
|
98 return null; |
|
99 } |
|
100 } |
|
101 } |
|
102 |
|
103 /* Opcodes */ |
|
104 public static final int opc_dead = -2; |
|
105 public static final int opc_label = -1; |
|
106 public static final int opc_nop = 0; |
|
107 public static final int opc_aconst_null = 1; |
|
108 public static final int opc_iconst_m1 = 2; |
|
109 public static final int opc_iconst_0 = 3; |
|
110 public static final int opc_iconst_1 = 4; |
|
111 public static final int opc_iconst_2 = 5; |
|
112 public static final int opc_iconst_3 = 6; |
|
113 public static final int opc_iconst_4 = 7; |
|
114 public static final int opc_iconst_5 = 8; |
|
115 public static final int opc_lconst_0 = 9; |
|
116 public static final int opc_lconst_1 = 10; |
|
117 public static final int opc_fconst_0 = 11; |
|
118 public static final int opc_fconst_1 = 12; |
|
119 public static final int opc_fconst_2 = 13; |
|
120 public static final int opc_dconst_0 = 14; |
|
121 public static final int opc_dconst_1 = 15; |
|
122 public static final int opc_bipush = 16; |
|
123 public static final int opc_sipush = 17; |
|
124 public static final int opc_ldc = 18; |
|
125 public static final int opc_ldc_w = 19; |
|
126 public static final int opc_ldc2_w = 20; |
|
127 public static final int opc_iload = 21; |
|
128 public static final int opc_lload = 22; |
|
129 public static final int opc_fload = 23; |
|
130 public static final int opc_dload = 24; |
|
131 public static final int opc_aload = 25; |
|
132 public static final int opc_iload_0 = 26; |
|
133 public static final int opc_iload_1 = 27; |
|
134 public static final int opc_iload_2 = 28; |
|
135 public static final int opc_iload_3 = 29; |
|
136 public static final int opc_lload_0 = 30; |
|
137 public static final int opc_lload_1 = 31; |
|
138 public static final int opc_lload_2 = 32; |
|
139 public static final int opc_lload_3 = 33; |
|
140 public static final int opc_fload_0 = 34; |
|
141 public static final int opc_fload_1 = 35; |
|
142 public static final int opc_fload_2 = 36; |
|
143 public static final int opc_fload_3 = 37; |
|
144 public static final int opc_dload_0 = 38; |
|
145 public static final int opc_dload_1 = 39; |
|
146 public static final int opc_dload_2 = 40; |
|
147 public static final int opc_dload_3 = 41; |
|
148 public static final int opc_aload_0 = 42; |
|
149 public static final int opc_aload_1 = 43; |
|
150 public static final int opc_aload_2 = 44; |
|
151 public static final int opc_aload_3 = 45; |
|
152 public static final int opc_iaload = 46; |
|
153 public static final int opc_laload = 47; |
|
154 public static final int opc_faload = 48; |
|
155 public static final int opc_daload = 49; |
|
156 public static final int opc_aaload = 50; |
|
157 public static final int opc_baload = 51; |
|
158 public static final int opc_caload = 52; |
|
159 public static final int opc_saload = 53; |
|
160 public static final int opc_istore = 54; |
|
161 public static final int opc_lstore = 55; |
|
162 public static final int opc_fstore = 56; |
|
163 public static final int opc_dstore = 57; |
|
164 public static final int opc_astore = 58; |
|
165 public static final int opc_istore_0 = 59; |
|
166 public static final int opc_istore_1 = 60; |
|
167 public static final int opc_istore_2 = 61; |
|
168 public static final int opc_istore_3 = 62; |
|
169 public static final int opc_lstore_0 = 63; |
|
170 public static final int opc_lstore_1 = 64; |
|
171 public static final int opc_lstore_2 = 65; |
|
172 public static final int opc_lstore_3 = 66; |
|
173 public static final int opc_fstore_0 = 67; |
|
174 public static final int opc_fstore_1 = 68; |
|
175 public static final int opc_fstore_2 = 69; |
|
176 public static final int opc_fstore_3 = 70; |
|
177 public static final int opc_dstore_0 = 71; |
|
178 public static final int opc_dstore_1 = 72; |
|
179 public static final int opc_dstore_2 = 73; |
|
180 public static final int opc_dstore_3 = 74; |
|
181 public static final int opc_astore_0 = 75; |
|
182 public static final int opc_astore_1 = 76; |
|
183 public static final int opc_astore_2 = 77; |
|
184 public static final int opc_astore_3 = 78; |
|
185 public static final int opc_iastore = 79; |
|
186 public static final int opc_lastore = 80; |
|
187 public static final int opc_fastore = 81; |
|
188 public static final int opc_dastore = 82; |
|
189 public static final int opc_aastore = 83; |
|
190 public static final int opc_bastore = 84; |
|
191 public static final int opc_castore = 85; |
|
192 public static final int opc_sastore = 86; |
|
193 public static final int opc_pop = 87; |
|
194 public static final int opc_pop2 = 88; |
|
195 public static final int opc_dup = 89; |
|
196 public static final int opc_dup_x1 = 90; |
|
197 public static final int opc_dup_x2 = 91; |
|
198 public static final int opc_dup2 = 92; |
|
199 public static final int opc_dup2_x1 = 93; |
|
200 public static final int opc_dup2_x2 = 94; |
|
201 public static final int opc_swap = 95; |
|
202 public static final int opc_iadd = 96; |
|
203 public static final int opc_ladd = 97; |
|
204 public static final int opc_fadd = 98; |
|
205 public static final int opc_dadd = 99; |
|
206 public static final int opc_isub = 100; |
|
207 public static final int opc_lsub = 101; |
|
208 public static final int opc_fsub = 102; |
|
209 public static final int opc_dsub = 103; |
|
210 public static final int opc_imul = 104; |
|
211 public static final int opc_lmul = 105; |
|
212 public static final int opc_fmul = 106; |
|
213 public static final int opc_dmul = 107; |
|
214 public static final int opc_idiv = 108; |
|
215 public static final int opc_ldiv = 109; |
|
216 public static final int opc_fdiv = 110; |
|
217 public static final int opc_ddiv = 111; |
|
218 public static final int opc_irem = 112; |
|
219 public static final int opc_lrem = 113; |
|
220 public static final int opc_frem = 114; |
|
221 public static final int opc_drem = 115; |
|
222 public static final int opc_ineg = 116; |
|
223 public static final int opc_lneg = 117; |
|
224 public static final int opc_fneg = 118; |
|
225 public static final int opc_dneg = 119; |
|
226 public static final int opc_ishl = 120; |
|
227 public static final int opc_lshl = 121; |
|
228 public static final int opc_ishr = 122; |
|
229 public static final int opc_lshr = 123; |
|
230 public static final int opc_iushr = 124; |
|
231 public static final int opc_lushr = 125; |
|
232 public static final int opc_iand = 126; |
|
233 public static final int opc_land = 127; |
|
234 public static final int opc_ior = 128; |
|
235 public static final int opc_lor = 129; |
|
236 public static final int opc_ixor = 130; |
|
237 public static final int opc_lxor = 131; |
|
238 public static final int opc_iinc = 132; |
|
239 public static final int opc_i2l = 133; |
|
240 public static final int opc_i2f = 134; |
|
241 public static final int opc_i2d = 135; |
|
242 public static final int opc_l2i = 136; |
|
243 public static final int opc_l2f = 137; |
|
244 public static final int opc_l2d = 138; |
|
245 public static final int opc_f2i = 139; |
|
246 public static final int opc_f2l = 140; |
|
247 public static final int opc_f2d = 141; |
|
248 public static final int opc_d2i = 142; |
|
249 public static final int opc_d2l = 143; |
|
250 public static final int opc_d2f = 144; |
|
251 public static final int opc_i2b = 145; |
|
252 public static final int opc_int2byte = 145; |
|
253 public static final int opc_i2c = 146; |
|
254 public static final int opc_int2char = 146; |
|
255 public static final int opc_i2s = 147; |
|
256 public static final int opc_int2short = 147; |
|
257 public static final int opc_lcmp = 148; |
|
258 public static final int opc_fcmpl = 149; |
|
259 public static final int opc_fcmpg = 150; |
|
260 public static final int opc_dcmpl = 151; |
|
261 public static final int opc_dcmpg = 152; |
|
262 public static final int opc_ifeq = 153; |
|
263 public static final int opc_ifne = 154; |
|
264 public static final int opc_iflt = 155; |
|
265 public static final int opc_ifge = 156; |
|
266 public static final int opc_ifgt = 157; |
|
267 public static final int opc_ifle = 158; |
|
268 public static final int opc_if_icmpeq = 159; |
|
269 public static final int opc_if_icmpne = 160; |
|
270 public static final int opc_if_icmplt = 161; |
|
271 public static final int opc_if_icmpge = 162; |
|
272 public static final int opc_if_icmpgt = 163; |
|
273 public static final int opc_if_icmple = 164; |
|
274 public static final int opc_if_acmpeq = 165; |
|
275 public static final int opc_if_acmpne = 166; |
|
276 public static final int opc_goto = 167; |
|
277 public static final int opc_jsr = 168; |
|
278 public static final int opc_ret = 169; |
|
279 public static final int opc_tableswitch = 170; |
|
280 public static final int opc_lookupswitch = 171; |
|
281 public static final int opc_ireturn = 172; |
|
282 public static final int opc_lreturn = 173; |
|
283 public static final int opc_freturn = 174; |
|
284 public static final int opc_dreturn = 175; |
|
285 public static final int opc_areturn = 176; |
|
286 public static final int opc_return = 177; |
|
287 public static final int opc_getstatic = 178; |
|
288 public static final int opc_putstatic = 179; |
|
289 public static final int opc_getfield = 180; |
|
290 public static final int opc_putfield = 181; |
|
291 public static final int opc_invokevirtual = 182; |
|
292 public static final int opc_invokenonvirtual = 183; |
|
293 public static final int opc_invokespecial = 183; |
|
294 public static final int opc_invokestatic = 184; |
|
295 public static final int opc_invokeinterface = 185; |
|
296 // public static final int opc_xxxunusedxxx = 186; |
|
297 public static final int opc_new = 187; |
|
298 public static final int opc_newarray = 188; |
|
299 public static final int opc_anewarray = 189; |
|
300 public static final int opc_arraylength = 190; |
|
301 public static final int opc_athrow = 191; |
|
302 public static final int opc_checkcast = 192; |
|
303 public static final int opc_instanceof = 193; |
|
304 public static final int opc_monitorenter = 194; |
|
305 public static final int opc_monitorexit = 195; |
|
306 public static final int opc_wide = 196; |
|
307 public static final int opc_multianewarray = 197; |
|
308 public static final int opc_ifnull = 198; |
|
309 public static final int opc_ifnonnull = 199; |
|
310 public static final int opc_goto_w = 200; |
|
311 public static final int opc_jsr_w = 201; |
|
312 |
|
313 /* Pseudo-instructions */ |
|
314 public static final int opc_bytecode = 203; |
|
315 public static final int opc_try = 204; |
|
316 public static final int opc_endtry = 205; |
|
317 public static final int opc_catch = 206; |
|
318 public static final int opc_var = 207; |
|
319 public static final int opc_endvar = 208; |
|
320 public static final int opc_localsmap = 209; |
|
321 public static final int opc_stackmap = 210; |
|
322 |
|
323 /* PicoJava prefixes */ |
|
324 public static final int opc_nonpriv = 254; |
|
325 public static final int opc_priv = 255; |
|
326 |
|
327 /* Wide instructions */ |
|
328 public static final int opc_iload_w = (opc_wide << 8 ) | opc_iload; |
|
329 public static final int opc_lload_w = (opc_wide << 8 ) | opc_lload; |
|
330 public static final int opc_fload_w = (opc_wide << 8 ) | opc_fload; |
|
331 public static final int opc_dload_w = (opc_wide << 8 ) | opc_dload; |
|
332 public static final int opc_aload_w = (opc_wide << 8 ) | opc_aload; |
|
333 public static final int opc_istore_w = (opc_wide << 8 ) | opc_istore; |
|
334 public static final int opc_lstore_w = (opc_wide << 8 ) | opc_lstore; |
|
335 public static final int opc_fstore_w = (opc_wide << 8 ) | opc_fstore; |
|
336 public static final int opc_dstore_w = (opc_wide << 8 ) | opc_dstore; |
|
337 public static final int opc_astore_w = (opc_wide << 8 ) | opc_astore; |
|
338 public static final int opc_ret_w = (opc_wide << 8 ) | opc_ret; |
|
339 public static final int opc_iinc_w = (opc_wide << 8 ) | opc_iinc; |
|
340 |
|
341 /* Opcode Names */ |
|
342 private static final String opcNamesTab[] = { |
|
343 "nop", |
|
344 "aconst_null", |
|
345 "iconst_m1", |
|
346 "iconst_0", |
|
347 "iconst_1", |
|
348 "iconst_2", |
|
349 "iconst_3", |
|
350 "iconst_4", |
|
351 "iconst_5", |
|
352 "lconst_0", |
|
353 "lconst_1", |
|
354 "fconst_0", |
|
355 "fconst_1", |
|
356 "fconst_2", |
|
357 "dconst_0", |
|
358 "dconst_1", |
|
359 "bipush", |
|
360 "sipush", |
|
361 "ldc", |
|
362 "ldc_w", |
|
363 "ldc2_w", |
|
364 "iload", |
|
365 "lload", |
|
366 "fload", |
|
367 "dload", |
|
368 "aload", |
|
369 "iload_0", |
|
370 "iload_1", |
|
371 "iload_2", |
|
372 "iload_3", |
|
373 "lload_0", |
|
374 "lload_1", |
|
375 "lload_2", |
|
376 "lload_3", |
|
377 "fload_0", |
|
378 "fload_1", |
|
379 "fload_2", |
|
380 "fload_3", |
|
381 "dload_0", |
|
382 "dload_1", |
|
383 "dload_2", |
|
384 "dload_3", |
|
385 "aload_0", |
|
386 "aload_1", |
|
387 "aload_2", |
|
388 "aload_3", |
|
389 "iaload", |
|
390 "laload", |
|
391 "faload", |
|
392 "daload", |
|
393 "aaload", |
|
394 "baload", |
|
395 "caload", |
|
396 "saload", |
|
397 "istore", |
|
398 "lstore", |
|
399 "fstore", |
|
400 "dstore", |
|
401 "astore", |
|
402 "istore_0", |
|
403 "istore_1", |
|
404 "istore_2", |
|
405 "istore_3", |
|
406 "lstore_0", |
|
407 "lstore_1", |
|
408 "lstore_2", |
|
409 "lstore_3", |
|
410 "fstore_0", |
|
411 "fstore_1", |
|
412 "fstore_2", |
|
413 "fstore_3", |
|
414 "dstore_0", |
|
415 "dstore_1", |
|
416 "dstore_2", |
|
417 "dstore_3", |
|
418 "astore_0", |
|
419 "astore_1", |
|
420 "astore_2", |
|
421 "astore_3", |
|
422 "iastore", |
|
423 "lastore", |
|
424 "fastore", |
|
425 "dastore", |
|
426 "aastore", |
|
427 "bastore", |
|
428 "castore", |
|
429 "sastore", |
|
430 "pop", |
|
431 "pop2", |
|
432 "dup", |
|
433 "dup_x1", |
|
434 "dup_x2", |
|
435 "dup2", |
|
436 "dup2_x1", |
|
437 "dup2_x2", |
|
438 "swap", |
|
439 "iadd", |
|
440 "ladd", |
|
441 "fadd", |
|
442 "dadd", |
|
443 "isub", |
|
444 "lsub", |
|
445 "fsub", |
|
446 "dsub", |
|
447 "imul", |
|
448 "lmul", |
|
449 "fmul", |
|
450 "dmul", |
|
451 "idiv", |
|
452 "ldiv", |
|
453 "fdiv", |
|
454 "ddiv", |
|
455 "irem", |
|
456 "lrem", |
|
457 "frem", |
|
458 "drem", |
|
459 "ineg", |
|
460 "lneg", |
|
461 "fneg", |
|
462 "dneg", |
|
463 "ishl", |
|
464 "lshl", |
|
465 "ishr", |
|
466 "lshr", |
|
467 "iushr", |
|
468 "lushr", |
|
469 "iand", |
|
470 "land", |
|
471 "ior", |
|
472 "lor", |
|
473 "ixor", |
|
474 "lxor", |
|
475 "iinc", |
|
476 "i2l", |
|
477 "i2f", |
|
478 "i2d", |
|
479 "l2i", |
|
480 "l2f", |
|
481 "l2d", |
|
482 "f2i", |
|
483 "f2l", |
|
484 "f2d", |
|
485 "d2i", |
|
486 "d2l", |
|
487 "d2f", |
|
488 "i2b", |
|
489 "i2c", |
|
490 "i2s", |
|
491 "lcmp", |
|
492 "fcmpl", |
|
493 "fcmpg", |
|
494 "dcmpl", |
|
495 "dcmpg", |
|
496 "ifeq", |
|
497 "ifne", |
|
498 "iflt", |
|
499 "ifge", |
|
500 "ifgt", |
|
501 "ifle", |
|
502 "if_icmpeq", |
|
503 "if_icmpne", |
|
504 "if_icmplt", |
|
505 "if_icmpge", |
|
506 "if_icmpgt", |
|
507 "if_icmple", |
|
508 "if_acmpeq", |
|
509 "if_acmpne", |
|
510 "goto", |
|
511 "jsr", |
|
512 "ret", |
|
513 "tableswitch", |
|
514 "lookupswitch", |
|
515 "ireturn", |
|
516 "lreturn", |
|
517 "freturn", |
|
518 "dreturn", |
|
519 "areturn", |
|
520 "return", |
|
521 "getstatic", |
|
522 "putstatic", |
|
523 "getfield", |
|
524 "putfield", |
|
525 "invokevirtual", |
|
526 "invokespecial", // was "invokenonvirtual", |
|
527 "invokestatic", |
|
528 "invokeinterface", |
|
529 "bytecode 186", //"xxxunusedxxx", |
|
530 "new", |
|
531 "newarray", |
|
532 "anewarray", |
|
533 "arraylength", |
|
534 "athrow", |
|
535 "checkcast", |
|
536 "instanceof", |
|
537 "monitorenter", |
|
538 "monitorexit", |
|
539 null, // "wide", |
|
540 "multianewarray", |
|
541 "ifnull", |
|
542 "ifnonnull", |
|
543 "goto_w", |
|
544 "jsr_w", |
|
545 "bytecode 202", // "breakpoint", |
|
546 "bytecode", |
|
547 "try", |
|
548 "endtry", |
|
549 "catch", |
|
550 "var", |
|
551 "endvar", |
|
552 "locals_map", |
|
553 "stack_map" |
|
554 }; |
|
555 |
|
556 /* Opcode Lengths */ |
|
557 private static final int opcLengthsTab[] = { |
|
558 1, |
|
559 1, |
|
560 1, |
|
561 1, |
|
562 1, |
|
563 1, |
|
564 1, |
|
565 1, |
|
566 1, |
|
567 1, |
|
568 1, |
|
569 1, |
|
570 1, |
|
571 1, |
|
572 1, |
|
573 1, |
|
574 2, |
|
575 3, |
|
576 2, |
|
577 3, |
|
578 3, |
|
579 2, |
|
580 2, |
|
581 2, |
|
582 2, |
|
583 2, |
|
584 1, |
|
585 1, |
|
586 1, |
|
587 1, |
|
588 1, |
|
589 1, |
|
590 1, |
|
591 1, |
|
592 1, |
|
593 1, |
|
594 1, |
|
595 1, |
|
596 1, |
|
597 1, |
|
598 1, |
|
599 1, |
|
600 1, |
|
601 1, |
|
602 1, |
|
603 1, |
|
604 1, |
|
605 1, |
|
606 1, |
|
607 1, |
|
608 1, |
|
609 1, |
|
610 1, |
|
611 1, |
|
612 2, |
|
613 2, |
|
614 2, |
|
615 2, |
|
616 2, |
|
617 1, |
|
618 1, |
|
619 1, |
|
620 1, |
|
621 1, |
|
622 1, |
|
623 1, |
|
624 1, |
|
625 1, |
|
626 1, |
|
627 1, |
|
628 1, |
|
629 1, |
|
630 1, |
|
631 1, |
|
632 1, |
|
633 1, |
|
634 1, |
|
635 1, |
|
636 1, |
|
637 1, |
|
638 1, |
|
639 1, |
|
640 1, |
|
641 1, |
|
642 1, |
|
643 1, |
|
644 1, |
|
645 1, |
|
646 1, |
|
647 1, |
|
648 1, |
|
649 1, |
|
650 1, |
|
651 1, |
|
652 1, |
|
653 1, |
|
654 1, |
|
655 1, |
|
656 1, |
|
657 1, |
|
658 1, |
|
659 1, |
|
660 1, |
|
661 1, |
|
662 1, |
|
663 1, |
|
664 1, |
|
665 1, |
|
666 1, |
|
667 1, |
|
668 1, |
|
669 1, |
|
670 1, |
|
671 1, |
|
672 1, |
|
673 1, |
|
674 1, |
|
675 1, |
|
676 1, |
|
677 1, |
|
678 1, |
|
679 1, |
|
680 1, |
|
681 1, |
|
682 1, |
|
683 1, |
|
684 1, |
|
685 1, |
|
686 1, |
|
687 1, |
|
688 1, |
|
689 1, |
|
690 3, |
|
691 1, |
|
692 1, |
|
693 1, |
|
694 1, |
|
695 1, |
|
696 1, |
|
697 1, |
|
698 1, |
|
699 1, |
|
700 1, |
|
701 1, |
|
702 1, |
|
703 1, |
|
704 1, |
|
705 1, |
|
706 1, |
|
707 1, |
|
708 1, |
|
709 1, |
|
710 1, |
|
711 3, |
|
712 3, |
|
713 3, |
|
714 3, |
|
715 3, |
|
716 3, |
|
717 3, |
|
718 3, |
|
719 3, |
|
720 3, |
|
721 3, |
|
722 3, |
|
723 3, |
|
724 3, |
|
725 3, |
|
726 3, |
|
727 2, |
|
728 99, |
|
729 99, |
|
730 1, |
|
731 1, |
|
732 1, |
|
733 1, |
|
734 1, |
|
735 1, |
|
736 3, |
|
737 3, |
|
738 3, |
|
739 3, |
|
740 3, |
|
741 3, |
|
742 3, |
|
743 5, |
|
744 0, |
|
745 3, |
|
746 2, |
|
747 3, |
|
748 1, |
|
749 1, |
|
750 3, |
|
751 3, |
|
752 1, |
|
753 1, |
|
754 0, // wide |
|
755 4, |
|
756 3, |
|
757 3, |
|
758 5, |
|
759 5, |
|
760 1, |
|
761 1, 0, 0, 0, 0, 0 // pseudo |
|
762 }; |
|
763 |
|
764 /* Type codes, used in newarray opcode */ |
|
765 public static final int T_CLASS = 0x00000002; |
|
766 public static final int T_BOOLEAN = 0x00000004; |
|
767 public static final int T_CHAR = 0x00000005; |
|
768 public static final int T_FLOAT = 0x00000006; |
|
769 public static final int T_DOUBLE = 0x00000007; |
|
770 public static final int T_BYTE = 0x00000008; |
|
771 public static final int T_SHORT = 0x00000009; |
|
772 public static final int T_INT = 0x0000000a; |
|
773 public static final int T_LONG = 0x0000000b; |
|
774 |
|
775 private static HashMap<String,Integer> mnemocodes = new HashMap<String,Integer>(301, 0.5f); |
|
776 private static String opcExtNamesTab[]=new String[128]; |
|
777 private static String opcPrivExtNamesTab[]=new String[128]; |
|
778 |
|
779 private static void defineNonPriv(int opc, String mnem) { |
|
780 mnemocodes.put(opcExtNamesTab[opc] = mnem, opc_nonpriv * 256 + opc); |
|
781 } |
|
782 |
|
783 private static void definePriv(int opc, String mnem) { |
|
784 mnemocodes.put(opcPrivExtNamesTab[opc] = "priv_" + mnem, opc_priv * 256 + opc); |
|
785 } |
|
786 |
|
787 private static void defineExt(int opc, String mnem) { |
|
788 defineNonPriv(opc, mnem); |
|
789 definePriv(opc, mnem); |
|
790 } |
|
791 |
|
792 static { |
|
793 for (int i = 0; i < opc_wide; i++) { |
|
794 mnemocodes.put(opcNamesTab[i], i); |
|
795 } |
|
796 for (int i = opc_wide + 1; i < opcNamesTab.length; i++) { |
|
797 mnemocodes.put(opcNamesTab[i], i); |
|
798 } |
|
799 mnemocodes.put("invokenonvirtual", opc_invokespecial); |
|
800 |
|
801 mnemocodes.put("iload_w", opc_iload_w); |
|
802 mnemocodes.put("lload_w", opc_lload_w); |
|
803 mnemocodes.put("fload_w", opc_fload_w); |
|
804 mnemocodes.put("dload_w", opc_dload_w); |
|
805 mnemocodes.put("aload_w", opc_aload_w); |
|
806 mnemocodes.put("istore_w", opc_istore_w); |
|
807 mnemocodes.put("lstore_w", opc_lstore_w); |
|
808 mnemocodes.put("fstore_w", opc_fstore_w); |
|
809 mnemocodes.put("dstore_w", opc_dstore_w); |
|
810 mnemocodes.put("astore_w", opc_astore_w); |
|
811 mnemocodes.put("ret_w", opc_ret_w); |
|
812 mnemocodes.put("iinc_w", opc_iinc_w); |
|
813 |
|
814 mnemocodes.put("nonpriv", opc_nonpriv); |
|
815 mnemocodes.put("priv", opc_priv); |
|
816 |
|
817 defineExt(0, "load_ubyte"); |
|
818 defineExt(1, "load_byte"); |
|
819 defineExt(2, "load_char"); |
|
820 defineExt(3, "load_short"); |
|
821 defineExt(4, "load_word"); |
|
822 defineExt(10, "load_char_oe"); |
|
823 defineExt(11, "load_short_oe"); |
|
824 defineExt(12, "load_word_oe"); |
|
825 defineExt(16, "ncload_ubyte"); |
|
826 defineExt(17, "ncload_byte"); |
|
827 defineExt(18, "ncload_char"); |
|
828 defineExt(19, "ncload_short"); |
|
829 defineExt(20, "ncload_word"); |
|
830 defineExt(26, "ncload_char_oe"); |
|
831 defineExt(27, "ncload_short_oe"); |
|
832 defineExt(28, "ncload_word_oe"); |
|
833 defineExt(30, "cache_flush"); |
|
834 defineExt(32, "store_byte"); |
|
835 defineExt(34, "store_short"); |
|
836 defineExt(36, "store_word"); |
|
837 defineExt(42, "store_short_oe"); |
|
838 defineExt(44, "store_word_oe"); |
|
839 defineExt(48, "ncstore_byte"); |
|
840 defineExt(50, "ncstore_short"); |
|
841 defineExt(52, "ncstore_word"); |
|
842 defineExt(58, "ncstore_short_oe"); |
|
843 defineExt(60, "ncstore_word_oe"); |
|
844 defineExt(62, "zero_line"); |
|
845 defineNonPriv(5, "ret_from_sub"); |
|
846 defineNonPriv(63, "enter_sync_method"); |
|
847 definePriv(5, "ret_from_trap"); |
|
848 definePriv(6, "read_dcache_tag"); |
|
849 definePriv(7, "read_dcache_data"); |
|
850 definePriv(14, "read_icache_tag"); |
|
851 definePriv(15, "read_icache_data"); |
|
852 definePriv(22, "powerdown"); |
|
853 definePriv(23, "read_scache_data"); |
|
854 definePriv(31, "cache_index_flush"); |
|
855 definePriv(38, "write_dcache_tag"); |
|
856 definePriv(39, "write_dcache_data"); |
|
857 definePriv(46, "write_icache_tag"); |
|
858 definePriv(47, "write_icache_data"); |
|
859 definePriv(54, "reset"); |
|
860 definePriv(55, "write_scache_data"); |
|
861 for (int i = 0; i < 32; i++) { |
|
862 definePriv(i + 64, "read_reg_" + i); |
|
863 } |
|
864 for (int i = 0; i < 32; i++) { |
|
865 definePriv(i + 96, "write_reg_" + i); |
|
866 } |
|
867 } |
|
868 } |
|