Пример #1
0
    void DynamicTypeHandler::ExtractSnapHandler(TTD::NSSnapType::SnapHandler* handler, ThreadContext* threadContext, TTD::SlabAllocator& alloc) const
    {
        handler->HandlerId = TTD_CONVERT_TYPEINFO_TO_PTR_ID(this);

        handler->InlineSlotCapacity = this->inlineSlotCapacity;
        handler->TotalSlotCapacity = this->slotCapacity;

        handler->MaxPropertyIndex = 0;
        handler->PropertyInfoArray = nullptr;

        if(handler->TotalSlotCapacity != 0)
        {
            handler->PropertyInfoArray = alloc.SlabReserveArraySpace<TTD::NSSnapType::SnapHandlerPropertyEntry>(handler->TotalSlotCapacity);
            memset(handler->PropertyInfoArray, 0, handler->TotalSlotCapacity * sizeof(TTD::NSSnapType::SnapHandlerPropertyEntry));

            handler->MaxPropertyIndex = this->ExtractSlotInfo_TTD(handler->PropertyInfoArray, threadContext, alloc);
            AssertMsg(handler->MaxPropertyIndex <= handler->TotalSlotCapacity, "Huh we have more property entries than slots to put them in.");

            if(handler->MaxPropertyIndex != 0)
            {
                alloc.SlabCommitArraySpace<TTD::NSSnapType::SnapHandlerPropertyEntry>(handler->MaxPropertyIndex, handler->TotalSlotCapacity);
            }
            else
            {
                alloc.SlabAbortArraySpace<TTD::NSSnapType::SnapHandlerPropertyEntry>(handler->TotalSlotCapacity);
                handler->PropertyInfoArray = nullptr;
            }
        }

        //The kind of type this snaptype record is associated with and the extensible flag
        handler->IsExtensibleFlag = this->GetFlags() & Js::DynamicTypeHandler::IsExtensibleFlag;
    }
Пример #2
0
    void SnapshotExtractor::ExtractTypeIfNeeded(Js::Type* jstype, ThreadContext* threadContext)
    {
        if(this->m_marks.IsMarked(jstype))
        {
            if(Js::DynamicType::Is(jstype->GetTypeId()))
            {
                this->ExtractHandlerIfNeeded(static_cast<Js::DynamicType*>(jstype)->GetTypeHandler(), threadContext);
            }

            NSSnapType::SnapHandler* sHandler = nullptr;
            if(Js::DynamicType::Is(jstype->GetTypeId()))
            {
                Js::DynamicTypeHandler* dhandler = static_cast<const Js::DynamicType*>(jstype)->GetTypeHandler();

                TTD_PTR_ID handlerId = TTD_CONVERT_TYPEINFO_TO_PTR_ID(dhandler);
                sHandler = this->m_idToHandlerMap.LookupKnownItem(handlerId);
            }

            NSSnapType::SnapType* sType = this->m_pendingSnap->GetNextAvailableTypeEntry();
            jstype->ExtractSnapType(sType, sHandler, this->m_pendingSnap->GetSnapshotSlabAllocator());

            this->m_idToTypeMap.AddItem(sType->TypePtrId, sType);
            this->m_marks.ClearMark(jstype);
        }
    }
Пример #3
0
    void Type::ExtractSnapType(TTD::NSSnapType::SnapType* sType, TTD::NSSnapType::SnapHandler* optHandler, TTD::SlabAllocator& alloc) const
    {
        sType->TypePtrId = TTD_CONVERT_TYPEINFO_TO_PTR_ID(this);
        sType->JsTypeId = this->GetTypeId();

        sType->PrototypeVar = this->GetPrototype();

        sType->ScriptContextLogId = this->GetScriptContext()->ScriptContextLogTag;
        sType->TypeHandlerInfo = optHandler;

        sType->HasNoEnumerableProperties = false;
        if(Js::DynamicType::Is(this->typeId))
        {
            sType->HasNoEnumerableProperties = static_cast<const Js::DynamicType*>(this)->GetHasNoEnumerableProperties();
        }
    }