Unified variables changes for common/i386.
[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 5404 2006-09-07 13:29:05Z christian $
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 #if defined(NEW_VAR)
147 #define GET_NEW_INDEX(new_varindex)                                                                      \
148         do {                                                                                                                     \
149                 assert(jd->vartop < jd->varcount);                                                       \
150                 (new_varindex) = (jd->vartop)++;                                                         \
151         } while (0)
152
153 /* not implemented now, can be used to reuse varindices          */
154 /* pay attention to not release a localvar once implementing it! */
155 #define RELEASE_INDEX(varindex)
156
157 /* with the new vars setting an OUTVAR is not as trivial as changing */
158 /* the varkind before. If varindex was a localvar, a new TEMPVAR has */
159 /* to be created for the slot and the OUTVAR flag set */
160 #define SET_OUTVAR(sp)                                                  \
161         do {                                                                            \
162                 if (IS_LOCALVAR((sp))) {                                \
163                         GET_NEW_INDEX(new_index);                       \
164                         sp->varnum = new_index;                         \
165                         sp->flags = 0;                                          \
166                 }                                                                               \
167                 SET_OUTVAR_BY_INDEX((sp)->varnum);              \
168         } while(0)
169
170 #define SET_OUTVAR_BY_INDEX(index) \
171         do {                                                                                                            \
172                 assert(index >= jd->localcount);                                                \
173                 jd->var[(index)].flags |=OUTVAR;                                                \
174         } while (0);
175
176
177 #define SET_TEMPVAR(sp) \
178         do {                                                                                                            \
179                 if ( IS_LOCALVAR( (sp) ) ) {                                                    \
180                         GET_NEW_INDEX(new_index);                                                       \
181                         (sp)->varnum = new_index;                                                       \
182                         jd->var[(sp)->varnum].flags = copy->flags;                      \
183                 }                                                                                                               \
184                 jd->var[(sp)->varnum].flags &= ~(OUTVAR | PREALLOC);    \
185         } while (0);
186
187 #define SET_PREALLOC(sp) \
188         do { \
189                 assert(!IS_LOCALVAR((sp))); \
190                 jd->var[(sp)->varnum].flags |= PREALLOC; \
191         } while (0);
192
193 #define IS_OUTVAR(sp) \
194         (jd->var[(sp)->varnum].flags & OUTVAR)
195
196 #define IS_PREALLOC(sp) \
197         (jd->var[(sp)->varnum].flags & PREALLOC)
198
199 #define IS_TEMPVAR(sp) \
200         ( (jd->var[(sp)->varnum].flags & (OUTVAR | PREALLOC)    \
201            && (((sp)->varnum < jd->localcount)) == 0) )
202
203 #define IS_LOCALVAR(sp)                                                 \
204                  ((sp)->varnum < jd->localcount)
205
206 #define CLR_S1                                                       \
207     (iptr->s1.varindex = -1)
208
209 #define USE_S1_LOCAL(type1)
210
211 #define USE_S1(type1)                                                \
212     do {                                                             \
213         REQUIRE_1;                                                   \
214         CHECK_BASIC_TYPE(type1, curstack->type);                     \
215         iptr->s1.varindex = curstack->varnum;                        \
216     } while (0)
217
218 #define USE_S1_ANY                                                   \
219     do {                                                             \
220         REQUIRE_1;                                                   \
221         iptr->s1.varindex = curstack->varnum;                        \
222     } while (0)
223
224 #define USE_S1_S2(type1, type2)                                      \
225     do {                                                             \
226         REQUIRE_2;                                                   \
227         CHECK_BASIC_TYPE(type1, curstack->prev->type);               \
228         CHECK_BASIC_TYPE(type2, curstack->type);                     \
229         iptr->sx.s23.s2.varindex = curstack->varnum;                 \
230         iptr->s1.varindex = curstack->prev->varnum;                  \
231     } while (0)
232
233 #define USE_S1_S2_ANY_ANY                                            \
234     do {                                                             \
235         REQUIRE_2;                                                   \
236         iptr->sx.s23.s2.varindex = curstack->varnum;                 \
237         iptr->s1.varindex = curstack->prev->varnum;                  \
238     } while (0)
239
240 #define USE_S1_S2_S3(type1, type2, type3)                            \
241     do {                                                             \
242         REQUIRE_3;                                                   \
243         CHECK_BASIC_TYPE(type1, curstack->prev->prev->type);         \
244         CHECK_BASIC_TYPE(type2, curstack->prev->type);               \
245         CHECK_BASIC_TYPE(type3, curstack->type);                                                \
246         iptr->sx.s23.s3.varindex = curstack->varnum;                                    \
247         iptr->sx.s23.s2.varindex = curstack->prev->varnum;                              \
248         iptr->s1.varindex = curstack->prev->prev->varnum;                               \
249     } while (0)
250
251 #define CLR_DST                                                      \
252     (iptr->dst.varindex = -1)
253
254 #define DST(typed, index)                                                                                        \
255     do {                                                             \
256         NEWSTACKn((typed),(index));                                                                      \
257         iptr->dst.varindex = (index);                                                            \
258     } while (0)
259
260 #define DST_LOCALVAR(typed, index)                                   \
261     do {                                                                                                                           \
262         NEWSTACK(typed, LOCALVAR, (index));                                                        \
263         iptr->dst.varindex = (index);                                                              \
264     } while (0)
265
266 #define OP0_1(typed)                                                 \
267     do {                                                             \
268         CLR_S1;                                                      \
269                 GET_NEW_INDEX(new_index);                                                                        \
270                 DST(typed, new_index);                                                                           \
271         stackdepth++;                                                \
272     } while (0)
273
274 #define OP1_0_ANY                                                    \
275     do {                                                             \
276         POP_S1_ANY;                                                  \
277         CLR_DST;                                                     \
278         stackdepth--;                                                \
279     } while (0)
280
281 #define OP1_BRANCH(type1)                                            \
282     do {                                                             \
283         POP_S1(type1);                                               \
284         stackdepth--;                                                \
285     } while (0)
286
287 #define OP1_1(type1, typed)                                          \
288     do {                                                             \
289         POP_S1(type1);                                               \
290                 GET_NEW_INDEX(new_index);                                                                        \
291         DST(typed, new_index);                                                                           \
292     } while (0)
293
294 #define OP2_1(type1, type2, typed)                                   \
295     do {                                                             \
296         POP_S1_S2(type1, type2);                                     \
297                 GET_NEW_INDEX(new_index);                                                                        \
298         DST(typed, new_index);                                                                           \
299                 stackdepth--;                                                \
300     } while (0)
301
302 #define DUP_SLOT(sp)                                                 \
303     do {                                                             \
304         if ((sp)->varkind != TEMPVAR) {                                                          \
305                         GET_NEW_INDEX(new_index);                                                                \
306             NEWSTACK((sp)->type, TEMPVAR, new_index);               \
307                 }                                                                                                                        \
308         else                                                         \
309             NEWSTACK((sp)->type, (sp)->varkind, (sp)->varnum);       \
310     } while(0)
311
312 #else /* defined(NEW_VAR) */
313
314 #define CLR_S1                                                       \
315     (iptr->s1.var = NULL)
316
317 #define USE_S1_LOCAL(type1)
318
319 #define USE_S1(type1)                                                \
320     do {                                                             \
321         REQUIRE_1;                                                   \
322         CHECK_BASIC_TYPE(type1, curstack->type);                     \
323         iptr->s1.var = curstack;                                     \
324     } while (0)
325
326 #define USE_S1_ANY                                                   \
327     do {                                                             \
328         REQUIRE_1;                                                   \
329         iptr->s1.var = curstack;                                     \
330     } while (0)
331
332 #define USE_S1_S2(type1, type2)                                      \
333     do {                                                             \
334         REQUIRE_2;                                                   \
335         CHECK_BASIC_TYPE(type1, curstack->prev->type);               \
336         CHECK_BASIC_TYPE(type2, curstack->type);                     \
337         iptr->sx.s23.s2.var = curstack;                              \
338         iptr->s1.var = curstack->prev;                               \
339     } while (0)
340
341 #define USE_S1_S2_ANY_ANY                                            \
342     do {                                                             \
343         REQUIRE_2;                                                   \
344         iptr->sx.s23.s2.var = curstack;                              \
345         iptr->s1.var = curstack->prev;                               \
346     } while (0)
347
348 #define USE_S1_S2_S3(type1, type2, type3)                            \
349     do {                                                             \
350         REQUIRE_3;                                                   \
351         CHECK_BASIC_TYPE(type1, curstack->prev->prev->type);         \
352         CHECK_BASIC_TYPE(type2, curstack->prev->type);               \
353         CHECK_BASIC_TYPE(type3, curstack->type);                     \
354         iptr->sx.s23.s3.var = curstack;                              \
355         iptr->sx.s23.s2.var = curstack->prev;                        \
356         iptr->s1.var = curstack->prev->prev;                         \
357     } while (0)
358
359 #define CLR_DST                                                      \
360     (iptr->dst.var = NULL)
361
362 #define DST(typed, depth)                                            \
363     do {                                                             \
364         NEWSTACKn(typed, (depth));                                   \
365         iptr->dst.var = curstack;                                    \
366     } while (0)
367
368 #define DST_LOCALVAR(typed, index)                                   \
369     do {                                                             \
370         NEWSTACK(typed, LOCALVAR, (index));                          \
371         iptr->dst.var = curstack;                                    \
372     } while (0)
373
374 #define OP0_1(typed)                                                 \
375     do {                                                             \
376         CLR_S1;                                                      \
377         DST(typed, stackdepth);                                      \
378         stackdepth++;                                                \
379     } while (0)
380
381 #define OP1_0_ANY                                                    \
382     do {                                                             \
383         POP_S1_ANY;                                                  \
384         CLR_DST;                                                     \
385         stackdepth--;                                                \
386     } while (0)
387
388 #define OP1_BRANCH(type1)                                            \
389     do {                                                             \
390         POP_S1(type1);                                               \
391         stackdepth--;                                                \
392     } while (0)
393
394 #define OP1_1(type1, typed)                                          \
395     do {                                                             \
396         POP_S1(type1);                                               \
397         DST(typed, stackdepth - 1);                                  \
398     } while (0)
399
400 #define OP2_1(type1, type2, typed)                                   \
401     do {                                                             \
402         POP_S1_S2(type1, type2);                                     \
403         DST(typed, stackdepth - 2);                                  \
404         stackdepth--;                                                \
405     } while (0)
406
407 #define DUP_SLOT(sp)                                                 \
408     do {                                                             \
409         if ((sp)->varkind != TEMPVAR)                                \
410             NEWSTACK((sp)->type, TEMPVAR, stackdepth);               \
411         else                                                         \
412             NEWSTACK((sp)->type, (sp)->varkind, (sp)->varnum);       \
413     } while(0)
414
415 #endif /* defined(NEW_VAR) */
416
417
418 #define POP_S1(type1)                                                \
419     do {                                                             \
420         USE_S1(type1);                                               \
421         if (curstack->varkind == UNDEFVAR)                           \
422             curstack->varkind = TEMPVAR;                             \
423         curstack = curstack->prev;                                   \
424     } while (0)
425
426 #define POP_S1_ANY                                                   \
427     do {                                                             \
428         USE_S1_ANY;                                                  \
429         if (curstack->varkind == UNDEFVAR)                           \
430             curstack->varkind = TEMPVAR;                             \
431         curstack = curstack->prev;                                   \
432     } while (0)
433
434 #define POP_S1_S2(type1, type2)                                      \
435     do {                                                             \
436         USE_S1_S2(type1, type2);                                     \
437         if (curstack->varkind == UNDEFVAR)                           \
438             curstack->varkind = TEMPVAR;                             \
439         if (curstack->prev->varkind == UNDEFVAR)                     \
440             curstack->prev->varkind = TEMPVAR;                       \
441         curstack = curstack->prev->prev;                             \
442     } while (0)
443
444 #define POP_S1_S2_ANY_ANY                                            \
445     do {                                                             \
446         USE_S1_S2_ANY_ANY;                                           \
447         if (curstack->varkind == UNDEFVAR)                           \
448             curstack->varkind = TEMPVAR;                             \
449         if (curstack->prev->varkind == UNDEFVAR)                     \
450             curstack->prev->varkind = TEMPVAR;                       \
451         curstack = curstack->prev->prev;                             \
452     } while (0)
453
454 #define POP_S1_S2_S3(type1, type2, type3)                            \
455     do {                                                             \
456         USE_S1_S2_S3(type1, type2, type3);                           \
457         if (curstack->varkind == UNDEFVAR)                           \
458             curstack->varkind = TEMPVAR;                             \
459         if (curstack->prev->varkind == UNDEFVAR)                     \
460             curstack->prev->varkind = TEMPVAR;                       \
461         if (curstack->prev->prev->varkind == UNDEFVAR)               \
462             curstack->prev->prev->varkind = TEMPVAR;                 \
463         curstack = curstack->prev->prev->prev;                       \
464     } while (0)
465
466 #define CLR_SX                                                       \
467     (iptr->sx.val.l = 0)
468
469 #define OP0_0                                                        \
470     do {                                                             \
471         CLR_S1;                                                      \
472         CLR_DST;                                                     \
473     } while (0)
474
475 #define OP0_BRANCH                                                   \
476     do {                                                             \
477         CLR_S1;                                                      \
478     } while (0)
479
480 #define OP1_0(type1)                                                 \
481     do {                                                             \
482         POP_S1(type1);                                               \
483         CLR_DST;                                                     \
484         stackdepth--;                                                \
485     } while (0)
486
487 #define OP2_0(type1, type2)                                          \
488     do {                                                             \
489         POP_S1_S2(type1, type2);                                     \
490         CLR_DST;                                                     \
491         stackdepth -= 2;                                             \
492     } while (0)
493
494 #define OP2_BRANCH(type1, type2)                                     \
495     do {                                                             \
496         POP_S1_S2(type1, type2);                                     \
497         stackdepth -= 2;                                             \
498     } while (0)
499
500 #define OP2_0_ANY_ANY                                                \
501     do {                                                             \
502         POP_S1_S2_ANY_ANY;                                           \
503         CLR_DST;                                                     \
504         stackdepth -= 2;                                             \
505     } while (0)
506
507 #define OP3_0(type1, type2, type3)                                   \
508     do {                                                             \
509         POP_S1_S2_S3(type1, type2, type3);                           \
510         CLR_DST;                                                     \
511         stackdepth -= 3;                                             \
512     } while (0)
513
514 #define LOAD(type1, index)                                           \
515     do {                                                             \
516         DST_LOCALVAR(type1, index);                                  \
517         stackdepth++;                                                \
518     } while (0)
519
520 #define STORE(type1, index)                                          \
521     do {                                                             \
522         POP_S1(type1);                                               \
523         stackdepth--;                                                \
524     } while (0)
525
526 #define BRANCH_TARGET(bt, tempbptr, tempsp)                          \
527     do {                                                             \
528         (bt).block = tempbptr = BLOCK_OF((bt).insindex);             \
529         MARKREACHED(tempbptr, tempsp);                               \
530     } while (0)
531
532 #define BRANCH(tempbptr, tempsp)                                     \
533     do {                                                             \
534         iptr->dst.block = tempbptr = BLOCK_OF(iptr->dst.insindex);   \
535         MARKREACHED(tempbptr, tempsp);                               \
536     } while (0)
537
538 bool new_stack_analyse(jitdata *jd)
539 {
540         methodinfo   *m;              /* method being analyzed                    */
541         codeinfo     *code;
542         codegendata  *cd;
543         registerdata *rd;
544         int           b_count;        /* basic block counter                      */
545         int           b_index;        /* basic block index                        */
546         int           stackdepth;
547         stackptr      curstack;       /* current stack top                        */
548         stackptr      new;
549         stackptr      copy;
550         int           opcode;         /* opcode of current instruction            */
551         int           i, j;
552         int           len;            /* # of instructions after the current one  */
553         bool          superblockend;  /* if true, no fallthrough to next block    */
554         bool          repeat;         /* if true, outermost loop must run again   */
555         bool          deadcode;       /* true if no live code has been reached    */
556         instruction  *iptr;           /* the current instruction                  */
557         basicblock   *bptr;           /* the current basic block                  */
558         basicblock   *tbptr;
559
560         stackptr     *last_store_boundary;
561         stackptr      last_pei_boundary;
562         stackptr      last_dup_boundary;
563
564         branch_target_t *table;
565         lookup_target_t *lookup;
566 #if defined(ENABLE_VERIFIER)
567         int           expectedtype;   /* used by CHECK_BASIC_TYPE                 */
568 #endif
569         builtintable_entry *bte;
570         methoddesc         *md;
571         constant_FMIref    *fmiref;
572 #if defined(ENABLE_STATISTICS)
573         int           iteration_count;  /* number of iterations of analysis       */
574 #endif
575 #if defined(NEW_VAR)
576         int           new_index; /* used to get a new var index with GET_NEW_INDEX*/
577 #endif
578 #if defined(STACK_VERBOSE)
579         new_show_method(jd, SHOW_PARSE);
580 #endif
581
582         /* get required compiler data - initialization */
583
584         m    = jd->m;
585         code = jd->code;
586         cd   = jd->cd;
587         rd   = jd->rd;
588
589 #if defined(ENABLE_LSRA)
590         m->maxlifetimes = 0;
591 #endif
592
593 #if defined(ENABLE_STATISTICS)
594         iteration_count = 0;
595 #endif
596
597 #if defined(NEW_VAR)
598         /* init jd->interface_map */
599
600         jd->interface_map = DMNEW(s4, m->maxstack * 5);
601         for (i = 0; i < m->maxstack * 5; i++)
602                 jd->interface_map[i] = UNUSED;
603
604         last_store_boundary = DMNEW(stackptr, jd->localcount);
605 #else
606         last_store_boundary = DMNEW(stackptr , cd->maxlocals);
607 #endif
608
609         /* initialize in-stack of first block */
610
611         new = jd->new_stack;
612         jd->new_basicblocks[0].flags = BBREACHED;
613         jd->new_basicblocks[0].instack = NULL;
614         jd->new_basicblocks[0].invars = NULL;
615         jd->new_basicblocks[0].indepth = 0;
616
617         /* initialize in-stack of exception handlers */
618
619         for (i = 0; i < cd->exceptiontablelength; i++) {
620                 bptr = BLOCK_OF(cd->exceptiontable[i].handlerpc);
621                 bptr->flags = BBREACHED;
622                 bptr->type = BBTYPE_EXH;
623                 bptr->instack = new;
624                 bptr->indepth = 1;
625                 bptr->predecessorcount = CFG_UNKNOWN_PREDECESSORS;
626                 STACKRESET;
627 #if defined(NEW_VAR)
628                 GET_NEW_INDEX(new_index);
629                 bptr->invars = DMNEW(s4, 1);
630                 bptr->invars[0] = new_index;
631                 NEWSTACK(TYPE_ADR, STACKVAR, new_index);
632
633                 jd->interface_map[0 * 5 + TYPE_ADR] = new_index;
634                 SET_OUTVAR_BY_INDEX(new_index);
635 #else
636                 bptr->invars = DMNEW(stackptr, 1);
637                 bptr->invars[0] = new;
638                 NEWXSTACK;
639 #endif
640         }
641
642         /* stack analysis loop (until fixpoint reached) **************************/
643
644         do {
645 #if defined(ENABLE_STATISTICS)
646                 iteration_count++;
647 #endif
648
649                 /* initialize loop over basic blocks */
650
651                 b_count = jd->new_basicblockcount;
652                 bptr = jd->new_basicblocks;
653                 superblockend = true;
654                 repeat = false;
655                 STACKRESET;
656                 deadcode = true;
657
658                 /* iterate over basic blocks *****************************************/
659
660                 while (--b_count >= 0) {
661 #if defined(STACK_VERBOSE)
662                         printf("----\nANALYZING BLOCK L%03d ", bptr->nr);
663                         if (bptr->type == BBTYPE_EXH) printf("EXH\n");
664                         else if (bptr->type == BBTYPE_SBR) printf("SBR\n");
665                         else printf("STD\n");
666                            
667 #endif
668
669                         if (bptr->flags == BBDELETED) {
670                                 /* This block has been deleted - do nothing. */
671                         }
672                         else if (superblockend && (bptr->flags < BBREACHED)) {
673                                 /* This block has not been reached so far, and we      */
674                                 /* don't fall into it, so we'll have to iterate again. */
675                                 repeat = true;
676                         }
677                         else if (bptr->flags <= BBREACHED) {
678                                 if (superblockend) {
679                                         /* We know that bptr->flags == BBREACHED. */
680                                         /* This block has been reached before.    */
681                                         stackdepth = bptr->indepth;
682                                 }
683                                 else if (bptr->flags < BBREACHED) {
684                                         /* This block is reached for the first time now */
685                                         /* by falling through from the previous block.  */
686                                         COPYCURSTACK(copy);
687                                         bptr->instack = copy;
688
689 #if defined(NEW_VAR)
690                                         bptr->invars = DMNEW(s4, stackdepth);
691                                         for (i=stackdepth; i--; copy = copy->prev)
692                                                 bptr->invars[i] = copy->varnum;
693 #else
694                                         bptr->invars = DMNEW(stackptr, stackdepth);
695                                         for (i=stackdepth; i--; copy = copy->prev)
696                                                 bptr->invars[i] = copy;
697 #endif
698                                         bptr->indepth = stackdepth;
699                                 }
700                                 else {
701                                         /* This block has been reached before. now we are */
702                                         /* falling into it from the previous block.       */
703                                         /* Check that stack depth is well-defined.        */
704                                         CHECK_STACK_DEPTH(bptr->indepth, stackdepth);
705                                 }
706
707                                 /* set up local variables for analyzing this block */
708
709                                 curstack = bptr->instack;
710                                 deadcode = false;
711                                 superblockend = false;
712                                 bptr->flags = BBFINISHED;
713                                 len = bptr->icount;
714                                 iptr = bptr->iinstr;
715                                 b_index = bptr - jd->new_basicblocks;
716
717                                 /* reset variables for dependency checking */
718
719                                 last_pei_boundary = new;
720                                 last_dup_boundary = new;
721                                 for( i = 0; i < cd->maxlocals; i++)
722                                         last_store_boundary[i] = new;
723
724                                 /* XXX store the start of the block's stack representation */
725
726                                 bptr->stack = new;
727 #if defined(STACK_VERBOSE)
728                                 printf("INVARS\n");
729                                         for( copy = bptr->instack; copy; copy = copy->prev ) {
730                                                 printf("%2d(%d", copy->varnum, copy->type);
731                                                 if (IS_OUTVAR(copy))
732                                                         printf("S");
733                                                 if (IS_PREALLOC(copy))
734                                                         printf("A");
735                                                 printf(") ");
736                                         }
737                                         printf("\n");
738
739 #endif
740                                 /* iterate over ICMDs ****************************************/
741
742                                 while (--len >= 0)  {
743 #if defined(STACK_VERBOSE)
744                                         new_show_icmd(jd, iptr, false, SHOW_PARSE); printf("\n");
745                                         for( copy = curstack; copy; copy = copy->prev ) {
746                                                 printf("%2d(%d", copy->varnum, copy->type);
747                                                 if (IS_OUTVAR(copy))
748                                                         printf("S");
749                                                 if (IS_PREALLOC(copy))
750                                                         printf("A");
751                                                 printf(") ");
752                                         }
753                                         printf("\n");
754 #endif
755
756                                         /* fetch the current opcode */
757
758                                         opcode = iptr->opc;
759
760                                         /* automatically replace some ICMDs with builtins */
761
762 #if defined(USEBUILTINTABLE)
763                                         IF_NO_INTRP(
764                                                 bte = builtintable_get_automatic(opcode);
765
766                                                 if (bte && bte->opcode == opcode) {
767                                                         iptr->opc           = ICMD_BUILTIN;
768                                                         iptr->flags.bits    = 0;
769                                                         iptr->sx.s23.s3.bte = bte;
770                                                         /* iptr->line is already set */
771                                                         jd->isleafmethod = false;
772                                                         goto icmd_BUILTIN;
773                                                 }
774                                         );
775 #endif /* defined(USEBUILTINTABLE) */
776
777                                         /* main opcode switch *************************************/
778
779                                         switch (opcode) {
780
781                                                 /* pop 0 push 0 */
782
783                                         case ICMD_NOP:
784 icmd_NOP:
785                                                 CLR_SX;
786                                                 OP0_0;
787                                                 break;
788
789                                         case ICMD_CHECKNULL:
790                                                 last_pei_boundary = new;
791                                                 COUNT(count_check_null);
792                                                 USE_S1(TYPE_ADR);
793                                                 CLR_SX;
794                                                 CLR_DST; /* XXX live through? */
795                                                 break;
796
797                                         case ICMD_RET:
798                                                 USE_S1_LOCAL(TYPE_ADR);
799                                                 CLR_SX;
800                                                 CLR_DST;
801 #if !defined(NEW_VAR)
802                                                 IF_NO_INTRP( rd->locals[iptr->s1.localindex][TYPE_ADR].type = TYPE_ADR; );
803 #endif
804                                                 superblockend = true;
805                                                 break;
806
807                                         case ICMD_RETURN:
808                                                 COUNT(count_pcmd_return);
809                                                 CLR_SX;
810                                                 OP0_0;
811                                                 superblockend = true;
812                                                 break;
813
814
815                                                 /* pop 0 push 1 const */
816
817         /************************** ICONST OPTIMIZATIONS **************************/
818
819                                         case ICMD_ICONST:
820                                                 COUNT(count_pcmd_load);
821                                                 if (len == 0)
822                                                         goto normal_ICONST;
823
824                                                 switch (iptr[1].opc) {
825                                                         case ICMD_IADD:
826                                                                 iptr->opc = ICMD_IADDCONST;
827                                                                 /* FALLTHROUGH */
828
829                                                         icmd_iconst_tail:
830                                                                 iptr[1].opc = ICMD_NOP;
831                                                                 OP1_1(TYPE_INT, TYPE_INT);
832                                                                 COUNT(count_pcmd_op);
833                                                                 break;
834
835                                                         case ICMD_ISUB:
836                                                                 iptr->opc = ICMD_ISUBCONST;
837                                                                 goto icmd_iconst_tail;
838 #if SUPPORT_CONST_MUL
839                                                         case ICMD_IMUL:
840                                                                 iptr->opc = ICMD_IMULCONST;
841                                                                 goto icmd_iconst_tail;
842 #else /* SUPPORT_CONST_MUL */
843                                                         case ICMD_IMUL:
844                                                                 if (iptr->sx.val.i == 0x00000002)
845                                                                         iptr->sx.val.i = 1;
846                                                                 else if (iptr->sx.val.i == 0x00000004)
847                                                                         iptr->sx.val.i = 2;
848                                                                 else if (iptr->sx.val.i == 0x00000008)
849                                                                         iptr->sx.val.i = 3;
850                                                                 else if (iptr->sx.val.i == 0x00000010)
851                                                                         iptr->sx.val.i = 4;
852                                                                 else if (iptr->sx.val.i == 0x00000020)
853                                                                         iptr->sx.val.i = 5;
854                                                                 else if (iptr->sx.val.i == 0x00000040)
855                                                                         iptr->sx.val.i = 6;
856                                                                 else if (iptr->sx.val.i == 0x00000080)
857                                                                         iptr->sx.val.i = 7;
858                                                                 else if (iptr->sx.val.i == 0x00000100)
859                                                                         iptr->sx.val.i = 8;
860                                                                 else if (iptr->sx.val.i == 0x00000200)
861                                                                         iptr->sx.val.i = 9;
862                                                                 else if (iptr->sx.val.i == 0x00000400)
863                                                                         iptr->sx.val.i = 10;
864                                                                 else if (iptr->sx.val.i == 0x00000800)
865                                                                         iptr->sx.val.i = 11;
866                                                                 else if (iptr->sx.val.i == 0x00001000)
867                                                                         iptr->sx.val.i = 12;
868                                                                 else if (iptr->sx.val.i == 0x00002000)
869                                                                         iptr->sx.val.i = 13;
870                                                                 else if (iptr->sx.val.i == 0x00004000)
871                                                                         iptr->sx.val.i = 14;
872                                                                 else if (iptr->sx.val.i == 0x00008000)
873                                                                         iptr->sx.val.i = 15;
874                                                                 else if (iptr->sx.val.i == 0x00010000)
875                                                                         iptr->sx.val.i = 16;
876                                                                 else if (iptr->sx.val.i == 0x00020000)
877                                                                         iptr->sx.val.i = 17;
878                                                                 else if (iptr->sx.val.i == 0x00040000)
879                                                                         iptr->sx.val.i = 18;
880                                                                 else if (iptr->sx.val.i == 0x00080000)
881                                                                         iptr->sx.val.i = 19;
882                                                                 else if (iptr->sx.val.i == 0x00100000)
883                                                                         iptr->sx.val.i = 20;
884                                                                 else if (iptr->sx.val.i == 0x00200000)
885                                                                         iptr->sx.val.i = 21;
886                                                                 else if (iptr->sx.val.i == 0x00400000)
887                                                                         iptr->sx.val.i = 22;
888                                                                 else if (iptr->sx.val.i == 0x00800000)
889                                                                         iptr->sx.val.i = 23;
890                                                                 else if (iptr->sx.val.i == 0x01000000)
891                                                                         iptr->sx.val.i = 24;
892                                                                 else if (iptr->sx.val.i == 0x02000000)
893                                                                         iptr->sx.val.i = 25;
894                                                                 else if (iptr->sx.val.i == 0x04000000)
895                                                                         iptr->sx.val.i = 26;
896                                                                 else if (iptr->sx.val.i == 0x08000000)
897                                                                         iptr->sx.val.i = 27;
898                                                                 else if (iptr->sx.val.i == 0x10000000)
899                                                                         iptr->sx.val.i = 28;
900                                                                 else if (iptr->sx.val.i == 0x20000000)
901                                                                         iptr->sx.val.i = 29;
902                                                                 else if (iptr->sx.val.i == 0x40000000)
903                                                                         iptr->sx.val.i = 30;
904                                                                 else if (iptr->sx.val.i == 0x80000000)
905                                                                         iptr->sx.val.i = 31;
906                                                                 else
907                                                                         goto normal_ICONST;
908
909                                                                 iptr->opc = ICMD_IMULPOW2;
910                                                                 goto icmd_iconst_tail;
911 #endif /* SUPPORT_CONST_MUL */
912                                                         case ICMD_IDIV:
913                                                                 if (iptr->sx.val.i == 0x00000002)
914                                                                         iptr->sx.val.i = 1;
915                                                                 else if (iptr->sx.val.i == 0x00000004)
916                                                                         iptr->sx.val.i = 2;
917                                                                 else if (iptr->sx.val.i == 0x00000008)
918                                                                         iptr->sx.val.i = 3;
919                                                                 else if (iptr->sx.val.i == 0x00000010)
920                                                                         iptr->sx.val.i = 4;
921                                                                 else if (iptr->sx.val.i == 0x00000020)
922                                                                         iptr->sx.val.i = 5;
923                                                                 else if (iptr->sx.val.i == 0x00000040)
924                                                                         iptr->sx.val.i = 6;
925                                                                 else if (iptr->sx.val.i == 0x00000080)
926                                                                         iptr->sx.val.i = 7;
927                                                                 else if (iptr->sx.val.i == 0x00000100)
928                                                                         iptr->sx.val.i = 8;
929                                                                 else if (iptr->sx.val.i == 0x00000200)
930                                                                         iptr->sx.val.i = 9;
931                                                                 else if (iptr->sx.val.i == 0x00000400)
932                                                                         iptr->sx.val.i = 10;
933                                                                 else if (iptr->sx.val.i == 0x00000800)
934                                                                         iptr->sx.val.i = 11;
935                                                                 else if (iptr->sx.val.i == 0x00001000)
936                                                                         iptr->sx.val.i = 12;
937                                                                 else if (iptr->sx.val.i == 0x00002000)
938                                                                         iptr->sx.val.i = 13;
939                                                                 else if (iptr->sx.val.i == 0x00004000)
940                                                                         iptr->sx.val.i = 14;
941                                                                 else if (iptr->sx.val.i == 0x00008000)
942                                                                         iptr->sx.val.i = 15;
943                                                                 else if (iptr->sx.val.i == 0x00010000)
944                                                                         iptr->sx.val.i = 16;
945                                                                 else if (iptr->sx.val.i == 0x00020000)
946                                                                         iptr->sx.val.i = 17;
947                                                                 else if (iptr->sx.val.i == 0x00040000)
948                                                                         iptr->sx.val.i = 18;
949                                                                 else if (iptr->sx.val.i == 0x00080000)
950                                                                         iptr->sx.val.i = 19;
951                                                                 else if (iptr->sx.val.i == 0x00100000)
952                                                                         iptr->sx.val.i = 20;
953                                                                 else if (iptr->sx.val.i == 0x00200000)
954                                                                         iptr->sx.val.i = 21;
955                                                                 else if (iptr->sx.val.i == 0x00400000)
956                                                                         iptr->sx.val.i = 22;
957                                                                 else if (iptr->sx.val.i == 0x00800000)
958                                                                         iptr->sx.val.i = 23;
959                                                                 else if (iptr->sx.val.i == 0x01000000)
960                                                                         iptr->sx.val.i = 24;
961                                                                 else if (iptr->sx.val.i == 0x02000000)
962                                                                         iptr->sx.val.i = 25;
963                                                                 else if (iptr->sx.val.i == 0x04000000)
964                                                                         iptr->sx.val.i = 26;
965                                                                 else if (iptr->sx.val.i == 0x08000000)
966                                                                         iptr->sx.val.i = 27;
967                                                                 else if (iptr->sx.val.i == 0x10000000)
968                                                                         iptr->sx.val.i = 28;
969                                                                 else if (iptr->sx.val.i == 0x20000000)
970                                                                         iptr->sx.val.i = 29;
971                                                                 else if (iptr->sx.val.i == 0x40000000)
972                                                                         iptr->sx.val.i = 30;
973                                                                 else if (iptr->sx.val.i == 0x80000000)
974                                                                         iptr->sx.val.i = 31;
975                                                                 else
976                                                                         goto normal_ICONST;
977
978                                                                 iptr->opc = ICMD_IDIVPOW2;
979                                                                 goto icmd_iconst_tail;
980
981                                                         case ICMD_IREM:
982                                                                 /*log_text("stack.c: ICMD_ICONST/ICMD_IREM");*/
983                                                                 if ((iptr->sx.val.i == 0x00000002) ||
984                                                                         (iptr->sx.val.i == 0x00000004) ||
985                                                                         (iptr->sx.val.i == 0x00000008) ||
986                                                                         (iptr->sx.val.i == 0x00000010) ||
987                                                                         (iptr->sx.val.i == 0x00000020) ||
988                                                                         (iptr->sx.val.i == 0x00000040) ||
989                                                                         (iptr->sx.val.i == 0x00000080) ||
990                                                                         (iptr->sx.val.i == 0x00000100) ||
991                                                                         (iptr->sx.val.i == 0x00000200) ||
992                                                                         (iptr->sx.val.i == 0x00000400) ||
993                                                                         (iptr->sx.val.i == 0x00000800) ||
994                                                                         (iptr->sx.val.i == 0x00001000) ||
995                                                                         (iptr->sx.val.i == 0x00002000) ||
996                                                                         (iptr->sx.val.i == 0x00004000) ||
997                                                                         (iptr->sx.val.i == 0x00008000) ||
998                                                                         (iptr->sx.val.i == 0x00010000) ||
999                                                                         (iptr->sx.val.i == 0x00020000) ||
1000                                                                         (iptr->sx.val.i == 0x00040000) ||
1001                                                                         (iptr->sx.val.i == 0x00080000) ||
1002                                                                         (iptr->sx.val.i == 0x00100000) ||
1003                                                                         (iptr->sx.val.i == 0x00200000) ||
1004                                                                         (iptr->sx.val.i == 0x00400000) ||
1005                                                                         (iptr->sx.val.i == 0x00800000) ||
1006                                                                         (iptr->sx.val.i == 0x01000000) ||
1007                                                                         (iptr->sx.val.i == 0x02000000) ||
1008                                                                         (iptr->sx.val.i == 0x04000000) ||
1009                                                                         (iptr->sx.val.i == 0x08000000) ||
1010                                                                         (iptr->sx.val.i == 0x10000000) ||
1011                                                                         (iptr->sx.val.i == 0x20000000) ||
1012                                                                         (iptr->sx.val.i == 0x40000000) ||
1013                                                                         (iptr->sx.val.i == 0x80000000))
1014                                                                 {
1015                                                                         iptr->opc = ICMD_IREMPOW2;
1016                                                                         iptr->sx.val.i -= 1;
1017                                                                         goto icmd_iconst_tail;
1018                                                                 }
1019                                                                 goto normal_ICONST;
1020 #if SUPPORT_CONST_LOGICAL
1021                                                         case ICMD_IAND:
1022                                                                 iptr->opc = ICMD_IANDCONST;
1023                                                                 goto icmd_iconst_tail;
1024
1025                                                         case ICMD_IOR:
1026                                                                 iptr->opc = ICMD_IORCONST;
1027                                                                 goto icmd_iconst_tail;
1028
1029                                                         case ICMD_IXOR:
1030                                                                 iptr->opc = ICMD_IXORCONST;
1031                                                                 goto icmd_iconst_tail;
1032
1033 #endif /* SUPPORT_CONST_LOGICAL */
1034                                                         case ICMD_ISHL:
1035                                                                 iptr->opc = ICMD_ISHLCONST;
1036                                                                 goto icmd_iconst_tail;
1037
1038                                                         case ICMD_ISHR:
1039                                                                 iptr->opc = ICMD_ISHRCONST;
1040                                                                 goto icmd_iconst_tail;
1041
1042                                                         case ICMD_IUSHR:
1043                                                                 iptr->opc = ICMD_IUSHRCONST;
1044                                                                 goto icmd_iconst_tail;
1045 #if SUPPORT_LONG_SHIFT
1046                                                         case ICMD_LSHL:
1047                                                                 iptr->opc = ICMD_LSHLCONST;
1048                                                                 goto icmd_lconst_tail;
1049
1050                                                         case ICMD_LSHR:
1051                                                                 iptr->opc = ICMD_LSHRCONST;
1052                                                                 goto icmd_lconst_tail;
1053
1054                                                         case ICMD_LUSHR:
1055                                                                 iptr->opc = ICMD_LUSHRCONST;
1056                                                                 goto icmd_lconst_tail;
1057 #endif /* SUPPORT_LONG_SHIFT */
1058                                                         case ICMD_IF_ICMPEQ:
1059                                                                 iptr[1].opc = ICMD_IFEQ;
1060                                                                 /* FALLTHROUGH */
1061
1062                                                         icmd_if_icmp_tail:
1063                                                                 /* set the constant for the following icmd */
1064                                                                 iptr[1].sx.val.i = iptr->sx.val.i;
1065
1066                                                                 /* this instruction becomes a nop */
1067                                                                 iptr->opc = ICMD_NOP;
1068                                                                 goto icmd_NOP;
1069
1070                                                         case ICMD_IF_ICMPLT:
1071                                                                 iptr[1].opc = ICMD_IFLT;
1072                                                                 goto icmd_if_icmp_tail;
1073
1074                                                         case ICMD_IF_ICMPLE:
1075                                                                 iptr[1].opc = ICMD_IFLE;
1076                                                                 goto icmd_if_icmp_tail;
1077
1078                                                         case ICMD_IF_ICMPNE:
1079                                                                 iptr[1].opc = ICMD_IFNE;
1080                                                                 goto icmd_if_icmp_tail;
1081
1082                                                         case ICMD_IF_ICMPGT:
1083                                                                 iptr[1].opc = ICMD_IFGT;
1084                                                                 goto icmd_if_icmp_tail;
1085
1086                                                         case ICMD_IF_ICMPGE:
1087                                                                 iptr[1].opc = ICMD_IFGE;
1088                                                                 goto icmd_if_icmp_tail;
1089
1090 #if SUPPORT_CONST_STORE
1091                                                         case ICMD_IASTORE:
1092                                                         case ICMD_BASTORE:
1093                                                         case ICMD_CASTORE:
1094                                                         case ICMD_SASTORE:
1095                                                                 IF_INTRP( goto normal_ICONST; )
1096 # if SUPPORT_CONST_STORE_ZERO_ONLY
1097                                                                 if (iptr->sx.val.i != 0)
1098                                                                         goto normal_ICONST;
1099 # endif
1100                                                                 switch (iptr[1].opc) {
1101                                                                         case ICMD_IASTORE:
1102                                                                                 iptr->opc = ICMD_IASTORECONST;
1103                                                                                 iptr->flags.bits |= INS_FLAG_CHECK;
1104                                                                                 break;
1105                                                                         case ICMD_BASTORE:
1106                                                                                 iptr->opc = ICMD_BASTORECONST;
1107                                                                                 iptr->flags.bits |= INS_FLAG_CHECK;
1108                                                                                 break;
1109                                                                         case ICMD_CASTORE:
1110                                                                                 iptr->opc = ICMD_CASTORECONST;
1111                                                                                 iptr->flags.bits |= INS_FLAG_CHECK;
1112                                                                                 break;
1113                                                                         case ICMD_SASTORE:
1114                                                                                 iptr->opc = ICMD_SASTORECONST;
1115                                                                                 iptr->flags.bits |= INS_FLAG_CHECK;
1116                                                                                 break;
1117                                                                 }
1118
1119                                                                 iptr[1].opc = ICMD_NOP;
1120
1121                                                                 /* copy the constant to s3 */
1122                                                                 /* XXX constval -> astoreconstval? */
1123                                                                 iptr->sx.s23.s3.constval = iptr->sx.val.i;
1124                                                                 OP2_0(TYPE_ADR, TYPE_INT);
1125                                                                 COUNT(count_pcmd_op);
1126                                                                 break;
1127
1128                                                         case ICMD_PUTSTATIC:
1129                                                         case ICMD_PUTFIELD:
1130                                                                 IF_INTRP( goto normal_ICONST; )
1131 # if SUPPORT_CONST_STORE_ZERO_ONLY
1132                                                                 if (iptr->sx.val.i != 0)
1133                                                                         goto normal_ICONST;
1134 # endif
1135                                                                 /* XXX check field type? */
1136
1137                                                                 /* copy the constant to s2 */
1138                                                                 /* XXX constval -> fieldconstval? */
1139                                                                 iptr->sx.s23.s2.constval = iptr->sx.val.i;
1140
1141 putconst_tail:
1142                                                                 /* set the field reference (s3) */
1143                                                                 if (iptr[1].flags.bits & INS_FLAG_UNRESOLVED) {
1144                                                                         iptr->sx.s23.s3.uf = iptr[1].sx.s23.s3.uf;
1145                                                                         iptr->flags.bits |= INS_FLAG_UNRESOLVED;
1146                                                                 }
1147                                                                 else {
1148                                                                         iptr->sx.s23.s3.fmiref = iptr[1].sx.s23.s3.fmiref;
1149                                                                 }
1150                                                                 
1151                                                                 switch (iptr[1].opc) {
1152                                                                         case ICMD_PUTSTATIC:
1153                                                                                 iptr->opc = ICMD_PUTSTATICCONST;
1154                                                                                 OP0_0;
1155                                                                                 break;
1156                                                                         case ICMD_PUTFIELD:
1157                                                                                 iptr->opc = ICMD_PUTFIELDCONST;
1158                                                                                 OP1_0(TYPE_ADR);
1159                                                                                 break;
1160                                                                 }
1161
1162                                                                 iptr[1].opc = ICMD_NOP;
1163                                                                 COUNT(count_pcmd_op);
1164                                                                 break;
1165 #endif /* SUPPORT_CONST_STORE */
1166
1167                                                         default:
1168                                                                 goto normal_ICONST;
1169                                                 }
1170
1171                                                 /* if we get here, the ICONST has been optimized */
1172                                                 break;
1173
1174 normal_ICONST:
1175                                                 /* normal case of an unoptimized ICONST */
1176                                                 OP0_1(TYPE_INT);
1177                                                 break;
1178
1179         /************************** LCONST OPTIMIZATIONS **************************/
1180
1181                                         case ICMD_LCONST:
1182                                                 COUNT(count_pcmd_load);
1183                                                 if (len == 0)
1184                                                         goto normal_LCONST;
1185
1186                                                 /* switch depending on the following instruction */
1187
1188                                                 switch (iptr[1].opc) {
1189 #if SUPPORT_LONG_ADD
1190                                                         case ICMD_LADD:
1191                                                                 iptr->opc = ICMD_LADDCONST;
1192                                                                 /* FALLTHROUGH */
1193
1194                                                         icmd_lconst_tail:
1195                                                                 /* instruction of type LONG -> LONG */
1196                                                                 iptr[1].opc = ICMD_NOP;
1197                                                                 OP1_1(TYPE_LNG, TYPE_LNG);
1198                                                                 COUNT(count_pcmd_op);
1199                                                                 break;
1200
1201                                                         case ICMD_LSUB:
1202                                                                 iptr->opc = ICMD_LSUBCONST;
1203                                                                 goto icmd_lconst_tail;
1204
1205 #endif /* SUPPORT_LONG_ADD */
1206 #if SUPPORT_LONG_MUL && SUPPORT_CONST_MUL
1207                                                         case ICMD_LMUL:
1208                                                                 iptr->opc = ICMD_LMULCONST;
1209                                                                 goto icmd_lconst_tail;
1210 #else /* SUPPORT_LONG_MUL && SUPPORT_CONST_MUL */
1211 # if SUPPORT_LONG_SHIFT
1212                                                         case ICMD_LMUL:
1213                                                                 if (iptr->sx.val.l == 0x00000002)
1214                                                                         iptr->sx.val.i = 1;
1215                                                                 else if (iptr->sx.val.l == 0x00000004)
1216                                                                         iptr->sx.val.i = 2;
1217                                                                 else if (iptr->sx.val.l == 0x00000008)
1218                                                                         iptr->sx.val.i = 3;
1219                                                                 else if (iptr->sx.val.l == 0x00000010)
1220                                                                         iptr->sx.val.i = 4;
1221                                                                 else if (iptr->sx.val.l == 0x00000020)
1222                                                                         iptr->sx.val.i = 5;
1223                                                                 else if (iptr->sx.val.l == 0x00000040)
1224                                                                         iptr->sx.val.i = 6;
1225                                                                 else if (iptr->sx.val.l == 0x00000080)
1226                                                                         iptr->sx.val.i = 7;
1227                                                                 else if (iptr->sx.val.l == 0x00000100)
1228                                                                         iptr->sx.val.i = 8;
1229                                                                 else if (iptr->sx.val.l == 0x00000200)
1230                                                                         iptr->sx.val.i = 9;
1231                                                                 else if (iptr->sx.val.l == 0x00000400)
1232                                                                         iptr->sx.val.i = 10;
1233                                                                 else if (iptr->sx.val.l == 0x00000800)
1234                                                                         iptr->sx.val.i = 11;
1235                                                                 else if (iptr->sx.val.l == 0x00001000)
1236                                                                         iptr->sx.val.i = 12;
1237                                                                 else if (iptr->sx.val.l == 0x00002000)
1238                                                                         iptr->sx.val.i = 13;
1239                                                                 else if (iptr->sx.val.l == 0x00004000)
1240                                                                         iptr->sx.val.i = 14;
1241                                                                 else if (iptr->sx.val.l == 0x00008000)
1242                                                                         iptr->sx.val.i = 15;
1243                                                                 else if (iptr->sx.val.l == 0x00010000)
1244                                                                         iptr->sx.val.i = 16;
1245                                                                 else if (iptr->sx.val.l == 0x00020000)
1246                                                                         iptr->sx.val.i = 17;
1247                                                                 else if (iptr->sx.val.l == 0x00040000)
1248                                                                         iptr->sx.val.i = 18;
1249                                                                 else if (iptr->sx.val.l == 0x00080000)
1250                                                                         iptr->sx.val.i = 19;
1251                                                                 else if (iptr->sx.val.l == 0x00100000)
1252                                                                         iptr->sx.val.i = 20;
1253                                                                 else if (iptr->sx.val.l == 0x00200000)
1254                                                                         iptr->sx.val.i = 21;
1255                                                                 else if (iptr->sx.val.l == 0x00400000)
1256                                                                         iptr->sx.val.i = 22;
1257                                                                 else if (iptr->sx.val.l == 0x00800000)
1258                                                                         iptr->sx.val.i = 23;
1259                                                                 else if (iptr->sx.val.l == 0x01000000)
1260                                                                         iptr->sx.val.i = 24;
1261                                                                 else if (iptr->sx.val.l == 0x02000000)
1262                                                                         iptr->sx.val.i = 25;
1263                                                                 else if (iptr->sx.val.l == 0x04000000)
1264                                                                         iptr->sx.val.i = 26;
1265                                                                 else if (iptr->sx.val.l == 0x08000000)
1266                                                                         iptr->sx.val.i = 27;
1267                                                                 else if (iptr->sx.val.l == 0x10000000)
1268                                                                         iptr->sx.val.i = 28;
1269                                                                 else if (iptr->sx.val.l == 0x20000000)
1270                                                                         iptr->sx.val.i = 29;
1271                                                                 else if (iptr->sx.val.l == 0x40000000)
1272                                                                         iptr->sx.val.i = 30;
1273                                                                 else if (iptr->sx.val.l == 0x80000000)
1274                                                                         iptr->sx.val.i = 31;
1275                                                                 else {
1276                                                                         goto normal_LCONST;
1277                                                                 }
1278                                                                 iptr->opc = ICMD_LMULPOW2;
1279                                                                 goto icmd_lconst_tail;
1280 # endif /* SUPPORT_LONG_SHIFT */
1281 #endif /* SUPPORT_LONG_MUL && SUPPORT_CONST_MUL */
1282 #if SUPPORT_LONG_DIV_POW2
1283                                                         case ICMD_LDIV:
1284                                                                 if (iptr->sx.val.l == 0x00000002)
1285                                                                         iptr->sx.val.i = 1;
1286                                                                 else if (iptr->sx.val.l == 0x00000004)
1287                                                                         iptr->sx.val.i = 2;
1288                                                                 else if (iptr->sx.val.l == 0x00000008)
1289                                                                         iptr->sx.val.i = 3;
1290                                                                 else if (iptr->sx.val.l == 0x00000010)
1291                                                                         iptr->sx.val.i = 4;
1292                                                                 else if (iptr->sx.val.l == 0x00000020)
1293                                                                         iptr->sx.val.i = 5;
1294                                                                 else if (iptr->sx.val.l == 0x00000040)
1295                                                                         iptr->sx.val.i = 6;
1296                                                                 else if (iptr->sx.val.l == 0x00000080)
1297                                                                         iptr->sx.val.i = 7;
1298                                                                 else if (iptr->sx.val.l == 0x00000100)
1299                                                                         iptr->sx.val.i = 8;
1300                                                                 else if (iptr->sx.val.l == 0x00000200)
1301                                                                         iptr->sx.val.i = 9;
1302                                                                 else if (iptr->sx.val.l == 0x00000400)
1303                                                                         iptr->sx.val.i = 10;
1304                                                                 else if (iptr->sx.val.l == 0x00000800)
1305                                                                         iptr->sx.val.i = 11;
1306                                                                 else if (iptr->sx.val.l == 0x00001000)
1307                                                                         iptr->sx.val.i = 12;
1308                                                                 else if (iptr->sx.val.l == 0x00002000)
1309                                                                         iptr->sx.val.i = 13;
1310                                                                 else if (iptr->sx.val.l == 0x00004000)
1311                                                                         iptr->sx.val.i = 14;
1312                                                                 else if (iptr->sx.val.l == 0x00008000)
1313                                                                         iptr->sx.val.i = 15;
1314                                                                 else if (iptr->sx.val.l == 0x00010000)
1315                                                                         iptr->sx.val.i = 16;
1316                                                                 else if (iptr->sx.val.l == 0x00020000)
1317                                                                         iptr->sx.val.i = 17;
1318                                                                 else if (iptr->sx.val.l == 0x00040000)
1319                                                                         iptr->sx.val.i = 18;
1320                                                                 else if (iptr->sx.val.l == 0x00080000)
1321                                                                         iptr->sx.val.i = 19;
1322                                                                 else if (iptr->sx.val.l == 0x00100000)
1323                                                                         iptr->sx.val.i = 20;
1324                                                                 else if (iptr->sx.val.l == 0x00200000)
1325                                                                         iptr->sx.val.i = 21;
1326                                                                 else if (iptr->sx.val.l == 0x00400000)
1327                                                                         iptr->sx.val.i = 22;
1328                                                                 else if (iptr->sx.val.l == 0x00800000)
1329                                                                         iptr->sx.val.i = 23;
1330                                                                 else if (iptr->sx.val.l == 0x01000000)
1331                                                                         iptr->sx.val.i = 24;
1332                                                                 else if (iptr->sx.val.l == 0x02000000)
1333                                                                         iptr->sx.val.i = 25;
1334                                                                 else if (iptr->sx.val.l == 0x04000000)
1335                                                                         iptr->sx.val.i = 26;
1336                                                                 else if (iptr->sx.val.l == 0x08000000)
1337                                                                         iptr->sx.val.i = 27;
1338                                                                 else if (iptr->sx.val.l == 0x10000000)
1339                                                                         iptr->sx.val.i = 28;
1340                                                                 else if (iptr->sx.val.l == 0x20000000)
1341                                                                         iptr->sx.val.i = 29;
1342                                                                 else if (iptr->sx.val.l == 0x40000000)
1343                                                                         iptr->sx.val.i = 30;
1344                                                                 else if (iptr->sx.val.l == 0x80000000)
1345                                                                         iptr->sx.val.i = 31;
1346                                                                 else {
1347                                                                         goto normal_LCONST;
1348                                                                 }
1349                                                                 iptr->opc = ICMD_LDIVPOW2;
1350                                                                 goto icmd_lconst_tail;
1351 #endif /* SUPPORT_LONG_DIV_POW2 */
1352
1353 #if SUPPORT_LONG_REM_POW2
1354                                                         case ICMD_LREM:
1355                                                                 if ((iptr->sx.val.l == 0x00000002) ||
1356                                                                         (iptr->sx.val.l == 0x00000004) ||
1357                                                                         (iptr->sx.val.l == 0x00000008) ||
1358                                                                         (iptr->sx.val.l == 0x00000010) ||
1359                                                                         (iptr->sx.val.l == 0x00000020) ||
1360                                                                         (iptr->sx.val.l == 0x00000040) ||
1361                                                                         (iptr->sx.val.l == 0x00000080) ||
1362                                                                         (iptr->sx.val.l == 0x00000100) ||
1363                                                                         (iptr->sx.val.l == 0x00000200) ||
1364                                                                         (iptr->sx.val.l == 0x00000400) ||
1365                                                                         (iptr->sx.val.l == 0x00000800) ||
1366                                                                         (iptr->sx.val.l == 0x00001000) ||
1367                                                                         (iptr->sx.val.l == 0x00002000) ||
1368                                                                         (iptr->sx.val.l == 0x00004000) ||
1369                                                                         (iptr->sx.val.l == 0x00008000) ||
1370                                                                         (iptr->sx.val.l == 0x00010000) ||
1371                                                                         (iptr->sx.val.l == 0x00020000) ||
1372                                                                         (iptr->sx.val.l == 0x00040000) ||
1373                                                                         (iptr->sx.val.l == 0x00080000) ||
1374                                                                         (iptr->sx.val.l == 0x00100000) ||
1375                                                                         (iptr->sx.val.l == 0x00200000) ||
1376                                                                         (iptr->sx.val.l == 0x00400000) ||
1377                                                                         (iptr->sx.val.l == 0x00800000) ||
1378                                                                         (iptr->sx.val.l == 0x01000000) ||
1379                                                                         (iptr->sx.val.l == 0x02000000) ||
1380                                                                         (iptr->sx.val.l == 0x04000000) ||
1381                                                                         (iptr->sx.val.l == 0x08000000) ||
1382                                                                         (iptr->sx.val.l == 0x10000000) ||
1383                                                                         (iptr->sx.val.l == 0x20000000) ||
1384                                                                         (iptr->sx.val.l == 0x40000000) ||
1385                                                                         (iptr->sx.val.l == 0x80000000))
1386                                                                 {
1387                                                                         iptr->opc = ICMD_LREMPOW2;
1388                                                                         iptr->sx.val.l -= 1;
1389                                                                         goto icmd_lconst_tail;
1390                                                                 }
1391                                                                 goto normal_LCONST;
1392 #endif /* SUPPORT_LONG_REM_POW2 */
1393
1394 #if SUPPORT_LONG_LOGICAL && SUPPORT_CONST_LOGICAL
1395
1396                                                         case ICMD_LAND:
1397                                                                 iptr->opc = ICMD_LANDCONST;
1398                                                                 goto icmd_lconst_tail;
1399
1400                                                         case ICMD_LOR:
1401                                                                 iptr->opc = ICMD_LORCONST;
1402                                                                 goto icmd_lconst_tail;
1403
1404                                                         case ICMD_LXOR:
1405                                                                 iptr->opc = ICMD_LXORCONST;
1406                                                                 goto icmd_lconst_tail;
1407 #endif /* SUPPORT_LONG_LOGICAL && SUPPORT_CONST_LOGICAL */
1408
1409 #if SUPPORT_LONG_CMP_CONST
1410                                                         case ICMD_LCMP:
1411                                                                 if ((len <= 1) || (iptr[2].sx.val.i != 0))
1412                                                                         goto normal_LCONST;
1413
1414                                                                 /* switch on the instruction after LCONST - LCMP */
1415
1416                                                                 switch (iptr[2].opc) {
1417                                                                         case ICMD_IFEQ:
1418                                                                                 iptr->opc = ICMD_IF_LEQ;
1419                                                                                 /* FALLTHROUGH */
1420
1421                                                                         icmd_lconst_lcmp_tail:
1422                                                                                 /* convert LCONST, LCMP, IFXX to IF_LXX */
1423                                                                                 iptr->dst.insindex = iptr[2].dst.insindex;
1424                                                                                 iptr[1].opc = ICMD_NOP;
1425                                                                                 iptr[2].opc = ICMD_NOP;
1426
1427                                                                                 OP1_BRANCH(TYPE_LNG);
1428                                                                                 BRANCH(tbptr, copy);
1429                                                                                 COUNT(count_pcmd_bra);
1430                                                                                 COUNT(count_pcmd_op);
1431                                                                                 break;
1432
1433                                                                         case ICMD_IFNE:
1434                                                                                 iptr->opc = ICMD_IF_LNE;
1435                                                                                 goto icmd_lconst_lcmp_tail;
1436
1437                                                                         case ICMD_IFLT:
1438                                                                                 iptr->opc = ICMD_IF_LLT;
1439                                                                                 goto icmd_lconst_lcmp_tail;
1440
1441                                                                         case ICMD_IFGT:
1442                                                                                 iptr->opc = ICMD_IF_LGT;
1443                                                                                 goto icmd_lconst_lcmp_tail;
1444
1445                                                                         case ICMD_IFLE:
1446                                                                                 iptr->opc = ICMD_IF_LLE;
1447                                                                                 goto icmd_lconst_lcmp_tail;
1448
1449                                                                         case ICMD_IFGE:
1450                                                                                 iptr->opc = ICMD_IF_LGE;
1451                                                                                 goto icmd_lconst_lcmp_tail;
1452
1453                                                                         default:
1454                                                                                 goto normal_LCONST;
1455                                                                 } /* end switch on opcode after LCONST - LCMP */
1456                                                                 break;
1457 #endif /* SUPPORT_LONG_CMP_CONST */
1458
1459 #if SUPPORT_CONST_STORE
1460                                                         case ICMD_LASTORE:
1461                                                                 IF_INTRP( goto normal_LCONST; )
1462 # if SUPPORT_CONST_STORE_ZERO_ONLY
1463                                                                 if (iptr->sx.val.l != 0)
1464                                                                         goto normal_LCONST;
1465 # endif
1466 #if SIZEOF_VOID_P == 4
1467                                                                 /* the constant must fit into a ptrint */
1468                                                                 if (iptr->sx.val.l < -0x80000000L || iptr->sx.val.l >= 0x80000000L)
1469                                                                         goto normal_LCONST;
1470 #endif
1471                                                                 /* move the constant to s3 */
1472                                                                 iptr->sx.s23.s3.constval = iptr->sx.val.l;
1473
1474                                                                 iptr->opc = ICMD_LASTORECONST;
1475                                                                 iptr->flags.bits |= INS_FLAG_CHECK;
1476                                                                 OP2_0(TYPE_ADR, TYPE_INT);
1477
1478                                                                 iptr[1].opc = ICMD_NOP;
1479                                                                 COUNT(count_pcmd_op);
1480                                                                 break;
1481
1482                                                         case ICMD_PUTSTATIC:
1483                                                         case ICMD_PUTFIELD:
1484                                                                 IF_INTRP( goto normal_LCONST; )
1485 # if SUPPORT_CONST_STORE_ZERO_ONLY
1486                                                                 if (iptr->sx.val.l != 0)
1487                                                                         goto normal_LCONST;
1488 # endif
1489 #if SIZEOF_VOID_P == 4
1490                                                                 /* the constant must fit into a ptrint */
1491                                                                 if (iptr->sx.val.l < -0x80000000L || iptr->sx.val.l >= 0x80000000L)
1492                                                                         goto normal_LCONST;
1493 #endif
1494                                                                 /* XXX check field type? */
1495
1496                                                                 /* copy the constant to s2 */
1497                                                                 /* XXX constval -> fieldconstval? */
1498                                                                 iptr->sx.s23.s2.constval = iptr->sx.val.l;
1499
1500                                                                 goto putconst_tail;
1501
1502 #endif /* SUPPORT_CONST_STORE */
1503
1504                                                         default:
1505                                                                 goto normal_LCONST;
1506                                                 } /* end switch opcode after LCONST */
1507
1508                                                 /* if we get here, the LCONST has been optimized */
1509                                                 break;
1510
1511 normal_LCONST:
1512                                                 /* the normal case of an unoptimized LCONST */
1513                                                 OP0_1(TYPE_LNG);
1514                                                 break;
1515
1516         /************************ END OF LCONST OPTIMIZATIONS *********************/
1517
1518                                         case ICMD_FCONST:
1519                                                 COUNT(count_pcmd_load);
1520                                                 OP0_1(TYPE_FLT);
1521                                                 break;
1522
1523                                         case ICMD_DCONST:
1524                                                 COUNT(count_pcmd_load);
1525                                                 OP0_1(TYPE_DBL);
1526                                                 break;
1527
1528         /************************** ACONST OPTIMIZATIONS **************************/
1529
1530                                         case ICMD_ACONST:
1531                                                 last_pei_boundary = new;
1532                                                 COUNT(count_pcmd_load);
1533 #if SUPPORT_CONST_STORE
1534                                                 IF_INTRP( goto normal_ACONST; )
1535
1536                                                 /* We can only optimize if the ACONST is resolved
1537                                                  * and there is an instruction after it. */
1538
1539                                                 if ((len == 0) || (iptr->flags.bits & INS_FLAG_UNRESOLVED))
1540                                                         goto normal_ACONST;
1541
1542                                                 switch (iptr[1].opc) {
1543                                                         case ICMD_AASTORE:
1544                                                                 /* We can only optimize for NULL values
1545                                                                  * here because otherwise a checkcast is
1546                                                                  * required. */
1547                                                                 if (iptr->sx.val.anyptr != NULL)
1548                                                                         goto normal_ACONST;
1549
1550                                                                 /* copy the constant (NULL) to s3 */
1551                                                                 iptr->sx.s23.s3.constval = 0;
1552                                                                 iptr->opc = ICMD_AASTORECONST;
1553                                                                 iptr->flags.bits |= INS_FLAG_CHECK;
1554                                                                 OP2_0(TYPE_ADR, TYPE_INT);
1555
1556                                                                 iptr[1].opc = ICMD_NOP;
1557                                                                 COUNT(count_pcmd_op);
1558                                                                 break;
1559
1560                                                         case ICMD_PUTSTATIC:
1561                                                         case ICMD_PUTFIELD:
1562 # if SUPPORT_CONST_STORE_ZERO_ONLY
1563                                                                 if (iptr->sx.val.anyptr != NULL)
1564                                                                         goto normal_ACONST;
1565 # endif
1566                                                                 /* XXX check field type? */
1567                                                                 /* copy the constant to s2 */
1568                                                                 /* XXX constval -> fieldconstval? */
1569                                                                 iptr->sx.s23.s2.constval = (ptrint) iptr->sx.val.anyptr;
1570
1571                                                                 goto putconst_tail;
1572
1573                                                         default:
1574                                                                 goto normal_ACONST;
1575                                                 }
1576
1577                                                 /* if we get here the ACONST has been optimized */
1578                                                 break;
1579
1580 normal_ACONST:
1581 #endif /* SUPPORT_CONST_STORE */
1582                                                 OP0_1(TYPE_ADR);
1583                                                 break;
1584
1585
1586                                                 /* pop 0 push 1 load */
1587
1588                                         case ICMD_ILOAD:
1589                                         case ICMD_LLOAD:
1590                                         case ICMD_FLOAD:
1591                                         case ICMD_DLOAD:
1592                                         case ICMD_ALOAD:
1593                                                 COUNT(count_load_instruction);
1594                                                 i = opcode - ICMD_ILOAD;
1595 #if defined(NEW_VAR)
1596                                                 iptr->s1.varindex = 
1597                                                         jd->local_map[iptr->s1.varindex * 5 + i];
1598                 
1599                                                 LOAD(i, iptr->s1.varindex);
1600 #else
1601
1602                                                 IF_NO_INTRP( rd->locals[iptr->s1.localindex][i].type = 
1603                                                                          i; )
1604                                                 LOAD(i, iptr->s1.localindex);
1605 #endif
1606                                                 break;
1607
1608                                                 /* pop 2 push 1 */
1609
1610                                         case ICMD_LALOAD:
1611                                         case ICMD_FALOAD:
1612                                         case ICMD_DALOAD:
1613                                         case ICMD_AALOAD:
1614                                                 last_pei_boundary = new;
1615                                                 iptr->flags.bits |= INS_FLAG_CHECK;
1616                                                 COUNT(count_check_null);
1617                                                 COUNT(count_check_bound);
1618                                                 COUNT(count_pcmd_mem);
1619                                                 OP2_1(TYPE_ADR, TYPE_INT, opcode - ICMD_IALOAD);
1620                                                 break;
1621
1622                                         case ICMD_IALOAD:
1623                                         case ICMD_BALOAD:
1624                                         case ICMD_CALOAD:
1625                                         case ICMD_SALOAD:
1626                                                 last_pei_boundary = new;
1627                                                 iptr->flags.bits |= INS_FLAG_CHECK;
1628                                                 COUNT(count_check_null);
1629                                                 COUNT(count_check_bound);
1630                                                 COUNT(count_pcmd_mem);
1631                                                 OP2_1(TYPE_ADR, TYPE_INT, TYPE_INT);
1632                                                 break;
1633
1634                                                 /* pop 0 push 0 iinc */
1635
1636                                         case ICMD_IINC:
1637                                                 STATISTICS_STACKDEPTH_DISTRIBUTION(count_store_depth);
1638
1639 #if defined(NEW_VAR)
1640                                                 iptr->s1.varindex = 
1641                                                         jd->local_map[iptr->s1.varindex * 5 + i];
1642
1643                                                 last_store_boundary[iptr->s1.varindex] = new;
1644 #else
1645                                                 last_store_boundary[iptr->s1.localindex] = new;
1646 #endif
1647
1648                                                 copy = curstack;
1649                                                 i = stackdepth - 1;
1650                                                 while (copy) {
1651                                                         if ((copy->varkind == LOCALVAR) &&
1652                                                                 (copy->varnum == iptr->s1.varindex))
1653                                                         {
1654                                                                 copy->varkind = TEMPVAR;
1655 #if defined(NEW_VAR)
1656                                                                 assert(IS_LOCALVAR(copy));
1657                                                                 SET_TEMPVAR(copy);
1658 #else
1659                                                                 copy->varnum = i;
1660 #endif
1661                                                         }
1662                                                         i--;
1663                                                         copy = copy->prev;
1664                                                 }
1665
1666 #if defined(NEW_VAR)
1667                                                 iptr->dst.varindex = iptr->s1.varindex;
1668 #else
1669                                                 iptr->dst.localindex = iptr->s1.localindex;
1670 #endif
1671                                                 break;
1672
1673                                                 /* pop 1 push 0 store */
1674
1675                                         case ICMD_ISTORE:
1676                                         case ICMD_LSTORE:
1677                                         case ICMD_FSTORE:
1678                                         case ICMD_DSTORE:
1679                                         case ICMD_ASTORE:
1680                                                 REQUIRE_1;
1681
1682                                                 i = opcode - ICMD_ISTORE; /* type */
1683 #if defined(NEW_VAR)
1684                                                 j = iptr->dst.varindex = 
1685                                                         jd->local_map[iptr->dst.varindex * 5 + i];
1686
1687 #else
1688                                                 j = iptr->dst.localindex; /* index */
1689
1690                                                 IF_NO_INTRP( rd->locals[j][i].type = i; )
1691 #endif
1692
1693 #if defined(ENABLE_STATISTICS)
1694                                                 if (opt_stat) {
1695                                                         count_pcmd_store++;
1696                                                         i = new - curstack;
1697                                                         if (i >= 20)
1698                                                                 count_store_length[20]++;
1699                                                         else
1700                                                                 count_store_length[i]++;
1701                                                         i = stackdepth - 1;
1702                                                         if (i >= 10)
1703                                                                 count_store_depth[10]++;
1704                                                         else
1705                                                                 count_store_depth[i]++;
1706                                                 }
1707 #endif
1708                                                 /* check for conflicts as described in Figure 5.2 */
1709
1710                                                 copy = curstack->prev;
1711                                                 i = stackdepth - 2;
1712                                                 while (copy) {
1713                                                         if ((copy->varkind == LOCALVAR) &&
1714                                                                 (copy->varnum == j))
1715                                                         {
1716                                                                 copy->varkind = TEMPVAR;
1717 #if defined(NEW_VAR)
1718                                                                 assert(IS_LOCALVAR(copy));
1719                                                                 SET_TEMPVAR(copy);
1720 #else
1721                                                                 copy->varnum = i;
1722 #endif
1723                                                         }
1724                                                         i--;
1725                                                         copy = copy->prev;
1726                                                 }
1727
1728                                                 /* if the variable is already coalesced, don't bother */
1729
1730                                                 if (IS_OUTVAR(curstack)
1731                                                         || (curstack->varkind == LOCALVAR 
1732                                                                 && curstack->varnum != j))
1733                                                         goto store_tail;
1734
1735                                                 /* there is no STORE Lj while curstack is live */
1736
1737                                                 if (curstack < last_store_boundary[j])
1738                                                         goto assume_conflict;
1739
1740                                                 /* there is no PEI while curstack is live */
1741
1742                                                 if (curstack < last_pei_boundary)
1743                                                         goto assume_conflict;
1744
1745                                                 /*there is no non-consuming USE while curstack is live*/
1746
1747                                                 if (curstack < last_dup_boundary)
1748                                                         goto assume_conflict;
1749
1750                                                 /* there is no DEF LOCALVAR(j) while curstack is live */
1751
1752                                                 copy = new; /* most recent stackslot created + 1 */
1753                                                 while (--copy > curstack) {
1754                                                         if (copy->varkind == LOCALVAR && copy->varnum == j)
1755                                                                 goto assume_conflict;
1756                                                 }
1757
1758                                                 /* coalesce the temporary variable with Lj */
1759 #if defined(NEW_VAR)
1760                                                 assert( (CURKIND == TEMPVAR) || (CURKIND == UNDEFVAR));
1761                                                 assert(!IS_LOCALVAR(curstack));
1762                                                 assert(!IS_OUTVAR(curstack));
1763                                                 assert(!IS_PREALLOC(curstack));
1764
1765                                                 RELEASE_INDEX(curstack);
1766 #endif
1767                                                 curstack->varkind = LOCALVAR;
1768                                                 curstack->varnum = j;
1769                                                 goto store_tail;
1770
1771                                                 /* revert the coalescing, if it has been done earlier */
1772 assume_conflict:
1773                                                 if ((curstack->varkind == LOCALVAR)
1774                                                         && (curstack->varnum == j))
1775                                                 {
1776                                                         curstack->varkind = TEMPVAR;
1777 #if defined(NEW_VAR)
1778                                                         assert(IS_LOCALVAR(curstack));
1779                                                         SET_TEMPVAR(curstack);
1780 #else
1781                                                         curstack->varnum = stackdepth-1;
1782 #endif
1783                                                 }
1784
1785                                                 /* remember the stack boundary at this store */
1786 store_tail:
1787                                                 last_store_boundary[j] = new;
1788
1789                                                 STORE(opcode - ICMD_ISTORE, j);
1790                                                 break;
1791
1792                                         /* pop 3 push 0 */
1793
1794                                         case ICMD_AASTORE:
1795                                                 last_pei_boundary = new;
1796                                                 iptr->flags.bits |= INS_FLAG_CHECK;
1797                                                 COUNT(count_check_null);
1798                                                 COUNT(count_check_bound);
1799                                                 COUNT(count_pcmd_mem);
1800
1801                                                 bte = builtintable_get_internal(BUILTIN_canstore);
1802                                                 md = bte->md;
1803
1804                                                 if (md->memuse > rd->memuse)
1805                                                         rd->memuse = md->memuse;
1806                                                 if (md->argintreguse > rd->argintreguse)
1807                                                         rd->argintreguse = md->argintreguse;
1808                                                 /* XXX non-leaf method? */
1809
1810                                                 /* make all stack variables saved */
1811
1812                                                 copy = curstack;
1813                                                 while (copy) {
1814 #if defined(NEW_VAR)
1815                                                         jd->var[copy->varnum].flags |= SAVEDVAR;
1816                                                         /* in case copy->varnum is/will be a LOCALVAR */
1817                                                         /* once and set back to a non LOCALVAR        */
1818                                                         /* the correct SAVEDVAR flag has to be        */
1819                                                         /* remembered in copy->flags, too             */
1820 #endif
1821                                                         copy->flags |= SAVEDVAR;
1822                                                         copy = copy->prev;
1823                                                 }
1824
1825                                                 OP3_0(TYPE_ADR, TYPE_INT, TYPE_ADR);
1826                                                 break;
1827
1828
1829                                         case ICMD_LASTORE:
1830                                         case ICMD_FASTORE:
1831                                         case ICMD_DASTORE:
1832                                                 last_pei_boundary = new;
1833                                                 iptr->flags.bits |= INS_FLAG_CHECK;
1834                                                 COUNT(count_check_null);
1835                                                 COUNT(count_check_bound);
1836                                                 COUNT(count_pcmd_mem);
1837                                                 OP3_0(TYPE_ADR, TYPE_INT, opcode - ICMD_IASTORE);
1838                                                 break;
1839
1840                                         case ICMD_IASTORE:
1841                                         case ICMD_BASTORE:
1842                                         case ICMD_CASTORE:
1843                                         case ICMD_SASTORE:
1844                                                 last_pei_boundary = new;
1845                                                 iptr->flags.bits |= INS_FLAG_CHECK;
1846                                                 COUNT(count_check_null);
1847                                                 COUNT(count_check_bound);
1848                                                 COUNT(count_pcmd_mem);
1849                                                 OP3_0(TYPE_ADR, TYPE_INT, TYPE_INT);
1850                                                 break;
1851
1852                                                 /* pop 1 push 0 */
1853
1854                                         case ICMD_POP:
1855 #ifdef ENABLE_VERIFIER
1856                                                 if (opt_verify) {
1857                                                         REQUIRE_1;
1858                                                         if (IS_2_WORD_TYPE(curstack->type))
1859                                                                 goto throw_stack_category_error;
1860                                                 }
1861 #endif
1862                                                 OP1_0_ANY;
1863                                                 break;
1864
1865                                         case ICMD_IRETURN:
1866                                         case ICMD_LRETURN:
1867                                         case ICMD_FRETURN:
1868                                         case ICMD_DRETURN:
1869                                         case ICMD_ARETURN:
1870                                                 last_pei_boundary = new;
1871                                                 IF_JIT( md_return_alloc(jd, curstack); )
1872                                                 COUNT(count_pcmd_return);
1873                                                 OP1_0(opcode - ICMD_IRETURN);
1874                                                 superblockend = true;
1875                                                 break;
1876
1877                                         case ICMD_ATHROW:
1878                                                 last_pei_boundary = new;
1879                                                 COUNT(count_check_null);
1880                                                 OP1_0(TYPE_ADR);
1881                                                 STACKRESET;
1882                                                 superblockend = true;
1883                                                 break;
1884
1885                                         case ICMD_PUTSTATIC:
1886                                                 last_pei_boundary = new;
1887                                                 COUNT(count_pcmd_mem);
1888                                                 INSTRUCTION_GET_FIELDREF(iptr, fmiref);
1889                                                 OP1_0(fmiref->parseddesc.fd->type);
1890                                                 break;
1891
1892                                                 /* pop 1 push 0 branch */
1893
1894                                         case ICMD_IFNULL:
1895                                         case ICMD_IFNONNULL:
1896                                                 COUNT(count_pcmd_bra);
1897                                                 OP1_BRANCH(TYPE_ADR);
1898                                                 BRANCH(tbptr, copy);
1899                                                 break;
1900
1901                                         case ICMD_IFEQ:
1902                                         case ICMD_IFNE:
1903                                         case ICMD_IFLT:
1904                                         case ICMD_IFGE:
1905                                         case ICMD_IFGT:
1906                                         case ICMD_IFLE:
1907                                                 COUNT(count_pcmd_bra);
1908                                                 /* iptr->sx.val.i is set implicitly in parse by
1909                                                    clearing the memory or from IF_ICMPxx
1910                                                    optimization. */
1911
1912                                                 OP1_BRANCH(TYPE_INT);
1913 /*                                              iptr->sx.val.i = 0; */
1914                                                 BRANCH(tbptr, copy);
1915                                                 break;
1916
1917                                                 /* pop 0 push 0 branch */
1918
1919                                         case ICMD_GOTO:
1920                                                 COUNT(count_pcmd_bra);
1921                                                 OP0_BRANCH;
1922                                                 BRANCH(tbptr, copy);
1923                                                 superblockend = true;
1924                                                 break;
1925
1926                                                 /* pop 1 push 0 table branch */
1927
1928                                         case ICMD_TABLESWITCH:
1929                                                 COUNT(count_pcmd_table);
1930                                                 OP1_BRANCH(TYPE_INT);
1931
1932                                                 table = iptr->dst.table;
1933                                                 BRANCH_TARGET(*table, tbptr, copy);
1934                                                 table++;
1935
1936                                                 i = iptr->sx.s23.s3.tablehigh
1937                                                   - iptr->sx.s23.s2.tablelow + 1;
1938
1939                                                 while (--i >= 0) {
1940                                                         BRANCH_TARGET(*table, tbptr, copy);
1941                                                         table++;
1942                                                 }
1943                                                 superblockend = true;
1944                                                 break;
1945
1946                                                 /* pop 1 push 0 table branch */
1947
1948                                         case ICMD_LOOKUPSWITCH:
1949                                                 COUNT(count_pcmd_table);
1950                                                 OP1_BRANCH(TYPE_INT);
1951
1952                                                 BRANCH_TARGET(iptr->sx.s23.s3.lookupdefault, tbptr, copy);
1953
1954                                                 lookup = iptr->dst.lookup;
1955
1956                                                 i = iptr->sx.s23.s2.lookupcount;
1957
1958                                                 while (--i >= 0) {
1959                                                         BRANCH_TARGET(lookup->target, tbptr, copy);
1960                                                         lookup++;
1961                                                 }
1962                                                 superblockend = true;
1963                                                 break;
1964
1965                                         case ICMD_MONITORENTER:
1966                                         case ICMD_MONITOREXIT:
1967                                                 last_pei_boundary = new;
1968                                                 COUNT(count_check_null);
1969                                                 OP1_0(TYPE_ADR);
1970                                                 break;
1971
1972                                                 /* pop 2 push 0 branch */
1973
1974                                         case ICMD_IF_ICMPEQ:
1975                                         case ICMD_IF_ICMPNE:
1976                                         case ICMD_IF_ICMPLT:
1977                                         case ICMD_IF_ICMPGE:
1978                                         case ICMD_IF_ICMPGT:
1979                                         case ICMD_IF_ICMPLE:
1980                                                 COUNT(count_pcmd_bra);
1981                                                 OP2_BRANCH(TYPE_INT, TYPE_INT);
1982                                                 BRANCH(tbptr, copy);
1983                                                 break;
1984
1985                                         case ICMD_IF_ACMPEQ:
1986                                         case ICMD_IF_ACMPNE:
1987                                                 COUNT(count_pcmd_bra);
1988                                                 OP2_BRANCH(TYPE_ADR, TYPE_ADR);
1989                                                 BRANCH(tbptr, copy);
1990                                                 break;
1991
1992                                                 /* pop 2 push 0 */
1993
1994                                         case ICMD_PUTFIELD:
1995                                                 last_pei_boundary = new;
1996                                                 COUNT(count_check_null);
1997                                                 COUNT(count_pcmd_mem);
1998                                                 INSTRUCTION_GET_FIELDREF(iptr, fmiref);
1999                                                 OP2_0(TYPE_ADR, fmiref->parseddesc.fd->type);
2000                                                 break;
2001
2002                                         case ICMD_POP2:
2003                                                 REQUIRE_1;
2004                                                 if (!IS_2_WORD_TYPE(curstack->type)) {
2005                                                         /* ..., cat1 */
2006 #ifdef ENABLE_VERIFIER
2007                                                         if (opt_verify) {
2008                                                                 REQUIRE_2;
2009                                                                 if (IS_2_WORD_TYPE(curstack->prev->type))
2010                                                                         goto throw_stack_category_error;
2011                                                         }
2012 #endif
2013                                                         OP2_0_ANY_ANY; /* pop two slots */
2014                                                 }
2015                                                 else {
2016                                                         iptr->opc = ICMD_POP;
2017                                                         OP1_0_ANY; /* pop one (two-word) slot */
2018                                                 }
2019                                                 break;
2020
2021                                                 /* pop 0 push 1 dup */
2022
2023                                         case ICMD_DUP:
2024 #ifdef ENABLE_VERIFIER
2025                                                 if (opt_verify) {
2026                                                         REQUIRE_1;
2027                                                         if (IS_2_WORD_TYPE(curstack->type))
2028                                                                 goto throw_stack_category_error;
2029                                                 }
2030 #endif
2031                                                 COUNT(count_dup_instruction);
2032
2033 icmd_DUP:
2034                                                 USE_S1_ANY; /* XXX live through */
2035                                                 /* DUP_SLOT(iptr->s1.var); */
2036                                                 DUP_SLOT(curstack);
2037                                                 last_dup_boundary = new - 1;
2038 #if defined(NEW_VAR)
2039                                                 iptr->dst.varindex = curstack->varnum;
2040 #else
2041                                                 iptr->dst.var = curstack;
2042 #endif
2043                                                 stackdepth++;
2044                                                 break;
2045
2046                                         case ICMD_DUP2:
2047                                                 REQUIRE_1;
2048                                                 if (IS_2_WORD_TYPE(curstack->type)) {
2049                                                         /* ..., cat2 */
2050                                                         iptr->opc = ICMD_DUP;
2051                                                         goto icmd_DUP;
2052                                                 }
2053                                                 else {
2054                                                         REQUIRE_2;
2055                                                         /* ..., ????, cat1 */
2056 #ifdef ENABLE_VERIFIER
2057                                                         if (opt_verify) {
2058                                                                 if (IS_2_WORD_TYPE(curstack->prev->type))
2059                                                                         goto throw_stack_category_error;
2060                                                         }
2061 #endif
2062 #if defined(NEW_VAR)
2063                                                         iptr->dst.dupslots = DMNEW(s4, 2 + 2);
2064                                                                                  /* XXX live through */
2065                                                         iptr->dst.dupslots[0] = curstack->prev->varnum;
2066                                                                            /* XXX live through */
2067                                                         iptr->dst.dupslots[1] = curstack->varnum;
2068                                                         copy = curstack;
2069
2070                                                         DUP_SLOT(copy->prev);
2071                                                         iptr->dst.dupslots[2+0] = curstack->varnum;
2072                                                         DUP_SLOT(copy);
2073                                                         iptr->dst.dupslots[2+1] = curstack->varnum;
2074 #else
2075                                                         iptr->dst.dupslots = DMNEW(stackptr, 2 + 2);
2076                                                         iptr->dst.dupslots[0] = curstack->prev; /* XXX live through */
2077                                                         iptr->dst.dupslots[1] = curstack;       /* XXX live through */
2078
2079                                                         DUP_SLOT(iptr->dst.dupslots[0]);
2080                                                         iptr->dst.dupslots[2+0] = curstack;
2081                                                         DUP_SLOT(iptr->dst.dupslots[1]);
2082                                                         iptr->dst.dupslots[2+1] = curstack;
2083 #endif
2084                                                         last_dup_boundary = new;
2085                                                         stackdepth += 2;
2086                                                 }
2087                                                 break;
2088
2089                                                 /* pop 2 push 3 dup */
2090
2091                                         case ICMD_DUP_X1:
2092 #ifdef ENABLE_VERIFIER
2093                                                 if (opt_verify) {
2094                                                         REQUIRE_2;
2095                                                         if (IS_2_WORD_TYPE(curstack->type) ||
2096                                                                 IS_2_WORD_TYPE(curstack->prev->type))
2097                                                                         goto throw_stack_category_error;
2098                                                 }
2099 #endif
2100
2101 icmd_DUP_X1:
2102 #if defined(NEW_VAR)
2103                                                 iptr->dst.dupslots = DMNEW(int, 2 + 3);
2104                                                 iptr->dst.dupslots[0] = curstack->prev->varnum;
2105                                                 iptr->dst.dupslots[1] = curstack->varnum;
2106                                                 copy = curstack;
2107                                                 POPANY; POPANY;
2108
2109                                                 DUP_SLOT(copy);
2110                                                 iptr->dst.dupslots[2+0] = curstack->varnum;
2111                                                 DUP_SLOT(copy->prev);
2112                                                 iptr->dst.dupslots[2+1] = curstack->varnum;
2113                                                 DUP_SLOT(copy);
2114                                                 iptr->dst.dupslots[2+2] = curstack->varnum;
2115 #else
2116                                                 iptr->dst.dupslots = DMNEW(stackptr, 2 + 3);
2117                                                 iptr->dst.dupslots[0] = curstack->prev;
2118                                                 iptr->dst.dupslots[1] = curstack;
2119                                                 POPANY; POPANY;
2120
2121                                                 DUP_SLOT(iptr->dst.dupslots[1]);
2122                                                 iptr->dst.dupslots[2+0] = curstack;
2123                                                 DUP_SLOT(iptr->dst.dupslots[0]);
2124                                                 iptr->dst.dupslots[2+1] = curstack;
2125                                                 DUP_SLOT(iptr->dst.dupslots[1]);
2126                                                 iptr->dst.dupslots[2+2] = curstack;
2127 #endif
2128                                                 last_dup_boundary = new;
2129                                                 stackdepth++;
2130                                                 break;
2131
2132                                         case ICMD_DUP2_X1:
2133                                                 REQUIRE_2;
2134                                                 if (IS_2_WORD_TYPE(curstack->type)) {
2135                                                         /* ..., ????, cat2 */
2136 #ifdef ENABLE_VERIFIER
2137                                                         if (opt_verify) {
2138                                                                 if (IS_2_WORD_TYPE(curstack->prev->type))
2139                                                                         goto throw_stack_category_error;
2140                                                         }
2141 #endif
2142                                                         iptr->opc = ICMD_DUP_X1;
2143                                                         goto icmd_DUP_X1;
2144                                                 }
2145                                                 else {
2146                                                         /* ..., ????, cat1 */
2147 #ifdef ENABLE_VERIFIER
2148                                                         if (opt_verify) {
2149                                                                 REQUIRE_3;
2150                                                                 if (IS_2_WORD_TYPE(curstack->prev->type)
2151                                                                         || IS_2_WORD_TYPE(curstack->prev->prev->type))
2152                                                                                 goto throw_stack_category_error;
2153                                                         }
2154 #endif
2155
2156 icmd_DUP2_X1:
2157 #if defined(NEW_VAR)
2158                                                         iptr->dst.dupslots = DMNEW(s4, 3 + 5);
2159                                                         iptr->dst.dupslots[0] =curstack->prev->prev->varnum;
2160                                                         iptr->dst.dupslots[1] = curstack->prev->varnum;
2161                                                         iptr->dst.dupslots[2] = curstack->varnum;
2162                                                         copy = curstack;
2163                                                         POPANY; POPANY; POPANY;
2164
2165                                                         DUP_SLOT(copy->prev);
2166                                                         iptr->dst.dupslots[3+0] = curstack->varnum;
2167                                                         DUP_SLOT(copy);
2168                                                         iptr->dst.dupslots[3+1] = curstack->varnum;
2169                                                         DUP_SLOT(copy->prev->prev);
2170                                                         iptr->dst.dupslots[3+2] = curstack->varnum;
2171                                                         DUP_SLOT(copy->prev);
2172                                                         iptr->dst.dupslots[3+3] = curstack->varnum;
2173                                                         DUP_SLOT(copy);
2174                                                         iptr->dst.dupslots[3+4] = curstack->varnum;
2175 #else
2176                                                         iptr->dst.dupslots = DMNEW(stackptr, 3 + 5);
2177                                                         iptr->dst.dupslots[0] = curstack->prev->prev;
2178                                                         iptr->dst.dupslots[1] = curstack->prev;
2179                                                         iptr->dst.dupslots[2] = curstack;
2180                                                         POPANY; POPANY; POPANY;
2181
2182                                                         DUP_SLOT(iptr->dst.dupslots[1]);
2183                                                         iptr->dst.dupslots[3+0] = curstack;
2184                                                         DUP_SLOT(iptr->dst.dupslots[2]);
2185                                                         iptr->dst.dupslots[3+1] = curstack;
2186                                                         DUP_SLOT(iptr->dst.dupslots[0]);
2187                                                         iptr->dst.dupslots[3+2] = curstack;
2188                                                         DUP_SLOT(iptr->dst.dupslots[1]);
2189                                                         iptr->dst.dupslots[3+3] = curstack;
2190                                                         DUP_SLOT(iptr->dst.dupslots[2]);
2191                                                         iptr->dst.dupslots[3+4] = curstack;
2192 #endif
2193                                                         last_dup_boundary = new;
2194                                                         stackdepth += 2;
2195                                                 }
2196                                                 break;
2197
2198                                                 /* pop 3 push 4 dup */
2199
2200                                         case ICMD_DUP_X2:
2201                                                 REQUIRE_2;
2202                                                 if (IS_2_WORD_TYPE(curstack->prev->type)) {
2203                                                         /* ..., cat2, ???? */
2204 #ifdef ENABLE_VERIFIER
2205                                                         if (opt_verify) {
2206                                                                 if (IS_2_WORD_TYPE(curstack->type))
2207                                                                         goto throw_stack_category_error;
2208                                                         }
2209 #endif
2210                                                         iptr->opc = ICMD_DUP_X1;
2211                                                         goto icmd_DUP_X1;
2212                                                 }
2213                                                 else {
2214                                                         /* ..., cat1, ???? */
2215 #ifdef ENABLE_VERIFIER
2216                                                         if (opt_verify) {
2217                                                                 REQUIRE_3;
2218                                                                 if (IS_2_WORD_TYPE(curstack->type)
2219                                                                         || IS_2_WORD_TYPE(curstack->prev->prev->type))
2220                                                                                         goto throw_stack_category_error;
2221                                                         }
2222 #endif
2223 icmd_DUP_X2:
2224 #if defined(NEW_VAR)
2225                                                         iptr->dst.dupslots = DMNEW(s4, 3 + 4);
2226                                                         iptr->dst.dupslots[0] =curstack->prev->prev->varnum;
2227                                                         iptr->dst.dupslots[1] = curstack->prev->varnum;
2228                                                         iptr->dst.dupslots[2] = curstack->varnum;
2229                                                         copy = curstack;
2230                                                         POPANY; POPANY; POPANY;
2231
2232                                                         DUP_SLOT(copy);
2233                                                         iptr->dst.dupslots[3+0] = curstack->varnum;
2234                                                         DUP_SLOT(copy->prev->prev);
2235                                                         iptr->dst.dupslots[3+1] = curstack->varnum;
2236                                                         DUP_SLOT(copy->prev);
2237                                                         iptr->dst.dupslots[3+2] = curstack->varnum;
2238                                                         DUP_SLOT(copy);
2239                                                         iptr->dst.dupslots[3+3] = curstack->varnum;
2240 #else
2241                                                         iptr->dst.dupslots = DMNEW(stackptr, 3 + 4);
2242                                                         iptr->dst.dupslots[0] = curstack->prev->prev;
2243                                                         iptr->dst.dupslots[1] = curstack->prev;
2244                                                         iptr->dst.dupslots[2] = curstack;
2245                                                         POPANY; POPANY; POPANY;
2246
2247                                                         DUP_SLOT(iptr->dst.dupslots[2]);
2248                                                         iptr->dst.dupslots[3+0] = curstack;
2249                                                         DUP_SLOT(iptr->dst.dupslots[0]);
2250                                                         iptr->dst.dupslots[3+1] = curstack;
2251                                                         DUP_SLOT(iptr->dst.dupslots[1]);
2252                                                         iptr->dst.dupslots[3+2] = curstack;
2253                                                         DUP_SLOT(iptr->dst.dupslots[2]);
2254                                                         iptr->dst.dupslots[3+3] = curstack;
2255 #endif
2256                                                         last_dup_boundary = new;
2257                                                         stackdepth++;
2258                                                 }
2259                                                 break;
2260
2261                                         case ICMD_DUP2_X2:
2262                                                 REQUIRE_2;
2263                                                 if (IS_2_WORD_TYPE(curstack->type)) {
2264                                                         /* ..., ????, cat2 */
2265                                                         if (IS_2_WORD_TYPE(curstack->prev->type)) {
2266                                                                 /* ..., cat2, cat2 */
2267                                                                 iptr->opc = ICMD_DUP_X1;
2268                                                                 goto icmd_DUP_X1;
2269                                                         }
2270                                                         else {
2271                                                                 /* ..., cat1, cat2 */
2272 #ifdef ENABLE_VERIFIER
2273                                                                 if (opt_verify) {
2274                                                                         REQUIRE_3;
2275                                                                         if (IS_2_WORD_TYPE(curstack->prev->prev->type))
2276                                                                                         goto throw_stack_category_error;
2277                                                                 }
2278 #endif
2279                                                                 iptr->opc = ICMD_DUP_X2;
2280                                                                 goto icmd_DUP_X2;
2281                                                         }
2282                                                 }
2283
2284                                                 REQUIRE_3;
2285                                                 /* ..., ????, ????, cat1 */
2286
2287                                                 if (IS_2_WORD_TYPE(curstack->prev->prev->type)) {
2288                                                         /* ..., cat2, ????, cat1 */
2289 #ifdef ENABLE_VERIFIER
2290                                                         if (opt_verify) {
2291                                                                 if (IS_2_WORD_TYPE(curstack->prev->type))
2292                                                                         goto throw_stack_category_error;
2293                                                         }
2294 #endif
2295                                                         iptr->opc = ICMD_DUP2_X1;
2296                                                         goto icmd_DUP2_X1;
2297                                                 }
2298                                                 else {
2299                                                         /* ..., cat1, ????, cat1 */
2300 #ifdef ENABLE_VERIFIER
2301                                                         if (opt_verify) {
2302                                                                 REQUIRE_4;
2303                                                                 if (IS_2_WORD_TYPE(curstack->prev->type)
2304                                                                         || IS_2_WORD_TYPE(curstack->prev->prev->prev->type))
2305                                                                         goto throw_stack_category_error;
2306                                                         }
2307 #endif
2308
2309 #if defined(NEW_VAR)
2310                                                         iptr->dst.dupslots = DMNEW(s4, 4 + 6);
2311                                                         iptr->dst.dupslots[0] = 
2312                                                                 curstack->prev->prev->prev->varnum;
2313                                                         iptr->dst.dupslots[1] = 
2314                                                                 curstack->prev->prev->varnum;
2315                                                         iptr->dst.dupslots[2] = curstack->prev->varnum;
2316                                                         iptr->dst.dupslots[3] = curstack->varnum;
2317                                                         copy = curstack;
2318                                                         POPANY; POPANY; POPANY; POPANY;
2319
2320                                                         DUP_SLOT(copy->prev);
2321                                                         iptr->dst.dupslots[4+0] = curstack->varnum;
2322                                                         DUP_SLOT(copy);
2323                                                         iptr->dst.dupslots[4+1] = curstack->varnum;
2324                                                         DUP_SLOT(copy->prev->prev->prev);
2325                                                         iptr->dst.dupslots[4+2] = curstack->varnum;
2326                                                         DUP_SLOT(copy->prev->prev);
2327                                                         iptr->dst.dupslots[4+3] = curstack->varnum;
2328                                                         DUP_SLOT(copy->prev);
2329                                                         iptr->dst.dupslots[4+4] = curstack->varnum;
2330                                                         DUP_SLOT(copy);
2331                                                         iptr->dst.dupslots[4+5] = curstack->varnum;
2332 #else
2333                                                         iptr->dst.dupslots = DMNEW(stackptr, 4 + 6);
2334                                                         iptr->dst.dupslots[0] = curstack->prev->prev->prev;
2335                                                         iptr->dst.dupslots[1] = curstack->prev->prev;
2336                                                         iptr->dst.dupslots[2] = curstack->prev;
2337                                                         iptr->dst.dupslots[3] = curstack;
2338                                                         POPANY; POPANY; POPANY; POPANY;
2339
2340                                                         DUP_SLOT(iptr->dst.dupslots[2]);
2341                                                         iptr->dst.dupslots[4+0] = curstack;
2342                                                         DUP_SLOT(iptr->dst.dupslots[3]);
2343                                                         iptr->dst.dupslots[4+1] = curstack;
2344                                                         DUP_SLOT(iptr->dst.dupslots[0]);
2345                                                         iptr->dst.dupslots[4+2] = curstack;
2346                                                         DUP_SLOT(iptr->dst.dupslots[1]);
2347                                                         iptr->dst.dupslots[4+3] = curstack;
2348                                                         DUP_SLOT(iptr->dst.dupslots[2]);
2349                                                         iptr->dst.dupslots[4+4] = curstack;
2350                                                         DUP_SLOT(iptr->dst.dupslots[3]);
2351                                                         iptr->dst.dupslots[4+5] = curstack;
2352 #endif
2353                                                         last_dup_boundary = new;
2354                                                         stackdepth += 2;
2355                                                 }
2356                                                 break;
2357
2358                                                 /* pop 2 push 2 swap */
2359
2360                                         case ICMD_SWAP:
2361 #ifdef ENABLE_VERIFIER
2362                                                 if (opt_verify) {
2363                                                         REQUIRE_2;
2364                                                         if (IS_2_WORD_TYPE(curstack->type)
2365                                                                 || IS_2_WORD_TYPE(curstack->prev->type))
2366                                                                 goto throw_stack_category_error;
2367                                                 }
2368 #endif
2369
2370 #if defined(NEW_VAR)
2371                                                 iptr->dst.dupslots = DMNEW(s4, 2 + 2);
2372                                                 iptr->dst.dupslots[0] = curstack->prev->varnum;
2373                                                 iptr->dst.dupslots[1] = curstack->varnum;
2374                                                 copy = curstack;
2375                                                 POPANY; POPANY;
2376
2377                                                 DUP_SLOT(copy);
2378                                                 iptr->dst.dupslots[2+0] = curstack->varnum;
2379                                                 DUP_SLOT(copy->prev);
2380                                                 iptr->dst.dupslots[2+1] = curstack->varnum;
2381 #else
2382                                                 iptr->dst.dupslots = DMNEW(stackptr, 2 + 2);
2383                                                 iptr->dst.dupslots[0] = curstack->prev;
2384                                                 iptr->dst.dupslots[1] = curstack;
2385                                                 POPANY; POPANY;
2386
2387                                                 DUP_SLOT(iptr->dst.dupslots[1]);
2388                                                 iptr->dst.dupslots[2+0] = curstack;
2389                                                 DUP_SLOT(iptr->dst.dupslots[0]);
2390                                                 iptr->dst.dupslots[2+1] = curstack;
2391 #endif
2392                                                 last_dup_boundary = new;
2393                                                 break;
2394
2395                                                 /* pop 2 push 1 */
2396
2397                                         case ICMD_IDIV:
2398                                         case ICMD_IREM:
2399                                                 last_pei_boundary = new;
2400 #if !SUPPORT_DIVISION
2401                                                 bte = iptr->sx.s23.s3.bte;
2402                                                 md = bte->md;
2403
2404                                                 if (md->memuse > rd->memuse)
2405                                                         rd->memuse = md->memuse;
2406                                                 if (md->argintreguse > rd->argintreguse)
2407                                                         rd->argintreguse = md->argintreguse;
2408
2409                                                 /* make all stack variables saved */
2410
2411                                                 copy = curstack;
2412                                                 while (copy) {
2413 #if defined(NEW_VAR)
2414                                                         jd->var[copy->varnum].flags |= SAVEDVAR;
2415 #endif
2416                                                         copy->flags |= SAVEDVAR;
2417                                                         copy = copy->prev;
2418                                                 }
2419                                                 /* FALLTHROUGH */
2420
2421 #endif /* !SUPPORT_DIVISION */
2422
2423                                         case ICMD_ISHL:
2424                                         case ICMD_ISHR:
2425                                         case ICMD_IUSHR:
2426                                         case ICMD_IADD:
2427                                         case ICMD_ISUB:
2428                                         case ICMD_IMUL:
2429                                         case ICMD_IAND:
2430                                         case ICMD_IOR:
2431                                         case ICMD_IXOR:
2432                                                 COUNT(count_pcmd_op);
2433                                                 OP2_1(TYPE_INT, TYPE_INT, TYPE_INT);
2434                                                 break;
2435
2436                                         case ICMD_LDIV:
2437                                         case ICMD_LREM:
2438                                                 last_pei_boundary = new;
2439 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
2440                                                 bte = iptr->sx.s23.s3.bte;
2441                                                 md = bte->md;
2442
2443                                                 if (md->memuse > rd->memuse)
2444                                                         rd->memuse = md->memuse;
2445                                                 if (md->argintreguse > rd->argintreguse)
2446                                                         rd->argintreguse = md->argintreguse;
2447                                                 /* XXX non-leaf method? */
2448
2449                                                 /* make all stack variables saved */
2450
2451                                                 copy = curstack;
2452                                                 while (copy) {
2453 #if defined(NEW_VAR)
2454                                                         jd->var[copy->varnum].flags |= SAVEDVAR;
2455 #endif
2456                                                         copy->flags |= SAVEDVAR;
2457                                                         copy = copy->prev;
2458                                                 }
2459                                                 /* FALLTHROUGH */
2460
2461 #endif /* !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV) */
2462
2463                                         case ICMD_LMUL:
2464                                         case ICMD_LADD:
2465                                         case ICMD_LSUB:
2466 #if SUPPORT_LONG_LOGICAL
2467                                         case ICMD_LAND:
2468                                         case ICMD_LOR:
2469                                         case ICMD_LXOR:
2470 #endif /* SUPPORT_LONG_LOGICAL */
2471                                                 COUNT(count_pcmd_op);
2472                                                 OP2_1(TYPE_LNG, TYPE_LNG, TYPE_LNG);
2473                                                 break;
2474
2475                                         case ICMD_LSHL:
2476                                         case ICMD_LSHR:
2477                                         case ICMD_LUSHR:
2478                                                 COUNT(count_pcmd_op);
2479                                                 OP2_1(TYPE_LNG, TYPE_INT, TYPE_LNG);
2480                                                 break;
2481
2482                                         case ICMD_FADD:
2483                                         case ICMD_FSUB:
2484                                         case ICMD_FMUL:
2485                                         case ICMD_FDIV:
2486                                         case ICMD_FREM:
2487                                                 COUNT(count_pcmd_op);
2488                                                 OP2_1(TYPE_FLT, TYPE_FLT, TYPE_FLT);
2489                                                 break;
2490
2491                                         case ICMD_DADD:
2492                                         case ICMD_DSUB:
2493                                         case ICMD_DMUL:
2494                                         case ICMD_DDIV:
2495                                         case ICMD_DREM:
2496                                                 COUNT(count_pcmd_op);
2497                                                 OP2_1(TYPE_DBL, TYPE_DBL, TYPE_DBL);
2498                                                 break;
2499
2500                                         case ICMD_LCMP:
2501                                                 COUNT(count_pcmd_op);
2502 #if SUPPORT_LONG_CMP_CONST
2503                                                 if ((len == 0) || (iptr[1].sx.val.i != 0))
2504                                                         goto normal_LCMP;
2505
2506                                                 switch (iptr[1].opc) {
2507                                                 case ICMD_IFEQ:
2508                                                         iptr->opc = ICMD_IF_LCMPEQ;
2509                                                 icmd_lcmp_if_tail:
2510                                                         iptr->dst.insindex = iptr[1].dst.insindex;
2511                                                         iptr[1].opc = ICMD_NOP;
2512
2513                                                         OP2_BRANCH(TYPE_LNG, TYPE_LNG);
2514                                                         BRANCH(tbptr, copy);
2515
2516                                                         COUNT(count_pcmd_bra);
2517                                                         break;
2518                                                 case ICMD_IFNE:
2519                                                         iptr->opc = ICMD_IF_LCMPNE;
2520                                                         goto icmd_lcmp_if_tail;
2521                                                 case ICMD_IFLT:
2522                                                         iptr->opc = ICMD_IF_LCMPLT;
2523                                                         goto icmd_lcmp_if_tail;
2524                                                 case ICMD_IFGT:
2525                                                         iptr->opc = ICMD_IF_LCMPGT;
2526                                                         goto icmd_lcmp_if_tail;
2527                                                 case ICMD_IFLE:
2528                                                         iptr->opc = ICMD_IF_LCMPLE;
2529                                                         goto icmd_lcmp_if_tail;
2530                                                 case ICMD_IFGE:
2531                                                         iptr->opc = ICMD_IF_LCMPGE;
2532                                                         goto icmd_lcmp_if_tail;
2533                                                 default:
2534                                                         goto normal_LCMP;
2535                                                 }
2536                                                 break;
2537 normal_LCMP:
2538 #endif /* SUPPORT_LONG_CMP_CONST */
2539                                                         OP2_1(TYPE_LNG, TYPE_LNG, TYPE_INT);
2540                                                 break;
2541
2542                                                 /* XXX why is this deactivated? */
2543 #if 0
2544                                         case ICMD_FCMPL:
2545                                                 COUNT(count_pcmd_op);
2546                                                 if ((len == 0) || (iptr[1].sx.val.i != 0))
2547                                                         goto normal_FCMPL;
2548
2549                                                 switch (iptr[1].opc) {
2550                                                 case ICMD_IFEQ:
2551                                                         iptr->opc = ICMD_IF_FCMPEQ;
2552                                                 icmd_if_fcmpl_tail:
2553                                                         iptr->dst.insindex = iptr[1].dst.insindex;
2554                                                         iptr[1].opc = ICMD_NOP;
2555
2556                                                         OP2_BRANCH(TYPE_FLT, TYPE_FLT);
2557                                                         BRANCH(tbptr, copy);
2558
2559                                                         COUNT(count_pcmd_bra);
2560                                                         break;
2561                                                 case ICMD_IFNE:
2562                                                         iptr->opc = ICMD_IF_FCMPNE;
2563                                                         goto icmd_if_fcmpl_tail;
2564                                                 case ICMD_IFLT:
2565                                                         iptr->opc = ICMD_IF_FCMPL_LT;
2566                                                         goto icmd_if_fcmpl_tail;
2567                                                 case ICMD_IFGT:
2568                                                         iptr->opc = ICMD_IF_FCMPL_GT;
2569                                                         goto icmd_if_fcmpl_tail;
2570                                                 case ICMD_IFLE:
2571                                                         iptr->opc = ICMD_IF_FCMPL_LE;
2572                                                         goto icmd_if_fcmpl_tail;
2573                                                 case ICMD_IFGE:
2574                                                         iptr->opc = ICMD_IF_FCMPL_GE;
2575                                                         goto icmd_if_fcmpl_tail;
2576                                                 default:
2577                                                         goto normal_FCMPL;
2578                                                 }
2579                                                 break;
2580
2581 normal_FCMPL:
2582                                                 OPTT2_1(TYPE_FLT, TYPE_FLT, TYPE_INT);
2583                                                 break;
2584
2585                                         case ICMD_FCMPG:
2586                                                 COUNT(count_pcmd_op);
2587                                                 if ((len == 0) || (iptr[1].sx.val.i != 0))
2588                                                         goto normal_FCMPG;
2589
2590                                                 switch (iptr[1].opc) {
2591                                                 case ICMD_IFEQ:
2592                                                         iptr->opc = ICMD_IF_FCMPEQ;
2593                                                 icmd_if_fcmpg_tail:
2594                                                         iptr->dst.insindex = iptr[1].dst.insindex;
2595                                                         iptr[1].opc = ICMD_NOP;
2596
2597                                                         OP2_BRANCH(TYPE_FLT, TYPE_FLT);
2598                                                         BRANCH(tbptr, copy);
2599
2600                                                         COUNT(count_pcmd_bra);
2601                                                         break;
2602                                                 case ICMD_IFNE:
2603                                                         iptr->opc = ICMD_IF_FCMPNE;
2604                                                         goto icmd_if_fcmpg_tail;
2605                                                 case ICMD_IFLT:
2606                                                         iptr->opc = ICMD_IF_FCMPG_LT;
2607                                                         goto icmd_if_fcmpg_tail;
2608                                                 case ICMD_IFGT:
2609                                                         iptr->opc = ICMD_IF_FCMPG_GT;
2610                                                         goto icmd_if_fcmpg_tail;
2611                                                 case ICMD_IFLE:
2612                                                         iptr->opc = ICMD_IF_FCMPG_LE;
2613                                                         goto icmd_if_fcmpg_tail;
2614                                                 case ICMD_IFGE:
2615                                                         iptr->opc = ICMD_IF_FCMPG_GE;
2616                                                         goto icmd_if_fcmpg_tail;
2617                                                 default:
2618                                                         goto normal_FCMPG;
2619                                                 }
2620                                                 break;
2621
2622 normal_FCMPG:
2623                                                 OP2_1(TYPE_FLT, TYPE_FLT, TYPE_INT);
2624                                                 break;
2625
2626                                         case ICMD_DCMPL:
2627                                                 COUNT(count_pcmd_op);
2628                                                 if ((len == 0) || (iptr[1].sx.val.i != 0))
2629                                                         goto normal_DCMPL;
2630
2631                                                 switch (iptr[1].opc) {
2632                                                 case ICMD_IFEQ:
2633                                                         iptr->opc = ICMD_IF_DCMPEQ;
2634                                                 icmd_if_dcmpl_tail:
2635                                                         iptr->dst.insindex = iptr[1].dst.insindex;
2636                                                         iptr[1].opc = ICMD_NOP;
2637
2638                                                         OP2_BRANCH(TYPE_DBL, TYPE_DBL);
2639                                                         BRANCH(tbptr, copy);
2640
2641                                                         COUNT(count_pcmd_bra);
2642                                                         break;
2643                                                 case ICMD_IFNE:
2644                                                         iptr->opc = ICMD_IF_DCMPNE;
2645                                                         goto icmd_if_dcmpl_tail;
2646                                                 case ICMD_IFLT:
2647                                                         iptr->opc = ICMD_IF_DCMPL_LT;
2648                                                         goto icmd_if_dcmpl_tail;
2649                                                 case ICMD_IFGT:
2650                                                         iptr->opc = ICMD_IF_DCMPL_GT;
2651                                                         goto icmd_if_dcmpl_tail;
2652                                                 case ICMD_IFLE:
2653                                                         iptr->opc = ICMD_IF_DCMPL_LE;
2654                                                         goto icmd_if_dcmpl_tail;
2655                                                 case ICMD_IFGE:
2656                                                         iptr->opc = ICMD_IF_DCMPL_GE;
2657                                                         goto icmd_if_dcmpl_tail;
2658                                                 default:
2659                                                         goto normal_DCMPL;
2660                                                 }
2661                                                 break;
2662
2663 normal_DCMPL:
2664                                                 OPTT2_1(TYPE_DBL, TYPE_INT);
2665                                                 break;
2666
2667                                         case ICMD_DCMPG:
2668                                                 COUNT(count_pcmd_op);
2669                                                 if ((len == 0) || (iptr[1].sx.val.i != 0))
2670                                                         goto normal_DCMPG;
2671
2672                                                 switch (iptr[1].opc) {
2673                                                 case ICMD_IFEQ:
2674                                                         iptr->opc = ICMD_IF_DCMPEQ;
2675                                                 icmd_if_dcmpg_tail:
2676                                                         iptr->dst.insindex = iptr[1].dst.insindex;
2677                                                         iptr[1].opc = ICMD_NOP;
2678
2679                                                         OP2_BRANCH(TYPE_DBL, TYPE_DBL);
2680                                                         BRANCH(tbptr, copy);
2681
2682                                                         COUNT(count_pcmd_bra);
2683                                                         break;
2684                                                 case ICMD_IFNE:
2685                                                         iptr->opc = ICMD_IF_DCMPNE;
2686                                                         goto icmd_if_dcmpg_tail;
2687                                                 case ICMD_IFLT:
2688                                                         iptr->opc = ICMD_IF_DCMPG_LT;
2689                                                         goto icmd_if_dcmpg_tail;
2690                                                 case ICMD_IFGT:
2691                                                         iptr->opc = ICMD_IF_DCMPG_GT;
2692                                                         goto icmd_if_dcmpg_tail;
2693                                                 case ICMD_IFLE:
2694                                                         iptr->opc = ICMD_IF_DCMPG_LE;
2695                                                         goto icmd_if_dcmpg_tail;
2696                                                 case ICMD_IFGE:
2697                                                         iptr->opc = ICMD_IF_DCMPG_GE;
2698                                                         goto icmd_if_dcmpg_tail;
2699                                                 default:
2700                                                         goto normal_DCMPG;
2701                                                 }
2702                                                 break;
2703
2704 normal_DCMPG:
2705                                                 OP2_1(TYPE_DBL, TYPE_DBL, TYPE_INT);
2706                                                 break;
2707 #else
2708                                         case ICMD_FCMPL:
2709                                         case ICMD_FCMPG:
2710                                                 COUNT(count_pcmd_op);
2711                                                 OP2_1(TYPE_FLT, TYPE_FLT, TYPE_INT);
2712                                                 break;
2713
2714                                         case ICMD_DCMPL:
2715                                         case ICMD_DCMPG:
2716                                                 COUNT(count_pcmd_op);
2717                                                 OP2_1(TYPE_DBL, TYPE_DBL, TYPE_INT);
2718                                                 break;
2719 #endif
2720
2721                                                 /* pop 1 push 1 */
2722
2723                                         case ICMD_INEG:
2724                                         case ICMD_INT2BYTE:
2725                                         case ICMD_INT2CHAR:
2726                                         case ICMD_INT2SHORT:
2727                                                 COUNT(count_pcmd_op);
2728                                                 OP1_1(TYPE_INT, TYPE_INT);
2729                                                 break;
2730                                         case ICMD_LNEG:
2731                                                 COUNT(count_pcmd_op);
2732                                                 OP1_1(TYPE_LNG, TYPE_LNG);
2733                                                 break;
2734                                         case ICMD_FNEG:
2735                                                 COUNT(count_pcmd_op);
2736                                                 OP1_1(TYPE_FLT, TYPE_FLT);
2737                                                 break;
2738                                         case ICMD_DNEG:
2739                                                 COUNT(count_pcmd_op);
2740                                                 OP1_1(TYPE_DBL, TYPE_DBL);
2741                                                 break;
2742
2743                                         case ICMD_I2L:
2744                                                 COUNT(count_pcmd_op);
2745                                                 OP1_1(TYPE_INT, TYPE_LNG);
2746                                                 break;
2747                                         case ICMD_I2F:
2748                                                 COUNT(count_pcmd_op);
2749                                                 OP1_1(TYPE_INT, TYPE_FLT);
2750                                                 break;
2751                                         case ICMD_I2D:
2752                                                 COUNT(count_pcmd_op);
2753                                                 OP1_1(TYPE_INT, TYPE_DBL);
2754                                                 break;
2755                                         case ICMD_L2I:
2756                                                 COUNT(count_pcmd_op);
2757                                                 OP1_1(TYPE_LNG, TYPE_INT);
2758                                                 break;
2759                                         case ICMD_L2F:
2760                                                 COUNT(count_pcmd_op);
2761                                                 OP1_1(TYPE_LNG, TYPE_FLT);
2762                                                 break;
2763                                         case ICMD_L2D:
2764                                                 COUNT(count_pcmd_op);
2765                                                 OP1_1(TYPE_LNG, TYPE_DBL);
2766                                                 break;
2767                                         case ICMD_F2I:
2768                                                 COUNT(count_pcmd_op);
2769                                                 OP1_1(TYPE_FLT, TYPE_INT);
2770                                                 break;
2771                                         case ICMD_F2L:
2772                                                 COUNT(count_pcmd_op);
2773                                                 OP1_1(TYPE_FLT, TYPE_LNG);
2774                                                 break;
2775                                         case ICMD_F2D:
2776                                                 COUNT(count_pcmd_op);
2777                                                 OP1_1(TYPE_FLT, TYPE_DBL);
2778                                                 break;
2779                                         case ICMD_D2I:
2780                                                 COUNT(count_pcmd_op);
2781                                                 OP1_1(TYPE_DBL, TYPE_INT);
2782                                                 break;
2783                                         case ICMD_D2L:
2784                                                 COUNT(count_pcmd_op);
2785                                                 OP1_1(TYPE_DBL, TYPE_LNG);
2786                                                 break;
2787                                         case ICMD_D2F:
2788                                                 COUNT(count_pcmd_op);
2789                                                 OP1_1(TYPE_DBL, TYPE_FLT);
2790                                                 break;
2791
2792                                         case ICMD_CHECKCAST:
2793                                                 last_pei_boundary = new;
2794                                                 if (iptr->flags.bits & INS_FLAG_ARRAY) {
2795                                                         /* array type cast-check */
2796
2797                                                         bte = builtintable_get_internal(BUILTIN_arraycheckcast);
2798                                                         md = bte->md;
2799
2800                                                         if (md->memuse > rd->memuse)
2801                                                                 rd->memuse = md->memuse;
2802                                                         if (md->argintreguse > rd->argintreguse)
2803                                                                 rd->argintreguse = md->argintreguse;
2804
2805                                                         /* make all stack variables saved */
2806
2807                                                         copy = curstack;
2808                                                         while (copy) {
2809 #if defined(NEW_VAR)
2810                                                                 jd->var[copy->varnum].flags |= SAVEDVAR;
2811 #endif
2812                                                                 copy->flags |= SAVEDVAR;
2813                                                                 copy = copy->prev;
2814                                                         }
2815                                                 }
2816                                                 OP1_1(TYPE_ADR, TYPE_ADR);
2817                                                 break;
2818
2819                                         case ICMD_INSTANCEOF:
2820                                         case ICMD_ARRAYLENGTH:
2821                                                 last_pei_boundary = new;
2822                                                 OP1_1(TYPE_ADR, TYPE_INT);
2823                                                 break;
2824
2825                                         case ICMD_NEWARRAY:
2826                                         case ICMD_ANEWARRAY:
2827                                                 last_pei_boundary = new;
2828                                                 OP1_1(TYPE_INT, TYPE_ADR);
2829                                                 break;
2830
2831                                         case ICMD_GETFIELD:
2832                                                 last_pei_boundary = new;
2833                                                 COUNT(count_check_null);
2834                                                 COUNT(count_pcmd_mem);
2835                                                 INSTRUCTION_GET_FIELDREF(iptr, fmiref);
2836                                                 OP1_1(TYPE_ADR, fmiref->parseddesc.fd->type);
2837                                                 break;
2838
2839                                                 /* pop 0 push 1 */
2840
2841                                         case ICMD_GETSTATIC:
2842                                                 last_pei_boundary = new;
2843                                                 COUNT(count_pcmd_mem);
2844                                                 INSTRUCTION_GET_FIELDREF(iptr, fmiref);
2845                                                 OP0_1(fmiref->parseddesc.fd->type);
2846                                                 break;
2847
2848                                         case ICMD_NEW:
2849                                                 last_pei_boundary = new;
2850                                                 OP0_1(TYPE_ADR);
2851                                                 break;
2852
2853                                         case ICMD_JSR:
2854                                                 OP0_1(TYPE_ADR);
2855
2856                                                 BRANCH_TARGET(iptr->sx.s23.s3.jsrtarget, tbptr, copy);
2857
2858                                                 tbptr->type = BBTYPE_SBR;
2859
2860                                                 /* We need to check for overflow right here because
2861                                                  * the pushed value is poped afterwards */
2862                                                 CHECKOVERFLOW;
2863
2864                                                 /* calculate stack after return */
2865                                                 POPANY;
2866                                                 stackdepth--;
2867                                                 break;
2868
2869                                         /* pop many push any */
2870
2871                                         case ICMD_BUILTIN:
2872 icmd_BUILTIN:
2873                                                 bte = iptr->sx.s23.s3.bte;
2874                                                 md = bte->md;
2875                                                 goto _callhandling;
2876
2877                                         case ICMD_INVOKESTATIC:
2878                                         case ICMD_INVOKESPECIAL:
2879                                         case ICMD_INVOKEVIRTUAL:
2880                                         case ICMD_INVOKEINTERFACE:
2881                                                 COUNT(count_pcmd_met);
2882
2883                                                 /* Check for functions to replace with builtin
2884                                                  * functions. */
2885
2886                                                 if (builtintable_replace_function(iptr))
2887                                                         goto icmd_BUILTIN;
2888
2889                                                 INSTRUCTION_GET_METHODDESC(iptr, md);
2890                                                 /* XXX resurrect this COUNT? */
2891 /*                          if (lm->flags & ACC_STATIC) */
2892 /*                              {COUNT(count_check_null);} */
2893
2894                                         _callhandling:
2895
2896                                                 last_pei_boundary = new;
2897
2898                                                 i = md->paramcount;
2899
2900                                                 if (md->memuse > rd->memuse)
2901                                                         rd->memuse = md->memuse;
2902                                                 if (md->argintreguse > rd->argintreguse)
2903                                                         rd->argintreguse = md->argintreguse;
2904                                                 if (md->argfltreguse > rd->argfltreguse)
2905                                                         rd->argfltreguse = md->argfltreguse;
2906
2907                                                 REQUIRE(i);
2908
2909                                                 /* XXX optimize for <= 2 args */
2910                                                 /* XXX not for ICMD_BUILTIN */
2911                                                 iptr->s1.argcount = stackdepth;
2912 #if defined(NEW_VAR)
2913                                                 iptr->sx.s23.s2.args = DMNEW(s4, stackdepth);
2914 #else                                     
2915                                                 iptr->sx.s23.s2.args = DMNEW(stackptr, stackdepth);
2916 #endif
2917
2918                                                 copy = curstack;
2919                                                 for (i-- ; i >= 0; i--) {
2920 #if defined(NEW_VAR)
2921                                                         iptr->sx.s23.s2.args[i] = copy->varnum;
2922 #else
2923                                                         iptr->sx.s23.s2.args[i] = copy;
2924 #endif
2925
2926                                                         /* do not change STACKVARs or LOCALVARS to ARGVAR*/
2927                                                         /* ->  won't help anyway */
2928 #if defined(NEW_VAR)
2929                                                         if (!(IS_OUTVAR(copy) || IS_LOCALVAR(copy))) {
2930 #else
2931                                                         if (copy->varkind != STACKVAR) {
2932 #endif
2933
2934 #if defined(SUPPORT_PASS_FLOATARGS_IN_INTREGS)
2935                         /* If we pass float arguments in integer argument registers, we
2936                          * are not allowed to precolor them here. Floats have to be moved
2937                          * to this regs explicitly in codegen().
2938                          * Only arguments that are passed by stack anyway can be precolored
2939                          * (michi 2005/07/24) */
2940 # if defined(NEW_VAR)
2941                                                         if (!(jd->var[copy->varnum].flags & SAVEDVAR) &&
2942                                                            (!IS_FLT_DBL_TYPE(copy->type) 
2943                                                                 || md->params[i].inmemory)) {
2944 # else /* defined(NEW_VAR) */
2945                                                         if (!(copy->flags & SAVEDVAR) &&
2946                                                            (!IS_FLT_DBL_TYPE(copy->type) 
2947                                                                 || md->params[i].inmemory)) {
2948 # endif /* defined(NEW_VAR) */
2949 #else
2950 # if defined(NEW_VAR)
2951                                                         if (!(jd->var[copy->varnum].flags & SAVEDVAR)) {
2952 #else
2953                                                         if (!(copy->flags & SAVEDVAR)) {
2954 #endif
2955 #endif
2956
2957 #if defined(NEW_VAR)
2958                                                                 SET_PREALLOC(copy);
2959 #else
2960                                                                 copy->varkind = ARGVAR;
2961                                                                 copy->varnum = i;
2962 #endif
2963
2964 #if defined(ENABLE_INTRP)
2965                                                                 if (!opt_intrp) {
2966 #endif
2967                                                                         if (md->params[i].inmemory) {
2968 #if defined(NEW_VAR)
2969                                                                                 jd->var[copy->varnum].regoff =
2970                                                                                         md->params[i].regoff;
2971                                                                                 jd->var[copy->varnum].flags |= 
2972                                                                                         INMEMORY;
2973 #else    
2974                                                                                 copy->flags = INMEMORY;
2975                                                                                 copy->regoff = md->params[i].regoff;
2976 #endif
2977                                                                         }
2978                                                                         else {
2979 #if !defined(NEW_VAR)
2980                                                                                 copy->flags = 0;
2981 #endif
2982                                                                                 if (IS_FLT_DBL_TYPE(copy->type)) {
2983 #if defined(SUPPORT_PASS_FLOATARGS_IN_INTREGS)
2984                                                                                         assert(0); /* XXX is this assert ok? */
2985 #else
2986 #if defined(NEW_VAR)
2987                                                                                         jd->var[copy->varnum].regoff = 
2988                                                                                 rd->argfltregs[md->params[i].regoff];
2989 #else                                                                                   
2990                                                                                         copy->regoff =
2991                                                                                 rd->argfltregs[md->params[i].regoff];
2992 #endif
2993 #endif /* SUPPORT_PASS_FLOATARGS_IN_INTREGS */
2994                                                                                 }
2995                                                                                 else {
2996 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
2997                                                                                         if (IS_2_WORD_TYPE(copy->type))
2998 #if defined(NEW_VAR)
2999                                                                                                 jd->var[copy->varnum].regoff = 
3000                                 PACK_REGS( rd->argintregs[GET_LOW_REG(md->params[i].regoff)],
3001                                                    rd->argintregs[GET_HIGH_REG(md->params[i].regoff)]);
3002
3003 #else
3004                                                                                             copy->regoff = PACK_REGS(
3005                                                         rd->argintregs[GET_LOW_REG(md->params[i].regoff)],
3006                                                         rd->argintregs[GET_HIGH_REG(md->params[i].regoff)]);
3007 #endif
3008                                                                                         else
3009 #endif /* SUPPORT_COMBINE_INTEGER_REGISTERS */
3010 #if defined(NEW_VAR)
3011                                                                                                 jd->var[copy->varnum].regoff = 
3012                                                                                 rd->argintregs[md->params[i].regoff];
3013 #else
3014                                                                                                         copy->regoff =
3015                                                                                 rd->argintregs[md->params[i].regoff];
3016 #endif
3017                                                                                 }
3018                                                                         }
3019 #if defined(ENABLE_INTRP)
3020                                                                 } /* end if (!opt_intrp) */
3021 #endif
3022                                                         }
3023                                                         }
3024                                                         copy = copy->prev;
3025                                                 }
3026
3027                                                 /* deal with live-through stack slots "under" the */
3028                                                 /* arguments */
3029                                                 /* XXX not for ICMD_BUILTIN */
3030
3031                                                 i = md->paramcount;
3032
3033                                                 while (copy) {
3034 #if defined(NEW_VAR)
3035                                                         iptr->sx.s23.s2.args[i++] = copy->varnum;
3036                                                         jd->var[copy->varnum].flags |= SAVEDVAR;
3037 #else
3038                                                         iptr->sx.s23.s2.args[i++] = copy;
3039                                                         copy->flags |= SAVEDVAR;
3040 #endif
3041                                                         copy = copy->prev;
3042                                                 }
3043
3044                                                 /* pop the arguments */
3045
3046                                                 i = md->paramcount;
3047
3048                                                 stackdepth -= i;
3049                                                 while (--i >= 0) {
3050                                                         POPANY;
3051                                                 }
3052
3053                                                 /* push the return value */
3054
3055                                                 if (md->returntype.type != TYPE_VOID) {
3056 #if defined(NEW_VAR)
3057                                                         GET_NEW_INDEX(new_index);
3058                                                         DST(md->returntype.type, new_index);
3059 #else
3060                                                         DST(md->returntype.type, stackdepth);
3061 #endif
3062                                                         stackdepth++;
3063                                                 }
3064                                                 break;
3065
3066                                         case ICMD_INLINE_START:
3067                                         case ICMD_INLINE_END:
3068                                                 CLR_S1;
3069                                                 CLR_DST;
3070                                                 break;
3071
3072                                         case ICMD_MULTIANEWARRAY:
3073                                                 last_pei_boundary = new;
3074                                                 if (rd->argintreguse < 3)
3075                                                         rd->argintreguse = 3;
3076
3077                                                 i = iptr->s1.argcount;
3078
3079                                                 REQUIRE(i);
3080
3081 #if defined(NEW_VAR)
3082                                                 iptr->sx.s23.s2.args = DMNEW(s4, i);
3083 #else
3084                                                 iptr->sx.s23.s2.args = DMNEW(stackptr, i);
3085 #endif
3086
3087 #if defined(SPECIALMEMUSE)
3088 # if defined(__DARWIN__)
3089                                                 if (rd->memuse < (i + INT_ARG_CNT +LA_SIZE_IN_POINTERS))
3090                                                         rd->memuse = i + LA_SIZE_IN_POINTERS + INT_ARG_CNT;
3091 # else
3092                                                 if (rd->memuse < (i + LA_SIZE_IN_POINTERS + 3))
3093                                                         rd->memuse = i + LA_SIZE_IN_POINTERS + 3;
3094 # endif
3095 #else
3096 # if defined(__I386__)
3097                                                 if (rd->memuse < i + 3)
3098                                                         rd->memuse = i + 3; /* n integer args spilled on stack */
3099 # elif defined(__MIPS__) && SIZEOF_VOID_P == 4
3100                                                 if (rd->memuse < i + 2)
3101                                                         rd->memuse = i + 2; /* 4*4 bytes callee save space */
3102 # else
3103                                                 if (rd->memuse < i)
3104                                                         rd->memuse = i; /* n integer args spilled on stack */
3105 # endif /* defined(__I386__) */
3106 #endif
3107                                                 copy = curstack;
3108                                                 while (--i >= 0) {
3109                                         /* check INT type here? Currently typecheck does this. */
3110 #if defined(NEW_VAR)
3111                                                         iptr->sx.s23.s2.args[i] = copy->varnum;
3112                                                         if (!(jd->var[copy->varnum].flags & SAVEDVAR)
3113                                                                 && (!IS_OUTVAR(copy))
3114                                                                 && (!IS_LOCALVAR(copy)) ) {
3115 #else
3116                                                         iptr->sx.s23.s2.args[i] = copy;
3117                                                         if (!(copy->flags & SAVEDVAR) 
3118                                                                 && (copy->varkind != STACKVAR)) {
3119 #endif
3120                                                                 copy->varkind = ARGVAR;
3121 #if defined(NEW_VAR)
3122                                                                 jd->var[copy->varnum].flags |=
3123                                                                         INMEMORY & PREALLOC;
3124 #if defined(SPECIALMEMUSE)
3125 # if defined(__DARWIN__)
3126                                                                 jd->var[copy->varnum].regoff = i + 
3127                                                                         LA_SIZE_IN_POINTERS + INT_ARG_CNT;
3128 # else
3129                                                                 jd->var[copy->varnum].regoff = i + 
3130                                                                         LA_SIZE_IN_POINTERS + 3;
3131 # endif
3132 #else
3133 # if defined(__I386__)
3134                                                                 jd->var[copy->varnum].regoff = i + 3;
3135 # elif defined(__MIPS__) && SIZEOF_VOID_P == 4
3136                                                                 jd->var[copy->varnum].regoff = i + 2;
3137 # else
3138                                                                 jd->var[copy->varnum].regoff = i;
3139 # endif /* defined(__I386__) */
3140 #endif /* defined(SPECIALMEMUSE) */
3141 #else /* defined(NEW_VAR) */
3142                                                                 copy->varnum = i + INT_ARG_CNT;
3143                                                                 copy->flags |= INMEMORY;
3144 #if defined(SPECIALMEMUSE)
3145 # if defined(__DARWIN__)
3146                                                                 copy->regoff = i + LA_SIZE_IN_POINTERS + INT_ARG_CNT;
3147 # else
3148                                                                 copy->regoff = i + LA_SIZE_IN_POINTERS + 3;
3149 # endif
3150 #else
3151 # if defined(__I386__)
3152                                                                 copy->regoff = i + 3;
3153 # elif defined(__MIPS__) && SIZEOF_VOID_P == 4
3154                                                                 copy->regoff = i + 2;
3155 # else
3156                                                                 copy->regoff = i;
3157 # endif /* defined(__I386__) */
3158 #endif /* defined(SPECIALMEMUSE) */
3159
3160 #endif /* defined(NEW_VAR) */
3161                                                         }
3162                                                         copy = copy->prev;
3163                                                 }
3164                                                 while (copy) {
3165 #if defined(NEW_VAR)
3166                                                         jd->var[copy->varnum].flags |= SAVEDVAR;
3167 #else
3168                                                         copy->flags |= SAVEDVAR;
3169 #endif
3170                                                         copy = copy->prev;
3171                                                 }
3172
3173                                                 i = iptr->s1.argcount;
3174                                                 stackdepth -= i;
3175                                                 while (--i >= 0) {
3176                                                         POPANY;
3177                                                 }
3178 #if defined(NEW_VAR)
3179                                                 GET_NEW_INDEX(new_index);
3180                                                 DST(TYPE_ADR, new_index);
3181 #else
3182                                                 DST(TYPE_ADR, stackdepth);
3183 #endif
3184                                                 stackdepth++;
3185                                                 break;
3186
3187                                         default:
3188                                                 *exceptionptr =
3189                                                         new_internalerror("Unknown ICMD %d", opcode);
3190                                                 return false;
3191                                         } /* switch */
3192
3193                                         CHECKOVERFLOW;
3194                                         iptr++;
3195                                 } /* while instructions */
3196
3197                                 /* set out-stack of block */
3198
3199                                 bptr->outstack = curstack;
3200                                 bptr->outdepth = stackdepth;
3201 #if defined(NEW_VAR)
3202                                 bptr->outvars = DMNEW(s4, stackdepth);
3203                                 for (i = stackdepth, copy = curstack; i--; copy = copy->prev)
3204                                         bptr->outvars[i] = copy->varnum;
3205 #else
3206                                 bptr->outvars = DMNEW(stackptr, stackdepth);
3207                                 for (i = stackdepth, copy = curstack; i--; copy = copy->prev)
3208                                         bptr->outvars[i] = copy;
3209 #endif
3210
3211                                 /* stack slots at basic block end become interfaces */
3212
3213                                 i = stackdepth - 1;
3214                                 for (copy = curstack; copy; i--, copy = copy->prev) {
3215 #if defined(NEW_VAR)
3216                                         /* with the new vars rd->interfaces will be removed */
3217                                         /* and all in and outvars have to be STACKVARS!     */
3218                                         /* in the moment i.e. SWAP with in and out vars can */
3219                                         /* create an unresolvable conflict */
3220
3221                                         j = jd->interface_map[i * 5 + copy->type];
3222                                         if (j == UNUSED) {
3223                                                 /* no interface var until now for this depth and */
3224                                                 /* type */
3225                                                 
3226                                                 SET_OUTVAR(copy);
3227                                                 
3228                                                 if (! IS_LOCALVAR(copy) )
3229                                                         jd->var[j].flags |= jd->var[copy->varnum].flags;
3230                                                 jd->interface_map[i*5 + copy->type] = copy->varnum;
3231                                         }
3232                                         else if (j != copy->varnum) {
3233                                                 /* release copy->varnum and take already existing */
3234                                                 /* interface var */
3235                                                 RELEASE_INDEX(copy);
3236                                                 
3237                                                 if (! IS_LOCALVAR(copy) )
3238                                                         jd->var[j].flags |= jd->var[copy->varnum].flags;
3239                                                 copy->varnum = jd->interface_map[i*5 + copy->type];
3240                                         } /* else <-> if (j == copy->varnum) --> nothing todo! */
3241 #else
3242                                         if ((copy->varkind == STACKVAR) && (copy->varnum > i)) {
3243                                                 copy->varkind = TEMPVAR;
3244                                         } else {
3245                                                 copy->varkind = STACKVAR;
3246                                                 copy->varnum = i;
3247                                         }
3248                                         IF_NO_INTRP(
3249                                                         rd->interfaces[i][copy->type].type = copy->type;
3250                                                         rd->interfaces[i][copy->type].flags |= copy->flags;
3251                                         );
3252 #endif
3253                                 }
3254
3255                                 /* check if interface slots at basic block begin must be saved */
3256 #if !defined(NEW_VAR)
3257                                 IF_NO_INTRP(
3258                                         i = bptr->indepth - 1;
3259                                         for (copy = bptr->instack; copy; i--, copy = copy->prev) {
3260                                                 rd->interfaces[i][copy->type].type = copy->type;
3261                                                 if (copy->varkind == STACKVAR) {
3262                                                         if (copy->flags & SAVEDVAR)
3263                                                                 rd->interfaces[i][copy->type].flags |= SAVEDVAR;
3264                                                 }
3265                                         }
3266                                 );
3267 #endif
3268
3269 #if defined(STACK_VERBOSE)
3270                                 printf("OUTVARS\n");
3271                                 for( copy = bptr->outstack; copy; copy = copy->prev ) {
3272                                         printf("%2d(%d", copy->varnum, copy->type);
3273                                         if (IS_OUTVAR(copy))
3274                                                 printf("S");
3275                                         if (IS_PREALLOC(copy))
3276                                                 printf("A");
3277                                         printf(") ");
3278                                 }
3279                                 printf("\n");
3280 #endif
3281                     } /* if */
3282                         else
3283                                 superblockend = true;
3284
3285                         bptr++;
3286                 } /* while blocks */
3287         } while (repeat && !deadcode);
3288
3289         /* gather statistics *****************************************************/
3290
3291 #if defined(ENABLE_STATISTICS)
3292         if (opt_stat) {
3293                 if (jd->new_basicblockcount > count_max_basic_blocks)
3294                         count_max_basic_blocks = jd->new_basicblockcount;
3295                 count_basic_blocks += jd->new_basicblockcount;
3296                 if (jd->new_instructioncount > count_max_javainstr)
3297                         count_max_javainstr = jd->new_instructioncount;
3298                 count_javainstr += jd->new_instructioncount;
3299                 if (jd->new_stackcount > count_upper_bound_new_stack)
3300                         count_upper_bound_new_stack = jd->new_stackcount;
3301                 if ((new - jd->new_stack) > count_max_new_stack)
3302                         count_max_new_stack = (new - jd->new_stack);
3303
3304                 b_count = jd->new_basicblockcount;
3305                 bptr = jd->new_basicblocks;
3306                 while (--b_count >= 0) {
3307                         if (bptr->flags > BBREACHED) {
3308                                 if (bptr->indepth >= 10)
3309                                         count_block_stack[10]++;
3310                                 else
3311                                         count_block_stack[bptr->indepth]++;
3312                                 len = bptr->icount;
3313                                 if (len < 10)
3314                                         count_block_size_distribution[len]++;
3315                                 else if (len <= 12)
3316                                         count_block_size_distribution[10]++;
3317                                 else if (len <= 14)
3318                                         count_block_size_distribution[11]++;
3319                                 else if (len <= 16)
3320                                         count_block_size_distribution[12]++;
3321                                 else if (len <= 18)
3322                                         count_block_size_distribution[13]++;
3323                                 else if (len <= 20)
3324                                         count_block_size_distribution[14]++;
3325                                 else if (len <= 25)
3326                                         count_block_size_distribution[15]++;
3327                                 else if (len <= 30)
3328                                         count_block_size_distribution[16]++;
3329                                 else
3330                                         count_block_size_distribution[17]++;
3331                         }
3332                         bptr++;
3333                 }
3334
3335                 if (iteration_count == 1)
3336                         count_analyse_iterations[0]++;
3337                 else if (iteration_count == 2)
3338                         count_analyse_iterations[1]++;
3339                 else if (iteration_count == 3)
3340                         count_analyse_iterations[2]++;
3341                 else if (iteration_count == 4)
3342                         count_analyse_iterations[3]++;
3343                 else
3344                         count_analyse_iterations[4]++;
3345
3346                 if (jd->new_basicblockcount <= 5)
3347                         count_method_bb_distribution[0]++;
3348                 else if (jd->new_basicblockcount <= 10)
3349                         count_method_bb_distribution[1]++;
3350                 else if (jd->new_basicblockcount <= 15)
3351                         count_method_bb_distribution[2]++;
3352                 else if (jd->new_basicblockcount <= 20)
3353                         count_method_bb_distribution[3]++;
3354                 else if (jd->new_basicblockcount <= 30)
3355                         count_method_bb_distribution[4]++;
3356                 else if (jd->new_basicblockcount <= 40)
3357                         count_method_bb_distribution[5]++;
3358                 else if (jd->new_basicblockcount <= 50)
3359                         count_method_bb_distribution[6]++;
3360                 else if (jd->new_basicblockcount <= 75)
3361                         count_method_bb_distribution[7]++;
3362                 else
3363                         count_method_bb_distribution[8]++;
3364         }
3365 #endif /* defined(ENABLE_STATISTICS) */
3366
3367         /* everything's ok *******************************************************/
3368
3369         return true;
3370
3371         /* goto labels for throwing verifier exceptions **************************/
3372
3373 #if defined(ENABLE_VERIFIER)
3374
3375 throw_stack_underflow:
3376         exceptions_throw_verifyerror(m, "Unable to pop operand off an empty stack");
3377         return false;
3378
3379 throw_stack_overflow:
3380         exceptions_throw_verifyerror(m, "Stack size too large");
3381         return false;
3382
3383 throw_stack_depth_error:
3384         exceptions_throw_verifyerror(m,"Stack depth mismatch");
3385         return false;
3386
3387 throw_stack_type_error:
3388         exceptions_throw_verifyerror_for_stack(m, expectedtype);
3389         return false;
3390
3391 throw_stack_category_error:
3392         exceptions_throw_verifyerror(m, "Attempt to split long or double on the stack");
3393         return false;
3394
3395 #endif
3396 }
3397
3398
3399 /*
3400  * These are local overrides for various environment variables in Emacs.
3401  * Please do not remove this and leave it at the end of the file, where
3402  * Emacs will automagically detect them.
3403  * ---------------------------------------------------------------------
3404  * Local variables:
3405  * mode: c
3406  * indent-tabs-mode: t
3407  * c-basic-offset: 4
3408  * tab-width: 4
3409  * End:
3410  * vim:noexpandtab:sw=4:ts=4:
3411  */