aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4value_p.h
Commit message (Collapse)AuthorAgeFilesLines
* QtQml: Avoid potential gc issuesFabian Kosmale2024-12-181-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implicitly constructing a value from a ReturnedValue muddies the responsibility for ensuring that the gc can find the object. With this change, we disable the implicit conversion. The expectation for lifetime management is now: - If a ReturnedValue is stored on the C++ stack, it must be put into a QV4::Scoped class (or there should be a comment why not doing so is safe). Passing a ReturnedValue to a function should no longer be possible, unless the function takes a ReturnedValue, in which case the expectation is that it stores the value in a place where it can be seen by the gc, before doing anything that could trigger a gc run. Using Value::fromReturnedValue can still be used to pass a Value on, but in that case, the expectation is that there is a comment which explains why this is safe. - If a QV4::Value is obtained from a function call, it ought to be stored in a ScopedValue, too. We currently can't enforce this easily, so this should be checked during code review. A possible way forward would be to disallow returning Values, but that would be a larger change, and is deferred to the future. - If a functions has a QV4::Value parameter, it's the callers' responsibilty to ensure that the gc can find it. Pick-to: 6.9 6.8 6.5 Fixes: QTBUG-131961 Change-Id: Iea055589d35a5f1ac36fe376d4389eb81de87961 Reviewed-by: Ulf Hermann <[email protected]>
* QV4::Value: introduce undefined helper methodFabian Kosmale2024-12-181-0/+5
| | | | | | | | | | | | A value storing a primitive like undefined is completely safe. Having a helper method to create it eases porting (usafe) code which directly accepted QV4::ReturnedValue as a parameter to a variant taking a QV4::Value. Pick-to: 6.9 6.8 6.5 Task-number: QTBUG-131961 Change-Id: Ib1c27d45706faa570edc175245e9f34b4ceabcc8 Reviewed-by: Ulf Hermann <[email protected]>
* HeapValue: Introduce set overload taking ReturnedValueFabian Kosmale2024-12-181-0/+3
| | | | | | | | | | | | In general, methods should not take a ReturnedValue. However, set leads directly to a write through the WriteBarrier, so it's safe. Adding the overload now helps to prepare for next commit which removes the implicit conversion from ReturnedVaule to Value. Pick-to: 6.9 6.8 6.5 Task-number: QTBUG-131961 Change-Id: I3fe2fbfbc1893190840bc8e48637eec3ae43ce46 Reviewed-by: Ulf Hermann <[email protected]>
* V4: Move FunctionObject flags into VTableUlf Hermann2024-05-141-1/+4
| | | | | | | | | | | | | | | | | | | These are really rather generic type traits that shouldn't be stored in individual objects. Moving them away slims down FunctionObject even more. FunctionObject doesn't add any extra overhead on top of Object anymore. You also cannot easily cast an object that doesn't implement any call methods to FunctionObject anymore. Therefore, we can derive from FunctionObject even if we only need to implement call methods in a further derived class. The fact that ProxyObject is not a FunctionObject but its derivatives are is already tested as part of the ecmascript test suite. Task-number: QTBUG-124662 Change-Id: I5632de8c54ac1d6a4b15c4926c655b87b475db49 Reviewed-by: Fabian Kosmale <[email protected]>
* Remove the use of Q_QML_PRIVATE_EXPORTAlexey Edelev2024-01-111-1/+1
| | | | | | Task-number: QTBUG-117983 Change-Id: I5790f01d614cd70c7fcc9bd817ec6ace3f3e3730 Reviewed-by: Ulf Hermann <[email protected]>
* V4: Remove some dead codeUlf Hermann2023-08-311-13/+0
| | | | | | Change-Id: I7aac01c2176db377efd7ab0a255b82ea7c36b9b4 Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
* Change value encoding scheme to make space for larger pointersUlf Hermann2023-01-121-48/+0
| | | | | | | | | | | | | | | | | | On android and on some other platforms, the upper bits of a pointer are significant. We need to store them in our JS value encoding. Shift the bits around to make this happen. We now can store pointers of up to 57 bits. That's enough for everything we've seen so far. Fixes: QTBUG-101686 Fixes: QTBUG-91150 Pick-to: 6.5 Change-Id: I72e0fe63b27fca94840f82963e4d3936b3581b28 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Sami Shalayel <[email protected]> Reviewed-by: Ville Voutilainen <[email protected]>
* 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 <[email protected]>
* Upgrade std::is_trivial::value to C++17 std::is_trivial_vIvan Tkachenko2021-08-241-1/+1
| | | | | | | | | Since Qt 6 requires at least C++17, we can finally make use of some of its goodness. Change-Id: I56a318bc0b1b60d1e2b0186f335f8feda7622df4 Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Andrei Golubev <[email protected]>
* Add a QJSManagedValueUlf Hermann2020-12-181-0/+3
| | | | | | | | | | | | | A QJSManagedValue is a view on a QJSValue which always knows the engine the value belongs to. This allows us to implement the JavaScript semantics of the various QJSValue methods in a much more rigorous way. [ChangeLog][QtQml] The new QJSManagedValue should be used instead of QJSValue for manipulating properties and prototypes of JavaScript values, as well as for calling JavaScript functions. Change-Id: I9d445ffcf68dfa72dba9bae0818e83c80665ad66 Reviewed-by: Fabian Kosmale <[email protected]>
* Allow JavaScript primitive type transformations inline in C++Ulf Hermann2020-12-181-2/+2
| | | | | | | | | | We don't want to call into the engine just for adding two numbers. This implements the most common operators on primitive JavaScript values. More are to follow in the future. Change-Id: Id51a5af59a3af9fec78a2d8f293e59e6567e9204 Reviewed-by: Fabian Kosmale <[email protected]>
* Replace old Q_DECL statements with modern C++Allan Sandfeld Jensen2020-10-311-2/+2
| | | | | | | Since we depend on C++17 now, all of these can go. Change-Id: I0484fd4bb99e4367ec211c29146c316453729959 Reviewed-by: Volker Hilsheimer <[email protected]>
* V4: Fix mark stack overrunsUlf Hermann2020-02-271-23/+2
| | | | | | | | | | | | | | Instead of applying a heuristic on when to call drain() in unrelated code, we check the stack limit on each push(). If the soft limit is reached we try to drain. As drain() itself can push again, we try to limit the stack size by allowing at most 65 recursions of drain(). If none of that helps, we crash with a meaningful error message. This allows us to remove all the hacky drain() calls in other parts of the code. Change-Id: Ib979339470da0e85981de8131e7997755b757c71 Reviewed-by: Simon Hausmann <[email protected]>
* QV4MM: Fix crash caused by MarkStack overflowFabian Kosmale2020-01-071-0/+2
| | | | | | | | | | | | | | MemoryManager::collectFromJSStack did push to the mark stack without checking if there is actually still space available. To fix this, we now drain the stack once we hit the limit. The test case is a slightly modified version compared to the reported one, removing one loop. This was required as our regular expression does not throw an exception when there are too many capture groups. However, to trigger the bug, looping was not actually necessary. Change-Id: I4d00865f25a989c380f4f5b221f4068c80b71d2b Reviewed-by: Ulf Hermann <[email protected]>
* Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-06-111-0/+17
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4value_p.h src/qml/qml/qqmlmetatype.cpp src/qml/qml/qqmltypewrapper.cpp src/quick/items/qquicktableview.cpp Change-Id: I684f8e01a711580512848bf1253f39b39fcbf4c7
| * Add a workaround for ia64 to move Value bits 63-61 to 49-47 for pointersJason Duerstock2019-05-301-0/+17
| | | | | | | | | | | | Task-number: QTBUG-56264 Change-Id: Ifdede70d95f5846e160772c43d22bc2a4123959b Reviewed-by: Thiago Macieira <[email protected]>
* | Split QV4::Value into a static and a dynamic partUlf Hermann2019-05-311-455/+127
| | | | | | | | | | | | | | | | The static part can be used for compilation and won't resolve managed objects. This allows us to remove all the remaining V4_BOOTSTRAP. Change-Id: Id2f6feb64c48beb2a407697881aea8c0d791a532 Reviewed-by: Simon Hausmann <[email protected]>
* | Merge remote-tracking branch 'origin/5.13' into HEADUlf Hermann2019-03-221-0/+16
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4compileddata_p.h src/qml/jit/qv4baselinejit.cpp src/qml/jit/qv4jithelpers.cpp src/qml/jsruntime/qv4lookup.cpp src/qml/jsruntime/qv4runtime.cpp src/qml/jsruntime/qv4runtimeapi_p.h src/qml/jsruntime/qv4vme_moth.cpp src/qml/qml/qqmltypemodule_p.h Change-Id: If28793e9e08418457a11fc2c5832f03cab2fcc76
| * Enable lookups in QMLSimon Hausmann2019-03-191-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main feature that needs to be implemented in order to enable lookups in QML files is to respect that the QObject wrapper has its own storage layer (meta-object properties). Lookups need to be able to index those when the base is a QObject. This is done by caching the property data and guarding the validity by comparing property cache pointers. The same lookup logic is also implemented for value type wrappers. OVerall there's more that can be done with lookups in meta-objects, for constant properties for example. For "global" lookups we have a safeguard in place that generates a LoadName instruction for property access that should end up in the qml context wrapper. So no changes are needed here at first, but the lookup in the QML context can be optimized in the future. The way of storing the property cache in the lookup itself trades ugliness on destruction against the creation of less internal classes. Another option would be to store the property cache in the internal class and let QObjectWrapper always transition via the property cache. Task-number: QTBUG-69898 Change-Id: I9c378c071acc6d7d4a34a2a76616f9594119d515 Reviewed-by: Ulf Hermann <[email protected]>
* | Tweak managed/undefined checks in QV4::Value for 32bit systemsErik Verbruggen2019-02-211-2/+16
|/ | | | | | | | | On 32 bit systems, the pointers can only be 32 bit. So instead of shifting bits 32-49 away in the upper part of the 64 bit value, we can just check if the tag (the upper 32 bits) is 0. Change-Id: I25e6542676e8aa2c566f10c70c532dd8bf5c7192 Reviewed-by: Ulf Hermann <[email protected]>
* Fix signed/unsigned warning in VS 2017Jason Erb2018-11-191-1/+1
| | | | | | | Task-number: QTBUG-71862 Change-Id: I836756d004753420bfb7a00013ade0229bd5946e Reviewed-by: Friedemann Kleint <[email protected]> Reviewed-by: Lars Knoll <[email protected]>
* Cleanups in Value/PrimitiveLars Knoll2018-09-171-92/+55
| | | | | | | | | | | | Get rid of Primitive and move the corresponding methods directly into Value. Mark many methods in Value as constexpr and turn Value into a POD type again. Keep Primitive as a pure alias to Value for source compatibility of other modules that might be using it. Change-Id: Icb47458947dd3482c8852e95782123ea4346f5ec Reviewed-by: Simon Hausmann <[email protected]>
* Micro optimization when initializing the Cpp frameLars Knoll2018-09-111-2/+2
| | | | | Change-Id: I07db2df7eec2bdbeb84bd576d9e4f7912f79fc78 Reviewed-by: Erik Verbruggen <[email protected]>
* Fix some remaining issues with detaching of array buffersLars Knoll2018-08-231-0/+10
| | | | | | | | | | Make sure we check for detached buffers after all other calls that could execute code have happened. To do that convert the values to numbers before calling the write() methods of the specific typed array. Change-Id: I091e41400f740dfc1d0826657e285443c9336c40 Reviewed-by: Simon Hausmann <[email protected]>
* JS: Encode result of Math.min and Math.max as int when possibleErik Verbruggen2018-07-131-4/+7
| | | | | | | | | | So now Math.max(array1.length, array2.length) won't return a double anymore. This improves the score in the crypto benchmark by ~10% Change-Id: I8453a671d28d7f2a39ba74b18b3155f031d9b12f Reviewed-by: Simon Hausmann <[email protected]>
* Get rid of Value::asArrayIndex()Lars Knoll2018-07-021-32/+0
| | | | | | | | | | | It was only used in a few places now, that can be replaced by either using a PropertyKey, or by limiting the fast path optimization in the runtime to array indices smaller than INT_MAX. Since there are less branches this should even be faster for pretty much all use cases. Change-Id: Ib4f2f2f3e27f14ad180b810546e82ac83170b106 Reviewed-by: Simon Hausmann <[email protected]>
* Introduce a PropertyKey class that inherits from ValueLars Knoll2018-07-021-1/+1
| | | | | | | | | | | This will replace Identifier over the next few commits. The advantage of PropertyKey is that it can be stored on the JS stack, so that a GC run won't accidentally clean up the string/symbol referenced by the key. Change-Id: Ib4daa4616bcfa537e6d371ef7c7740bc7727a50d Reviewed-by: Simon Hausmann <[email protected]>
* Fix creation of object literalsLars Knoll2018-06-041-1/+0
| | | | | | | | | | | | | | | | Our method to create object literals wasn't compliant with the ES7 spec, as we would in some cases re-order the properties. This violated the spec which required properties to be created in order, so that for-of would also iterate over them in creation order. As a nice side effect, this simplifies the code and gets a couple of test cases using computed property names to pass. Task-number: QTBUG-62512 Change-Id: I6dfe004357c5d46a0890027f4fd9e2d1e1a2a17a Reviewed-by: Simon Hausmann <[email protected]>
* Implement ToPropertyKey() from the ES7 specLars Knoll2018-06-041-5/+2
| | | | | | | and use it where required. Change-Id: I309ca61e0360b26428fc2ea5a2eea47c8e0632a0 Reviewed-by: Simon Hausmann <[email protected]>
* qv4arrayobject: Implement Array.prototype.includes from ES7Robin Burchell2018-05-251-1/+2
| | | | | | | | | | | | | | We also add a sameValueZero helper, to make life easier. Remaining failures: built-ins/Array/prototype/includes/get-prop.js fails (due to missing Proxy) built-ins/Array/prototype/includes/length-boundaries.js fails length-boundaries failure is due to strange treatment of edge number values in Value, I think, I haven't yet been able to rectify that one. Change-Id: Idacca528d88fb052d19a5d244662927f502f20d2 Reviewed-by: Lars Knoll <[email protected]>
* Don't use empty values anymore to store internal freelistsLars Knoll2018-05-241-26/+2
| | | | | | | | | | | | Simply encode them as integers. That works just as well, and allows removing the indexed empty values. This is helpful, to swap the internal representations of undefined and empty values, which in turn will simplify an implementation of correct handling of uninitialized variables (through let/const). Change-Id: I299f975d665309611d1b561f6a0c86b5ca15782a Reviewed-by: Simon Hausmann <[email protected]>
* Fix another ubsan warningLars Knoll2018-05-041-1/+1
| | | | | | | Don't call asReturnedValue() on something that might be null. Change-Id: I31ab7df7e353dee0718957ec0d5b4edcc72f7a56 Reviewed-by: Erik Verbruggen <[email protected]>
* Optimize conversions to array indicesLars Knoll2018-05-031-19/+21
| | | | | Change-Id: Ic83314fc2a5bb80f88c1616e7d3179fe6573a0e9 Reviewed-by: Simon Hausmann <[email protected]>
* Fix asan warningsLars Knoll2018-05-021-0/+14
| | | | | | | Don't try to allocate an array buffer with negative length. Change-Id: Ie95b9bcf7a3108b47df27ef813b7922e9da42b17 Reviewed-by: Simon Hausmann <[email protected]>
* Fixes when using getLength()Lars Knoll2018-05-021-1/+1
| | | | | | | Do some more bounds checking to avoid crashes. Change-Id: I44e838c3577a9176628aa5e382d712eac9800203 Reviewed-by: Simon Hausmann <[email protected]>
* Partial Symbol supportLars Knoll2018-05-021-1/+18
| | | | | | | | | Added basic infrastructure to create symbols and convert them back to strings. In addition, storing and retrieving of symbol based properties in Objects works. Change-Id: I185f7aa46e7afa19db5a801102142892e03b7bf1 Reviewed-by: Simon Hausmann <[email protected]>
* Change Objects vtable methods to take a StringOrSymbolLars Knoll2018-05-021-0/+14
| | | | | | | This is needed for symbol support. Change-Id: I83db21f232168710d18999fd97d912016e86d630 Reviewed-by: Simon Hausmann <[email protected]>
* The length of array like objects can in some cases be 2^53 -1 in ES7Lars Knoll2018-05-021-0/+13
| | | | | | | | | Add a Value::getLength(), that converts a Value to a length bound between 0 and 2^53-1 as per ES7 spec. Use the extended range in Array.prototype.splice and map to fix hanging test cases. Change-Id: If9280d501423cfc10a60abd4e8aa30521d2a7bca Reviewed-by: Simon Hausmann <[email protected]>
* Remove dependency from qv4heap_p.h onto qv4internalclass_p.hLars Knoll2018-04-121-5/+6
| | | | | | | | This is required to be able to turn the internal class into something that lives on the GC heap. Change-Id: Ie4318588d420743b1e1ab1cd596a1c9d153eb793 Reviewed-by: Simon Hausmann <[email protected]>
* Fix isInt32 for -0.0Erik Verbruggen2018-03-261-1/+1
| | | | | | | Because no, that can't be represented as an 32bit integer. Change-Id: I83e5e74fdfbd9b13ac04a49311619d8939c7b093 Reviewed-by: Lars Knoll <[email protected]>
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-3/+3
| | | | | | | | | | | | | From now on we prefer nullptr instead of 0 to clarify cases where we are assigning or testing a pointer rather than a numeric zero. Also, replaced cases where 0 was passed as Qt::KeyboardModifiers with Qt::NoModifier (clang-tidy replaced them with nullptr, which waas wrong, so it was just as well to make the tests more readable rather than to revert those lines). Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d Reviewed-by: Simon Hausmann <[email protected]>
* Merge remote-tracking branch 'origin/5.10' into 5.11Liang Qi2018-02-121-0/+4
|\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/imports/shapes/qquickshape.cpp src/imports/shapes/qquickshape_p_p.h src/qml/compiler/qqmlpropertycachecreator_p.h src/qml/jsruntime/qv4value_p.h src/quick/items/qquickloader_p.h tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp tools/qmlprofiler/qmlprofilerapplication.cpp Change-Id: Iafc66ae84bf78630ed72a986acb678e9d19e3a69
| * Merge remote-tracking branch 'origin/5.9' into 5.105.10Liang Qi2018-02-071-0/+4
| |\ | | | | | | | | | Change-Id: I3b250545e334f50dcef1a75acdef51820d34079a
| | * QML: Collapse all NaNs into one single (encoded) NaNErik Verbruggen2018-02-051-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The idea of NaN boxing is to use one single NaN as a "true" NaN, and all others as a boxed value. So when encoding some NaN, be sure to use that one "true" NaN. Otherwise, it will be interpreted as an encoded value. Task-number: QTBUG-65998 Change-Id: Ia6e4641be180f3d626c40a57b473f181358e04db Reviewed-by: Simon Hausmann <[email protected]>
* | | Disentangle include dependencies around the write barrierLars Knoll2018-01-191-0/+89
| | | | | | | | | | | | | | | | | | | | | The write barrier header should have minimal dependencies. Change-Id: I071718c2fafe5020d1093ca3b363844f7a9b7b35 Reviewed-by: Simon Hausmann <[email protected]>
* | | Raise minimum supported MSVC version to 2015Friedemann Kleint2018-01-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove code for older versions and streamline #ifdefs. Remove the helpers macros Q_STATIC_ASSERT_FOR_SANE_COMPILERS and V4_ASSERT_IS_TRIVIAL. Task-number: QTBUG-40658 Task-number: QTBUG-51673 Change-Id: Ifa4fab653b10ce7858739adef08364cddc6507cf Reviewed-by: Simon Hausmann <[email protected]>
* | | V4: Remove left-overs from previous 32bit Value encodingErik Verbruggen2017-11-161-29/+0
| | | | | | | | | | | | | | | Change-Id: I0eb3300ac2e3e29b5311f9b7599d85eab7f775c5 Reviewed-by: Lars Knoll <[email protected]>
* | | Optimize Value::toObject/toStringLars Knoll2017-11-151-0/+4
| | | | | | | | | | | | | | | Change-Id: Iccfe50c967560deee9e2903bbe3a293b13fe8b48 Reviewed-by: Erik Verbruggen <[email protected]>
* | | Allow for encoding a nullptr Heap::Base as a ValueErik Verbruggen2017-11-141-1/+0
| | | | | | | | | | | | | | | | | | | | | The encoding will end up being the same as undefined. Change-Id: I2427e96f98d410c291234615969791de6bf4f833 Reviewed-by: Lars Knoll <[email protected]>
* | | Bring back markObjects(), this time generatedLars Knoll2017-11-141-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | Doing the marking of objects in a function instead of using the table seems to be somewhat faster. Change-Id: I9ec00cc0264f9a15c69b285db493bee31d99bf96 Reviewed-by: Erik Verbruggen <[email protected]>