Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: src/array.js

Issue 237253002: Fix bogus Object.isSealed check in some Array builtins. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-builtinbust-4.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 return new_length; 456 return new_length;
457 } 457 }
458 458
459 // 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
460 // 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.
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 if (m > 0 && ObjectIsSealed(this)) {
467 throw MakeTypeError("array_functions_change_sealed",
468 ["Array.prototype.push"]);
469 }
470 466
471 if (%IsObserved(this)) 467 if (%IsObserved(this))
472 return ObservedArrayPush.apply(this, arguments); 468 return ObservedArrayPush.apply(this, arguments);
473 469
474 for (var i = 0; i < m; i++) { 470 for (var i = 0; i < m; i++) {
475 this[i+n] = %_Arguments(i); 471 this[i+n] = %_Arguments(i);
476 } 472 }
477 473
478 var new_length = n + m; 474 var new_length = n + m;
479 this.length = new_length; 475 this.length = new_length;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 return new_length; 638 return new_length;
643 } 639 }
644 640
645 function ArrayUnshift(arg1) { // length == 1 641 function ArrayUnshift(arg1) { // length == 1
646 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.unshift"); 642 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.unshift");
647 643
648 var len = TO_UINT32(this.length); 644 var len = TO_UINT32(this.length);
649 var num_arguments = %_ArgumentsLength(); 645 var num_arguments = %_ArgumentsLength();
650 var is_sealed = ObjectIsSealed(this); 646 var is_sealed = ObjectIsSealed(this);
651 647
652 if (num_arguments > 0 && is_sealed) {
653 throw MakeTypeError("array_functions_change_sealed",
654 ["Array.prototype.unshift"]);
655 }
656
657 if (%IsObserved(this)) 648 if (%IsObserved(this))
658 return ObservedArrayUnshift.apply(this, arguments); 649 return ObservedArrayUnshift.apply(this, arguments);
659 650
660 if (IS_ARRAY(this) && !is_sealed) { 651 if (IS_ARRAY(this) && !is_sealed) {
661 SmartMove(this, 0, 0, len, num_arguments); 652 SmartMove(this, 0, 0, len, num_arguments);
662 } else { 653 } else {
663 if (num_arguments == 0 && ObjectIsFrozen(this)) { 654 if (num_arguments == 0 && ObjectIsFrozen(this)) {
664 // In the zero argument case, values from the prototype come into the 655 // In the zero argument case, values from the prototype come into the
665 // object. This can't be allowed on frozen arrays. 656 // object. This can't be allowed on frozen arrays.
666 for (var i = 0; i < len; i++) { 657 for (var i = 0; i < len; i++) {
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 )); 1632 ));
1642 1633
1643 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( 1634 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array(
1644 "join", getFunction("join", ArrayJoin), 1635 "join", getFunction("join", ArrayJoin),
1645 "pop", getFunction("pop", ArrayPop), 1636 "pop", getFunction("pop", ArrayPop),
1646 "push", getFunction("push", ArrayPush) 1637 "push", getFunction("push", ArrayPush)
1647 )); 1638 ));
1648 } 1639 }
1649 1640
1650 SetUpArray(); 1641 SetUpArray();
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-builtinbust-4.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698