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

Side by Side Diff: src/v8natives.js

Issue 15681004: Revert "Make Object.freeze fast" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 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 | « src/runtime.cc ('k') | test/mjsunit/object-freeze.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 // 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 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 %PreventExtensions(obj); 1218 %PreventExtensions(obj);
1219 return obj; 1219 return obj;
1220 } 1220 }
1221 1221
1222 1222
1223 // ES5 section 15.2.3.9. 1223 // ES5 section 15.2.3.9.
1224 function ObjectFreeze(obj) { 1224 function ObjectFreeze(obj) {
1225 if (!IS_SPEC_OBJECT(obj)) { 1225 if (!IS_SPEC_OBJECT(obj)) {
1226 throw MakeTypeError("called_on_non_object", ["Object.freeze"]); 1226 throw MakeTypeError("called_on_non_object", ["Object.freeze"]);
1227 } 1227 }
1228 var isProxy = %IsJSProxy(obj); 1228 if (%IsJSProxy(obj)) {
1229 if (isProxy || %HasNonStrictArgumentsElements(obj)) { 1229 ProxyFix(obj);
1230 if (isProxy) { 1230 }
1231 ProxyFix(obj); 1231 var names = ObjectGetOwnPropertyNames(obj);
1232 for (var i = 0; i < names.length; i++) {
1233 var name = names[i];
1234 var desc = GetOwnProperty(obj, name);
1235 if (desc.isWritable() || desc.isConfigurable()) {
1236 if (IsDataDescriptor(desc)) desc.setWritable(false);
1237 desc.setConfigurable(false);
1238 DefineOwnProperty(obj, name, desc, true);
1232 } 1239 }
1233 var names = ObjectGetOwnPropertyNames(obj);
1234 for (var i = 0; i < names.length; i++) {
1235 var name = names[i];
1236 var desc = GetOwnProperty(obj, name);
1237 if (desc.isWritable() || desc.isConfigurable()) {
1238 if (IsDataDescriptor(desc)) desc.setWritable(false);
1239 desc.setConfigurable(false);
1240 DefineOwnProperty(obj, name, desc, true);
1241 }
1242 }
1243 %PreventExtensions(obj);
1244 } else {
1245 // TODO(adamk): Is it worth going to this fast path if the
1246 // object's properties are already in dictionary mode?
1247 %ObjectFreeze(obj);
1248 } 1240 }
1241 %PreventExtensions(obj);
1249 return obj; 1242 return obj;
1250 } 1243 }
1251 1244
1252 1245
1253 // ES5 section 15.2.3.10 1246 // ES5 section 15.2.3.10
1254 function ObjectPreventExtension(obj) { 1247 function ObjectPreventExtension(obj) {
1255 if (!IS_SPEC_OBJECT(obj)) { 1248 if (!IS_SPEC_OBJECT(obj)) {
1256 throw MakeTypeError("called_on_non_object", ["Object.preventExtension"]); 1249 throw MakeTypeError("called_on_non_object", ["Object.preventExtension"]);
1257 } 1250 }
1258 if (%IsJSProxy(obj)) { 1251 if (%IsJSProxy(obj)) {
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 %SetCode($Function, NewFunction); 1794 %SetCode($Function, NewFunction);
1802 %SetProperty($Function.prototype, "constructor", $Function, DONT_ENUM); 1795 %SetProperty($Function.prototype, "constructor", $Function, DONT_ENUM);
1803 1796
1804 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1797 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1805 "bind", FunctionBind, 1798 "bind", FunctionBind,
1806 "toString", FunctionToString 1799 "toString", FunctionToString
1807 )); 1800 ));
1808 } 1801 }
1809 1802
1810 SetUpFunction(); 1803 SetUpFunction();
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/object-freeze.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698