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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
463 var m = %_ArgumentsLength(); | 463 var m = %_ArgumentsLength(); |
464 if (m > 0 && ObjectIsSealed(this)) { | 464 if (m > 0 && ObjectIsSealed(this)) { |
465 throw MakeTypeError("array_functions_change_sealed", | 465 throw MakeTypeError("array_functions_change_sealed", |
466 ["Array.prototype.push"]); | 466 ["Array.prototype.push"]); |
467 } | 467 } |
468 | 468 |
469 if (%IsObserved(this)) | 469 if (%IsObserved(this)) |
470 return ObservedArrayPush.apply(this, arguments); | 470 return ObservedArrayPush.apply(this, arguments); |
471 | 471 |
472 for (var i = 0; i < m; i++) { | 472 for (var i = 0; i < m; i++) { |
473 this[i+n] = %_Arguments(i); | 473 // Use SetProperty rather than a direct keyed store to ensure that the store |
474 // site doesn't become poisened with an elements transition KeyedStoreIC. | |
475 %SetProperty(this, i+n, %_Arguments(i), 0, 0); | |
Michael Starzinger
2014/04/11 13:12:08
This will break for primitive values as "this" bec
danno
2014/04/16 14:34:38
Done.
| |
474 } | 476 } |
475 | 477 |
476 var new_length = n + m; | 478 var new_length = n + m; |
477 this.length = new_length; | 479 this.length = new_length; |
478 return new_length; | 480 return new_length; |
479 } | 481 } |
480 | 482 |
481 | 483 |
482 // Returns an array containing the array elements of the object followed | 484 // Returns an array containing the array elements of the object followed |
483 // by the array elements of each argument in order. See ECMA-262, | 485 // by the array elements of each argument in order. See ECMA-262, |
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1639 )); | 1641 )); |
1640 | 1642 |
1641 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( | 1643 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( |
1642 "join", getFunction("join", ArrayJoin), | 1644 "join", getFunction("join", ArrayJoin), |
1643 "pop", getFunction("pop", ArrayPop), | 1645 "pop", getFunction("pop", ArrayPop), |
1644 "push", getFunction("push", ArrayPush) | 1646 "push", getFunction("push", ArrayPush) |
1645 )); | 1647 )); |
1646 } | 1648 } |
1647 | 1649 |
1648 SetUpArray(); | 1650 SetUpArray(); |
OLD | NEW |