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