* vm/tables.h: Removed.
[cacao.git] / src / vm / jit / stack.c
1 /* src/vm/jit/stack.c - stack analysis
2
3    Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4    R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5    C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6    Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23    02111-1307, USA.
24
25    Contact: cacao@complang.tuwien.ac.at
26
27    Authors: Andreas Krall
28
29    Changes: Edwin Steiner
30             Christian Thalinger
31             Christian Ullrich
32
33    $Id: stack.c 3848 2005-12-03 12:31:30Z twisti $
34
35 */
36
37
38 #include <assert.h>
39 #include <stdio.h>
40 #include <string.h>
41
42 #include "vm/types.h"
43
44 #include "arch.h"
45 #include "md-abi.h"
46
47 #include "mm/memory.h"
48 #include "native/native.h"
49 #include "toolbox/logging.h"
50 #include "vm/global.h"
51 #include "vm/builtin.h"
52 #include "vm/options.h"
53 #include "vm/resolve.h"
54 #include "vm/statistics.h"
55 #include "vm/stringlocal.h"
56 #include "vm/jit/codegen.inc.h"
57 #include "vm/jit/disass.h"
58 #include "vm/jit/jit.h"
59 #include "vm/jit/reg.h"
60 #include "vm/jit/stack.h"
61 #include "vm/jit/lsra.h"
62
63
64 /* global variables ***********************************************************/
65
66 #if defined(USE_THREADS)
67 static java_objectheader *lock_show_icmd;
68 #endif
69
70
71 /* stack_init ******************************************************************
72
73    Initialized the stack analysis subsystem (called by jit_init).
74
75 *******************************************************************************/
76
77 bool stack_init(void)
78 {
79 #if defined(USE_THREADS)
80         /* initialize the show lock */
81
82         lock_show_icmd = NEW(java_objectheader);
83
84 # if defined(NATIVE_THREADS)
85         initObjectLock(lock_show_icmd);
86 # endif
87 #endif
88
89         /* everything's ok */
90
91         return true;
92 }
93
94
95 /**********************************************************************/
96 /* analyse_stack                                                      */
97 /**********************************************************************/
98
99 /* analyse_stack uses the intermediate code created by parse.c to
100  * build a model of the JVM operand stack for the current method.
101  *
102  * The following checks are performed:
103  *   - check for operand stack underflow (before each instruction)
104  *   - check for operand stack overflow (after[1] each instruction)
105  *   - check for matching stack depth at merging points
106  *   - check for matching basic types[2] at merging points
107  *   - check basic types for instruction input (except for BUILTIN*
108  *         opcodes, INVOKE* opcodes and MULTIANEWARRAY)
109  *
110  * [1]) Checking this after the instruction should be ok. parse.c
111  * counts the number of required stack slots in such a way that it is
112  * only vital that we don't exceed `maxstack` at basic block
113  * boundaries.
114  *
115  * [2]) 'basic types' means the distinction between INT, LONG, FLOAT,
116  * DOUBLE and ADDRESS types. Subtypes of INT and different ADDRESS
117  * types are not discerned.
118  */
119
120 methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
121 {
122         int           b_count;
123         int           b_index;
124         int           stackdepth;
125         stackptr      curstack;
126         stackptr      new;
127         stackptr      copy;
128         int           opcode, i, len, loops;
129         int           superblockend, repeat, deadcode;
130         instruction  *iptr;
131         basicblock   *bptr;
132         basicblock   *tbptr;
133         s4           *s4ptr;
134         void        **tptr;
135         s4           *argren;
136
137         builtintable_entry *bte;
138         unresolved_method  *um;
139         methoddesc         *md;
140
141 #ifdef LSRA
142         m->maxlifetimes = 0;
143 #endif
144
145         argren = DMNEW(s4, cd->maxlocals);   /* table for argument renaming       */
146         for (i = 0; i < cd->maxlocals; i++)
147                 argren[i] = i;
148         
149         new = m->stack;
150         loops = 0;
151         m->basicblocks[0].flags = BBREACHED;
152         m->basicblocks[0].instack = 0;
153         m->basicblocks[0].indepth = 0;
154
155         for (i = 0; i < cd->exceptiontablelength; i++) {
156                 bptr = &m->basicblocks[m->basicblockindex[cd->exceptiontable[i].handlerpc]];
157                 bptr->flags = BBREACHED;
158                 bptr->type = BBTYPE_EXH;
159                 bptr->instack = new;
160                 bptr->indepth = 1;
161                 bptr->pre_count = 10000;
162                 STACKRESET;
163                 NEWXSTACK;
164         }
165
166 #if CONDITIONAL_LOADCONST
167         b_count = m->basicblockcount;
168         bptr = m->basicblocks;
169         while (--b_count >= 0) {
170                 if (bptr->icount != 0) {
171                         iptr = bptr->iinstr + bptr->icount - 1;
172                         switch (iptr->opc) {
173                         case ICMD_RET:
174                         case ICMD_RETURN:
175                         case ICMD_IRETURN:
176                         case ICMD_LRETURN:
177                         case ICMD_FRETURN:
178                         case ICMD_DRETURN:
179                         case ICMD_ARETURN:
180                         case ICMD_ATHROW:
181                                 break;
182
183                         case ICMD_IFEQ:
184                         case ICMD_IFNE:
185                         case ICMD_IFLT:
186                         case ICMD_IFGE:
187                         case ICMD_IFGT:
188                         case ICMD_IFLE:
189
190                         case ICMD_IFNULL:
191                         case ICMD_IFNONNULL:
192
193                         case ICMD_IF_ICMPEQ:
194                         case ICMD_IF_ICMPNE:
195                         case ICMD_IF_ICMPLT:
196                         case ICMD_IF_ICMPGE:
197                         case ICMD_IF_ICMPGT:
198                         case ICMD_IF_ICMPLE:
199
200                         case ICMD_IF_ACMPEQ:
201                         case ICMD_IF_ACMPNE:
202                                 bptr[1].pre_count++;
203                         case ICMD_GOTO:
204                                 m->basicblocks[m->basicblockindex[iptr->op1]].pre_count++;
205                                 break;
206
207                         case ICMD_TABLESWITCH:
208                                 s4ptr = iptr->val.a;
209                                 m->basicblocks[m->basicblockindex[*s4ptr++]].pre_count++;
210                                 i = *s4ptr++;                               /* low     */
211                                 i = *s4ptr++ - i + 1;                       /* high    */
212                                 while (--i >= 0) {
213                                         m->basicblocks[m->basicblockindex[*s4ptr++]].pre_count++;
214                                 }
215                                 break;
216                                         
217                         case ICMD_LOOKUPSWITCH:
218                                 s4ptr = iptr->val.a;
219                                 m->basicblocks[m->basicblockindex[*s4ptr++]].pre_count++;
220                                 i = *s4ptr++;                               /* count   */
221                                 while (--i >= 0) {
222                                         m->basicblocks[m->basicblockindex[s4ptr[1]]].pre_count++;
223                                         s4ptr += 2;
224                                 }
225                                 break;
226                         default:
227                                 bptr[1].pre_count++;
228                                 break;
229                         }
230                 }
231                 bptr++;
232         }
233 #endif /* CONDITIONAL_LOADCONST */
234
235
236         do {
237                 loops++;
238                 b_count = m->basicblockcount;
239                 bptr = m->basicblocks;
240                 superblockend = true;
241                 repeat = false;
242                 STACKRESET;
243                 deadcode = true;
244
245                 while (--b_count >= 0) {
246                         if (bptr->flags == BBDELETED) {
247                                 /* do nothing */
248
249                         } else if (superblockend && (bptr->flags < BBREACHED)) {
250                                 repeat = true;
251
252                         } else if (bptr->flags <= BBREACHED) {
253                                 if (superblockend) {
254                                         stackdepth = bptr->indepth;
255
256                                 } else if (bptr->flags < BBREACHED) {
257                                         COPYCURSTACK(copy);
258                                         bptr->instack = copy;
259                                         bptr->indepth = stackdepth;
260
261                                 } else if (bptr->indepth != stackdepth) {
262                                         /*show_icmd_method(m, cd, rd);
263                                         printf("Block: %d, required depth: %d, current depth: %d\n",
264                                         bptr->debug_nr, bptr->indepth, stackdepth);*/
265                                         *exceptionptr = new_verifyerror(m,"Stack depth mismatch");
266                                         return NULL;
267                                 }
268
269                                 curstack = bptr->instack;
270                                 deadcode = false;
271                                 superblockend = false;
272                                 bptr->flags = BBFINISHED;
273                                 len = bptr->icount;
274                                 iptr = bptr->iinstr;
275                                 b_index = bptr - m->basicblocks;
276
277                                 while (--len >= 0)  {
278                                         opcode = iptr->opc;
279
280 #if defined(USEBUILTINTABLE)
281 # if defined(ENABLE_INTRP)
282                                         if (!opt_intrp) {
283 # endif
284                                                 bte = builtintable_get_automatic(opcode);
285
286                                                 if (bte && bte->opcode == opcode) {
287                                                         iptr->opc = ICMD_BUILTIN;
288                                                         iptr->op1 = false;   /* don't check for exception */
289                                                         iptr->val.a = bte;
290                                                         m->isleafmethod = false;
291                                                         goto builtin;
292                                                 }
293 # if defined(ENABLE_INTRP)
294                                         }
295 # endif
296 #endif /* defined(USEBUILTINTABLE) */
297                                         
298                                         switch (opcode) {
299
300                                                 /* pop 0 push 0 */
301
302                                         case ICMD_CHECKNULL:
303                                                 COUNT(count_check_null);
304                                         case ICMD_NOP:
305
306                                         case ICMD_IFEQ_ICONST:
307                                         case ICMD_IFNE_ICONST:
308                                         case ICMD_IFLT_ICONST:
309                                         case ICMD_IFGE_ICONST:
310                                         case ICMD_IFGT_ICONST:
311                                         case ICMD_IFLE_ICONST:
312                                         case ICMD_ELSE_ICONST:
313                                                 SETDST;
314                                                 break;
315
316                                         case ICMD_RET:
317 #if defined(ENABLE_INTRP)
318                                                 if (!opt_intrp)
319 #endif
320                                                         rd->locals[iptr->op1][TYPE_ADR].type = TYPE_ADR;
321                                         case ICMD_RETURN:
322                                                 COUNT(count_pcmd_return);
323                                                 SETDST;
324                                                 superblockend = true;
325                                                 break;
326
327                                                 /* pop 0 push 1 const */
328                                                 
329                                         case ICMD_ICONST:
330                                                 COUNT(count_pcmd_load);
331                                                 if (len > 0) {
332                                                         switch (iptr[1].opc) {
333                                                         case ICMD_IADD:
334                                                                 iptr[0].opc = ICMD_IADDCONST;
335                                                         icmd_iconst_tail:
336                                                                 iptr[1].opc = ICMD_NOP;
337                                                                 OP1_1(TYPE_INT, TYPE_INT);
338                                                                 COUNT(count_pcmd_op);
339                                                                 break;
340                                                         case ICMD_ISUB:
341                                                                 iptr[0].opc = ICMD_ISUBCONST;
342                                                                 goto icmd_iconst_tail;
343 #if SUPPORT_CONST_MUL
344                                                         case ICMD_IMUL:
345                                                                 iptr[0].opc = ICMD_IMULCONST;
346                                                                 goto icmd_iconst_tail;
347 #else /* SUPPORT_CONST_MUL */
348                                                         case ICMD_IMUL:
349                                                                 if (iptr[0].val.i == 0x00000002)
350                                                                         iptr[0].val.i = 1;
351                                                                 else if (iptr[0].val.i == 0x00000004)
352                                                                         iptr[0].val.i = 2;
353                                                                 else if (iptr[0].val.i == 0x00000008)
354                                                                         iptr[0].val.i = 3;
355                                                                 else if (iptr[0].val.i == 0x00000010)
356                                                                         iptr[0].val.i = 4;
357                                                                 else if (iptr[0].val.i == 0x00000020)
358                                                                         iptr[0].val.i = 5;
359                                                                 else if (iptr[0].val.i == 0x00000040)
360                                                                         iptr[0].val.i = 6;
361                                                                 else if (iptr[0].val.i == 0x00000080)
362                                                                         iptr[0].val.i = 7;
363                                                                 else if (iptr[0].val.i == 0x00000100)
364                                                                         iptr[0].val.i = 8;
365                                                                 else if (iptr[0].val.i == 0x00000200)
366                                                                         iptr[0].val.i = 9;
367                                                                 else if (iptr[0].val.i == 0x00000400)
368                                                                         iptr[0].val.i = 10;
369                                                                 else if (iptr[0].val.i == 0x00000800)
370                                                                         iptr[0].val.i = 11;
371                                                                 else if (iptr[0].val.i == 0x00001000)
372                                                                         iptr[0].val.i = 12;
373                                                                 else if (iptr[0].val.i == 0x00002000)
374                                                                         iptr[0].val.i = 13;
375                                                                 else if (iptr[0].val.i == 0x00004000)
376                                                                         iptr[0].val.i = 14;
377                                                                 else if (iptr[0].val.i == 0x00008000)
378                                                                         iptr[0].val.i = 15;
379                                                                 else if (iptr[0].val.i == 0x00010000)
380                                                                         iptr[0].val.i = 16;
381                                                                 else if (iptr[0].val.i == 0x00020000)
382                                                                         iptr[0].val.i = 17;
383                                                                 else if (iptr[0].val.i == 0x00040000)
384                                                                         iptr[0].val.i = 18;
385                                                                 else if (iptr[0].val.i == 0x00080000)
386                                                                         iptr[0].val.i = 19;
387                                                                 else if (iptr[0].val.i == 0x00100000)
388                                                                         iptr[0].val.i = 20;
389                                                                 else if (iptr[0].val.i == 0x00200000)
390                                                                         iptr[0].val.i = 21;
391                                                                 else if (iptr[0].val.i == 0x00400000)
392                                                                         iptr[0].val.i = 22;
393                                                                 else if (iptr[0].val.i == 0x00800000)
394                                                                         iptr[0].val.i = 23;
395                                                                 else if (iptr[0].val.i == 0x01000000)
396                                                                         iptr[0].val.i = 24;
397                                                                 else if (iptr[0].val.i == 0x02000000)
398                                                                         iptr[0].val.i = 25;
399                                                                 else if (iptr[0].val.i == 0x04000000)
400                                                                         iptr[0].val.i = 26;
401                                                                 else if (iptr[0].val.i == 0x08000000)
402                                                                         iptr[0].val.i = 27;
403                                                                 else if (iptr[0].val.i == 0x10000000)
404                                                                         iptr[0].val.i = 28;
405                                                                 else if (iptr[0].val.i == 0x20000000)
406                                                                         iptr[0].val.i = 29;
407                                                                 else if (iptr[0].val.i == 0x40000000)
408                                                                         iptr[0].val.i = 30;
409                                                                 else if (iptr[0].val.i == 0x80000000)
410                                                                         iptr[0].val.i = 31;
411                                                                 else {
412                                                                         PUSHCONST(TYPE_INT);
413                                                                         break;
414                                                                 }
415                                                                 iptr[0].opc = ICMD_IMULPOW2;
416                                                                 goto icmd_iconst_tail;
417 #endif /* SUPPORT_CONST_MUL */
418                                                         case ICMD_IDIV:
419                                                                 if (iptr[0].val.i == 0x00000002)
420                                                                         iptr[0].val.i = 1;
421                                                                 else if (iptr[0].val.i == 0x00000004)
422                                                                         iptr[0].val.i = 2;
423                                                                 else if (iptr[0].val.i == 0x00000008)
424                                                                         iptr[0].val.i = 3;
425                                                                 else if (iptr[0].val.i == 0x00000010)
426                                                                         iptr[0].val.i = 4;
427                                                                 else if (iptr[0].val.i == 0x00000020)
428                                                                         iptr[0].val.i = 5;
429                                                                 else if (iptr[0].val.i == 0x00000040)
430                                                                         iptr[0].val.i = 6;
431                                                                 else if (iptr[0].val.i == 0x00000080)
432                                                                         iptr[0].val.i = 7;
433                                                                 else if (iptr[0].val.i == 0x00000100)
434                                                                         iptr[0].val.i = 8;
435                                                                 else if (iptr[0].val.i == 0x00000200)
436                                                                         iptr[0].val.i = 9;
437                                                                 else if (iptr[0].val.i == 0x00000400)
438                                                                         iptr[0].val.i = 10;
439                                                                 else if (iptr[0].val.i == 0x00000800)
440                                                                         iptr[0].val.i = 11;
441                                                                 else if (iptr[0].val.i == 0x00001000)
442                                                                         iptr[0].val.i = 12;
443                                                                 else if (iptr[0].val.i == 0x00002000)
444                                                                         iptr[0].val.i = 13;
445                                                                 else if (iptr[0].val.i == 0x00004000)
446                                                                         iptr[0].val.i = 14;
447                                                                 else if (iptr[0].val.i == 0x00008000)
448                                                                         iptr[0].val.i = 15;
449                                                                 else if (iptr[0].val.i == 0x00010000)
450                                                                         iptr[0].val.i = 16;
451                                                                 else if (iptr[0].val.i == 0x00020000)
452                                                                         iptr[0].val.i = 17;
453                                                                 else if (iptr[0].val.i == 0x00040000)
454                                                                         iptr[0].val.i = 18;
455                                                                 else if (iptr[0].val.i == 0x00080000)
456                                                                         iptr[0].val.i = 19;
457                                                                 else if (iptr[0].val.i == 0x00100000)
458                                                                         iptr[0].val.i = 20;
459                                                                 else if (iptr[0].val.i == 0x00200000)
460                                                                         iptr[0].val.i = 21;
461                                                                 else if (iptr[0].val.i == 0x00400000)
462                                                                         iptr[0].val.i = 22;
463                                                                 else if (iptr[0].val.i == 0x00800000)
464                                                                         iptr[0].val.i = 23;
465                                                                 else if (iptr[0].val.i == 0x01000000)
466                                                                         iptr[0].val.i = 24;
467                                                                 else if (iptr[0].val.i == 0x02000000)
468                                                                         iptr[0].val.i = 25;
469                                                                 else if (iptr[0].val.i == 0x04000000)
470                                                                         iptr[0].val.i = 26;
471                                                                 else if (iptr[0].val.i == 0x08000000)
472                                                                         iptr[0].val.i = 27;
473                                                                 else if (iptr[0].val.i == 0x10000000)
474                                                                         iptr[0].val.i = 28;
475                                                                 else if (iptr[0].val.i == 0x20000000)
476                                                                         iptr[0].val.i = 29;
477                                                                 else if (iptr[0].val.i == 0x40000000)
478                                                                         iptr[0].val.i = 30;
479                                                                 else if (iptr[0].val.i == 0x80000000)
480                                                                         iptr[0].val.i = 31;
481                                                                 else {
482                                                                         PUSHCONST(TYPE_INT);
483                                                                         break;
484                                                                 }
485                                                                 iptr[0].opc = ICMD_IDIVPOW2;
486                                                                 goto icmd_iconst_tail;
487                                                         case ICMD_IREM:
488                                                                 /*log_text("stack.c: ICMD_ICONST/ICMD_IREM");*/
489                                                                 if ((iptr[0].val.i == 0x00000002) ||
490                                                                         (iptr[0].val.i == 0x00000004) ||
491                                                                         (iptr[0].val.i == 0x00000008) ||
492                                                                         (iptr[0].val.i == 0x00000010) ||
493                                                                         (iptr[0].val.i == 0x00000020) ||
494                                                                         (iptr[0].val.i == 0x00000040) ||
495                                                                         (iptr[0].val.i == 0x00000080) ||
496                                                                         (iptr[0].val.i == 0x00000100) ||
497                                                                         (iptr[0].val.i == 0x00000200) ||
498                                                                         (iptr[0].val.i == 0x00000400) ||
499                                                                         (iptr[0].val.i == 0x00000800) ||
500                                                                         (iptr[0].val.i == 0x00001000) ||
501                                                                         (iptr[0].val.i == 0x00002000) ||
502                                                                         (iptr[0].val.i == 0x00004000) ||
503                                                                         (iptr[0].val.i == 0x00008000) ||
504                                                                         (iptr[0].val.i == 0x00010000) ||
505                                                                         (iptr[0].val.i == 0x00020000) ||
506                                                                         (iptr[0].val.i == 0x00040000) ||
507                                                                         (iptr[0].val.i == 0x00080000) ||
508                                                                         (iptr[0].val.i == 0x00100000) ||
509                                                                         (iptr[0].val.i == 0x00200000) ||
510                                                                         (iptr[0].val.i == 0x00400000) ||
511                                                                         (iptr[0].val.i == 0x00800000) ||
512                                                                         (iptr[0].val.i == 0x01000000) ||
513                                                                         (iptr[0].val.i == 0x02000000) ||
514                                                                         (iptr[0].val.i == 0x04000000) ||
515                                                                         (iptr[0].val.i == 0x08000000) ||
516                                                                         (iptr[0].val.i == 0x10000000) ||
517                                                                         (iptr[0].val.i == 0x20000000) ||
518                                                                         (iptr[0].val.i == 0x40000000) ||
519                                                                         (iptr[0].val.i == 0x80000000)) {
520                                                                         iptr[0].opc = ICMD_IREMPOW2;
521                                                                         iptr[0].val.i -= 1;
522                                                                         goto icmd_iconst_tail;
523                                                                 }
524                                                                 PUSHCONST(TYPE_INT);
525                                                                 break;
526 #if SUPPORT_CONST_LOGICAL
527                                                         case ICMD_IAND:
528                                                                 iptr[0].opc = ICMD_IANDCONST;
529                                                                 goto icmd_iconst_tail;
530                                                         case ICMD_IOR:
531                                                                 iptr[0].opc = ICMD_IORCONST;
532                                                                 goto icmd_iconst_tail;
533                                                         case ICMD_IXOR:
534                                                                 iptr[0].opc = ICMD_IXORCONST;
535                                                                 goto icmd_iconst_tail;
536 #endif /* SUPPORT_CONST_LOGICAL */
537                                                         case ICMD_ISHL:
538                                                                 iptr[0].opc = ICMD_ISHLCONST;
539                                                                 goto icmd_iconst_tail;
540                                                         case ICMD_ISHR:
541                                                                 iptr[0].opc = ICMD_ISHRCONST;
542                                                                 goto icmd_iconst_tail;
543                                                         case ICMD_IUSHR:
544                                                                 iptr[0].opc = ICMD_IUSHRCONST;
545                                                                 goto icmd_iconst_tail;
546 #if SUPPORT_LONG_SHIFT
547                                                         case ICMD_LSHL:
548                                                                 iptr[0].opc = ICMD_LSHLCONST;
549                                                                 goto icmd_lconst_tail;
550                                                         case ICMD_LSHR:
551                                                                 iptr[0].opc = ICMD_LSHRCONST;
552                                                                 goto icmd_lconst_tail;
553                                                         case ICMD_LUSHR:
554                                                                 iptr[0].opc = ICMD_LUSHRCONST;
555                                                                 goto icmd_lconst_tail;
556 #endif /* SUPPORT_LONG_SHIFT */
557                                                         case ICMD_IF_ICMPEQ:
558                                                                 iptr[0].opc = ICMD_IFEQ;
559                                                         icmd_if_icmp_tail:
560                                                                 iptr[0].op1 = iptr[1].op1;
561                                                                 /* IF_ICMPxx is the last instruction in the   */
562                                                                 /* basic block, just remove it                */
563                                                                 /* iptr[1].opc = ICMD_NOP; */
564                                                                 bptr->icount--;
565                                                                 len--;
566
567                                                                 OP1_0(TYPE_INT);
568                                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
569
570                                                                 iptr[0].target = (void *) tbptr;
571
572                                                                 MARKREACHED(tbptr, copy);
573                                                                 COUNT(count_pcmd_bra);
574                                                                 break;
575                                                         case ICMD_IF_ICMPLT:
576                                                                 iptr[0].opc = ICMD_IFLT;
577                                                                 goto icmd_if_icmp_tail;
578                                                         case ICMD_IF_ICMPLE:
579                                                                 iptr[0].opc = ICMD_IFLE;
580                                                                 goto icmd_if_icmp_tail;
581                                                         case ICMD_IF_ICMPNE:
582                                                                 iptr[0].opc = ICMD_IFNE;
583                                                                 goto icmd_if_icmp_tail;
584                                                         case ICMD_IF_ICMPGT:
585                                                                 iptr[0].opc = ICMD_IFGT;
586                                                                 goto icmd_if_icmp_tail;
587                                                         case ICMD_IF_ICMPGE:
588                                                                 iptr[0].opc = ICMD_IFGE;
589                                                                 goto icmd_if_icmp_tail;
590
591 #if SUPPORT_CONST_STORE
592                                                         case ICMD_IASTORE:
593                                                         case ICMD_BASTORE:
594                                                         case ICMD_CASTORE:
595                                                         case ICMD_SASTORE:
596 # if defined(ENABLE_INTRP)
597                                                                 if (!opt_intrp) {
598 # endif
599 #if SUPPORT_CONST_STORE_ZERO_ONLY
600                                                                         if (iptr[0].val.i == 0) {
601 #endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
602                                                                                 switch (iptr[1].opc) {
603                                                                                 case ICMD_IASTORE:
604                                                                                         iptr[0].opc = ICMD_IASTORECONST;
605                                                                                         break;
606                                                                                 case ICMD_BASTORE:
607                                                                                         iptr[0].opc = ICMD_BASTORECONST;
608                                                                                         break;
609                                                                                 case ICMD_CASTORE:
610                                                                                         iptr[0].opc = ICMD_CASTORECONST;
611                                                                                         break;
612                                                                                 case ICMD_SASTORE:
613                                                                                         iptr[0].opc = ICMD_SASTORECONST;
614                                                                                         break;
615                                                                                 }
616
617                                                                                 iptr[1].opc = ICMD_NOP;
618                                                                                 OPTT2_0(TYPE_INT, TYPE_ADR);
619                                                                                 COUNT(count_pcmd_op);
620 #if SUPPORT_CONST_STORE_ZERO_ONLY
621                                                                         } else
622                                                                                 PUSHCONST(TYPE_INT);
623 #endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
624 # if defined(ENABLE_INTRP)
625                                                                 } else
626                                                                         PUSHCONST(TYPE_INT);
627 # endif
628                                                                 break;
629
630                                                         case ICMD_PUTSTATIC:
631                                                         case ICMD_PUTFIELD:
632 #if SUPPORT_CONST_STORE_ZERO_ONLY
633                                                                 if (iptr[0].val.i == 0) {
634 #endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
635                                                                         switch (iptr[1].opc) {
636                                                                         case ICMD_PUTSTATIC:
637                                                                                 iptr[0].opc = ICMD_PUTSTATICCONST;
638                                                                                 SETDST;
639                                                                                 break;
640                                                                         case ICMD_PUTFIELD:
641                                                                                 iptr[0].opc = ICMD_PUTFIELDCONST;
642                                                                                 OP1_0(TYPE_ADR);
643                                                                                 break;
644                                                                         }
645
646                                                                         iptr[1].opc = ICMD_NOP;
647                                                                         iptr[0].op1 = TYPE_INT;
648                                                                         COUNT(count_pcmd_op);
649 #if SUPPORT_CONST_STORE_ZERO_ONLY
650                                                                 } else
651                                                                         PUSHCONST(TYPE_INT);
652 #endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
653                                                                 break;
654 #endif /* SUPPORT_CONST_STORE */
655                                                         default:
656                                                                 PUSHCONST(TYPE_INT);
657                                                         }
658                                                 }
659                                                 else
660                                                         PUSHCONST(TYPE_INT);
661                                                 break;
662
663                                         case ICMD_LCONST:
664                                                 COUNT(count_pcmd_load);
665                                                 if (len > 0) {
666                                                         switch (iptr[1].opc) {
667 #if SUPPORT_LONG_ADD
668                                                         case ICMD_LADD:
669                                                                 iptr[0].opc = ICMD_LADDCONST;
670                                                         icmd_lconst_tail:
671                                                                 iptr[1].opc = ICMD_NOP;
672                                                                 OP1_1(TYPE_LNG,TYPE_LNG);
673                                                                 COUNT(count_pcmd_op);
674                                                                 break;
675                                                         case ICMD_LSUB:
676                                                                 iptr[0].opc = ICMD_LSUBCONST;
677                                                                 goto icmd_lconst_tail;
678 #endif /* SUPPORT_LONG_ADD */
679 #if SUPPORT_LONG_MUL && SUPPORT_CONST_MUL
680                                                         case ICMD_LMUL:
681                                                                 iptr[0].opc = ICMD_LMULCONST;
682                                                                 goto icmd_lconst_tail;
683 #else /* SUPPORT_LONG_MUL && SUPPORT_CONST_MUL */
684 # if SUPPORT_LONG_SHIFT
685                                                         case ICMD_LMUL:
686                                                                 if (iptr[0].val.l == 0x00000002)
687                                                                         iptr[0].val.i = 1;
688                                                                 else if (iptr[0].val.l == 0x00000004)
689                                                                         iptr[0].val.i = 2;
690                                                                 else if (iptr[0].val.l == 0x00000008)
691                                                                         iptr[0].val.i = 3;
692                                                                 else if (iptr[0].val.l == 0x00000010)
693                                                                         iptr[0].val.i = 4;
694                                                                 else if (iptr[0].val.l == 0x00000020)
695                                                                         iptr[0].val.i = 5;
696                                                                 else if (iptr[0].val.l == 0x00000040)
697                                                                         iptr[0].val.i = 6;
698                                                                 else if (iptr[0].val.l == 0x00000080)
699                                                                         iptr[0].val.i = 7;
700                                                                 else if (iptr[0].val.l == 0x00000100)
701                                                                         iptr[0].val.i = 8;
702                                                                 else if (iptr[0].val.l == 0x00000200)
703                                                                         iptr[0].val.i = 9;
704                                                                 else if (iptr[0].val.l == 0x00000400)
705                                                                         iptr[0].val.i = 10;
706                                                                 else if (iptr[0].val.l == 0x00000800)
707                                                                         iptr[0].val.i = 11;
708                                                                 else if (iptr[0].val.l == 0x00001000)
709                                                                         iptr[0].val.i = 12;
710                                                                 else if (iptr[0].val.l == 0x00002000)
711                                                                         iptr[0].val.i = 13;
712                                                                 else if (iptr[0].val.l == 0x00004000)
713                                                                         iptr[0].val.i = 14;
714                                                                 else if (iptr[0].val.l == 0x00008000)
715                                                                         iptr[0].val.i = 15;
716                                                                 else if (iptr[0].val.l == 0x00010000)
717                                                                         iptr[0].val.i = 16;
718                                                                 else if (iptr[0].val.l == 0x00020000)
719                                                                         iptr[0].val.i = 17;
720                                                                 else if (iptr[0].val.l == 0x00040000)
721                                                                         iptr[0].val.i = 18;
722                                                                 else if (iptr[0].val.l == 0x00080000)
723                                                                         iptr[0].val.i = 19;
724                                                                 else if (iptr[0].val.l == 0x00100000)
725                                                                         iptr[0].val.i = 20;
726                                                                 else if (iptr[0].val.l == 0x00200000)
727                                                                         iptr[0].val.i = 21;
728                                                                 else if (iptr[0].val.l == 0x00400000)
729                                                                         iptr[0].val.i = 22;
730                                                                 else if (iptr[0].val.l == 0x00800000)
731                                                                         iptr[0].val.i = 23;
732                                                                 else if (iptr[0].val.l == 0x01000000)
733                                                                         iptr[0].val.i = 24;
734                                                                 else if (iptr[0].val.l == 0x02000000)
735                                                                         iptr[0].val.i = 25;
736                                                                 else if (iptr[0].val.l == 0x04000000)
737                                                                         iptr[0].val.i = 26;
738                                                                 else if (iptr[0].val.l == 0x08000000)
739                                                                         iptr[0].val.i = 27;
740                                                                 else if (iptr[0].val.l == 0x10000000)
741                                                                         iptr[0].val.i = 28;
742                                                                 else if (iptr[0].val.l == 0x20000000)
743                                                                         iptr[0].val.i = 29;
744                                                                 else if (iptr[0].val.l == 0x40000000)
745                                                                         iptr[0].val.i = 30;
746                                                                 else if (iptr[0].val.l == 0x80000000)
747                                                                         iptr[0].val.i = 31;
748                                                                 else {
749                                                                         PUSHCONST(TYPE_LNG);
750                                                                         break;
751                                                                 }
752                                                                 iptr[0].opc = ICMD_LMULPOW2;
753                                                                 goto icmd_lconst_tail;
754 # endif /* SUPPORT_LONG_SHIFT */
755 #endif /* SUPPORT_LONG_MUL && SUPPORT_CONST_MUL */
756 #if SUPPORT_LONG_DIV
757                                                         case ICMD_LDIV:
758                                                                 if (iptr[0].val.l == 0x00000002)
759                                                                         iptr[0].val.i = 1;
760                                                                 else if (iptr[0].val.l == 0x00000004)
761                                                                         iptr[0].val.i = 2;
762                                                                 else if (iptr[0].val.l == 0x00000008)
763                                                                         iptr[0].val.i = 3;
764                                                                 else if (iptr[0].val.l == 0x00000010)
765                                                                         iptr[0].val.i = 4;
766                                                                 else if (iptr[0].val.l == 0x00000020)
767                                                                         iptr[0].val.i = 5;
768                                                                 else if (iptr[0].val.l == 0x00000040)
769                                                                         iptr[0].val.i = 6;
770                                                                 else if (iptr[0].val.l == 0x00000080)
771                                                                         iptr[0].val.i = 7;
772                                                                 else if (iptr[0].val.l == 0x00000100)
773                                                                         iptr[0].val.i = 8;
774                                                                 else if (iptr[0].val.l == 0x00000200)
775                                                                         iptr[0].val.i = 9;
776                                                                 else if (iptr[0].val.l == 0x00000400)
777                                                                         iptr[0].val.i = 10;
778                                                                 else if (iptr[0].val.l == 0x00000800)
779                                                                         iptr[0].val.i = 11;
780                                                                 else if (iptr[0].val.l == 0x00001000)
781                                                                         iptr[0].val.i = 12;
782                                                                 else if (iptr[0].val.l == 0x00002000)
783                                                                         iptr[0].val.i = 13;
784                                                                 else if (iptr[0].val.l == 0x00004000)
785                                                                         iptr[0].val.i = 14;
786                                                                 else if (iptr[0].val.l == 0x00008000)
787                                                                         iptr[0].val.i = 15;
788                                                                 else if (iptr[0].val.l == 0x00010000)
789                                                                         iptr[0].val.i = 16;
790                                                                 else if (iptr[0].val.l == 0x00020000)
791                                                                         iptr[0].val.i = 17;
792                                                                 else if (iptr[0].val.l == 0x00040000)
793                                                                         iptr[0].val.i = 18;
794                                                                 else if (iptr[0].val.l == 0x00080000)
795                                                                         iptr[0].val.i = 19;
796                                                                 else if (iptr[0].val.l == 0x00100000)
797                                                                         iptr[0].val.i = 20;
798                                                                 else if (iptr[0].val.l == 0x00200000)
799                                                                         iptr[0].val.i = 21;
800                                                                 else if (iptr[0].val.l == 0x00400000)
801                                                                         iptr[0].val.i = 22;
802                                                                 else if (iptr[0].val.l == 0x00800000)
803                                                                         iptr[0].val.i = 23;
804                                                                 else if (iptr[0].val.l == 0x01000000)
805                                                                         iptr[0].val.i = 24;
806                                                                 else if (iptr[0].val.l == 0x02000000)
807                                                                         iptr[0].val.i = 25;
808                                                                 else if (iptr[0].val.l == 0x04000000)
809                                                                         iptr[0].val.i = 26;
810                                                                 else if (iptr[0].val.l == 0x08000000)
811                                                                         iptr[0].val.i = 27;
812                                                                 else if (iptr[0].val.l == 0x10000000)
813                                                                         iptr[0].val.i = 28;
814                                                                 else if (iptr[0].val.l == 0x20000000)
815                                                                         iptr[0].val.i = 29;
816                                                                 else if (iptr[0].val.l == 0x40000000)
817                                                                         iptr[0].val.i = 30;
818                                                                 else if (iptr[0].val.l == 0x80000000)
819                                                                         iptr[0].val.i = 31;
820                                                                 else {
821                                                                         PUSHCONST(TYPE_LNG);
822                                                                         break;
823                                                                 }
824                                                                 iptr[0].opc = ICMD_LDIVPOW2;
825                                                                 goto icmd_lconst_tail;
826                                                         case ICMD_LREM:
827                                                                 if ((iptr[0].val.l == 0x00000002) ||
828                                                                         (iptr[0].val.l == 0x00000004) ||
829                                                                         (iptr[0].val.l == 0x00000008) ||
830                                                                         (iptr[0].val.l == 0x00000010) ||
831                                                                         (iptr[0].val.l == 0x00000020) ||
832                                                                         (iptr[0].val.l == 0x00000040) ||
833                                                                         (iptr[0].val.l == 0x00000080) ||
834                                                                         (iptr[0].val.l == 0x00000100) ||
835                                                                         (iptr[0].val.l == 0x00000200) ||
836                                                                         (iptr[0].val.l == 0x00000400) ||
837                                                                         (iptr[0].val.l == 0x00000800) ||
838                                                                         (iptr[0].val.l == 0x00001000) ||
839                                                                         (iptr[0].val.l == 0x00002000) ||
840                                                                         (iptr[0].val.l == 0x00004000) ||
841                                                                         (iptr[0].val.l == 0x00008000) ||
842                                                                         (iptr[0].val.l == 0x00010000) ||
843                                                                         (iptr[0].val.l == 0x00020000) ||
844                                                                         (iptr[0].val.l == 0x00040000) ||
845                                                                         (iptr[0].val.l == 0x00080000) ||
846                                                                         (iptr[0].val.l == 0x00100000) ||
847                                                                         (iptr[0].val.l == 0x00200000) ||
848                                                                         (iptr[0].val.l == 0x00400000) ||
849                                                                         (iptr[0].val.l == 0x00800000) ||
850                                                                         (iptr[0].val.l == 0x01000000) ||
851                                                                         (iptr[0].val.l == 0x02000000) ||
852                                                                         (iptr[0].val.l == 0x04000000) ||
853                                                                         (iptr[0].val.l == 0x08000000) ||
854                                                                         (iptr[0].val.l == 0x10000000) ||
855                                                                         (iptr[0].val.l == 0x20000000) ||
856                                                                         (iptr[0].val.l == 0x40000000) ||
857                                                                         (iptr[0].val.l == 0x80000000)) {
858                                                                         iptr[0].opc = ICMD_LREMPOW2;
859                                                                         iptr[0].val.l -= 1;
860                                                                         goto icmd_lconst_tail;
861                                                                 }
862                                                                 PUSHCONST(TYPE_LNG);
863                                                                 break;
864 #endif /* SUPPORT_LONG_DIV */
865 #if SUPPORT_LONG_LOGICAL && SUPPORT_CONST_LOGICAL
866
867                                                         case ICMD_LAND:
868                                                                 iptr[0].opc = ICMD_LANDCONST;
869                                                                 goto icmd_lconst_tail;
870                                                         case ICMD_LOR:
871                                                                 iptr[0].opc = ICMD_LORCONST;
872                                                                 goto icmd_lconst_tail;
873                                                         case ICMD_LXOR:
874                                                                 iptr[0].opc = ICMD_LXORCONST;
875                                                                 goto icmd_lconst_tail;
876 #endif /* SUPPORT_LONG_LOGICAL && SUPPORT_CONST_LOGICAL */
877
878 #if SUPPORT_LONG_CMP_CONST
879                                                         case ICMD_LCMP:
880                                                                 if ((len > 1) && (iptr[2].val.i == 0)) {
881                                                                         switch (iptr[2].opc) {
882                                                                         case ICMD_IFEQ:
883                                                                                 iptr[0].opc = ICMD_IF_LEQ;
884                                                                         icmd_lconst_lcmp_tail:
885                                                                                 iptr[0].op1 = iptr[2].op1;
886                                                                                 bptr->icount -= 2;
887                                                                                 len -= 2;
888                                                                                 /* iptr[1].opc = ICMD_NOP;
889                                                                                    iptr[2].opc = ICMD_NOP; */
890                                                                                 OP1_0(TYPE_LNG);
891                                                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
892
893                                                                                 iptr[0].target = (void *) tbptr;
894
895                                                                                 MARKREACHED(tbptr, copy);
896                                                                                 COUNT(count_pcmd_bra);
897                                                                                 COUNT(count_pcmd_op);
898                                                                                 break;
899                                                                         case ICMD_IFNE:
900                                                                                 iptr[0].opc = ICMD_IF_LNE;
901                                                                                 goto icmd_lconst_lcmp_tail;
902                                                                         case ICMD_IFLT:
903                                                                                 iptr[0].opc = ICMD_IF_LLT;
904                                                                                 goto icmd_lconst_lcmp_tail;
905                                                                         case ICMD_IFGT:
906                                                                                 iptr[0].opc = ICMD_IF_LGT;
907                                                                                 goto icmd_lconst_lcmp_tail;
908                                                                         case ICMD_IFLE:
909                                                                                 iptr[0].opc = ICMD_IF_LLE;
910                                                                                 goto icmd_lconst_lcmp_tail;
911                                                                         case ICMD_IFGE:
912                                                                                 iptr[0].opc = ICMD_IF_LGE;
913                                                                                 goto icmd_lconst_lcmp_tail;
914                                                                         default:
915                                                                                 PUSHCONST(TYPE_LNG);
916                                                                         } /* switch (iptr[2].opc) */
917                                                                 } /* if (iptr[2].val.i == 0) */
918                                                                 else
919                                                                         PUSHCONST(TYPE_LNG);
920                                                                 break;
921 #endif /* SUPPORT_LONG_CMP_CONST */
922
923 #if SUPPORT_CONST_STORE
924                                                         case ICMD_LASTORE:
925 # if defined(ENABLE_INTRP)
926                                                                 if (!opt_intrp) {
927 # endif
928 #if SUPPORT_CONST_STORE_ZERO_ONLY
929                                                                         if (iptr[0].val.l == 0) {
930 #endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
931                                                                                 iptr[0].opc = ICMD_LASTORECONST;
932                                                                                 iptr[1].opc = ICMD_NOP;
933                                                                                 OPTT2_0(TYPE_INT, TYPE_ADR);
934                                                                                 COUNT(count_pcmd_op);
935 #if SUPPORT_CONST_STORE_ZERO_ONLY
936                                                                         } else
937                                                                                 PUSHCONST(TYPE_LNG);
938 #endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
939 # if defined(ENABLE_INTRP)
940                                                                 } else
941                                                                         PUSHCONST(TYPE_LNG);
942 # endif
943                                                                 break;
944
945                                                         case ICMD_PUTSTATIC:
946                                                         case ICMD_PUTFIELD:
947 #if SUPPORT_CONST_STORE_ZERO_ONLY
948                                                                 if (iptr[0].val.l == 0) {
949 #endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
950                                                                         switch (iptr[1].opc) {
951                                                                         case ICMD_PUTSTATIC:
952                                                                                 iptr[0].opc = ICMD_PUTSTATICCONST;
953                                                                                 SETDST;
954                                                                                 break;
955                                                                         case ICMD_PUTFIELD:
956                                                                                 iptr[0].opc = ICMD_PUTFIELDCONST;
957                                                                                 OP1_0(TYPE_ADR);
958                                                                                 break;
959                                                                         }
960
961                                                                         iptr[1].opc = ICMD_NOP;
962                                                                         iptr[0].op1 = TYPE_LNG;
963                                                                         COUNT(count_pcmd_op);
964 #if SUPPORT_CONST_STORE_ZERO_ONLY
965                                                                 } else
966                                                                         PUSHCONST(TYPE_LNG);
967 #endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
968                                                                 break;
969 #endif /* SUPPORT_CONST_STORE */
970                                                         default:
971                                                                 PUSHCONST(TYPE_LNG);
972                                                         }
973                                                 }
974                                                 else
975                                                         PUSHCONST(TYPE_LNG);
976                                                 break;
977
978                                         case ICMD_FCONST:
979                                                 COUNT(count_pcmd_load);
980                                                 PUSHCONST(TYPE_FLT);
981                                                 break;
982
983                                         case ICMD_DCONST:
984                                                 COUNT(count_pcmd_load);
985                                                 PUSHCONST(TYPE_DBL);
986                                                 break;
987
988                                         case ICMD_ACONST:
989                                                 COUNT(count_pcmd_load);
990 #if SUPPORT_CONST_STORE
991                                                 if (len > 0 && iptr->val.a == 0) {
992                                                         switch (iptr[1].opc) {
993 #if !defined(__POWERPC__) && !defined(__X86_64__) && !defined(__I386__) && !defined(__ALPHA__) && !defined(__MIPS__)
994                                                         case ICMD_BUILTIN:
995                                                                 if (iptr[1].val.fp != BUILTIN_aastore) {
996                                                                         PUSHCONST(TYPE_ADR);
997                                                                         break;
998                                                                 }
999                                                                 /* fall through */
1000 #endif
1001                                                         case ICMD_PUTSTATIC:
1002                                                         case ICMD_PUTFIELD:
1003                                                                 switch (iptr[1].opc) {
1004                                                                 case ICMD_BUILTIN:
1005                                                                         iptr[0].opc = ICMD_AASTORECONST;
1006                                                                         OPTT2_0(TYPE_INT, TYPE_ADR);
1007                                                                         break;
1008                                                                 case ICMD_PUTSTATIC:
1009                                                                         iptr[0].opc = ICMD_PUTSTATICCONST;
1010                                                                         iptr[0].op1 = TYPE_ADR;
1011                                                                         SETDST;
1012                                                                         break;
1013                                                                 case ICMD_PUTFIELD:
1014                                                                         iptr[0].opc = ICMD_PUTFIELDCONST;
1015                                                                         iptr[0].op1 = TYPE_ADR;
1016                                                                         OP1_0(TYPE_ADR);
1017                                                                         break;
1018                                                                 }
1019
1020                                                                 iptr[1].opc = ICMD_NOP;
1021                                                                 COUNT(count_pcmd_op);
1022                                                                 break;
1023
1024                                                         default:
1025                                                                 PUSHCONST(TYPE_ADR);
1026                                                         }
1027                                                 } else
1028 #endif /* SUPPORT_CONST_STORE */
1029                                                         PUSHCONST(TYPE_ADR);
1030                                                 break;
1031
1032                                                 /* pop 0 push 1 load */
1033                                                 
1034                                         case ICMD_ILOAD:
1035                                         case ICMD_LLOAD:
1036                                         case ICMD_FLOAD:
1037                                         case ICMD_DLOAD:
1038                                         case ICMD_ALOAD:
1039                                                 COUNT(count_load_instruction);
1040                                                 i = opcode - ICMD_ILOAD;
1041                                                 iptr->op1 = argren[iptr->op1];
1042 #if defined(ENABLE_INTRP)
1043                                                 if (!opt_intrp)
1044 #endif
1045                                                         rd->locals[iptr->op1][i].type = i;
1046                                                 LOAD(i, LOCALVAR, iptr->op1);
1047                                                 break;
1048
1049                                                 /* pop 2 push 1 */
1050
1051                                         case ICMD_LALOAD:
1052                                         case ICMD_IALOAD:
1053                                         case ICMD_FALOAD:
1054                                         case ICMD_DALOAD:
1055                                         case ICMD_AALOAD:
1056                                                 COUNT(count_check_null);
1057                                                 COUNT(count_check_bound);
1058                                                 COUNT(count_pcmd_mem);
1059                                                 OP2IAT_1(opcode - ICMD_IALOAD);
1060                                                 break;
1061
1062                                         case ICMD_BALOAD:
1063                                         case ICMD_CALOAD:
1064                                         case ICMD_SALOAD:
1065                                                 COUNT(count_check_null);
1066                                                 COUNT(count_check_bound);
1067                                                 COUNT(count_pcmd_mem);
1068                                                 OP2IAT_1(TYPE_INT);
1069                                                 break;
1070
1071                                                 /* pop 0 push 0 iinc */
1072
1073                                         case ICMD_IINC:
1074 #if defined(STATISTICS)
1075                                                 if (opt_stat) {
1076                                                         i = stackdepth;
1077                                                         if (i >= 10)
1078                                                                 count_store_depth[10]++;
1079                                                         else
1080                                                                 count_store_depth[i]++;
1081                                                 }
1082 #endif
1083                                                 copy = curstack;
1084                                                 i = stackdepth - 1;
1085                                                 while (copy) {
1086                                                         if ((copy->varkind == LOCALVAR) &&
1087                                                                 (copy->varnum == iptr->op1)) {
1088                                                                 copy->varkind = TEMPVAR;
1089                                                                 copy->varnum = i;
1090                                                         }
1091                                                         i--;
1092                                                         copy = copy->prev;
1093                                                 }
1094
1095                                                 /* allocate a dummy stack slot to keep ISTORE from */
1096                                                 /* marking its input stack as a LOCALVAR, since we */
1097                                                 /* change the value of the local variable here.    */
1098                                                 NEWSTACK0(TYPE_INT);
1099                                                 POP(TYPE_INT);
1100                                                 
1101                                                 SETDST;
1102                                                 break;
1103
1104                                                 /* pop 1 push 0 store */
1105
1106                                         case ICMD_ISTORE:
1107                                         case ICMD_LSTORE:
1108                                         case ICMD_FSTORE:
1109                                         case ICMD_DSTORE:
1110                                         case ICMD_ASTORE:
1111                                         icmd_store:
1112                                                 REQUIRE_1;
1113
1114                                         i = opcode - ICMD_ISTORE;
1115 #if defined(ENABLE_INTRP)
1116                                                 if (!opt_intrp)
1117 #endif
1118                                                         rd->locals[iptr->op1][i].type = i;
1119 #if defined(STATISTICS)
1120                                         if (opt_stat) {
1121                                                 count_pcmd_store++;
1122                                                 i = new - curstack;
1123                                                 if (i >= 20)
1124                                                         count_store_length[20]++;
1125                                                 else
1126                                                         count_store_length[i]++;
1127                                                 i = stackdepth - 1;
1128                                                 if (i >= 10)
1129                                                         count_store_depth[10]++;
1130                                                 else
1131                                                         count_store_depth[i]++;
1132                                         }
1133 #endif
1134                                         copy = curstack->prev;
1135                                         i = stackdepth - 2;
1136                                         while (copy) {
1137                                                 if ((copy->varkind == LOCALVAR) &&
1138                                                         (copy->varnum == iptr->op1)) {
1139                                                         copy->varkind = TEMPVAR;
1140                                                         copy->varnum = i;
1141                                                 }
1142                                                 i--;
1143                                                 copy = copy->prev;
1144                                         }
1145                                         if ((new - curstack) == 1) {
1146                                                 curstack->varkind = LOCALVAR;
1147                                                 curstack->varnum = iptr->op1;
1148                                         };
1149                                         STORE(opcode - ICMD_ISTORE);
1150                                         break;
1151
1152                                         /* pop 3 push 0 */
1153
1154                                         case ICMD_AASTORE:
1155                                                 COUNT(count_check_null);
1156                                                 COUNT(count_check_bound);
1157                                                 COUNT(count_pcmd_mem);
1158
1159                                                 bte = builtintable_get_internal(BUILTIN_canstore);
1160                                                 md = bte->md;
1161
1162                                                 if (md->memuse > rd->memuse)
1163                                                         rd->memuse = md->memuse;
1164                                                 if (md->argintreguse > rd->argintreguse)
1165                                                         rd->argintreguse = md->argintreguse;
1166
1167                                                 /* make all stack variables saved */
1168
1169                                                 copy = curstack;
1170                                                 while (copy) {
1171                                                         copy->flags |= SAVEDVAR;
1172                                                         copy = copy->prev;
1173                                                 }
1174
1175                                                 OP3TIA_0(TYPE_ADR);
1176                                                 break;
1177
1178                                         case ICMD_IASTORE:
1179                                         case ICMD_LASTORE:
1180                                         case ICMD_FASTORE:
1181                                         case ICMD_DASTORE:
1182                                                 COUNT(count_check_null);
1183                                                 COUNT(count_check_bound);
1184                                                 COUNT(count_pcmd_mem);
1185                                                 OP3TIA_0(opcode - ICMD_IASTORE);
1186                                                 break;
1187
1188                                         case ICMD_BASTORE:
1189                                         case ICMD_CASTORE:
1190                                         case ICMD_SASTORE:
1191                                                 COUNT(count_check_null);
1192                                                 COUNT(count_check_bound);
1193                                                 COUNT(count_pcmd_mem);
1194                                                 OP3TIA_0(TYPE_INT);
1195                                                 break;
1196
1197                                                 /* pop 1 push 0 */
1198
1199                                         case ICMD_POP:
1200 #ifdef TYPECHECK_STACK_COMPCAT
1201                                                 if (opt_verify) {
1202                                                         REQUIRE_1;
1203                                                         if (IS_2_WORD_TYPE(curstack->type)) {
1204                                                                 *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1205                                                                 return NULL;
1206                                                         }
1207                                                 }
1208 #endif
1209                                                 OP1_0ANY;
1210                                                 break;
1211
1212                                         case ICMD_IRETURN:
1213                                         case ICMD_LRETURN:
1214                                         case ICMD_FRETURN:
1215                                         case ICMD_DRETURN:
1216                                         case ICMD_ARETURN:
1217                                                 md_return_alloc(m, rd, opcode - ICMD_IRETURN, curstack);
1218                                                 COUNT(count_pcmd_return);
1219                                                 OP1_0(opcode - ICMD_IRETURN);
1220                                                 superblockend = true;
1221                                                 break;
1222
1223                                         case ICMD_ATHROW:
1224                                                 COUNT(count_check_null);
1225                                                 OP1_0(TYPE_ADR);
1226                                                 STACKRESET;
1227                                                 SETDST;
1228                                                 superblockend = true;
1229                                                 break;
1230
1231                                         case ICMD_PUTSTATIC:
1232                                                 COUNT(count_pcmd_mem);
1233                                                 OP1_0(iptr->op1);
1234                                                 break;
1235
1236                                                 /* pop 1 push 0 branch */
1237
1238                                         case ICMD_IFNULL:
1239                                         case ICMD_IFNONNULL:
1240                                                 COUNT(count_pcmd_bra);
1241                                                 OP1_0(TYPE_ADR);
1242                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
1243
1244                                                 iptr[0].target = (void *) tbptr;
1245
1246                                                 MARKREACHED(tbptr, copy);
1247                                                 break;
1248
1249                                         case ICMD_IFEQ:
1250                                         case ICMD_IFNE:
1251                                         case ICMD_IFLT:
1252                                         case ICMD_IFGE:
1253                                         case ICMD_IFGT:
1254                                         case ICMD_IFLE:
1255                                                 COUNT(count_pcmd_bra);
1256 #if CONDITIONAL_LOADCONST
1257 # if defined(ENABLE_INTRP)
1258                                                 if (!opt_intrp) {
1259 # endif
1260                                                         tbptr = m->basicblocks + b_index;
1261                                                         if ((b_count >= 3) &&
1262                                                                 ((b_index + 2) == m->basicblockindex[iptr[0].op1]) &&
1263                                                                 (tbptr[1].pre_count == 1) &&
1264                                                                 (tbptr[1].iinstr[0].opc == ICMD_ICONST) &&
1265                                                                 (tbptr[1].iinstr[1].opc == ICMD_GOTO)   &&
1266                                                                 ((b_index + 3) == m->basicblockindex[tbptr[1].iinstr[1].op1]) &&
1267                                                                 (tbptr[2].pre_count == 1) &&
1268                                                                 (tbptr[2].iinstr[0].opc == ICMD_ICONST)  &&
1269                                                                 (tbptr[2].icount==1)) {
1270                                                                 /*printf("tbptr[2].icount=%d\n",tbptr[2].icount);*/
1271                                                                 OP1_1(TYPE_INT, TYPE_INT);
1272                                                                 switch (iptr[0].opc) {
1273                                                                 case ICMD_IFEQ:
1274                                                                         iptr[0].opc = ICMD_IFNE_ICONST;
1275                                                                         break;
1276                                                                 case ICMD_IFNE:
1277                                                                         iptr[0].opc = ICMD_IFEQ_ICONST;
1278                                                                         break;
1279                                                                 case ICMD_IFLT:
1280                                                                         iptr[0].opc = ICMD_IFGE_ICONST;
1281                                                                         break;
1282                                                                 case ICMD_IFGE:
1283                                                                         iptr[0].opc = ICMD_IFLT_ICONST;
1284                                                                         break;
1285                                                                 case ICMD_IFGT:
1286                                                                         iptr[0].opc = ICMD_IFLE_ICONST;
1287                                                                         break;
1288                                                                 case ICMD_IFLE:
1289                                                                         iptr[0].opc = ICMD_IFGT_ICONST;
1290                                                                         break;
1291                                                                 }
1292 #if 1
1293                                                                 iptr[0].val.i = iptr[1].val.i;
1294                                                                 iptr[1].opc = ICMD_ELSE_ICONST;
1295                                                                 iptr[1].val.i = iptr[3].val.i;
1296                                                                 iptr[2].opc = ICMD_NOP;
1297                                                                 iptr[3].opc = ICMD_NOP;
1298 #else
1299                                                                 /* HACK: save compare value in iptr[1].op1 */    
1300                                                                 iptr[1].op1 = iptr[0].val.i;     
1301                                                                 iptr[0].val.i = tbptr[1].iinstr[0].val.i;        
1302                                                                 iptr[1].opc = ICMD_ELSE_ICONST;          
1303                                                                 iptr[1].val.i = tbptr[2].iinstr[0].val.i;        
1304                                                                 tbptr[1].iinstr[0].opc = ICMD_NOP;       
1305                                                                 tbptr[1].iinstr[1].opc = ICMD_NOP;       
1306                                                                 tbptr[2].iinstr[0].opc = ICMD_NOP;       
1307 #endif
1308                                                                 tbptr[1].flags = BBDELETED;
1309                                                                 tbptr[2].flags = BBDELETED;
1310                                                                 tbptr[1].icount = 0;
1311                                                                 tbptr[2].icount = 0;
1312                                                                 if (tbptr[3].pre_count == 2) {
1313                                                                         len += tbptr[3].icount + 3;
1314                                                                         bptr->icount += tbptr[3].icount + 3;
1315                                                                         tbptr[3].flags = BBDELETED;
1316                                                                         tbptr[3].icount = 0;
1317                                                                         b_index++;
1318                                                                 }
1319                                                                 else {
1320                                                                         bptr->icount++;
1321                                                                         len ++;
1322                                                                 }
1323                                                                 b_index += 2;
1324                                                                 break;
1325                                                         }
1326 # if defined(ENABLE_INTRP)
1327                                                 }
1328 # endif
1329
1330 #endif /* CONDITIONAL_LOADCONST */
1331
1332                                                 OP1_0(TYPE_INT);
1333                                                 iptr->val.i = 0;
1334                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
1335
1336                                                 iptr[0].target = (void *) tbptr;
1337
1338                                                 MARKREACHED(tbptr, copy);
1339                                                 break;
1340
1341                                                 /* pop 0 push 0 branch */
1342
1343                                         case ICMD_GOTO:
1344                                                 COUNT(count_pcmd_bra);
1345                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
1346
1347                                                 iptr[0].target = (void *) tbptr;
1348
1349                                                 MARKREACHED(tbptr, copy);
1350                                                 SETDST;
1351                                                 superblockend = true;
1352                                                 break;
1353
1354                                                 /* pop 1 push 0 table branch */
1355
1356                                         case ICMD_TABLESWITCH:
1357                                                 COUNT(count_pcmd_table);
1358                                                 OP1_0(TYPE_INT);
1359                                                 s4ptr = iptr->val.a;
1360                                                 tbptr = m->basicblocks + m->basicblockindex[*s4ptr++];
1361                                                 MARKREACHED(tbptr, copy);
1362                                                 i = *s4ptr++;                          /* low     */
1363                                                 i = *s4ptr++ - i + 1;                  /* high    */
1364
1365                                                 tptr = DMNEW(void*, i+1);
1366                                                 iptr->target = (void *) tptr;
1367
1368                                                 tptr[0] = (void *) tbptr;
1369                                                 tptr++;
1370
1371                                                 while (--i >= 0) {
1372                                                         tbptr = m->basicblocks + m->basicblockindex[*s4ptr++];
1373
1374                                                         tptr[0] = (void *) tbptr;
1375                                                         tptr++;
1376
1377                                                         MARKREACHED(tbptr, copy);
1378                                                 }
1379                                                 SETDST;
1380                                                 superblockend = true;
1381                                                 break;
1382                                                         
1383                                                 /* pop 1 push 0 table branch */
1384
1385                                         case ICMD_LOOKUPSWITCH:
1386                                                 COUNT(count_pcmd_table);
1387                                                 OP1_0(TYPE_INT);
1388                                                 s4ptr = iptr->val.a;
1389                                                 tbptr = m->basicblocks + m->basicblockindex[*s4ptr++];
1390                                                 MARKREACHED(tbptr, copy);
1391                                                 i = *s4ptr++;                          /* count   */
1392
1393                                                 tptr = DMNEW(void*, i+1);
1394                                                 iptr->target = (void *) tptr;
1395
1396                                                 tptr[0] = (void *) tbptr;
1397                                                 tptr++;
1398
1399                                                 while (--i >= 0) {
1400                                                         tbptr = m->basicblocks + m->basicblockindex[s4ptr[1]];
1401
1402                                                         tptr[0] = (void *) tbptr;
1403                                                         tptr++;
1404                                                                 
1405                                                         MARKREACHED(tbptr, copy);
1406                                                         s4ptr += 2;
1407                                                 }
1408                                                 SETDST;
1409                                                 superblockend = true;
1410                                                 break;
1411
1412                                         case ICMD_MONITORENTER:
1413                                                 COUNT(count_check_null);
1414                                         case ICMD_MONITOREXIT:
1415                                                 OP1_0(TYPE_ADR);
1416                                                 break;
1417
1418                                                 /* pop 2 push 0 branch */
1419
1420                                         case ICMD_IF_ICMPEQ:
1421                                         case ICMD_IF_ICMPNE:
1422                                         case ICMD_IF_ICMPLT:
1423                                         case ICMD_IF_ICMPGE:
1424                                         case ICMD_IF_ICMPGT:
1425                                         case ICMD_IF_ICMPLE:
1426                                                 COUNT(count_pcmd_bra);
1427                                                 OP2_0(TYPE_INT);
1428                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
1429                                                         
1430                                                 iptr[0].target = (void *) tbptr;
1431
1432                                                 MARKREACHED(tbptr, copy);
1433                                                 break;
1434
1435                                         case ICMD_IF_ACMPEQ:
1436                                         case ICMD_IF_ACMPNE:
1437                                                 COUNT(count_pcmd_bra);
1438                                                 OP2_0(TYPE_ADR);
1439                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
1440
1441                                                 iptr[0].target = (void *) tbptr;
1442
1443                                                 MARKREACHED(tbptr, copy);
1444                                                 break;
1445
1446                                                 /* pop 2 push 0 */
1447
1448                                         case ICMD_PUTFIELD:
1449                                                 COUNT(count_check_null);
1450                                                 COUNT(count_pcmd_mem);
1451                                                 OPTT2_0(iptr->op1,TYPE_ADR);
1452                                                 break;
1453
1454                                         case ICMD_POP2:
1455                                                 REQUIRE_1;
1456                                                 if (!IS_2_WORD_TYPE(curstack->type)) {
1457                                                         /* ..., cat1 */
1458 #ifdef TYPECHECK_STACK_COMPCAT
1459                                                         if (opt_verify) {
1460                                                                 REQUIRE_2;
1461                                                                 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1462                                                                         *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1463                                                                         return NULL;
1464                                                                 }
1465                                                         }
1466 #endif
1467                                                         OP1_0ANY;                /* second pop */
1468                                                 }
1469                                                 else
1470                                                         iptr->opc = ICMD_POP;
1471                                                 OP1_0ANY;
1472                                                 break;
1473
1474                                                 /* pop 0 push 1 dup */
1475                                                 
1476                                         case ICMD_DUP:
1477 #ifdef TYPECHECK_STACK_COMPCAT
1478                                                 if (opt_verify) {
1479                                                         REQUIRE_1;
1480                                                         if (IS_2_WORD_TYPE(curstack->type)) {
1481                                                                 *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1482                                                                 return NULL;
1483                                                         }
1484                                                 }
1485 #endif
1486                                                 COUNT(count_dup_instruction);
1487                                                 DUP;
1488                                                 break;
1489
1490                                         case ICMD_DUP2:
1491                                                 REQUIRE_1;
1492                                                 if (IS_2_WORD_TYPE(curstack->type)) {
1493                                                         /* ..., cat2 */
1494                                                         iptr->opc = ICMD_DUP;
1495                                                         DUP;
1496                                                 }
1497                                                 else {
1498                                                         REQUIRE_2;
1499                                                         /* ..., ????, cat1 */
1500 #ifdef TYPECHECK_STACK_COMPCAT
1501                                                         if (opt_verify) {
1502                                                                 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1503                                                                         *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1504                                                                         return NULL;
1505                                                                 }
1506                                                         }
1507 #endif
1508                                                         copy = curstack;
1509                                                         NEWSTACK(copy->prev->type, copy->prev->varkind,
1510                                                                          copy->prev->varnum);
1511                                                         NEWSTACK(copy->type, copy->varkind,
1512                                                                          copy->varnum);
1513                                                         SETDST;
1514                                                         stackdepth += 2;
1515                                                 }
1516                                                 break;
1517
1518                                                 /* pop 2 push 3 dup */
1519                                                 
1520                                         case ICMD_DUP_X1:
1521 #ifdef TYPECHECK_STACK_COMPCAT
1522                                                 if (opt_verify) {
1523                                                         REQUIRE_2;
1524                                                         if (IS_2_WORD_TYPE(curstack->type) ||
1525                                                                 IS_2_WORD_TYPE(curstack->prev->type)) {
1526                                                                         *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1527                                                                         return NULL;
1528                                                         }
1529                                                 }
1530 #endif
1531                                                 DUP_X1;
1532                                                 break;
1533
1534                                         case ICMD_DUP2_X1:
1535                                                 REQUIRE_2;
1536                                                 if (IS_2_WORD_TYPE(curstack->type)) {
1537                                                         /* ..., ????, cat2 */
1538 #ifdef TYPECHECK_STACK_COMPCAT
1539                                                         if (opt_verify) {
1540                                                                 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1541                                                                         *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1542                                                                         return NULL;
1543                                                                 }
1544                                                         }
1545 #endif
1546                                                         iptr->opc = ICMD_DUP_X1;
1547                                                         DUP_X1;
1548                                                 }
1549                                                 else {
1550                                                         /* ..., ????, cat1 */
1551 #ifdef TYPECHECK_STACK_COMPCAT
1552                                                         if (opt_verify) {
1553                                                                 REQUIRE_3;
1554                                                                 if (IS_2_WORD_TYPE(curstack->prev->type)
1555                                                                         || IS_2_WORD_TYPE(curstack->prev->prev->type)) {
1556                                                                         *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1557                                                                         return NULL;
1558                                                                 }
1559                                                         }
1560 #endif
1561                                                         DUP2_X1;
1562                                                 }
1563                                                 break;
1564
1565                                                 /* pop 3 push 4 dup */
1566                                                 
1567                                         case ICMD_DUP_X2:
1568                                                 REQUIRE_2;
1569                                                 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1570                                                         /* ..., cat2, ???? */
1571 #ifdef TYPECHECK_STACK_COMPCAT
1572                                                         if (opt_verify) {
1573                                                                 if (IS_2_WORD_TYPE(curstack->type)) {
1574                                                                         *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1575                                                                         return NULL;
1576                                                                 }
1577                                                         }
1578 #endif
1579                                                         iptr->opc = ICMD_DUP_X1;
1580                                                         DUP_X1;
1581                                                 }
1582                                                 else {
1583                                                         /* ..., cat1, ???? */
1584 #ifdef TYPECHECK_STACK_COMPCAT
1585                                                         if (opt_verify) {
1586                                                                 REQUIRE_3;
1587                                                                 if (IS_2_WORD_TYPE(curstack->type)
1588                                                                         || IS_2_WORD_TYPE(curstack->prev->prev->type)) {
1589                                                                         *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1590                                                                         return NULL;
1591                                                                 }
1592                                                         }
1593 #endif
1594                                                         DUP_X2;
1595                                                 }
1596                                                 break;
1597
1598                                         case ICMD_DUP2_X2:
1599                                                 REQUIRE_2;
1600                                                 if (IS_2_WORD_TYPE(curstack->type)) {
1601                                                         /* ..., ????, cat2 */
1602                                                         if (IS_2_WORD_TYPE(curstack->prev->type)) {
1603                                                                 /* ..., cat2, cat2 */
1604                                                                 iptr->opc = ICMD_DUP_X1;
1605                                                                 DUP_X1;
1606                                                         }
1607                                                         else {
1608                                                                 /* ..., cat1, cat2 */
1609 #ifdef TYPECHECK_STACK_COMPCAT
1610                                                                 if (opt_verify) {
1611                                                                         REQUIRE_3;
1612                                                                         if (IS_2_WORD_TYPE(curstack->prev->prev->type)) {
1613                                                                                 *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1614                                                                                 return NULL;
1615                                                                         }
1616                                                                 }
1617 #endif
1618                                                                 iptr->opc = ICMD_DUP_X2;
1619                                                                 DUP_X2;
1620                                                         }
1621                                                 }
1622                                                 else {
1623                                                         REQUIRE_3;
1624                                                         /* ..., ????, ????, cat1 */
1625                                                         if (IS_2_WORD_TYPE(curstack->prev->prev->type)) {
1626                                                                 /* ..., cat2, ????, cat1 */
1627 #ifdef TYPECHECK_STACK_COMPCAT
1628                                                                 if (opt_verify) {
1629                                                                         if (IS_2_WORD_TYPE(curstack->prev->type)) {
1630                                                                                 *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1631                                                                                 return NULL;
1632                                                                         }
1633                                                                 }
1634 #endif
1635                                                                 iptr->opc = ICMD_DUP2_X1;
1636                                                                 DUP2_X1;
1637                                                         }
1638                                                         else {
1639                                                                 /* ..., cat1, ????, cat1 */
1640 #ifdef TYPECHECK_STACK_COMPCAT
1641                                                                 if (opt_verify) {
1642                                                                         REQUIRE_4;
1643                                                                         if (IS_2_WORD_TYPE(curstack->prev->type)
1644                                                                                 || IS_2_WORD_TYPE(curstack->prev->prev->prev->type)) {
1645                                                                                 *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1646                                                                                 return NULL;
1647                                                                         }
1648                                                                 }
1649 #endif
1650                                                                 DUP2_X2;
1651                                                         }
1652                                                 }
1653                                                 break;
1654
1655                                                 /* pop 2 push 2 swap */
1656                                                 
1657                                         case ICMD_SWAP:
1658 #ifdef TYPECHECK_STACK_COMPCAT
1659                                                 if (opt_verify) {
1660                                                         REQUIRE_2;
1661                                                         if (IS_2_WORD_TYPE(curstack->type)
1662                                                                 || IS_2_WORD_TYPE(curstack->prev->type)) {
1663                                                                 *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1664                                                                 return NULL;
1665                                                         }
1666                                                 }
1667 #endif
1668                                                 SWAP;
1669                                                 break;
1670
1671                                                 /* pop 2 push 1 */
1672
1673                                         case ICMD_IDIV:
1674                                         case ICMD_IREM:
1675 #if !SUPPORT_DIVISION
1676                                                 bte = (builtintable_entry *) iptr->val.a;
1677                                                 md = bte->md;
1678                                                 i = iptr->op1;
1679
1680                                                 if (md->memuse > rd->memuse)
1681                                                         rd->memuse = md->memuse;
1682                                                 if (md->argintreguse > rd->argintreguse)
1683                                                         rd->argintreguse = md->argintreguse;
1684
1685                                                 /* make all stack variables saved */
1686
1687                                                 copy = curstack;
1688                                                 while (copy) {
1689                                                         copy->flags |= SAVEDVAR;
1690                                                         copy = copy->prev;
1691                                                 }
1692
1693                                                 /* fall through */
1694 #endif /* !SUPPORT_DIVISION */
1695
1696                                         case ICMD_ISHL:
1697                                         case ICMD_ISHR:
1698                                         case ICMD_IUSHR:
1699                                         case ICMD_IADD:
1700                                         case ICMD_ISUB:
1701                                         case ICMD_IMUL:
1702                                         case ICMD_IAND:
1703                                         case ICMD_IOR:
1704                                         case ICMD_IXOR:
1705                                                 COUNT(count_pcmd_op);
1706                                                 OP2_1(TYPE_INT);
1707                                                 break;
1708
1709                                         case ICMD_LDIV:
1710                                         case ICMD_LREM:
1711 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
1712                                                 bte = (builtintable_entry *) iptr->val.a;
1713                                                 md = bte->md;
1714                                                 i = iptr->op1;
1715
1716                                                 if (md->memuse > rd->memuse)
1717                                                         rd->memuse = md->memuse;
1718                                                 if (md->argintreguse > rd->argintreguse)
1719                                                         rd->argintreguse = md->argintreguse;
1720
1721                                                 /* make all stack variables saved */
1722
1723                                                 copy = curstack;
1724                                                 while (copy) {
1725                                                         copy->flags |= SAVEDVAR;
1726                                                         copy = copy->prev;
1727                                                 }
1728
1729                                                 /* fall through */
1730 #endif /* !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV) */
1731
1732                                         case ICMD_LMUL:
1733                                         case ICMD_LADD:
1734                                         case ICMD_LSUB:
1735 #if SUPPORT_LONG_LOGICAL
1736                                         case ICMD_LAND:
1737                                         case ICMD_LOR:
1738                                         case ICMD_LXOR:
1739 #endif /* SUPPORT_LONG_LOGICAL */
1740                                                 COUNT(count_pcmd_op);
1741                                                 OP2_1(TYPE_LNG);
1742                                                 break;
1743
1744                                         case ICMD_LSHL:
1745                                         case ICMD_LSHR:
1746                                         case ICMD_LUSHR:
1747                                                 COUNT(count_pcmd_op);
1748                                                 OP2IT_1(TYPE_LNG);
1749                                                 break;
1750
1751                                         case ICMD_FADD:
1752                                         case ICMD_FSUB:
1753                                         case ICMD_FMUL:
1754                                         case ICMD_FDIV:
1755                                         case ICMD_FREM:
1756                                                 COUNT(count_pcmd_op);
1757                                                 OP2_1(TYPE_FLT);
1758                                                 break;
1759
1760                                         case ICMD_DADD:
1761                                         case ICMD_DSUB:
1762                                         case ICMD_DMUL:
1763                                         case ICMD_DDIV:
1764                                         case ICMD_DREM:
1765                                                 COUNT(count_pcmd_op);
1766                                                 OP2_1(TYPE_DBL);
1767                                                 break;
1768
1769                                         case ICMD_LCMP:
1770                                                 COUNT(count_pcmd_op);
1771 #if SUPPORT_LONG_CMP_CONST
1772                                                 if ((len > 0) && (iptr[1].val.i == 0)) {
1773                                                         switch (iptr[1].opc) {
1774                                                         case ICMD_IFEQ:
1775                                                                 iptr[0].opc = ICMD_IF_LCMPEQ;
1776                                                         icmd_lcmp_if_tail:
1777                                                                 iptr[0].op1 = iptr[1].op1;
1778                                                                 len--;
1779                                                                 bptr->icount--;
1780                                                                 /* iptr[1].opc = ICMD_NOP; */
1781                                                                 OP2_0(TYPE_LNG);
1782                                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
1783                         
1784                                                                 iptr[0].target = (void *) tbptr;
1785
1786                                                                 MARKREACHED(tbptr, copy);
1787                                                                 COUNT(count_pcmd_bra);
1788                                                                 break;
1789                                                         case ICMD_IFNE:
1790                                                                 iptr[0].opc = ICMD_IF_LCMPNE;
1791                                                                 goto icmd_lcmp_if_tail;
1792                                                         case ICMD_IFLT:
1793                                                                 iptr[0].opc = ICMD_IF_LCMPLT;
1794                                                                 goto icmd_lcmp_if_tail;
1795                                                         case ICMD_IFGT:
1796                                                                 iptr[0].opc = ICMD_IF_LCMPGT;
1797                                                                 goto icmd_lcmp_if_tail;
1798                                                         case ICMD_IFLE:
1799                                                                 iptr[0].opc = ICMD_IF_LCMPLE;
1800                                                                 goto icmd_lcmp_if_tail;
1801                                                         case ICMD_IFGE:
1802                                                                 iptr[0].opc = ICMD_IF_LCMPGE;
1803                                                                 goto icmd_lcmp_if_tail;
1804                                                         default:
1805                                                                 OPTT2_1(TYPE_LNG, TYPE_INT);
1806                                                         }
1807                                                 }
1808                                                 else
1809 #endif /* SUPPORT_LONG_CMP_CONST */
1810                                                         OPTT2_1(TYPE_LNG, TYPE_INT);
1811                                                 break;
1812                                         case ICMD_FCMPL:
1813                                         case ICMD_FCMPG:
1814                                                 COUNT(count_pcmd_op);
1815                                                 OPTT2_1(TYPE_FLT, TYPE_INT);
1816                                                 break;
1817                                         case ICMD_DCMPL:
1818                                         case ICMD_DCMPG:
1819                                                 COUNT(count_pcmd_op);
1820                                                 OPTT2_1(TYPE_DBL, TYPE_INT);
1821                                                 break;
1822
1823                                                 /* pop 1 push 1 */
1824                                                 
1825                                         case ICMD_INEG:
1826                                         case ICMD_INT2BYTE:
1827                                         case ICMD_INT2CHAR:
1828                                         case ICMD_INT2SHORT:
1829                                                 COUNT(count_pcmd_op);
1830                                                 OP1_1(TYPE_INT, TYPE_INT);
1831                                                 break;
1832                                         case ICMD_LNEG:
1833                                                 COUNT(count_pcmd_op);
1834                                                 OP1_1(TYPE_LNG, TYPE_LNG);
1835                                                 break;
1836                                         case ICMD_FNEG:
1837                                                 COUNT(count_pcmd_op);
1838                                                 OP1_1(TYPE_FLT, TYPE_FLT);
1839                                                 break;
1840                                         case ICMD_DNEG:
1841                                                 COUNT(count_pcmd_op);
1842                                                 OP1_1(TYPE_DBL, TYPE_DBL);
1843                                                 break;
1844
1845                                         case ICMD_I2L:
1846                                                 COUNT(count_pcmd_op);
1847                                                 OP1_1(TYPE_INT, TYPE_LNG);
1848                                                 break;
1849                                         case ICMD_I2F:
1850                                                 COUNT(count_pcmd_op);
1851                                                 OP1_1(TYPE_INT, TYPE_FLT);
1852                                                 break;
1853                                         case ICMD_I2D:
1854                                                 COUNT(count_pcmd_op);
1855                                                 OP1_1(TYPE_INT, TYPE_DBL);
1856                                                 break;
1857                                         case ICMD_L2I:
1858                                                 COUNT(count_pcmd_op);
1859                                                 OP1_1(TYPE_LNG, TYPE_INT);
1860                                                 break;
1861                                         case ICMD_L2F:
1862                                                 COUNT(count_pcmd_op);
1863                                                 OP1_1(TYPE_LNG, TYPE_FLT);
1864                                                 break;
1865                                         case ICMD_L2D:
1866                                                 COUNT(count_pcmd_op);
1867                                                 OP1_1(TYPE_LNG, TYPE_DBL);
1868                                                 break;
1869                                         case ICMD_F2I:
1870                                                 COUNT(count_pcmd_op);
1871                                                 OP1_1(TYPE_FLT, TYPE_INT);
1872                                                 break;
1873                                         case ICMD_F2L:
1874                                                 COUNT(count_pcmd_op);
1875                                                 OP1_1(TYPE_FLT, TYPE_LNG);
1876                                                 break;
1877                                         case ICMD_F2D:
1878                                                 COUNT(count_pcmd_op);
1879                                                 OP1_1(TYPE_FLT, TYPE_DBL);
1880                                                 break;
1881                                         case ICMD_D2I:
1882                                                 COUNT(count_pcmd_op);
1883                                                 OP1_1(TYPE_DBL, TYPE_INT);
1884                                                 break;
1885                                         case ICMD_D2L:
1886                                                 COUNT(count_pcmd_op);
1887                                                 OP1_1(TYPE_DBL, TYPE_LNG);
1888                                                 break;
1889                                         case ICMD_D2F:
1890                                                 COUNT(count_pcmd_op);
1891                                                 OP1_1(TYPE_DBL, TYPE_FLT);
1892                                                 break;
1893
1894                                         case ICMD_CHECKCAST:
1895                                                 if (iptr->op1 == 0) {
1896                                                         /* array type cast-check */
1897
1898                                                         bte = builtintable_get_internal(BUILTIN_arraycheckcast);
1899                                                         md = bte->md;
1900
1901                                                         if (md->memuse > rd->memuse)
1902                                                                 rd->memuse = md->memuse;
1903                                                         if (md->argintreguse > rd->argintreguse)
1904                                                                 rd->argintreguse = md->argintreguse;
1905
1906                                                         /* make all stack variables saved */
1907
1908                                                         copy = curstack;
1909                                                         while (copy) {
1910                                                                 copy->flags |= SAVEDVAR;
1911                                                                 copy = copy->prev;
1912                                                         }
1913                                                 }
1914                                                 OP1_1(TYPE_ADR, TYPE_ADR);
1915                                                 break;
1916
1917                                         case ICMD_INSTANCEOF:
1918                                         case ICMD_ARRAYLENGTH:
1919                                                 OP1_1(TYPE_ADR, TYPE_INT);
1920                                                 break;
1921
1922                                         case ICMD_NEWARRAY:
1923                                         case ICMD_ANEWARRAY:
1924                                                 OP1_1(TYPE_INT, TYPE_ADR);
1925                                                 break;
1926
1927                                         case ICMD_GETFIELD:
1928                                                 COUNT(count_check_null);
1929                                                 COUNT(count_pcmd_mem);
1930                                                 OP1_1(TYPE_ADR, iptr->op1);
1931                                                 break;
1932
1933                                                 /* pop 0 push 1 */
1934                                                 
1935                                         case ICMD_GETSTATIC:
1936                                                 COUNT(count_pcmd_mem);
1937                                                 OP0_1(iptr->op1);
1938                                                 break;
1939
1940                                         case ICMD_NEW:
1941                                                 OP0_1(TYPE_ADR);
1942                                                 break;
1943
1944                                         case ICMD_JSR:
1945                                                 OP0_1(TYPE_ADR);
1946                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
1947
1948                                                 iptr[0].target = (void *) tbptr;
1949
1950                                                 /* This is a dirty hack. The typechecker
1951                                                  * needs it because the OP1_0ANY below
1952                                                  * overwrites iptr->dst.
1953                                                  */
1954                                                 iptr->val.a = (void *) iptr->dst;
1955
1956                                                 tbptr->type = BBTYPE_SBR;
1957
1958                                                 /* We need to check for overflow right here because
1959                                                  * the pushed value is poped after MARKREACHED. */
1960                                                 CHECKOVERFLOW;
1961                                                 MARKREACHED(tbptr, copy);
1962                                                 OP1_0ANY;
1963                                                 break;
1964
1965                                         /* pop many push any */
1966
1967                                         case ICMD_BUILTIN:
1968 #if defined(USEBUILTINTABLE)
1969                                         builtin:
1970 #endif
1971                                                 bte = (builtintable_entry *) iptr->val.a;
1972                                                 md = bte->md;
1973                                                 goto _callhandling;
1974
1975                                         case ICMD_INVOKESTATIC:
1976                                         case ICMD_INVOKESPECIAL:
1977                                         case ICMD_INVOKEVIRTUAL:
1978                                         case ICMD_INVOKEINTERFACE:
1979                                                 COUNT(count_pcmd_met);
1980                                                 um = iptr->target;
1981                                                 md = um->methodref->parseddesc.md;
1982 /*                          if (lm->flags & ACC_STATIC) */
1983 /*                              {COUNT(count_check_null);} */    
1984
1985                                         _callhandling:
1986                                                 i = md->paramcount;
1987
1988                                                 if (md->memuse > rd->memuse)
1989                                                         rd->memuse = md->memuse;
1990                                                 if (md->argintreguse > rd->argintreguse)
1991                                                         rd->argintreguse = md->argintreguse;
1992                                                 if (md->argfltreguse > rd->argfltreguse)
1993                                                         rd->argfltreguse = md->argfltreguse;
1994
1995                                                 REQUIRE(i);
1996
1997                                                 copy = curstack;
1998                                                 for (i-- ; i >= 0; i--) {
1999 #if defined(SUPPORT_PASS_FLOATARGS_IN_INTREGS)
2000                                                 /* If we pass float arguments in integer argument registers, we
2001                                                  * are not allowed to precolor them here. Floats have to be moved
2002                                                  * to this regs explicitly in codegen().
2003                                                  * Only arguments that are passed by stack anyway can be precolored
2004                                                  * (michi 2005/07/24) */
2005                                                         if (!(copy->flags & SAVEDVAR) &&
2006                                                            (!IS_FLT_DBL_TYPE(copy->type) || md->params[i].inmemory)) {
2007 #else
2008                                                         if (!(copy->flags & SAVEDVAR)) {
2009 #endif
2010                                                                 copy->varkind = ARGVAR;
2011                                                                 copy->varnum = i;
2012
2013 #if defined(ENABLE_INTRP)
2014                                                                 if (!opt_intrp) {
2015 #endif
2016                                                                         if (md->params[i].inmemory) {
2017                                                                                 copy->flags = INMEMORY;
2018                                                                                 copy->regoff = md->params[i].regoff;
2019                                                                         } else {
2020                                                                                 copy->flags = 0;
2021                                                                                 if (IS_FLT_DBL_TYPE(copy->type))
2022 #if defined(SUPPORT_PASS_FLOATARGS_IN_INTREGS)
2023                                                                                         assert(0); /* XXX is this assert ok? */
2024 #else
2025                                                                                 copy->regoff =
2026                                                                                         rd->argfltregs[md->params[i].regoff];
2027 #endif
2028                                                                                 else {
2029 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
2030                                                                                         if (IS_2_WORD_TYPE(copy->type))
2031                                                                                                 copy->regoff = PACK_REGS(
2032                                                                                                                                                  rd->argintregs[GET_LOW_REG(md->params[i].regoff)],
2033                                                                                                                                                  rd->argintregs[GET_HIGH_REG(md->params[i].regoff)]);
2034                                                                                         else
2035 #endif
2036                                                                                                 copy->regoff =
2037                                                                                                         rd->argintregs[md->params[i].regoff];
2038                                                                                 }
2039                                                                         }
2040 #if defined(ENABLE_INTRP)
2041                                                                 }
2042 #endif
2043                                                         }
2044                                                         copy = copy->prev;
2045                                                 }
2046
2047                                                 while (copy) {
2048                                                         copy->flags |= SAVEDVAR;
2049                                                         copy = copy->prev;
2050                                                 }
2051
2052                                                 i = md->paramcount;
2053                                                 POPMANY(i);
2054                                                 if (md->returntype.type != TYPE_VOID)
2055                                                         OP0_1(md->returntype.type);
2056                                                 break;
2057
2058                                         case ICMD_INLINE_START:
2059                                         case ICMD_INLINE_END:
2060                                                 SETDST;
2061                                                 break;
2062
2063                                         case ICMD_MULTIANEWARRAY:
2064                                                 if (rd->argintreguse < 3)
2065                                                         rd->argintreguse = 3;
2066
2067                                                 i = iptr->op1;
2068
2069                                                 REQUIRE(i);
2070 #if defined(SPECIALMEMUSE)
2071 # if defined(__DARWIN__)
2072                                                 if (rd->memuse < (i + INT_ARG_CNT + LA_WORD_SIZE))
2073                                                         rd->memuse = i + LA_WORD_SIZE + INT_ARG_CNT;
2074 # else
2075                                                 if (rd->memuse < (i + LA_WORD_SIZE + 3))
2076                                                         rd->memuse = i + LA_WORD_SIZE + 3;
2077 # endif
2078 #else
2079 # if defined(__I386__)
2080                                                 if (rd->memuse < i + 3)
2081                                                         rd->memuse = i + 3; /* n integer args spilled on stack */
2082 # elif defined(__MIPS__) && SIZEOF_VOID_P == 4
2083                                                 if (rd->memuse < i + 2)
2084                                                         rd->memuse = i + 2; /* 4*4 bytes callee save space */
2085 # else
2086                                                 if (rd->memuse < i)
2087                                                         rd->memuse = i; /* n integer args spilled on stack */
2088 # endif /* defined(__I386__) */
2089 #endif
2090                                                 copy = curstack;
2091                                                 while (--i >= 0) {
2092                                                         /* check INT type here? Currently typecheck does this. */
2093                                                         if (!(copy->flags & SAVEDVAR)) {
2094                                                                 copy->varkind = ARGVAR;
2095                                                                 copy->varnum = i + INT_ARG_CNT;
2096                                                                 copy->flags |= INMEMORY;
2097 #if defined(SPECIALMEMUSE)
2098 # if defined(__DARWIN__)
2099                                                                 copy->regoff = i + LA_WORD_SIZE + INT_ARG_CNT;
2100 # else
2101                                                                 copy->regoff = i + LA_WORD_SIZE + 3;
2102 # endif
2103 #else
2104 # if defined(__I386__)
2105                                                                 copy->regoff = i + 3;
2106 # elif defined(__MIPS__) && SIZEOF_VOID_P == 4
2107                                                                 copy->regoff = i + 2;
2108 # else
2109                                                                 copy->regoff = i;
2110 # endif /* defined(__I386__) */
2111 #endif /* defined(SPECIALMEMUSE) */
2112                                                         }
2113                                                         copy = copy->prev;
2114                                                 }
2115                                                 while (copy) {
2116                                                         copy->flags |= SAVEDVAR;
2117                                                         copy = copy->prev;
2118                                                 }
2119                                                 i = iptr->op1;
2120                                                 POPMANY(i);
2121                                                 OP0_1(TYPE_ADR);
2122                                                 break;
2123
2124                                         case ICMD_CLEAR_ARGREN:
2125                                                 for (i = iptr->op1; i < cd->maxlocals; i++)
2126                                                         argren[i] = i;
2127                                                 iptr->opc = opcode = ICMD_NOP;
2128                                                 SETDST;
2129                                                 break;
2130                                                 
2131                                         case ICMD_READONLY_ARG:
2132                                         case ICMD_READONLY_ARG+1:
2133                                         case ICMD_READONLY_ARG+2:
2134                                         case ICMD_READONLY_ARG+3:
2135                                         case ICMD_READONLY_ARG+4:
2136
2137                                                 REQUIRE_1;
2138                                                 if (curstack->varkind == LOCALVAR) {
2139                                                         i = curstack->varnum;
2140                                                         argren[iptr->op1] = i;
2141                                                         iptr->op1 = i;
2142                                                 }
2143                                                 opcode = iptr->opc = opcode - ICMD_READONLY_ARG + ICMD_ISTORE;
2144                                                 goto icmd_store;
2145
2146                                                 break;
2147
2148                                         default:
2149                                                 *exceptionptr =
2150                                                         new_internalerror("Unknown ICMD %d", opcode);
2151                                                 return NULL;
2152                                         } /* switch */
2153
2154                                         CHECKOVERFLOW;
2155                                         iptr++;
2156                                 } /* while instructions */
2157
2158                                 bptr->outstack = curstack;
2159                                 bptr->outdepth = stackdepth;
2160                                 BBEND(curstack, i);
2161                         } /* if */
2162                         else
2163                                 superblockend = true;
2164                         bptr++;
2165                 } /* while blocks */
2166         } while (repeat && !deadcode);
2167
2168 #if defined(STATISTICS)
2169         if (opt_stat) {
2170                 if (m->basicblockcount > count_max_basic_blocks)
2171                         count_max_basic_blocks = m->basicblockcount;
2172                 count_basic_blocks += m->basicblockcount;
2173                 if (m->instructioncount > count_max_javainstr)                  count_max_javainstr = m->instructioncount;
2174                 count_javainstr += m->instructioncount;
2175                 if (m->stackcount > count_upper_bound_new_stack)
2176                         count_upper_bound_new_stack = m->stackcount;
2177                 if ((new - m->stack) > count_max_new_stack)
2178                         count_max_new_stack = (new - m->stack);
2179
2180                 b_count = m->basicblockcount;
2181                 bptr = m->basicblocks;
2182                 while (--b_count >= 0) {
2183                         if (bptr->flags > BBREACHED) {
2184                                 if (bptr->indepth >= 10)
2185                                         count_block_stack[10]++;
2186                                 else
2187                                         count_block_stack[bptr->indepth]++;
2188                                 len = bptr->icount;
2189                                 if (len < 10) 
2190                                         count_block_size_distribution[len]++;
2191                                 else if (len <= 12)
2192                                         count_block_size_distribution[10]++;
2193                                 else if (len <= 14)
2194                                         count_block_size_distribution[11]++;
2195                                 else if (len <= 16)
2196                                         count_block_size_distribution[12]++;
2197                                 else if (len <= 18)
2198                                         count_block_size_distribution[13]++;
2199                                 else if (len <= 20)
2200                                         count_block_size_distribution[14]++;
2201                                 else if (len <= 25)
2202                                         count_block_size_distribution[15]++;
2203                                 else if (len <= 30)
2204                                         count_block_size_distribution[16]++;
2205                                 else
2206                                         count_block_size_distribution[17]++;
2207                         }
2208                         bptr++;
2209                 }
2210
2211                 if (loops == 1)
2212                         count_analyse_iterations[0]++;
2213                 else if (loops == 2)
2214                         count_analyse_iterations[1]++;
2215                 else if (loops == 3)
2216                         count_analyse_iterations[2]++;
2217                 else if (loops == 4)
2218                         count_analyse_iterations[3]++;
2219                 else
2220                         count_analyse_iterations[4]++;
2221
2222                 if (m->basicblockcount <= 5)
2223                         count_method_bb_distribution[0]++;
2224                 else if (m->basicblockcount <= 10)
2225                         count_method_bb_distribution[1]++;
2226                 else if (m->basicblockcount <= 15)
2227                         count_method_bb_distribution[2]++;
2228                 else if (m->basicblockcount <= 20)
2229                         count_method_bb_distribution[3]++;
2230                 else if (m->basicblockcount <= 30)
2231                         count_method_bb_distribution[4]++;
2232                 else if (m->basicblockcount <= 40)
2233                         count_method_bb_distribution[5]++;
2234                 else if (m->basicblockcount <= 50)
2235                         count_method_bb_distribution[6]++;
2236                 else if (m->basicblockcount <= 75)
2237                         count_method_bb_distribution[7]++;
2238                 else
2239                         count_method_bb_distribution[8]++;
2240         }
2241 #endif
2242
2243         /* just return methodinfo* to signal everything was ok */
2244
2245         return m;
2246 }
2247
2248
2249 /**********************************************************************/
2250 /* DEBUGGING HELPERS                                                  */
2251 /**********************************************************************/
2252
2253 void icmd_print_stack(codegendata *cd, stackptr s)
2254 {
2255         int i, j;
2256         stackptr t;
2257
2258         i = cd->maxstack;
2259         t = s;
2260         
2261         while (t) {
2262                 i--;
2263                 t = t->prev;
2264         }
2265         j = cd->maxstack - i;
2266         while (--i >= 0)
2267                 printf("    ");
2268
2269         while (s) {
2270                 j--;
2271                 if (s->flags & SAVEDVAR)
2272                         switch (s->varkind) {
2273                         case TEMPVAR:
2274                                 if (s->flags & INMEMORY)
2275                                         printf(" M%02d", s->regoff);
2276 #ifdef HAS_ADDRESS_REGISTER_FILE
2277                                 else if (s->type == TYPE_ADR)
2278                                         printf(" R%02d", s->regoff);
2279 #endif
2280                                 else if (IS_FLT_DBL_TYPE(s->type))
2281                                         printf(" F%02d", s->regoff);
2282                                 else {
2283 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
2284                                         if (IS_2_WORD_TYPE(s->type))
2285                                                 printf(" %3s/%3s", regs[GET_LOW_REG(s->regoff)],
2286                             regs[GET_HIGH_REG(s->regoff)]);
2287                                         else
2288 #endif
2289 #if defined(ENABLE_INTRP)
2290                                                 printf(" %3d", s->regoff);
2291 #else
2292                                                 printf(" %3s", regs[s->regoff]);
2293 #endif
2294                                 }
2295                                 break;
2296                         case STACKVAR:
2297                                 printf(" I%02d", s->varnum);
2298                                 break;
2299                         case LOCALVAR:
2300                                 printf(" L%02d", s->varnum);
2301                                 break;
2302                         case ARGVAR:
2303                                 if (s->varnum == -1) {
2304                                         /* Return Value                                  */
2305                                         /* varkind ARGVAR "misused for this special case */
2306                                         printf("  V0");
2307                                 } else /* "normal" Argvar */
2308                                         printf(" A%02d", s->varnum);
2309 #ifdef INVOKE_NEW_DEBUG
2310                                 if (s->flags & INMEMORY)
2311                                         printf("(M%i)", s->regoff);
2312                                 else
2313                                         printf("(R%i)", s->regoff);
2314 #endif
2315                                 break;
2316                         default:
2317                                 printf(" !%02d", j);
2318                         }
2319                 else
2320                         switch (s->varkind) {
2321                         case TEMPVAR:
2322                                 if (s->flags & INMEMORY)
2323                                         printf(" m%02d", s->regoff);
2324 #ifdef HAS_ADDRESS_REGISTER_FILE
2325                                 else if (s->type == TYPE_ADR)
2326                                         printf(" r%02d", s->regoff);
2327 #endif
2328                                 else if (IS_FLT_DBL_TYPE(s->type))
2329                                         printf(" f%02d", s->regoff);
2330                                 else {
2331 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
2332                                         if (IS_2_WORD_TYPE(s->type))
2333                                                 printf(" %3s/%3s", regs[GET_LOW_REG(s->regoff)],
2334                             regs[GET_HIGH_REG(s->regoff)]);
2335                                         else
2336 #endif
2337 #if defined(ENABLE_INTRP)
2338                                                 printf(" %3d", s->regoff);
2339 #else
2340                                                 printf(" %3s", regs[s->regoff]);
2341 #endif
2342                                 }
2343                                 break;
2344                         case STACKVAR:
2345                                 printf(" i%02d", s->varnum);
2346                                 break;
2347                         case LOCALVAR:
2348                                 printf(" l%02d", s->varnum);
2349                                 break;
2350                         case ARGVAR:
2351                                 if (s->varnum == -1) {
2352                                         /* Return Value                                  */
2353                                         /* varkind ARGVAR "misused for this special case */
2354                                         printf("  v0");
2355                                 } else /* "normal" Argvar */
2356                                 printf(" a%02d", s->varnum);
2357 #ifdef INVOKE_NEW_DEBUG
2358                                 if (s->flags & INMEMORY)
2359                                         printf("(M%i)", s->regoff);
2360                                 else
2361                                         printf("(R%i)", s->regoff);
2362 #endif
2363                                 break;
2364                         default:
2365                                 printf(" ?%02d", j);
2366                         }
2367                 s = s->prev;
2368         }
2369 }
2370
2371
2372 #if 0
2373 static void print_reg(stackptr s) {
2374         if (s) {
2375                 if (s->flags & SAVEDVAR)
2376                         switch (s->varkind) {
2377                         case TEMPVAR:
2378                                 if (s->flags & INMEMORY)
2379                                         printf(" tm%02d", s->regoff);
2380                                 else
2381                                         printf(" tr%02d", s->regoff);
2382                                 break;
2383                         case STACKVAR:
2384                                 printf(" s %02d", s->varnum);
2385                                 break;
2386                         case LOCALVAR:
2387                                 printf(" l %02d", s->varnum);
2388                                 break;
2389                         case ARGVAR:
2390                                 printf(" a %02d", s->varnum);
2391                                 break;
2392                         default:
2393                                 printf(" ! %02d", s->varnum);
2394                         }
2395                 else
2396                         switch (s->varkind) {
2397                         case TEMPVAR:
2398                                 if (s->flags & INMEMORY)
2399                                         printf(" Tm%02d", s->regoff);
2400                                 else
2401                                         printf(" Tr%02d", s->regoff);
2402                                 break;
2403                         case STACKVAR:
2404                                 printf(" S %02d", s->varnum);
2405                                 break;
2406                         case LOCALVAR:
2407                                 printf(" L %02d", s->varnum);
2408                                 break;
2409                         case ARGVAR:
2410                                 printf(" A %02d", s->varnum);
2411                                 break;
2412                         default:
2413                                 printf(" ? %02d", s->varnum);
2414                         }
2415         }
2416         else
2417                 printf("     ");
2418                 
2419 }
2420 #endif
2421
2422
2423 static char *jit_type[] = {
2424         "int",
2425         "lng",
2426         "flt",
2427         "dbl",
2428         "adr"
2429 };
2430
2431
2432 /* show_icmd_method ************************************************************
2433
2434    XXX
2435
2436 *******************************************************************************/
2437
2438 void show_icmd_method(methodinfo *m, codegendata *cd, registerdata *rd)
2439 {
2440         basicblock     *bptr;
2441         exceptiontable *ex;
2442         s4              i, j;
2443         u1             *u1ptr;
2444
2445 #if defined(USE_THREADS)
2446         /* We need to enter a lock here, since the binutils disassembler
2447            is not reentrant-able and we could not read functions printed
2448            at the same time. */
2449
2450         builtin_monitorenter(lock_show_icmd);
2451 #endif
2452
2453         printf("\n");
2454         utf_fprint_classname(stdout, m->class->name);
2455         printf(".");
2456         utf_fprint(stdout, m->name);
2457         utf_fprint(stdout, m->descriptor);
2458         printf("\n\nMax locals: %d\n", (int) cd->maxlocals);
2459         printf("Max stack:  %d\n", (int) cd->maxstack);
2460         printf("Line number table length: %d\n", m->linenumbercount);
2461
2462         printf("Exceptions (Number: %d):\n", cd->exceptiontablelength);
2463         for (ex = cd->exceptiontable; ex != NULL; ex = ex->down) {
2464                 printf("    L%03d ... ", ex->start->debug_nr );
2465                 printf("L%03d  = ", ex->end->debug_nr);
2466                 printf("L%03d", ex->handler->debug_nr);
2467                 printf("  (catchtype: ");
2468                 if (ex->catchtype.any)
2469                         if (IS_CLASSREF(ex->catchtype))
2470                                 utf_display_classname(ex->catchtype.ref->name);
2471                         else
2472                                 utf_display_classname(ex->catchtype.cls->name);
2473                 else
2474                         printf("ANY");
2475                 printf(")\n");
2476         }
2477         
2478         printf("Local Table:\n");
2479         for (i = 0; i < cd->maxlocals; i++) {
2480                 printf("   %3d: ", i);
2481                 for (j = TYPE_INT; j <= TYPE_ADR; j++) {
2482 #if defined(ENABLE_INTRP)
2483                         if (!opt_intrp) {
2484 #endif
2485                                 if (rd->locals[i][j].type >= 0) {
2486                                         printf("   (%s) ", jit_type[j]);
2487                                         if (rd->locals[i][j].flags & INMEMORY)
2488                                                 printf("m%2d", rd->locals[i][j].regoff);
2489 #ifdef HAS_ADDRESS_REGISTER_FILE
2490                                         else if (j == TYPE_ADR)
2491                                                 printf("r%02d", rd->locals[i][j].regoff);
2492 #endif
2493                                         else if ((j == TYPE_FLT) || (j == TYPE_DBL))
2494                                                 printf("f%02d", rd->locals[i][j].regoff);
2495                                         else {
2496 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
2497                                                 if (IS_2_WORD_TYPE(j))
2498                                                         printf(" %3s/%3s",
2499                                                                    regs[GET_LOW_REG(rd->locals[i][j].regoff)],
2500                                                                    regs[GET_HIGH_REG(rd->locals[i][j].regoff)]);
2501                                                 else
2502 #endif
2503                                                         printf("%3s", regs[rd->locals[i][j].regoff]);
2504                                         }
2505                                 }
2506 #if defined(ENABLE_INTRP)
2507                         }
2508 #endif
2509                 }
2510                 printf("\n");
2511         }
2512         printf("\n");
2513
2514 #ifdef LSRA
2515         if (!opt_lsra) {
2516 #endif
2517 #if defined(ENABLE_INTRP)
2518                 if (!opt_intrp) {
2519 #endif
2520         printf("Interface Table:\n");
2521         for (i = 0; i < cd->maxstack; i++) {
2522                 if ((rd->interfaces[i][0].type >= 0) ||
2523                         (rd->interfaces[i][1].type >= 0) ||
2524                     (rd->interfaces[i][2].type >= 0) ||
2525                         (rd->interfaces[i][3].type >= 0) ||
2526                     (rd->interfaces[i][4].type >= 0)) {
2527                         printf("   %3d: ", i);
2528                         for (j = TYPE_INT; j <= TYPE_ADR; j++)
2529                                 if (rd->interfaces[i][j].type >= 0) {
2530                                         printf("   (%s) ", jit_type[j]);
2531                                         if (rd->interfaces[i][j].flags & SAVEDVAR) {
2532                                                 if (rd->interfaces[i][j].flags & INMEMORY)
2533                                                         printf("M%2d", rd->interfaces[i][j].regoff);
2534 #ifdef HAS_ADDRESS_REGISTER_FILE
2535                                                 else if (j == TYPE_ADR)
2536                                                         printf("R%02d", rd->interfaces[i][j].regoff);
2537 #endif
2538                                                 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
2539                                                         printf("F%02d", rd->interfaces[i][j].regoff);
2540                                                 else {
2541 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
2542                                                         if (IS_2_WORD_TYPE(j))
2543                                                                 printf(" %3s/%3s",
2544                              regs[GET_LOW_REG(rd->interfaces[i][j].regoff)],
2545                              regs[GET_HIGH_REG(rd->interfaces[i][j].regoff)]);
2546                                                         else
2547 #endif
2548                                                                 printf("%3s",regs[rd->interfaces[i][j].regoff]);
2549                                                 }
2550                                         }
2551                                         else {
2552                                                 if (rd->interfaces[i][j].flags & INMEMORY)
2553                                                         printf("m%2d", rd->interfaces[i][j].regoff);
2554 #ifdef HAS_ADDRESS_REGISTER_FILE
2555                                                 else if (j == TYPE_ADR)
2556                                                         printf("r%02d", rd->interfaces[i][j].regoff);
2557 #endif
2558                                                 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
2559                                                         printf("f%02d", rd->interfaces[i][j].regoff);
2560                                                 else {
2561 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
2562                                                         if (IS_2_WORD_TYPE(j))
2563                                                                 printf(" %3s/%3s",
2564                              regs[GET_LOW_REG(rd->interfaces[i][j].regoff)],
2565                                                          regs[GET_HIGH_REG(rd->interfaces[i][j].regoff)]);
2566                                                         else
2567 #endif
2568                                                                 printf("%3s",regs[rd->interfaces[i][j].regoff]);
2569                                                 }
2570                                         }
2571                                 }
2572                         printf("\n");
2573                 }
2574         }
2575         printf("\n");
2576
2577 #if defined(ENABLE_INTRP)
2578                 }
2579 #endif
2580 #ifdef LSRA
2581         }
2582 #endif
2583
2584         /* show code before first basic block */
2585
2586         if (opt_showdisassemble) {
2587                 u1ptr = (u1 *) ((ptrint) m->mcode + cd->dseglen);
2588
2589                 for (; u1ptr < (u1 *) ((ptrint) m->mcode + cd->dseglen + m->basicblocks[0].mpc);)
2590                         u1ptr = disassinstr(u1ptr);
2591
2592                 printf("\n");
2593         }
2594
2595         /* show code of all basic blocks */
2596
2597         for (bptr = m->basicblocks; bptr != NULL; bptr = bptr->next) {
2598                 show_icmd_block(m, cd, bptr);
2599         }
2600
2601         /* show stubs code */
2602
2603         if (opt_showdisassemble && opt_showexceptionstubs) {
2604                 printf("\nException stubs code:\n");
2605                 printf("Length: %d\n\n", (s4) (m->mcodelength -
2606                                                                            ((ptrint) cd->dseglen +
2607                                                                                 m->basicblocks[m->basicblockcount].mpc)));
2608
2609                 u1ptr = (u1 *) ((ptrint) m->mcode + cd->dseglen +
2610                                                 m->basicblocks[m->basicblockcount].mpc);
2611
2612                 for (; (ptrint) u1ptr < ((ptrint) m->mcode + m->mcodelength);)
2613                         u1ptr = disassinstr(u1ptr);
2614
2615                 printf("\n");
2616         }
2617
2618 #if defined(USE_THREADS)
2619         builtin_monitorexit(lock_show_icmd);
2620 #endif
2621 }
2622
2623
2624 void show_icmd_block(methodinfo *m, codegendata *cd, basicblock *bptr)
2625 {
2626         s4           i, j;
2627         bool         deadcode;
2628         instruction *iptr;
2629         u1          *u1ptr;
2630
2631         if (bptr->flags != BBDELETED) {
2632                 deadcode = bptr->flags <= BBREACHED;
2633                 printf("[");
2634                 if (deadcode)
2635                         for (j = cd->maxstack; j > 0; j--)
2636                                 printf(" ?  ");
2637                 else
2638                         icmd_print_stack(cd, bptr->instack);
2639                 printf("] L%03d(%d - %d) flags=%d:\n", bptr->debug_nr, bptr->icount, bptr->pre_count,bptr->flags);
2640                 iptr = bptr->iinstr;
2641
2642                 for (i = 0; i < bptr->icount; i++, iptr++) {
2643                         printf("[");
2644                         if (deadcode) {
2645                                 for (j = cd->maxstack; j > 0; j--)
2646                                         printf(" ?  ");
2647                         }
2648                         else
2649                                 icmd_print_stack(cd, iptr->dst);
2650                         printf("] %5d (line: %5d)  ", i, iptr->line);
2651
2652                         show_icmd(iptr, deadcode);
2653                         printf("\n");
2654                 }
2655
2656                 if (opt_showdisassemble && (!deadcode)) {
2657                         printf("\n");
2658                         u1ptr = (u1 *) ((ptrint) m->mcode + cd->dseglen + bptr->mpc);
2659
2660                         if (bptr->next != NULL) {
2661                                 for (; u1ptr < (u1 *) ((ptrint) m->mcode + cd->dseglen + bptr->next->mpc);)
2662                                         u1ptr = disassinstr(u1ptr);
2663
2664                         } else {
2665                                 for (; u1ptr < (u1 *) ((ptrint) m->mcode + m->mcodelength);)
2666                                         u1ptr = disassinstr(u1ptr); 
2667                         }
2668                         printf("\n");
2669                 }
2670         }
2671 }
2672
2673
2674 void show_icmd(instruction *iptr, bool deadcode)
2675 {
2676         int j;
2677         s4  *s4ptr;
2678         void **tptr = NULL;
2679         
2680         printf("%s", icmd_names[iptr->opc]);
2681
2682         switch (iptr->opc) {
2683         case ICMD_IADDCONST:
2684         case ICMD_ISUBCONST:
2685         case ICMD_IMULCONST:
2686         case ICMD_IMULPOW2:
2687         case ICMD_IDIVPOW2:
2688         case ICMD_IREMPOW2:
2689         case ICMD_IANDCONST:
2690         case ICMD_IORCONST:
2691         case ICMD_IXORCONST:
2692         case ICMD_ISHLCONST:
2693         case ICMD_ISHRCONST:
2694         case ICMD_IUSHRCONST:
2695         case ICMD_LSHLCONST:
2696         case ICMD_LSHRCONST:
2697         case ICMD_LUSHRCONST:
2698         case ICMD_ICONST:
2699         case ICMD_ELSE_ICONST:
2700         case ICMD_IASTORECONST:
2701         case ICMD_BASTORECONST:
2702         case ICMD_CASTORECONST:
2703         case ICMD_SASTORECONST:
2704                 printf(" %d (0x%08x)", iptr->val.i, iptr->val.i);
2705                 break;
2706
2707         case ICMD_IFEQ_ICONST:
2708         case ICMD_IFNE_ICONST:
2709         case ICMD_IFLT_ICONST:
2710         case ICMD_IFGE_ICONST:
2711         case ICMD_IFGT_ICONST:
2712         case ICMD_IFLE_ICONST:
2713                 printf("(%d) %d", iptr[1].op1, iptr->val.i);
2714                 break;
2715
2716         case ICMD_LADDCONST:
2717         case ICMD_LSUBCONST:
2718         case ICMD_LMULCONST:
2719         case ICMD_LMULPOW2:
2720         case ICMD_LDIVPOW2:
2721         case ICMD_LREMPOW2:
2722         case ICMD_LANDCONST:
2723         case ICMD_LORCONST:
2724         case ICMD_LXORCONST:
2725         case ICMD_LCONST:
2726         case ICMD_LASTORECONST:
2727 #if SIZEOF_VOID_P == 4
2728                 printf(" %lld (0x%016llx)", iptr->val.l, iptr->val.l);
2729 #else
2730                 printf(" %ld (0x%016lx)", iptr->val.l, iptr->val.l);
2731 #endif
2732                 break;
2733
2734         case ICMD_FCONST:
2735                 printf(" %f (0x%08x)", iptr->val.f, iptr->val.i);
2736                 break;
2737
2738         case ICMD_DCONST:
2739 #if SIZEOF_VOID_P == 4
2740                 printf(" %g (0x%016llx)", iptr->val.d, iptr->val.l);
2741 #else
2742                 printf(" %g (0x%016lx)", iptr->val.d, iptr->val.l);
2743 #endif
2744                 break;
2745
2746         case ICMD_ACONST:
2747         case ICMD_AASTORECONST:
2748                 /* check if this is a constant string or a class reference */
2749
2750                 if (iptr->target) {
2751                         if (iptr->val.a)
2752                                 printf(" %p", iptr->val.a);
2753                         else
2754                                 printf(" (NOT RESOLVED)");
2755
2756                         printf(", Class = \"");
2757                         utf_display(((constant_classref *) iptr->target)->name);
2758                         printf("\"");
2759
2760                 } else {
2761                         printf(" %p", iptr->val.a);
2762                         if (iptr->val.a) {
2763                                 printf(", String = \"");
2764                                 utf_display(javastring_toutf(iptr->val.a, false));
2765                                 printf("\"");
2766                         }
2767                 }
2768                 break;
2769
2770         case ICMD_GETFIELD:
2771         case ICMD_PUTFIELD:
2772                 if (iptr->val.a)         
2773                         printf(" %d, ", ((fieldinfo *) iptr->val.a)->offset);
2774                 else     
2775                         printf(" (NOT RESOLVED), ");
2776                 utf_display_classname(((unresolved_field *) iptr->target)->fieldref->classref->name);
2777                 printf(".");
2778                 utf_display(((unresolved_field *) iptr->target)->fieldref->name);
2779                 printf(" (type ");
2780                 utf_display(((unresolved_field *) iptr->target)->fieldref->descriptor);
2781                 printf(")"); 
2782                 break;
2783
2784         case ICMD_PUTSTATIC:
2785         case ICMD_GETSTATIC:
2786                 if (iptr->val.a) {
2787                         if (!(((fieldinfo *) iptr->val.a)->class->state & CLASS_INITIALIZED))
2788                                 printf(" (NOT INITIALIZED) ");
2789                         else
2790                                 printf(" ");
2791                 } else
2792                         printf(" (NOT RESOLVED) ");
2793                 utf_display_classname(((unresolved_field *) iptr->target)->fieldref->classref->name);
2794                 printf(".");
2795                 utf_display(((unresolved_field *) iptr->target)->fieldref->name);
2796                 printf(" (type ");
2797                 utf_display(((unresolved_field *) iptr->target)->fieldref->descriptor);
2798                 printf(")");
2799                 break;
2800
2801         case ICMD_PUTSTATICCONST:
2802         case ICMD_PUTFIELDCONST:
2803                 switch (iptr[1].op1) {
2804                 case TYPE_INT:
2805                         printf(" %d (0x%08x),", iptr->val.i, iptr->val.i);
2806                         break;
2807                 case TYPE_LNG:
2808 #if SIZEOF_VOID_P == 4
2809                         printf(" %lld (0x%016llx),", iptr->val.l, iptr->val.l);
2810 #else
2811                         printf(" %ld (0x%016lx),", iptr->val.l, iptr->val.l);
2812 #endif
2813                         break;
2814                 case TYPE_ADR:
2815                         printf(" %p,", iptr->val.a);
2816                         break;
2817                 case TYPE_FLT:
2818                         printf(" %g (0x%08x),", iptr->val.f, iptr->val.i);
2819                         break;
2820                 case TYPE_DBL:
2821 #if SIZEOF_VOID_P == 4
2822                         printf(" %g (0x%016llx),", iptr->val.d, iptr->val.l);
2823 #else
2824                         printf(" %g (0x%016lx),", iptr->val.d, iptr->val.l);
2825 #endif
2826                         break;
2827                 }
2828                 if (iptr->opc == ICMD_PUTFIELDCONST) {
2829                         if (iptr[1].val.a)
2830                                 printf(" %d,", ((fieldinfo *) iptr[1].val.a)->offset);
2831                         else
2832                                 printf(" (NOT RESOLVED),");
2833                 }
2834                 printf(" ");     
2835                 utf_display_classname(((unresolved_field *) iptr[1].target)->fieldref->classref->name);          
2836                 printf(".");     
2837                 utf_display(((unresolved_field *) iptr[1].target)->fieldref->name);      
2838                 printf(" (type ");       
2839                 utf_display(((unresolved_field *) iptr[1].target)->fieldref->descriptor);        
2840                 printf(")");     
2841                 break;
2842
2843         case ICMD_IINC:
2844                 printf(" %d + %d", iptr->op1, iptr->val.i);
2845                 break;
2846
2847         case ICMD_IASTORE:
2848         case ICMD_SASTORE:
2849         case ICMD_BASTORE:
2850         case ICMD_CASTORE:
2851         case ICMD_LASTORE:
2852         case ICMD_DASTORE:
2853         case ICMD_FASTORE:
2854         case ICMD_AASTORE:
2855
2856         case ICMD_IALOAD:
2857         case ICMD_SALOAD:
2858         case ICMD_BALOAD:
2859         case ICMD_CALOAD:
2860         case ICMD_LALOAD:
2861         case ICMD_DALOAD:
2862         case ICMD_FALOAD:
2863         case ICMD_AALOAD:
2864                 if (iptr->op1 != 0)
2865                         printf("(opt.)");
2866                 break;
2867
2868         case ICMD_RET:
2869         case ICMD_ILOAD:
2870         case ICMD_LLOAD:
2871         case ICMD_FLOAD:
2872         case ICMD_DLOAD:
2873         case ICMD_ALOAD:
2874         case ICMD_ISTORE:
2875         case ICMD_LSTORE:
2876         case ICMD_FSTORE:
2877         case ICMD_DSTORE:
2878         case ICMD_ASTORE:
2879                 printf(" %d", iptr->op1);
2880                 break;
2881
2882         case ICMD_NEW:
2883                 printf(" ");
2884                 utf_display_classname(((classinfo *) iptr->val.a)->name);
2885                 break;
2886
2887         case ICMD_NEWARRAY:
2888                 switch (iptr->op1) {
2889                 case 4:
2890                         printf(" boolean");
2891                         break;
2892                 case 5:
2893                         printf(" char");
2894                         break;
2895                 case 6:
2896                         printf(" float");
2897                         break;
2898                 case 7:
2899                         printf(" double");
2900                         break;
2901                 case 8:
2902                         printf(" byte");
2903                         break;
2904                 case 9:
2905                         printf(" short");
2906                         break;
2907                 case 10:
2908                         printf(" int");
2909                         break;
2910                 case 11:
2911                         printf(" long");
2912                         break;
2913                 }
2914                 break;
2915
2916         case ICMD_ANEWARRAY:
2917                 if (iptr->op1) {
2918                         printf(" ");
2919                         utf_display_classname(((classinfo *) iptr->val.a)->name);
2920                 }
2921                 break;
2922
2923         case ICMD_MULTIANEWARRAY:
2924                 if (iptr->target) {
2925                         printf(" (NOT RESOLVED) %d ",iptr->op1);
2926                         utf_display(((constant_classref *) iptr->val.a)->name);
2927                 } else {
2928                         printf(" %d ",iptr->op1);
2929                         utf_display_classname(((vftbl_t *) iptr->val.a)->class->name);
2930                 }
2931                 break;
2932
2933         case ICMD_CHECKCAST:
2934         case ICMD_INSTANCEOF:
2935                 {
2936                         classinfo *c = iptr->val.a;
2937                         if (c) {
2938                                 if (c->flags & ACC_INTERFACE)
2939                                         printf(" (INTERFACE) ");
2940                                 else
2941                                         printf(" (CLASS,%3d) ", c->vftbl->diffval);
2942                         } else {
2943                                 printf(" (NOT RESOLVED) ");
2944                         }
2945                         utf_display_classname(((constant_classref *) iptr->target)->name);
2946                 }
2947                 break;
2948
2949         case ICMD_INLINE_START:
2950                 printf(" ");
2951                 utf_display_classname(iptr->method->class->name);
2952                 printf(".");
2953                 utf_display_classname(iptr->method->name);
2954                 utf_display_classname(iptr->method->descriptor);
2955                 printf(", depth=%i", iptr->op1);
2956                 break;
2957
2958         case ICMD_INLINE_END:
2959                 break;
2960
2961         case ICMD_BUILTIN:
2962                 printf(" %s", ((builtintable_entry *) iptr->val.a)->name);
2963                 break;
2964
2965         case ICMD_INVOKEVIRTUAL:
2966         case ICMD_INVOKESPECIAL:
2967         case ICMD_INVOKESTATIC:
2968         case ICMD_INVOKEINTERFACE:
2969                 if (!iptr->val.a)
2970                         printf(" (NOT RESOLVED) ");
2971                 else
2972                         printf(" ");
2973                 utf_display_classname(((unresolved_method *) iptr->target)->methodref->classref->name);
2974                 printf(".");
2975                 utf_display(((unresolved_method *) iptr->target)->methodref->name);
2976                 utf_display(((unresolved_method *) iptr->target)->methodref->descriptor);
2977                 break;
2978
2979         case ICMD_IFEQ:
2980         case ICMD_IFNE:
2981         case ICMD_IFLT:
2982         case ICMD_IFGE:
2983         case ICMD_IFGT:
2984         case ICMD_IFLE:
2985                 if (deadcode || !iptr->target)
2986                         printf(" %d (0x%08x) op1=%d", iptr->val.i, iptr->val.i, iptr->op1);
2987                 else
2988                         printf(" %d (0x%08x) L%03d", iptr->val.i, iptr->val.i, ((basicblock *) iptr->target)->debug_nr);
2989                 break;
2990
2991         case ICMD_IF_LEQ:
2992         case ICMD_IF_LNE:
2993         case ICMD_IF_LLT:
2994         case ICMD_IF_LGE:
2995         case ICMD_IF_LGT:
2996         case ICMD_IF_LLE:
2997                 if (deadcode || !iptr->target)
2998 #if SIZEOF_VOID_P == 4
2999                         printf("(%lld) op1=%d", iptr->val.l, iptr->op1);
3000 #else
3001                         printf("(%ld) op1=%d", iptr->val.l, iptr->op1);
3002 #endif
3003                 else
3004 #if SIZEOF_VOID_P == 4
3005                         printf("(%lld) L%03d", iptr->val.l, ((basicblock *) iptr->target)->debug_nr);
3006 #else
3007                         printf("(%ld) L%03d", iptr->val.l, ((basicblock *) iptr->target)->debug_nr);
3008 #endif
3009                 break;
3010
3011         case ICMD_JSR:
3012         case ICMD_GOTO:
3013         case ICMD_IFNULL:
3014         case ICMD_IFNONNULL:
3015         case ICMD_IF_ICMPEQ:
3016         case ICMD_IF_ICMPNE:
3017         case ICMD_IF_ICMPLT:
3018         case ICMD_IF_ICMPGE:
3019         case ICMD_IF_ICMPGT:
3020         case ICMD_IF_ICMPLE:
3021         case ICMD_IF_LCMPEQ:
3022         case ICMD_IF_LCMPNE:
3023         case ICMD_IF_LCMPLT:
3024         case ICMD_IF_LCMPGE:
3025         case ICMD_IF_LCMPGT:
3026         case ICMD_IF_LCMPLE:
3027         case ICMD_IF_ACMPEQ:
3028         case ICMD_IF_ACMPNE:
3029                 if (deadcode || !iptr->target)
3030                         printf(" op1=%d", iptr->op1);
3031                 else
3032                         printf(" L%03d", ((basicblock *) iptr->target)->debug_nr);
3033                 break;
3034
3035         case ICMD_TABLESWITCH:
3036                 s4ptr = (s4*)iptr->val.a;
3037
3038                 if (deadcode || !iptr->target) {
3039                         printf(" %d;", *s4ptr);
3040                 }
3041                 else {
3042                         tptr = (void **) iptr->target;
3043                         printf(" L%03d;", ((basicblock *) *tptr)->debug_nr); 
3044                         tptr++;
3045                 }
3046
3047                 s4ptr++;         /* skip default */
3048                 j = *s4ptr++;                               /* low     */
3049                 j = *s4ptr++ - j;                           /* high    */
3050                 while (j >= 0) {
3051                         if (deadcode || !*tptr)
3052                                 printf(" %d", *s4ptr++);
3053                         else {
3054                                 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
3055                                 tptr++;
3056                         }
3057                         j--;
3058                 }
3059                 break;
3060
3061         case ICMD_LOOKUPSWITCH:
3062                 s4ptr = (s4*)iptr->val.a;
3063
3064                 if (deadcode || !iptr->target) {
3065                         printf(" %d;", *s4ptr);
3066                 }
3067                 else {
3068                         tptr = (void **) iptr->target;
3069                         printf(" L%03d;", ((basicblock *) *tptr)->debug_nr);
3070                         tptr++;
3071                 }
3072                 s4ptr++;                                         /* default */
3073                 j = *s4ptr++;                                    /* count   */
3074
3075                 while (--j >= 0) {
3076                         if (deadcode || !*tptr) {
3077                                 s4ptr++; /* skip value */
3078                                 printf(" %d",*s4ptr++);
3079                         }
3080                         else {
3081                                 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
3082                                 tptr++;
3083                         }
3084                 }
3085                 break;
3086
3087         case ICMD_ARETURN:
3088                 if (iptr->val.a) {
3089                         printf(" (NOT RESOLVED), Class = \"");
3090                         utf_display(((unresolved_class *) iptr->val.a)->classref->name);
3091                         printf("\"");
3092                 }
3093         }
3094 }
3095
3096
3097 /*
3098  * These are local overrides for various environment variables in Emacs.
3099  * Please do not remove this and leave it at the end of the file, where
3100  * Emacs will automagically detect them.
3101  * ---------------------------------------------------------------------
3102  * Local variables:
3103  * mode: c
3104  * indent-tabs-mode: t
3105  * c-basic-offset: 4
3106  * tab-width: 4
3107  * End:
3108  */