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

Unified Diff: src/builtins.cc

Issue 601092: Adding checks for the cases when array grows too big. (Closed)
Patch Set: Turning checks into asserts as per Mad's suggestion Created 10 years, 10 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 | test/mjsunit/array-splice.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins.cc
diff --git a/src/builtins.cc b/src/builtins.cc
index 7ded532241be6fb193059a1943f24bb7ac838308..ee98769b47f446f1735874b34fc727bfcc95aa1c 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -251,6 +251,9 @@ BUILTIN(ArrayPush) {
if (to_add == 0) {
return Smi::FromInt(len);
}
+ // Currently fixed arrays cannot grow too big, so
+ // we should never hit this case.
+ ASSERT(to_add <= (Smi::kMaxValue - len));
int new_length = len + to_add;
FixedArray* elms = FixedArray::cast(array->elements());
@@ -370,6 +373,10 @@ BUILTIN(ArrayUnshift) {
// the array.
int new_length = len + to_add;
+ // Currently fixed arrays cannot grow too big, so
+ // we should never hit this case.
+ ASSERT(to_add <= (Smi::kMaxValue - len));
+
FixedArray* elms = FixedArray::cast(array->elements());
// Fetch the prototype.
@@ -614,6 +621,10 @@ BUILTIN(ArraySplice) {
elms->set(k - 1, Heap::the_hole_value());
}
} else if (itemCount > actualDeleteCount) {
+ // Currently fixed arrays cannot grow too big, so
+ // we should never hit this case.
+ ASSERT((itemCount - actualDeleteCount) <= (Smi::kMaxValue - len));
+
FixedArray* source_elms = elms;
// Check if array need to grow.
« no previous file with comments | « no previous file | test/mjsunit/array-splice.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698