Hi,
 
I have code as :
 
 
v8::Persistent <v8::Context> context = v8::Context::New( NULL, 
orderTemplate );

v8::Handle <v8::Script> script = v8::Script::Compile( source );

v8::Persistent <v8::Script > per_script = 
v8::Persistent<v8::Script>::New(script );

I store the persistent handle-> context and per_script. Later in my 
allication, i retrive the above and try to run the script as follows:

context->Enter();

per_script->Run();

context->Exit();

The above three statements try to retrive the object from the persistent 
handle and then run the script. This has a lot of overhead in terms of 
performance (Time taken to run the function) . How would this problem be 
solved? 

 

 

 

On Thursday, April 12, 2012 6:53:42 AM UTC+5:30, marcel wrote:

> Ah that makes sense. Thank you!
>
> On Tue, Apr 10, 2012 at 2:50 AM, Vyacheslav Egorov 
> <veg...@chromium.org<javascript:>
> > wrote:
>
>> Locally scoped version of persistent is almost equivalent to Local
>> except that Local can never be weak.
>>
>> > Local<Context> lcontext = pcontext;
>>
>> It should be
>>
>> Local<Context> lcontext = Local<Context>::New(pcontext);
>>
>> --
>> Vyacheslav Egorov
>>  
>>
>> On Fri, Apr 6, 2012 at 3:32 AM, Marcel Laverdet 
>> <mar...@laverdet.com<javascript:>> 
>> wrote:
>> > Hey I'm wondering why there isn't a helper class for Persistent<T> which
>> > will Dispose() a handle at the end of scope. It seems like right now v8
>> > encourages lots of unfriendly cleanup code such as:
>> >
>> > void function hello() {
>> >   Persistent<Thing> thing = Persistent<Thing>::New(...);
>> >   ...
>> >   thing.Dispose();
>> > }
>> >
>> > This kind of code is difficult to maintain in many cases, and also
>> > vulnerable to memory leaks when using C++ exceptions. I'd like to see a
>> > version of Persistent<T> that behaves similarly to std::unique_ptr<T>. 
>> v8
>> > already has helper classes like this with Isolate::Scope and 
>> Context::Scope.
>> >
>> > Or perhaps there's a way to get what I want with local handles? I tried
>> > something like this to no avail:
>> >
>> > Persistent<Context> pcontext = Context::New(NULL, global);
>> > Local<Context> lcontext = pcontext;
>> > pcontext.Dispose();
>> >
>> > Any advise would be appreciated!
>> >
>> > --
>> > v8-users mailing list
>> > v8-u...@googlegroups.com <javascript:>
>> > http://groups.google.com/group/v8-users
>>
>> --
>> v8-users mailing list
>> v8-u...@googlegroups.com <javascript:>
>> http://groups.google.com/group/v8-users
>>
>
>

-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

Reply via email to