aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4arraydata.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Check in even more places for exceptionsFabian Kosmale2020-04-211-0/+2
| | | | | | | | | Amends commit 4c5ed04e64ea9ac0038ae30e1189cfe745b29bd9 Task-number: QTBUG-83384 Pick-to: 5.15 5.12 Change-Id: I0918c27dfa73dff83cbf0f58b41ce8620dff8a0a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* V4: Don't crash when sorting arrays with non-stringifyable entriesUlf Hermann2020-01-081-0/+6
| | | | | | Fixes: QTBUG-81108 Change-Id: I7e121776a2416b5338c4c1309ec7cc31c703ad28 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Avoid oob access on Array.concatUlf Hermann2020-01-061-1/+1
| | | | | | | | | | As we have already determined that we're past the end of the allocated space on the source object by checking os->values.alloc, we should conclude that all the remaining values are undefined. Fixes: QTBUG-81037 Change-Id: I664f22b7eb37c26061e8a9e2f88bcf2a7b6e09f3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Get rid of ArrayData::ComplexLars Knoll2018-09-271-2/+0
| | | | | | | It's been pretty much unused. ArrayData::Simple does the job. Change-Id: I0fbd0b7787499244f4c8ca00b3ba7330a6640b75 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Cleanups in Value/PrimitiveLars Knoll2018-09-171-6/+6
| | | | | | | | | | | | 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>
* Unify the managed and object vtablesLars Knoll2018-07-031-22/+1
| | | | | | | | | | Allow for nullptr entries in the vtable. To nevertheless get some decent error checking if one of the methods is reimplemented, use a base class for Managed that contains a full set of the vtable entries all being nullptr's. Change-Id: Ibc53973b539f87331e8e465a6c44436a30acbefd Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Unify the get and getIndexed vtable functions of QV4::ObjectLars Knoll2018-07-021-1/+1
| | | | | | | | This finalizes the refactoring of Object's vtable API. Also added the receiver argument to the method as required by the ES7 spec. Change-Id: I36f9989211c47458788fe9f7e929862bcfe7b845 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.11' into devUlf Hermann2018-06-251-4/+0
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp src/quick/handlers/qquickhandlerpoint.cpp src/quick/handlers/qquicksinglepointhandler.cpp tests/auto/qml/ecmascripttests/test262 Change-Id: I8908ec8c6116ca626fbd269af7625d4c429429ca
| * revert change 353164263c55825a0ec72d30128c50560c626334Lars Knoll2018-06-191-4/+0
| | | | | | | | | | | | | | | | | | | | | | The change was too aggressive in trying to avoid marking the array data. We didn't catch all cases where on could be inserting a GC controlled object into the array data. Let's be safe and always mark the content of array data objects. Task-number: QTBUG-68894 Change-Id: Ifbb628be898c0903596b1a483212384295b01df5 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | Don't use empty values anymore to store internal freelistsLars Knoll2018-05-241-38/+29
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Don't use bitfields for VTable flagsLars Knoll2018-05-031-1/+1
| | | | | | | | | | | | | | | | | | Accessing those is significantly slower than using a byte for each flag. As they are performance critical, let's rather use some more bytes in the vtable. Change-Id: I7104d3b791f469fe5d6705f20db0c965878126e2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Add a StringOrSymbol intermediate class between Managed and StringLars Knoll2018-05-021-0/+1
|/ | | | | | | | | This introduces a common base class for Strings and Symbols giving us a unified approach to handling object properties for both. Change-Id: Ic9e5a18b084c8b730e134db990f101d47af224e3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Qml/ArrayElementLessThan: Remove unused member variable thisObjectFriedemann Kleint2018-04-121-4/+3
| | | | | | | Fix a warning by clang-cl. Change-Id: Ie9285a8937cdfa2640403b07b27ae938c5f61743 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix out of bounds reads in Array.concatLars Knoll2018-03-201-1/+1
| | | | | | | | | | In some cases, when our simple array data had an offset and data would wrap around, ArrayData::append would write out of bounds data into the new array, leading to crashes. Task-number: QTBUG-51581 Change-Id: I55172542ef0b94d263cfc9a17d7ca49ec6c3a565 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-6/+6
| | | | | | | | | | | | | 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>
* Fix crash when changing from a simple to a sparse arrayLars Knoll2018-02-151-1/+1
| | | | | | | | | After that change, if we ran out of slots in the freeList, the last entry would point to the first Value in the value array, not indicating that we ran out of free slots. Task-number: QTBUG-65828 Change-Id: I3e57bb7a0c2dc29172a485a6ea957b6ab5ac962e
* Move the freeList from Heap::ArrayData to SparseArrayLars Knoll2018-01-151-16/+15
| | | | | | | It's only used for sparse arrays, so the data should live there. Change-Id: I9ca04c73dd2dbebf459ee64c164a69681623a351 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Avoid marking on simple array data'sLars Knoll2017-11-141-0/+11
| | | | | | | Speeds up things by 2-3%. Change-Id: Ib17ab126cf91ce48a0ced7dd7b06c4f7f0a70a3b Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Bring back markObjects(), this time generatedLars Knoll2017-11-141-2/+1
| | | | | | | | 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>
* Simplify JSCallData constructionLars Knoll2017-11-071-1/+1
| | | | | Change-Id: Ic53532edae9a209aa7125af6f00a9d993d74f1a3 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Get rid of JSCallData::call()Lars Knoll2017-11-071-4/+4
| | | | | Change-Id: I6b99e9a7102b3dcb6a7699f54b6456eba6248699 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Rename JSCall to JSCallDataLars Knoll2017-11-071-1/+1
| | | | | | | | As, this is going to change in a simple stack based structure to keep pointers to the data to pass to calls. Change-Id: Ia9aa3f81ee3eeba36affd16aac7b2fe97d59aea9 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Always set the correct FunctionObject when calling JS functionsLars Knoll2017-09-021-8/+7
| | | | | | | | | Renamed ScopedCallData to JSCall, enforced passing a JS FunctionObject to it, and added call() and callAsConstructor() methods to it. Change-Id: I30db65c9765c2896b5909fe2105c0934c6dad861 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move ScopedCallData and ScopedStackFrame into a separate fileLars Knoll2017-09-011-0/+1
| | | | | Change-Id: I9ae42aa7a811aa93fe0950725e9d253a0c5e8dba Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-06-061-0/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/qml/jsruntime/qv4argumentsobject.cpp src/qml/jsruntime/qv4arraydata.cpp src/qml/jsruntime/qv4context.cpp src/qml/jsruntime/qv4context_p.h src/qml/jsruntime/qv4errorobject.cpp src/qml/jsruntime/qv4functionobject.cpp src/qml/jsruntime/qv4internalclass.cpp src/qml/jsruntime/qv4lookup.cpp src/qml/jsruntime/qv4managed.cpp src/qml/jsruntime/qv4managed_p.h src/qml/jsruntime/qv4object.cpp src/qml/jsruntime/qv4object_p.h src/qml/jsruntime/qv4qmlcontext.cpp src/qml/jsruntime/qv4runtime.cpp src/qml/jsruntime/qv4vme_moth.cpp src/qml/memory/qv4heap_p.h src/qml/memory/qv4mm.cpp src/qml/memory/qv4mm_p.h src/qml/memory/qv4mmdefs_p.h src/quick/scenegraph/util/qsgdistancefieldutil.cpp src/quick/scenegraph/util/qsgdistancefieldutil_p.h tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp Change-Id: I7ed925d4f5d308f872a58ddf51fdce0c8494ec9c
| * Re-add some inline property storageLars Knoll2017-05-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It turns out that not using any inline property storage comes at a relatively high price in terms of memory consumption, as we always need to also create a memberData for any object. This avoids the memberData creation in quite a few cases, as we use the additional padding we have up to the 32 byte boundary given by the memory manager to store some property data. This complicates property access somewhat. To avoid performance regressions because of this, add specialized QV4::Lookup functions that optimize for properties that are inline or in the memberData struct. Change seems to be performance neutral on v8-bench on x86_64, but reduces peak memory usage when running the benchmark by around 20%. Change-Id: I0127d31a2d6038aaa540c4c4a1156f45ca3b7464 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
* | Merge remote-tracking branch 'origin/5.9' into HEADSimon Hausmann2017-03-231-1/+1
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp src/qml/jit/qv4assembler.cpp src/qml/jit/qv4assembler_p.h src/qml/jit/qv4isel_masm.cpp src/qml/jsruntime/qv4context.cpp src/qml/jsruntime/qv4context_p.h src/qml/jsruntime/qv4engine.cpp src/qml/jsruntime/qv4vme_moth.cpp src/qml/memory/qv4mmdefs_p.h Change-Id: I9966750b7cd9106b78e4c4779f12b95a481cca40
| * Prepare run-time method calling mechanism for cross-compilationSimon Hausmann2017-03-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current way of encoding the offsetof() of the method_ members in QV4::Runtime is not portable when cross-compiling from a 64-bit host (where the offsetof would be calculated on) to a 32-bit target (where the offset would be different), or vice versa. In preparation for making this work, this patch first replaces the direct use of the run-time members with use through a void * and an enum for indexing. This gives us some type-safety in some places and will also allow for a translation of the pointer offset from host pointer indexing to target pointer indexes. As a bonus we can avoid going through the engine->runtime indirection in the interpreter altogether and call the static methods right away. Task-number: QTBUG-58666 Change-Id: I3cd6459523923a9719408317fa729bca19c2bf3c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Make writes to ArrayData write-barrier safeLars Knoll2017-03-091-31/+34
| | | | | | | | | | Change-Id: I2e46100fe72fd83b36b3195130eefce5289d1627 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Unify mark handling for MemberData and ArrayDataLars Knoll2017-03-091-72/+72
| | | | | | | | | | | | | | | | Introduce a ValueArray class, that defines an array of Values at the end of a Heap Object. Change-Id: I00efbf6f5839a6687dd5bc5fc037ec8f06e0936e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | New mark table implementationLars Knoll2017-03-091-23/+1
|/ | | | | | | | | | | | | | | | | | | Automatically generate a table containing the data where JS Values and pointers are in objects in the JS heap. This will allow making the GC mark phase a lot more efficient. A bit of a special hack is currently required for MemberData and ArrayData, as they have a variable length, and we need to read the size from the object. We keep backwards compatibility with the old markObjects() functions for now (calling them if they are defined). Some further work on QV4::String and in a few other places is required before we can get remove the compatibility. Change-Id: I78528ace67e886bdbe4a4330c9677c7fc9f08a33 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Improve SimpleArrayData::markObjectsLars Knoll2017-01-251-2/+8
| | | | | | | Avoid an expensive modulo operation per Value to be marked. Change-Id: Ibe0adcf0fce73ff760a6adf983c746e66f183332 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.6' into 5.8Simon Hausmann2016-10-131-12/+21
|\ | | | | | | Change-Id: I175b27337b534c0b8f46a4a792d2c43cde73ffc4
| * V4: Fix usage of QV4::Value tags/typesErik Verbruggen2016-10-131-12/+17
| | | | | | | | | | | | | | | | These two were mixed, but have completely different values. Task-number: QTBUG-56471 Change-Id: Ifbf6da3032335ea89bfbc3acde17f64a571b9dc0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Fix developer-build with gcc 6Allan Sandfeld Jensen2016-10-101-0/+4
| | | | | | | | | | | | | | | | Locally suppress bogus tautological compare warnings. Task-number: QTBUG-56266 Change-Id: Ic1b554982a778cdd89c8047483523c44d53bbadd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QML: Make all context objects trivialErik Verbruggen2016-09-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change also adds a check to the d() calls for Managed, verifies that the object has been initialized. This is only done for debug builds. To prevent other code from tripping the check, a number of other classes are either marked as trivial, or do initialization in the constructors. Because of template function changes in them memory manager (those now call init() instead of in-place new), String has an extra parameter to force it to temporarily use an old/unmodified template function. Change-Id: I8c35161ce7680835d830638b6d21498c5129b02b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-06-211-5/+5
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/quick/items/qquickflickable_p_p.h src/quick/items/qquickpathview_p_p.h tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp Change-Id: I77664a095d8a203e07a021c9d5953e02b8b99a1e
| * | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-06-201-5/+5
| |\| | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jit/qv4targetplatform_p.h src/quick/accessible/qaccessiblequickitem_p.h Change-Id: Ic95075a5fad81ec997a61561bd65979dfa3b9d4d
| | * V4: Always set the tag when boxing a pointer in QV4::Value.Erik Verbruggen2016-06-161-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | All setters now store tags, so no-one can play loosy-goosy with the boxed values (and accidentally forget to "tag" a value, resulting in random garbage). Change-Id: Ia0b78aa038d3ff46d5292b14bd593de310da16a0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-05-131-1/+7
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsapi/qjsengine.cpp src/qml/qml/qqmlengine_p.h src/quick/items/qquickanchors.cpp src/quick/items/qquickanimatedimage_p_p.h src/quick/items/qquickitem_p.h tests/auto/qml/qqmlecmascript/testtypes.h tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp tests/benchmarks/qml/creation/tst_creation.cpp Change-Id: I65861e32f16e8a04c7090a90231627e1ebf6ba6f
| * | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-04-271-1/+7
| |\| | | | | | | | | | | | | | | | | | | | | | Conflicts: src/quick/items/qquickimagebase.cpp src/imports/layouts/plugin.cpp Change-Id: I5f48474df4034a1347ec74795c85d369a55b6b21
| | * Fix memory corruption when calling Array.unshift()Simon Hausmann2016-04-141-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The dequeue offset won't wrap around when n > offset. [ChangeLog][QtQml] Fix crash with Array.unshift() Task-number: QTBUG-52065 Change-Id: I5e8b89ec964cd6397100442a5239254bca989a3f Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
* | | Convert the first batch of runtime functionsLars Knoll2016-04-111-1/+1
|/ / | | | | | | | | | | | | | | Convert them to the new calling convention through function pointers in the execution engine. Change-Id: Iecc54c9512f7231a04eb1659490a5d56118ff66a Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* / Updated license headersJani Heikkinen2016-01-191-14/+20
|/ | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: Ic36f1a0a1436fe6ac6eeca8c2375a79857e9cb12 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Don't return Property * from ArrayData::insertLars Knoll2015-09-151-3/+6
| | | | | Change-Id: Ibabee04a17f5b2f3ba993cd61cbe64c897031f71 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Simplify Object::getValueLars Knoll2015-09-151-2/+2
| | | | | | | | | | Object::getValue only needs the value/property getter. Because of this it's enough to pass it the Value stored in the member/arrayData and the property attributes. Like this we avoid the reinterpret_cast to a Property pointer. Change-Id: Ib6873526f9db22ed0e607e3617be5729b15271ab Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Remove type punning from QV4::Value.Erik Verbruggen2015-07-241-31/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The union in QV4::Value is used to do type punning. In C++, this is compiler-defined behavior. For example, Clang and GCC will try to detect it and try to do the proper thing. However, it can play havoc with Alias Analysis, and it is not guaranteed that some Undefined Behavior (or Compiler depenedent behavior) might occur. The really problematic part is the struct inside the union: depending on the calling convention and the register size, it results in some exciting code. For example, the AMD64 ABI specifies that a struct of two values of INTEGER class can be passed in separate registers when doing a function call. Now, if the AA in the compiler looses track of the fact that the tag overlaps with the double, you might get: ecx := someTag ... conditional jumps double_case: rdx := xorredDoubleValue callq someWhere If the someWhere function checks for the tag first, mayhem ensues: the double value in rdx does not overwrite the tag that is passed in ecx. Changing the code to do reinterpret_cast<>s might also give problems on 32bit architectures, because there is a double, whose size is not the same as the size of the tag, which could confuse AA. So, to fix this, the following is changed: - only have a quint64 field in the QV4::Value, which has the added benefit that it's very clear for the compiler that it's a POD - as memcpy is the only approved way to ensure bit-by-bit "conversion" between types (esp. FP<->non-FP types), change all conversions to use memcpy. Use bitops (shift/and/or) for anything else. - only use accessor functions for non-quint64 values As any modern compiler has memcpy as an intrinsic, the call will be replaced with one or a few move instructions. The accessor functions also get inlined, the bitops get optimized, so in all cases the compiler can generate the most compact code possible. This patch obsoletes f558bc48585c69de36151248c969a484a969ebb4 (which had the exact aliassing problem of the double and the tag as described above). Change-Id: I60a39d8564be5ce6106403a56a8de90943217006 Reviewed-by: Ulf Hermann <ulf.hermann@theqtcompany.com>
* Merge remote-tracking branch 'origin/5.5' into devSimon Hausmann2015-06-041-3/+2
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4engine_p.h src/quick/items/qquickitemsmodule.cpp src/quick/items/qquicktext.cpp src/quick/util/qquickpixmapcache.cpp tests/auto/quick/qquickwindow/tst_qquickwindow.cpp Change-Id: I90ecaad6a4bfaa4f36149a7463f4d7141f4a516a
| * Fix memory corruption in array handlingSimon Hausmann2015-05-081-3/+2
| | | | | | | | | | | | | | | | | | | | SimpleArrayData's markObjects() implementation did not mark the entries correctly. When the dequeue offset was non-zero, we would end up marking values that may have been garbage collected earlier. Task-number: QTBUG-45888 Change-Id: Iacec350ccc76399ad4d16138af50acf22b2809db Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Get rid of qv4value_inl_p.h and replace it by qv4typedvalue_p.hLars Knoll2015-04-241-0/+1
| | | | | | | | | | | | | | | | This is a cleaner separation and further reduces include dependencies in the definitions of our basic data structured. Change-Id: I18aa86cdea0c0dfbc16075d4d617af97e638811e Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>