aboutsummaryrefslogtreecommitdiffstats
path: root/libevmasm/ExpressionClasses.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2017-01-06 18:33:08 +0800
committerchriseth <c@ethdev.com>2017-01-13 00:52:26 +0800
commitafad40ac5a259cf60cd2f5c8b31495f3f64f3e8e (patch)
treed7ad918559cfe5a2e9c1012aa7bb2bf1ef1fc69f /libevmasm/ExpressionClasses.cpp
parent74d74fb00bc159076d8322c5780894b1c2d68791 (diff)
downloaddexon-solidity-afad40ac5a259cf60cd2f5c8b31495f3f64f3e8e.tar.gz
dexon-solidity-afad40ac5a259cf60cd2f5c8b31495f3f64f3e8e.tar.zst
dexon-solidity-afad40ac5a259cf60cd2f5c8b31495f3f64f3e8e.zip
Optimise AssemblyItem::m_data.
Diffstat (limited to 'libevmasm/ExpressionClasses.cpp')
-rw-r--r--libevmasm/ExpressionClasses.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/libevmasm/ExpressionClasses.cpp b/libevmasm/ExpressionClasses.cpp
index d5ccd7e3..b903ae04 100644
--- a/libevmasm/ExpressionClasses.cpp
+++ b/libevmasm/ExpressionClasses.cpp
@@ -40,8 +40,18 @@ bool ExpressionClasses::Expression::operator<(ExpressionClasses::Expression cons
assertThrow(!!item && !!_other.item, OptimizerException, "");
auto type = item->type();
auto otherType = _other.item->type();
- return std::tie(type, item->data(), arguments, sequenceNumber) <
- std::tie(otherType, _other.item->data(), _other.arguments, _other.sequenceNumber);
+ if (type != otherType)
+ return type < otherType;
+ else if (type == Operation)
+ {
+ auto instr = item->instruction();
+ auto otherInstr = _other.item->instruction();
+ return std::tie(instr, arguments, sequenceNumber) <
+ std::tie(otherInstr, _other.arguments, _other.sequenceNumber);
+ }
+ else
+ return std::tie(item->data(), arguments, sequenceNumber) <
+ std::tie(_other.item->data(), _other.arguments, _other.sequenceNumber);
}
ExpressionClasses::Id ExpressionClasses::find(
@@ -479,8 +489,13 @@ bool Pattern::matchesBaseItem(AssemblyItem const* _item) const
return false;
if (m_type != _item->type())
return false;
- if (m_requireDataMatch && m_data != _item->data())
- return false;
+ if (m_requireDataMatch)
+ {
+ if (m_type == Operation)
+ return m_data == u256(byte(_item->instruction()));
+ else
+ return m_data == _item->data();
+ }
return true;
}