Reviewers: Michael Achenbach,

Description:
Add an --omit-quit flag to d8 for Emscripten's sake.

Please review this at https://codereview.chromium.org/1101683002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+13, -5 lines):
  M src/d8.h
  M src/d8.cc
  M test/mjsunit/mjsunit.status
  M tools/run-tests.py


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.
Index: src/d8.h
diff --git a/src/d8.h b/src/d8.h
index 9b14c4d87dab1f6eb2eccda5165d036045450efc..1f4bee29ed9dec50847fe6ac499d0354fe344d21 100644
--- a/src/d8.h
+++ b/src/d8.h
@@ -196,6 +196,7 @@ class ShellOptions {
         last_run(true),
         send_idle_notification(false),
         invoke_weak_callbacks(false),
+        omit_quit(false),
         stress_opt(false),
         stress_deopt(false),
         interactive_shell(false),
@@ -222,6 +223,7 @@ class ShellOptions {
   bool last_run;
   bool send_idle_notification;
   bool invoke_weak_callbacks;
+  bool omit_quit;
   bool stress_opt;
   bool stress_deopt;
   bool interactive_shell;
Index: test/mjsunit/mjsunit.status
diff --git a/test/mjsunit/mjsunit.status b/test/mjsunit/mjsunit.status
index 997fdbaa486c3dac60e645071db4bb5ce80f7401..265e8dfb88470d9bd70a126374a8fbd212f51181 100644
--- a/test/mjsunit/mjsunit.status
+++ b/test/mjsunit/mjsunit.status
@@ -396,9 +396,6 @@
   'big-array-literal': [SKIP],
   'big-object-literal': [SKIP],
   'regress/regress-crbug-178790': [SKIP],
-
-  # FIXME(svenpanne,titzer): Skipped until leak-free.
-  'asm/sqlite3/*': [SKIP],
 }],  # 'asan == True'

##############################################################################
Index: tools/run-tests.py
diff --git a/tools/run-tests.py b/tools/run-tests.py
index 19f4ed874cd840cfa10afda9248718c8234f2720..b13b92191a0869082a09188753b125d81d005a4d 100755
--- a/tools/run-tests.py
+++ b/tools/run-tests.py
@@ -352,6 +352,7 @@ def ProcessOptions(options):

   if options.asan:
     options.extra_flags.append("--invoke-weak-callbacks")
+    options.extra_flags.append("--omit-quit")

   if options.tsan:
     VARIANTS = ["default"]


--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to