aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4persistent.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Introduce a new mechanism to iterate over object propertiesLars Knoll2018-08-021-0/+12
| | | | | | | | | | | | | | | | | The old advanceIterator schema was extremely ugly and in addition not flexible enough to support the requirements for Proxy.ownKeys and some of the methods in Object Implemented a new scheme through a OwnPropertyKeys method in the Object VTable that creates and returns an iterator object. Ported QJSValueIterator and for-in to use the new mechanism. There's still many places where we use the old ObjectIterator (that relies on advanceIterator). Those will be ported in subsequent commits. Change-Id: I091a9bea9ff6b2b63630cc336814700757a718be Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Don't use empty values anymore to store internal freelistsLars Knoll2018-05-241-3/+3
| | | | | | | | | | | | Simply encode them as integers. That works just as well, and allows removing the indexed empty values. This is helpful, to swap the internal representations of undefined and empty values, which in turn will simplify an implementation of correct handling of uninitialized variables (through let/const). Change-Id: I299f975d665309611d1b561f6a0c86b5ca15782a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-8/+8
| | | | | | | | | | | | | 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.9' into 5.10Liang Qi2018-02-021-10/+24
|\ | | | | | | Change-Id: I41ca9120a470a905c2f5c168c1de4cf970fa0fff
| * Improve persistent/weak value allocation performanceSimon Hausmann2018-01-311-10/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the persistent storage becomes fragmented, we would find the page with a hole in it, but we wouldn't put it to the front of the page list. So upon the next allocation we would begin iterating through firstPage again. This wasn't quite visible in callgrind as overall not many instructions were executed, but in perf this function showed up as hotspot because the search for free pages ends up with a lot of cache misses. In delegates_item_states.qml this was about ~7% of measured cycles with perf. Change-Id: I2bfa337ea9be14d1321756963c72d31336790a0a Done-with: Erik Task-number: QTBUG-65708 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Separate the stack used for GC from the regular JS stackLars Knoll2017-04-071-7/+5
| | | | | | | | | | | | | | | | This is required to be able to implement concurrent or incremental garbage collection. Change-Id: Ib3c5eee3779ca2ee08a57cd3961dbcb0537bbb54 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | New mark table implementationLars Knoll2017-03-091-10/+1
|/ | | | | | | | | | | | | | | | | | | 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>
* QML: Create a fast-path for QV4::WeakValue::setErik Verbruggen2016-10-211-21/+5
| | | | | | | And hint the compiler (with LTO) to never inline the slow path. Change-Id: Idad15498bca457d3f1f063031ad1a08415e9b3db 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.6' into 5.7Liang Qi2016-06-201-6/+3
|\| | | | | | | | | | | | | | | Conflicts: src/qml/jit/qv4targetplatform_p.h src/quick/accessible/qaccessiblequickitem_p.h Change-Id: Ic95075a5fad81ec997a61561bd65979dfa3b9d4d
| * V4: Always set the tag when boxing a pointer in QV4::Value.Erik Verbruggen2016-06-161-6/+3
| | | | | | | | | | | | | | | | | | All setters now store tags, so no-one can play loosy-goosy with the boxed values (and accidentally forget to "tag" a value, resulting in random garbage). Change-Id: Ia0b78aa038d3ff46d5292b14bd593de310da16a0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.6' into devLiang Qi2016-01-291-1/+20
|\| | | | | | | Change-Id: Iec1b2de53c275996364c4bab0123ccb3e6e9895e
| * Make sure we destroy all QV4::QObjectWrapper objectsJian Liang2016-01-221-1/+20
| | | | | | | | | | | | | | | | | | | | Delay freeing QObjectWrapper Value to MemoryManager::sweep() to make sure we can destroy all QObjectWrapper objects. We also keep track of QObjectWrapper in QV4::Heap::ModelObject to make sure we destory them in QV4::MemoryManager::sweep() Change-Id: I3a8a3b07faab1f88c2eb746f68aa8d9584b40026 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | 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>
* Revert "Fix QtSharedPointer::ExternalRefCountData object leaks"J-P Nurmi2015-12-231-7/+0
| | | | | | | | | | This reverts commit 839d2d3e2368bc8e107d22203b0611c852f54319, which has been causing crashes in qtquickcontrols2 auto tests and making it nearly impossible to integrate anything over the past few days. Change-Id: I570b286a067aae5e3c2d8c56ad601e1a6cb58c20 Task-number: QTBUG-50134 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Fix QtSharedPointer::ExternalRefCountData object leaksJian Liang2015-12-181-0/+7
| | | | | | | | | | | Call destroyObject() for every QV4::Heap::QObectWrapper object in heap in QV4::MemoryManager::sweep() to make sure the QPointer object contained in QV4::Heap::QObjectWrapper is properly destructed. We also keep track of QObjectWrapper in QV4::Heap::ModelObject to make sure we destory them in QV4::MemoryManager::sweep() Change-Id: I3b3e96cfc300c2e21ab691762879ac2970afa90c Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Make iteration over persistent values saferLars Knoll2015-08-241-8/+55
| | | | | | | | This makes it safe to destruct persistents while we are iterating over them. Change-Id: I8797d0c553d3201859cdf03fb25df28836e55691 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Encapsulate and protect all accesses to the vtable of Heap objectsLars Knoll2015-08-101-2/+2
| | | | | | | | 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>
* Remove type punning from QV4::Value.Erik Verbruggen2015-07-241-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The union in QV4::Value is used to do type punning. In C++, this is compiler-defined behavior. For example, Clang and GCC will try to detect it and try to do the proper thing. However, it can play havoc with Alias Analysis, and it is not guaranteed that some Undefined Behavior (or Compiler depenedent behavior) might occur. The really problematic part is the struct inside the union: depending on the calling convention and the register size, it results in some exciting code. For example, the AMD64 ABI specifies that a struct of two values of INTEGER class can be passed in separate registers when doing a function call. Now, if the AA in the compiler looses track of the fact that the tag overlaps with the double, you might get: ecx := someTag ... conditional jumps double_case: rdx := xorredDoubleValue callq someWhere If the someWhere function checks for the tag first, mayhem ensues: the double value in rdx does not overwrite the tag that is passed in ecx. Changing the code to do reinterpret_cast<>s might also give problems on 32bit architectures, because there is a double, whose size is not the same as the size of the tag, which could confuse AA. So, to fix this, the following is changed: - only have a quint64 field in the QV4::Value, which has the added benefit that it's very clear for the compiler that it's a POD - as memcpy is the only approved way to ensure bit-by-bit "conversion" between types (esp. FP<->non-FP types), change all conversions to use memcpy. Use bitops (shift/and/or) for anything else. - only use accessor functions for non-quint64 values As any modern compiler has memcpy as an intrinsic, the call will be replaced with one or a few move instructions. The accessor functions also get inlined, the bitops get optimized, so in all cases the compiler can generate the most compact code possible. This patch obsoletes f558bc48585c69de36151248c969a484a969ebb4 (which had the exact aliassing problem of the double and the tag as described above). Change-Id: I60a39d8564be5ce6106403a56a8de90943217006 Reviewed-by: Ulf Hermann <ulf.hermann@theqtcompany.com>
* Fix the RegExpCache to be GC safeLars Knoll2015-06-171-0/+6
| | | | | Change-Id: I6c20c2c5fcdaefa0743f7c1f50cf6dd8d8edc753 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Get rid of asManaged()Lars Knoll2015-04-211-1/+1
| | | | | Change-Id: I853417fdf1cc339f7d43a006c20e1626b6bfb288 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Merge remote-tracking branch 'origin/5.5' into devFrederik Gladhorn2015-03-031-1/+1
|\ | | | | | | Change-Id: I94f8ae93d76bd5c120de25d9c238701afe8bfbd0
| * Fix MSVC 64 bit warnings about loss of data when converting from 'size_t' to ↵Friedemann Kleint2015-02-231-1/+1
| | | | | | | | | | | | | | | | | | | | 'int'. jsruntime\qv4arraybuffer.cpp(94) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data jsruntime\qv4persistent.cpp(53) : warning C4267: 'initializing' : conversion from 'size_t' to 'const int', possible loss of data Change-Id: I6ccef9a64ecfb53b18204b35e17421c0a5ac955b Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Move memory management related functionality into it's own folderLars Knoll2015-03-021-1/+1
|/ | | | | | | | | 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>
* Update copyright headersJani Heikkinen2015-02-121-7/+7
| | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Change-Id: I61120571787870c0ed17066afb31779b1e6e30e9 Reviewed-by: Iikka Eklund <iikka.eklund@theqtcompany.com>
* Keep PersistentValueStorage page size in sync with system page sizeTor Arne Vestbø2015-02-021-14/+12
| | | | | | | | | | | | | WTF::PageAllocation::allocate() requires the allocated size to be a multiple of the system page size (available through WTF::pageSize()), so we can't hard-code the page size in PersistentValueStorage to 4K. As we control the memory of the page we can use 'Value values[1]' as a trick to let the compiler set up a head-reference for our list of Values, which we access by values[0:kEntriesPerPage - 1]. Change-Id: I71fdfffa0424d510fc1073bb67b6675a04ac2d80 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Get rid of most uses of ValueRefLars Knoll2015-01-231-3/+13
| | | | | | | | | | | | Instead pass a const Value & into the functions With our new inheritance structure, we can get rid of ValueRef and instead simply pass a pointer to a Value again. Pointers to Values are safe to use again now, as they are now guaranteed to be in a place where the GC knows about them. Change-Id: I44c606fde764db3993b8128fd6fb781d3a298e53 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move vtable out of internalClassLars Knoll2015-01-201-2/+2
| | | | | | | | | | | | | | | | We can move the internalClass to Object later on, and such save having the internalClass on lots of Heap objects. This commit basically adds and starts making use of a new vtable pointer in Heap::Base. In addition, the construction methods in the memory manager now automatically setup the correct vtable. Removing the vtable code from InternalClass and moving it into Object will come in a separate commit Change-Id: If49e8d73c769bf65bf47fe4dbf8b9546c8019dbc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Refactor persistent valuesLars Knoll2015-01-161-149/+237
| | | | | | | | | | Use a page wise allocation mechanism for persistent values. This significantly reduces memory consumption of persistent values and also improves their performance a lot. Change-Id: I8499d2ca5bdd871e029f643ae605a94544558bb5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Make sure we always have an engine when assigning to a PersistentLars Knoll2015-01-131-50/+58
| | | | | | | This prepares things for a rewrite of the internals of Persistent. Change-Id: Ib93ec5911984d1bfce87ffdc3f86bc75f6ecafe9 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Cleanup debugger to be safe for the new GCLars Knoll2014-11-121-0/+10
| | | | | | | Added a bit of convenience to PersistentValue as well. Change-Id: I5a858079543b41ce1ef48a84e9350a7d6fa64501 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Update license headers and add new licensesJani Heikkinen2014-08-251-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Change-Id: I84a565e2e0caa3b76bf291a7d188a57a4b00e1b0 Reviewed-by: Jani Heikkinen <jani.heikkinen@digia.com>
* Move PersistenValue and WeakValue into it's own fileLars Knoll2014-02-051-0/+255
They deserve having their own set of files, and it helps reduce dependencies. Change-Id: Ifd4394f88ef51cbccc61bf92dd20636f570141d9 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>