aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/memory/qv4heap_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Upgrade std::is_trivial::value to C++17 std::is_trivial_vIvan Tkachenko2021-08-241-3/+3
| | | | | | | | | Since Qt 6 requires at least C++17, we can finally make use of some of its goodness. Change-Id: I56a318bc0b1b60d1e2b0186f335f8feda7622df4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Cleanup some includesFabian Kosmale2021-03-171-2/+1
| | | | | | | Some were superfluous, others were missing. Change-Id: I6bf3057f97ab3453d735cb7b90da945b8f6b993c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Replace old Q_DECL statements with modern C++Allan Sandfeld Jensen2020-10-311-2/+2
| | | | | | | 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>
* 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>
* 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>
* 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>
* 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>
* garbage collect InternalClassLars Knoll2018-04-121-3/+2
| | | | | | | | | | | | | | | | 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>
* Remove dependency from qv4heap_p.h onto qv4internalclass_p.hLars Knoll2018-04-121-12/+0
| | | | | | | | 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>
* CleanupsLars Knoll2018-02-091-35/+41
| | | | | | | | | | | Move the Pointer<> declaration before the declaration of Heap::Base, as Heap::Base will start using Pointer<> in an upcoming commit. Remove redundant namespace prefixes and move the definition of the vtable() method out of the class. Change-Id: I388d4836448869faca88af9e3bfdbea3619508b9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove InternalClass forward declarationsLars Knoll2018-02-091-2/+0
| | | | | | | qv4global_p.h has it already. Change-Id: I7c2526873d1176d62a03708d8159546c65344cd2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Disentangle include dependencies around the write barrierLars Knoll2018-01-191-0/+34
| | | | | | | The write barrier header should have minimal dependencies. Change-Id: I071718c2fafe5020d1093ca3b363844f7a9b7b35 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Raise minimum supported MSVC version to 2015Friedemann Kleint2018-01-061-8/+2
| | | | | | | | | | | | Remove code for older versions and streamline #ifdefs. Remove the helpers macros Q_STATIC_ASSERT_FOR_SANE_COMPILERS and V4_ASSERT_IS_TRIVIAL. Task-number: QTBUG-40658 Task-number: QTBUG-51673 Change-Id: Ifa4fab653b10ce7858739adef08364cddc6507cf Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Bring back markObjects(), this time generatedLars Knoll2017-11-141-3/+20
| | | | | | | | Doing the marking of objects in a function instead of using the table seems to be somewhat faster. Change-Id: I9ec00cc0264f9a15c69b285db493bee31d99bf96 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-06-061-4/+8
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/qml/jsruntime/qv4argumentsobject.cpp src/qml/jsruntime/qv4arraydata.cpp src/qml/jsruntime/qv4context.cpp src/qml/jsruntime/qv4context_p.h src/qml/jsruntime/qv4errorobject.cpp src/qml/jsruntime/qv4functionobject.cpp src/qml/jsruntime/qv4internalclass.cpp src/qml/jsruntime/qv4lookup.cpp src/qml/jsruntime/qv4managed.cpp src/qml/jsruntime/qv4managed_p.h src/qml/jsruntime/qv4object.cpp src/qml/jsruntime/qv4object_p.h src/qml/jsruntime/qv4qmlcontext.cpp src/qml/jsruntime/qv4runtime.cpp src/qml/jsruntime/qv4vme_moth.cpp src/qml/memory/qv4heap_p.h src/qml/memory/qv4mm.cpp src/qml/memory/qv4mm_p.h src/qml/memory/qv4mmdefs_p.h src/quick/scenegraph/util/qsgdistancefieldutil.cpp src/quick/scenegraph/util/qsgdistancefieldutil_p.h tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp Change-Id: I7ed925d4f5d308f872a58ddf51fdce0c8494ec9c
| * Move the internalClass field from Heap::Object to Heap::BaseLars Knoll2017-05-191-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * Re-add some inline property storageLars Knoll2017-05-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Separate the stack used for GC from the regular JS stackLars Knoll2017-04-071-3/+3
| | | | | | | | | | | | | | | | This is required to be able to implement concurrent or incremental garbage collection. Change-Id: Ib3c5eee3779ca2ee08a57cd3961dbcb0537bbb54 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | CleanupsLars Knoll2017-04-071-0/+2
| | | | | | | | | | | | | | | | | | | | | | * Only call ExecutionEngine::markObjects() on a full GC, it doesn't do anything in the incrementall case anyway. * Move the marking of child objects into it's own method for clarity * Move collection of gray items down to happen directly before we drain the mark stack Change-Id: I41067e17d483067bd1c4d60da22c5628482dae78 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into devSimon Hausmann2017-03-271-1/+1
|\| | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4functionobject_p.h Change-Id: I4bbed45f1fe02cf64df3c8a5f92f811e38e772f3
| * 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>
* | | | Merge remote-tracking branch 'origin/5.9' into HEADSimon Hausmann2017-03-231-0/+6
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp src/qml/jit/qv4assembler.cpp src/qml/jit/qv4assembler_p.h src/qml/jit/qv4isel_masm.cpp src/qml/jsruntime/qv4context.cpp src/qml/jsruntime/qv4context_p.h src/qml/jsruntime/qv4engine.cpp src/qml/jsruntime/qv4vme_moth.cpp src/qml/memory/qv4mmdefs_p.h Change-Id: I9966750b7cd9106b78e4c4779f12b95a481cca40
| * | | 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>
* | | Implement a real write barrierLars Knoll2017-03-091-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement a Steel write barrier for our objects. The barrier is interesting as it can also be used for incremental GC runs by simply turning the barrier on and leaving old objects marked as black. Change-Id: I0b273974d94a990dee3cd9298089b8b202c75bf2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Add an actual write barrier and centralize it in one placeLars Knoll2017-03-091-20/+0
| | | | | | | | | | | | | | | | | | | | | | | | All stores into the Heap from C++ and Moth should now go through the write barrier. Change-Id: Iae9347754b90d68c10fade9f345842e86ec460cd Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Make all write operations to Pointer<> types go through a set() methodLars Knoll2017-03-091-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | The new set() method also taked an ExecutionEngine pointer. This makes it trivial to now add a write barrier for those operations. Change-Id: I321eccfe6fb279cc240b5c84910e6854f71759f6 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Make every member of a Heap object aware of its offset inside the objectLars Knoll2017-03-091-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | This will allow adding a write barrier to those fields with manageable effort. Change-Id: I7d06d7ffccbcefe66e2524c64c962353c91c2766 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Refactor how we define Heap objectsLars Knoll2017-03-091-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Declare the type of Heap object in the Member() macro, instead of deducing it from templates. This allows us to encode the offset of the member in the second template argument to Pointer<> in a second step. Change-Id: I2cfb73785749d3fb991689b4e0554a72b3e5e13f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | New mark table implementationLars Knoll2017-03-091-0/+3
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Automatically generate a table containing the data where JS Values and pointers are in objects in the JS heap. This will allow making the GC mark phase a lot more efficient. A bit of a special hack is currently required for MemberData and ArrayData, as they have a variable length, and we need to read the size from the object. We keep backwards compatibility with the old markObjects() functions for now (calling them if they are defined). Some further work on QV4::String and in a few other places is required before we can get remove the compatibility. Change-Id: I78528ace67e886bdbe4a4330c9677c7fc9f08a33 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-251-6/+13
|/ | | | | | | | | | | | | 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>
* QML: Also check for correct destroy() chainingErik Verbruggen2016-10-061-6/+28
| | | | | | | | | 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-061-3/+17
| | | | | | | | | | | | 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 all context objects trivialErik Verbruggen2016-09-301-0/+14
| | | | | | | | | | | | | | | 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>
* Updated license headersJani Heikkinen2016-01-191-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: Ic36f1a0a1436fe6ac6eeca8c2375a79857e9cb12 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Add missing "We mean it" comments to private headers.Friedemann Kleint2015-10-061-0/+11
| | | | | | Task-number: QTBUG-48594 Change-Id: Ifc207938de7f0c8995fc712df92665f222612647 Reviewed-by: Alan Alpert <aalpert@blackberry.com>
* Encapsulate and protect all accesses to the vtable of Heap objectsLars Knoll2015-08-101-5/+6
| | | | | | | | This is required, so we can safely access the vtable even while we're marking objects during GC. Change-Id: I34f56b61b4bca0d0742faf607eb5ab8b2c30685e Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Use Heap::Pointer in more placesLars Knoll2015-04-241-4/+3
| | | | | Change-Id: I2a64aadcd47ed05ad7d08a70a5d765d898a671fd Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Rename Heap::Base::as() to cast()Lars Knoll2015-04-211-1/+1
| | | | | | | | The as() methods in other places to dynamic type checking, whereas cast() methods are basically the same as a static_cast. Change-Id: Iacd0174824b41b8fad05d6b55b1e62e3b44a31db Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Cleanup some of the casting codeLars Knoll2015-03-201-3/+20
| | | | | | | | Get rid of value_cast, and move the Managed::as() method into Value. Change-Id: I440ac44ae77f4fda1a8a837383fe631f432f6532 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Wrap members in Object in a Heap::PointerLars Knoll2015-03-201-0/+3
| | | | | Change-Id: I0d132592487255027c215da21fbec15b23b00624 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Move memory management related functionality into it's own folderLars Knoll2015-03-021-0/+109
Start moving the memory related functionality into it's own folder. This will simplify refactoring of the GC related functionality later on. Change-Id: I70ec6f512af7a7897625afb84d914c17572b0ccd Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>