From 9bb8b58549d543bacc230b4094ff5c196fa61ad3 Mon Sep 17 00:00:00 2001 From: svenpanne Date: Wed, 22 Apr 2015 05:24:29 -0700 Subject: [PATCH] Add an --omit-quit flag to d8 for Emscripten's sake. Review URL: https://codereview.chromium.org/1101683002 Cr-Commit-Position: refs/heads/master@{#28004} --- src/d8.cc | 12 ++++++++++-- src/d8.h | 2 ++ test/mjsunit/mjsunit.status | 3 --- tools/run-tests.py | 1 + 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/d8.cc b/src/d8.cc index c3b0bfc..0d1b936 100644 --- a/src/d8.cc +++ b/src/d8.cc @@ -924,8 +924,13 @@ Handle 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. diff --git a/src/d8.h b/src/d8.h index 9b14c4d..1f4bee2 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; diff --git a/test/mjsunit/mjsunit.status b/test/mjsunit/mjsunit.status index 997fdba..265e8df 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' ############################################################################## diff --git a/tools/run-tests.py b/tools/run-tests.py index 19f4ed8..b13b921 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"] -- 2.7.4