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

Unified Diff: src/d8.cc

Issue 1101683002: Add an --omit-quit flag to d8 for Emscripten's sake. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Revert SKIP Created 5 years, 8 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 c3b0bfcb430868547aa9593ab63036fed5c0d95c..0d1b93699bc9ef3342df90d84616f1dec7746124 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -924,8 +924,13 @@ Handle<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
FunctionTemplate::New(isolate, ReadLine));
global_template->Set(String::NewFromUtf8(isolate, "load"),
FunctionTemplate::New(isolate, Load));
- global_template->Set(String::NewFromUtf8(isolate, "quit"),
- FunctionTemplate::New(isolate, Quit));
+ // Some Emscripten-generated code tries to call 'quit', which in turn would
+ // call C's exit(). This would lead to memory leaks, because there is no way
+ // we can terminate cleanly then, so we need a way to hide 'quit'.
+ if (!options.omit_quit) {
+ global_template->Set(String::NewFromUtf8(isolate, "quit"),
+ FunctionTemplate::New(isolate, Quit));
+ }
global_template->Set(String::NewFromUtf8(isolate, "version"),
FunctionTemplate::New(isolate, Version));
@@ -1374,6 +1379,9 @@ bool Shell::SetOptions(int argc, char* argv[]) {
// TODO(jochen) See issue 3351
options.send_idle_notification = true;
argv[i] = NULL;
+ } else if (strcmp(argv[i], "--omit-quit") == 0) {
+ options.omit_quit = true;
+ argv[i] = NULL;
} else if (strcmp(argv[i], "-f") == 0) {
// Ignore any -f flags for compatibility with other stand-alone
// JavaScript engines.
« 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