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

Unified Diff: src/hydrogen.cc

Issue 286203010: Harden builtins BuildResultFromMatchInfo and URIDecodeOctets (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: address comments Created 6 years, 7 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/regexp.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 7c8c0560664056249ddfce0ef1cbd918b8de8fbe..9c782f2967bc143464ea2760a1ae9897cd1da296 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -1535,12 +1535,14 @@ HValue* HGraphBuilder::BuildRegExpConstructResult(HValue* length,
// Compute the size of the RegExpResult followed by FixedArray with length.
HValue* size = length;
- size = AddUncasted<HShl>(size, Add<HConstant>(kPointerSizeLog2));
- size = AddUncasted<HAdd>(size, Add<HConstant>(static_cast<int32_t>(
- JSRegExpResult::kSize + FixedArray::kHeaderSize)));
+ // Make sure size does not exceed max regular heap object size.
+ const int kHeaderSize = JSRegExpResult::kSize + FixedArray::kHeaderSize;
+ const int kMaxLength =
+ (Page::kMaxRegularHeapObjectSize - kHeaderSize) >> kPointerSizeLog2;
+ Add<HBoundsCheck>(size, Add<HConstant>(kMaxLength));
- // Make sure size does not exceeds max regular heap object size.
- Add<HBoundsCheck>(size, Add<HConstant>(Page::kMaxRegularHeapObjectSize));
+ size = AddUncasted<HShl>(size, Add<HConstant>(kPointerSizeLog2));
+ size = AddUncasted<HAdd>(size, Add<HConstant>(kHeaderSize));
// Allocate the JSRegExpResult and the FixedArray in one step.
HValue* result = Add<HAllocate>(
« no previous file with comments | « no previous file | src/regexp.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698