mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Use native shift instructions on Constantinople
This commit is contained in:
parent
5cce2e552b
commit
22bfd3da41
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
Features:
|
Features:
|
||||||
* Build System: Update internal dependency of jsoncpp to 1.8.4, which introduces more strictness and reduces memory usage.
|
* Build System: Update internal dependency of jsoncpp to 1.8.4, which introduces more strictness and reduces memory usage.
|
||||||
|
* Code Generator: Use native shift instructions on target Constantinople.
|
||||||
* Optimizer: Remove unnecessary masking of the result of known short instructions (``ADDRESS``, ``CALLER``, ``ORIGIN`` and ``COINBASE``).
|
* Optimizer: Remove unnecessary masking of the result of known short instructions (``ADDRESS``, ``CALLER``, ``ORIGIN`` and ``COINBASE``).
|
||||||
* Type Checker: Deprecate the ``years`` unit denomination and raise a warning for it (or an error as experimental 0.5.0 feature).
|
* Type Checker: Deprecate the ``years`` unit denomination and raise a warning for it (or an error as experimental 0.5.0 feature).
|
||||||
* Type Checker: Make literals (without explicit type casting) an error for tight packing as experimental 0.5.0 feature.
|
* Type Checker: Make literals (without explicit type casting) an error for tight packing as experimental 0.5.0 feature.
|
||||||
|
@ -1265,13 +1265,19 @@ void CompilerUtils::cleanHigherOrderBits(IntegerType const& _typeOnStack)
|
|||||||
void CompilerUtils::leftShiftNumberOnStack(unsigned _bits)
|
void CompilerUtils::leftShiftNumberOnStack(unsigned _bits)
|
||||||
{
|
{
|
||||||
solAssert(_bits < 256, "");
|
solAssert(_bits < 256, "");
|
||||||
m_context << (u256(1) << _bits) << Instruction::MUL;
|
if (m_context.evmVersion().hasBitwiseShifting())
|
||||||
|
m_context << _bits << Instruction::SHL;
|
||||||
|
else
|
||||||
|
m_context << (u256(1) << _bits) << Instruction::MUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompilerUtils::rightShiftNumberOnStack(unsigned _bits, bool _isSigned)
|
void CompilerUtils::rightShiftNumberOnStack(unsigned _bits, bool _isSigned)
|
||||||
{
|
{
|
||||||
solAssert(_bits < 256, "");
|
solAssert(_bits < 256, "");
|
||||||
m_context << (u256(1) << _bits) << Instruction::SWAP1 << (_isSigned ? Instruction::SDIV : Instruction::DIV);
|
if (m_context.evmVersion().hasBitwiseShifting())
|
||||||
|
m_context << _bits << (_isSigned ? Instruction::SAR : Instruction::SHR);
|
||||||
|
else
|
||||||
|
m_context << (u256(1) << _bits) << Instruction::SWAP1 << (_isSigned ? Instruction::SDIV : Instruction::DIV);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned CompilerUtils::prepareMemoryStore(Type const& _type, bool _padToWords)
|
unsigned CompilerUtils::prepareMemoryStore(Type const& _type, bool _padToWords)
|
||||||
|
@ -1706,13 +1706,22 @@ void ExpressionCompiler::appendShiftOperatorCode(Token::Value _operator, Type co
|
|||||||
m_context.appendConditionalInvalid();
|
m_context.appendConditionalInvalid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_context << Instruction::SWAP1;
|
||||||
|
// stack: value_to_shift shift_amount
|
||||||
|
|
||||||
switch (_operator)
|
switch (_operator)
|
||||||
{
|
{
|
||||||
case Token::SHL:
|
case Token::SHL:
|
||||||
m_context << Instruction::SWAP1 << u256(2) << Instruction::EXP << Instruction::MUL;
|
if (m_context.evmVersion().hasBitwiseShifting())
|
||||||
|
m_context << Instruction::SHL;
|
||||||
|
else
|
||||||
|
m_context << u256(2) << Instruction::EXP << Instruction::MUL;
|
||||||
break;
|
break;
|
||||||
case Token::SAR:
|
case Token::SAR:
|
||||||
m_context << Instruction::SWAP1 << u256(2) << Instruction::EXP << Instruction::SWAP1 << (c_valueSigned ? Instruction::SDIV : Instruction::DIV);
|
if (m_context.evmVersion().hasBitwiseShifting())
|
||||||
|
m_context << (c_valueSigned ? Instruction::SAR : Instruction::SHR);
|
||||||
|
else
|
||||||
|
m_context << u256(2) << Instruction::EXP << Instruction::SWAP1 << (c_valueSigned ? Instruction::SDIV : Instruction::DIV);
|
||||||
break;
|
break;
|
||||||
case Token::SHR:
|
case Token::SHR:
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user