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 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.unshift"); | 621 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.unshift"); |
622 | 622 |
623 if (%IsObserved(this)) | 623 if (%IsObserved(this)) |
624 return ObservedArrayUnshift.apply(this, arguments); | 624 return ObservedArrayUnshift.apply(this, arguments); |
625 | 625 |
626 var array = TO_OBJECT_INLINE(this); | 626 var array = TO_OBJECT_INLINE(this); |
627 var len = TO_UINT32(array.length); | 627 var len = TO_UINT32(array.length); |
628 var num_arguments = %_ArgumentsLength(); | 628 var num_arguments = %_ArgumentsLength(); |
629 var is_sealed = ObjectIsSealed(array); | 629 var is_sealed = ObjectIsSealed(array); |
630 | 630 |
631 if (IS_ARRAY(array) && !is_sealed) { | 631 if (IS_ARRAY(array) && !is_sealed && len > 0) { |
632 SmartMove(array, 0, 0, len, num_arguments); | 632 SmartMove(array, 0, 0, len, num_arguments); |
633 } else { | 633 } else { |
634 SimpleMove(array, 0, 0, len, num_arguments); | 634 SimpleMove(array, 0, 0, len, num_arguments); |
635 } | 635 } |
636 | 636 |
637 for (var i = 0; i < num_arguments; i++) { | 637 for (var i = 0; i < num_arguments; i++) { |
638 array[i] = %_Arguments(i); | 638 array[i] = %_Arguments(i); |
639 } | 639 } |
640 | 640 |
641 var new_length = len + num_arguments; | 641 var new_length = len + num_arguments; |
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1525 )); | 1525 )); |
1526 | 1526 |
1527 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( | 1527 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( |
1528 "join", getFunction("join", ArrayJoin), | 1528 "join", getFunction("join", ArrayJoin), |
1529 "pop", getFunction("pop", ArrayPop), | 1529 "pop", getFunction("pop", ArrayPop), |
1530 "push", getFunction("push", ArrayPush) | 1530 "push", getFunction("push", ArrayPush) |
1531 )); | 1531 )); |
1532 } | 1532 } |
1533 | 1533 |
1534 SetUpArray(); | 1534 SetUpArray(); |
OLD | NEW |