diff options
author | Yoichi Hirai <i@yoichihirai.com> | 2016-12-13 05:39:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-13 05:39:47 +0800 |
commit | 1c3605362d6018f5ab72cc84c7511fb49c15d126 (patch) | |
tree | 0dd967a78fc37b9efc49fb7f71578a0fb52432f0 /libsolidity/codegen/ArrayUtils.cpp | |
parent | c111d6e27e7a951d49e587d0984fc8c24898c18f (diff) | |
parent | 81d7e0233aa24a2d38103b2bf746cef5eb12a893 (diff) | |
download | dexon-solidity-1c3605362d6018f5ab72cc84c7511fb49c15d126.tar dexon-solidity-1c3605362d6018f5ab72cc84c7511fb49c15d126.tar.gz dexon-solidity-1c3605362d6018f5ab72cc84c7511fb49c15d126.tar.bz2 dexon-solidity-1c3605362d6018f5ab72cc84c7511fb49c15d126.tar.lz dexon-solidity-1c3605362d6018f5ab72cc84c7511fb49c15d126.tar.xz dexon-solidity-1c3605362d6018f5ab72cc84c7511fb49c15d126.tar.zst dexon-solidity-1c3605362d6018f5ab72cc84c7511fb49c15d126.zip |
Merge pull request #1468 from ethereum/memcpy-assembly
Implement memcpy without the identity precompile
Diffstat (limited to 'libsolidity/codegen/ArrayUtils.cpp')
-rw-r--r-- | libsolidity/codegen/ArrayUtils.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libsolidity/codegen/ArrayUtils.cpp b/libsolidity/codegen/ArrayUtils.cpp index 2c982982..352c7177 100644 --- a/libsolidity/codegen/ArrayUtils.cpp +++ b/libsolidity/codegen/ArrayUtils.cpp @@ -335,9 +335,14 @@ void ArrayUtils::copyArrayToMemory(ArrayType const& _sourceType, bool _padToWord if (baseSize > 1) m_context << u256(baseSize) << Instruction::MUL; // stack: <target> <source> <size> - //@TODO do not use ::CALL if less than 32 bytes? m_context << Instruction::DUP1 << Instruction::DUP4 << Instruction::DUP4; - utils.memoryCopy(); + // We can resort to copying full 32 bytes only if + // - the length is known to be a multiple of 32 or + // - we will pad to full 32 bytes later anyway. + if (((baseSize % 32) == 0) || _padToWordBoundaries) + utils.memoryCopy32(); + else + utils.memoryCopy(); m_context << Instruction::SWAP1 << Instruction::POP; // stack: <target> <size> |