OLD | NEW |
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 $objectDefineArrayProperty; | 7 var $objectDefineArrayProperty; |
8 var $objectGetOwnPropertyDescriptor; | 8 var $objectGetOwnPropertyDescriptor; |
9 var $toCompletePropertyDescriptor; | 9 var $toCompletePropertyDescriptor; |
10 | 10 |
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 // Step 9a | 675 // Step 9a |
676 if (IsDataDescriptor(current) != IsDataDescriptor(desc)) { | 676 if (IsDataDescriptor(current) != IsDataDescriptor(desc)) { |
677 if (should_throw) { | 677 if (should_throw) { |
678 throw MakeTypeError(kRedefineDisallowed, p); | 678 throw MakeTypeError(kRedefineDisallowed, p); |
679 } else { | 679 } else { |
680 return false; | 680 return false; |
681 } | 681 } |
682 } | 682 } |
683 // Step 10a | 683 // Step 10a |
684 if (IsDataDescriptor(current) && IsDataDescriptor(desc)) { | 684 if (IsDataDescriptor(current) && IsDataDescriptor(desc)) { |
685 if (!current.isWritable() && desc.isWritable()) { | 685 var currentIsWritable = current.isWritable(); |
686 if (should_throw) { | 686 if (currentIsWritable != desc.isWritable()) { |
687 throw MakeTypeError(kRedefineDisallowed, p); | 687 if (!currentIsWritable || IS_STRONG(obj)) { |
688 } else { | 688 if (should_throw) { |
689 return false; | 689 throw currentIsWritable |
| 690 ? MakeTypeError(kStrongRedefineDisallowed, obj, p) |
| 691 : MakeTypeError(kRedefineDisallowed, p); |
| 692 } else { |
| 693 return false; |
| 694 } |
690 } | 695 } |
691 } | 696 } |
692 if (!current.isWritable() && desc.hasValue() && | 697 if (!currentIsWritable && desc.hasValue() && |
693 !$sameValue(desc.getValue(), current.getValue())) { | 698 !$sameValue(desc.getValue(), current.getValue())) { |
694 if (should_throw) { | 699 if (should_throw) { |
695 throw MakeTypeError(kRedefineDisallowed, p); | 700 throw MakeTypeError(kRedefineDisallowed, p); |
696 } else { | 701 } else { |
697 return false; | 702 return false; |
698 } | 703 } |
699 } | 704 } |
700 } | 705 } |
701 // Step 11 | 706 // Step 11 |
702 if (IsAccessorDescriptor(desc) && IsAccessorDescriptor(current)) { | 707 if (IsAccessorDescriptor(desc) && IsAccessorDescriptor(current)) { |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 %ObjectSeal(obj); | 1221 %ObjectSeal(obj); |
1217 } | 1222 } |
1218 return obj; | 1223 return obj; |
1219 } | 1224 } |
1220 | 1225 |
1221 | 1226 |
1222 // ES5 section 15.2.3.9. | 1227 // ES5 section 15.2.3.9. |
1223 function ObjectFreezeJS(obj) { | 1228 function ObjectFreezeJS(obj) { |
1224 if (!IS_SPEC_OBJECT(obj)) return obj; | 1229 if (!IS_SPEC_OBJECT(obj)) return obj; |
1225 var isProxy = %_IsJSProxy(obj); | 1230 var isProxy = %_IsJSProxy(obj); |
1226 if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj)) { | 1231 // TODO(conradw): Investigate modifying the fast path to accommodate strong |
| 1232 // objects. |
| 1233 if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj) || |
| 1234 IS_STRONG(obj)) { |
1227 if (isProxy) { | 1235 if (isProxy) { |
1228 ProxyFix(obj); | 1236 ProxyFix(obj); |
1229 } | 1237 } |
1230 var names = ObjectGetOwnPropertyNames(obj); | 1238 var names = ObjectGetOwnPropertyNames(obj); |
1231 for (var i = 0; i < names.length; i++) { | 1239 for (var i = 0; i < names.length; i++) { |
1232 var name = names[i]; | 1240 var name = names[i]; |
1233 var desc = GetOwnPropertyJS(obj, name); | 1241 var desc = GetOwnPropertyJS(obj, name); |
1234 if (desc.isWritable() || desc.isConfigurable()) { | 1242 if (desc.isWritable() || desc.isConfigurable()) { |
1235 if (IsDataDescriptor(desc)) desc.setWritable(false); | 1243 if (IsDataDescriptor(desc)) desc.setWritable(false); |
1236 desc.setConfigurable(false); | 1244 desc.setConfigurable(false); |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1857 to.ObjectGetOwnPropertyKeys = ObjectGetOwnPropertyKeys; | 1865 to.ObjectGetOwnPropertyKeys = ObjectGetOwnPropertyKeys; |
1858 to.ObjectHasOwnProperty = ObjectHasOwnProperty; | 1866 to.ObjectHasOwnProperty = ObjectHasOwnProperty; |
1859 to.ObjectIsFrozen = ObjectIsFrozen; | 1867 to.ObjectIsFrozen = ObjectIsFrozen; |
1860 to.ObjectIsSealed = ObjectIsSealed; | 1868 to.ObjectIsSealed = ObjectIsSealed; |
1861 to.ObjectToString = ObjectToString; | 1869 to.ObjectToString = ObjectToString; |
1862 to.OwnPropertyKeys = OwnPropertyKeys; | 1870 to.OwnPropertyKeys = OwnPropertyKeys; |
1863 to.ToNameArray = ToNameArray; | 1871 to.ToNameArray = ToNameArray; |
1864 }); | 1872 }); |
1865 | 1873 |
1866 }) | 1874 }) |
OLD | NEW |