summaryrefslogtreecommitdiff
path: root/src/qml/compiler/qqmlirbuilder.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add support for enum declarations in QMLMichael Brasser2017-07-131-2/+92
| | | | | | | | | | | | | | | | | Enums can be declared with the following syntax: enum MyEnum { Value1, Value2 } Grammar changes done by Simon Hausmann. [ChangeLog][QtQml] Enums can now be declared directly in QML. Task-number: QTBUG-14861 Change-Id: Ic6b6e032651d01ee2ecf9d5ce5734976cb3ad7ab Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Refactor le integer types from qjson_p.h to qendian_p.hAllan Sandfeld Jensen2017-07-061-6/+6
| | | | | Change-Id: Ibb24b0a55dd94e03fea3104e8af5ddb266004300 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-07-041-4/+4
|\ | | | | | | | | | | | | | | Conflicts: .qmake.conf src/quick/doc/src/qmltypereference.qdoc Change-Id: Ia58f1c5a98309c32ef8d8e5c893faf261215f19f
| * Fix QML compiler crashes on big endian systemsDmitry Shachnev2017-06-181-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Commit be491913c036b148 changed QV4::CompiledData::Unit to use LEUInt32 structures internally, rather than native uints, however the generators were not updated at that time and still wrote native uints. Also initialize constants field of CompilationUnit to prevent crashes in unlink() where operator delete[] is called. Change-Id: Id6c6e6ad519c9927ba6027479689ecfde9ea86de Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-06-151-1/+2
|\ \ | |/ | | | | | | | | | | Conflicts: src/qml/compiler/qv4codegen.cpp Change-Id: I3c41b9fc9ba7d41741e4dd400402ae80dd7726d9
| * Change temp allocation when generating IRLars Knoll2017-06-091-1/+2
| | | | | | | | | | | | | | | | | | For functions that won't get optimized, it's useful to limit the number of temporaries as much as possible. Change-Id: I6e9be3129c064fdc4c01e1ec6f1617e901c05935 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-06-071-2/+3
|\ \ | |/ | | | | Change-Id: I61ab3d0bd8cc02f640c60c037226eace09ec09ba
| * QQmlIRBuilder: Only query type name cache for type namesRobin Burchell2017-05-191-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The behavior here was always incorrect: type names must start with an uppercase letter, so querying the type name cache with a lowercase string is wrong. However, this was turned into a larger problem by making more extensive use of QQmlTypeNameCache in e74a1d0b342f2c95dc3a543c8c9ec07fd52d8fe0, as it contained a lot of new types (including composite types, which previously were only in the cache if they were singletons). Task-number: QTBUG-60547 Change-Id: I40be2d535e99d3e1af250d995d7149ecbe2965d7 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | C++11 scoped enum support for QMLMichael Brasser2017-05-031-0/+37
| | | | | | | | | | | | | | | | | | [ChangeLog][QtQml] Support C++11 scoped enums in QML. These can now be accessed as <TypeName>.<EnumName>.<EnumValue> Change-Id: I29bd3f16e980f3e6f1b2390b5a8e9e8e999952a3 Task-number: QTBUG-54961 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into devSimon Hausmann2017-03-271-5/+4
|\ \ | |/ | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4functionobject_p.h Change-Id: I4bbed45f1fe02cf64df3c8a5f92f811e38e772f3
| * Merge remote-tracking branch 'origin/5.8' into 5.9Simon Hausmann2017-03-151-5/+4
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qqmltypecompiler.cpp src/qml/compiler/qqmltypecompiler_p.h src/qml/qml/qqmltypeloader.cpp src/qml/qml/qqmltypeloader_p.h Change-Id: I4894555ab7a0879b56bbda7a46d16d1c40c19e7c
| | * Clean up type dependency hashing for QML cachingSimon Hausmann2017-03-131-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-03-141-1/+16
|\ \ \ | |/ / | | | | | | Change-Id: I0ec164ce6e8099e6e4d6b40a3c7340737473ef4b
| * | Fix restoring IR from cache filesSimon Hausmann2017-03-061-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit eeb08d9537d0b4e77b91848169e0bb79ec3d912c was missing the code to restore the aliases, the AST function formals as well as the object flags/id. This also fixes crashes with the QML compiler. Change-Id: I1c50816dc77ae66edbc3ddc7146da4edfd4170f4 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | compiler: Rename _env to _variableEnvironmentRobin Burchell2017-02-031-1/+1
|/ / | | | | | | | | | | | | | | More in keeping with the spec's terminology, and allows us to introduce a LexicalEnvironment for ES6. Change-Id: I1d98387a0ad6372317cf1036f814ac0c6063c1bf Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Re-do QML type compilation of ahead-of-time generated QML cache filesSimon Hausmann2017-01-311-0/+152
| | | | | | | | | | | | | | | | | | | | As we currently lack the ability to do type resolution at AOT cache generation time, we need to re-do the work after loading the cache file, making us essentially only re-use the code and avoiding the step of parsing. Change-Id: I12844692d4766345d8a313b59d21abf1f868e2d1 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-12-141-5/+5
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp src/qml/qml/qqmlimport.cpp src/quick/items/context2d/qquickcontext2dtexture_p.h tools/qmleasing/splineeditor.h Change-Id: I8f6630fcac243824350986c8e9f4bd6483bf20b5
| * Fix support for namespaced types in property/signal declarationsSimon Hausmann2016-11-301-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Declarations such as property Namespace.Item foo or property list<Namespace.Item> foo would get rejected by the grammar due to the lack of productions. This is now encapsulated in the UiPropertyType, which used to be merely an identifier but is now changed to produce a UiQualifiedId - the same type that's also used for MyNamespace.Item { ... } object declarations for example. Task-number: QTBUG-10822 Change-Id: Ic3ac1adbe17c83b24b67950c2f089e267b73b99b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-10-221-0/+2
|\ \ | |/ | | | | Change-Id: I171c7dbb6a74fe743c2eec63e86e9c0bef7c7dfd
| * Fix excessive invalidation of QML disk cachesSimon Hausmann2016-10-181-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 compiler: replace 'foreach' with 'range for'Anton Kudryavtsev2016-09-091-9/+10
| | | | | | | | | | | | | | ... and with 'index-based for' in one place. Change-Id: I4df75bd5921f9ee8b5744067adbaafbc46452f87 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Replace QStringLiteral with QL1S in QStringBuilderAnton Kudryavtsev2016-08-241-1/+2
|/ | | | | | | Saves some text size. Change-Id: Ib521959784071a79462cf7962657d8158cf130a2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Make the unit mapping on Windows configurable with regards to executable mappingSimon Hausmann2016-08-171-2/+0
| | | | | | | | | | 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>
* QML: Make all fields in QQmlPropertyRawData privateErik Verbruggen2016-08-101-4/+4
| | | | | | | | And add accessors. This makes it easier later on to change the storage of the fields. Change-Id: I21163668ac83a7d52f398981baf3c27ef161c177 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix crashes with attached property accessSimon Hausmann2016-08-081-1/+6
| | | | | | | | | | | | We currently embed the attached object ids in the generated code, which is not stable because they come from a hash and the meta-objects of the attached types are also not part of the check-sum verification. So for now disable accelerated access in order to proceed with qtquickcontrols2 integrations. This needs to be re-enabled later with proper checking and stable lookups. Change-Id: I54a3f0c905ee26fb80f4e2687a2901a11a921b38 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix android buildOlivier Goffart2016-08-041-0/+1
| | | | | Change-Id: Id65119bef515c9b6336a343f39541f557a00e015 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QQmlIRBuilder: Initialize variableRobin Burchell2016-08-031-1/+1
| | | | | | | | gcc on Centos 7 struggles to understand that this variable is always used when initialized, so give it a helping hand. Change-Id: I11d2e9fdf23ae9173fa9205fbe0615158a2460ad Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add a checksum to the generated QML compilation unitsSimon Hausmann2016-08-021-1/+15
| | | | | Change-Id: Icd5b1d805059981cbbb4c0eb2a5c842d59223839 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix endian support in compiled data structuresSimon Hausmann2016-07-141-4/+7
| | | | | | | | | | | | 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>
* Minor optimizationSimon Hausmann2016-06-271-1/+13
| | | | | | | | | | | | | | | I've seen people write property SomeItem myProperty: null This is an unnecessary initialization that ends up creating a binding expression. Generally there's handling missing for null and undefined, but in this very case we should just optimize away the initializer expression, because QObject style properties are initialized to null by default, as opposed to undefined. Change-Id: I7af4cd45461304753c93cef3926f6e92d3b6c95d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QML: Do not register static QML dependencies on every call.Erik Verbruggen2016-06-241-1/+3
| | | | | | | | | | | | | | | | | | | | | | QML objects can be re-parented on the fly, resulting in different dependencies for expressions like 'parent.width'. So, because of this, dependencies are cleared and re-calculated after every binding evaluation. However, dependencies on properties of the scope and context objects cannot change, because these objects do not get changed for the life-time of a binding. So we can permanently register them. This is only done for bindings, not for functions, because those might be conditionally executed. According to valgrind, this is a reduction of ~186 instructions on x86 for every evaluation of: Item { height: width } Change-Id: Ib095497323d4f08caf712d480007e2627a176369 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* PropertyCacheCreator traversal cleanupSimon Hausmann2016-06-161-0/+10
| | | | | | | | | Replace the direct linked list object traversal with iterators. This will allow for re-use of the code against the QV4::CompiledData structures when they get the same interface. Change-Id: I901fd3377ef0f0317e5d9278cface37d80f93abf Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Clean up property cache creation codeSimon Hausmann2016-06-161-2/+2
| | | | | | | | | | | | | | | | | | * Reduce the complexity of the recursive tree traversal by moving the base type property cache creation into a helper function and using a context to encapsulate the origin of the current traversal * ensureVMEMetaObject() had only one call site and it's easiest to inline that for now. * Transition to a new state-less error handling, so that in the future this code can be used without the QQmlTypeCompiler dependency, which will be needed for loading of compilation units from disk. * A few missing consts. Change-Id: Ibe7209c357a3c7e101fac6960ece40a033e55f72 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Cleanup: generalize type reference collection codeSimon Hausmann2016-06-141-25/+0
| | | | | | | | | | For loading compilation units from disk we'll have to scan the unit for type references, in order to correctly load dependencies. In preparation for that this patch template'izes the loops so that they can work on the Qml IR as well as on the CompiledData::Object structures. Change-Id: I32e4e3277e16c5a2d1bf6baf24456c9837c189ff Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove QQmlCompiledData in favor of QV4::CompiledData::CompilationUnitSimon Hausmann2016-06-011-2/+1
| | | | | | | | | 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>
* Moved meta-type id members to QV4::CompiledData::CompilationUnitSimon Hausmann2016-05-311-1/+1
| | | | | Change-Id: I808d0a36094e873b69cf24a5b0113e741ff2a25d Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Optimize named object handlingSimon Hausmann2016-05-261-5/+15
| | | | | | | | | | | | | | | | 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 object to id-in-context mappingSimon Hausmann2016-05-261-5/+7
| | | | | | | | | By storing the calculated integer id for an id-named object in CompiledData::Object we can simplify the code and replace a hash table with a plain vector. Change-Id: I4a84cdd00e98766d603d152e5a6574b232771a02 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Add a flag to CompiledData::Object record component boundariesSimon Hausmann2016-05-261-0/+2
| | | | | | | | This allows simplifying some code and reducing the usage of the objectIndexToId hash maps. Change-Id: I1f08d4b224c4f9fa498d90471fa545ae4e4f2af4 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Minor cleanup of pool array allocationSimon Hausmann2016-05-261-3/+2
| | | | | | | | | We store the CompiledData::Function indices for a give QML object in a fixed sized array in the memory pool in the IR. That array can be stored as pointer/len pair directly, there is no need for another pointer indirection. Change-Id: Iccad465ab873e0e7203dc563abb67cf6354a8bfd Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
* Shrink QQmlVMEMetaData::AliasDataSimon Hausmann2016-05-241-2/+2
| | | | | | | | We can retrieve the alias property index from the QV4::CompiledData::Alias and the property type from the property cache (only needed for aliases to value types). Change-Id: Ibf0cb909a4cd1ce1c2d67b57e1be1de491d4d598 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Optimize property/alias data structuresSimon Hausmann2016-05-231-110/+182
| | | | | | | | | | | | | We used to store property declarations and alias declarations in the same properties array in CompiledData::Object. However at run-time the QQmlVMEMetaObject implements them separately, using separate data structures (in the meta-data) and (most importantly) using separate property id segments: First the properties, then the aliases. By reflecting the same separation in CompiledData::Object with property arrays and alias arrays, we can pave the way for getting rid of the meta-data in QQmlVMEMetaObject. Change-Id: Ia84813fe3da6f3fdbd4d2b16136a8bf11fa175a6 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Fix regression with assignments to default propertiesSimon Hausmann2016-05-191-1/+4
| | | | | | | | | | | | | | | | | With commit ad8d760decd5f1c6242a42688417b3c86122121c the precision of the location (row/column) fields was reduced. The same fields are used to preserve the insertion orer of bindings as they appear in the .qml file, which meant that for large qml files without any line feeds we may end up with an overrun in the column range (2048). This happened in the Tests_TabView::test_mousePressOnTabBar test in qtquickcontrols. The reduced precision is fine because those column/row fields should only be used for error reporting. In this case where we need the precision we can just as well use the file offset in the temporary QML-IR Binding data structure. Task-number: QTBUG-53115 Change-Id: Ifb6f76b4f83a06fa228211134d12cc67c071bbec Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
* Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-05-131-4/+4
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsapi/qjsengine.cpp src/qml/qml/qqmlengine_p.h src/quick/items/qquickanchors.cpp src/quick/items/qquickanimatedimage_p_p.h src/quick/items/qquickitem_p.h tests/auto/qml/qqmlecmascript/testtypes.h tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp tests/benchmarks/qml/creation/tst_creation.cpp Change-Id: I65861e32f16e8a04c7090a90231627e1ebf6ba6f
| * Use QStringRef to optimize memory allocationAnton Kudryavtsev2016-04-261-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Scrape off some more allocations by using the QStringBuilderFrank Meerkoetter2016-05-091-6/+3
| | | | | | | | | | Change-Id: I25cbbcad086afb15694f69bdc52bd4ddce4b3a18 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Allow the use of uncreatable types for propertiesSimon Hausmann2016-04-291-1/+0
|/ | | | | | | | | | | | | | It should be possible to write property SomeUncreatableType blah; It should not be possible to write: property SomeUncreatableType blah: SomeUncreatableType {} Task-number: QTBUG-36752 Change-Id: I2d1aa9f070a368f51844bbc0733d285022aab403 Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
* QML: add type info for the built-in qml context.Erik Verbruggen2016-04-051-1/+6
| | | | | | | | | | Previously, the type for the target temp would be 'var', which would subsequently be corrected to qobject through a member access. That resulted in typing the defining move again, which is unnecessary. Change-Id: Ife993a667331e69aea64ac2af0f64096a142a583 Reviewed-by: Robin Burchell <robin.burchell@viroteck.net> Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* QML: do not re-use the resolver data for members.Erik Verbruggen2016-04-041-23/+43
| | | | | | | | | | | | | | | | | | | On successful lookup, the resolver data was cleared and re-used for the resolved member. The effect is that a second time the resolver is used, it will not be able to do the same lookup, resulting in it returning an unknown type. Because the same expression might need to be resolved multiple times (e.g. when a dependency changes type), this results in the wrong type (var), and then more iterations to propagate this wrong type to all usages. Instead, return a new resolver with its own data for the resolved member. This way, a member access on this result can be resolved correctly by this new resolver. Change-Id: Ia930c08a2e4a2182d800192547fc03cba209c78c Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Qml: replace QStringLiteral with QLatin1StringAnton Kudryavtsev2016-02-101-5/+5
| | | | | | | ... in string comparisons. It's more efficient. Change-Id: I3be5a2be9ba5d55546472eac28f5f639a496bf3b Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>