From 2e08515d219f6ca564728527e76f2b8044740e79 Mon Sep 17 00:00:00 2001 From: "vegorov@chromium.org" Date: Tue, 27 Sep 2011 12:55:43 +0000 Subject: [PATCH] Check the depth of the constructed HEnvironment. Temporary check to catch 1727 on the reliability bot. R=fschneider@chromium.org BUG=v8:1727 Review URL: http://codereview.chromium.org/8055010 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9452 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/hydrogen.cc | 1 + src/hydrogen.h | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/hydrogen.cc b/src/hydrogen.cc index f35f3d6..96dd0ee 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -6472,6 +6472,7 @@ void HEnvironment::Initialize(const HEnvironment* other) { pop_count_ = other->pop_count_; push_count_ = other->push_count_; ast_id_ = other->ast_id_; + CheckDepth(); } diff --git a/src/hydrogen.h b/src/hydrogen.h index 8b507c2..5f0163c 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; -- 2.7.4