> thanks for a prompt response. When I compile a script via > v8::Script::Compile, it is "bound" to the current context in a certain way > (for instance, references to objects in current context), so it is not > possible to execute a compiled script in other context.
Correct. If you've compiled a script in context X it doesn't matter if you're currently in context Y or Z, the script will always be executed in context X. Note that the behavior should be completely predictable so if it's not I'd encourage you to report it as a bug. > Do I understand > correctly that snapshot compilation works differently - in a sense that a > compiled snapshot can be then executed in arbitrary context with same > results? The snapshot only covers our built-in native .js files. Instead of loading them every time you create a new context the snapshot is loaded, which is much faster. Except for better performance the behavior of using and not using snapshots should be exactly the same. > Also, when exactly are compiled snapshots executed? For example, I do (now) > this: > > 1) create empty context, > 2) set global property "Config" as an empty object, > 3) execute config.js (contains: "Config.someProperty = someValue"). > > In this scenario, I want config.js to be pre-compiled snapshot, but it shall > not be executed prior to global.Config creation (#2). How can I achieve > this? That's not possible. Snapshots only work for our native js files. What you can do is use preparsing to speed up loading of your script (see ScriptData::PreCompile) but there is no way to include user code in snapshots. -- Christian --~--~---------~--~----~------------~-------~--~----~ v8-users mailing list [email protected] http://groups.google.com/group/v8-users -~----------~----~----~----~------~----~------~--~---
