Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Unified Diff: src/d8.cc

Issue 1230403003: d8 workers: make sure Shell::Quit is only called once (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: move once_type_ out of V8_SHARED section Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/d8.h ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()));
« no previous file with comments | « src/d8.h ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698