Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Unified Diff: src/codegen.cc

Issue 974213002: Extract ParseInfo from CompilationInfo. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/background-parsing-task.cc ('k') | src/compiler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codegen.cc
diff --git a/src/codegen.cc b/src/codegen.cc
index 178ba4a69df8d1e423a6d9611518c11307135678..ba32aceface87f8b71e180134da40eade6ffdf5a 100644
--- a/src/codegen.cc
+++ b/src/codegen.cc
@@ -12,6 +12,7 @@
#include "src/compiler.h"
#include "src/cpu-profiler.h"
#include "src/debug.h"
+#include "src/parser.h"
#include "src/prettyprinter.h"
#include "src/rewriter.h"
#include "src/runtime/runtime.h"
@@ -134,13 +135,13 @@ void CodeGenerator::MakeCodePrologue(CompilationInfo* info, const char* kind) {
}
#ifdef DEBUG
- if (!info->IsStub() && print_source) {
+ if (info->parse_info() && print_source) {
PrintF("--- Source from AST ---\n%s\n",
PrettyPrinter(info->isolate(), info->zone())
.PrintProgram(info->function()));
}
- if (!info->IsStub() && print_ast) {
+ if (info->parse_info() && print_ast) {
PrintF("--- AST ---\n%s\n", AstPrinter(info->isolate(), info->zone())
.PrintProgram(info->function()));
}
@@ -181,14 +182,25 @@ void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) {
(info->IsStub() && FLAG_print_code_stubs) ||
(info->IsOptimizing() && FLAG_print_opt_code));
if (print_code) {
- // Print the source code if available.
- FunctionLiteral* function = info->function();
- bool print_source = code->kind() == Code::OPTIMIZED_FUNCTION ||
- code->kind() == Code::FUNCTION;
+ const char* debug_name;
+ if (info->IsStub()) {
+ CodeStub::Major major_key = info->code_stub()->MajorKey();
+ debug_name = CodeStub::MajorName(major_key, false);
+ } else {
+ debug_name =
+ info->parse_info()->function()->debug_name()->ToCString().get();
+ }
CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer());
OFStream os(tracing_scope.file());
+
+ // Print the source code if available.
+ FunctionLiteral* function = nullptr;
+ bool print_source =
+ info->parse_info() && (code->kind() == Code::OPTIMIZED_FUNCTION ||
+ code->kind() == Code::FUNCTION);
if (print_source) {
+ function = info->function();
Handle<Script> script = info->script();
if (!script->IsUndefined() && !script->source()->IsUndefined()) {
os << "--- Raw source ---\n";
@@ -207,10 +219,9 @@ void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) {
}
}
if (info->IsOptimizing()) {
- if (FLAG_print_unopt_code) {
+ if (FLAG_print_unopt_code && info->parse_info()) {
os << "--- Unoptimized code ---\n";
- info->closure()->shared()->code()->Disassemble(
- function->debug_name()->ToCString().get(), os);
+ info->closure()->shared()->code()->Disassemble(debug_name, os);
}
os << "--- Optimized code ---\n"
<< "optimization_id = " << info->optimization_id() << "\n";
@@ -220,12 +231,7 @@ void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) {
if (print_source) {
os << "source_position = " << function->start_position() << "\n";
}
- if (info->IsStub()) {
- CodeStub::Major major_key = info->code_stub()->MajorKey();
- code->Disassemble(CodeStub::MajorName(major_key, false), os);
- } else {
- code->Disassemble(function->debug_name()->ToCString().get(), os);
- }
+ code->Disassemble(debug_name, os);
os << "--- End code ---\n";
}
#endif // ENABLE_DISASSEMBLER
« no previous file with comments | « src/background-parsing-task.cc ('k') | src/compiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698