[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v3-RESEND 12/28] libxl: ocaml: make Val_defbool GC-proof



Hi,

> On Oct 31, 2013, at 7:10 PM, "Ian Campbell" <Ian.Campbell@xxxxxxxxxx> wrote:
> 
>> On Thu, 2013-10-31 at 18:57 +0000, Ian Jackson wrote:
>> Ian Jackson writes ("Re: [PATCH v3-RESEND 12/28] libxl: ocaml: make 
>> Val_defbool GC-proof"):
>>> What difference do you think it makes whether things are "assigned to
>>> variables" or not ?
>>> 
>>> Bonus if your explanation refers to sequence points.
>> 
>> Perhaps these special CAMLlocal macros make the things volatile or
>> something, I guess.
> 
> They seem to end up being structs.

IIRC the CAML{param,local} macros put the values into structs which can be 
reached from a GC root (the previous interface used macros called something 
like "Begin_roots" "End_roots"). Any value you've allocated and you want to 
keep had better be reachable when the GC comes calling -- so I tend to 
obsessively use the macros everywhere. You can optimise them away but if you 
call a function which ends up allocating, one time in a hundred the minor heap 
will be full, it'll do a sweep and deallocate anything unreachable. Having been 
bitten too many times, I'd rather sacrifice a little performance for safety 
there :)

It is quite hard to write good ocaml c stubs, because you're caught between the 
two worlds. To appease the GC you have to write some fairly unidiomatic C. FYI 
there's an exciting new way of building C stubs through a library called 
"ctypes" being written by Jeremy Yallop from OCamlLabs-- we should check it out 
for version 2 of these bindings...

Cheers,
Dave

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.