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