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 (function(global, utils) { | 5 (function(global, utils) { |
6 | 6 |
7 %CheckIsBootstrapping(); | 7 %CheckIsBootstrapping(); |
8 | 8 |
9 // ---------------------------------------------------------------------------- | 9 // ---------------------------------------------------------------------------- |
10 // Imports | 10 // Imports |
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 } | 1044 } |
1045 return obj; | 1045 return obj; |
1046 } | 1046 } |
1047 return %ObjectDefineProperties(obj, properties); | 1047 return %ObjectDefineProperties(obj, properties); |
1048 } | 1048 } |
1049 | 1049 |
1050 | 1050 |
1051 // ES5 section 15.2.3.8. | 1051 // ES5 section 15.2.3.8. |
1052 function ObjectSealJS(obj) { | 1052 function ObjectSealJS(obj) { |
1053 if (!IS_SPEC_OBJECT(obj)) return obj; | 1053 if (!IS_SPEC_OBJECT(obj)) return obj; |
1054 var isProxy = %_IsJSProxy(obj); | 1054 return %ObjectSeal(obj); |
1055 if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj)) { | |
1056 // TODO(neis): For proxies, must call preventExtensions trap first. | |
1057 var names = OwnPropertyKeys(obj); | |
1058 for (var i = 0; i < names.length; i++) { | |
1059 var name = names[i]; | |
1060 var desc = GetOwnPropertyJS(obj, name); | |
1061 if (desc.isConfigurable()) { | |
1062 desc.setConfigurable(false); | |
1063 DefineOwnProperty(obj, name, desc, true); | |
1064 } | |
1065 } | |
1066 %PreventExtensions(obj); | |
1067 } else { | |
1068 // TODO(adamk): Is it worth going to this fast path if the | |
1069 // object's properties are already in dictionary mode? | |
1070 %ObjectSeal(obj); | |
1071 } | |
1072 return obj; | |
1073 } | 1055 } |
1074 | 1056 |
1075 | 1057 |
1076 // ES5 section 15.2.3.9. | 1058 // ES5 section 15.2.3.9. |
1077 function ObjectFreezeJS(obj) { | 1059 function ObjectFreezeJS(obj) { |
1078 if (!IS_SPEC_OBJECT(obj)) return obj; | 1060 if (!IS_SPEC_OBJECT(obj)) return obj; |
1079 var isProxy = %_IsJSProxy(obj); | 1061 return %ObjectFreeze(obj); |
1080 // TODO(conradw): Investigate modifying the fast path to accommodate strong | |
1081 // objects. | |
1082 if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj) || | |
1083 IS_STRONG(obj)) { | |
1084 // TODO(neis): For proxies, must call preventExtensions trap first. | |
1085 var names = OwnPropertyKeys(obj); | |
1086 for (var i = 0; i < names.length; i++) { | |
1087 var name = names[i]; | |
1088 var desc = GetOwnPropertyJS(obj, name); | |
1089 if (desc.isWritable() || desc.isConfigurable()) { | |
1090 if (IsDataDescriptor(desc)) desc.setWritable(false); | |
1091 desc.setConfigurable(false); | |
1092 DefineOwnProperty(obj, name, desc, true); | |
1093 } | |
1094 } | |
1095 %PreventExtensions(obj); | |
1096 } else { | |
1097 // TODO(adamk): Is it worth going to this fast path if the | |
1098 // object's properties are already in dictionary mode? | |
1099 %ObjectFreeze(obj); | |
1100 } | |
1101 return obj; | |
1102 } | 1062 } |
1103 | 1063 |
1104 | 1064 |
1105 // ES5 section 15.2.3.10 | 1065 // ES5 section 15.2.3.10 |
1106 function ObjectPreventExtension(obj) { | 1066 function ObjectPreventExtension(obj) { |
1107 if (!IS_SPEC_OBJECT(obj)) return obj; | 1067 if (!IS_SPEC_OBJECT(obj)) return obj; |
1108 return %PreventExtensions(obj); | 1068 return %PreventExtensions(obj); |
1109 } | 1069 } |
1110 | 1070 |
1111 | 1071 |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1736 | 1696 |
1737 %InstallToContext([ | 1697 %InstallToContext([ |
1738 "global_eval_fun", GlobalEval, | 1698 "global_eval_fun", GlobalEval, |
1739 "object_value_of", ObjectValueOf, | 1699 "object_value_of", ObjectValueOf, |
1740 "object_to_string", ObjectToString, | 1700 "object_to_string", ObjectToString, |
1741 "object_get_own_property_descriptor", ObjectGetOwnPropertyDescriptor, | 1701 "object_get_own_property_descriptor", ObjectGetOwnPropertyDescriptor, |
1742 "to_complete_property_descriptor", ToCompletePropertyDescriptor, | 1702 "to_complete_property_descriptor", ToCompletePropertyDescriptor, |
1743 ]); | 1703 ]); |
1744 | 1704 |
1745 }) | 1705 }) |
OLD | NEW |