[turbofan] Robustify the GraphTrimmer.

The GraphTrimmer should not ever see a dead node, except for the roots
that are explicitly fed into it. To defend against this, turn the
condition into a DCHECK.

R=jarin@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#34001}
This commit is contained in:
bmeurer 2016-02-15 09:28:15 -08:00 committed by Commit bot
parent 73eae4c26a
commit 86d1b7e83d
2 changed files with 8 additions and 3 deletions

View File

@ -24,7 +24,8 @@ void GraphTrimmer::TrimGraph() {
MarkAsLive(graph()->end());
// Compute transitive closure of live nodes.
for (size_t i = 0; i < live_.size(); ++i) {
for (Node* const input : live_[i]->inputs()) MarkAsLive(input);
Node* const live = live_[i];
for (Node* const input : live->inputs()) MarkAsLive(input);
}
// Remove dead->live edges.
for (Node* const live : live_) {

View File

@ -28,14 +28,18 @@ class GraphTrimmer final {
// or any of the roots in the sequence [{begin},{end}[.
template <typename ForwardIterator>
void TrimGraph(ForwardIterator begin, ForwardIterator end) {
while (begin != end) MarkAsLive(*begin++);
while (begin != end) {
Node* const node = *begin++;
if (!node->IsDead()) MarkAsLive(node);
}
TrimGraph();
}
private:
V8_INLINE bool IsLive(Node* const node) { return is_live_.Get(node); }
V8_INLINE void MarkAsLive(Node* const node) {
if (!node->IsDead() && !IsLive(node)) {
DCHECK(!node->IsDead());
if (!IsLive(node)) {
is_live_.Set(node, true);
live_.push_back(node);
}