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