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