[MLton-commit] r4909
Matthew Fluet
fluet at mlton.org
Wed Dec 6 20:32:26 PST 2006
Compute both offsets and sizes of GC_state fields
----------------------------------------------------------------------
U mlton/branches/on-20050822-x86_64-branch/mlton/backend/runtime.fun
U mlton/branches/on-20050822-x86_64-branch/mlton/backend/runtime.sig
U mlton/branches/on-20050822-x86_64-branch/mlton/main/compile.fun
U mlton/branches/on-20050822-x86_64-branch/mlton/main/lookup-constant.fun
----------------------------------------------------------------------
Modified: mlton/branches/on-20050822-x86_64-branch/mlton/backend/runtime.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/backend/runtime.fun 2006-12-07 03:36:25 UTC (rev 4908)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/backend/runtime.fun 2006-12-07 04:32:24 UTC (rev 4909)
@@ -90,6 +90,52 @@
| StackLimit => !stackLimitOffset
| StackTop => !stackTopOffset
+ val canHandleSize: Bytes.t ref = ref Bytes.zero
+ val cardMapSize: Bytes.t ref = ref Bytes.zero
+ val currentThreadSize: Bytes.t ref = ref Bytes.zero
+ val curSourceSeqsIndexSize: Bytes.t ref = ref Bytes.zero
+ val exnStackSize: Bytes.t ref = ref Bytes.zero
+ val frontierSize: Bytes.t ref = ref Bytes.zero
+ val limitSize: Bytes.t ref = ref Bytes.zero
+ val limitPlusSlopSize: Bytes.t ref = ref Bytes.zero
+ val maxFrameSizeSize: Bytes.t ref = ref Bytes.zero
+ val signalIsPendingSize: Bytes.t ref = ref Bytes.zero
+ val stackBottomSize: Bytes.t ref = ref Bytes.zero
+ val stackLimitSize: Bytes.t ref = ref Bytes.zero
+ val stackTopSize: Bytes.t ref = ref Bytes.zero
+
+ fun setSizes {canHandle, cardMap, currentThread, curSourceSeqsIndex,
+ exnStack, frontier, limit, limitPlusSlop, maxFrameSize,
+ signalIsPending, stackBottom, stackLimit, stackTop} =
+ (canHandleSize := canHandle
+ ; cardMapSize := cardMap
+ ; currentThreadSize := currentThread
+ ; curSourceSeqsIndexSize := curSourceSeqsIndex
+ ; exnStackSize := exnStack
+ ; frontierSize := frontier
+ ; limitSize := limit
+ ; limitPlusSlopSize := limitPlusSlop
+ ; maxFrameSizeSize := maxFrameSize
+ ; signalIsPendingSize := signalIsPending
+ ; stackBottomSize := stackBottom
+ ; stackLimitSize := stackLimit
+ ; stackTopSize := stackTop)
+
+ val size =
+ fn CanHandle => !canHandleSize
+ | CardMap => !cardMapSize
+ | CurrentThread => !currentThreadSize
+ | CurSourceSeqsIndex => !curSourceSeqsIndexSize
+ | ExnStack => !exnStackSize
+ | Frontier => !frontierSize
+ | Limit => !limitSize
+ | LimitPlusSlop => !limitPlusSlopSize
+ | MaxFrameSize => !maxFrameSizeSize
+ | SignalIsPending => !signalIsPendingSize
+ | StackBottom => !stackBottomSize
+ | StackLimit => !stackLimitSize
+ | StackTop => !stackTopSize
+
val toString =
fn CanHandle => "CanHandle"
| CardMap => "CardMap"
Modified: mlton/branches/on-20050822-x86_64-branch/mlton/backend/runtime.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/backend/runtime.sig 2006-12-07 03:36:25 UTC (rev 4908)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/backend/runtime.sig 2006-12-07 04:32:24 UTC (rev 4909)
@@ -50,6 +50,20 @@
stackBottom: Bytes.t,
stackLimit: Bytes.t,
stackTop: Bytes.t} -> unit
+ val setSizes: {canHandle: Bytes.t,
+ cardMap: Bytes.t,
+ currentThread: Bytes.t,
+ curSourceSeqsIndex: Bytes.t,
+ exnStack: Bytes.t,
+ frontier: Bytes.t,
+ limit: Bytes.t,
+ limitPlusSlop: Bytes.t,
+ maxFrameSize: Bytes.t,
+ signalIsPending: Bytes.t,
+ stackBottom: Bytes.t,
+ stackLimit: Bytes.t,
+ stackTop: Bytes.t} -> unit
+ val size: t -> Bytes.t (* Field size in struct GC_state. *)
val toString: t -> string
end
structure RObjectType:
Modified: mlton/branches/on-20050822-x86_64-branch/mlton/main/compile.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/main/compile.fun 2006-12-07 03:36:25 UTC (rev 4908)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/main/compile.fun 2006-12-07 04:32:24 UTC (rev 4909)
@@ -440,7 +440,7 @@
val _ = Control.message (Control.Detail, fn () =>
CoreML.Program.layoutStats coreML)
*)
- (* Set GC_state offsets. *)
+ (* Set GC_state offsets and sizes. *)
val _ =
let
fun get (name: string): Bytes.t =
@@ -451,19 +451,35 @@
in
Runtime.GCField.setOffsets
{
- canHandle = get "atomicState",
- cardMap = get "generationalMaps.cardMapAbsolute",
- currentThread = get "currentThread",
- curSourceSeqsIndex = get "sourceMaps.curSourceSeqsIndex",
- exnStack = get "exnStack",
- frontier = get "frontier",
- limit = get "limit",
- limitPlusSlop = get "limitPlusSlop",
- maxFrameSize = get "maxFrameSize",
- signalIsPending = get "signalsInfo.signalIsPending",
- stackBottom = get "stackBottom",
- stackLimit = get "stackLimit",
- stackTop = get "stackTop"
+ canHandle = get "atomicState_Offset",
+ cardMap = get "generationalMaps.cardMapAbsolute_Offset",
+ currentThread = get "currentThread_Offset",
+ curSourceSeqsIndex = get "sourceMaps.curSourceSeqsIndex_Offset",
+ exnStack = get "exnStack_Offset",
+ frontier = get "frontier_Offset",
+ limit = get "limit_Offset",
+ limitPlusSlop = get "limitPlusSlop_Offset",
+ maxFrameSize = get "maxFrameSize_Offset",
+ signalIsPending = get "signalsInfo.signalIsPending_Offset",
+ stackBottom = get "stackBottom_Offset",
+ stackLimit = get "stackLimit_Offset",
+ stackTop = get "stackTop_Offset"
+ };
+ Runtime.GCField.setSizes
+ {
+ canHandle = get "atomicState_Size",
+ cardMap = get "generationalMaps.cardMapAbsolute_Size",
+ currentThread = get "currentThread_Size",
+ curSourceSeqsIndex = get "sourceMaps.curSourceSeqsIndex_Size",
+ exnStack = get "exnStack_Size",
+ frontier = get "frontier_Size",
+ limit = get "limit_Size",
+ limitPlusSlop = get "limitPlusSlop_Size",
+ maxFrameSize = get "maxFrameSize_Size",
+ signalIsPending = get "signalsInfo.signalIsPending_Size",
+ stackBottom = get "stackBottom_Size",
+ stackLimit = get "stackLimit_Size",
+ stackTop = get "stackTop_Size"
}
end
(* Setup endianness *)
Modified: mlton/branches/on-20050822-x86_64-branch/mlton/main/lookup-constant.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/main/lookup-constant.fun 2006-12-07 03:36:25 UTC (rev 4908)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/main/lookup-constant.fun 2006-12-07 04:32:24 UTC (rev 4909)
@@ -56,17 +56,22 @@
"stackTop"
]
-val gcFields =
+val gcFieldsOffsets =
List.map (gcFields, fn s =>
- {name = s,
+ {name = s ^ "_Offset",
value = concat ["offsetof (struct GC_state, ", s, ")"],
ty = ConstType.Word WordSize.default})
+val gcFieldsSizes =
+ List.map (gcFields, fn s =>
+ {name = s ^ "_Size",
+ value = concat ["sizeof (gcState.", s, ")"],
+ ty = ConstType.Word WordSize.default})
fun build (constants, out) =
let
val constants =
List.fold
- (constants, gcFields, fn ((name, ty), ac) =>
+ (constants, gcFieldsSizes @ gcFieldsOffsets, fn ((name, ty), ac) =>
if List.exists (buildConstants, fn (name', _) => name = name')
then ac
else {name = name, value = name, ty = ty} :: ac)
More information about the MLton-commit
mailing list