* [Caml-list] Lamda expressions and a caml interpreter
@ 2004-03-12 16:19 Alex Baretta
2004-03-12 16:35 ` Thomas Fischbacher
2004-03-12 17:08 ` Nuutti Kotivuori
0 siblings, 2 replies; 6+ messages in thread
From: Alex Baretta @ 2004-03-12 16:19 UTC (permalink / raw)
To: Ocaml
Dear Caml breeders, I am facing a big memory leak in a program which
dynamically generates, compiles and links code by taking advantage of
the toplevel library. Unfortunately, this approach to dynamic
programming has two problems: it is incompatible with a native code
compilation of the main program, which otherwise could take advantage of
the speed benefits of ocamlopt, and a memory leak due to the
impossibility of unlinking bytecode modules. The latter problem is the
major one.
I believe one possibile solution would be to compile the generated ocaml
code halfway only, up to a lambda expression, and apply an interpreter
function to it. Such a function could probably also be implemented in a
native code program. Also, lambda expressions do not constitute linked
code but data structures, so they would be garbage collected as soon as
no closure refers to them.
I wonder if such an interpreter exists. If it does not exist, it might
be a worthwhile task to implement one (at least for me). Could anyone
point me to some reference material on this matter?
Thank you very much.
Alex
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Lamda expressions and a caml interpreter
2004-03-12 16:19 [Caml-list] Lamda expressions and a caml interpreter Alex Baretta
@ 2004-03-12 16:35 ` Thomas Fischbacher
2004-03-12 17:27 ` Yamagata Yoriyuki
2004-03-12 17:08 ` Nuutti Kotivuori
1 sibling, 1 reply; 6+ messages in thread
From: Thomas Fischbacher @ 2004-03-12 16:35 UTC (permalink / raw)
To: Alex Baretta; +Cc: Ocaml
On Fri, 12 Mar 2004, Alex Baretta wrote:
> I believe one possibile solution would be to compile the generated ocaml
> code halfway only,
Maybe you want to google for MetaML.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Lamda expressions and a caml interpreter
2004-03-12 16:19 [Caml-list] Lamda expressions and a caml interpreter Alex Baretta
2004-03-12 16:35 ` Thomas Fischbacher
@ 2004-03-12 17:08 ` Nuutti Kotivuori
2004-03-12 18:23 ` Alex Baretta
1 sibling, 1 reply; 6+ messages in thread
From: Nuutti Kotivuori @ 2004-03-12 17:08 UTC (permalink / raw)
To: Alex Baretta; +Cc: Ocaml
Alex Baretta wrote:
> Unfortunately, this approach to dynamic programming has two
> problems: it is incompatible with a native code compilation of the
> main program, which otherwise could take advantage of the speed
> benefits of ocamlopt, and a memory leak due to the impossibility of
> unlinking bytecode modules. The latter problem is the major one.
The former problem is solved by Asmdynlink module. It last worked at
3.02 I believe, but there is hope that someone could resurrect it.
The latter problem I have an unfinished patch to fix. You may browse
the list archives to know more or ask me directly.
Finishing the patch has been greatly delayed due to me being busy on
switching jobs and such - but I have not forgotten it and will get
around to it again.
-- Naked
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Lamda expressions and a caml interpreter
2004-03-12 16:35 ` Thomas Fischbacher
@ 2004-03-12 17:27 ` Yamagata Yoriyuki
0 siblings, 0 replies; 6+ messages in thread
From: Yamagata Yoriyuki @ 2004-03-12 17:27 UTC (permalink / raw)
To: alex; +Cc: caml-list
CDK (http://pauillac.inria.fr/cdk/) contains Asmdynlink, which is an
ocaml bytecode-interpreter solely written by ocaml. *I think* that a
bytecode block is implemented as int array. But the current
implementation seems to register all modules to a global table, so
they would not be reclaimed. Moreover, Asmdynlink looks like not
maintained now. But you could start from here. I also remember that
SCaml has something similar, but I do not know the detail.
From: Thomas Fischbacher <Thomas.Fischbacher@Physik.Uni-Muenchen.DE>
Subject: Re: [Caml-list] Lamda expressions and a caml interpreter
Date: Fri, 12 Mar 2004 17:35:18 +0100 (CET)
> On Fri, 12 Mar 2004, Alex Baretta wrote:
>
> > I believe one possibile solution would be to compile the generated ocaml
> > code halfway only,
>
> Maybe you want to google for MetaML.
There is MetaOcaml, too. (http://www.cs.rice.edu/~taha/MetaOCaml/)
--
Yamagata Yoriyuki
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Lamda expressions and a caml interpreter
2004-03-12 17:08 ` Nuutti Kotivuori
@ 2004-03-12 18:23 ` Alex Baretta
2004-03-12 18:29 ` Nuutti Kotivuori
0 siblings, 1 reply; 6+ messages in thread
From: Alex Baretta @ 2004-03-12 18:23 UTC (permalink / raw)
To: Nuutti Kotivuori; +Cc: Ocaml
Nuutti Kotivuori wrote:
> Alex Baretta wrote:
>
>>Unfortunately, this approach to dynamic programming has two
>>problems: it is incompatible with a native code compilation of the
>>main program, which otherwise could take advantage of the speed
>>benefits of ocamlopt, and a memory leak due to the impossibility of
>>unlinking bytecode modules. The latter problem is the major one.
>
>
> The former problem is solved by Asmdynlink module. It last worked at
> 3.02 I believe, but there is hope that someone could resurrect it.
The former problem is no big deal, since the Caml team made the VM so
efficient that for most practical purposes bytecode is good enough. I
can live with it until Xavier will release Dynlink for native code.
> The latter problem I have an unfinished patch to fix. You may browse
> the list archives to know more or ask me directly.
I am aware of your patch. However, before using it in production code I
would have to see it adopted by Inria in the CVS or official releases.
Otherwise, I would risk breaking compatibility of my code with future
releases of Ocaml.
I look forward to seeing dynamic unlinking of code (bytecode or native)
in OCaml. Hopefully, your patch will help in this direction.
Alex
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Lamda expressions and a caml interpreter
2004-03-12 18:23 ` Alex Baretta
@ 2004-03-12 18:29 ` Nuutti Kotivuori
0 siblings, 0 replies; 6+ messages in thread
From: Nuutti Kotivuori @ 2004-03-12 18:29 UTC (permalink / raw)
To: Alex Baretta; +Cc: Ocaml
Alex Baretta wrote:
> I am aware of your patch. However, before using it in production
> code I would have to see it adopted by Inria in the CVS or official
> releases. Otherwise, I would risk breaking compatibility of my code
> with future releases of Ocaml.
Sane approach.
> I look forward to seeing dynamic unlinking of code (bytecode or
> native) in OCaml. Hopefully, your patch will help in this direction.
Hopefully. My patch tries to get the functionality working as cleanly
as possible with as little modifications to the core are possible. If
it would get incorporated into OCaml mainline, it is probably
worthwhile to get a little muddier to integrate it better with
everything else.
-- Naked
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-03-12 18:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-12 16:19 [Caml-list] Lamda expressions and a caml interpreter Alex Baretta
2004-03-12 16:35 ` Thomas Fischbacher
2004-03-12 17:27 ` Yamagata Yoriyuki
2004-03-12 17:08 ` Nuutti Kotivuori
2004-03-12 18:23 ` Alex Baretta
2004-03-12 18:29 ` Nuutti Kotivuori
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).