aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
Commit message (Collapse)AuthorAgeFilesLines
...
* Use QDateTime to get offsets for emscripten (wasm)Edward Welbourne2021-08-101-0/+38
| | | | | | | | | | | | | | | | | | | | | Since our wasm implementation doesn't have access to time-zone data by default, but its QDateTime implementation does manage to get offsets right for local time, use it as fall-back for V4's Date implementation's DaylightSavingTA() and getLocalTZA(). This implementation might also be viable for other cases without timezone support (and a way to reset it when the system zone has changed), but we'll need to experiment to find out. For now, since we have nothing better for wasm, use it there. In passing, update a comment about a bug report against the ECMA spec to say it's been fixed (and we're compatible with the result). Fixes: QTBUG-95314 Pick-to: 6.2 5.15 Change-Id: I40c1537815ada950dc0b5cebd4d641f7bfc45bd9 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Skip superfluous property capture attemptFabian Kosmale2021-08-091-1/+2
| | | | | | | | | | If a QQmlProperyBinding tries to capture a QProperty, there is nothing to do as the dependency tracking happens in C++ anyway. Thus we can avoid calling captureProperty. Pick-to: 6.2 Change-Id: I96b2876d4b2ba10b00af8342be9beae660a95ef3 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QV4::Heap::GeneratorObject: remove unused memberFabian Kosmale2021-08-021-1/+0
| | | | | | | | | | | | | The member was marked as a Pointer for the gc; however it was never used, and thus also left uninitialized. This could cause memory corruption or asserts during the gc's mark phase. Fixes: QTBUG-95417 Pick-to: 6.2 6.1 5.15 Change-Id: Ide826c0284b6060de8689e6f0dc753011108dba9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* JS: Ensure that array keeps valid after length changes and fix concatFabian Kosmale2021-07-272-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | This is a partial revert of 6fa617524a6d0a2bc988e2dc70e8d719d1b9c282. The reasoning there was wrong: Due to the ring structure of the array, there might be further (non-undefined) elements at the start of the allocated memory. Those need to be copied to. This patch therefore reverts the change in 6fa617524a6d0a2bc988e2dc70e8d719d1b9c282 which simply set the size, and restores the copying behavior again. The actual fix for the crash in QTBUG-81037 requires a change to how we set the array length: Previously, when the size increased, we only reinitialized the array (as a sparse array) when the new size was greater than a certain threshold. If the new size was smaller than that threshold (but larger than the current alloc value), we would end up with an inconsistent array: It was non-sparse, but had a smaller capacity than size, leading to the memory corruption in concat when the elements that should exist (but did not) were accessed. This patch ensures that we now always resize the alloc buffer if necessary. Task-number: QTBUG-81037 Fixes: QTBUG-90456 Change-Id: Ie193aa3d714121ce6e8203c4b663b9015715e025 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Use ExecutionEngine::currentContext() where applicableUlf Hermann2021-06-301-2/+2
| | | | | Change-Id: I7e83819d4551ffc9125e5bf376ae6bc620a11d2b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use QV4::Scope::hasException() where applicableUlf Hermann2021-06-3017-88/+87
| | | | | | | It is shorter and encapsulates the exception handling a bit. Change-Id: I8e2dc0eb3b930e222b8cb4852b73d99ca18a0379 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Replace "fall through" comments with Q_FALLTHROUGHThiago Macieira2021-06-221-1/+1
| | | | | | | | Noted by GCC 11. Looks like it doesn't see the "fall through" comment (only "fallthrough"). Change-Id: I7246c3e7bb894e0d9521fffd168af15da21a2c93 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QV4Engine: Do not use currentContext() when calling JavaScript from C++Andrei Golubev2021-06-211-1/+5
| | | | | | | | | | | | | | | | | | | | | This turns out to be not quite valid since context hierarchy is afffected. It was fine before since all the generated classes either had the same context or a dead-simple hierarchy + the tests for comprehensive usage were lacking. The problems arise when contexts are meant to be different for unrelated JS calls e.g. in property bindings with non-trivial cross-context dependencies (e.g. derived property uses both neighbor property and base class property in a binding) As a drive by, simplify QQmlEnginePrivate::executeRuntimeFunction(): * Expect function index to always be valid (in range), it's a very bad otherwise anyway * Use QQmlData::outerContext directly as a context argument for callInContext(). This is what was done anyhow, just through a QQmlContext -> QQmlContextData conversion, which is actually needless Change-Id: I8ac6b181363a5d03e468c2b6f35db2dac188ea8b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix conversion of entries to be added to QVariantListsUlf Hermann2021-06-171-4/+6
| | | | | | | | | We should pass the variants themselves, not their constData(). Fixes: QTBUG-94502 Pick-to: 6.1 6.2 Change-Id: I92688348d7b46d74935dc11080b26290f5e8be86 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Allow AOT functions to signal an undefined result via the contextUlf Hermann2021-06-153-2/+9
| | | | | | | | | | | | undefined as value returned from bindings has the special meaning of resetting the binding. As AOT-compiled functions return the actual type of the binding rather than a QV4::Value, we cannot always encode undefined. Therefore, add a flag that tells us whether the result was supposed to be undefined. Pick-to: 6.2 Change-Id: Iac2298869dde80f6d889240dd8200b2ad83e5dc5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Eliminate JS call frame from metatypes callsUlf Hermann2021-06-1014-150/+277
| | | | | | | | If we call an AOT-compiled function we never need the JavaScript call frame. We can just skip its setup and save some overhead. Change-Id: I39dc2ca6eea5b5a66f3b87b642a310534cecf6cd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qv4function: Fix crash due to reference being invalidatedMaximilian Goldstein2021-06-091-1/+1
| | | | | | | | | | | Function::updateInternalClass creates a reference to a QStringList that is appended to before being used. This is unsafe and can leads to a segfault if the append() causes a reallocation. Fixes: QTBUG-94360 Pick-to: 5.15 6.1 6.2 Change-Id: Iac49e8d816cf440ca2b70e133c88314eb8df6b91 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Pass QMetaType by value rather than by ID in more placesUlf Hermann2021-06-095-48/+57
| | | | | | | | | | This saves us some ping-pong between the IDs and the QMetaTypes, and avoids possible ambiguities if multiple metatypes are registered for the same C++ type. Change-Id: I81cec94a9cd05d69927dc884f65574f0ab2ddc22 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Rename QQmlMetaType::metaObjectForMetaType into metaObjectForValueTypeUlf Hermann2021-06-082-4/+4
| | | | | | | | It really only works for value types and it's not intended to do anythign else. The name should reflect this. Change-Id: Ib73bf7e9655971f7826fe72145e2d2fab363363c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Do QMetaType-style call in QQmlPropertyBinding::evaluateUlf Hermann2021-06-023-12/+11
| | | | | | | | | | | | | | | | We already have a void* and metatype available. There is no need to convert, unless we have bound arguments. The call() itself will convert as necessary anyway. However, we do need to figure out whether the returned value was undefined. Pass this information up from the actual call. This reverts commit 8ac705247430ff6fbbc25a9db20c0e7dc572abe7. The original commit 3a4e013f0058952c94ed3414aafbf96216efff8d was correct. We were just missing the value type conversions in metaTypeFromJS(). Change-Id: Ic4b2ebf1eb3fb2e5a50a045be774dd02d0fed7c6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Allow value type conversion in metaTypeFromJSUlf Hermann2021-06-021-3/+7
| | | | | | | We implicitly do the same when calling toVariant(). Change-Id: I288326125d88bc658dcaf12d3ee623e0e529bb69 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QV4StackFrame: Fix ubsan warningFabian Kosmale2021-05-281-1/+3
| | | | | | | | | | Calling memcpy with a nullptr is UB, even if we copy 0 bytes. Add a null check to avoid the issue. Pick-to: 6.1 Fixes: QTBUG-94067 Change-Id: I1d47424754e22f13d7b494ae984b4407b96b1805 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Clarify ambiguous Object to be one under V4Janne Koskinen2021-05-281-1/+1
| | | | | | | Fixes Integrity "ambiguous" compiler error Change-Id: Iea96eba25df83d97ea29b205fcb779f6efbe3d7f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix type to be correct in calling Q_ALLOCA_DECLAREJanne Koskinen2021-05-271-1/+1
| | | | | | | | | Fixes compilation issue with Qt_AllocaWrapper version of the macro that tries to use name part as part of variable name. Change-Id: I388ed01caf85e268c758c0ba2474c88fc8da5530 Reviewed-by: Kimmo Ollila <kimmo.ollila@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Evaluate type assertions in QMLUlf Hermann2021-05-263-0/+24
| | | | | | | | | | | | | | | | | | Type assertions actually check whether the expression matches the type, and return null if it doesn't. [ChangeLog][QtQml] You can use TypeScript-like type assertions using "as" now. In contrast to TypeScript, QML's type assertions are enforced at runtime. If the type doesn't match, null is returned for object types. Also, type assertions can only cast to object types. There is no way to create a value type or primitive type reference. As value types and primitives cannot be polymorphic, this doesn't matter, though. There are other ways of converting those. Task-number: QTBUG-93662 Change-Id: I00fce3d4ea7a8c6b4631c580eaf6c113ac485813 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Revert "Do QMetaType-style call in QQmlPropertyBinding::evaluate"Ivan Solovev2021-05-253-11/+12
| | | | | | | | | | This reverts commit 3a4e013f0058952c94ed3414aafbf96216efff8d. The patch seems to break the tests in QtPositioning (see QTBUG-93983 for some more details) Task-number: QTBUG-93983 Change-Id: Ie2caa8418f06add1c24d9f3d3d137e51e94908c2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Do QMetaType-style call in QQmlPropertyBinding::evaluateUlf Hermann2021-05-203-12/+11
| | | | | | | | | | | | | | We already have a void* and metatype available. There is no need to convert, unless we have bound arguments. The call() itself will convert as necessary anyway. However, we do need to figure out whether the returned value was undefined. Pass this information up from the actual call. Change-Id: Icfa69e946adf80d18110a158f5bab906674b7381 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Use QHash instead of QMap for resolved typesFabian Kosmale2021-05-202-4/+14
| | | | | | | | | | | | | | | | This vastly speeds up resolved type reference lookups in QQmlObjectCreator::createInstance, which translates to significant improvements in qmlbench: perf record -b ./src/qmlbench --shell frame-count delegates_qobject.qml went from roughly 730 frames to > 800 locally. To have a stable order in the hash, we simply sort a tempory vector of keys. As this happens only once, the overhead is negligible and partially offset by the better memory locality of the QHash anyway. Task-number: QTBUG-88672 Change-Id: Ib547a87fd0d2d81f366ea927ade232f33b3d3788 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Rename a parameter to avoid shadowing a memberEdward Welbourne2021-05-181-3/+3
| | | | | Change-Id: I189e6fd49e5c5dec8240d2b36043240d1c059f81 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Make QDate handling consistent in its use of UTCEdward Welbourne2021-05-181-4/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to the quirk of ECMAScript's Date.parse() spec [0] stipulating the use of UTC for date-only strings, in contrast to most other ways of creating a Date using local time, reasonable users get surprised by the behavior of QDate properties initialized from strings. This can't be avoided without breaking other uses of Date, so document the work-around needed to cope with it (use UTC-specific methods to access the Date object). [0] https://tc39.es/ecma262/#sec-date.parse Make conversions back to QDate from Date work round the possibility that the Date, seen as a QDateTime(,, LocalTime), needs to be handled as UTC when extracting the date, and catch two more places that conversion from QDate neglected to use UTC's start of day, for consistency. Revised tests to call UTC-specific methods instead of the local-time ones, where appropriate. Drive-by: some tests were (entirely bogusly) constructing a fresh Date using the UTC-fields of the Date they had, in order to then test the non-UTC fields of this fresh Date; instead, simply test that the UTC fields are as expected. [ChangeLog][QML][Behavior change] Where a QDate is represented in QML's JavaScript as a Date, it is now more consistently associated with the start of the UTC day it describes. Previously cases where it was represented as the start of local time's day could lead to a Date turning into a QDate for the preceding day. Inconsistencies in the specified behavior of Date preclude eliminating such problems entirely, but they should now be limited to cases where (perversely for a date property or parameter) the date is specified with a local time late enough to make it coincide with the start of the next UTC day (in which case that next day's QDate will be its C++ representation). Fixes: QTBUG-92466 Change-Id: I2306dd9ecef0d5c2d59b562762392e51bb6d66ca Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlEngine::executeRuntimeFunction: pass return value as input argumentAndrei Golubev2021-05-112-16/+15
| | | | | | | | | Use the newer version of QV4::Function::call() that does not require manual JSCallData setup and is more optimal for AOT function calls Change-Id: I5a5e2d0477c0603b05b7213f1b2adcc34d156bf5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* V4: Do not write back value type references on const method callsUlf Hermann2021-05-101-33/+47
| | | | | | | | | | | The property setters can have side effects. We should only call them if really necessary. We don't have to write back after calling const methods. Fixes: QTBUG-93480 Change-Id: I53a246edd37b7f0c31f0e0effe5dfa996548f74c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* qv4engine: Fix enums getting turned into objects when passed in listsMaximilian Goldstein2021-05-061-0/+4
| | | | | | | | | | | | | Previously passing a QList of a registered enum would result in an array of objects instead of the array of numbers which usually represent enum values in QML. You now get an array of numbers as you would expect. [ChangeLog][QtQml][Important Behavior Changes] QJSEngine::toScriptValue() used to return a QVariant containing an enum, now it returns the enum directly. If you still wish to use valueOf() on the resulting value use QJSEngine::toManagedValue() instead. [ChangeLog][QtQml][Important Behavior Changes] A QList containing enums will now result in an array of numbers instead of an array of objects. Fixes: QTBUG-85861 Change-Id: I5c28f4489dfd02d8256aa818e27b1dd6b7d3113d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Workaround mingw compiler bugUlf Hermann2021-05-061-0/+5
| | | | | | | | | | | | std::acosh(v) wrongly returns NaN for v == Inf on mingw. This makes the ecmascript tests fail. Fixes: QTBUG-93175 Pick-to: 6.0 6.1 Change-Id: Ic6677b3259dad591b946b23d4d6a6859f6e70b0f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* V4: Write back value type references after function callsUlf Hermann2021-05-051-1/+10
| | | | | | | | | | | | If we call a function on a value type reference we have to assume that the value has changed. Therefore, we need to write back, just like we do when writing a property on the reference. Fixes: QTBUG-91783 Pick-to: 6.1 5.15 Change-Id: I6d2e957997d64e40e42eb5210350b6592a92ee26 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use custom lookup for QJSValue singletonFabian Kosmale2021-05-052-3/+13
| | | | | | | | There is no reason to branch in the getter, the type of the singleton cannot change as long as the lookup exists. Change-Id: I32534c505191d2da797cc94f536aa59e9b96e8ba Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add QJSEngine::registerModuleAlex Shaw2021-05-013-10/+87
| | | | | | | | | | | | | | | | | | | | | | | | Some applications that use JavaScript as a scripting language may want to extend JS through C++ code. The current way to do that is with global objects. ES6 provides a better way of encapsulating code: modules. registerModule() allows an application to provide a QJSValue as a named module. Developers familiar with Node.js will find this very easy to use. Example: ```c++ QJSValue num(666); myEngine.registerModule("themarkofthebeast", num); ``` ```js import badnews from "themarkofthebeast"; ``` [ChangeLog][QtQml][QJSEngine] Adds the ability to register QJSValues in C++ as modules for importing in MJS files. Change-Id: I0c98dcb746aa2aa15aa2ab3082129d106413a23b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove caching of recursive AOT context lookupsUlf Hermann2021-04-303-2/+9
| | | | | | | | | Such lookups are usually caused by repeaters or similar constructs where many objects look up something in their parent context. As all those objects have different contexts, we would constantly invalidate the cache. Change-Id: I06c7d337d859e5e6a81f6e9a8693b155b2af7498 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Redesign the AOT lookupsUlf Hermann2021-04-304-2/+18
| | | | | | | | | | | | | | | Each kind of lookup should come with a function that tries to execute the lookup, taking a minimal number of parameters, and another one that initializes the lookup, taking whatever is needed for that. No initialization should be done in the execution step and vice versa. Rather, the execution step should be repeated if an initialization had to be done first. This way, the happy path can be very fast if the lookups have been initialized before. Change-Id: Ic435b3dd4906d00144138cb05161a99a0a9c64ed Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix compiler warnings from char*/QString conversionVolker Hilsheimer2021-04-281-1/+2
| | | | | Change-Id: I904c123f73a6c398d45215a976652a0712ce40fa Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Support native transformation between UrlObject and QVariant/QUrlUlf Hermann2021-04-224-16/+48
| | | | | | | | | | | | | | URL has become a builtin type. We should support it on the same level as QString/String and QDateTime/Date. In order to continue support for comparing URL properties with the JavaScript equality operators, we still pass URLs as variants when using them in JavaScript. However, we now create proper URL objects for QJSValue and QJSManagedValue, and we allow transforming the URL-carrying variant objects back into QUrls. Change-Id: I78cb2d7d51ac720877217d2d4b4d0ab17cdd2a4b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Optimize the case of AOT functions returning QObject*Ulf Hermann2021-04-191-6/+17
| | | | | | | | | | We don't need to go through all the metatype construction, conversion, and destruction if we know that both the expected and the actual return types are QObject pointers. We can just check if they're compatible and assign if they are. Change-Id: Ic5ab13536cf2e0e2a982ed9a9be81eb5927e85c2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Don't pre-resolve the QQmlContext for AOT functionsUlf Hermann2021-04-191-1/+1
| | | | | | | | We only ever need it to retrieve the QQmlEngine. However, resolving the context can involve an allocation. Change-Id: I064fd528fa7ab9bd37043c5dd1c62d17ea9380e3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix build without features.qml-sequence-objectTasuku Suzuki2021-04-191-0/+2
| | | | | Change-Id: I2da9712201f3057b4d20aa0176716442d69d0ab9 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Rework qmljsrootgenUlf Hermann2021-04-161-3/+3
| | | | | | | | | This way it actually generates interesting data about the JavaScript types, for example the functions of the String prototype. Add a helper method to create a symbol to QJSEngine. This should be generally useful. Change-Id: I6c7b253b9d6cdb61602ceeae0955aed8d942c139 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Streamline retrieval of context property names and IDsUlf Hermann2021-04-154-13/+8
| | | | | | | | Most of this can be inline, and we never need to copy the actual identifier hash. Change-Id: I6468b6b1a571e4854c00c865a2aa57c3b2f0ca8c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Check thisObject when calling various methods on URLUlf Hermann2021-04-141-38/+122
| | | | | | | | | We should not crash when you try to call them on the wrong object. Rather, throw a type error. Pick-to: 6.1.0 6.1 Change-Id: I1b146d9c77d838e013408988e02a65a623641f1f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Implement optional chainingMaximilian Goldstein2021-04-131-0/+27
| | | | | | | | | | | | | | | | | This change implements optional chaining (https://github.com/tc39/proposal-optional-chaining) by adding a new type of optional lookup with an offset to the end of a chain. If `undefined` or `null` is encountered during an access marked as optional, we jump to that end offset. Features: - Full support for all kinds of optional chain - With some codegen overhead but zero overhead during normal non-optional FieldMemberExpression resolution - Properly retains this contexts and does not need to resolve anything twice (this has been an issue previously) - No extra AST structures, just flags for existing ones [ChangeLog][QtQml] Added support for optional chaining (https://github.com/tc39/proposal-optional-chaining) Fixes: QTBUG-77926 Change-Id: I9a41cdc4ca272066c79c72b9b22206498a546843 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QV4::EngineBase: Remove pragma packFabian Kosmale2021-04-131-7/+0
| | | | | | | | | | | This was only used on a subset of our compilers, and caused issues with pointer alignment. We have static_assert's in place to verify that the struct members are in the correct place, and pack had no effect anyway after we added the alignment padding to the struct. Change-Id: I162664ec01d4b5d97ac800afc354d0ab2e04de42 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QV4EngineBase: Do not create zero-sized array on 32 bit platformsFabian Kosmale2021-04-121-1/+3
| | | | | | | | | | | Zero-sized arrays are a non-standard extension, and do not work on MSVC. We can instead conditionally add an explicit padding member on platforms where POINTER_SIZE == 8. Fixes: QTBUG-92562 Pick-to: 6.1 6.1.0 Change-Id: I8462eb05e16c42045c0c95f026321c6e20e5c6bb Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* QV4QObjectWrapper: Store the whole signalFabian Kosmale2021-04-011-6/+7
| | | | | | | | | | | | | | | | | | | | | 90be89d771425044a84e9e79e4e668e065acc825 changed the connection logic to actually pass the receiver to connect in order to fix disconnect cleanup. However, we omitted to change QObjectSlotDispatcher::impl accordingly. The previous logic was: - store the index of the signal in signalIndex - In impl, in the call case, we would get passed the emitting object (sic!) as the receiver parameter. Then we would use the object and the signal index to obtain the QMetaMethod. - From the QMetaMethod, we could get the signal's number of parameters. After the aforementioned change, that does not work anymore: The receiver is now the actual receiver of the signal, thus we get the wrong method, and potentially the wrong number of parameters. To fix this, we now store the complete QMetaMethod of the signal. Pick-to: 6.1 Change-Id: I868c51edf24a61d14eaf958ed7942da27f54a5c3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Simplify populateJSCallArguments a bitUlf Hermann2021-04-011-4/+2
| | | | | Change-Id: I7e2f09c3ddf4a855c87c36a16b9f48af3dadf978 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qv4qobjectwrapper_p.h: Work around MinGW bugFabian Kosmale2021-03-301-0/+2
| | | | | | | | | | mingw 8.1 does not handle the access to privates in a SFINAE context correctly. Publically expose MultiplyWrappedQObjectMap::value_type to work around this issue. Change-Id: I9cddeaca8ebaaa77a786fac2c4e210dd3b852d4d Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Avoid needless construction and destruction of return valuesUlf Hermann2021-03-292-13/+11
| | | | | | | | | | In most cases the AOT compiled function will successfully placement-new the return value. Therefore, we can provide uninitialized space. Only do the construct/destruct dance in the cases when it's already slow. Change-Id: Ia339774fde03e459f290f167ddadd1c47a644b8e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QV4::Engine::toVariant: Use metatype instead of metatype idFabian Kosmale2021-03-255-27/+26
| | | | | | | | | | This way, we can avoid the costly id to metatype lookup in case where we actually need the full metatype. Task-number: QTBUG-88766 Change-Id: Ibe29b323007f00d2f8d1807fb9b64f9a8f87e807 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>