3b0b4fa377a45bc9426797c0a7b2a9270eea3b1f
[cacao.git] / jit / parse.c
1 /* jit/parse.c *****************************************************************
2
3         Copyright (c) 1997 A. Krall, R. Grafl, M. Gschwind, M. Probst
4
5         See file COPYRIGHT for information on usage and disclaimer of warranties
6
7         Parser for JavaVM to intermediate code translation
8         
9         Author: Andreas  Krall      EMAIL: cacao@complang.tuwien.ac.at
10
11         Last Change: $Id: parse.c 553 2003-11-01 20:50:03Z twisti $
12                      include Rapid Type Analysis parse - 5/2003 - carolyn
13
14
15 *******************************************************************************/
16
17 #include "math.h"
18 #include "sets.h"
19                                 /* data about the currently parsed   method   */
20
21 static classinfo  *rt_class;    /* class the compiled method belongs to       */
22 static methodinfo *rt_method;   /* pointer to method info of compiled method  */
23 static utf      *rt_descriptor; /* type descriptor of compiled method         */
24 static int       rt_jcodelength; /*length of JavaVM-codes                     */
25 static u1       *rt_jcode;      /* pointer to start of JavaVM-code            */
26
27
28 /* macros for byte code fetching ***********************************************
29
30         fetch a byte code of given size from position p in code array jcode
31
32 *******************************************************************************/
33
34 #define code_get_u1(p)  jcode[p]
35 #define code_get_s1(p)  ((s1)jcode[p])
36 #define code_get_u2(p)  ((((u2)jcode[p])<<8)+jcode[p+1])
37 #define code_get_s2(p)  ((s2)((((u2)jcode[p])<<8)+jcode[p+1]))
38 #define code_get_u4(p)  ((((u4)jcode[p])<<24)+(((u4)jcode[p+1])<<16)\
39                            +(((u4)jcode[p+2])<<8)+jcode[p+3])
40 #define code_get_s4(p)  ((s4)((((u4)jcode[p])<<24)+(((u4)jcode[p+1])<<16)\
41                            +(((u4)jcode[p+2])<<8)+jcode[p+3]))
42
43
44
45 /*INLINING*/
46 #include "inline.c"
47 /*#define debug_writebranch printf("op: %s i: %d label_index[i]: %d\n",icmd_names[opcode], i, label_index[i]);*/
48 #define debug_writebranch
49
50 /* functionc compiler_addinitclass *********************************************
51
52         add class into the list of classes to initialize
53
54 *******************************************************************************/
55                                 
56 static void compiler_addinitclass (classinfo *c)
57 {
58         classinfo *cl;
59
60         if (c->initialized) return;
61         
62         cl = chain_first(uninitializedclasses);
63         if (cl == c)
64                 return;
65         
66         if (cl == class)
67                 cl = chain_next(uninitializedclasses);
68         for (;;) {
69                 if (cl == c)
70                         return;
71                 if (cl == NULL) {
72                         if (runverbose) {
73                                 sprintf(logtext, "compiler_addinitclass: ");
74                                 utf_sprint(logtext+strlen(logtext), c->name);
75                                 dolog();
76                                 }
77                         chain_addlast(uninitializedclasses, c);
78                         return;
79                         }
80                 if (c < cl) {
81                         if (runverbose) {
82                                 sprintf(logtext, "compiler_addinitclass: ");
83                                 utf_sprint(logtext+strlen(logtext), c->name);
84                                 dolog();
85                                 }
86                         chain_addbefore(uninitializedclasses, c);
87                         return;
88                         }
89                 cl = chain_next(uninitializedclasses);
90                 }
91 }                       
92
93
94 /* function descriptor2typesL ***************************************************
95
96         decodes a already checked method descriptor. The parameter count, the
97         return type and the argument types are stored in the passed methodinfo.
98         gets and saves classptr for object ref.s
99
100 *******************************************************************************/                
101
102 classSetNode * descriptor2typesL (methodinfo *m)
103 {
104 int debugInfo = 0;
105         int i;
106         u1 *types, *tptr;
107         int pcount, c;
108         char *utf_ptr;
109         classinfo** classtypes;
110         char *class; 
111         char *desc;
112         classSetNode *p=NULL;
113 if (debugInfo >= 1) {
114         printf("In descriptor2typesL >>>\t"); fflush(stdout);
115         utf_display(m->class->name); printf(".");
116         method_display(m);fflush(stdout);
117         }
118
119         pcount = 0;
120         desc =       MNEW (char, 256); 
121         types = DMNEW (u1, m->descriptor->blength); 
122         classtypes = MNEW (classinfo*, m->descriptor->blength+1);
123         m->returnclass = NULL;
124         tptr = types;
125         if (!(m->flags & ACC_STATIC)) {
126                 *tptr++ = TYPE_ADR;
127                 if (debugInfo >= 1) {
128                         printf("param #0 (this?) method class =");utf_display(m->class->name);printf("\n");
129                         }
130                 classtypes[pcount] = m->class;
131                 p = addClassCone(p,  m->class);
132                 pcount++;
133                 }
134
135         utf_ptr = m->descriptor->text + 1;
136         strcpy (desc,utf_ptr);
137    
138         while ((c = *desc++) != ')') {
139                 pcount++;
140                 switch (c) {
141                         case 'B':
142                         case 'C':
143                         case 'I':
144                         case 'S':
145                         case 'Z':  *tptr++ = TYPE_INT;
146                                    break;
147                         case 'J':  *tptr++ = TYPE_LNG;
148                                    break;
149                         case 'F':  *tptr++ = TYPE_FLT;
150                                    break;
151                         case 'D':  *tptr++ = TYPE_DBL;
152                                    break;
153                         case 'L':  *tptr++ = TYPE_ADR;
154                                    /* get class string */
155                                    class = strtok(desc,";");
156                                    desc = strtok(NULL,"\0");
157                                    /* get/save classinfo ptr */
158                                    classtypes[pcount-1] = class_get(utf_new_char(class));
159                                    p = addClassCone(p,  class_get(utf_new_char(class)));
160                                         if (debugInfo >= 1) {
161                                                 printf("LParam#%i 's class type is: %s\n",pcount-1,class);fflush(stdout);
162                                                 printf("Lclasstypes[%i]=",pcount-1);fflush(stdout);
163                                                 utf_display(classtypes[pcount-1]->name);
164                                                 }
165                                    break;
166                         case '[':  *tptr++ = TYPE_ADR;
167                                    while (c == '[')
168                                        c = *desc++;
169                                    /* get class string */
170                                    if (c == 'L') {
171                                         class = strtok(desc,";");
172                                         desc = strtok(NULL,"\0");
173                                         /* get/save classinfo ptr */
174                                         classtypes[pcount-1] = class_get(utf_new_char(class));
175                                         p= addClassCone(p,  class_get(utf_new_char(class)));
176                                         if (debugInfo >= 1) {
177                                                 printf("[Param#%i 's class type is: %s\n",pcount-1,class);
178                                                 printf("[classtypes[%i]=",pcount-1);fflush(stdout);
179                                                 utf_display(classtypes[pcount-1]->name);
180                                                 printf("\n");
181                                                 }
182                                         }
183                                    else
184                                         classtypes[pcount-1] = NULL;
185                                    break;
186                         default:   
187                                 panic("Ill formed methodtype-descriptor");
188                         }
189                 }
190
191         /* compute return type */
192         switch (*desc++) {
193                 case 'B':
194                 case 'C':
195                 case 'I':
196                 case 'S':
197                 case 'Z':  m->returntype = TYPE_INT;
198                            break;
199                 case 'J':  m->returntype = TYPE_LNG;
200                            break;
201                 case 'F':  m->returntype = TYPE_FLT;
202                            break;
203                 case 'D':  m->returntype = TYPE_DBL;
204                            break;
205                 case '[':
206                            m->returntype = TYPE_ADR;
207                            c = *desc;
208                            while (c == '[')
209                                c = *desc++;
210                            if (c != 'L') break;
211                            *(desc++);
212                            
213                 case 'L':  
214                            m->returntype = TYPE_ADR;
215                           
216                             /* get class string */
217                             class = strtok(desc,";");
218                             m->returnclass = class_get(utf_new_char(class));
219                             if (m->returnclass == NULL) {
220                                 printf("class=%s :\t",class);
221                                 panic ("return class not found");
222                                 }
223                            break;
224                 case 'V':  m->returntype = TYPE_VOID;
225                            break;
226
227         default:   panic("Ill formed methodtype-descriptor-ReturnType");
228                 }
229
230         m->paramcount = pcount;
231         m->paramtypes = types;
232         m->paramclass = classtypes;
233
234 if (debugInfo >=1) {
235         if (pcount > 0) {
236                 for (i=0; i< m->paramcount; i++) {
237                         if ((m->paramtypes[i] == TYPE_ADR) && (m->paramclass[i] != NULL)) {
238                               printf("Param #%i is:\t",i);
239                               utf_display(m->paramclass[i]->name);
240                               printf("\n");
241                               }
242                          }
243                }
244         if ((m->returntype == TYPE_ADR) && (m->returnclass != NULL)) { 
245                   printf("\tReturn Type is:\t"); fflush(stdout);
246                   utf_display(m->returnclass->name);
247                   printf("\n");
248                   }
249
250         printf("params2types: START  results in a set \n");
251         printf("param2types: A Set size=%i=\n",sizeOfSet(p));
252         printSet(p);
253         }
254
255 return p;
256 }
257
258 /* function descriptor2types ***************************************************
259
260         decodes a already checked method descriptor. The parameter count, the
261         return type and the argument types are stored in the passed methodinfo.
262
263 *******************************************************************************/                
264
265 static void descriptor2types (methodinfo *m)
266 {
267         u1 *types, *tptr;
268         int pcount, c;
269         char *utf_ptr;
270         pcount = 0;
271         types = DMNEW (u1, m->descriptor->blength); 
272         
273         tptr = types;
274         if (!(m->flags & ACC_STATIC)) {
275                 *tptr++ = TYPE_ADR;
276                 pcount++;
277                 }
278
279         utf_ptr = m->descriptor->text + 1;
280    
281         while ((c = *utf_ptr++) != ')') {
282                 pcount++;
283                 switch (c) {
284                         case 'B':
285                         case 'C':
286                         case 'I':
287                         case 'S':
288                         case 'Z':  *tptr++ = TYPE_INT;
289                                    break;
290                         case 'J':  *tptr++ = TYPE_LNG;
291                                    break;
292                         case 'F':  *tptr++ = TYPE_FLT;
293                                    break;
294                         case 'D':  *tptr++ = TYPE_DBL;
295                                    break;
296                         case 'L':  *tptr++ = TYPE_ADR;
297                                    while (*utf_ptr++ != ';');
298                                    break;
299                         case '[':  *tptr++ = TYPE_ADR;
300                                    while (c == '[')
301                                        c = *utf_ptr++;
302                                    if (c == 'L')
303                                        while (*utf_ptr++ != ';') /* skip */;
304                                    break;
305                         default:   panic ("Ill formed methodtype-descriptor");
306                         }
307                 }
308
309         /* compute return type */
310
311         switch (*utf_ptr++) {
312                 case 'B':
313                 case 'C':
314                 case 'I':
315                 case 'S':
316                 case 'Z':  m->returntype = TYPE_INT;
317                            break;
318                 case 'J':  m->returntype = TYPE_LNG;
319                            break;
320                 case 'F':  m->returntype = TYPE_FLT;
321                            break;
322                 case 'D':  m->returntype = TYPE_DBL;
323                            break;
324                 case '[':
325                 case 'L':  m->returntype = TYPE_ADR;
326                            break;
327                 case 'V':  m->returntype = TYPE_VOID;
328                            break;
329
330                 default:   panic ("Ill formed methodtype-descriptor");
331                 }
332
333         m->paramcount = pcount;
334         m->paramtypes = types;
335 }
336
337
338 /*******************************************************************************
339
340         function 'parse' scans the JavaVM code and generates intermediate code
341
342         During parsing the block index table is used to store at bit pos 0
343         a flag which marks basic block starts and at position 1 to 31 the
344         intermediate instruction index. After parsing the block index table
345         is scanned, for marked positions a block is generated and the block
346         number is stored in the block index table.
347
348 *******************************************************************************/
349
350 /* intermediate code generating macros */
351
352 #define PINC           iptr++;ipc++
353 #define LOADCONST_I(v) iptr->opc=ICMD_ICONST;iptr->op1=0;iptr->val.i=(v);PINC
354 #define LOADCONST_L(v) iptr->opc=ICMD_LCONST;iptr->op1=0;iptr->val.l=(v);PINC
355 #define LOADCONST_F(v) iptr->opc=ICMD_FCONST;iptr->op1=0;iptr->val.f=(v);PINC
356 #define LOADCONST_D(v) iptr->opc=ICMD_DCONST;iptr->op1=0;iptr->val.d=(v);PINC
357 #define LOADCONST_A(v) iptr->opc=ICMD_ACONST;iptr->op1=0;iptr->val.a=(v);PINC
358 #define OP(o)          iptr->opc=(o);iptr->op1=0;iptr->val.l=0;PINC
359 #define OP1(o,o1)      iptr->opc=(o);iptr->op1=(o1);iptr->val.l=(0);PINC
360 #define OP2I(o,o1,v)   iptr->opc=(o);iptr->op1=(o1);iptr->val.i=(v);PINC
361 #define OP2A(o,o1,v)   iptr->opc=(o);iptr->op1=(o1);iptr->val.a=(v);PINC
362 #define BUILTIN1(v,t)  isleafmethod=false;iptr->opc=ICMD_BUILTIN1;iptr->op1=t;\
363                        iptr->val.a=(v);PINC
364 #define BUILTIN2(v,t)  isleafmethod=false;iptr->opc=ICMD_BUILTIN2;iptr->op1=t;\
365                        iptr->val.a=(v);PINC
366 #define BUILTIN3(v,t)  isleafmethod=false;iptr->opc=ICMD_BUILTIN3;iptr->op1=t;\
367                        iptr->val.a=(v);PINC
368
369
370 /* block generating and checking macros */
371
372 #define block_insert(i)    {if(!(block_index[i]&1))\
373                                {b_count++;block_index[i] |= 1;}}
374 #define bound_check(i)     {if((i< 0) || (i>=cumjcodelength)) \
375                                panic("branch target out of code-boundary");}
376 #define bound_check1(i)    {if((i< 0) || (i>cumjcodelength)) \
377                                panic("branch target out of code-boundary");}
378 /* FIXME really use cumjcodelength for the bound_checkers ? */
379
380 static xtable* fillextable (xtable* extable, exceptiontable *raw_extable, int exceptiontablelength, int *label_index, int *block_count)
381 {
382         int b_count, i, p;
383         
384         if (exceptiontablelength == 0) 
385                 return extable;
386         
387         b_count = *block_count;
388         for (i = 0; i < exceptiontablelength; i++) {
389                                                                  
390                 p = raw_extable[i].startpc;
391                 if (label_index != NULL) p = label_index[p];
392                 extable[i].startpc = p;
393                 bound_check(p);
394                 block_insert(p);
395                 
396                 p = raw_extable[i].endpc;
397                 if (label_index != NULL) p = label_index[p];
398                 extable[i].endpc = p;
399                 bound_check1(p);
400                 if (p < cumjcodelength)
401                         block_insert(p);
402
403                 p = raw_extable[i].handlerpc;
404                 if (label_index != NULL) p = label_index[p];
405                 extable[i].handlerpc = p;
406                 bound_check(p);
407                 block_insert(p);
408
409                 extable[i].catchtype  = raw_extable[i].catchtype;
410
411                 extable[i].next = NULL;
412                 extable[i].down = &extable[i+1];
413                 }
414         *block_count = b_count;
415         return &extable[i];  /* return the next free xtable* */
416 }
417
418 static void parse()
419 {
420         int  p;                     /* java instruction counter                   */
421         int  nextp;                 /* start of next java instruction             */
422         int  opcode;                /* java opcode                                */
423         int  i;                     /* temporary for different uses (counters)    */
424         int  ipc = 0;               /* intermediate instruction counter           */
425         int  b_count = 0;           /* basic block counter                        */
426         int  s_count = 0;           /* stack element counter                      */
427         bool blockend = false;      /* true if basic block end has been reached   */
428         bool iswide = false;        /* true if last instruction was a wide        */
429         instruction *iptr;          /* current pointer into instruction array     */
430         int gp;                     /* global java instruction counter            */
431                                     /* inlining info for current method           */
432         inlining_methodinfo *inlinfo = inlining_rootinfo, *tmpinlinf; 
433         int nextgp = -1;            /* start of next method to be inlined         */
434         int *label_index = NULL;    /* label redirection table                    */
435         int firstlocal = 0;         /* first local variable of method             */
436         xtable* nextex;             /* points next free entry in extable          */
437
438         bool useinltmp;
439
440 /*INLINING*/
441         if (useinlining)
442                 {
443                         label_index = inlinfo->label_index;
444                         maxstack = cummaxstack;
445                         exceptiontablelength=cumextablelength;
446                 }
447         
448         useinltmp = useinlining; /*FIXME remove this after debugging */
449     /*useinlining = false;*/     /* and merge the if-statements  */
450         
451         if (!useinlining) {
452           cumjcodelength = jcodelength;
453         } else {
454           tmpinlinf = (inlining_methodinfo*) list_first(inlinfo->inlinedmethods);
455           if (tmpinlinf != NULL) nextgp = tmpinlinf->startgp;
456         }
457
458                 /*RTAprint*/ if  ( ((opt_rt) ||(opt_xta) || (opt_vta)) && ((pOpcodes == 2) || (pOpcodes == 3)) )
459                 /*RTAprint*/    {printf("PARSE method name =");
460                 /*RTAprint*/    utf_display(method->class->name);printf(".");
461                 /*RTAprint*/    method_display(method); printf(">\n\n");fflush(stdout);}
462         if ((opt_rt) || (opt_xta)) { 
463             RT_jit_parse(method);
464             }
465         else    {
466                 if (opt_vta) 
467                         printf("VTA requested, but not yet implemented\n");
468                 }
469          
470
471         /* allocate instruction array and block index table */
472         
473         /* 1 additional for end ipc and 3 for loop unrolling */
474         
475         block_index = DMNEW(int, cumjcodelength + 4);
476
477         /* 1 additional for TRACEBUILTIN and 4 for MONITORENTER/EXIT */
478         /* additional MONITOREXITS are reached by branches which are 3 bytes */
479         
480         iptr = instr = DMNEW(instruction, cumjcodelength + 5); 
481         
482         /* initialize block_index table (unrolled four times) */
483
484         {
485         int *ip;
486         
487         for (i = 0, ip = block_index; i <= cumjcodelength; i += 4, ip += 4) {
488                 ip[0] = 0;
489                 ip[1] = 0;
490                 ip[2] = 0;
491                 ip[3] = 0;
492                 }
493         }
494
495         /* compute branch targets of exception table */
496
497         extable = DMNEW(xtable, exceptiontablelength + 1);
498         /*
499         for (i = 0; i < method->exceptiontablelength; i++) {
500
501                 p = extable[i].startpc = raw_extable[i].startpc;
502                 if (useinlining) p = label_index[p];
503                 bound_check(p);
504                 block_insert(p);
505
506                 p = extable[i].endpc = raw_extable[i].endpc;
507                 if (useinlining) p = label_index[p];
508                 bound_check1(p);
509                 if (p < cumjcodelength)
510                         block_insert(p);
511
512                 p = extable[i].handlerpc = raw_extable[i].handlerpc;
513                 bound_check(p);
514                 block_insert(p);
515
516                 extable[i].catchtype  = raw_extable[i].catchtype;
517
518                 extable[i].next = NULL;
519                 extable[i].down = &extable[i+1];
520                 }
521         */
522
523         nextex = fillextable(extable, raw_extable, method->exceptiontablelength, label_index, &b_count);
524
525         s_count = 1 + exceptiontablelength; /* initialize stack element counter   */
526
527 #ifdef USE_THREADS
528         if (checksync && (method->flags & ACC_SYNCHRONIZED)) {
529                 isleafmethod=false;
530                 }                       
531 #endif
532
533         /* scan all java instructions */
534
535         for (p = 0, gp = 0; p < jcodelength; gp += (nextp - p), p = nextp) {
536           
537           /* DEBUG        printf("p:%d gp:%d ",p,gp); */
538
539 /*INLINING*/
540           if ((useinlining) && (gp == nextgp)) {
541                   u1 *tptr;
542                   bool *readonly = NULL;
543
544                   opcode = code_get_u1 (p);
545                   nextp = p += jcommandsize[opcode];
546                   tmpinlinf = list_first(inlinfo->inlinedmethods);
547                   firstlocal = tmpinlinf->firstlocal;
548                   label_index = tmpinlinf->label_index;
549                   readonly = tmpinlinf->readonly;
550                   for (i=0, tptr=tmpinlinf->method->paramtypes + tmpinlinf->method->paramcount - 1 ; i<tmpinlinf->method->paramcount; i++, tptr--)
551                           {
552                                   int op;
553
554                                   if ( (i==0) && inlineparamopt) {
555                                           OP1(ICMD_CLEAR_ARGREN, firstlocal);
556                                   }
557
558                                   if ( !inlineparamopt || !readonly[i] )
559                                           op = ICMD_ISTORE;
560                                   else op = ICMD_READONLY_ARG;   
561
562                                   op += *tptr;
563                                   OP1(op, firstlocal + tmpinlinf->method->paramcount - 1 - i);
564
565                                   /* block_index[gp] |= (ipc << 1);*/  /*FIXME: necessary ? */
566                           }
567                   inlining_save_compiler_variables();
568                   inlining_set_compiler_variables(tmpinlinf);
569                   if (inlinfo->inlinedmethods == NULL) gp = -1;
570                   else {
571                           tmpinlinf = list_first(inlinfo->inlinedmethods);
572                           nextgp = (tmpinlinf != NULL) ? tmpinlinf->startgp : -1;
573                   }
574                   if (method->exceptiontablelength > 0) 
575                           nextex = fillextable(nextex, method->exceptiontable, method->exceptiontablelength, label_index, &b_count);
576                   continue;
577           }
578           
579           opcode = code_get_u1 (p);           /* fetch op code                  */
580
581           
582           /*RTAprint*/ if  ((opt_rt) && ((pOpcodes == 2) || (pOpcodes == 3)) )
583           /*RTAprint*/    {printf("Parse<%i> p=%i<%i<   opcode=<%i> %s\n",
584           /*RTAprint*/            pOpcodes, p,rt_jcodelength,opcode,icmd_names[opcode]);}
585           
586           block_index[gp] |= (ipc << 1);       /* store intermediate count       */
587
588           if (blockend) {
589                   block_insert(gp);                /* start new block                */
590                   blockend = false;
591           }
592
593                 nextp = p + jcommandsize[opcode];   /* compute next instruction start */
594                 s_count += stackreq[opcode];            /* compute stack element count    */
595
596                 switch (opcode) {
597
598                         case JAVA_NOP:
599                                 break;
600
601                         /* pushing constants onto the stack p */
602
603                         case JAVA_BIPUSH:
604                                 LOADCONST_I(code_get_s1(p+1));
605                                 break;
606
607                         case JAVA_SIPUSH:
608                                 LOADCONST_I(code_get_s2(p+1));
609                                 break;
610
611                         case JAVA_LDC1:
612                                 i = code_get_u1(p+1);
613                                 goto pushconstantitem;
614                         case JAVA_LDC2:
615                         case JAVA_LDC2W:
616                                 i = code_get_u2(p + 1);
617
618                         pushconstantitem:
619
620                                 if (i >= class->cpcount) 
621                                         panic ("Attempt to access constant outside range");
622
623                                 switch (class->cptags[i]) {
624                                         case CONSTANT_Integer:
625                                                 LOADCONST_I(((constant_integer*)
626                                                              (class->cpinfos[i]))->value);
627                                                 break;
628                                         case CONSTANT_Long:
629                                                 LOADCONST_L(((constant_long*)
630                                                              (class->cpinfos[i]))->value);
631                                                 break;
632                                         case CONSTANT_Float:
633                                                 LOADCONST_F(((constant_float*)
634                                                              (class->cpinfos[i]))->value);
635                                                 break;
636                                         case CONSTANT_Double:
637                                                 LOADCONST_D(((constant_double*)
638                                                              (class->cpinfos[i]))->value);
639                                                 break;
640                                         case CONSTANT_String:
641                                                 LOADCONST_A(literalstring_new((utf*)
642                                                                               (class->cpinfos[i])));
643                                                 break;
644                                         default: panic("Invalid constant type to push");
645                                         }
646                                 break;
647
648                         case JAVA_ACONST_NULL:
649                                 LOADCONST_A(NULL);
650                                 break;
651
652                         case JAVA_ICONST_M1:
653                         case JAVA_ICONST_0:
654                         case JAVA_ICONST_1:
655                         case JAVA_ICONST_2:
656                         case JAVA_ICONST_3:
657                         case JAVA_ICONST_4:
658                         case JAVA_ICONST_5:
659                                 LOADCONST_I(opcode - JAVA_ICONST_0);
660                                 break;
661
662                         case JAVA_LCONST_0:
663                         case JAVA_LCONST_1:
664                                 LOADCONST_L(opcode - JAVA_LCONST_0);
665                                 break;
666
667                         case JAVA_FCONST_0:
668                         case JAVA_FCONST_1:
669                         case JAVA_FCONST_2:
670                                 LOADCONST_F(opcode - JAVA_FCONST_0);
671                                 break;
672
673                         case JAVA_DCONST_0:
674                         case JAVA_DCONST_1:
675                                 LOADCONST_D(opcode - JAVA_DCONST_0);
676                                 break;
677
678                         /* loading variables onto the stack */
679
680                         case JAVA_ILOAD:
681                         case JAVA_LLOAD:
682                         case JAVA_FLOAD:
683                         case JAVA_DLOAD:
684                         case JAVA_ALOAD:
685                                 if (!iswide)
686                                         i = code_get_u1(p+1);
687                                 else {
688                                         i = code_get_u2(p+1);
689                                         nextp = p+3;
690                                         iswide = false;
691                                         }
692                                 OP1(opcode, i + firstlocal);
693                                 break;
694
695                         case JAVA_ILOAD_0:
696                         case JAVA_ILOAD_1:
697                         case JAVA_ILOAD_2:
698                         case JAVA_ILOAD_3:
699                                 OP1(ICMD_ILOAD, opcode - JAVA_ILOAD_0 + firstlocal);
700                                 break;
701
702                         case JAVA_LLOAD_0:
703                         case JAVA_LLOAD_1:
704                         case JAVA_LLOAD_2:
705                         case JAVA_LLOAD_3:
706                                 OP1(ICMD_LLOAD, opcode - JAVA_LLOAD_0 + firstlocal);
707                                 break;
708
709                         case JAVA_FLOAD_0:
710                         case JAVA_FLOAD_1:
711                         case JAVA_FLOAD_2:
712                         case JAVA_FLOAD_3:
713                                 OP1(ICMD_FLOAD, opcode - JAVA_FLOAD_0 + firstlocal);
714                                 break;
715
716                         case JAVA_DLOAD_0:
717                         case JAVA_DLOAD_1:
718                         case JAVA_DLOAD_2:
719                         case JAVA_DLOAD_3:
720                                 OP1(ICMD_DLOAD, opcode - JAVA_DLOAD_0 + firstlocal);
721                                 break;
722
723                         case JAVA_ALOAD_0:
724                         case JAVA_ALOAD_1:
725                         case JAVA_ALOAD_2:
726                         case JAVA_ALOAD_3:
727                                 OP1(ICMD_ALOAD, opcode - JAVA_ALOAD_0 + firstlocal);
728                                 break;
729
730                         /* storing stack values into local variables */
731
732                         case JAVA_ISTORE:
733                         case JAVA_LSTORE:
734                         case JAVA_FSTORE:
735                         case JAVA_DSTORE:
736                         case JAVA_ASTORE:
737                                 if (!iswide)
738                                         i = code_get_u1(p+1);
739                                 else {
740                                         i = code_get_u2(p+1);
741                                         iswide=false;
742                                         nextp = p+3;
743                                         }
744                                 OP1(opcode, i + firstlocal);
745                                 break;
746
747                         case JAVA_ISTORE_0:
748                         case JAVA_ISTORE_1:
749                         case JAVA_ISTORE_2:
750                         case JAVA_ISTORE_3:
751                                 OP1(ICMD_ISTORE, opcode - JAVA_ISTORE_0 + firstlocal);
752                                 break;
753
754                         case JAVA_LSTORE_0:
755                         case JAVA_LSTORE_1:
756                         case JAVA_LSTORE_2:
757                         case JAVA_LSTORE_3:
758                                 OP1(ICMD_LSTORE, opcode - JAVA_LSTORE_0 + firstlocal);
759                                 break;
760
761                         case JAVA_FSTORE_0:
762                         case JAVA_FSTORE_1:
763                         case JAVA_FSTORE_2:
764                         case JAVA_FSTORE_3:
765                                 OP1(ICMD_FSTORE, opcode - JAVA_FSTORE_0 + firstlocal);
766                                 break;
767
768                         case JAVA_DSTORE_0:
769                         case JAVA_DSTORE_1:
770                         case JAVA_DSTORE_2:
771                         case JAVA_DSTORE_3:
772                                 OP1(ICMD_DSTORE, opcode - JAVA_DSTORE_0 + firstlocal);
773                                 break;
774
775                         case JAVA_ASTORE_0:
776                         case JAVA_ASTORE_1:
777                         case JAVA_ASTORE_2:
778                         case JAVA_ASTORE_3:
779                                 OP1(ICMD_ASTORE, opcode - JAVA_ASTORE_0 + firstlocal);
780                                 break;
781
782                         case JAVA_IINC:
783                                 {
784                                 int v;
785                                 
786                                 if (!iswide) {
787                                         i = code_get_u1(p + 1);
788                                         v = code_get_s1(p + 2);
789                                         }
790                                 else {
791                                         i = code_get_u2(p + 1);
792                                         v = code_get_s2(p + 3);
793                                         iswide = false;
794                                         nextp = p+5;
795                                         }
796                                 OP2I(opcode, i + firstlocal, v);
797                                 }
798                                 break;
799
800                         /* wider index for loading, storing and incrementing */
801
802                         case JAVA_WIDE:
803                                 iswide = true;
804                                 nextp = p + 1;
805                                 break;
806
807                         /* managing arrays ************************************************/
808
809                         case JAVA_NEWARRAY:
810                                 OP2I(ICMD_CHECKASIZE, 0, 0);
811                                 switch (code_get_s1(p+1)) {
812                                         case 4:
813                                                 BUILTIN1((functionptr)builtin_newarray_boolean, TYPE_ADR);
814                                                 break;
815                                         case 5:
816                                                 BUILTIN1((functionptr)builtin_newarray_char, TYPE_ADR);
817                                                 break;
818                                         case 6:
819                                                 BUILTIN1((functionptr)builtin_newarray_float, TYPE_ADR);
820                                                 break;
821                                         case 7:
822                                                 BUILTIN1((functionptr)builtin_newarray_double, TYPE_ADR);
823                                                 break;
824                                         case 8:
825                                                 BUILTIN1((functionptr)builtin_newarray_byte, TYPE_ADR);
826                                                 break;
827                                         case 9:
828                                                 BUILTIN1((functionptr)builtin_newarray_short, TYPE_ADR);
829                                                 break;
830                                         case 10:
831                                                 BUILTIN1((functionptr)builtin_newarray_int, TYPE_ADR);
832                                                 break;
833                                         case 11:
834                                                 BUILTIN1((functionptr)builtin_newarray_long, TYPE_ADR);
835                                                 break;
836                                         default: panic("Invalid array-type to create");
837                                         }
838                                 break;
839
840                         case JAVA_ANEWARRAY:
841                                 OP2I(ICMD_CHECKASIZE, 0, 0);
842                                 i = code_get_u2(p+1);
843                                 /* array or class type ? */
844                                 if (class_constanttype (class, i) == CONSTANT_Arraydescriptor) {
845                                         s_count++;
846                                         LOADCONST_A(class_getconstant(class, i,
847                                                                       CONSTANT_Arraydescriptor));
848 #if defined(__I386__)
849                                         BUILTIN2((functionptr) asm_builtin_newarray_array, TYPE_ADR);
850 #else
851                                         BUILTIN2((functionptr)builtin_newarray_array, TYPE_ADR);
852 #endif
853                                         }
854                                 else {
855                                         LOADCONST_A(class_getconstant(class, i, CONSTANT_Class));
856                                         s_count++;
857 #if defined(__I386__)
858                                         BUILTIN2((functionptr) asm_builtin_anewarray, TYPE_ADR);
859 #else
860                                         BUILTIN2((functionptr)builtin_anewarray, TYPE_ADR);
861 #endif
862                                         }
863                                 break;
864
865                         case JAVA_MULTIANEWARRAY:
866                                 isleafmethod=false;
867                                 i = code_get_u2(p+1);
868                                 {
869                                 int v = code_get_u1(p+3);
870                                 constant_arraydescriptor *desc =
871                                     class_getconstant (class, i, CONSTANT_Arraydescriptor);
872                                 OP2A(opcode, v, desc);
873                                 }
874                                 break;
875
876                         case JAVA_IFEQ:
877                         case JAVA_IFLT:
878                         case JAVA_IFLE:
879                         case JAVA_IFNE:
880                         case JAVA_IFGT:
881                         case JAVA_IFGE:
882                         case JAVA_IFNULL:
883                         case JAVA_IFNONNULL:
884                         case JAVA_IF_ICMPEQ:
885                         case JAVA_IF_ICMPNE:
886                         case JAVA_IF_ICMPLT:
887                         case JAVA_IF_ICMPGT:
888                         case JAVA_IF_ICMPLE:
889                         case JAVA_IF_ICMPGE:
890                         case JAVA_IF_ACMPEQ:
891                         case JAVA_IF_ACMPNE:
892                         case JAVA_GOTO:
893                         case JAVA_JSR:
894                                 i = p + code_get_s2(p+1);
895                                 if (useinlining) { 
896                                   debug_writebranch
897                                   i = label_index[i];
898                                 }
899                                 bound_check(i);
900                                 block_insert(i);
901                                 blockend = true;
902                                 OP1(opcode, i);
903                                 break;
904                         case JAVA_GOTO_W:
905                         case JAVA_JSR_W:
906                                 i = p + code_get_s4(p+1);
907                                 if (useinlining) { 
908                                   debug_writebranch
909                                   i = label_index[i];
910                                 }
911                                 bound_check(i);
912                                 block_insert(i);
913                                 blockend = true;
914                                 OP1(opcode, i);
915                                 break;
916
917                         case JAVA_RET:
918                                 if (!iswide)
919                                         i = code_get_u1(p+1);
920                                 else {
921                                         i = code_get_u2(p+1);
922                                         nextp = p+3;
923                                         iswide = false;
924                                         }
925                                 blockend = true;
926                                 
927                                 /*
928                                 if (isinlinedmethod) {
929                                   OP1(ICMD_GOTO, inlinfo->stopgp);
930                                   break;
931                                   }*/
932
933                                 OP1(opcode, i + firstlocal);
934                                 break;
935
936                         case JAVA_IRETURN:
937                         case JAVA_LRETURN:
938                         case JAVA_FRETURN:
939                         case JAVA_DRETURN:
940                         case JAVA_ARETURN:
941                         case JAVA_RETURN:
942
943
944                                 if (isinlinedmethod) {
945 /*                                      if (p==jcodelength-1) {*/ /* return is at end of inlined method */
946 /*                                              OP(ICMD_NOP); */
947 /*                                              break; */
948 /*                                      } */
949                                         blockend = true;
950                                         OP1(ICMD_GOTO, inlinfo->stopgp);
951                                         break;
952                                 }
953
954                                 blockend = true;
955                                 OP(opcode);
956                                 break;
957
958                         case JAVA_ATHROW:
959                                 blockend = true;
960                                 OP(opcode);
961                                 break;
962                                 
963
964                         /* table jumps ********************************/
965
966                         case JAVA_LOOKUPSWITCH:
967                                 {
968                                 s4 num, j;
969                                 s4 *tablep;
970
971                                 blockend = true;
972                                 nextp = ALIGN((p + 1), 4);
973                                 if (!useinlining) {
974                                         tablep = (s4*)(jcode + nextp);
975                                 }
976                                 else {
977                                         num = code_get_u4(nextp + 4);
978                                         tablep = DMNEW(s4, num * 2 + 2);
979                                 }
980
981                                 OP2A(opcode, 0, tablep);
982
983                                 /* default target */
984
985                                 j =  p + code_get_s4(nextp);
986                                 if (useinlining) j = label_index[j];
987                                 *tablep = j;     /* restore for little endian */
988                                 tablep++;
989                                 nextp += 4;
990                                 bound_check(j);
991                                 block_insert(j);
992
993                                 /* number of pairs */
994
995                                 num = code_get_u4(nextp);
996                                 *tablep = num;
997                                 tablep++;
998                                 nextp += 4;
999
1000                                 for (i = 0; i < num; i++) {
1001
1002                                         /* value */
1003
1004                                         j = code_get_s4(nextp);
1005                                         *tablep = j; /* restore for little endian */
1006                                         tablep++;
1007                                         nextp += 4;
1008
1009                                         /* target */
1010
1011                                         j = p + code_get_s4(nextp);
1012                                         if (useinlining) j = label_index[j];
1013                                         *tablep = j; /* restore for little endian */
1014                                         tablep++;
1015                                         nextp += 4;
1016                                         bound_check(j);
1017                                         block_insert(j);
1018                                         }
1019
1020                                 break;
1021                                 }
1022
1023
1024                         case JAVA_TABLESWITCH:
1025                                 {
1026                                 s4 num, j;
1027                                 s4 *tablep;
1028
1029                                 blockend = true;
1030                                 nextp = ALIGN((p + 1), 4);
1031                                 if (!useinlining) {
1032                                         tablep = (s4*)(jcode + nextp);
1033                                 }
1034                                 else {
1035                                         num = code_get_u4(nextp + 8) - code_get_u4(nextp + 4);
1036                                         tablep = DMNEW(s4, num + 1 + 3);
1037                                 }
1038
1039                                 OP2A(opcode, 0, tablep);
1040
1041                                 /* default target */
1042
1043                                 j = p + code_get_s4(nextp);
1044                                 if (useinlining) j = label_index[j];
1045                                 *tablep = j;     /* restore for little endian */
1046                                 tablep++;
1047                                 nextp += 4;
1048                                 bound_check(j);
1049                                 block_insert(j);
1050
1051                                 /* lower bound */
1052
1053                                 j = code_get_s4(nextp);
1054                                 *tablep = j;     /* restore for little endian */
1055                                 tablep++;
1056                                 nextp += 4;
1057
1058                                 /* upper bound */
1059
1060                                 num = code_get_s4(nextp);
1061                                 *tablep = num;   /* restore for little endian */
1062                                 tablep++;
1063                                 nextp += 4;
1064
1065                                 num -= j;
1066
1067                                 for (i = 0; i <= num; i++) {
1068                                         j = p + code_get_s4(nextp);
1069                                         if (useinlining) j = label_index[j];
1070                                         *tablep = j; /* restore for little endian */
1071                                         tablep++;
1072                                         nextp += 4;
1073                                         bound_check(j);
1074                                         block_insert(j);
1075                                         }
1076
1077                                 break;
1078                                 }
1079
1080
1081                         /* load and store of object fields *******************/
1082
1083                         case JAVA_AASTORE:
1084                                 BUILTIN3((functionptr) asm_builtin_aastore, TYPE_VOID);
1085                                 break;
1086
1087                         case JAVA_PUTSTATIC:
1088                         case JAVA_GETSTATIC:
1089                                 i = code_get_u2(p + 1);
1090                                 {
1091                                 constant_FMIref *fr;
1092                                 fieldinfo *fi;
1093                                 fr = class_getconstant (class, i, CONSTANT_Fieldref);
1094                                 fi = class_findfield (fr->class, fr->name, fr->descriptor);
1095                                 compiler_addinitclass (fr->class);
1096                                 OP2A(opcode, fi->type, fi);
1097                                 }
1098                                 break;
1099                         case JAVA_PUTFIELD:
1100                         case JAVA_GETFIELD:
1101                                 i = code_get_u2(p + 1);
1102                                 {
1103                                 constant_FMIref *fr;
1104                                 fieldinfo *fi;
1105                                 fr = class_getconstant (class, i, CONSTANT_Fieldref);
1106                                 fi = class_findfield (fr->class, fr->name, fr->descriptor);
1107                                 OP2A(opcode, fi->type, fi);
1108                                 }
1109                                 break;
1110
1111
1112                         /* method invocation *****/
1113
1114                         case JAVA_INVOKESTATIC:
1115                                 i = code_get_u2(p + 1);
1116                                 {
1117                                 constant_FMIref *mr;
1118                                 methodinfo *mi;
1119                                 
1120                                 mr = class_getconstant (class, i, CONSTANT_Methodref);
1121                                 mi = class_findmethod (mr->class, mr->name, mr->descriptor);
1122                                         /*RTAprint*/ if (((pOpcodes == 2) || (pOpcodes == 3)) && opt_rt)
1123                                         /*RTAprint*/    {printf(" method name =");
1124                                         /*RTAprint*/    utf_display(mi->class->name); printf(".");
1125                                         /*RTAprint*/    utf_display(mi->name);printf("\tINVOKE STATIC\n");
1126                                         /*RTAprint*/    fflush(stdout);}
1127                                 if (! (mi->flags & ACC_STATIC))
1128                                         panic ("Static/Nonstatic mismatch calling static method");
1129                                 descriptor2types(mi);
1130
1131                                 isleafmethod=false;
1132                                 OP2A(opcode, mi->paramcount, mi);
1133                                 }
1134                                 break;
1135                         case JAVA_INVOKESPECIAL:
1136                         case JAVA_INVOKEVIRTUAL:
1137                                 i = code_get_u2(p + 1);
1138                                 {
1139                                 constant_FMIref *mr;
1140                                 methodinfo *mi;
1141                                 
1142                                 mr = class_getconstant (class, i, CONSTANT_Methodref);
1143                                 mi = class_findmethod (mr->class, mr->name, mr->descriptor);
1144                                         /*RTAprint*/ if (((pOpcodes == 2) || (pOpcodes == 3)) && opt_rt)
1145                                         /*RTAprint*/    {printf(" method name =");
1146                                                         method_display(mi);
1147                                         /*RTAprint*/    utf_display(mi->class->name); printf(".");
1148                                         /*RTAprint*/    utf_display(mi->name);printf("\tINVOKE SPECIAL/VIRTUAL\n");
1149                                         /*RTAprint*/    fflush(stdout);}
1150
1151                                 if (mi->flags & ACC_STATIC)
1152                                         panic ("Static/Nonstatic mismatch calling static method");
1153                                 descriptor2types(mi);
1154                                 isleafmethod=false;
1155                                 OP2A(opcode, mi->paramcount, mi);
1156                                 }
1157                                 break;
1158                         case JAVA_INVOKEINTERFACE:
1159                                 i = code_get_u2(p + 1);
1160                                 {
1161                                 constant_FMIref *mr;
1162                                 methodinfo *mi;
1163                                 
1164                                 mr = class_getconstant (class, i, CONSTANT_InterfaceMethodref);
1165                                 mi = class_findmethod (mr->class, mr->name, mr->descriptor);
1166                                 if (mi->flags & ACC_STATIC)
1167                                         panic ("Static/Nonstatic mismatch calling static method");
1168                                 descriptor2types(mi);
1169                                 isleafmethod=false;
1170                                 OP2A(opcode, mi->paramcount, mi);
1171                                 }
1172                                 break;
1173
1174                         /* miscellaneous object operations *******/
1175
1176                         case JAVA_NEW:
1177                                 i = code_get_u2 (p+1);
1178
1179                                 LOADCONST_A(class_getconstant(class, i, CONSTANT_Class));
1180                                 s_count++;
1181                                 BUILTIN1((functionptr) builtin_new, TYPE_ADR);
1182                                 break;
1183
1184                         case JAVA_CHECKCAST:
1185                                 i = code_get_u2(p+1);
1186
1187                                 /* array type cast-check */
1188                                 if (class_constanttype (class, i) == CONSTANT_Arraydescriptor) {
1189                                         LOADCONST_A(class_getconstant(class, i, CONSTANT_Arraydescriptor));
1190                                         s_count++;
1191                                         BUILTIN2((functionptr) asm_builtin_checkarraycast, TYPE_ADR);
1192                                         }
1193                                 else { /* object type cast-check */
1194                                         /*
1195                                         LOADCONST_A(class_getconstant(class, i, CONSTANT_Class));
1196                                         s_count++;
1197                                         BUILTIN2((functionptr) asm_builtin_checkcast, TYPE_ADR);
1198                                         */
1199                                         OP2A(opcode, 1, (class_getconstant(class, i, CONSTANT_Class)));
1200                                         }
1201                                 break;
1202
1203                         case JAVA_INSTANCEOF:
1204                                 i = code_get_u2(p+1);
1205
1206                                 /* array type cast-check */
1207                                 if (class_constanttype (class, i) == CONSTANT_Arraydescriptor) {
1208                                         LOADCONST_A(class_getconstant(class, i, CONSTANT_Arraydescriptor));
1209                                         s_count++;
1210 #if defined(__I386__)
1211                                         BUILTIN2((functionptr) asm_builtin_arrayinstanceof, TYPE_INT);
1212 #else
1213                                         BUILTIN2((functionptr) builtin_arrayinstanceof, TYPE_INT);
1214 #endif
1215                                         }
1216                                 else { /* object type cast-check */
1217                                         /*
1218                                         LOADCONST_A(class_getconstant(class, i, CONSTANT_Class));
1219                                         s_count++;
1220                                         BUILTIN2((functionptr) builtin_instanceof, TYPE_INT);
1221                                         */
1222                                         OP2A(opcode, 1, (class_getconstant(class, i, CONSTANT_Class)));
1223                                         }
1224                                 break;
1225
1226                         case JAVA_MONITORENTER:
1227 #ifdef USE_THREADS
1228                                 if (checksync) {
1229                                         BUILTIN1((functionptr) asm_builtin_monitorenter, TYPE_VOID);
1230                                 } else
1231 #endif
1232                                         {
1233                                         OP(ICMD_NULLCHECKPOP);
1234                                         }
1235                                 break;
1236
1237                         case JAVA_MONITOREXIT:
1238 #ifdef USE_THREADS
1239                                 if (checksync) {
1240                                         BUILTIN1((functionptr) asm_builtin_monitorexit, TYPE_VOID);
1241                                         }
1242                                 else
1243 #endif
1244                                         {
1245                                         OP(ICMD_POP);
1246                                         }
1247                                 break;
1248
1249                         /* any other basic operation **************************************/
1250
1251                         case JAVA_IDIV:
1252                                 OP(opcode);
1253                                 break;
1254
1255                         case JAVA_IREM:
1256                                 OP(opcode);
1257                                 break;
1258
1259                         case JAVA_LDIV:
1260                                 OP(opcode);
1261                                 break;
1262
1263                         case JAVA_LREM:
1264                                 OP(opcode);
1265                                 break;
1266
1267                         case JAVA_FREM:
1268 #if defined(__I386__)
1269                                 OP(opcode);
1270 #else
1271                                 BUILTIN2((functionptr) builtin_frem, TYPE_FLOAT);
1272 #endif
1273                                 break;
1274
1275                         case JAVA_DREM:
1276 #if defined(__I386__)
1277                                 OP(opcode);
1278 #else
1279                                 BUILTIN2((functionptr) builtin_drem, TYPE_DOUBLE);
1280 #endif
1281                                 break;
1282
1283                         case JAVA_F2I:
1284 #if defined(__ALPHA__)
1285                                 if (!opt_noieee) {
1286                                         BUILTIN1((functionptr) builtin_f2i, TYPE_INT);
1287                                 } else
1288 #endif
1289                                 {
1290                                         OP(opcode);
1291                                 }
1292                                 break;
1293
1294                         case JAVA_F2L:
1295 #if defined(__ALPHA__)
1296                                 if (!opt_noieee) {
1297                                         BUILTIN1((functionptr) builtin_f2l, TYPE_LONG);
1298                                 } else 
1299 #endif
1300                                 {
1301                                         OP(opcode);
1302                                 }
1303                                 break;
1304
1305                         case JAVA_D2I:
1306 #if defined(__ALPHA__)
1307                                 if (!opt_noieee) {
1308                                         BUILTIN1((functionptr) builtin_d2i, TYPE_INT);
1309                                 } else
1310 #endif
1311                                 {
1312                                         OP(opcode);
1313                                 }
1314                                 break;
1315
1316                         case JAVA_D2L:
1317 #if defined(__ALPHA__)
1318                                 if (!opt_noieee) {
1319                                         BUILTIN1((functionptr) builtin_d2l, TYPE_LONG);
1320                                 } else
1321 #endif
1322                                 {
1323                                         OP(opcode);
1324                                 }
1325                                 break;
1326
1327                         case JAVA_BREAKPOINT:
1328                                 panic("Illegal opcode Breakpoint encountered");
1329                                 break;
1330
1331                         case 203:
1332                         case 204:
1333                         case 205:
1334                         case 206:
1335                         case 207:
1336                         case 208:
1337                         case 209:
1338                         case 210:
1339                         case 211:
1340                         case 212:
1341                         case 213:
1342                         case 214:
1343                         case 215:
1344                         case 216:
1345                         case 217:
1346                         case 218:
1347                         case 219:
1348                         case 220:
1349                         case 221:
1350                         case 222:
1351                         case 223:
1352                         case 224:
1353                         case 225:
1354                         case 226:
1355                         case 227:
1356                         case 228:
1357                         case 229:
1358                         case 230:
1359                         case 231:
1360                         case 232:
1361                         case 233:
1362                         case 234:
1363                         case 235:
1364                         case 236:
1365                         case 237:
1366                         case 238:
1367                         case 239:
1368                         case 240:
1369                         case 241:
1370                         case 242:
1371                         case 243:
1372                         case 244:
1373                         case 245:
1374                         case 246:
1375                         case 247:
1376                         case 248:
1377                         case 249:
1378                         case 250:
1379                         case 251:
1380                         case 252:
1381                         case 253:
1382                         case 254:
1383                         case 255:
1384                                 printf("Illegal opcode %d at instr %d", opcode, ipc);
1385                                 panic("encountered");
1386                                 break;
1387
1388                         default:
1389                                 OP(opcode);
1390                                 break;
1391                                 
1392                     } /* end switch */
1393                 
1394                 /* INLINING */
1395                   
1396                 if ((isinlinedmethod) && (p==jcodelength-1)) { /*end of an inlined method */
1397                   /*              printf("setting gp from %d to %d\n",gp, inlinfo->stopgp); */
1398                   gp = inlinfo->stopgp; 
1399                   inlining_restore_compiler_variables();
1400                   list_remove(inlinfo->inlinedmethods, list_first(inlinfo->inlinedmethods));
1401                   if (inlinfo->inlinedmethods == NULL) nextgp = -1;
1402                   else {
1403                           tmpinlinf = list_first(inlinfo->inlinedmethods);
1404                           nextgp = (tmpinlinf != NULL) ? tmpinlinf->startgp : -1;
1405                   }
1406                   /*              printf("nextpgp: %d\n", nextgp); */
1407                   label_index=inlinfo->label_index;
1408                   firstlocal = inlinfo->firstlocal;
1409                 }
1410
1411                 } /* end for */
1412         if (p != jcodelength)
1413                 panic("Command-sequence crosses code-boundary");
1414
1415         if (!blockend)
1416                 panic("Code does not end with branch/return/athrow - stmt");    
1417
1418         /* adjust block count if target 0 is not first intermediate instruction   */
1419
1420         if (!block_index[0] || (block_index[0] > 1))
1421                 b_count++;
1422
1423         /* copy local to global variables   */
1424
1425         instr_count = ipc;
1426         block_count = b_count;
1427         stack_count = s_count + block_count * maxstack;
1428
1429         /* allocate stack table */
1430
1431         stack = DMNEW(stackelement, stack_count);
1432
1433         {
1434         basicblock  *bptr;
1435
1436         bptr = block = DMNEW(basicblock, b_count + 1);    /* one more for end ipc */
1437
1438         b_count = 0;
1439         c_debug_nr = 0;
1440         
1441         /* additional block if target 0 is not first intermediate instruction     */
1442
1443         if (!block_index[0] || (block_index[0] > 1)) {
1444                 bptr->iinstr = instr;
1445                 bptr->mpc = -1;
1446                 bptr->flags = -1;
1447                 bptr->type = BBTYPE_STD;
1448                 bptr->branchrefs = NULL;
1449                 bptr->pre_count = 0;
1450                 bptr->debug_nr = c_debug_nr++;
1451                 bptr++;
1452                 b_count++;
1453                 (bptr - 1)->next = bptr;
1454         
1455                 }
1456
1457         /* allocate blocks */
1458
1459
1460         for (p = 0; p < cumjcodelength; p++)
1461                 
1462                 if (block_index[p] & 1) {
1463                         bptr->iinstr = instr + (block_index[p] >> 1);
1464                         bptr->debug_nr = c_debug_nr++;
1465                         if (b_count != 0)
1466                                 (bptr - 1)->icount = bptr->iinstr - (bptr - 1)->iinstr;
1467                         bptr->mpc = -1;
1468                         bptr->flags = -1;
1469                         bptr->lflags = 0;
1470                         bptr->type = BBTYPE_STD;
1471                         bptr->branchrefs = NULL;
1472                         block_index[p] = b_count;
1473                         bptr->pre_count = 0;
1474                         bptr++;
1475                         b_count++;
1476
1477                         (bptr - 1)->next = bptr;
1478                         }
1479
1480         /* allocate additional block at end */
1481
1482         
1483         bptr->instack = bptr->outstack = NULL;
1484         bptr->indepth = bptr->outdepth = 0;
1485         bptr->iinstr = NULL;
1486         (bptr - 1)->icount = (instr + instr_count) - (bptr - 1)->iinstr;
1487         bptr->icount = 0;
1488         bptr->mpc = -1;
1489         bptr->flags = -1;
1490         bptr->lflags = 0;
1491         bptr->type = BBTYPE_STD;
1492         bptr->branchrefs = NULL;
1493         bptr->pre_count = 0;
1494         bptr->debug_nr = c_debug_nr++;
1495                         
1496         (bptr - 1)->next = bptr;
1497         bptr->next = NULL;
1498
1499         last_block = bptr;
1500
1501         if (exceptiontablelength > 0)
1502                 extable[exceptiontablelength-1].down = NULL;
1503         else
1504                 extable = NULL;
1505
1506         for (i = 0; i < exceptiontablelength; ++i) {
1507                 p = extable[i].startpc;
1508                 extable[i].start = block + block_index[p];
1509
1510                 p = extable[i].endpc;
1511                 extable[i].end = block + block_index[p]; 
1512
1513                 p = extable[i].handlerpc;
1514                 extable[i].handler = block + block_index[p];
1515             }
1516         }
1517         
1518         if (useinlining) inlining_cleanup();
1519         useinlining = useinltmp;
1520 }
1521 #include "sets.c"
1522 #include "parseRT.h"
1523
1524 /*
1525  * These are local overrides for various environment variables in Emacs.
1526  * Please do not remove this and leave it at the end of the file, where
1527  * Emacs will automagically detect them.
1528  * ---------------------------------------------------------------------
1529  * Local variables:
1530  * mode: c
1531  * indent-tabs-mode: t
1532  * c-basic-offset: 4
1533  * tab-width: 4
1534  * End:
1535  */