mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
To be removed: do not force enable yul optimizer, but run stack limit evader in presence of inline assembly.
This commit is contained in:
parent
3a5cbf248e
commit
bda2033dc4
@ -659,16 +659,14 @@ string IRGenerator::dispatchRoutine(ContractDefinition const& _contract)
|
|||||||
return t.render();
|
return t.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
string IRGenerator::memoryInit(bool _useMemoryGuard)
|
string IRGenerator::memoryInit(bool)
|
||||||
{
|
{
|
||||||
// This function should be called at the beginning of the EVM call frame
|
// This function should be called at the beginning of the EVM call frame
|
||||||
// and thus can assume all memory to be zero, including the contents of
|
// and thus can assume all memory to be zero, including the contents of
|
||||||
// the "zero memory area" (the position CompilerUtils::zeroPointer points to).
|
// the "zero memory area" (the position CompilerUtils::zeroPointer points to).
|
||||||
return
|
return
|
||||||
Whiskers{
|
Whiskers{
|
||||||
_useMemoryGuard ?
|
"mstore(<memPtr>, memoryguard(<freeMemoryStart>))"
|
||||||
"mstore(<memPtr>, memoryguard(<freeMemoryStart>))" :
|
|
||||||
"mstore(<memPtr>, <freeMemoryStart>)"
|
|
||||||
}
|
}
|
||||||
("memPtr", to_string(CompilerUtils::freeMemoryPointer))
|
("memPtr", to_string(CompilerUtils::freeMemoryPointer))
|
||||||
(
|
(
|
||||||
|
|||||||
@ -74,37 +74,21 @@ bytes SolidityExecutionFramework::multiSourceCompileContract(
|
|||||||
obj = m_compiler.ewasmObject(contractName);
|
obj = m_compiler.ewasmObject(contractName);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Try compiling twice: If the first run fails due to stack errors, forcefully enable
|
OptimiserSettings optimiserSettings = m_optimiserSettings;
|
||||||
// the optimizer.
|
if (!optimiserSettings.runYulOptimiser)
|
||||||
for (bool forceEnableOptimizer: {false, true})
|
|
||||||
{
|
{
|
||||||
OptimiserSettings optimiserSettings = m_optimiserSettings;
|
// Enable some optimizations on the first run
|
||||||
if (!forceEnableOptimizer && !optimiserSettings.runYulOptimiser)
|
optimiserSettings.runYulOptimiser = true;
|
||||||
{
|
optimiserSettings.yulOptimiserSteps = "uljmul jmul";
|
||||||
// Enable some optimizations on the first run
|
|
||||||
optimiserSettings.runYulOptimiser = true;
|
|
||||||
optimiserSettings.yulOptimiserSteps = "uljmul jmul";
|
|
||||||
}
|
|
||||||
else if (forceEnableOptimizer)
|
|
||||||
optimiserSettings = OptimiserSettings::full();
|
|
||||||
|
|
||||||
yul::AssemblyStack
|
|
||||||
asmStack(m_evmVersion, yul::AssemblyStack::Language::StrictAssembly, optimiserSettings);
|
|
||||||
bool analysisSuccessful = asmStack.parseAndAnalyze("", m_compiler.yulIROptimized(contractName));
|
|
||||||
solAssert(analysisSuccessful, "Code that passed analysis in CompilerStack can't have errors");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
asmStack.optimize();
|
|
||||||
obj = std::move(*asmStack.assemble(yul::AssemblyStack::Machine::EVM).bytecode);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
if (forceEnableOptimizer || optimiserSettings == OptimiserSettings::full())
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
yul::AssemblyStack
|
||||||
|
asmStack(m_evmVersion, yul::AssemblyStack::Language::StrictAssembly, optimiserSettings);
|
||||||
|
bool analysisSuccessful = asmStack.parseAndAnalyze("", m_compiler.yulIROptimized(contractName));
|
||||||
|
solAssert(analysisSuccessful, "Code that passed analysis in CompilerStack can't have errors");
|
||||||
|
|
||||||
|
asmStack.optimize();
|
||||||
|
obj = std::move(*asmStack.assemble(yul::AssemblyStack::Machine::EVM).bytecode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user