| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/base/adapters.h" | 5 #include "src/base/adapters.h" |
| 6 #include "src/compiler/frame-elider.h" | 6 #include "src/compiler/frame-elider.h" |
| 7 | 7 |
| 8 namespace v8 { | 8 namespace v8 { |
| 9 namespace internal { | 9 namespace internal { |
| 10 namespace compiler { | 10 namespace compiler { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // Propagate towards the end ("downwards") if there is a predecessor needing | 107 // Propagate towards the end ("downwards") if there is a predecessor needing |
| 108 // a frame, but don't "bleed" from deferred code to non-deferred code. | 108 // a frame, but don't "bleed" from deferred code to non-deferred code. |
| 109 for (RpoNumber& pred : block->predecessors()) { | 109 for (RpoNumber& pred : block->predecessors()) { |
| 110 if (InstructionBlockAt(pred)->needs_frame() && | 110 if (InstructionBlockAt(pred)->needs_frame() && |
| 111 (!InstructionBlockAt(pred)->IsDeferred() || block->IsDeferred())) { | 111 (!InstructionBlockAt(pred)->IsDeferred() || block->IsDeferred())) { |
| 112 block->mark_needs_frame(); | 112 block->mark_needs_frame(); |
| 113 return true; | 113 return true; |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| 117 // Propagate towards start ("upwards") if there are successors and all of | 117 // Propagate towards start ("upwards") |
| 118 // them need a frame. | 118 bool need_frame_successors = false; |
| 119 for (RpoNumber& succ : block->successors()) { | 119 if (block->SuccessorCount() == 1) { |
| 120 if (!InstructionBlockAt(succ)->needs_frame()) return false; | 120 // For single successors, propagate the needs_frame information. |
| 121 need_frame_successors = |
| 122 InstructionBlockAt(block->successors()[0])->needs_frame(); |
| 123 } else { |
| 124 // For multiple successors, each successor must only have a single |
| 125 // predecessor (because the graph is in edge-split form), so each successor |
| 126 // can independently create/dismantle a frame if needed. Given this |
| 127 // independent control, only propagate needs_frame if all non-deferred |
| 128 // blocks need a frame. |
| 129 for (RpoNumber& succ : block->successors()) { |
| 130 InstructionBlock* successor_block = InstructionBlockAt(succ); |
| 131 DCHECK_EQ(1, successor_block->PredecessorCount()); |
| 132 if (!successor_block->IsDeferred()) { |
| 133 if (successor_block->needs_frame()) { |
| 134 need_frame_successors = true; |
| 135 } else { |
| 136 return false; |
| 137 } |
| 138 } |
| 139 } |
| 121 } | 140 } |
| 122 block->mark_needs_frame(); | 141 if (need_frame_successors) { |
| 123 return true; | 142 block->mark_needs_frame(); |
| 143 return true; |
| 144 } else { |
| 145 return false; |
| 146 } |
| 124 } | 147 } |
| 125 | 148 |
| 126 | 149 |
| 127 const InstructionBlocks& FrameElider::instruction_blocks() const { | 150 const InstructionBlocks& FrameElider::instruction_blocks() const { |
| 128 return code_->instruction_blocks(); | 151 return code_->instruction_blocks(); |
| 129 } | 152 } |
| 130 | 153 |
| 131 | 154 |
| 132 InstructionBlock* FrameElider::InstructionBlockAt(RpoNumber rpo_number) const { | 155 InstructionBlock* FrameElider::InstructionBlockAt(RpoNumber rpo_number) const { |
| 133 return code_->InstructionBlockAt(rpo_number); | 156 return code_->InstructionBlockAt(rpo_number); |
| 134 } | 157 } |
| 135 | 158 |
| 136 | 159 |
| 137 Instruction* FrameElider::InstructionAt(int index) const { | 160 Instruction* FrameElider::InstructionAt(int index) const { |
| 138 return code_->InstructionAt(index); | 161 return code_->InstructionAt(index); |
| 139 } | 162 } |
| 140 | 163 |
| 141 } // namespace compiler | 164 } // namespace compiler |
| 142 } // namespace internal | 165 } // namespace internal |
| 143 } // namespace v8 | 166 } // namespace v8 |
| OLD | NEW |