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