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 "use strict"; | 5 "use strict"; |
6 | 6 |
7 // This file relies on the fact that the following declarations have been made | 7 // This file relies on the fact that the following declarations have been made |
8 // in runtime.js: | 8 // in runtime.js: |
9 // var $Array = global.Array; | 9 // var $Array = global.Array; |
10 | 10 |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.push"); | 436 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.push"); |
437 | 437 |
438 if (%IsObserved(this)) | 438 if (%IsObserved(this)) |
439 return ObservedArrayPush.apply(this, arguments); | 439 return ObservedArrayPush.apply(this, arguments); |
440 | 440 |
441 var array = TO_OBJECT_INLINE(this); | 441 var array = TO_OBJECT_INLINE(this); |
442 var n = TO_UINT32(array.length); | 442 var n = TO_UINT32(array.length); |
443 var m = %_ArgumentsLength(); | 443 var m = %_ArgumentsLength(); |
444 | 444 |
445 for (var i = 0; i < m; i++) { | 445 for (var i = 0; i < m; i++) { |
446 // Use SetProperty rather than a direct keyed store to ensure that the store | 446 array[i+n] = %_Arguments(i); |
447 // site doesn't become poisened with an elements transition KeyedStoreIC. | |
448 %SetProperty(array, i+n, %_Arguments(i), 0, kStrictMode); | |
449 } | 447 } |
450 | 448 |
451 var new_length = n + m; | 449 var new_length = n + m; |
452 array.length = new_length; | 450 array.length = new_length; |
453 return new_length; | 451 return new_length; |
454 } | 452 } |
455 | 453 |
456 | 454 |
457 // Returns an array containing the array elements of the object followed | 455 // Returns an array containing the array elements of the object followed |
458 // by the array elements of each argument in order. See ECMA-262, | 456 // by the array elements of each argument in order. See ECMA-262, |
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1525 )); | 1523 )); |
1526 | 1524 |
1527 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( | 1525 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( |
1528 "join", getFunction("join", ArrayJoin), | 1526 "join", getFunction("join", ArrayJoin), |
1529 "pop", getFunction("pop", ArrayPop), | 1527 "pop", getFunction("pop", ArrayPop), |
1530 "push", getFunction("push", ArrayPush) | 1528 "push", getFunction("push", ArrayPush) |
1531 )); | 1529 )); |
1532 } | 1530 } |
1533 | 1531 |
1534 SetUpArray(); | 1532 SetUpArray(); |
OLD | NEW |