Re: Heap file content

John Reppy <[email protected]>
Newsgroups gmane.comp.lang.sml.smlnj
Message-ID <[email protected]>
The technique used is called "tree shaking".  Prior to export, we
run a full GC, which has two benefits: it removes non-reachable
data and it compacts the heap into contiguous addresses.  We then
write out the heap data with special relocation tags for pointers
and references into the runtime system.  Compiled SML code lives
in the heap, so tree shaking removes it too.  The controlling factor
on the heap size is what is live at export time.  We go to a fair
bit of effort to prune stuff that is not needed, but the baseline
is still quite high.  We haven't figured out an easy way to reduce
it.  I think that splitting out module initialization code is
probably the biggest potential gain.  Another possibility would
be using a shared library mechanism.  Both of these ideas are
nontrivial to implement.

To understand the inner workings, I recommend reading Appel's
"A runtime system" paper, which is still a fairly accurate
description of the gross runtime system architecture.  My TR
on the SML/NJ GC is the other good source of information.
The latter is at

	http://smlnj.org/compiler-notes/93-tr-reppy.ps

	- John

On Dec 1, 2004, at 3:03 AM, Morten Rhiger wrote:

> Dear SML/NJ developers and compiler hackers,
>
> I'm trying to get a grasp of SML/NJ's internal workings, especially
> with an eye on generating, loading, linking, and executing code.
>
> An answer to the following question would be a first step towards
> unraveling the mysteries of the infrastructures of the compiler and
> runtime system.
>
> What does a heap file contain?  What is considered 'live' before an
> export?
>
> It puzzles me that the heap file generated by ml-build from the
> (rather trivial) function
>
>     structure Foo = struct
>       fun main(_, _) = 0
>     end
>
> and the .cm file
>
>     Library
>       structure Foo
>     is
>       foo.sml
>
> contains several hundred thousand bytes (379840 bytes on my x86-linux
> machine).
>
> The ml-build script automatically adds the basis library before
> exporting the function.  Does this library become part of the heap?
> Does the compiler (which is typically available before a export, at
> least if issued from the interactive prompt) become part of the heap?
>
> Is it possible to control what does and what does not go into a heap
> file?
>
> -- Morten
> ________________________________
> Morten Rhiger
> Computer Science
> Roskilde University, Denmark
> Homepage: http://www.ruc.dk/~mir
>
>
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real 
> users.
> Discover which products truly live up to the hype. Start reading now.
> http://productguide.itmanagersjournal.com/
> _______________________________________________
> Smlnj-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/smlnj-list
>



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.