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

Side by Side 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, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/hydrogen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 ASSERT(index < length()); 441 ASSERT(index < length());
442 values_[index] = value; 442 values_[index] = value;
443 } 443 }
444 444
445 void PrintTo(StringStream* stream); 445 void PrintTo(StringStream* stream);
446 void PrintToStd(); 446 void PrintToStd();
447 447
448 private: 448 private:
449 explicit HEnvironment(const HEnvironment* other); 449 explicit HEnvironment(const HEnvironment* other);
450 450
451 void CheckDepth() {
452 // Verify that we are not trying to create an
453 // impossibly deeply nested environment.
454 if (!FLAG_limit_inlining) return;
455
456 static const int kMaxDepth = 4;
457
458 int cnt = 0;
459 for (HEnvironment* env = this;
460 env != NULL && cnt <= kMaxDepth; // Check cnt to avoid infinite loop.
461 env = env->outer()) {
462 cnt++;
463 }
464
465 CHECK(cnt <= kMaxDepth);
466 }
467
451 // True if index is included in the expression stack part of the environment. 468 // True if index is included in the expression stack part of the environment.
452 bool HasExpressionAt(int index) const; 469 bool HasExpressionAt(int index) const;
453 470
454 void Initialize(int parameter_count, int local_count, int stack_height); 471 void Initialize(int parameter_count, int local_count, int stack_height);
455 void Initialize(const HEnvironment* other); 472 void Initialize(const HEnvironment* other);
456 473
457 // Map a variable to an environment index. Parameter indices are shifted 474 // Map a variable to an environment index. Parameter indices are shifted
458 // by 1 (receiver is parameter index -1 but environment index 0). 475 // by 1 (receiver is parameter index -1 but environment index 0).
459 // Stack-allocated local indices are shifted by the number of parameters. 476 // Stack-allocated local indices are shifted by the number of parameters.
460 int IndexFor(Variable* variable) const { 477 int IndexFor(Variable* variable) const {
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 const char* filename_; 1258 const char* filename_;
1242 HeapStringAllocator string_allocator_; 1259 HeapStringAllocator string_allocator_;
1243 StringStream trace_; 1260 StringStream trace_;
1244 int indent_; 1261 int indent_;
1245 }; 1262 };
1246 1263
1247 1264
1248 } } // namespace v8::internal 1265 } } // namespace v8::internal
1249 1266
1250 #endif // V8_HYDROGEN_H_ 1267 #endif // V8_HYDROGEN_H_
OLDNEW
« 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