mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Take only Assembly instance as an input to ConstantOptimiser
This commit is contained in:
parent
e83e9a81e5
commit
ae1cd252b0
@ -496,8 +496,7 @@ map<u256, u256> Assembly::optimiseInternal(
|
|||||||
_settings.isCreation,
|
_settings.isCreation,
|
||||||
_settings.isCreation ? 1 : _settings.expectedExecutionsPerDeployment,
|
_settings.isCreation ? 1 : _settings.expectedExecutionsPerDeployment,
|
||||||
_settings.evmVersion,
|
_settings.evmVersion,
|
||||||
*this,
|
*this
|
||||||
m_items
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return tagReplacements;
|
return tagReplacements;
|
||||||
|
@ -86,6 +86,9 @@ public:
|
|||||||
/// Returns the assembly items.
|
/// Returns the assembly items.
|
||||||
AssemblyItems const& items() const { return m_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; }
|
int deposit() const { return m_deposit; }
|
||||||
void adjustDeposit(int _adjustment) { m_deposit += _adjustment; assertThrow(m_deposit >= 0, InvalidDeposit, ""); }
|
void adjustDeposit(int _adjustment) { m_deposit += _adjustment; assertThrow(m_deposit >= 0, InvalidDeposit, ""); }
|
||||||
void setDeposit(int _deposit) { m_deposit = _deposit; 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,
|
bool _isCreation,
|
||||||
size_t _runs,
|
size_t _runs,
|
||||||
solidity::EVMVersion _evmVersion,
|
solidity::EVMVersion _evmVersion,
|
||||||
Assembly& _assembly,
|
Assembly& _assembly
|
||||||
AssemblyItems& _items
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
// TODO: design the optimiser in a way this is not needed
|
||||||
|
AssemblyItems& _items = _assembly.items();
|
||||||
|
|
||||||
unsigned optimisations = 0;
|
unsigned optimisations = 0;
|
||||||
map<AssemblyItem, size_t> pushes;
|
map<AssemblyItem, size_t> pushes;
|
||||||
for (AssemblyItem const& item: _items)
|
for (AssemblyItem const& item: _items)
|
||||||
|
@ -47,14 +47,13 @@ class ConstantOptimisationMethod
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Tries to optimised how constants are represented in the source code and modifies
|
/// 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.
|
/// @returns zero if no optimisations could be performed.
|
||||||
static unsigned optimiseConstants(
|
static unsigned optimiseConstants(
|
||||||
bool _isCreation,
|
bool _isCreation,
|
||||||
size_t _runs,
|
size_t _runs,
|
||||||
solidity::EVMVersion _evmVersion,
|
solidity::EVMVersion _evmVersion,
|
||||||
Assembly& _assembly,
|
Assembly& _assembly
|
||||||
AssemblyItems& _items
|
|
||||||
);
|
);
|
||||||
|
|
||||||
struct Params
|
struct Params
|
||||||
|
@ -111,8 +111,7 @@ void FuzzerUtil::testConstantOptimizer(string const& _input, bool _quiet)
|
|||||||
isCreation,
|
isCreation,
|
||||||
runs,
|
runs,
|
||||||
EVMVersion{},
|
EVMVersion{},
|
||||||
tmp,
|
tmp
|
||||||
const_cast<AssemblyItems &>(tmp.items())
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user