Thanks Jakob. As I'm an embedder, and when I need to terminate execution, it's when I need to throw a retry-able exception to my system and start from scratch. So I'm following the practice Ben suggested a while ago, which seems to work with some basic testing:
v8::V8::TerminateExecution(isolate); v8::Local<v8::String> script_source = v8::String::NewFromUtf8(isolate, "0"); v8::TryCatch try_catch; v8::Script::Compile(script_source)->Run(); assert(v8::V8::IsExecutionTerminating(isolate)); Is this the recommended way to force termination? Any gochas I should watch out for? Thanks, Jane On Tuesday, September 30, 2014 1:18:46 AM UTC-7, Jakob Kummerow wrote: > > Generated code doesn't check for termination requests after every machine > instruction, because that would be way too slow. It does check in loops > (not on every iteration, though, only now and then), and some other > situations like function calls. > > Note that TerminateExecution is intended for permanent *termination*, not > suspension. Primary use case: allow a user to kill hanging tabs in Chrome. > This also motivates why it's perfectly fine if termination doesn't happen > instantly, as long as it happens within a time that a human perceives as > "quickly" (a couple of milliseconds). > > > On Tue, Sep 30, 2014 at 7:29 AM, Jane Chen <jxch...@gmail.com > <javascript:>> wrote: > >> I'm following the example in TestTerminateOnlyV8ThreadFromThreadItself() >> in test-thread-termination.cc, and it works for me: >> >> function f() { >> var term = true; >> try { >> while (true) { >> if (term) terminate(); >> term = false; >> } >> print("not terminated."); >> } catch (err) { >> print("not terminated."); >> err.toString(); >> } >> } >> f() >> >> But if I modify the test and remove the while loop, it doesn't work and >> print will be called and fail: >> >> function f() { >> var term = true; >> try { >> if (term) terminate(); >> term = false; >> print("not terminated."); >> } catch (err) { >> print("not terminated."); >> err.toString(); >> } >> } >> f() >> >> What's the significance of the while loop here? >> >> Thanks. >> >> -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.