Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(406)

Unified Diff: src/hydrogen.h

Issue 8055010: Check the depth of the constructed HEnvironment. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/hydrogen.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698