aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
Commit message (Collapse)AuthorAgeFilesLines
* Fix failing context->next != 0x1 assertionSimon Hausmann2014-01-163-10/+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>
* Fix bad cast of virtual class to base class via reinterpret_castThiago Macieira2014-01-101-1/+1
| | | | | | | | | | | | | | | | | | | Clang 3.4 found it: qv4managed_p.h:202:9: error: 'reinterpret_cast' to class 'QQmlDelegateModelGroupChangeArray *' from its base at non-zero offset 'QV4::Managed *' behaves differently from 'static_cast' [-Werror,--Wreinterpret-base-class] QV4::Managed and QV4::Object are non-virtual classes (they have no virtual table). I'm not sure if they are (C++11) standard layout, but they seem to fit the bill. However, QQmlDelegateModelGroupChangeArray has virtual functions, so the QV4::Managed sub-object in that class does not start at offset zero. That means reinterpret_cast'ing the base to the derived class is *wrong*, even if we're just calling a static function. In any case, we're static_cast'ing in the next line anyway, so this can't hurt. Change-Id: Icc796f7ecf8f41f859ea5fc877f5db5c87799964 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [ChangeLog][QtQml] Fix JavaScript Array.pop() not updating the internal ↵Simon Hausmann2014-01-071-1/+1
| | | | | | | | | | | | | array length correctly While the length property was reporting the correct value, the internal array length was out-of-sync. Task-number: QTBUG-35979 Change-Id: I68820a349cf1ce88c6aabc6a2301a8a861018a10 Reviewed-by: Liang Qi <liang.qi@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fixes: qml memory corruption on Androidaavit2013-12-171-0/+10
| | | | | | | | Bionic pthreads reports too small stack size for main thread. Change-Id: I3d33229e76101a847309c723d534844ffb2d2042 Reviewed-by: Andy Nichols <andy.nichols@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Merge remote-tracking branch 'origin/release' into stableFrederik Gladhorn2013-12-121-2/+7
|\ | | | | | | | | | | | | Conflicts: src/qml/qml/qqmlcompiler.cpp Change-Id: I802731139d47c5b733dd805f7bf432d67d7331e1
| * Fix a crash in JSON.parseLars Knoll2013-12-041-2/+7
| | | | | | | | | | | | | | | | | | | | Properly set members that are actually array indices and don't crash when trying to set those. Task-number: QTBUG-35383 Change-Id: I04d4b65c27e97a2e9db19541ed46ee1bb202f780 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* | Fix regression in QML string list concatenationsSimon Hausmann2013-12-111-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | String lists and other QList property types (wrapped as QQmlSequence) should behave like arrays and have the Array prototype. Therefore it should be possible to pass them also as parameter to concat and they get composed correctly, i.e. the individual items get appended instead of the list being appened as one item. In the spec for concat this "special" casing should be applied if the "class internal property" is "Array", and concat appears to be the only place where this check is done. Therefore this patch adds another exception to match the expected behavior in QML and extends the "internal class is Array" meaning to QML list types. This is a regression from Qt <= 5.1.x Task-number: QTBUG-33149 Change-Id: Iab9522ac3c4ae6b746e790a99d87501b1cc1b655 Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Fix data layout of Managed classLars Knoll2013-12-051-4/+4
| | | | | | | | | | | | | | | | The internal class should really be the first member. The flags should go away over time. Change-Id: Id2373a438e2af63a55704819c9dd5569c3895080 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Fix some header guardsLars Knoll2013-12-043-4/+4
| | | | | | | | | | Change-Id: Ib696c79754cc238e3f4fa356c461a07d9f06d6e7 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Encapsulate the current context and fix it's usageLars Knoll2013-12-0428-156/+151
| | | | | | | | | | | | | | | | | | | | | | 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-0419-73/+95
| | | | | | | | | | | | | | | | | | | | 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-0438-226/+281
| | | | | | | | | | | | | | | | 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>
* | Fix a bug in the code for evalLars Knoll2013-12-041-5/+5
| | | | | | | | | | | | | | | | | | When eval was being used as an indirect call, the code didn't reset the current context properly before returning from the eval call. Change-Id: Id5c7e9a897101d25593ef0f3b9945adaf19360b3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Add a static toArrayIndex() method to QV4::StringLars Knoll2013-12-042-3/+11
| | | | | | | | | | | | | | | | This avoids a hack in QV4::Codegen where we created a V4::String on the stack to convert to an array index. Change-Id: I9a88d45817bbcde52a4037a52fbae299b8c9cb1a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Optimize ExecutionContext::setPropertyLars Knoll2013-12-041-3/+12
| | | | | | | | | | | | | | | | | | | | No need to call hasProperty followed by put. Instead get the property descriptor and call putValue for it. Improves v8-bench by 5%. Change-Id: Ied047126c651c033f7ad4c27deaeec08e5fee7f9 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Use an internalClass to represent formals and locals in CallContextsLars Knoll2013-12-047-67/+65
| | | | | | | | | | | | | | | | | | | | formals and locals in a CallContext where so far accessed through a linear search in ExecutionContext::getProperty. Fix this by introducing an internalClass for the Function used by the call context. Change-Id: I1141efa12b19d6de4a354bfd6e769c5ffcb8898b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Remove unused inline wrapperLars Knoll2013-12-044-10/+7
| | | | | | | | | | | | | | | | | | The wrapper method for Function::code() was still there from the times we used C++ exceptions. It's not needed any more, so get rid of it. Change-Id: I2ec25fbca71eeef9d7a94a38b5adfa42e4de3a84 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Speedup JS instanceof operatorLars Knoll2013-12-047-58/+50
| | | | | | | | | | | | | | | | Cache the prototype of the functionobject, and inline hasInstance. This removes a vtbl method and speeds things up quite a bit. Change-Id: Ic68f301f7e09763d445a98bffa2cd201303f902e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Initialize variableLars Knoll2013-12-041-0/+1
| | | | | | | | | | Change-Id: I37b14a406ebb9cf87fef20426a94725a2441b7cd Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Fix JavaScript signal connect on alias without other handlersSimon Hausmann2013-11-291-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | The changed handlers for aliases are connected lazily in the engine. QQmlPropertyPrivate::flushSignal is responsible for that and called in other places, for example when installing a onSomeAliasPropertyChanged handler. However we were missing a call to flushSignal when doing onSomeAliasPropertyChanged.connect(...), i.e. using the JavaScript connect API. Task-number: QTBUG-30493 Change-Id: Ia3f008626fd7af3f2cfbdd30d13fb83158bed4d5 Reviewed-by: Albert Astals Cid <albert.astals@canonical.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Add support for accelerated property access to QML types and namespace supportSimon Hausmann2013-11-285-29/+44
| | | | | | | | | | | | | | | | | | | | | | * Resolve lookups in namespaces at compile time and instruct the SSA optimizer to eliminate reads from the namespace (QQmlTypeWrapper) if possible. For example access to attached properties of types (i.e. MyNameSpace.ListView.isCurrentItem) requires neither reading the namespace nor the type. * Add support for accelerated lookup of attached properties Change-Id: Ib0b66404ed7e70e1d4a46a1ac8218743a4cc8608 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Prospective fix for crashes when sorting JS arrays on WindowsSimon Hausmann2013-11-271-6/+2
| | | | | | | | | | | | | | | | | | | | std::sort doesn't seem to like sorting empty arrays, so check the size before sorting. Task-number: QTBUG-33658 Change-Id: I841259939ea3bf850d23c129744c322ed46a95fe Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* | Merge "Merge branch 'release' of ↵Lars Knoll2013-11-261-1/+8
|\ \ | | | | | | | | | ssh://codereview.qt-project.org/qt/qtdeclarative into stable" into refs/staging/stable
| * | Merge branch 'release' of ssh://codereview.qt-project.org/qt/qtdeclarative ↵Simon Hausmann2013-11-261-1/+8
| |\| | | | | | | | | | | | | | | | into stable Change-Id: I0bf06be69927d5961f1bdb4948c3572ef6111923
| | * V4 Use getrlimit on Darwin to get the stack size for the main threadAndy Nichols2013-11-201-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | Turns out pthread_get_size does not return the correct size when it is called from the main thread, so to workaround you call getrlimit instead Without this change, most QML applications are broken on iOS. Change-Id: I9a61494de26caa3d7be7e46a991e6d6d0514ce17 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | | Fix MSVC-64-warnings about truncation of integers.Friedemann Kleint2013-11-261-3/+4
| | | | | | | | | | | | | | | Change-Id: Ib92ce4b7e42061bb1892957f04cbfc1fcfe43615 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* | | Fix MSVC-64-warning about shift word size.Friedemann Kleint2013-11-261-1/+1
|/ / | | | | | | | | | | | | | | jsruntime\qv4mm.cpp(301) : warning C4334: '<<' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?). Change-Id: I6a4ca024d43776e16a323fdb8c35a339b74e6c09 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* | Initial support for accelerated property access to QML singletons and enumsSimon Hausmann2013-11-253-0/+10
| | | | | | | | | | | | | | | | | | With this patch we determine the meta-object of singletons, propagate it into the IR and load them separately using a dedicated run-time function. In addition enums in singletons and QML types are resolved at compile time. Change-Id: I01ce1288391b476d1c9af669cb2987a44c885703 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | IR Cleanup, resolve ID objects through array subscriptsSimon Hausmann2013-11-253-7/+6
| | | | | | | | | | | | | | | | | | | | | | | | ...instead of a special MEMBER type. This allows removing the type member from V4IR::Member altogether (and thus unshadow from V4IR::Expr::type). By not requiring the base of a id lookup member expression to be a NAME, we can also speed up repeated id lookups by fetching the id object array wrapper only once per function. Change-Id: I3e9b8f498d32ace4a0cc2254f49e02ecc124f79c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Improve type interference for QObject propertiesSimon Hausmann2013-11-252-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Propagate QObject properties in member expressions across temporaries as part of the type interference SSA pass. This replaces the earlier attempt to resolving QObject properties in fieldMemberExpression() in the codegen, but it was incomplete and now things like the following are fully resolved: var tmp = blah.somePropertyThatReturnsAQQuickItem; <-- QQuickItem property return type propagated into tmp var width = tmp.width; <-- and picked up here again to resolve the index of width instead of by name With this patch Temp gets a helper structure with a function pointer, initialized to aid the resolution of properties in Qt meta objects. This structure is propagated into the temps until it reaches the next member expression that uses the temp. Similarly QObjectType is added as IR type, next to VarType. The resolution inside the SSA type interference pass also requires passing through the QQmlEngine from the upper caller levels, in order to resolve the property type to a potential QMetaObject property. Change-Id: I14c98fa455db57603da46613ce49c174d0944291 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Saner and simpler way to handle line numbers for JITed codeLars Knoll2013-11-222-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | Instead of storing the current instruction pointer in the ExecutionContext, we might as well directly store the current line number there. Leads to simpler code, works cross platform and should also be faster. Change-Id: Ifb7897cf8dbe8a962505fe876aa3ed43283ebb06 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Turn execution contexts into Managed objectsLars Knoll2013-11-229-62/+85
| | | | | | | | | | | | | | | | | | | | This finally gives proper memory management for ExecutionContexts. So far they had been garbage collected but where still allocated using standard malloc/free(). This allows us to collect the contexts faster and speed up context creation. Change-Id: I02e642391d55eaa59ab3f4c2720a2ac71259caf4 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Add support for large items to the memory managerLars Knoll2013-11-221-2/+39
| | | | | | | | | | | | | | | | This is required, so we can track ExecutionContexts through the regular memory manager. Change-Id: I1bd2e2ef275e6e9e1f364a35affbb991f4377b05 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Speed up arguments objectLars Knoll2013-11-226-23/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't fully create the arguments object unless required. In the 95% use case, we can avoid creating any array based data structures for the arguments object and directly manipulate the functions arguments. only create the full data structure for the other 5%. Speeds up the raytrace test by 50%, gives around 10% overall on v8-bench. Change-Id: If727d28b96585e83314f544031a6c3ca1817ea19 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Use lookups for create_property (ie. new foo.bar)Lars Knoll2013-11-223-5/+27
|/ | | | | | | | This is not used that often, but it removes one more place where we do lookups by name. Change-Id: I9f798b8b4a64be3fdf3e53090e4288724c9d2b22 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* V4: fix Array.indexOf() for QStringListLiang Qi2013-11-201-1/+1
| | | | | | | | | Autotest is included. Task-number: QTBUG-33542 Change-Id: I46c3a81006019c6613a3d35aa018217f85a15d0b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Liang Qi <liang.qi@digia.com>
* Greatly reduce memory consumed by QQmlEngine instancesLars Knoll2013-11-193-29/+112
| | | | | | | | | | | | | | | | 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>
* Fix compilation on QNXFabian Bumberger2013-11-191-1/+1
| | | | | | | pthread_getattr_np is not available there, so we use the default implementation (1MB stack limit) for now. Change-Id: Ia1f3cbbcd846998b688541c0b576ef42f22ac8b6 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix compiler warnings with mingw64.Erik Verbruggen2013-11-182-27/+29
| | | | | | | Task-number: QTBUG-34152 Change-Id: Ibb93d1cac8c343a7ca34ce7d010f24fc56ba89df Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix small bug in array sortingLars Knoll2013-11-181-3/+3
| | | | | | | Task-number: QTBUG-34321 Change-Id: I33089499f730bce16a9dfdda04cc8402602bc5fa Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Make comparison of singletons and qobjects workAlbert Astals Cid2013-11-182-0/+12
| | | | | | | | | | | Otherwise you can end up with some weird situation in which you have two objects, you print them and then you print the comparison and get a Foo(0x858480) b Foo(0x858480) a == b false Task-number: QTBUG-34651 Change-Id: Id2444d919f039be085eb5ed9112345db691540a5 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix interaction between head room and appending in arraysLars Knoll2013-11-183-7/+7
| | | | | | | | | | We reserve space on both ends of the JS array for appending and prepending. Make sure they interact well with each other and don't cause any memory corruption. Task-number: QTBUG-34853 Change-Id: I184280178690e3cb12ab9b199a8436b32383af38 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Limit the amount of memory we allocate on the stackLars Knoll2013-11-186-3/+93
| | | | | | | | | | | | | | | | | | | Setup limits for both the C and the JS stack, and check them before entering functions. If we run out of space, throw a RangeError exception. Be careful and recheck the stack bounds when things go outside. This catches the case where the engine got moved to another thread changing the stack boundaries. Windows currently uses an unsafe fallback implementation, this needs to be fixed later on. Task-number: QTBUG-34568 Change-Id: I22fbcbec57b28f9cc8a49e12f1cc6e53e4f07888 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
* Fix === operator for value typesLars Knoll2013-11-152-3/+6
| | | | | | | | | Fix === comparison for urls and other QML value types. Task-number: QTBUG-33546 Change-Id: I4a7066e6bbc7de7c599fe2c7b2fdfb75e0ff5196 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Don't crash when trying to assign to null.propLars Knoll2013-11-151-0/+2
| | | | | | | | | | Fixes a regression introduced during the exception handling refactoring. Task-number: QTBUG-34544 Change-Id: Ib751274d759030db3e5d3b1380b30dc07ec85f83 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* V4 debugging: fix step-over and step-out.Erik Verbruggen2013-11-144-37/+54
| | | | | | | | | | | | | | | | - step-out: only stop if we’re leaving the context for the function we previously stopped at, so intermediate calls between the current position and the end do not stop the engine - step-over: set breakpoints on all lines in current function and continue to run. When hitting a breakpoint, see if we are in the same context, because recursive calls might happen. Breakpoints on all lines are needed, because the (pure) next line might be jumped over (like when doing step-over a single-line then clause, where the next line might be in the else clause). Change-Id: Idf35dc740ca64fae5079162162906490a96af2a7 Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com>
* Allow passing qmlRegisterSingletonType QObjects to C++ as QObject*Albert Astals Cid2013-11-141-0/+7
| | | | | | | | | | | | | At the moment you can pass them as their FinalType* or as one of their ParentType* but not as QObject* which does not make much sense to me Task-number: QTBUG-34617 Task-number: QTBUG-30730 Change-Id: Id5cfb7bbb123456ef43f44f33b450f8966a7641a Reviewed-by: Alan Alpert <aalpert@blackberry.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix native compilation on linux/arm with gcc 4.7.2Erik Verbruggen2013-11-131-1/+1
| | | | | | | | | | | /disk/qt5-dev/qtdeclarative/src/qml/jsruntime/qv4function.cpp: In instantiation of ‘int QV4::LineNumberMappingHelper<field, SearchType>::lowerBound(int, int, SearchType) [with int field = 0; SearchType = int]’: /disk/qt5-dev/qtdeclarative/src/qml/jsruntime/qv4function.cpp:142:49: required from here /disk/qt5-dev/qtdeclarative/src/qml/jsruntime/qv4function.cpp:106:13: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] cc1plus: all warnings being treated as errors Change-Id: Ic97d6a2a9acd392d565e9c66f30159552473e092 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix property dependency generation for accelerated QML QObject propertiesSimon Hausmann2013-11-125-15/+17
| | | | | | | | | | | | | | The previous approach of collecting the dependencies through an IR visitor doesn't work, because it relies on a fixed structure - for example MEMBER(NAME, prop) - which we can't guarantee (it's usually MEMBER(TEMP, prop)). But it turns out that we can only pre-calculate dependencies for context, scope or id properties, so we can do that right away in the QML specific JS codegen, store that information in the IR function and use it from there in the data structure generator as well as in the isel as a parameter to getQObjectProperty to tell the run-time whether capture is required or not. Change-Id: I33711c3420d6534c653c2a6a4284f0fc12e941cf Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix Object::getArrayHeadRoom()Lars Knoll2013-11-121-0/+1
| | | | | | | | | | The method didn't adjust the size of the allocated array properly, leading to crashes when being called repeatedly. Task-number: QTBUG-34723 Change-Id: Ib58e7dcab6d0f5f46f3cf342eb541c1cc6b6cdc6 Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>