Index: src/js/v8natives.js |
diff --git a/src/js/v8natives.js b/src/js/v8natives.js |
index e6ade90a3fdc886407e520bd7d157e06a9a92196..30fde7f809294041dd0f1ac61ac161e98a2100d4 100644 |
--- a/src/js/v8natives.js |
+++ b/src/js/v8natives.js |
@@ -926,109 +926,42 @@ function ObjectDefineProperties(obj, properties) { |
} |
-// ES5 section 15.2.3.8. |
+// ES6 19.1.2.17 |
function ObjectSealJS(obj) { |
if (!IS_SPEC_OBJECT(obj)) return obj; |
- var isProxy = %_IsJSProxy(obj); |
- if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj)) { |
- // TODO(neis): For proxies, must call preventExtensions trap first. |
- var names = OwnPropertyKeys(obj); |
- for (var i = 0; i < names.length; i++) { |
- var name = names[i]; |
- var desc = GetOwnPropertyJS(obj, name); |
- if (desc.isConfigurable()) { |
- 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? |
- %ObjectSeal(obj); |
- } |
- return obj; |
+ return %ObjectSeal(obj); |
} |
-// ES5 section 15.2.3.9. |
+// ES6 19.1.2.5 |
function ObjectFreezeJS(obj) { |
if (!IS_SPEC_OBJECT(obj)) return obj; |
- var isProxy = %_IsJSProxy(obj); |
- // TODO(conradw): Investigate modifying the fast path to accommodate strong |
- // objects. |
- if (isProxy || %HasSloppyArgumentsElements(obj) || %IsObserved(obj) || |
- IS_STRONG(obj)) { |
- // TODO(neis): For proxies, must call preventExtensions trap first. |
- var names = OwnPropertyKeys(obj); |
- for (var i = 0; i < names.length; i++) { |
- var name = names[i]; |
- var desc = GetOwnPropertyJS(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); |
- } |
- return obj; |
+ return %ObjectFreeze(obj); |
} |
-// ES5 section 15.2.3.10 |
+// ES6 19.1.2.15 |
function ObjectPreventExtension(obj) { |
if (!IS_SPEC_OBJECT(obj)) return obj; |
return %PreventExtensions(obj); |
} |
-// ES5 section 15.2.3.11 |
+// ES6 19.1.2.13 |
function ObjectIsSealed(obj) { |
if (!IS_SPEC_OBJECT(obj)) return true; |
- if (%_IsJSProxy(obj)) { |
- return false; // TODO(neis): Must call isExtensible trap and ownKeys trap. |
- } |
- if (%IsExtensible(obj)) { |
- return false; |
- } |
- var names = OwnPropertyKeys(obj); |
- for (var i = 0; i < names.length; i++) { |
- var name = names[i]; |
- var desc = GetOwnPropertyJS(obj, name); |
- if (desc.isConfigurable()) { |
- return false; |
- } |
- } |
- return true; |
+ return %ObjectIsSealed(obj); |
} |
-// ES5 section 15.2.3.12 |
+// ES6 19.1.2.12 |
function ObjectIsFrozen(obj) { |
if (!IS_SPEC_OBJECT(obj)) return true; |
- if (%_IsJSProxy(obj)) { |
- return false; // TODO(neis): Must call isExtensible trap and ownKeys trap. |
- } |
- if (%IsExtensible(obj)) { |
- return false; |
- } |
- var names = OwnPropertyKeys(obj); |
- for (var i = 0; i < names.length; i++) { |
- var name = names[i]; |
- var desc = GetOwnPropertyJS(obj, name); |
- if (IsDataDescriptor(desc) && desc.isWritable()) return false; |
- if (desc.isConfigurable()) return false; |
- } |
- return true; |
+ return %ObjectIsFrozen(obj); |
} |
-// ES5 section 15.2.3.13 |
+// ES6 19.1.2.11 |
function ObjectIsExtensible(obj) { |
if (!IS_SPEC_OBJECT(obj)) return false; |
return %IsExtensible(obj); |