* LSRA: Renamed to ENABLE_LSRA.
[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 3969 2005-12-21 00:07:23Z 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 #if defined(ENABLE_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 defined(ENABLE_INTRP)
633                                                                 if (!opt_intrp) {
634 # endif
635 # if SUPPORT_CONST_STORE_ZERO_ONLY
636                                                                         if (iptr[0].val.i == 0) {
637 # endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
638                                                                                 switch (iptr[1].opc) {
639                                                                                 case ICMD_PUTSTATIC:
640                                                                                         iptr[0].opc = ICMD_PUTSTATICCONST;
641                                                                                         SETDST;
642                                                                                         break;
643                                                                                 case ICMD_PUTFIELD:
644                                                                                         iptr[0].opc = ICMD_PUTFIELDCONST;
645                                                                                         OP1_0(TYPE_ADR);
646                                                                                         break;
647                                                                                 }
648
649                                                                                 iptr[1].opc = ICMD_NOP;
650                                                                                 iptr[0].op1 = TYPE_INT;
651                                                                                 COUNT(count_pcmd_op);
652 # if SUPPORT_CONST_STORE_ZERO_ONLY
653                                                                         } else
654                                                                                 PUSHCONST(TYPE_INT);
655 # endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
656 # if defined(ENABLE_INTRP)
657                                                                 } else
658                                                                         PUSHCONST(TYPE_INT);
659 # endif
660                                                                 break;
661 #endif /* SUPPORT_CONST_STORE */
662                                                         default:
663                                                                 PUSHCONST(TYPE_INT);
664                                                         }
665                                                 }
666                                                 else
667                                                         PUSHCONST(TYPE_INT);
668                                                 break;
669
670                                         case ICMD_LCONST:
671                                                 COUNT(count_pcmd_load);
672                                                 if (len > 0) {
673                                                         switch (iptr[1].opc) {
674 #if SUPPORT_LONG_ADD
675                                                         case ICMD_LADD:
676                                                                 iptr[0].opc = ICMD_LADDCONST;
677                                                         icmd_lconst_tail:
678                                                                 iptr[1].opc = ICMD_NOP;
679                                                                 OP1_1(TYPE_LNG,TYPE_LNG);
680                                                                 COUNT(count_pcmd_op);
681                                                                 break;
682                                                         case ICMD_LSUB:
683                                                                 iptr[0].opc = ICMD_LSUBCONST;
684                                                                 goto icmd_lconst_tail;
685 #endif /* SUPPORT_LONG_ADD */
686 #if SUPPORT_LONG_MUL && SUPPORT_CONST_MUL
687                                                         case ICMD_LMUL:
688                                                                 iptr[0].opc = ICMD_LMULCONST;
689                                                                 goto icmd_lconst_tail;
690 #else /* SUPPORT_LONG_MUL && SUPPORT_CONST_MUL */
691 # if SUPPORT_LONG_SHIFT
692                                                         case ICMD_LMUL:
693                                                                 if (iptr[0].val.l == 0x00000002)
694                                                                         iptr[0].val.i = 1;
695                                                                 else if (iptr[0].val.l == 0x00000004)
696                                                                         iptr[0].val.i = 2;
697                                                                 else if (iptr[0].val.l == 0x00000008)
698                                                                         iptr[0].val.i = 3;
699                                                                 else if (iptr[0].val.l == 0x00000010)
700                                                                         iptr[0].val.i = 4;
701                                                                 else if (iptr[0].val.l == 0x00000020)
702                                                                         iptr[0].val.i = 5;
703                                                                 else if (iptr[0].val.l == 0x00000040)
704                                                                         iptr[0].val.i = 6;
705                                                                 else if (iptr[0].val.l == 0x00000080)
706                                                                         iptr[0].val.i = 7;
707                                                                 else if (iptr[0].val.l == 0x00000100)
708                                                                         iptr[0].val.i = 8;
709                                                                 else if (iptr[0].val.l == 0x00000200)
710                                                                         iptr[0].val.i = 9;
711                                                                 else if (iptr[0].val.l == 0x00000400)
712                                                                         iptr[0].val.i = 10;
713                                                                 else if (iptr[0].val.l == 0x00000800)
714                                                                         iptr[0].val.i = 11;
715                                                                 else if (iptr[0].val.l == 0x00001000)
716                                                                         iptr[0].val.i = 12;
717                                                                 else if (iptr[0].val.l == 0x00002000)
718                                                                         iptr[0].val.i = 13;
719                                                                 else if (iptr[0].val.l == 0x00004000)
720                                                                         iptr[0].val.i = 14;
721                                                                 else if (iptr[0].val.l == 0x00008000)
722                                                                         iptr[0].val.i = 15;
723                                                                 else if (iptr[0].val.l == 0x00010000)
724                                                                         iptr[0].val.i = 16;
725                                                                 else if (iptr[0].val.l == 0x00020000)
726                                                                         iptr[0].val.i = 17;
727                                                                 else if (iptr[0].val.l == 0x00040000)
728                                                                         iptr[0].val.i = 18;
729                                                                 else if (iptr[0].val.l == 0x00080000)
730                                                                         iptr[0].val.i = 19;
731                                                                 else if (iptr[0].val.l == 0x00100000)
732                                                                         iptr[0].val.i = 20;
733                                                                 else if (iptr[0].val.l == 0x00200000)
734                                                                         iptr[0].val.i = 21;
735                                                                 else if (iptr[0].val.l == 0x00400000)
736                                                                         iptr[0].val.i = 22;
737                                                                 else if (iptr[0].val.l == 0x00800000)
738                                                                         iptr[0].val.i = 23;
739                                                                 else if (iptr[0].val.l == 0x01000000)
740                                                                         iptr[0].val.i = 24;
741                                                                 else if (iptr[0].val.l == 0x02000000)
742                                                                         iptr[0].val.i = 25;
743                                                                 else if (iptr[0].val.l == 0x04000000)
744                                                                         iptr[0].val.i = 26;
745                                                                 else if (iptr[0].val.l == 0x08000000)
746                                                                         iptr[0].val.i = 27;
747                                                                 else if (iptr[0].val.l == 0x10000000)
748                                                                         iptr[0].val.i = 28;
749                                                                 else if (iptr[0].val.l == 0x20000000)
750                                                                         iptr[0].val.i = 29;
751                                                                 else if (iptr[0].val.l == 0x40000000)
752                                                                         iptr[0].val.i = 30;
753                                                                 else if (iptr[0].val.l == 0x80000000)
754                                                                         iptr[0].val.i = 31;
755                                                                 else {
756                                                                         PUSHCONST(TYPE_LNG);
757                                                                         break;
758                                                                 }
759                                                                 iptr[0].opc = ICMD_LMULPOW2;
760                                                                 goto icmd_lconst_tail;
761 # endif /* SUPPORT_LONG_SHIFT */
762 #endif /* SUPPORT_LONG_MUL && SUPPORT_CONST_MUL */
763 #if SUPPORT_LONG_DIV
764                                                         case ICMD_LDIV:
765                                                                 if (iptr[0].val.l == 0x00000002)
766                                                                         iptr[0].val.i = 1;
767                                                                 else if (iptr[0].val.l == 0x00000004)
768                                                                         iptr[0].val.i = 2;
769                                                                 else if (iptr[0].val.l == 0x00000008)
770                                                                         iptr[0].val.i = 3;
771                                                                 else if (iptr[0].val.l == 0x00000010)
772                                                                         iptr[0].val.i = 4;
773                                                                 else if (iptr[0].val.l == 0x00000020)
774                                                                         iptr[0].val.i = 5;
775                                                                 else if (iptr[0].val.l == 0x00000040)
776                                                                         iptr[0].val.i = 6;
777                                                                 else if (iptr[0].val.l == 0x00000080)
778                                                                         iptr[0].val.i = 7;
779                                                                 else if (iptr[0].val.l == 0x00000100)
780                                                                         iptr[0].val.i = 8;
781                                                                 else if (iptr[0].val.l == 0x00000200)
782                                                                         iptr[0].val.i = 9;
783                                                                 else if (iptr[0].val.l == 0x00000400)
784                                                                         iptr[0].val.i = 10;
785                                                                 else if (iptr[0].val.l == 0x00000800)
786                                                                         iptr[0].val.i = 11;
787                                                                 else if (iptr[0].val.l == 0x00001000)
788                                                                         iptr[0].val.i = 12;
789                                                                 else if (iptr[0].val.l == 0x00002000)
790                                                                         iptr[0].val.i = 13;
791                                                                 else if (iptr[0].val.l == 0x00004000)
792                                                                         iptr[0].val.i = 14;
793                                                                 else if (iptr[0].val.l == 0x00008000)
794                                                                         iptr[0].val.i = 15;
795                                                                 else if (iptr[0].val.l == 0x00010000)
796                                                                         iptr[0].val.i = 16;
797                                                                 else if (iptr[0].val.l == 0x00020000)
798                                                                         iptr[0].val.i = 17;
799                                                                 else if (iptr[0].val.l == 0x00040000)
800                                                                         iptr[0].val.i = 18;
801                                                                 else if (iptr[0].val.l == 0x00080000)
802                                                                         iptr[0].val.i = 19;
803                                                                 else if (iptr[0].val.l == 0x00100000)
804                                                                         iptr[0].val.i = 20;
805                                                                 else if (iptr[0].val.l == 0x00200000)
806                                                                         iptr[0].val.i = 21;
807                                                                 else if (iptr[0].val.l == 0x00400000)
808                                                                         iptr[0].val.i = 22;
809                                                                 else if (iptr[0].val.l == 0x00800000)
810                                                                         iptr[0].val.i = 23;
811                                                                 else if (iptr[0].val.l == 0x01000000)
812                                                                         iptr[0].val.i = 24;
813                                                                 else if (iptr[0].val.l == 0x02000000)
814                                                                         iptr[0].val.i = 25;
815                                                                 else if (iptr[0].val.l == 0x04000000)
816                                                                         iptr[0].val.i = 26;
817                                                                 else if (iptr[0].val.l == 0x08000000)
818                                                                         iptr[0].val.i = 27;
819                                                                 else if (iptr[0].val.l == 0x10000000)
820                                                                         iptr[0].val.i = 28;
821                                                                 else if (iptr[0].val.l == 0x20000000)
822                                                                         iptr[0].val.i = 29;
823                                                                 else if (iptr[0].val.l == 0x40000000)
824                                                                         iptr[0].val.i = 30;
825                                                                 else if (iptr[0].val.l == 0x80000000)
826                                                                         iptr[0].val.i = 31;
827                                                                 else {
828                                                                         PUSHCONST(TYPE_LNG);
829                                                                         break;
830                                                                 }
831                                                                 iptr[0].opc = ICMD_LDIVPOW2;
832                                                                 goto icmd_lconst_tail;
833                                                         case ICMD_LREM:
834                                                                 if ((iptr[0].val.l == 0x00000002) ||
835                                                                         (iptr[0].val.l == 0x00000004) ||
836                                                                         (iptr[0].val.l == 0x00000008) ||
837                                                                         (iptr[0].val.l == 0x00000010) ||
838                                                                         (iptr[0].val.l == 0x00000020) ||
839                                                                         (iptr[0].val.l == 0x00000040) ||
840                                                                         (iptr[0].val.l == 0x00000080) ||
841                                                                         (iptr[0].val.l == 0x00000100) ||
842                                                                         (iptr[0].val.l == 0x00000200) ||
843                                                                         (iptr[0].val.l == 0x00000400) ||
844                                                                         (iptr[0].val.l == 0x00000800) ||
845                                                                         (iptr[0].val.l == 0x00001000) ||
846                                                                         (iptr[0].val.l == 0x00002000) ||
847                                                                         (iptr[0].val.l == 0x00004000) ||
848                                                                         (iptr[0].val.l == 0x00008000) ||
849                                                                         (iptr[0].val.l == 0x00010000) ||
850                                                                         (iptr[0].val.l == 0x00020000) ||
851                                                                         (iptr[0].val.l == 0x00040000) ||
852                                                                         (iptr[0].val.l == 0x00080000) ||
853                                                                         (iptr[0].val.l == 0x00100000) ||
854                                                                         (iptr[0].val.l == 0x00200000) ||
855                                                                         (iptr[0].val.l == 0x00400000) ||
856                                                                         (iptr[0].val.l == 0x00800000) ||
857                                                                         (iptr[0].val.l == 0x01000000) ||
858                                                                         (iptr[0].val.l == 0x02000000) ||
859                                                                         (iptr[0].val.l == 0x04000000) ||
860                                                                         (iptr[0].val.l == 0x08000000) ||
861                                                                         (iptr[0].val.l == 0x10000000) ||
862                                                                         (iptr[0].val.l == 0x20000000) ||
863                                                                         (iptr[0].val.l == 0x40000000) ||
864                                                                         (iptr[0].val.l == 0x80000000)) {
865                                                                         iptr[0].opc = ICMD_LREMPOW2;
866                                                                         iptr[0].val.l -= 1;
867                                                                         goto icmd_lconst_tail;
868                                                                 }
869                                                                 PUSHCONST(TYPE_LNG);
870                                                                 break;
871 #endif /* SUPPORT_LONG_DIV */
872 #if SUPPORT_LONG_LOGICAL && SUPPORT_CONST_LOGICAL
873
874                                                         case ICMD_LAND:
875                                                                 iptr[0].opc = ICMD_LANDCONST;
876                                                                 goto icmd_lconst_tail;
877                                                         case ICMD_LOR:
878                                                                 iptr[0].opc = ICMD_LORCONST;
879                                                                 goto icmd_lconst_tail;
880                                                         case ICMD_LXOR:
881                                                                 iptr[0].opc = ICMD_LXORCONST;
882                                                                 goto icmd_lconst_tail;
883 #endif /* SUPPORT_LONG_LOGICAL && SUPPORT_CONST_LOGICAL */
884
885 #if SUPPORT_LONG_CMP_CONST
886                                                         case ICMD_LCMP:
887                                                                 if ((len > 1) && (iptr[2].val.i == 0)) {
888                                                                         switch (iptr[2].opc) {
889                                                                         case ICMD_IFEQ:
890                                                                                 iptr[0].opc = ICMD_IF_LEQ;
891                                                                         icmd_lconst_lcmp_tail:
892                                                                                 iptr[0].op1 = iptr[2].op1;
893                                                                                 bptr->icount -= 2;
894                                                                                 len -= 2;
895                                                                                 /* iptr[1].opc = ICMD_NOP;
896                                                                                    iptr[2].opc = ICMD_NOP; */
897                                                                                 OP1_0(TYPE_LNG);
898                                                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
899
900                                                                                 iptr[0].target = (void *) tbptr;
901
902                                                                                 MARKREACHED(tbptr, copy);
903                                                                                 COUNT(count_pcmd_bra);
904                                                                                 COUNT(count_pcmd_op);
905                                                                                 break;
906                                                                         case ICMD_IFNE:
907                                                                                 iptr[0].opc = ICMD_IF_LNE;
908                                                                                 goto icmd_lconst_lcmp_tail;
909                                                                         case ICMD_IFLT:
910                                                                                 iptr[0].opc = ICMD_IF_LLT;
911                                                                                 goto icmd_lconst_lcmp_tail;
912                                                                         case ICMD_IFGT:
913                                                                                 iptr[0].opc = ICMD_IF_LGT;
914                                                                                 goto icmd_lconst_lcmp_tail;
915                                                                         case ICMD_IFLE:
916                                                                                 iptr[0].opc = ICMD_IF_LLE;
917                                                                                 goto icmd_lconst_lcmp_tail;
918                                                                         case ICMD_IFGE:
919                                                                                 iptr[0].opc = ICMD_IF_LGE;
920                                                                                 goto icmd_lconst_lcmp_tail;
921                                                                         default:
922                                                                                 PUSHCONST(TYPE_LNG);
923                                                                         } /* switch (iptr[2].opc) */
924                                                                 } /* if (iptr[2].val.i == 0) */
925                                                                 else
926                                                                         PUSHCONST(TYPE_LNG);
927                                                                 break;
928 #endif /* SUPPORT_LONG_CMP_CONST */
929
930 #if SUPPORT_CONST_STORE
931                                                         case ICMD_LASTORE:
932 # if defined(ENABLE_INTRP)
933                                                                 if (!opt_intrp) {
934 # endif
935 # if SUPPORT_CONST_STORE_ZERO_ONLY
936                                                                         if (iptr[0].val.l == 0) {
937 # endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
938                                                                                 iptr[0].opc = ICMD_LASTORECONST;
939                                                                                 iptr[1].opc = ICMD_NOP;
940                                                                                 OPTT2_0(TYPE_INT, TYPE_ADR);
941                                                                                 COUNT(count_pcmd_op);
942 # if SUPPORT_CONST_STORE_ZERO_ONLY
943                                                                         } else
944                                                                                 PUSHCONST(TYPE_LNG);
945 # endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
946 # if defined(ENABLE_INTRP)
947                                                                 } else
948                                                                         PUSHCONST(TYPE_LNG);
949 # endif
950                                                                 break;
951
952                                                         case ICMD_PUTSTATIC:
953                                                         case ICMD_PUTFIELD:
954 # if defined(ENABLE_INTRP)
955                                                                 if (!opt_intrp) {
956 # endif
957 # if SUPPORT_CONST_STORE_ZERO_ONLY
958                                                                         if (iptr[0].val.l == 0) {
959 # endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
960                                                                                 switch (iptr[1].opc) {
961                                                                                 case ICMD_PUTSTATIC:
962                                                                                         iptr[0].opc = ICMD_PUTSTATICCONST;
963                                                                                         SETDST;
964                                                                                         break;
965                                                                                 case ICMD_PUTFIELD:
966                                                                                         iptr[0].opc = ICMD_PUTFIELDCONST;
967                                                                                         OP1_0(TYPE_ADR);
968                                                                                         break;
969                                                                                 }
970
971                                                                                 iptr[1].opc = ICMD_NOP;
972                                                                                 iptr[0].op1 = TYPE_LNG;
973                                                                                 COUNT(count_pcmd_op);
974 # if SUPPORT_CONST_STORE_ZERO_ONLY
975                                                                         } else
976                                                                                 PUSHCONST(TYPE_LNG);
977 # endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
978 # if defined(ENABLE_INTRP)
979                                                                 } else
980                                                                         PUSHCONST(TYPE_LNG);
981 # endif
982                                                                 break;
983 #endif /* SUPPORT_CONST_STORE */
984                                                         default:
985                                                                 PUSHCONST(TYPE_LNG);
986                                                         }
987                                                 }
988                                                 else
989                                                         PUSHCONST(TYPE_LNG);
990                                                 break;
991
992                                         case ICMD_FCONST:
993                                                 COUNT(count_pcmd_load);
994                                                 PUSHCONST(TYPE_FLT);
995                                                 break;
996
997                                         case ICMD_DCONST:
998                                                 COUNT(count_pcmd_load);
999                                                 PUSHCONST(TYPE_DBL);
1000                                                 break;
1001
1002                                         case ICMD_ACONST:
1003                                                 COUNT(count_pcmd_load);
1004 #if SUPPORT_CONST_STORE
1005 # if defined(ENABLE_INTRP)
1006                                                 if (!opt_intrp) {
1007 # endif
1008                                                         if ((len > 0) && (iptr->val.a == 0)) {
1009                                                                 switch (iptr[1].opc) {
1010                                                                 case ICMD_AASTORE:
1011                                                                 case ICMD_PUTSTATIC:
1012                                                                 case ICMD_PUTFIELD:
1013                                                                         switch (iptr[1].opc) {
1014                                                                         case ICMD_AASTORE:
1015                                                                                 iptr[0].opc = ICMD_AASTORECONST;
1016                                                                                 OPTT2_0(TYPE_INT, TYPE_ADR);
1017                                                                                 break;
1018                                                                         case ICMD_PUTSTATIC:
1019                                                                                 iptr[0].opc = ICMD_PUTSTATICCONST;
1020                                                                                 iptr[0].op1 = TYPE_ADR;
1021                                                                                 SETDST;
1022                                                                                 break;
1023                                                                         case ICMD_PUTFIELD:
1024                                                                                 iptr[0].opc = ICMD_PUTFIELDCONST;
1025                                                                                 iptr[0].op1 = TYPE_ADR;
1026                                                                                 OP1_0(TYPE_ADR);
1027                                                                                 break;
1028                                                                         }
1029
1030                                                                         iptr[1].opc = ICMD_NOP;
1031                                                                         COUNT(count_pcmd_op);
1032                                                                         break;
1033
1034                                                                 default:
1035                                                                         PUSHCONST(TYPE_ADR);
1036                                                                 }
1037
1038                                                         } else
1039                                                                 PUSHCONST(TYPE_ADR);
1040 # if defined(ENABLE_INTRP)
1041                                                 } else
1042                                                         PUSHCONST(TYPE_ADR);
1043 # endif
1044 #else /* SUPPORT_CONST_STORE */
1045                                                 PUSHCONST(TYPE_ADR);
1046 #endif /* SUPPORT_CONST_STORE */
1047                                                 break;
1048
1049                                                 /* pop 0 push 1 load */
1050                                                 
1051                                         case ICMD_ILOAD:
1052                                         case ICMD_LLOAD:
1053                                         case ICMD_FLOAD:
1054                                         case ICMD_DLOAD:
1055                                         case ICMD_ALOAD:
1056                                                 COUNT(count_load_instruction);
1057                                                 i = opcode - ICMD_ILOAD;
1058                                                 iptr->op1 = argren[iptr->op1];
1059 #if defined(ENABLE_INTRP)
1060                                                 if (!opt_intrp)
1061 #endif
1062                                                         rd->locals[iptr->op1][i].type = i;
1063                                                 LOAD(i, LOCALVAR, iptr->op1);
1064                                                 break;
1065
1066                                                 /* pop 2 push 1 */
1067
1068                                         case ICMD_LALOAD:
1069                                         case ICMD_IALOAD:
1070                                         case ICMD_FALOAD:
1071                                         case ICMD_DALOAD:
1072                                         case ICMD_AALOAD:
1073                                                 COUNT(count_check_null);
1074                                                 COUNT(count_check_bound);
1075                                                 COUNT(count_pcmd_mem);
1076                                                 OP2IAT_1(opcode - ICMD_IALOAD);
1077                                                 break;
1078
1079                                         case ICMD_BALOAD:
1080                                         case ICMD_CALOAD:
1081                                         case ICMD_SALOAD:
1082                                                 COUNT(count_check_null);
1083                                                 COUNT(count_check_bound);
1084                                                 COUNT(count_pcmd_mem);
1085                                                 OP2IAT_1(TYPE_INT);
1086                                                 break;
1087
1088                                                 /* pop 0 push 0 iinc */
1089
1090                                         case ICMD_IINC:
1091 #if defined(STATISTICS)
1092                                                 if (opt_stat) {
1093                                                         i = stackdepth;
1094                                                         if (i >= 10)
1095                                                                 count_store_depth[10]++;
1096                                                         else
1097                                                                 count_store_depth[i]++;
1098                                                 }
1099 #endif
1100                                                 copy = curstack;
1101                                                 i = stackdepth - 1;
1102                                                 while (copy) {
1103                                                         if ((copy->varkind == LOCALVAR) &&
1104                                                                 (copy->varnum == iptr->op1)) {
1105                                                                 copy->varkind = TEMPVAR;
1106                                                                 copy->varnum = i;
1107                                                         }
1108                                                         i--;
1109                                                         copy = copy->prev;
1110                                                 }
1111
1112                                                 /* allocate a dummy stack slot to keep ISTORE from */
1113                                                 /* marking its input stack as a LOCALVAR, since we */
1114                                                 /* change the value of the local variable here.    */
1115                                                 NEWSTACK0(TYPE_INT);
1116                                                 POP(TYPE_INT);
1117                                                 
1118                                                 SETDST;
1119                                                 break;
1120
1121                                                 /* pop 1 push 0 store */
1122
1123                                         case ICMD_ISTORE:
1124                                         case ICMD_LSTORE:
1125                                         case ICMD_FSTORE:
1126                                         case ICMD_DSTORE:
1127                                         case ICMD_ASTORE:
1128                                         icmd_store:
1129                                                 REQUIRE_1;
1130
1131                                         i = opcode - ICMD_ISTORE;
1132 #if defined(ENABLE_INTRP)
1133                                                 if (!opt_intrp)
1134 #endif
1135                                                         rd->locals[iptr->op1][i].type = i;
1136 #if defined(STATISTICS)
1137                                         if (opt_stat) {
1138                                                 count_pcmd_store++;
1139                                                 i = new - curstack;
1140                                                 if (i >= 20)
1141                                                         count_store_length[20]++;
1142                                                 else
1143                                                         count_store_length[i]++;
1144                                                 i = stackdepth - 1;
1145                                                 if (i >= 10)
1146                                                         count_store_depth[10]++;
1147                                                 else
1148                                                         count_store_depth[i]++;
1149                                         }
1150 #endif
1151                                         copy = curstack->prev;
1152                                         i = stackdepth - 2;
1153                                         while (copy) {
1154                                                 if ((copy->varkind == LOCALVAR) &&
1155                                                         (copy->varnum == iptr->op1)) {
1156                                                         copy->varkind = TEMPVAR;
1157                                                         copy->varnum = i;
1158                                                 }
1159                                                 i--;
1160                                                 copy = copy->prev;
1161                                         }
1162                                         if ((new - curstack) == 1) {
1163                                                 curstack->varkind = LOCALVAR;
1164                                                 curstack->varnum = iptr->op1;
1165                                         };
1166                                         STORE(opcode - ICMD_ISTORE);
1167                                         break;
1168
1169                                         /* pop 3 push 0 */
1170
1171                                         case ICMD_AASTORE:
1172                                                 COUNT(count_check_null);
1173                                                 COUNT(count_check_bound);
1174                                                 COUNT(count_pcmd_mem);
1175
1176                                                 bte = builtintable_get_internal(BUILTIN_canstore);
1177                                                 md = bte->md;
1178
1179                                                 if (md->memuse > rd->memuse)
1180                                                         rd->memuse = md->memuse;
1181                                                 if (md->argintreguse > rd->argintreguse)
1182                                                         rd->argintreguse = md->argintreguse;
1183
1184                                                 /* make all stack variables saved */
1185
1186                                                 copy = curstack;
1187                                                 while (copy) {
1188                                                         copy->flags |= SAVEDVAR;
1189                                                         copy = copy->prev;
1190                                                 }
1191
1192                                                 OP3TIA_0(TYPE_ADR);
1193                                                 break;
1194
1195                                         case ICMD_IASTORE:
1196                                         case ICMD_LASTORE:
1197                                         case ICMD_FASTORE:
1198                                         case ICMD_DASTORE:
1199                                                 COUNT(count_check_null);
1200                                                 COUNT(count_check_bound);
1201                                                 COUNT(count_pcmd_mem);
1202                                                 OP3TIA_0(opcode - ICMD_IASTORE);
1203                                                 break;
1204
1205                                         case ICMD_BASTORE:
1206                                         case ICMD_CASTORE:
1207                                         case ICMD_SASTORE:
1208                                                 COUNT(count_check_null);
1209                                                 COUNT(count_check_bound);
1210                                                 COUNT(count_pcmd_mem);
1211                                                 OP3TIA_0(TYPE_INT);
1212                                                 break;
1213
1214                                                 /* pop 1 push 0 */
1215
1216                                         case ICMD_POP:
1217 #ifdef TYPECHECK_STACK_COMPCAT
1218                                                 if (opt_verify) {
1219                                                         REQUIRE_1;
1220                                                         if (IS_2_WORD_TYPE(curstack->type)) {
1221                                                                 *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1222                                                                 return NULL;
1223                                                         }
1224                                                 }
1225 #endif
1226                                                 OP1_0ANY;
1227                                                 break;
1228
1229                                         case ICMD_IRETURN:
1230                                         case ICMD_LRETURN:
1231                                         case ICMD_FRETURN:
1232                                         case ICMD_DRETURN:
1233                                         case ICMD_ARETURN:
1234                                                 md_return_alloc(m, rd, opcode - ICMD_IRETURN, curstack);
1235                                                 COUNT(count_pcmd_return);
1236                                                 OP1_0(opcode - ICMD_IRETURN);
1237                                                 superblockend = true;
1238                                                 break;
1239
1240                                         case ICMD_ATHROW:
1241                                                 COUNT(count_check_null);
1242                                                 OP1_0(TYPE_ADR);
1243                                                 STACKRESET;
1244                                                 SETDST;
1245                                                 superblockend = true;
1246                                                 break;
1247
1248                                         case ICMD_PUTSTATIC:
1249                                                 COUNT(count_pcmd_mem);
1250                                                 OP1_0(iptr->op1);
1251                                                 break;
1252
1253                                                 /* pop 1 push 0 branch */
1254
1255                                         case ICMD_IFNULL:
1256                                         case ICMD_IFNONNULL:
1257                                                 COUNT(count_pcmd_bra);
1258                                                 OP1_0(TYPE_ADR);
1259                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
1260
1261                                                 iptr[0].target = (void *) tbptr;
1262
1263                                                 MARKREACHED(tbptr, copy);
1264                                                 break;
1265
1266                                         case ICMD_IFEQ:
1267                                         case ICMD_IFNE:
1268                                         case ICMD_IFLT:
1269                                         case ICMD_IFGE:
1270                                         case ICMD_IFGT:
1271                                         case ICMD_IFLE:
1272                                                 COUNT(count_pcmd_bra);
1273 #if CONDITIONAL_LOADCONST
1274 # if defined(ENABLE_INTRP)
1275                                                 if (!opt_intrp) {
1276 # endif
1277                                                         tbptr = m->basicblocks + b_index;
1278                                                         if ((b_count >= 3) &&
1279                                                                 ((b_index + 2) == m->basicblockindex[iptr[0].op1]) &&
1280                                                                 (tbptr[1].pre_count == 1) &&
1281                                                                 (tbptr[1].iinstr[0].opc == ICMD_ICONST) &&
1282                                                                 (tbptr[1].iinstr[1].opc == ICMD_GOTO)   &&
1283                                                                 ((b_index + 3) == m->basicblockindex[tbptr[1].iinstr[1].op1]) &&
1284                                                                 (tbptr[2].pre_count == 1) &&
1285                                                                 (tbptr[2].iinstr[0].opc == ICMD_ICONST)  &&
1286                                                                 (tbptr[2].icount==1)) {
1287                                                                 /*printf("tbptr[2].icount=%d\n",tbptr[2].icount);*/
1288                                                                 OP1_1(TYPE_INT, TYPE_INT);
1289                                                                 switch (iptr[0].opc) {
1290                                                                 case ICMD_IFEQ:
1291                                                                         iptr[0].opc = ICMD_IFNE_ICONST;
1292                                                                         break;
1293                                                                 case ICMD_IFNE:
1294                                                                         iptr[0].opc = ICMD_IFEQ_ICONST;
1295                                                                         break;
1296                                                                 case ICMD_IFLT:
1297                                                                         iptr[0].opc = ICMD_IFGE_ICONST;
1298                                                                         break;
1299                                                                 case ICMD_IFGE:
1300                                                                         iptr[0].opc = ICMD_IFLT_ICONST;
1301                                                                         break;
1302                                                                 case ICMD_IFGT:
1303                                                                         iptr[0].opc = ICMD_IFLE_ICONST;
1304                                                                         break;
1305                                                                 case ICMD_IFLE:
1306                                                                         iptr[0].opc = ICMD_IFGT_ICONST;
1307                                                                         break;
1308                                                                 }
1309 #if 1
1310                                                                 iptr[0].val.i = iptr[1].val.i;
1311                                                                 iptr[1].opc = ICMD_ELSE_ICONST;
1312                                                                 iptr[1].val.i = iptr[3].val.i;
1313                                                                 iptr[2].opc = ICMD_NOP;
1314                                                                 iptr[3].opc = ICMD_NOP;
1315 #else
1316                                                                 /* HACK: save compare value in iptr[1].op1 */    
1317                                                                 iptr[1].op1 = iptr[0].val.i;     
1318                                                                 iptr[0].val.i = tbptr[1].iinstr[0].val.i;        
1319                                                                 iptr[1].opc = ICMD_ELSE_ICONST;          
1320                                                                 iptr[1].val.i = tbptr[2].iinstr[0].val.i;        
1321                                                                 tbptr[1].iinstr[0].opc = ICMD_NOP;       
1322                                                                 tbptr[1].iinstr[1].opc = ICMD_NOP;       
1323                                                                 tbptr[2].iinstr[0].opc = ICMD_NOP;       
1324 #endif
1325                                                                 tbptr[1].flags = BBDELETED;
1326                                                                 tbptr[2].flags = BBDELETED;
1327                                                                 tbptr[1].icount = 0;
1328                                                                 tbptr[2].icount = 0;
1329                                                                 if (tbptr[3].pre_count == 2) {
1330                                                                         len += tbptr[3].icount + 3;
1331                                                                         bptr->icount += tbptr[3].icount + 3;
1332                                                                         tbptr[3].flags = BBDELETED;
1333                                                                         tbptr[3].icount = 0;
1334                                                                         b_index++;
1335                                                                 }
1336                                                                 else {
1337                                                                         bptr->icount++;
1338                                                                         len ++;
1339                                                                 }
1340                                                                 b_index += 2;
1341                                                                 break;
1342                                                         }
1343 # if defined(ENABLE_INTRP)
1344                                                 }
1345 # endif
1346
1347 #endif /* CONDITIONAL_LOADCONST */
1348
1349                                                 OP1_0(TYPE_INT);
1350                                                 iptr->val.i = 0;
1351                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
1352
1353                                                 iptr[0].target = (void *) tbptr;
1354
1355                                                 MARKREACHED(tbptr, copy);
1356                                                 break;
1357
1358                                                 /* pop 0 push 0 branch */
1359
1360                                         case ICMD_GOTO:
1361                                                 COUNT(count_pcmd_bra);
1362                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
1363
1364                                                 iptr[0].target = (void *) tbptr;
1365
1366                                                 MARKREACHED(tbptr, copy);
1367                                                 SETDST;
1368                                                 superblockend = true;
1369                                                 break;
1370
1371                                                 /* pop 1 push 0 table branch */
1372
1373                                         case ICMD_TABLESWITCH:
1374                                                 COUNT(count_pcmd_table);
1375                                                 OP1_0(TYPE_INT);
1376                                                 s4ptr = iptr->val.a;
1377                                                 tbptr = m->basicblocks + m->basicblockindex[*s4ptr++];
1378                                                 MARKREACHED(tbptr, copy);
1379                                                 i = *s4ptr++;                          /* low     */
1380                                                 i = *s4ptr++ - i + 1;                  /* high    */
1381
1382                                                 tptr = DMNEW(void*, i+1);
1383                                                 iptr->target = (void *) tptr;
1384
1385                                                 tptr[0] = (void *) tbptr;
1386                                                 tptr++;
1387
1388                                                 while (--i >= 0) {
1389                                                         tbptr = m->basicblocks + m->basicblockindex[*s4ptr++];
1390
1391                                                         tptr[0] = (void *) tbptr;
1392                                                         tptr++;
1393
1394                                                         MARKREACHED(tbptr, copy);
1395                                                 }
1396                                                 SETDST;
1397                                                 superblockend = true;
1398                                                 break;
1399                                                         
1400                                                 /* pop 1 push 0 table branch */
1401
1402                                         case ICMD_LOOKUPSWITCH:
1403                                                 COUNT(count_pcmd_table);
1404                                                 OP1_0(TYPE_INT);
1405                                                 s4ptr = iptr->val.a;
1406                                                 tbptr = m->basicblocks + m->basicblockindex[*s4ptr++];
1407                                                 MARKREACHED(tbptr, copy);
1408                                                 i = *s4ptr++;                          /* count   */
1409
1410                                                 tptr = DMNEW(void*, i+1);
1411                                                 iptr->target = (void *) tptr;
1412
1413                                                 tptr[0] = (void *) tbptr;
1414                                                 tptr++;
1415
1416                                                 while (--i >= 0) {
1417                                                         tbptr = m->basicblocks + m->basicblockindex[s4ptr[1]];
1418
1419                                                         tptr[0] = (void *) tbptr;
1420                                                         tptr++;
1421                                                                 
1422                                                         MARKREACHED(tbptr, copy);
1423                                                         s4ptr += 2;
1424                                                 }
1425                                                 SETDST;
1426                                                 superblockend = true;
1427                                                 break;
1428
1429                                         case ICMD_MONITORENTER:
1430                                                 COUNT(count_check_null);
1431                                         case ICMD_MONITOREXIT:
1432                                                 OP1_0(TYPE_ADR);
1433                                                 break;
1434
1435                                                 /* pop 2 push 0 branch */
1436
1437                                         case ICMD_IF_ICMPEQ:
1438                                         case ICMD_IF_ICMPNE:
1439                                         case ICMD_IF_ICMPLT:
1440                                         case ICMD_IF_ICMPGE:
1441                                         case ICMD_IF_ICMPGT:
1442                                         case ICMD_IF_ICMPLE:
1443                                                 COUNT(count_pcmd_bra);
1444                                                 OP2_0(TYPE_INT);
1445                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
1446                                                         
1447                                                 iptr[0].target = (void *) tbptr;
1448
1449                                                 MARKREACHED(tbptr, copy);
1450                                                 break;
1451
1452                                         case ICMD_IF_ACMPEQ:
1453                                         case ICMD_IF_ACMPNE:
1454                                                 COUNT(count_pcmd_bra);
1455                                                 OP2_0(TYPE_ADR);
1456                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
1457
1458                                                 iptr[0].target = (void *) tbptr;
1459
1460                                                 MARKREACHED(tbptr, copy);
1461                                                 break;
1462
1463                                                 /* pop 2 push 0 */
1464
1465                                         case ICMD_PUTFIELD:
1466                                                 COUNT(count_check_null);
1467                                                 COUNT(count_pcmd_mem);
1468                                                 OPTT2_0(iptr->op1,TYPE_ADR);
1469                                                 break;
1470
1471                                         case ICMD_POP2:
1472                                                 REQUIRE_1;
1473                                                 if (!IS_2_WORD_TYPE(curstack->type)) {
1474                                                         /* ..., cat1 */
1475 #ifdef TYPECHECK_STACK_COMPCAT
1476                                                         if (opt_verify) {
1477                                                                 REQUIRE_2;
1478                                                                 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1479                                                                         *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1480                                                                         return NULL;
1481                                                                 }
1482                                                         }
1483 #endif
1484                                                         OP1_0ANY;                /* second pop */
1485                                                 }
1486                                                 else
1487                                                         iptr->opc = ICMD_POP;
1488                                                 OP1_0ANY;
1489                                                 break;
1490
1491                                                 /* pop 0 push 1 dup */
1492                                                 
1493                                         case ICMD_DUP:
1494 #ifdef TYPECHECK_STACK_COMPCAT
1495                                                 if (opt_verify) {
1496                                                         REQUIRE_1;
1497                                                         if (IS_2_WORD_TYPE(curstack->type)) {
1498                                                                 *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1499                                                                 return NULL;
1500                                                         }
1501                                                 }
1502 #endif
1503                                                 COUNT(count_dup_instruction);
1504                                                 DUP;
1505                                                 break;
1506
1507                                         case ICMD_DUP2:
1508                                                 REQUIRE_1;
1509                                                 if (IS_2_WORD_TYPE(curstack->type)) {
1510                                                         /* ..., cat2 */
1511                                                         iptr->opc = ICMD_DUP;
1512                                                         DUP;
1513                                                 }
1514                                                 else {
1515                                                         REQUIRE_2;
1516                                                         /* ..., ????, cat1 */
1517 #ifdef TYPECHECK_STACK_COMPCAT
1518                                                         if (opt_verify) {
1519                                                                 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1520                                                                         *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1521                                                                         return NULL;
1522                                                                 }
1523                                                         }
1524 #endif
1525                                                         copy = curstack;
1526                                                         NEWSTACK(copy->prev->type, copy->prev->varkind,
1527                                                                          copy->prev->varnum);
1528                                                         NEWSTACK(copy->type, copy->varkind,
1529                                                                          copy->varnum);
1530                                                         SETDST;
1531                                                         stackdepth += 2;
1532                                                 }
1533                                                 break;
1534
1535                                                 /* pop 2 push 3 dup */
1536                                                 
1537                                         case ICMD_DUP_X1:
1538 #ifdef TYPECHECK_STACK_COMPCAT
1539                                                 if (opt_verify) {
1540                                                         REQUIRE_2;
1541                                                         if (IS_2_WORD_TYPE(curstack->type) ||
1542                                                                 IS_2_WORD_TYPE(curstack->prev->type)) {
1543                                                                         *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1544                                                                         return NULL;
1545                                                         }
1546                                                 }
1547 #endif
1548                                                 DUP_X1;
1549                                                 break;
1550
1551                                         case ICMD_DUP2_X1:
1552                                                 REQUIRE_2;
1553                                                 if (IS_2_WORD_TYPE(curstack->type)) {
1554                                                         /* ..., ????, cat2 */
1555 #ifdef TYPECHECK_STACK_COMPCAT
1556                                                         if (opt_verify) {
1557                                                                 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1558                                                                         *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1559                                                                         return NULL;
1560                                                                 }
1561                                                         }
1562 #endif
1563                                                         iptr->opc = ICMD_DUP_X1;
1564                                                         DUP_X1;
1565                                                 }
1566                                                 else {
1567                                                         /* ..., ????, cat1 */
1568 #ifdef TYPECHECK_STACK_COMPCAT
1569                                                         if (opt_verify) {
1570                                                                 REQUIRE_3;
1571                                                                 if (IS_2_WORD_TYPE(curstack->prev->type)
1572                                                                         || IS_2_WORD_TYPE(curstack->prev->prev->type)) {
1573                                                                         *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1574                                                                         return NULL;
1575                                                                 }
1576                                                         }
1577 #endif
1578                                                         DUP2_X1;
1579                                                 }
1580                                                 break;
1581
1582                                                 /* pop 3 push 4 dup */
1583                                                 
1584                                         case ICMD_DUP_X2:
1585                                                 REQUIRE_2;
1586                                                 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1587                                                         /* ..., cat2, ???? */
1588 #ifdef TYPECHECK_STACK_COMPCAT
1589                                                         if (opt_verify) {
1590                                                                 if (IS_2_WORD_TYPE(curstack->type)) {
1591                                                                         *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1592                                                                         return NULL;
1593                                                                 }
1594                                                         }
1595 #endif
1596                                                         iptr->opc = ICMD_DUP_X1;
1597                                                         DUP_X1;
1598                                                 }
1599                                                 else {
1600                                                         /* ..., cat1, ???? */
1601 #ifdef TYPECHECK_STACK_COMPCAT
1602                                                         if (opt_verify) {
1603                                                                 REQUIRE_3;
1604                                                                 if (IS_2_WORD_TYPE(curstack->type)
1605                                                                         || IS_2_WORD_TYPE(curstack->prev->prev->type)) {
1606                                                                         *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1607                                                                         return NULL;
1608                                                                 }
1609                                                         }
1610 #endif
1611                                                         DUP_X2;
1612                                                 }
1613                                                 break;
1614
1615                                         case ICMD_DUP2_X2:
1616                                                 REQUIRE_2;
1617                                                 if (IS_2_WORD_TYPE(curstack->type)) {
1618                                                         /* ..., ????, cat2 */
1619                                                         if (IS_2_WORD_TYPE(curstack->prev->type)) {
1620                                                                 /* ..., cat2, cat2 */
1621                                                                 iptr->opc = ICMD_DUP_X1;
1622                                                                 DUP_X1;
1623                                                         }
1624                                                         else {
1625                                                                 /* ..., cat1, cat2 */
1626 #ifdef TYPECHECK_STACK_COMPCAT
1627                                                                 if (opt_verify) {
1628                                                                         REQUIRE_3;
1629                                                                         if (IS_2_WORD_TYPE(curstack->prev->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_DUP_X2;
1636                                                                 DUP_X2;
1637                                                         }
1638                                                 }
1639                                                 else {
1640                                                         REQUIRE_3;
1641                                                         /* ..., ????, ????, cat1 */
1642                                                         if (IS_2_WORD_TYPE(curstack->prev->prev->type)) {
1643                                                                 /* ..., cat2, ????, cat1 */
1644 #ifdef TYPECHECK_STACK_COMPCAT
1645                                                                 if (opt_verify) {
1646                                                                         if (IS_2_WORD_TYPE(curstack->prev->type)) {
1647                                                                                 *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1648                                                                                 return NULL;
1649                                                                         }
1650                                                                 }
1651 #endif
1652                                                                 iptr->opc = ICMD_DUP2_X1;
1653                                                                 DUP2_X1;
1654                                                         }
1655                                                         else {
1656                                                                 /* ..., cat1, ????, cat1 */
1657 #ifdef TYPECHECK_STACK_COMPCAT
1658                                                                 if (opt_verify) {
1659                                                                         REQUIRE_4;
1660                                                                         if (IS_2_WORD_TYPE(curstack->prev->type)
1661                                                                                 || IS_2_WORD_TYPE(curstack->prev->prev->prev->type)) {
1662                                                                                 *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1663                                                                                 return NULL;
1664                                                                         }
1665                                                                 }
1666 #endif
1667                                                                 DUP2_X2;
1668                                                         }
1669                                                 }
1670                                                 break;
1671
1672                                                 /* pop 2 push 2 swap */
1673                                                 
1674                                         case ICMD_SWAP:
1675 #ifdef TYPECHECK_STACK_COMPCAT
1676                                                 if (opt_verify) {
1677                                                         REQUIRE_2;
1678                                                         if (IS_2_WORD_TYPE(curstack->type)
1679                                                                 || IS_2_WORD_TYPE(curstack->prev->type)) {
1680                                                                 *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1681                                                                 return NULL;
1682                                                         }
1683                                                 }
1684 #endif
1685                                                 SWAP;
1686                                                 break;
1687
1688                                                 /* pop 2 push 1 */
1689
1690                                         case ICMD_IDIV:
1691                                         case ICMD_IREM:
1692 #if !SUPPORT_DIVISION
1693                                                 bte = (builtintable_entry *) iptr->val.a;
1694                                                 md = bte->md;
1695                                                 i = iptr->op1;
1696
1697                                                 if (md->memuse > rd->memuse)
1698                                                         rd->memuse = md->memuse;
1699                                                 if (md->argintreguse > rd->argintreguse)
1700                                                         rd->argintreguse = md->argintreguse;
1701
1702                                                 /* make all stack variables saved */
1703
1704                                                 copy = curstack;
1705                                                 while (copy) {
1706                                                         copy->flags |= SAVEDVAR;
1707                                                         copy = copy->prev;
1708                                                 }
1709
1710                                                 /* fall through */
1711 #endif /* !SUPPORT_DIVISION */
1712
1713                                         case ICMD_ISHL:
1714                                         case ICMD_ISHR:
1715                                         case ICMD_IUSHR:
1716                                         case ICMD_IADD:
1717                                         case ICMD_ISUB:
1718                                         case ICMD_IMUL:
1719                                         case ICMD_IAND:
1720                                         case ICMD_IOR:
1721                                         case ICMD_IXOR:
1722                                                 COUNT(count_pcmd_op);
1723                                                 OP2_1(TYPE_INT);
1724                                                 break;
1725
1726                                         case ICMD_LDIV:
1727                                         case ICMD_LREM:
1728 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
1729                                                 bte = (builtintable_entry *) iptr->val.a;
1730                                                 md = bte->md;
1731                                                 i = iptr->op1;
1732
1733                                                 if (md->memuse > rd->memuse)
1734                                                         rd->memuse = md->memuse;
1735                                                 if (md->argintreguse > rd->argintreguse)
1736                                                         rd->argintreguse = md->argintreguse;
1737
1738                                                 /* make all stack variables saved */
1739
1740                                                 copy = curstack;
1741                                                 while (copy) {
1742                                                         copy->flags |= SAVEDVAR;
1743                                                         copy = copy->prev;
1744                                                 }
1745
1746                                                 /* fall through */
1747 #endif /* !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV) */
1748
1749                                         case ICMD_LMUL:
1750                                         case ICMD_LADD:
1751                                         case ICMD_LSUB:
1752 #if SUPPORT_LONG_LOGICAL
1753                                         case ICMD_LAND:
1754                                         case ICMD_LOR:
1755                                         case ICMD_LXOR:
1756 #endif /* SUPPORT_LONG_LOGICAL */
1757                                                 COUNT(count_pcmd_op);
1758                                                 OP2_1(TYPE_LNG);
1759                                                 break;
1760
1761                                         case ICMD_LSHL:
1762                                         case ICMD_LSHR:
1763                                         case ICMD_LUSHR:
1764                                                 COUNT(count_pcmd_op);
1765                                                 OP2IT_1(TYPE_LNG);
1766                                                 break;
1767
1768                                         case ICMD_FADD:
1769                                         case ICMD_FSUB:
1770                                         case ICMD_FMUL:
1771                                         case ICMD_FDIV:
1772                                         case ICMD_FREM:
1773                                                 COUNT(count_pcmd_op);
1774                                                 OP2_1(TYPE_FLT);
1775                                                 break;
1776
1777                                         case ICMD_DADD:
1778                                         case ICMD_DSUB:
1779                                         case ICMD_DMUL:
1780                                         case ICMD_DDIV:
1781                                         case ICMD_DREM:
1782                                                 COUNT(count_pcmd_op);
1783                                                 OP2_1(TYPE_DBL);
1784                                                 break;
1785
1786                                         case ICMD_LCMP:
1787                                                 COUNT(count_pcmd_op);
1788 #if SUPPORT_LONG_CMP_CONST
1789                                                 if ((len > 0) && (iptr[1].val.i == 0)) {
1790                                                         switch (iptr[1].opc) {
1791                                                         case ICMD_IFEQ:
1792                                                                 iptr[0].opc = ICMD_IF_LCMPEQ;
1793                                                         icmd_lcmp_if_tail:
1794                                                                 iptr[0].op1 = iptr[1].op1;
1795                                                                 len--;
1796                                                                 bptr->icount--;
1797                                                                 /* iptr[1].opc = ICMD_NOP; */
1798                                                                 OP2_0(TYPE_LNG);
1799                                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
1800                         
1801                                                                 iptr[0].target = (void *) tbptr;
1802
1803                                                                 MARKREACHED(tbptr, copy);
1804                                                                 COUNT(count_pcmd_bra);
1805                                                                 break;
1806                                                         case ICMD_IFNE:
1807                                                                 iptr[0].opc = ICMD_IF_LCMPNE;
1808                                                                 goto icmd_lcmp_if_tail;
1809                                                         case ICMD_IFLT:
1810                                                                 iptr[0].opc = ICMD_IF_LCMPLT;
1811                                                                 goto icmd_lcmp_if_tail;
1812                                                         case ICMD_IFGT:
1813                                                                 iptr[0].opc = ICMD_IF_LCMPGT;
1814                                                                 goto icmd_lcmp_if_tail;
1815                                                         case ICMD_IFLE:
1816                                                                 iptr[0].opc = ICMD_IF_LCMPLE;
1817                                                                 goto icmd_lcmp_if_tail;
1818                                                         case ICMD_IFGE:
1819                                                                 iptr[0].opc = ICMD_IF_LCMPGE;
1820                                                                 goto icmd_lcmp_if_tail;
1821                                                         default:
1822                                                                 OPTT2_1(TYPE_LNG, TYPE_INT);
1823                                                         }
1824                                                 }
1825                                                 else
1826 #endif /* SUPPORT_LONG_CMP_CONST */
1827                                                         OPTT2_1(TYPE_LNG, TYPE_INT);
1828                                                 break;
1829                                         case ICMD_FCMPL:
1830                                         case ICMD_FCMPG:
1831                                                 COUNT(count_pcmd_op);
1832                                                 OPTT2_1(TYPE_FLT, TYPE_INT);
1833                                                 break;
1834                                         case ICMD_DCMPL:
1835                                         case ICMD_DCMPG:
1836                                                 COUNT(count_pcmd_op);
1837                                                 OPTT2_1(TYPE_DBL, TYPE_INT);
1838                                                 break;
1839
1840                                                 /* pop 1 push 1 */
1841                                                 
1842                                         case ICMD_INEG:
1843                                         case ICMD_INT2BYTE:
1844                                         case ICMD_INT2CHAR:
1845                                         case ICMD_INT2SHORT:
1846                                                 COUNT(count_pcmd_op);
1847                                                 OP1_1(TYPE_INT, TYPE_INT);
1848                                                 break;
1849                                         case ICMD_LNEG:
1850                                                 COUNT(count_pcmd_op);
1851                                                 OP1_1(TYPE_LNG, TYPE_LNG);
1852                                                 break;
1853                                         case ICMD_FNEG:
1854                                                 COUNT(count_pcmd_op);
1855                                                 OP1_1(TYPE_FLT, TYPE_FLT);
1856                                                 break;
1857                                         case ICMD_DNEG:
1858                                                 COUNT(count_pcmd_op);
1859                                                 OP1_1(TYPE_DBL, TYPE_DBL);
1860                                                 break;
1861
1862                                         case ICMD_I2L:
1863                                                 COUNT(count_pcmd_op);
1864                                                 OP1_1(TYPE_INT, TYPE_LNG);
1865                                                 break;
1866                                         case ICMD_I2F:
1867                                                 COUNT(count_pcmd_op);
1868                                                 OP1_1(TYPE_INT, TYPE_FLT);
1869                                                 break;
1870                                         case ICMD_I2D:
1871                                                 COUNT(count_pcmd_op);
1872                                                 OP1_1(TYPE_INT, TYPE_DBL);
1873                                                 break;
1874                                         case ICMD_L2I:
1875                                                 COUNT(count_pcmd_op);
1876                                                 OP1_1(TYPE_LNG, TYPE_INT);
1877                                                 break;
1878                                         case ICMD_L2F:
1879                                                 COUNT(count_pcmd_op);
1880                                                 OP1_1(TYPE_LNG, TYPE_FLT);
1881                                                 break;
1882                                         case ICMD_L2D:
1883                                                 COUNT(count_pcmd_op);
1884                                                 OP1_1(TYPE_LNG, TYPE_DBL);
1885                                                 break;
1886                                         case ICMD_F2I:
1887                                                 COUNT(count_pcmd_op);
1888                                                 OP1_1(TYPE_FLT, TYPE_INT);
1889                                                 break;
1890                                         case ICMD_F2L:
1891                                                 COUNT(count_pcmd_op);
1892                                                 OP1_1(TYPE_FLT, TYPE_LNG);
1893                                                 break;
1894                                         case ICMD_F2D:
1895                                                 COUNT(count_pcmd_op);
1896                                                 OP1_1(TYPE_FLT, TYPE_DBL);
1897                                                 break;
1898                                         case ICMD_D2I:
1899                                                 COUNT(count_pcmd_op);
1900                                                 OP1_1(TYPE_DBL, TYPE_INT);
1901                                                 break;
1902                                         case ICMD_D2L:
1903                                                 COUNT(count_pcmd_op);
1904                                                 OP1_1(TYPE_DBL, TYPE_LNG);
1905                                                 break;
1906                                         case ICMD_D2F:
1907                                                 COUNT(count_pcmd_op);
1908                                                 OP1_1(TYPE_DBL, TYPE_FLT);
1909                                                 break;
1910
1911                                         case ICMD_CHECKCAST:
1912                                                 if (iptr->op1 == 0) {
1913                                                         /* array type cast-check */
1914
1915                                                         bte = builtintable_get_internal(BUILTIN_arraycheckcast);
1916                                                         md = bte->md;
1917
1918                                                         if (md->memuse > rd->memuse)
1919                                                                 rd->memuse = md->memuse;
1920                                                         if (md->argintreguse > rd->argintreguse)
1921                                                                 rd->argintreguse = md->argintreguse;
1922
1923                                                         /* make all stack variables saved */
1924
1925                                                         copy = curstack;
1926                                                         while (copy) {
1927                                                                 copy->flags |= SAVEDVAR;
1928                                                                 copy = copy->prev;
1929                                                         }
1930                                                 }
1931                                                 OP1_1(TYPE_ADR, TYPE_ADR);
1932                                                 break;
1933
1934                                         case ICMD_INSTANCEOF:
1935                                         case ICMD_ARRAYLENGTH:
1936                                                 OP1_1(TYPE_ADR, TYPE_INT);
1937                                                 break;
1938
1939                                         case ICMD_NEWARRAY:
1940                                         case ICMD_ANEWARRAY:
1941                                                 OP1_1(TYPE_INT, TYPE_ADR);
1942                                                 break;
1943
1944                                         case ICMD_GETFIELD:
1945                                                 COUNT(count_check_null);
1946                                                 COUNT(count_pcmd_mem);
1947                                                 OP1_1(TYPE_ADR, iptr->op1);
1948                                                 break;
1949
1950                                                 /* pop 0 push 1 */
1951                                                 
1952                                         case ICMD_GETSTATIC:
1953                                                 COUNT(count_pcmd_mem);
1954                                                 OP0_1(iptr->op1);
1955                                                 break;
1956
1957                                         case ICMD_NEW:
1958                                                 OP0_1(TYPE_ADR);
1959                                                 break;
1960
1961                                         case ICMD_JSR:
1962                                                 OP0_1(TYPE_ADR);
1963                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
1964
1965                                                 iptr[0].target = (void *) tbptr;
1966
1967                                                 /* This is a dirty hack. The typechecker
1968                                                  * needs it because the OP1_0ANY below
1969                                                  * overwrites iptr->dst.
1970                                                  */
1971                                                 iptr->val.a = (void *) iptr->dst;
1972
1973                                                 tbptr->type = BBTYPE_SBR;
1974
1975                                                 /* We need to check for overflow right here because
1976                                                  * the pushed value is poped after MARKREACHED. */
1977                                                 CHECKOVERFLOW;
1978                                                 MARKREACHED(tbptr, copy);
1979                                                 OP1_0ANY;
1980                                                 break;
1981
1982                                         /* pop many push any */
1983
1984                                         case ICMD_BUILTIN:
1985 #if defined(USEBUILTINTABLE)
1986                                         builtin:
1987 #endif
1988                                                 bte = (builtintable_entry *) iptr->val.a;
1989                                                 md = bte->md;
1990                                                 goto _callhandling;
1991
1992                                         case ICMD_INVOKESTATIC:
1993                                         case ICMD_INVOKESPECIAL:
1994                                         case ICMD_INVOKEVIRTUAL:
1995                                         case ICMD_INVOKEINTERFACE:
1996                                                 COUNT(count_pcmd_met);
1997                                                 um = iptr->target;
1998                                                 md = um->methodref->parseddesc.md;
1999 /*                          if (lm->flags & ACC_STATIC) */
2000 /*                              {COUNT(count_check_null);} */    
2001
2002                                         _callhandling:
2003                                                 i = md->paramcount;
2004
2005                                                 if (md->memuse > rd->memuse)
2006                                                         rd->memuse = md->memuse;
2007                                                 if (md->argintreguse > rd->argintreguse)
2008                                                         rd->argintreguse = md->argintreguse;
2009                                                 if (md->argfltreguse > rd->argfltreguse)
2010                                                         rd->argfltreguse = md->argfltreguse;
2011
2012                                                 REQUIRE(i);
2013
2014                                                 copy = curstack;
2015                                                 for (i-- ; i >= 0; i--) {
2016 #if defined(SUPPORT_PASS_FLOATARGS_IN_INTREGS)
2017                                                 /* If we pass float arguments in integer argument registers, we
2018                                                  * are not allowed to precolor them here. Floats have to be moved
2019                                                  * to this regs explicitly in codegen().
2020                                                  * Only arguments that are passed by stack anyway can be precolored
2021                                                  * (michi 2005/07/24) */
2022                                                         if (!(copy->flags & SAVEDVAR) &&
2023                                                            (!IS_FLT_DBL_TYPE(copy->type) || md->params[i].inmemory)) {
2024 #else
2025                                                         if (!(copy->flags & SAVEDVAR)) {
2026 #endif
2027                                                                 copy->varkind = ARGVAR;
2028                                                                 copy->varnum = i;
2029
2030 #if defined(ENABLE_INTRP)
2031                                                                 if (!opt_intrp) {
2032 #endif
2033                                                                         if (md->params[i].inmemory) {
2034                                                                                 copy->flags = INMEMORY;
2035                                                                                 copy->regoff = md->params[i].regoff;
2036                                                                         } else {
2037                                                                                 copy->flags = 0;
2038                                                                                 if (IS_FLT_DBL_TYPE(copy->type))
2039 #if defined(SUPPORT_PASS_FLOATARGS_IN_INTREGS)
2040                                                                                         assert(0); /* XXX is this assert ok? */
2041 #else
2042                                                                                 copy->regoff =
2043                                                                                         rd->argfltregs[md->params[i].regoff];
2044 #endif
2045                                                                                 else {
2046 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
2047                                                                                         if (IS_2_WORD_TYPE(copy->type))
2048                                                                                                 copy->regoff = PACK_REGS(
2049                                                                                                                                                  rd->argintregs[GET_LOW_REG(md->params[i].regoff)],
2050                                                                                                                                                  rd->argintregs[GET_HIGH_REG(md->params[i].regoff)]);
2051                                                                                         else
2052 #endif
2053                                                                                                 copy->regoff =
2054                                                                                                         rd->argintregs[md->params[i].regoff];
2055                                                                                 }
2056                                                                         }
2057 #if defined(ENABLE_INTRP)
2058                                                                 }
2059 #endif
2060                                                         }
2061                                                         copy = copy->prev;
2062                                                 }
2063
2064                                                 while (copy) {
2065                                                         copy->flags |= SAVEDVAR;
2066                                                         copy = copy->prev;
2067                                                 }
2068
2069                                                 i = md->paramcount;
2070                                                 POPMANY(i);
2071                                                 if (md->returntype.type != TYPE_VOID)
2072                                                         OP0_1(md->returntype.type);
2073                                                 break;
2074
2075                                         case ICMD_INLINE_START:
2076                                         case ICMD_INLINE_END:
2077                                                 SETDST;
2078                                                 break;
2079
2080                                         case ICMD_MULTIANEWARRAY:
2081                                                 if (rd->argintreguse < 3)
2082                                                         rd->argintreguse = 3;
2083
2084                                                 i = iptr->op1;
2085
2086                                                 REQUIRE(i);
2087 #if defined(SPECIALMEMUSE)
2088 # if defined(__DARWIN__)
2089                                                 if (rd->memuse < (i + INT_ARG_CNT + LA_WORD_SIZE))
2090                                                         rd->memuse = i + LA_WORD_SIZE + INT_ARG_CNT;
2091 # else
2092                                                 if (rd->memuse < (i + LA_WORD_SIZE + 3))
2093                                                         rd->memuse = i + LA_WORD_SIZE + 3;
2094 # endif
2095 #else
2096 # if defined(__I386__)
2097                                                 if (rd->memuse < i + 3)
2098                                                         rd->memuse = i + 3; /* n integer args spilled on stack */
2099 # elif defined(__MIPS__) && SIZEOF_VOID_P == 4
2100                                                 if (rd->memuse < i + 2)
2101                                                         rd->memuse = i + 2; /* 4*4 bytes callee save space */
2102 # else
2103                                                 if (rd->memuse < i)
2104                                                         rd->memuse = i; /* n integer args spilled on stack */
2105 # endif /* defined(__I386__) */
2106 #endif
2107                                                 copy = curstack;
2108                                                 while (--i >= 0) {
2109                                                         /* check INT type here? Currently typecheck does this. */
2110                                                         if (!(copy->flags & SAVEDVAR)) {
2111                                                                 copy->varkind = ARGVAR;
2112                                                                 copy->varnum = i + INT_ARG_CNT;
2113                                                                 copy->flags |= INMEMORY;
2114 #if defined(SPECIALMEMUSE)
2115 # if defined(__DARWIN__)
2116                                                                 copy->regoff = i + LA_WORD_SIZE + INT_ARG_CNT;
2117 # else
2118                                                                 copy->regoff = i + LA_WORD_SIZE + 3;
2119 # endif
2120 #else
2121 # if defined(__I386__)
2122                                                                 copy->regoff = i + 3;
2123 # elif defined(__MIPS__) && SIZEOF_VOID_P == 4
2124                                                                 copy->regoff = i + 2;
2125 # else
2126                                                                 copy->regoff = i;
2127 # endif /* defined(__I386__) */
2128 #endif /* defined(SPECIALMEMUSE) */
2129                                                         }
2130                                                         copy = copy->prev;
2131                                                 }
2132                                                 while (copy) {
2133                                                         copy->flags |= SAVEDVAR;
2134                                                         copy = copy->prev;
2135                                                 }
2136                                                 i = iptr->op1;
2137                                                 POPMANY(i);
2138                                                 OP0_1(TYPE_ADR);
2139                                                 break;
2140
2141                                         case ICMD_CLEAR_ARGREN:
2142                                                 for (i = iptr->op1; i < cd->maxlocals; i++)
2143                                                         argren[i] = i;
2144                                                 iptr->opc = opcode = ICMD_NOP;
2145                                                 SETDST;
2146                                                 break;
2147                                                 
2148                                         case ICMD_READONLY_ARG:
2149                                         case ICMD_READONLY_ARG+1:
2150                                         case ICMD_READONLY_ARG+2:
2151                                         case ICMD_READONLY_ARG+3:
2152                                         case ICMD_READONLY_ARG+4:
2153
2154                                                 REQUIRE_1;
2155                                                 if (curstack->varkind == LOCALVAR) {
2156                                                         i = curstack->varnum;
2157                                                         argren[iptr->op1] = i;
2158                                                         iptr->op1 = i;
2159                                                 }
2160                                                 opcode = iptr->opc = opcode - ICMD_READONLY_ARG + ICMD_ISTORE;
2161                                                 goto icmd_store;
2162
2163                                                 break;
2164
2165                                         default:
2166                                                 *exceptionptr =
2167                                                         new_internalerror("Unknown ICMD %d", opcode);
2168                                                 return NULL;
2169                                         } /* switch */
2170
2171                                         CHECKOVERFLOW;
2172                                         iptr++;
2173                                 } /* while instructions */
2174
2175                                 bptr->outstack = curstack;
2176                                 bptr->outdepth = stackdepth;
2177                                 BBEND(curstack, i);
2178                         } /* if */
2179                         else
2180                                 superblockend = true;
2181                         bptr++;
2182                 } /* while blocks */
2183         } while (repeat && !deadcode);
2184
2185 #if defined(STATISTICS)
2186         if (opt_stat) {
2187                 if (m->basicblockcount > count_max_basic_blocks)
2188                         count_max_basic_blocks = m->basicblockcount;
2189                 count_basic_blocks += m->basicblockcount;
2190                 if (m->instructioncount > count_max_javainstr)                  count_max_javainstr = m->instructioncount;
2191                 count_javainstr += m->instructioncount;
2192                 if (m->stackcount > count_upper_bound_new_stack)
2193                         count_upper_bound_new_stack = m->stackcount;
2194                 if ((new - m->stack) > count_max_new_stack)
2195                         count_max_new_stack = (new - m->stack);
2196
2197                 b_count = m->basicblockcount;
2198                 bptr = m->basicblocks;
2199                 while (--b_count >= 0) {
2200                         if (bptr->flags > BBREACHED) {
2201                                 if (bptr->indepth >= 10)
2202                                         count_block_stack[10]++;
2203                                 else
2204                                         count_block_stack[bptr->indepth]++;
2205                                 len = bptr->icount;
2206                                 if (len < 10) 
2207                                         count_block_size_distribution[len]++;
2208                                 else if (len <= 12)
2209                                         count_block_size_distribution[10]++;
2210                                 else if (len <= 14)
2211                                         count_block_size_distribution[11]++;
2212                                 else if (len <= 16)
2213                                         count_block_size_distribution[12]++;
2214                                 else if (len <= 18)
2215                                         count_block_size_distribution[13]++;
2216                                 else if (len <= 20)
2217                                         count_block_size_distribution[14]++;
2218                                 else if (len <= 25)
2219                                         count_block_size_distribution[15]++;
2220                                 else if (len <= 30)
2221                                         count_block_size_distribution[16]++;
2222                                 else
2223                                         count_block_size_distribution[17]++;
2224                         }
2225                         bptr++;
2226                 }
2227
2228                 if (loops == 1)
2229                         count_analyse_iterations[0]++;
2230                 else if (loops == 2)
2231                         count_analyse_iterations[1]++;
2232                 else if (loops == 3)
2233                         count_analyse_iterations[2]++;
2234                 else if (loops == 4)
2235                         count_analyse_iterations[3]++;
2236                 else
2237                         count_analyse_iterations[4]++;
2238
2239                 if (m->basicblockcount <= 5)
2240                         count_method_bb_distribution[0]++;
2241                 else if (m->basicblockcount <= 10)
2242                         count_method_bb_distribution[1]++;
2243                 else if (m->basicblockcount <= 15)
2244                         count_method_bb_distribution[2]++;
2245                 else if (m->basicblockcount <= 20)
2246                         count_method_bb_distribution[3]++;
2247                 else if (m->basicblockcount <= 30)
2248                         count_method_bb_distribution[4]++;
2249                 else if (m->basicblockcount <= 40)
2250                         count_method_bb_distribution[5]++;
2251                 else if (m->basicblockcount <= 50)
2252                         count_method_bb_distribution[6]++;
2253                 else if (m->basicblockcount <= 75)
2254                         count_method_bb_distribution[7]++;
2255                 else
2256                         count_method_bb_distribution[8]++;
2257         }
2258 #endif
2259
2260         /* just return methodinfo* to signal everything was ok */
2261
2262         return m;
2263 }
2264
2265
2266 /**********************************************************************/
2267 /* DEBUGGING HELPERS                                                  */
2268 /**********************************************************************/
2269
2270 void icmd_print_stack(codegendata *cd, stackptr s)
2271 {
2272         int i, j;
2273         stackptr t;
2274
2275         i = cd->maxstack;
2276         t = s;
2277         
2278         while (t) {
2279                 i--;
2280                 t = t->prev;
2281         }
2282         j = cd->maxstack - i;
2283         while (--i >= 0)
2284                 printf("    ");
2285
2286         while (s) {
2287                 j--;
2288                 if (s->flags & SAVEDVAR)
2289                         switch (s->varkind) {
2290                         case TEMPVAR:
2291                                 if (s->flags & INMEMORY)
2292                                         printf(" M%02d", s->regoff);
2293 #ifdef HAS_ADDRESS_REGISTER_FILE
2294                                 else if (s->type == TYPE_ADR)
2295                                         printf(" R%02d", s->regoff);
2296 #endif
2297                                 else if (IS_FLT_DBL_TYPE(s->type))
2298                                         printf(" F%02d", s->regoff);
2299                                 else {
2300 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
2301                                         if (IS_2_WORD_TYPE(s->type))
2302                                                 printf(" %3s/%3s", regs[GET_LOW_REG(s->regoff)],
2303                             regs[GET_HIGH_REG(s->regoff)]);
2304                                         else
2305 #endif
2306 #if defined(ENABLE_INTRP)
2307                                                 printf(" %3d", s->regoff);
2308 #else
2309                                                 printf(" %3s", regs[s->regoff]);
2310 #endif
2311                                 }
2312                                 break;
2313                         case STACKVAR:
2314                                 printf(" I%02d", s->varnum);
2315                                 break;
2316                         case LOCALVAR:
2317                                 printf(" L%02d", s->varnum);
2318                                 break;
2319                         case ARGVAR:
2320                                 if (s->varnum == -1) {
2321                                         /* Return Value                                  */
2322                                         /* varkind ARGVAR "misused for this special case */
2323                                         printf("  V0");
2324                                 } else /* "normal" Argvar */
2325                                         printf(" A%02d", s->varnum);
2326 #ifdef INVOKE_NEW_DEBUG
2327                                 if (s->flags & INMEMORY)
2328                                         printf("(M%i)", s->regoff);
2329                                 else
2330                                         printf("(R%i)", s->regoff);
2331 #endif
2332                                 break;
2333                         default:
2334                                 printf(" !%02d", j);
2335                         }
2336                 else
2337                         switch (s->varkind) {
2338                         case TEMPVAR:
2339                                 if (s->flags & INMEMORY)
2340                                         printf(" m%02d", s->regoff);
2341 #ifdef HAS_ADDRESS_REGISTER_FILE
2342                                 else if (s->type == TYPE_ADR)
2343                                         printf(" r%02d", s->regoff);
2344 #endif
2345                                 else if (IS_FLT_DBL_TYPE(s->type))
2346                                         printf(" f%02d", s->regoff);
2347                                 else {
2348 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
2349                                         if (IS_2_WORD_TYPE(s->type))
2350                                                 printf(" %3s/%3s", regs[GET_LOW_REG(s->regoff)],
2351                             regs[GET_HIGH_REG(s->regoff)]);
2352                                         else
2353 #endif
2354 #if defined(ENABLE_INTRP)
2355                                                 printf(" %3d", s->regoff);
2356 #else
2357                                                 printf(" %3s", regs[s->regoff]);
2358 #endif
2359                                 }
2360                                 break;
2361                         case STACKVAR:
2362                                 printf(" i%02d", s->varnum);
2363                                 break;
2364                         case LOCALVAR:
2365                                 printf(" l%02d", s->varnum);
2366                                 break;
2367                         case ARGVAR:
2368                                 if (s->varnum == -1) {
2369                                         /* Return Value                                  */
2370                                         /* varkind ARGVAR "misused for this special case */
2371                                         printf("  v0");
2372                                 } else /* "normal" Argvar */
2373                                 printf(" a%02d", s->varnum);
2374 #ifdef INVOKE_NEW_DEBUG
2375                                 if (s->flags & INMEMORY)
2376                                         printf("(M%i)", s->regoff);
2377                                 else
2378                                         printf("(R%i)", s->regoff);
2379 #endif
2380                                 break;
2381                         default:
2382                                 printf(" ?%02d", j);
2383                         }
2384                 s = s->prev;
2385         }
2386 }
2387
2388
2389 #if 0
2390 static void print_reg(stackptr s) {
2391         if (s) {
2392                 if (s->flags & SAVEDVAR)
2393                         switch (s->varkind) {
2394                         case TEMPVAR:
2395                                 if (s->flags & INMEMORY)
2396                                         printf(" tm%02d", s->regoff);
2397                                 else
2398                                         printf(" tr%02d", s->regoff);
2399                                 break;
2400                         case STACKVAR:
2401                                 printf(" s %02d", s->varnum);
2402                                 break;
2403                         case LOCALVAR:
2404                                 printf(" l %02d", s->varnum);
2405                                 break;
2406                         case ARGVAR:
2407                                 printf(" a %02d", s->varnum);
2408                                 break;
2409                         default:
2410                                 printf(" ! %02d", s->varnum);
2411                         }
2412                 else
2413                         switch (s->varkind) {
2414                         case TEMPVAR:
2415                                 if (s->flags & INMEMORY)
2416                                         printf(" Tm%02d", s->regoff);
2417                                 else
2418                                         printf(" Tr%02d", s->regoff);
2419                                 break;
2420                         case STACKVAR:
2421                                 printf(" S %02d", s->varnum);
2422                                 break;
2423                         case LOCALVAR:
2424                                 printf(" L %02d", s->varnum);
2425                                 break;
2426                         case ARGVAR:
2427                                 printf(" A %02d", s->varnum);
2428                                 break;
2429                         default:
2430                                 printf(" ? %02d", s->varnum);
2431                         }
2432         }
2433         else
2434                 printf("     ");
2435                 
2436 }
2437 #endif
2438
2439
2440 static char *jit_type[] = {
2441         "int",
2442         "lng",
2443         "flt",
2444         "dbl",
2445         "adr"
2446 };
2447
2448
2449 /* show_icmd_method ************************************************************
2450
2451    XXX
2452
2453 *******************************************************************************/
2454
2455 void show_icmd_method(methodinfo *m, codegendata *cd, registerdata *rd)
2456 {
2457         basicblock     *bptr;
2458         exceptiontable *ex;
2459         s4              i, j;
2460         u1             *u1ptr;
2461
2462 #if defined(USE_THREADS)
2463         /* We need to enter a lock here, since the binutils disassembler
2464            is not reentrant-able and we could not read functions printed
2465            at the same time. */
2466
2467         builtin_monitorenter(lock_show_icmd);
2468 #endif
2469
2470         printf("\n");
2471         utf_fprint_classname(stdout, m->class->name);
2472         printf(".");
2473         utf_fprint(stdout, m->name);
2474         utf_fprint(stdout, m->descriptor);
2475         printf("\n\nMax locals: %d\n", (int) cd->maxlocals);
2476         printf("Max stack:  %d\n", (int) cd->maxstack);
2477         printf("Line number table length: %d\n", m->linenumbercount);
2478
2479         printf("Exceptions (Number: %d):\n", cd->exceptiontablelength);
2480         for (ex = cd->exceptiontable; ex != NULL; ex = ex->down) {
2481                 printf("    L%03d ... ", ex->start->debug_nr );
2482                 printf("L%03d  = ", ex->end->debug_nr);
2483                 printf("L%03d", ex->handler->debug_nr);
2484                 printf("  (catchtype: ");
2485                 if (ex->catchtype.any)
2486                         if (IS_CLASSREF(ex->catchtype))
2487                                 utf_display_classname(ex->catchtype.ref->name);
2488                         else
2489                                 utf_display_classname(ex->catchtype.cls->name);
2490                 else
2491                         printf("ANY");
2492                 printf(")\n");
2493         }
2494         
2495         printf("Local Table:\n");
2496         for (i = 0; i < cd->maxlocals; i++) {
2497                 printf("   %3d: ", i);
2498                 for (j = TYPE_INT; j <= TYPE_ADR; j++) {
2499 #if defined(ENABLE_INTRP)
2500                         if (!opt_intrp) {
2501 #endif
2502                                 if (rd->locals[i][j].type >= 0) {
2503                                         printf("   (%s) ", jit_type[j]);
2504                                         if (rd->locals[i][j].flags & INMEMORY)
2505                                                 printf("m%2d", rd->locals[i][j].regoff);
2506 #ifdef HAS_ADDRESS_REGISTER_FILE
2507                                         else if (j == TYPE_ADR)
2508                                                 printf("r%02d", rd->locals[i][j].regoff);
2509 #endif
2510                                         else if ((j == TYPE_FLT) || (j == TYPE_DBL))
2511                                                 printf("f%02d", rd->locals[i][j].regoff);
2512                                         else {
2513 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
2514                                                 if (IS_2_WORD_TYPE(j))
2515                                                         printf(" %3s/%3s",
2516                                                                    regs[GET_LOW_REG(rd->locals[i][j].regoff)],
2517                                                                    regs[GET_HIGH_REG(rd->locals[i][j].regoff)]);
2518                                                 else
2519 #endif
2520                                                         printf("%3s", regs[rd->locals[i][j].regoff]);
2521                                         }
2522                                 }
2523 #if defined(ENABLE_INTRP)
2524                         }
2525 #endif
2526                 }
2527                 printf("\n");
2528         }
2529         printf("\n");
2530
2531 #if defined(ENABLE_LSRA)
2532         if (!opt_lsra) {
2533 #endif
2534 #if defined(ENABLE_INTRP)
2535                 if (!opt_intrp) {
2536 #endif
2537         printf("Interface Table:\n");
2538         for (i = 0; i < cd->maxstack; i++) {
2539                 if ((rd->interfaces[i][0].type >= 0) ||
2540                         (rd->interfaces[i][1].type >= 0) ||
2541                     (rd->interfaces[i][2].type >= 0) ||
2542                         (rd->interfaces[i][3].type >= 0) ||
2543                     (rd->interfaces[i][4].type >= 0)) {
2544                         printf("   %3d: ", i);
2545                         for (j = TYPE_INT; j <= TYPE_ADR; j++)
2546                                 if (rd->interfaces[i][j].type >= 0) {
2547                                         printf("   (%s) ", jit_type[j]);
2548                                         if (rd->interfaces[i][j].flags & SAVEDVAR) {
2549                                                 if (rd->interfaces[i][j].flags & INMEMORY)
2550                                                         printf("M%2d", rd->interfaces[i][j].regoff);
2551 #ifdef HAS_ADDRESS_REGISTER_FILE
2552                                                 else if (j == TYPE_ADR)
2553                                                         printf("R%02d", rd->interfaces[i][j].regoff);
2554 #endif
2555                                                 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
2556                                                         printf("F%02d", rd->interfaces[i][j].regoff);
2557                                                 else {
2558 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
2559                                                         if (IS_2_WORD_TYPE(j))
2560                                                                 printf(" %3s/%3s",
2561                              regs[GET_LOW_REG(rd->interfaces[i][j].regoff)],
2562                              regs[GET_HIGH_REG(rd->interfaces[i][j].regoff)]);
2563                                                         else
2564 #endif
2565                                                                 printf("%3s",regs[rd->interfaces[i][j].regoff]);
2566                                                 }
2567                                         }
2568                                         else {
2569                                                 if (rd->interfaces[i][j].flags & INMEMORY)
2570                                                         printf("m%2d", rd->interfaces[i][j].regoff);
2571 #ifdef HAS_ADDRESS_REGISTER_FILE
2572                                                 else if (j == TYPE_ADR)
2573                                                         printf("r%02d", rd->interfaces[i][j].regoff);
2574 #endif
2575                                                 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
2576                                                         printf("f%02d", rd->interfaces[i][j].regoff);
2577                                                 else {
2578 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
2579                                                         if (IS_2_WORD_TYPE(j))
2580                                                                 printf(" %3s/%3s",
2581                              regs[GET_LOW_REG(rd->interfaces[i][j].regoff)],
2582                                                          regs[GET_HIGH_REG(rd->interfaces[i][j].regoff)]);
2583                                                         else
2584 #endif
2585                                                                 printf("%3s",regs[rd->interfaces[i][j].regoff]);
2586                                                 }
2587                                         }
2588                                 }
2589                         printf("\n");
2590                 }
2591         }
2592         printf("\n");
2593
2594 #if defined(ENABLE_INTRP)
2595                 }
2596 #endif
2597 #if defined(ENABLE_LSRA)
2598         }
2599 #endif
2600
2601         /* show code before first basic block */
2602
2603         if (opt_showdisassemble) {
2604                 u1ptr = (u1 *) ((ptrint) m->mcode + cd->dseglen);
2605
2606                 for (; u1ptr < (u1 *) ((ptrint) m->mcode + cd->dseglen + m->basicblocks[0].mpc);)
2607                         u1ptr = disassinstr(u1ptr);
2608
2609                 printf("\n");
2610         }
2611
2612         /* show code of all basic blocks */
2613
2614         for (bptr = m->basicblocks; bptr != NULL; bptr = bptr->next) {
2615                 show_icmd_block(m, cd, bptr);
2616         }
2617
2618         /* show stubs code */
2619
2620         if (opt_showdisassemble && opt_showexceptionstubs) {
2621                 printf("\nException stubs code:\n");
2622                 printf("Length: %d\n\n", (s4) (m->mcodelength -
2623                                                                            ((ptrint) cd->dseglen +
2624                                                                                 m->basicblocks[m->basicblockcount].mpc)));
2625
2626                 u1ptr = (u1 *) ((ptrint) m->mcode + cd->dseglen +
2627                                                 m->basicblocks[m->basicblockcount].mpc);
2628
2629                 for (; (ptrint) u1ptr < ((ptrint) m->mcode + m->mcodelength);)
2630                         u1ptr = disassinstr(u1ptr);
2631
2632                 printf("\n");
2633         }
2634
2635 #if defined(USE_THREADS)
2636         builtin_monitorexit(lock_show_icmd);
2637 #endif
2638 }
2639
2640
2641 void show_icmd_block(methodinfo *m, codegendata *cd, basicblock *bptr)
2642 {
2643         s4           i, j;
2644         bool         deadcode;
2645         instruction *iptr;
2646         u1          *u1ptr;
2647
2648         if (bptr->flags != BBDELETED) {
2649                 deadcode = bptr->flags <= BBREACHED;
2650                 printf("[");
2651                 if (deadcode)
2652                         for (j = cd->maxstack; j > 0; j--)
2653                                 printf(" ?  ");
2654                 else
2655                         icmd_print_stack(cd, bptr->instack);
2656                 printf("] L%03d(%d - %d) flags=%d:\n", bptr->debug_nr, bptr->icount, bptr->pre_count,bptr->flags);
2657                 iptr = bptr->iinstr;
2658
2659                 for (i = 0; i < bptr->icount; i++, iptr++) {
2660                         printf("[");
2661                         if (deadcode) {
2662                                 for (j = cd->maxstack; j > 0; j--)
2663                                         printf(" ?  ");
2664                         }
2665                         else
2666                                 icmd_print_stack(cd, iptr->dst);
2667                         printf("] %5d (line: %5d)  ", i, iptr->line);
2668
2669                         show_icmd(iptr, deadcode);
2670                         printf("\n");
2671                 }
2672
2673                 if (opt_showdisassemble && (!deadcode)) {
2674                         printf("\n");
2675                         u1ptr = (u1 *) ((ptrint) m->mcode + cd->dseglen + bptr->mpc);
2676
2677                         if (bptr->next != NULL) {
2678                                 for (; u1ptr < (u1 *) ((ptrint) m->mcode + cd->dseglen + bptr->next->mpc);)
2679                                         u1ptr = disassinstr(u1ptr);
2680
2681                         } else {
2682                                 for (; u1ptr < (u1 *) ((ptrint) m->mcode + m->mcodelength);)
2683                                         u1ptr = disassinstr(u1ptr); 
2684                         }
2685                         printf("\n");
2686                 }
2687         }
2688 }
2689
2690
2691 void show_icmd(instruction *iptr, bool deadcode)
2692 {
2693         int j;
2694         s4  *s4ptr;
2695         void **tptr = NULL;
2696         
2697         printf("%s", icmd_names[iptr->opc]);
2698
2699         switch (iptr->opc) {
2700         case ICMD_IADDCONST:
2701         case ICMD_ISUBCONST:
2702         case ICMD_IMULCONST:
2703         case ICMD_IMULPOW2:
2704         case ICMD_IDIVPOW2:
2705         case ICMD_IREMPOW2:
2706         case ICMD_IANDCONST:
2707         case ICMD_IORCONST:
2708         case ICMD_IXORCONST:
2709         case ICMD_ISHLCONST:
2710         case ICMD_ISHRCONST:
2711         case ICMD_IUSHRCONST:
2712         case ICMD_LSHLCONST:
2713         case ICMD_LSHRCONST:
2714         case ICMD_LUSHRCONST:
2715         case ICMD_ICONST:
2716         case ICMD_ELSE_ICONST:
2717         case ICMD_IASTORECONST:
2718         case ICMD_BASTORECONST:
2719         case ICMD_CASTORECONST:
2720         case ICMD_SASTORECONST:
2721                 printf(" %d (0x%08x)", iptr->val.i, iptr->val.i);
2722                 break;
2723
2724         case ICMD_IFEQ_ICONST:
2725         case ICMD_IFNE_ICONST:
2726         case ICMD_IFLT_ICONST:
2727         case ICMD_IFGE_ICONST:
2728         case ICMD_IFGT_ICONST:
2729         case ICMD_IFLE_ICONST:
2730                 printf("(%d) %d", iptr[1].op1, iptr->val.i);
2731                 break;
2732
2733         case ICMD_LADDCONST:
2734         case ICMD_LSUBCONST:
2735         case ICMD_LMULCONST:
2736         case ICMD_LMULPOW2:
2737         case ICMD_LDIVPOW2:
2738         case ICMD_LREMPOW2:
2739         case ICMD_LANDCONST:
2740         case ICMD_LORCONST:
2741         case ICMD_LXORCONST:
2742         case ICMD_LCONST:
2743         case ICMD_LASTORECONST:
2744 #if SIZEOF_VOID_P == 4
2745                 printf(" %lld (0x%016llx)", iptr->val.l, iptr->val.l);
2746 #else
2747                 printf(" %ld (0x%016lx)", iptr->val.l, iptr->val.l);
2748 #endif
2749                 break;
2750
2751         case ICMD_FCONST:
2752                 printf(" %f (0x%08x)", iptr->val.f, iptr->val.i);
2753                 break;
2754
2755         case ICMD_DCONST:
2756 #if SIZEOF_VOID_P == 4
2757                 printf(" %g (0x%016llx)", iptr->val.d, iptr->val.l);
2758 #else
2759                 printf(" %g (0x%016lx)", iptr->val.d, iptr->val.l);
2760 #endif
2761                 break;
2762
2763         case ICMD_ACONST:
2764         case ICMD_AASTORECONST:
2765                 /* check if this is a constant string or a class reference */
2766
2767                 if (iptr->target) {
2768                         if (iptr->val.a)
2769                                 printf(" %p", iptr->val.a);
2770                         else
2771                                 printf(" (NOT RESOLVED)");
2772
2773                         printf(", Class = \"");
2774                         utf_display(((constant_classref *) iptr->target)->name);
2775                         printf("\"");
2776
2777                 } else {
2778                         printf(" %p", iptr->val.a);
2779                         if (iptr->val.a) {
2780                                 printf(", String = \"");
2781                                 utf_display(javastring_toutf(iptr->val.a, false));
2782                                 printf("\"");
2783                         }
2784                 }
2785                 break;
2786
2787         case ICMD_GETFIELD:
2788         case ICMD_PUTFIELD:
2789                 if (iptr->val.a)         
2790                         printf(" %d, ", ((fieldinfo *) iptr->val.a)->offset);
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_PUTSTATIC:
2802         case ICMD_GETSTATIC:
2803                 if (iptr->val.a) {
2804                         if (!(((fieldinfo *) iptr->val.a)->class->state & CLASS_INITIALIZED))
2805                                 printf(" (NOT INITIALIZED) ");
2806                         else
2807                                 printf(" ");
2808                 } else
2809                         printf(" (NOT RESOLVED) ");
2810                 utf_display_classname(((unresolved_field *) iptr->target)->fieldref->classref->name);
2811                 printf(".");
2812                 utf_display(((unresolved_field *) iptr->target)->fieldref->name);
2813                 printf(" (type ");
2814                 utf_display(((unresolved_field *) iptr->target)->fieldref->descriptor);
2815                 printf(")");
2816                 break;
2817
2818         case ICMD_PUTSTATICCONST:
2819         case ICMD_PUTFIELDCONST:
2820                 switch (iptr[1].op1) {
2821                 case TYPE_INT:
2822                         printf(" %d (0x%08x),", iptr->val.i, iptr->val.i);
2823                         break;
2824                 case TYPE_LNG:
2825 #if SIZEOF_VOID_P == 4
2826                         printf(" %lld (0x%016llx),", iptr->val.l, iptr->val.l);
2827 #else
2828                         printf(" %ld (0x%016lx),", iptr->val.l, iptr->val.l);
2829 #endif
2830                         break;
2831                 case TYPE_ADR:
2832                         printf(" %p,", iptr->val.a);
2833                         break;
2834                 case TYPE_FLT:
2835                         printf(" %g (0x%08x),", iptr->val.f, iptr->val.i);
2836                         break;
2837                 case TYPE_DBL:
2838 #if SIZEOF_VOID_P == 4
2839                         printf(" %g (0x%016llx),", iptr->val.d, iptr->val.l);
2840 #else
2841                         printf(" %g (0x%016lx),", iptr->val.d, iptr->val.l);
2842 #endif
2843                         break;
2844                 }
2845                 if (iptr->opc == ICMD_PUTFIELDCONST) {
2846                         if (iptr[1].val.a)
2847                                 printf(" %d,", ((fieldinfo *) iptr[1].val.a)->offset);
2848                         else
2849                                 printf(" (NOT RESOLVED),");
2850                 }
2851                 printf(" ");     
2852                 utf_display_classname(((unresolved_field *) iptr[1].target)->fieldref->classref->name);          
2853                 printf(".");     
2854                 utf_display(((unresolved_field *) iptr[1].target)->fieldref->name);      
2855                 printf(" (type ");       
2856                 utf_display(((unresolved_field *) iptr[1].target)->fieldref->descriptor);        
2857                 printf(")");     
2858                 break;
2859
2860         case ICMD_IINC:
2861                 printf(" %d + %d", iptr->op1, iptr->val.i);
2862                 break;
2863
2864         case ICMD_IASTORE:
2865         case ICMD_SASTORE:
2866         case ICMD_BASTORE:
2867         case ICMD_CASTORE:
2868         case ICMD_LASTORE:
2869         case ICMD_DASTORE:
2870         case ICMD_FASTORE:
2871         case ICMD_AASTORE:
2872
2873         case ICMD_IALOAD:
2874         case ICMD_SALOAD:
2875         case ICMD_BALOAD:
2876         case ICMD_CALOAD:
2877         case ICMD_LALOAD:
2878         case ICMD_DALOAD:
2879         case ICMD_FALOAD:
2880         case ICMD_AALOAD:
2881                 if (iptr->op1 != 0)
2882                         printf("(opt.)");
2883                 break;
2884
2885         case ICMD_RET:
2886         case ICMD_ILOAD:
2887         case ICMD_LLOAD:
2888         case ICMD_FLOAD:
2889         case ICMD_DLOAD:
2890         case ICMD_ALOAD:
2891         case ICMD_ISTORE:
2892         case ICMD_LSTORE:
2893         case ICMD_FSTORE:
2894         case ICMD_DSTORE:
2895         case ICMD_ASTORE:
2896                 printf(" %d", iptr->op1);
2897                 break;
2898
2899         case ICMD_NEW:
2900                 printf(" ");
2901                 utf_display_classname(((classinfo *) iptr->val.a)->name);
2902                 break;
2903
2904         case ICMD_NEWARRAY:
2905                 switch (iptr->op1) {
2906                 case 4:
2907                         printf(" boolean");
2908                         break;
2909                 case 5:
2910                         printf(" char");
2911                         break;
2912                 case 6:
2913                         printf(" float");
2914                         break;
2915                 case 7:
2916                         printf(" double");
2917                         break;
2918                 case 8:
2919                         printf(" byte");
2920                         break;
2921                 case 9:
2922                         printf(" short");
2923                         break;
2924                 case 10:
2925                         printf(" int");
2926                         break;
2927                 case 11:
2928                         printf(" long");
2929                         break;
2930                 }
2931                 break;
2932
2933         case ICMD_ANEWARRAY:
2934                 if (iptr->op1) {
2935                         printf(" ");
2936                         utf_display_classname(((classinfo *) iptr->val.a)->name);
2937                 }
2938                 break;
2939
2940         case ICMD_MULTIANEWARRAY:
2941                 if (iptr->target) {
2942                         printf(" (NOT RESOLVED) %d ",iptr->op1);
2943                         utf_display(((constant_classref *) iptr->val.a)->name);
2944                 } else {
2945                         printf(" %d ",iptr->op1);
2946                         utf_display_classname(((vftbl_t *) iptr->val.a)->class->name);
2947                 }
2948                 break;
2949
2950         case ICMD_CHECKCAST:
2951         case ICMD_INSTANCEOF:
2952                 {
2953                         classinfo *c = iptr->val.a;
2954                         if (c) {
2955                                 if (c->flags & ACC_INTERFACE)
2956                                         printf(" (INTERFACE) ");
2957                                 else
2958                                         printf(" (CLASS,%3d) ", c->vftbl->diffval);
2959                         } else {
2960                                 printf(" (NOT RESOLVED) ");
2961                         }
2962                         utf_display_classname(((constant_classref *) iptr->target)->name);
2963                 }
2964                 break;
2965
2966         case ICMD_INLINE_START:
2967                 printf(" ");
2968                 utf_display_classname(iptr->method->class->name);
2969                 printf(".");
2970                 utf_display_classname(iptr->method->name);
2971                 utf_display_classname(iptr->method->descriptor);
2972                 printf(", depth=%i", iptr->op1);
2973                 break;
2974
2975         case ICMD_INLINE_END:
2976                 break;
2977
2978         case ICMD_BUILTIN:
2979                 printf(" %s", ((builtintable_entry *) iptr->val.a)->name);
2980                 break;
2981
2982         case ICMD_INVOKEVIRTUAL:
2983         case ICMD_INVOKESPECIAL:
2984         case ICMD_INVOKESTATIC:
2985         case ICMD_INVOKEINTERFACE:
2986                 if (!iptr->val.a)
2987                         printf(" (NOT RESOLVED) ");
2988                 else
2989                         printf(" ");
2990                 utf_display_classname(((unresolved_method *) iptr->target)->methodref->classref->name);
2991                 printf(".");
2992                 utf_display(((unresolved_method *) iptr->target)->methodref->name);
2993                 utf_display(((unresolved_method *) iptr->target)->methodref->descriptor);
2994                 break;
2995
2996         case ICMD_IFEQ:
2997         case ICMD_IFNE:
2998         case ICMD_IFLT:
2999         case ICMD_IFGE:
3000         case ICMD_IFGT:
3001         case ICMD_IFLE:
3002                 if (deadcode || !iptr->target)
3003                         printf(" %d (0x%08x) op1=%d", iptr->val.i, iptr->val.i, iptr->op1);
3004                 else
3005                         printf(" %d (0x%08x) L%03d", iptr->val.i, iptr->val.i, ((basicblock *) iptr->target)->debug_nr);
3006                 break;
3007
3008         case ICMD_IF_LEQ:
3009         case ICMD_IF_LNE:
3010         case ICMD_IF_LLT:
3011         case ICMD_IF_LGE:
3012         case ICMD_IF_LGT:
3013         case ICMD_IF_LLE:
3014                 if (deadcode || !iptr->target)
3015 #if SIZEOF_VOID_P == 4
3016                         printf("(%lld) op1=%d", iptr->val.l, iptr->op1);
3017 #else
3018                         printf("(%ld) op1=%d", iptr->val.l, iptr->op1);
3019 #endif
3020                 else
3021 #if SIZEOF_VOID_P == 4
3022                         printf("(%lld) L%03d", iptr->val.l, ((basicblock *) iptr->target)->debug_nr);
3023 #else
3024                         printf("(%ld) L%03d", iptr->val.l, ((basicblock *) iptr->target)->debug_nr);
3025 #endif
3026                 break;
3027
3028         case ICMD_JSR:
3029         case ICMD_GOTO:
3030         case ICMD_IFNULL:
3031         case ICMD_IFNONNULL:
3032         case ICMD_IF_ICMPEQ:
3033         case ICMD_IF_ICMPNE:
3034         case ICMD_IF_ICMPLT:
3035         case ICMD_IF_ICMPGE:
3036         case ICMD_IF_ICMPGT:
3037         case ICMD_IF_ICMPLE:
3038         case ICMD_IF_LCMPEQ:
3039         case ICMD_IF_LCMPNE:
3040         case ICMD_IF_LCMPLT:
3041         case ICMD_IF_LCMPGE:
3042         case ICMD_IF_LCMPGT:
3043         case ICMD_IF_LCMPLE:
3044         case ICMD_IF_ACMPEQ:
3045         case ICMD_IF_ACMPNE:
3046                 if (deadcode || !iptr->target)
3047                         printf(" op1=%d", iptr->op1);
3048                 else
3049                         printf(" L%03d", ((basicblock *) iptr->target)->debug_nr);
3050                 break;
3051
3052         case ICMD_TABLESWITCH:
3053                 s4ptr = (s4*)iptr->val.a;
3054
3055                 if (deadcode || !iptr->target) {
3056                         printf(" %d;", *s4ptr);
3057                 }
3058                 else {
3059                         tptr = (void **) iptr->target;
3060                         printf(" L%03d;", ((basicblock *) *tptr)->debug_nr); 
3061                         tptr++;
3062                 }
3063
3064                 s4ptr++;         /* skip default */
3065                 j = *s4ptr++;                               /* low     */
3066                 j = *s4ptr++ - j;                           /* high    */
3067                 while (j >= 0) {
3068                         if (deadcode || !*tptr)
3069                                 printf(" %d", *s4ptr++);
3070                         else {
3071                                 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
3072                                 tptr++;
3073                         }
3074                         j--;
3075                 }
3076                 break;
3077
3078         case ICMD_LOOKUPSWITCH:
3079                 s4ptr = (s4*)iptr->val.a;
3080
3081                 if (deadcode || !iptr->target) {
3082                         printf(" %d;", *s4ptr);
3083                 }
3084                 else {
3085                         tptr = (void **) iptr->target;
3086                         printf(" L%03d;", ((basicblock *) *tptr)->debug_nr);
3087                         tptr++;
3088                 }
3089                 s4ptr++;                                         /* default */
3090                 j = *s4ptr++;                                    /* count   */
3091
3092                 while (--j >= 0) {
3093                         if (deadcode || !*tptr) {
3094                                 s4ptr++; /* skip value */
3095                                 printf(" %d",*s4ptr++);
3096                         }
3097                         else {
3098                                 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
3099                                 tptr++;
3100                         }
3101                 }
3102                 break;
3103
3104         case ICMD_ARETURN:
3105                 if (iptr->val.a) {
3106                         printf(" (NOT RESOLVED), Class = \"");
3107                         utf_display(((unresolved_class *) iptr->val.a)->classref->name);
3108                         printf("\"");
3109                 }
3110         }
3111 }
3112
3113
3114 /*
3115  * These are local overrides for various environment variables in Emacs.
3116  * Please do not remove this and leave it at the end of the file, where
3117  * Emacs will automagically detect them.
3118  * ---------------------------------------------------------------------
3119  * Local variables:
3120  * mode: c
3121  * indent-tabs-mode: t
3122  * c-basic-offset: 4
3123  * tab-width: 4
3124  * End:
3125  */