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

Side by Side Diff: src/d8.cc

Issue 1235083004: Revert 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;
220 219
221 #ifndef V8_SHARED 220 #ifndef V8_SHARED
222 bool CounterMap::Match(void* key1, void* key2) { 221 bool CounterMap::Match(void* key1, void* key2) {
223 const char* name1 = reinterpret_cast<const char*>(key1); 222 const char* name1 = reinterpret_cast<const char*>(key1);
224 const char* name2 = reinterpret_cast<const char*>(key2); 223 const char* name2 = reinterpret_cast<const char*>(key2);
225 return strcmp(name1, name2) == 0; 224 return strcmp(name1, name2) == 0;
226 } 225 }
227 #endif // !V8_SHARED 226 #endif // !V8_SHARED
228 227
229 228
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 return; 802 return;
804 } 803 }
805 804
806 Worker* worker = 805 Worker* worker =
807 static_cast<Worker*>(Local<External>::Cast(this_value)->Value()); 806 static_cast<Worker*>(Local<External>::Cast(this_value)->Value());
808 worker->Terminate(); 807 worker->Terminate();
809 } 808 }
810 #endif // !V8_SHARED 809 #endif // !V8_SHARED
811 810
812 811
813 void Shell::QuitOnce(v8::FunctionCallbackInfo<v8::Value>* args) { 812 void Shell::Quit(const v8::FunctionCallbackInfo<v8::Value>& args) {
814 int exit_code = (*args)[0]->Int32Value(); 813 int exit_code = args[0]->Int32Value();
815 #ifndef V8_SHARED 814 #ifndef V8_SHARED
816 CleanupWorkers(); 815 CleanupWorkers();
817 #endif // !V8_SHARED 816 #endif // !V8_SHARED
818 OnExit(args->GetIsolate()); 817 OnExit(args.GetIsolate());
819 exit(exit_code); 818 exit(exit_code);
820 } 819 }
821 820
822 821
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
829 void Shell::Version(const v8::FunctionCallbackInfo<v8::Value>& args) { 822 void Shell::Version(const v8::FunctionCallbackInfo<v8::Value>& args) {
830 args.GetReturnValue().Set( 823 args.GetReturnValue().Set(
831 String::NewFromUtf8(args.GetIsolate(), V8::GetVersion())); 824 String::NewFromUtf8(args.GetIsolate(), V8::GetVersion()));
832 } 825 }
833 826
834 827
835 void Shell::ReportException(Isolate* isolate, v8::TryCatch* try_catch) { 828 void Shell::ReportException(Isolate* isolate, v8::TryCatch* try_catch) {
836 HandleScope handle_scope(isolate); 829 HandleScope handle_scope(isolate);
837 #ifndef V8_SHARED 830 #ifndef V8_SHARED
838 Handle<Context> utility_context; 831 Handle<Context> utility_context;
(...skipping 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after
2453 } 2446 }
2454 2447
2455 } // namespace v8 2448 } // namespace v8
2456 2449
2457 2450
2458 #ifndef GOOGLE3 2451 #ifndef GOOGLE3
2459 int main(int argc, char* argv[]) { 2452 int main(int argc, char* argv[]) {
2460 return v8::Shell::Main(argc, argv); 2453 return v8::Shell::Main(argc, argv);
2461 } 2454 }
2462 #endif 2455 #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