all-nodes.cc 1.03 KB
Newer Older
1 2 3 4 5 6
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/compiler/all-nodes.h"

7 8
#include "src/compiler/graph.h"

9 10 11 12 13
namespace v8 {
namespace internal {
namespace compiler {

AllNodes::AllNodes(Zone* local_zone, const Graph* graph)
14
    : live(local_zone), is_live(graph->NodeCount(), false, local_zone) {
15
  Node* end = graph->end();
16
  is_live[end->id()] = true;
17 18 19 20 21 22 23 24 25 26 27 28
  live.push_back(end);
  // Find all live nodes reachable from end.
  for (size_t i = 0; i < live.size(); i++) {
    for (Node* const input : live[i]->inputs()) {
      if (input == nullptr) {
        // TODO(titzer): print a warning.
        continue;
      }
      if (input->id() >= graph->NodeCount()) {
        // TODO(titzer): print a warning.
        continue;
      }
29 30
      if (!is_live[input->id()]) {
        is_live[input->id()] = true;
31 32 33 34 35
        live.push_back(input);
      }
    }
  }
}
36 37 38 39

}  // namespace compiler
}  // namespace internal
}  // namespace v8