| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var $arrayConcat; | 5 var $arrayConcat; |
| 6 var $arrayPush; | 6 var $arrayPush; |
| 7 var $arrayPop; | 7 var $arrayPop; |
| 8 var $arrayShift; | 8 var $arrayShift; |
| 9 var $arraySlice; | 9 var $arraySlice; |
| 10 var $arraySplice; | 10 var $arraySplice; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 // This function implements the optimized splice implementation that can use | 236 // This function implements the optimized splice implementation that can use |
| 237 // special array operations to handle sparse arrays in a sensible fashion. | 237 // special array operations to handle sparse arrays in a sensible fashion. |
| 238 function SparseSlice(array, start_i, del_count, len, deleted_elements) { | 238 function SparseSlice(array, start_i, del_count, len, deleted_elements) { |
| 239 // Move deleted elements to a new array (the return value from splice). | 239 // Move deleted elements to a new array (the return value from splice). |
| 240 var indices = %GetArrayKeys(array, start_i + del_count); | 240 var indices = %GetArrayKeys(array, start_i + del_count); |
| 241 if (IS_NUMBER(indices)) { | 241 if (IS_NUMBER(indices)) { |
| 242 var limit = indices; | 242 var limit = indices; |
| 243 for (var i = start_i; i < limit; ++i) { | 243 for (var i = start_i; i < limit; ++i) { |
| 244 var current = array[i]; | 244 var current = array[i]; |
| 245 if (!IS_UNDEFINED(current) || i in array) { | 245 if (!IS_UNDEFINED(current) || i in array) { |
| 246 %AddElement(deleted_elements, i - start_i, current, NONE); | 246 %AddElement(deleted_elements, i - start_i, current); |
| 247 } | 247 } |
| 248 } | 248 } |
| 249 } else { | 249 } else { |
| 250 var length = indices.length; | 250 var length = indices.length; |
| 251 for (var k = 0; k < length; ++k) { | 251 for (var k = 0; k < length; ++k) { |
| 252 var key = indices[k]; | 252 var key = indices[k]; |
| 253 if (!IS_UNDEFINED(key)) { | 253 if (!IS_UNDEFINED(key)) { |
| 254 if (key >= start_i) { | 254 if (key >= start_i) { |
| 255 var current = array[key]; | 255 var current = array[key]; |
| 256 if (!IS_UNDEFINED(current) || key in array) { | 256 if (!IS_UNDEFINED(current) || key in array) { |
| 257 %AddElement(deleted_elements, key - start_i, current, NONE); | 257 %AddElement(deleted_elements, key - start_i, current); |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 } | 260 } |
| 261 } | 261 } |
| 262 } | 262 } |
| 263 } | 263 } |
| 264 | 264 |
| 265 | 265 |
| 266 // This function implements the optimized splice implementation that can use | 266 // This function implements the optimized splice implementation that can use |
| 267 // special array operations to handle sparse arrays in a sensible fashion. | 267 // special array operations to handle sparse arrays in a sensible fashion. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 // because the receiver is not an array (so we have no choice) or because we | 329 // because the receiver is not an array (so we have no choice) or because we |
| 330 // know we are not deleting or moving a lot of elements. | 330 // know we are not deleting or moving a lot of elements. |
| 331 function SimpleSlice(array, start_i, del_count, len, deleted_elements) { | 331 function SimpleSlice(array, start_i, del_count, len, deleted_elements) { |
| 332 var is_array = IS_ARRAY(array); | 332 var is_array = IS_ARRAY(array); |
| 333 for (var i = 0; i < del_count; i++) { | 333 for (var i = 0; i < del_count; i++) { |
| 334 var index = start_i + i; | 334 var index = start_i + i; |
| 335 if (HAS_INDEX(array, index, is_array)) { | 335 if (HAS_INDEX(array, index, is_array)) { |
| 336 var current = array[index]; | 336 var current = array[index]; |
| 337 // The spec requires [[DefineOwnProperty]] here, %AddElement is close | 337 // The spec requires [[DefineOwnProperty]] here, %AddElement is close |
| 338 // enough (in that it ignores the prototype). | 338 // enough (in that it ignores the prototype). |
| 339 %AddElement(deleted_elements, i, current, NONE); | 339 %AddElement(deleted_elements, i, current); |
| 340 } | 340 } |
| 341 } | 341 } |
| 342 } | 342 } |
| 343 | 343 |
| 344 | 344 |
| 345 function SimpleMove(array, start_i, del_count, len, num_additional_args) { | 345 function SimpleMove(array, start_i, del_count, len, num_additional_args) { |
| 346 var is_array = IS_ARRAY(array); | 346 var is_array = IS_ARRAY(array); |
| 347 if (num_additional_args !== del_count) { | 347 if (num_additional_args !== del_count) { |
| 348 // Move the existing elements after the elements to be deleted | 348 // Move the existing elements after the elements to be deleted |
| 349 // to the right position in the resulting array. | 349 // to the right position in the resulting array. |
| (...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1694 | 1694 |
| 1695 $arrayConcat = ArrayConcatJS; | 1695 $arrayConcat = ArrayConcatJS; |
| 1696 $arrayPush = ArrayPush; | 1696 $arrayPush = ArrayPush; |
| 1697 $arrayPop = ArrayPop; | 1697 $arrayPop = ArrayPop; |
| 1698 $arrayShift = ArrayShift; | 1698 $arrayShift = ArrayShift; |
| 1699 $arraySlice = ArraySlice; | 1699 $arraySlice = ArraySlice; |
| 1700 $arraySplice = ArraySplice; | 1700 $arraySplice = ArraySplice; |
| 1701 $arrayUnshift = ArrayUnshift; | 1701 $arrayUnshift = ArrayUnshift; |
| 1702 | 1702 |
| 1703 }); | 1703 }); |
| OLD | NEW |