Change SmartMove no-op behavior to match SimpleMove (and ES6 spec)

The previous behavior, which caused Array.prototype.unshift() (with no args)
to have side-effects, no longer matches the spec (ES6 changed the no-arg behavior
in April 2014). The new SmartMove behavior is also compatible with current
versions of Firefox.

This is a baby step towards getting rid of SmartMove; it isolates the test
change in this patch, instead of lumping it in confusingly with all the
other test updates necessary for moving away from SmartMove.

R=dslomov@chromium.org

Review URL: https://codereview.chromium.org/666883009

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24854 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
adamk@chromium.org 2014-10-23 17:46:34 +00:00
parent f194b3cc9e
commit f3c3697521
2 changed files with 13 additions and 15 deletions

View File

@ -234,6 +234,8 @@ function SmartSlice(array, start_i, del_count, len, deleted_elements) {
// This function implements the optimized splice implementation that can use
// special array operations to handle sparse arrays in a sensible fashion.
function SmartMove(array, start_i, del_count, len, num_additional_args) {
// Bail out if no moving is necessary.
if (num_additional_args === del_count) return;
// Move data to new array.
var new_array = new InternalArray(len - del_count + num_additional_args);
var indices = %GetArrayKeys(array, len);

View File

@ -37,9 +37,7 @@
})();
// Check that unshift with no args has a side-effect of
// filling the holes with elements from the prototype
// (if present, of course)
// Check that unshift with no args has no side-effects.
(function() {
var len = 3;
var array = new Array(len);
@ -65,15 +63,15 @@
assertTrue(delete Array.prototype[0]);
assertTrue(delete Array.prototype[2]);
// unshift makes array own 0 and 2...
assertTrue(array.hasOwnProperty(0));
// array still owns nothing...
assertFalse(array.hasOwnProperty(0));
assertFalse(array.hasOwnProperty(1));
assertTrue(array.hasOwnProperty(2));
assertFalse(array.hasOwnProperty(2));
// ... so they are not affected be delete.
assertEquals(array[0], at0);
assertEquals(array[0], undefined);
assertEquals(array[1], undefined);
assertEquals(array[2], at2);
assertEquals(array[2], undefined);
})();
@ -115,9 +113,7 @@
assertTrue(delete Array.prototype[7]);
})();
// Check that unshift with no args has a side-effect of
// filling the holes with elements from the prototype
// (if present, of course)
// Check that unshift with no args has no side-effects.
(function() {
var len = 3;
var array = new Array(len);
@ -142,12 +138,12 @@
assertEquals(len, array.unshift());
// unshift makes array own 0 and 2...
assertTrue(array.hasOwnProperty(0));
// array still owns nothing.
assertFalse(array.hasOwnProperty(0));
assertFalse(array.hasOwnProperty(1));
assertTrue(array.hasOwnProperty(2));
assertFalse(array.hasOwnProperty(2));
// ... so they are not affected be delete.
// ... but still sees values from array_proto.
assertEquals(array[0], at0);
assertEquals(array[1], undefined);
assertEquals(array[2], at2);