mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Calculate the dataGas correctly in the constant optimiser
This may cause a wrong decision about cost (and as a result choosing the least efficient code), but will not cause any miscompilation or invalid output.
This commit is contained in:
parent
3f42118d19
commit
0b6a26f854
@ -92,6 +92,7 @@ Bugfixes:
|
|||||||
* Code Generator: Properly handle negative number literals in ABIEncoderV2.
|
* Code Generator: Properly handle negative number literals in ABIEncoderV2.
|
||||||
* Commandline Interface: Correctly handle paths with backslashes on windows.
|
* Commandline Interface: Correctly handle paths with backslashes on windows.
|
||||||
* Fix NatSpec json output for `@notice` and `@dev` tags on contract definitions.
|
* Fix NatSpec json output for `@notice` and `@dev` tags on contract definitions.
|
||||||
|
* Optimizer: Correctly estimate gas costs of constants for special cases.
|
||||||
* References Resolver: Do not crash on using ``_slot`` and ``_offset`` suffixes on their own.
|
* References Resolver: Do not crash on using ``_slot`` and ``_offset`` suffixes on their own.
|
||||||
* References Resolver: Enforce ``storage`` as data location for mappings.
|
* References Resolver: Enforce ``storage`` as data location for mappings.
|
||||||
* References Resolver: Properly handle invalid references used together with ``_slot`` and ``_offset``.
|
* References Resolver: Properly handle invalid references used together with ``_slot`` and ``_offset``.
|
||||||
|
@ -93,6 +93,7 @@ bigint ConstantOptimisationMethod::simpleRunGas(AssemblyItems const& _items)
|
|||||||
|
|
||||||
bigint ConstantOptimisationMethod::dataGas(bytes const& _data) const
|
bigint ConstantOptimisationMethod::dataGas(bytes const& _data) const
|
||||||
{
|
{
|
||||||
|
assertThrow(_data.size() > 0, OptimizerException, "Empty bytecode generated.");
|
||||||
if (m_params.isCreation)
|
if (m_params.isCreation)
|
||||||
{
|
{
|
||||||
bigint gas;
|
bigint gas;
|
||||||
@ -101,7 +102,7 @@ bigint ConstantOptimisationMethod::dataGas(bytes const& _data) const
|
|||||||
return gas;
|
return gas;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return GasCosts::createDataGas * dataSize();
|
return GasCosts::createDataGas * _data.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ConstantOptimisationMethod::bytesRequired(AssemblyItems const& _items)
|
size_t ConstantOptimisationMethod::bytesRequired(AssemblyItems const& _items)
|
||||||
|
@ -75,8 +75,6 @@ public:
|
|||||||
virtual AssemblyItems execute(Assembly& _assembly) const = 0;
|
virtual AssemblyItems execute(Assembly& _assembly) const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
size_t dataSize() const { return std::max<size_t>(1, dev::bytesRequired(m_value)); }
|
|
||||||
|
|
||||||
/// @returns the run gas for the given items ignoring special gas costs
|
/// @returns the run gas for the given items ignoring special gas costs
|
||||||
static bigint simpleRunGas(AssemblyItems const& _items);
|
static bigint simpleRunGas(AssemblyItems const& _items);
|
||||||
/// @returns the gas needed to store the given data literally
|
/// @returns the gas needed to store the given data literally
|
||||||
|
Loading…
Reference in New Issue
Block a user