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