merge = graph()->NewNode(common_->Merge(2), merge, loop);
end->ReplaceInput(0, merge);
to_add = merge;
+ // Mark the node as visited so that we can revisit later.
+ EnsureStateSize(merge->id());
+ state_[merge->id()] = kVisited;
} else {
// Append a new input to the final merge at the end.
merge->AppendInput(graph()->zone(), loop);
if (replacement != node) Recurse(replacement);
}
+ void EnsureStateSize(size_t id) {
+ if (id >= state_.size()) {
+ state_.resize((3 * id) / 2, kUnvisited);
+ }
+ }
+
// Push a node onto the stack if its state is {kUnvisited} or {kRevisit}.
bool Recurse(Node* node) {
size_t id = static_cast<size_t>(node->id());
- if (id < state_.size()) {
- if (state_[id] != kRevisit && state_[id] != kUnvisited) return false;
- } else {
- state_.resize((3 * id) / 2, kUnvisited);
- }
+ EnsureStateSize(id);
+ if (state_[id] != kRevisit && state_[id] != kUnvisited) return false;
Push(node);
return true;
}
--- /dev/null
+// Copyright 2015 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.
+
+// Flags: --allow-natives-syntax
+
+function f(x) {
+ while (1) { s++; }
+ while (x) { s++; }
+}
+
+assertThrows(function () { f(1); });