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