[MLton-commit] r4989

Matthew Fluet fluet at mlton.org
Tue Dec 19 10:09:27 PST 2006


Added assertion that new objects are properly aligned
----------------------------------------------------------------------

U   mlton/trunk/runtime/gc/new-object.c
U   mlton/trunk/runtime/gc/stack.c

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

Modified: mlton/trunk/runtime/gc/new-object.c
===================================================================
--- mlton/trunk/runtime/gc/new-object.c	2006-12-19 18:08:40 UTC (rev 4988)
+++ mlton/trunk/runtime/gc/new-object.c	2006-12-19 18:09:25 UTC (rev 4989)
@@ -37,6 +37,7 @@
   GC_profileAllocInc (s, bytesRequested);
   *((GC_header*)frontier) = header;
   result = frontier + GC_NORMAL_HEADER_SIZE;
+  assert (isAligned ((size_t)result, s->alignment));
   if (DEBUG)
     fprintf (stderr, FMTPTR " = newObject ("FMTHDR", %zu, %s)\n",
              (uintptr_t)result,

Modified: mlton/trunk/runtime/gc/stack.c
===================================================================
--- mlton/trunk/runtime/gc/stack.c	2006-12-19 18:08:40 UTC (rev 4988)
+++ mlton/trunk/runtime/gc/stack.c	2006-12-19 18:09:25 UTC (rev 4989)
@@ -50,17 +50,29 @@
 
 /* Pointer to the topmost word in use on the stack. */
 pointer getStackTop (GC_state s, GC_stack stack) {
-  return getStackBottom (s, stack) + stack->used;
+  pointer res;
+
+  res = getStackBottom (s, stack) + stack->used;
+  assert (isAligned ((size_t)res, s->alignment));
+  return res;
 }
 
 /* Pointer to the end of stack. */
 pointer getStackLimitPlusSlop (GC_state s, GC_stack stack) {
-  return getStackBottom (s, stack) + stack->reserved;
+  pointer res;
+
+  res = getStackBottom (s, stack) + stack->reserved;
+  // assert (isAligned ((size_t)res, s->alignment));
+  return res;
 }
 
 /* The maximum value which is valid for stackTop. */
 pointer getStackLimit (GC_state s, GC_stack stack) {
-  return getStackLimitPlusSlop (s, stack) - sizeofStackSlop (s);
+  pointer res;
+
+  res  = getStackLimitPlusSlop (s, stack) - sizeofStackSlop (s);
+  // assert (isAligned ((size_t)res, s->alignment));
+  return res;
 }
 
 




More information about the MLton-commit mailing list