# HG changeset patch # User Adam Chlipala # Date 1313421970 14400 # Node ID 659a2f71f5e55886468a14a57e90936b33700e4d # Parent dde3bd82cb3d534c8a04efc26dcb6adf233c71f4 Compiler frees as much memory as possible before passing control to C compiler diff -r dde3bd82cb3d -r 659a2f71f5e5 src/compiler.mlb --- a/src/compiler.mlb Mon Aug 15 10:22:09 2011 -0400 +++ b/src/compiler.mlb Mon Aug 15 11:26:10 2011 -0400 @@ -1,4 +1,5 @@ $(SML_LIB)/basis/basis.mlb +$(SML_LIB)/basis/mlton.mlb urweb.mlb diff -r dde3bd82cb3d -r 659a2f71f5e5 src/compiler.sig --- a/src/compiler.sig Mon Aug 15 10:22:09 2011 -0400 +++ b/src/compiler.sig Mon Aug 15 11:26:10 2011 -0400 @@ -65,6 +65,11 @@ val compileC : {cname : string, oname : string, ename : string, libs : string, profile : bool, debug : bool, link : string list} -> bool + val beforeC : (unit -> unit) ref + (* This function is called before beginning C compilation. + * The current use is for MLton to compact its heap here, to avoid hogging + * space after all the interesting ML code is done. *) + type ('src, 'dst) phase type ('src, 'dst) transform diff -r dde3bd82cb3d -r 659a2f71f5e5 src/compiler.sml --- a/src/compiler.sml Mon Aug 15 10:22:09 2011 -0400 +++ b/src/compiler.sml Mon Aug 15 11:26:10 2011 -0400 @@ -1311,6 +1311,8 @@ val escapeFilename = String.translate (fn #" " => "\\ " | #"\"" => "\\\"" | #"'" => "\\'" | ch => str ch) +val beforeC = ref (fn () => ()) + fun compileC {cname, oname, ename, libs, profile, debug, link = link'} = let val proto = Settings.currentProtocol () @@ -1348,6 +1350,7 @@ (); OS.Process.isSuccess (OS.Process.system s)) in + !beforeC (); system compile andalso system link end diff -r dde3bd82cb3d -r 659a2f71f5e5 src/main.mlton.sml --- a/src/main.mlton.sml Mon Aug 15 10:22:09 2011 -0400 +++ b/src/main.mlton.sml Mon Aug 15 11:26:10 2011 -0400 @@ -32,6 +32,8 @@ val tutorial = ref false val css = ref false +val () = Compiler.beforeC := MLton.GC.pack + fun printVersion () = (print (Config.versionString ^ "\n"); OS.Process.exit OS.Process.success) fun printNumericVersion () = (print (Config.versionNumber ^ "\n");