aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/memory
Commit message (Collapse)AuthorAgeFilesLines
* Remove the qmake project filesFabian Kosmale2021-01-151-11/+0
| | | | | | | | | Remove all qmake project files, except for examples which are used to test that qmake continues to work. Change-Id: Ic4abb72dc2dcd75df7a797c56056b6b3c5fe62ac Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* V4: Prevent heap objects from getting immediately swept by GCUlf Hermann2020-11-061-0/+14
| | | | | | | | | | | A destruction handler can cause a new object to be allocated during garbage collection. Depending on where in the heap the object ends up, it may be found during the sweep pass. As the mark pass had no chance to mark the object, we need to set the mark bit right at allocation time in this case. Change-Id: Ie43eeb548e78bd375b001b3a6bb4ef6596f91980 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Replace old Q_DECL statements with modern C++Allan Sandfeld Jensen2020-10-314-5/+5
| | | | | | | Since we depend on C++17 now, all of these can go. Change-Id: I0484fd4bb99e4367ec211c29146c316453729959 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Rename QQmlQPointer to QV4QPointerUlf Hermann2020-09-211-4/+4
| | | | | | | You can wrap QObject pointers in plain JavaScript. Change-Id: I246a72a7d5d7b2562e722bf9eafc7880b772a806 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Rephrase Chunk::sortIntoBins() for more clarityUlf Hermann2020-05-251-4/+7
| | | | | | | | | | | | | | Assigning -1 to a quintptr so that it later overflows in another place when adding 1 warrants a comment. Also, assert against i overflowing the bitmaps. This way coverity might also understand what we are doing. Coverity-Id: 175402 Pick-to: 5.15 Pick-to: 5.12 Change-Id: I212110cbb784f89b1865bd0c0cc775c08cd40c04 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* MemoryManager: Forward arguments to init()Ulf Hermann2020-03-121-10/+10
| | | | | | | | | | The templating transforms references into their base types. Passing those through involves copying, and refcount ping-pong for QQmlRefPointers. Use forwarding references and std::forward to avoid this. Change-Id: I2524b53b9e06fadcc67a78c6ebf04f5bc2da354b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Fix mark stack overrunsUlf Hermann2020-02-272-24/+39
| | | | | | | | | | | | | | Instead of applying a heuristic on when to call drain() in unrelated code, we check the stack limit on each push(). If the soft limit is reached we try to drain. As drain() itself can push again, we try to limit the stack size by allowing at most 65 recursions of drain(). If none of that helps, we crash with a meaningful error message. This allows us to remove all the hacky drain() calls in other parts of the code. Change-Id: Ib979339470da0e85981de8131e7997755b757c71 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2020-01-091-0/+2
|\ | | | | | | | | | | | | | | | | Conflicts: src/particles/qquickitemparticle.cpp src/qmlmodels/qqmladaptormodel.cpp tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp Change-Id: Ibd8fbb91da6893a09f4ffe61ad0b95d8149bbc87
| * QV4MM: Fix crash caused by MarkStack overflowFabian Kosmale2020-01-071-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | MemoryManager::collectFromJSStack did push to the mark stack without checking if there is actually still space available. To fix this, we now drain the stack once we hit the limit. The test case is a slightly modified version compared to the reported one, removing one loop. This was required as our regular expression does not throw an exception when there are too many capture groups. However, to trigger the bug, looping was not actually necessary. Change-Id: I4d00865f25a989c380f4f5b221f4068c80b71d2b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Fix Qt6 build in preparation of qt5 submodule updateAlexandru Croitor2019-12-191-2/+3
|/ | | | | | | | | Fixes the QTextStream usages. Change-Id: I0c009a82fb644a9f3c3d42ec410d18b680977f23 (cherry picked from commit 1c5c5f7aadc2dcc73a21eeb818e95c4e1b7de70f) Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Split compiler and runtime more clearlyUlf Hermann2019-07-111-1/+1
| | | | | | | | Provide different export macros and different top level headers for each, don't include runtime headers from compiler sources. Change-Id: I7dc3f8c95839a00a871ba045ec65af87123154be Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* rtems: Reduce MemorySegment::NumChunksMikhail Svetkin2019-06-281-0/+4
| | | | | | | Reduce memory allocation on platforms without virtual memory Change-Id: I54114a9fde008ecb67a5cbf0da33962b0d933017 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add environment variable for configure maxJSStackSize and maxGCStackSizeMikhail Svetkin2019-06-281-1/+1
| | | | | | | | | | QMLEngine by default allocates 4 MB for javascript stack and garbage collection stack takes 2 MB. It is a lot of memory for platforms without virtual memory. Change-Id: I1575dd9584898dca33df66704f716c7b5a7c01c1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Port towards load/storeRelaxed atomicsGiuseppe D'Angelo2019-06-251-2/+2
| | | | | | | | | | Plain load() / store() have been deprecated, so port away to their straight replacements. Task-number: QTBUG-76611 Change-Id: I79935b889cf7b2ba7698f70cc5e33994b034aa09 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Eliminate qmldevtools_buildUlf Hermann2019-05-311-5/+1
| | | | | | | | Move the relevant files into more fitting locations and build the devtools from only parser, compiler and qmldirparser. Change-Id: Ibf37a1187f36d02983f9f43c6622acb243785b7b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Don't include qv4enginebase_p.h in qmldevtoolsUlf Hermann2019-05-102-1/+2
| | | | | | | | We don't need it and we don't need to check for V4_BOOTSTRAP in there. Shuffle some includes around to provide everything we do need. Change-Id: I3e75f1c6f9dc518006aabc9dcee21e5153899ac5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-03-292-54/+45
|\ | | | | | | Change-Id: I9ba374f0c652628b7c84c36893c32b22529e384f
| * Trigger the garbage collector when allocating InternalClass objectsUlf Hermann2019-03-262-54/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As we check the icAllocator's slots on shouldRunGC() we should also check shouldRunGC() when adding slots. Otherwise we might never run the GC when only allocating InternalClasses. In addition, account for the "unmanaged" size of the PropertyAttributes that are part of the InternalClass objects. Those can be large. In cases where an excessive number of large InternalClass objects is created the garbage collector is now invoked frequently, which costs a significant number of CPU cycles, but prevents the memory usage from growing indefinitely. Task-number: QTBUG-58559 Change-Id: Icf102cb6100f6dba212b8bffe1c178897880eda0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Fix logging output for GCUlf Hermann2019-03-271-9/+14
|/ | | | | | | | It failed to consider the IC allocator when calculating various sizes. Task-number: QTBUG-74190 Change-Id: Id34c31d639896eed8422790b4adc56c989402807 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* V4: Fix failing assert on all 32bit platformsErik Verbruggen2019-02-141-1/+1
| | | | | | | | | | The failing assert is in qv4mm.cpp:170, which is correct. The failure stemms from the fact that on 32bit platforms, quint64 does not have the same size as quintptr. Who would have thought? Fixes: QTBUG-73821 Change-Id: I9abe6bc9e2bfcdb6700ab7997c078076a9883cf2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* MemoryManager: Only clear weak values onceUlf Hermann2019-01-231-2/+0
| | | | | | | | | | | | We want to keep the weak values alive while the destruction callbacks are running, so that they can still access them. We set them to undefined later anyway because we expect the destruction callbacks to mess with the values. Therefore there is no point in also setting them in between. Fixes: QTBUG-72137 Change-Id: I83f70230f5b4ad2761c74770f975b14a5ca71f18 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix a crash when allocating huge memory segmentsLars Knoll2018-11-021-3/+2
| | | | | | | | | | When allocating a huge item that requires it's own memory segment, we were actually not committing enough memory from the OS. Fixes: QTBUG-71501 Change-Id: Ic86a648bba4d7f1eeeded78d8de0f0fc1d3a251d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Cleanups in Value/PrimitiveLars Knoll2018-09-171-2/+2
| | | | | | | | | | | | Get rid of Primitive and move the corresponding methods directly into Value. Mark many methods in Value as constexpr and turn Value into a POD type again. Keep Primitive as a pure alias to Value for source compatibility of other modules that might be using it. Change-Id: Icb47458947dd3482c8852e95782123ea4346f5ec Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Don't let GC runs be dominated by internal classesLars Knoll2018-09-141-2/+2
| | | | | Change-Id: Icdd0f303f06605e8fdf2f1b324274ad95bfdebf3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add support for WeakSetLars Knoll2018-08-282-0/+20
| | | | | Change-Id: I5cee2bf0c6a45ad2c14b52e1a4fc5ef015e01042 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement support for WeakMapLars Knoll2018-08-282-0/+22
| | | | | Change-Id: Id23e80fe5918ba7dc897568123bf3db4d35e9092 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Simplify chunk sweeping codeSimon Hausmann2018-08-051-17/+11
| | | | | | | | | Instead of collecting the empty chunks after sweeping in a separate vector, partition the chunks into non-empty and empty ones and erase the second half after freeing them. Change-Id: I7896c167b8b09a01b124dcdcb1eba8ddc0eef7f4 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix crashes when GC'ing internal classesLars Knoll2018-08-041-3/+11
| | | | | | | | | | | | | The destroy() method of internal classes tries to reference it's parent class to unregister itself there. This could go wrong if the parent class had been destroyed already and it's associated memory been freed by the GC. Fix this by only freeing actual memory at the end after the sweeping has been done. Change-Id: I85beb4792038d5a1a5708f5897af2c1950f8b8d1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move the Vtable for Managed objects into it's own fileLars Knoll2018-07-031-20/+1
| | | | | | | | Move both the code from qv4object and qv4managed into a new qv4vtable_p.h file. Change-Id: Ib1d58120b6c3b9b779b2692526c7e40a5265c4db Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Memory manager: Track icAllocator as part of used and allocated memoryUlf Hermann2018-05-301-3/+4
| | | | | | | This makes it consistent with the memory profiler. Change-Id: I628d03a4c0d079af0940f0e424b779d992b2919d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Don't use bitfields for VTable flagsLars Knoll2018-05-031-11/+11
| | | | | | | | | Accessing those is significantly slower than using a byte for each flag. As they are performance critical, let's rather use some more bytes in the vtable. Change-Id: I7104d3b791f469fe5d6705f20db0c965878126e2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Make the statistics variables members of the memory managerLars Knoll2018-05-022-22/+8
| | | | | | | | Otherwise this will show wrong stuff when running multiple engines in different threads (and create noise in thread sanitizers) Change-Id: Ia90054f5a54ee2c43870c8d839f25b195b09698c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Garbage collect identifiersLars Knoll2018-05-021-0/+3
| | | | | | | | | | | | | | | | | | | | | Implemented by storing a backpointer to the Heap object in the identifier. Since identifiers now point back to their originating String or Symbol, we can now easily mark all identifiers that are still in use and collect those that aren't. Since Identifiers are 64bit also add support for holding an array index in there. With that an identifier can describe any kind of property that can be accessed in an object. This helps speed up and simplify some code paths. To make this possible, we need to register all IdentifierHash instances with the identifier table, so that we can properly mark those identifiers. Change-Id: Icadbaf5712ab9d252d4e71aa4a520e86b14cd2a0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add a StringOrSymbol intermediate class between Managed and StringLars Knoll2018-05-021-1/+2
| | | | | | | | | This introduces a common base class for Strings and Symbols giving us a unified approach to handling object properties for both. Change-Id: Ic9e5a18b084c8b730e134db990f101d47af224e3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove some scopes in the memory managerLars Knoll2018-04-121-8/+6
| | | | | | | | | | These allocation functions only perform a single allocation. Since all live objects have to be reachable by the GC before calling into it, these scopes are not required. Change-Id: Ia7e89791d6ff2bfe87b7c5462191d28e04688df1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* garbage collect InternalClassLars Knoll2018-04-123-22/+52
| | | | | | | | | | | | | | | | Internal classes are now allocated and collected through the GC. As they are important to the deletion of other objects (because of the vtable pointer living inside the internal class), they need to get destroyed after regular objects have been sweeped. Achieve this by using a separate block allocator for internal class objects. Our lookups do often contain pointers to internal classes, so those need to be marked as well, so we don't accidentally collect them. Change-Id: I4762b054361c70c31f79f920f669ea0e8551601f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Better encapsulation for EngineBase::internalClassLars Knoll2018-04-121-1/+1
| | | | | | | | Turn it into a method instead of accessing the array directly to simplify refactoring. Change-Id: I197b56c8f58cfdfd294f429e6b15268c755f9837 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove dependency from qv4heap_p.h onto qv4internalclass_p.hLars Knoll2018-04-122-17/+5
| | | | | | | | This is required to be able to turn the internal class into something that lives on the GC heap. Change-Id: Ie4318588d420743b1e1ab1cd596a1c9d153eb793 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Disambiguate different allocation functions in the memory managerLars Knoll2018-04-121-1/+1
| | | | | | | | | | | Some compilers (in this case MingW 5.3) don't manage to properly disambiguate the template overloads, and try to instantiate the wrong template function. Solve this by renaming the one of the template functions. Change-Id: I3574e617fe96c4bd52920a0127a1dfe39cc3d302 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Cleanup MM::allocObject()Lars Knoll2018-04-121-3/+1
| | | | | | | | The prototype argument has been unused for quite some time, finally remove it. Change-Id: Ifcebe413a1951ed972b370afc48640bd22969943 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Optimize MM::allocManaged()Lars Knoll2018-04-121-4/+1
| | | | | | | | We can manage without calls to changeVTable() here, as the set of classes allocated with this is rather limited. Change-Id: I804e4850b91c61ebbca8a04edbe51deac911928d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Simplify allocation functions in the memory managerLars Knoll2018-04-121-150/+16
| | | | | | | Reduce code duplication by using variadic templates. Change-Id: Ia12b67184f66190b433c99fb2157fca4e46cb2b6 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-03-151-14/+14
|\ | | | | | | Change-Id: I98ef98ca603a1d82f944973a06375e65192fdab2
| * Fix ABI/API symbol taggingSimon Hausmann2018-03-121-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The findclasslist.pl perl script that produces the linker version script got confused by the "struct name" that was part of a macro and thought that the class "name" in the *_p.h was supposed to be annotated with the private API tag, resulting in a "*4name*" mask in the linker script, which in turn made lots of public symbols "private" that had name in it, such as QQmlProperty::name(). Fixing the indentation works around it and conforms to coding style. Change-Id: I0c66a6bb1d49941d6ec6dd89d9433d9b6ae0c639 Done-with: Thiago Macieira <thiago.macieira@intel.com> Task-number: QTBUG-67004 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-03-122-3/+24
|\| | | | | | | Change-Id: I6b2568337c09ff98850b4ecccccc9a8fc25064cd
| * Fix issue with allocating huge objects in the memory managerLars Knoll2018-03-082-3/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We shouldn't allocate objects that are larger than the size of a standard memory segment through the chunk allocator, as this can lead to problems when freeing the segment and then re-using it again. Instead allocate a private MemorySegment for these objects, and free it when the object gets garbage collected. Task-number: QTBUG-66732 Change-Id: Ic24ff65d204977f313ab0adaf7a8132883e525f0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devLiang Qi2018-02-273-15/+15
|\| | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4engine.cpp src/qml/jsruntime/qv4internalclass.cpp src/qml/parser/qqmljslexer.cpp src/qml/qml/v8/qv8engine.cpp src/qml/util/qqmladaptormodel_p.h src/quick/items/qquickanimatedsprite.cpp tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp Change-Id: I16702b7a0da29c2a332afee47728d6a6ebf4fb3f
| * use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-263-15/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | From now on we prefer nullptr instead of 0 to clarify cases where we are assigning or testing a pointer rather than a numeric zero. Also, replaced cases where 0 was passed as Qt::KeyboardModifiers with Qt::NoModifier (clang-tidy replaced them with nullptr, which waas wrong, so it was just as well to make the tests more readable rather than to revert those lines). Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-02-151-0/+15
|\| | | | | | | Change-Id: I2d4c012c8ca578f90d7eb56dbc6b306ac7cbb841
| * Merge remote-tracking branch 'origin/5.10' into 5.11Liang Qi2018-02-121-0/+15
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/imports/shapes/qquickshape.cpp src/imports/shapes/qquickshape_p_p.h src/qml/compiler/qqmlpropertycachecreator_p.h src/qml/jsruntime/qv4value_p.h src/quick/items/qquickloader_p.h tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp tools/qmlprofiler/qmlprofilerapplication.cpp Change-Id: Iafc66ae84bf78630ed72a986acb678e9d19e3a69