aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-05-01 00:13:58 +0800
committerGitHub <noreply@github.com>2018-05-01 00:13:58 +0800
commit05248f5a1b6f6122100291f02a6efcb0b5c8f0a0 (patch)
treeb993d0c296953670e2326a62d60b6cf26f19c135
parent52cc416a3f2b8d34a1208a7e8deb67deeb481942 (diff)
parent3ac3018e1d30a34fa2f92a5422c222d9af6cddbd (diff)
downloaddexon-solidity-05248f5a1b6f6122100291f02a6efcb0b5c8f0a0.tar.gz
dexon-solidity-05248f5a1b6f6122100291f02a6efcb0b5c8f0a0.tar.zst
dexon-solidity-05248f5a1b6f6122100291f02a6efcb0b5c8f0a0.zip
Merge pull request #3999 from ethereum/subasm
Fix sub assembly tag handling on certain boost / compiler combinations
-rw-r--r--libevmasm/AssemblyItem.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/libevmasm/AssemblyItem.cpp b/libevmasm/AssemblyItem.cpp
index 5af618ff..a3a4d6b6 100644
--- a/libevmasm/AssemblyItem.cpp
+++ b/libevmasm/AssemblyItem.cpp
@@ -26,27 +26,35 @@ using namespace std;
using namespace dev;
using namespace dev::eth;
+static_assert(sizeof(size_t) <= 8, "size_t must be at most 64-bits wide");
+
AssemblyItem AssemblyItem::toSubAssemblyTag(size_t _subId) const
{
assertThrow(data() < (u256(1) << 64), Exception, "Tag already has subassembly set.");
-
assertThrow(m_type == PushTag || m_type == Tag, Exception, "");
+ size_t tag = size_t(u256(data()) & 0xffffffffffffffffULL);
AssemblyItem r = *this;
r.m_type = PushTag;
- r.setPushTagSubIdAndTag(_subId, size_t(data()));
+ r.setPushTagSubIdAndTag(_subId, tag);
return r;
}
pair<size_t, size_t> AssemblyItem::splitForeignPushTag() const
{
assertThrow(m_type == PushTag || m_type == Tag, Exception, "");
- return make_pair(size_t((data()) / (u256(1) << 64)) - 1, size_t(data()));
+ u256 combined = u256(data());
+ size_t subId = size_t((combined >> 64) - 1);
+ size_t tag = size_t(combined & 0xffffffffffffffffULL);
+ return make_pair(subId, tag);
}
void AssemblyItem::setPushTagSubIdAndTag(size_t _subId, size_t _tag)
{
assertThrow(m_type == PushTag || m_type == Tag, Exception, "");
- setData(_tag + (u256(_subId + 1) << 64));
+ u256 data = _tag;
+ if (_subId != size_t(-1))
+ data |= (u256(_subId) + 1) << 64;
+ setData(data);
}
unsigned AssemblyItem::bytesRequired(unsigned _addressLength) const