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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 function ArrayPush() { | 461 function ArrayPush() { |
462 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.push"); | 462 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.push"); |
463 | 463 |
464 var n = TO_UINT32(this.length); | 464 var n = TO_UINT32(this.length); |
465 var m = %_ArgumentsLength(); | 465 var m = %_ArgumentsLength(); |
466 | 466 |
467 if (%IsObserved(this)) | 467 if (%IsObserved(this)) |
468 return ObservedArrayPush.apply(this, arguments); | 468 return ObservedArrayPush.apply(this, arguments); |
469 | 469 |
470 for (var i = 0; i < m; i++) { | 470 for (var i = 0; i < m; i++) { |
471 this[i+n] = %_Arguments(i); | 471 // Use SetProperty rather than a direct keyed store to ensure that the store |
| 472 // site doesn't become poisened with an elements transition KeyedStoreIC. |
| 473 // |
| 474 // TODO(danno): Using %SetProperty is a temporary workaround. The spec says |
| 475 // that ToObject needs to be called for primitive values (and |
| 476 // Runtime_SetProperty seem to ignore them). |
| 477 %SetProperty(this, i+n, %_Arguments(i), 0, kStrictMode); |
472 } | 478 } |
473 | 479 |
474 var new_length = n + m; | 480 var new_length = n + m; |
475 this.length = new_length; | 481 this.length = new_length; |
476 return new_length; | 482 return new_length; |
477 } | 483 } |
478 | 484 |
479 | 485 |
480 // Returns an array containing the array elements of the object followed | 486 // Returns an array containing the array elements of the object followed |
481 // by the array elements of each argument in order. See ECMA-262, | 487 // by the array elements of each argument in order. See ECMA-262, |
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1621 )); | 1627 )); |
1622 | 1628 |
1623 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( | 1629 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( |
1624 "join", getFunction("join", ArrayJoin), | 1630 "join", getFunction("join", ArrayJoin), |
1625 "pop", getFunction("pop", ArrayPop), | 1631 "pop", getFunction("pop", ArrayPop), |
1626 "push", getFunction("push", ArrayPush) | 1632 "push", getFunction("push", ArrayPush) |
1627 )); | 1633 )); |
1628 } | 1634 } |
1629 | 1635 |
1630 SetUpArray(); | 1636 SetUpArray(); |
OLD | NEW |