diff options
author | chriseth <c@ethdev.com> | 2016-11-11 01:16:21 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-11-16 21:37:18 +0800 |
commit | e543bd34c0b4884b5a27555f698f50af6a1c0b81 (patch) | |
tree | ef2c12e4767a3d38603323212face114213ca4b4 /libevmasm/BlockDeduplicator.cpp | |
parent | ee3efa67a8d3eb4077786fd745c1925a916419f5 (diff) | |
download | dexon-solidity-e543bd34c0b4884b5a27555f698f50af6a1c0b81.tar.gz dexon-solidity-e543bd34c0b4884b5a27555f698f50af6a1c0b81.tar.zst dexon-solidity-e543bd34c0b4884b5a27555f698f50af6a1c0b81.zip |
Stored combined creation and runtime tags.
Includes a change to Assembly to allow tags from sub-assemblies to be
used.
Sorry, this get a bit bigger than I thought.
Diffstat (limited to 'libevmasm/BlockDeduplicator.cpp')
-rw-r--r-- | libevmasm/BlockDeduplicator.cpp | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/libevmasm/BlockDeduplicator.cpp b/libevmasm/BlockDeduplicator.cpp index 3bb7a797..18b595cd 100644 --- a/libevmasm/BlockDeduplicator.cpp +++ b/libevmasm/BlockDeduplicator.cpp @@ -77,7 +77,6 @@ bool BlockDeduplicator::deduplicate() { //@todo this should probably be optimized. set<size_t, function<bool(size_t, size_t)>> blocksSeen(comparator); - map<u256, u256> tagReplacement; for (size_t i = 0; i < m_items.size(); ++i) { if (m_items.at(i).type() != Tag) @@ -86,22 +85,40 @@ bool BlockDeduplicator::deduplicate() if (it == blocksSeen.end()) blocksSeen.insert(i); else - tagReplacement[m_items.at(i).data()] = m_items.at(*it).data(); + m_replacedTags[m_items.at(i).data()] = m_items.at(*it).data(); } - bool changed = false; - for (AssemblyItem& item: m_items) - if (item.type() == PushTag && tagReplacement.count(item.data())) - { - changed = true; - item.setData(tagReplacement.at(item.data())); - } - if (!changed) + if (!applyTagReplacement(m_items, m_replacedTags)) break; } return iterations > 0; } +bool BlockDeduplicator::applyTagReplacement( + AssemblyItems& _items, + map<u256, u256> const& _replacements, + size_t _subId +) +{ + bool changed = false; + for (AssemblyItem& item: _items) + if (item.type() == PushTag) + { + size_t subId; + size_t tagId; + tie(subId, tagId) = item.splitForeignPushTag(); + if (subId != _subId) + continue; + auto it = _replacements.find(tagId); + if (it != _replacements.end()) + { + changed = true; + item.setPushTagSubIdAndTag(subId, size_t(it->second)); + } + } + return changed; +} + BlockDeduplicator::BlockIterator& BlockDeduplicator::BlockIterator::operator++() { if (it == end) |