OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 var len = TO_UINT32(this.length); | 644 var len = TO_UINT32(this.length); |
645 var num_arguments = %_ArgumentsLength(); | 645 var num_arguments = %_ArgumentsLength(); |
646 var is_sealed = ObjectIsSealed(this); | 646 var is_sealed = ObjectIsSealed(this); |
647 | 647 |
648 if (%IsObserved(this)) | 648 if (%IsObserved(this)) |
649 return ObservedArrayUnshift.apply(this, arguments); | 649 return ObservedArrayUnshift.apply(this, arguments); |
650 | 650 |
651 if (IS_ARRAY(this) && !is_sealed) { | 651 if (IS_ARRAY(this) && !is_sealed) { |
652 SmartMove(this, 0, 0, len, num_arguments); | 652 SmartMove(this, 0, 0, len, num_arguments); |
653 } else { | 653 } else { |
654 if (num_arguments == 0 && ObjectIsFrozen(this)) { | |
655 // In the zero argument case, values from the prototype come into the | |
656 // object. This can't be allowed on frozen arrays. | |
657 for (var i = 0; i < len; i++) { | |
658 if (!this.hasOwnProperty(i) && !IS_UNDEFINED(this[i])) { | |
659 throw MakeTypeError("array_functions_on_frozen", | |
660 ["Array.prototype.shift"]); | |
661 } | |
662 } | |
663 } | |
664 | |
665 SimpleMove(this, 0, 0, len, num_arguments); | 654 SimpleMove(this, 0, 0, len, num_arguments); |
666 } | 655 } |
667 | 656 |
668 for (var i = 0; i < num_arguments; i++) { | 657 for (var i = 0; i < num_arguments; i++) { |
669 this[i] = %_Arguments(i); | 658 this[i] = %_Arguments(i); |
670 } | 659 } |
671 | 660 |
672 var new_length = len + num_arguments; | 661 var new_length = len + num_arguments; |
673 this.length = new_length; | 662 this.length = new_length; |
674 return new_length; | 663 return new_length; |
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1632 )); | 1621 )); |
1633 | 1622 |
1634 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( | 1623 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( |
1635 "join", getFunction("join", ArrayJoin), | 1624 "join", getFunction("join", ArrayJoin), |
1636 "pop", getFunction("pop", ArrayPop), | 1625 "pop", getFunction("pop", ArrayPop), |
1637 "push", getFunction("push", ArrayPush) | 1626 "push", getFunction("push", ArrayPush) |
1638 )); | 1627 )); |
1639 } | 1628 } |
1640 | 1629 |
1641 SetUpArray(); | 1630 SetUpArray(); |
OLD | NEW |