aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qqmlirbuilder.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add abstraction for temporarily setting StaticData when savingUlf Hermann2019-05-171-3/+0
| | | | | | | | | The StaticData flag needs to be saved to disk, but removed again afterwards so that we can free() the malloc'd data. This also allows us to avoid copying all the data into a byte array before saving. Change-Id: I96513f8d98acf0ea0b4514d96376b487e8444917 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Split CompiledData::CompilationUnit in twoUlf Hermann2019-05-161-8/+6
| | | | | | | | We need a CompilationUnit that only holds the data needed for compilation and another one that is executable by the runtime. Change-Id: I704d859ba028576a18460f5e3a59f210f64535d3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-05-091-22/+14
|\ | | | | | | | | | | | | Conflicts: src/qml/compiler/qqmlirbuilder.cpp Change-Id: I2cfda470515e2df778ad3c89105c07344af07c6d
| * Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-05-081-22/+14
| |\ | | | | | | | | | Change-Id: I3eb5d1affe64b6ae709d1154cc37de91db3816b6
| | * Avoid std::function in qqmlirbuilder.cppUlf Hermann2019-05-071-22/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some compilers seem to miscompile this construction. Furthermore, it doesn't really add to the readability of the code. Inline the code in question at the only place it's used and avoid most of the const_cast by adding a non-const accessor to CompiledData::Unit. Fixes: QTBUG-75392 Change-Id: I015317f28a92817d08d616cc35956745758d7847 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Drop some dead bootstrap codeUlf Hermann2019-05-081-20/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The dependencies are only hashed if a dependencyHasher is given. This is generally not the case when compiling ahead of time. There is also no need to hide the declaration of DependentTypesHasher from the bootstrap code. Change-Id: I0ea74c3079656ce1fe353956999820916c8ff626 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Move dynamicStrings into the bootstrapped part of QV4::CompiledDataUlf Hermann2019-05-071-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | We don't really need the dynamic strings at compile time, but having them defined simplifies some code. Change-Id: Ibcfaae7834f8aa63918da6787d222fe71657c4ee Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Move QQmlIR::IRLoader out of qqmlirbuilder*Ulf Hermann2019-05-061-164/+0
| | | | | | | | | | | | | | | | | | | | | | | | We don't need it to build the IR and we can drop a few checks for V4_BOOTSTRAP this way. Change-Id: I9464e65528c70c42ebc8ddad576eaab001dc9d2f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Move PropertyResolver out of qqmlirbuilder*Ulf Hermann2019-05-061-47/+0
|/ / | | | | | | | | | | | | | | The "early" compilation doesn't use it and we can get rid of a few V4_BOOTSTRAP checks this way. Change-Id: I1c4845aba445b105ddace0b6810e0e5c28a25b29 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-03-251-0/+2
|\| | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/qmltest/quicktest.cpp tests/auto/qml/qmlcachegen/qmlcachegen.pro Change-Id: I70e96e8817d59647f876b8b77b30cdeede8f0662
| * Initialize TranslationData padding before writing cache filesUlf Hermann2019-03-211-0/+2
| | | | | | | | | | | | | | | | Otherwise the resulting files differ subtly. Fixes: QTBUG-74532 Change-Id: I12b4f1ba6dda781d63ad50cce87861ba24582bf7 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-03-211-408/+1
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qqmltypecompiler.cpp src/qml/compiler/qv4bytecodehandler.cpp src/qml/compiler/qv4codegen.cpp src/qml/compiler/qv4compileddata_p.h src/qml/compiler/qv4compiler.cpp src/qml/compiler/qv4instr_moth.cpp src/qml/compiler/qv4instr_moth_p.h src/qml/jit/qv4baselinejit.cpp src/qml/jit/qv4baselinejit_p.h src/qml/jsruntime/qv4function.cpp src/qml/jsruntime/qv4vme_moth.cpp Change-Id: I8fb4d6f19677bcec0a4593b250f2eda5ae85e3d2
| * Remove dead compile time QML context/scope property and id object codeSimon Hausmann2019-03-201-409/+1
| | | | | | | | | | | | | | | | | | | | | | After enabling lookups in QML files, we can remove all the code that tries to deal with (type) compile time detection of access to id objects and properties of the scope/context object. This also allows removing quite a bit of run-time code paths and even byte code instructions. Task-number: QTBUG-69898 Change-Id: I7b26d7983393594a3ef56466d3e633f1822b76f4 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
| * Implement dummy QML lookups for "global" variablesSimon Hausmann2019-03-201-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When resolving names in the context of QML bindings, we now direct runtime access to QQmlContextWrapper::resolveQmlPropertyLookupGetter. At the moment this does basically the same as Runtime::method_loadName, which we called earlier. However this now provides the opportunity to optimize lookups in the QML context in a central place. When performing a call on a scope or context object property, we also did not use a CallName() instruction - which would have gotten the thisObject wrong - but instead we use a dedicated CallScopeObjectProperty and CallContextObjectProperty instruction. These rely on identifying these properties at compile time, which goes away with lookups (and also doesn't work when using ahead-of-time compilation). Therefore the qml context property lookup is using a getPropertyAndBase style signature and Runtime::method_callQmlContextPropertyLookup uses that. For the tests to pass, some error expectations need adjusting. In particular the compile-time detection of write attempts to id objects is now delayed to the run-time. The old code path is still there and will be removed separately in the next commit (as it is massive). Task-number: QTBUG-69898 Change-Id: Iad1ff93d3758c4db984a7c2d003beee21ed2275c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-03-181-1/+1
|\| | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4codegen.cpp Change-Id: I66b7db42bf208855889094ace0267326595ce03c
| * Save some stack space during code generationUlf Hermann2019-03-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Result objects are rather large, 96 bytes here. In a recursive algorithm such as our parser, we should not keep too many of them on the stack. Also, the size of Reference can be reduced by employing a bit field rather than a number of booleans. Also, try to convince the compiler to inline the accept() functions. The extra stack frames those create are unnecessary. Task-number: QTBUG-74087 Change-Id: I5c064491172366bb0abef99ffe9314080401a7d1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | V4: Move the FixedPoolArray into the MemoryPool headerErik Verbruggen2019-01-251-3/+3
| | | | | | | | | | | | | | So now the FixedPoolArray can be re-used in other places. Change-Id: I0e0504892944722a0c18f207dc6400d5b314f6ae Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | QML: Special case null as binding typeUlf Hermann2019-01-211-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | This gives us the opportunity to map the JavaScript null to QVariant's concept of isNull(). [ChangeLog][QML] Assigning JavaScript null to incompatibly typed properties generates a compile error now, rather than a runtime error. Fixes: QTBUG-72098 Change-Id: I72fd1c30d84128c774230eaaea10455b2a0e064c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.12' into devQt Forward Merge Bot2018-12-121-7/+3
|\| | | | | | | | | | | | | Conflicts: tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp Change-Id: Ic1dace832ad4b29023d24808b8617b5dcc915eb5
| * Generate lookups into the global object more aggressivelyLars Knoll2018-11-161-7/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since change 9333ea8649838d7e0400b0e94c8cbd4fa5d216b0, we lookup properties in the QML context object before the global object to have proper scoping rules for QML. Unfortunately this lead to a performance regression when using global properties such as Math in imported script files, as the lookup would always go through the qml context first. This can be fixed, as we know that the global object is frozen in qml mode, and the standard names of properties in the global object are illegal to use in QML. So simply check for those names in the code generator and create lookups into the global object for those. Change-Id: I4b2089178c9e5f9440abdfd834cf7d92c3c0e2c3 Fixes: QTBUG-71591 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | Fix warnings about unused Qt containersSergio Martins2018-11-301-2/+0
|/ | | | | | | | | | | Fixes -Wclazy-unused-non-trivial warnings, in preparation for using gcc/clang's warn_unused attribute in all containers. Maintainers please check if some unused variable isn't hidding an actual bug. Change-Id: I83c5a11aa2328db3dce4c6c402295d86ef297c83 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix lookup of methods in the scope objectSimon Hausmann2018-10-221-5/+9
| | | | | | | | | | | | | Commit 939014cb9cad2f3357f47b28a4580397c17b913c improved performance of property lookups beyond the scope object, with the unfortunate side-effect that the previously polymorphic lookup of methods broke. Fix this by moving the handling to the caller side and falling back to the string lookup for functions. Fixes: QTBUG-71204 Change-Id: I2d9924034a9c14e7d161fa49d51b1f876ab5bc0f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix logic error in JSCodeGen::fallbackNameLookup()Lars Knoll2018-09-051-26/+22
| | | | | | | | | | Don't return a name reference if we fail to lookup something in the scope object, but rather continue trying in the context object. Task-number: QTBUG-70315 Change-Id: I73f8aa7b648320434ef0ef37a4c12dca1eb7b209 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* reuse already calculated object offsets during compilationRolf Eike Beer2018-08-231-15/+12
| | | | | | | | Doing this in different ways could lead to broken object layout or other bad things later. Change-Id: Ifd7b4e535d6fad4a867a6ea0c594df18247ee943 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add support for importing ES modules in .qml filesSimon Hausmann2018-08-171-1/+1
| | | | | | | | | | | | | | | | | This is a straight-forward hook into the module implementation in QV4::ExecutionEngine. Modules are pre-compiled in the QML type loader thread. That thread keeps track of all pending loading scripts through the type loader's m_scriptCache. Once a module is compiled, it's thread-safely registered with the execution engine. Script instantiation and evaluation is done solely in the QQmlEngine's thread. ES Modules are identified in imports as well as qmldir files by the .mjs extension. Change-Id: Ie9c59785118afcb49f43a1e176a9f7db00f09428 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Simplify parsing of pragma directivesLars Knoll2018-08-011-2/+2
| | | | | | | | We only support 'pragma Singleton' currently, so there is no need to parse the right hand side of pragma as a member expression. Change-Id: Ic0dcbedb52cb58db2fd1cc099f14fd399b7162e3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Reduce memory consumption when loading AOT generated cache filesSimon Hausmann2018-08-011-81/+75
| | | | | | | | | | | | | | | | | Separate the qml data (objects/imports) from the general compilation unit data. It's only the former that needs to be re-generated as part of the type re-compilation and by separating it we can allocate memory just for that and keep using the mmap'ed general unit data for everything else (including byte code). Another upside of this change is that it allows eliminating the recently introduced concept of a backing unit again. Saves ~149K RAM with the QQC1 gallery. Task-number: QTBUG-69588 Change-Id: Ie88a4286feb7e2f472f58a28fa5dd6ff0a91c4b6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Encapsulate access to CompiledData::Object and CompiledData::ImportSimon Hausmann2018-07-311-3/+3
| | | | | | | | This will make it easier to move the data out of CompiledData::Unit and into a separate data structure. Change-Id: I32e6233a66f2279b44cc06ef7c3505db4a565f98 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove unused flagSimon Hausmann2018-07-311-1/+0
| | | | | Change-Id: Ib9028ffa8c7d014598da60bfe44e004031bf6017 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Reduce memory usage caused by strings with AOT cache filesSimon Hausmann2018-07-311-4/+21
| | | | | | | | | | | | | | | | For AOT loaded cache files, the CompiledData::Unit we produce is ephemeral by design. That same applies to the strings, where we don't really need to write out a new string table but we might as well just keep the QStringList around. That avoids copying all the string data and saves another 21K RAM with the gallery. It might even save a little more if some of the new strings are truly shared via implicit QString sharing. Also their "extraction" via stringAt(index) becomes as fast as for the strings that come from mmap'ed memory - with no copying involved. Task-number: QTBUG-69588 Change-Id: I06cf0f083e3b8d3c5dbabb22beb0711f88fc8692 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Clean up internal QML unit creation APISimon Hausmann2018-07-311-2/+2
| | | | | | | | | Since the callers always end up assigning the returned unit pointer back to the compilation unit's data member, we might as well do that inside the function and return void instead. Change-Id: I7a7f3e7a0c89ffe2f9474149fcf61736609b363d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Simplify loading of ahead-of-time created QML cache filesSimon Hausmann2018-07-311-11/+29
| | | | | | | | | | | Consolidate the old "createUnitData" code that used to be a virtual function into the one call site and avoid a malloc that way. By the way of that, the string table gets a guard to prevent accidental registerString() calls at a later point. Change-Id: Ia3f8d3e874b7733822e6942e411c940ec60d95a5 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Optimize memory consumption of ahead-of-time compile cache filesSimon Hausmann2018-07-311-3/+1
| | | | | | | | | | | | | | | When loading a pre-compiled cache file, the strings contained therein will remain available in memory since commit 7dcada48d2435e8ceb0cc8a6771f79b76979e11f. While for aot built cache files we may have to add new strings (for example for signal handler parameters), we can re-use the existing strings by omitting them from the intermediately created string table. This saves ~283K RAM with qtquickcontrols1 gallery. Task-number: QTBUG-69588 Change-Id: I8ea807f6dea4cc35d8b7e5f7329809ed1cd12880 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Clean up compilation unit string resolutionSimon Hausmann2018-07-311-3/+3
| | | | | | | | | Replace use of CompiledData::Unit::stringAt with CompilationUnit::stringAt as central place, in preparation for allowing derived compilation units to retrieve strings from base units. Change-Id: Ifafe6c18a9fd8d1e2259a60c17200124869b4c2d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Shrink CompiledData::Binding by 8 bytesSimon Hausmann2018-07-311-4/+4
| | | | | | | | | | | | | Move the translation data out into a separately indexed table, which allows to shrunk the value union down to 4 bytes, together with the previous commit. Saves ~4k with examples/quickcontrols/extras/flat/Content.qml and ~37K RAM with the gallery. Task-number: QTBUG-69588 Change-Id: Ia5016b072320ebb6b8fcfbb4dad128d53c901c74 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Clean up constant storage for CompiledData::BindingSimon Hausmann2018-07-311-2/+2
| | | | | | | | | | Store doubles in bindings in the constant table of the compilation unit instead of each binding. This removes one of the two 8 byte members of the value union and also allows for sharing of constants throughout a .qml file. Change-Id: I1d7daafdb7f24e34c14cd160d2dcb2c5aaac1c50 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Encapsulate the unit data in CompilationUnitSimon Hausmann2018-07-311-1/+1
| | | | | | | | This allows updating the constants table when the unit data is set / changes and removes the tie to the engine. Change-Id: Ice553650390589e30e18421c4e55422a55d0df89 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add debug code for dumping unit statsSimon Hausmann2018-07-301-0/+22
| | | | | | | This is useful for profiling the sizes of cache files. Change-Id: I831d0a20c4eda3d707221a61fa7290857605c7fb Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Merge remote-tracking branch 'origin/5.11' into devLars Knoll2018-05-241-0/+16
|\ | | | | | | Change-Id: I0127f2c16de1d930bdd8cbccd42ec6785f31ab96
| * Ensure we restore QML-defined enumsMichael Brasser2018-05-231-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | This code path was previously missed, leading to some AOT-compiled types generating errors of the form: Unable to assign [undefined] to int [ChangeLog][QtQml] Fix QML declared enums with CONFIG+=qtquickcompiler. Change-Id: Ib46a2b2505aa3863f091a6ccdebf8425e62fc38f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Set the name of the context as early as possibleLars Knoll2018-05-231-4/+8
| | | | | | | | | | | | | | | | | | | | We used to set the name later on when calling Codegen::defineFunction(), but this is too late in some cases, especially when using the name to determine if this function could be a QML signal handler. Change-Id: Ie620a65ac8f17906cd9eba338cbdd3563004375d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devLiang Qi2018-05-151-7/+7
|\| | | | | | | | | | | | | Conflicts: src/qml/qml/qqmltypeloader.cpp Change-Id: If9874faf23e813b05ee4cf042133a528d73ba72a
| * Fix .import within .js files with CONFIG+=qtquickcompilerSimon Hausmann2018-05-111-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When loading a .js file without QQC, we scan the sources and use the ScriptDirectivesCollector to extract things like .pragma library or .import ahead of time. That information is passed on to the compilation unit generator for serialization. When compiling .js files ahead of time, we also used the same collector, but we forgot to save the data into the right location before serialization, so we essentially lost the imports. This patch fixes that by centralizing this code into the ScriptDirectivesCollector itself. [ChangeLog][QtQml] Fix regression with .import in .js files not working when using CONFIG+=qtquickcompiler. Change-Id: I5413c14b1b8bd3114a997011534fe55cdb7634aa Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Add support for proper lexical scopingLars Knoll2018-05-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This is still to some extend work in progress as lexically scoped for loops won't yet do the right thing. let and const variables are still accessible before they are declared, and the global scope doesn't yet have a proper context for lexically declared variables. Change-Id: Ie39f74a8fccdaead437fbf07f9fc228a444c26ed Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Make sure we call Codegen::defineFunction with proper argumentsLars Knoll2018-05-021-11/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So far, when instantiating QML bindings, the node parameter could be the same or a child of the body. This will break badly when we introduce lexical scopeing as that node could be an AST::Block that opens it's own context. Changing this requires some smaller adjustments to our autotests, as error locations will now be slightly different (pointing to the beginning of the binding, not the beginning of the RHS of the binding). Change-Id: I2c536a4fe6d8b549a138cc7967ef034eb2523f3b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Rename the CompilationMode enum to ContextTypeLars Knoll2018-05-021-4/+4
| | | | | | | | | | | | | | | | | | And make it an enum class. The new name fits better, as it's mainly used to determine the type of the context when parsing. Also already added the 'Block' value that will be needed. Change-Id: I70d963b6a0b22db1a3c607cce6bdd2054b29e000 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Fix crashes when parsing functions with no parametersSimon Hausmann2018-05-021-1/+1
| | | | | | | | | | | | | | | | | | | | Commit da5fffbd34d8be68f8ee4c649881dbb673c9c0a5 introduced deferencing of the formals parameter list that can be a null pointer if the declared function has no parameters. Change-Id: Id7dce0f78b16266e672f0ae430ee4f979de5734d Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Bring JS grammar in line with ES7 specLars Knoll2018-04-251-7/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This basically updates all grammar rules in the qqmljs.g file to be in line with the ES7 specification. Some special handling for the lookahead rules appearing in the spec was needed and is implemented through empty lookahead rules in the grammar, that might push an additional token into the token stream. Renamed some classes in the AST to be in line with the names used in ES7, and removed some other ones (SourceElements) that are no longer used. The ES7 grammar rules contain lots of variations of the base rules (with In/Return/Yield/Default suffixes). With the exception of the In and Default rules, these are implemented through state tracking in the parser and lexer. Change-Id: I4017d97cd050ed816c1dad11833e882cba30801a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Partially support binding patternsLars Knoll2018-04-251-5/+6
| | | | | | | | | | | | | | | | Destructuring objects works, but arrays are not yet supported. Change-Id: I61e917e1964e3c719f71b8f11d194e09dfe288c2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Get rid of the AST::FunctionDeclaration member in QmlIR::FunctionLars Knoll2018-04-251-28/+10
| | | | | | | | | | | | | | | | It's not required and makes the refactoring of the function parameter handling required for ES6 a lot harder. Change-Id: I0273449219ea9f3324353d6cf9166c1b58eb914b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>