diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-03-12 21:02:14 +0100 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-03-12 21:02:14 +0100 |
commit | 3f4496ecea2cb1cb773c899675a6ecd0ef6183d5 (patch) | |
tree | a55813fb4fbe24fe0b1e1446abe29fd0818df576 /src/qml/memory | |
parent | 31e64606f253663f8ee2032b94521afd1804ab11 (diff) | |
parent | 4c689ad93d06bcfff5dfc4fdc41c69767aa04bee (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: I6b2568337c09ff98850b4ecccccc9a8fc25064cd
Diffstat (limited to 'src/qml/memory')
-rw-r--r-- | src/qml/memory/qv4mm.cpp | 25 | ||||
-rw-r--r-- | src/qml/memory/qv4mm_p.h | 2 |
2 files changed, 24 insertions, 3 deletions
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp index cdda0bf7ef..4e83abebdf 100644 --- a/src/qml/memory/qv4mm.cpp +++ b/src/qml/memory/qv4mm.cpp @@ -664,8 +664,21 @@ void BlockAllocator::collectGrayItems(MarkStack *markStack) } HeapItem *HugeItemAllocator::allocate(size_t size) { - Chunk *c = chunkAllocator->allocate(size); - chunks.push_back(HugeChunk{c, size}); + MemorySegment *m = nullptr; + Chunk *c = nullptr; + if (size >= MemorySegment::SegmentSize/2) { + // too large to handle through the ChunkAllocator, let's get our own memory segement + size_t segmentSize = size + Chunk::HeaderSize; // space required for the Chunk header + size_t pageSize = WTF::pageSize(); + segmentSize = (segmentSize + pageSize - 1) & ~(pageSize - 1); // align to page sizes + m = new MemorySegment(segmentSize); + size = (size + pageSize - 1) & ~(pageSize - 1); // align to page sizes + c = m->allocate(size); + } else { + c = chunkAllocator->allocate(size); + } + Q_ASSERT(c); + chunks.push_back(HugeChunk{m, c, size}); Chunk::setBit(c->objectBitmap, c->first() - c->realBase()); Q_V4_PROFILE_ALLOC(engine, size, Profiling::LargeItem); #ifdef V4_USE_HEAPTRACK @@ -686,7 +699,13 @@ static void freeHugeChunk(ChunkAllocator *chunkAllocator, const HugeItemAllocato v->destroy(b); b->_checkIsDestroyed(); } - chunkAllocator->free(c.chunk, c.size); + if (c.segment) { + // own memory segment + c.segment->free(c.chunk, c.size); + delete c.segment; + } else { + chunkAllocator->free(c.chunk, c.size); + } #ifdef V4_USE_HEAPTRACK heaptrack_report_free(c.chunk); #endif diff --git a/src/qml/memory/qv4mm_p.h b/src/qml/memory/qv4mm_p.h index 1ef54ffcc6..40670bcdc7 100644 --- a/src/qml/memory/qv4mm_p.h +++ b/src/qml/memory/qv4mm_p.h @@ -69,6 +69,7 @@ QT_BEGIN_NAMESPACE namespace QV4 { struct ChunkAllocator; +struct MemorySegment; struct BlockAllocator { BlockAllocator(ChunkAllocator *chunkAllocator, ExecutionEngine *engine) @@ -136,6 +137,7 @@ struct HugeItemAllocator { ChunkAllocator *chunkAllocator; ExecutionEngine *engine; struct HugeChunk { + MemorySegment *segment; Chunk *chunk; size_t size; }; |