This has been discussed a few times if you search this list.
I think the last solution seemed to be:
Use preemption + terminate execution.
The relevant stuff to look at would be:
v8::Locker::StartPreemption
and
v8::V8::TerminateExecution
Preemption would let you gain control even during infinite loops or
infinite recursion. Terminate execution just stops js execution.
I think what everyone is looking for is something like this for V8,
just baked into the API:
https://developer.mozilla.org/en/SpiderMonkey/JSAPI_Reference/JS_SetOperationCallback
Set a callback function that is automatically called periodically
while JavaScript code runs.
If the callback returns JS_TRUE, the JS engine continues to execute
the script.
If the callback returns JS_FALSE without raising an exception, then
the JS engine immediately stops running the script with an uncatchable
error.
On Aug 12, 12:30 pm, lei lu <
lulei...@gmail.com> wrote:
> hi,
>
> thank u very much:)
> i'll try it right now
>
> thanks
> lei
>
> 2011/8/12 Mikhail Naganov <
mnaga...@chromium.org>:
>
>
>
>
>
>
>
> > Hello,
>
> > You can interrupt VM execution from a parallel thread by executing
> > v8::Debug::DebugBreak or v8::Debug::DebugBreakForCommand. Look into
> > test/cctest/test-debug.cc for examples.
>