[MLton-commit] r6409
Matthew Fluet
fluet at mlton.org
Thu Feb 14 13:39:38 PST 2008
Explicitly compute padding for thread objects from alignment and
target sizes.
----------------------------------------------------------------------
U mlton/trunk/mlton/backend/rep-type.fun
----------------------------------------------------------------------
Modified: mlton/trunk/mlton/backend/rep-type.fun
===================================================================
--- mlton/trunk/mlton/backend/rep-type.fun 2008-02-14 21:39:35 UTC (rev 6408)
+++ mlton/trunk/mlton/backend/rep-type.fun 2008-02-14 21:39:38 UTC (rev 6409)
@@ -407,14 +407,31 @@
val thread = fn () =>
let
val padding =
- case (!Control.align,
- Bits.toInt (Control.Target.Size.csize ()),
- Bits.toInt (Control.Target.Size.objptr ())) of
- (Control.Align4,32,32) => Type.word0
- | (Control.Align8,32,32) => Type.word0
- | (Control.Align4,64,64) => Type.word0
- | (Control.Align8,64,64) => Type.word0
- | _ => Error.bug "RepType.ObjectType.thread"
+ let
+ val align =
+ case !Control.align of
+ Control.Align4 => Bytes.fromInt 4
+ | Control.Align8 => Bytes.fromInt 8
+ val bytesHeader =
+ Bits.toBytes (Control.Target.Size.header ())
+ val bytesCSize =
+ Bits.toBytes (Control.Target.Size.csize ())
+ val bytesExnStack =
+ Bits.toBytes (Type.width (Type.exnStack ()))
+ val bytesStack =
+ Bits.toBytes (Type.width (Type.stack ()))
+
+ val bytesObject =
+ Bytes.+ (bytesHeader,
+ Bytes.+ (bytesCSize,
+ Bytes.+ (bytesExnStack,
+ bytesStack)))
+ val bytesTotal =
+ Bytes.align (bytesObject, {alignment = align})
+ val bytesPad = Bytes.- (bytesTotal, bytesObject)
+ in
+ Type.bits (Bytes.toBits bytesPad)
+ end
in
Normal {hasIdentity = true,
ty = Type.seq (Vector.new4 (padding,
More information about the MLton-commit
mailing list