aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/memory
Commit message (Collapse)AuthorAgeFilesLines
* Get rid of the MemoryManager pointer inside StringLars Knoll2017-05-191-1/+1
| | | | | | | We can always get the pointer through the internalClass. Change-Id: If68432845e7c67da70d9e19aef1a90ebe1e6056b Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
* Move the engine() accessor from Object to ManagedLars Knoll2017-05-191-2/+2
| | | | | | | | | | | | We can easily do this now that Managed has a pointer to an internal class (which always has a back pointer to the ExecutionEngine). Remove the extra engine pointer from ExecutionContext, and clean up tow methods in String. Change-Id: I98d750b1afbdeadf42e66ae0c92c48db1a7adc31 Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
* Move the prototype into the internal classLars Knoll2017-05-191-7/+12
| | | | | | | | | | This saves another pointer on all Objects. Currently introduces a slight performance regression on some of the v8 benchmarks, that needs addressing. Change-Id: I87de8e1d198d2683f4e903c467ce2a60ba542243 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move the internalClass field from Heap::Object to Heap::BaseLars Knoll2017-05-193-10/+20
| | | | | | | | | | | | And do not store the vtable in Heap::Base anymore. This change makes the internal class the main distinguishing feature of all garbage collected objects. It also saves one pointer on all Objects. No measurable impact on runtime performance. Change-Id: I040a28b7581b993f1886b5219e279173dfa567e8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move the EngineBase class into it's own header fileLars Knoll2017-05-191-35/+0
| | | | | Change-Id: Idf87618e4ebff99f3b3c269c950191d67a0182b2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move a few more members from ExecutionEngine to EngineBaseLars Knoll2017-05-191-0/+8
| | | | | Change-Id: I5d1e0d2251e04cc871f9c298849aafac17f23fbf Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Free up completely empty Chunks, and return the memory to the OSLars Knoll2017-05-192-9/+27
| | | | | | | | Detect any Chunk that's completely empty, deallocate it and return the memory to the OS (as far as that's supported). Change-Id: I6b6a77f2cdf478cbf16aad30a9cae37c98c6500e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Re-add some inline property storageLars Knoll2017-05-083-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | It turns out that not using any inline property storage comes at a relatively high price in terms of memory consumption, as we always need to also create a memberData for any object. This avoids the memberData creation in quite a few cases, as we use the additional padding we have up to the 32 byte boundary given by the memory manager to store some property data. This complicates property access somewhat. To avoid performance regressions because of this, add specialized QV4::Lookup functions that optimize for properties that are inline or in the memberData struct. Change seems to be performance neutral on v8-bench on x86_64, but reduces peak memory usage when running the benchmark by around 20%. Change-Id: I0127d31a2d6038aaa540c4c4a1156f45ca3b7464 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
* Fix memory leak in the memory managerLars Knoll2017-04-281-2/+32
| | | | | | | | | | | | | | | | | There was a bug in Chunk::sweep() that would lead to parts of the memory not being freed as it should have been. This happened when an object 'overflowed' into the next index of the estendBitmap, where we then would not correctly clear the extends bits. Fixes performance degradation in qmlbench's delegates_item_empty_jscreation.qml over multiple runs. Change-Id: Ia2cecd2ff218e4258a067a74631b5479589b7a7e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
* Fix GC corruption on macOS and possibly some other OSesLars Knoll2017-04-211-0/+7
| | | | | | | | | | | | | | | | Marking mmap'ed memory as unneeded, leads to it being zeroed out on both Linux and Windows. Unfortunately that behavior is not defined by POSIX, so BSD based OSes (and possible others as well) do not do this. We do however rely on getting zeroed out memory whenever we allocate a new Chunk for the garbage collector. To work around this, zero out memory we deallocate on those platforms. Task-number: QTBUG-59278 Task-number: QTBUG-59977 Change-Id: Idde812db8537b63b9e9df7de41620ce0df09b6de Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
* Merge "Merge remote-tracking branch 'origin/5.8' into 5.9" into refs/staging/5.9Simon Hausmann2017-03-251-1/+1
|\
| * Merge remote-tracking branch 'origin/5.8' into 5.9Simon Hausmann2017-03-151-1/+1
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qqmltypecompiler.cpp src/qml/compiler/qqmltypecompiler_p.h src/qml/qml/qqmltypeloader.cpp src/qml/qml/qqmltypeloader_p.h Change-Id: I4894555ab7a0879b56bbda7a46d16d1c40c19e7c
| | * Fix accidental assignment in assertionSimon Hausmann2017-03-131-1/+1
| | | | | | | | | | | | | | | | | | Change-Id: I5b63697c0607f4300b7f203eeac74914f3fb43af Reviewed-by: Holger Freyther <holger+qt@freyther.de> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Fix handling of huge memory segmentsLars Knoll2017-03-221-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allocating a MemorySegment larger than 4M was not working correctly. We would in this case reserve the right amount of memory, but where not able to use it, leading to an assertion in the HugeItemAllocator. Fix this by ensuring we can properly allocate the memory that was reserved in the Segment. Change-Id: I1e3d2b3beebdde0a509fd123ad2aa8b1bc35a26b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Complete transition to standard layout classes for JIT accessSimon Hausmann2017-03-211-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the Runtime function pointer array into EngineBase so that we can eliminate the last use of qOffsetOf. For improved cache locality the memory manager point is now also located in the EngineBase. Change-Id: I0b3cf44c726aa4fb8db1206cc414a56c2f522a84 Task-number: QTBUG-58666 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Protect ExecutionContext member usage against word size differencesSimon Hausmann2017-03-171-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ensure the offsets we're taking from ExecutionContext members in the JIT code generator can be translated from host architecture sizes to target architecture, using assertions and a memory layout that we already have in the dev branch with commit 4de7e48ab160dacc7a09360e80264eac4945a8f4. Task-number: QTBUG-58666 Change-Id: I26cdbd1ddb995b116624fab16f7caba5d21c13b5 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Fix running of 32-bit JIT code generated on 64-bit hostsSimon Hausmann2017-03-171-0/+20
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | The offsets of members encoded in JIT generated code differ between 32-bit and 64-bit architectures. This patch moves some of the ExecutionEngine members into a separate standard-layout EngineBase class (in line with the same class in commit 2a554434a571dcefd26cf10ef8c5ae8b3b7d66db and subject to merging). By ensuring that the members are stored at pointer intervals, we can translate from host pointer size to target when generating the code. Task-number: QTBUG-58666 Change-Id: I1c38a7da059826848b80fd9972ed073214501386 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Fix assert on QT_POINTER_SIZE != 8BogDan Vatra2017-02-151-1/+1
| | | | | | | | | | Change-Id: I8fa64fc8d67b6093eb368866d17d967644514577 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | QtQml/qv4mm.cpp: Fix type of debug helper lastAllocRequestedSlotsFriedemann Kleint2017-02-151-1/+1
| | | | | | | | | | | | | | | | | | | | Fix MSVC 64 developer build: memory\qv4mm.cpp(653): error C2220: warning treated as error - no 'object' file generated memory\qv4mm.cpp(653): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data memory\qv4mm.cpp(689): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data Change-Id: Ia8c28e960027877eb4d45f12db7406902e755c03 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Make better use of the remaining memory before calling GCLars Knoll2017-02-131-1/+19
| | | | | | | | | | | | | | | | | | | | Some slots still have free memory available. If we only need to allocate a small object, check if we can split up one of these slots before giving up and starting a GC cycle. Change-Id: I11fb9d53c607274dbb5fd0bc02088ed94bfe7c4e Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
* | Fix a bug in Chunk::sortIntoBins()Lars Knoll2017-02-131-58/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bug lead to us not sorting all freed memory into the bins for the allocator to find. The lead to memory being 'lost' in the garbage collector. Add an assertion that checks for lost memory when we're running with aggressive GC. Also make sure we don't run GC twice in a row when aggressive GC is enabled. Change-Id: I4fb6732acce8a2e66258fa70fb7d8f1f939cfd9f Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
* | Inline creation of simple call contextsLars Knoll2017-01-251-2/+9
| | | | | | | | | | | | | | And avoid zero initializing stuff that's already 0 Change-Id: If90a808815b2b735bab661d22cbd498acc96b029 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Get rid of the inline member data in ObjectLars Knoll2017-01-252-11/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead allocate a MemberData at the same time as the object if required. Turns out this is faster now, and significantly simplifies some of our internal logic to access member properties. In addition, we can properly setup the inline member size to use the full extent of the memory reserved by the memory manager. This avoid some needless reallocations of MemberData objects. Change-Id: I36daeeaf6df16f2268103662fc78d600b4058ef8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Let allocData/allocString return 0 initialized memoryLars Knoll2017-01-252-4/+6
| | | | | | | | | | | | | | | | | | | | | | There's no point in having the memset inline. In theory, the compiler could optimize by combining this with later on inline initialization code, in practice this doesn't happen anyway, and we have some options of avoiding or combing the memsets in the allocator. Change-Id: I4502ef947ae235223726269821f9482ad62e1070 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Get rid of MemoryManager::DataLars Knoll2017-01-252-55/+30
| | | | | | | | | | | | | | | | Inline the few remaining members into the MemoryManager class itself. Change-Id: If5fef74581daa89df3e8cc237329c27395ce2289 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Cleanup Heap::BaseLars Knoll2017-01-251-21/+3
| | | | | | | | | | | | | | | | Since the markbit is not stored in line anymore, we can now simply store the pointer to the vtable in the object. Change-Id: I81b616c825dd4f3f2140838daab1f62bd6ecc812 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | New garbage collectorLars Knoll2017-01-254-261/+407
| | | | | | | | | | | | | | | | | | | | | | | | | | This is a block based allocator. We allocate HeapItems from 64k Chunks (except for huge items that get their own chunk). The allocator is block based, and aims to defragment when sweep'ing the blocks. The mark bit is now stored in the Chunk header, not inline in the object anymore. Change-Id: I2845f8b73dd496911ba50b868d54d144501d41e4 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | New allocator for huge itemsLars Knoll2017-01-252-54/+73
| | | | | | | | | | | | | | Use a new Chunk based allocator for very large items. Change-Id: Ie61a72efb6340cd9ef54e4fdd957d7ca36c8729f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Allocate simple call contexts from a special allocatorLars Knoll2017-01-252-0/+97
| | | | | | | | | | | | | | | | | | | | | | | | We used to allocate those on the C stack, but this doesn't work anymore with the new GC, as the mark bit is not stored inside the object anymore. Instead use a special allocator for these contexts that operates like a stack. Change-Id: I381ac3914ca866945312a1e79883aefe72662d2c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Implement an allocator for ChunksLars Knoll2017-01-252-2/+173
| | | | | | | | | | Change-Id: I7c054cda95d016ce8bb0b341730378afc15a3522 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Always allocate in 64k chunksLars Knoll2017-01-251-40/+1
| | | | | | | | | | | | | | | | Cleans up the code a bit in preparation of the new GC. Has minimal effect on performance these days. Change-Id: Ifa6afea9acf8b6f086412e7eab7fa37c5387c624 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Align allocations to multiples of Chunk::SlotSizeLars Knoll2017-01-251-1/+2
| | | | | | | | | | Change-Id: I13612d055b50331afa5eb9a9b61f4fd2d29b90bd Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Add data structures that will get used for the new garbage collectorLars Knoll2017-01-252-2/+257
| | | | | | | | | | | | | | | | | | | | Chunk is a 64k block of memory and the basic structure used in the new GC. HeapItem is a pointer to a slot of unallocated memory. When allocating memory, a number of HeapItems will get converted to a the correct class derived from Heap::Base. Change-Id: Id7c606df2d32501702330fbb6fa68ec66f62d6f9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Simplify handling of non GC managed heap dataLars Knoll2017-01-222-13/+4
|/ | | | | | | | | 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>
* Get rid of the GCBlockerLars Knoll2016-12-282-32/+0
| | | | | | | | | It's a hack we needed when we still had a conservative GC, but it is not required anymore. The only thing we still need is the protection against running the GC recursively. Change-Id: I55cd51d4929c828db5b61b38e781467c5bf77314 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Clean up duplicated checks whether a Value is a ManagedLars Knoll2016-11-291-11/+5
| | | | | Change-Id: Ib044be254dbb41bd9fb4a6e0baa3bd3c007e6a2a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.6' into 5.8Simon Hausmann2016-10-131-1/+1
|\ | | | | | | Change-Id: I175b27337b534c0b8f46a4a792d2c43cde73ffc4
| * V4: Fix usage of QV4::Value tags/typesErik Verbruggen2016-10-131-1/+1
| | | | | | | | | | | | | | | | These two were mixed, but have completely different values. Task-number: QTBUG-56471 Change-Id: Ifbf6da3032335ea89bfbc3acde17f64a571b9dc0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-10-101-5/+4
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/quick/quickwidgets/quickwidget/main.cpp src/qml/jsruntime/qv4jsonobject.cpp src/qml/jsruntime/qv4qobjectwrapper.cpp src/qml/jsruntime/qv4qobjectwrapper_p.h src/qml/qml/qqmlengine.cpp src/qml/qml/qqmlpropertycache.cpp src/qml/qml/qqmlpropertycache_p.h src/quick/items/qquickanimatedsprite.cpp src/quick/items/qquickitem.cpp src/quick/items/qquickitem.h src/quick/items/qquickitem_p.h src/quick/items/qquickview_p.h src/quick/scenegraph/qsgcontext.cpp src/quick/scenegraph/qsgdefaultrendercontext.cpp Change-Id: I172c6fbff97208f21ed4c8b6db3d1747a889f22b
| * | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-10-051-5/+4
| |\| | | | | | | | | | Change-Id: I081d9b15796b4133d2ba6f1a862f15b873a4846d
| | * Use QElapsedTimer instead of QTime to measure elapsed timeMilian Wolff2016-10-051-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | Getting the current time from QTime is expensive as it adheres to the locale timezone. To measure elapsed time in a code block, using the monotonic QElapsedTimer is much faster. Change-Id: Ibea390d7bc5270a20cf35111dfc919e37be7001e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | V4: Move zero-initialization of heap items into the header fileErik Verbruggen2016-10-072-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | QML: Also check for correct destroy() chainingErik Verbruggen2016-10-062-7/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | Check that the destroy() method of Heap::Base was called when a Managed object needs destruction. This checks if a call to the parent's destroy() method was accidentally omitted. Change-Id: Id025ecd6d4744bf3eab23503fbe317ed2a461138 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | QML: Make Heap::Object and all subclasses trivialErik Verbruggen2016-10-062-26/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GCC6 might dead-store-eliminate out our secret write to Base::mmdata, because it expects all memory content to be "undefined" before constructor calls. Clang might take the same approach if the constructor of Heap::Object is removed. By making these structs trivial, it also makes them memcpy-able. Change-Id: I055b2ad28311b997fbe059849ebda4d5894eaa9b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | QML: Make Heap::RegExp and Heap::String trivialErik Verbruggen2016-10-051-2/+4
| | | | | | | | | | | | | | | Change-Id: Ia8eda67c9d59069d3a64363699720a79ba1348a1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | QML: Introduce destroy() on Base subclassesErik Verbruggen2016-10-051-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | This removes the destructors of subclasses of Base, making them nearly trivial. Change-Id: Ia6f7d467e87899b5ad37b8709a8f633a51689d59 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | QML: Make all context objects trivialErik Verbruggen2016-09-302-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change also adds a check to the d() calls for Managed, verifies that the object has been initialized. This is only done for debug builds. To prevent other code from tripping the check, a number of other classes are either marked as trivial, or do initialization in the constructors. Because of template function changes in them memory manager (those now call init() instead of in-place new), String has an extra parameter to force it to temporarily use an old/unmodified template function. Change-Id: I8c35161ce7680835d830638b6d21498c5129b02b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | QML: Make QV4::Heap::Pointer trivialErik Verbruggen2016-09-281-3/+1
| | | | | | | | | | | | | | | | | | | | | One more step needed to make QV4::Heap::structs trivial. Change-Id: I6bebfaff970518d65a09f2b9f50a6855c431d4c0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | QML: Replace QPointer with a QQmlQPointer (which is trivial)Erik Verbruggen2016-09-271-0/+56
| | | | | | | | | | | | | | | | | | | | | One of the steps needed to make QV4::Heap::structs trivial. Change-Id: Ic4d73f15035af21c8a682aaad1ee68cdd91f8e7d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-08-171-1/+12
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qqmltypecompiler.cpp src/qml/compiler/qv4isel_moth.cpp src/qml/compiler/qv4ssa_p.h src/qml/qml/qqmlobjectcreator.cpp Change-Id: I8bb7fe773d657f908f20ee5e72c2b9bd643f6260