* src/vm/jit/allocator/simplereg.c (reg_new_temp_func): Removed old
[cacao.git] / src / vm / jit / allocator / simplereg.c
1 /* src/vm/jit/allocator/simplereg.c - register allocator
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: Stefan Ring
30             Christian Thalinger
31             Christian Ullrich
32             Michael Starzinger
33             Edwin Steiner
34
35    $Id: simplereg.c 5414 2006-09-07 22:44:07Z edwin $
36
37 */
38
39
40 #include "config.h"
41 #include "vm/types.h"
42
43 #include <assert.h>
44
45 #include "arch.h"
46 #include "md-abi.h"
47
48 #include "vm/builtin.h"
49 #include "vm/exceptions.h"
50 #include "mm/memory.h"
51 #include "vm/method.h"
52 #include "vm/options.h"
53 #include "vm/resolve.h"
54 #include "vm/stringlocal.h"
55 #include "vm/jit/reg.h"
56 #include "vm/jit/allocator/simplereg.h"
57
58
59 /* function prototypes for this file ******************************************/
60
61 static void interface_regalloc(jitdata *jd);
62 static void local_regalloc(jitdata *jd);
63 static void new_allocate_scratch_registers(jitdata *jd);
64 static void allocate_scratch_registers(jitdata *jd);
65
66
67 /* regalloc ********************************************************************
68
69    Does a simple register allocation.
70         
71 *******************************************************************************/
72         
73 bool new_regalloc(jitdata *jd)
74 {
75         /* There is a problem with the use of unused float argument
76            registers in leafmethods for stackslots on c7 (2 * Dual Core
77            AMD Opteron(tm) Processor 270) - runtime for the jvm98 _mtrt
78            benchmark is heaviliy increased. This could be prevented by
79            setting rd->argfltreguse to FLT_ARG_CNT before calling
80            allocate_scratch_registers and setting it back to the original
81            value before calling local_regalloc.  */
82
83         printf("------- rd->memuse bef %d\n",jd->rd->memuse);
84
85         interface_regalloc(jd);
86         printf("------- rd->memuse int %d\n",jd->rd->memuse);
87         new_allocate_scratch_registers(jd);
88         printf("------- rd->memuse scr %d\n",jd->rd->memuse);
89         local_regalloc(jd);
90         printf("------- rd->memuse loc %d\n",jd->rd->memuse);
91
92         /* everthing's ok */
93
94         return true;
95 }
96
97 /* interface_regalloc **********************************************************
98
99    Allocates registers for all interface variables.
100         
101 *******************************************************************************/
102         
103 static void interface_regalloc(jitdata *jd)
104 {
105         methodinfo   *m;
106         codegendata  *cd;
107         registerdata *rd;
108
109         int     s, t, tt, saved;
110         int     intalloc, fltalloc; /* Remember allocated Register/Memory offset */
111                         /* in case more vars are packed into this interface slot */
112         varinfo *v;
113         int             intregsneeded = 0;
114         int             memneeded = 0;
115     /* allocate LNG and DBL Types first to ensure 2 memory slots or registers */
116         /* on HAS_4BYTE_STACKSLOT architectures */
117         int     typeloop[] = { TYPE_LNG, TYPE_DBL, TYPE_INT, TYPE_FLT, TYPE_ADR };
118
119         /* get required compiler data */
120
121         m  = jd->m;
122         cd = jd->cd;
123         rd = jd->rd;
124
125         /* rd->memuse was already set in stack.c to allocate stack space
126            for passing arguments to called methods. */
127
128 #if defined(__I386__)
129         if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
130                 /* reserve 0(%esp) for Monitorenter/exit Argument on i386 */
131                 if (rd->memuse < 1)
132                         rd->memuse = 1;
133         }
134 #endif
135
136         if (jd->isleafmethod) {
137                 /* Reserve argument register, which will be used for Locals acting */
138                 /* as Parameters */
139                 if (rd->argintreguse < m->parseddesc->argintreguse)
140                         rd->argintreguse = m->parseddesc->argintreguse;
141                 if (rd->argfltreguse < m->parseddesc->argfltreguse)
142                         rd->argfltreguse = m->parseddesc->argfltreguse;
143 #ifdef HAS_ADDRESS_REGISTER_FILE
144                 if (rd->argadrreguse < m->parseddesc->argadrreguse)
145                         rd->argadrreguse = m->parseddesc->argadrreguse;
146 #endif
147
148         }
149
150         for (s = 0; s < cd->maxstack; s++) {
151                 intalloc = -1; fltalloc = -1;
152
153                 saved = 0;
154
155                 for (tt = 0; tt <=4; tt++) {
156                         if ((t = jd->interface_map[s * 5 + TYPE_INT]) != UNUSED) {
157                                 saved |= (jd->var[t].flags & SAVEDVAR);
158                         }
159                 }
160
161                 for (tt = 0; tt <= 4; tt++) {
162                         t = typeloop[tt];
163                         if (jd->interface_map[s * 5 + t] == UNUSED)
164                                 continue;
165
166                         v = &(jd->var[jd->interface_map[s * 5 + t]]);
167 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
168                                 intregsneeded = (IS_2_WORD_TYPE(t)) ? 1 : 0;
169 #endif
170 #if defined(HAS_4BYTE_STACKSLOT)
171                                 memneeded = (IS_2_WORD_TYPE(t)) ? 1 : 0;
172 #endif
173                                 if (!saved) {
174 #if defined(HAS_ADDRESS_REGISTER_FILE)
175                                         if (IS_ADR_TYPE(t)) {
176                                                 if (!jd->isleafmethod 
177                                                         &&(rd->argadrreguse < ADR_ARG_CNT)) {
178                                                         v->regoff = rd->argadrregs[rd->argadrreguse++];
179                                                 } else if (rd->tmpadrreguse > 0) {
180                                                                 v->regoff = rd->tmpadrregs[--rd->tmpadrreguse];
181                                                 } else if (rd->savadrreguse > 0) {
182                                                                 v->regoff = rd->savadrregs[--rd->savadrreguse];
183                                                 } else {
184                                                         v->flags |= INMEMORY;
185                                                         v->regoff = rd->memuse++;
186                                                 }                                               
187                                         } else /* !IS_ADR_TYPE */
188 #endif /* defined(HAS_ADDRESS_REGISTER_FILE) */
189                                         {
190                                                 if (IS_FLT_DBL_TYPE(t)) {
191                                                         if (fltalloc >= 0) {
192                        /* Reuse memory slot(s)/register(s) for shared interface slots */
193                                                                 v->flags |= jd->var[fltalloc].flags & INMEMORY;
194                                                                 v->regoff = jd->var[fltalloc].regoff;
195                                                         } else if (rd->argfltreguse < FLT_ARG_CNT) {
196                                                                 v->regoff = rd->argfltregs[rd->argfltreguse++];
197                                                         } else if (rd->tmpfltreguse > 0) {
198                                                                 v->regoff = rd->tmpfltregs[--rd->tmpfltreguse];
199                                                         } else if (rd->savfltreguse > 0) {
200                                                                 v->regoff = rd->savfltregs[--rd->savfltreguse];
201                                                         } else {
202                                                                 v->flags |= INMEMORY;
203 #if defined(ALIGN_DOUBLES_IN_MEMORY)
204                                                                 /* Align doubles in Memory */
205                                                                 if ( (memneeded) && (rd->memuse & 1))
206                                                                         rd->memuse++;
207 #endif
208                                                                 v->regoff = rd->memuse;
209                                                                 rd->memuse += memneeded + 1;
210                                                         }
211                                                         fltalloc = jd->interface_map[s * 5 + t];
212                                                 } else { /* !IS_FLT_DBL_TYPE(t) */
213 #if defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
214                                                         /*
215                                                          * for i386 put all longs in memory
216                                                          */
217                                                         if (IS_2_WORD_TYPE(t)) {
218                                                                 v->flags |= INMEMORY;
219 #if defined(ALIGN_LONGS_IN_MEMORY)
220                                                                 /* Align longs in Memory */
221                                                                 if (rd->memuse & 1)
222                                                                         rd->memuse++;
223 #endif
224                                                                 v->regoff = rd->memuse;
225                                                                 rd->memuse += memneeded + 1;
226                                                         } else
227 #endif /* defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE...GISTERS) */
228                                                                 if (intalloc >= 0) {
229                        /* Reuse memory slot(s)/register(s) for shared interface slots */
230                                                                         v->flags |= jd->var[intalloc].flags 
231                                                                                         & INMEMORY;
232 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
233                                                                         if (!(v->flags & INMEMORY) 
234                                                                           && IS_2_WORD_TYPE(jd->var[intalloc].type))
235                                                                                 v->regoff = GET_LOW_REG(
236                                                                                         jd->var[intalloc].regoff);
237                                                                         else
238 #endif
239                                                                                 v->regoff = 
240                                                                                     jd->var[intalloc].regoff;
241                                                                 } else 
242                                                                         if (rd->argintreguse + intregsneeded 
243                                                                                 < INT_ARG_CNT) {
244 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
245                                                                                 if (intregsneeded) 
246                                                                                         v->regoff=PACK_REGS( 
247                                                                                   rd->argintregs[rd->argintreguse],
248                                                                                   rd->argintregs[rd->argintreguse + 1]);
249                                                                                 else
250 #endif
251                                                                                         v->regoff = 
252                                                                                            rd->argintregs[rd->argintreguse];
253                                                                                 rd->argintreguse += intregsneeded + 1;
254                                                                         }
255                                                                         else if (rd->tmpintreguse > intregsneeded) {
256                                                                                 rd->tmpintreguse -= intregsneeded + 1;
257 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
258                                                                                 if (intregsneeded) 
259                                                                                         v->regoff=PACK_REGS( 
260                                                                                   rd->tmpintregs[rd->tmpintreguse],
261                                                                                   rd->tmpintregs[rd->tmpintreguse + 1]);
262                                                                                 else
263 #endif
264                                                                                         v->regoff = 
265                                                                                            rd->tmpintregs[rd->tmpintreguse];
266                                                                         }
267                                                                         else if (rd->savintreguse > intregsneeded) {
268                                                                                 rd->savintreguse -= intregsneeded + 1;
269                                                                                 v->regoff = 
270                                                                                         rd->savintregs[rd->savintreguse];
271 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
272                                                                                 if (intregsneeded) 
273                                                                                         v->regoff=PACK_REGS( 
274                                                                                   rd->savintregs[rd->savintreguse],
275                                                                                   rd->savintregs[rd->savintreguse + 1]);
276                                                                                 else
277 #endif
278                                                                                         v->regoff = 
279                                                                                            rd->savintregs[rd->savintreguse];
280                                                                         }
281                                                                         else {
282                                                                                 v->flags |= INMEMORY;
283 #if defined(ALIGN_LONGS_IN_MEMORY)
284                                                                                 /* Align longs in Memory */
285                                                                                 if ( (memneeded) && (rd->memuse & 1))
286                                                                                         rd->memuse++;
287 #endif
288                                                                                 v->regoff = rd->memuse;
289                                                                                 rd->memuse += memneeded + 1;
290                                                                         }
291
292                                                         intalloc = jd->interface_map[s * 5 + t];
293                                                 } /* if (IS_FLT_DBL_TYPE(t)) */
294                                         } 
295                                 } else { /* (saved) */
296 /* now the same like above, but without a chance to take a temporary register */
297 #ifdef HAS_ADDRESS_REGISTER_FILE
298                                         if (IS_ADR_TYPE(t)) {
299                                                 if (rd->savadrreguse > 0) {
300                                                         v->regoff = rd->savadrregs[--rd->savadrreguse];
301                                                 }
302                                                 else {
303                                                         v->flags |= INMEMORY;
304                                                         v->regoff = rd->memuse++;
305                                                 }                                               
306                                         } else
307 #endif
308                                         {
309                                                 if (IS_FLT_DBL_TYPE(t)) {
310                                                         if (fltalloc >= 0) {
311                                                                 v->flags |= jd->var[fltalloc].flags & INMEMORY;
312                                                                 v->regoff = jd->var[fltalloc].regoff;
313                                                         } else
314                                                                 if (rd->savfltreguse > 0) {
315                                                                         v->regoff = 
316                                                                                 rd->savfltregs[--rd->savfltreguse];
317                                                                 }
318                                                                 else {
319                                                                         v->flags |= INMEMORY;
320 #if defined(ALIGN_DOUBLES_IN_MEMORY)
321                                                                         /* Align doubles in Memory */
322                                                                         if ( (memneeded) && (rd->memuse & 1))
323                                                                                 rd->memuse++;
324 #endif
325                                                                         v->regoff = rd->memuse;
326                                                                         rd->memuse += memneeded + 1;
327                                                                 }
328                                                         fltalloc = jd->interface_map[s * 5 + t];
329                                                 }
330                                                 else { /* IS_INT_LNG */
331 #if defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
332                                                         /*
333                                                          * for i386 put all longs in memory
334                                                          */
335                                                         if (IS_2_WORD_TYPE(t)) {
336                                                                 v->flags |= INMEMORY;
337 #if defined(ALIGN_LONGS_IN_MEMORY)
338                                                                 /* Align longs in Memory */
339                                                                 if (rd->memuse & 1)
340                                                                         rd->memuse++;
341 #endif
342                                                                 v->regoff = rd->memuse;
343                                                                 rd->memuse += memneeded + 1;
344                                                         } else
345 #endif
346                                                         {
347                                                                 if (intalloc >= 0) {
348                                                                         v->flags |= jd->var[intalloc].flags 
349                                                                                         & INMEMORY;
350 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
351                                                                         if (!(v->flags & INMEMORY)
352                                                                           && IS_2_WORD_TYPE(jd->var[intalloc].type))
353                                                                                 v->regoff =
354                                                                                         GET_LOW_REG(
355                                                                                         jd->var[intalloc].regoff);
356                                                                         else
357 #endif
358                                                                                 v->regoff =
359                                                                                     jd->var[intalloc].regoff;
360                                                                 } else {
361                                                                         if (rd->savintreguse > intregsneeded) {
362                                                                                 rd->savintreguse -= intregsneeded + 1;
363 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
364                                                                                 if (intregsneeded) 
365                                                                                         v->regoff = PACK_REGS( 
366                                                                                   rd->savintregs[rd->savintreguse],
367                                                                                   rd->savintregs[rd->savintreguse + 1]);
368                                                                                 else
369 #endif
370                                                                                         v->regoff =
371                                                                                            rd->savintregs[rd->savintreguse];
372                                                                         } else {
373                                                                                 v->flags |= INMEMORY;
374 #if defined(ALIGN_LONGS_IN_MEMORY)
375                                                                         /* Align longs in Memory */
376                                                                         if ( (memneeded) && (rd->memuse & 1))
377                                                                                 rd->memuse++;
378 #endif
379                                                                                 v->regoff = rd->memuse;
380                                                                                 rd->memuse += memneeded + 1;
381                                                                         }
382                                                                 }
383                                                                 intalloc = t;
384                                                         }
385                                                 } /* if (IS_FLT_DBL_TYPE(t) else */
386                                         } /* if (IS_ADR_TYPE(t)) else */
387                                 } /* if (saved) else */
388                         /* if (type >= 0) */
389                 } /* for t */
390         } /* for s */
391 }
392
393
394
395 /* local_regalloc **************************************************************
396
397    Allocates registers for all local variables.
398         
399 *******************************************************************************/
400         
401 static void local_regalloc(jitdata *jd)
402 {
403         methodinfo   *m;
404         codegendata  *cd;
405         registerdata *rd;
406
407         int     p, s, t, tt,lm;
408         int     intalloc, fltalloc;
409         varinfo *v;
410         int     intregsneeded = 0;
411         int     memneeded = 0;
412         int     typeloop[] = { TYPE_LNG, TYPE_DBL, TYPE_INT, TYPE_FLT, TYPE_ADR };
413         int     fargcnt, iargcnt;
414 #ifdef HAS_ADDRESS_REGISTER_FILE
415         int     aargcnt;
416 #endif
417
418         /* get required compiler data */
419
420         m  = jd->m;
421         cd = jd->cd;
422         rd = jd->rd;
423
424         if (jd->isleafmethod) {
425                 methoddesc *md = m->parseddesc;
426
427                 iargcnt = rd->argintreguse;
428                 fargcnt = rd->argfltreguse;
429 #ifdef HAS_ADDRESS_REGISTER_FILE
430                 aargcnt = rd->argadrreguse;
431 #endif
432                 for (p = 0, s = 0; s < cd->maxlocals; s++, p++) {
433                         intalloc = -1; fltalloc = -1;
434                         for (tt = 0; tt <= 4; tt++) {
435                                 t = typeloop[tt];
436                                 lm = jd->local_map[s * 5 + t];
437                                 if (lm == UNUSED)
438                                         continue;
439
440                                 v = &(jd->var[lm]);
441
442 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
443                                 intregsneeded = (IS_2_WORD_TYPE(t)) ? 1 : 0;
444 #endif
445 #if defined(HAS_4BYTE_STACKSLOT)
446                                 memneeded = (IS_2_WORD_TYPE(t)) ? 1 : 0;
447 #endif
448
449                                 /*
450                                  *  The order of
451                                  *
452                                  *  #ifdef HAS_ADDRESS_REGISTER_FILE
453                                  *  if (IS_ADR_TYPE) { 
454                                  *  ...
455                                  *  } else 
456                                  *  #endif
457                                  *  if (IS_FLT_DBL) {
458                                  *  ...
459                                  *  } else { / int & lng
460                                  *  ...
461                                  *  }
462                                  *
463                                  *  must not to be changed!
464                                  */
465
466 #ifdef HAS_ADDRESS_REGISTER_FILE
467                                 if (IS_ADR_TYPE(t)) {
468                                         if ((p < md->paramcount) && !md->params[p].inmemory) {
469                                                 v->flags = 0;
470                                                 v->regoff = rd->argadrregs[md->params[p].regoff];
471                                         }
472                                         else if (rd->tmpadrreguse > 0) {
473                                                 v->flags = 0;
474                                                 v->regoff = rd->tmpadrregs[--rd->tmpadrreguse];
475                                         }
476                                         /* use unused argument registers as local registers */
477                                         else if ((p >= md->paramcount) &&
478                                                          (aargcnt < ADR_ARG_CNT)) {
479                                                 v->flags = 0;
480                                                 v->regoff = rd->argadrregs[aargcnt++];
481                                         }
482                                         else if (rd->savadrreguse > 0) {
483                                                 v->flags = 0;
484                                                 v->regoff = rd->savadrregs[--rd->savadrreguse];
485                                         }
486                                         else {
487                                                 v->flags |= INMEMORY;
488                                                 v->regoff = rd->memuse++;
489                                         }                                               
490                                 } else {
491 #endif
492                                         if (IS_FLT_DBL_TYPE(t)) {
493                                                 if (fltalloc >= 0) {
494                                                         v->flags = jd->var[fltalloc].flags;
495                                                         v->regoff = jd->var[fltalloc].regoff;
496                                                 }
497 #if !defined(SUPPORT_PASS_FLOATARGS_IN_INTREGS)
498                                                 /* We can only use float arguments as local variables,
499                                                  * if we do not pass them in integer registers. */
500                                                 else if ((p < md->paramcount) &&
501                                                                  !md->params[p].inmemory) {
502                                                         v->flags = 0;
503                                                         v->regoff = rd->argfltregs[md->params[p].regoff];
504                                                 }
505 #endif
506                                                 else if (rd->tmpfltreguse > 0) {
507                                                         v->flags = 0;
508                                                         v->regoff = rd->tmpfltregs[--rd->tmpfltreguse];
509                                                 }
510                                                 /* use unused argument registers as local registers */
511                                                 else if ((p >= md->paramcount) &&
512                                                                  (fargcnt < FLT_ARG_CNT)) {
513                                                         v->flags = 0;
514                                                         v->regoff = rd->argfltregs[fargcnt];
515                                                         fargcnt++;
516                                                 }
517                                                 else if (rd->savfltreguse > 0) {
518                                                         v->flags = 0;
519                                                         v->regoff = rd->savfltregs[--rd->savfltreguse];
520                                                 }
521                                                 else {
522                                                         v->flags = INMEMORY;
523 #if defined(ALIGN_DOUBLES_IN_MEMORY)
524                                                         /* Align doubles in Memory */
525                                                         if ( (memneeded) && (rd->memuse & 1))
526                                                                 rd->memuse++;
527 #endif
528                                                         v->regoff = rd->memuse;
529                                                         rd->memuse += memneeded + 1;
530                                                 }
531                                                 fltalloc = jd->local_map[s * 5 + t];
532
533                                         } else {
534 #if defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
535                                                 /*
536                                                  * for i386 put all longs in memory
537                                                  */
538                                                 if (IS_2_WORD_TYPE(t)) {
539                                                         v->flags = INMEMORY;
540 #if defined(ALIGN_LONGS_IN_MEMORY)
541                                                         /* Align longs in Memory */
542                                                         if (rd->memuse & 1)
543                                                                 rd->memuse++;
544 #endif
545                                                         v->regoff = rd->memuse;
546                                                         rd->memuse += memneeded + 1;
547                                                 } else 
548 #endif
549                                                 {
550                                                         if (intalloc >= 0) {
551                                                                 v->flags = jd->var[intalloc].flags;
552 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
553                                                                 if (!(v->flags & INMEMORY)
554                                                                         && IS_2_WORD_TYPE(jd->var[intalloc].type))
555                                                                         v->regoff = GET_LOW_REG(
556                                                                                                         jd->var[intalloc].regoff);
557                                                                 else
558 #endif
559                                                                         v->regoff = jd->var[intalloc].regoff;
560                                                         }
561                                                         else if ((p < md->paramcount) && 
562                                                                          !md->params[p].inmemory) {
563                                                                 v->flags = 0;
564 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
565                                                                 if (IS_2_WORD_TYPE(t))
566                                                                         v->regoff = PACK_REGS(
567                                                         rd->argintregs[GET_LOW_REG(md->params[p].regoff)],
568                                                         rd->argintregs[GET_HIGH_REG(md->params[p].regoff)]);
569                                                                         else
570 #endif
571                                                                                 v->regoff =
572                                                                                rd->argintregs[md->params[p].regoff];
573                                                         }
574                                                         else if (rd->tmpintreguse > intregsneeded) {
575                                                                 rd->tmpintreguse -= intregsneeded + 1;
576                                                                 v->flags = 0;
577 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
578                                                                 if (intregsneeded) 
579                                                                         v->regoff = PACK_REGS(
580                                                                             rd->tmpintregs[rd->tmpintreguse],
581                                                                                 rd->tmpintregs[rd->tmpintreguse + 1]);
582                                                                 else
583 #endif
584                                                                         v->regoff = 
585                                                                                 rd->tmpintregs[rd->tmpintreguse];
586                                                         }
587                                                         /*
588                                                          * use unused argument registers as local registers
589                                                          */
590                                                         else if ((p >= m->parseddesc->paramcount) &&
591                                                                          (iargcnt + intregsneeded < INT_ARG_CNT)) {
592                                                                 v->flags = 0;
593 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
594                                                                 if (intregsneeded) 
595                                                                         v->regoff=PACK_REGS( 
596                                                                                                    rd->argintregs[iargcnt],
597                                                                                                    rd->argintregs[iargcnt + 1]);
598                                                                 else
599 #endif
600                                                                 v->regoff = rd->argintregs[iargcnt];
601                                                                 iargcnt += intregsneeded + 1;
602                                                         }
603                                                         else if (rd->savintreguse > intregsneeded) {
604                                                                 rd->savintreguse -= intregsneeded + 1;
605                                                                 v->flags = 0;
606 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
607                                                                 if (intregsneeded) 
608                                                                         v->regoff = PACK_REGS(
609                                                                             rd->savintregs[rd->savintreguse],
610                                                                                 rd->savintregs[rd->savintreguse + 1]);
611                                                                 else
612 #endif
613                                                                         v->regoff =rd->savintregs[rd->savintreguse];
614                                                         }
615                                                         else {
616                                                                 v->flags = INMEMORY;
617 #if defined(ALIGN_LONGS_IN_MEMORY)
618                                                                 /* Align longs in Memory */
619                                                                 if ( (memneeded) && (rd->memuse & 1))
620                                                                         rd->memuse++;
621 #endif
622                                                                 v->regoff = rd->memuse;
623                                                                 rd->memuse += memneeded + 1;
624                                                         }
625                                                 }
626                                                 intalloc = jd->local_map[s * 5 + t];
627                                         }
628 #ifdef HAS_ADDRESS_REGISTER_FILE
629                                 }
630 #endif
631                         } /* for (tt=0;...) */
632
633                         /* If the current parameter is a 2-word type, the next local slot */
634                         /* is skipped.                                                    */
635
636                         if (p < md->paramcount)
637                                 if (IS_2_WORD_TYPE(md->paramtypes[p].type))
638                                         s++;
639                 }
640                 return;
641         }
642
643         for (s = 0; s < cd->maxlocals; s++) {
644                 intalloc = -1; fltalloc = -1;
645                 for (tt=0; tt<=4; tt++) {
646                         t = typeloop[tt];
647
648                         lm = jd->local_map[s * 5 + t];
649                         if (lm == UNUSED)
650                                 continue;
651
652                         v = &(jd->var[lm]);
653
654 #ifdef SUPPORT_COMBINE_INTEGER_REGISTERS
655                                 intregsneeded = (IS_2_WORD_TYPE(t)) ? 1 : 0;
656 #endif
657 #if defined(HAS_4BYTE_STACKSLOT)
658                                 memneeded = (IS_2_WORD_TYPE(t)) ? 1 : 0;
659 #endif
660 #ifdef HAS_ADDRESS_REGISTER_FILE
661                                 if ( IS_ADR_TYPE(t) ) {
662                                         if (rd->savadrreguse > 0) {
663                                                 v->flags = 0;
664                                                 v->regoff = rd->savadrregs[--rd->savadrreguse];
665                                         }
666                                         else {
667                                                 v->flags = INMEMORY;
668                                                 v->regoff = rd->memuse++;
669                                         }
670                                 } else {
671 #endif
672                                 if (IS_FLT_DBL_TYPE(t)) {
673                                         if (fltalloc >= 0) {
674                                                 v->flags = jd->var[fltalloc].flags;
675                                                 v->regoff = jd->var[fltalloc].regoff;
676                                         }
677                                         else if (rd->savfltreguse > 0) {
678                                                 v->flags = 0;
679                                                 v->regoff = rd->savfltregs[--rd->savfltreguse];
680                                         }
681                                         else {
682                                                 v->flags = INMEMORY;
683 #if defined(ALIGN_DOUBLES_IN_MEMORY)
684                                                 /* Align doubles in Memory */
685                                                 if ( (memneeded) && (rd->memuse & 1))
686                                                         rd->memuse++;
687 #endif
688                                                 v->regoff = rd->memuse;
689                                                 rd->memuse += memneeded + 1;
690                                         }
691                                         fltalloc = jd->local_map[s * 5 + t];
692                                 }
693                                 else {
694 #if defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
695                                         /*
696                                          * for i386 put all longs in memory
697                                          */
698                                         if (IS_2_WORD_TYPE(t)) {
699                                                 v->flags = INMEMORY;
700 #if defined(ALIGN_LONGS_IN_MEMORY)
701                                                 /* Align longs in Memory */
702                                                 if (rd->memuse & 1)
703                                                         rd->memuse++;
704 #endif
705                                                 v->regoff = rd->memuse;
706                                                 rd->memuse += memneeded + 1;
707                                         } else {
708 #endif
709                                                 if (intalloc >= 0) {
710                                                         v->flags = jd->var[intalloc].flags;
711 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
712                                                         if (!(v->flags & INMEMORY)
713                                                                 && IS_2_WORD_TYPE(jd->var[intalloc].type))
714                                                                 v->regoff = GET_LOW_REG(
715                                                                                             jd->var[intalloc].regoff);
716                                                         else
717 #endif
718                                                                 v->regoff = jd->var[intalloc].regoff;
719                                                 }
720                                                 else if (rd->savintreguse > intregsneeded) {
721                                                         rd->savintreguse -= intregsneeded+1;
722                                                         v->flags = 0;
723 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
724                                                                 if (intregsneeded) 
725                                                                         v->regoff = PACK_REGS(
726                                                                                 rd->savintregs[rd->savintreguse],
727                                                                             rd->savintregs[rd->savintreguse + 1]);
728                                                                 else
729 #endif
730                                                                         v->regoff =rd->savintregs[rd->savintreguse];
731                                                 }
732                                                 else {
733                                                         v->flags = INMEMORY;
734 #if defined(ALIGN_LONGS_IN_MEMORY)
735                                                         /* Align longs in Memory */
736                                                         if ( (memneeded) && (rd->memuse & 1))
737                                                                 rd->memuse++;
738 #endif
739                                                         v->regoff = rd->memuse;
740                                                         rd->memuse += memneeded + 1;
741                                                 }
742 #if defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
743                                         }
744 #endif
745                                         intalloc = jd->local_map[s * 5 + t];
746                                 }
747 #ifdef HAS_ADDRESS_REGISTER_FILE
748                                 }
749 #endif
750
751                 }
752         }
753 }
754
755
756 static void reg_init_temp(methodinfo *m, registerdata *rd)
757 {
758         rd->freememtop = 0;
759 #if defined(HAS_4BYTE_STACKSLOT)
760         rd->freememtop_2 = 0;
761 #endif
762
763         rd->freetmpinttop = 0;
764         rd->freesavinttop = 0;
765         rd->freetmpflttop = 0;
766         rd->freesavflttop = 0;
767 #ifdef HAS_ADDRESS_REGISTER_FILE
768         rd->freetmpadrtop = 0;
769         rd->freesavadrtop = 0;
770 #endif
771
772         rd->freearginttop = 0;
773         rd->freeargflttop = 0;
774 #ifdef HAS_ADDRESS_REGISTER_FILE
775         rd->freeargadrtop = 0;
776 #endif
777 }
778
779
780 #define reg_new_temp(jd,index) \
781         if ( (index >= jd->localcount) \
782                  && (!(jd->var[index].flags & OUTVAR))   \
783                  && (!(jd->var[index].flags & PREALLOC)) )      \
784                 reg_new_temp_func(jd, index)
785
786 static void reg_new_temp_func(jitdata *jd, s4 index)
787 {
788         s4 intregsneeded;
789         s4 memneeded;
790         s4 tryagain;
791         registerdata *rd;
792         varinfo      *v;
793
794         rd = jd->rd;
795         v = &(jd->var[index]);
796
797         /* Try to allocate a saved register if there is no temporary one          */
798         /* available. This is what happens during the second run.                 */
799         tryagain = (v->flags & SAVEDVAR) ? 1 : 2;
800
801 #ifdef SUPPORT_COMBINE_INTEGER_REGISTERS
802         intregsneeded = (IS_2_WORD_TYPE(v->type)) ? 1 : 0;
803 #else
804         intregsneeded = 0;
805 #endif
806 #if defined(HAS_4BYTE_STACKSLOT)
807         memneeded = (IS_2_WORD_TYPE(v->type)) ? 1 : 0;
808 #else
809         memneeded = 0;
810 #endif
811
812         for(; tryagain; --tryagain) {
813                 if (tryagain == 1) {
814                         if (!(v->flags & SAVEDVAR))
815                                 v->flags |= SAVEDTMP;
816 #ifdef HAS_ADDRESS_REGISTER_FILE
817                         if (IS_ADR_TYPE(v->type)) {
818                                 if (rd->freesavadrtop > 0) {
819                                         v->regoff = rd->freesavadrregs[--rd->freesavadrtop];
820                                         return;
821                                 } else if (rd->savadrreguse > 0) {
822                                         v->regoff = rd->savadrregs[--rd->savadrreguse];
823                                         return;
824                                 }
825                         } else
826 #endif
827                         {
828                                 if (IS_FLT_DBL_TYPE(v->type)) {
829                                         if (rd->freesavflttop > 0) {
830                                                 v->regoff = rd->freesavfltregs[--rd->freesavflttop];
831                                                 return;
832                                         } else if (rd->savfltreguse > 0) {
833                                                 v->regoff = rd->savfltregs[--rd->savfltreguse];
834                                                 return;
835                                         }
836                                 } else {
837 #if defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
838                                         /*
839                                          * for i386 put all longs in memory
840                                          */
841                                         if (!IS_2_WORD_TYPE(v->type))
842 #endif
843                                         {
844                                                 if (rd->freesavinttop > intregsneeded) {
845                                                         rd->freesavinttop -= intregsneeded + 1;
846 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
847                                                         if (intregsneeded)
848                                                                 v->regoff = PACK_REGS(
849                                                                 rd->freesavintregs[rd->freesavinttop],
850                                                                         rd->freesavintregs[rd->freesavinttop + 1]);
851                                                 else
852 #endif
853                                                                 v->regoff =
854                                                                         rd->freesavintregs[rd->freesavinttop];
855                                                         return;
856                                                 } else if (rd->savintreguse > intregsneeded) {
857                                                         rd->savintreguse -= intregsneeded + 1;
858 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
859                                                         if (intregsneeded)
860                                                                 v->regoff = PACK_REGS(
861                                                                         rd->savintregs[rd->savintreguse],
862                                                                 rd->savintregs[rd->savintreguse + 1]);
863                                                         else
864 #endif
865                                                                 v->regoff = rd->savintregs[rd->savintreguse];
866                                                         return;
867                                                 }
868                                         }
869                                 }
870                         }
871                 } else { /* tryagain == 2 */
872 #ifdef HAS_ADDRESS_REGISTER_FILE
873                         if (IS_ADR_TYPE(v->type)) {
874                                 if (rd->freetmpadrtop > 0) {
875                                         v->regoff = rd->freetmpadrregs[--rd->freetmpadrtop];
876                                         return;
877                                 } else if (rd->tmpadrreguse > 0) {
878                                         v->regoff = rd->tmpadrregs[--rd->tmpadrreguse];
879                                         return;
880                                 }
881                         } else
882 #endif
883                         {
884                                 if (IS_FLT_DBL_TYPE(v->type)) {
885                                         if (rd->freeargflttop > 0) {
886                                                 v->regoff = rd->freeargfltregs[--rd->freeargflttop];
887                                                 v->flags |= TMPARG;
888                                                 return;
889                                         } else if (rd->argfltreguse < FLT_ARG_CNT) {
890                                                 v->regoff = rd->argfltregs[rd->argfltreguse++];
891                                                 v->flags |= TMPARG;
892                                                 return;
893                                         } else if (rd->freetmpflttop > 0) {
894                                                 v->regoff = rd->freetmpfltregs[--rd->freetmpflttop];
895                                                 return;
896                                         } else if (rd->tmpfltreguse > 0) {
897                                                 v->regoff = rd->tmpfltregs[--rd->tmpfltreguse];
898                                                 return;
899                                         }
900
901                                 } else {
902 #if defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
903                                         /*
904                                          * for i386 put all longs in memory
905                                          */
906                                         if (!IS_2_WORD_TYPE(v->type))
907 #endif
908                                         {
909                                                 if (rd->freearginttop > intregsneeded) {
910                                                         rd->freearginttop -= intregsneeded + 1;
911                                                         v->flags |= TMPARG;
912 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
913                                                         if (intregsneeded) 
914                                                                 v->regoff = PACK_REGS(
915                                                                         rd->freeargintregs[rd->freearginttop],
916                                                                 rd->freeargintregs[rd->freearginttop + 1]);
917                                                         else
918 #endif
919                                                                 v->regoff =
920                                                                         rd->freeargintregs[rd->freearginttop];
921                                                         return;
922                                                 } else if (rd->argintreguse 
923                                                                    < INT_ARG_CNT - intregsneeded) {
924 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
925                                                         if (intregsneeded) 
926                                                                 v->regoff = PACK_REGS(
927                                                                         rd->argintregs[rd->argintreguse],
928                                                                     rd->argintregs[rd->argintreguse + 1]);
929                                                         else
930 #endif
931                                                                 v->regoff = rd->argintregs[rd->argintreguse];
932                                                         v->flags |= TMPARG;
933                                                         rd->argintreguse += intregsneeded + 1;
934                                                         return;
935                                                 } else if (rd->freetmpinttop > intregsneeded) {
936                                                         rd->freetmpinttop -= intregsneeded + 1;
937 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
938                                                         if (intregsneeded) 
939                                                                 v->regoff = PACK_REGS(
940                                                                         rd->freetmpintregs[rd->freetmpinttop],
941                                                                     rd->freetmpintregs[rd->freetmpinttop + 1]);
942                                                         else
943 #endif
944                                                                 v->regoff = rd->freetmpintregs[rd->freetmpinttop];
945                                                         return;
946                                                 } else if (rd->tmpintreguse > intregsneeded) {
947                                                         rd->tmpintreguse -= intregsneeded + 1;
948 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
949                                                         if (intregsneeded) 
950                                                                 v->regoff = PACK_REGS(
951                                                                         rd->tmpintregs[rd->tmpintreguse],
952                                                                     rd->tmpintregs[rd->tmpintreguse + 1]);
953                                                         else
954 #endif
955                                                                 v->regoff = rd->tmpintregs[rd->tmpintreguse];
956                                                         return;
957                                                 }
958                                         } /* if (!IS_2_WORD_TYPE(s->type)) */
959                                 } /* if (IS_FLT_DBL_TYPE(s->type)) */
960                         } /* if (IS_ADR_TYPE(s->type)) */
961                 } /* if (tryagain == 1) else */
962         } /* for(; tryagain; --tryagain) */
963
964 #if defined(HAS_4BYTE_STACKSLOT)
965         if ((memneeded == 1) && (rd->freememtop_2 > 0)) {
966                 rd->freememtop_2--;
967                 v->regoff = rd->freemem_2[rd->freememtop_2];
968         } else
969 #endif /*defined(HAS_4BYTE_STACKSLOT) */
970                 if ((memneeded == 0) && (rd->freememtop > 0)) {
971                         rd->freememtop--;;
972                         v->regoff = rd->freemem[rd->freememtop];
973                 } else {
974 #if defined(ALIGN_LONGS_IN_MEMORY) || defined(ALIGN_DOUBLES_IN_MEMORY)
975                         /* align 2 Word Types */
976                         if ((memneeded) && ((rd->memuse & 1) == 1)) { 
977                                 /* Put patched memory slot on freemem */
978                                 rd->freemem[rd->freememtop++] = rd->memuse;
979                                 rd->memuse++;
980                         }
981 #endif /* defined(ALIGN_LONGS_IN_MEMORY) || defined(ALIGN_DOUBLES_IN_MEMORY) */
982                         v->regoff = rd->memuse;
983                         rd->memuse += memneeded + 1;
984                 }
985         v->flags |= INMEMORY;
986 }
987
988
989 #define reg_free_temp(jd,index) \
990         if ((index > jd->localcount) \
991                 && (!(jd->var[index].flags & OUTVAR))   \
992                 && (!(jd->var[index].flags & STCOPY))    \
993                 && (!(jd->var[index].flags & PREALLOC)) ) \
994                 reg_free_temp_func(jd, index)
995
996 /* Do not free regs/memory locations used by Stackslots flagged STCOPY! There is still another Stackslot */
997 /* alive using this reg/memory location */
998
999 static void reg_free_temp_func(jitdata *jd, s4 index)
1000 {
1001         s4 intregsneeded;
1002         s4 memneeded;
1003         registerdata *rd;
1004         varinfo *v;
1005
1006         rd = jd->rd;
1007         v = &(jd->var[index]);
1008
1009
1010 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
1011         intregsneeded = (IS_2_WORD_TYPE(v->type)) ? 1 : 0;
1012 #else
1013         intregsneeded = 0;
1014 #endif
1015
1016 #if defined(HAS_4BYTE_STACKSLOT)
1017         memneeded = (IS_2_WORD_TYPE(v->type)) ? 1 : 0;
1018 #else
1019         memneeded = 0;
1020 #endif
1021
1022         if (v->flags & INMEMORY) {
1023 #if defined(HAS_4BYTE_STACKSLOT)
1024                 if (memneeded > 0) {
1025                         rd->freemem_2[rd->freememtop_2] = v->regoff;
1026                         rd->freememtop_2++;
1027                 } else 
1028 #endif
1029                 {
1030                         rd->freemem[rd->freememtop] = v->regoff;
1031                         rd->freememtop++;
1032                 }
1033
1034 #ifdef HAS_ADDRESS_REGISTER_FILE
1035         } else if (IS_ADR_TYPE(v->type)) {
1036                 if (v->flags & (SAVEDVAR | SAVEDTMP)) {
1037 /*                      v->flags &= ~SAVEDTMP; */
1038                         rd->freesavadrregs[rd->freesavadrtop++] = v->regoff;
1039                 } else
1040                         rd->freetmpadrregs[rd->freetmpadrtop++] = v->regoff;
1041 #endif
1042         } else if (IS_FLT_DBL_TYPE(v->type)) {
1043                 if (v->flags & (SAVEDVAR | SAVEDTMP)) {
1044 /*                      v->flags &= ~SAVEDTMP; */
1045                         rd->freesavfltregs[rd->freesavflttop++] = v->regoff;
1046                 } else if (v->flags & TMPARG) {
1047 /*                      v->flags &= ~TMPARG; */
1048                         rd->freeargfltregs[rd->freeargflttop++] = v->regoff;
1049                 } else
1050                         rd->freetmpfltregs[rd->freetmpflttop++] = v->regoff;
1051         } else { /* IS_INT_LNG_TYPE */
1052                 if (v->flags & (SAVEDVAR | SAVEDTMP)) {
1053 /*                      v->flags &= ~SAVEDTMP; */
1054 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
1055                         if (intregsneeded) {
1056                                 rd->freesavintregs[rd->freesavinttop] =
1057                                         GET_LOW_REG(v->regoff);
1058                                 rd->freesavintregs[rd->freesavinttop + 1] =
1059                                         GET_HIGH_REG(v->regoff);
1060                         } else
1061 #endif
1062                         rd->freesavintregs[rd->freesavinttop] = v->regoff;
1063                         rd->freesavinttop += intregsneeded + 1;
1064
1065                 } else if (v->flags & TMPARG) {
1066 /*                      s->flags &= ~TMPARG; */
1067 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
1068                         if (intregsneeded) {
1069                                 rd->freeargintregs[rd->freearginttop] =
1070                                         GET_LOW_REG(v->regoff);
1071                                 rd->freeargintregs[rd->freearginttop + 1] =
1072                                         GET_HIGH_REG(v->regoff);
1073                         } else 
1074 #endif
1075                         rd->freeargintregs[rd->freearginttop] = v->regoff;
1076                         rd->freearginttop += intregsneeded + 1;
1077                 } else {
1078 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
1079                         if (intregsneeded) {
1080                                 rd->freetmpintregs[rd->freetmpinttop] =
1081                                         GET_LOW_REG(s->regoff);
1082                                 rd->freetmpintregs[rd->freetmpinttop + 1] =
1083                                         GET_HIGH_REG(s->regoff);
1084                         } else
1085 #endif
1086                     rd->freetmpintregs[rd->freetmpinttop] = v->regoff;
1087                         rd->freetmpinttop += intregsneeded + 1;
1088                 }
1089         }
1090 }
1091
1092
1093 /* allocate_scratch_registers **************************************************
1094
1095    Allocate temporary (non-interface, non-local) registers.
1096
1097 *******************************************************************************/
1098
1099 static void new_allocate_scratch_registers(jitdata *jd)
1100 {
1101         methodinfo         *m;
1102         registerdata       *rd;
1103         s4                  i;
1104         s4                  len;
1105         instruction        *iptr;
1106         basicblock         *bptr;
1107         builtintable_entry *bte;
1108         methoddesc         *md;
1109         s4                 *argp;
1110
1111         /* get required compiler data */
1112
1113         m  = jd->m;
1114         rd = jd->rd;
1115
1116         /* initialize temp registers */
1117
1118         reg_init_temp(m, rd);
1119
1120         bptr = jd->new_basicblocks;
1121
1122         while (bptr != NULL) {
1123                 if (bptr->flags >= BBREACHED) {
1124                         iptr = bptr->iinstr;
1125                         len = bptr->icount;
1126
1127                         while (--len >= 0)  {
1128                                 switch (iptr->opc) {
1129
1130                                         /* pop 0 push 0 */
1131
1132                                 case ICMD_NOP:
1133                                 case ICMD_CHECKNULL:
1134                                 case ICMD_IINC:
1135                                 case ICMD_JSR:
1136                                 case ICMD_RET:
1137                                 case ICMD_RETURN:
1138                                 case ICMD_GOTO:
1139                                 case ICMD_PUTSTATICCONST:
1140                                 case ICMD_INLINE_START:
1141                                 case ICMD_INLINE_END:
1142                                 case ICMD_INLINE_GOTO:
1143                                         break;
1144
1145                                         /* pop 0 push 1 const */
1146                                         
1147                                 case ICMD_ICONST:
1148                                 case ICMD_LCONST:
1149                                 case ICMD_FCONST:
1150                                 case ICMD_DCONST:
1151                                 case ICMD_ACONST:
1152
1153                                         /* pop 0 push 1 load */
1154                                         
1155                                 case ICMD_ILOAD:
1156                                 case ICMD_LLOAD:
1157                                 case ICMD_FLOAD:
1158                                 case ICMD_DLOAD:
1159                                 case ICMD_ALOAD:
1160                                         reg_new_temp(jd, iptr->dst.varindex);
1161                                         break;
1162
1163                                         /* pop 2 push 1 */
1164
1165                                 case ICMD_IALOAD:
1166                                 case ICMD_LALOAD:
1167                                 case ICMD_FALOAD:
1168                                 case ICMD_DALOAD:
1169                                 case ICMD_AALOAD:
1170
1171                                 case ICMD_BALOAD:
1172                                 case ICMD_CALOAD:
1173                                 case ICMD_SALOAD:
1174                                         reg_free_temp(jd, iptr->sx.s23.s2.varindex);
1175                                         reg_free_temp(jd, iptr->s1.varindex);
1176                                         reg_new_temp(jd, iptr->dst.varindex);
1177                                         break;
1178
1179                                         /* pop 3 push 0 */
1180
1181                                 case ICMD_IASTORE:
1182                                 case ICMD_LASTORE:
1183                                 case ICMD_FASTORE:
1184                                 case ICMD_DASTORE:
1185                                 case ICMD_AASTORE:
1186
1187                                 case ICMD_BASTORE:
1188                                 case ICMD_CASTORE:
1189                                 case ICMD_SASTORE:
1190                                         reg_free_temp(jd, iptr->sx.s23.s3.varindex);
1191                                         reg_free_temp(jd, iptr->sx.s23.s2.varindex);
1192                                         reg_free_temp(jd, iptr->s1.varindex);
1193                                         break;
1194
1195                                         /* pop 1 push 0 store */
1196
1197                                 case ICMD_ISTORE:
1198                                 case ICMD_LSTORE:
1199                                 case ICMD_FSTORE:
1200                                 case ICMD_DSTORE:
1201                                 case ICMD_ASTORE:
1202
1203                                         /* pop 1 push 0 */
1204
1205                                 case ICMD_POP:
1206
1207                                 case ICMD_IRETURN:
1208                                 case ICMD_LRETURN:
1209                                 case ICMD_FRETURN:
1210                                 case ICMD_DRETURN:
1211                                 case ICMD_ARETURN:
1212
1213                                 case ICMD_ATHROW:
1214
1215                                 case ICMD_PUTSTATIC:
1216                                 case ICMD_PUTFIELDCONST:
1217
1218                                         /* pop 1 push 0 branch */
1219
1220                                 case ICMD_IFNULL:
1221                                 case ICMD_IFNONNULL:
1222
1223                                 case ICMD_IFEQ:
1224                                 case ICMD_IFNE:
1225                                 case ICMD_IFLT:
1226                                 case ICMD_IFGE:
1227                                 case ICMD_IFGT:
1228                                 case ICMD_IFLE:
1229
1230                                 case ICMD_IF_LEQ:
1231                                 case ICMD_IF_LNE:
1232                                 case ICMD_IF_LLT:
1233                                 case ICMD_IF_LGE:
1234                                 case ICMD_IF_LGT:
1235                                 case ICMD_IF_LLE:
1236
1237                                         /* pop 1 push 0 table branch */
1238
1239                                 case ICMD_TABLESWITCH:
1240                                 case ICMD_LOOKUPSWITCH:
1241
1242                                 case ICMD_MONITORENTER:
1243                                 case ICMD_MONITOREXIT:
1244                                         reg_free_temp(jd, iptr->s1.varindex);
1245                                         break;
1246
1247                                         /* pop 2 push 0 branch */
1248
1249                                 case ICMD_IF_ICMPEQ:
1250                                 case ICMD_IF_ICMPNE:
1251                                 case ICMD_IF_ICMPLT:
1252                                 case ICMD_IF_ICMPGE:
1253                                 case ICMD_IF_ICMPGT:
1254                                 case ICMD_IF_ICMPLE:
1255
1256                                 case ICMD_IF_LCMPEQ:
1257                                 case ICMD_IF_LCMPNE:
1258                                 case ICMD_IF_LCMPLT:
1259                                 case ICMD_IF_LCMPGE:
1260                                 case ICMD_IF_LCMPGT:
1261                                 case ICMD_IF_LCMPLE:
1262
1263                                 case ICMD_IF_FCMPEQ:
1264                                 case ICMD_IF_FCMPNE:
1265
1266                                 case ICMD_IF_FCMPL_LT:
1267                                 case ICMD_IF_FCMPL_GE:
1268                                 case ICMD_IF_FCMPL_GT:
1269                                 case ICMD_IF_FCMPL_LE:
1270
1271                                 case ICMD_IF_FCMPG_LT:
1272                                 case ICMD_IF_FCMPG_GE:
1273                                 case ICMD_IF_FCMPG_GT:
1274                                 case ICMD_IF_FCMPG_LE:
1275
1276                                 case ICMD_IF_DCMPEQ:
1277                                 case ICMD_IF_DCMPNE:
1278
1279                                 case ICMD_IF_DCMPL_LT:
1280                                 case ICMD_IF_DCMPL_GE:
1281                                 case ICMD_IF_DCMPL_GT:
1282                                 case ICMD_IF_DCMPL_LE:
1283
1284                                 case ICMD_IF_DCMPG_LT:
1285                                 case ICMD_IF_DCMPG_GE:
1286                                 case ICMD_IF_DCMPG_GT:
1287                                 case ICMD_IF_DCMPG_LE:
1288
1289                                 case ICMD_IF_ACMPEQ:
1290                                 case ICMD_IF_ACMPNE:
1291
1292                                         /* pop 2 push 0 */
1293
1294                                 case ICMD_POP2:
1295
1296                                 case ICMD_PUTFIELD:
1297
1298                                 case ICMD_IASTORECONST:
1299                                 case ICMD_LASTORECONST:
1300                                 case ICMD_AASTORECONST:
1301                                 case ICMD_BASTORECONST:
1302                                 case ICMD_CASTORECONST:
1303                                 case ICMD_SASTORECONST:
1304                                         reg_free_temp(jd, iptr->sx.s23.s2.varindex);
1305                                         reg_free_temp(jd, iptr->s1.varindex);
1306                                         break;
1307
1308                                         /* pop 0 push 1 dup */
1309                                         
1310                                 case ICMD_DUP:
1311                                         /* src === dst->prev (identical Stackslot Element)     */
1312                                         /* src --> dst       (copied value, take same reg/mem) */
1313
1314 /*                                      if (!reg_alloc_dup(iptr->s1.varindex, iptr->dst.varindex)) { */
1315                                                 reg_new_temp(jd, iptr->dst.varindex);
1316 /*                                      } else { */
1317 /*                                              iptr->dst.varindex->flags |= STCOPY; */
1318 /*                                      } */
1319                                         break;
1320
1321                                         /* pop 0 push 2 dup */
1322                                         
1323                                 case ICMD_DUP2:
1324                                         /* src->prev === dst->prev->prev->prev (identical Stackslot Element)     */
1325                                         /* src       === dst->prev->prev       (identical Stackslot Element)     */
1326                                         /* src->prev --> dst->prev             (copied value, take same reg/mem) */
1327                                         /* src       --> dst                   (copied value, take same reg/mem) */
1328                                                                                                 
1329 /*                                      if (!reg_alloc_dup(iptr->dst.dupslots[0], iptr->dst.dupslots[2+0])) */
1330                                                 reg_new_temp(jd, iptr->dst.dupslots[2+0]);
1331 /*                                      if (!reg_alloc_dup(iptr->dst.dupslots[1], iptr->dst.dupslots[2+1])) */
1332                                                 reg_new_temp(jd, iptr->dst.dupslots[2+1]);
1333 /*                                      new_reg_mark_copy(rd, iptr->dst.dupslots, 2, 2, 2); */
1334                                         break;
1335
1336                                         /* pop 2 push 3 dup */
1337                                         
1338                                 case ICMD_DUP_X1:
1339                                         /* src->prev --> dst->prev       (copied value, take same reg/mem) */
1340                                         /* src       --> dst             (copied value, take same reg/mem) */
1341                                         /* src       --> dst->prev->prev (copied value, take same reg/mem) */
1342                                                                                                 
1343 /*                                      if (!reg_alloc_dup(iptr->dst.dupslots[1], iptr->dst.dupslots[2+0])) */
1344                                                 reg_new_temp(jd, iptr->dst.dupslots[2+0]);
1345 /*                                      if (!reg_alloc_dup(iptr->dst.dupslots[1], iptr->dst.dupslots[2+2])) */
1346                                                 reg_new_temp(jd, iptr->dst.dupslots[2+2]);
1347 /*                                      if (!reg_alloc_dup(iptr->dst.dupslots[0], iptr->dst.dupslots[2+1])) */
1348                                                 reg_new_temp(jd, iptr->dst.dupslots[2+1]);
1349 /*                                      new_reg_mark_copy(rd, iptr->dst.dupslots, 2, 3, 0); */
1350                                         break;
1351
1352                                         /* pop 3 push 4 dup */
1353                                         
1354                                 case ICMD_DUP_X2:
1355                                         /* src->prev->prev --> dst->prev->prev        */
1356                                         /* src->prev       --> dst->prev              */
1357                                         /* src             --> dst                    */
1358                                         /* src             --> dst->prev->prev->prev  */
1359                                         
1360 /*                                      if (!reg_alloc_dup(iptr->dst.dupslots[2], iptr->dst.dupslots[3+0])) */
1361                                                 reg_new_temp(jd, iptr->dst.dupslots[3+0]);
1362 /*                                      if (!reg_alloc_dup(iptr->dst.dupslots[2], iptr->dst.dupslots[3+3])) */
1363                                                 reg_new_temp(jd, iptr->dst.dupslots[3+3]);
1364 /*                                      if (!reg_alloc_dup(iptr->dst.dupslots[1], iptr->dst.dupslots[3+2])) */
1365                                                 reg_new_temp(jd, iptr->dst.dupslots[3+2]);
1366 /*                                      if (!reg_alloc_dup(iptr->dst.dupslots[0], iptr->dst.dupslots[3+1])) */
1367                                                 reg_new_temp(jd, iptr->dst.dupslots[3+1]);
1368 /*                                      new_reg_mark_copy(rd, iptr->dst.dupslots, 3, 4, 0); */
1369                                         break;
1370
1371                                         /* pop 3 push 5 dup */
1372                                         
1373                                 case ICMD_DUP2_X1:
1374                                         /* src->prev->prev --> dst->prev->prev             */
1375                                         /* src->prev       --> dst->prev                   */
1376                                         /* src             --> dst                         */
1377                                         /* src->prev       --> dst->prev->prev->prev->prev */
1378                                         /* src             --> dst->prev->prev->prev       */
1379                                                                                                 
1380 /*                                      if (!reg_alloc_dup(iptr->dst.dupslots[2], iptr->dst.dupslots[3+1])) */
1381                                                 reg_new_temp(jd, iptr->dst.dupslots[3+1]);
1382 /*                                      if (!reg_alloc_dup(iptr->dst.dupslots[2], iptr->dst.dupslots[3+4])) */
1383                                                 reg_new_temp(jd, iptr->dst.dupslots[3+4]);
1384 /*                                      if (!reg_alloc_dup(iptr->dst.dupslots[1], iptr->dst.dupslots[3+0])) */
1385                                                 reg_new_temp(jd, iptr->dst.dupslots[3+0]);
1386 /*                                      if (!reg_alloc_dup(iptr->dst.dupslots[1], iptr->dst.dupslots[3+3])) */
1387                                                 reg_new_temp(jd, iptr->dst.dupslots[3+3]);
1388 /*                                      if (!reg_alloc_dup(iptr->dst.dupslots[0], iptr->dst.dupslots[3+2])) */
1389                                                 reg_new_temp(jd, iptr->dst.dupslots[3+2]);
1390 /*                                      new_reg_mark_copy(rd, iptr->dst.dupslots, 3, 5, 0); */
1391                                         break;
1392
1393                                         /* pop 4 push 6 dup */
1394                                         
1395                                 case ICMD_DUP2_X2:
1396                                         /* src->prev->prev->prev --> dst->prev->prev->prev             */
1397                                         /* src->prev->prev       --> dst->prev->prev                   */
1398                                         /* src->prev             --> dst->prev                         */
1399                                         /* src                   --> dst                               */
1400                                         /* src->prev             --> dst->prev->prev->prev->prev->prev */
1401                                         /* src                   --> dst->prev->prev->prev->prev       */
1402                                                                                                 
1403 /*                                      if (!reg_alloc_dup(iptr->dst.dupslots[3], iptr->dst.dupslots[4+1])) */
1404                                                 reg_new_temp(jd, iptr->dst.dupslots[4+1]);
1405 /*                                      if (!reg_alloc_dup(iptr->dst.dupslots[3], iptr->dst.dupslots[4+5])) */
1406                                                 reg_new_temp(jd, iptr->dst.dupslots[4+5]);
1407 /*                                      if (!reg_alloc_dup(iptr->dst.dupslots[2], iptr->dst.dupslots[4+0])) */
1408                                                 reg_new_temp(jd, iptr->dst.dupslots[4+0]);
1409 /*                                      if (!reg_alloc_dup(iptr->dst.dupslots[2], iptr->dst.dupslots[4+4])) */
1410                                                 reg_new_temp(jd, iptr->dst.dupslots[4+4]);
1411 /*                                      if (!reg_alloc_dup(iptr->dst.dupslots[1], iptr->dst.dupslots[4+3])) */
1412                                                 reg_new_temp(jd, iptr->dst.dupslots[4+3]);
1413 /*                                      if (!reg_alloc_dup(iptr->dst.dupslots[0], iptr->dst.dupslots[4+2])) */
1414                                                 reg_new_temp(jd, iptr->dst.dupslots[4+2]);
1415 /*                                      new_reg_mark_copy(rd, iptr->dst.dupslots, 4, 6, 0); */
1416                                         break;
1417
1418                                         /* pop 2 push 2 swap */
1419                                         
1420                                 case ICMD_SWAP:
1421                                         /* src       --> dst->prev   (copy) */
1422                                         /* src->prev --> dst         (copy) */
1423                                                                                                 
1424 /*                                      if (!reg_alloc_dup(iptr->dst.dupslots[1], iptr->dst.dupslots[2+0])) */
1425                                                 reg_new_temp(jd, iptr->dst.dupslots[2+0]);
1426 /*                                      if (!reg_alloc_dup(iptr->dst.dupslots[0], iptr->dst.dupslots[2+1])) */
1427                                                 reg_new_temp(jd, iptr->dst.dupslots[2+1]);
1428 /*                                      new_reg_mark_copy(rd, iptr->dst.dupslots, 2, 2, 0); */
1429                                         break;
1430
1431                                         /* pop 2 push 1 */
1432                                         
1433                                 case ICMD_IADD:
1434                                 case ICMD_ISUB:
1435                                 case ICMD_IMUL:
1436                                 case ICMD_IDIV:
1437                                 case ICMD_IREM:
1438
1439                                 case ICMD_ISHL:
1440                                 case ICMD_ISHR:
1441                                 case ICMD_IUSHR:
1442                                 case ICMD_IAND:
1443                                 case ICMD_IOR:
1444                                 case ICMD_IXOR:
1445
1446                                 case ICMD_LADD:
1447                                 case ICMD_LSUB:
1448                                 case ICMD_LMUL:
1449                                 case ICMD_LDIV:
1450                                 case ICMD_LREM:
1451
1452                                 case ICMD_LOR:
1453                                 case ICMD_LAND:
1454                                 case ICMD_LXOR:
1455
1456                                 case ICMD_LSHL:
1457                                 case ICMD_LSHR:
1458                                 case ICMD_LUSHR:
1459
1460                                 case ICMD_FADD:
1461                                 case ICMD_FSUB:
1462                                 case ICMD_FMUL:
1463                                 case ICMD_FDIV:
1464                                 case ICMD_FREM:
1465
1466                                 case ICMD_DADD:
1467                                 case ICMD_DSUB:
1468                                 case ICMD_DMUL:
1469                                 case ICMD_DDIV:
1470                                 case ICMD_DREM:
1471
1472                                 case ICMD_LCMP:
1473                                 case ICMD_FCMPL:
1474                                 case ICMD_FCMPG:
1475                                 case ICMD_DCMPL:
1476                                 case ICMD_DCMPG:
1477                                         reg_free_temp(jd, iptr->sx.s23.s2.varindex);
1478                                         reg_free_temp(jd, iptr->s1.varindex);
1479                                         reg_new_temp(jd, iptr->dst.varindex);
1480                                         break;
1481
1482                                         /* pop 1 push 1 */
1483                                         
1484                                 case ICMD_IADDCONST:
1485                                 case ICMD_ISUBCONST:
1486                                 case ICMD_IMULCONST:
1487                                 case ICMD_IMULPOW2:
1488                                 case ICMD_IDIVPOW2:
1489                                 case ICMD_IREMPOW2:
1490                                 case ICMD_IANDCONST:
1491                                 case ICMD_IORCONST:
1492                                 case ICMD_IXORCONST:
1493                                 case ICMD_ISHLCONST:
1494                                 case ICMD_ISHRCONST:
1495                                 case ICMD_IUSHRCONST:
1496
1497                                 case ICMD_LADDCONST:
1498                                 case ICMD_LSUBCONST:
1499                                 case ICMD_LMULCONST:
1500                                 case ICMD_LMULPOW2:
1501                                 case ICMD_LDIVPOW2:
1502                                 case ICMD_LREMPOW2:
1503                                 case ICMD_LANDCONST:
1504                                 case ICMD_LORCONST:
1505                                 case ICMD_LXORCONST:
1506                                 case ICMD_LSHLCONST:
1507                                 case ICMD_LSHRCONST:
1508                                 case ICMD_LUSHRCONST:
1509
1510                                 case ICMD_INEG:
1511                                 case ICMD_INT2BYTE:
1512                                 case ICMD_INT2CHAR:
1513                                 case ICMD_INT2SHORT:
1514                                 case ICMD_LNEG:
1515                                 case ICMD_FNEG:
1516                                 case ICMD_DNEG:
1517
1518                                 case ICMD_I2L:
1519                                 case ICMD_I2F:
1520                                 case ICMD_I2D:
1521                                 case ICMD_L2I:
1522                                 case ICMD_L2F:
1523                                 case ICMD_L2D:
1524                                 case ICMD_F2I:
1525                                 case ICMD_F2L:
1526                                 case ICMD_F2D:
1527                                 case ICMD_D2I:
1528                                 case ICMD_D2L:
1529                                 case ICMD_D2F:
1530
1531                                 case ICMD_CHECKCAST:
1532
1533                                 case ICMD_ARRAYLENGTH:
1534                                 case ICMD_INSTANCEOF:
1535
1536                                 case ICMD_NEWARRAY:
1537                                 case ICMD_ANEWARRAY:
1538
1539                                 case ICMD_GETFIELD:
1540                                         reg_free_temp(jd, iptr->s1.varindex);
1541                                         reg_new_temp(jd, iptr->dst.varindex);
1542                                         break;
1543
1544                                         /* pop 0 push 1 */
1545                                         
1546                                 case ICMD_GETSTATIC:
1547
1548                                 case ICMD_NEW:
1549                                         reg_new_temp(jd, iptr->dst.varindex);
1550                                         break;
1551
1552                                         /* pop many push any */
1553                                         
1554                                 case ICMD_INVOKESTATIC:
1555                                 case ICMD_INVOKESPECIAL:
1556                                 case ICMD_INVOKEVIRTUAL:
1557                                 case ICMD_INVOKEINTERFACE:
1558                                         INSTRUCTION_GET_METHODDESC(iptr,md);
1559                                         i = md->paramcount;
1560                                         argp = iptr->sx.s23.s2.args;
1561                                         while (--i >= 0) {
1562                                                 reg_free_temp(jd, *argp);
1563                                                 argp++;
1564                                         }
1565                                         if (md->returntype.type != TYPE_VOID)
1566                                                 reg_new_temp(jd, iptr->dst.varindex);
1567                                         break;
1568
1569                                 case ICMD_BUILTIN:
1570                                         bte = iptr->sx.s23.s3.bte;
1571                                         md = bte->md;
1572                                         i = md->paramcount;
1573                                         argp = iptr->sx.s23.s2.args;
1574                                         while (--i >= 0) {
1575                                                 reg_free_temp(jd, *argp);
1576                                                 argp++;
1577                                         }
1578                                         if (md->returntype.type != TYPE_VOID)
1579                                                 reg_new_temp(jd, iptr->dst.varindex);
1580                                         break;
1581
1582                                 case ICMD_MULTIANEWARRAY:
1583                                         i = iptr->s1.argcount;
1584                                         argp = iptr->sx.s23.s2.args;
1585                                         while (--i >= 0) {
1586                                                 reg_free_temp(jd, *argp);
1587                                                 argp++;
1588                                         }
1589                                         reg_new_temp(jd, iptr->dst.varindex);
1590                                         break;
1591
1592                                 default:
1593                                         *exceptionptr =
1594                                                 new_internalerror("Unknown ICMD %d during register allocation",
1595                                                                                   iptr->opc);
1596                                         return;
1597                                 } /* switch */
1598                                 iptr++;
1599                         } /* while instructions */
1600                 } /* if */
1601                 bptr = bptr->next;
1602         } /* while blocks */
1603 }
1604
1605
1606 #if defined(ENABLE_STATISTICS)
1607 void reg_make_statistics(jitdata *jd)
1608 {
1609         methodinfo   *m;
1610         codegendata  *cd;
1611         registerdata *rd;
1612         int i,type;
1613         s4 len;
1614         stackptr    src, src_old;
1615         stackptr    dst;
1616         instruction *iptr;
1617         basicblock  *bptr;
1618         int size_interface; /* == maximum size of in/out stack at basic block boundaries */
1619         bool in_register;
1620
1621         /* get required compiler data */
1622
1623         m  = jd->m;
1624         cd = jd->cd;
1625         rd = jd->rd;
1626
1627         in_register = true;
1628
1629         size_interface = 0;
1630
1631                 /* count how many local variables are held in memory or register */
1632                 for(i=0; i < cd->maxlocals; i++)
1633                         for (type=0; type <=4; type++)
1634                                 if (rd->locals[i][type].type != -1) { /* valid local */
1635                                         if (rd->locals[i][type].flags & INMEMORY) {
1636                                                 count_locals_spilled++;
1637                                                 in_register=false;
1638                                         }
1639                                         else
1640                                                 count_locals_register++;
1641                                 }
1642
1643                 /* count how many stack slots are held in memory or register */
1644
1645                 bptr = jd->new_basicblocks;
1646
1647                 while (bptr != NULL) {
1648                         if (bptr->flags >= BBREACHED) {
1649
1650 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
1651                         if (!opt_lsra) {
1652 #endif  
1653                                 /* check for memory moves from interface to BB instack */
1654                                 dst = bptr->instack;
1655                                 len = bptr->indepth;
1656                                 
1657                                 if (len > size_interface) size_interface = len;
1658
1659                                 while (dst != NULL) {
1660                                         len--;
1661                                         if (dst->varkind != STACKVAR) {
1662                                                 if ( (dst->flags & INMEMORY) ||
1663                                                          (rd->interfaces[len][dst->type].flags & INMEMORY) || 
1664                                                          ( (dst->flags & INMEMORY) && 
1665                                                            (rd->interfaces[len][dst->type].flags & INMEMORY) && 
1666                                                            (dst->regoff != rd->interfaces[len][dst->type].regoff) ))
1667                                                 {
1668                                                         /* one in memory or both inmemory at different offsets */
1669                                                         count_mem_move_bb++;
1670                                                         in_register=false;
1671                                                 }
1672                                         }
1673
1674                                         dst = dst->prev;
1675                                 }
1676
1677                                 /* check for memory moves from BB outstack to interface */
1678                                 dst = bptr->outstack;
1679                                 len = bptr->outdepth;
1680                                 if (len > size_interface) size_interface = len;
1681
1682                                 while (dst) {
1683                                         len--;
1684                                         if (dst->varkind != STACKVAR) {
1685                                                 if ( (dst->flags & INMEMORY) || \
1686                                                          (rd->interfaces[len][dst->type].flags & INMEMORY) || \
1687                                                          ( (dst->flags & INMEMORY) && \
1688                                                            (rd->interfaces[len][dst->type].flags & INMEMORY) && \
1689                                                            (dst->regoff != rd->interfaces[len][dst->type].regoff) ))
1690                                                 {
1691                                                         /* one in memory or both inmemory at different offsets */
1692                                                         count_mem_move_bb++;
1693                                                         in_register=false;
1694                                                 }
1695                                         }
1696
1697                                         dst = dst->prev;
1698                                 }
1699 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
1700                         }
1701 #endif  
1702
1703
1704                                 dst = bptr->instack;
1705                                 iptr = bptr->iinstr;
1706                                 len = bptr->icount;
1707                                 src_old = NULL;
1708
1709                                 while (--len >= 0)  {
1710                                         src = dst;
1711                                         dst = iptr->dst.var;
1712
1713                                         if ((src!= NULL) && (src != src_old)) { /* new stackslot */
1714                                                 switch (src->varkind) {
1715                                                 case TEMPVAR:
1716                                                 case STACKVAR:
1717                                                         if (!(src->flags & INMEMORY)) 
1718                                                                 count_ss_register++;
1719                                                         else {
1720                                                                 count_ss_spilled++;
1721                                                                 in_register=false;
1722                                                         }                               
1723                                                         break;
1724                                                         /*                                      case LOCALVAR: */
1725                                                         /*                                              if (!(rd->locals[src->varnum][src->type].flags & INMEMORY)) */
1726                                                         /*                                                      count_ss_register++; */
1727                                                         /*                                              else */
1728                                                         /*                                                      count_ss_spilled++; */
1729                                                         /*                                              break; */
1730                                                 case ARGVAR:
1731                                                         if (!(src->flags & INMEMORY)) 
1732                                                                 count_argument_mem_ss++;
1733                                                         else
1734                                                                 count_argument_reg_ss++;
1735                                                         break;
1736
1737
1738                                                         /*                                              if (IS_FLT_DBL_TYPE(src->type)) { */
1739                                                         /*                                                      if (src->varnum < FLT_ARG_CNT) { */
1740                                                         /*                                                              count_ss_register++; */
1741                                                         /*                                                              break; */
1742                                                         /*                                                      } */
1743                                                         /*                                              } else { */
1744                                                         /* #if defined(__POWERPC__) */
1745                                                         /*                                                      if (src->varnum < INT_ARG_CNT - (IS_2_WORD_TYPE(src->type) != 0)) { */
1746                                                         /* #else */
1747                                                         /*                                                      if (src->varnum < INT_ARG_CNT) { */
1748                                                         /* #endif */
1749                                                         /*                                                              count_ss_register++; */
1750                                                         /*                                                              break; */
1751                                                         /*                                                      } */
1752                                                         /*                                              } */
1753                                                         /*                                              count_ss_spilled++; */
1754                                                         /*                                              break; */
1755                                                 }
1756                                         }
1757                                         src_old = src;
1758                                         
1759                                         iptr++;
1760                                 } /* while instructions */
1761                         } /* if */
1762                         bptr = bptr->next;
1763                 } /* while blocks */
1764                 count_interface_size += size_interface; /* accummulate the size of the interface (between bb boundaries) */
1765                 if (in_register) count_method_in_register++;
1766                 if (in_register) {
1767                         printf("INREGISTER: %s%s%s\n",m->class->name->text, m->name->text, m->descriptor->text);
1768                 }
1769 }
1770 #endif /* defined(ENABLE_STATISTICS) */
1771
1772
1773 /*
1774  * These are local overrides for various environment variables in Emacs.
1775  * Please do not remove this and leave it at the end of the file, where
1776  * Emacs will automagically detect them.
1777  * ---------------------------------------------------------------------
1778  * Local variables:
1779  * mode: c
1780  * indent-tabs-mode: t
1781  * c-basic-offset: 4
1782  * tab-width: 4
1783  * End:
1784  * vim:noexpandtab:sw=4:ts=4:
1785  */