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

Side by Side Diff: src/js/v8natives.js

Issue 1393373005: Take Symbol-keyed properties into account in Object.freeze and friends (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Assert more things Created 5 years, 2 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
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-539875.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 // 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 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 1133
1134 1134
1135 // ES5 section 15.2.3.8. 1135 // ES5 section 15.2.3.8.
1136 function ObjectSealJS(obj) { 1136 function ObjectSealJS(obj) {
1137 if (!IS_SPEC_OBJECT(obj)) return obj; 1137 if (!IS_SPEC_OBJECT(obj)) return obj;
1138 var isProxy = %_IsJSProxy(obj); 1138 var isProxy = %_IsJSProxy(obj);
1139 if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj)) { 1139 if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj)) {
1140 if (isProxy) { 1140 if (isProxy) {
1141 ProxyFix(obj); 1141 ProxyFix(obj);
1142 } 1142 }
1143 var names = ObjectGetOwnPropertyNames(obj); 1143 var names = OwnPropertyKeys(obj);
1144 for (var i = 0; i < names.length; i++) { 1144 for (var i = 0; i < names.length; i++) {
1145 var name = names[i]; 1145 var name = names[i];
1146 var desc = GetOwnPropertyJS(obj, name); 1146 var desc = GetOwnPropertyJS(obj, name);
1147 if (desc.isConfigurable()) { 1147 if (desc.isConfigurable()) {
1148 desc.setConfigurable(false); 1148 desc.setConfigurable(false);
1149 DefineOwnProperty(obj, name, desc, true); 1149 DefineOwnProperty(obj, name, desc, true);
1150 } 1150 }
1151 } 1151 }
1152 %PreventExtensions(obj); 1152 %PreventExtensions(obj);
1153 } else { 1153 } else {
1154 // TODO(adamk): Is it worth going to this fast path if the 1154 // TODO(adamk): Is it worth going to this fast path if the
1155 // object's properties are already in dictionary mode? 1155 // object's properties are already in dictionary mode?
1156 %ObjectSeal(obj); 1156 %ObjectSeal(obj);
1157 } 1157 }
1158 return obj; 1158 return obj;
1159 } 1159 }
1160 1160
1161 1161
1162 // ES5 section 15.2.3.9. 1162 // ES5 section 15.2.3.9.
1163 function ObjectFreezeJS(obj) { 1163 function ObjectFreezeJS(obj) {
1164 if (!IS_SPEC_OBJECT(obj)) return obj; 1164 if (!IS_SPEC_OBJECT(obj)) return obj;
1165 var isProxy = %_IsJSProxy(obj); 1165 var isProxy = %_IsJSProxy(obj);
1166 // TODO(conradw): Investigate modifying the fast path to accommodate strong 1166 // TODO(conradw): Investigate modifying the fast path to accommodate strong
1167 // objects. 1167 // objects.
1168 if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj) || 1168 if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj) ||
1169 IS_STRONG(obj)) { 1169 IS_STRONG(obj)) {
1170 if (isProxy) { 1170 if (isProxy) {
1171 ProxyFix(obj); 1171 ProxyFix(obj);
1172 } 1172 }
1173 var names = ObjectGetOwnPropertyNames(obj); 1173 var names = OwnPropertyKeys(obj);
1174 for (var i = 0; i < names.length; i++) { 1174 for (var i = 0; i < names.length; i++) {
1175 var name = names[i]; 1175 var name = names[i];
1176 var desc = GetOwnPropertyJS(obj, name); 1176 var desc = GetOwnPropertyJS(obj, name);
1177 if (desc.isWritable() || desc.isConfigurable()) { 1177 if (desc.isWritable() || desc.isConfigurable()) {
1178 if (IsDataDescriptor(desc)) desc.setWritable(false); 1178 if (IsDataDescriptor(desc)) desc.setWritable(false);
1179 desc.setConfigurable(false); 1179 desc.setConfigurable(false);
1180 DefineOwnProperty(obj, name, desc, true); 1180 DefineOwnProperty(obj, name, desc, true);
1181 } 1181 }
1182 } 1182 }
1183 %PreventExtensions(obj); 1183 %PreventExtensions(obj);
(...skipping 19 matching lines...) Expand all
1203 1203
1204 // ES5 section 15.2.3.11 1204 // ES5 section 15.2.3.11
1205 function ObjectIsSealed(obj) { 1205 function ObjectIsSealed(obj) {
1206 if (!IS_SPEC_OBJECT(obj)) return true; 1206 if (!IS_SPEC_OBJECT(obj)) return true;
1207 if (%_IsJSProxy(obj)) { 1207 if (%_IsJSProxy(obj)) {
1208 return false; 1208 return false;
1209 } 1209 }
1210 if (%IsExtensible(obj)) { 1210 if (%IsExtensible(obj)) {
1211 return false; 1211 return false;
1212 } 1212 }
1213 var names = ObjectGetOwnPropertyNames(obj); 1213 var names = OwnPropertyKeys(obj);
1214 for (var i = 0; i < names.length; i++) { 1214 for (var i = 0; i < names.length; i++) {
1215 var name = names[i]; 1215 var name = names[i];
1216 var desc = GetOwnPropertyJS(obj, name); 1216 var desc = GetOwnPropertyJS(obj, name);
1217 if (desc.isConfigurable()) { 1217 if (desc.isConfigurable()) {
1218 return false; 1218 return false;
1219 } 1219 }
1220 } 1220 }
1221 return true; 1221 return true;
1222 } 1222 }
1223 1223
1224 1224
1225 // ES5 section 15.2.3.12 1225 // ES5 section 15.2.3.12
1226 function ObjectIsFrozen(obj) { 1226 function ObjectIsFrozen(obj) {
1227 if (!IS_SPEC_OBJECT(obj)) return true; 1227 if (!IS_SPEC_OBJECT(obj)) return true;
1228 if (%_IsJSProxy(obj)) { 1228 if (%_IsJSProxy(obj)) {
1229 return false; 1229 return false;
1230 } 1230 }
1231 if (%IsExtensible(obj)) { 1231 if (%IsExtensible(obj)) {
1232 return false; 1232 return false;
1233 } 1233 }
1234 var names = ObjectGetOwnPropertyNames(obj); 1234 var names = OwnPropertyKeys(obj);
1235 for (var i = 0; i < names.length; i++) { 1235 for (var i = 0; i < names.length; i++) {
1236 var name = names[i]; 1236 var name = names[i];
1237 var desc = GetOwnPropertyJS(obj, name); 1237 var desc = GetOwnPropertyJS(obj, name);
1238 if (IsDataDescriptor(desc) && desc.isWritable()) return false; 1238 if (IsDataDescriptor(desc) && desc.isWritable()) return false;
1239 if (desc.isConfigurable()) return false; 1239 if (desc.isConfigurable()) return false;
1240 } 1240 }
1241 return true; 1241 return true;
1242 } 1242 }
1243 1243
1244 1244
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 %InstallToContext([ 1841 %InstallToContext([
1842 "global_eval_fun", GlobalEval, 1842 "global_eval_fun", GlobalEval,
1843 "object_value_of", ObjectValueOf, 1843 "object_value_of", ObjectValueOf,
1844 "object_to_string", ObjectToString, 1844 "object_to_string", ObjectToString,
1845 "object_define_own_property", DefineOwnPropertyFromAPI, 1845 "object_define_own_property", DefineOwnPropertyFromAPI,
1846 "object_get_own_property_descriptor", ObjectGetOwnPropertyDescriptor, 1846 "object_get_own_property_descriptor", ObjectGetOwnPropertyDescriptor,
1847 "to_complete_property_descriptor", ToCompletePropertyDescriptor, 1847 "to_complete_property_descriptor", ToCompletePropertyDescriptor,
1848 ]); 1848 ]);
1849 1849
1850 }) 1850 })
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-539875.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698