inline void StorageStatistics::visit(JSCell* cell) { if (!cell->isObject()) return; JSObject* object = jsCast<JSObject*>(cell); if (hasIndexedProperties(object->indexingType())) return; if (object->structure()->isUncacheableDictionary()) return; ++m_objectCount; if (!object->hasInlineStorage()) ++m_objectWithOutOfLineStorageCount; m_storageSize += object->structure()->totalStorageSize() * sizeof(WriteBarrierBase<Unknown>); m_storageCapacity += object->structure()->totalStorageCapacity() * sizeof(WriteBarrierBase<Unknown>); }
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->indexingType())) { object->freeze(exec->vm()); return JSValue::encode(obj); } // 2. For each named own property name P of O, PropertyNameArray properties(exec); object->methodTable(exec->vm())->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->getOwnPropertyDescriptor(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(exec->vm())->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); }
bool Structure::holesMustForwardToPrototype(VM& vm) const { if (this->mayInterceptIndexedAccesses()) return true; JSValue prototype = this->storedPrototype(); if (!prototype.isObject()) return false; JSObject* object = asObject(prototype); while (true) { Structure& structure = *object->structure(vm); if (hasIndexedProperties(object->indexingType()) || structure.mayInterceptIndexedAccesses()) return true; prototype = structure.storedPrototype(); if (!prototype.isObject()) return false; object = asObject(prototype); } RELEASE_ASSERT_NOT_REACHED(); return false; }