diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2022-06-30 17:45:07 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-07-05 19:50:28 +0200 |
| commit | af335a89bd2f8b41c059c1467bac55fdaf4f2dc0 (patch) | |
| tree | 279aafd7999b8672d1a08cbf366dd7724f2b7dfb /src/qmlcompiler/qqmljsbasicblocks.cpp | |
| parent | 7d36ec0bd9cd4747dbf33e92b8188fe25c295b88 (diff) | |
QmlCompiler: Initialize registers with undefined where necessary
If we read the initial state of a register, we need to make sure it
actually exists at that point. Uninitialized variables are implicitly
undefined in JavaScript.
Pick-to: 6.4
Task-number: QTBUG-104687
Change-Id: Ide4fe429b10ec28dcf267e7d34c6316355b16baa
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljsbasicblocks.cpp')
| -rw-r--r-- | src/qmlcompiler/qqmljsbasicblocks.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/qmlcompiler/qqmljsbasicblocks.cpp b/src/qmlcompiler/qqmljsbasicblocks.cpp index 3e5657d2ab..a7bbd5326c 100644 --- a/src/qmlcompiler/qqmljsbasicblocks.cpp +++ b/src/qmlcompiler/qqmljsbasicblocks.cpp @@ -42,6 +42,7 @@ QQmlJSCompilePass::InstructionAnnotations QQmlJSBasicBlocks::run( const Function *function, const InstructionAnnotations &annotations) { + m_function = function; m_annotations = annotations; for (int i = 0, end = function->argumentTypes.length(); i != end; ++i) { @@ -51,6 +52,13 @@ QQmlJSCompilePass::InstructionAnnotations QQmlJSBasicBlocks::run( m_annotations[-annotation.changedRegisterIndex] = annotation; } + for (int i = 0, end = function->registerTypes.length(); i != end; ++i) { + InstructionAnnotation annotation; + annotation.changedRegisterIndex = firstRegisterIndex() + i; + annotation.changedRegister = function->registerTypes[i]; + m_annotations[-annotation.changedRegisterIndex] = annotation; + } + m_basicBlocks.insert_or_assign(m_annotations.begin().key(), BasicBlock()); const QByteArray byteCode = function->code; |
