Commit 489d751e authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[compiler] Switch code printing to not use literal.

This switches CodeGenerator::PrintCode to be based on the allocated
shared function info instead of the function literal. This is possible
now that even live edit allocates a shared function info for scripts.

R=ishell@chromium.org
BUG=chromium:604375
LOG=n

Review URL: https://codereview.chromium.org/1901753002

Cr-Commit-Position: refs/heads/master@{#35605}
parent 19c1a10b
......@@ -161,20 +161,16 @@ void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) {
bool print_source =
info->parse_info() && (code->kind() == Code::OPTIMIZED_FUNCTION ||
code->kind() == Code::FUNCTION);
// TODO(mstarzinger): Switch this over to use SharedFunctionInfo instead of
// the FunctionLiteral, once we have a SharedFunctionInfo for live edit.
print_source = print_source && info->literal() != nullptr;
if (print_source) {
FunctionLiteral* literal = info->literal();
Handle<SharedFunctionInfo> shared = info->shared_info();
Handle<Script> script = info->script();
if (!script->IsUndefined() && !script->source()->IsUndefined()) {
os << "--- Raw source ---\n";
StringCharacterStream stream(String::cast(script->source()),
literal->start_position());
shared->start_position());
// fun->end_position() points to the last character in the stream. We
// need to compensate by adding one to calculate the length.
int source_len =
literal->end_position() - literal->start_position() + 1;
int source_len = shared->end_position() - shared->start_position() + 1;
for (int i = 0; i < source_len; i++) {
if (stream.HasMore()) {
os << AsReversiblyEscapedUC16(stream.GetNext());
......@@ -194,8 +190,8 @@ void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) {
os << "--- Code ---\n";
}
if (print_source) {
FunctionLiteral* literal = info->literal();
os << "source_position = " << literal->start_position() << "\n";
Handle<SharedFunctionInfo> shared = info->shared_info();
os << "source_position = " << shared->start_position() << "\n";
}
code->Disassemble(debug_name.get(), os);
os << "--- End code ---\n";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment