From 9cf5e47bfaebd93f6c1d91e802bc1986e57c33a2 Mon Sep 17 00:00:00 2001 From: Mythri Date: Thu, 5 Apr 2018 13:29:26 +0100 Subject: [PATCH] Fix --cache=code option to work with interactive shell. --cache=code produces and consume cache in different isolates. Earlier we created a new isolate for the run consuming the code cache. This cl changes to create a new isolate when producing the code cache so that RunShell works as expected. Change-Id: I1c73aab2bee429aafdcc52a68ddcf742edfcd652 Reviewed-on: https://chromium-review.googlesource.com/997694 Commit-Queue: Mythri Alle Reviewed-by: Yang Guo Cr-Commit-Position: refs/heads/master@{#52424} --- src/d8.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/d8.cc b/src/d8.cc index 1c2e86d27a..2f6d833b40 100644 --- a/src/d8.cc +++ b/src/d8.cc @@ -2916,7 +2916,6 @@ bool Shell::SetOptions(int argc, char* argv[]) { return true; } - int Shell::RunMain(Isolate* isolate, int argc, char* argv[], bool last_run) { for (int i = 1; i < options.num_isolates; ++i) { options.isolate_sources[i].StartExecuteInThread(); @@ -3398,15 +3397,6 @@ int Shell::Main(int argc, char* argv[]) { ShellOptions::CodeCacheOptions::kNoProduceCache) { printf("============ Run: Produce code cache ============\n"); // First run to produce the cache - result = RunMain(isolate, argc, argv, false); - - // Change the options to consume cache - DCHECK(options.compile_options == v8::ScriptCompiler::kEagerCompile || - options.compile_options == v8::ScriptCompiler::kNoCompileOptions); - options.compile_options = v8::ScriptCompiler::kConsumeCodeCache; - - printf("============ Run: Consume code cache ============\n"); - // Second run to consume the cache in new isolate Isolate::CreateParams create_params; create_params.array_buffer_allocator = Shell::array_buffer_allocator; i::FLAG_hash_seed ^= 1337; // Use a different hash seed. @@ -3422,9 +3412,19 @@ int Shell::Main(int argc, char* argv[]) { PerIsolateData data(isolate2); Isolate::Scope isolate_scope(isolate2); - result = RunMain(isolate2, argc, argv, true); + result = RunMain(isolate2, argc, argv, false); } isolate2->Dispose(); + + // Change the options to consume cache + DCHECK(options.compile_options == v8::ScriptCompiler::kEagerCompile || + options.compile_options == v8::ScriptCompiler::kNoCompileOptions); + options.compile_options = v8::ScriptCompiler::kConsumeCodeCache; + + printf("============ Run: Consume code cache ============\n"); + // Second run to consume the cache in current isolate + result = RunMain(isolate, argc, argv, true); + options.compile_options = v8::ScriptCompiler::kNoCompileOptions; } else { bool last_run = true; result = RunMain(isolate, argc, argv, last_run);