Index: src/v8natives.js |
diff --git a/src/v8natives.js b/src/v8natives.js |
index b2ea749c73030e82d4e7323ce9637f721dc593e7..f5ab122ff0aa8d2a1604f640ca97de7cb2499d1e 100644 |
--- a/src/v8natives.js |
+++ b/src/v8natives.js |
@@ -1225,20 +1225,27 @@ function ObjectFreeze(obj) { |
if (!IS_SPEC_OBJECT(obj)) { |
throw MakeTypeError("called_on_non_object", ["Object.freeze"]); |
} |
- if (%IsJSProxy(obj)) { |
- ProxyFix(obj); |
- } |
- var names = ObjectGetOwnPropertyNames(obj); |
- for (var i = 0; i < names.length; i++) { |
- var name = names[i]; |
- var desc = GetOwnProperty(obj, name); |
- if (desc.isWritable() || desc.isConfigurable()) { |
- if (IsDataDescriptor(desc)) desc.setWritable(false); |
- desc.setConfigurable(false); |
- DefineOwnProperty(obj, name, desc, true); |
+ var isProxy = %IsJSProxy(obj); |
+ if (isProxy || %HasNonStrictArgumentsElements(obj)) { |
+ if (isProxy) { |
+ ProxyFix(obj); |
} |
+ var names = ObjectGetOwnPropertyNames(obj); |
+ for (var i = 0; i < names.length; i++) { |
+ var name = names[i]; |
+ var desc = GetOwnProperty(obj, name); |
+ if (desc.isWritable() || desc.isConfigurable()) { |
+ if (IsDataDescriptor(desc)) desc.setWritable(false); |
+ desc.setConfigurable(false); |
+ DefineOwnProperty(obj, name, desc, true); |
+ } |
+ } |
+ %PreventExtensions(obj); |
+ } else { |
+ // TODO(adamk): Is it worth going to this fast path if the |
+ // object's properties are already in dictionary mode? |
+ %ObjectFreeze(obj); |
} |
- %PreventExtensions(obj); |
return obj; |
} |