On 17/10/2016 20:38, Makarius wrote:
On 20/09/16 14:15, David Matthews wrote:
On 19/09/2016 21:15, Makarius wrote:
The handling of return addresses from functions has been simplified. A
consequence of this is that when pieces of code are compiled they are
stored in a separate area of memory rather than in the general heap and
Does that mean that run-time (re)compilation is a now potential memory
I've heard that the JVM has only recently learned to do proper garbage
collection of dynamically loaded modules.
Yes. I can't see a way round it at the moment. It would be difficult
to produce an example where the only reference to the code of a function
was through the return address but it could happen if a thread started
to execute a function contained in a reference and then the reference
Currently, there is a leak because each top-level expression is compiled
down to machine code even though the code is only executed once. My
plan is to avoid that by interpreting the top-level rather than fully
That reminds me a bit of OCaml.
I have always considered it one of the big assets of Poly/ML that fully
native compilation can be performed at run-time, without any difference
to off-line compiled code.
I think there may be some misunderstanding here. I am not suggesting
changing the way functions are compiled or making a distinction between
code compiled interactively or through "use".
The result of compiling each function is a piece of memory containing
the machine code for the function. However a piece of machine code is
also produced for each top-level "program" to perform whatever
side-effects or evaluations are necessary. It is this "extra" code that
I am suggesting could be interpreted. It is only executed once, usually
immediately after it has been compiled. Generally, the cost of
compiling it to fully optimised machine code totally outweighs the
The reason for actually compiling the top-level is simplicity: it can be
treated just like a function. Up till now it has simply been garbage
collected away once it has been executed but that's no longer the case.
With the latest changes every piece of code is kept whether it is
reachable or not.
Although the lack of garbage collection of code would mean that
repeatedly defining the same function would be a memory leak I would be
surprised if it was a serious problem. Is it likely that one would
repeatedly redefine the same function within a particular session?
polyml mailing list