aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4internalclass.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Speed up QQmlEngine constructorLars Knoll2015-09-251-7/+13
| | | | | | | | | | | | | | | | Freezing the global object using a script is pretty slow, esp. given that the script needs to be compiled as well. Rather do it programmatically. The old code actually had a bug that would only cause the global object to be frozen, not it's children. The new code fixes this, but doesn't completely freeze the objects. Instead it makes all the existing properties of the global object and it's children readonly, but still allows extending existing objects with new properties. Change-Id: I0d7331cdc89a0ac717b8ed3b1a490b2a3742de02 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Inline property data into the objectLars Knoll2015-09-221-2/+34
| | | | | | | | | | | | 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>
* Encapsulate the remaining direct accesses to Object::memberDataLars Knoll2015-09-151-4/+18
| | | | | Change-Id: I17f202cf58dc355524b89a456e6722d41e444ca1 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* CleanupsLars Knoll2015-09-151-7/+8
| | | | | | | | | | | 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>
* V4: Fix use of uninitialized field.Erik Verbruggen2015-06-081-4/+1
| | | | | | | | | | | | Valgrind pointed out that Transition::id was used in a conditional jump or move. Fixes regressions of the following tests on OSX: ch15/15.2/15.2.3/15.2.3.12/15.2.3.12-2-1 in non-strict mode ch15/15.2/15.2.3/15.2.3.12/15.2.3.12-2-2 in non-strict mode ch15/15.2/15.2.3/15.2.3.12/15.2.3.12-3-28 in non-strict mode Change-Id: Ia959ff6f9fdac8d4cb37f54f670fdff4c8ba9a67 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>
* Remove the remaining bit of code that use the vtable in the internalClassLars Knoll2015-01-211-47/+5
| | | | | Change-Id: Ia52f0e6db325aab37477d455f163487b319dce29 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix a bug in removeMember causing a duplicate transition with an 0 lookup.Robin Burchell2015-01-201-3/+8
| | | | | | | | | | | We shouldn't have taken a copy here. I'm not sure why I did that. Also sprinkle Q_ASSERT fairydust around to try ensure that this doesn't happen again. This was exposed when we started trying to delete the transitions again, which were leaked in 6421f275286b3238fe1a7a5e909225251f3e8dbf. Change-Id: Id9272db7f1863d1ccc5b1f48b6382c68ae0da9da Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* QV4::InternalClass: Fix a memory leak.Robin Burchell2015-01-201-2/+2
| | | | | | | | Accidentally introduced in 6421f275286b3238fe1a7a5e909225251f3e8dbf. Change-Id: I45d121a661ba403d1d4573f98fe0944f05319290 Done-by: Slava Monich <slava.monich@jolla.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Move extensible into the internal classLars Knoll2015-01-121-0/+26
| | | | | | | | With this, we can now save one pointer per Heap object. Change-Id: I7f69193ff51c9fd9c5dbfba90aa1ebb3f93da2e6 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Replace InternalClass transitions hash with a sorted vector.Robin Burchell2015-01-091-34/+41
| | | | | | | | | | | | | | | | | | | | | | | | | In a reasonable test application, there were some 1697 transition entries. Out of these, 1663 of them had only a single item. The remainder, with the exception of three, had <10 items. Only one of these had a count of >50 items (86). As can be seen, most of the time, transitions is usually quite sparsely populated, so using a hash is a large amount of overhead considering there's just a few elements. For the times when it isn't, the vector being sorted should help take care of that. Since transitions are never removed, we can use a similar trick to ba690fb73864915b4a35bbec5b7dc134ff1dafd0 and use a sorted vector to store them. Compared to the hash approach, this saved ~412kb according to malloc_stats on a reasonably comprehensive test application. Coincidentally, this also improved v8bench for me by ~10%. Note that this undoes 132cdfa69cae45d0c02ea715ce58722bbcd57e73, but the expectation is that the fewer allocations done by using a vector will outweigh the need to reserve any specific allocation initially. Change-Id: Iec57a7db7e9a60347c9683b1cb1598f6d9c866f7 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* QV4::InternalClass: reserve space for transitions.Robin Burchell2014-12-311-0/+2
| | | | | | | Profiling of allocations shows that this is one of the most frequent allocators. Change-Id: Iae0350c61bfe37381577642b9a93064377f45c1d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Move prototype back from the vtable into ObjectLars Knoll2014-12-111-61/+5
| | | | | | | | 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>
* Merge remote-tracking branch 'origin/5.4' into devSimon Hausmann2014-12-091-18/+17
|\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4arraydata.cpp src/qml/jsruntime/qv4context_p.h src/qml/jsruntime/qv4globalobject.cpp src/qml/jsruntime/qv4internalclass.cpp src/quick/items/qquicktext_p.h src/quick/items/qquicktextedit_p.h src/quick/items/qquicktextinput_p.h Change-Id: If07e483e03197cb997ef47a9c647a479cdb09f4c
| * Avoid stack overflow when destroying InternalClassUlf Hermann2014-11-061-18/+17
| | | | | | | | | | | | | | | | | | If there are deep object hierarchies connected to an InternalClass the recursive nature of the destroy() method could lead to a stack overflow. By changing the recursion into an iteration this is avoided. Change-Id: I6667f268a366749c2dbc5f7147882388f192a9c5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Remove two reinterpret_casts in ObjectLars Knoll2014-11-221-3/+3
| | | | | | | | | | Change-Id: I921cd8129acb47cffd58be9551a6925c4f296d41 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Changed InternalClass to store Identifier* instead of String*Simon Hausmann2014-11-211-20/+28
| | | | | | | | | | | | | | | | | | All members are identifiers anyway, so this gets rid of a ### and also simplifies some of the call sites by removing the need for a scoped string. Change-Id: Ic6b550cdb97afa5a4b0fa7e9b13e7768ed3f6bd8 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Ported ExecutionEngine::newString and newIdentifier to Heap::StringSimon Hausmann2014-11-121-1/+2
| | | | | | | | | | | | | | | | | | | | Avoid the use of Returned<String> for newString and changed the identifier table to use Heap::String. This required moving some code back into Heap::String, but that's code that doesn't call back into the GC, so allocations and therefore future object moves aren't possible. Change-Id: I1dca3e9c12a9c56f09419af8cc8cba39fe04f720 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Get rid of Members and directly store MemberData::Data pointersLars Knoll2014-11-071-3/+3
|/ | | | | | | And do the same change for ArrayData. Change-Id: Ia1ae56bd0ff586c9b987e15af7a53f395a37054a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Update license headers and add new licensesJani Heikkinen2014-08-251-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Change-Id: I84a565e2e0caa3b76bf291a7d188a57a4b00e1b0 Reviewed-by: Jani Heikkinen <jani.heikkinen@digia.com>
* Get rid of StringRefLars Knoll2014-07-221-15/+0
| | | | | | | | Remove the Ref classes, as they won't be required anymore once Managed and Managed::Data are separated. Change-Id: Ic6bec2d5b4ecf2595ce129dbb45bbf6a385138a5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Convert String to the new storage layoutLars Knoll2014-07-221-6/+6
| | | | | Change-Id: Ifa9aac63fdb270fb449f11832a1792caeb6c6724 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move object data into internal structureLars Knoll2014-07-221-3/+3
| | | | | Change-Id: I1fcccd535ed356e736468337bd450270cd290044 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move string data into subclassLars Knoll2014-07-221-6/+6
| | | | | Change-Id: I95dcdda8c68e2a5c36244798c8c10dcfdd69d2c2 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move Managed data into it's own subclassLars Knoll2014-07-221-19/+19
| | | | | | | | | This prepares for moving over to a d pointer scheme, where Managed subclasses don't hold any data directly. This is required to be able to move over to a modern GC. Change-Id: I3f59633ac07a7da461bd2d4f0f9f3a8e3b0baf02 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix marking of prototype objects in internal class poolSimon Hausmann2014-04-281-11/+19
| | | | | | | | | | As per reported bug, we have to protect ourselves against potential loops and can mark the internal classes much simpler by just walking through the memory pool they were allocated in. Task-number: QTBUG-38299 Change-Id: I3ae96e8082e76d06f4321c5aa6d2e9645d2830a0 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix marking of prototype objects in chainSimon Hausmann2014-04-071-9/+6
| | | | | | | | | | | | | | | | With a real prototype chain it can happen that an internal class' prototype's class itself has a prototype. Therefore the first transition on the empty class is a PrototypeChange one, but the class the transition leads to may have PrototypeChange transitions itself, which weren't marked. There are multiple solutions to this, but this patch is the minimal fix by recursing fully through the internal class tree. That way it's easier to back-port the fix also into 5.2.x based branches. Task-number: QTBUG-37834 Change-Id: I901b13a2663fbad5844003ca5752f2f304de320c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Garbage collect member dataLars Knoll2014-04-041-3/+3
| | | | | | | | Move the allocated member data into the garbage collected area, so that we can avoid using malloc/free for it. Change-Id: I20625efa67ecd60238568742b74854b0c8cb2e3e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use an array of Value's for Object::memberDataLars Knoll2014-03-071-3/+7
| | | | | | | | | | This cuts the memory required to store properties in an object in half for the common case. Accessor properties require two slots inside memberData, but data properties only one. Change-Id: I0bab1b88ca9ed5930abf065c77c89985b9ed5320 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Reserve a double slot for accessor propertiesLars Knoll2014-03-071-32/+95
| | | | | | | | | | Reserve two slots in the internal class for accessor properties. This opens up reducing the default storage required per data property to one Value. In practice this implies cutting the required memory in half. Change-Id: Ifed897852bbdfd810018f0d6b049fca6690ead2c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Do not call InternalClass::changeVTable directlyLars Knoll2014-01-031-0/+2
| | | | | | | | vtable changes need to happen when the internal class is being constructed, not later on. Change-Id: Ibb9515745c9fc3507a5a90b4cc50a33e2e0d3f99 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Encapsulate the current context and fix it's usageLars Knoll2013-12-041-1/+4
| | | | | | | | | | | Encapsulate accesses to the current context, and rework the way we push and pop this context from the context stack. Largely a cleanup, but simplifies the code in the long term Change-Id: I409e378490d0ab027be6a4c01a4031b2ea35c51d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove setVTable calls in performance critical areasLars Knoll2013-12-041-0/+6
| | | | | | | | | | Remove all the calls to setVTable that were in performance critical parts of the code. This now brings performance back to the level we had with the vtable inlined in the Managed objects. Change-Id: I76317cc5c53b5b700d1d3883b954407142a4c424 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move the vtable pointer from the object to the internal classLars Knoll2013-12-041-3/+46
| | | | | | | | This saves one pointer per object, and willmake other optimizations easier in the future. Change-Id: I1324cad31998896b5dc76af3c8a7ee9d86283bfe Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Greatly reduce memory consumed by QQmlEngine instancesLars Knoll2013-11-191-21/+18
| | | | | | | | | | | | | | | | Due to a inefficiency in our InternalClass implementation, we were not sharing the string and attribute table between internal class instances. This was extremely inefficient with the Qt object, as it created around 1000 internal classes with large string and property tables. With the patch these tables are now shared. Reduces memory consumption of a QQmlEngine instance from around 6.5M to a couple of 100k. Change-Id: Ib763f31deca0808c000ac2c30aa0b05e806bda40 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* Refactor marking GC'ed objectsLars Knoll2013-11-051-1/+1
| | | | | | | | | | | Don't use recursive function calls anymore. Instead, push marked objects onto the JS stack, and then pop them off when their children are being marked. Should reduce stack memory usage, and improves performance by ~5%. Change-Id: I2d37d97579144fcba87ec8e9fd545dd220c01fbb Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix various compiler warnings in order to remove warn_off in the near futureErik Verbruggen2013-11-041-8/+8
| | | | | Change-Id: Ic0492fbe31a1e134674bc6c20381f735dd6d5b7a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Cleanup API of Safe<T>Lars Knoll2013-10-021-0/+10
| | | | | | | | Don't have an implicit cast operator to Returned<T> anymore, and return a T* from the operator->() Change-Id: If4165071b986bfc84a157560d94d39c2dcfbc9e1 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use StringRef for most methods in ObjectLars Knoll2013-09-221-1/+1
| | | | | Change-Id: I8e2dad0e9e34c5a549952bc0765cd57f6aa8aadf Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Cleanup calls to Object::setPrototype()Lars Knoll2013-09-021-4/+9
| | | | | | | | Rather use the correct internalClass directly when constructing the objects. Change-Id: I8e916f1ce8f83d291c08ca6332fe85b1f57b90b5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move prototype pointer into QV4::InternalClassLars Knoll2013-09-021-4/+21
| | | | | | | | | | | | | The prototype is actually the same for most objects. By moving it into the internal class, we can save 8 bytes per object, as well as allowing for some future optimizations. Also fix a bug in the implementation of the Error prototype objects. Change-Id: I4d4b641055f644a9b088f27be34bfdb0446279b7 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Add the object's prototype to the InternalClass structureLars Knoll2013-09-021-0/+28
| | | | | Change-Id: Ifa97d3354a7a7afadf70f9ba540716bd5b1eef44 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Restructure source codeLars Knoll2013-08-081-0/+296
Move the v4 engine classes from a subdir of qml/qml into two subdirs (compiler and jsruntime) of the qml module Remove an unsued qv4syntaxchecker class, and move the moth code directly into compiler. Change-Id: I6929bede1f25098e6cb2e68087e779fac16b0c68 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>