aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/memory
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-04-30 10:44:29 +0200
committerLars Knoll <lars.knoll@qt.io>2017-05-02 08:40:48 +0200
commitc3e1e6390edbc28e6e528f401eb4f3639661302b (patch)
tree5c882bfe7fced9b357e80a6b56ccdc88de8a41c3 /src/qml/memory
parent9709d04ba7787c853a1ddbeed0347eab27c0924f (diff)
parent6a2febc680e163e56eb61d322d156dbf6fb07e0e (diff)
Merge remote-tracking branch 'origin/5.9' into dev
Diffstat (limited to 'src/qml/memory')
-rw-r--r--src/qml/memory/qv4mm.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp
index c4bd1a733f..64b07153cc 100644
--- a/src/qml/memory/qv4mm.cpp
+++ b/src/qml/memory/qv4mm.cpp
@@ -266,6 +266,18 @@ void ChunkAllocator::free(Chunk *chunk, size_t size)
Q_ASSERT(false);
}
+#ifdef DUMP_SWEEP
+QString binary(quintptr n) {
+ QString s = QString::number(n, 2);
+ while (s.length() < 64)
+ s.prepend(QChar::fromLatin1('0'));
+ return s;
+}
+#define SDUMP qDebug
+#else
+QString binary(quintptr) { return QString(); }
+#define SDUMP if (1) ; else qDebug
+#endif
void Heap::Base::markChildren(MarkStack *markStack)
{
@@ -338,8 +350,9 @@ static void increaseFreedCountForClass(const char *className)
void Chunk::sweep(ClassDestroyStatsCallback classCountPtr)
{
- // DEBUG << "sweeping chunk" << this << (*freeList);
+ SDUMP() << "sweeping chunk" << this;
HeapItem *o = realBase();
+ bool lastSlotFree = false;
for (uint i = 0; i < Chunk::EntriesInBitmap; ++i) {
#if WRITEBARRIER(none)
Q_ASSERT((grayBitmap[i] | blackBitmap[i]) == blackBitmap[i]); // check that we don't have gray only objects
@@ -347,7 +360,13 @@ void Chunk::sweep(ClassDestroyStatsCallback classCountPtr)
quintptr toFree = objectBitmap[i] ^ blackBitmap[i];
Q_ASSERT((toFree & objectBitmap[i]) == toFree); // check all black objects are marked as being used
quintptr e = extendsBitmap[i];
- // DEBUG << hex << " index=" << i << toFree;
+ SDUMP() << " index=" << i;
+ SDUMP() << " toFree =" << binary(toFree);
+ SDUMP() << " black =" << binary(blackBitmap[i]);
+ SDUMP() << " object =" << binary(objectBitmap[i]);
+ SDUMP() << " extends =" << binary(e);
+ if (lastSlotFree)
+ e &= (e + 1); // clear all lowest extent bits
while (toFree) {
uint index = qCountTrailingZeroBits(toFree);
quintptr bit = (static_cast<quintptr>(1) << index);
@@ -377,6 +396,10 @@ void Chunk::sweep(ClassDestroyStatsCallback classCountPtr)
objectBitmap[i] = blackBitmap[i];
grayBitmap[i] = 0;
extendsBitmap[i] = e;
+ lastSlotFree = !((objectBitmap[i]|extendsBitmap[i]) >> (sizeof(quintptr)*8 - 1));
+ SDUMP() << " new extends =" << binary(e);
+ SDUMP() << " lastSlotFree" << lastSlotFree;
+ Q_ASSERT((objectBitmap[i] & extendsBitmap[i]) == 0);
o += Chunk::Bits;
}
// DEBUG << "swept chunk" << this << "freed" << slotsFreed << "slots.";
@@ -1084,6 +1107,13 @@ size_t dumpBins(BlockAllocator *b, bool printOutput = true)
if (printOutput)
qDebug() << " number of entries in slot" << i << ":" << nEntries;
}
+ SDUMP() << " large slot map";
+ HeapItem *h = b->freeBins[BlockAllocator::NumBins - 1];
+ while (h) {
+ SDUMP() << " " << hex << (quintptr(h)/32) << h->freeData.availableSlots;
+ h = h->freeData.next;
+ }
+
if (printOutput)
qDebug() << " total mem in bins" << totalSlotMem*Chunk::SlotSize;
return totalSlotMem*Chunk::SlotSize;