Reviewers: rossberg,
Description:
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).
Please review this at https://codereview.chromium.org/12340008/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/v8natives.js
Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index
3978e88685156e69ec1660f1ea76d2f8b845b3b9..2225c628e9a8198af33b556b563d5ba054c26c94
100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -1240,16 +1240,16 @@ function ObjectIsSealed(obj) {
if (%IsJSProxy(obj)) {
return false;
}
+ if (ObjectIsExtensible(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;
}
@@ -1261,6 +1261,9 @@ function ObjectIsFrozen(obj) {
if (%IsJSProxy(obj)) {
return false;
}
+ if (ObjectIsExtensible(obj)) {
+ return false;
+ }
var names = ObjectGetOwnPropertyNames(obj);
for (var i = 0; i < names.length; i++) {
var name = names[i];
@@ -1268,10 +1271,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;
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.