Index: src/d8.cc |
diff --git a/src/d8.cc b/src/d8.cc |
index 2b1832a28e6c7e5ccba73900cebfc0346d8851f5..d882e45b24fa198748d4071aa6845cdb40c9ea58 100644 |
--- a/src/d8.cc |
+++ b/src/d8.cc |
@@ -216,6 +216,7 @@ Persistent<Context> Shell::evaluation_context_; |
ArrayBuffer::Allocator* Shell::array_buffer_allocator; |
ShellOptions Shell::options; |
const char* Shell::kPrompt = "d8> "; |
+base::OnceType Shell::quit_once_ = V8_ONCE_INIT; |
#ifndef V8_SHARED |
bool CounterMap::Match(void* key1, void* key2) { |
@@ -809,16 +810,22 @@ void Shell::WorkerTerminate(const v8::FunctionCallbackInfo<v8::Value>& args) { |
#endif // !V8_SHARED |
-void Shell::Quit(const v8::FunctionCallbackInfo<v8::Value>& args) { |
- int exit_code = args[0]->Int32Value(); |
+void Shell::QuitOnce(v8::FunctionCallbackInfo<v8::Value>* args) { |
+ int exit_code = (*args)[0]->Int32Value(); |
#ifndef V8_SHARED |
CleanupWorkers(); |
#endif // !V8_SHARED |
- OnExit(args.GetIsolate()); |
+ OnExit(args->GetIsolate()); |
exit(exit_code); |
} |
+void Shell::Quit(const v8::FunctionCallbackInfo<v8::Value>& args) { |
+ base::CallOnce(&quit_once_, &QuitOnce, |
+ const_cast<v8::FunctionCallbackInfo<v8::Value>*>(&args)); |
+} |
+ |
+ |
void Shell::Version(const v8::FunctionCallbackInfo<v8::Value>& args) { |
args.GetReturnValue().Set( |
String::NewFromUtf8(args.GetIsolate(), V8::GetVersion())); |