From 4619377409f28f35cfd9bf0f6ed2bd1094e66c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20De=20Canni=C3=A8re?= Date: Mon, 4 Mar 2024 09:45:34 +0100 Subject: Compiler: Extract Basic blocks generation into its own compiler pass The old basic blocks pass was responsible for two things: the basic blocks generation and dead code analysis/type adjustments based on those blocks and the type propagation performed earlier. Now the basic blocks get generated first, even before the type propagation and the dead code analysis and type adjustments are now grouped in a pass called QQmlJSOptimizations. The rest of the passes remain unchanged. Change-Id: I7b4303eaf67c761a49b82ab194e5d035d24d2615 Reviewed-by: Fabian Kosmale Reviewed-by: Ulf Hermann --- src/qmlcompiler/qqmljscompiler.cpp | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'src/qmlcompiler/qqmljscompiler.cpp') diff --git a/src/qmlcompiler/qqmljscompiler.cpp b/src/qmlcompiler/qqmljscompiler.cpp index 6514caad6f..2cc32fc63d 100644 --- a/src/qmlcompiler/qqmljscompiler.cpp +++ b/src/qmlcompiler/qqmljscompiler.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -774,32 +775,38 @@ QQmlJSAotFunction QQmlJSAotCompiler::doCompile( return QQmlJSAotFunction(); }; - QQmlJSTypePropagator propagator(m_unitGenerator, &m_typeResolver, m_logger); - auto typePropagationResult = propagator.run(function, error); if (error->isValid()) return compileError(); - QQmlJSShadowCheck shadowCheck(m_unitGenerator, &m_typeResolver, m_logger); - shadowCheck.run(&typePropagationResult, function, error); + bool basicBlocksValidationFailed = false; + QQmlJSBasicBlocks basicBlocks(context, m_unitGenerator, &m_typeResolver, m_logger); + auto passResult = basicBlocks.run(function, m_flags, basicBlocksValidationFailed); + auto &[blocks, annotations] = passResult; + + QQmlJSTypePropagator propagator(m_unitGenerator, &m_typeResolver, m_logger, blocks, annotations); + passResult = propagator.run(function, error); if (error->isValid()) return compileError(); - bool basicBlocksValidationFailed = false; - QQmlJSBasicBlocks basicBlocks(context, m_unitGenerator, &m_typeResolver, m_logger); - typePropagationResult = basicBlocks.run(function, typePropagationResult, error, m_flags, basicBlocksValidationFailed); + QQmlJSShadowCheck shadowCheck(m_unitGenerator, &m_typeResolver, m_logger, blocks, annotations); + passResult = shadowCheck.run(function, error); + if (error->isValid()) + return compileError(); + + QQmlJSOptimizations optimizer(m_unitGenerator, &m_typeResolver, m_logger, blocks, annotations, + basicBlocks.objectAndArrayDefinitions()); + passResult = optimizer.run(function, error); if (error->isValid()) return compileError(); // Generalize all arguments, registers, and the return type. - QQmlJSStorageGeneralizer generalizer( - m_unitGenerator, &m_typeResolver, m_logger); - typePropagationResult = generalizer.run(typePropagationResult, function, error); + QQmlJSStorageGeneralizer generalizer(m_unitGenerator, &m_typeResolver, m_logger, blocks, annotations); + passResult = generalizer.run(function, error); if (error->isValid()) return compileError(); - QQmlJSCodeGenerator codegen( - context, m_unitGenerator, &m_typeResolver, m_logger); - QQmlJSAotFunction result = codegen.run(function, &typePropagationResult, error, basicBlocksValidationFailed); + QQmlJSCodeGenerator codegen(context, m_unitGenerator, &m_typeResolver, m_logger, blocks, annotations); + QQmlJSAotFunction result = codegen.run(function, error, basicBlocksValidationFailed); return error->isValid() ? compileError() : result; } -- cgit v1.2.3