| 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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 | 596 |
| 597 return first; | 597 return first; |
| 598 } | 598 } |
| 599 | 599 |
| 600 function ObservedArrayUnshift() { | 600 function ObservedArrayUnshift() { |
| 601 var len = TO_UINT32(this.length); | 601 var len = TO_UINT32(this.length); |
| 602 var num_arguments = %_ArgumentsLength(); | 602 var num_arguments = %_ArgumentsLength(); |
| 603 | 603 |
| 604 try { | 604 try { |
| 605 BeginPerformSplice(this); | 605 BeginPerformSplice(this); |
| 606 SimpleMove(this, 0, 0, len, num_arguments); | 606 if (len > 0) { |
| 607 SimpleMove(this, 0, 0, len, num_arguments); |
| 608 } |
| 607 for (var i = 0; i < num_arguments; i++) { | 609 for (var i = 0; i < num_arguments; i++) { |
| 608 this[i] = %_Arguments(i); | 610 this[i] = %_Arguments(i); |
| 609 } | 611 } |
| 610 var new_length = len + num_arguments; | 612 var new_length = len + num_arguments; |
| 611 this.length = new_length; | 613 this.length = new_length; |
| 612 } finally { | 614 } finally { |
| 613 EndPerformSplice(this); | 615 EndPerformSplice(this); |
| 614 EnqueueSpliceRecord(this, 0, [], num_arguments); | 616 EnqueueSpliceRecord(this, 0, [], num_arguments); |
| 615 } | 617 } |
| 616 | 618 |
| 617 return new_length; | 619 return new_length; |
| 618 } | 620 } |
| 619 | 621 |
| 620 function ArrayUnshift(arg1) { // length == 1 | 622 function ArrayUnshift(arg1) { // length == 1 |
| 621 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.unshift"); | 623 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.unshift"); |
| 622 | 624 |
| 623 if (%IsObserved(this)) | 625 if (%IsObserved(this)) |
| 624 return ObservedArrayUnshift.apply(this, arguments); | 626 return ObservedArrayUnshift.apply(this, arguments); |
| 625 | 627 |
| 626 var array = TO_OBJECT_INLINE(this); | 628 var array = TO_OBJECT_INLINE(this); |
| 627 var len = TO_UINT32(array.length); | 629 var len = TO_UINT32(array.length); |
| 628 var num_arguments = %_ArgumentsLength(); | 630 var num_arguments = %_ArgumentsLength(); |
| 629 var is_sealed = ObjectIsSealed(array); | 631 var is_sealed = ObjectIsSealed(array); |
| 630 | 632 |
| 631 if (IS_ARRAY(array) && !is_sealed) { | 633 if (len > 0) { |
| 632 SmartMove(array, 0, 0, len, num_arguments); | 634 if (IS_ARRAY(array) && !is_sealed) { |
| 633 } else { | 635 SmartMove(array, 0, 0, len, num_arguments); |
| 634 SimpleMove(array, 0, 0, len, num_arguments); | 636 } else { |
| 637 SimpleMove(array, 0, 0, len, num_arguments); |
| 638 } |
| 635 } | 639 } |
| 636 | 640 |
| 637 for (var i = 0; i < num_arguments; i++) { | 641 for (var i = 0; i < num_arguments; i++) { |
| 638 array[i] = %_Arguments(i); | 642 array[i] = %_Arguments(i); |
| 639 } | 643 } |
| 640 | 644 |
| 641 var new_length = len + num_arguments; | 645 var new_length = len + num_arguments; |
| 642 array.length = new_length; | 646 array.length = new_length; |
| 643 return new_length; | 647 return new_length; |
| 644 } | 648 } |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 )); | 1529 )); |
| 1526 | 1530 |
| 1527 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( | 1531 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( |
| 1528 "join", getFunction("join", ArrayJoin), | 1532 "join", getFunction("join", ArrayJoin), |
| 1529 "pop", getFunction("pop", ArrayPop), | 1533 "pop", getFunction("pop", ArrayPop), |
| 1530 "push", getFunction("push", ArrayPush) | 1534 "push", getFunction("push", ArrayPush) |
| 1531 )); | 1535 )); |
| 1532 } | 1536 } |
| 1533 | 1537 |
| 1534 SetUpArray(); | 1538 SetUpArray(); |
| OLD | NEW |