[MLton-commit] r6407

Matthew Fluet fluet at mlton.org
Thu Feb 14 13:39:33 PST 2008


Combine the Weak and WeakGone variants in OBJECT_TYPE.t and
RUNTIME.RObjectType.t to make it clear that the four variants
correspond to the four GC_objectTypeTag kinds.

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

U   mlton/trunk/mlton/backend/object-type.sig
U   mlton/trunk/mlton/backend/packed-representation.fun
U   mlton/trunk/mlton/backend/rep-type.fun
U   mlton/trunk/mlton/backend/runtime.fun
U   mlton/trunk/mlton/backend/runtime.sig
U   mlton/trunk/mlton/codegen/c-codegen/c-codegen.fun

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

Modified: mlton/trunk/mlton/backend/object-type.sig
===================================================================
--- mlton/trunk/mlton/backend/object-type.sig	2008-02-14 20:10:55 UTC (rev 6406)
+++ mlton/trunk/mlton/backend/object-type.sig	2008-02-14 21:39:32 UTC (rev 6407)
@@ -17,8 +17,7 @@
        | Normal of {hasIdentity: bool,
                     ty: ty}
        | Stack
-       | Weak of ty (* in Weak t, must have Type.isPointer t *)
-       | WeakGone
+       | Weak of ty option (* in Weak (SOME t), must have Type.isPointer t *)
 
       val basic: unit -> (ObjptrTycon.t * t) vector
       val isOk: t -> bool

Modified: mlton/trunk/mlton/backend/packed-representation.fun
===================================================================
--- mlton/trunk/mlton/backend/packed-representation.fun	2008-02-14 20:10:55 UTC (rev 6406)
+++ mlton/trunk/mlton/backend/packed-representation.fun	2008-02-14 21:39:32 UTC (rev 6407)
@@ -2692,7 +2692,7 @@
                               val r = Value.get r
                            in
                               if Rep.isObjptr r
-                                 then SOME (opt, ObjectType.Weak (Rep.ty r))
+                                 then SOME (opt, ObjectType.Weak (SOME (Rep.ty r)))
                               else NONE
                            end)
                     in

Modified: mlton/trunk/mlton/backend/rep-type.fun
===================================================================
--- mlton/trunk/mlton/backend/rep-type.fun	2008-02-14 20:10:55 UTC (rev 6406)
+++ mlton/trunk/mlton/backend/rep-type.fun	2008-02-14 21:39:32 UTC (rev 6407)
@@ -361,8 +361,7 @@
        | Normal of {hasIdentity: bool,
                     ty: ty}
        | Stack
-       | Weak of Type.t
-       | WeakGone
+       | Weak of Type.t option
 
       fun layout (t: t) =
          let
@@ -378,8 +377,7 @@
                        record [("hasIdentity", Bool.layout hasIdentity),
                                ("ty", Type.layout ty)]]
              | Stack => str "Stack"
-             | Weak t => seq [str "Weak ", Type.layout t]
-             | WeakGone => str "WeakGone"
+             | Weak t => seq [str "Weak ", Option.layout Type.layout t]
          end
 
       fun isOk (t: t): bool =
@@ -402,8 +400,7 @@
                             | Control.Align8 => Bits.isWord64Aligned b)
                end
           | Stack => true
-          | Weak t => Type.isObjptr t
-          | WeakGone => true
+          | Weak to => Option.fold (to, true, fn (t,_) => Type.isObjptr t)
 
       val stack = Stack
 
@@ -427,7 +424,7 @@
          end
 
       (* Order in the following vector matters.  The basic pointer tycons must
-       * correspond to the constants in gc.h.
+       * correspond to the constants in gc/object.h.
        * STACK_TYPE_INDEX,
        * THREAD_TYPE_INDEX,
        * WEAK_GONE_TYPE_INDEX,
@@ -450,7 +447,7 @@
             Vector.fromList
             [(ObjptrTycon.stack, stack),
              (ObjptrTycon.thread, thread ()),
-             (ObjptrTycon.weakGone, WeakGone),
+             (ObjptrTycon.weakGone, Weak NONE),
              wordVec 8,
              wordVec 32,
              wordVec 16,
@@ -479,8 +476,7 @@
                                numObjptrs = nops}
                   end
              | Stack => R.Stack
-             | Weak _ => R.Weak
-             | WeakGone => R.WeakGone
+             | Weak to => R.Weak {gone = Option.isNone to}
       end
    end
 

Modified: mlton/trunk/mlton/backend/runtime.fun
===================================================================
--- mlton/trunk/mlton/backend/runtime.fun	2008-02-14 20:10:55 UTC (rev 6406)
+++ mlton/trunk/mlton/backend/runtime.fun	2008-02-14 21:39:32 UTC (rev 6407)
@@ -147,8 +147,7 @@
                     bytesNonObjptrs: Bytes.t,
                     numObjptrs: int}
        | Stack
-       | Weak
-       | WeakGone
+       | Weak of {gone: bool}
 
       fun layout (t: t): Layout.t =
          let
@@ -166,8 +165,9 @@
                                ("bytesNonObjptrs", Bytes.layout bytesNonObjptrs),
                                ("numObjptrs", Int.layout numObjptrs)]]
              | Stack => str "Stack"
-             | Weak => str "Weak"
-             | WeakGone => str "WeakGone"
+             | Weak {gone} => 
+                  seq [str "Weak",
+                       record [("gone", Bool.layout gone)]]
          end
       val _ = layout (* quell unused warning *)
    end

Modified: mlton/trunk/mlton/backend/runtime.sig
===================================================================
--- mlton/trunk/mlton/backend/runtime.sig	2008-02-14 20:10:55 UTC (rev 6406)
+++ mlton/trunk/mlton/backend/runtime.sig	2008-02-14 21:39:32 UTC (rev 6407)
@@ -75,8 +75,7 @@
                           bytesNonObjptrs: Bytes.t,
                           numObjptrs: int}
              | Stack
-             | Weak
-             | WeakGone
+             | Weak of {gone: bool}
          end
 
       val allocTooLarge: Bytes.t

Modified: mlton/trunk/mlton/codegen/c-codegen/c-codegen.fun
===================================================================
--- mlton/trunk/mlton/codegen/c-codegen/c-codegen.fun	2008-02-14 20:10:55 UTC (rev 6406)
+++ mlton/trunk/mlton/codegen/c-codegen/c-codegen.fun	2008-02-14 21:39:32 UTC (rev 6407)
@@ -339,7 +339,7 @@
                        Bytes.toInt bytesNonObjptrs, numObjptrs)
                  | Stack =>
                       (2, false, 0, 0)
-                 | Weak =>
+                 | Weak {gone = false} =>
                       (case (!Control.align,
                              Bits.toInt (Control.Target.Size.cpointer ()),
                              Bits.toInt (Control.Target.Size.objptr ())) of
@@ -348,7 +348,7 @@
                         | (Control.Align4,64,64) => (3, false, 8, 1)
                         | (Control.Align8,64,64) => (3, false, 8, 1)
                         | _ => Error.bug "CCodegen.declareObjectTypes")
-                 | WeakGone =>
+                 | Weak {gone = true} =>
                       (case (!Control.align,
                              Bits.toInt (Control.Target.Size.cpointer ()),
                              Bits.toInt (Control.Target.Size.objptr ())) of




More information about the MLton-commit mailing list