mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #12748 from ethereum/markCreationAssembly
Store whether an evmasm Assembly is creation code.
This commit is contained in:
@@ -415,9 +415,8 @@ map<u256, u256> const& Assembly::optimiseInternal(
|
||||
for (size_t subId = 0; subId < m_subs.size(); ++subId)
|
||||
{
|
||||
OptimiserSettings settings = _settings;
|
||||
// Disable creation mode for sub-assemblies.
|
||||
settings.isCreation = false;
|
||||
map<u256, u256> const& subTagReplacements = m_subs[subId]->optimiseInternal(
|
||||
Assembly& sub = *m_subs[subId];
|
||||
map<u256, u256> const& subTagReplacements = sub.optimiseInternal(
|
||||
settings,
|
||||
JumpdestRemover::referencedTags(m_items, subId)
|
||||
);
|
||||
@@ -436,7 +435,7 @@ map<u256, u256> const& Assembly::optimiseInternal(
|
||||
m_items,
|
||||
_tagsReferencedFromOutside,
|
||||
_settings.expectedExecutionsPerDeployment,
|
||||
_settings.isCreation,
|
||||
isCreation(),
|
||||
_settings.evmVersion
|
||||
}.optimise();
|
||||
|
||||
@@ -537,8 +536,8 @@ map<u256, u256> const& Assembly::optimiseInternal(
|
||||
|
||||
if (_settings.runConstantOptimiser)
|
||||
ConstantOptimisationMethod::optimiseConstants(
|
||||
_settings.isCreation,
|
||||
_settings.isCreation ? 1 : _settings.expectedExecutionsPerDeployment,
|
||||
isCreation(),
|
||||
isCreation() ? 1 : _settings.expectedExecutionsPerDeployment,
|
||||
_settings.evmVersion,
|
||||
*this
|
||||
);
|
||||
|
||||
@@ -48,7 +48,7 @@ using AssemblyPointer = std::shared_ptr<Assembly>;
|
||||
class Assembly
|
||||
{
|
||||
public:
|
||||
explicit Assembly(std::string _name = std::string()):m_name(std::move(_name)) { }
|
||||
Assembly(bool _creation, std::string _name): m_creation(_creation), m_name(std::move(_name)) { }
|
||||
|
||||
AssemblyItem newTag() { assertThrow(m_usedTags < 0xffffffff, AssemblyException, ""); return AssemblyItem(Tag, m_usedTags++); }
|
||||
AssemblyItem newPushTag() { assertThrow(m_usedTags < 0xffffffff, AssemblyException, ""); return AssemblyItem(PushTag, m_usedTags++); }
|
||||
@@ -117,7 +117,6 @@ public:
|
||||
|
||||
struct OptimiserSettings
|
||||
{
|
||||
bool isCreation = false;
|
||||
bool runInliner = false;
|
||||
bool runJumpdestRemover = false;
|
||||
bool runPeephole = false;
|
||||
@@ -157,6 +156,8 @@ public:
|
||||
std::vector<size_t> decodeSubPath(size_t _subObjectId) const;
|
||||
size_t encodeSubPath(std::vector<size_t> const& _subPath);
|
||||
|
||||
bool isCreation() const { return m_creation; }
|
||||
|
||||
protected:
|
||||
/// Does the same operations as @a optimise, but should only be applied to a sub and
|
||||
/// returns the replaced tags. Also takes an argument containing the tags of this assembly
|
||||
@@ -214,6 +215,8 @@ protected:
|
||||
mutable std::vector<size_t> m_tagPositionsInBytecode;
|
||||
|
||||
int m_deposit = 0;
|
||||
/// True, if the assembly contains contract creation code.
|
||||
bool const m_creation = false;
|
||||
/// Internal name of the assembly object, only used with the Yul backend
|
||||
/// currently
|
||||
std::string m_name;
|
||||
|
||||
Reference in New Issue
Block a user