Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
|
#include <qv4mm_p.h>
Public Types | |
enum | Blockness : quint8 { Unblocked , NormalBlocked , InCriticalSection } |
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 (Heap::InternalClass *ic) |
template<typename ManagedType > | |
ManagedType::Data * | allocManaged (std::size_t size, InternalClass *ic) |
template<typename ManagedType > | |
ManagedType::Data * | allocManaged (InternalClass *ic) |
template<typename ManagedType > | |
ManagedType::Data * | allocManaged (std::size_t size) |
template<typename ManagedType > | |
ManagedType::Data * | allocManaged () |
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 () |
bool | tryForceGCCompletion () |
void | runFullGC () |
void | dumpStats () const |
size_t | getUsedMem () const |
size_t | getAllocatedMem () const |
size_t | getLargeItemsMem () const |
void | changeUnmanagedHeapSizeUsage (qptrdiff delta) |
void | updateUnmanagedHeapSizeGCLimit () |
template<typename ManagedType > | |
ManagedType::Data * | allocIC () |
void | registerWeakMap (Heap::MapObject *map) |
void | registerWeakSet (Heap::SetObject *set) |
void | onEventLoop () |
void | setGCTimeLimit (int timeMs) |
MarkStack * | markStack () |
void | collectFromJSStack (MarkStack *markStack) const |
void | sweep (bool lastSweep=false, ClassDestroyStatsCallback classCountPtr=nullptr) |
void | cleanupDeletedQObjectWrappersInSweep () |
bool | isAboveUnmanagedHeapLimit () |
Static Public Member Functions | |
static constexpr std::size_t | align (std::size_t size) |
Public Attributes | ||
QV4::ExecutionEngine * | engine | |
ChunkAllocator * | chunkAllocator | |
BlockAllocator | blockAllocator | |
BlockAllocator | icAllocator | |
HugeItemAllocator | hugeItemAllocator | |
PersistentValueStorage * | m_persistentValues | |
PersistentValueStorage * | m_weakValues | |
QVector< Value * > | m_pendingFreedObjectWrapperValue | |
Heap::MapObject * | weakMaps = nullptr | |
Heap::SetObject * | weakSets = nullptr | |
std::unique_ptr< GCStateMachine > | gcStateMachine {nullptr} | |
std::unique_ptr< MarkStack > | m_markStack {nullptr} | |
std::size_t | unmanagedHeapSize = 0 | |
std::size_t | unmanagedHeapSizeGCLimit | |
std::size_t | usedSlotsAfterLastFullSweep = 0 | |
Blockness | gcBlocked = Unblocked | |
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::Base * | allocString (std::size_t unmanagedSize) |
expects size to be aligned | |
Heap::Base * | allocData (std::size_t size) |
Heap::Object * | allocObjectWithMemberData (const QV4::VTable *vtable, uint nMembers) |
Friends | |
template<typename ToBeMarked > | |
struct | GCCriticalSection |
QV4::MemoryManager::MemoryManager | ( | ExecutionEngine * | engine | ) |
Definition at line 900 of file qv4mm.cpp.
References QV4::BlockAllocator::allocationStats, blockAllocator, QV4::CallDestroyObjects, QV4::DoSweep, QV4::FreeWeakMaps, QV4::FreeWeakSets, gcStateMachine, gcStats, QV4::HandleQObjectWrappers, QV4::InitCallDestroyObjects, QV4::InitMarkPersistentValues, QV4::InitMarkWeakValues, QV4::MarkDrain, QV4::MarkGlobalObject, QV4::MarkJSStack, QV4::MarkPersistentValues, QV4::MarkReady, QV4::MarkStart, QV4::MarkWeakValues, and statistics.
QV4::MemoryManager::~MemoryManager | ( | ) |
Definition at line 1401 of file qv4mm.cpp.
References blockAllocator, chunkAllocator, dumpStats(), engine, QV4::BlockAllocator::freeAll(), QV4::HugeItemAllocator::freeAll(), gcStateMachine, hugeItemAllocator, icAllocator, QV4::Invalid, QV4::EngineBase::isGCOngoing, m_markStack, m_persistentValues, m_weakValues, QV4::BlockAllocator::resetBlackBits(), QV4::HugeItemAllocator::resetBlackBits(), setGCTimeLimit(), and sweep().
|
inlinestaticconstexpr |
Definition at line 187 of file qv4mm_p.h.
Referenced by QV4::MemberData::allocate(), allocObjectWithMemberData(), and allocString().
|
inline |
Definition at line 307 of file qv4mm_p.h.
Referenced by QV4::RuntimeHelpers::addHelper(), QV4::RegExpObject::builtinExec(), QV4::Symbol::create(), QV4::QmlContext::create(), QV4::RegExpPrototype::execFirstMatch(), QV4::StringPrototype::method_slice(), and QV4::ExecutionContext::newWithContext().
|
inline |
Definition at line 298 of file qv4mm_p.h.
Referenced by QV4::ExecutionEngine::ExecutionEngine(), allocData(), allocString(), QtObject::binding(), QV4::NodeList::create(), QV4::NamedNodeMap::create(), QV4::QQmlTypeWrapper::create(), QV4::QQmlTypeWrapper::create(), QV4::QMetaObjectWrapper::create(), QV4::QmlListWrapper::create(), QV4::QmlListWrapper::create(), QV4::QmlListWrapper::create(), QV4::Node::create(), QV4::QmlContext::create(), QV4::QQmlSqlDatabaseWrapper::create(), QQuickJSContext2DPrototype::create(), QV4::FunctionObject::createBuiltinFunction(), QV4::FunctionObject::createConstructorFunction(), QV4::FunctionObject::createScriptFunction(), QV4::Heap::Sequence::detached(), QV4::Promise::ReactionHandler::executeResolveThenable(), QQmlDMAbstractItemModelData::get(), QQmlDMListAccessorData::get(), QQmlDelegateModelGroup::get(), QQmlListModel::get(), QV4::NodePrototype::getProto(), QQmlComponent::incubateObject(), QV4::GlobalExtensions::init(), VDMAbstractItemModelDataType::initializeConstructor(), QV4::Document::load(), QV4::PromiseCtor::method_all(), QQuickJSContext2DPrototype::method_createConicalGradient(), QQuickJSContext2DPrototype::method_createLinearGradient(), QQuickJSContext2DPrototype::method_createPattern(), QQuickJSContext2DPrototype::method_createRadialGradient(), QV4::StringPrototype::method_iterator(), QV4::PromiseCtor::method_race(), QV4::PromiseCtor::method_reject(), QV4::PromiseCtor::method_resolve(), QV4::Proxy::method_revocable(), QV4::PromisePrototype::method_then(), 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(), and QV4::QQmlTypeWrapper::virtualResolveLookupGetter().
|
inline |
|
inline |
|
inline |
|
protected |
Definition at line 999 of file qv4mm.cpp.
References allocate(), allocationCount, blockAllocator, lastAllocRequestedSlots, Q_ASSERT, QV4::Chunk::SlotSize, and QV4::Chunk::SlotSizeShift.
Referenced by allocObjectWithMemberData().
|
inline |
Definition at line 333 of file qv4mm_p.h.
Referenced by QV4::ExecutionEngine::ExecutionEngine(), and QV4::ExecutionEngine::newClass().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 199 of file qv4mm_p.h.
References d, engine, Q_ASSERT, Q_STATIC_ASSERT, and QV4::Heap::InternalClass::vtable.
Referenced by QV4::MemberData::allocate(), QV4::ExecutionContext::cloneBlockContext(), QV4::ExecutionEngine::initRootContext(), QV4::ExecutionEngine::newArrayObject(), QV4::ExecutionContext::newBlockContext(), QV4::ExecutionContext::newCallContext(), QV4::ArrayData::realloc(), and QV4::GeneratorFunction::virtualCall().
|
inline |
|
inline |
Definition at line 282 of file qv4mm_p.h.
Referenced by QV4::ExecutionEngine::ExecutionEngine(), QV4::ErrorObject::create(), QV4::ErrorObject::create(), QV4::ErrorObject::create(), QV4::TypedArray::create(), QV4::ExecutionEngine::newArrayObject(), QV4::ExecutionEngine::newObject(), QV4::ExecutionEngine::newSymbolObject(), and QV4::ScriptFunction::virtualCallAsConstructor().
|
inline |
|
protected |
Definition at line 1014 of file qv4mm.cpp.
References align(), QV4::HugeItemAllocator::allocate(), allocData(), QV4::HeapItem::as(), QV4::EngineBase::Class_MemberData, QV4::Chunk::clearBit(), QV4::Chunk::DataSize, engine, hugeItemAllocator, QV4::VTable::inlinePropertyOffset, QV4::EngineBase::internalClasses(), QV4::VTable::nInlineProperties, o, Q_ASSERT, QV4::Chunk::realBase(), QV4::Chunk::setBit(), and QV4::Chunk::SlotSizeShift.
|
protected |
expects size to be aligned
Definition at line 985 of file qv4mm.cpp.
References align(), allocate(), allocationCount, blockAllocator, lastAllocRequestedSlots, QV4::Chunk::SlotSizeShift, and unmanagedHeapSize.
|
inline |
Definition at line 272 of file qv4mm_p.h.
References engine, o, and Q_ASSERT.
Referenced by QV4::ExecutionEngine::newIdentifier(), and QV4::ExecutionEngine::newString().
void QV4::MemoryManager::cleanupDeletedQObjectWrappersInSweep | ( | ) |
Definition at line 1154 of file qv4mm.cpp.
References QSet< T >::begin(), QV4::PersistentValueStorage::begin(), QSet< T >::end(), QV4::PersistentValueStorage::end(), engine, QSet< T >::erase(), QV4::PersistentValueStorage::free(), i, it, QV4::ExecutionEngine::m_multiplyWrappedQObjects, m_pendingFreedObjectWrapperValue, m_weakValues, QV4::Value::managed(), and QV4::Value::undefinedValue().
Referenced by sweep().
Definition at line 1448 of file qv4mm.cpp.
References engine, QV4::EngineBase::jsStackBase, QV4::EngineBase::jsStackTop, QV4::Value::managed(), markStack(), and Q_ASSERT.
void QV4::MemoryManager::dumpStats | ( | ) | const |
Definition at line 1432 of file qv4mm.cpp.
References gcStats, i, QV4::BlockAllocator::NumBins, qDebug, QV4::Chunk::SlotSizeShift, and statistics.
Referenced by ~MemoryManager().
size_t QV4::MemoryManager::getAllocatedMem | ( | ) | const |
Definition at line 1356 of file qv4mm.cpp.
References QV4::BlockAllocator::allocatedMem(), blockAllocator, hugeItemAllocator, icAllocator, and QV4::HugeItemAllocator::usedMem().
Referenced by runGC().
size_t QV4::MemoryManager::getLargeItemsMem | ( | ) | const |
Definition at line 1361 of file qv4mm.cpp.
References hugeItemAllocator, and QV4::HugeItemAllocator::usedMem().
Referenced by runGC().
size_t QV4::MemoryManager::getUsedMem | ( | ) | const |
Definition at line 1351 of file qv4mm.cpp.
References blockAllocator, icAllocator, and QV4::BlockAllocator::usedMem().
Referenced by runGC().
|
inline |
Definition at line 363 of file qv4mm_p.h.
Referenced by QV4::GCCriticalSection< ToBeMarked >::~GCCriticalSection().
|
inline |
Definition at line 346 of file qv4mm_p.h.
Referenced by QV4::GCCriticalSection< ToBeMarked >::~GCCriticalSection(), and collectFromJSStack().
void QV4::MemoryManager::onEventLoop | ( | ) |
Definition at line 1092 of file qv4mm.cpp.
References engine, gcBlocked, gcStateMachine, InCriticalSection, QV4::EngineBase::inShutdown, QMetaObject::invokeMethod(), QV4::ExecutionEngine::publicEngine, and Qt::QueuedConnection.
void QV4::MemoryManager::registerWeakMap | ( | Heap::MapObject * | map | ) |
void QV4::MemoryManager::registerWeakSet | ( | Heap::SetObject * | set | ) |
void QV4::MemoryManager::runFullGC | ( | ) |
Definition at line 1250 of file qv4mm.cpp.
References m_markStack, runGC(), and tryForceGCCompletion().
void QV4::MemoryManager::runGC | ( | ) |
Definition at line 1258 of file qv4mm.cpp.
References QV4::BlockAllocator::allocatedMem(), allocationCount, blockAllocator, QSet< T >::cbegin(), QSet< T >::cend(), QV4::BlockAllocator::chunks, QSet< T >::constBegin(), QSet< T >::constEnd(), QV4::dumpBins(), QString::fromLatin1(), gcBlocked, gcCollectorStats, gcStateMachine, gcStats, getAllocatedMem(), getLargeItemsMem(), getUsedMem(), icAllocator, it, lastAllocRequestedSlots, QV4::markStackSize, NormalBlocked, QString::number(), qDebug, qMax(), QElapsedTimer::start(), statistics, Unblocked, unmanagedHeapSize, and unmanagedHeapSizeGCLimit.
Referenced by QV4::GCCriticalSection< ToBeMarked >::~GCCriticalSection(), QQmlEngine::clearComponentCache(), QJSEngine::collectGarbage(), and runFullGC().
void QV4::MemoryManager::setGCTimeLimit | ( | int | timeMs | ) |
Definition at line 1108 of file qv4mm.cpp.
References gcStateMachine.
Referenced by ~MemoryManager(), and QQmlEngine::clearComponentCache().
void QV4::MemoryManager::sweep | ( | bool | lastSweep = false, |
ClassDestroyStatsCallback | classCountPtr = nullptr ) |
Definition at line 1113 of file qv4mm.cpp.
References QV4::Value::as(), QV4::PersistentValueStorage::begin(), blockAllocator, cleanupDeletedQObjectWrappersInSweep(), QV4::PersistentValueStorage::end(), engine, gcBlocked, hugeItemAllocator, icAllocator, QV4::EngineBase::identifierTable, it, m_weakValues, QV4::Value::managed(), QV4::BlockAllocator::resetBlackBits(), QV4::HugeItemAllocator::resetBlackBits(), QV4::IdentifierTable::sweep(), QV4::BlockAllocator::sweep(), QV4::HugeItemAllocator::sweep(), Unblocked, updateUnmanagedHeapSizeGCLimit(), usedSlotsAfterLastFullSweep, and QV4::BlockAllocator::usedSlotsAfterLastSweep.
Referenced by ~MemoryManager().
bool QV4::MemoryManager::tryForceGCCompletion | ( | ) |
Precondition: Incremental garbage collection must be currently active Finishes incremental garbage collection, unless in a critical section Code entering a critical section is expected to check if we need to force a gc completion, and to trigger the gc again if necessary when exiting the critcial section. Returns true
if the gc cycle completed, false otherwise.
Definition at line 1236 of file qv4mm.cpp.
References gcBlocked, gcStateMachine, InCriticalSection, m_markStack, and Q_ASSERT.
Referenced by QV4::GCCriticalSection< ToBeMarked >::~GCCriticalSection(), and runFullGC().
void QV4::MemoryManager::updateUnmanagedHeapSizeGCLimit | ( | ) |
Definition at line 1366 of file qv4mm.cpp.
References aggressiveGC, QV4::BlockAllocator::allocatedMem(), blockAllocator, QV4::dumpBins(), engine, icAllocator, QV4::EngineBase::inShutdown, Q_ASSERT, qMax(), unmanagedHeapSize, unmanagedHeapSizeGCLimit, and QV4::BlockAllocator::usedMem().
Referenced by sweep().
|
friend |
bool QV4::MemoryManager::aggressiveGC = false |
Definition at line 423 of file qv4mm_p.h.
Referenced by updateUnmanagedHeapSizeGCLimit().
int QV4::MemoryManager::allocationCount = 0 |
Definition at line 427 of file qv4mm_p.h.
Referenced by allocData(), allocString(), and runGC().
uint QV4::MemoryManager::allocations[BlockAllocator::NumBins] |
BlockAllocator QV4::MemoryManager::blockAllocator |
Definition at line 405 of file qv4mm_p.h.
Referenced by MemoryManager(), ~MemoryManager(), allocData(), allocString(), getAllocatedMem(), getUsedMem(), runGC(), sweep(), and updateUnmanagedHeapSizeGCLimit().
ChunkAllocator* QV4::MemoryManager::chunkAllocator |
Definition at line 404 of file qv4mm_p.h.
Referenced by ~MemoryManager().
QV4::ExecutionEngine* QV4::MemoryManager::engine |
Definition at line 403 of file qv4mm_p.h.
Referenced by ~MemoryManager(), allocObjectWithMemberData(), cleanupDeletedQObjectWrappersInSweep(), collectFromJSStack(), onEventLoop(), sweep(), QV4::GCStateMachine::transition(), and updateUnmanagedHeapSizeGCLimit().
Definition at line 422 of file qv4mm_p.h.
Referenced by QV4::GCCriticalSection< ToBeMarked >::~GCCriticalSection(), onEventLoop(), runGC(), sweep(), and tryForceGCCompletion().
bool QV4::MemoryManager::gcCollectorStats = false |
std::unique_ptr<GCStateMachine> QV4::MemoryManager::gcStateMachine {nullptr} |
Definition at line 414 of file qv4mm_p.h.
Referenced by MemoryManager(), ~MemoryManager(), QQmlEngine::clearComponentCache(), onEventLoop(), runGC(), QV4::WeakValue::set(), QV4::WeakValue::set(), QV4::WeakValue::set(), setGCTimeLimit(), and tryForceGCCompletion().
bool QV4::MemoryManager::gcStats = false |
Definition at line 424 of file qv4mm_p.h.
Referenced by MemoryManager(), dumpStats(), and runGC().
HugeItemAllocator QV4::MemoryManager::hugeItemAllocator |
Definition at line 407 of file qv4mm_p.h.
Referenced by ~MemoryManager(), allocObjectWithMemberData(), getAllocatedMem(), getLargeItemsMem(), and sweep().
BlockAllocator QV4::MemoryManager::icAllocator |
Definition at line 406 of file qv4mm_p.h.
Referenced by ~MemoryManager(), getAllocatedMem(), getUsedMem(), runGC(), sweep(), and updateUnmanagedHeapSizeGCLimit().
size_t QV4::MemoryManager::lastAllocRequestedSlots = 0 |
Definition at line 428 of file qv4mm_p.h.
Referenced by allocData(), allocString(), and runGC().
Definition at line 415 of file qv4mm_p.h.
Referenced by ~MemoryManager(), runFullGC(), and tryForceGCCompletion().
Definition at line 410 of file qv4mm_p.h.
Referenced by cleanupDeletedQObjectWrappersInSweep().
PersistentValueStorage* QV4::MemoryManager::m_persistentValues |
Definition at line 408 of file qv4mm_p.h.
Referenced by QJSManagedValue::QJSManagedValue(), ~MemoryManager(), QV4::ExecutionEngine::registerNativeModule(), QV4::PersistentValue::set(), QV4::PersistentValue::set(), and QV4::PersistentValue::set().
PersistentValueStorage* QV4::MemoryManager::m_weakValues |
Definition at line 409 of file qv4mm_p.h.
Referenced by ~MemoryManager(), cleanupDeletedQObjectWrappersInSweep(), and sweep().
struct { ... } QV4::MemoryManager::statistics |
Referenced by MemoryManager(), dumpStats(), and runGC().
std::size_t QV4::MemoryManager::unmanagedHeapSize = 0 |
Definition at line 417 of file qv4mm_p.h.
Referenced by allocString(), runGC(), and updateUnmanagedHeapSizeGCLimit().
std::size_t QV4::MemoryManager::unmanagedHeapSizeGCLimit |
Definition at line 418 of file qv4mm_p.h.
Referenced by runGC(), and updateUnmanagedHeapSizeGCLimit().
std::size_t QV4::MemoryManager::usedSlotsAfterLastFullSweep = 0 |
Heap::MapObject* QV4::MemoryManager::weakMaps = nullptr |
Definition at line 411 of file qv4mm_p.h.
Referenced by registerWeakMap().
Heap::SetObject* QV4::MemoryManager::weakSets = nullptr |
Definition at line 412 of file qv4mm_p.h.
Referenced by registerWeakSet().