Commit 3bede2f7 authored by clemensh's avatar clemensh Committed by Commit bot

[compiler] Emit source position also for the control input

Before, source position information was only emitted for nodes
contained in a block, which excluded calls that terminate a block.

R=mstarzinger@chromium.org, titzer@chromium.org

Review-Url: https://codereview.chromium.org/2586123003
Cr-Commit-Position: refs/heads/master@{#41847}
parent faf80b4e
...@@ -828,7 +828,11 @@ bool InstructionSelector::IsSourcePositionUsed(Node* node) { ...@@ -828,7 +828,11 @@ bool InstructionSelector::IsSourcePositionUsed(Node* node) {
void InstructionSelector::VisitBlock(BasicBlock* block) { void InstructionSelector::VisitBlock(BasicBlock* block) {
DCHECK(!current_block_); DCHECK(!current_block_);
current_block_ = block; current_block_ = block;
int current_block_end = static_cast<int>(instructions_.size()); auto current_num_instructions = [&] {
DCHECK_GE(kMaxInt, instructions_.size());
return static_cast<int>(instructions_.size());
};
int current_block_end = current_num_instructions();
int effect_level = 0; int effect_level = 0;
for (Node* const node : *block) { for (Node* const node : *block) {
...@@ -847,10 +851,25 @@ void InstructionSelector::VisitBlock(BasicBlock* block) { ...@@ -847,10 +851,25 @@ void InstructionSelector::VisitBlock(BasicBlock* block) {
SetEffectLevel(block->control_input(), effect_level); SetEffectLevel(block->control_input(), effect_level);
} }
auto FinishEmittedInstructions = [&](Node* node, int instruction_start) {
if (instruction_selection_failed()) return false;
if (current_num_instructions() == instruction_start) return true;
std::reverse(instructions_.begin() + instruction_start,
instructions_.end());
if (!node) return true;
SourcePosition source_position = source_positions_->GetSourcePosition(node);
if (source_position.IsKnown() && IsSourcePositionUsed(node)) {
sequence()->SetSourcePosition(instructions_[instruction_start],
source_position);
}
return true;
};
// Generate code for the block control "top down", but schedule the code // Generate code for the block control "top down", but schedule the code
// "bottom up". // "bottom up".
VisitControl(block); VisitControl(block);
std::reverse(instructions_.begin() + current_block_end, instructions_.end()); if (!FinishEmittedInstructions(block->control_input(), current_block_end))
return;
// Visit code in reverse control flow order, because architecture-specific // Visit code in reverse control flow order, because architecture-specific
// matching may cover more than one node at a time. // matching may cover more than one node at a time.
...@@ -859,17 +878,9 @@ void InstructionSelector::VisitBlock(BasicBlock* block) { ...@@ -859,17 +878,9 @@ void InstructionSelector::VisitBlock(BasicBlock* block) {
if (!IsUsed(node) || IsDefined(node)) continue; if (!IsUsed(node) || IsDefined(node)) continue;
// Generate code for this node "top down", but schedule the code "bottom // Generate code for this node "top down", but schedule the code "bottom
// up". // up".
size_t current_node_end = instructions_.size(); int current_node_end = current_num_instructions();
VisitNode(node); VisitNode(node);
if (instruction_selection_failed()) return; if (!FinishEmittedInstructions(node, current_node_end)) return;
std::reverse(instructions_.begin() + current_node_end, instructions_.end());
if (instructions_.size() == current_node_end) continue;
// Mark source position on first instruction emitted.
SourcePosition source_position = source_positions_->GetSourcePosition(node);
if (source_position.IsKnown() && IsSourcePositionUsed(node)) {
sequence()->SetSourcePosition(instructions_[current_node_end],
source_position);
}
} }
// We're done with the block. // We're done with the block.
......
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