diff options
Diffstat (limited to 'src/qml/memory/qv4mmdefs_p.h')
-rw-r--r-- | src/qml/memory/qv4mmdefs_p.h | 77 |
1 files changed, 23 insertions, 54 deletions
diff --git a/src/qml/memory/qv4mmdefs_p.h b/src/qml/memory/qv4mmdefs_p.h index 43e81e0434..b77b615e6c 100644 --- a/src/qml/memory/qv4mmdefs_p.h +++ b/src/qml/memory/qv4mmdefs_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QV4MMDEFS_P_H #define QV4MMDEFS_P_H @@ -54,10 +18,11 @@ #include <private/qv4runtimeapi_p.h> #include <QtCore/qalgorithms.h> #include <QtCore/qmath.h> -#include <qdebug.h> QT_BEGIN_NAMESPACE +class QDeadlineTimer; + namespace QV4 { struct MarkStack; @@ -96,7 +61,7 @@ struct Chunk { SlotSizeShift = 5, NumSlots = ChunkSize/SlotSize, BitmapSize = NumSlots/8, - HeaderSize = 4*BitmapSize, + HeaderSize = 3*BitmapSize, DataSize = ChunkSize - HeaderSize, AvailableSlots = DataSize/SlotSize, #if QT_POINTER_SIZE == 8 @@ -108,7 +73,6 @@ struct Chunk { #endif EntriesInBitmap = BitmapSize/sizeof(quintptr) }; - quintptr grayBitmap[BitmapSize/sizeof(quintptr)]; quintptr blackBitmap[BitmapSize/sizeof(quintptr)]; quintptr objectBitmap[BitmapSize/sizeof(quintptr)]; quintptr extendsBitmap[BitmapSize/sizeof(quintptr)]; @@ -189,7 +153,6 @@ struct Chunk { bool sweep(ClassDestroyStatsCallback classCountPtr); void resetBlackBits(); - void collectGrayItems(QV4::MarkStack *markStack); bool sweep(ExecutionEngine *engine); void freeAll(ExecutionEngine *engine); @@ -213,19 +176,14 @@ struct HeapItem { return reinterpret_cast<Chunk *>(reinterpret_cast<quintptr>(this) >> Chunk::ChunkShift << Chunk::ChunkShift); } - bool isGray() const { - Chunk *c = chunk(); - uint index = this - c->realBase(); - return Chunk::testBit(c->grayBitmap, index); - } bool isBlack() const { Chunk *c = chunk(); - uint index = this - c->realBase(); + std::ptrdiff_t index = this - c->realBase(); return Chunk::testBit(c->blackBitmap, index); } bool isInUse() const { Chunk *c = chunk(); - uint index = this - c->realBase(); + std::ptrdiff_t index = this - c->realBase(); return Chunk::testBit(c->objectBitmap, index); } @@ -244,10 +202,10 @@ struct HeapItem { // Doesn't report correctly for huge items size_t size() const { Chunk *c = chunk(); - uint index = this - c->realBase(); + std::ptrdiff_t index = this - c->realBase(); Q_ASSERT(Chunk::testBit(c->objectBitmap, index)); // ### optimize me - uint end = index + 1; + std::ptrdiff_t end = index + 1; while (end < Chunk::NumSlots && Chunk::testBit(c->extendsBitmap, end)) ++end; return (end - index)*sizeof(HeapItem); @@ -271,9 +229,9 @@ Q_STATIC_ASSERT(sizeof(HeapItem) == Chunk::SlotSize); Q_STATIC_ASSERT(QT_POINTER_SIZE*8 == Chunk::Bits); Q_STATIC_ASSERT((1 << Chunk::BitShift) == Chunk::Bits); -struct Q_QML_PRIVATE_EXPORT MarkStack { +struct Q_QML_EXPORT MarkStack { MarkStack(ExecutionEngine *engine); - ~MarkStack() { drain(); } + ~MarkStack() { /* we drain manually */ } void push(Heap::Base *m) { *(m_top++) = m; @@ -294,17 +252,28 @@ struct Q_QML_PRIVATE_EXPORT MarkStack { } } + bool isEmpty() const { return m_top == m_base; } + + qptrdiff remainingBeforeSoftLimit() const + { + return m_softLimit - m_top; + } + ExecutionEngine *engine() const { return m_engine; } + void drain(); + enum class DrainState { Ongoing, Complete }; + DrainState drain(QDeadlineTimer deadline); private: Heap::Base *pop() { return *(--m_top); } - void drain(); Heap::Base **m_top = nullptr; Heap::Base **m_base = nullptr; Heap::Base **m_softLimit = nullptr; Heap::Base **m_hardLimit = nullptr; + ExecutionEngine *m_engine = nullptr; + quintptr m_drainRecursion = 0; }; |