Scripts are tied to the context in which they were compiled so you
have to recompile the source code for each new context.  Our
documentation doesn't say that clearly; it should.

If you know you're going to compile the same script many times you can
precompile it using ScriptData::PreCompile and pass in the result
along with the source code when you call Script::Compile; this speeds
up compilation.  Also, we're adding internal compilation caching that
is likely to automatically give more or less the same effect as manual
caching when compiling the same scripts repeatedly.


-- Christian

On Wed, Sep 10, 2008 at 9:20 PM, Bryan White <[EMAIL PROTECTED]> wrote:
>
> I am having a weird problem that makes me suspect I do not understand
> something about Script objects and/or global script variables.
>
> My program runs as a persistent web service.  For each page request,
> it determines which JavaScript source file to use to handle the
> request.  It keeps a cache of the pre-compiled script objects and
> recompiles them when needed if the timestamp of the source file
> changes.
>
> Here is a summary of the steps to handle each request:
>
> 1) On the first request only it creates a persistent ObjectTemplate to
> use as the global template for all contexts.  This global template is
> pre-populated with a bunch of functions implemented in C++.
> 2) Create a context.
> 3) Assign a security token to the context.  All contexts will be
> created with the same security token.  This is to allow cached scripts
> to be used in subsequent contexts.
> 4) Set some request specific variables in the Context.Global() object
> 5) Compile and run the requested script (re-using pre-compiled scripts
> when available).
>
> The problem I am seeing is with the global variables set in 4.  Inside
> the script run in step 5, the values of these variables seem to always
> be the values encountered on the first request.
>
> If I change step 5 to always compile a new Script object then it works
> as expected.
>
> It seems like the Script object is somehow storing its own copies of
> the global variables.
>
> --
> Bryan White
>
> >
>

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

Reply via email to