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

Side by Side Diff: src/v8natives.js

Issue 1142393003: [strong] Implement per-object restrictions behaviour of property freezing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Object.freeze Created 5 years, 6 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var $functionSourceString; 5 var $functionSourceString;
6 var $globalEval; 6 var $globalEval;
7 var $objectGetOwnPropertyDescriptor; 7 var $objectGetOwnPropertyDescriptor;
8 var $toCompletePropertyDescriptor; 8 var $toCompletePropertyDescriptor;
9 9
10 (function(global, utils) { 10 (function(global, utils) {
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 // Step 9a 674 // Step 9a
675 if (IsDataDescriptor(current) != IsDataDescriptor(desc)) { 675 if (IsDataDescriptor(current) != IsDataDescriptor(desc)) {
676 if (should_throw) { 676 if (should_throw) {
677 throw MakeTypeError(kRedefineDisallowed, p); 677 throw MakeTypeError(kRedefineDisallowed, p);
678 } else { 678 } else {
679 return false; 679 return false;
680 } 680 }
681 } 681 }
682 // Step 10a 682 // Step 10a
683 if (IsDataDescriptor(current) && IsDataDescriptor(desc)) { 683 if (IsDataDescriptor(current) && IsDataDescriptor(desc)) {
684 if (!current.isWritable() && desc.isWritable()) { 684 var currentIsWritable = current.isWritable();
685 if (should_throw) { 685 if (currentIsWritable != desc.isWritable()) {
686 throw MakeTypeError(kRedefineDisallowed, p); 686 if (!currentIsWritable || IS_STRONG(obj)) {
687 } else { 687 if (should_throw) {
688 return false; 688 throw currentIsWritable
689 ? MakeTypeError(kStrongRedefineDisallowed, obj, p)
690 : MakeTypeError(kRedefineDisallowed, p);
691 } else {
692 return false;
693 }
689 } 694 }
690 } 695 }
691 if (!current.isWritable() && desc.hasValue() && 696 if (!currentIsWritable && desc.hasValue() &&
692 !$sameValue(desc.getValue(), current.getValue())) { 697 !$sameValue(desc.getValue(), current.getValue())) {
693 if (should_throw) { 698 if (should_throw) {
694 throw MakeTypeError(kRedefineDisallowed, p); 699 throw MakeTypeError(kRedefineDisallowed, p);
695 } else { 700 } else {
696 return false; 701 return false;
697 } 702 }
698 } 703 }
699 } 704 }
700 // Step 11 705 // Step 11
701 if (IsAccessorDescriptor(desc) && IsAccessorDescriptor(current)) { 706 if (IsAccessorDescriptor(desc) && IsAccessorDescriptor(current)) {
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 %ObjectSeal(obj); 1209 %ObjectSeal(obj);
1205 } 1210 }
1206 return obj; 1211 return obj;
1207 } 1212 }
1208 1213
1209 1214
1210 // ES5 section 15.2.3.9. 1215 // ES5 section 15.2.3.9.
1211 function ObjectFreezeJS(obj) { 1216 function ObjectFreezeJS(obj) {
1212 if (!IS_SPEC_OBJECT(obj)) return obj; 1217 if (!IS_SPEC_OBJECT(obj)) return obj;
1213 var isProxy = %_IsJSProxy(obj); 1218 var isProxy = %_IsJSProxy(obj);
1214 if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj)) { 1219 if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj) ||
1220 IS_STRONG(obj)) {
1215 if (isProxy) { 1221 if (isProxy) {
1216 ProxyFix(obj); 1222 ProxyFix(obj);
1217 } 1223 }
1218 var names = ObjectGetOwnPropertyNames(obj); 1224 var names = ObjectGetOwnPropertyNames(obj);
1219 for (var i = 0; i < names.length; i++) { 1225 for (var i = 0; i < names.length; i++) {
1220 var name = names[i]; 1226 var name = names[i];
1221 var desc = GetOwnPropertyJS(obj, name); 1227 var desc = GetOwnPropertyJS(obj, name);
1222 if (desc.isWritable() || desc.isConfigurable()) { 1228 if (desc.isWritable() || desc.isConfigurable()) {
1223 if (IsDataDescriptor(desc)) desc.setWritable(false); 1229 if (IsDataDescriptor(desc)) desc.setWritable(false);
1224 desc.setConfigurable(false); 1230 desc.setConfigurable(false);
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 to.ObjectGetOwnPropertyKeys = ObjectGetOwnPropertyKeys; 1850 to.ObjectGetOwnPropertyKeys = ObjectGetOwnPropertyKeys;
1845 to.ObjectHasOwnProperty = ObjectHasOwnProperty; 1851 to.ObjectHasOwnProperty = ObjectHasOwnProperty;
1846 to.ObjectIsFrozen = ObjectIsFrozen; 1852 to.ObjectIsFrozen = ObjectIsFrozen;
1847 to.ObjectIsSealed = ObjectIsSealed; 1853 to.ObjectIsSealed = ObjectIsSealed;
1848 to.ObjectToString = ObjectToString; 1854 to.ObjectToString = ObjectToString;
1849 to.OwnPropertyKeys = OwnPropertyKeys; 1855 to.OwnPropertyKeys = OwnPropertyKeys;
1850 to.ToNameArray = ToNameArray; 1856 to.ToNameArray = ToNameArray;
1851 }); 1857 });
1852 1858
1853 }) 1859 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698