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