* Removed all Id tags.
[cacao.git] / src / vm / jit / allocator / simplereg.c
index 3d057aa1daa8c7885eb52a5f388ef2c98af34633..a2a14bdc9088aa69e9cb5def082a1f37a3e6f161 100644 (file)
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    02111-1307, USA.
 
-   $Id: simplereg.c 8123 2007-06-20 23:50:55Z michi $
-
 */
 
 
 #include "config.h"
 
 #include <assert.h>
+#include <stdint.h>
 
 #include "vm/types.h"
 
@@ -440,7 +439,7 @@ static void simplereg_allocate_interfaces(jitdata *jd)
                                                fltalloc = s * 5 + t;
                                        }
                                        else { /* !IS_FLT_DBL_TYPE(t) */
-#if defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
+#if (SIZEOF_VOID_P == 4) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
                                                /*
                                                 * for i386 put all longs in memory
                                                 */
@@ -449,7 +448,7 @@ static void simplereg_allocate_interfaces(jitdata *jd)
                                                        NEW_MEM_SLOT_INT_LNG(regoff);
                                                } 
                                                else
-#endif /* defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE...GISTERS) */
+#endif
                                                        if (intalloc >= 0) {
                                                                /* Reuse memory slot(s)/register(s) for shared interface slots */
                                                                flags |= jd->interface_map[intalloc].flags & ~SAVEDVAR;
@@ -515,7 +514,7 @@ static void simplereg_allocate_interfaces(jitdata *jd)
                                                fltalloc = s * 5 + t;
                                        }
                                        else { /* IS_INT_LNG */
-#if defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
+#if (SIZEOF_VOID_P == 4) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
                                                /*
                                                 * for i386 put all longs in memory
                                                 */
@@ -694,7 +693,7 @@ static void simplereg_allocate_locals_leafmethod(jitdata *jd)
 
                                } 
                                else {
-#if defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
+#if (SIZEOF_VOID_P == 4) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
                                        /*
                                         * for i386 put all longs in memory
                                         */
@@ -846,7 +845,7 @@ static void simplereg_allocate_locals(jitdata *jd)
                                        fltalloc = jd->local_map[s * 5 + t];
                                }
                                else {
-#if defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
+#if (SIZEOF_VOID_P == 4) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
                                        /*
                                         * for i386 put all longs in memory
                                         */
@@ -875,7 +874,7 @@ static void simplereg_allocate_locals(jitdata *jd)
                                                        v->flags = INMEMORY;
                                                        NEW_MEM_SLOT_INT_LNG(v->vv.regoff);
                                                }
-#if defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
+#if (SIZEOF_VOID_P == 4) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
                                        }
 #endif
                                        intalloc = jd->local_map[s * 5 + t];
@@ -1065,7 +1064,7 @@ static void simplereg_new_temp(jitdata *jd, s4 index)
                                        }
                                } 
                                else {
-#if defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
+#if (SIZEOF_VOID_P == 4) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
                                        /*
                                         * for i386 put all longs in memory
                                         */
@@ -1121,7 +1120,7 @@ static void simplereg_new_temp(jitdata *jd, s4 index)
 
                                } 
                                else {
-#if defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
+#if (SIZEOF_VOID_P == 4) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
                                        /*
                                         * for i386 put all longs in memory
                                         */
@@ -1177,13 +1176,15 @@ static void simplereg_free(registerdata *rd, s4 flags, s4 regoff, s4 type)
        /* if this is a copy of another variable, just decrement the copy counter */
 
        if (flags & INMEMORY) {
+               int32_t memindex;
+
                if (flags & INOUT)
                        return;
 
-               #warning this will be more efficient if we divide it by SIZE_OF_STACKSLOT
+               memindex = regoff / SIZE_OF_STACKSLOT;
 
-               if (regoff < rd->memcopycountsize && rd->memcopycount[regoff]) {
-                       rd->memcopycount[regoff]--;
+               if (memindex < rd->memcopycountsize && rd->memcopycount[memindex]) {
+                       rd->memcopycount[memindex]--;
                        return;
                }
        }
@@ -1610,14 +1611,15 @@ static void simplereg_allocate_temporaries(jitdata *jd)
                                                v = VAROP(iptr->dst);
 
                                                if (v->flags & INMEMORY) {
-                                                       if (v->vv.regoff >= rd->memcopycountsize) {
-                                                               int newsize = (v->vv.regoff + 1) * 2;
+                                                       int32_t memindex = v->vv.regoff / SIZE_OF_STACKSLOT;
+                                                       if (memindex >= rd->memcopycountsize) {
+                                                               int newsize = (memindex + 1) * 2;
                                                                i = rd->memcopycountsize;
                                                                rd->memcopycount = DMREALLOC(rd->memcopycount, int, i, newsize);
                                                                MZERO(rd->memcopycount + i, int, newsize - i);
                                                                rd->memcopycountsize = newsize;
                                                        }
-                                                       rd->memcopycount[v->vv.regoff]++;
+                                                       rd->memcopycount[memindex]++;
                                                }
                                                else {
                                                        /* XXX split reg/mem variables on arm may need special handling here */