aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/memory
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-01-03 11:38:00 +0100
committerLars Knoll <lars.knoll@qt.io>2017-01-22 11:50:36 +0000
commit94e6106d357ca5a1349a2b10a69dd84db34065c8 (patch)
tree30e139e2eca3d950c69efeb148dcc5a1be00ab4d /src/qml/memory
parent2f16dd7b1415995109bc44b925cf860236977776 (diff)
Simplify handling of non GC managed heap data
Let the destroy() method in QV4::String clean up the unmanaged heap size instead of having a special hook in the code that sweeps the GC heap. Change-Id: I989ee99604f0cc67b896d3acc94e200dd5e56a60 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/memory')
-rw-r--r--src/qml/memory/qv4mm.cpp15
-rw-r--r--src/qml/memory/qv4mm_p.h2
2 files changed, 4 insertions, 13 deletions
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp
index 8732b02685..51eb82059a 100644
--- a/src/qml/memory/qv4mm.cpp
+++ b/src/qml/memory/qv4mm.cpp
@@ -194,10 +194,8 @@ struct MemoryManager::Data
namespace {
-bool sweepChunk(MemoryManager::Data::ChunkHeader *header, uint *itemsInUse, ExecutionEngine *engine, std::size_t *unmanagedHeapSize)
+bool sweepChunk(MemoryManager::Data::ChunkHeader *header, uint *itemsInUse, ExecutionEngine *engine)
{
- Q_ASSERT(unmanagedHeapSize);
-
bool isEmpty = true;
Heap::Base *tail = &header->freeItems;
// qDebug("chunkStart @ %p, size=%x, pos=%x", header->itemStart, header->itemSize, header->itemSize>>4);
@@ -222,13 +220,6 @@ bool sweepChunk(MemoryManager::Data::ChunkHeader *header, uint *itemsInUse, Exec
#ifdef V4_USE_VALGRIND
VALGRIND_ENABLE_ERROR_REPORTING;
#endif
- if (std::size_t(header->itemSize) == MemoryManager::align(sizeof(Heap::String)) && m->vtable()->isString) {
- std::size_t heapBytes = static_cast<Heap::String *>(m)->retainedTextSize();
- Q_ASSERT(*unmanagedHeapSize >= heapBytes);
-// qDebug() << "-- it's a string holding on to" << heapBytes << "bytes";
- *unmanagedHeapSize -= heapBytes;
- }
-
if (m->vtable()->destroy) {
m->vtable()->destroy(m);
m->_checkIsDestroyed();
@@ -502,7 +493,7 @@ void MemoryManager::sweep(bool lastSweep)
for (size_t i = 0; i < m_d->heapChunks.size(); ++i) {
Data::ChunkHeader *header = reinterpret_cast<Data::ChunkHeader *>(m_d->heapChunks[i].base());
- chunkIsEmpty[i] = sweepChunk(header, &itemsInUse[header->itemSize >> 4], engine, &m_d->unmanagedHeapSize);
+ chunkIsEmpty[i] = sweepChunk(header, &itemsInUse[header->itemSize >> 4], engine);
}
std::vector<PageAllocation>::iterator chunkIter = m_d->heapChunks.begin();
@@ -642,7 +633,7 @@ size_t MemoryManager::getLargeItemsMem() const
return total;
}
-void MemoryManager::growUnmanagedHeapSizeUsage(size_t delta)
+void MemoryManager::changeUnmanagedHeapSizeUsage(qptrdiff delta)
{
m_d->unmanagedHeapSize += delta;
}
diff --git a/src/qml/memory/qv4mm_p.h b/src/qml/memory/qv4mm_p.h
index 86a0ba2735..e6417cb2e0 100644
--- a/src/qml/memory/qv4mm_p.h
+++ b/src/qml/memory/qv4mm_p.h
@@ -297,7 +297,7 @@ public:
size_t getAllocatedMem() const;
size_t getLargeItemsMem() const;
- void growUnmanagedHeapSizeUsage(size_t delta); // called when a JS object grows itself. Specifically: Heap::String::append
+ void changeUnmanagedHeapSizeUsage(qptrdiff delta); // called when a JS object grows itself. Specifically: Heap::String::append
protected:
/// expects size to be aligned