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