mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #9354 from ethereum/improveTestSpeed
Improve testing speed by only enabling the Yul optimizer if needed.
This commit is contained in:
commit
ecc4bf2464
@ -61,18 +61,40 @@ bytes SolidityExecutionFramework::multiSourceCompileContract(
|
|||||||
evmasm::LinkerObject obj;
|
evmasm::LinkerObject obj;
|
||||||
if (m_compileViaYul)
|
if (m_compileViaYul)
|
||||||
{
|
{
|
||||||
|
// Try compiling twice: If the first run fails due to stack errors, forcefully enable
|
||||||
|
// the optimizer.
|
||||||
|
for (bool forceEnableOptimizer: {false, true})
|
||||||
|
{
|
||||||
|
OptimiserSettings optimiserSettings = m_optimiserSettings;
|
||||||
|
if (!forceEnableOptimizer && !optimiserSettings.runYulOptimiser)
|
||||||
|
{
|
||||||
|
// Enable some optimizations on the first run
|
||||||
|
optimiserSettings.runYulOptimiser = true;
|
||||||
|
optimiserSettings.yulOptimiserSteps = "uljmul jmul";
|
||||||
|
}
|
||||||
|
else if (forceEnableOptimizer)
|
||||||
|
optimiserSettings = OptimiserSettings::full();
|
||||||
|
|
||||||
yul::AssemblyStack asmStack(
|
yul::AssemblyStack asmStack(
|
||||||
m_evmVersion,
|
m_evmVersion,
|
||||||
yul::AssemblyStack::Language::StrictAssembly,
|
yul::AssemblyStack::Language::StrictAssembly,
|
||||||
// Ignore optimiser settings here because we need Yul optimisation to
|
optimiserSettings
|
||||||
// get code that does not exhaust the stack.
|
|
||||||
OptimiserSettings::full()
|
|
||||||
);
|
);
|
||||||
bool analysisSuccessful = asmStack.parseAndAnalyze("", m_compiler.yulIROptimized(contractName));
|
bool analysisSuccessful = asmStack.parseAndAnalyze("", m_compiler.yulIROptimized(contractName));
|
||||||
solAssert(analysisSuccessful, "Code that passed analysis in CompilerStack can't have errors");
|
solAssert(analysisSuccessful, "Code that passed analysis in CompilerStack can't have errors");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
asmStack.optimize();
|
asmStack.optimize();
|
||||||
obj = std::move(*asmStack.assemble(yul::AssemblyStack::Machine::EVM).bytecode);
|
obj = std::move(*asmStack.assemble(yul::AssemblyStack::Machine::EVM).bytecode);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
if (forceEnableOptimizer || optimiserSettings == OptimiserSettings::full())
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
obj = m_compiler.object(contractName);
|
obj = m_compiler.object(contractName);
|
||||||
|
Loading…
Reference in New Issue
Block a user