[Interpreter] Internalize AST before print-ast is triggered

Print AST needs access to the internalized strings, so make sure AST
is internalized before we print it.

BUG=v8:5203

Change-Id: Ia4995147feb7ec466523a0c4a89620749b23dcab
Reviewed-on: https://chromium-review.googlesource.com/593648
Reviewed-by: Georg Neis <neis@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47006}
This commit is contained in:
Ross McIlroy 2017-07-31 12:25:00 +01:00 committed by Commit Bot
parent 3532528f90
commit 3c31e109ea
3 changed files with 23 additions and 0 deletions

View File

@ -17,6 +17,7 @@
#include "src/debug/debug.h"
#include "src/eh-frame.h"
#include "src/objects-inl.h"
#include "src/parsing/parse-info.h"
#include "src/runtime/runtime.h"
namespace v8 {
@ -96,6 +97,14 @@ void CodeGenerator::MakeCodePrologue(CompilationInfo* info, const char* kind) {
ftype = "user-defined";
}
if (!FLAG_trace_codegen && !print_ast) return;
// Requires internalizing the AST, so make sure we are on the main thread.
DCHECK(ThreadId::Current().Equals(info->isolate()->thread_id()));
AllowDeferredHandleDereference allow_deref;
AllowHeapAllocation allow_gc;
info->parse_info()->ast_value_factory()->Internalize(info->isolate());
if (FLAG_trace_codegen || print_ast) {
std::unique_ptr<char[]> name = info->GetDebugName();
PrintF("[generating %s code for %s function: %s]\n", kind, ftype,

View File

@ -150,6 +150,7 @@ InterpreterCompilationJob::InterpreterCompilationJob(CompilationInfo* info)
background_execute_counter_("CompileBackgroundIgnition") {}
InterpreterCompilationJob::Status InterpreterCompilationJob::PrepareJobImpl() {
// TODO(5203): Move code out of codegen.cc once FCG goes away.
CodeGenerator::MakeCodePrologue(info(), "interpreter");
return SUCCEEDED;
}

View File

@ -0,0 +1,13 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --print-ast
// Ensures that the --print-ast flag doesn't crash.
function foo(a) {
var b = 2;
return function bar() { return a + b; };
}
foo()();