18#include <private/qv4global_p.h>
19#include <private/qv4runtimeapi_p.h>
20#include <QtCore/qalgorithms.h>
21#include <QtCore/qmath.h>
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
66#if QT_POINTER_SIZE == 8
154 bool sweep(ExecutionEngine *engine);
155 void freeAll(ExecutionEngine *engine);
171 T *
as() {
return static_cast<
T *>(
reinterpret_cast<
Heap::
Base *>(
this)); }
215 return reinterpret_cast<
HeapItem *>(
this);
237 if (m_top < m_softLimit)
242 const quintptr segmentSize = qNextPowerOfTwo(quintptr(m_hardLimit - m_softLimit) / 64u);
243 if (m_drainRecursion * segmentSize <= quintptr(m_top - m_softLimit)) {
247 }
else if (m_top == m_hardLimit) {
248 qFatal(
"GC mark stack overrun. Either simplify your application or"
249 "increase QV4_GC_MAX_STACK_SIZE");
253 bool isEmpty()
const {
return m_top == m_base; }
257 return m_softLimit - m_top;
269 Heap::Base **m_top =
nullptr;
270 Heap::Base **m_base =
nullptr;
271 Heap::Base **m_softLimit =
nullptr;
272 Heap::Base **m_hardLimit =
nullptr;
274 ExecutionEngine *m_engine =
nullptr;
276 quintptr m_drainRecursion = 0;
282#define HEAP_OBJECT_OFFSET_MEMBER_EXPANSION(c, gcType, type, name)
283 HEAP_OBJECT_OFFSET_MEMBER_EXPANSION_##gcType(c, type, name)
285#define HEAP_OBJECT_OFFSET_MEMBER_EXPANSION_Pointer(c, type, name) Pointer<type, 0
> name;
286#define HEAP_OBJECT_OFFSET_MEMBER_EXPANSION_NoMark(c, type, name) type name;
287#define HEAP_OBJECT_OFFSET_MEMBER_EXPANSION_HeapValue(c, type, name) HeapValue<0
> name;
288#define HEAP_OBJECT_OFFSET_MEMBER_EXPANSION_ValueArray(c, type, name) type<0
> name;
290#define HEAP_OBJECT_MEMBER_EXPANSION(c, gcType, type, name)
291 HEAP_OBJECT_MEMBER_EXPANSION_##gcType(c, type, name)
293#define HEAP_OBJECT_MEMBER_EXPANSION_Pointer(c, type, name)
294 Pointer<type, offsetof(c##OffsetStruct, name) + baseOffset> name;
295#define HEAP_OBJECT_MEMBER_EXPANSION_NoMark(c, type, name)
297#define HEAP_OBJECT_MEMBER_EXPANSION_HeapValue(c, type, name)
298 HeapValue<offsetof(c##OffsetStruct, name) + baseOffset> name;
299#define HEAP_OBJECT_MEMBER_EXPANSION_ValueArray(c, type, name)
300 type<offsetof(c##OffsetStruct, name) + baseOffset> name;
302#define HEAP_OBJECT_MARKOBJECTS_EXPANSION(c, gcType, type, name)
303 HEAP_OBJECT_MARKOBJECTS_EXPANSION_##gcType(c, type, name)
304#define HEAP_OBJECT_MARKOBJECTS_EXPANSION_Pointer(c, type, name)
305 if (o->name) o->name.heapObject()->mark(stack);
306#define HEAP_OBJECT_MARKOBJECTS_EXPANSION_NoMark(c, type, name)
307#define HEAP_OBJECT_MARKOBJECTS_EXPANSION_HeapValue(c, type, name)
309#define HEAP_OBJECT_MARKOBJECTS_EXPANSION_ValueArray(c, type, name)
313#define DECLARE_HEAP_OBJECT_BASE(name, base)
314 struct name##OffsetStruct {
317 struct name##SizeStruct : base, name##OffsetStruct {};
319 typedef base SuperClass;
320 static constexpr size_t baseOffset = sizeof(name##SizeStruct) - sizeof(name##OffsetStruct);
323 Q_STATIC_ASSERT(sizeof(name##SizeStruct) == sizeof(name##Data) + name##Data::baseOffset);
325#define DECLARE_HEAP_OBJECT(name, base)
327 struct name : base, name##Data
328#define DECLARE_EXPORTED_HEAP_OBJECT(name, base)
330 struct Q_QML_EXPORT name : base, name##Data
332#define DECLARE_MARKOBJECTS(class)
333 static void markObjects(Heap::Base *b, MarkStack *stack) {
334 class *o = static_cast<class *>(b);
335 class##Data::SuperClass::markObjects(o, stack);
Q_STATIC_ASSERT(sizeof(CppStackFrame)==sizeof(JSTypesStackFrame))
#define HEAP_OBJECT_MARKOBJECTS_EXPANSION(c, gcType, type, name)
#define HEAP_OBJECT_OFFSET_MEMBER_EXPANSION(c, gcType, type, name)
#define HEAP_OBJECT_MEMBER_EXPANSION(c, gcType, type, name)
#define DECLARE_HEAP_OBJECT_BASE(name, base)
quintptr objectBitmap[BitmapSize/sizeof(quintptr)]
bool sweep(ExecutionEngine *engine)
void freeAll(ExecutionEngine *engine)
quintptr extendsBitmap[BitmapSize/sizeof(quintptr)]
void sortIntoBins(HeapItem **bins, uint nBins)
quintptr blackBitmap[BitmapSize/sizeof(quintptr)]
quint64 payload[Chunk::SlotSize/sizeof(quint64)]
qptrdiff remainingBeforeSoftLimit() const
DrainState drain(QDeadlineTimer deadline)
ExecutionEngine * engine() const
void setSoftLimit(size_t size)