std::sort(m_d->heapChunks.begin(), m_d->heapChunks.end());
char *chunk = (char *)allocation.memory.base();
char *end = chunk + allocation.memory.size() - size;
+#ifndef QT_NO_DEBUG
memset(chunk, 0, allocation.memory.size());
+#endif
Managed **last = &m_d->smallItems[pos];
while (chunk <= end) {
Managed *o = reinterpret_cast<Managed *>(chunk);
}
}
-std::size_t MemoryManager::sweep(bool lastSweep)
+void MemoryManager::sweep(bool lastSweep)
{
PersistentValuePrivate *weak = m_weakValues;
while (weak) {
}
}
- std::size_t freedCount = 0;
GCDeletable *deletable = 0;
GCDeletable **firstDeletable = &deletable;
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, &deletable);
+ sweep(reinterpret_cast<char*>(i->memory.base()), i->memory.size(), i->chunkSize, &deletable);
ExecutionContext *ctx = m_contextList;
ExecutionContext **n = &m_contextList;
delete deletable;
deletable = next;
}
-
- return freedCount;
}
-std::size_t MemoryManager::sweep(char *chunkStart, std::size_t chunkSize, size_t size, GCDeletable **deletable)
+void MemoryManager::sweep(char *chunkStart, std::size_t chunkSize, size_t size, GCDeletable **deletable)
{
// qDebug("chunkStart @ %p, size=%x, pos=%x (%x)", chunkStart, size, size>>4, m_d->smallItems[size >> 4]);
- std::size_t freedCount = 0;
-
Managed **f = &m_d->smallItems[size >> 4];
#ifdef V4_USE_VALGRIND
#endif
*f = m;
SCRIBBLE(m, 0x99, size);
- ++freedCount;
}
}
}
#ifdef V4_USE_VALGRIND
VALGRIND_ENABLE_ERROR_REPORTING;
#endif
-
- return freedCount;
}
bool MemoryManager::isGCBlocked() const
void collectFromStack() const;
void collectFromJSStack() const;
void mark();
- std::size_t sweep(bool lastSweep = false);
- std::size_t sweep(char *chunkStart, std::size_t chunkSize, size_t size, GCDeletable **deletable);
+ void sweep(bool lastSweep = false);
+ void sweep(char *chunkStart, std::size_t chunkSize, size_t size, GCDeletable **deletable);
protected:
QScopedPointer<Data> m_d;
{
Object *o = static_cast<Object *>(that);
- for (int i = 0; i < o->internalClass->size; ++i) {
- const Property &pd = o->memberData[i];
- if (o->internalClass->propertyData[i].isData()) {
- if (Managed *m = pd.value.asManaged())
- m->mark();
- } else {
- if (pd.getter())
- pd.getter()->mark();
- if (pd.setter())
- pd.setter()->mark();
+ if (!o->hasAccessorProperty) {
+ for (int i = 0; i < o->internalClass->size; ++i)
+ o->memberData[i].value.mark();
+ } else {
+ for (int i = 0; i < o->internalClass->size; ++i) {
+ const Property &pd = o->memberData[i];
+ if (o->internalClass->propertyData[i].isAccessor()) {
+ if (pd.getter())
+ pd.getter()->mark();
+ if (pd.setter())
+ pd.setter()->mark();
+ } else {
+ pd.value.mark();
+ }
+ }
+ }
+ if (o->flags & SimpleArray) {
+ for (uint i = 0; i < o->arrayDataLen; ++i)
+ o->arrayData[i].value.mark();
+ return;
+ } else {
+ for (uint i = 0; i < o->arrayDataLen; ++i) {
+ const Property &pd = o->arrayData[i];
+ if (o->arrayAttributes && o->arrayAttributes[i].isAccessor()) {
+ if (pd.getter())
+ pd.getter()->mark();
+ if (pd.setter())
+ pd.setter()->mark();
+ } else {
+ pd.value.mark();
+ }
}
}
- o->markArrayObjects();
}
void Object::ensureMemberIndex(uint idx)
return ok;
}
-void Object::markArrayObjects() const
-{
- for (uint i = 0; i < arrayDataLen; ++i) {
- const Property &pd = arrayData[i];
- if (!arrayAttributes || arrayAttributes[i].isData()) {
- if (Managed *m = pd.value.asManaged())
- m->mark();
- } else if (arrayAttributes[i].isAccessor()) {
- if (pd.getter())
- pd.getter()->mark();
- if (pd.setter())
- pd.setter()->mark();
- }
- }
-}
-
DEFINE_MANAGED_VTABLE(ArrayObject);
ArrayObject::ArrayObject(ExecutionEngine *engine, const QStringList &list)
return arrayData + index;
}
- void markArrayObjects() const;
-
void push_back(const ValueRef v);
SparseArrayNode *sparseArrayBegin() { return sparseArray ? sparseArray->begin() : 0; }