| 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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 if (!IS_UNDEFINED(result)) return result; | 392 if (!IS_UNDEFINED(result)) return result; |
| 393 | 393 |
| 394 return Join(this, length, separator, ConvertToString); | 394 return Join(this, length, separator, ConvertToString); |
| 395 } | 395 } |
| 396 | 396 |
| 397 | 397 |
| 398 function ObservedArrayPop(n) { | 398 function ObservedArrayPop(n) { |
| 399 n--; | 399 n--; |
| 400 var value = this[n]; | 400 var value = this[n]; |
| 401 | 401 |
| 402 EnqueueSpliceRecord(this, n, [value], 0); |
| 403 |
| 402 try { | 404 try { |
| 403 BeginPerformSplice(this); | 405 BeginPerformSplice(this); |
| 404 delete this[n]; | 406 delete this[n]; |
| 405 this.length = n; | 407 this.length = n; |
| 406 } finally { | 408 } finally { |
| 407 EndPerformSplice(this); | 409 EndPerformSplice(this); |
| 408 EnqueueSpliceRecord(this, n, [value], 0); | |
| 409 } | 410 } |
| 410 | 411 |
| 411 return value; | 412 return value; |
| 412 } | 413 } |
| 413 | 414 |
| 414 // Removes the last element from the array and returns it. See | 415 // Removes the last element from the array and returns it. See |
| 415 // ECMA-262, section 15.4.4.6. | 416 // ECMA-262, section 15.4.4.6. |
| 416 function ArrayPop() { | 417 function ArrayPop() { |
| 417 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | 418 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
| 418 throw MakeTypeError("called_on_null_or_undefined", | 419 throw MakeTypeError("called_on_null_or_undefined", |
| (...skipping 14 matching lines...) Expand all Loading... |
| 433 delete this[n]; | 434 delete this[n]; |
| 434 this.length = n; | 435 this.length = n; |
| 435 return value; | 436 return value; |
| 436 } | 437 } |
| 437 | 438 |
| 438 | 439 |
| 439 function ObservedArrayPush() { | 440 function ObservedArrayPush() { |
| 440 var n = TO_UINT32(this.length); | 441 var n = TO_UINT32(this.length); |
| 441 var m = %_ArgumentsLength(); | 442 var m = %_ArgumentsLength(); |
| 442 | 443 |
| 444 EnqueueSpliceRecord(this, n, [], m); |
| 445 |
| 443 try { | 446 try { |
| 444 BeginPerformSplice(this); | 447 BeginPerformSplice(this); |
| 445 for (var i = 0; i < m; i++) { | 448 for (var i = 0; i < m; i++) { |
| 446 this[i+n] = %_Arguments(i); | 449 this[i+n] = %_Arguments(i); |
| 447 } | 450 } |
| 448 this.length = n + m; | 451 this.length = n + m; |
| 449 } finally { | 452 } finally { |
| 450 EndPerformSplice(this); | 453 EndPerformSplice(this); |
| 451 EnqueueSpliceRecord(this, n, [], m); | |
| 452 } | 454 } |
| 453 | 455 |
| 454 return this.length; | 456 return this.length; |
| 455 } | 457 } |
| 456 | 458 |
| 457 // Appends the arguments to the end of the array and returns the new | 459 // Appends the arguments to the end of the array and returns the new |
| 458 // length of the array. See ECMA-262, section 15.4.4.7. | 460 // length of the array. See ECMA-262, section 15.4.4.7. |
| 459 function ArrayPush() { | 461 function ArrayPush() { |
| 460 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | 462 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
| 461 throw MakeTypeError("called_on_null_or_undefined", | 463 throw MakeTypeError("called_on_null_or_undefined", |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 } | 574 } |
| 573 } | 575 } |
| 574 } | 576 } |
| 575 return this; | 577 return this; |
| 576 } | 578 } |
| 577 | 579 |
| 578 | 580 |
| 579 function ObservedArrayShift(len) { | 581 function ObservedArrayShift(len) { |
| 580 var first = this[0]; | 582 var first = this[0]; |
| 581 | 583 |
| 584 EnqueueSpliceRecord(this, 0, [first], 0); |
| 585 |
| 582 try { | 586 try { |
| 583 BeginPerformSplice(this); | 587 BeginPerformSplice(this); |
| 584 SimpleMove(this, 0, 1, len, 0); | 588 SimpleMove(this, 0, 1, len, 0); |
| 585 this.length = len - 1; | 589 this.length = len - 1; |
| 586 } finally { | 590 } finally { |
| 587 EndPerformSplice(this); | 591 EndPerformSplice(this); |
| 588 EnqueueSpliceRecord(this, 0, [first], 0); | |
| 589 } | 592 } |
| 590 | 593 |
| 591 return first; | 594 return first; |
| 592 } | 595 } |
| 593 | 596 |
| 594 function ArrayShift() { | 597 function ArrayShift() { |
| 595 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | 598 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
| 596 throw MakeTypeError("called_on_null_or_undefined", | 599 throw MakeTypeError("called_on_null_or_undefined", |
| 597 ["Array.prototype.shift"]); | 600 ["Array.prototype.shift"]); |
| 598 } | 601 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 617 | 620 |
| 618 this.length = len - 1; | 621 this.length = len - 1; |
| 619 | 622 |
| 620 return first; | 623 return first; |
| 621 } | 624 } |
| 622 | 625 |
| 623 function ObservedArrayUnshift() { | 626 function ObservedArrayUnshift() { |
| 624 var len = TO_UINT32(this.length); | 627 var len = TO_UINT32(this.length); |
| 625 var num_arguments = %_ArgumentsLength(); | 628 var num_arguments = %_ArgumentsLength(); |
| 626 | 629 |
| 630 EnqueueSpliceRecord(this, 0, [], num_arguments); |
| 631 |
| 627 try { | 632 try { |
| 628 BeginPerformSplice(this); | 633 BeginPerformSplice(this); |
| 629 SimpleMove(this, 0, 0, len, num_arguments); | 634 SimpleMove(this, 0, 0, len, num_arguments); |
| 630 for (var i = 0; i < num_arguments; i++) { | 635 for (var i = 0; i < num_arguments; i++) { |
| 631 this[i] = %_Arguments(i); | 636 this[i] = %_Arguments(i); |
| 632 } | 637 } |
| 633 this.length = len + num_arguments; | 638 this.length = len + num_arguments; |
| 634 } finally { | 639 } finally { |
| 635 EndPerformSplice(this); | 640 EndPerformSplice(this); |
| 636 EnqueueSpliceRecord(this, 0, [], num_arguments); | |
| 637 } | 641 } |
| 638 | 642 |
| 639 return len + num_arguments; | 643 return len + num_arguments; |
| 640 } | 644 } |
| 641 | 645 |
| 642 function ArrayUnshift(arg1) { // length == 1 | 646 function ArrayUnshift(arg1) { // length == 1 |
| 643 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | 647 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
| 644 throw MakeTypeError("called_on_null_or_undefined", | 648 throw MakeTypeError("called_on_null_or_undefined", |
| 645 ["Array.prototype.unshift"]); | 649 ["Array.prototype.unshift"]); |
| 646 } | 650 } |
| (...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1652 )); | 1656 )); |
| 1653 | 1657 |
| 1654 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( | 1658 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( |
| 1655 "join", getFunction("join", ArrayJoin), | 1659 "join", getFunction("join", ArrayJoin), |
| 1656 "pop", getFunction("pop", ArrayPop), | 1660 "pop", getFunction("pop", ArrayPop), |
| 1657 "push", getFunction("push", ArrayPush) | 1661 "push", getFunction("push", ArrayPush) |
| 1658 )); | 1662 )); |
| 1659 } | 1663 } |
| 1660 | 1664 |
| 1661 SetUpArray(); | 1665 SetUpArray(); |
| OLD | NEW |