diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2022-06-27 16:26:43 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-07-05 19:50:19 +0200 |
| commit | 46396070368568d44597a36b7c7646f139d92b23 (patch) | |
| tree | dd94c75c1b9f5cc61bcc19d5ee4b2f61b18a614d /tests/auto/qml/qmlcppcodegen/data/javaScriptArgument.qml | |
| parent | 5e4a1738b05f6f188eada38f1805018bdccc1c96 (diff) | |
QmlCompiler: Really fix writing into argument values
Arguments are now treated as registers "written" at the beginning of
the first basic block. By modeling them this way, we can avoid all the
complicated logic on whether to use a local or the arguments array when
accessing any particular one of them. Furthermore, we can detect whether
they are overwritten or not. If they are not overwritten, we can
initialize them as a const reference into the arguments array. This way
we save a copy.
Treating the arguments as generic registers causes the basic blocks pass
to aggressively adjust their types, pushing some conversions back into
the QML engine. This is good. Unused arguments become void, for example,
and don't have to be passed at all. However, we also need a special case
for QJSPrimitiveValue arguments now.
Pick-to: 6.4
Fixes: QTBUG-104462
Change-Id: I994bea0929bd508aa41db58dee4a7f12cd20f053
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/data/javaScriptArgument.qml')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/javaScriptArgument.qml | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/javaScriptArgument.qml b/tests/auto/qml/qmlcppcodegen/data/javaScriptArgument.qml index 870540240e..058a2ad574 100644 --- a/tests/auto/qml/qmlcppcodegen/data/javaScriptArgument.qml +++ b/tests/auto/qml/qmlcppcodegen/data/javaScriptArgument.qml @@ -31,4 +31,86 @@ QtObject { property string c: stringMinusOne(-5) property string d: stringMinusOne(10) + + function printAmount(amount: real) : string { + var sign; + if (amount < 0) { + sign = "-"; + amount = -amount; + } else { + sign = ""; + } + return sign + amount; + } + + property string e: printAmount(10); + property string f: printAmount(-10); + + readonly property string units: " kMGT" + + function roundTo3Digits(number: real) : real { + var factor; + + if (number < 10) + factor = 100; + else if (number < 100) + factor = 10; + else + factor = 1; + + return Math.round(number * factor) / factor; + } + + function prettyPrintScale(amount: real) : string { + var sign; + if (amount < 0) { + sign = "-"; + amount = -amount; + } else { + sign = ""; + } + var unitOffset = 0; + var unitAmount = 1; + for (unitOffset = 0; amount > unitAmount * 1024; ++unitOffset, unitAmount *= 1024) {} + var result = amount / unitAmount; + return sign + roundTo3Digits(result) + units[unitOffset]; + } + + property list<string> scales: [ + prettyPrintScale(0), + + prettyPrintScale(1), + prettyPrintScale(10), + prettyPrintScale(100), + prettyPrintScale(1000), + prettyPrintScale(10000), + prettyPrintScale(100000), + prettyPrintScale(1000000), + prettyPrintScale(10000000), + prettyPrintScale(100000000), + prettyPrintScale(1000000000), + prettyPrintScale(10000000000), + prettyPrintScale(100000000000), + prettyPrintScale(1000000000000), + prettyPrintScale(10000000000000), + + prettyPrintScale(-1), + prettyPrintScale(-10), + prettyPrintScale(-100), + prettyPrintScale(-1000), + prettyPrintScale(-10000), + prettyPrintScale(-100000), + prettyPrintScale(-1000000), + prettyPrintScale(-10000000), + prettyPrintScale(-100000000), + prettyPrintScale(-1000000000), + prettyPrintScale(-10000000000), + prettyPrintScale(-100000000000), + prettyPrintScale(-1000000000000), + prettyPrintScale(-10000000000000), + ] + + function forwardArg(a: real) : string { + return prettyPrintScale(a); + } } |
