caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* two questions for keeping harmony (with the garbage collector)
@ 2006-05-12 22:59 Hendrik Tews
  2006-05-12 23:47 ` [Caml-list] " Markus Mottl
  0 siblings, 1 reply; 2+ messages in thread
From: Hendrik Tews @ 2006-05-12 22:59 UTC (permalink / raw)
  To: caml-list

Dear all,

could somebody knowledgeable please comment on the following two
points?

1. About rule 1: CAMLparam / CAMLreturn can be ommitted in the
   following cases:

   a) there is no value in the function that is a pointer to a
      block inside the heap.

   b) no allocation will take place between the start and the end
      of the function. (Really? Even in the presence of threads?)


2. I believe rule 2 (register with CAMLlocal) must be extended to
   intermediate values. Consider for instance

      value f(...);
      value g(...);

      ...
      h(f(...), g(...));

   Assuming right to left evaluation, this will break if the
   garbage collector is called inside f, because the value
   returned by g is not registered as a root.

   However, the following is save:

      h2(g(...))

   because h2 will register the value before any allocation can
   happen.

Bye,

Hendrik


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-05-12 23:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-12 22:59 two questions for keeping harmony (with the garbage collector) Hendrik Tews
2006-05-12 23:47 ` [Caml-list] " Markus Mottl

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).