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