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