StructureCache.cpp [plain text]
#include "config.h"
#include "StructureCache.h"
#include "IndexingType.h"
#include "JSGlobalObject.h"
#include "JSCInlines.h"
namespace JSC {
inline Structure* StructureCache::createEmptyStructure(JSGlobalObject* globalObject, JSObject* prototype, const TypeInfo& typeInfo, const ClassInfo* classInfo, IndexingType indexingType, unsigned inlineCapacity, bool makePolyProtoStructure, FunctionExecutable* executable)
{
RELEASE_ASSERT(!!prototype);
PrototypeKey key { makePolyProtoStructure ? nullptr : prototype, executable, inlineCapacity, classInfo, globalObject };
if (Structure* structure = m_structures.get(key)) {
if (makePolyProtoStructure) {
prototype->didBecomePrototype();
RELEASE_ASSERT(structure->hasPolyProto());
} else
RELEASE_ASSERT(structure->hasMonoProto());
ASSERT(prototype->mayBePrototype());
return structure;
}
prototype->didBecomePrototype();
VM& vm = globalObject->vm();
Structure* structure;
if (makePolyProtoStructure) {
structure = Structure::create(
Structure::PolyProto, vm, globalObject, prototype, typeInfo, classInfo, indexingType, inlineCapacity);
} else {
structure = Structure::create(
vm, globalObject, prototype, typeInfo, classInfo, indexingType, inlineCapacity);
}
m_structures.set(key, structure);
return structure;
}
Structure* StructureCache::emptyStructureForPrototypeFromBaseStructure(JSGlobalObject* globalObject, JSObject* prototype, Structure* baseStructure)
{
IndexingType indexingType = baseStructure->indexingType();
if (prototype->anyObjectInChainMayInterceptIndexedAccesses(globalObject->vm()) && hasIndexedProperties(indexingType))
indexingType = (indexingType & ~IndexingShapeMask) | SlowPutArrayStorageShape;
return createEmptyStructure(globalObject, prototype, baseStructure->typeInfo(), baseStructure->classInfo(), indexingType, 0, false, nullptr);
}
Structure* StructureCache::emptyObjectStructureForPrototype(JSGlobalObject* globalObject, JSObject* prototype, unsigned inlineCapacity, bool makePolyProtoStructure, FunctionExecutable* executable)
{
return createEmptyStructure(globalObject, prototype, JSFinalObject::typeInfo(), JSFinalObject::info(), JSFinalObject::defaultIndexingType, inlineCapacity, makePolyProtoStructure, executable);
}
}