Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
QV4::MemoryManager Class Reference

#include <qv4mm_p.h>

+ Collaboration diagram for QV4::MemoryManager:

Public Member Functions

 MemoryManager (ExecutionEngine *engine)
 
 ~MemoryManager ()
 
template<typename ManagedType >
ManagedType::Data * allocManaged (std::size_t size, Heap::InternalClass *ic)
 
template<typename ManagedType >
ManagedType::Data * allocManaged (std::size_t size, InternalClass *ic)
 
template<typename ManagedType >
ManagedType::Data * allocManaged (std::size_t size)
 
template<typename ObjectType >
ObjectType::Data * allocateObject (Heap::InternalClass *ic)
 
template<typename ObjectType >
ObjectType::Data * allocateObject (InternalClass *ic)
 
template<typename ObjectType >
ObjectType::Data * allocateObject ()
 
template<typename ManagedType , typename Arg1 >
ManagedType::Data * allocWithStringData (std::size_t unmanagedSize, Arg1 &&arg1)
 
template<typename ObjectType , typename... Args>
ObjectType::Data * allocObject (Heap::InternalClass *ic, Args &&... args)
 
template<typename ObjectType , typename... Args>
ObjectType::Data * allocObject (InternalClass *ic, Args &&... args)
 
template<typename ObjectType , typename... Args>
ObjectType::Data * allocate (Args &&... args)
 
template<typename ManagedType , typename... Args>
ManagedType::Data * alloc (Args &&... args)
 
void runGC ()
 
void dumpStats () const
 
size_t getUsedMem () const
 
size_t getAllocatedMem () const
 
size_t getLargeItemsMem () const
 
void changeUnmanagedHeapSizeUsage (qptrdiff delta)
 
template<typename ManagedType >
ManagedType::Data * allocIC ()
 
void registerWeakMap (Heap::MapObject *map)
 
void registerWeakSet (Heap::SetObject *set)
 

Static Public Member Functions

static constexpr std::size_t align (std::size_t size)
 

Public Attributes

QV4::ExecutionEngineengine
 
ChunkAllocatorchunkAllocator
 
BlockAllocator blockAllocator
 
BlockAllocator icAllocator
 
HugeItemAllocator hugeItemAllocator
 
PersistentValueStoragem_persistentValues
 
PersistentValueStoragem_weakValues
 
QVector< Value * > m_pendingFreedObjectWrapperValue
 
Heap::MapObjectweakMaps = nullptr
 
Heap::SetObjectweakSets = nullptr
 
std::size_t unmanagedHeapSize = 0
 
std::size_t unmanagedHeapSizeGCLimit
 
std::size_t usedSlotsAfterLastFullSweep = 0
 
bool gcBlocked = false
 
bool aggressiveGC = false
 
bool gcStats = false
 
bool gcCollectorStats = false
 
int allocationCount = 0
 
size_t lastAllocRequestedSlots = 0
 
struct { 
 
   size_t   maxReservedMem = 0 
 
   size_t   maxAllocatedMem = 0 
 
   size_t   maxUsedMem = 0 
 
   uint   allocations [BlockAllocator::NumBins
 
statistics 
 

Protected Member Functions

Heap::BaseallocString (std::size_t unmanagedSize)
 expects size to be aligned
 
Heap::BaseallocData (std::size_t size)
 
Heap::Object * allocObjectWithMemberData (const QV4::VTable *vtable, uint nMembers)
 

Detailed Description

Definition at line 107 of file qv4mm_p.h.

Constructor & Destructor Documentation

◆ MemoryManager()

QV4::MemoryManager::MemoryManager ( ExecutionEngine engine)

Definition at line 675 of file qv4mm.cpp.

References QV4::BlockAllocator::allocationStats, blockAllocator, gcStats, and statistics.

◆ ~MemoryManager()

QV4::MemoryManager::~MemoryManager ( )

Definition at line 1106 of file qv4mm.cpp.

References blockAllocator, chunkAllocator, dumpStats(), QV4::BlockAllocator::freeAll(), QV4::HugeItemAllocator::freeAll(), hugeItemAllocator, icAllocator, m_persistentValues, and m_weakValues.

+ Here is the call graph for this function:

Member Function Documentation

◆ align()

static constexpr std::size_t QV4::MemoryManager::align ( std::size_t  size)
inlinestaticconstexpr

Definition at line 117 of file qv4mm_p.h.

Referenced by QV4::MemberData::allocate(), allocObjectWithMemberData(), and allocString().

+ Here is the caller graph for this function:

◆ alloc()

template<typename ManagedType , typename... Args>
ManagedType::Data * QV4::MemoryManager::alloc ( Args &&...  args)
inline

Definition at line 208 of file qv4mm_p.h.

References args, and engine.

Referenced by QV4::RuntimeHelpers::addHelper(), QV4::RegExpObject::builtinExec(), QV4::QmlContext::create(), QV4::RegExpPrototype::execFirstMatch(), QV4::StringPrototype::method_slice(), and QV4::ExecutionContext::newWithContext().

+ Here is the caller graph for this function:

◆ allocate()

template<typename ObjectType , typename... Args>
ObjectType::Data * QV4::MemoryManager::allocate ( Args &&...  args)
inline

Definition at line 199 of file qv4mm_p.h.

References args, and engine.

Referenced by QV4::ExecutionEngine::ExecutionEngine(), QQuickV4ParticleData::QQuickV4ParticleData(), allocData(), allocString(), QV4::NodeList::create(), QV4::NamedNodeMap::create(), QV4::QQmlTypeWrapper::create(), QV4::QQmlTypeWrapper::create(), QV4::QmlListWrapper::create(), QV4::QmlListWrapper::create(), QV4::QmlListWrapper::create(), QV4::Node::create(), QV4::QmlContext::create(), QV4::QObjectMethod::create(), QV4::QObjectMethod::create(), QV4::QQmlSqlDatabaseWrapper::create(), QQuickJSContext2DPrototype::create(), QV4::FunctionObject::createBuiltinFunction(), QV4::Heap::Sequence::detached(), QV4::Promise::ReactionHandler::executeResolveThenable(), QQmlDMListAccessorData::get(), QQmlDelegateModelGroup::get(), QQmlListModel::get(), QV4::NodePrototype::getProto(), QQmlComponent::incubateObject(), VDMAbstractItemModelDataType::initializeConstructor(), QV4::Document::load(), QQuickJSContext2DPrototype::method_createConicalGradient(), QQuickJSContext2DPrototype::method_createLinearGradient(), QQuickJSContext2DPrototype::method_createPattern(), QQuickJSContext2DPrototype::method_createRadialGradient(), QV4::StringPrototype::method_iterator(), QV4::PromiseCtor::method_race(), QV4::Proxy::method_revocable(), QV4::ExecutionEngine::newArrayBuffer(), QV4::ExecutionEngine::newArrayBuffer(), QV4::ExecutionEngine::newArrayIteratorObject(), QV4::ExecutionEngine::newArrayObject(), QV4::ExecutionEngine::newArrayObject(), QV4::ExecutionEngine::newArrayObject(), QV4::ExecutionEngine::newBooleanObject(), QV4::ExecutionEngine::newDateObject(), QV4::ExecutionEngine::newDateObject(), QV4::ExecutionEngine::newDateObject(), QV4::ExecutionEngine::newDateObject(), QV4::ExecutionEngine::newDateObject(), QV4::ExecutionEngine::newForInIteratorObject(), QV4::ExecutionEngine::newMapIteratorObject(), QV4::ExecutionEngine::newNumberObject(), QV4::ExecutionEngine::newObject(), QV4::ExecutionEngine::newPromiseObject(), QV4::ExecutionEngine::newPromiseObject(), QV4::ExecutionEngine::newRegExpObject(), QV4::ExecutionEngine::newSetIteratorObject(), QV4::ExecutionEngine::newStringObject(), QV4::ExecutionEngine::newUrlObject(), QV4::ExecutionEngine::newUrlSearchParamsObject(), QV4::ExecutionEngine::newVariantObject(), qt_add_qmlxmlhttprequest(), qt_create_image_data(), QV4::Proxy::virtualCallAsConstructor(), QV4::QQmlTypeWrapper::virtualGet(), QV4::QQmlTypeWrapper::virtualResolveLookupGetter(), and QQmlLocale::wrap().

◆ allocateObject() [1/3]

template<typename ObjectType >
ObjectType::Data * QV4::MemoryManager::allocateObject ( )
inline

Definition at line 163 of file qv4mm_p.h.

References d, and engine.

◆ allocateObject() [2/3]

template<typename ObjectType >
ObjectType::Data * QV4::MemoryManager::allocateObject ( Heap::InternalClass ic)
inline

Definition at line 147 of file qv4mm_p.h.

References engine, o, Q_ASSERT, and QV4::Heap::InternalClass::size.

◆ allocateObject() [3/3]

template<typename ObjectType >
ObjectType::Data * QV4::MemoryManager::allocateObject ( InternalClass ic)
inline

Definition at line 157 of file qv4mm_p.h.

◆ allocData()

Heap::Base * QV4::MemoryManager::allocData ( std::size_t  size)
protected

Definition at line 717 of file qv4mm.cpp.

References allocate(), allocationCount, blockAllocator, gcBlocked, lastAllocRequestedSlots, Q_ASSERT, QV4::Chunk::SlotSize, and QV4::Chunk::SlotSizeShift.

Referenced by allocObjectWithMemberData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ allocIC()

template<typename ManagedType >
ManagedType::Data * QV4::MemoryManager::allocIC ( )
inline

Definition at line 229 of file qv4mm_p.h.

Referenced by QV4::ExecutionEngine::ExecutionEngine(), and QV4::ExecutionEngine::newClass().

+ Here is the caller graph for this function:

◆ allocManaged() [1/3]

template<typename ManagedType >
ManagedType::Data * QV4::MemoryManager::allocManaged ( std::size_t  size)
inline

Definition at line 139 of file qv4mm_p.h.

References engine.

◆ allocManaged() [2/3]

template<typename ManagedType >
ManagedType::Data * QV4::MemoryManager::allocManaged ( std::size_t  size,
Heap::InternalClass ic 
)
inline

Definition at line 121 of file qv4mm_p.h.

References d, engine, Q_ASSERT, Q_STATIC_ASSERT, and QV4::Heap::InternalClass::vtable.

Referenced by QV4::ExecutionContext::cloneBlockContext(), QV4::ExecutionEngine::initRootContext(), QV4::ExecutionEngine::newArrayObject(), QV4::ExecutionContext::newBlockContext(), QV4::ExecutionContext::newCallContext(), QV4::ArrayData::realloc(), and QV4::GeneratorFunction::virtualCall().

+ Here is the caller graph for this function:

◆ allocManaged() [3/3]

template<typename ManagedType >
ManagedType::Data * QV4::MemoryManager::allocManaged ( std::size_t  size,
InternalClass ic 
)
inline

Definition at line 133 of file qv4mm_p.h.

◆ allocObject() [1/2]

template<typename ObjectType , typename... Args>
ObjectType::Data * QV4::MemoryManager::allocObject ( Heap::InternalClass ic,
Args &&...  args 
)
inline

Definition at line 183 of file qv4mm_p.h.

References args, and d.

Referenced by QV4::ExecutionEngine::ExecutionEngine(), QV4::ExecutionEngine::newArrayObject(), QV4::ExecutionEngine::newObject(), QV4::ExecutionEngine::newSymbolObject(), and QV4::ScriptFunction::virtualCallAsConstructor().

+ Here is the caller graph for this function:

◆ allocObject() [2/2]

template<typename ObjectType , typename... Args>
ObjectType::Data * QV4::MemoryManager::allocObject ( InternalClass ic,
Args &&...  args 
)
inline

Definition at line 191 of file qv4mm_p.h.

References args, and d.

◆ allocObjectWithMemberData()

Heap::Object * QV4::MemoryManager::allocObjectWithMemberData ( const QV4::VTable vtable,
uint  nMembers 
)
protected

◆ allocString()

Heap::Base * QV4::MemoryManager::allocString ( std::size_t  unmanagedSize)
protected

expects size to be aligned

Definition at line 696 of file qv4mm.cpp.

References align(), allocate(), allocationCount, blockAllocator, gcBlocked, lastAllocRequestedSlots, QV4::Chunk::SlotSizeShift, and unmanagedHeapSize.

+ Here is the call graph for this function:

◆ allocWithStringData()

template<typename ManagedType , typename Arg1 >
ManagedType::Data * QV4::MemoryManager::allocWithStringData ( std::size_t  unmanagedSize,
Arg1 &&  arg1 
)
inline

Definition at line 173 of file qv4mm_p.h.

References engine, o, and Q_ASSERT.

Referenced by QV4::ExecutionEngine::newIdentifier(), and QV4::ExecutionEngine::newString().

+ Here is the caller graph for this function:

◆ changeUnmanagedHeapSizeUsage()

void QV4::MemoryManager::changeUnmanagedHeapSizeUsage ( qptrdiff  delta)
inline

Definition at line 226 of file qv4mm_p.h.

◆ dumpStats()

void QV4::MemoryManager::dumpStats ( ) const

Definition at line 1125 of file qv4mm.cpp.

References gcStats, i, QV4::BlockAllocator::NumBins, qDebug, QV4::Chunk::SlotSizeShift, and statistics.

Referenced by ~MemoryManager().

+ Here is the caller graph for this function:

◆ getAllocatedMem()

size_t QV4::MemoryManager::getAllocatedMem ( ) const

Definition at line 1084 of file qv4mm.cpp.

References QV4::BlockAllocator::allocatedMem(), blockAllocator, hugeItemAllocator, icAllocator, and QV4::HugeItemAllocator::usedMem().

Referenced by runGC().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLargeItemsMem()

size_t QV4::MemoryManager::getLargeItemsMem ( ) const

Definition at line 1089 of file qv4mm.cpp.

References hugeItemAllocator, and QV4::HugeItemAllocator::usedMem().

Referenced by runGC().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUsedMem()

size_t QV4::MemoryManager::getUsedMem ( ) const

Definition at line 1079 of file qv4mm.cpp.

References blockAllocator, icAllocator, and QV4::BlockAllocator::usedMem().

Referenced by runGC().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ registerWeakMap()

void QV4::MemoryManager::registerWeakMap ( Heap::MapObject map)

Definition at line 1094 of file qv4mm.cpp.

References map, and weakMaps.

◆ registerWeakSet()

void QV4::MemoryManager::registerWeakSet ( Heap::SetObject set)

Definition at line 1100 of file qv4mm.cpp.

References set, and weakSets.

◆ runGC()

Member Data Documentation

◆ aggressiveGC

bool QV4::MemoryManager::aggressiveGC = false

Definition at line 308 of file qv4mm_p.h.

Referenced by runGC().

◆ allocationCount

int QV4::MemoryManager::allocationCount = 0

Definition at line 312 of file qv4mm_p.h.

Referenced by allocData(), allocString(), and runGC().

◆ allocations

uint QV4::MemoryManager::allocations[BlockAllocator::NumBins]

Definition at line 319 of file qv4mm_p.h.

◆ blockAllocator

BlockAllocator QV4::MemoryManager::blockAllocator

◆ chunkAllocator

ChunkAllocator* QV4::MemoryManager::chunkAllocator

Definition at line 293 of file qv4mm_p.h.

Referenced by ~MemoryManager().

◆ engine

QV4::ExecutionEngine* QV4::MemoryManager::engine

Definition at line 292 of file qv4mm_p.h.

Referenced by allocObjectWithMemberData().

◆ gcBlocked

bool QV4::MemoryManager::gcBlocked = false

Definition at line 307 of file qv4mm_p.h.

Referenced by allocData(), allocString(), and runGC().

◆ gcCollectorStats

bool QV4::MemoryManager::gcCollectorStats = false

Definition at line 310 of file qv4mm_p.h.

Referenced by runGC().

◆ gcStats

bool QV4::MemoryManager::gcStats = false

Definition at line 309 of file qv4mm_p.h.

Referenced by MemoryManager(), dumpStats(), and runGC().

◆ hugeItemAllocator

HugeItemAllocator QV4::MemoryManager::hugeItemAllocator

◆ icAllocator

BlockAllocator QV4::MemoryManager::icAllocator

Definition at line 295 of file qv4mm_p.h.

Referenced by ~MemoryManager(), getAllocatedMem(), getUsedMem(), and runGC().

◆ lastAllocRequestedSlots

size_t QV4::MemoryManager::lastAllocRequestedSlots = 0

Definition at line 313 of file qv4mm_p.h.

Referenced by allocData(), allocString(), and runGC().

◆ m_pendingFreedObjectWrapperValue

QVector<Value *> QV4::MemoryManager::m_pendingFreedObjectWrapperValue

Definition at line 299 of file qv4mm_p.h.

◆ m_persistentValues

◆ m_weakValues

PersistentValueStorage* QV4::MemoryManager::m_weakValues

Definition at line 298 of file qv4mm_p.h.

Referenced by ~MemoryManager().

◆ maxAllocatedMem

size_t QV4::MemoryManager::maxAllocatedMem = 0

Definition at line 317 of file qv4mm_p.h.

◆ maxReservedMem

size_t QV4::MemoryManager::maxReservedMem = 0

Definition at line 316 of file qv4mm_p.h.

◆ maxUsedMem

size_t QV4::MemoryManager::maxUsedMem = 0

Definition at line 318 of file qv4mm_p.h.

◆ [struct]

struct { ... } QV4::MemoryManager::statistics

Referenced by MemoryManager(), dumpStats(), and runGC().

◆ unmanagedHeapSize

std::size_t QV4::MemoryManager::unmanagedHeapSize = 0

Definition at line 303 of file qv4mm_p.h.

Referenced by allocString(), and runGC().

◆ unmanagedHeapSizeGCLimit

std::size_t QV4::MemoryManager::unmanagedHeapSizeGCLimit

Definition at line 304 of file qv4mm_p.h.

Referenced by runGC().

◆ usedSlotsAfterLastFullSweep

std::size_t QV4::MemoryManager::usedSlotsAfterLastFullSweep = 0

Definition at line 305 of file qv4mm_p.h.

Referenced by runGC().

◆ weakMaps

Heap::MapObject* QV4::MemoryManager::weakMaps = nullptr

Definition at line 300 of file qv4mm_p.h.

Referenced by registerWeakMap().

◆ weakSets

Heap::SetObject* QV4::MemoryManager::weakSets = nullptr

Definition at line 301 of file qv4mm_p.h.

Referenced by registerWeakSet().


The documentation for this class was generated from the following files: