[MLton-commit] r5322
Matthew Fluet
fluet at mlton.org
Sun Feb 25 14:02:30 PST 2007
(Very) Preliminary 64-bit executables.
This commit changes the amd64-* target platforms from 32-bit
compatability mode (i.e., -m32) to 64-bit mode (i.e., -m64).
This only supports the C-backend. (Even building the bytecode
interpreter in 64-bit mode is broken. For expediency, I've simply
disabled the bytecode backend entirely (for all platforms).)
This only supports the simplest ML object-pointer model, namely, every
object pointer is represented as a native pointer. More type-checking
in the RSSA and Machine ILs would be helpful when pushing to support
alternate object-pointer models.
All regressions compile and pass (with -debug true). Neither all of
the benchmarks nor a self-compile has been attempted.
There were two main aspects of the runtime/compiler that hadn't been
addressed previously:
* With the copying collector, the forwarding pointer is written over
the initial bytes of the object (i.e., immediately following the
header). This means that every object must have size at least
equal to that of a pointer. Previously, this was never explicitly
enforced; rather, it was implied by requiring objects to be mod 4
aligned (making every object at least 32 bits).
With 64-bit pointers, this means that every object must be at least
64-bits. Hence, there is now an explicit check in the
PackedRepresentation to ensure that all objects have room for a
forwarding object pointer.
Similarly, there are additional checks in the runtime/gc to ensure
that arrays always have room for an object pointer. Previously,
there were checks to ensure that zero-length arrays were allocated
(and sized) with room for an object pointer. However, with 64-bit
forwarding object pointers, we must also check that very small
arrays (e.g., 3 element array of Word8.word) have sufficient room
for a forwarding object pointer. (Previously, alignment would have
ensured that a 3 element array of Word8.word consumed 32-bits
(sufficient for a 32-bit forwarding object pointer).)
* A type like
datatype realopt = NONE | SOME of Real32.real
poses new opportunities and difficulties with 64-bits. The new
opportunity is that with 64-bit object pointers, the
PackedRepresentation determines that each variant is a 'small' type
(i.e., smaller in size than an object pointer), and tries to
represent all the variants with a object pointer sized word,
shifting the carried values and using low-order tag bits. The
shift and tag operation on a Real32 first requires casting the
Real32 to a Word32, then extending to Word64, and then shifting and
tagging at Word64. Unfortunately, we don't have a *bitcast* from
Real32 to Word32; naively emitting
Real32 r = ...
Word32 w = (Word32)r;
results in coercion that attempts to preserve the numeric meaning
of r, rather than the bits of r. Simply more evidence that we need
real/word bitcast primitives.
Currently, I simply force a variant with a Real32 (on a 64-bit
platform) to be a 'big' type, which effectively boxes such
variants.
Known bugs:
* The mark-compact collector doesn't work. (Conveniently, on my 6GB
machine, I rarely need to make use of the mark-compact collector.
Certainly, none of the regression tests are very large.)
I believe that this is due to the threading of objects. Because an
object header is 32-bits, but an object pointer is 64-bits,
threading an object pointer through a header writes over the first
32-bits of the object. For objects with object pointers, but no
non-object pointer bytes, this ends up corrupting the first object
pointer of the object. (We would be o.k. if the first 32-bits of
the object were non-object pointer bytes, since the threading code
copies the bytes in the right way.)
But, this is just a guess and I need to do more investigating.
----------------------------------------------------------------------
U mlton/branches/on-20050822-x86_64-branch/Makefile
U mlton/branches/on-20050822-x86_64-branch/bin/add-cross
U mlton/branches/on-20050822-x86_64-branch/bin/mlton-script
U mlton/branches/on-20050822-x86_64-branch/include/c-chunk.h
U mlton/branches/on-20050822-x86_64-branch/mlton/backend/packed-representation.fun
U mlton/branches/on-20050822-x86_64-branch/mlton/backend/rep-type.fun
U mlton/branches/on-20050822-x86_64-branch/mlton/backend/rep-type.sig
U mlton/branches/on-20050822-x86_64-branch/mlton/codegen/c-codegen/c-codegen.fun
U mlton/branches/on-20050822-x86_64-branch/mlton/main/main.fun
A mlton/branches/on-20050822-x86_64-branch/regression/mlton.share.amd64-linux.ok
U mlton/branches/on-20050822-x86_64-branch/runtime/Makefile
U mlton/branches/on-20050822-x86_64-branch/runtime/cenv.h
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/array-allocate.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/debug.h
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/foreach.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/garbage-collection.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/gc_state.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/generational.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/init-world.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/invariant.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/mark-compact.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/object-size.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/objptr.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gc.h
----------------------------------------------------------------------
Modified: mlton/branches/on-20050822-x86_64-branch/Makefile
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/Makefile 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/Makefile 2007-02-25 22:00:41 UTC (rev 5322)
@@ -289,14 +289,14 @@
basis-library/config/c/$(TARGET_ARCH)-$(TARGET_OS)/c-types.sml
$(CP) runtime/gen/basis-ffi.sml \
basis-library/primitive/basis-ffi.sml
- $(CP) runtime/bytecode/opcodes "$(LIB)/"
+ # $(CP) runtime/bytecode/opcodes "$(LIB)/"
$(CP) runtime/*.h "$(INC)/"
mv "$(INC)/c-types.h" "$(LIB)/$(TARGET)/include"
for d in basis basis/Real basis/Word gc platform util; do \
mkdir -p "$(INC)/$$d"; \
$(CP) runtime/$$d/*.h "$(INC)/$$d"; \
done
- $(CP) runtime/bytecode/interpret.h "$(INC)"
+ # $(CP) runtime/bytecode/interpret.h "$(INC)"
for x in "$(LIB)"/"$(TARGET)"/*.a; do $(RANLIB) "$$x"; done
.PHONY: script
Modified: mlton/branches/on-20050822-x86_64-branch/bin/add-cross
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/bin/add-cross 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/bin/add-cross 2007-02-25 22:00:41 UTC (rev 5322)
@@ -105,7 +105,7 @@
# Copied from mlton-script
case "$crossArch" in
amd64)
- archOpts='-m32'
+ archOpts='-m64'
;;
hppa)
archOpts=''
Modified: mlton/branches/on-20050822-x86_64-branch/bin/mlton-script
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/bin/mlton-script 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/bin/mlton-script 2007-02-25 22:00:41 UTC (rev 5322)
@@ -83,8 +83,8 @@
-cc-opt '-O1' \
-cc-opt '-fno-strict-aliasing -fomit-frame-pointer -w' \
-mlb-path-map "$lib/mlb-path-map" \
- -target-as-opt amd64 '-m32 -mtune=opteron' \
- -target-cc-opt amd64 '-m32 -mtune=opteron' \
+ -target-as-opt amd64 '-m64 -mtune=opteron' \
+ -target-cc-opt amd64 '-m64 -mtune=opteron' \
-target-cc-opt darwin \
'-I/opt/local/include -I/sw/include' \
-target-cc-opt freebsd '-I/usr/local/include' \
@@ -100,7 +100,7 @@
-malign-functions=5
-malign-jumps=2
-malign-loops=2' \
- -target-link-opt amd64 '-m32' \
+ -target-link-opt amd64 '-m64' \
-target-link-opt darwin "$darwinLinkOpts" \
-target-link-opt freebsd '-L/usr/local/lib/' \
-target-link-opt mingw \
Modified: mlton/branches/on-20050822-x86_64-branch/include/c-chunk.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/include/c-chunk.h 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/include/c-chunk.h 2007-02-25 22:00:41 UTC (rev 5322)
@@ -171,7 +171,7 @@
#define Return() \
do { \
- l_nextFun = *(Word32*)(StackTop - sizeof(Word32)); \
+ l_nextFun = *(Word32*)(StackTop - sizeof(void*)); \
if (DEBUG_CCODEGEN) \
fprintf (stderr, "%s:%d: Return() l_nextFun = %d\n", \
__FILE__, __LINE__, l_nextFun); \
Modified: mlton/branches/on-20050822-x86_64-branch/mlton/backend/packed-representation.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/backend/packed-representation.fun 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/backend/packed-representation.fun 2007-02-25 22:00:41 UTC (rev 5322)
@@ -227,6 +227,13 @@
rep = rep}
else Error.bug "PackedRepresentation.WordRep.make"
+ val make =
+ Trace.trace
+ ("PackedRepresentation.WordRep.make",
+ layout o T,
+ layout)
+ make
+
fun padToWidth (T {components, rep}, b: Bits.t): t =
make {components = components,
rep = Rep.padToWidth (rep, b)}
@@ -484,33 +491,53 @@
case Scale.fromInt (Bytes.toInt eltWidth) of
NONE =>
let
- val size = WordSize.seqIndex ()
- val wty = Type.word (WordSize.bits size)
- (* vector + (width * index) + offset *)
+ val seqIndexSize = WordSize.seqIndex ()
+ val seqIndexTy = Type.word (WordSize.bits seqIndexSize)
+ val csizeSize = WordSize.csize ()
+ val csizeTy = Type.word (WordSize.bits csizeSize)
+ (* vector + (eltWidth * index) + offset *)
+ val ind = Var.newNoname ()
+ val s0 =
+ case WordSize.compare (seqIndexSize, csizeSize) of
+ EQUAL =>
+ Bind {dst = (ind, csizeTy),
+ isMutable = false,
+ src = index}
+ | GREATER => Error.bug "PackedRepresentation.Base.ToOperand: WordSize.compare (seqIndexSize, csizeSize)"
+ | LESS =>
+ PrimApp {args = Vector.new1 index,
+ dst = SOME (ind, csizeTy),
+ prim = (Prim.wordToWord
+ (seqIndexSize,
+ csizeSize,
+ {signed = false}))}
val prod = Var.newNoname ()
val s1 =
PrimApp {args = (Vector.new2
- (index,
+ (Operand.Var {ty = csizeTy,
+ var = ind},
Operand.word
(WordX.fromIntInf
(Bytes.toIntInf eltWidth,
- size)))),
- dst = SOME (prod, wty),
- prim = Prim.wordMul (size, {signed = false})}
+ csizeSize)))),
+ dst = SOME (prod, csizeTy),
+ prim = (Prim.wordMul
+ (csizeSize,
+ {signed = false}))}
val eltBase = Var.newNoname ()
val s2 =
PrimApp {args = (Vector.new2
(vector,
- Operand.Var {ty = wty,
+ Operand.Var {ty = csizeTy,
var = prod})),
- dst = SOME (eltBase, wty),
- prim = Prim.wordAdd size}
+ dst = SOME (eltBase, csizeTy),
+ prim = Prim.wordAdd csizeSize}
in
- (Offset {base = Operand.Var {ty = wty,
+ (Offset {base = Operand.Var {ty = csizeTy,
var = eltBase},
offset = offset,
ty = ty},
- [s1, s2])
+ [s0, s1, s2])
end
| SOME s =>
(ArrayOffset {base = vector,
@@ -724,26 +751,31 @@
val padBytes: Bytes.t =
if isVector
then let
- val width = width
val alignWidth =
- if (Vector.exists
- (components, fn {component = c, ...} =>
- case Type.deReal (Component.ty c) of
- NONE => false
- | SOME s => RealSize.equals (s, RealSize.R64)))
- then Bytes.alignWord64 width
- else width
+ case !Control.align of
+ Control.Align4 => width
+ | Control.Align8 =>
+ if (Vector.exists
+ (components, fn {component = c, ...} =>
+ case Type.deReal (Component.ty c) of
+ NONE => false
+ | SOME s => RealSize.equals (s, RealSize.R64)))
+ then Bytes.alignWord64 width
+ else width
in
Bytes.- (alignWidth, width)
end
else let
- val width = Bytes.+ (width, Runtime.headerSize ())
- val alignWidth =
+ (* An object needs space for a forwarding objptr. *)
+ val width' = Bytes.max (width, Runtime.objptrSize ())
+ val width'' = Bytes.+ (width', Runtime.headerSize ())
+ val alignWidth'' =
case !Control.align of
- Control.Align4 => Bytes.alignWord32 width
- | Control.Align8 => Bytes.alignWord64 width
+ Control.Align4 => Bytes.alignWord32 width''
+ | Control.Align8 => Bytes.alignWord64 width''
+ val alignWidth' = Bytes.- (alignWidth'', Runtime.headerSize ())
in
- Bytes.- (alignWidth, width)
+ Bytes.- (alignWidth', width)
end
val (components, selects) =
if Bytes.isZero padBytes
@@ -759,17 +791,21 @@
if 0 = Vector.length objptrs
then width
else #offset (Vector.sub (objptrs, 0))
- val pad =
- {component = (Component.padToWidth
- (Component.unit,
- Bytes.toBits padBytes)),
- offset = padOffset}
+ val pad =
+ (#1 o Vector.unfoldi)
+ ((Bytes.toInt padBytes) div (Bytes.toInt Bytes.inWord32),
+ padOffset,
+ fn (_, padOffset) =>
+ ({component = (Component.padToWidth
+ (Component.unit, Bits.inWord32)),
+ offset = padOffset},
+ Bytes.+ (padOffset, Bytes.inWord32)))
val objptrs =
Vector.map (objptrs, fn {component = c, offset} =>
{component = c,
offset = Bytes.+ (offset, padBytes)})
val components =
- Vector.concat [nonObjptrs, Vector.new1 pad, objptrs]
+ Vector.concat [nonObjptrs, pad, objptrs]
val selects =
Selects.map
(selects, fn s =>
@@ -1700,6 +1736,17 @@
in
if i >= objptrBitsAsInt ()
then makeBig ()
+ else if (* FIXME: must box Real32 w/ 64bit object pointers,
+ * since ShiftAndTag operations aren't bit casts;
+ * we end up rounding a Real32 to a Word64.
+ *)
+ Type.exists
+ (ty, fn ty =>
+ case Type.deReal ty of
+ NONE => false
+ | SOME rs => Bytes.< (RealSize.bytes rs,
+ objptrBytes ()))
+ then makeBig ()
else
let
val {component, selects} =
@@ -2454,7 +2501,7 @@
if nInt = 8
orelse nInt = 16
orelse nInt = 32
- (* orelse nInt = 64 *)
+ orelse nInt = 64
then
now
(ObjptrTycon.wordVector nBits)
Modified: mlton/branches/on-20050822-x86_64-branch/mlton/backend/rep-type.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/backend/rep-type.fun 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/backend/rep-type.fun 2007-02-25 22:00:41 UTC (rev 5322)
@@ -252,7 +252,14 @@
Trace.trace2 ("RepType.Type.isSubtype", layout, layout, Bool.layout)
isSubtype
+ fun exists (t, p) =
+ if p t
+ then true
+ else (case node t of
+ Seq ts => Vector.exists (ts, fn t => exists (t, p))
+ | _ => false)
+
val resize: t * Bits.t -> t = fn (_, b) => word b
val bogusWord: t -> WordX.t =
Modified: mlton/branches/on-20050822-x86_64-branch/mlton/backend/rep-type.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/backend/rep-type.sig 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/backend/rep-type.sig 2007-02-25 22:00:41 UTC (rev 5322)
@@ -67,6 +67,7 @@
val equals: t * t -> bool
val exnStack: unit -> t
val gcState: unit -> t
+ val exists: t * (t -> bool) -> bool
val intInf: unit -> t
val isCPointer: t -> bool
val isObjptr: t -> bool
Modified: mlton/branches/on-20050822-x86_64-branch/mlton/codegen/c-codegen/c-codegen.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/codegen/c-codegen/c-codegen.fun 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/codegen/c-codegen/c-codegen.fun 2007-02-25 22:00:41 UTC (rev 5322)
@@ -335,13 +335,21 @@
| Stack =>
(2, false, 0, 0)
| Weak =>
- (case !Control.align of
- Control.Align4 => (3, false, 4, 1)
- | Control.Align8 => (3, false, 8, 1))
+ (case (!Control.align,
+ Bits.toInt (Control.Target.Size.cpointer ()),
+ Bits.toInt (Control.Target.Size.objptr ())) of
+ (Control.Align4,32,32) => (3, false, 4, 1)
+ | (Control.Align8,32,32) => (3, false, 8, 1)
+ | (Control.Align4,64,64) => (3, false, 8, 1)
+ | _ => Error.bug "CCodegen.declareObjectTypes")
| WeakGone =>
- (case !Control.align of
- Control.Align4 => (3, false, 8, 0)
- | Control.Align8 => (3, false, 12, 0))
+ (case (!Control.align,
+ Bits.toInt (Control.Target.Size.cpointer ()),
+ Bits.toInt (Control.Target.Size.objptr ())) of
+ (Control.Align4,32,32) => (3, false, 8, 0)
+ | (Control.Align8,32,32) => (3, false, 12, 0)
+ | (Control.Align4,64,64) => (3, false, 16, 0)
+ | _ => Error.bug "CCodegen.declareObjectTypes")
in
concat ["{ ", C.int tag, ", ",
C.bool hasIdentity, ", ",
Modified: mlton/branches/on-20050822-x86_64-branch/mlton/main/main.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/main/main.fun 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/main/main.fun 2007-02-25 22:00:41 UTC (rev 5322)
@@ -114,8 +114,7 @@
datatype z = datatype Control.Target.arch
in
case !Control.Target.arch of
- AMD64 => true
- | X86 => true
+ X86 => true
| _ => false
end
@@ -212,7 +211,8 @@
SpaceString (fn s =>
explicitCodegen
:= SOME (case s of
- "bytecode" => Bytecode
+ "bytecode" => (* Bytecode *)
+ usage "can't use bytecode codegen"
| "c" => CCodegen
| "native" => Native
| _ => usage (concat
@@ -683,19 +683,36 @@
| MinGW => true
| _ => false)
val () =
- let
- val word32 = Bits.fromInt 32
- in
- Control.Target.setSizes
- {cint = word32,
- cpointer = word32,
- cptrdiff = word32,
- csize = word32,
- header = word32,
- mplimb = word32,
- objptr = word32,
- seqIndex = word32}
- end
+ case targetArch of
+ AMD64 =>
+ let
+ val word32 = Bits.fromInt 32
+ val word64 = Bits.fromInt 64
+ in
+ Control.Target.setSizes
+ {cint = word32,
+ cpointer = word64,
+ cptrdiff = word64,
+ csize = word64,
+ header = word32,
+ mplimb = word64,
+ objptr = word64,
+ seqIndex = word32}
+ end
+ | _ =>
+ let
+ val word32 = Bits.fromInt 32
+ in
+ Control.Target.setSizes
+ {cint = word32,
+ cpointer = word32,
+ cptrdiff = word32,
+ csize = word32,
+ header = word32,
+ mplimb = word32,
+ objptr = word32,
+ seqIndex = word32}
+ end
val OSStr = String.toLower (MLton.Platform.OS.toString targetOS)
fun tokenize l =
String.tokens (concat (List.separate (l, " ")), Char.isSpace)
Copied: mlton/branches/on-20050822-x86_64-branch/regression/mlton.share.amd64-linux.ok (from rev 5306, mlton/branches/on-20050822-x86_64-branch/regression/mlton.share.sparc-solaris.ok)
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/regression/mlton.share.sparc-solaris.ok 2007-02-23 14:50:08 UTC (rev 5306)
+++ mlton/branches/on-20050822-x86_64-branch/regression/mlton.share.amd64-linux.ok 2007-02-25 22:00:41 UTC (rev 5322)
@@ -0,0 +1,718 @@
+size of a is 2000
+0 => NONE
+1 => (1, 1)
+2 => (0, 2)
+3 => (1, 0)
+4 => (0, 1)
+5 => (1, 2)
+6 => (0, 0)
+7 => (1, 1)
+8 => (0, 2)
+9 => (1, 0)
+10 => (0, 1)
+11 => (1, 2)
+12 => (0, 0)
+13 => (1, 1)
+14 => (0, 2)
+15 => (1, 0)
+16 => (0, 1)
+17 => (1, 2)
+18 => (0, 0)
+19 => (1, 1)
+20 => (0, 2)
+21 => (1, 0)
+22 => (0, 1)
+23 => (1, 2)
+24 => (0, 0)
+25 => (1, 1)
+26 => (0, 2)
+27 => (1, 0)
+28 => (0, 1)
+29 => (1, 2)
+30 => (0, 0)
+31 => (1, 1)
+32 => (0, 2)
+33 => (1, 0)
+34 => (0, 1)
+35 => (1, 2)
+36 => (0, 0)
+37 => (1, 1)
+38 => (0, 2)
+39 => (1, 0)
+40 => (0, 1)
+41 => (1, 2)
+42 => (0, 0)
+43 => (1, 1)
+44 => (0, 2)
+45 => (1, 0)
+46 => (0, 1)
+47 => (1, 2)
+48 => (0, 0)
+49 => (1, 1)
+50 => (0, 2)
+51 => (1, 0)
+52 => (0, 1)
+53 => (1, 2)
+54 => (0, 0)
+55 => (1, 1)
+56 => (0, 2)
+57 => (1, 0)
+58 => (0, 1)
+59 => (1, 2)
+60 => (0, 0)
+61 => (1, 1)
+62 => (0, 2)
+63 => (1, 0)
+64 => (0, 1)
+65 => (1, 2)
+66 => (0, 0)
+67 => (1, 1)
+68 => (0, 2)
+69 => (1, 0)
+70 => (0, 1)
+71 => (1, 2)
+72 => (0, 0)
+73 => (1, 1)
+74 => (0, 2)
+75 => (1, 0)
+76 => (0, 1)
+77 => (1, 2)
+78 => (0, 0)
+79 => (1, 1)
+80 => (0, 2)
+81 => (1, 0)
+82 => (0, 1)
+83 => (1, 2)
+84 => (0, 0)
+85 => (1, 1)
+86 => (0, 2)
+87 => (1, 0)
+88 => (0, 1)
+89 => (1, 2)
+90 => (0, 0)
+91 => (1, 1)
+92 => (0, 2)
+93 => (1, 0)
+94 => (0, 1)
+95 => (1, 2)
+96 => (0, 0)
+97 => (1, 1)
+98 => (0, 2)
+99 => (1, 0)
+size of a is 884
+0 => NONE
+1 => (1, 1)
+2 => (0, 2)
+3 => (1, 0)
+4 => (0, 1)
+5 => (1, 2)
+6 => (0, 0)
+7 => (1, 1)
+8 => (0, 2)
+9 => (1, 0)
+10 => (0, 1)
+11 => (1, 2)
+12 => (0, 0)
+13 => (1, 1)
+14 => (0, 2)
+15 => (1, 0)
+16 => (0, 1)
+17 => (1, 2)
+18 => (0, 0)
+19 => (1, 1)
+20 => (0, 2)
+21 => (1, 0)
+22 => (0, 1)
+23 => (1, 2)
+24 => (0, 0)
+25 => (1, 1)
+26 => (0, 2)
+27 => (1, 0)
+28 => (0, 1)
+29 => (1, 2)
+30 => (0, 0)
+31 => (1, 1)
+32 => (0, 2)
+33 => (1, 0)
+34 => (0, 1)
+35 => (1, 2)
+36 => (0, 0)
+37 => (1, 1)
+38 => (0, 2)
+39 => (1, 0)
+40 => (0, 1)
+41 => (1, 2)
+42 => (0, 0)
+43 => (1, 1)
+44 => (0, 2)
+45 => (1, 0)
+46 => (0, 1)
+47 => (1, 2)
+48 => (0, 0)
+49 => (1, 1)
+50 => (0, 2)
+51 => (1, 0)
+52 => (0, 1)
+53 => (1, 2)
+54 => (0, 0)
+55 => (1, 1)
+56 => (0, 2)
+57 => (1, 0)
+58 => (0, 1)
+59 => (1, 2)
+60 => (0, 0)
+61 => (1, 1)
+62 => (0, 2)
+63 => (1, 0)
+64 => (0, 1)
+65 => (1, 2)
+66 => (0, 0)
+67 => (1, 1)
+68 => (0, 2)
+69 => (1, 0)
+70 => (0, 1)
+71 => (1, 2)
+72 => (0, 0)
+73 => (1, 1)
+74 => (0, 2)
+75 => (1, 0)
+76 => (0, 1)
+77 => (1, 2)
+78 => (0, 0)
+79 => (1, 1)
+80 => (0, 2)
+81 => (1, 0)
+82 => (0, 1)
+83 => (1, 2)
+84 => (0, 0)
+85 => (1, 1)
+86 => (0, 2)
+87 => (1, 0)
+88 => (0, 1)
+89 => (1, 2)
+90 => (0, 0)
+91 => (1, 1)
+92 => (0, 2)
+93 => (1, 0)
+94 => (0, 1)
+95 => (1, 2)
+96 => (0, 0)
+97 => (1, 1)
+98 => (0, 2)
+99 => (1, 0)
+size of a is 1424
+0 => NONE
+1 => (1, 1)
+2 => (1, 1)
+3 => (0, 0)
+4 => (1, 1)
+5 => (2, 2)
+6 => (1, 1)
+7 => (1, 1)
+8 => (1, 1)
+9 => (0, 0)
+10 => (1, 1)
+11 => (2, 2)
+12 => (1, 1)
+13 => (1, 1)
+14 => (1, 1)
+15 => (0, 0)
+16 => (1, 1)
+17 => (2, 2)
+18 => (1, 1)
+19 => (1, 1)
+20 => (1, 1)
+21 => (0, 0)
+22 => (1, 1)
+23 => (2, 2)
+24 => (1, 1)
+25 => (1, 1)
+26 => (1, 1)
+27 => (0, 0)
+28 => (1, 1)
+29 => (2, 2)
+30 => (1, 1)
+31 => (1, 1)
+32 => (1, 1)
+33 => (0, 0)
+34 => (1, 1)
+35 => (2, 2)
+36 => (1, 1)
+37 => (1, 1)
+38 => (1, 1)
+39 => (0, 0)
+40 => (1, 1)
+41 => (2, 2)
+42 => (1, 1)
+43 => (1, 1)
+44 => (1, 1)
+45 => (0, 0)
+46 => (1, 1)
+47 => (2, 2)
+48 => (1, 1)
+49 => (1, 1)
+50 => (1, 1)
+51 => (0, 0)
+52 => (1, 1)
+53 => (2, 2)
+54 => (1, 1)
+55 => (1, 1)
+56 => (1, 1)
+57 => (0, 0)
+58 => (1, 1)
+59 => (2, 2)
+60 => (1, 1)
+61 => (1, 1)
+62 => (1, 1)
+63 => (0, 0)
+64 => (1, 1)
+65 => (2, 2)
+66 => (1, 1)
+67 => (1, 1)
+68 => (1, 1)
+69 => (0, 0)
+70 => (1, 1)
+71 => (2, 2)
+72 => (1, 1)
+73 => (1, 1)
+74 => (1, 1)
+75 => (0, 0)
+76 => (1, 1)
+77 => (2, 2)
+78 => (1, 1)
+79 => (1, 1)
+80 => (1, 1)
+81 => (0, 0)
+82 => (1, 1)
+83 => (2, 2)
+84 => (1, 1)
+85 => (1, 1)
+86 => (1, 1)
+87 => (0, 0)
+88 => (1, 1)
+89 => (2, 2)
+90 => (1, 1)
+91 => (1, 1)
+92 => (1, 1)
+93 => (0, 0)
+94 => (1, 1)
+95 => (2, 2)
+96 => (1, 1)
+97 => (1, 1)
+98 => (1, 1)
+99 => (0, 0)
+size of a is 848
+0 => NONE
+1 => (1, 1)
+2 => (1, 1)
+3 => (0, 0)
+4 => (1, 1)
+5 => (2, 2)
+6 => (1, 1)
+7 => (1, 1)
+8 => (1, 1)
+9 => (0, 0)
+10 => (1, 1)
+11 => (2, 2)
+12 => (1, 1)
+13 => (1, 1)
+14 => (1, 1)
+15 => (0, 0)
+16 => (1, 1)
+17 => (2, 2)
+18 => (1, 1)
+19 => (1, 1)
+20 => (1, 1)
+21 => (0, 0)
+22 => (1, 1)
+23 => (2, 2)
+24 => (1, 1)
+25 => (1, 1)
+26 => (1, 1)
+27 => (0, 0)
+28 => (1, 1)
+29 => (2, 2)
+30 => (1, 1)
+31 => (1, 1)
+32 => (1, 1)
+33 => (0, 0)
+34 => (1, 1)
+35 => (2, 2)
+36 => (1, 1)
+37 => (1, 1)
+38 => (1, 1)
+39 => (0, 0)
+40 => (1, 1)
+41 => (2, 2)
+42 => (1, 1)
+43 => (1, 1)
+44 => (1, 1)
+45 => (0, 0)
+46 => (1, 1)
+47 => (2, 2)
+48 => (1, 1)
+49 => (1, 1)
+50 => (1, 1)
+51 => (0, 0)
+52 => (1, 1)
+53 => (2, 2)
+54 => (1, 1)
+55 => (1, 1)
+56 => (1, 1)
+57 => (0, 0)
+58 => (1, 1)
+59 => (2, 2)
+60 => (1, 1)
+61 => (1, 1)
+62 => (1, 1)
+63 => (0, 0)
+64 => (1, 1)
+65 => (2, 2)
+66 => (1, 1)
+67 => (1, 1)
+68 => (1, 1)
+69 => (0, 0)
+70 => (1, 1)
+71 => (2, 2)
+72 => (1, 1)
+73 => (1, 1)
+74 => (1, 1)
+75 => (0, 0)
+76 => (1, 1)
+77 => (2, 2)
+78 => (1, 1)
+79 => (1, 1)
+80 => (1, 1)
+81 => (0, 0)
+82 => (1, 1)
+83 => (2, 2)
+84 => (1, 1)
+85 => (1, 1)
+86 => (1, 1)
+87 => (0, 0)
+88 => (1, 1)
+89 => (2, 2)
+90 => (1, 1)
+91 => (1, 1)
+92 => (1, 1)
+93 => (0, 0)
+94 => (1, 1)
+95 => (2, 2)
+96 => (1, 1)
+97 => (1, 1)
+98 => (1, 1)
+99 => (0, 0)
+size of a is 3200
+0 => NONE
+1 => (1, 1)
+2 => (0, 2)
+3 => (1, 0)
+4 => (0, 1)
+5 => (1, 2)
+6 => (0, 0)
+7 => (1, 1)
+8 => (0, 2)
+9 => (1, 0)
+10 => (0, 1)
+11 => (1, 2)
+12 => (0, 0)
+13 => (1, 1)
+14 => (0, 2)
+15 => (1, 0)
+16 => (0, 1)
+17 => (1, 2)
+18 => (0, 0)
+19 => (1, 1)
+20 => (0, 2)
+21 => (1, 0)
+22 => (0, 1)
+23 => (1, 2)
+24 => (0, 0)
+25 => (1, 1)
+26 => (0, 2)
+27 => (1, 0)
+28 => (0, 1)
+29 => (1, 2)
+30 => (0, 0)
+31 => (1, 1)
+32 => (0, 2)
+33 => (1, 0)
+34 => (0, 1)
+35 => (1, 2)
+36 => (0, 0)
+37 => (1, 1)
+38 => (0, 2)
+39 => (1, 0)
+40 => (0, 1)
+41 => (1, 2)
+42 => (0, 0)
+43 => (1, 1)
+44 => (0, 2)
+45 => (1, 0)
+46 => (0, 1)
+47 => (1, 2)
+48 => (0, 0)
+49 => (1, 1)
+50 => (0, 2)
+51 => (1, 0)
+52 => (0, 1)
+53 => (1, 2)
+54 => (0, 0)
+55 => (1, 1)
+56 => (0, 2)
+57 => (1, 0)
+58 => (0, 1)
+59 => (1, 2)
+60 => (0, 0)
+61 => (1, 1)
+62 => (0, 2)
+63 => (1, 0)
+64 => (0, 1)
+65 => (1, 2)
+66 => (0, 0)
+67 => (1, 1)
+68 => (0, 2)
+69 => (1, 0)
+70 => (0, 1)
+71 => (1, 2)
+72 => (0, 0)
+73 => (1, 1)
+74 => (0, 2)
+75 => (1, 0)
+76 => (0, 1)
+77 => (1, 2)
+78 => (0, 0)
+79 => (1, 1)
+80 => (0, 2)
+81 => (1, 0)
+82 => (0, 1)
+83 => (1, 2)
+84 => (0, 0)
+85 => (1, 1)
+86 => (0, 2)
+87 => (1, 0)
+88 => (0, 1)
+89 => (1, 2)
+90 => (0, 0)
+91 => (1, 1)
+92 => (0, 2)
+93 => (1, 0)
+94 => (0, 1)
+95 => (1, 2)
+96 => (0, 0)
+97 => (1, 1)
+98 => (0, 2)
+99 => (1, 0)
+size of a is 2084
+0 => NONE
+1 => (1, 1)
+2 => (0, 2)
+3 => (1, 0)
+4 => (0, 1)
+5 => (1, 2)
+6 => (0, 0)
+7 => (1, 1)
+8 => (0, 2)
+9 => (1, 0)
+10 => (0, 1)
+11 => (1, 2)
+12 => (0, 0)
+13 => (1, 1)
+14 => (0, 2)
+15 => (1, 0)
+16 => (0, 1)
+17 => (1, 2)
+18 => (0, 0)
+19 => (1, 1)
+20 => (0, 2)
+21 => (1, 0)
+22 => (0, 1)
+23 => (1, 2)
+24 => (0, 0)
+25 => (1, 1)
+26 => (0, 2)
+27 => (1, 0)
+28 => (0, 1)
+29 => (1, 2)
+30 => (0, 0)
+31 => (1, 1)
+32 => (0, 2)
+33 => (1, 0)
+34 => (0, 1)
+35 => (1, 2)
+36 => (0, 0)
+37 => (1, 1)
+38 => (0, 2)
+39 => (1, 0)
+40 => (0, 1)
+41 => (1, 2)
+42 => (0, 0)
+43 => (1, 1)
+44 => (0, 2)
+45 => (1, 0)
+46 => (0, 1)
+47 => (1, 2)
+48 => (0, 0)
+49 => (1, 1)
+50 => (0, 2)
+51 => (1, 0)
+52 => (0, 1)
+53 => (1, 2)
+54 => (0, 0)
+55 => (1, 1)
+56 => (0, 2)
+57 => (1, 0)
+58 => (0, 1)
+59 => (1, 2)
+60 => (0, 0)
+61 => (1, 1)
+62 => (0, 2)
+63 => (1, 0)
+64 => (0, 1)
+65 => (1, 2)
+66 => (0, 0)
+67 => (1, 1)
+68 => (0, 2)
+69 => (1, 0)
+70 => (0, 1)
+71 => (1, 2)
+72 => (0, 0)
+73 => (1, 1)
+74 => (0, 2)
+75 => (1, 0)
+76 => (0, 1)
+77 => (1, 2)
+78 => (0, 0)
+79 => (1, 1)
+80 => (0, 2)
+81 => (1, 0)
+82 => (0, 1)
+83 => (1, 2)
+84 => (0, 0)
+85 => (1, 1)
+86 => (0, 2)
+87 => (1, 0)
+88 => (0, 1)
+89 => (1, 2)
+90 => (0, 0)
+91 => (1, 1)
+92 => (0, 2)
+93 => (1, 0)
+94 => (0, 1)
+95 => (1, 2)
+96 => (0, 0)
+97 => (1, 1)
+98 => (0, 2)
+99 => (1, 0)
+size of a is 3200
+0 => NONE
+1 => (1, 1)
+2 => (0, 2)
+3 => (1, 0)
+4 => (0, 1)
+5 => (1, 2)
+6 => (0, 0)
+7 => (1, 1)
+8 => (0, 2)
+9 => (1, 0)
+10 => (0, 1)
+11 => (1, 2)
+12 => (0, 0)
+13 => (1, 1)
+14 => (0, 2)
+15 => (1, 0)
+16 => (0, 1)
+17 => (1, 2)
+18 => (0, 0)
+19 => (1, 1)
+20 => (0, 2)
+21 => (1, 0)
+22 => (0, 1)
+23 => (1, 2)
+24 => (0, 0)
+25 => (1, 1)
+26 => (0, 2)
+27 => (1, 0)
+28 => (0, 1)
+29 => (1, 2)
+30 => (0, 0)
+31 => (1, 1)
+32 => (0, 2)
+33 => (1, 0)
+34 => (0, 1)
+35 => (1, 2)
+36 => (0, 0)
+37 => (1, 1)
+38 => (0, 2)
+39 => (1, 0)
+40 => (0, 1)
+41 => (1, 2)
+42 => (0, 0)
+43 => (1, 1)
+44 => (0, 2)
+45 => (1, 0)
+46 => (0, 1)
+47 => (1, 2)
+48 => (0, 0)
+49 => (1, 1)
+50 => (0, 2)
+51 => (1, 0)
+52 => (0, 1)
+53 => (1, 2)
+54 => (0, 0)
+55 => (1, 1)
+56 => (0, 2)
+57 => (1, 0)
+58 => (0, 1)
+59 => (1, 2)
+60 => (0, 0)
+61 => (1, 1)
+62 => (0, 2)
+63 => (1, 0)
+64 => (0, 1)
+65 => (1, 2)
+66 => (0, 0)
+67 => (1, 1)
+68 => (0, 2)
+69 => (1, 0)
+70 => (0, 1)
+71 => (1, 2)
+72 => (0, 0)
+73 => (1, 1)
+74 => (0, 2)
+75 => (1, 0)
+76 => (0, 1)
+77 => (1, 2)
+78 => (0, 0)
+79 => (1, 1)
+80 => (0, 2)
+81 => (1, 0)
+82 => (0, 1)
+83 => (1, 2)
+84 => (0, 0)
+85 => (1, 1)
+86 => (0, 2)
+87 => (1, 0)
+88 => (0, 1)
+89 => (1, 2)
+90 => (0, 0)
+91 => (1, 1)
+92 => (0, 2)
+93 => (1, 0)
+94 => (0, 1)
+95 => (1, 2)
+96 => (0, 0)
+97 => (1, 1)
+98 => (0, 2)
+99 => (1, 0)
+size of a is 2000000
+(1, 1)
+size of a is 800084
+(1, 1)
+size is 212
+size is 112
+abcdef abcdef
+size is 60
+size is 40
+abcdef abcdef
+1 2
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Makefile
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Makefile 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Makefile 2007-02-25 22:00:41 UTC (rev 5322)
@@ -23,14 +23,14 @@
EXE :=
OPTFLAGS := -O2 -fomit-frame-pointer
GCOPTFLAGS :=
-DEBUGFLAGS :=
+DEBUGFLAGS := -O1 -fno-inline -fkeep-inline-functions -g2
GCDEBUGFLAGS :=
WARNFLAGS :=
OPTWARNFLAGS :=
DEBUGWARNFLAGS :=
ifeq ($(TARGET_ARCH), amd64)
-FLAGS += -m32
+FLAGS += -m64
ifeq ($(findstring $(GCC_MAJOR_VERSION), 3),$(GCC_MAJOR_VERSION))
OPTFLAGS += -mcpu=opteron
endif
@@ -107,7 +107,7 @@
CC := gcc -std=gnu99
CFLAGS := -I. -Iplatform $(FLAGS)
OPTCFLAGS := $(CFLAGS) $(OPTFLAGS)
-DEBUGCFLAGS := $(CFLAGS) -g2 -O1 -DASSERT=1 $(DEBUGFLAGS)
+DEBUGCFLAGS := $(CFLAGS) -DASSERT=1 $(DEBUGFLAGS)
GCOPTCFLAGS = $(GCOPTFLAGS)
GCDEBUGCFLAGS = $(GCDEBUGFLAGS)
WARNCFLAGS :=
@@ -147,7 +147,7 @@
endif
WARNCFLAGS += -Wmissing-noreturn
WARNCFLAGS += -Wmissing-format-attribute
-WARNCFLAGS += -Wpacked
+# WARNCFLAGS += -Wpacked
# WARNCFLAGS += -Wpadded
WARNCFLAGS += -Wredundant-decls
WARNCFLAGS += -Wnested-externs
@@ -214,6 +214,7 @@
platform-gdb.o \
platform/$(TARGET_OS)-gdb.o
+OMIT_BYTECODE := yes
ifeq ($(OMIT_BYTECODE), yes)
else
OBJS += bytecode/interpret.o
@@ -232,10 +233,15 @@
$(foreach f, $(basename $(REAL_BASISCFILES)), $(f)-gdb.o)
endif
-all: libgdtoa.a libmlton.a libmlton-gdb.a \
- gen/c-types.sml gen/basis-ffi.sml \
- bytecode/opcodes
+ALL := libgdtoa.a libmlton.a libmlton-gdb.a
+ALL += gen/c-types.sml gen/basis-ffi.sml
+ifeq ($(OMIT_BYTECODE), yes)
+else
+ ALL += bytecode/opcodes
+endif
+all: $(ALL)
+
libgdtoa.a: gdtoa/arith.h
cd gdtoa && \
$(CC) $(OPTCFLAGS) $(OPTWARNCFLAGS) \
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/cenv.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/cenv.h 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/cenv.h 2007-02-25 22:00:41 UTC (rev 5322)
@@ -121,5 +121,8 @@
#error unknown platform arch
#endif
+COMPILE_TIME_ASSERT(sizeof_uintptr_t__is_sizeof_voidStar, sizeof(uintptr_t) == sizeof(void*));
+COMPILE_TIME_ASSERT(sizeof_uintptr_t__is__sizeof_size_t, sizeof(uintptr_t) == sizeof(size_t));
+COMPILE_TIME_ASSERT(sizeof_uintptr_t__is__sizeof_ptrdiff_t, sizeof(uintptr_t) == sizeof(ptrdiff_t));
#endif /* _MLTON_CENV_H_ */
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/array-allocate.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/array-allocate.c 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/array-allocate.c 2007-02-25 22:00:41 UTC (rev 5322)
@@ -33,13 +33,15 @@
arraySize = (size_t)arraySizeMax;
arraySizeAligned = (size_t)arraySizeAlignedMax;
if (arraySizeAligned < GC_ARRAY_HEADER_SIZE + OBJPTR_SIZE) {
- /* Create space for forwarding pointer. */
+ /* Very small (including empty) arrays have OBJPTR_SIZE bytes
+ * space for the forwarding pointer.
+ */
arraySize = GC_ARRAY_HEADER_SIZE;
arraySizeAligned = align(GC_ARRAY_HEADER_SIZE + OBJPTR_SIZE, s->alignment);
}
if (DEBUG_ARRAY)
fprintf (stderr,
- "Array with "FMTARRLEN" elts of size %zu and size %s and aligned size %s. "
+ "Array with "FMTARRLEN" elts of size %zu and total size %s and total aligned size %s. "
"Ensure %s bytes free.\n",
numElements, bytesPerElement,
uintmaxToCommaString(arraySize),
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/debug.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/debug.h 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/debug.h 2007-02-25 22:00:41 UTC (rev 5322)
@@ -22,6 +22,7 @@
DEBUG_INT_INF_DETAILED = FALSE,
DEBUG_MARK_COMPACT = FALSE,
DEBUG_MEM = FALSE,
+ DEBUG_OBJPTR = FALSE,
DEBUG_PROFILE = FALSE,
DEBUG_RESIZING = FALSE,
DEBUG_SHARE = FALSE,
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/foreach.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/foreach.c 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/foreach.c 2007-02-25 22:00:41 UTC (rev 5322)
@@ -74,22 +74,23 @@
p += OBJPTR_SIZE;
}
} else if (ARRAY_TAG == tag) {
+ size_t bytesPerElement;
size_t dataBytes;
pointer last;
GC_arrayLength numElements;
numElements = getArrayLength (p);
- dataBytes = numElements * (bytesNonObjptrs + (numObjptrs * OBJPTR_SIZE));
- /* Must check 0 == dataBytes before 0 == numPointers to correctly
- * handle arrays when both are true.
- */
- if (0 == dataBytes)
- /* Empty arrays have space for forwarding pointer. */
+ bytesPerElement = bytesNonObjptrs + (numObjptrs * OBJPTR_SIZE);
+ dataBytes = numElements * bytesPerElement;
+ if (dataBytes < OBJPTR_SIZE) {
+ /* Very small (including empty) arrays have OBJPTR_SIZE bytes
+ * space for the forwarding pointer.
+ */
dataBytes = OBJPTR_SIZE;
- else if (0 == numObjptrs)
- /* No pointers to process. */
+ } else if (0 == numObjptrs) {
+ /* No objptrs to process. */
;
- else {
+ } else {
last = p + dataBytes;
if (0 == bytesNonObjptrs)
/* Array with only pointers. */
@@ -187,7 +188,8 @@
fprintf (stderr,
" front = "FMTPTR" *back = "FMTPTR"\n",
(uintptr_t)front, (uintptr_t)(*back));
- front = foreachObjptrInObject (s, advanceToObjectData (s, front), f, skipWeaks);
+ pointer p = advanceToObjectData (s, front);
+ front = foreachObjptrInObject (s, p, f, skipWeaks);
}
b = *back;
}
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/garbage-collection.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/garbage-collection.c 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/garbage-collection.c 2007-02-25 22:00:41 UTC (rev 5322)
@@ -24,7 +24,7 @@
s->hashConsDuringGC = TRUE;
desiredSize =
sizeofHeapDesired (s, s->lastMajorStatistics.bytesLive + bytesRequested, 0);
- if ((not FORCE_MARK_COMPACT)
+ if (not FORCE_MARK_COMPACT
and not s->hashConsDuringGC // only markCompact can hash cons
and s->heap.size < s->sysvals.ram
and (not isHeapInit (&s->secondaryHeap)
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/gc_state.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/gc_state.c 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/gc_state.c 2007-02-25 22:00:41 UTC (rev 5322)
@@ -59,7 +59,7 @@
nurserySize = h->size - h->oldGenSize - oldGenBytesRequested;
s->limitPlusSlop = h->start + h->size;
s->limit = s->limitPlusSlop - GC_HEAP_LIMIT_SLOP;
- assert (isAligned (nurserySize, POINTER_SIZE));
+ assert (isAligned (nurserySize, s->alignment));
if (/* The mutator marks cards. */
s->mutatorMarksCards
/* There is enough space in the nursery. */
@@ -73,11 +73,9 @@
<= s->controls.ratios.nursery)
and /* There is a reason to use generational GC. */
(
- /* We must use it for debugging pruposes. */
+ /* We must use it for debugging purposes. */
FORCE_GENERATIONAL
- /* We just did a mark compact, so it will be advantageous to to
- * use it.
- */
+ /* We just did a mark compact, so it will be advantageous to to use it. */
or (s->lastMajorStatistics.kind == GC_MARK_COMPACT)
/* The live ratio is low enough to make it worthwhile. */
or ((float)h->size / (float)s->lastMajorStatistics.bytesLive
@@ -87,7 +85,7 @@
)) {
s->canMinor = TRUE;
nurserySize /= 2;
- while (not (isAligned (nurserySize, POINTER_SIZE))) {
+ while (not (isAligned (nurserySize, s->alignment))) {
nurserySize -= 2;
}
clearCardMap (s);
@@ -110,7 +108,6 @@
assert (hasHeapBytesFree (s, oldGenBytesRequested, nurseryBytesRequested));
}
-
bool GC_getAmOriginal (GC_state s) {
return s->amOriginal;
}
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/generational.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/generational.c 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/generational.c 2007-02-25 22:00:41 UTC (rev 5322)
@@ -10,7 +10,7 @@
struct GC_generationalMaps *generational,
FILE *stream) {
fprintf(stream,
- "\t\tcardMap ="FMTPTR"\n"
+ "\t\tcardMap = "FMTPTR"\n"
"\t\tcardMapAbsolute = "FMTPTR"\n"
"\t\tcardMapLength = %zu\n"
"\t\tcrossMap = "FMTPTR"\n"
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 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/init-world.c 2007-02-25 22:00:41 UTC (rev 5322)
@@ -24,7 +24,7 @@
size_t sizeofInitialBytesLive (GC_state s) {
uint32_t i;
- size_t numBytes;
+ size_t dataBytes;
size_t total;
total = 0;
@@ -32,13 +32,13 @@
total += sizeofIntInfFromString (s, s->intInfInits[i].mlstr);
}
for (i = 0; i < s->vectorInitsLength; ++i) {
- numBytes =
+ dataBytes =
s->vectorInits[i].bytesPerElement
* s->vectorInits[i].numElements;
total += align (GC_ARRAY_HEADER_SIZE
- + ((0 == numBytes)
+ + ((dataBytes < OBJPTR_SIZE)
? OBJPTR_SIZE
- : numBytes),
+ : dataBytes),
s->alignment);
}
return total;
@@ -89,8 +89,8 @@
bytesPerElement = inits[i].bytesPerElement;
dataBytes = bytesPerElement * inits[i].numElements;
objectSize = align (GC_ARRAY_HEADER_SIZE
- + ((0 == dataBytes)
- ? POINTER_SIZE
+ + ((dataBytes < OBJPTR_SIZE)
+ ? OBJPTR_SIZE
: dataBytes),
s->alignment);
assert (objectSize <= (size_t)(s->heap.start + s->heap.size - frontier));
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/invariant.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/invariant.c 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/invariant.c 2007-02-25 22:00:41 UTC (rev 5322)
@@ -80,7 +80,7 @@
foreachObjptrInRange (s, s->heap.nursery, &s->frontier,
assertIsObjptrInFromSpace, FALSE);
/* Current thread. */
- __attribute__ ((unused)) GC_stack stack = getStackCurrent(s);
+ GC_stack stack = getStackCurrent(s);
assert (isStackReservedAligned (s, stack->reserved));
assert (s->stackBottom == getStackBottom (s, stack));
assert (s->stackTop == getStackTop (s, stack));
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/mark-compact.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/mark-compact.c 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/mark-compact.c 2007-02-25 22:00:41 UTC (rev 5322)
@@ -134,9 +134,9 @@
/* Compress all of the unmarked into one vector. We require
* (GC_ARRAY_HEADER_SIZE + OBJPTR_SIZE) space to be available
* because that is the smallest possible array. You cannot
- * use GC_ARRAY_HEADER_SIZE because even zero-length arrays
- * require extra space for the forwarding pointer. If you did
- * use GC_ARRAY_HEADER_SIZE,
+ * use GC_ARRAY_HEADER_SIZE because even very small (including
+ * zero-length) arrays require extra space for the forwarding
+ * pointer. If you did use GC_ARRAY_HEADER_SIZE,
* updateBackwardPointersAndSlideForMarkCompact would skip the
* extra space and be completely busted.
*/
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/object-size.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/object-size.c 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/object-size.c 2007-02-25 22:00:41 UTC (rev 5322)
@@ -12,8 +12,10 @@
size_t result;
result = numElements * (bytesNonObjptrs + (numObjptrs * OBJPTR_SIZE));
- /* Empty arrays have OBJPTR_SIZE bytes for the forwarding pointer. */
- if (0 == result)
+ /* Very small (including empty) arrays have OBJPTR_SIZE bytes for
+ * the forwarding pointer.
+ */
+ if (result < OBJPTR_SIZE)
result = OBJPTR_SIZE;
return alignWithExtra (s, result, GC_ARRAY_HEADER_SIZE);
}
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/objptr.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/objptr.c 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/objptr.c 2007-02-25 22:00:41 UTC (rev 5322)
@@ -31,7 +31,7 @@
P_ = ((O_ << S_) + B_);
P = (pointer)P_;
- if (DEBUG_DETAILED)
+ if (DEBUG_OBJPTR)
fprintf (stderr, "objptrToPointer ("FMTOBJPTR") = "FMTPTR"\n", O, (uintptr_t)P);
return P;
@@ -52,7 +52,7 @@
O_ = ((P_ - B_) >> S_);
O = (objptr)O_;
- if (DEBUG_DETAILED)
+ if (DEBUG_OBJPTR)
fprintf (stderr, "pointerToObjptr ("FMTPTR") = "FMTOBJPTR"\n", (uintptr_t)P, O);
return O;
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.c 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.c 2007-02-25 22:00:41 UTC (rev 5322)
@@ -145,7 +145,7 @@
+ reserved,
s->alignment);
if (DEBUG_STACKS)
- fprintf (stderr, "%zu = sizeofStackTotalAligned (%zu)\n", res, reserved);
+ fprintf (stderr, "%zu = sizeofStackWithHeaderAligned (%zu)\n", res, reserved);
return res;
}
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc.h 2007-02-25 20:56:18 UTC (rev 5321)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc.h 2007-02-25 22:00:41 UTC (rev 5322)
@@ -20,7 +20,17 @@
typedef struct GC_state *GC_state;
typedef GC_state GCState_t;
+#ifdef __WORDSIZE
+#if __WORDSIZE == 32
#define GC_MODEL_NATIVE32
+#elif __WORDSIZE == 64
+#define GC_MODEL_NATIVE64
+#else
+#error __WORDSIZE unknown
+#endif
+#else
+#define GC_MODEL_NATIVE32
+#endif
#include "gc/align.h"
#include "gc/model.h"
More information about the MLton-commit
mailing list