Hi Behram,

Basically speaking ObjectVisitor just gets all pointer slots in the object.
It gets no information about the meaning of those slots (certain
slots in code objects and external strings require special handling so
visitor gets information about them).

IterateBody is not recursive by default. It iterates slots of a single objects.
If caller wants to iterate objects recursively (e.g. to build a
transitive closure)
then it has to handle that manually.

So the only way to implement serialization on top of ObjectVisitor is
to serialize heap as whole as a sequence of bytes (+ some information
to link things
back together during deserialization) --- just like serialize.h does that.

Anything more 'clever' requires a separate visitor that actually
understands meaning of different fields of objects.

Hope this answers your question.

--
Vyacheslav Egorov


On Wed, May 25, 2011 at 8:59 AM, bmistree <bmist...@stanford.edu> wrote:
> I'm building an application on top of v8 that requires some objects to
> be checkpointed to some state and then later restored from that
> state.
>
> I am having trouble checkpointing closures.  Looking through the code,
> I noticed the function JSFunctionIterateBody in the JSFunction class
> (in objects.h).  What I was thinking of doing was writing my own
> ObjectVisitor that would be passed into each JSFunction's
> JSFunctionIterateBody method.  This ObjectVistor would then log all
> objects that it encountered.  I have a couple of questions though:
>
>  1)  Would an objectVisitor passed into the JSFunctionIterateBody
> function run through all the contexts that are associated with that
> JSFunction?
>  2)  When writing my objectVisitor, am I wrong in thinking that just
> writing the VisitPointers function would give me adequate information
> to reconstruct a JSFunction with its closure?  (Right now, I don't see
> how I'd be able to tell which object pointers would be associated with
> which contexts.)
>  3)  Is there another way that I should be doing things?  I've looked
> through serialize.h, and think that it would be a bad idea to try to
> extend that for my application, and would like to do as much of the
> checkpointing and restoration from javascript as possible for
> flexibility and speedy development.
>
> Please let me know.  Thanks.
>  -Behram
>
> --
> v8-users mailing list
> v8-users@googlegroups.com
> http://groups.google.com/group/v8-users
>

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Reply via email to