summaryrefslogtreecommitdiff
path: root/src/qml/compiler/qv4compiler.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix excessive invalidation of QML disk cachesSimon Hausmann2016-10-181-0/+6
| | | | | | | | | | | | | | | | | | | | | We use an MD5 checksum over the meta-object data to verify that the types a QML file depends on haven't changed since the cache was generated. However when the dependent types are QML types, then the meta-object data contains dynamically generated type names such as QMLTYPE_1234, which is non-deterministic. To address this, we resort to the checksum over the meta-object data only for C++ types (if those change it's likely an incompatible change) and for QML types use the fact that all the information about the QML declared types comes from the QML file only, which means we can in that case simply use a checksum over the QV4::CompiledData memory chunk. In addition we need to ensure that the generated CompiledData memory chunk is deterministic by avoiding any uninitialized bytes (memset) and using a map instead of a hash for the mapping of object index to object id. Task-number: QTBUG-55926 Change-Id: I27c840b1960ad36b486198e504b70989c22a3972 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* QML: Make sure the integer data is aligned on 4-byte boundariesErik Verbruggen2016-08-301-0/+1
| | | | | | | | | The packing for a the compiled data is 1 byte, but integers clearly need 4 byte alignment. This worked before by accident, but broke when a single quint8 was added to the Function. Change-Id: Ia7954423d5a7b4a0e6ef177fc3ee350889f43154 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Make the unit mapping on Windows configurable with regards to executable mappingSimon Hausmann2016-08-171-0/+1
| | | | | | | | | | If we generate byte code, then we can mmap without the executable flags, otherwise we need them. This should make things work out of the box on platforms where special rights are needed before executable mappings are allowed. Change-Id: I24e663f85d661bc51cd3bf2463547b1d1590ea32 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Fix endianness in constant handlingSimon Hausmann2016-08-031-0/+6
| | | | | | | | When running on a big-endian system, we need to convert the constant values into big-endian once and then it's possible to access them directly. Change-Id: I655bad7b7734e3b95e79e5f688f0b4041d0c41c4 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Make generated code loading constants relocatableSimon Hausmann2016-08-021-0/+4
| | | | | | | | | | | | On 32-bit architectures we were encoding the absolute address of generated constants in memory into the load instruction. In order to make the code reloctable, this patch changes the JIT over to use the constant table in the compilation unit. This means two additional loads per constant. On architectures that support instruction pointer relative addressing, we can try to fix this in the future (arm32 for example). Change-Id: I8ed7aa7c67711696d6c46c72b3b642d610ff2cbc Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Add a checksum to the generated QML compilation unitsSimon Hausmann2016-08-021-0/+1
| | | | | Change-Id: Icd5b1d805059981cbbb4c0eb2a5c842d59223839 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Improve robustness of qml disk cachingSimon Hausmann2016-07-231-4/+6
| | | | | | | | Perform various basic checks before proceeding to load an existing cache file, including the qt version, architecture, data structure version and others. Change-Id: Ie822b056e944ac120643aad260e97f62616688bf Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Improve robustness of qml cache expiry checkingSimon Hausmann2016-07-191-0/+1
| | | | | | | | | | | Instead of relying on two time stamps in the file system (source file and cache file), make the determination on whether the source file is newer than the cache solely depend on the time stamp of only the source file. This means that when cache files are stored in archives for example their modification date does not need to be preserved upon extraction. Change-Id: I0b4362663868c6fb9bd7e106028161b2d67274d4 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Simplify CompiledData::Unit serializationSimon Hausmann2016-07-151-59/+79
| | | | | | | | | | | | | | | There are currently two places where we calculate the total size of a CompiledData::Unit including all of its data, once in its calculateSize() function and then when constructing the Unit itself. This is error prone when trying to do changes to the layout, as two places need to be adjusted. Instead we can centralize the populating of the entire CompiledData::Unit header, the calculation of the various offsets as well as the entire size in one shot in a new generateHeader function. Afterwards we can allocate the final amount of memory and copy the remaining bytes across and assemble the final data structure. Change-Id: Ic26d7812e59d2bee2f45cd72742e3195a56950df Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Clean up function offset table generationSimon Hausmann2016-07-151-7/+4
| | | | | | | | We can replace the intermediate hash with a vector of the final little-endian encoded function offsets. Change-Id: If3f970330ab232a672f7c75b4d32f8ef4d246714 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* More endianness fixesSimon Hausmann2016-07-151-6/+8
| | | | | | | | It's necessary to consistently use LEUInt32 when writing the offset tables, as that's also what we're using when reading from them. Change-Id: Idbef310bd6b28a0e6b6b0dff516e0ef178f04999 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Clean up JS internal class serializationSimon Hausmann2016-07-151-31/+24
| | | | | | | | We can serialize the compiled JS class data right when we collect it from the IR. That makes the assembly of the compilation a little simpler later on. Change-Id: I36d7dd2cc74241338fb1c236ce7778405066c8b8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove unused fields in CompiledData::FunctionSimon Hausmann2016-07-141-8/+2
| | | | | | | | The table for referencing the inner functions is not needed. This also allows making the function offsets table a local variable. Change-Id: I3f1a1d6ab8c4f417edeafdc174e5b41d2d2b611b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix endian support in compiled data structuresSimon Hausmann2016-07-141-0/+6
| | | | | | | | | | | | The goal is to make the compiled data structures persistent on disk. In order to make it possible to create these data structures on a "host" system that may have a different endianness than the target system, we now make all the word sized fields little-endian. The template wrappers from QJson provide zero-overhead access for little-endian machines (the vast majority) while maintaining a large degree of source compatibility. Change-Id: I3d30da1fcf3bffb98dbe9337d3a35482fb7b57c8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QML: Store idObjectDependencies in a QVarLengthArray.Erik Verbruggen2016-06-241-2/+4
| | | | | | | | | The number of id objects referenced from a function or binding is often very small. So using a QSet that allocates hash nodes takes more memory, and is actually slower than using an array. Change-Id: Id9fa60a860314790284f66318593b3ef938e6eef Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Added basic support for saving compilation units to diskSimon Hausmann2016-06-171-0/+3
| | | | | | | | | Hidden behind a QML_DISK_CACHE=1 environment variable we will now attempt to save a binary representation of the type compilation for Foo.qml next to it called Foo.qmlc. Change-Id: I27e800b50cdb186669256fd277578ea1f1e70513 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Clean up CompiledData::FunctionSimon Hausmann2016-06-071-3/+2
| | | | | | | | | * We don't need 64 bits for the flags, for now 8 bits are sufficient. * Removed the unused index member. It's symmetric to the index of the function object in the function table anyway. Change-Id: I18248e8ed79b3c3af87e17689dadf7323d5d9bb3 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Save some memoryLars Knoll2016-04-111-1/+0
| | | | | Change-Id: I866eeba45e30fd5e38541b2de4a2fda5549104a9 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* QML: Convert the PropertyDependencyMap to a QVarLengthArray.Erik Verbruggen2016-04-051-4/+2
| | | | | | | This is much more efficient than a QHash. Change-Id: I84752eecb6a456402ae222c4d6543bbb67cbcf63 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Updated license headersJani Heikkinen2016-01-191-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: Ic36f1a0a1436fe6ac6eeca8c2375a79857e9cb12 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Add 28 QList::reserve() callsSérgio Martins2015-06-081-0/+1
| | | | | Change-Id: Id4820ac458f48b10f2bf457144767efdef9e2c07 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Merge remote-tracking branch 'origin/5.5' into devSimon Hausmann2015-06-041-1/+1
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4engine_p.h src/quick/items/qquickitemsmodule.cpp src/quick/items/qquicktext.cpp src/quick/util/qquickpixmapcache.cpp tests/auto/quick/qquickwindow/tst_qquickwindow.cpp Change-Id: I90ecaad6a4bfaa4f36149a7463f4d7141f4a516a
| * Fix uninitialized variables/dataSimon Hausmann2015-04-291-1/+1
| | | | | | | | | | | | | | | | | | | | * Initialize the indexOfRootObject member * When creating the QV4::CompiledData::String objects, don't include the one ushort _beyond_ the QString, which is random data. Change-Id: I8fe8a465e2713a385504f217b367a62b70ee5fdf Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Fix build with QT_STRICT_ITERATORSSérgio Martins2015-05-151-2/+2
| | | | | | | | | | Change-Id: I3df6ac107cb46b3a1b15b80f39d7c6015adcd9ac 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-1/+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>
* 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>
* Cleanup: Simplify CompiledData::Unit structure to always include the string ↵Simon Hausmann2014-09-241-10/+15
| | | | | | | table at the end Change-Id: Iae86b8f4dc0dc67c14974472f627e28d6795369f 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>
* CleanupSimon Hausmann2014-08-151-6/+8
| | | | | | | | | Merge QV4::CompiledData::QmlUnit into QV4::CompiledData::Unit. For pure JS units it means a slight increase of memory usage by a few bytes, but overall it makes the code a lot simpler. Change-Id: Ib48927749720b056f004aac0fe22cb8ec729e3f6 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix crash on host/target word size mismatchesSimon Hausmann2014-05-091-5/+1
| | | | | | | | | | | When compiling on a 64-bit host and using the QV4::CompileData on a 32-bit target, the size of QArrayData is different. Therefore we cannot use it in the QV4::CompiledData and have to resort to storing only the characters in there. We can at least still use fromRawData when extracting strings, but the QStringData will have to be allocated now. Change-Id: Ia9dab1722ed72186451b65ba74457051c6ce3155 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Extend the QML bootstrap library by the IR buildersSimon Hausmann2014-04-231-3/+2
| | | | | | | | | | | | | 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>
* V4 string table cleanupsSimon Hausmann2014-03-281-15/+15
| | | | | | | | | | Move the string table (index and data) to the end of the compilation unit. That makes it easier to extend the string table later with new strings - for example when transitioning from JS data to an entire QML unit - because all the other offsets within the JS data remain the same. Change-Id: Ib28caf943ee2ec74b7acc19c2980de0853bb8086 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Various cleanupsSimon Hausmann2014-03-281-39/+54
| | | | | | | | | | | | | * Encapsulate the string pooling for the V4 data generation into a StringGenerator class. * Move type reference collection into the IR::Document, where it belongs (as it writes into the typeReferences there) * const fixes * Remove unused methods and members * Store unit and qml unit sizes right in the generated data structure. That makes copying easier (like we do when generating the QML data based on the JS fields) Change-Id: I053146ab0b00cc90ac7f72f867415962d1be121b Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Remove unused entries in CompiledDataLars Knoll2014-03-071-4/+2
| | | | | Change-Id: Ie5313371fa5dec6630a1d955d4409ea4d6163810 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Add a Line instruction to the interpreterLars Knoll2014-03-071-22/+0
| | | | | | | | | | This unifies the way we handle line numbers in the JIT and Interpreter. Remove the now unused lineNumberMapping code and data. Change-Id: I1d60b1fbb77e70b531fa73d93410683e84dd1e3c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Clean up object literal handling with integral indicesSimon Hausmann2014-02-241-5/+3
| | | | | | | | | | | | | | | | | | | | | * Object literals with array indices are now created with one run-time call, instead of an initial one for non-integral keys followed by sub-sequent define_builtin_property calls. * Cleaned up propert name retrieval. Instead of using a visitor, it's easier to define a virtual method on the PropertyName type. The visitor doesn't buy us much as it's not possible to recurse within property names, and this way we can use it also from the function scanner to correctly determine the number of arguments needed for object literal initalizations. * Similarly the duplicated/common name member for all property assignments has been moved into PropertyName, for convenient access without AST casts. * Removed now unused builtin_define_property/settergetter functions from IR, run-time and moth. Change-Id: I90d54c81ea5f3f500f4f4a9c14f7caf5135e7f9f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Clean up our internal namespacesLars Knoll2014-02-231-17/+17
| | | | | | | | QQmlJS::MASM -> QV4::JIT QQmlJS::V4IR -> QV4::IR Change-Id: I707e8990459114a699c200fe3c22cec3c8df1afc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* [new compiler] Cleanup empty string handlingSimon Hausmann2014-02-041-0/+2
| | | | | | | | | Ensure that the empty string always has index 0, that simplifies the code in a few places and makes it easier to check for the empty string in other places where there's no access to the string pool itself. Change-Id: Icd204aec478e8350ef3fee75d89bda1f88cffe26 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Implement Lookup::indexedSetterLars Knoll2014-01-311-0/+9
| | | | | | | | | use this instead of the generic runtime method. This gives around 10% speedup for array heavy Javascript such as crypto.js. Change-Id: Ic8f478c5b18893f2ef49e3f658b1ef24ae22e64f Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use lookups for indexed accessesLars Knoll2014-01-201-0/+10
| | | | | | | This speeds up reading array data from objects significantly. Change-Id: I5d17a7b3e7583a16dc76d1ee6cbc1d7134e4c2fa Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Clean up property dependency data structuresSimon Hausmann2013-12-051-64/+27
| | | | | | | | | | | | | | | | As a follow-up to the previous commit, this patch cleans up the data structures used to track dependencies of QML binding expressions and functions to context and scope properties, determined at compile time. Instead of "collecting" these depending properties upfront (codegen time), we propagate the information that a property is a context or scope property into the IR at codegen time and later in the isel collect these properties and their notify signal index in a hash in the IR functions. The CompileData structure generator then can read these hashes directly when writing out the dependency information. Change-Id: I32134706e2d24bf63d1b1abad0259ab072460173 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix property dependency generation for accelerated QML QObject propertiesSimon Hausmann2013-11-121-10/+6
| | | | | | | | | | | | | | 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>
* Simplify & speed up function callingLars Knoll2013-11-091-0/+2
| | | | | | | | | Get rid of the SimpleCallContext, instead simply use the CallContext data structure, but don't initialize the unused variables. Change-Id: I11b311986da180c62c815b516a2c55844156d0ab 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-2/+2
| | | | | Change-Id: Ic0492fbe31a1e134674bc6c20381f735dd6d5b7a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Initial support for resolving meta-property access for the scope and context ↵Simon Hausmann2013-10-311-13/+82
| | | | | | | | | | | | | | | | | objects at QML compile time This avoids having to do a string lookup for ids and in the import cache at run-time, before we can do a string hash lookup in the property cache. Instead we resolve final properties in the context and scope object at compile time and look them up at run-time using their index instead. The dependencies to these properties are also tracked separately and recorded in the compiled data. This is merely the initial patch. There's a lot left to do, such as having specialized getter and setters for specific property types. Setters are missing altogether right now and will fall back to name lookup. Change-Id: If3cb4e7c9454ef4850a615f0935b311c9395b165 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Speed up id object lookupsSimon Hausmann2013-10-291-2/+25
| | | | | | | | | | | | | | | | | We can resolve lookups for objects referenced by id at QML compile time and use a run-time helper to extract the id object out of the QML context data by index instead of name. Dependencies to id objects are also tracked at compile time and registered separately before entering the generated function code. The lookup of id objects is encoded in the IR as special member lookups. Members will also then in the future be used to for property lookups in context and scope properties, as well as any other property lookups in QObjects where we can determine the meta-object. Change-Id: I36cf3ceb11b51a983da6cad5b61c3bf574acc20a Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Add a constant table to the compiled dataLars Knoll2013-10-291-2/+17
| | | | | | | | This will help simplifying and speeding up the moth generated code. Change-Id: I1b87c4b25dbfa6ce2e8a0b77e526f7fc063b0de2 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Qml JavaScript code generation cleanupsSimon Hausmann2013-10-201-0/+1
| | | | | | | | | | | | | | | * Run the binding expressions, functions and signal handlers through the V4 codegen _per_ component, and run the isel at the end for the entire file. We need to do per-component codegen because we want to set up the correct id and object scopes, which are different for the root component and anonymous components. * Changed V4IR::Module to allow for the concept of "qml modules" where there is no root function defined. This is a logical consequence of running v4 codegen multiple times with different input but the same V4IR::Module. Change-Id: Ib3a719f83507cbab7c2e4e145ccad5b663c795cf Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Improve error reportingSimon Hausmann2013-09-121-0/+3
| | | | | | | | Re-enable COMPILE_EXCEPTION calls that were commented out due to missing location information (that this patch also adds). Change-Id: I0d584f474cc7e879350c8aae2869a9603ba415aa Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Beginning of a new qml parserSimon Hausmann2013-09-081-5/+12
| | | | | | | | | | | | | | The goal is to parse QML and JavaScript binding expressions/functions in one go and generate data structures that allow for the parsing to happen in a thread and the instantiation of the object tree in another thread, just reading from the generated data structures. This will replace qqmlcompiler and the VME. This new way of loading QML is currently hidden behind the QML_NEW_COMPILER=1 environment variable. There's lots of work left to fill in the gaps in object construction, Component support, Component.onComplete, error messages, etc. etc. Change-Id: I5e40643cff169f469f0b6ce151584ffee5ca5e90 Reviewed-by: Lars Knoll <lars.knoll@digia.com>