Commit Graph

50 Commits

Author SHA1 Message Date
Fabian Kosmale dd86881520 QQmlIRBuilder: Always preserve "undefined" string
QQmlIRBuilder skips storing binding scripts as a string to save memory.
However, for QQmlScriptString, we need the string to be available. This
is solved by running QQmlScriptStringScanner in the type compiler at
runtime, which sets the correct stringIndex for script string bindings.
However, that one does not run when we already have a compilation unit
from cachegen (and if we would run it unconditionally, we still would
miss the source code to recover the string).
We work around this issue by noting that QQmlScriptString only cares
about a very limited set of strings: Namely the various literals and
undefined. The literals are already correctly handled, as IRBuilder has
specific optimizations for them anyway. We now check in the generic case
whether the bindings string equals "undefined", and if so, ensure that
the string is registered.

Fixes: QTBUG-91165
Pick-to: 6.2
Change-Id: I4c4696952a082d1e69e0c9e5a0b9bf2470d59187
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-08-09 16:53:44 +02:00
Craig Scott 1c4ba17015 Refactor and update qml CMake API
The existing CMake API for qml modules had a number of
shortcomings. Refactor it to achieve the following:

- Clearly separate public and internal aspects.
- Re-use code from qtbase for adding plugins and module
  targets rather than reimplementing close variations.
- Provide more robust and complete support for qmllint,
  qmlcachegen and automatic generation of qmldir files.
- Reduce the steps needed for more common scenarios.
- Encourage the use of separate backing library and plugin
  targets.
- Automatically generate the plugin class .cpp file where
  possible.
- Specify .qml files directly through qml-specific API
  elements rather than assuming they can be extracted
  out of a set of resources.

[ChangeLog][QtQml] The qml CMake API has changed from 6.1
and is now out of Technical Preview status. The most
notable change is that .qml files should no longer be
specified as resources, there is dedicated handling for
them in the qt6_add_qml_module(). A related change is
that the qt6_target_qml_files() command has been replaced
by qt6_target_qml_sources(). More complete integration
with qmlcachegen, qmllint and qmldir generation is also
part of the CMake API.

Fixes: QTBUG-91621
Task-number: QTBUG-82598
Task-number: QTBUG-88763
Task-number: QTBUG-89274
Task-number: QTBUG-91444
Change-Id: I25aae1b0e89890394dfe2ba2824008164b2ca8d9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-06-04 16:54:52 +10:00
Kai Köhne c442542627 Move tools to libexec
Move qmlimportscanner, qmltyperegistrar, qmljsrootgen, qmlcachegen to libexec
These are internal tools that is not supposed to be run by the user directly.

[ChangeLog][Linux] qmlimportscanner, qmltyperegistrar, qmljsrootgen,
qmlcachegen tools got moved from QTDIR/bin into QTDIR/libexec
directory.

Task-number: QTBUG-88791
Change-Id: I2739044e872ec83ef7da7dd857c26395ecfd407d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2021-05-11 08:48:11 +02:00
Andreas Buhr 7e029878c0 Fix some "can be marked override" warnings
Change-Id: I13da0d085901314950c4fa0afb5853e183652e67
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-02-23 16:50:07 +01:00
Fabian Kosmale b322a971f0 QQmlIRLoader: Actually load RequiredPropertyExtraData
If a QML component wants to mark properties of its "parent" component as
required, it can do so via
required propertyName
The information about those properties is stored in a
RequiredPropertyExtraData data structure. This structure is already
serialized to disk in the QQmlIRWriter. However, we neglected to restore
it so far in the loader.

Fixes: QTBUG-90538
Pick-to: 5.15 6.0
Change-Id: I789daff9bc881e4f35c942c77f5116b5284de81b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-02-03 08:49:50 +01:00
Volker Hilsheimer 38b9c4f327 Fix additional warnings from usage of deprecated APIs
Replace more QLibaryInfo::location with QLibraryInfo::path

Replace old event accessors APIs, including relevant comments.

Change-Id: Ie205fc93b6e1c0dfb3dca9100fbde417ab68fc9f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-09-16 16:24:21 +02:00
Fabian Kosmale b4d36a05be QQmlIRLoader: Restore inline components correctly
Whether a component is an inline component is not only stored in the
flags, but also in the isInlineComponent member.
Ideally, this should be unified and the member removed, but for now we
just restore the value correctly.
Adjusted tst_qmlcachegen::initTestCase so that we testFile and
testFileUrl are actually usable in the test.

Fixes: QTBUG-84237
Pick-to: 5.15
Change-Id: I759cd6b8914b186b9e5c8118863fc8d0580d21af
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2020-07-22 09:57:06 +02:00
Ulf Hermann 41890402db Revive QTQUICK_COMPILER_SKIPPED_RESOURCES
There are valid reasons not to compile some resources with qmlcachegen.

Pick-to: 5.15
Fixes: QTBUG-85243
Change-Id: I9a1233864ed5dda0c264e61db596a9d8c80ea1f3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-06-30 09:39:55 +00:00
Ulf Hermann 84d58a43cd Make qmlcachegen test ASAN clean
The unitSize given there is the size of the qmlData. The previous code
copied some other random stuff around.

Change-Id: Idb5efac27fa9fbf6950850050627822a824e97ad
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-06-16 15:22:30 +02:00
Simon Hausmann fc3f603d00 Prepare for new members in QQmlPrivate::CachedQmlUnit
Pass the address of the entire structure through to the compiler, so
that when adding new members we can easily access them.

Change-Id: I5da75ba4e64d3e0e750a3ff3df4edbb88cdb6937
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-04-21 22:34:46 +02:00
Qt Forward Merge Bot 328b97a0ac Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts:
	src/qml/qml/qqmlpropertyvalidator.cpp
	tests/auto/qml/qmlmin/tst_qmlmin.cpp

Change-Id: I920c133e839d980ed32c179a0bc4fa44c46e2296
2019-10-24 15:42:35 +02:00
Ulf Hermann 00ae3b2323 Pass suitable nFormals when constructing JS stack frame
The extra formal parameters for signal handlers are not passed in
"registers" and therefore should not be given here.

Fixes: QTBUG-78486
Change-Id: I18594e0139a7a23d4e53b41e8b00b1e9f2e07aeb
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-21 14:39:44 +02:00
Qt Forward Merge Bot 9c7121df15 Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts:
	src/imports/qtquick2/plugins.qmltypes
	src/quick/items/qquickitemsmodule.cpp

Change-Id: I841c65c9c131354788b4f3fcfe3d7ed27be316d5
2019-10-04 11:29:16 +02:00
Simon Hausmann d5f3e7a7e3 Fix regression when using CONFIG+=QtQuickCompiler and .qrc files in subdirs
Commit 41864db3b6 removed the processing
of .qrc files that removed .qml/etc. files. Since the chaining of
resources remains critical to ensure that the cached compilation units
are loaded, the build system copied the input .qrc file to a new one.
That mere copying caused the build to break when the copied .qrc file
was not in the same directory as the original one, as file paths within
the .qrc file are interpreted as relative to the .qrc file, which was
now in a different location. To fix this, this patch brings back the
"filtering" code that rewrites the paths to the source files in the .qrc
file.

Fixes: QTBUG-78253
Change-Id: Ie1d56f3248e713a964260bc2da37c9374f7b6a36
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-09-19 11:32:23 +02:00
Liang Qi c80eb38354 Merge remote-tracking branch 'origin/5.13' into 5.14
Conflicts:
	src/qml/jsruntime/qv4engine.cpp
	src/quick/handlers/qquicktaphandler.cpp
	src/quick/items/qquicktableview.cpp

Done-With: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Done-With: Ulf Hermann <ulf.hermann@qt.io>
Done-With: Shawn Rutledge <shawn.rutledge@qt.io>
Change-Id: If9558a33f01693ce96420c094e0b57dfff0626cd
2019-09-12 08:01:21 +02:00
Simon Hausmann 41864db3b6 Fix *.js files disappearing from RESOURCES when not using QtQml
[ChangeLog][QtQml][Important Behavior Changes] Using the Qt Quick
Compiler would exclude the original .qml files from the resource system.
This made it impossible to change the Qt library binary later as the
program binary was tied the to the exact Qt version. In addition
sometimes unrelated files (QTBUG-73669) were removed. For the latter
scenario, retain and skip options were added for the Qt Quick Compiler.
In Qt 5.15 the Qt Quick Compiler does not remove the input files
anymore. All files are retained and the compiler merely adds the more
efficient binary representation to the application.

Task-number: QTBUG-73669
Change-Id: I5a523bfc69d4f48a1451bd880616c82fd73b8d15
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2019-09-09 07:52:25 +02:00
Qt Forward Merge Bot f6ab93a9f9 Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I0ae0a162e133cffd8fb1a2c6b70826e50f06facd
2019-08-28 07:34:06 +02:00
Simon Hausmann 4b944cb61f Fix loading of ES modules when using CONFIG += qtquickcompiler
Added the missing lookup for cached .mjs files in
ExecutionEngine::compileModule. This allows using .mjs files in
WorkerScript {} elements in conjunction with the Qt Quick Compiler and
also fixes the use when using QJSEngine::importModule.

[ChangeLog][QtQml] Fix loading of EcmaScript modules when using the Qt
Quick Compiler.

Fixes: QTBUG-77761
Change-Id: I58130b0468f4920b2f6c49b98a2f51d5ae3a0491
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2019-08-26 12:42:05 +02:00
Ulf Hermann be600348ef Split qqmltypeloader{_p.h|.cpp} into a several files
No one can read this mess.

Change-Id: Icec4f2afc466435c1ae5e4e80fa2c1b5baf7d087
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-11 09:42:52 +02:00
Qt Forward Merge Bot a1e38651ce Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
	.qmake.conf
	src/qmltest/quicktest.cpp
	tests/auto/qml/qmlcachegen/qmlcachegen.pro

Change-Id: I70e96e8817d59647f876b8b77b30cdeede8f0662
2019-03-25 10:13:23 +01:00
Ulf Hermann 497a795081 Initialize TranslationData padding before writing cache files
Otherwise the resulting files differ subtly.

Fixes: QTBUG-74532
Change-Id: I12b4f1ba6dda781d63ad50cce87861ba24582bf7
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-03-21 16:29:29 +00:00
Ulf Hermann 21ffde85a1 Add option to retain sources when generating QML cache
By default any .qrc files are filtered and QML and JS sources dropped
when generating the cache. The new QTQUICK_COMPILER_RETAINED_RESOURCES
option allows the specification of .qrc files to be kept as they are.
The source fils specified in them will be available to the application.

Change-Id: If45bcd95c29fe4b91f5817573964ff55b1db8a00
Fixes: QTBUG-72430
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-01-04 14:13:49 +00:00
Frederik Gladhorn 00b1ff4607 Fix translation bindings when qtquickcompiler is used
It turns out that the context information is lost when using the
compiler. The unit->unitData()->sourceFileIndex is wrong (always 0),
which should probably be fixed. This change only works around that by
using unit->fileName(); instead.
Make sure that the test actually verifies translations happen and have a
context.

Done-with: Jan Arve Sæther
Fixes: QTBUG-71553
Change-Id: Ib5926bd4b9a6267644f5c9328a84c23d61ca5466
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-11-06 10:40:15 +00:00
Simon Hausmann 4b2b1fc121 Add support for compiling ES modules ahead of time
This is also pretty straight-forward by adding .mjs as supported
extension in the qmake and cmake support.

This also tweaks qv4engine.cpp to share the same module compilation
function across all code paths.

Change-Id: Ia0e23c78a794f2330ecf8f991ee6ea948f4ac89d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-08-17 11:06:18 +00:00
Simon Hausmann e99038b24d Reduce memory consumption when loading AOT generated cache files
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>
2018-08-01 09:42:06 +00:00
Simon Hausmann a05d1796b8 Simplify signal handler parameter handling
Unify the two QQmlBoundSignalExpression constructors and always call
updateInternalClass on the run-time function to set up the parameter
name -> argument mapping.

This streamlines the code, shares the error handling for unnamed
parameter clashes and allows getting rid of the code to extend the
formals of functions that become signal handlers in AOT generated cache
files. Either

   onThatSignal: function(param1, param2) { ... }

syntax is used and the mapping is fixed and known at AOT/compile time.
Or alternatively the dynamic variant is used where the formals are
determined at signal handler installation time.

Saves a whopping KB of RAM on the QQC1 gallery.

Change-Id: I33a9afc06474143d7893f42366cb6553a07ce937
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-07-31 17:08:19 +00:00
Simon Hausmann 8237f645a3 Optimize memory consumption of ahead-of-time compile cache files
When loading a pre-compiled cache file, the strings contained therein
will remain available in memory since commit
7dcada48d2. 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>
2018-07-31 17:08:08 +00:00
Simon Hausmann f70a25aecb Reduce memory usage when loading QML files from AOT generated caches
When we have to modify the string table, we should make sure to discard
the old one for the new CompiledData::Unit we hold in memory. This also
allows discarding the old QML tables as they'll be rewritten anyway.

Saves about ~402K RAM with qtquickcontrols1 gallery.

Task-number: QTBUG-69588
Change-Id: Iae3e9fe2578ea8cb7ec1859ce660f75cfb388dee
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-07-31 12:01:04 +00:00
Simon Hausmann 8e45393d10 Fix import of precompiled .js files
Loading those must not fail the file relocation test, so set the source
file names to empty, as we also do for .qml files.

Also added tests for all the scenarios: no embedded file paths for AOT
files but absolute paths for run-time created cache files.

Change-Id: I3fc92e89cfd0da512afeac22bd0da3e915ec46ea
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-07-31 07:28:03 +00:00
Simon Hausmann e56eeee990 Encapsulate the unit data in CompilationUnit
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>
2018-07-31 05:13:48 +00:00
Thiago Macieira 447e2e0246 Try to load QML cache from CacheLocation if side-by-side fails
This could happen if the .qmlc file is stale or corrupt for some reason.
In that case, we should try to load a cache file from the user's
CacheLocation.

Change-Id: Id2be776c7ae0467c9d9ffffd1543204272a531d1
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-07-27 04:56:14 +00:00
Simon Hausmann d6177808d6 Clarify error message when using eval in signal handlers
Task-number: QTBUG-64024
Change-Id: If8f749ef9ec072928cb352ad7cd4dcf140b6ed53
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-06-28 07:56:46 +00:00
Simon Hausmann 0996f18b25 Fix CONFIG+=qtquickcompiler with umlauts in the file path
Instead of replacing every character that is not allowed in C++
identifiers with an underscore (which in turn could lead to
collissions), replace it with the hexadecimal value of the offending
character's unicode value.

In addition we must use the complete suffix when mapping Foo.qml to
Foo_qml.cpp.

Task-number: QTBUG-68608
Started-by: Erik Verbruggen <erik.verbruggen@qt.io>
Change-Id: I7e2153f0e6671b37dcaee4efb9aaae1d9b230f0c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2018-06-19 13:30:35 +00:00
Michael Brasser 1aecb24682 Ensure we restore QML-defined enums
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>
2018-05-23 08:00:41 +00:00
Simon Hausmann 0a2aaee61c Fix .import within .js files with CONFIG+=qtquickcompiler
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>
2018-05-11 19:18:45 +00:00
Simon Hausmann e09a02fac0 Fix CONFIG+=qtquickcompiler with paths that contain spaces
Map spaces to underscores as well.

Task-number: QTBUG-54683
Change-Id: Id73c086a2845111623df631c06733ba2b42249e0
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2018-03-27 18:44:32 +00:00
Simon Hausmann 64e90f3931 Fix QML data structure version checking for ahead-of-time generated files
We must also do version checking for QML and JS files that were compiled
ahead of time and are embedded in resources. If the lookup for the
original source code fails, then we must generate an appropriate error
message.

As an upside we get better error reporting when trying to load an empty
file and Qt.include() now reports the error message in the statusText
field.

The error reporting for imported scripts was not changed as importing an
empty script is (oddly) allowed.

Task-number: QTBUG-66986
Change-Id: Ie0ef81af371a51ecf8c66ae7954d43f5cc6c12de
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2018-03-20 09:44:11 +00:00
Erik Verbruggen 22b13921f8 Handle function expressions as signal handlers
There are two ways to use function expressions on the right-hand side
of bindings:

  property var somethingPressed
  somethingPressed: function() { /* ..press something else.. */ }

  signal buttonPressed
  onButtonPressed: function() { /* ..handle buttonPress.. */ }

In the former case, it declares a property that holds a function. So on
initialization, the right-hand side of the binding returns a closure
that gets assigned to the property 'somethingPressed'.

In the latter case, the signal handler is explicitly marked as a
function for clarity. So, the handler should not be returning the
closure, but the handler should *be* the closure.

In general, it is not possible to detect if the left-hand side is a
property or a signal handler when generating QML cache files ahead of
time. So for this case, we mark the function as only returning a
closure. Then when instantiating the object, we check if it is a signal
handler, and if the handler is marked as only returning a closure. If
so, we set that closure to be the signal handler.

Task-number: QTBUG-57043
Task-number: QTBUG-50328
Change-Id: I3008ddd847e30b7d0adef07344a326f84d85f1ba
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-03-20 09:38:27 +00:00
Liang Qi 4d525de33e Merge remote-tracking branch 'origin/5.10' into 5.11
Conflicts:
	src/imports/shapes/qquickshape.cpp
	src/imports/shapes/qquickshape_p_p.h
	src/qml/compiler/qqmlpropertycachecreator_p.h
	src/qml/jsruntime/qv4value_p.h
	src/quick/items/qquickloader_p.h
	tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
	tools/qmlprofiler/qmlprofilerapplication.cpp

Change-Id: Iafc66ae84bf78630ed72a986acb678e9d19e3a69
2018-02-12 16:31:13 +01:00
Liang Qi 2e65f6c2a5 Merge remote-tracking branch 'origin/5.9' into 5.10
Change-Id: I41ca9120a470a905c2f5c168c1de4cf970fa0fff
2018-02-02 09:50:10 +01:00
Simon Hausmann 7bd5d93899 Fix memory leak with QtQuick compiler generated files
When for the QQC code path we do QML type re-compilation, we allocate a
new QV4::CompiledData::Unit. We must make sure that this dynamically
allocated memory is released in QV4::CompiledData::CompilationUnit's
destructor, by ensuring that the StaticData flag is not set.

This isn't directly applicable to the ahead-of-time generated cache file
unit data as they will always be re-generated (and thus the unsetting of
StaticData at the end of createCompilationUnit::createUnitData()), but
I've added a test-case nevertheless to ensure the correct engine
behavior.

Change-Id: I16973d7989567892bf8bf9dd6214bf293055d260
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-02-02 05:46:20 +00:00
Simon Hausmann e5b157275d Add support for compiling QML/JS files ahead of time in resources
This is bringing over the loading infrastructure from the Qt Quick
Compiler that allows embedding qml/js files in resources and compiling
them ahead of time.

At the moment, the approach of generating one cpp file per qml/js file
and the loader stub is needed because the build system does not support
dynamic resource generation. In addition, as per QTBUG-60961, we must
ensure that the generated data structures are aligned.

To retain compatibility this is enabled via CONFIG += qtquickcompiler,
but we may need to find a new name (but should keep the old one in any
case).

Task-number: QTBUG-60961
Change-Id: Ia9839bf98d3af4c50636b6e06815364a9fc7ee57
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-01-28 16:37:26 +00:00
Simon Hausmann 1ab5d14615 Minor data structure cleanup
The cache files are architecture and ABI independent, so we can remove
any associated field/code as well as the workaround for Android.

Change-Id: Ia52a5be886fc22a2105460e003e7a76af7dc1818
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-01-22 09:21:38 +00:00
Simon Hausmann 781caafe1f Fix decoding of bytecode instructions on ARM generated on x86-64
Due to the difference of sign of the char type, byte code is encoded
differently on x86-64 than if it was on ARM and it also is decoded
differently. The problem at hand here was that negative jumps were
encoded as two-byte instructions (opcode and negative offset as byte) on
x86-64 when qmlcachegen is run. At run-time the negative offset was read
into a char type and consequently interpreted as a positive jump,
leading to crashes.

The explicit use of qint8 as signed byte type in encoding/decoding
sensitive parts avoids the decoding issue and should also result in
consistent encoding.

The added auto-test is (among other configurations) run in the CI under
qemu, which means the x86-64 host-built qmlcachegen will generate byte
code and the tst_qmlcachegen ARM binary will run under qemu and
reproduce this scenario.

Task-number: QTBUG-65521
Change-Id: I615628f53475dad38a41095c6e7ffea0c34d58ac
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-01-05 12:44:17 +00:00
Lars Knoll 55a671ea73 Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts:
	src/qml/compiler/qv4compileddata.cpp
	src/qml/compiler/qv4compileddata_p.h
	src/qml/jsruntime/qv4engine.cpp
	src/qml/jsruntime/qv4qmlcontext.cpp
	src/qml/jsruntime/qv4qmlcontext_p.h
	src/qml/jsruntime/qv4regexpobject.cpp
	src/qml/jsruntime/qv4regexpobject_p.h
	src/qml/types/qqmllistmodel.cpp
	src/quick/items/qquickanimatedimage_p.h
	src/quick/scenegraph/qsgrenderloop.cpp
	tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp

Change-Id: If20ef62b2c98bdf656cb2f5d27b1897b754d3dc0
2017-09-20 14:27:41 +02:00
Simon Hausmann fa00f0a020 Error out when compiling signal handlers with arguments in qml files
Ahead of time we cannot tell whether the use of "arguments" in a signal
hander refers to the JS arguments object or a potential arguments signal
parameter. Resolving that requires access to information we currently
don't have. The QML engine has it at run-time (in
SignalHandlerConverter) and that's why it works there accordingly.
However when generating caches ahead of time, let's rather produce an
error message with a hint how to work around it instead of producing
differing behavior at run-time.

Task-number: QTBUG-60011
Change-Id: I9e460bd467dbb5998f12a44c439223ea44e7bbad
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-09-12 19:50:16 +00:00
Simon Hausmann 463a1ed22a Fix lookup of formals in QML signal handlers with AOT
Partially revert commit 38221427bc to
allow for the lookup of formals by name even when using the simple call
context.

Task-number: QTBUG-61531
Change-Id: Ic5b235b62949ce050817ef2937bd4a35dd64aa6a
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-06-21 14:02:39 +00:00
Simon Hausmann 9b961334cf Fix support for jsTr() and QT_TR_NOOP in list elements when caching
Similar to the Qt Quick Compiler we need to do the expression
simplification pass at cache generation time to extract translation
calls in list elements.

Change-Id: I267fc9647ab82bc83d6b087c06c0036df38238ff
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-04-06 11:19:16 +00:00
Simon Hausmann fcb9a74078 Fix loading of ahead-of-time generated cache files when cross-compiling
The target ABI is something that we must include correctly at cache
generation time. The corresponding qmake variable is available in qtbase
now, so we can use that and embed it in the generated data.

Change-Id: Icd6e44824f5151535ce9ddac27687b7877288725
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-04-06 08:14:52 +00:00
Simon Hausmann 80060b7bec Add auto-test for qmlcachegen
This test writes a simple QML file with embedded JS code into a
temporary directory, calls qmlcachegen to generate the cache file,
removes the original source code and tries to load the component.

Change-Id: I63e1b0c76a987f4a21b3dc6cb7c4dc828dd5d11f
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-04-06 06:58:44 +00:00