[d8] cleanly force exit in d8 on windows.

Using _exit on windows may cause race conditions in threads.

BUG=chromium:603131

Review-Url: https://codereview.chromium.org/2478473003
Cr-Commit-Position: refs/heads/master@{#40789}
This commit is contained in:
yangguo 2016-11-06 23:24:48 -08:00 committed by Commit bot
parent 76bd4ff492
commit 639f6f1774
3 changed files with 15 additions and 10 deletions

View File

@ -772,4 +772,12 @@ void Shell::AddOSMethods(Isolate* isolate, Local<ObjectTemplate> os_templ) {
FunctionTemplate::New(isolate, RemoveDirectory));
}
void Shell::Exit(int exit_code) {
// Use _exit instead of exit to avoid races between isolate
// threads and static destructors.
fflush(stdout);
fflush(stderr);
_exit(exit_code);
}
} // namespace v8

View File

@ -10,5 +10,12 @@ namespace v8 {
void Shell::AddOSMethods(Isolate* isolate, Local<ObjectTemplate> os_templ) {}
void Shell::Exit(int exit_code) {
// Use TerminateProcess avoid races between isolate threads and
// static destructors.
fflush(stdout);
fflush(stderr);
TerminateProcess(GetCurrentProcess(), exit_code);
}
} // namespace v8

View File

@ -1569,16 +1569,6 @@ Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) {
return handle_scope.Escape(context);
}
void Shell::Exit(int exit_code) {
// Use _exit instead of exit to avoid races between isolate
// threads and static destructors.
fflush(stdout);
fflush(stderr);
_exit(exit_code);
}
struct CounterAndKey {
Counter* counter;
const char* key;