I was playing around with the shell and the snapshot code to see if I can use the shell to generate and load a snapshot. I use the PartialSerializer and the StartupSerializer to serialize the context and the entire heap. Most of my code is derived from the unit tests ContextSerialization/ContextDeserialization in test-serialize.cc. The snapshot serialization and deserialization works fine if I don't have any external callbacks, but if I do then I get an assertion failure in ExternalReferenceEncoder::Encode: ASSERT(key == NULL || index >= 0); Is it possible to take a snapshot while having external callbacks hooked onto the global object?
I was able to overcome the above assertion failure by exposing the ExternalReferenceTable's Add method to my code and adding an ExternalReference to my callbacks into the table. After this the serialization step goes through without any complains. I am also able to deserialize the snapshot into the shell, but if I call any of the external methods (like print) the code segfaults within v8::internal::HandleApiCallHelper when it tries to execute the callback. This happens even if I explicitly hook the callbacks again after the context is deserialized. Looking at the code it does seem that there are callbacks into the V8 code which are serialized, like random_uint32_function in assembler.h . But how can one do this for user defined external code? Thanks, Rohit -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
