| Index: src/hydrogen-mark-unreachable.cc
|
| diff --git a/src/hydrogen-sce.cc b/src/hydrogen-mark-unreachable.cc
|
| similarity index 54%
|
| copy from src/hydrogen-sce.cc
|
| copy to src/hydrogen-mark-unreachable.cc
|
| index a6995f647afc00437783f057110c7654a28265c3..d7c5ed2b180281628e79d92f3522c71a4e9518b9 100644
|
| --- a/src/hydrogen-sce.cc
|
| +++ b/src/hydrogen-mark-unreachable.cc
|
| @@ -25,38 +25,53 @@
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -#include "hydrogen-sce.h"
|
| -#include "v8.h"
|
| +#include "hydrogen-mark-unreachable.h"
|
|
|
| namespace v8 {
|
| namespace internal {
|
|
|
| -void HStackCheckEliminationPhase::Run() {
|
| - // For each loop block walk the dominator tree from the backwards branch to
|
| - // the loop header. If a call instruction is encountered the backwards branch
|
| - // is dominated by a call and the stack check in the backwards branch can be
|
| - // removed.
|
| - for (int i = 0; i < graph()->blocks()->length(); i++) {
|
| - HBasicBlock* block = graph()->blocks()->at(i);
|
| - if (block->IsLoopHeader()) {
|
| - HBasicBlock* back_edge = block->loop_information()->GetLastBackEdge();
|
| - HBasicBlock* dominator = back_edge;
|
| - while (true) {
|
| - for (HInstructionIterator it(dominator); !it.Done(); it.Advance()) {
|
| - if (it.Current()->IsCall()) {
|
| - block->loop_information()->stack_check()->Eliminate();
|
| +
|
| +void HMarkUnreachableBlocksPhase::MarkUnreachableBlocks() {
|
| + // If there is unreachable code in the graph, propagate the unreachable marks
|
| + // using a fixed-point iteration.
|
| + bool changed = true;
|
| + const ZoneList<HBasicBlock*>* blocks = graph()->blocks();
|
| + while (changed) {
|
| + changed = false;
|
| + for (int i = 0; i < blocks->length(); i++) {
|
| + HBasicBlock* block = blocks->at(i);
|
| + if (!block->IsReachable()) continue;
|
| + bool is_reachable = blocks->at(0) == block;
|
| + for (HPredecessorIterator it(block); !it.Done(); it.Advance()) {
|
| + HBasicBlock* predecessor = it.Current();
|
| + // A block is reachable if one of its predecessors is reachable,
|
| + // doesn't deoptimize and either is known to transfer control to the
|
| + // block or has a control flow instruction for which the next block
|
| + // cannot be determined.
|
| + if (predecessor->IsReachable() && !predecessor->IsDeoptimizing()) {
|
| + HBasicBlock* pred_succ;
|
| + bool known_pred_succ =
|
| + predecessor->end()->KnownSuccessorBlock(&pred_succ);
|
| + if (!known_pred_succ || pred_succ == block) {
|
| + is_reachable = true;
|
| break;
|
| }
|
| }
|
| -
|
| - // Done when the loop header is processed.
|
| - if (dominator == block) break;
|
| -
|
| - // Move up the dominator tree.
|
| - dominator = dominator->dominator();
|
| + if (block->is_osr_entry()) {
|
| + is_reachable = true;
|
| + }
|
| + }
|
| + if (!is_reachable) {
|
| + block->MarkUnreachable();
|
| + changed = true;
|
| }
|
| }
|
| }
|
| }
|
|
|
| +
|
| +void HMarkUnreachableBlocksPhase::Run() {
|
| + MarkUnreachableBlocks();
|
| +}
|
| +
|
| } } // namespace v8::internal
|
|
|