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

Side by Side Diff: src/d8.cc

Issue 1224203004: Reland of d8 workers: make sure Shell::Quit is only called once (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « src/d8.h ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 // Defined when linking against shared lib on Windows. 6 // Defined when linking against shared lib on Windows.
7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED)
8 #define V8_SHARED 8 #define V8_SHARED
9 #endif 9 #endif
10 10
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 base::Mutex Shell::workers_mutex_; 209 base::Mutex Shell::workers_mutex_;
210 bool Shell::allow_new_workers_ = true; 210 bool Shell::allow_new_workers_ = true;
211 i::List<Worker*> Shell::workers_; 211 i::List<Worker*> Shell::workers_;
212 i::List<SharedArrayBuffer::Contents> Shell::externalized_shared_contents_; 212 i::List<SharedArrayBuffer::Contents> Shell::externalized_shared_contents_;
213 #endif // !V8_SHARED 213 #endif // !V8_SHARED
214 214
215 Persistent<Context> Shell::evaluation_context_; 215 Persistent<Context> Shell::evaluation_context_;
216 ArrayBuffer::Allocator* Shell::array_buffer_allocator; 216 ArrayBuffer::Allocator* Shell::array_buffer_allocator;
217 ShellOptions Shell::options; 217 ShellOptions Shell::options;
218 const char* Shell::kPrompt = "d8> "; 218 const char* Shell::kPrompt = "d8> ";
219 base::OnceType Shell::quit_once_ = V8_ONCE_INIT;
219 220
220 #ifndef V8_SHARED 221 #ifndef V8_SHARED
221 bool CounterMap::Match(void* key1, void* key2) { 222 bool CounterMap::Match(void* key1, void* key2) {
222 const char* name1 = reinterpret_cast<const char*>(key1); 223 const char* name1 = reinterpret_cast<const char*>(key1);
223 const char* name2 = reinterpret_cast<const char*>(key2); 224 const char* name2 = reinterpret_cast<const char*>(key2);
224 return strcmp(name1, name2) == 0; 225 return strcmp(name1, name2) == 0;
225 } 226 }
226 #endif // !V8_SHARED 227 #endif // !V8_SHARED
227 228
228 229
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 return; 803 return;
803 } 804 }
804 805
805 Worker* worker = 806 Worker* worker =
806 static_cast<Worker*>(Local<External>::Cast(this_value)->Value()); 807 static_cast<Worker*>(Local<External>::Cast(this_value)->Value());
807 worker->Terminate(); 808 worker->Terminate();
808 } 809 }
809 #endif // !V8_SHARED 810 #endif // !V8_SHARED
810 811
811 812
812 void Shell::Quit(const v8::FunctionCallbackInfo<v8::Value>& args) { 813 void Shell::QuitOnce(v8::FunctionCallbackInfo<v8::Value>* args) {
813 int exit_code = args[0]->Int32Value(); 814 int exit_code = (*args)[0]->Int32Value();
814 #ifndef V8_SHARED 815 #ifndef V8_SHARED
815 CleanupWorkers(); 816 CleanupWorkers();
816 #endif // !V8_SHARED 817 #endif // !V8_SHARED
817 OnExit(args.GetIsolate()); 818 OnExit(args->GetIsolate());
818 exit(exit_code); 819 exit(exit_code);
819 } 820 }
820 821
821 822
823 void Shell::Quit(const v8::FunctionCallbackInfo<v8::Value>& args) {
824 base::CallOnce(&quit_once_, &QuitOnce,
825 const_cast<v8::FunctionCallbackInfo<v8::Value>*>(&args));
826 }
827
828
822 void Shell::Version(const v8::FunctionCallbackInfo<v8::Value>& args) { 829 void Shell::Version(const v8::FunctionCallbackInfo<v8::Value>& args) {
823 args.GetReturnValue().Set( 830 args.GetReturnValue().Set(
824 String::NewFromUtf8(args.GetIsolate(), V8::GetVersion())); 831 String::NewFromUtf8(args.GetIsolate(), V8::GetVersion()));
825 } 832 }
826 833
827 834
828 void Shell::ReportException(Isolate* isolate, v8::TryCatch* try_catch) { 835 void Shell::ReportException(Isolate* isolate, v8::TryCatch* try_catch) {
829 HandleScope handle_scope(isolate); 836 HandleScope handle_scope(isolate);
830 #ifndef V8_SHARED 837 #ifndef V8_SHARED
831 Handle<Context> utility_context; 838 Handle<Context> utility_context;
(...skipping 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after
2446 } 2453 }
2447 2454
2448 } // namespace v8 2455 } // namespace v8
2449 2456
2450 2457
2451 #ifndef GOOGLE3 2458 #ifndef GOOGLE3
2452 int main(int argc, char* argv[]) { 2459 int main(int argc, char* argv[]) {
2453 return v8::Shell::Main(argc, argv); 2460 return v8::Shell::Main(argc, argv);
2454 } 2461 }
2455 #endif 2462 #endif
OLDNEW
« 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