On Wed, Apr 8, 2015 at 12:18 PM, Augusto Roman <[email protected]> wrote: > I've dug through the post history, but I'm still having trouble > understanding exactly what capability snapshots provide. > > My question is: > Within a single execution of a single binary, given a single isolate and > context that has executed some JS, can I snapshot the state and later create > a new context from that snapshot?
Yes, with restrictions. Native functions and objects currently cannot be serialized. Large typed arrays exist outside of the JS heap and probably cannot be serialized. No doubt there are more caveats. > For example, imagine a server that should execute one of N JS functions with > per-request parameters. I'd like to snapshot each of the loaded JS > functions and (for each request selecting a JS func and specifying > parameters) create a new, clean context from the appropriate snapshot and > execute the func with the parameters. I don't think that's going to work. The snapshot is a per-isolate property, not per-context. > How do snapshots relate to StartupData? (What is StartupData?) What's the > difference between SetNativesDataBlob and SetSnapshotDataBlob? mksnapshot > appears to enable compiling in a fixed, hard-coded snapshot, which is not > what I want. StartupData is a serialized snapshot, basically a VM core dump. The natives blob contains the built-in objects and functions, like Array, Date, Object, etc. I don't think you would normally touch this. The snapshot blob is your custom start state and you can set it with V8::SetSnapshotDataBlob() or pass it in the Isolate::CreateParams argument to Isolate::New(). You need to build V8 with v8_use_snapshot == 'true' and v8_use_external_startup_data == 1 for that to work, or `make snapshot=external` when using the Makefile. > I understand that V8 is not an AOT JS compiler, but some posts seem to > indicate that snapshots may be appropriate for my use case which is > confusingly inconsistent. It's similar to emacs' dump mechanism if you are familiar with that, only with more restrictions. :-) -- -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
