Reviewers: fschneider,

Description:
Check the depth of the constructed HEnvironment.

Temporary check to catch 1727 on the reliability bot.

[email protected]
BUG=v8:1727


Please review this at http://codereview.chromium.org/8055010/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/hydrogen.h
  M src/hydrogen.cc


Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index c8075d5a0bbc885e6b6cd112ae1390f7087e50b6..ef6ed0abf7f9e5438717d47a8baff5e985e70903 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -6431,6 +6431,7 @@ void HEnvironment::Initialize(const HEnvironment* other) {
   pop_count_ = other->pop_count_;
   push_count_ = other->push_count_;
   ast_id_ = other->ast_id_;
+  CheckDepth();
 }


Index: src/hydrogen.h
diff --git a/src/hydrogen.h b/src/hydrogen.h
index 8b507c26b3fdff31a006418196bdd255c0997036..5f0163c266ef195c37825ec9fbee4f0bf06093d7 100644
--- a/src/hydrogen.h
+++ b/src/hydrogen.h
@@ -448,6 +448,23 @@ class HEnvironment: public ZoneObject {
  private:
   explicit HEnvironment(const HEnvironment* other);

+  void CheckDepth() {
+    // Verify that we are not trying to create an
+    // impossibly deeply nested environment.
+    if (!FLAG_limit_inlining) return;
+
+    static const int kMaxDepth = 4;
+
+    int cnt = 0;
+    for (HEnvironment* env = this;
+ env != NULL && cnt <= kMaxDepth; // Check cnt to avoid infinite loop.
+         env = env->outer()) {
+      cnt++;
+    }
+
+    CHECK(cnt <= kMaxDepth);
+  }
+
// True if index is included in the expression stack part of the environment.
   bool HasExpressionAt(int index) const;



--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to