You might be able to use the Script::New instead of Script::Compile, as Script::New creates a context independent Script object. Take a look at the comments in include/v8.h for the difference between these two ways of compiling a script.
Regards, Søren On Sun, Dec 27, 2009 at 16:20, Philippe Roy <[email protected]>wrote: > Would you be able to provide sample code? > > On Sun, Dec 27, 2009 at 8:27 AM, Bryan White <[email protected]> wrote: > > On Sat, Dec 26, 2009 at 5:15 PM, Philippe Roy <[email protected]> > wrote: > >> I am currently using v8 as my javascript engine in order to calculate > >> conceptual representations of natural language input. It works > >> extremely well, but I feel that it could have better performance. > >> > >> In my snippet of code lower, I first compile the javascript source, > >> and then execute it. I have tried to keep the script variable into a > >> cache so that I wouldn't need to compile it on the second pass, but it > >> appears the script variable only lives within the context under which > >> it was compiled. This is a sad limitation that I would like to get rid > >> of. Is there a way to do that? > > > > I keep a cache of contexts around. The downside is data can be left > > in the global scope from one execution to the next. I try to prevent > > this by: > > > > 1) creating before each execution a 'Request' object and placing it > > in the Global object. > > 2) Installing an interceptor in the global object to prevent > > assignments during script execution. > > > > The idea is to have the scripts use the Request object as a place to > > install globals. There are probably a lot of ways to get information > > bleed that the interceptor will not catch. I trust my script > > programmers to not be intentionally doing bad things and the > > interceptor catches most of the accidents. Third party javascript > > libraries may not play be the rules however. > > > > Note, the interceptor is not active when the script is 'Run', only > > later when I call a script provided function. > > > > -- > > Bryan White > > > > -- > > v8-users mailing list > > [email protected] > > http://groups.google.com/group/v8-users > > > > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users > -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
