Hi Christoph,
While we wait for an expert's answer, I allow myself to add some observations
from my own investigations of the runtime system (hopefully correct):
* OCaml uses very different calling convention than the standard C convention.
When calling C code (for example, when the GC is triggered) we need to pass the content of
the registers as used by OCaml (this includes things like the allocation pointer, exception
pointer, etc) to the C code so that they can be adjusted as necessary. Since these
registers need to be handled according the C calling convention, we need to save their values somewhere.
The simplest way to do this is to pass them to the C code using global variables and restore those
globals into the registers when returning from the C code back into OCaml code.
As far as I know the global variables are only updated when passing the OCaml-C boundary.
* Having said that one could bundle all the globals in one record so as to allow multiple
OCaml processes (with separate heaps) running on the same process. I think I even remember
seeing some experiments in this direction ...
(Corrections welcome!)
Thanks!
Cheers,
Nicolas