aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
Commit message (Collapse)AuthorAgeFilesLines
* QtQml: Move ResolvedTypeReference into base CUUlf Hermann2024-01-132-47/+18
| | | | | Change-Id: I25063457aad3a6d29a8c2a5b236f9a51b56a2f51 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move BindingPropertyData into the base CUUlf Hermann2024-01-131-8/+6
| | | | | Change-Id: I2edcb2c324919a1131ae490bee9c9b1140097b09 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move inlineComponentData and icRootName into base CUUlf Hermann2024-01-132-41/+35
| | | | | | Change-Id: I89e44644b083681f069d1d7a385bec68b4bfd80b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove the use of Q_QML_PRIVATE_EXPORTAlexey Edelev2024-01-1124-138/+138
| | | | | | Task-number: QTBUG-117983 Change-Id: I5790f01d614cd70c7fcc9bd817ec6ace3f3e3730 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Clear stale compilation units more thoroughlyUlf Hermann2024-01-111-1/+10
| | | | | | | | | There are various places where we can still hold references. Clean them up when asked to do so. Also, free unused types and caches outside the type loader mutex, and only once on engine shutdown. Change-Id: Iae77cd6f50ad847d29a7eae4ac5c7c1c2524065d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move creation of ExecutableCompilationUnit into engineUlf Hermann2024-01-116-19/+33
| | | | | | | This is in preparation for letting the engine cache the executable CUs. Change-Id: Ideac10d8dda0784b41304b58f9b9fbd106173ea6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Remove QQmlTypeLoader from QQmlImportUlf Hermann2024-01-114-17/+37
| | | | | | | | | The type loader belongs to the engine and we must not store it in engine-independent data structures. We do want the import cache to be stored in the type registry, though (in a separate change). Change-Id: I2828f5098b27bf1fc96852fc2bd160db44b109e7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Get rid of the module mutexUlf Hermann2024-01-104-49/+14
| | | | | | | | | | | | | It only exists so that the type loader can query pre-compiled and native modules from the loader thread. However, the type loader already has a mutex of its own. We can use that to inject a "native" blob into its script cache for the same effect. We need to get rid of the mutex so that we can use the module map for other compilation units, too. Change-Id: I5a9c266ea36b50f5ea69214110def644f7501674 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Always link executable CU on creationUlf Hermann2024-01-106-160/+74
| | | | | | | | | | | | | | | We don't want floating unlinked executable CUs. They should always be tied to an engine, and the engine should not change. This gives us one definite point where to register them with the engine (to be done in subsequent change). Unfortunately, due to the refcounting, we need to remove the engine from any still-referenced CUs when the engine itself is destructed. We will be able to drop the refcounting and make the engine fully own its executable CUs once we can hold base CUs in most places. Change-Id: I9a53e83d5c4746c2b2bca896b51baa4fe7fee757 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Make base CU a member of ExecutableCompilationUnitUlf Hermann2024-01-107-53/+102
| | | | | | | | | | | | We want to re-use the base compilation unit across engines. For that to work it cannot be a slice of the engine-specific ExecutableCompilationUnit. Since CompiledData::CompilationUnit is refcounted on its own now, make it unmovable. Change-Id: I8418c9754d7a07e5210c1e7a7fc69355e1d57807 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Compiler: Guard against null dereference when ignoring function returnOlivier De Cannière2024-01-091-7/+9
| | | | | | | | | | | | | | | | | | | When a function is called, two arrays with the necessary information are passed to the engine: argv: [return address, prameter 1 address, parameter 2 address, ...] types: [return type, parameter 1 type, parameter 2 type, ...] When the result of the call is ignored, the return type is set to void and the return address to null. A check for this null value was missing leading to a null derefence. Amends: 4f1b9156a48e44cf1f127a4563d0ac69ab436f12 Fixes: QTBUG-120336 Pick-to: 6.7 Change-Id: I4a21779f3276b0143087b41b0d16c0cd3ba0e7db Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* ExecutableAllocator: Use non-recursive mutex againFabian Kosmale2024-01-081-1/+1
| | | | | | | | | | | Amends/parially reverts 4bac72aa13e6818460f6b71127d3af5bd7e00ca5, which replaced recursive Qt5 mutexes with QRecursiveMutex – but ExecutableAllocator used QMutex::NonRecursive, so this instance was misguided. Pick-to: 6.7 6.6 Change-Id: I33fd9e903b8861a7907bc8bde7632045198ef5c7 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QtQml: Move engine-specific data out of base compilation unitUlf Hermann2024-01-083-8/+41
| | | | | | | | | | We want to re-use the base compilation unit for different engines. To do that, we cannot have data in there that belongs to a specific engine. Pick-to: 6.7 Task-number: QTBUG-120189 Change-Id: I8e43e7ec6c1cd33249dc4ed15fec16babc6d06fb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Make QQmlNullableValue somewhat saferUlf Hermann2024-01-081-2/+8
| | | | | | | | We need it movable, and you shouldn't be able to poke its internals. Change-Id: Ia9fbde26ef525837402d9214aa534eeec0221e2f Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* Long live incremental garbage collection in QML!Fabian Kosmale2023-12-207-6/+49
| | | | | | | | | | | | | | | | | The design of the garbage collector is described in src/qml/memory/design.md. The gc and gcdone test helpers are adjusted to drive the gc to completion, even when in incremental mode. Parts of tst_qv4mm and tst_qqmlqt need to run with the incremental gc disabled, as they call gc inside QML and assumes that the GC finishes before returning. Initial-patch-by: Rafal Chomentowski <rafal.chomentowski@ge.com> Task-number: QTBUG-119274 Change-Id: I1d94f41bc7a434fad67de0fd46454b6db285f2eb Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QJSValue: convert more aggressively to QVariantFabian Kosmale2023-12-192-16/+33
| | | | | | | | | | | | | | | | | | | | | | | Normally, we don't want to convert aggressively between JS objects and QVariant, as that is prone to losing information. However, QJSValue::toVariant is documented to attempt lossy conversions. Restore the behavior of Qt < 6.5.3 for it. This is done by replacing the boolean indicating we should wrap JS objects into QJSValue with an enum instead. That enum introduces a third state ("Aggressive"), which is only used for QJSValue::toVariant. All other users of QJSEngine::toVariant behave as before (post 6.5.3). Function objects are still not converted, as we know that this would be a futile attempt, and more importantly, to keep the behavior that existed before Qt 6.5.3. Amends 43077556550c6b17226a7d393ec844b605c9c678 which introduced the regression and afe96c4d633146df477012975824b8ab65034239 which fixed the issue only partially. Pick-to: 6.5 6.6 6.7 Fixes: QTBUG-119963 Change-Id: I07d9901437812579ac5b873a4dff4de60c8f617e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QML: Don't crash when calling coerceAndCall() with null thisObjectUlf Hermann2023-12-081-2/+5
| | | | | | | | Pick-to: 6.6 6.5 Fixes: QTBUG-119395 Change-Id: I5877beef9a53d358a6f58f9ce5029688bd9dcedb Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* JSEngine: Optimize QV4InternalClass for tests on MSVCOlivier De Cannière2023-12-052-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Running tst_ecmascripttests on MSVC in debug mode has become very slow and times out the CI. Analysing the program reveals that most of the slowdown is due to extensive wait times caused by locks. The test is run on all threads by default and this constant synchronization tanks performance. A large amount of these locks come from the fact that, in debug mode, MSVC standard containers use locks for most operations on iterators. This patch changes the container of the internal class transitions from an std::vector to a QVarLengthArray. This eliminates the iterator lock problem. The QVarLengthArray is given one inline entry to store a value. From the tests, it seems that the transitions contain only 0 or 1 entries about 84% of the time. In the remaining cases, more allocations will be needed. The additional entry will also increase the size of the containing object by 24 bytes. This should be a worthwhile tradeoff. This change alone has a significant impact on the duration of the tests. tst_ecmascripttests on 13900k with 32 threads Debug MSVC Windows Debug GCC Linux baseline: 2267s 104s QVarLengthArray 569s (~ -73%) 102s (~ -2%) This should be enough to no longer timeout the CI but many issues still remain. Change-Id: I69fefabc0375d76c817ef7d2d3b2e97dc1ace5bc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML: Let IDs in outer context override bound components' propertiesUlf Hermann2023-12-042-2/+31
| | | | | | | | | | | | | | | | | | This is necessary to make the usage of such IDs actually safe. If we let local properties override outer IDs, then adding local properties in later versions invalidates the ID lookups. [ChangeLog][QtQml][Important Behavior Changes] In QML documents with bound components, IDs defined in outer contexts override properties defined in inner contexts now. This is how qmlcachegen has always interpreted bound components when generating C++ code, and it is required to make access to outer IDs actually safe. The interpreter and JIT have previously preferred inner properties over outer IDs. Pick-to: 6.6 6.5 Fixes: QTBUG-119162 Change-Id: Ic5d3cc3342b4518d3fde1b800efe1b95d8e8b210 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlConnections: Allow connections to C++-defined methodsUlf Hermann2023-11-291-3/+3
| | | | | | | | | | | | | | | | | | | | With qmltc you can produce classes derived from QQmlConnections with handler methods that should still receive the signals. Introduce a new helper class QQmlConnectionSlotDispatcher that enables connections to a C++ method inside a QQmlConnections, in the same way as QQmlBoundSignal does for Javascript functions. Change QQmlConnectionsPrivate::boundsignals to allow for C++ slots using QQmlConnectionSlotDispatcher. This allows usage of Connections QML elements when they are compiled to C++ via qmltc. Pick-to: 6.6 6.5 Fixes: QTBUG-119084 Change-Id: I05d78a45a703630f43d37337268d0a3df341e7d3 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix build with -no-feature-qml-localeTasuku Suzuki2023-11-241-0/+2
| | | | | Change-Id: I01c1005d962a030672f785d8ef752dab62ed5712 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Engine: Group 'bad' case handling for optional chainsOlivier De Cannière2023-11-201-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch changes the way optional chains are dealt with in the bytecode. Instead of dealing with the 'bad' case (where the base of the lookup is null or undefined) of each instruction separately, all optional operations point to the same piece of code at the end of the optional chain to deal with bad accesses. In practice, for the lookup `root?.foo.bar?.baz` the following bytecode instructions are generated. LoadQmlContextPropertyLookup // root GetOptionalLookup --v // ?.foo GetLookup | // .bar GetOptionalLookup --v // ?.baz Jump done ------------v undefined: <----< | LoadUndefined | done: <------< In this way, the 'bad' case is handled in one place at the undefined label. If, on the other hand, the chain evaluation reaches the bottom, one jump takes the resulting value to the rest of the program. In this way, the 'bad' case has a constant size relative to the length of the chain. If no optional operation is performed at all. The 'bad' case handler is not generated at all. For this to work, GetOptionalLookup now jumps to the undefined label when its base is null of undefined. Other operations such as function calls `f?.()`, array access `a?.[0]` and delete expressions `delete foo?.bar` have also been adapted to point to the undefined label. Change-Id: I07158efc8767d84a7588299cae9fb763b0f6e253 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Detect slot object if explicitly providedFabian Kosmale2023-11-151-2/+20
| | | | | | | | | | | If explicitly context is given to function when connecting, it is used as the receiver. Then when the context is destroyed, the connection will also be cleared. Pick-to: 6.6 Fixes: QTBUG-29676 Change-Id: Iec9318132245094603f71e3e6279d65c8021cb7e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Optimize reading properties into V4 valuesUlf Hermann2023-11-152-25/+130
| | | | | | | | | | | | | | | We need to be more careful here since the builtins will become proper value types with metaobjects, but we don't want to encode them into QQmlValueTypeWrapper, but rather their specialized representations. Besides, avoiding the code path via QVariant and engine->fromVariant() is also a performance boost. Task-number: QTBUG-101143 Change-Id: I1c570ebcb6c4e129e9bdeef069b8a49e2a1e29d6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* resolveQmlContextPropertyLookupGetter: Use ScopedPropertyKeyFabian Kosmale2023-11-151-4/+4
| | | | | | | | | | We already have a scope, and there is no guarantee that the various calls we do won't cause an allocation, and conseqently trigger the garbage collector Pick-to: 6.6 6.5 Change-Id: I31db85e74b986c7d9f9d97b5d409e2030cd5f583 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Fix some problems with deep aliasesUlf Hermann2023-11-092-0/+10
| | | | | | | | | | | | | | | | | | | We cannot get the property cache for an inline component the usual way during type compilation. We have to ask the compilation unit for it. Guard against still not being able to retrieve the property cache for any reason. Abort the compilation rather than crashing. Also, unify the setting of property attributes. Those should really work the same way everywhere. Finally, disallow writing aliases to value type properties where the property holding the value type itself is not writable. Pick-to: 6.6 6.5 6.2 Task-number: QTBUG-115579 Change-Id: I029eb56a9a390085d0c696a787a64c48acf0d620 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Clear the whole lookup in storeNameSloppy()Ulf Hermann2023-11-021-4/+0
| | | | | | | | | | The clear() method was only use by storeNameSloppy() for the temporary lookup. It only cleared part of the lookup. Drop it and do the memset() directly. Pick-to: 6.6 6.5 6.2 Change-Id: Ib31be1d6fba09d2c86f3c4cd64626ab1fd90eb7f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add pragma syntax to support translation contextLucie Gérard2023-10-261-3/+10
| | | | | | | | | | | | | Translator pragma can be used to set the translation context instead of having the file name used [ChangeLog][qml][translation][Important Behavior Changes] The context for the translation can now be controled in a given file using pragma Translator. Task-number: QTBUG-114528 Change-Id: I6d9d7fb81ea969a90d8637d7277bdbe96c102088 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML Debugger: Don't crash when looking up values from imported modulesUlf Hermann2023-10-244-11/+30
| | | | | | | | | | We cannot look up the imports from other modules because those are stored in the CU. But we can avoid the crash. Pick-to: 6.6 6.5 6.2 5.15 Fixes: QTBUG-117479 Change-Id: Ib5660c94dfb7ed20baedf7f71b2f175e6be042b1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix compile time qsTranslate with empty contextUlf Hermann2023-10-241-2/+4
| | | | | | | | | | | | | | | | | An empty context is to be passed as-is. We shall not replace it with the file context context. Since the TranslationData struct has a field for the context, we need to invent a "no context" value we use for the methods that don't allow you to set a context (e.g. qsTr, qsTrId). We cannot use 0 because that is the empty string which is a valid context now. Amends commit 9cfc19faf5d1ce2b9626914ab4528998b072385d. Pick-to: 6.6 6.5 Fixes: QTBUG-118469 Change-Id: I160c512f42aba4a8ae2fc8860cdf4e50c53d9d3e Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Fix further return type constructionsUlf Hermann2023-10-201-5/+4
| | | | | | | | | | | | | There, too, the return type is already initialized and needs to be copied or moved rather than placement new'd. Amends commit 1d8859ce3a3d161ffa2ccd74f195b276795a5af5. Change-Id: I5008659171962a3bd476a6e890e7576579646ae3 Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QtQml: Don't unnecessarily detour through the CU to look up typesUlf Hermann2023-10-191-2/+1
| | | | | | | | | | | Since we also store partial types as QQmlType now, we can just look them up the regular way. Pick-to: 6.6 6.5 6.2 Fixes: QTBUG-117788 Change-Id: Id3e81853f802419f1121ef5e856c3272a3c977a1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QML: Add missing metaType-s to ExecutionEngine::metaTypeFromJSDmitrii Akshintsev2023-10-091-0/+6
| | | | | | | | | | | | | After debugging QTBUG-117384 it was found out that ExecutionEnginge is failing to convert Long and ULong types to a meta-type, because they were missing from the switch statement. Fixes: QTBUG-117384 Change-Id: Idcd7325e783df45d27323cb9d9d8372ddde25c3e Pick-to: 6.5 6.6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QtQml: Fix return type constructions when calling methodsUlf Hermann2023-10-071-9/+17
| | | | | | | | | | | | | | | We now expect the return type to be initialized in all cases. This is in line with what the various metacall() methods expect. Unifying this behavior makes it much easier to reason about and avoids complicated bugs and memory leaks. The code generated by QmlCompiler always passes initialized values for the return type anyway. Amends commit 4f1b9156a48e44cf1f127a4563d0ac69ab436f12 Amends commit 02c4c817fe1cfa4766c56759be99fb081382a586 Change-Id: I26c016676dd82c91d6ef81762b5c4b599f6f7f72 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QtQml: Correctly convert to QQmlListProperty<QObject>Ulf Hermann2023-10-071-0/+7
| | | | | | | | | If we have a QQmlListWrapper, we can extract its property. Fixes: QTBUG-117829 Pick-to: 6.6 6.5 6.2 Change-Id: I46ae8db1aabf7c1b617a22f371ce4f060cf4bb38 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qv4mm: Document and extend allocManaged overload setFabian Kosmale2023-10-062-2/+2
| | | | | | | | | Add some helper overloads to centralize the sizeof computation. Add a doc note about the various variants of allocManaged, including a note why we even need the size parameter. Change-Id: I4e0c485217e87c339a7433c306cb05d6614d30e1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML diskcache: Verify cache file sizeFabian Kosmale2023-10-062-0/+27
| | | | | | | | | | | | | | | | | | We can't rely on the checksum verification, as we still assume that we can read all bytes in the range claimed by the unit's header. If for some reason the cache file has been truncated, that will lead to crashes due to out-of-bound reads. As we already store the unit's size in the header, use it for an initial verification before doing any further work. Initial test case was provided by Harald Sitter <sitter@kde.org>. Pick-to: 6.6 6.5 6.2 5.15 Fixes: QTBUG-117130 Change-Id: Idd20191ed0e0ef9c37985c4c64124578f0607ad3 Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Construct return type before metaCallUlf Hermann2023-09-291-0/+2
| | | | | | | | | The metacall expects initialized memory. Let's give it what it wants. Fixes: QTBUG-117672 Change-Id: If139029ac4771ac919c5f09728633546e7bb9d1e Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Implement QObjectMethod::virtualCallWithMetaTypesUlf Hermann2023-09-287-139/+396
| | | | | | | | | | | | We can use the same mechanism we have in place when calling typed JavaScript functions. The type coercion is generalized and moved to qv4jscall_p.h. We also use the correct JavaScript coercion in the rare fallback case where the types are actually different. Fixes: QTBUG-113258 Change-Id: I30404ee0122433b47227b2fc0dc4b0e3862a99c7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Check for isReference() before trying to write backUlf Hermann2023-09-251-2/+3
| | | | | | | | | | | If we neglect this we get an assert further down the line. Amends commit a824a6f060ec3a0000d7349649a3ab9e0570ecaa. Pick-to: 6.6 6.5 Change-Id: Ib8fd01d329d5b45b27dfe117e168860c6a1d267f Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Silence warnings about converting holes in sparse arraysUlf Hermann2023-09-252-5/+6
| | | | | | | | | | | | | | Holes in sparse arrays are undefined when read via get(). QV4::Sequence does not have holes, by design. Therefore, when converting, we fill the holes with default-constructed values. This is on purpose and should not cause warnings. Furthermore, since QVariant::convert() always produces the given type, we don't need to re-initialize the variant afterwards. Change-Id: I46a675dfb71ae9f66858c97a580ec133aabef10e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* qml: use QSL lessAnton Kudryavtsev2023-09-151-2/+4
| | | | | | | | prefer _L1 where it's possible Change-Id: I3f3e1ccc985f6eb93ff2150825cae891add5dba1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* qml: replace fromLatin with _L1Anton Kudryavtsev2023-09-153-7/+10
| | | | | | | to improve readability and reduce allocations Change-Id: I1ffe10d6a14fb9cc09dd438cca84f4a1d74b8cb8 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* V4: Eliminate "done" from iteratorsUlf Hermann2023-09-088-51/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of dragging another stack value around to mark if the iterator was done, rather pass it an offset it should jump to if so. It can then jump over any IteratorClose instruction while the ExceptionHandler can still point to the IteratorClose instruction. For this to work, we also have to refrain from checking for exceptions as part of IteratorNext or IteratorClose. If IteratorNext generates an exception, it also jumps to the "done" label, after which we dispatch the exception. We don't want to jump to the exception handler for other instructions in between as that would close the iterator. The iterator should _not_ be closed if it has just thrown an exception, though. The same holds for IteratorClose: If it throws an exception, we don't want to jump back to the beginning of the loop's exception handler, since that would produce an infinite loop. We also don't want to reset the exception handler before IteratorClose because it needs to also be reset if the iterator does not need to be closed. This saves quite a few instructions and stack variables on actual iteration. For destructuring, we have to change the execution flow a bit. We need to first perform the iteration for non-rest parameters, saving the results in separate stack slots. This way we can apply our new "jump if done" behavior if the iterator runs out or produces an exception itself. We then save the "done" state in a separate stack slot, as before. During the assignment of the iteration results to the actual variables, we install an exception handler, so that we can still close the iterator if one of the initializers throws an exception. This produces a few more instructions than before: 1. We need to set and read the "needsClose" variable explicitly rather than having IteratorNext and IteratorDone do it implicitly. 2. We need an additional CheckException after the iteration. 3. We need an additional conditional Jump over the IteratorDone. Everything considered, the savings we get for regular iteration and the more consistent semantics of the instructions involved are well worth the few extra instructions on destructuring, especially since everything those extra instructions do was done implicitly by the iterator instructions before. For consistency, the IteratorNextForYieldStar instruction is refactored to work the same way as IteratorNext: In case of either an exception or "done" it jumps to an offset, and we refrain from individually exception-checking each IteratorNextForYieldStart instruction. Task-number: QTBUG-116725 Change-Id: I9e2ad4319495aecabafdbbd3dd0cbf3c6191f942 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* V4: Remove some dead codeUlf Hermann2023-08-311-13/+0
| | | | | | Change-Id: I7aac01c2176db377efd7ab0a255b82ea7c36b9b4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QmlCompiler: Allow coercing date values to numbersUlf Hermann2023-08-252-0/+8
| | | | | | | | | This is the equivalent of JavaScript's valueOf(). Change-Id: If850519d6dbc7354b447acb6aad8ac04211d059d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QtQml: Reset context object when destroying it from QObjectWrapperUlf Hermann2023-08-221-0/+2
| | | | | | | | | | | There may be other objects that still hold on to the context data. We should not leave them with a dangling context obejct. Pick-to: 6.6 6.5 6.2 Fixes: QTBUG-116228 Change-Id: I3dddd20b13956408d0e66c3a46e59377e45d91e5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QV4::QObjectWrapper: Use the object's actual meta typeKai Uwe Broulik2023-08-221-4/+2
| | | | | | | | | | | | | | | | | | | Otherwise, a derived type's methods will not be found. In our particular case we tried to call a method of 'B*' on a QML attached property declared as 'A*'. This restores the previous behavior of using the object() for the meta type except for when it's a value type wrapper. Amends commit 63b622d5908ec2960ce5dfa301e9d3fd4d92fdb4. Pick-to: 6.6 6.5 6.2 Change-Id: I08b9f4b97a58c15fdc3703dd3c5d927cd1beb3ce Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QV4::QObjectWrapper: Remove superfluous loopKai Uwe Broulik2023-08-191-7/+5
| | | | | | | | This caused all overloads to be printed in exponential amounts. Pick-to: 6.6 6.5 Change-Id: I619b5402e9d9f164c4372c30ba28655818b81014 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Allow construction of Date objectsUlf Hermann2023-08-182-11/+28
| | | | | | | | | We map Date to QDateTime and special-case its constructors. Task-number: QTBUG-111624 Change-Id: I0496f853613da3ccee9b6f6c4cf0adffa064f9f8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>