mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #5891 from ethereum/const-opt-assembly
Take only Assembly instance as an input to ConstantOptimiser
This commit is contained in:
commit
bb46e91677
@ -496,8 +496,7 @@ map<u256, u256> Assembly::optimiseInternal(
|
||||
_settings.isCreation,
|
||||
_settings.isCreation ? 1 : _settings.expectedExecutionsPerDeployment,
|
||||
_settings.evmVersion,
|
||||
*this,
|
||||
m_items
|
||||
*this
|
||||
);
|
||||
|
||||
return tagReplacements;
|
||||
|
@ -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, ""); }
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -115,8 +115,7 @@ void FuzzerUtil::testConstantOptimizer(string const& _input, bool _quiet)
|
||||
isCreation,
|
||||
runs,
|
||||
EVMVersion{},
|
||||
tmp,
|
||||
const_cast<AssemblyItems &>(tmp.items())
|
||||
tmp
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user