aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4functionobject.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Don't check the this pointer for 0 in member functionsLars Knoll2014-10-271-1/+3
| | | | | | | | | | | | 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 <simon.hausmann@digia.com>
* Rework our simple array implementationLars Knoll2014-10-271-3/+3
| | | | | | | | | | | 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 <simon.hausmann@digia.com>
* Fix QQmlExpression/QQmlScriptString/QQmlBinding crashesSimon Hausmann2014-10-091-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | In the QQmlScriptString we store the binding id and it is an index into the runtimeFunctions array of the compilation unit. However we don't store the compilation unit and instead in QQmlBinding and QQmlExpression try to retrieve it from the cache via the context url (we have the context after all). That turns out to be not a reliable way, as sometimes the URL might slightly differ from the originally compiled cache (qrc:/// turning to qrc:/ maybe). Consequently the type is (unnecessarily) compiled again and unfortunately not _linked_, therefore the runtime functions array is empty. Another option is that when the component was created from a QByteArray, then no entry exists in the cache in the first place. This patch addresses the problem by storing a reference to the compilation unit in the QQmlContextData. That we can safely retrieve and it'll make sure the compilation unit also stays alive. In the process of that the manual reference counting was switched over to QQmlRefCount and QQmlRefPointer for QV4::CompilationUnit. Task-number: QTBUG-41193 Change-Id: I9111f9a3b65618e453954abcd789c039e65a94f7 Reviewed-by: Lars Knoll <lars.knoll@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>
* Fix crash when throwing an exception from within a constructorSimon Hausmann2014-07-311-0/+3
| | | | | | | | We need to check for the exception before doing anything with the returned value. Change-Id: I0086be96b2df2434b95187489d7430ae67f561a1 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change the object allocation schemeSimon Hausmann2014-07-221-3/+3
| | | | | | | | | Instead of allocating the data directly, centralize the object and its ::Data allocation in one place in the memory manager. This is in preparation for additional pointer indirection later. Change-Id: I7880e1e7354b3258b6a8965be378cd09c9467d25 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Convert Execution contexts to new constructor syntaxLars Knoll2014-07-221-28/+28
| | | | | Change-Id: I4bc6a61b7a96139353e20871ff7ff007822c64c3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Convert remaining FunctionObject's to new constructor schemeLars Knoll2014-07-221-44/+4
| | | | | Change-Id: I440d5b128d0ee28566ebfa82c2505a4bd97bba6b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Convert FunctionObject derived classes to new construction schemeLars Knoll2014-07-221-59/+36
| | | | | Change-Id: I0d43a79ed531a9d651bd00866d73113c05d95a09 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Convert regexpsLars Knoll2014-07-221-1/+2
| | | | | Change-Id: I5b62a265a7ce363a16b1e14ae93cadbb1ab0cb5b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Convert delegate model and indexed builtin functionLars Knoll2014-07-221-3/+41
| | | | | Change-Id: Ic7d50aa472d6a1bafadb6641f88b5f89a9b893ad Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Get rid of all uses of ObjectRefLars Knoll2014-07-221-1/+1
| | | | | Change-Id: I705e2362dcda542f56826dadec6b0a6f15848788 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove the less often used Ref classesLars Knoll2014-07-221-1/+1
| | | | | Change-Id: I9ee531c903317a0f324671d98af1f967b684915c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Get rid of StringRefLars Knoll2014-07-221-6/+6
| | | | | | | | 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 ExecutionContext to new storage schemeLars Knoll2014-07-221-54/+54
| | | | | Change-Id: I9fcc13da5360f37cef3149b114ed9263b9b74281 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move MemberData over to new storage layoutLars Knoll2014-07-221-1/+1
| | | | | Change-Id: I971b614d471e49d1be2e9474c985cb93ed7e2117 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Rename Managed::managedData() to d() to be consistentLars Knoll2014-07-221-8/+8
| | | | | | | | No need to differentiate in the name anymore, as the data structures all inherit from each other now. Change-Id: Ia41f50ce4e521f9626d874311ceb57e0e194888b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Convert FunctionObject to new storage schemeLars Knoll2014-07-221-16/+16
| | | | | Change-Id: Ida213b4684c4d7c4c64e75999cbc87987d9894c8 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move ArrayData over to new data layoutLars Knoll2014-07-221-1/+1
| | | | | Change-Id: Ic51f37bea030b196f0fa35ab21e618447edaa25d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Convert the remaining classes in functionobject.hLars Knoll2014-07-221-18/+19
| | | | | Change-Id: I7dbc56ca3952772b99681f95f50129204f9d6c7c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move data of FunctionObject into an inner structLars Knoll2014-07-221-38/+41
| | | | | Change-Id: Ic00b1761565f9f8881b665a3fecca723239e2279 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move object data into internal structureLars Knoll2014-07-221-6/+6
| | | | | Change-Id: I1fcccd535ed356e736468337bd450270cd290044 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move Managed data into it's own subclassLars Knoll2014-07-221-26/+26
| | | | | | | | | 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>
* Get rid of different macros for vtable specializationsLars Knoll2014-07-221-6/+6
| | | | | | | Detect existence of a a vtable entry at compile time. Change-Id: Ieed5d34b063184bc4435b22c6685ac0e3fabf493 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use Members for storing the bound arguments in BoundFunctionLars Knoll2014-07-221-8/+12
| | | | | | | | Cleans up the code, and allows us to remove the destructor for bound function objects. Change-Id: Id32ac69171f7975ec7679d07d25c0eb6b4ca6fb5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Avoid calling destroy() on most objectsLars Knoll2014-07-221-6/+6
| | | | | | | | | The method is now optional, and we can simply avoid calling it if all members an object has are themselves garbage collected. Change-Id: If560fce051908bcc10409ead1a7d8a5bd5fa71d2 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* v4: Remove dead code ScriptFunction constructorHolger Hans Peter Freyther2014-07-201-6/+1
| | | | | | | | | Creating a Scope/ScopedValue will immediately access ExecutionEngine of the ExecutionContext so the null check is not needed here. Move the v4 variable into the scope that is using it. Change-Id: I9189ee9d1a63997119e49c12182dffefadc916f1 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix failing assertion inside MSVC STL in debug buildsSimon Hausmann2014-05-211-2/+2
| | | | | | | | | | | | | | | When using FunctionObject's call() method, we use std::copy to copy the arguments over to the new call context. Unfortunately std::copy has an assertion in there to check that we're not copying out of bounds. What the STL doesn't know is that the Value args[1] array is dynamically allocated and easily expands beyond just one entry. Fall back to copying by hand to work around this issue. Task-number: QTBUG-38195 Change-Id: I6e254b1c893ccf5cad2358179cda1b07b00228e0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Garbage collect member dataLars Knoll2014-04-041-1/+2
| | | | | | | | 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>
* Fix typoSimon Hausmann2014-04-011-2/+2
| | | | | | | creatScriptFunction -> createScriptFunction Change-Id: Icdb9214b1ae067fa2b8693d50cdac0be9fe6d390 Reviewed-by: Michael Brasser <michael.brasser@live.com>
* Optimize construct callsLars Knoll2014-03-271-1/+1
| | | | | | | | Optimize construction of the internalClass for the object being constructed. Change-Id: Id5fc02c291664ec01c3595ae0acbb6895cc5b147 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix CompiledData::CompilationUnit object leakLiang Jian2014-03-131-5/+0
| | | | | | | | Don't ref CompiledData::CompilationUnit in constructor of ScriptFunction since its has been referenced in its base class Change-Id: I9ad2d6e190c2ac11de4ccd63015c81d2dead3971 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix copying of Property'sLars Knoll2014-03-101-3/+3
| | | | | | | | | | Data properties don't contain valid data in the set field if they are being stored in Objects. Thus we should never access that field unless we are dealing with accessor properties. Change-Id: I19dcbaee7ebd042ae24387f92a93571d75ca578a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use an array of Value's for Object::memberDataLars Knoll2014-03-071-5/+4
| | | | | | | | | | 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>
* Better way of retrieving the prototype property for FunctionObjectsLars Knoll2014-03-071-53/+22
| | | | | | | | | Make sure FunctionObjects always have the prototype property at index 0. This way we can speed up the instanceOf operator even more, and at the same time save 16-28 bytes of memory per FunctionObject. Change-Id: I8527bc8f9dc7b04a9db8395b5f05bab47ddc21ce Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove the name member of FunctionObjectLars Knoll2014-03-071-9/+19
| | | | | | | | The data is anyway stored in the name property of the FunctionObject, and is not performance critical. Change-Id: If1784b0ec6f368bc474c246bb9c2c50d5e56b689 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Reduce memory consumption of FunctionObjectLars Knoll2014-03-071-21/+6
| | | | | | | | | Remove varCount and formalParameterCount members in FunctionObject and retrieve them from the CompiledFunction instead. Change-Id: I8a6cdc6d354b0f33da9d67a4c3dbfe8a7cc96176 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove nArguments and name from QV4::FunctionLars Knoll2014-03-031-8/+6
| | | | | | | | Saves 12 bytes per Function Change-Id: I9a495805f9201eb6162a520ff5c2defeb73dc37a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Michael Brasser <michael.brasser@live.com>
* Improve memory usage in QML/V4 engine.Michael Brasser2014-02-281-4/+4
| | | | | | | | | | | | | | * Don't create prototype Object for bindings and signal handlers. It is inaccessible and not required. This saves one Object-sized allocation per binding. * Shrink the size of QQmlContextWrapper by removing the v8 member variable. * Shrink the size of QObjectWrapper by moving the destroy identifier to the engine. Change-Id: I76e84e4c0581e97a19d2e959f814ac84d9c431fa Task-number: QTBUG-37134 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Clean up our internal namespacesLars Knoll2014-02-231-2/+2
| | | | | | | | QQmlJS::MASM -> QV4::JIT QQmlJS::V4IR -> QV4::IR Change-Id: I707e8990459114a699c200fe3c22cec3c8df1afc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Merge remote-tracking branch 'origin/stable' into devSimon Hausmann2014-02-181-7/+12
|\ | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4functionobject.cpp src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h Change-Id: Id164f6c3b45501aa466908659ec4e3b957323753
| * Fix spurious binding loop errors in QtQuick Controls and other placesSimon Hausmann2014-02-161-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 5dc7649f5ad7dca6e13707e827d001c3f118a6ef caused this regression, as a result of lazy binding evaluation and self-referencing objects: import QtQml 2.0 QtObject { property QtObject objectRef : subObject property QtObject blah: QtObject { id: subObject property int value: 42 property int blah: objectRef.value } } When blah is evaluated, we now lazily initialize objectRef - as opposed to previously throwing an exception and then when objectRef gets initialized we re-evaluate blah due to its dependency. So while evaluating "objectRef.value" for blah, we initialize objectRef by evaluating "subObject", and after doing that we write the "objectRef" property. That triggers a change notification, and since the objectRef reference for blah is a compile-time known dependency, the change notification triggers a re-evaluation of "blah", which is the binding loop. What's wrong here is that we register the pre-defined captures before the code execution, when we should register them after the evaluation, or strictly speaking after flushing pending bindings, like it is the case for individual properties in bindings where we could not pre-determine the depenencies. Change-Id: I9fb0c7583cba9d9b71c9ada2791fe87574f6ef44 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Satellite profiler for V4Ulf Hermann2014-02-121-4/+5
| | | | | | | | | | | | | | | | Self-contained profiler for V4. By itself it doesn't have any connections to qqmlprofilerservice. Change-Id: I471a6119e07eab9c5f4712a16835be49c8886d1a Reviewed-by: Kai Koehne <kai.koehne@digia.com>
* | CleanupsLars Knoll2014-01-311-7/+7
| | | | | | | | | | | | | | | | | | | | Remove SafeValue, it was used to port over to an exact GC. Since we now have that, we can now safely merge it with QV4::Value again. Also rename SafeString to StringValue for better naming consistency. Change-Id: I8553d1bec5134c53996f6b0d758738a0ec8a2e4d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Split ManagedVTable into two classesLars Knoll2014-01-211-13/+13
| | | | | | | | | | | | | | | | Keep the basic methods in ManagedVTable, but have the Object related stuff in an ObjectVTable class. Change-Id: I9b068acf3caef813686227b8d935e7df1a7d1a6e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Save memory on array dataLars Knoll2014-01-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Store a simple vector of Values in the array data, instead of a Vector of Property's. This halfes the memory consumption on 64bit and simplifies our code. If an indexed property gets converted to an accessor property, we simply convert the ArrayData into a SparseArrayData. Add support in SparseArrayData to allocate double slots (two Value's) to hold a full Property in case someone sets an accessor on an indexed property. Some methods still return a Property*, but this is safe, as only the first Value in the Property pointer will ever get accessed if the Property doesn't contain an accessor. Change-Id: Ic9b0f309b09a2772a328d947a10faaf3be9fe56f Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Merge remote-tracking branch 'origin/stable' into devSimon Hausmann2014-01-171-3/+0
|\| | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/imports/dialogs/DefaultFileDialog.qml src/imports/widgets/qquickqfiledialog.cpp Change-Id: I00de6dd05cb773f01254061d585a82c90b229acd
| * Fix failing context->next != 0x1 assertionSimon Hausmann2014-01-161-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After commit bf173fe5da381c88343296ca33ef6b06389c6d20 context objects are always on the GC heap and no more in that special linked list or stack allocated, so the next pointer became dangling/uninitialized and asserting on it was bound to fail randomly. Since we no more allocate contexts on the stack, we can safely remove the assertion. Task-number: QTBUG-35917 Change-Id: I104bd129c6c32f46a6302052f563abdf926cb879 Reviewed-by: Albert Astals Cid <albert.astals@canonical.com> Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
* | Cleanup: change signature of Object::insertMember()Lars Knoll2014-01-091-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | Methods returning a Property pointer have to be removed, so that we can move over to store member data requiring only one value for the common case of data properties. This will in the long term reduce memory consumption on 64 bit systems quite a bit. Change-Id: I78de3794ec7b3bc5db13aa57275d3f08fa9d470a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Rework array handling for JS objectsLars Knoll2014-01-091-4/+4
| | | | | | | | | | | | | | | | | | Split up ArrayData into two classes, one for regular arrays, one for sparse arrays and cleanly separate the two cases. Only create array data on demand. Change-Id: I9ca8d0b53592174f213ba0f20caf93e77dba690a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>