aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4identifiertable_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Remove the use of Q_QML_PRIVATE_EXPORTAlexey Edelev2024-01-111-1/+1
| | | | | | Task-number: QTBUG-117983 Change-Id: I5790f01d614cd70c7fcc9bd817ec6ace3f3e3730 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* IdentifierTable::asPropertyKey: Remove unused overloadFabian Kosmale2023-07-311-1/+0
| | | | | | Change-Id: Ibe5690673401c442bd3ba1f82aaaa5ef6fa3a2d3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Context properties: Don't trigger an assert for numeric namesFabian Kosmale2023-07-311-1/+2
| | | | | | | | | | | | | | | | | | | | The logic in our IdentifierHash assumes that every entry is a StringOrSymbol; however, IdentifierTable::asProperyKey will convert keys that look like numbers to ArrayIndex instead. This is noramlly what we want, and not an issue, except for setContextPropery where the user can pass an arbitrary string that is not necessarily a valid identifier. In an ideal world, we would just disallow such identifiers, but for backward compatibility change the code to handle this case (avoiding a Qt internal assert). We only need to modify the QString overloads, as those are the only ones that interact with unsanitized user input. A later commit will modify setContextPropery to warn if the key is numeric. Fixes: QTBUG-115319 Pick-to: 6.6 6.5 6.2 5.15 Change-Id: Ifc4e4d2bc99321836e6976c4cbd0c5ff687b430c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Use SPDX license identifiersLucie GĂ©rard2022-06-111-38/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* IdentifierTable: Optimize property key lookup by QStringUlf Hermann2021-03-171-0/+3
| | | | | | | | | | | We only have to create QV4::String if the entry doesn't exist, yet. Also, make sure the identifier of a new QV4::String inserted for an array index is actually populated. Change-Id: I223d191905baea5e537f483a9b3aa3db26f891b2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Re-arrange qv4identifier{_p.h|.cpp}Ulf Hermann2020-04-151-1/+1
| | | | | | | | | | | | QV4::IdentifierHashData doesn't need to be visible to all the clients. Furthermore, it can be completely inline. The public functions of QV4::IdentifierHash need to be out of line, but the private ones can be all inline. This shouldn't make much of a difference as most of the public functions call at least one private function. Finally, the files should be named by the class names. Change-Id: I931f2aa71103e41fdd3dae9cc47d204edece0e12 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Improve performance of IdentifierTable::sweep()Lars Knoll2018-09-141-2/+2
| | | | | Change-Id: I634f30ceb520af440c668e597a82b09b3c0024c9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix invalid object property key conversionsSimon Hausmann2018-07-101-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Different property names are mapped to the same property key through a the identifier hash table. In the case of QTBUG-69280 we map a for-in loop "for (var prop in testCase)" in TestCase.qml to an internal iterator object, which signals whether it's finished or not by setting a "done" property on the iterator result object to a boolean. On the setter side, the property is specified via result->put(engine->newString("done")) and on the getter side the code uses result->get(engine->id_done()) For this to work, the newly created string has to map to the same identifier, otherwise we end up with differing property keys and wrong values. The test failure of QTBUG-69280 reproduced a scenario where two strings, "pathChanged" and "done", mapped to the same index in the hash table after a rehashing (growing), despite different string hash values. As a consequence of the hash collision they had adjacent entries in the hash table, with "pathChanged" coming first. A subsequent garbage collection run ended up with "pathChanged" being not marked and subject to removal from the identifier table. IdentifierTable::sweep() wiped the entry for "pathChanged" and lastEntry to the now free index and also remembered the exact string hash value. In the next iteration, sweep() looked at the entry for "done", which should move to the now free slot, as both strings map to the same index. However sweep() didn't do that because the comparison of string hash values failed. The fix is to compare table indices (covered by sweepFirstEntryInSameBucketWithDifferingHash) and respect bucket boundaries (covered by dontSweepAcrossBucketBoundaries). However it may happen that entries that would map to the same bucket end up after another bucket because of the insertion order. This would lead to Q_ASSERT(table[lastIdx] == nullptr); failing right after lastIdx = (lastIdx + 1) % alloc; Instead the determination of the next free slot must follow the same logic as in addEntry, by finding the first null entry. This is covered by sweepAcrossBucketBoundariesIfFirstBucketFull. Task-number: QTBUG-69280 Change-Id: I284f53418d0a75e2edb631f8bacca8c5a596e603 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Rename IdentifierTable methodsLars Knoll2018-07-021-7/+7
| | | | | | | identifier -> asPropertyKey Change-Id: I4e6f33bdad12e901303ec6101dd2b8d6b0e99ac4 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Replace Identifier by PropertyKeyLars Knoll2018-07-021-8/+8
| | | | | | | | Change all uses of Identifier to use the new PropertyKey class and get rid of Identifier. Change-Id: Ib7e83b06a3c923235e145b6e083fe980dc240452 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement Symbol.for and Symbol.keyForLars Knoll2018-05-021-3/+6
| | | | | Change-Id: I5fde731b3a1a6d7c15154881ed82549b2800d104 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Garbage collect identifiersLars Knoll2018-05-021-9/+11
| | | | | | | | | | | | | | | | | | | | | 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>
* Use Identifier by value and don't new them anymoreLars Knoll2018-05-021-7/+7
| | | | | Change-Id: Ib25c08027013217657beb2675dafa9a8c85cbaf9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Turn Identifier into a simple integerLars Knoll2018-05-021-2/+3
| | | | | | | | | | Add a reverse mapping table to the IdentifierHash to avoid having to store a hash value inside the identifier. This makes it possible to then use the identifiers value based and not new them on the heap anymore. Change-Id: If1f177588ea104565c6e3add49c70534a6c7dcb8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove the QString member from IdentifierLars Knoll2018-05-021-1/+1
| | | | | | | First step to turning identifier into a simple int. Change-Id: I4988587aa61f1f02ed80426ccbf00b685f38c829 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Separate the stack used for GC from the regular JS stackLars Knoll2017-04-071-2/+2
| | | | | | | | This is required to be able to implement concurrent or incremental garbage collection. Change-Id: Ib3c5eee3779ca2ee08a57cd3961dbcb0537bbb54 Reviewed-by: Simon Hausmann <simon.hausmann@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>
* Add method to convert identifiers back into QV4::String objectsLars Knoll2015-09-251-0/+2
| | | | | | | | Allocating a new String for the Identifier is wasting both memory and CPU. Let's rather extract it from the IdentifierTable. Change-Id: Ibb9b2ac9775fefce74602d6954586195cdd5814e 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>
* 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>
* 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>
* Fold the markBit into the internalClass pointerLars Knoll2015-01-121-4/+4
| | | | | Change-Id: I79f9286275f833dd01a3193042976d1f86ed5019 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Ported ExecutionEngine::newString and newIdentifier to Heap::StringSimon Hausmann2014-11-121-12/+15
| | | | | | | | | | Avoid the use of Returned<String> for newString and changed the identifier table to use Heap::String. This required moving some code back into Heap::String, but that's code that doesn't call back into the GC, so allocations and therefore future object moves aren't possible. Change-Id: I1dca3e9c12a9c56f09419af8cc8cba39fe04f720 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Let markObjects() operate directly on HeapObjectsLars Knoll2014-11-041-1/+1
| | | | | | | | | This decouples things a bit better and helps moving over to directly store heapobject pointers in other objects. Change-Id: I798f922e018b0a3ca6f8768e4a810187f34d82f6 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>
* Rename Managed::managedData() to d() to be consistentLars Knoll2014-07-221-1/+1
| | | | | | | | No need to differentiate in the name anymore, as the data structures all inherit from each other now. Change-Id: Ia41f50ce4e521f9626d874311ceb57e0e194888b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Convert String to the new storage layoutLars Knoll2014-07-221-2/+2
| | | | | Change-Id: Ifa9aac63fdb270fb449f11832a1792caeb6c6724 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move string data into subclassLars Knoll2014-07-221-6/+6
| | | | | Change-Id: I95dcdda8c68e2a5c36244798c8c10dcfdd69d2c2 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move Managed data into it's own subclassLars Knoll2014-07-221-4/+4
| | | | | | | | | This prepares for moving over to a d pointer scheme, where Managed subclasses don't hold any data directly. This is required to be able to move over to a modern GC. Change-Id: I3f59633ac07a7da461bd2d4f0f9f3a8e3b0baf02 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Reduce memory pressure on JS stack when garbage collectingSimon Hausmann2014-04-091-3/+8
| | | | | | | | | | | | As the identifier table grows with long running programs, we may end up allocating more identifiers than we have space left on the JS stack for them alongside all the other objects in the environment. To mitigate this, we can simply treat the identifiers as roots, mark them manually and only end up putting sub-strings onto the JS stack if necessary. Task-number: QTBUG-36183 Change-Id: Ie6994555305c84b007860792d066a8df60089847 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Refactor marking GC'ed objectsLars Knoll2013-11-051-2/+2
| | | | | | | | | | | Don't use recursive function calls anymore. Instead, push marked objects onto the JS stack, and then pop them off when their children are being marked. Should reduce stack memory usage, and improves performance by ~5%. Change-Id: I2d37d97579144fcba87ec8e9fd545dd220c01fbb Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use StringRef for most methods in ObjectLars Knoll2013-09-221-2/+2
| | | | | Change-Id: I8e2dad0e9e34c5a549952bc0765cd57f6aa8aadf Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Inline identifier lookup where it makes senseLars Knoll2013-09-021-1/+8
| | | | | Change-Id: I42ac6f4232fec2ce1535a007007542d8cc116433 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Restructure source codeLars Knoll2013-08-081-0/+86
Move the v4 engine classes from a subdir of qml/qml into two subdirs (compiler and jsruntime) of the qml module Remove an unsued qv4syntaxchecker class, and move the moth code directly into compiler. Change-Id: I6929bede1f25098e6cb2e68087e779fac16b0c68 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>