summaryrefslogtreecommitdiff
path: root/src/qml/compiler/qv4compileddata.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Clean up type dependency hashing for QML cachingSimon Hausmann2017-03-131-4/+3
| | | | | | | | | | | | | | Instead of passing the engine parameter all the way through the data structure generator, along with the dependent type data structure that is unused otherwise, let's simply provide a function object for the dependency hashing. This is also in preparation for adding singleton types to the dependency hash. Task-number: QTBUG-58486 Change-Id: I5bb5e5c06b7b5c77195cec3da13141333cfea7a8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix build without features.temporaryfileTasuku Suzuki2017-01-271-0/+5
| | | | | Change-Id: I31bcf56ee0c4ec9285dccb356b03b89e8ce8356a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix QML cache not being invalidated when source path changesSimon Hausmann2017-01-021-0/+5
| | | | | | | | | | | | When somebody renames the directory name underneath a QML file and its cache file, then we need to re-generate the cache as it contains the fully path of the source path. That is sometimes used to resolve relative URLs (such as images) and therefore needs updating (by re-creating the cache). Task-number: QTBUG-57644 Change-Id: I9766668859aad8e9d71f278c3f26c0585258c14e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Get rid of most QT_NO_FOO usagesLars Knoll2016-11-291-1/+1
| | | | | | | | Instead use QT_CONFIG(foo). This change actually detected a few mis-spelled macros and invalid usages. Change-Id: I06ac327098dd1a458e6bc379d637b8e2dac52f85 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix handling of qrc:/// urls with disk cachingSimon Hausmann2016-11-231-1/+1
| | | | | | | | | | | | Use the right function for converting a qrc:/// url to a local path. QUrl::toLocalFile() gives us an empty path, which prevents us from getting a time stamp and comparing it against the stamp in the cache file. This fixes disk caching with samegame. Change-Id: Id3eb270f1f7a7f25143d2f075a45f32bdb0384c5 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix bootstrap and qtquick compiler buildSimon Hausmann2016-10-211-2/+6
| | | | | | | | We need to always include the checksum generating code, even if dummy (for the lack of the md5 code being in the bootstrap library). Change-Id: I3dd9c585a23ffea9bd7c79dbe6dae29b9f93fa6d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Improve QML development experienceSimon Hausmann2016-10-181-0/+41
| | | | | | | | | | | | | | | With the cache files it is tricky to do changes to the code generator and it is easy to forget that the cache files need to be re-generated. So facilitate this, we add the sha1 checksum of the QtQml library to the checksum embedded in the cache files. This is currently only implemented on Unixy platforms and it is limited to developer builds with shared libraries. This is not intended for release builds. Change-Id: If59f31f700254f7e9c6e3384d2fae4e5396fb698 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix excessive invalidation of QML disk cachesSimon Hausmann2016-10-181-4/+26
| | | | | | | | | | | | | | | | | | | | | 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>
* Enable disk cache for files coming from resourcesSimon Hausmann2016-08-121-6/+20
| | | | | | | | By storing the cached data in QStandardPaths::CacheDir + "/qmlcache/" + sha1(filename) Change-Id: I6a8b4ca701019204fff362504697c3dac9f54bf1 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Separate header verification and mmap handling of CompiledData::UnitSimon Hausmann2016-08-091-45/+5
| | | | | | | | ...into a separate class. This will make it easier to specialize the handling for Posix and Windows platforms. Change-Id: I995538fa8239eac8586c96812086e50b4c19257f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Use on-disk compilation unit if availableSimon Hausmann2016-08-041-0/+2
| | | | | | | | | | | If we succeeded in saving the compilation unit to disk, then attempt to use it right away. This replaces the C++ heap usage for the compilation unit data as well as the anonymous allocated executable memory with file-backed mmap'ed memory. That means the memory can be discarded when overall availability is low and paged in on-demand. Change-Id: Ide1b1e11752d861eb049a99a26ca12cec5e2502e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix interaction of files selectors with disk cachingSimon Hausmann2016-08-041-2/+1
| | | | | | | | Make sure to save the .qmlc/.jsc files to the location determined by the file selectors. Change-Id: If535bb1e4f0d20ac692b3d8e6d563f77cd00446b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Safeguard disk cache loading with checksum verificationSimon Hausmann2016-08-041-0/+19
| | | | | | | | | | | | | | | When loading a QML component from the disk cache, compare the checksum of the dependent types against the checksum when the cache was created. Any change in the meta-object of a dependent type should trigger a re-creation discard of the cache and consequent re-creation (in the test-case). Unfortunately this also requires extending the existing hack in the unit test to deal with the low second precision on HFS+ in order to pass the tests. Change-Id: Ib8e899347680f7be676788388e9c23a09b0277e3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix build on QNX/Windows/MinGWSimon Hausmann2016-08-031-0/+1
| | | | | | | | Oddly the include order is different and we need to include the header for the class we use. Change-Id: If8a7485b8b728b1d3565023f37234912a0e0feea Reviewed-by: Liang Qi <liang.qi@qt.io>
* Fix endianness in constant handlingSimon Hausmann2016-08-031-0/+13
| | | | | | | | 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>
* Don't save compilation units to disk that don't orignate from filesSimon Hausmann2016-08-021-0/+5
| | | | | | | | It's asking for trouble and we have no way of verifying that the source changed. Change-Id: I2ae2e975ef52142b8a6821b23f99ab3517ae3d49 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add a checksum to the generated QML compilation unitsSimon Hausmann2016-08-021-0/+13
| | | | | Change-Id: Icd5b1d805059981cbbb4c0eb2a5c842d59223839 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Cleanup: Move ResolvedTypeReference(Map) one scope upSimon Hausmann2016-08-011-3/+3
| | | | | | | | The class is a candidate for further functionality, it doesn't have to be nested in CompilationUnit. Change-Id: I100553160f5ae34f66b9f8ff5df9f636da2ffb67 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Improve robustness of qml disk cachingSimon Hausmann2016-07-231-5/+50
| | | | | | | | 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>
* V4 CompilationUnit: missing #include for date-time comparisonEdward Welbourne2016-07-211-0/+1
| | | | | | | | MinGW's cc got upset at a QDateTime comparison when it only had a forward declaration of the type. Change-Id: I0404248cbdfc35610d8465294534bd5201dcf2a2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Improve robustness of qml cache expiry checkingSimon Hausmann2016-07-191-8/+9
| | | | | | | | | | | 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>
* Added basic loading of compilation units from diskSimon Hausmann2016-07-191-0/+47
| | | | | | | | This remains hidden behind the QML_DISK_CACHE flag until all backends support it and the verification code is in place. Change-Id: Ic77c64e20a2dc4c43473c47640e09f8070237e85 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix endian support in compiled data structuresSimon Hausmann2016-07-141-3/+3
| | | | | | | | | | | | 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>
* Fix crash in qmljsSimon Hausmann2016-07-131-2/+2
| | | | | | | When running in pure JS mode, we may not have a QQmlEngine. Change-Id: Ibb6e9087312b13cca53cb672a8f5372764cdf515 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move type compilation independent bits out of QQmlTypeCompilerSimon Hausmann2016-06-201-1/+16
| | | | | | | | | | The type validation is something that works on the final compilation unit, so it can be done separately. The same applies to the composite type registration and object/binding calculation. Both steps will be shared with compilation units loaded from disk. Change-Id: I43636d7ac76077c76289d7c1c9eba5e9c6b8239a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Added basic support for saving compilation units to diskSimon Hausmann2016-06-171-0/+58
| | | | | | | | | 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>
* Move object/binding counter code to CompilationUnitSimon Hausmann2016-06-171-0/+28
| | | | | | | | | | The code to update the counters operates entirely on data structures from CompilationUnit, so it makes sense to move it into that class. Plus - you guessed it - this will also be called when not using the type compiler in the future. Change-Id: I644b0914980b799be1020ed74d2791b127bbcf9f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Clean up property cache array handlingSimon Hausmann2016-06-161-4/+1
| | | | | | | | | | | | | The QQmlPropertyCacheVector in the CompilationUnit encapsulates the property caches for the objects declared in the QML tree as well as the bits indicating whether a VME meta-object is needed. The ref-counting for the caches in that vector was done "manually" and thus error prone. This patch replaces the vector with a wrapper container that has explicit move semantics and takes care of the addref() and release() calls upon insertion, replacement and destruction. Change-Id: If805fe016f1a1c70e56f8a90909ab87b653ea026 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* More reference counting cleanupsSimon Hausmann2016-06-031-8/+0
| | | | | | | Replace more uses of manual reference counting with automatic counting. Change-Id: Id3ce13814ac7f13d62562be21e4d59119d099944 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Minor const cleanupSimon Hausmann2016-06-031-1/+1
| | | | | | | | | The unit data of QV4::CompiledData::CompilationUnit is read-only, which we should "enforce" with a const, especially as in the future it may come from a read-only mmap'ed chunk of memory. Change-Id: I58dde9fe2494d3cfa52cdc9f612c7fa90b98aa26 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove QQmlCompiledData in favor of QV4::CompiledData::CompilationUnitSimon Hausmann2016-06-011-7/+6
| | | | | | | | | QQmlCompiledData used to contain the binary data for instantiating QML types in the QML VME. Nowadays the QML type compiler as well as the JavaScript compiler create a QV4::CompiledData::CompilationUnit. Change-Id: I155f62a5ecfb55a3fe230520231b6d8fd5b28ac9 Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
* Ensure that CompilationUnit instances are deleted in the engine threadSimon Hausmann2016-06-011-0/+11
| | | | | | | | | | | | | When using CompilationUnit with a QML engine, ensure that they are deleted in the same thread as the QML engine. Only the QML engine has a secondary thread (not a plain QJSEngine) and there it may happen that the last refcount drops within the loader thread. For example when the trimCache() is called within the loader. The destruction of the CompilationUnit however is not safe to perform in a secondary thread. Change-Id: Ia0105a8885ec97b0b2159e32e637adbd4e99f016 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Remove some dead codeSimon Hausmann2016-06-011-6/+0
| | | | | | Change-Id: I1f3baa11e7c7860d6052182a1056f5b13d4ce593 Reviewed-by: Robin Burchell <robin.burchell@viroteck.net> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Moved meta-type id members to QV4::CompiledData::CompilationUnitSimon Hausmann2016-05-311-0/+10
| | | | | Change-Id: I808d0a36094e873b69cf24a5b0113e741ff2a25d Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Moved resolved type references over to QV4::CompiledData::CompilationUnitSimon Hausmann2016-05-311-0/+64
| | | | | Change-Id: I99bb37bf4d4aa4aedd8e02a0fb4afb4a908573a6 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Move dependent scripts to QV4::CompiledData::CompilationUnitSimon Hausmann2016-05-311-0/+5
| | | | | Change-Id: I85e8267ce4cd26ae83fe567357e1368658fdb43d Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Moved object/bindings/customparser counters to CompilationUnitSimon Hausmann2016-05-311-0/+3
| | | | | | | These allow pre-allocating some arrays when instantiating types. Change-Id: I2ca4ba4a69429918f03a5ba4c501c763e7ffa8dc Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Moved the import cache from QQmlCompiledData to CompilationUnitSimon Hausmann2016-05-311-0/+2
| | | | | Change-Id: I77892919678cb01ba1e697a44122760679a72045 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Move property caches from QQmlCompiledData to QV4::CompiledData::CompilationUnitSimon Hausmann2016-05-311-0/+6
| | | | | | | | | This makes particularly sense as the binding property data per object that allows us to avoid a by-name property lookup when instantiating types is also stored there. Change-Id: I4d9275c1d8fde252df83eb11a9dfea71e5e9583a Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Optimize named object handlingSimon Hausmann2016-05-261-0/+16
| | | | | | | | | | | | | | | | By storing the object indices of named objects in the CompiledData::Object of a component, we can achieve two things: (1) We can eliminate the hash of vectors in QQmlCompiledData for the object-to-id mapping (2) We can store the mapping from object name to integer object id in the CompilationUnit and share it across different QQmlContextData instances (as long as it is not modified). Also added a new test that verifies the functionality of a .qml file starting with Component{} itself with object names, something that was previously only implicitly tested through some of the examples (corkboards.qml for example). Change-Id: I28c70217222dc0e5252bf5247b7e3fc4def47446 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Simplify VME meta object meta-dataSimon Hausmann2016-05-231-3/+3
| | | | | | | | | | | | | | | | | For each type of VME meta object we store an array of integers holding the meta-type ids of the QML declared properties. We can replace that array with access to the QV4::CompiledData::Property entry for each property, where the type is also accessible. This is a fairly straight-forward change, except for the bit in QV4::CompilationUnit where we delay the release of the CompiledData::Unit and friends until the destructor instead of releasing it at unlink time. That should be a safe change and is necessary as there are a few tests around where the VME meta object still needs access to this meta-data at a very late stage in the life-cycle right before the deferred deletion is run. Change-Id: I431de15d12766df837c0e0251192df16a5a76868 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Use QStringRef to optimize memory allocationAnton Kudryavtsev2016-04-261-2/+2
| | | | | | | | | | | | | | | | | Replace substring functions that return QString with corresponding functions that return QStringRef where it's possible. Create QString from QStringRef only where necessary. While touching the code, also port loops to C++11 style. Change-Id: I04c99b24ea6afd3715e3edf9ea00bfab838fd53c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com> Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com> Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
* 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>
* 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>
* Speed up property binding initialization on object creationSimon Hausmann2015-04-211-0/+10
| | | | | | | | | | Avoid repeated string hashing and lookups in the property cache in order to retrieve the property details when initializing literal and script bindings. Instead we now cache the property data at type validation time, similar to how the property data was encoded in the VME instructions in the old engine. Change-Id: I3957c7c4c3e26dfa97c4880b23940a3755ee90e4 Reviewed-by: Lars Knoll <lars.knoll@digia.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-1/+1
| | | | | Change-Id: Ia52f0e6db325aab37477d455f163487b319dce29 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Changed InternalClass to store Identifier* instead of String*Simon Hausmann2014-11-211-4/+1
| | | | | | | | | 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>
* Fix run-time string handling with regards to the new heapSimon Hausmann2014-11-211-14/+9
| | | | | | | | | | | | | | | | | Changed runtimeStrings to be an array of Heap::String pointers instead of indirect String pointers. Later that member along with other GC related members will go into a managed subclass. Meanwhile the generated code no more loads String pointers directly but just passes the index into the run-time strings to the run-time functions, which in turn will load the heap string into a scoped string. Also replaced the template<T> Value::operator=(T *m) with a non-template overload that takes a Managed *, in order to help the compiler choose the non-template operator=(Heap::Base *) overload. This allows removing a bunch of Value::fromHeapObject calls. Change-Id: I20415c0549d33cca6813441a2495976b66d4c00e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Ported ExecutionEngine::newString and newIdentifier to Heap::StringSimon Hausmann2014-11-121-2/+4
| | | | | | | | | | 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>