aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jit/qv4baselinejit.cpp
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2021-04-09 17:42:06 +0200
committerMaximilian Goldstein <max.goldstein@qt.io>2021-04-13 19:19:56 +0200
commit5f7ecce23321f499b1b002c32a27c63815535baa (patch)
tree4e1e23e18cacd4e0d9883fc0f581a77cd3df56e6 /src/qml/jit/qv4baselinejit.cpp
parent9b0069d94a5b725923e303ccdb3d7739088e06fc (diff)
Implement optional chaining
This change implements optional chaining (https://github.com/tc39/proposal-optional-chaining) by adding a new type of optional lookup with an offset to the end of a chain. If `undefined` or `null` is encountered during an access marked as optional, we jump to that end offset. Features: - Full support for all kinds of optional chain - With some codegen overhead but zero overhead during normal non-optional FieldMemberExpression resolution - Properly retains this contexts and does not need to resolve anything twice (this has been an issue previously) - No extra AST structures, just flags for existing ones [ChangeLog][QtQml] Added support for optional chaining (https://github.com/tc39/proposal-optional-chaining) Fixes: QTBUG-77926 Change-Id: I9a41cdc4ca272066c79c72b9b22206498a546843 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jit/qv4baselinejit.cpp')
-rw-r--r--src/qml/jit/qv4baselinejit.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/qml/jit/qv4baselinejit.cpp b/src/qml/jit/qv4baselinejit.cpp
index 22cbfd1536..f660e363ea 100644
--- a/src/qml/jit/qv4baselinejit.cpp
+++ b/src/qml/jit/qv4baselinejit.cpp
@@ -283,6 +283,13 @@ void BaselineJIT::generate_LoadProperty(int name)
BASELINEJIT_GENERATE_RUNTIME_CALL(LoadProperty, CallResultDestination::InAccumulator);
}
+void BaselineJIT::generate_LoadOptionalProperty(int name, int offset)
+{
+ labels.insert(as->jumpEqNull(absoluteOffset(offset)));
+
+ generate_LoadProperty(name);
+}
+
void BaselineJIT::generate_GetLookup(int index)
{
STORE_IP();
@@ -295,6 +302,13 @@ void BaselineJIT::generate_GetLookup(int index)
BASELINEJIT_GENERATE_RUNTIME_CALL(GetLookup, CallResultDestination::InAccumulator);
}
+void BaselineJIT::generate_GetOptionalLookup(int index, int offset)
+{
+ labels.insert(as->jumpEqNull(absoluteOffset(offset)));
+
+ generate_GetLookup(index);
+}
+
void BaselineJIT::generate_StoreProperty(int name, int base)
{
STORE_IP();