Version française
Home     About     Download     Resources     Contact us    
Browse thread
two questions for keeping harmony (with the garbage collector)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Hendrik Tews <tews@t...>
Subject: two questions for keeping harmony (with the garbage collector)
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