On Sun, Jun 22, 2014 at 8:36 AM, Danny Dorfman <[email protected]> wrote:
> I already tried that, but  V8::IsExecutionTerminating() returned false.
> I don't know if it's a bug or a feature.

I just remembered something from our code base: termination doesn't go
into effect until you enter the VM again.  In our project, we force
that by executing a no-op script, see below.  HTH.

void ExitFunction(const v8::FunctionCallbackInfo<v8::Value>& info) {
  v8::Isolate* isolate = info.GetIsolate();
  v8::HandleScope handle_scope(isolate);
  // Sets a thread-local flag that is checked by the JS function prologue.
  v8::V8::TerminateExecution(isolate);
  // Which means it's not in effect yet.
  CHECK_EQ(false, v8::V8::IsExecutionTerminating(isolate));
  // Now force the termination exception by entering the VM.
  v8::Local<v8::String> script_source = v8::String::NewFromUtf8(isolate, "0");
  v8::TryCatch try_catch;
  v8::Script::Compile(script_source)->Run();
  CHECK_EQ(true, try_catch.HasCaught());
  CHECK_EQ(true, try_catch.HasTerminated());
  CHECK_EQ(true, v8::V8::IsExecutionTerminating(isolate));
}

-- 
-- 
v8-users mailing list
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to