Commit 86d1b7e8 authored by bmeurer's avatar bmeurer Committed by Commit bot

[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}
parent 73eae4c2
......@@ -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_) {
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment