aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4executablecompilationunit.cpp
Commit message (Collapse)AuthorAgeFilesLines
* CRA review qml/jsruntimeFabian Kosmale2025-09-161-0/+1
| | | | | | | | | | | | | | | | | | This relies heavily on the documented fact that we only support trusted QML/JS content, meaning most files are only significant, not critical. This also extends to the handling of qmlc files (as in compilationunitmapper), as we store them in a user owned, non-shared cache directory – so any vulnerability there would already mean that an attacker has write-priviledges on user data. An exception is ArrayBuffer, which can be used with arbitrary user data, and should create a valid QBA. Fixes: QTBUG-136970 Pick-to: 6.10 6.9 6.8 QUIP: 23 Change-Id: I22033fe6ab4acf8362a8183e25b92331d45cb32c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* JSRuntime: Add const correctnessOlivier De Cannière2025-08-121-1/+1
| | | | | | Change-Id: I2fc82de562909ab2e0eecfbbe1e2e53953a33756 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Ensure that dependencies of modules are properly loadedUlf Hermann2025-06-181-21/+16
| | | | | | | | | The type loader should make sure that they are available. Prove that by wrapping all access to dependencies into an accessor that checks the dependent scripts. Change-Id: I6e0153fcb213e1a5b6ece79e3fbc0e27dc1b292c Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QtQml: Model native modules as compilation unitsUlf Hermann2024-12-061-114/+19
| | | | | | | | | | | | | | | | | | | | | | | QQmlTypeLoader::injectedScript() was unsafe and impossible to fix because it had to query the engine from the type loader thread in order to find out whether to load a script from an actual file. By removing the whole special-casing of native modules, we can make the script loading thread safe. A native module is now also a compilation unit, with a regular QV4::Module as value. This means we can remove a lot of code that deals with the native modules in the engine. The downside is that native modules are now a lot larger than before. However, given that they don't appear in any examples and hardly any bugs have been filed about native modules since their introduction, we can assume that they are not a very popular feature. The reduction in complexity and the removal of the native modules map in the engine is expected to outweigh the extra memory overhead for native modules. Task-number: QTBUG-131721 Pick-to: 6.8 Change-Id: Ia7388d7ba8d71637559a791d874257fba4646330 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Remove base CU when clearing executable CUUlf Hermann2024-10-241-0/+4
| | | | | | | | | | | | | | This allows the base CU to be released while there may still be objects around that reference the executable CU. Since the JS engine is gone, the CU is not useful for much anymore anyway. Since we don't want to check for the presence of a base CU in every method, we replace the base CU with a static null value. Fixes: QTBUG-129388 Change-Id: I84f8410fa8652203ac7c39f88a6d5aa05420ab11 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Call lookups based on enums rather than via function pointersUlf Hermann2024-10-241-4/+4
| | | | | | | | | | | | | | | | | While the C++ standard says that different functions need to have unique addresses, some compilers have take substantial liberties with that rule. This means we can't actually rely on the addresses of our different lookup functions to differ and therefore we cannot use them as discriminator. Introduce an enumeration for all the different lookups and use that instead. Now we can also drop all the purely redirecting methods we've introduced just to have different addresses. Change-Id: Ifa68c27c0d2fef4084893a19227dab21bd948dfd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Decouple JavaScript library CUs from enginesUlf Hermann2024-09-201-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | In order to re-use the compilation units for JavaScript libraries, we need to eliminate the "m_value" member they are carrying, indirectly. The values are tied to specific engines and invalid in others. Luckily, we already have two suitable places to store such values: 1. In case of a "native" module without a compilation unit we have the nativeModules hash in ExecutionEngine. 2. In case of a module or library backed by a CU we have the "module" member of ExecutableCompilationUnit. This can currently only hold modules but there is no reason why it wouldn't hold JavaScript libraries equally well. By using the "empty" V4 value we can also get rid of the m_loaded bool. As a drive by, correct the QQmlScriptBlob::isNative() misnomer. We don't want to know whether the script is native (for any value of that), but rather whether it has a value. Pick-to: 6.8 Fixes: QTBUG-129052 Change-Id: I284823f4aa26e46dec8328f88f65877f59e40f79 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix typo in commentLuca Di Sera2024-06-281-1/+1
| | | | | | | scopde -> scoped Change-Id: I34d68aa09a9d3fb84cc558055ed0388725f41fbb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Properly enforce signatures of AOT-compiled functionsUlf Hermann2024-04-261-1/+1
| | | | | | | | | | | | | Pass the metatypes of the contained types rather than the stored types. [ChangeLog][QtQml][Important Behavior Changes] The AOT compiled code for type-annotated JavaScript functions does not let you pass or return values of the wrong type anymore. Fixes: QTBUG-119885 Change-Id: I685d398c0745d32a999a3abd76c622a2c0d6651f Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qv4mm: Handle running out of native heap memoryFabian Kosmale2024-03-051-6/+1
| | | | | | | | | | | | | | | | | With the current setup, we would have risked running out of native heap space if the incremental garbage collection takes too long. Remedy this by forcing the current gc run to complete immediately once we overshoot the limit by a factor of 3/2. We still need to respect that the gc must not run in a critical section: Handle this by rechecking the condition when leaving the critical section, and only forcing a gc run at that point if necessary. Note that we currently update the gc limits before the gc cycle finishes, so that the effective limit might actually not be 3/2 in that case. This will be remedied in an upcoming patch. Change-Id: I19c367bd1ff6ffc129293fc79e39b101f0728135 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Prepare for white allocations during gc (9/9): ExecutableCompilationUnitFabian Kosmale2024-03-051-4/+16
| | | | | | | | | | | | | | | | | | | | | | | ExecutableCompilationUnits are meant to be part of the roots as far as the gc is concerned. However, they can be created at any point in time, notably also while the GC is running. This was safe so far because all allocations are black, and the compilation unit will only reference freshly allocated heap items. As we want to move away from that pattern, we have to change this: We could use the typical combination of QV4::Scope and usage of the WriteBarrier, however that would add overhead for a very uncommon case (except when using QV4_MM_AGGRESSIVE_GC). Instead, we temporarily block the garbage collection, reset the state of an ongoing garbage collection and at the end of the setup of the ExecutableCompilationUnit, we mark the ExecutableCompilationUnit if the GC was already running. Introduce a new blocked state (CriticalSection) to distinguish between the normal blocked state (gc is running) and the new state where we must not even run an incremental gc to completion until the section has finished. Task-number: QTBUG-121910 Change-Id: I1dba3cc8a4f8d2b741a1a5e84fdfe7736b08e166 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Move header verification into CompiledData::UnitUlf Hermann2024-01-231-66/+0
| | | | | | | | There is nothing that makes it depend on ExecutableCompilationUnit. Change-Id: I482dfc0177530f748bb90e5373c64ca5558d8629 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Use CompiledData::CompilationUnit in more placesUlf Hermann2024-01-201-139/+2
| | | | | | | | | | We rarely actually need the executable CU, and where we need it, we can dynamically create or retrieve it from the engine. To that end, store all the CUs in the same container in the engine. Change-Id: I0b786048c578ac4f41ae4aee601da850fa400f2e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move dependentScripts into base CUUlf Hermann2024-01-181-2/+0
| | | | | Change-Id: Ia332a691a4a5f04fcca50eb1c3e2018f8368dbe6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move type name cache into base CUUlf Hermann2024-01-181-2/+0
| | | | | Change-Id: Ie3504f16b34859cdef72f8138e6058dcc2d1f58f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move qmlType into base CUUlf Hermann2024-01-181-15/+4
| | | | | Change-Id: I81ae9a4d24518dffc5b924994d45203958bb9546 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move checksum verification into base CUUlf Hermann2024-01-131-17/+0
| | | | | Change-Id: I49d48a7bc38e727bb23f3154311e1f7876f8cc03 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move binding, object and parser status counts to base CUUlf Hermann2024-01-131-21/+3
| | | | | Change-Id: Id52e3d50b02649010ebcb2309253aa689a536770 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move property caches into base CUUlf Hermann2024-01-131-1/+1
| | | | | Change-Id: I1567c9d3d61312e98200fb0854d7fcf111983948 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move ResolvedTypeReference into base CUUlf Hermann2024-01-131-38/+3
| | | | | Change-Id: I25063457aad3a6d29a8c2a5b236f9a51b56a2f51 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move inlineComponentData and icRootName into base CUUlf Hermann2024-01-131-17/+17
| | | | | | Change-Id: I89e44644b083681f069d1d7a385bec68b4bfd80b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move creation of ExecutableCompilationUnit into engineUlf Hermann2024-01-111-2/+2
| | | | | | | This is in preparation for letting the engine cache the executable CUs. Change-Id: Ideac10d8dda0784b41304b58f9b9fbd106173ea6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Get rid of the module mutexUlf Hermann2024-01-101-13/+4
| | | | | | | | | | | | | 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-101-115/+36
| | | | | | | | | | | | | | | 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-101-19/+39
| | | | | | | | | | | | 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>
* QtQml: Move engine-specific data out of base compilation unitUlf Hermann2024-01-081-2/+6
| | | | | | | | | | 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: Fix some problems with deep aliasesUlf Hermann2023-11-091-0/+9
| | | | | | | | | | | | | | | | | | | 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>
* 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>
* 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: Use QQmlType as container for composite types (inline or not)Ulf Hermann2023-06-221-22/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This gives us a unified interface to all kinds of QML types at run time and reduces the effort of finding corresponding type attributes. QQmlType is much larger than CompositeMetaTypeIds. Most composite types, however, are initially referenced by URL, and we call typeForUrl anyway. typeForUrl already creates a mostly functional QQmlType; we only need to add the dynamic metatypes. The same type can be retrieved later and associated with the actual CU using the compositeTypes hash. That way, we don't need any extra type. We do, however, incur the cost of creating the QMetaTypePrivate instances when first referencing a type. This could be optimized, like many things in this area, by using thread safe lazy initialization. Now some QQmlTypes implicitly depend on the CUs they were created for. This creates problems if the CUs are removed but the types still persist. Such a situation can arise if you create and delete engines. In order to avoid it, we: 1. Make the compositeTypes hold a strong reference to the CUs 2. When unlinking, avoid dropping the property caches (as those are used to hold the metaobjects) Now, however we got a cyclic reference between the CU and its QQmlType(s). To resolve this, we clear the QQmlTypes on unlinking. Finally, to avoid deletion recursion when clearing the last CUs on destruction of the QQmlMetaTypeData, we move the compilation units out of the way first. All of this still doesn't work if multiple CUs hold the same QQmlType, since compositeTypes can only hold one CU per type and that may be the one that gets removed first. Therefore, we cannot allow such a situation to happen and have to create a new QQmlType if it arises. It can only arise if you have multiple engines loading the same QML components, which should be fairly rare. For inline components, we apply a similar trick: You can either find an inline component by Url, and receive any type that matches, no matter what CU it belongs to. Or you can request an inline component type that belongs to a specific CU. It turns out we don't have to store the containing type of an IC at all. Also, we slightly change the naming of internal components' "class names" since we want to use the inline components' element names for them. Change-Id: I0ef89bd4b0a02cc927aed2525e72f6bff56df626 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QtQml: Index inline components by name rather than IDUlf Hermann2023-05-301-27/+51
| | | | | | | | | | | The ID can only be determined once the compilation unit is present. It depends on the order of objects in the compiled data. The name is always available. Indexing by name increases the overhead. However, since we don't have to "amend" the ID later on and since we only need one lookup table rather than two per type now, it's probably worth it. Change-Id: I478de505a1934b5b6ab340b4be4fa5da4e95aeb3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Remove dead memberUlf Hermann2023-05-241-4/+1
| | | | | | | | Besides never getting read it would also never get invalidated when the QML engine was deleted. Change-Id: Ibaceafbd3d61d0ed82a76e4d7caec518fa12ef09 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Undeprecate AOTCompiledFunctionUlf Hermann2023-05-231-2/+2
| | | | | | | We're going to call the JavaScript-typed functions a different name. Change-Id: If92c3fb1b16b1b0bd7d009e7dd712ae6405e1232 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Runtime codegen: Avoid memset for zeroingFabian Kosmale2023-05-041-12/+8
| | | | | | | | | We can just use calloc and zero-initialization. Change-Id: I88dc79d5b880253655159ae3b4385b9792a18ec6 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Refactor the usage of icutils::NodeAmir Masoud Abdol2023-04-241-1/+1
| | | | | | | | | | | In Unity Build, on OpenSUSE, for some reason compiler confuses the Node with an `int`. This refactoring resolves the issue by moving the type into the `icutils` namespace. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: Id379b9aff21b29115d4503791debd658f034a0cd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Improve handling of CU's sourceFileIndexUlf Hermann2023-03-281-4/+9
| | | | | | | | | | | | | | In the unlikely case that we get a corrupted CU from a cache file and it still passes the header verification we don't want it to access invalid memory when checking the file name. We also generally want to use uint as index into the string table. A signed integer makes no sense here. Pick-to: 6.5 Coverity-Id: 310389 Change-Id: I12e9b8f39e1d3c68fd701c1ef4f54845ab8c3c12 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Invalidate any existing cache files when saving a CU to diskUlf Hermann2023-02-101-2/+8
| | | | | | | | | | Otherwise we just re-load the old cache file next time. That's clearly not intended. Pick-to: 6.5 6.4 6.2 Fixes: QTBUG-111078 Change-Id: Ia65b46880eca2b6e8c4792a09f20716125beada3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Allow more fine grained control of the disk cacheUlf Hermann2023-01-021-2/+5
| | | | | | | | | You can now enable and disable the AOT-compiled code and the loading and saving of .qmlc files separately. Fixes: QTBUG-101358 Change-Id: I1305c4f2f75d8cff544a127e956589d1ed1aeb52 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Qml: Analyze qsTranslate at compile timeUlf Hermann2022-10-131-9/+14
| | | | | | | | | | We generate translation bindings for all the other translation functions already. We can just as well generate a translation binding for this one, too. Fixes: QTBUG-107536 Change-Id: I851f03c26510b6d450aa78f5d7a1f0142d3a81aa Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-10-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that on() was replaced with a matcher that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Change-Id: I58e1b41b91c34d2e860dbb5847b3752edbfc6fc9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-071-4/+4
| | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace. Task-number: QTBUG-99313 Change-Id: I601bf70f020f511019ed28731ba53b14b765dbf0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-1/+1
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Use an enum to categorize functions and rename aotFunctionUlf Hermann2022-09-291-2/+2
| | | | | | | | We want to use the aotFunction member also for typed JavaScript functions. Change-Id: Iad6d12ebed3ad3069832484137ed8e4d9e7a7cf4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Optimize QObject method callsUlf Hermann2022-09-201-1/+2
| | | | | | | | | | | | | | | | | | | | | | So far, for each method call we had to allocate a new QObjectMethod as we didn't have any lookup to cache the methods. Introduce a new lookup for that and use it for all QObject methods. Since QObjectMethod contains a pointer to the concrete QObject the method was retrieved from, some more care has to be taken: If we are going to call the method right away, we don't need the object since we always have a thisObject and any further retrieval of the same method will result in a call again. This enables us to cache the method for any instance of the same class. When storing the method elsewhere, though, we need to hold on to the object since you can defer the call or connect a handler to a signal or similar. For such operations we do need the object. We can still optimize a bit by re-using the method cache we build the first time around. Fixes: QTBUG-95628 Change-Id: I5991180c5e0234cdc179c2b78a43dafc9083e525 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Remove unused includes in qml, first partSemih Yavuz2022-09-141-1/+0
| | | | | | | | | | | | | | | Drop unnecessary includes detected by clangd-iwyu. Add new includes due to the transitive includes. Also, some of the includes were detected as unused even if they were actually in use. In those cases, use angular brackets instead of "" which deceives the tool not to complain. Affected subfolders: Debugger, Compiler, JsApi, JsRuntime, Memory, Parser Task-number: QTBUG-106473 Change-Id: I01d996a2a2ba31cbbc5f60f5454c8f850298f528 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Make modules imported with registerModule() available in QMLUlf Hermann2022-09-021-57/+110
| | | | | | | | | So far, you could only use them from pure JavaScript programs. Also, fix re-exporting parts of native modules. Fixes: QTBUG-105901 Change-Id: I170017083284e6457b1aa0c6e606fd26227edae3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Create Translation Bindings without CompiledData::BindingSami Shalayel2022-08-151-19/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To add translation bindings to qmltc, the methods used to create translation bindings need to be adapted to work without QV4::CompiledData::Binding as it is not available from qmltc. Instead, information already available from the QQmlJSScope should be used, along with a newly introduced helper class QQmlTranslation. Details: Add a QQmlTranslation class that represents a call to qsTr, qsTrId etc that knows how to translate itself (without needing any ExecutableCompilationUnit or Binding). It encapsulates the information needed to create a translation binding. ExecutableCompilationUnit::bindingValueAsString refactored so its functionality can be used without Binding. Instead, it uses only the translationId, see ExecutableCompilationUnit::translateFromId and ExecutableCompilationUnit::translateFrom. Refactored QQmlTranslationBinding to work with QQmlTranslation instead of CompiledData::Binding. Same for QQmlCppBinding::createTranslationBindingForBindable, QQmlTranslationPropertyBinding::create and QQmlCppBinding::createTranslationBindingForNonBindable. Changed TranslationBindingInformation to work without CompiledData::Binding, and also removed static unused QString ProxyTranslator::originStringFromInformation( const TranslationBindingInformation &translationBindingInformation) as I could not find out what this origin string is. Same for the translation debugging in qmldb_preview. Added QmltcCodeGenerator::generate_createTranslationBindingOnProperty. Added #if to avoid compilation error for standalone DOM compilation due to the new QQmlTranslation class. Task-number: QTBUG-105345 Change-Id: Iccd94d5cba4eaf63901233451fec48051c855c2a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@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>
* QML: Port QV4::CompiledData::Binding to new special integer bitfieldUlf Hermann2022-05-111-1/+1
| | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: I9f8bc5fa45c61f77ee95b055a3d8de001da8f8c5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Port QV4::CompiledData::Location to new special integer bitfieldUlf Hermann2022-05-111-3/+9
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: If0d6f893f2351a4146ddf125be4079b5e312f308 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>