diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-12-12 11:41:21 +0100 |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-12-12 11:56:12 +0100 |
commit | 2a6f6eee104ef66e4e236fa82fe71bb77f151ee8 (patch) | |
tree | 699fa20bf35fbba6499a90c1042e6d9b438c5a0f /src/qml/jsruntime/qv4mm.cpp | |
parent | f9a00808991b01f5c3b473e9ec5d309b25b230b9 (diff) |
Fix the V4 valgrind integration
87a055bc8eee653a18d51f94a546cd452732223a broke the build and
introduced invalid writes to chunks outside of the existing
VALGRIND_DISABLE_ERROR_REPORTING block.
Fix the build by using MemoryManager::Data* instead of MemoryManager*
as the pool argument to VALGRIND MEMPOOL calls since the Data pointer
is protected.
Change-Id: I24136e25291570ade825dcd84a9568d8169a235b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4mm.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4mm.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/qml/jsruntime/qv4mm.cpp b/src/qml/jsruntime/qv4mm.cpp index c66a436454..451b5b8b7b 100644 --- a/src/qml/jsruntime/qv4mm.cpp +++ b/src/qml/jsruntime/qv4mm.cpp @@ -171,7 +171,7 @@ struct ChunkSweepData { bool isEmpty; }; -void sweepChunk(const MemoryManager::Data::Chunk &chunk, ChunkSweepData *sweepData, uint *itemsInUse, ExecutionEngine *engine) +void sweepChunk(const MemoryManager::Data::Chunk &chunk, ChunkSweepData *sweepData, uint *itemsInUse, MemoryManager::Data *data) { char *chunkStart = reinterpret_cast<char*>(chunk.memory.base()); std::size_t itemSize = chunk.chunkSize; @@ -204,9 +204,9 @@ void sweepChunk(const MemoryManager::Data::Chunk &chunk, ChunkSweepData *sweepDa memset(m, 0, itemSize); #ifdef V4_USE_VALGRIND VALGRIND_DISABLE_ERROR_REPORTING; - VALGRIND_MEMPOOL_FREE(this, m); + VALGRIND_MEMPOOL_FREE(data, m); #endif - Q_V4_PROFILE_DEALLOC(engine, m, itemSize, Profiling::SmallItem); + Q_V4_PROFILE_DEALLOC(data->engine, m, itemSize, Profiling::SmallItem); ++(*itemsInUse); } // Relink all free blocks to rewrite references to any released chunk. @@ -227,7 +227,7 @@ MemoryManager::MemoryManager() , m_weakValues(0) { #ifdef V4_USE_VALGRIND - VALGRIND_CREATE_MEMPOOL(this, 0, true); + VALGRIND_CREATE_MEMPOOL(m_d.data(), 0, true); #endif } @@ -310,7 +310,7 @@ Heap::Base *MemoryManager::allocData(std::size_t size) found: #ifdef V4_USE_VALGRIND - VALGRIND_MEMPOOL_ALLOC(this, m, size); + VALGRIND_MEMPOOL_ALLOC(m_d.data(), m, size); #endif Q_V4_PROFILE_ALLOC(m_d->engine, size, Profiling::SmallItem); @@ -427,14 +427,17 @@ void MemoryManager::sweep(bool lastSweep) for (int i = 0; i < m_d->heapChunks.size(); ++i) { const MemoryManager::Data::Chunk &chunk = m_d->heapChunks[i]; - sweepChunk(chunk, &chunkSweepData[i], &itemsInUse[chunk.chunkSize >> 4], m_d->engine); + sweepChunk(chunk, &chunkSweepData[i], &itemsInUse[chunk.chunkSize >> 4], m_d.data()); } - Heap::Base** tails[MemoryManager::Data::MaxItemSize/16]; + Heap::Base **tails[MemoryManager::Data::MaxItemSize/16]; memset(m_d->smallItems, 0, sizeof(m_d->smallItems)); for (int pos = 0; pos < MemoryManager::Data::MaxItemSize/16; ++pos) tails[pos] = &m_d->smallItems[pos]; +#ifdef V4_USE_VALGRIND + VALGRIND_DISABLE_ERROR_REPORTING; +#endif QVector<Data::Chunk>::iterator chunkIter = m_d->heapChunks.begin(); for (int i = 0; i < chunkSweepData.size(); ++i) { Q_ASSERT(chunkIter != m_d->heapChunks.end()); @@ -458,6 +461,9 @@ void MemoryManager::sweep(bool lastSweep) } for (int pos = 0; pos < MemoryManager::Data::MaxItemSize/16; ++pos) *tails[pos] = 0; +#ifdef V4_USE_VALGRIND + VALGRIND_ENABLE_ERROR_REPORTING; +#endif Data::LargeItem *i = m_d->largeItems; Data::LargeItem **last = &m_d->largeItems; @@ -585,7 +591,7 @@ MemoryManager::~MemoryManager() sweep(/*lastSweep*/true); #ifdef V4_USE_VALGRIND - VALGRIND_DESTROY_MEMPOOL(this); + VALGRIND_DESTROY_MEMPOOL(m_d.data()); #endif } |