[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:
parent
3532528f90
commit
3c31e109ea
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
13
test/mjsunit/ignition/print-ast.js
Normal file
13
test/mjsunit/ignition/print-ast.js
Normal 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()();
|
Loading…
Reference in New Issue
Block a user