aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4value_p.h
Commit message (Collapse)AuthorAgeFilesLines
* 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 <fabian.kosmale@qt.io>
* 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 <fabian.kosmale@qt.io>
* 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 <volker.hilsheimer@qt.io>
* 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 <simon.hausmann@qt.io>
* 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 <ulf.hermann@qt.io>
* 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 <thiago.macieira@intel.com>
* | 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 <simon.hausmann@qt.io>
* | 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 <ulf.hermann@qt.io>
* | 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 <ulf.hermann@qt.io>
* Fix signed/unsigned warning in VS 2017Jason Erb2018-11-191-1/+1
| | | | | | | Task-number: QTBUG-71862 Change-Id: I836756d004753420bfb7a00013ade0229bd5946e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* 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 <simon.hausmann@qt.io>
* Micro optimization when initializing the Cpp frameLars Knoll2018-09-111-2/+2
| | | | | Change-Id: I07db2df7eec2bdbeb84bd576d9e4f7912f79fc78 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* 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 <simon.hausmann@qt.io>
* 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 <simon.hausmann@qt.io>
* 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 <simon.hausmann@qt.io>
* 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 <simon.hausmann@qt.io>
* 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 <simon.hausmann@qt.io>
* Implement ToPropertyKey() from the ES7 specLars Knoll2018-06-041-5/+2
| | | | | | | and use it where required. Change-Id: I309ca61e0360b26428fc2ea5a2eea47c8e0632a0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* 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 <lars.knoll@qt.io>
* 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 <simon.hausmann@qt.io>
* 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 <erik.verbruggen@qt.io>
* Optimize conversions to array indicesLars Knoll2018-05-031-19/+21
| | | | | Change-Id: Ic83314fc2a5bb80f88c1616e7d3179fe6573a0e9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* 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 <simon.hausmann@qt.io>
* 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 <simon.hausmann@qt.io>
* 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 <simon.hausmann@qt.io>
* 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 <simon.hausmann@qt.io>
* 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 <simon.hausmann@qt.io>
* 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 <simon.hausmann@qt.io>
* 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 <lars.knoll@qt.io>
* 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 <simon.hausmann@qt.io>
* 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 <simon.hausmann@qt.io>
* | | 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 <simon.hausmann@qt.io>
* | | 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 <simon.hausmann@qt.io>
* | | V4: Remove left-overs from previous 32bit Value encodingErik Verbruggen2017-11-161-29/+0
| | | | | | | | | | | | | | | Change-Id: I0eb3300ac2e3e29b5311f9b7599d85eab7f775c5 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Optimize Value::toObject/toStringLars Knoll2017-11-151-0/+4
| | | | | | | | | | | | | | | Change-Id: Iccfe50c967560deee9e2903bbe3a293b13fe8b48 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | 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 <lars.knoll@qt.io>
* | | 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 <erik.verbruggen@qt.io>
* | | Remove Binop/BinopContext instructions and implement missing binopsErik Verbruggen2017-10-231-3/+4
| | | | | | | | | | | | | | | Change-Id: Ibefac50246045066c90c4c2dbc36d2776c5dab0e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Merge remote-tracking branch 'origin/dev' into HEADLars Knoll2017-10-221-1/+1
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4codegen.cpp src/qml/compiler/qv4compileddata.cpp src/qml/compiler/qv4compileddata_p.h src/qml/compiler/qv4isel_moth_p.h src/qml/compiler/qv4ssa.cpp src/qml/jit/qv4assembler_p.h src/qml/jit/qv4isel_masm_p.h src/qml/jit/qv4regalloc.cpp src/qml/jsruntime/qv4engine.cpp src/qml/jsruntime/qv4qmlcontext_p.h src/qml/jsruntime/qv4regexp.cpp src/qml/jsruntime/qv4regexp_p.h src/qml/jsruntime/qv4regexpobject.cpp src/qml/jsruntime/qv4runtime.cpp src/qml/jsruntime/qv4vme_moth.cpp src/qml/qml/v8/qqmlbuiltinfunctions.cpp tests/auto/qml/qml.pro tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp tools/qmlcachegen/qmlcachegen.cpp Change-Id: I1577e195c736f3414089036b957a01cb91a3ca23
| * | | Replace Q_NULLPTR with nullptrKevin Funk2017-09-271-1/+1
| |/ / | | | | | | | | | | | | Change-Id: I0c01862dbb475494c84e39c695cb563df8cbcfa8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Fix 32bit builds/testsErik Verbruggen2017-09-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that we use the xor-NaN boxing on all platforms, the 32bit checks are not valid anymore. We do need to check if we still want specialized 32bit versions to prevent bad code generation for the 64bit stored value. Task-number: QTBUG-63194 Change-Id: Ic58a174194bfd343c09b78076ecbf8f2816d5749 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Add a Value::isFunctionObject() methodLars Knoll2017-09-011-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | This is just as fast as isObject(), and allows for some smaller optimizations. Change-Id: Icc2117941a2851e56e9ef2baf87ba3bca9538581 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Fix calling convention for some often used functions in QV4::ValueLars Knoll2017-08-281-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calling a non inline memberfunction does force the this argument onto the stack. Replacing those functions with static member functions taking the object by Value avoids that problem and allows the QV4::Value to be passed in registers. Change-Id: I9cf1c220e1dc0f958b416a7216d9ba1ae79a4b3e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | New value type encodingLars Knoll2017-08-251-97/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | Switch to a more efficient encoding of Values. This makes the type() determination easier and faster than before, and should allow us to optimize comparison operations better. Change-Id: I22106262cea052ae1887f42a957860ee00b450e6 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Optimize toInt32()/toUInt32()Lars Knoll2017-08-181-12/+82
| | | | | | | | | | | | | | | | | | | | | | | | And with this there is no need to special case integers in the BitXxx binops anymore. Change-Id: I9f94651d776f4e31ff8152fe7ce00dc5b1fa706e Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Remove Scope::result and convert calling convention for builtinsLars Knoll2017-08-081-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | Allow for faster calling of builtins, and completely avoid scope creation in many cases. Change-Id: I0f1681e19e9908db10def85a74e134a87fc2e44c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>