Subj : Re: Custom finalization for functions To : Brendan Eich From : Alain Frisch Date : Mon May 23 2005 10:17 pm Hello, Many thanks for your quick answers. > What is the strong reference into the other GC's heap that is stored in > a Function object (either JSFunction.u.native or a reserved slot, I am > guessing)? Yes, I use the first of the two reserved slots as an index in an array of closures of the other system; the array is itself a root for the other GC. > What keeps the peer function object that you reference in > this way alive, if it's GC-allocated? Don't you have to mark or scan > this reference, or otherwise root or protect it? Yes, they are rooted. > If the other language really uses GC, then you don't want to finalize > the peer function object, unless you can be 100% certain that no strong > refs to it exist apart from the one stored in, or associated with, the > JS function object. You simply want to stop marking that peer function > object. Indeed. Actually, I want to remove the closure from the above mentioned array. > XPConnect uses JS_SetGCCallback to run its own mark/sweep GC on top of > the SpiderMonkey one. You might do the same. You need to keep track of > JS functions that have peers in the other language's runtime. I need to be able to detect when a JSFunction that I created is finalized. I don't see immediatly how to do that with JS_SetGCCallback. Is there a way to retrieve all the objects just before they are finalized? -- Alain .