Lucas Dixon wrote:
is the code for the substructure n1 literally getting copied each time?
Even with this I find it hard to imagine how I'd generate 120 MB of
machine code from 7500 lines of ML...
I noticed some forget functions in the PolyML compiler; is there some
clever way to say all I care about is stuff reachable from calling some
specified function?
There are several things you can do. To be honest I don't know why
there is such an enormous blow-up.
If you are producing a single function as the result of your compilation
then if you are exporting this all you need, as Phil says, is to run
PolyML.shareCommonData on the function before you export it.
If you are building the function but still want to retain it within
Poly/ML it's a little more complicated.
If you're using saveState to save the state it is always a good idea to run
PolyML.shareCommonData PolyML.rootFunction;
before PolyML.SaveState.saveState
What this does is go over the whole reachable memory and merge immutable
values that are identical. In particular if the compiler has had to
copy some signatures it will be able to merge those parts that can be
merged and if they are in an existing parent state it will set the
pointers to use the already saved data.
You can use PolyML.objSize to see the number of words used by everything
reachable from a particular value. This could be useful to see if the
blow-up is due to code in your function or information Poly/ML is
keeping about structures and signatures. For example,
> val x = ([1,2,3], [1,2,3]);
val x = ([1, 2, 3], [1, 2, 3]) : int list * int list
> PolyML.objSize x;
val it = 21 : int
> PolyML.shareCommonData x;
val it = () : unit
> PolyML.objSize x;
val it = 12 : int
PolyML.objSize PolyML.rootFunction; can be used to see the total size of
everything reachable from the root.
You can use PolyML.Compiler.structureNames() and similar to get a list
of the structures and remove those you don't want with
PolyML.Compiler.forgetStructure. You need to do this before saving state.
Let us know if this works.
David.
_______________________________________________
polyml mailing list
[email protected]
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml