size increase
Matthew Fluet
fluet@CS.Cornell.EDU
Fri, 5 Apr 2002 17:46:18 -0500 (EST)
> > Having some spare cycles, I figured out that the 2Mb size increase in
> > the mlton compiler executable occured between March 23 and March 24.
> > Haven't combed through the CVS logs to figure out what changed b/w then.
>
> I think with all the runtime changes (probably dealing with Cygwin's
> issues with handlers), something let threads creep back into to compiler.
> The .ssa for 0324 has Thread_copyCurrent and Thread_switchTo, so that
> pretty effectively inhibits constantProp and localRef.
I think I found the change:
===================================================================
RCS file:
/home/henry/usr/mlton/CVS/ROOT/mlton/lib/mlton/basic/process.sml,v
retrieving revision 1.4
retrieving revision 1.5
diff -r1.4 -r1.5
379,392c379,399
< in callWithIn
< ("size", [f], fn ins =>
< case In.lines ins of
< [_, nums] =>
< (case String.tokens (nums, Char.isSpace) of
< text :: data :: bss :: _ =>
< (case (Int.fromString text,
< Int.fromString data,
< Int.fromString bss) of
< (SOME text, SOME data, SOME bss) =>
< {text = text, data = data, bss = bss}
< | _ => fail ())
< | _ => fail ())
< | _ => fail ())
---
> in
> File.withTemp
> (fn sizeRes =>
> let
> val _ = OS.Process.system (concat ["size ", f, ">", sizeRes])
> in
> File.withIn
> (sizeRes, fn ins =>
> case In.lines ins of
> [_, nums] =>
> (case String.tokens (nums, Char.isSpace) of
> text :: data :: bss :: _ =>
> (case (Int.fromString text,
> Int.fromString data,
> Int.fromString bss) of
> (SOME text, SOME data, SOME bss) =>
> {text = text, data = data, bss = bss}
> | _ => fail ())
> | _ => fail ())
> | _ => fail ())
> end)
The implementation of OS.Process.system is as follows:
fun system cmd =
let
val pid =
MLton.Process.spawn {path = "/bin/sh",
args = ["sh", "-c", cmd]}
val old =
List.map (fn s =>
let
val old = Signal.getHandler s
val _ = Signal.ignore s
in (s, old)
end)
[Signal.int, Signal.quit]
in
DynamicWind.wind (fn () => wait pid,
fn () => List.app Signal.setHandler old)
end
The Signal structure here is MLton.Signal, and Signal.setHandler
references enough signal and thread stuff to pull in threads.
So, what was wrong with the callWithIn? Can we work around it in another
way?