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