+EncodedJSValue JSC_HOST_CALL objectConstructorDefineProperties(ExecState* exec)
+{
+ if (!exec->argument(0).isObject())
+ return throwVMError(exec, createTypeError(exec, ASCIILiteral("Properties can only be defined on Objects.")));
+ return JSValue::encode(defineProperties(exec, asObject(exec->argument(0)), exec->argument(1).toObject(exec)));
+}
+
+EncodedJSValue JSC_HOST_CALL objectConstructorCreate(ExecState* exec)
+{
+ if (!exec->argument(0).isObject() && !exec->argument(0).isNull())
+ return throwVMError(exec, createTypeError(exec, ASCIILiteral("Object prototype may only be an Object or null.")));
+ JSValue proto = exec->argument(0);
+ JSObject* newObject = proto.isObject()
+ ? constructEmptyObject(exec, asObject(proto))
+ : constructEmptyObject(exec, exec->lexicalGlobalObject()->nullPrototypeObjectStructure());
+ if (exec->argument(1).isUndefined())
+ return JSValue::encode(newObject);
+ if (!exec->argument(1).isObject())
+ return throwVMError(exec, createTypeError(exec, ASCIILiteral("Property descriptor list must be an Object.")));
+ return JSValue::encode(defineProperties(exec, newObject, asObject(exec->argument(1))));
+}
+
+EncodedJSValue JSC_HOST_CALL objectConstructorSeal(ExecState* exec)
+{
+ // 1. If Type(O) is not Object throw a TypeError exception.
+ JSValue obj = exec->argument(0);
+ if (!obj.isObject())
+ return throwVMError(exec, createTypeError(exec, ASCIILiteral("Object.seal can only be called on Objects.")));
+ JSObject* object = asObject(obj);
+
+ if (isJSFinalObject(object)) {
+ object->seal(exec->vm());
+ return JSValue::encode(obj);
+ }
+
+ // 2. For each named own property name P of O,
+ PropertyNameArray properties(exec);
+ object->methodTable()->getOwnPropertyNames(object, exec, properties, IncludeDontEnumProperties);
+ PropertyNameArray::const_iterator end = properties.end();
+ for (PropertyNameArray::const_iterator iter = properties.begin(); iter != end; ++iter) {
+ // a. Let desc be the result of calling the [[GetOwnProperty]] internal method of O with P.
+ PropertyDescriptor desc;
+ if (!object->methodTable()->getOwnPropertyDescriptor(object, exec, *iter, desc))
+ continue;
+ // b. If desc.[[Configurable]] is true, set desc.[[Configurable]] to false.
+ desc.setConfigurable(false);
+ // c. Call the [[DefineOwnProperty]] internal method of O with P, desc, and true as arguments.
+ object->methodTable()->defineOwnProperty(object, exec, *iter, desc, true);
+ if (exec->hadException())
+ return JSValue::encode(obj);
+ }
+
+ // 3. Set the [[Extensible]] internal property of O to false.
+ object->preventExtensions(exec->vm());
+
+ // 4. Return O.
+ return JSValue::encode(obj);
+}
+
+EncodedJSValue JSC_HOST_CALL objectConstructorFreeze(ExecState* exec)
+{
+ // 1. If Type(O) is not Object throw a TypeError exception.
+ JSValue obj = exec->argument(0);
+ if (!obj.isObject())
+ return throwVMError(exec, createTypeError(exec, ASCIILiteral("Object.freeze can only be called on Objects.")));
+ JSObject* object = asObject(obj);
+
+ if (isJSFinalObject(object) && !hasIndexedProperties(object->structure()->indexingType())) {
+ object->freeze(exec->vm());
+ return JSValue::encode(obj);
+ }
+
+ // 2. For each named own property name P of O,
+ PropertyNameArray properties(exec);
+ object->methodTable()->getOwnPropertyNames(object, exec, properties, IncludeDontEnumProperties);
+ PropertyNameArray::const_iterator end = properties.end();
+ for (PropertyNameArray::const_iterator iter = properties.begin(); iter != end; ++iter) {
+ // a. Let desc be the result of calling the [[GetOwnProperty]] internal method of O with P.
+ PropertyDescriptor desc;
+ if (!object->methodTable()->getOwnPropertyDescriptor(object, exec, *iter, desc))
+ continue;
+ // b. If IsDataDescriptor(desc) is true, then
+ // i. If desc.[[Writable]] is true, set desc.[[Writable]] to false.
+ if (desc.isDataDescriptor())
+ desc.setWritable(false);
+ // c. If desc.[[Configurable]] is true, set desc.[[Configurable]] to false.
+ desc.setConfigurable(false);
+ // d. Call the [[DefineOwnProperty]] internal method of O with P, desc, and true as arguments.
+ object->methodTable()->defineOwnProperty(object, exec, *iter, desc, true);
+ if (exec->hadException())
+ return JSValue::encode(obj);
+ }
+
+ // 3. Set the [[Extensible]] internal property of O to false.
+ object->preventExtensions(exec->vm());
+
+ // 4. Return O.
+ return JSValue::encode(obj);
+}
+
+EncodedJSValue JSC_HOST_CALL objectConstructorPreventExtensions(ExecState* exec)
+{
+ JSValue obj = exec->argument(0);
+ if (!obj.isObject())
+ return throwVMError(exec, createTypeError(exec, ASCIILiteral("Object.preventExtensions can only be called on Objects.")));
+ asObject(obj)->preventExtensions(exec->vm());
+ return JSValue::encode(obj);
+}
+
+EncodedJSValue JSC_HOST_CALL objectConstructorIsSealed(ExecState* exec)