| 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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 | 437 |
| 438 function ObservedArrayPush() { | 438 function ObservedArrayPush() { |
| 439 var n = TO_UINT32(this.length); | 439 var n = TO_UINT32(this.length); |
| 440 var m = %_ArgumentsLength(); | 440 var m = %_ArgumentsLength(); |
| 441 | 441 |
| 442 try { | 442 try { |
| 443 BeginPerformSplice(this); | 443 BeginPerformSplice(this); |
| 444 for (var i = 0; i < m; i++) { | 444 for (var i = 0; i < m; i++) { |
| 445 this[i+n] = %_Arguments(i); | 445 this[i+n] = %_Arguments(i); |
| 446 } | 446 } |
| 447 this.length = n + m; | 447 var new_length = n + m; |
| 448 this.length = new_length; |
| 448 } finally { | 449 } finally { |
| 449 EndPerformSplice(this); | 450 EndPerformSplice(this); |
| 450 EnqueueSpliceRecord(this, n, [], m); | 451 EnqueueSpliceRecord(this, n, [], m); |
| 451 } | 452 } |
| 452 | 453 |
| 453 return this.length; | 454 return new_length; |
| 454 } | 455 } |
| 455 | 456 |
| 456 // Appends the arguments to the end of the array and returns the new | 457 // Appends the arguments to the end of the array and returns the new |
| 457 // length of the array. See ECMA-262, section 15.4.4.7. | 458 // length of the array. See ECMA-262, section 15.4.4.7. |
| 458 function ArrayPush() { | 459 function ArrayPush() { |
| 459 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.push"); | 460 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.push"); |
| 460 | 461 |
| 461 var n = TO_UINT32(this.length); | 462 var n = TO_UINT32(this.length); |
| 462 var m = %_ArgumentsLength(); | 463 var m = %_ArgumentsLength(); |
| 463 if (m > 0 && ObjectIsSealed(this)) { | 464 if (m > 0 && ObjectIsSealed(this)) { |
| 464 throw MakeTypeError("array_functions_change_sealed", | 465 throw MakeTypeError("array_functions_change_sealed", |
| 465 ["Array.prototype.push"]); | 466 ["Array.prototype.push"]); |
| 466 } | 467 } |
| 467 | 468 |
| 468 if (%IsObserved(this)) | 469 if (%IsObserved(this)) |
| 469 return ObservedArrayPush.apply(this, arguments); | 470 return ObservedArrayPush.apply(this, arguments); |
| 470 | 471 |
| 471 for (var i = 0; i < m; i++) { | 472 for (var i = 0; i < m; i++) { |
| 472 this[i+n] = %_Arguments(i); | 473 this[i+n] = %_Arguments(i); |
| 473 } | 474 } |
| 474 this.length = n + m; | 475 |
| 475 return this.length; | 476 var new_length = n + m; |
| 477 this.length = new_length; |
| 478 return new_length; |
| 476 } | 479 } |
| 477 | 480 |
| 478 | 481 |
| 479 // Returns an array containing the array elements of the object followed | 482 // Returns an array containing the array elements of the object followed |
| 480 // by the array elements of each argument in order. See ECMA-262, | 483 // by the array elements of each argument in order. See ECMA-262, |
| 481 // section 15.4.4.7. | 484 // section 15.4.4.7. |
| 482 function ArrayConcat(arg1) { // length == 1 | 485 function ArrayConcat(arg1) { // length == 1 |
| 483 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.concat"); | 486 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.concat"); |
| 484 | 487 |
| 485 var array = ToObject(this); | 488 var array = ToObject(this); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 function ObservedArrayUnshift() { | 623 function ObservedArrayUnshift() { |
| 621 var len = TO_UINT32(this.length); | 624 var len = TO_UINT32(this.length); |
| 622 var num_arguments = %_ArgumentsLength(); | 625 var num_arguments = %_ArgumentsLength(); |
| 623 | 626 |
| 624 try { | 627 try { |
| 625 BeginPerformSplice(this); | 628 BeginPerformSplice(this); |
| 626 SimpleMove(this, 0, 0, len, num_arguments); | 629 SimpleMove(this, 0, 0, len, num_arguments); |
| 627 for (var i = 0; i < num_arguments; i++) { | 630 for (var i = 0; i < num_arguments; i++) { |
| 628 this[i] = %_Arguments(i); | 631 this[i] = %_Arguments(i); |
| 629 } | 632 } |
| 630 this.length = len + num_arguments; | 633 var new_length = len + num_arguments; |
| 634 this.length = new_length; |
| 631 } finally { | 635 } finally { |
| 632 EndPerformSplice(this); | 636 EndPerformSplice(this); |
| 633 EnqueueSpliceRecord(this, 0, [], num_arguments); | 637 EnqueueSpliceRecord(this, 0, [], num_arguments); |
| 634 } | 638 } |
| 635 | 639 |
| 636 return len + num_arguments; | 640 return new_length; |
| 637 } | 641 } |
| 638 | 642 |
| 639 function ArrayUnshift(arg1) { // length == 1 | 643 function ArrayUnshift(arg1) { // length == 1 |
| 640 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.unshift"); | 644 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.unshift"); |
| 641 | 645 |
| 642 var len = TO_UINT32(this.length); | 646 var len = TO_UINT32(this.length); |
| 643 var num_arguments = %_ArgumentsLength(); | 647 var num_arguments = %_ArgumentsLength(); |
| 644 var is_sealed = ObjectIsSealed(this); | 648 var is_sealed = ObjectIsSealed(this); |
| 645 | 649 |
| 646 if (num_arguments > 0 && is_sealed) { | 650 if (num_arguments > 0 && is_sealed) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 665 } | 669 } |
| 666 } | 670 } |
| 667 | 671 |
| 668 SimpleMove(this, 0, 0, len, num_arguments); | 672 SimpleMove(this, 0, 0, len, num_arguments); |
| 669 } | 673 } |
| 670 | 674 |
| 671 for (var i = 0; i < num_arguments; i++) { | 675 for (var i = 0; i < num_arguments; i++) { |
| 672 this[i] = %_Arguments(i); | 676 this[i] = %_Arguments(i); |
| 673 } | 677 } |
| 674 | 678 |
| 675 this.length = len + num_arguments; | 679 var new_length = len + num_arguments; |
| 676 | 680 this.length = new_length; |
| 677 return this.length; | 681 return new_length; |
| 678 } | 682 } |
| 679 | 683 |
| 680 | 684 |
| 681 function ArraySlice(start, end) { | 685 function ArraySlice(start, end) { |
| 682 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.slice"); | 686 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.slice"); |
| 683 | 687 |
| 684 var len = TO_UINT32(this.length); | 688 var len = TO_UINT32(this.length); |
| 685 var start_i = TO_INTEGER(start); | 689 var start_i = TO_INTEGER(start); |
| 686 var end_i = len; | 690 var end_i = len; |
| 687 | 691 |
| (...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1635 )); | 1639 )); |
| 1636 | 1640 |
| 1637 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( | 1641 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( |
| 1638 "join", getFunction("join", ArrayJoin), | 1642 "join", getFunction("join", ArrayJoin), |
| 1639 "pop", getFunction("pop", ArrayPop), | 1643 "pop", getFunction("pop", ArrayPop), |
| 1640 "push", getFunction("push", ArrayPush) | 1644 "push", getFunction("push", ArrayPush) |
| 1641 )); | 1645 )); |
| 1642 } | 1646 } |
| 1643 | 1647 |
| 1644 SetUpArray(); | 1648 SetUpArray(); |
| OLD | NEW |