Commit 21dfcf5d authored by danno's avatar danno Committed by Commit bot

[turbofan]: Better source position information

* Ensure that a source position is already specified in generated code before
  prologue is assembled.
* Ensure source position is set for instructions before their gaps are assembled
  (this fixes missing source position information at the beginning of deferred
  code).
* Don't output source position information for gap moves that are
  redundant. This led to extraneous, confusing source positions for constants
  that did not end up producing any code.
* Output source position information that is usable in turbolizer when --trace-turbo
  is specified.

LOG=N

Review-Url: https://codereview.chromium.org/2599433002
Cr-Commit-Position: refs/heads/master@{#41914}
parent 89259657
......@@ -92,6 +92,11 @@ Handle<Code> CodeGenerator::GenerateCode() {
// the frame (that is done in AssemblePrologue).
FrameScope frame_scope(masm(), StackFrame::MANUAL);
if (info->is_source_positions_enabled()) {
SourcePosition source_position(info->shared_info()->start_position());
AssembleSourcePosition(source_position);
}
// Place function entry hook if requested to do so.
if (linkage()->GetIncomingDescriptor()->IsJSFunctionCall()) {
ProfileEntryHookStub::MaybeCallEntryHook(masm());
......@@ -405,6 +410,10 @@ void CodeGenerator::GetPushCompatibleMoves(Instruction* instr,
CodeGenerator::CodeGenResult CodeGenerator::AssembleInstruction(
Instruction* instr, const InstructionBlock* block) {
int first_unused_stack_slot;
FlagsMode mode = FlagsModeField::decode(instr->opcode());
if (mode != kFlags_trap) {
AssembleSourcePosition(instr);
}
bool adjust_stack =
GetSlotAboveSPBeforeTailCall(instr, &first_unused_stack_slot);
if (adjust_stack) AssembleTailCallBeforeGap(instr, first_unused_stack_slot);
......@@ -417,10 +426,6 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleInstruction(
if (instr->IsJump() && block->must_deconstruct_frame()) {
AssembleDeconstructFrame();
}
FlagsMode mode = FlagsModeField::decode(instr->opcode());
if (mode != kFlags_trap) {
AssembleSourcePosition(instr);
}
// Assemble architecture-specific code for the instruction.
CodeGenResult result = AssembleArchInstruction(instr);
if (result != kSuccess) return result;
......@@ -487,10 +492,14 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleInstruction(
return kSuccess;
}
void CodeGenerator::AssembleSourcePosition(Instruction* instr) {
SourcePosition source_position = SourcePosition::Unknown();
if (instr->IsNop() && instr->AreMovesRedundant()) return;
if (!code()->GetSourcePosition(instr, &source_position)) return;
AssembleSourcePosition(source_position);
}
void CodeGenerator::AssembleSourcePosition(SourcePosition source_position) {
if (source_position == current_source_position_) return;
current_source_position_ = source_position;
if (!source_position.IsKnown()) return;
......@@ -500,7 +509,13 @@ void CodeGenerator::AssembleSourcePosition(Instruction* instr) {
CompilationInfo* info = this->info();
if (!info->parse_info()) return;
std::ostringstream buffer;
buffer << "-- " << source_position.InliningStack(info) << " --";
buffer << "-- ";
if (FLAG_trace_turbo) {
buffer << source_position;
} else {
buffer << source_position.InliningStack(info);
}
buffer << " --";
masm()->RecordComment(StrDup(buffer.str().c_str()));
}
}
......
......@@ -72,6 +72,8 @@ class CodeGenerator final : public GapResolver::Assembler {
void AssembleSourcePosition(Instruction* instr);
void AssembleSourcePosition(SourcePosition source_position);
// Record a safepoint with the given pointer map.
void RecordSafepoint(ReferenceMap* references, Safepoint::Kind kind,
int arguments, Safepoint::DeoptMode deopt_mode);
......
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