Commit 04239cfe authored by baptiste.afsa's avatar baptiste.afsa Committed by Commit bot

[turbofan] Properly handle deoptimizations in the instruction scheduler.

R=jarin@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#35709}
parent fa43f4c9
...@@ -82,7 +82,8 @@ InstructionScheduler::InstructionScheduler(Zone* zone, ...@@ -82,7 +82,8 @@ InstructionScheduler::InstructionScheduler(Zone* zone,
graph_(zone), graph_(zone),
last_side_effect_instr_(nullptr), last_side_effect_instr_(nullptr),
pending_loads_(zone), pending_loads_(zone),
last_live_in_reg_marker_(nullptr) { last_live_in_reg_marker_(nullptr),
last_deopt_(nullptr) {
} }
...@@ -91,6 +92,7 @@ void InstructionScheduler::StartBlock(RpoNumber rpo) { ...@@ -91,6 +92,7 @@ void InstructionScheduler::StartBlock(RpoNumber rpo) {
DCHECK(last_side_effect_instr_ == nullptr); DCHECK(last_side_effect_instr_ == nullptr);
DCHECK(pending_loads_.empty()); DCHECK(pending_loads_.empty());
DCHECK(last_live_in_reg_marker_ == nullptr); DCHECK(last_live_in_reg_marker_ == nullptr);
DCHECK(last_deopt_ == nullptr);
sequence()->StartBlock(rpo); sequence()->StartBlock(rpo);
} }
...@@ -106,6 +108,7 @@ void InstructionScheduler::EndBlock(RpoNumber rpo) { ...@@ -106,6 +108,7 @@ void InstructionScheduler::EndBlock(RpoNumber rpo) {
last_side_effect_instr_ = nullptr; last_side_effect_instr_ = nullptr;
pending_loads_.clear(); pending_loads_.clear();
last_live_in_reg_marker_ = nullptr; last_live_in_reg_marker_ = nullptr;
last_deopt_ = nullptr;
} }
...@@ -128,6 +131,12 @@ void InstructionScheduler::AddInstruction(Instruction* instr) { ...@@ -128,6 +131,12 @@ void InstructionScheduler::AddInstruction(Instruction* instr) {
last_live_in_reg_marker_->AddSuccessor(new_node); last_live_in_reg_marker_->AddSuccessor(new_node);
} }
// Make sure that new instructions are not scheduled before the last
// deoptimization point.
if (last_deopt_ != nullptr) {
last_deopt_->AddSuccessor(new_node);
}
// Instructions with side effects and memory operations can't be // Instructions with side effects and memory operations can't be
// reordered with respect to each other. // reordered with respect to each other.
if (HasSideEffect(instr)) { if (HasSideEffect(instr)) {
...@@ -146,6 +155,13 @@ void InstructionScheduler::AddInstruction(Instruction* instr) { ...@@ -146,6 +155,13 @@ void InstructionScheduler::AddInstruction(Instruction* instr) {
last_side_effect_instr_->AddSuccessor(new_node); last_side_effect_instr_->AddSuccessor(new_node);
} }
pending_loads_.push_back(new_node); pending_loads_.push_back(new_node);
} else if (instr->IsDeoptimizeCall()) {
// Ensure that deopts are not reordered with respect to side-effect
// instructions.
if (last_side_effect_instr_ != nullptr) {
last_side_effect_instr_->AddSuccessor(new_node);
}
last_deopt_ = new_node;
} }
// Look for operand dependencies. // Look for operand dependencies.
......
...@@ -209,6 +209,9 @@ class InstructionScheduler final : public ZoneObject { ...@@ -209,6 +209,9 @@ class InstructionScheduler final : public ZoneObject {
// All these nops are chained together and added as a predecessor of every // All these nops are chained together and added as a predecessor of every
// other instructions in the basic block. // other instructions in the basic block.
ScheduleGraphNode* last_live_in_reg_marker_; ScheduleGraphNode* last_live_in_reg_marker_;
// Last deoptimization instruction encountered while building the graph.
ScheduleGraphNode* last_deopt_;
}; };
} // namespace compiler } // namespace compiler
......
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