aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
Commit message (Collapse)AuthorAgeFilesLines
* Android: Fix crash in String.replace() in release buildsv5.3.0-rc1Eskil Abrahamsen Blomfeldt2014-05-051-4/+7
| | | | | | | | | | | | | | | | | When enabling optimizations in the compiler, it produces bogus code for the regExp->value deref in the line nMatchOffsets += regExp->value->captureCount() * 2 This is a random refactoring to work around the compiler bug. The only line that actually needs to be touched is the one mentioned above, but I replaced all uses of regExp->value so that it wouldn't look too weird. Task-number: QTBUG-38692 Change-Id: Ib33a523a86ce51ebc6c7095a803fedaebcaa8e63 Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* v4: ignore quiet bit for NaNs in 32 bit value encodingFawzi Mohamed2014-04-301-10/+11
| | | | | | | | | | | on iOS x % 0 generates a NaN with the silent bit set, i.e. 0x7ffc_0000_0000_0000 which was interpreted as a null managed object which crashed the interpreter. Task-number: QTBUG-36859 Change-Id: Idf31ad9f0454f83d321b49b2f76bdbc2ee906189 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* v4: assert when an unsupported double value is stored in a valueFawzi Mohamed2014-04-301-2/+2
| | | | | | | | | | | | | | | | | we assume that just few NaN values can be generated by the HW (currently 0x7ff800..00 and 0x7ffc00..00), and we use the other values to encode js values. If uninitialized memory is interpreted as double or another NaN is explicitly constructed and feed to the interpreter, it might crash (later when actually accessing that value). Adding an assertion to catch those values when assertions are active for the 32 bit encoding (64 bit already has it). Task-number: QTBUG-36859 Change-Id: I7ac7b2619f286ba19066729836af718014a515a6 Reviewed-by: Johannes Matokic <johannes.matokic@microchip.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix marking of prototype objects in internal class poolSimon Hausmann2014-04-284-17/+34
| | | | | | | | | | 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>
* Extend the QML bootstrap library by the IR buildersSimon Hausmann2014-04-2312-39/+154
| | | | | | | | | | | | | This is among other things needed to fix the qml import scanner to detect dependencies from .js files correctly. The patch also fixes the use of Q_QML_EXPORT towards Q_QML_PRIVATE_EXPORT where appropriate and corrects the wrong include path for the double conversion code to actually be relative to the file it is included from. This worked by accident because of other include paths present in the build. Change-Id: I338583dad2f76300819af8ab0dae8e5724c84430 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Refine fix for dynamic properties on QObjects wrapped in JavaScriptSimon Hausmann2014-04-171-1/+1
| | | | | | | | | | | | | | This is an ammendment to commit 60730cbb5e5475b5db6a15641211aa6958a93197 to further restrict the ability to set dynamic properties on JS wrapped QObjects only on those that are associated with a qml context. Only one such association comes with the static property lookup rules of QML and therefore only those should be prohibited from dynamic properties. The previous implementation on using the "compiledData" field to detect QML association or not is not strong and reliable enough. Change-Id: I10c0e6e58a2727c01a6cb56fdf912bf250333e1f Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Reduce memory pressure on JS stack when garbage collectingSimon Hausmann2014-04-091-3/+8
| | | | | | | | | | | | As the identifier table grows with long running programs, we may end up allocating more identifiers than we have space left on the JS stack for them alongside all the other objects in the environment. To mitigate this, we can simply treat the identifiers as roots, mark them manually and only end up putting sub-strings onto the JS stack if necessary. Task-number: QTBUG-36183 Change-Id: Ie6994555305c84b007860792d066a8df60089847 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix unreliable behavior of array methods on qml list propertiesSimon Hausmann2014-04-091-0/+2
| | | | | | | | | | | Array methods such as forEach rely on the hasProperty boolean of getIndexed to be set appropriately. Some getIndexed implementation - such as the QQmlListProperty one - didn't initialize it correctly and therefore the behavior was undefined. Task-number: QTBUG-38088 Change-Id: I34bc3136d8cc2bc280397d0c4d5051e7d72269e8 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Add support for dynamic properties for QObjects in JavaScriptSimon Hausmann2014-04-091-3/+10
| | | | | | | | | | | | | | | | | In QtScript you could add properties to a JS object that wraps a QObject. Depending on the wrap option the property was either stored on the JavaScript side or as dynamic QObject property. In QJSEngine/QJSValue, neither was supported - properties could not be added. For QObjects wrapped in JavaScript that weren't created by QML, we can restore the behavior of storing dynamically added properties as JavaScript properties. This makes porting from QtScript to QJS* much easier. Task-number: QTBUG-37408 Change-Id: I5ef1f379c08c3d84de9bdcac9b6a9397238064de Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> 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>
* Make the destroy method optionalLars Knoll2014-04-041-4/+5
| | | | | | | | | | | | This allows us to avoid calling a destructor on objects that don't require one. After the memberData change this should be most objects. Also fix a bug where we didn't call the destroy() method on large objects, potentially leaking memory. Change-Id: I1708055d568d85b0a3876899d35e8c3eb92dd222 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Garbage collect member dataLars Knoll2014-04-0412-43/+207
| | | | | | | | 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 'missing header' compilation error (shadow build)Kai Koehne2014-04-031-1/+1
| | | | | | | | Change the private header path to the canonical one. This fixes shadow builds for me on Windows. Change-Id: I7c18ec2d9f0769a51d296deac16c78ae41894c36 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Avoid recompiling of signal handlers defined in QtQuick state changes and ↵Simon Hausmann2014-04-022-2/+25
| | | | | | | | | | Connection objects We can re-use the expression we've compiled at QML type compilation time, as long as we "inject" the signal parameters in the dynamic qml lookup chain. Change-Id: Icc417531c41dea06ff5d033011179af49b03f542 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix compilation of script stringsSimon Hausmann2014-04-022-3/+19
| | | | | | | | | | | | | | | | | | | | | | | | | The right hand side of script string properties can be evaluated in entirely dynamic scopes, due to QQmlExpressions' public API of allowing construction from a QQmlScriptString and a variable scope/context. Nevertheless we should compile these bindings at type compile time, as long as we make sure that the compiled code doesn't try to do any compile time determined property lookups and type resolution. This is implemented using a separate compilation pass that ensures the disableAcceleratedLookups flag is set. A few minor cleanups come with this patch: * Ensure that the property caches array is always symmetric to the list of compiled QML objects, as that allows the use of at() instead of value(). * The code for creating a QML callable function object for a given run-time function is now centralized in a static function QmlBindingWrapper, used for script strings and bindings from custom parsers. The provided unit test verifies the successful execution of the same script string with two different scope objects. Change-Id: Ica2cea46dd9e47263b4d494d922d3cc9664b08ae Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Move inline function Bool Runtime::compareEqual() above usage.Friedemann Kleint2014-04-011-19/+19
| | | | | | | | | | Fix MinGW-warnings: src/qml/jsruntime/qv4runtime_p.h:496:13: warning: 'static QV4::Bool QV4::Runtime::compareEqual(QV4::ValueRef, QV4::ValueRef)' redeclared without dllimport attribute after being referenced with dll linkage Change-Id: Ieb212ed6aba2a0deeeddd033126ae7e9737bb38e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Making the CHUNKSIZE setable via environment variableKarim Pinter2014-04-011-4/+8
| | | | | | | | | With this modification the CHUNKSIZE is setable by QV4_MM_MAX_CHUNK_SIZE environment variable so the memory usage which is important for embedded devices can be finetuned. Change-Id: I3cd75158f2255651edd341873de035c1222e3c92 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix typoSimon Hausmann2014-04-014-5/+5
| | | | | | | creatScriptFunction -> createScriptFunction Change-Id: Icdb9214b1ae067fa2b8693d50cdac0be9fe6d390 Reviewed-by: Michael Brasser <michael.brasser@live.com>
* Fix crash in sparse array handlingSimon Hausmann2014-03-281-12/+13
| | | | | | | | | | | | When re-allocating the sparse array data, make sure to initialize the free list correctly. Previously this was only done for the first allocation. Test cases uses an object literal, as that's a reliable way to ensure a sparse array is created. Task-number: QTBUG-37892 Change-Id: Ib38cfce50104904af0c980f022c9dbb7461ae5f8 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix interpreter math routines.Erik Verbruggen2014-03-281-6/+9
| | | | | | | | | | | | | | | | This: qint64 result = a + b; is not equal to: qint64 result = static_cast<qint64>(a) + b; So checking if the former will overflow, and then doing the "double case", will get thrown out by an optimizing compiler. While we're in the area, optimize the X86 case a bit too. Change-Id: Idfb69b16dbaaa0ae9f013a430ff060ca789526ba Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix double deletionSimon Hausmann2014-03-281-1/+1
| | | | | | | | | | | | | | Small regression from commit 7ae796cb141b73a1b215b2b0fd64b7ffbbd1e510. Processing the deletables might result in the onDestruction emission, which in turn may end up in GC allocation and thus GC runs. That in turn may result in m_deletables processing, which at this point is nested then. For that to work we need to set m_deletables back to zero _before_ beginning with the iteration. Fixes tst_qqmlecmascript with aggressive gc. Change-Id: Ibb310b30cd496644557f4c1bb23318b18ee8f36c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix QtSharedPointer::ExternalRefCountData object leak in v4 engineLiang Jian2014-03-281-4/+5
| | | | | | | | | | | | Always call ~QObjectWrapper() to the wrapper object in QObjectWrapper::destroy(), otherwise the m_object member of QObjectWrapper may still hold a QtSharedPointer::ExternalRefCountData object which will never been deleted. I don't know why this will not cause leak in the past, but it seems that the leak was introduced in 7ae796cb141b73a1b215b2b0fd64b7ffbbd1e510 Change-Id: I24b49bb11f95b7e3060c7adba1ab80b615da2942 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Be a bit more conservative with allocating memoryLars Knoll2014-03-271-2/+2
| | | | | | | | | | Cap the max chunk size at 2MB. This value still still doesn't affect the v8 benchmark noticably, but should avoid extreme memory usage in some corner cases Task-number: QTBUG-37134 Change-Id: If2050374c4a7df7ff74194d64880e2d660ea26fd Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove the scribble option from the memory managerLars Knoll2014-03-271-7/+0
| | | | | | | | This option doesn't make sense anymore, as we memset the object to 0 on destruction anyway. Change-Id: Ie40563394f9cacda1b35fde114c9a6043f53d460 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Get rid of collectDeletablesLars Knoll2014-03-276-45/+24
| | | | | | | | | The method is only required for the QObjectWrapper, but there we can instead simply register the deletable in the destroy method. Change-Id: I944319d327859cce33ac31a174e8d56fc4babfc1 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Optimize ExecutionContext::setPropertyLars Knoll2014-03-271-1/+7
| | | | | | | | | Optimize the code in case the setProperty call tries to set something in the activation. Avoid resolving the property index twice. Change-Id: I60a4535adc014f7118bc3ab6773e10ed688ca0d6 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Don't use scopes in the instanceOf operatorLars Knoll2014-03-271-9/+9
| | | | | | | | | There's no need to use scopes here, as instanceof can't trigger any calls into the memorymanager. This slightly speeds up the code. Change-Id: Ie7f5c8f3982df1e24d21cfc4e0841d479a75c664 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Optimize construct callsLars Knoll2014-03-273-1/+3
| | | | | | | | Optimize construction of the internalClass for the object being constructed. Change-Id: Id5fc02c291664ec01c3595ae0acbb6895cc5b147 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Call tzset() from getLocalTZA() so we learn about tz changesIain Lane2014-03-271-0/+1
| | | | | | | | | | | | | | Per POSIX, localtime_r isn't required to call tzset(). This means that we don't notice that the timezone has changed when calling Date.timeZoneUpdated() from JS. Call this in getLocalTZA() so that it always returns results pertaining to the selected timezone. Task-number: QTBUG-37683 Change-Id: Ia9098ef0100b7c909a82b125a5ea4f39fba1f306 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Don't create prototype objects for bindingsLars Knoll2014-03-251-2/+2
| | | | | | | They are neither used not accessible from QML. Change-Id: I14fa6059b8e64cb2c3b9d025061548009a473f96 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Optional reporting of GC statistics to stdoutLars Knoll2014-03-252-13/+46
| | | | | | | | Use QV4_MM_STATS to get some statistics about each GC run written to stderr. Change-Id: Idc30c06e1c3ca8353a2f16615cb26df13a8f23ed Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove unused methodLars Knoll2014-03-252-13/+4
| | | | | Change-Id: Ia7df68e78ac105fe5519cb4f80a64561310d3324 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove code for conservative GCLars Knoll2014-03-252-187/+0
| | | | | | | | | | This was meant as a debugging help after we took the exact GC into use. Turns out it doesn't help debug any issues, aggressive garbage collection is much more helpful in finding GC issues. Change-Id: Idfff26d3a4a15e570615009c1e57921bca6297ca Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Correctly parse unicode escape sequences between 0 and u001fLars Knoll2014-03-251-2/+0
| | | | | | | | | The old code rejected these escape sequences because of a slight misreading of the spec. Task-number: QTBUG-36968 Change-Id: I56a0e76295d1903b4798719de028bd21ad5be719 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Small fixesLars Knoll2014-03-251-4/+5
| | | | | | | | | Don't cast from ushort to uchar and back, and remove a condition that's always true. Allocate some more memory for matching. Change-Id: I8167b6e4b4989365ca0ea8e17f4bdb15c0d8e27d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix infinite loop in method overload resolutionSimon Hausmann2014-03-241-0/+5
| | | | | | | | | | When resolving overloaded slots in a situation without property cache, then we need to detect that we've reached the end of the overload lists and exit from RelatedMethod with zero. Task-number: QTBUG-37157 Change-Id: Ifaab8cc1b377725c99c1bb89bb9bb74d5a0af1b8 Reviewed-by: Michael Brasser <michael.brasser@live.com>
* Don't crash on Runtime::getQmlImportedScriptsAlbert Astals Cid2014-03-241-0/+4
| | | | | | | Task-number: QTBUG-37303 Change-Id: I083ca0cc3223fe0dbf1c768ad43a0d4927579867 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Cleanup: Remove last traces of QQmlScriptSimon Hausmann2014-03-191-2/+2
| | | | | | | | | | What remains is the code for removing .pragma from script source code (and replacing it with white-space to preserve line/column numbers). The previous code even returned the value of the pragmas, but for the remaining caller sites that value isn't used, so we can just return void. Change-Id: I16db15da236970660b817d6c4493005365a7a1af Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Clean up script importsSimon Hausmann2014-03-192-8/+5
| | | | | | | | | | Move the .pragma and .import script extraction out of qqmlscript and into qqmlirbuilder, where it can populate a QQmlIR::Document. Changed the script part of the type loader to use that, which also allowed eliminating the m_source member and m_metaData. Change-Id: Icc64d219fff5666679a02e6afda73f7edfca132b Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Use Q_ASSERT instead of assertLars Knoll2014-03-193-11/+8
| | | | | Change-Id: I6185b59a7dfd6977ce82581ab4385e07d78f13f6 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fixes to for...in statementLars Knoll2014-03-191-1/+1
| | | | | | | | | | | Properly convert the argument to an object if it's not null or undefined as mandated by the standard. Add a similar test case for the with statement. Change-Id: Idd8e245e8dae4803eb0e2010e3d43bb912670444 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Optimize construction of SimpleArrayDataLars Knoll2014-03-193-2/+5
| | | | | Change-Id: I7f8a0ac8a368af23534378e8c31d820b3b9f1f4c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Small optimization to RegExpLars Knoll2014-03-183-1/+14
| | | | | | | | | Also add markObjects() calls to all the identifiers we keep around in the engine. It's probably pure luck this hasn't caused any issues until now. Change-Id: Ie31d19793efa53867e4e240ba548070dcde32ec1 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Add some specialized lookups for two internal classesLars Knoll2014-03-183-28/+187
| | | | | | | | | | | | Some methods are being called with two different types of objects, alternating between them. This adds a specialized lookup for that case. Speeds up the splay test by ~20%. Also create a clean path to a fallback lookup instead of going back to the generic lookup and then alternating. Change-Id: I3082d70d27155ef5f2cf2b680d227c6dd389956d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Minor optimization: Avoid some QString constructorsLars Knoll2014-03-181-1/+1
| | | | | | Change-Id: I51af67e9ba4076216142e05b5de5b2e8f8c526bc Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix crash when calling concat on an empty arraySimon Hausmann2014-03-151-0/+2
| | | | | | | | | Make sure to create the array data. The earlier called copyArrayData() doesn't have to do that. Task-number: QTBUG-37506 Change-Id: I6671769fcd471234c4c2eaa1614aa61266db0e5c Reviewed-by: Lars Knoll <lars.knoll@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>
* Allow maximum block size to be specified as an environment variable.Michael Brasser2014-03-131-3/+11
| | | | | | | | A smaller maximum block size helps limit RAM usage on constrained systems, at the cost of more frequent garbage collection. Change-Id: Iba07d9cc628e3178dfaad35664c631844540bc9d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Don't crash when a signal/slot connection outlives the engineSimon Hausmann2014-03-121-2/+7
| | | | | | | | | | In the test case in the bug, the signal was emitted from the QApplication destructor (somewhere from the qpa plugin when the platform windows were destroyed) Task-number: QTBUG-37351 Change-Id: Ieec59e12be10bab1428743b80eecdf22ef9d8bf6 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Remove redundant QQmlBinding members.Michael Brasser2014-03-111-3/+4
| | | | | | | | | This reduces the size of QQmlBinding by 12 bytes. Task-number: QTBUG-37134 Change-Id: Id55257edec8cee88d863374e8a96d7eebbeaf523 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Michael Brasser <michael.brasser@live.com>