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