On Tue, May 19, 2009 at 1:15 PM, Ondrej Zara <[email protected]> wrote:
>> > 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.
>
> Understood. The "unpredictability" I experience is surely only a
> manifestation of the behavior described above.
>
>>
>> > 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.
>
> Okay, so the only way to speed up loading is to pre-compile. Do you also
> please have any suggestions regarding my second idea, that is "freeze /
> serialize the context so it can be safely reused" ?

fork() ?

>
>
> Thanks for answer,
> Ondrej Zara
>
>
>
>
>>
>> -- Christian
>>
>>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to