aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
Commit message (Collapse)AuthorAgeFilesLines
* QtQml: Move QMetaObjectWrapper into separate header/impl filesUlf Hermann11 days5-140/+214
| | | | | | | | | We want to use it from QQmlTypeWrapper and avoid circular includes. Task-number: QTBUG-124662 Change-Id: I4c78a17eb262a303b7239bbdd853ec02d609c330 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Properly enforce signatures of AOT-compiled functionsUlf Hermann13 days6-64/+73
| | | | | | | | | | | | | 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>
* gc: Fix stale pointers in WeakValuesFabian Kosmale2024-04-252-18/+53
| | | | | | | | | | | | | | | | | WeakValue::set shold normally not mark objects, given that a weak value is not supposed to keep an object alive. However, if we are past GCState::HandleQObjectWrappers, nothing will reset weak values referencing unmarked values, even if sweep collects the referenced value. That leads to stale pointers, and then most likely to crashes. To avoid this, we mark the objects under this special condition. The test is written in a way that would also allow for resetting the new weak values instead, but the current implementation treats memory usage for throughput and doesn't revisit weak values to reset them. Change-Id: I789f63c1d8609957711c2253d2e76b4bd3f9810a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Perform return value assignment inside generated codeUlf Hermann2024-04-241-1/+1
| | | | | | | | | | | | This is in preparation for using exact types and actually enforcing them. We shouldn't wrap the return value into a QVariant in order to then painstakingly unwrap it again. The generated code can already do the right thing. Task-number: QTBUG-119885 Change-Id: I13e517967ee982be717024a9abb74d5e02a185d6 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Fix some type conversion edge casesUlf Hermann2024-04-232-15/+24
| | | | | | | | | | | | If the type conversion code fails to convert an argument, we still need to make sure the argument has a definite value. Otherwise we may trigger undefined behavior somewhere down the line. Furthermore, we want to look at the precise type when converting list properties. Otherwise we get a list property without any methods back when converting. Pick-to: 6.7 6.5 6.2 Change-Id: I012c0360ef1578c768362d5a4648252d3e6803d8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Use QHash/QMap's constFind() to avoid unnecessary detachesVladimir Belyavsky2024-04-222-8/+8
| | | | | | | | Use QHash/QMap's constFind() instead of non-const find() where applicable to avoid unnecessary detaches. Change-Id: I6b31af1d163d11deb229681ff7e2f6c9f8335d8c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: do not obtain the stack trace twice in CallPrecise()Vladimir Belyavsky2024-04-221-1/+1
| | | | | | Change-Id: Ieb108a84f5c1fefe813ac0af6c2ca9332fdbefe8 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Handle all array-like containers when converting to QJsonArrayOlivier De Cannière2024-04-223-11/+14
| | | | | | | | | | | | | | | | Commit b9bfdea0e2c6721d2306af0ecc44f88da9988957 removed specialized code for QVariantList conversions by relying on sequences instead. Some checks for sequences and other array-like containers were missed. Add those and perform all calls to QJsonObject::toJsonArray through a common QV4::Object interface. Amends b9bfdea0e2c6721d2306af0ecc44f88da9988957 Pick-to: 6.7 Fixes: QTBUG-123993 Change-Id: Ia671d556af4f2b4d44f652fa93182977d88621f2 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* UrlObject: Avoid potential extra QList detachesVladimir Belyavsky2024-04-221-6/+1
| | | | | | | | | | There might be potential extra QList detach due to the use of non-const QList iterators in UrlSearchParamsPrototype::method_delete(). To avoid this, we can use QList::removeIf() which doesn't detach if there is nothing to remove and also makes the code a bit clearer. Change-Id: Ia4d2d2d0ac2d1dc4b08ed0b34b701bab7bca6250 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Add a wrapper builtin for QQmlV4Function*Ulf Hermann2024-04-122-2/+2
| | | | | | | | | This way qmltyperegistrar can recognize it and refrain from warning about it. Task-number: QTBUG-101143 Change-Id: I598140e7e90dbd3e27a78c26eff3d46f0fd3e989 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Don't call methods on nullptrUlf Hermann2024-04-051-18/+26
| | | | | | | | | | The root node of a sparse array can be null. Pick-to: 6.7 6.5 6.2 5.15 Fixes: QTBUG-123596 Change-Id: I5ea7fd73aeec460082d0cf19c7fc8a01993ed1f9 Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix heap-buffer-overflow in ESTable::removeOliver Dawes2024-04-042-17/+17
| | | | | | | | | | | Fixes a heap-buffer-overflow issue in ESTable::remove due to an off by one error in the count provided to memmove calls. Task-number: QTBUG-123999 Pick-to: 6.7 6.5 6.2 5.15 Change-Id: I4ee0fbc16ba8936ea921e5f1d1bb267dae0b1d5f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* ArrayData/MemberData: Prove Fixed gc interactionFabian Kosmale2024-03-051-1/+1
| | | | | | | | | | | | | | | | | | When setting values on a newly allocated Array- or MemberData, d7aa952e143accc18d54707d956d019272197078 made the assumption that it is safe to skip the write-barrier, as the new values would be marked when the "values" member would be written to (pushing the new data on the mark stack, and then later marking all objects stored in values when it gets popped and markObjects runs). Now that we no longer do black allocations, this actually holds true. Add a unit test to verify it. Task-number: QTBUG-119274 Task-number: QTBUG-121910 Change-Id: Ia1ceeaffeaf30dc1fb2b9e1992dd0b599050294c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* qv4mm: Handle running out of native heap memoryFabian Kosmale2024-03-052-8/+2
| | | | | | | | | | | | | | | | | 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-052-6/+18
| | | | | | | | | | | | | | | | | | | | | | | 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>
* Prepare for white allocations (7/9): QQuick(Window|View)Fabian Kosmale2024-03-052-1/+26
| | | | | | | | | | | | | Prevent QObjectWrapper from being gced - if we use white alloctations, and the weak values have already been marked, then nothing will mark the newly created QObjectWrapper. Use a helper function which takes care of the marking, and call it in the appropriate places. Also mark the normal wrap and wrapConst functions as [[nodiscard]] to avoid this issue from resurfacing in the future, and adjust a few call-sites to also call ensureWrapper. Change-Id: I8d4c73ae62b61d21b1456a3b096fc6a42f302160 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Prepare for white allocations during gc(6/9): Engine setupFabian Kosmale2024-03-051-0/+3
| | | | | | | | | | | | | | | | We temporarily forbid the GC from running before global object is setup, as our root set marking would otherwise run into issues in incremental mode (we don't revisit roots, and roots don't generally employ write barriers, so we might miss internal classes referenced by the global object). The GC would normally never run while the engine's constructor has not completed, however this does not hold true when QV4_MM_AGGRESSIVE_GC is enabled. Task-number: QTBUG-121910 Change-Id: I08360005f66bb6e6a36da2e16704093398f0d154 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Prepare for white allocation during gc (5/9): SharedInternalClassDataFabian Kosmale2024-03-052-7/+6
| | | | | | | | | | Employ the new WriteBarrier::Pointer to ensure that MemberData is always protected. Change-Id: I3a6d0fddc8fc6d2056023da35c11559bb7701401 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Prepare for white allocation during gc (4/9): BoundFunctionFabian Kosmale2024-03-051-2/+2
| | | | | | | | | | | Put the newly created FunctionObject into a Scope. This isn't actually needed, but acts as a safeguard in case FunctionObject::function is changed in the future to allocate memory. Change-Id: I5bcd888cd8bd5cb8c727eb3b29222981c851d4fe Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Prepare for white allocation during gc(3/9): FunctionFabian Kosmale2024-03-055-18/+32
| | | | | | | | | | | | | | | | Function(Data) keeps references to two heap-items; use the newly introduced wrapper classes to ensure writes always go through the WriteBarrier. Provide a "mark" function in ExecutableCompilationUnit so that the wrapper can actually pick it up - the existing function there was called markObjects. We don't rename the existing function to keep the diff minimal. Provide a mark function in Function for the same reason. Task-number: QTBUG-121910 Change-Id: Ib56eb2f3f2315036ce43273c9ebc629d10458e9a Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Prepare for white allocations during gc (1/9): Write barrier for LookupsFabian Kosmale2024-03-056-37/+47
| | | | | | | | | | | | | | | | | | | | | | | Lookups can (and do) reference HeapItems. This was safe in a non-incremental gc world, as Lookups are always reachable via their containing CompilationUnits, which are part of the root set. However, when using an incremental gc, an already marked Lookup might reference a new heap item, which then becomes otherwise unreachable. This is alleviated by the fact that Lookups generally either refer to something already existing or a freshly allocated string. The latter however is only safe when we can rely on black allocations during gc, and the former is somewhat reckless. Remedy this by employing the WriteBarrier for Lookups. We wrap all HeapItems in a helper class, which -while trivial itself- can't be used for direct assignments. Intead, it employs a set method which ensures that the WriteBarrier is used. Task-number: QTBUG-121910 Change-Id: I6a0ede66ad044076d2e87f134bc95686cb586aee Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Prepare for white allocation during gc (0/9): EngineFabian Kosmale2024-03-052-6/+17
| | | | | | | | | | | | When inserting compilation units into the engine, we don't have any write barrier, as those are treaded as roots. However, we still have to be careful when an executable compilation unit is created while the gc is already ongoing. Thus, when we insert a CU into the engine, we mark it. Change-Id: I5e7c7e9518190dd6943cf57b0a82229d6be8d3b9 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* Silence -Wimplicit-fallthrough for clangTim Blechmann2024-03-031-0/+1
| | | | | | | | | Unlike gcc, clang warns about implicit fallthrough even if the following label only contains a `break` statement Pick-to: 6.7 Change-Id: If7fb15b5e2e1a8fb80668087e4497efb8d3d30d4 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QtQml: Make QLocale an actual value typeUlf Hermann2024-03-022-24/+0
| | | | | | | | | | | | | | | | | | | | We want to be accessible to qmllint and other QML tooling. To this end, make all legal invocations of its methods properly typed invokables. Keep two QQmlV4Function overloads to produce error messages if the methods are called with the wrong parameters. We have to do this because JavaScript is more liberal in its argument coercion than the methods would like. Un-deprecate QJSNumberCoercion::isInteger() since it's actually quite practical here. Pick-to: 6.7 Fixes: QTBUG-112366 Change-Id: I016e5edc47efaade44461c504c1b3e2b1b829b58 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Do not construct strings where we don't need toUlf Hermann2024-02-261-5/+9
| | | | | | | | If we want to know whether the QML.StrictArguments class info is "true", we can just compare the byte array directly. Change-Id: If857f88c0cce7314abaaa6131a2fba3cd459c4b2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Clean up and clarify Date's ParseString's commentEdward Welbourne2024-02-161-8/+8
| | | | | | | | | | | | | The comment on the supported formats used a notation for date-time formats that doesn't match what QDateTime and friends use. So amend to match that and make clear (by repeating parts of the format in the explanation, where their fields are named) what the various fields mean. Pick-to: 6.7 6.6 6.5 Task-number: QTBUG-62111 Change-Id: I9926bbc11efe14c01df8fb538121acdb2ee18b1d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* V4: Fix setting of regexp flagsUlf Hermann2024-02-151-5/+5
| | | | | | | | | | | | | | | | We of course have to amend the previously set flags, not the origin. This only worked sort of because most of the flags are the same in input and output. This causes one test in the ECMAScript suite to pass and three to fail. Those three were passing for the wrong reason, relying on the confusion between the unicode and sticky flags. The failures are actually due to a defect in Yarr that will have to be addressed separately. Fixes: QTBUG-121509 Change-Id: Id930bba49e12dede2eb699e446eb528072f092b4 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Consider value types when looking for metaobjectsUlf Hermann2024-02-151-1/+1
| | | | | | | | | | | We have quite a few types with only extension metaobjects now. Move the functionality to retrieve the metaobject into QQmlType where it belongs. Pick-to: 6.7 6.6 Fixes: QTBUG-119829 Change-Id: I2b99b1a305d8726547ae0512d3c832799a4e4b04 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QtQml: Re-allow manual calling of signal handlersUlf Hermann2024-02-134-7/+42
| | | | | | | | | | | | | | | The fact that you could do this was due to a mistake in the implementation of QQmlPropertyCache. The cache entry for the signal handler looked like the signal itself. Make it possible to call QmlSignalHandler objects, and output a categorized warning when doing so. Also, align the call code between the interpreter and the JIT. Pick-to: 6.7 Fixes: QTBUG-120573 Change-Id: Ic76d37f587d21b68c55d77a08ac2d30950bec133 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Yifan Zhu <fanzhuyifan@gmail.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* RegExp: Do on demand JIT compilationFabian Kosmale2024-02-132-26/+59
| | | | | | | | | | | | | | | | | | | | | | | JIT compiling means that we need to obtain executable memory for the jitted code. That has a non-neglibile cost (in addition to the runtime cost of compiling the pattern). Thus, only compile the pattern if we suspect it to be worthwhile: - when we called match multiple times - or when the string we match against is quite large We also assume that the JIT generally works, and thus discard the bytecode immediately before jitting – if the JIT fails once (either to compile, or with offset failure), we recompile the bytecode and never JIT this pattern again. Amends commit 04820be3011395bd5cb13dea8f81c9b9bca4da8f. Change-Id: I7aed4c0fdd85f1c69bc16cb2caa384aeabd62af2 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Drop some dead codeUlf Hermann2024-02-081-3/+1
| | | | | | Change-Id: I3a426145929d6bed1ca7af3639b88632c187e86b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QtQml: Drop some dead codeUlf Hermann2024-02-081-10/+7
| | | | | | | | The meta types of inline components are always valid these days. Change-Id: I2e45b29b816ad4798876185e773e9f7be98557e8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QtQml: Double-check inline components when type-checking functionsUlf Hermann2024-02-081-6/+13
| | | | | | | | | | Inline components are created speculatively. You can end up with a QQmlType that's not backed by a compilation unit. Pick-to: 6.7 6.6 Fixes: QTBUG-120506 Change-Id: Ie12f0d503ae8d8d238346948981803c1c07e8515 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* jsruntime: silence msvc warning 4201 (nameless struct/union)Tim Blechmann2024-02-062-0/+6
| | | | | | | | | qml's private headers are pulled into binaries when using the qml compiler. we should keep the warnings out of downstream code Pick-to: 6.5 6.6 6.7 Change-Id: I330b5f76d7846b5f2e5f2a4c1ece95b58c67a876 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* SharedInternalClassData: Mark newly inserted valuesFabian Kosmale2024-02-031-0/+18
| | | | | | | | | | | | If a Heap value is inserted into a SharedInternalClassData instance which was already marked, we would potentially never mark the entry at all. Note that this is only necessary for the PropertyKey specialization, as PropertyAttributes does not contain any heap values. Change-Id: I0da098936bcc940cd24123cb58a90b2ee4234f3f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* PersistentValue: fix gc isuesFabian Kosmale2024-02-011-25/+13
| | | | | | | | | | | Heap objects shouldn't be put on the markStack, but instead be marked (so that their own black bit is set, too). Also, consistenyl call set in all copy ctors and assignement operators to ensure that marking happens there, too. The compiler should be able to optimize the superfluous null checks out in the ctors. Change-Id: I45df06d1ba569d61467455a7e4628162abd1bd9f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Clear context objects more thoroughly on destructionUlf Hermann2024-02-011-3/+1
| | | | | | | | | | | | The same object can be the context object of a hierarchy of contexts. So far we would only clear one of them, leaving dangling pointers in the others. Clear all the contexts. Pick-to: 6.7 6.6 6.5 6.2 5.15 Fixes: QTBUG-119326 Change-Id: I509f257672813866e3736b51f430f1243a8577f0 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* setInternalClass: Correctly handle deleted propertiesFabian Kosmale2024-01-301-2/+5
| | | | | | | | | | | | | | | When an IC was rebuilt, we must not set members that were deleted, otherwise we'll trigger an assertion. Since the nameMap has to match the data we still allocate memory for such members and fill it with undefined. This could be avoided with some deeper refactoring, but a simple solution is to be preferred because this needs to be picked back all the way to 6.2. Pick-to: 6.7 6.6 6.5 6.2 Fixes: QTBUG-111729 Change-Id: I730d6b4634d989191434225600a08cf0208e72f8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Revert "RegExp: Do on demand JIT compilation"Fabian Kosmale2024-01-262-52/+26
| | | | | | | | | | This reverts commit 04820be3011395bd5cb13dea8f81c9b9bca4da8f. Reason for revert: Caused QTBUG-121535 Fixes: QTBUG-121535 Change-Id: Ie65a98bc8dd07e836cf663695d9259014581bda6 Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* PersistentValueStorage: remember last free page instead of reshufflingFabian Kosmale2024-01-252-4/+27
| | | | | | | | | | | This unifies the operation when the gc is running with the normal mode, avoiding a potentially costly iteration over all pages for allocations during an ongoing gc cycle. Change-Id: I39e8990c303149e3bc458b10522cc1487e62a401 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QtQml: Use a multihash to store executable CUsUlf Hermann2024-01-255-13/+27
| | | | | | | | | | | | | | | You can produce multiple CUs for the same URL with createQmlObject() and friends. They need to be marked during garbage collection and therefore the engine needs to keep track of them. With the multihash there can be a lot of CUs of the same URL. Searching through them can take a lot of time. However, there is no point in searching for an existing executable CU if we've just freshly compiled the base CU. So, in those cases, insert directly instead. Fixes: QTBUG-121436 Change-Id: I804dbc74d2ade118f6680a7fbde3f234699ccbc3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* RegExp: Do on demand JIT compilationFabian Kosmale2024-01-232-26/+52
| | | | | | | | | | | | | | | | | | JIT compiling means that we need to obtain executable memory for the jitted code. That has a non-neglibile cost (in addition to the runtime cost of compiling the pattern). Thus, only compile the pattern if we suspect it to be worthwhile: - when we called match multiple times - or when the string we match against is quite large We also assume that the JIT generally works, and thus discard the bytecode immediately after jitting – if the JIT fails once (either to compile, or with offset failure), we recompile the bytecode and never JIT again. Change-Id: I91e9e10c5ab895af730dbb4a9bc85470dd794d1f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Move header verification into CompiledData::UnitUlf Hermann2024-01-235-82/+15
| | | | | | | | 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>
* String::append: Avoid growing list more than necessaryFabian Kosmale2024-01-221-8/+23
| | | | | | | | | | | | To visit all nodes, we should need at most depth of the rope many entries. So far, we might however have added more nodes, as we immediately pushed both the left and the right child. By storing a marker together with the node, we can avoid populating the list with both the left and right subtree at the same time. Change-Id: Ife095c439bb20a7cf5546c31918d19869263ece1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QtQml: Remove some dead codeUlf Hermann2024-01-221-77/+1
| | | | | Change-Id: Ic3755748b849852c366a8681e858d60b02968273 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Use CompiledData::CompilationUnit in more placesUlf Hermann2024-01-205-171/+44
| | | | | | | | | | 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 the property cache creator interface into the base CUUlf Hermann2024-01-181-36/+10
| | | | | Change-Id: I521b00754593dee600465047b3fe9a57d614bc77 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move dependentScripts into base CUUlf Hermann2024-01-182-3/+10
| | | | | Change-Id: Ia332a691a4a5f04fcca50eb1c3e2018f8368dbe6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move type name cache into base CUUlf Hermann2024-01-183-11/+19
| | | | | Change-Id: Ie3504f16b34859cdef72f8138e6058dcc2d1f58f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move getters for flags into base CUUlf Hermann2024-01-181-36/+9
| | | | | Change-Id: I6bf0bd06e489d07517a9fba6f675c402e9beddbb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>