Merge pull request #5891 from ethereum/const-opt-assembly

Take only Assembly instance as an input to ConstantOptimiser
This commit is contained in:
chriseth 2019-01-31 18:54:12 +01:00 committed by GitHub
commit bb46e91677
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 9 deletions

View File

@ -496,8 +496,7 @@ map<u256, u256> Assembly::optimiseInternal(
_settings.isCreation,
_settings.isCreation ? 1 : _settings.expectedExecutionsPerDeployment,
_settings.evmVersion,
*this,
m_items
*this
);
return tagReplacements;

View File

@ -86,6 +86,9 @@ public:
/// Returns the assembly items.
AssemblyItems const& items() const { return m_items; }
/// Returns the mutable assembly items. Use with care!
AssemblyItems& items() { return m_items; }
int deposit() const { return m_deposit; }
void adjustDeposit(int _adjustment) { m_deposit += _adjustment; assertThrow(m_deposit >= 0, InvalidDeposit, ""); }
void setDeposit(int _deposit) { m_deposit = _deposit; assertThrow(m_deposit >= 0, InvalidDeposit, ""); }

View File

@ -30,10 +30,12 @@ unsigned ConstantOptimisationMethod::optimiseConstants(
bool _isCreation,
size_t _runs,
solidity::EVMVersion _evmVersion,
Assembly& _assembly,
AssemblyItems& _items
Assembly& _assembly
)
{
// TODO: design the optimiser in a way this is not needed
AssemblyItems& _items = _assembly.items();
unsigned optimisations = 0;
map<AssemblyItem, size_t> pushes;
for (AssemblyItem const& item: _items)

View File

@ -47,14 +47,13 @@ class ConstantOptimisationMethod
{
public:
/// Tries to optimised how constants are represented in the source code and modifies
/// @a _assembly and its @a _items.
/// @a _assembly.
/// @returns zero if no optimisations could be performed.
static unsigned optimiseConstants(
bool _isCreation,
size_t _runs,
solidity::EVMVersion _evmVersion,
Assembly& _assembly,
AssemblyItems& _items
Assembly& _assembly
);
struct Params

View File

@ -115,8 +115,7 @@ void FuzzerUtil::testConstantOptimizer(string const& _input, bool _quiet)
isCreation,
runs,
EVMVersion{},
tmp,
const_cast<AssemblyItems &>(tmp.items())
tmp
);
}
}