Commit 8f407c7b authored by adamk@chromium.org's avatar adamk@chromium.org

Move extensibility check to the top of Object.isFrozen/Object.isSealed

This speeds up isFrozen/isSealed checks on "normal" objects without
slowing down checks on frozen/sealed objects.

Though this ordering is not what ES5 specifies, the difference is not
observable (especially since the code bails out if the passed-in object
is a proxy).

Review URL: https://codereview.chromium.org/12340008

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13726 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 30a4a798
......@@ -1246,16 +1246,16 @@ function ObjectIsSealed(obj) {
if (%IsJSProxy(obj)) {
return false;
}
if (%IsExtensible(obj)) {
return false;
}
var names = ObjectGetOwnPropertyNames(obj);
for (var i = 0; i < names.length; i++) {
var name = names[i];
var desc = GetOwnProperty(obj, name);
if (desc.isConfigurable()) return false;
}
if (!ObjectIsExtensible(obj)) {
return true;
}
return false;
return true;
}
......@@ -1267,6 +1267,9 @@ function ObjectIsFrozen(obj) {
if (%IsJSProxy(obj)) {
return false;
}
if (%IsExtensible(obj)) {
return false;
}
var names = ObjectGetOwnPropertyNames(obj);
for (var i = 0; i < names.length; i++) {
var name = names[i];
......@@ -1274,10 +1277,7 @@ function ObjectIsFrozen(obj) {
if (IsDataDescriptor(desc) && desc.isWritable()) return false;
if (desc.isConfigurable()) return false;
}
if (!ObjectIsExtensible(obj)) {
return true;
}
return false;
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment