aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljscompiler_p.h
Commit message (Collapse)AuthorAgeFilesLines
* QmlCompiler: Pass QQmlJSSaveFunction as const refUlf Hermann13 days1-3/+3
| | | | | | | | std::function is quite heavy-weight. Coverity-Id: 486648 Change-Id: Ia7c61a726bde9c9d6a02412b9aa5f683bb4d355a Reviewed-by: Fabian Kosmale <[email protected]>
* QML compiler: Fix Unity build on WindowsFriedemann Kleint2025-06-041-3/+3
| | | | | | | | | | Somehow, qt_windows.h gets in the mix which has the 'interface' define. Rename the variable. Pick-to: 6.10 6.9 Task-number: QTBUG-115140 Change-Id: I6d46d66d0db3350a975984bcc6c4858214615c8b Reviewed-by: Ulf Hermann <[email protected]>
* Compiler: Add infrastructure to skip functionsOlivier De Cannière2025-04-171-0/+1
| | | | | | | | | | | | | | When trying to compile a function in the compiler, sometimes, the outcome is neither successful compilation nor an error. Introduce skiping functions for those cases. When a function is skipped its compilation has not failed. Skipping is therefore allowed in strict mode. Task-number: QTBUG-134790 Pick-to: 6.9 6.8 Change-Id: I0f1ca85404db8dd4c87cd5eb9b96c9dc8cc8d290 Reviewed-by: Sami Shalayel <[email protected]>
* QmlCompiler: Clean up error handlingUlf Hermann2025-02-021-8/+7
| | | | | | | | | | | | | | | | We should only have one way to handle diagnostic messages: The QQmlJSLogger. In addition each compile pass may result in an error that prevents the running of further passes. But that error should not rely on the selection of messages posted earlier. For this to work we need to introduce a further state transition into the logger. The logger now "archives" messages after compiling each function, so that only the current function's compile errors are taken into account as result of the current function's compilation. Task-number: QTBUG-124913 Change-Id: I4b6d9910b80527cefb1aba02598114d1fe5ba172 Reviewed-by: Olivier De Cannière <[email protected]>
* Compiler: Create infrastructure to support multiple warningsOlivier De Cannière2024-08-211-4/+4
| | | | | | | | | | | | | | | | | Currently only one DiagnosticMessage can be stored at a time when using the compiler. However, we want to be able to show more than one to the user. Therefore, use a list that gets passed inside the compiler instead of a pointer to the sole error. This also means that the error is valid by its very existence. There is no need to check validity explicitly anymore. Task-number: QTBUG-127624 Change-Id: I356db917b86703b508dc1ad52de7825d82eafd71 Reviewed-by: Ulf Hermann <[email protected]> Reviewed-by: Sami Shalayel <[email protected]>
* QtQml: Fix misuse of logging categoriesUlf Hermann2024-06-141-1/+1
| | | | | | | | | | | | | | | | | | If we manually define the logging category function, we should really avoid the macro for declaring it. When exporting a logging category, we need to use the special export macro since we shouldn't rely on the internals of the declaration macro for placing the export. The same holds for static logging categories. Furthermore, consistently call the functions for lcQml and lcJs. We also need to fix the namespaces in qmlls now since the logging categories are decidedly not in either of the used namespaces, and the namespaces are all inside any Qt namespace. Task-number: QTBUG-67692 Change-Id: I00fdcb80379e47dd7e928260e9c1dec91f22ad4b Reviewed-by: Fabian Kosmale <[email protected]>
* Compiler: Record statistics about aot compilationOlivier De Cannière2024-05-281-3/+9
| | | | | | | | | | | | | This patch introduces the collection of statistics about the ahead-of-time compilation of functions and bindings to Cpp by qmlcachegen. This is done by having qmlcachegen save an aotstats file for every qml file it compiles. This file contains, for every function and binding, whether the Cpp codegen was successful, its duration and a potential error message Task-number: QTBUG-124667 Change-Id: Iba9a72be04f6642688533a3ae12ea687296c85e1 Reviewed-by: Fabian Kosmale <[email protected]>
* QtQml: Properly enforce signatures of AOT-compiled functionsUlf Hermann2024-04-261-2/+2
| | | | | | | | | | | | | Pass the metatypes of the contained types rather than the stored types. [ChangeLog][QtQml][Important Behavior Changes] The AOT compiled code for type-annotated JavaScript functions does not let you pass or return values of the wrong type anymore. Fixes: QTBUG-119885 Change-Id: I685d398c0745d32a999a3abd76c622a2c0d6651f Reviewed-by: Olivier De Cannière <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>
* Remove the use of Q_QMLCOMPILER_PRIVATE_EXPORTAlexey Edelev2024-01-091-9/+9
| | | | | | Task-number: QTBUG-117983 Change-Id: I893ba2a6c83af92d65d843b6a37bb14c6c1e45bf Reviewed-by: Ulf Hermann <[email protected]>
* Compiler: Separate function prolog block and add validation of blocksOlivier De Cannière2023-08-041-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function prolog logic is now separated in its own basic block. The first "real" block with user code starts at offset 0. Having the function prolog as a hidden part of the first block caused some inconsistencies in block generation and would create empty blocks. This happened for example when a back edge of a loop would target offset 0 in code where a loop condition is the very first set of instructions that are run. This is because the target block offset didn't exist due to it being part of the hidden prolog block. Validation for the basic blocks was also added. This checks for three things at the moment: 1. That return and throw blocks don't have jump targets. 2. That the basic blocks graph is connected. 3. That jump targets are the first offset of a block. Test tst_QmlCppCodegen::basicBlocksWithBackJump_infinite() is expected to fail because it contains an infinite loop and the basic blocks that are generated for it are inconsistent due to dead-code elimination happening earlier in compilation. Debug outputs for dumping basic blocks were also adapted to reflect these changes. Change-Id: I513f73856412d488d443c2b47a052b0023d45496 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>
* QmlCompiler: Drop broken line comments in generated C++Ulf Hermann2023-02-231-1/+0
| | | | | | | | | | | | | | | | | | They didn't work because the ordering of instructions is not the same as the ordering of lines. They also weren't very helpful because a single line may result in multiple instructions and vice versa. On top of everything, they also introduced UB via the std::upper_bound call. Rather, just print the name of the function and the place in the file at the beginning of each C++ function. That is much more helpful since we can then just correlate it to the original QML code. For instruction-by-instruction mapping we have to consult the byte code trace anyway. Pick-to: 6.5 6.4 6.2 Fixes: QTBUG-111340 Change-Id: I599ce384cfaf88a7347583a55976a3b98080435d Reviewed-by: Fabian Kosmale <[email protected]>
* QmlCompiler: Handle trivial signal handler constructionsUlf Hermann2022-07-071-2/+3
| | | | | | | | | | | | | | If the signal handler does nothing but return a closure, we have to compile the closure using the same signature as the outer signal handler. In order for this to work, we also have to detect unresolved argument types for signal handlers. Those are just as bad as unresolved argument types for other functions. Fixes: QTBUG-101531 Change-Id: Idb5b3994809d91a4b4ce936282685435eb75e670 Reviewed-by: Fabian Kosmale <[email protected]>
* Use SPDX license identifiersLucie Gérard2022-06-111-27/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <[email protected]>
* QmlCompiler: Clean up exportsUlf Hermann2022-03-301-9/+9
| | | | | | | | We need to export all the classes used by qmlsc, and we need to use the private export macro for private symbols. Change-Id: I91d59611e864621dc2c49b9383596e706529bd42 Reviewed-by: Fabian Kosmale <[email protected]>
* Turn qmlcompiler into a shared libraryMaximilian Goldstein2022-03-251-23/+31
| | | | | | | | | Converts qmlcompiler into a shared library so it isn't duplicated when statically linked in tools and so that plugins can link against it. Change-Id: I91e13cc588796f71a5463dbdce21e42a74120565 Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
* qqmljscompiler: Allow for reading file contents from memoryMaximilian Goldstein2021-12-131-2/+4
| | | | | | | | | | This is necessary in order for the qmllint library to provide linting in memory. This in turn is used by our LSP. Pick-to: 6.3 Change-Id: Ice01c16b4d9ff90cddac87c8840dc5556981f9d5 Reviewed-by: Andrei Golubev <[email protected]> Reviewed-by: Ulf Hermann <[email protected]>
* Pass qmldir to qmlcachegen, qmllint and qmltc, not the qmltypes fileUlf Hermann2021-12-131-2/+2
| | | | | | | | | | | | | | | | | | The tools will still grudgingly accept qmltypes files being passed via the -i option. We generally expect qmldir files, though. Ignoring the qmldir file and importing the qmltypes directly, ignores qmldir imports, dependencies and other component entries. This leads to unresolvable types. [ChangeLog][QML Tooling] qmllint expects qmldir files, not qmltypes files to be passed via the -i option now. This enables it to see the imports and dependencies of the module being imported. For backwards compatibility it still accepts qmltypes files, with a warning. Pick-to: 6.3 Fixes: QTBUG-99043 Change-Id: I5ed32d7e78df1e604aaf1bfa2ebda09d5d57b628 Reviewed-by: Fabian Kosmale <[email protected]>
* Add a default implementation for QQmlJSAotCompilerUlf Hermann2021-11-291-8/+36
| | | | | | | | | | | | | | | | The default AOT compiler compiles QML code in indirect, dynamic mode. It uses the logger's Log_Compiler category to determine the verbosity of its output. In addition you can use the qt.qml.compiler.aot category for even more verbosity. In preparation for using QQmlJSAotCompiler with qmlcachegen, the default level of that category is increased to QtFatalMsg. The highest level we actually output is QtDebugMsg, so it doesn't make a difference yet. If the logger's Log_Compiler category is set to produce errors, it will qFatal() on "pragma Strict" violations. Change-Id: Ieb74bfa7cd51cfa8616792ab467c32f6ba0e0702 Reviewed-by: Fabian Kosmale <[email protected]>
* QmlCompiler: Tighten the constness of various method parametersUlf Hermann2021-11-261-1/+1
| | | | | | | | | | The compile passes shouldn't need to change the document, AST, or IR. At least not accidentally. We might add interfaces to explicitly modify things later. As a side effect, you can now use one instance of QQmlJSTypeResolver for multiple documents by re-init()'ing it. Change-Id: Ic3544b3ddedd30d7f8d00b1df9cee3e6292ca7de Reviewed-by: Fabian Kosmale <[email protected]>
* qmllint: Move use-before-declaration warning out of checkidentifiersMaximilian Goldstein2021-08-041-2/+6
| | | | | | | Another step to making checkidentifiers obsolete. Change-Id: I14be7491387200101b66e0930faf16e9b61d4159 Reviewed-by: Fabian Kosmale <[email protected]>
* qv4bytecodegenerator: Supply SourceLocations in compiler contextMaximilian Goldstein2021-07-131-2/+3
| | | | | | | | | | This is required for better warnings in qmlcompiler's type propagator. Remains optional as to not consume superfluous memory when not needed (during normal QML engine operation). Change-Id: I50293f878e4f6659935925f5f2266427d2f64d7b Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Ulf Hermann <[email protected]> Reviewed-by: Andrei Golubev <[email protected]>
* QmlCompiler: Pass further information about the IR to AOT compilersUlf Hermann2021-03-191-1/+3
| | | | | | | | | | | | | Without access to the JSCodeGen and the contexts for functions and bindings, the AOT compiler is forced to re-generate the byte code for each function. Also filter out object bindings. The AOT compiler cannot generate anything sensible for those. Change-Id: I415ed23791dc220918cdf6d49e9ef5d005796239 Reviewed-by: Andrei Golubev <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>
* Add qCompileQmlFile overload with QmlIR::Document as in/out parameterAndrei Golubev2021-02-231-0/+3
| | | | | | | | | | | | | | | | QML compiler doesn't quite follow QQmlJSAotCompiler interface conventions and it's unclear if it can/should. However, it works with a populated QmlIR::Document and must really share the setup logic with some existing code. Thus, a new version of qCompileQmlFile is introduced that accepts QmlIR::Document as parameter to allow to use the set document afterwards. This way we can share the same code paths between qmlcachegen and qmlcompiler POC (and maybe even qmlcachegenplus could benefit) Task-number: QTBUG-84368 Change-Id: I4b662644a54e494a80224fe8512e3055952692c0 Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Ulf Hermann <[email protected]>
* QtQmlCompiler: Notify any AOT compiler about binding scope and objectUlf Hermann2020-11-241-1/+1
| | | | | | | | | The scope can be different from the object a binding is attached to. In particular, a group property or an attached property are executed in the scope of the surrounding object but are attached to the inner object. Change-Id: I3671c0ba425b791960f3205baaff91471d2e7205 Reviewed-by: Fabian Kosmale <[email protected]>
* V4: Allow passing arguments to AOT-compiled functionsUlf Hermann2020-11-201-0/+1
| | | | | Change-Id: I2340f4413ae9a44c71000e840a79e904b6a0fec9 Reviewed-by: Fabian Kosmale <[email protected]>
* QmlCompiler: Allow AOT compilation of JS functionsUlf Hermann2020-11-111-0/+2
| | | | | | | Previously, only bindings were compiled. Change-Id: I6e76c3f5e628e60538a0ed754fdd915978b88c1d Reviewed-by: Fabian Kosmale <[email protected]>
* QmlCompiler: Allow the specification of file scope codeUlf Hermann2020-11-031-1/+3
| | | | | | | | This can contain extra includes and code that should be added before any functions. Change-Id: Ida13d38ab7198c3986e134fe6f3786acd821927f Reviewed-by: Fabian Kosmale <[email protected]>
* QmlCompiler: Allow AOT compiled function to specify includesUlf Hermann2020-10-261-0/+1
| | | | | | | | This is necessary for include directives specific to the types being used. Change-Id: I34e0e5907d795714797fbb99a75b863cc41e9ad3 Reviewed-by: Fabian Kosmale <[email protected]>
* qmlcachegen: Move functions to compile QML/JS files to QmlCompilerUlf Hermann2020-10-231-0/+100
We need to re-use them. Also, provide a way to insert AOT compiled functions into the C++ code. Change-Id: I7b0d13cb307e8f979745f096a9614f087d135f68 Reviewed-by: Fabian Kosmale <[email protected]>