1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "hydrogen-mark-unreachable.h"
11 void HMarkUnreachableBlocksPhase::MarkUnreachableBlocks() {
12 // If there is unreachable code in the graph, propagate the unreachable marks
13 // using a fixed-point iteration.
15 const ZoneList<HBasicBlock*>* blocks = graph()->blocks();
18 for (int i = 0; i < blocks->length(); i++) {
19 HBasicBlock* block = blocks->at(i);
20 if (!block->IsReachable()) continue;
21 bool is_reachable = blocks->at(0) == block;
22 for (HPredecessorIterator it(block); !it.Done(); it.Advance()) {
23 HBasicBlock* predecessor = it.Current();
24 // A block is reachable if one of its predecessors is reachable,
25 // doesn't deoptimize and either is known to transfer control to the
26 // block or has a control flow instruction for which the next block
27 // cannot be determined.
28 if (predecessor->IsReachable() && !predecessor->IsDeoptimizing()) {
29 HBasicBlock* pred_succ;
30 bool known_pred_succ =
31 predecessor->end()->KnownSuccessorBlock(&pred_succ);
32 if (!known_pred_succ || pred_succ == block) {
37 if (block->is_osr_entry()) {
42 block->MarkUnreachable();
50 void HMarkUnreachableBlocksPhase::Run() {
51 MarkUnreachableBlocks();
54 } } // namespace v8::internal