Reviewers: danno,
Message:
PTAL
Description:
Ensure CopyElementsImpl is always executed so it fills in holes even if
from_size is 0. Allow FixedDoubleArray::cast to also support FixedArray with
size 0.
Please review this at https://chromiumcodereview.appspot.com/11280054/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/elements.cc
M src/objects-inl.h
M test/mjsunit/array-store-and-grow.js
Index: src/elements.cc
diff --git a/src/elements.cc b/src/elements.cc
index
0f4d533f2e307ed613e5db4896a789d1286834d6..46a788bc84932683bad1d4ce0ddbf68f723d9e7e
100644
--- a/src/elements.cc
+++ b/src/elements.cc
@@ -696,9 +696,6 @@ class ElementsAccessorBase : public ElementsAccessor {
}
}
}
- if (from->length() == 0 || copy_size == 0) {
- return from;
- }
return ElementsAccessorSubclass::CopyElementsImpl(
from, from_start, to, to_kind, to_start, packed_size, copy_size);
}
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index
7db9175d41d6604d0f1f12ee2b92753fb412a618..e23adf2c2452b137361ea9078fda18977e3ebe93
100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -2342,8 +2342,14 @@ void
SeededNumberDictionary::set_requires_slow_elements() {
// Cast operations
+FixedDoubleArray* FixedDoubleArray::cast(Object* object) {
+ ASSERT((object->IsFixedArray() && FixedArray::cast(object)->length() ==
0) ||
+ object->IsFixedDoubleArray());
+ return reinterpret_cast<FixedDoubleArray*>(object);
+}
+
+
CAST_ACCESSOR(FixedArray)
-CAST_ACCESSOR(FixedDoubleArray)
CAST_ACCESSOR(DescriptorArray)
CAST_ACCESSOR(DeoptimizationInputData)
CAST_ACCESSOR(DeoptimizationOutputData)
Index: test/mjsunit/array-store-and-grow.js
diff --git a/test/mjsunit/array-store-and-grow.js
b/test/mjsunit/array-store-and-grow.js
index
131d4ebc512d9f022238e5ff258447f7b05928de..88f3db8f646ca93f12676ccd601d0a1372246bc5
100644
--- a/test/mjsunit/array-store-and-grow.js
+++ b/test/mjsunit/array-store-and-grow.js
@@ -99,7 +99,10 @@ array_store_5(a, 1, 0.5);
a = makeCOW();
array_store_5(a, 1, 0.5);
assertEquals(0.5, a[1]);
-assertEquals(0.5, array_store_5([], 1, 0.5));
+a = [];
+assertEquals(0.5, array_store_5(a, 1, 0.5));
+assertEquals(undefined, a[0]);
+assertEquals(0.5, a[1]);
function array_store_6(a,b,c) {
return (a[b] = c);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev