diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-10-07 13:47:52 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-10-07 12:47:24 +0000 |
commit | a6be2d77aa6dc9f834b971eaff749a02cf982525 (patch) | |
tree | f147298d1a526eb0405f1b2e5ebaad5aa06c8681 | |
parent | 57c9d6969ac474177c77d5ea59768b39620a3b2f (diff) |
V4: Move zero-initialization of heap items into the header file
This allows for a compiler to do dead-store elimination for zero-
initialized memory that gets overwritten directly after the allocated
chunk is returned.
Change-Id: I6493aae8fdabc2306e7cfa1233f917b1775c4451
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r-- | src/qml/memory/qv4mm.cpp | 2 | ||||
-rw-r--r-- | src/qml/memory/qv4mm_p.h | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp index ad4ecfe76d..5aaf710ee8 100644 --- a/src/qml/memory/qv4mm.cpp +++ b/src/qml/memory/qv4mm.cpp @@ -234,7 +234,7 @@ bool sweepChunk(MemoryManager::Data::ChunkHeader *header, uint *itemsInUse, Exec m->_checkIsDestroyed(); } - memset(m, 0, header->itemSize); + memset(m, 0, sizeof(Heap::Base)); #ifdef V4_USE_VALGRIND VALGRIND_DISABLE_ERROR_REPORTING; VALGRIND_MEMPOOL_FREE(engine->memoryManager, m); diff --git a/src/qml/memory/qv4mm_p.h b/src/qml/memory/qv4mm_p.h index e68fc07a46..dfa0d85dff 100644 --- a/src/qml/memory/qv4mm_p.h +++ b/src/qml/memory/qv4mm_p.h @@ -111,6 +111,7 @@ public: V4_ASSERT_IS_TRIVIAL(typename ManagedType::Data) size = align(size); Heap::Base *o = allocData(size, unmanagedSize); + memset(o, 0, size); o->setVtable(ManagedType::staticVTable()); return static_cast<typename ManagedType::Data *>(o); } |