2012-12-04 12:40:18 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
|
|
|
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
|
|
|
|
** Contact: http://www.qt-project.org/legal
|
|
|
|
**
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
**
|
|
|
|
** 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 Digia. For licensing terms and
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
**
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "qmljs_engine.h"
|
2013-01-21 20:54:53 +00:00
|
|
|
#include "qv4object.h"
|
2013-01-21 21:17:55 +00:00
|
|
|
#include "qv4objectproto.h"
|
2012-12-04 12:40:18 +00:00
|
|
|
#include "qv4mm.h"
|
2012-12-18 14:03:26 +00:00
|
|
|
#include "PageAllocation.h"
|
|
|
|
#include "StdLibExtras.h"
|
2012-12-04 12:40:18 +00:00
|
|
|
|
|
|
|
#include <QTime>
|
|
|
|
#include <QVector>
|
2013-01-02 15:43:47 +00:00
|
|
|
#include <QVector>
|
2012-12-13 22:46:51 +00:00
|
|
|
#include <QMap>
|
2012-12-04 12:40:18 +00:00
|
|
|
|
|
|
|
#include <iostream>
|
2012-12-10 08:56:30 +00:00
|
|
|
#include <cstdlib>
|
2012-12-17 21:43:22 +00:00
|
|
|
#include <alloca.h>
|
2012-12-04 12:40:18 +00:00
|
|
|
|
|
|
|
using namespace QQmlJS::VM;
|
2012-12-18 14:03:26 +00:00
|
|
|
using namespace WTF;
|
2012-12-04 12:40:18 +00:00
|
|
|
|
|
|
|
static const std::size_t CHUNK_SIZE = 65536;
|
|
|
|
|
|
|
|
struct MemoryManager::Data
|
|
|
|
{
|
|
|
|
bool enableGC;
|
|
|
|
bool gcBlocked;
|
|
|
|
bool scribble;
|
|
|
|
bool aggressiveGC;
|
|
|
|
ExecutionEngine *engine;
|
|
|
|
|
2013-01-11 13:33:10 +00:00
|
|
|
enum { MaxItemSize = 256 };
|
2013-01-02 21:09:31 +00:00
|
|
|
Managed *smallItems[MaxItemSize/16];
|
2013-01-30 07:58:27 +00:00
|
|
|
uint nChunks[MaxItemSize/16];
|
2013-01-02 15:43:47 +00:00
|
|
|
struct Chunk {
|
|
|
|
PageAllocation memory;
|
|
|
|
int chunkSize;
|
|
|
|
};
|
|
|
|
|
|
|
|
QVector<Chunk> heapChunks;
|
2013-01-28 12:32:08 +00:00
|
|
|
QHash<Managed *, uint> protectedObject;
|
2012-12-04 12:40:18 +00:00
|
|
|
|
|
|
|
// statistics:
|
|
|
|
#ifdef DETAILED_MM_STATS
|
|
|
|
QVector<unsigned> allocSizeCounters;
|
|
|
|
#endif // DETAILED_MM_STATS
|
|
|
|
|
|
|
|
Data(bool enableGC)
|
|
|
|
: enableGC(enableGC)
|
|
|
|
, gcBlocked(false)
|
|
|
|
, engine(0)
|
|
|
|
{
|
2012-12-13 22:46:51 +00:00
|
|
|
memset(smallItems, 0, sizeof(smallItems));
|
2013-01-30 07:58:27 +00:00
|
|
|
memset(nChunks, 0, sizeof(nChunks));
|
2012-12-04 12:40:18 +00:00
|
|
|
scribble = qgetenv("MM_NO_SCRIBBLE").isEmpty();
|
|
|
|
aggressiveGC = !qgetenv("MM_AGGRESSIVE_GC").isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
~Data()
|
|
|
|
{
|
2013-01-02 15:43:47 +00:00
|
|
|
for (QVector<Chunk>::iterator i = heapChunks.begin(), ei = heapChunks.end(); i != ei; ++i)
|
|
|
|
i->memory.deallocate();
|
2012-12-04 12:40:18 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-01-03 13:00:59 +00:00
|
|
|
namespace QQmlJS { namespace VM {
|
|
|
|
|
|
|
|
bool operator<(const MemoryManager::Data::Chunk &a, const MemoryManager::Data::Chunk &b)
|
2013-01-02 15:43:47 +00:00
|
|
|
{
|
|
|
|
return a.memory.base() < b.memory.base();
|
|
|
|
}
|
|
|
|
|
2013-01-03 13:00:59 +00:00
|
|
|
} } // namespace QQmlJS::VM
|
2013-01-02 15:43:47 +00:00
|
|
|
|
2012-12-04 12:40:18 +00:00
|
|
|
MemoryManager::MemoryManager()
|
|
|
|
: m_d(new Data(true))
|
|
|
|
{
|
2013-01-02 14:25:25 +00:00
|
|
|
setEnableGC(true);
|
2012-12-04 12:40:18 +00:00
|
|
|
}
|
|
|
|
|
2013-01-02 21:09:31 +00:00
|
|
|
Managed *MemoryManager::alloc(std::size_t size)
|
2012-12-04 12:40:18 +00:00
|
|
|
{
|
|
|
|
if (m_d->aggressiveGC)
|
|
|
|
runGC();
|
|
|
|
#ifdef DETAILED_MM_STATS
|
|
|
|
willAllocate(size);
|
|
|
|
#endif // DETAILED_MM_STATS
|
|
|
|
|
|
|
|
assert(size >= 16);
|
|
|
|
assert(size % 16 == 0);
|
|
|
|
|
2012-12-13 22:46:51 +00:00
|
|
|
size_t pos = size >> 4;
|
2012-12-04 12:40:18 +00:00
|
|
|
|
2012-12-13 22:46:51 +00:00
|
|
|
// fits into a small bucket
|
2013-01-02 15:43:47 +00:00
|
|
|
assert(size < MemoryManager::Data::MaxItemSize);
|
2012-12-04 12:40:18 +00:00
|
|
|
|
2013-01-02 21:09:31 +00:00
|
|
|
Managed *m = m_d->smallItems[pos];
|
2013-01-02 15:43:47 +00:00
|
|
|
if (m)
|
|
|
|
goto found;
|
2012-12-13 22:46:51 +00:00
|
|
|
|
2013-01-02 15:43:47 +00:00
|
|
|
// try to free up space, otherwise allocate
|
2013-01-14 15:15:01 +00:00
|
|
|
if (!m_d->aggressiveGC) {
|
2013-01-02 21:09:31 +00:00
|
|
|
runGC();
|
2013-01-14 15:15:01 +00:00
|
|
|
m = m_d->smallItems[pos];
|
|
|
|
if (m)
|
|
|
|
goto found;
|
|
|
|
}
|
2012-12-13 22:46:51 +00:00
|
|
|
|
2013-01-02 15:43:47 +00:00
|
|
|
// no free item available, allocate a new chunk
|
|
|
|
{
|
2013-01-30 07:58:27 +00:00
|
|
|
// allocate larger chunks at a time to avoid excessive GC, but cap at 64M chunks
|
|
|
|
uint shift = ++m_d->nChunks[pos];
|
|
|
|
if (shift > 10)
|
|
|
|
shift = 10;
|
|
|
|
std::size_t allocSize = std::max(size, CHUNK_SIZE*(1 << shift));
|
2013-01-02 15:43:47 +00:00
|
|
|
allocSize = roundUpToMultipleOf(WTF::pageSize(), allocSize);
|
|
|
|
Data::Chunk allocation;
|
|
|
|
allocation.memory = PageAllocation::allocate(allocSize, OSAllocator::JSGCHeapPages);
|
|
|
|
allocation.chunkSize = size;
|
|
|
|
m_d->heapChunks.append(allocation);
|
|
|
|
qSort(m_d->heapChunks);
|
|
|
|
char *chunk = (char *)allocation.memory.base();
|
|
|
|
char *end = chunk + allocation.memory.size() - size;
|
2013-01-28 15:46:09 +00:00
|
|
|
memset(chunk, 0, allocation.memory.size());
|
2013-01-02 21:09:31 +00:00
|
|
|
Managed **last = &m_d->smallItems[pos];
|
2013-01-02 15:43:47 +00:00
|
|
|
while (chunk <= end) {
|
2013-01-02 21:09:31 +00:00
|
|
|
Managed *o = reinterpret_cast<Managed *>(chunk);
|
|
|
|
o->inUse = 0;
|
|
|
|
o->markBit = 0;
|
2013-01-02 15:43:47 +00:00
|
|
|
*last = o;
|
2013-01-02 21:09:31 +00:00
|
|
|
last = &o->nextFree;
|
2013-01-02 15:43:47 +00:00
|
|
|
chunk += size;
|
|
|
|
}
|
2013-01-02 21:09:31 +00:00
|
|
|
*last = 0;
|
2013-01-02 15:43:47 +00:00
|
|
|
m = m_d->smallItems[pos];
|
2012-12-04 12:40:18 +00:00
|
|
|
}
|
|
|
|
|
2013-01-02 15:43:47 +00:00
|
|
|
found:
|
2013-01-02 21:09:31 +00:00
|
|
|
m_d->smallItems[pos] = m->nextFree;
|
2012-12-04 12:40:18 +00:00
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2013-01-02 21:09:31 +00:00
|
|
|
void MemoryManager::scribble(Managed *obj, int c, int size) const
|
2012-12-04 12:40:18 +00:00
|
|
|
{
|
|
|
|
if (m_d->scribble)
|
2013-01-08 11:57:45 +00:00
|
|
|
::memset((void *)(obj + 1), c, size - sizeof(Managed));
|
2012-12-04 12:40:18 +00:00
|
|
|
}
|
|
|
|
|
2013-01-28 15:46:09 +00:00
|
|
|
void MemoryManager::mark()
|
2012-12-04 12:40:18 +00:00
|
|
|
{
|
2013-01-28 15:46:09 +00:00
|
|
|
m_d->engine->markObjects();
|
|
|
|
|
|
|
|
for (ExecutionContext *ctxt = engine()->current; ctxt; ctxt = ctxt->parent)
|
|
|
|
ctxt->mark();
|
|
|
|
|
|
|
|
for (QHash<Managed *, uint>::const_iterator it = m_d->protectedObject.begin(); it != m_d->protectedObject.constEnd(); ++it)
|
|
|
|
it.key()->mark();
|
|
|
|
|
|
|
|
collectFromStack();
|
2012-12-04 12:40:18 +00:00
|
|
|
|
2013-01-25 11:43:44 +00:00
|
|
|
return;
|
2012-12-04 12:40:18 +00:00
|
|
|
}
|
|
|
|
|
2013-01-02 15:43:47 +00:00
|
|
|
std::size_t MemoryManager::sweep()
|
2012-12-04 12:40:18 +00:00
|
|
|
{
|
|
|
|
std::size_t freedCount = 0;
|
|
|
|
|
2013-01-02 15:43:47 +00:00
|
|
|
for (QVector<Data::Chunk>::iterator i = m_d->heapChunks.begin(), ei = m_d->heapChunks.end(); i != ei; ++i)
|
|
|
|
freedCount += sweep(reinterpret_cast<char*>(i->memory.base()), i->memory.size(), i->chunkSize);
|
2012-12-04 12:40:18 +00:00
|
|
|
|
|
|
|
return freedCount;
|
|
|
|
}
|
|
|
|
|
2013-01-02 15:43:47 +00:00
|
|
|
std::size_t MemoryManager::sweep(char *chunkStart, std::size_t chunkSize, size_t size)
|
2012-12-04 12:40:18 +00:00
|
|
|
{
|
2013-01-22 16:24:25 +00:00
|
|
|
// qDebug("chunkStart @ %p, size=%x, pos=%x (%x)", chunkStart, size, size>>4, m_d->smallItems[size >> 4]);
|
2012-12-04 12:40:18 +00:00
|
|
|
std::size_t freedCount = 0;
|
|
|
|
|
2013-01-02 21:09:31 +00:00
|
|
|
Managed **f = &m_d->smallItems[size >> 4];
|
|
|
|
|
2013-01-02 15:43:47 +00:00
|
|
|
for (char *chunk = chunkStart, *chunkEnd = chunk + chunkSize - size; chunk <= chunkEnd; ) {
|
2013-01-02 21:09:31 +00:00
|
|
|
Managed *m = reinterpret_cast<Managed *>(chunk);
|
2012-12-04 12:40:18 +00:00
|
|
|
// qDebug("chunk @ %p, size = %lu, in use: %s, mark bit: %s",
|
2013-01-02 21:09:31 +00:00
|
|
|
// chunk, m->size, (m->inUse ? "yes" : "no"), (m->markBit ? "true" : "false"));
|
2012-12-04 12:40:18 +00:00
|
|
|
|
|
|
|
assert((intptr_t) chunk % 16 == 0);
|
|
|
|
|
2013-01-02 15:43:47 +00:00
|
|
|
chunk = chunk + size;
|
2013-01-02 21:09:31 +00:00
|
|
|
if (m->inUse) {
|
|
|
|
if (m->markBit) {
|
|
|
|
m->markBit = 0;
|
2012-12-04 12:40:18 +00:00
|
|
|
} else {
|
2013-01-22 16:24:25 +00:00
|
|
|
// qDebug() << "-- collecting it." << m << *f << &m->nextFree;
|
2013-01-02 21:09:31 +00:00
|
|
|
m->~Managed();
|
|
|
|
|
|
|
|
m->nextFree = *f;
|
|
|
|
f = &m->nextFree;
|
|
|
|
//scribble(m, 0x99, size);
|
2012-12-04 12:40:18 +00:00
|
|
|
++freedCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return freedCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MemoryManager::isGCBlocked() const
|
|
|
|
{
|
|
|
|
return m_d->gcBlocked;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MemoryManager::setGCBlocked(bool blockGC)
|
|
|
|
{
|
|
|
|
m_d->gcBlocked = blockGC;
|
|
|
|
}
|
|
|
|
|
2013-01-02 15:43:47 +00:00
|
|
|
void MemoryManager::runGC()
|
2012-12-04 12:40:18 +00:00
|
|
|
{
|
|
|
|
if (!m_d->enableGC || m_d->gcBlocked) {
|
|
|
|
// qDebug() << "Not running GC.";
|
2013-01-02 15:43:47 +00:00
|
|
|
return;
|
2012-12-04 12:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// QTime t; t.start();
|
|
|
|
|
2013-01-02 15:43:47 +00:00
|
|
|
// qDebug() << ">>>>>>>>runGC";
|
2012-12-04 12:40:18 +00:00
|
|
|
|
2013-01-28 15:46:09 +00:00
|
|
|
mark();
|
2012-12-04 12:40:18 +00:00
|
|
|
// std::cerr << "GC: marked " << marks
|
|
|
|
// << " objects in " << t.elapsed()
|
|
|
|
// << "ms" << std::endl;
|
|
|
|
|
|
|
|
// t.restart();
|
2013-01-02 15:43:47 +00:00
|
|
|
/*std::size_t freedCount =*/ sweep();
|
2012-12-04 12:40:18 +00:00
|
|
|
// std::cerr << "GC: sweep freed " << freedCount
|
|
|
|
// << " objects in " << t.elapsed()
|
|
|
|
// << "ms" << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MemoryManager::setEnableGC(bool enableGC)
|
|
|
|
{
|
|
|
|
m_d->enableGC = enableGC;
|
|
|
|
}
|
|
|
|
|
|
|
|
MemoryManager::~MemoryManager()
|
|
|
|
{
|
2013-01-02 15:43:47 +00:00
|
|
|
sweep();
|
2012-12-04 12:40:18 +00:00
|
|
|
}
|
|
|
|
|
2013-01-28 12:32:08 +00:00
|
|
|
void MemoryManager::protect(Managed *m)
|
|
|
|
{
|
|
|
|
++m_d->protectedObject[m];
|
|
|
|
}
|
|
|
|
|
|
|
|
void MemoryManager::unprotect(Managed *m)
|
|
|
|
{
|
|
|
|
if (!--m_d->protectedObject[m])
|
|
|
|
m_d->protectedObject.remove(m);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void add(QVector<Managed *> &values, const Value &v)
|
2012-12-04 12:40:18 +00:00
|
|
|
{
|
|
|
|
if (Object *o = v.asObject())
|
|
|
|
values.append(o);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MemoryManager::setExecutionEngine(ExecutionEngine *engine)
|
|
|
|
{
|
|
|
|
m_d->engine = engine;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MemoryManager::dumpStats() const
|
|
|
|
{
|
2013-01-25 18:32:30 +00:00
|
|
|
#ifdef DETAILED_MM_STATS
|
2012-12-04 12:40:18 +00:00
|
|
|
std::cerr << "=================" << std::endl;
|
|
|
|
std::cerr << "Allocation stats:" << std::endl;
|
|
|
|
std::cerr << "Requests for each chunk size:" << std::endl;
|
|
|
|
for (int i = 0; i < m_d->allocSizeCounters.size(); ++i) {
|
|
|
|
if (unsigned count = m_d->allocSizeCounters[i]) {
|
|
|
|
std::cerr << "\t" << (i << 4) << " bytes chunks: " << count << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // DETAILED_MM_STATS
|
|
|
|
}
|
|
|
|
|
|
|
|
ExecutionEngine *MemoryManager::engine() const
|
|
|
|
{
|
|
|
|
return m_d->engine;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DETAILED_MM_STATS
|
|
|
|
void MemoryManager::willAllocate(std::size_t size)
|
|
|
|
{
|
|
|
|
unsigned alignedSize = (size + 15) >> 4;
|
|
|
|
QVector<unsigned> &counters = m_d->allocSizeCounters;
|
|
|
|
if ((unsigned) counters.size() < alignedSize + 1)
|
|
|
|
counters.resize(alignedSize + 1);
|
|
|
|
counters[alignedSize]++;
|
|
|
|
}
|
2012-12-13 22:46:51 +00:00
|
|
|
|
2012-12-04 12:40:18 +00:00
|
|
|
#endif // DETAILED_MM_STATS
|
|
|
|
|
2013-01-28 15:46:09 +00:00
|
|
|
void MemoryManager::collectFromStack() const
|
2012-12-08 17:22:25 +00:00
|
|
|
{
|
2012-12-17 21:43:22 +00:00
|
|
|
if (!m_d->heapChunks.count())
|
|
|
|
return;
|
2013-01-02 21:09:31 +00:00
|
|
|
|
2013-01-28 15:46:09 +00:00
|
|
|
quintptr valueOnStack = 0;
|
2013-01-03 12:50:10 +00:00
|
|
|
|
|
|
|
#if USE(PTHREADS)
|
|
|
|
#if OS(DARWIN)
|
2013-01-28 15:46:09 +00:00
|
|
|
void* stackTop = 0;
|
2013-01-03 12:50:10 +00:00
|
|
|
stackTop = pthread_get_stackaddr_np(pthread_self());
|
2013-01-28 15:46:09 +00:00
|
|
|
quintptr *top = static_cast<quintptr *>(stackTop);
|
2013-01-03 12:50:10 +00:00
|
|
|
#else
|
2013-01-28 15:46:09 +00:00
|
|
|
void* stackBottom = 0;
|
2013-01-03 12:50:10 +00:00
|
|
|
pthread_attr_t attr;
|
|
|
|
pthread_getattr_np(pthread_self(), &attr);
|
|
|
|
size_t stackSize = 0;
|
2013-01-28 15:46:09 +00:00
|
|
|
pthread_attr_getstack(&attr, &stackBottom, &stackSize);
|
|
|
|
pthread_attr_destroy(&attr);
|
|
|
|
|
|
|
|
quintptr *top = static_cast<quintptr *>(stackBottom) + stackSize/sizeof(quintptr);
|
2013-01-03 12:50:10 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2013-01-28 15:46:09 +00:00
|
|
|
// qDebug() << "stack:" << hex << stackTop << stackSize << (stackTop + stackSize);
|
2013-01-03 12:50:10 +00:00
|
|
|
|
2013-01-28 15:46:09 +00:00
|
|
|
quintptr *current = (&valueOnStack) + 1;
|
|
|
|
// qDebug() << "collectFromStack" << top << current << &valueOnStack;
|
2012-12-17 21:43:22 +00:00
|
|
|
|
|
|
|
char** heapChunkBoundaries = (char**)alloca(m_d->heapChunks.count() * 2 * sizeof(char*));
|
|
|
|
char** heapChunkBoundariesEnd = heapChunkBoundaries + 2 * m_d->heapChunks.count();
|
|
|
|
int i = 0;
|
2013-01-02 15:43:47 +00:00
|
|
|
for (QVector<Data::Chunk>::Iterator it = m_d->heapChunks.begin(), end =
|
2012-12-17 21:43:22 +00:00
|
|
|
m_d->heapChunks.end(); it != end; ++it) {
|
2013-01-02 15:43:47 +00:00
|
|
|
heapChunkBoundaries[i++] = reinterpret_cast<char*>(it->memory.base());
|
|
|
|
heapChunkBoundaries[i++] = reinterpret_cast<char*>(it->memory.base()) + it->memory.size();
|
2012-12-17 21:43:22 +00:00
|
|
|
}
|
|
|
|
|
2012-12-18 07:08:31 +00:00
|
|
|
for (; current < top; ++current) {
|
2013-01-28 15:46:09 +00:00
|
|
|
char* genericPtr =
|
|
|
|
#if CPU(X86_64)
|
|
|
|
reinterpret_cast<char *>((*current) & ~(quint64(Value::Type_Mask) << Value::Tag_Shift));
|
|
|
|
#else
|
|
|
|
reinterpret_cast<char *>(*current);
|
|
|
|
#endif
|
2013-01-02 15:43:47 +00:00
|
|
|
|
2012-12-17 21:43:22 +00:00
|
|
|
if (genericPtr < *heapChunkBoundaries || genericPtr >= *(heapChunkBoundariesEnd - 1))
|
|
|
|
continue;
|
|
|
|
int index = qLowerBound(heapChunkBoundaries, heapChunkBoundariesEnd, genericPtr) - heapChunkBoundaries;
|
|
|
|
// An odd index means the pointer is _before_ the end of a heap chunk and therefore valid.
|
|
|
|
if (index & 1) {
|
2013-01-02 15:43:47 +00:00
|
|
|
int size = m_d->heapChunks.at(index >> 1).chunkSize;
|
2013-01-28 15:46:09 +00:00
|
|
|
Managed *m = reinterpret_cast<Managed *>(genericPtr);
|
|
|
|
// qDebug() << " inside" << size << m;
|
2013-01-02 15:43:47 +00:00
|
|
|
|
|
|
|
if (((quintptr)m - (quintptr)heapChunkBoundaries[index-1]) % size)
|
|
|
|
// wrongly aligned value, skip it
|
|
|
|
continue;
|
|
|
|
|
2013-01-02 21:09:31 +00:00
|
|
|
if (!m->inUse)
|
2013-01-02 15:43:47 +00:00
|
|
|
// Skip pointers to already freed objects, they are bogus as well
|
|
|
|
continue;
|
|
|
|
|
2013-01-28 15:46:09 +00:00
|
|
|
m->mark();
|
|
|
|
// qDebug() << " marking";
|
2012-12-17 21:43:22 +00:00
|
|
|
}
|
2012-12-08 17:22:25 +00:00
|
|
|
}
|
|
|
|
}
|