[MLton-commit] r4331

Matthew Fluet MLton@mlton.org
Mon, 30 Jan 2006 17:46:20 -0800


A 'small' IntInf has absolute value in [0,2^(CHAR_BIT * OBJPTR_SIZE) - 2]:
one bit for the non-pointer tag and one bit for the twos-complement sign.


----------------------------------------------------------------------

U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/init-world.c

----------------------------------------------------------------------

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/init-world.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/init-world.c	2006-01-30 00:44:07 UTC (rev 4330)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/init-world.c	2006-01-31 01:46:18 UTC (rev 4331)
@@ -53,7 +53,7 @@
   uint32_t i, j;
   bool neg;
   GC_intInf bp;
-  unsigned char* cp;
+  unsigned char *cp;
 
   assert (isFrontierAligned (s, s->frontier));
   frontier = s->frontier;
@@ -66,12 +66,11 @@
       str++;
     slen = strlen (str);
     assert (slen > 0);
+    bp = (GC_intInf)frontier;
     cp = (unsigned char*)(s->heap.start + (s->heap.size - slen));
 
-    bp = (GC_intInf)frontier;
-
     for (j = 0; j != slen; j++) {
-      assert('0' <= str[j] && str[j] <= '9');
+      assert ('0' <= str[j] && str[j] <= '9');
       cp[j] = str[j] - '0' + 0;
     }
     alen = mpn_set_str ((mp_limb_t*)(bp->limbs), cp, slen, 10);
@@ -84,16 +83,16 @@
         val = bp->limbs[0];
       if (neg) {
         /*
-         * We only fit if val in [1, 2^(8 * OBJPTR_SIZE - 1)].
+         * We only fit if val in [1, 2^(CHAR_BIT * OBJPTR_SIZE - 2)].
          */
         ans = - val;
         val = val - 1;
       } else
         /* 
-         * We only fit if val in [0, 2^(8 * OBJPTR_SIZE - 1) - 1].
+         * We only fit if val in [0, 2^(CHAR_BIT * OBJPTR_SIZE - 2) - 1].
          */
         ans = val;
-      if (val < (uintmax_t)1<<(8 * OBJPTR_SIZE - 1)) {
+      if (val < (uintmax_t)1<<(CHAR_BIT * OBJPTR_SIZE - 2)) {
         s->globals[inits->globalIndex] = (objptr)(ans<<1 | 1);
         continue;
       }