aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4arraydata.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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 <[email protected]>
* | 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 <[email protected]>
* | 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 <[email protected]>
* Don't return Property * from ArrayData::insertLars Knoll2015-09-151-3/+6
| | | | | Change-Id: Ibabee04a17f5b2f3ba993cd61cbe64c897031f71 Reviewed-by: Simon Hausmann <[email protected]>
* 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 <[email protected]>
* 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 <[email protected]>
* 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 <[email protected]>
* | 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 <[email protected]>
* | Rename Heap::Base::as() to cast()Lars Knoll2015-04-211-27/+27
| | | | | | | | | | | | | | | | The as() methods in other places to dynamic type checking, whereas cast() methods are basically the same as a static_cast. Change-Id: Iacd0174824b41b8fad05d6b55b1e62e3b44a31db Reviewed-by: Simon Hausmann <[email protected]>
* | More cleanupsLars Knoll2015-04-211-1/+1
| | | | | | | | | | | | | | | | Get rid of Value::asObject(), and pass const Managed pointers into some more vtable methods. Change-Id: Ia4f427d5fd8868f77b4015d1ce5424d32bfc2115 Reviewed-by: Simon Hausmann <[email protected]>
* | Cleanup some of the casting codeLars Knoll2015-03-201-1/+1
| | | | | | | | | | | | | | | | Get rid of value_cast, and move the Managed::as() method into Value. Change-Id: I440ac44ae77f4fda1a8a837383fe631f432f6532 Reviewed-by: Simon Hausmann <[email protected]>
* | Wrap members in Object in a Heap::PointerLars Knoll2015-03-201-27/+27
| | | | | | | | | | Change-Id: I0d132592487255027c215da21fbec15b23b00624 Reviewed-by: Simon Hausmann <[email protected]>
* | Move memory management related functionality into it's own folderLars Knoll2015-03-021-1/+1
|/ | | | | | | | | Start moving the memory related functionality into it's own folder. This will simplify refactoring of the GC related functionality later on. Change-Id: I70ec6f512af7a7897625afb84d914c17572b0ccd Reviewed-by: Simon Hausmann <[email protected]>
* Update copyright headersJani Heikkinen2015-02-121-7/+7
| | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Change-Id: I61120571787870c0ed17066afb31779b1e6e30e9 Reviewed-by: Iikka Eklund <[email protected]>
* CleanupsLars Knoll2015-01-231-2/+2
| | | | | | | | Simplify some code in BooleanObject Simplify access to call arguments and thisObject Change-Id: I2f8e844019bc587385608beb02f05b15f827535c Reviewed-by: Simon Hausmann <[email protected]>
* Remove all remaining usages of ValueRefLars Knoll2015-01-231-1/+1
| | | | | Change-Id: Icd76d3d03fac2e57530e55f8ec15b97109dcdcbc Reviewed-by: Simon Hausmann <[email protected]>
* Get rid of most uses of ValueRefLars Knoll2015-01-231-9/+9
| | | | | | | | | | | | Instead pass a const Value & into the functions With our new inheritance structure, we can get rid of ValueRef and instead simply pass a pointer to a Value again. Pointers to Values are safe to use again now, as they are now guaranteed to be in a place where the GC knows about them. Change-Id: I44c606fde764db3993b8128fd6fb781d3a298e53 Reviewed-by: Simon Hausmann <[email protected]>
* Move the internalClass pointer into Heap::ObjectLars Knoll2015-01-211-2/+2
| | | | | | | | The other classes that derive from Heap::Base don't need it at all. So get rid of it there and save a pointer. Change-Id: I9c5df2e43cd6eeac2e6e41f3d3b8077d3afbc8f2 Reviewed-by: Simon Hausmann <[email protected]>
* Move vtable out of internalClassLars Knoll2015-01-201-2/+2
| | | | | | | | | | | | | | | | We can move the internalClass to Object later on, and such save having the internalClass on lots of Heap objects. This commit basically adds and starts making use of a new vtable pointer in Heap::Base. In addition, the construction methods in the memory manager now automatically setup the correct vtable. Removing the vtable code from InternalClass and moving it into Object will come in a separate commit Change-Id: If49e8d73c769bf65bf47fe4dbf8b9546c8019dbc Reviewed-by: Simon Hausmann <[email protected]>
* Get rid of hasAccessorProperty in Heap::BaseLars Knoll2015-01-121-2/+7
| | | | | | | | | This shouldn't affect performance as we can just as well check for cases where we need to take the slow path differently. Change-Id: I4b9f69c39e9e64b437820ca3a6ea43e8877f2cf3 Reviewed-by: Simon Hausmann <[email protected]>
* Make Property uses GC safeLars Knoll2014-12-201-1/+1
| | | | | Change-Id: I5aa41a07a2d25e5c8a2d64bfa58a55fcd7aaf77e Reviewed-by: Simon Hausmann <[email protected]>
* Fix Object::arrayData() accessor to return a heap objectLars Knoll2014-12-111-21/+20
| | | | | Change-Id: Iffc82c2f415251d73bb7446848399b54b16589c9 Reviewed-by: Simon Hausmann <[email protected]>
* Move readonly accessors into Heap::ArrayDataLars Knoll2014-12-101-20/+5
| | | | | | | | these methods don't modify the object, so it's safe to have them there and this simplifies quite a bit of the code. Change-Id: I2f591758efba9cb8d17b956bc7c02e2d7a468ea4 Reviewed-by: Simon Hausmann <[email protected]>
* Operate directly on Heap::ArrayData where possibleLars Knoll2014-11-221-108/+114
| | | | | Change-Id: I87dfb3e9a07673b5c405619eab8b6ee292d5c097 Reviewed-by: Simon Hausmann <[email protected]>
* Reduce usage of Object::arrayData()Lars Knoll2014-11-221-63/+64
| | | | | | | | This will simplify porting over to returning Heap::ArrayData from the method (as required for the new GC). Change-Id: I5fb9ca7dfeab1aa63cc17c8948ef0966716f1bcb Reviewed-by: Simon Hausmann <[email protected]>
* Let the memory manager operate on Heap::Base objects, not ManagedLars Knoll2014-11-211-2/+3
| | | | | Change-Id: Ib5c9b51dbf9c69abeda088094e6348dd545bf3c8 Reviewed-by: Simon Hausmann <[email protected]>
* Cleanup destruction of heap objectsLars Knoll2014-11-211-6/+0
| | | | | | | | Generate the code from a macro instead of duplicating boiler plate code. Operate on Heap::Base instead of Managed. Change-Id: I84c5a705980899be3e5b931a093645e50d3923bf Reviewed-by: Simon Hausmann <[email protected]>
* Remove ExecutionContext from the array sorting codeLars Knoll2014-11-151-7/+7
| | | | | Change-Id: I3c59fdb2413664f1c541264a89613a325ecefd2a Reviewed-by: Simon Hausmann <[email protected]>
* Cleanup: remove Value::toString/Object overloads taking a contextLars Knoll2014-11-151-2/+2
| | | | | Change-Id: I4cb63c3cc4eb9bb81f10f9826f80e581b4e1990c Reviewed-by: Simon Hausmann <[email protected]>
* Change signature or runtime methods to take an engine pointerLars Knoll2014-11-121-1/+1
| | | | | | | | | This makes a lot more sense in the long term and is the more maintainable solution, once the GC starts moving objects around in memory Change-Id: I8f327c0f5b5b0af38c5fe1a217852ee8c4a5c2fc Reviewed-by: Simon Hausmann <[email protected]>
* Begin moving the data out of Managed objectsLars Knoll2014-11-081-26/+26
| | | | | | | | | | | We need to move the Data objects out of the Managed objects, to avoid lots of trouble because inner classes can't be forward declared in C++. Instead move them all into a Heap namespace. Change-Id: I736af60702b68a1759f4643aa16d64108693dea2 Reviewed-by: Simon Hausmann <[email protected]>
* Let markObjects() operate directly on HeapObjectsLars Knoll2014-11-041-8/+8
| | | | | | | | | This decouples things a bit better and helps moving over to directly store heapobject pointers in other objects. Change-Id: I798f922e018b0a3ca6f8768e4a810187f34d82f6 Reviewed-by: Simon Hausmann <[email protected]>
* Move the throw methods from ExecutionContext to ExecutionEngineLars Knoll2014-11-041-1/+1
| | | | | | | | The methods don't require a context, and thus shouldn't be implemented there. Change-Id: If058e0c5067093a4161f2275ac4288aa2bc500f3 Reviewed-by: Simon Hausmann <[email protected]>
* Cleanup header file dependenciesLars Knoll2014-11-041-0/+1
| | | | | Change-Id: Ibb4658576a98b53de2eac2474ce4d5b9eb83b6ae Reviewed-by: Simon Hausmann <[email protected]>
* Get rid of !this and similar constructsLars Knoll2014-10-311-3/+3
| | | | | | | | | The C++ standard doesn't allow calling member functions on a mull object. Fix all such places, by moving the checks to the caller where required. Change-Id: I10fb22acaf0324d8ffd3a6d8e19152e5d32f56bb Reviewed-by: Simon Hausmann <[email protected]>
* Don't allocate less memory than requiredLars Knoll2014-10-311-0/+2
| | | | | | | | | When switching from a simple to a sparse array, keep the previously allocated size, to not corrupt memory. Change-Id: I33f0fb049a2ad6f24ee3703f2c333855830fe9d2 Reviewed-by: Simon Hausmann <[email protected]>
* Don't check the this pointer for 0 in member functionsLars Knoll2014-10-271-1/+1
| | | | | | | | | | | | This actually violates the C++ standard that defines that you aren't allowed to call member functions on an invalid object. Instead insert the 0 pointer checks on the caller side where required. Change-Id: I8be3c3831594bb6482e9ef6de6e590ec437ac0f8 Reviewed-by: Simon Hausmann <[email protected]>
* Reduce size of ArrayData by one pointerLars Knoll2014-10-271-11/+11
| | | | | | | | | | The pointer to the real data is not required anymore, as it always follows the class itself. Like this we save one pointer of overhead, and one indirection when doing reads and writes of array data. Change-Id: If6afdac8e97b57420b50e7b7eb8979f77e8dbbcf Reviewed-by: Simon Hausmann <[email protected]>
* Rework our simple array implementationLars Knoll2014-10-271-129/+132
| | | | | | | | | | | Implement the simple array as a circular buffer instead of an array with head room. This fixes a couple of severe issues with performance and memory management if the array is being used as a queue. Task-number: QTBUG-41421 Change-Id: I146ad8a874407c108aa8fe1eae68e9957e154847 Reviewed-by: Simon Hausmann <[email protected]>
* Merge remote-tracking branch 'origin/5.3' into 5.4Simon Hausmann2014-09-081-1/+55
|\ | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/qml/jsruntime/qv4arraydata.cpp src/quick/scenegraph/util/qsgatlastexture.cpp Change-Id: Ic4c96066d5c37dcf0d5446baed590ea005d445ce
| * Fix crashes when calling Array.sort with imperfect sort functionsLars Knoll2014-09-011-1/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We can't use std::sort to implement Array.sort. The reason is that std::sort expects a conformant compare function, and can do weird things (esp. crash) when the sort function isn't conformant. Falling back to qSort is not possible, as the method has been deprecated. So add a copy of the qSort implementation here, and use that one instead. Fix the sortint test in tst_qqmlecmascript to have a consistent sort function for strings, as the result of calling sort is otherwise undefined according to the ecma standard. Task-number: QTBUG-39072 Change-Id: I0602b3aa1ffa4de5006da58396f166805cf4a5e2 Reviewed-by: Robin Burchell <[email protected]> Reviewed-by: Simon Hausmann <[email protected]>
* | Merge remote-tracking branch 'origin/5.3' into 5.4Simon Hausmann2014-08-261-2/+2
|\| | | | | | | | | | | Conflicts: src/qml/qml/qqmlobjectcreator_p.h Change-Id: I60858ddb46866a8fa1a8576bb05b412afeeb4e41
| * Don't use d->instanceModel after free'ing itLars Knoll2014-08-261-2/+2
| | | | | | | | | | | | | | | | | | prevModel points to d->instanceModel and is being used further down in the code. So reset the pointer to 0 after freeing the old instanceModel. Change-Id: I8854ae3e09c8b2fe50ad311f3dbc7b8ed26805e1 Reviewed-by: Simon Hausmann <[email protected]>
* | Update license headers and add new licensesJani Heikkinen2014-08-251-18/+10
| | | | | | | | | | | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Change-Id: I84a565e2e0caa3b76bf291a7d188a57a4b00e1b0 Reviewed-by: Jani Heikkinen <[email protected]>
* | Cleanup: Get rid of __data membersSimon Hausmann2014-07-221-4/+4
| | | | | | | | | | | | | | These are not needed anymore Change-Id: Ib834aa294e84ca9fbdd5b6850d5bc172e8b54ba1 Reviewed-by: Lars Knoll <[email protected]>
* | Fix build on WindowsSimon Hausmann2014-07-221-0/+16
| | | | | | | | | | | | | | | | | | * Add missing exports * Define otherwise unused ArrayData vtbl - somehow the linker wants to see the symbols despite them being unused. Change-Id: I83a7ad4dea89bffc16018093a3cd4f4feecbfa3c Reviewed-by: Lars Knoll <[email protected]>
* | Ported array data to the new object structureSimon Hausmann2014-07-221-2/+2
| | | | | | | | | | Change-Id: Ice53925f42924c889d265bcd1e4af7b9bd356fa8 Reviewed-by: Lars Knoll <[email protected]>