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 <jxche...@gmail.com> 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.

Reply via email to