aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4object.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix a crash when copying array dataLars Knoll2015-10-201-1/+1
| | | | | | | | | | | Regression from 5.5. d()->arrayData->alloc can be larger, but never smaller than the allocation of the other's array data. Change-Id: I7d2265768f9d6e6298bfbba0d674a4d0e642422f Task-number: QTBUG-48727 Reviewed-by: Liang Qi <liang.qi@theqtcompany.com> Reviewed-by: Nikita Krupenko <krnekit@gmail.com> Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Add method to convert identifiers back into QV4::String objectsLars Knoll2015-09-251-1/+2
| | | | | | | | Allocating a new String for the Identifier is wasting both memory and CPU. Let's rather extract it from the IdentifierTable. Change-Id: Ibb9b2ac9775fefce74602d6954586195cdd5814e Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Move remaining objects to new constructor syntaxLars Knoll2015-09-221-10/+0
| | | | | | | Also disable the old way of constructing objects. Change-Id: Ib4e69087cd563ae1481da116d6caf97876239798 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Use the new construction scheme for RegExpObjectsLars Knoll2015-09-221-1/+0
| | | | | | | | Gives around 10% speed improvement on the v8 regexp benchmark. Change-Id: Iad37bcbc79ccbfb92f65852b660364c919862a75 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Inline property data into the objectLars Knoll2015-09-221-5/+13
| | | | | | | | | | | | Append the part of the objects property data that is known ad instantiation time to the object itself and by that avoid creating a separate MemberData. Saves some memory and should speed up object creation. Currently implemented only for Object and ArrayObject. Change-Id: I7693bf2f3a28fb718522398ebb94ac115e021fa4 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Get rid of propertyAt in ObjectLars Knoll2015-09-151-13/+30
| | | | | Change-Id: I3022b3c5c1ae90530ef5ca88e0b88a2fd1102e73 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Replace __getPropertyDescriptor__ with a getValueOrSetter callLars Knoll2015-09-151-35/+30
| | | | | | | This one returns a pointer to a Value instead of a property. Change-Id: I66e16526cc61d1ff3564cae983881c30b9106b54 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Further reduce usage of PropertyLars Knoll2015-09-151-17/+20
| | | | | | | | | Using Property * as return value is something I wanted to get rid of for a long time. As this interferes with storing properties inline in the Object, now is a good time to finally do the work :) Change-Id: I30594bad9a4cea5d9d606ebe02d7f3e707b4263a Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Simplify Object::getValueLars Knoll2015-09-151-8/+8
| | | | | | | | | | 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>
* Simplify Object::putValue()Lars Knoll2015-09-151-2/+5
| | | | | Change-Id: I1cc43f0081f63aed27c82875192e0f415ec995d5 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* CleanupsLars Knoll2015-09-151-14/+17
| | | | | | | | | | | There's only one place where we need to resize our member data, namely when we call setInternalClass() on an object. In addition, encapsulate the access to the memberdata better in preparation for inline property data later on. Change-Id: Ia34d0253d5d1792f1d7c4981556d78375fa7a755 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Further cleanupsLars Knoll2015-09-151-3/+3
| | | | | | | Reduce usage of ScopedContext. Change-Id: I84a6a7478065de3398fd0b21596ca1308e78ceb3 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Cleanup usage of ExecutionEngine::currentContextLars Knoll2015-09-151-11/+11
| | | | | Change-Id: Ic79d6da162375928ec25871cd0341daeab6483d2 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Encapsulate and protect all accesses to the vtable of Heap objectsLars Knoll2015-08-101-1/+1
| | | | | | | | This is required, so we can safely access the vtable even while we're marking objects during GC. Change-Id: I34f56b61b4bca0d0742faf607eb5ab8b2c30685e Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Remove type punning from QV4::Value.Erik Verbruggen2015-07-241-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Store a Heap::String pointer in StringObjectLars Knoll2015-06-171-4/+2
| | | | | Change-Id: I926c5bb2dd4f1613af6737d4200e568f0ec13d58 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Get rid of the tmpProperty in StringObjectLars Knoll2015-06-171-22/+19
| | | | | | | | | This was a bad hack. The new code is cleaner, and should also perform faster in a couple of cases (avoiding the creation of a temporary String that is then only thrown away). Change-Id: Ia6f978e037506484adbc01a61606307d4645b343 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Fix Object::getOwnProperty APILars Knoll2015-06-171-16/+19
| | | | | | | | | Don't return a Proprety pointer, this has issues with StringObject. Instead pass in a pointer that will get filled with the correct data. Change-Id: I28536ca129f5be3a4a1bc9583223521458411195 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Move the StringValue members of ExecutionEngine onto the JS stackLars Knoll2015-06-101-7/+7
| | | | | Change-Id: Ib55c05f1730b7659e2f6fee7e1fa79c10c759167 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Move more objects from the v4 engine to the js stackLars Knoll2015-04-241-1/+1
| | | | | | | Convert most of the prototype objects in the v4 engine. Change-Id: I365f290493c20973bc991b6a383649836e42a16a Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.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>
* Rename Heap::Base::as() to cast()Lars Knoll2015-04-211-2/+2
| | | | | | | | 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 <simon.hausmann@theqtcompany.com>
* More cleanupsLars Knoll2015-04-211-10/+10
| | | | | | | | Get rid of Value::asObject(), and pass const Managed pointers into some more vtable methods. Change-Id: Ia4f427d5fd8868f77b4015d1ce5424d32bfc2115 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Get rid of asManaged()Lars Knoll2015-04-211-2/+2
| | | | | Change-Id: I853417fdf1cc339f7d43a006c20e1626b6bfb288 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Further cleanupsLars Knoll2015-04-161-6/+6
| | | | | | | | | The get and getIndexed vtable methods should take a const Managed pointer. Start cleaning up the asFoo() methods in Value and Managed by removing asArrayObject() and asErrorObject(). Change-Id: Ibd49bf20773ef84c15785b7ac37a7bc9fd4745d5 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Reduce dependenciesLars Knoll2015-03-201-2/+2
| | | | | Change-Id: I4190c1a6d8a06a130e50cb727feafa7cf11f21cd Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Wrap members in Object in a Heap::PointerLars Knoll2015-03-201-2/+2
| | | | | Change-Id: I0d132592487255027c215da21fbec15b23b00624 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* 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 <simon.hausmann@theqtcompany.com>
* 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 <iikka.eklund@theqtcompany.com>
* Get rid of most uses of ValueRefLars Knoll2015-01-231-20/+20
| | | | | | | | | | | | 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 <simon.hausmann@digia.com>
* Move the internalClass pointer into Heap::ObjectLars Knoll2015-01-211-1/+1
| | | | | | | | 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 <simon.hausmann@digia.com>
* Get rid of all uses of Managed::engine()Lars Knoll2015-01-211-8/+8
| | | | | Change-Id: I596f14554d81f5e9af9996294d96047f2e810bef Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move vtable out of internalClassLars Knoll2015-01-201-1/+1
| | | | | | | | | | | | | | | | 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 <simon.hausmann@digia.com>
* Don't require an ExecutionEngine member in String anymoreLars Knoll2015-01-161-6/+6
| | | | | Change-Id: I7c1a5471507669871564d79dc17d1026c268b6d0 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Get rid of hasAccessorProperty in Heap::BaseLars Knoll2015-01-121-14/+2
| | | | | | | | | 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 <simon.hausmann@digia.com>
* Use QV4::ScopedFunctionObject typedef instead of actual typeOleg Shparber2015-01-021-2/+2
| | | | | Change-Id: I6b4effaa5bef992b4ae9402eea7fe655bc7b18f0 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use QV4::ScopedString typedef instead of actual typeOleg Shparber2015-01-021-1/+1
| | | | | Change-Id: I64ecbf6cea463387a70e909ecc5f9165d22a7b0f Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Make Managed inherit ValueLars Knoll2014-12-201-1/+1
| | | | | | | | This completes the first milestone towards being able to move objects across the GC heap. Change-Id: I8e6ce90254ea767188a31f0dc85b133534c87eb0 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Make Property uses GC safeLars Knoll2014-12-201-26/+26
| | | | | Change-Id: I5aa41a07a2d25e5c8a2d64bfa58a55fcd7aaf77e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Return a Heap object from the getter()/setter() methods of PropertyLars Knoll2014-12-201-8/+11
| | | | | | | | | | We actually need to put the returned value into a ScopedFunctionObject before calling it, as the Property could get deleted during the call leading to a dangling pointer. With a GC that moves objects this will become even more important. Change-Id: I43bece6f80eb3501c1291065846e230a59ae8aed Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix crash when setting proto to 0Lars Knoll2014-12-201-2/+2
| | | | | Change-Id: Id0621c51466721c503f1a54156e21e1671a13561 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove most of the places where getPointer() is usedLars Knoll2014-12-201-9/+9
| | | | | | | This is no longer required, and simply uglifies the code Change-Id: Iba91a1d7735ebe23a43437f137a488423b6eb743 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix the way we set the property name during iterationLars Knoll2014-12-201-4/+3
| | | | | | | This was broken due to the new inheritance scheme for Managed Change-Id: Ia9df50e7e655c3a812a01a2c78945e648aa444dc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Return Heap::ExecutionContext for globalContext()Lars Knoll2014-12-191-4/+7
| | | | | Change-Id: Ide7c81735be4662ff45bf268cfe750ff1f784453 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Return Heap::ExecutionContext for currentContext()Lars Knoll2014-12-191-11/+11
| | | | | Change-Id: I155ab996e24d7f36761d2ea62a04774e16469b34 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Return a Heap::Object in Object::prototype()Lars Knoll2014-12-171-17/+23
| | | | | Change-Id: Ice0265ae558ba14497421a5bbf25ee9db76adab5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Add default parameter value for ScopedCallData()Oleg Shparber2014-12-121-1/+1
| | | | | Change-Id: I16b6662a47c682e145d3e2201f9e90f58405a599 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move prototype back from the vtable into ObjectLars Knoll2014-12-111-7/+10
| | | | | | | | This is the only way we can support a GC that moves objects around in memory. Change-Id: I1d168fae4aa9f575b730e469e762bc5b5549b886 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Encapsulate accesses to the root contextLars Knoll2014-12-111-4/+4
| | | | | Change-Id: I668cef1363a5c1a5c5b9a7e138f3bd0338712eea Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove arrayData() calls from qv4object.cppLars Knoll2014-12-101-21/+24
| | | | | Change-Id: I92c74e87918a5f958ff17f4cbbc1888b58833fc6 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>