<feed xmlns='http://www.w3.org/2005/Atom'>
<title>qt/qtdeclarative.git/src/qml/jsruntime/qv4runtime.cpp, branch wip/nativemenus</title>
<subtitle>Qt Declarative (Quick 2)
</subtitle>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/'/>
<entry>
<title>QML: Deprecate coercion on type assertions</title>
<updated>2024-05-24T06:22:23+00:00</updated>
<author>
<name>Ulf Hermann</name>
<email>ulf.hermann@qt.io</email>
</author>
<published>2024-04-26T16:31:40+00:00</published>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=71e259837967f1eee50c057229094c2a971a1a61'/>
<id>71e259837967f1eee50c057229094c2a971a1a61</id>
<content type='text'>
By using an "as" cast you want to check the type of the value, not
coerce it. Previously, however, if you did this with a value type, it
would create the value type instead of just checking for it.

Add an attribute "Assertable" to the ValueTypeBehavior pragma that
prevents this and enables the correct behavior. Also print a warning
when coercing as part of an as-cast.

[ChangeLog][QtQml] A new attribute "Assertable" has been added to the
"ValueTypeBehavior" pragma. You should always use it if you want to
type-check value types using "as". If you don't use it, an instance of
the type is created as result of the "as" if the type doesn't match.

Task-number: QTBUG-124662
Change-Id: I1d5a6ca0a6f97d7d48440330bed1f9f6472198aa
Reviewed-by: Fabian Kosmale &lt;fabian.kosmale@qt.io&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
By using an "as" cast you want to check the type of the value, not
coerce it. Previously, however, if you did this with a value type, it
would create the value type instead of just checking for it.

Add an attribute "Assertable" to the ValueTypeBehavior pragma that
prevents this and enables the correct behavior. Also print a warning
when coercing as part of an as-cast.

[ChangeLog][QtQml] A new attribute "Assertable" has been added to the
"ValueTypeBehavior" pragma. You should always use it if you want to
type-check value types using "as". If you don't use it, an instance of
the type is created as result of the "as" if the type doesn't match.

Task-number: QTBUG-124662
Change-Id: I1d5a6ca0a6f97d7d48440330bed1f9f6472198aa
Reviewed-by: Fabian Kosmale &lt;fabian.kosmale@qt.io&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>V4: Move FunctionObject flags into VTable</title>
<updated>2024-05-14T12:17:02+00:00</updated>
<author>
<name>Ulf Hermann</name>
<email>ulf.hermann@qt.io</email>
</author>
<published>2024-05-06T15:18:09+00:00</published>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=1f13344e500e837e296212eaf3525e57e14cd055'/>
<id>1f13344e500e837e296212eaf3525e57e14cd055</id>
<content type='text'>
These are really rather generic type traits that shouldn't be stored in
individual objects. Moving them away slims down FunctionObject even
more.

FunctionObject doesn't add any extra overhead on top of Object anymore.
You also cannot easily cast an object that doesn't implement any call
methods to FunctionObject anymore. Therefore, we can derive from
FunctionObject even if we only need to implement call methods in a
further derived class.

The fact that ProxyObject is not a FunctionObject but its derivatives
are is already tested as part of the ecmascript test suite.

Task-number: QTBUG-124662
Change-Id: I5632de8c54ac1d6a4b15c4926c655b87b475db49
Reviewed-by: Fabian Kosmale &lt;fabian.kosmale@qt.io&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
These are really rather generic type traits that shouldn't be stored in
individual objects. Moving them away slims down FunctionObject even
more.

FunctionObject doesn't add any extra overhead on top of Object anymore.
You also cannot easily cast an object that doesn't implement any call
methods to FunctionObject anymore. Therefore, we can derive from
FunctionObject even if we only need to implement call methods in a
further derived class.

The fact that ProxyObject is not a FunctionObject but its derivatives
are is already tested as part of the ecmascript test suite.

Task-number: QTBUG-124662
Change-Id: I5632de8c54ac1d6a4b15c4926c655b87b475db49
Reviewed-by: Fabian Kosmale &lt;fabian.kosmale@qt.io&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>V4: Slim down FunctionObject</title>
<updated>2024-05-14T12:16:57+00:00</updated>
<author>
<name>Ulf Hermann</name>
<email>ulf.hermann@qt.io</email>
</author>
<published>2024-04-30T09:55:01+00:00</published>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=8b6a9403bf2e04d34b9b07d2780186029fab99d0'/>
<id>8b6a9403bf2e04d34b9b07d2780186029fab99d0</id>
<content type='text'>
Most FunctionObjects do not actually need their custom jsCall members.
They will only call the functions from the vtable anyway. FunctionObject
can therefore be split into a static and a dynamic variant. Only the
dyanmic variant needs to carry (and invoke) the extra pointer. The
jsCallWithMetaTypes pointer is completely pointless because none of the
dynamic functions actually implement it.

Furthermore, the QV4::Function and QV4::ExecutionContext pointers in
FunctionObject are only needed by actual JavaScript functions. The
builtins that like to be dynamic functions never need them. Therefore,
split out another class for this.

In the generic FunctionObject, we need the capability to decide at run
time whether the function shall be a constructor or not. Add a flag to
replace the check for jsCallAsConstructor.

Also, where we can, avoid the pessimization of checking whether a
function is a constructor before trying to call it as constructor.
Rather have the default implementation throw the exception.

As a side effect, for most functions we don't need an ExecutionContext
anymore. The engine is enough.

Task-number: QTBUG-124662
Change-Id: Iac657fa71288dd6ec230a33de2986ba3bcf4628c
Reviewed-by: Fabian Kosmale &lt;fabian.kosmale@qt.io&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Most FunctionObjects do not actually need their custom jsCall members.
They will only call the functions from the vtable anyway. FunctionObject
can therefore be split into a static and a dynamic variant. Only the
dyanmic variant needs to carry (and invoke) the extra pointer. The
jsCallWithMetaTypes pointer is completely pointless because none of the
dynamic functions actually implement it.

Furthermore, the QV4::Function and QV4::ExecutionContext pointers in
FunctionObject are only needed by actual JavaScript functions. The
builtins that like to be dynamic functions never need them. Therefore,
split out another class for this.

In the generic FunctionObject, we need the capability to decide at run
time whether the function shall be a constructor or not. Add a flag to
replace the check for jsCallAsConstructor.

Also, where we can, avoid the pessimization of checking whether a
function is a constructor before trying to call it as constructor.
Rather have the default implementation throw the exception.

As a side effect, for most functions we don't need an ExecutionContext
anymore. The engine is enough.

Task-number: QTBUG-124662
Change-Id: Iac657fa71288dd6ec230a33de2986ba3bcf4628c
Reviewed-by: Fabian Kosmale &lt;fabian.kosmale@qt.io&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>QtQml: Re-allow manual calling of signal handlers</title>
<updated>2024-02-13T19:04:59+00:00</updated>
<author>
<name>Ulf Hermann</name>
<email>ulf.hermann@qt.io</email>
</author>
<published>2024-02-06T16:01:45+00:00</published>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=03ac6a0990afeb0ea3294e22d6e553a4370f32eb'/>
<id>03ac6a0990afeb0ea3294e22d6e553a4370f32eb</id>
<content type='text'>
The fact that you could do this was due to a mistake in the
implementation of QQmlPropertyCache. The cache entry for the signal
handler looked like the signal itself. Make it possible to call
QmlSignalHandler objects, and output a categorized warning when doing
so. Also, align the call code between the interpreter and the JIT.

Pick-to: 6.7
Fixes: QTBUG-120573
Change-Id: Ic76d37f587d21b68c55d77a08ac2d30950bec133
Reviewed-by: Fabian Kosmale &lt;fabian.kosmale@qt.io&gt;
Reviewed-by: Yifan Zhu &lt;fanzhuyifan@gmail.com&gt;
Reviewed-by: Qt CI Bot &lt;qt_ci_bot@qt-project.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The fact that you could do this was due to a mistake in the
implementation of QQmlPropertyCache. The cache entry for the signal
handler looked like the signal itself. Make it possible to call
QmlSignalHandler objects, and output a categorized warning when doing
so. Also, align the call code between the interpreter and the JIT.

Pick-to: 6.7
Fixes: QTBUG-120573
Change-Id: Ic76d37f587d21b68c55d77a08ac2d30950bec133
Reviewed-by: Fabian Kosmale &lt;fabian.kosmale@qt.io&gt;
Reviewed-by: Yifan Zhu &lt;fanzhuyifan@gmail.com&gt;
Reviewed-by: Qt CI Bot &lt;qt_ci_bot@qt-project.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>String: optimize integer conversion</title>
<updated>2024-01-18T10:12:29+00:00</updated>
<author>
<name>Fabian Kosmale</name>
<email>fabian.kosmale@qt.io</email>
</author>
<published>2024-01-17T20:19:02+00:00</published>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=3968a651abd2192b0b2d46e3382b456f4d155f6d'/>
<id>3968a651abd2192b0b2d46e3382b456f4d155f6d</id>
<content type='text'>
If we want to append an integer to a string, there is no need to run the
complete floating point formatting machinery specified by ECMAScript.
Instead, simply use QString::number.

Change-Id: Iea0421cc908239e75b34de2181a345a32416a803
Reviewed-by: Ulf Hermann &lt;ulf.hermann@qt.io&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If we want to append an integer to a string, there is no need to run the
complete floating point formatting machinery specified by ECMAScript.
Instead, simply use QString::number.

Change-Id: Iea0421cc908239e75b34de2181a345a32416a803
Reviewed-by: Ulf Hermann &lt;ulf.hermann@qt.io&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>V4: Eliminate "done" from iterators</title>
<updated>2023-09-08T20:27:58+00:00</updated>
<author>
<name>Ulf Hermann</name>
<email>ulf.hermann@qt.io</email>
</author>
<published>2023-08-25T13:40:37+00:00</published>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=e7eb542a553c75cdb917450915addb3b9e20c0db'/>
<id>e7eb542a553c75cdb917450915addb3b9e20c0db</id>
<content type='text'>
Instead of dragging another stack value around to mark if the iterator
was done, rather pass it an offset it should jump to if so. It can then
jump over any IteratorClose instruction while the ExceptionHandler can
still point to the IteratorClose instruction.

For this to work, we also have to refrain from checking for exceptions
as part of IteratorNext or IteratorClose. If IteratorNext generates an
exception, it also jumps to the "done" label, after which we dispatch
the exception. We don't want to jump to the exception handler for other
instructions in between as that would close the iterator. The iterator
should _not_ be closed if it has just thrown an exception, though. The
same holds for IteratorClose: If it throws an exception, we don't want
to jump back to the beginning of the loop's exception handler, since
that would produce an infinite loop. We also don't want to reset the
exception handler before IteratorClose because it needs to also be reset
if the iterator does not need to be closed.

This saves quite a few instructions and stack variables on actual
iteration.

For destructuring, we have to change the execution flow a bit. We need
to first perform the iteration for non-rest parameters, saving the
results in separate stack slots. This way we can apply our new "jump if
done" behavior if the iterator runs out or produces an exception itself.
We then save the "done" state in a separate stack slot, as before.
During the assignment of the iteration results to the actual variables,
we install an exception handler, so that we can still close the iterator
if one of the initializers throws an exception. This produces a few more
instructions than before:

1. We need to set and read the "needsClose" variable explicitly rather
   than having IteratorNext and IteratorDone do it implicitly.
2. We need an additional CheckException after the iteration.
3. We need an additional conditional Jump over the IteratorDone.

Everything considered, the savings we get for regular iteration and the
more consistent semantics of the instructions involved are well worth
the few extra instructions on destructuring, especially since everything
those extra instructions do was done implicitly by the iterator
instructions before.

For consistency, the IteratorNextForYieldStar instruction is refactored
to work the same way as IteratorNext: In case of either an exception or
"done" it jumps to an offset, and we refrain from individually
exception-checking each IteratorNextForYieldStart instruction.

Task-number: QTBUG-116725
Change-Id: I9e2ad4319495aecabafdbbd3dd0cbf3c6191f942
Reviewed-by: Olivier De Cannière &lt;olivier.decanniere@qt.io&gt;
Reviewed-by: Sami Shalayel &lt;sami.shalayel@qt.io&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Instead of dragging another stack value around to mark if the iterator
was done, rather pass it an offset it should jump to if so. It can then
jump over any IteratorClose instruction while the ExceptionHandler can
still point to the IteratorClose instruction.

For this to work, we also have to refrain from checking for exceptions
as part of IteratorNext or IteratorClose. If IteratorNext generates an
exception, it also jumps to the "done" label, after which we dispatch
the exception. We don't want to jump to the exception handler for other
instructions in between as that would close the iterator. The iterator
should _not_ be closed if it has just thrown an exception, though. The
same holds for IteratorClose: If it throws an exception, we don't want
to jump back to the beginning of the loop's exception handler, since
that would produce an infinite loop. We also don't want to reset the
exception handler before IteratorClose because it needs to also be reset
if the iterator does not need to be closed.

This saves quite a few instructions and stack variables on actual
iteration.

For destructuring, we have to change the execution flow a bit. We need
to first perform the iteration for non-rest parameters, saving the
results in separate stack slots. This way we can apply our new "jump if
done" behavior if the iterator runs out or produces an exception itself.
We then save the "done" state in a separate stack slot, as before.
During the assignment of the iteration results to the actual variables,
we install an exception handler, so that we can still close the iterator
if one of the initializers throws an exception. This produces a few more
instructions than before:

1. We need to set and read the "needsClose" variable explicitly rather
   than having IteratorNext and IteratorDone do it implicitly.
2. We need an additional CheckException after the iteration.
3. We need an additional conditional Jump over the IteratorDone.

Everything considered, the savings we get for regular iteration and the
more consistent semantics of the instructions involved are well worth
the few extra instructions on destructuring, especially since everything
those extra instructions do was done implicitly by the iterator
instructions before.

For consistency, the IteratorNextForYieldStar instruction is refactored
to work the same way as IteratorNext: In case of either an exception or
"done" it jumps to an offset, and we refrain from individually
exception-checking each IteratorNextForYieldStart instruction.

Task-number: QTBUG-116725
Change-Id: I9e2ad4319495aecabafdbbd3dd0cbf3c6191f942
Reviewed-by: Olivier De Cannière &lt;olivier.decanniere@qt.io&gt;
Reviewed-by: Sami Shalayel &lt;sami.shalayel@qt.io&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>V4: Use memmove() for tail calls</title>
<updated>2023-07-24T19:27:29+00:00</updated>
<author>
<name>Ulf Hermann</name>
<email>ulf.hermann@qt.io</email>
</author>
<published>2023-07-24T13:31:33+00:00</published>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=d4a6673d2e66d7f0e26cb8a4265adfc5c0ef0577'/>
<id>d4a6673d2e66d7f0e26cb8a4265adfc5c0ef0577</id>
<content type='text'>
If you have many arguments, the argument ranges can overlap. In that
case memcpy is UB.

Pick-to: 6.2 6.5 6.6
Fixes: QTBUG-115320
Change-Id: I54dd4d7762e7278502954b8ac2cb4af1197ce88c
Reviewed-by: Fabian Kosmale &lt;fabian.kosmale@qt.io&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If you have many arguments, the argument ranges can overlap. In that
case memcpy is UB.

Pick-to: 6.2 6.5 6.6
Fixes: QTBUG-115320
Change-Id: I54dd4d7762e7278502954b8ac2cb4af1197ce88c
Reviewed-by: Fabian Kosmale &lt;fabian.kosmale@qt.io&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>QML: Use new coerce() method also for 'as' casts</title>
<updated>2023-06-26T18:43:02+00:00</updated>
<author>
<name>Ulf Hermann</name>
<email>ulf.hermann@qt.io</email>
</author>
<published>2023-06-26T09:06:22+00:00</published>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=cae23efe45ee92b41b7899a28d4d1d7d1048584d'/>
<id>cae23efe45ee92b41b7899a28d4d1d7d1048584d</id>
<content type='text'>
Casting via QVariant is unreliable and inefficient. toVariant() is not
required to produce the type we are requesting.

Amends commit 05f56d7c78754855c643470ad4e8dfd35c96f927.

Change-Id: Idabcac7420155649692ec589d637dd9ee3016716
Reviewed-by: Fabian Kosmale &lt;fabian.kosmale@qt.io&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Casting via QVariant is unreliable and inefficient. toVariant() is not
required to produce the type we are requesting.

Amends commit 05f56d7c78754855c643470ad4e8dfd35c96f927.

Change-Id: Idabcac7420155649692ec589d637dd9ee3016716
Reviewed-by: Fabian Kosmale &lt;fabian.kosmale@qt.io&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Move ScopedStackFrame into qv4stackframe_p.h</title>
<updated>2023-05-17T07:26:50+00:00</updated>
<author>
<name>Ulf Hermann</name>
<email>ulf.hermann@qt.io</email>
</author>
<published>2023-05-15T07:23:03+00:00</published>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=d83c35a2e6216d2568f005c2260a06991134d8cf'/>
<id>d83c35a2e6216d2568f005c2260a06991134d8cf</id>
<content type='text'>
This is where it belongs. We need to apply some tricks to avoid
cyclic includes, but that's better than what we have so far.

Also, sort and clean up the includes in the affected files.

Change-Id: Ia7a957d06c0ca284045d831417740c3f9920bc92
Reviewed-by: Fabian Kosmale &lt;fabian.kosmale@qt.io&gt;
Reviewed-by: Qt CI Bot &lt;qt_ci_bot@qt-project.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is where it belongs. We need to apply some tricks to avoid
cyclic includes, but that's better than what we have so far.

Also, sort and clean up the includes in the affected files.

Change-Id: Ia7a957d06c0ca284045d831417740c3f9920bc92
Reviewed-by: Fabian Kosmale &lt;fabian.kosmale@qt.io&gt;
Reviewed-by: Qt CI Bot &lt;qt_ci_bot@qt-project.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>QML: Allow as-casting to value types</title>
<updated>2023-03-03T11:02:00+00:00</updated>
<author>
<name>Ulf Hermann</name>
<email>ulf.hermann@qt.io</email>
</author>
<published>2023-02-16T09:54:34+00:00</published>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=05f56d7c78754855c643470ad4e8dfd35c96f927'/>
<id>05f56d7c78754855c643470ad4e8dfd35c96f927</id>
<content type='text'>
If the "Addressable" option to ValueTypeBehavior is set, you can use the
"as" operator to cast a previously unknown type into either undefined
or the given type. We can use this in qmlcachegen to generate efficient
code for further operations on the same type.

In the generated C++ it in fact only works for GetLookup because:
a, We generally don't do SetLookup on value types, yet.
b, We generally don't call methods on value types, yet.
c, We cannot store a union of undefined and a sequence type, yet.

However, getting properties of value types is the most important
application of the new casts so this is well worth it.

As a side effect we can also look up things in potentially undefined
results of other operations now. For example list lookups.

Task-number: QTBUG-94807
Change-Id: Ifdf34f1f3f67b7a0a8953b9ed0e947b74638a28c
Reviewed-by: Fabian Kosmale &lt;fabian.kosmale@qt.io&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If the "Addressable" option to ValueTypeBehavior is set, you can use the
"as" operator to cast a previously unknown type into either undefined
or the given type. We can use this in qmlcachegen to generate efficient
code for further operations on the same type.

In the generated C++ it in fact only works for GetLookup because:
a, We generally don't do SetLookup on value types, yet.
b, We generally don't call methods on value types, yet.
c, We cannot store a union of undefined and a sequence type, yet.

However, getting properties of value types is the most important
application of the new casts so this is well worth it.

As a side effect we can also look up things in potentially undefined
results of other operations now. For example list lookups.

Task-number: QTBUG-94807
Change-Id: Ifdf34f1f3f67b7a0a8953b9ed0e947b74638a28c
Reviewed-by: Fabian Kosmale &lt;fabian.kosmale@qt.io&gt;
</pre>
</div>
</content>
</entry>
</feed>
