Ok... so the problem with terminate execution is that it will
completely kill a given isolate (as far as I can tell).  What I think
that means is that all local handles are destroyed and all persistant
handles are disposed.  What I think you want (and also something I
want) is to be able to set a timeout for a single call to script-
>Run().  There is a subtle difference here.  If your application calls
Run many times and is using a single isolate then we still have a
problem thats not solved by V8 (as far as I can tell).

Hopefully a V8 dev will come in here and explain this better and
hopefully offer a solution that I am not seeing.  However, if we get
enough interest in this, I want to suggest a formal feature
enhancement to the V8 team to add a parameter to the Run function that
takes a timeout and maybe also a callback for when the timeout is
exceeded.

Here is the scenario I want to solve:

1.) My application is not threaded and it uses a single isolate.
2.) My application calls Run() many times.  It does some work in C++,
calls Run() to run some JS supplied by a user, does some work in C++,
calls Run() ect...
3.) The JS supplied by the user could have infinite loops or long
running functions where the JS code is not calling into C++ (where I
could prevent them from running).





On May 6, 9:18 am, Chinnu <[email protected]> wrote:
> Hi,
>
> I've been trying to implement a way to limit the execution time of a
> script in V8. I've seen some previous posts that suggest using Locker
> and Preemption (which effectively schedules the thread) and check for
> timeout in the 'OnPreemtionReceived' method. If timeout exceeded,
> invoke TerminateExecution().
>
> However, invoking TerminateExecution() from within
> 'OnPreemptionReceived()' method is causing issues (I'm guessing it's
> leaving the stack in an unbalanced state).
>
> Is it wrong to invoke TerminateExecution() from within V8's code? Is
> there a better way to implement the limiting of execution time?
>
> Thank you,
> Ravi

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

Reply via email to