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 // This file relies on the fact that the following declarations have been made | 5 // This file relies on the fact that the following declarations have been made |
6 // in runtime.js: | 6 // in runtime.js: |
7 // var $Object = global.Object; | 7 // var $Object = global.Object; |
8 // var $Boolean = global.Boolean; | 8 // var $Boolean = global.Boolean; |
9 // var $Number = global.Number; | 9 // var $Number = global.Number; |
10 // var $Function = global.Function; | 10 // var $Function = global.Function; |
(...skipping 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 %FunctionSetPrototype(obj, prototype); | 1235 %FunctionSetPrototype(obj, prototype); |
1236 obj.length = 0; | 1236 obj.length = 0; |
1237 } else { | 1237 } else { |
1238 %Fix(obj); | 1238 %Fix(obj); |
1239 } | 1239 } |
1240 ObjectDefineProperties(obj, props); | 1240 ObjectDefineProperties(obj, props); |
1241 } | 1241 } |
1242 | 1242 |
1243 | 1243 |
1244 // ES5 section 15.2.3.8. | 1244 // ES5 section 15.2.3.8. |
1245 function ObjectSeal(obj) { | 1245 function ObjectSealJS(obj) { |
1246 if (!IS_SPEC_OBJECT(obj)) { | 1246 if (!IS_SPEC_OBJECT(obj)) { |
1247 throw MakeTypeError("called_on_non_object", ["Object.seal"]); | 1247 throw MakeTypeError("called_on_non_object", ["Object.seal"]); |
1248 } | 1248 } |
1249 if (%_IsJSProxy(obj)) { | 1249 var isProxy = %_IsJSProxy(obj); |
1250 ProxyFix(obj); | 1250 if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj)) { |
| 1251 if (isProxy) { |
| 1252 ProxyFix(obj); |
| 1253 } |
| 1254 var names = ObjectGetOwnPropertyNames(obj); |
| 1255 for (var i = 0; i < names.length; i++) { |
| 1256 var name = names[i]; |
| 1257 var desc = GetOwnPropertyJS(obj, name); |
| 1258 if (desc.isConfigurable()) { |
| 1259 desc.setConfigurable(false); |
| 1260 DefineOwnProperty(obj, name, desc, true); |
| 1261 } |
| 1262 } |
| 1263 %PreventExtensions(obj); |
| 1264 } else { |
| 1265 // TODO(adamk): Is it worth going to this fast path if the |
| 1266 // object's properties are already in dictionary mode? |
| 1267 %ObjectSeal(obj); |
1251 } | 1268 } |
1252 var names = ObjectGetOwnPropertyNames(obj); | |
1253 for (var i = 0; i < names.length; i++) { | |
1254 var name = names[i]; | |
1255 var desc = GetOwnPropertyJS(obj, name); | |
1256 if (desc.isConfigurable()) { | |
1257 desc.setConfigurable(false); | |
1258 DefineOwnProperty(obj, name, desc, true); | |
1259 } | |
1260 } | |
1261 %PreventExtensions(obj); | |
1262 return obj; | 1269 return obj; |
1263 } | 1270 } |
1264 | 1271 |
1265 | 1272 |
1266 // ES5 section 15.2.3.9. | 1273 // ES5 section 15.2.3.9. |
1267 function ObjectFreezeJS(obj) { | 1274 function ObjectFreezeJS(obj) { |
1268 if (!IS_SPEC_OBJECT(obj)) { | 1275 if (!IS_SPEC_OBJECT(obj)) { |
1269 throw MakeTypeError("called_on_non_object", ["Object.freeze"]); | 1276 throw MakeTypeError("called_on_non_object", ["Object.freeze"]); |
1270 } | 1277 } |
1271 var isProxy = %_IsJSProxy(obj); | 1278 var isProxy = %_IsJSProxy(obj); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1433 "getPrototypeOf", ObjectGetPrototypeOf, | 1440 "getPrototypeOf", ObjectGetPrototypeOf, |
1434 "setPrototypeOf", ObjectSetPrototypeOf, | 1441 "setPrototypeOf", ObjectSetPrototypeOf, |
1435 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, | 1442 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, |
1436 "getOwnPropertyNames", ObjectGetOwnPropertyNames, | 1443 "getOwnPropertyNames", ObjectGetOwnPropertyNames, |
1437 // getOwnPropertySymbols is added in symbol.js. | 1444 // getOwnPropertySymbols is added in symbol.js. |
1438 "is", ObjectIs, | 1445 "is", ObjectIs, |
1439 "isExtensible", ObjectIsExtensible, | 1446 "isExtensible", ObjectIsExtensible, |
1440 "isFrozen", ObjectIsFrozen, | 1447 "isFrozen", ObjectIsFrozen, |
1441 "isSealed", ObjectIsSealed, | 1448 "isSealed", ObjectIsSealed, |
1442 "preventExtensions", ObjectPreventExtension, | 1449 "preventExtensions", ObjectPreventExtension, |
1443 "seal", ObjectSeal | 1450 "seal", ObjectSealJS |
1444 // deliverChangeRecords, getNotifier, observe and unobserve are added | 1451 // deliverChangeRecords, getNotifier, observe and unobserve are added |
1445 // in object-observe.js. | 1452 // in object-observe.js. |
1446 )); | 1453 )); |
1447 } | 1454 } |
1448 | 1455 |
1449 SetUpObject(); | 1456 SetUpObject(); |
1450 | 1457 |
1451 | 1458 |
1452 // ---------------------------------------------------------------------------- | 1459 // ---------------------------------------------------------------------------- |
1453 // Boolean | 1460 // Boolean |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1900 } | 1907 } |
1901 if (!IS_SPEC_FUNCTION(method)) { | 1908 if (!IS_SPEC_FUNCTION(method)) { |
1902 throw MakeTypeError('not_iterable', [obj]); | 1909 throw MakeTypeError('not_iterable', [obj]); |
1903 } | 1910 } |
1904 var iterator = %_CallFunction(obj, method); | 1911 var iterator = %_CallFunction(obj, method); |
1905 if (!IS_SPEC_OBJECT(iterator)) { | 1912 if (!IS_SPEC_OBJECT(iterator)) { |
1906 throw MakeTypeError('not_an_iterator', [iterator]); | 1913 throw MakeTypeError('not_an_iterator', [iterator]); |
1907 } | 1914 } |
1908 return iterator; | 1915 return iterator; |
1909 } | 1916 } |
OLD | NEW |