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

Side by Side Diff: src/v8natives.js

Issue 12340008: Move extensibility check to the top of Object.isFrozen/Object.isSealed (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Call %IsExtensible directly Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 1233
1234 1234
1235 // ES5 section 15.2.3.11 1235 // ES5 section 15.2.3.11
1236 function ObjectIsSealed(obj) { 1236 function ObjectIsSealed(obj) {
1237 if (!IS_SPEC_OBJECT(obj)) { 1237 if (!IS_SPEC_OBJECT(obj)) {
1238 throw MakeTypeError("called_on_non_object", ["Object.isSealed"]); 1238 throw MakeTypeError("called_on_non_object", ["Object.isSealed"]);
1239 } 1239 }
1240 if (%IsJSProxy(obj)) { 1240 if (%IsJSProxy(obj)) {
1241 return false; 1241 return false;
1242 } 1242 }
1243 if (%IsExtensible(obj)) {
1244 return false;
1245 }
1243 var names = ObjectGetOwnPropertyNames(obj); 1246 var names = ObjectGetOwnPropertyNames(obj);
1244 for (var i = 0; i < names.length; i++) { 1247 for (var i = 0; i < names.length; i++) {
1245 var name = names[i]; 1248 var name = names[i];
1246 var desc = GetOwnProperty(obj, name); 1249 var desc = GetOwnProperty(obj, name);
1247 if (desc.isConfigurable()) return false; 1250 if (desc.isConfigurable()) return false;
1248 } 1251 }
1249 if (!ObjectIsExtensible(obj)) { 1252 return true;
1250 return true;
1251 }
1252 return false;
1253 } 1253 }
1254 1254
1255 1255
1256 // ES5 section 15.2.3.12 1256 // ES5 section 15.2.3.12
1257 function ObjectIsFrozen(obj) { 1257 function ObjectIsFrozen(obj) {
1258 if (!IS_SPEC_OBJECT(obj)) { 1258 if (!IS_SPEC_OBJECT(obj)) {
1259 throw MakeTypeError("called_on_non_object", ["Object.isFrozen"]); 1259 throw MakeTypeError("called_on_non_object", ["Object.isFrozen"]);
1260 } 1260 }
1261 if (%IsJSProxy(obj)) { 1261 if (%IsJSProxy(obj)) {
1262 return false; 1262 return false;
1263 } 1263 }
1264 if (%IsExtensible(obj)) {
1265 return false;
1266 }
1264 var names = ObjectGetOwnPropertyNames(obj); 1267 var names = ObjectGetOwnPropertyNames(obj);
1265 for (var i = 0; i < names.length; i++) { 1268 for (var i = 0; i < names.length; i++) {
1266 var name = names[i]; 1269 var name = names[i];
1267 var desc = GetOwnProperty(obj, name); 1270 var desc = GetOwnProperty(obj, name);
1268 if (IsDataDescriptor(desc) && desc.isWritable()) return false; 1271 if (IsDataDescriptor(desc) && desc.isWritable()) return false;
1269 if (desc.isConfigurable()) return false; 1272 if (desc.isConfigurable()) return false;
1270 } 1273 }
1271 if (!ObjectIsExtensible(obj)) { 1274 return true;
1272 return true;
1273 }
1274 return false;
1275 } 1275 }
1276 1276
1277 1277
1278 // ES5 section 15.2.3.13 1278 // ES5 section 15.2.3.13
1279 function ObjectIsExtensible(obj) { 1279 function ObjectIsExtensible(obj) {
1280 if (!IS_SPEC_OBJECT(obj)) { 1280 if (!IS_SPEC_OBJECT(obj)) {
1281 throw MakeTypeError("called_on_non_object", ["Object.isExtensible"]); 1281 throw MakeTypeError("called_on_non_object", ["Object.isExtensible"]);
1282 } 1282 }
1283 if (%IsJSProxy(obj)) { 1283 if (%IsJSProxy(obj)) {
1284 return true; 1284 return true;
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
1718 1718
1719 function SetUpFunction() { 1719 function SetUpFunction() {
1720 %CheckIsBootstrapping(); 1720 %CheckIsBootstrapping();
1721 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1721 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1722 "bind", FunctionBind, 1722 "bind", FunctionBind,
1723 "toString", FunctionToString 1723 "toString", FunctionToString
1724 )); 1724 ));
1725 } 1725 }
1726 1726
1727 SetUpFunction(); 1727 SetUpFunction();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698