mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Movability.
This commit is contained in:
@@ -153,6 +153,31 @@ bool SemanticInformation::isDeterministic(AssemblyItem const& _item)
|
||||
}
|
||||
}
|
||||
|
||||
bool SemanticInformation::movable(Instruction _instruction)
|
||||
{
|
||||
// These are not really functional.
|
||||
if (isDupInstruction(_instruction) || isSwapInstruction(_instruction))
|
||||
return false;
|
||||
InstructionInfo info = instructionInfo(_instruction);
|
||||
if (info.sideEffects)
|
||||
return false;
|
||||
switch (_instruction)
|
||||
{
|
||||
case Instruction::KECCAK256:
|
||||
case Instruction::BALANCE:
|
||||
case Instruction::EXTCODESIZE:
|
||||
case Instruction::RETURNDATASIZE:
|
||||
case Instruction::SLOAD:
|
||||
case Instruction::PC:
|
||||
case Instruction::MSIZE:
|
||||
case Instruction::GAS:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SemanticInformation::invalidatesMemory(Instruction _instruction)
|
||||
{
|
||||
switch (_instruction)
|
||||
|
||||
@@ -49,6 +49,10 @@ struct SemanticInformation
|
||||
/// @returns false if the value put on the stack by _item depends on anything else than
|
||||
/// the information in the current block header, memory, storage or stack.
|
||||
static bool isDeterministic(AssemblyItem const& _item);
|
||||
/// @returns true if the instruction can be moved or copied (together with its arguments)
|
||||
/// without altering the semantics. This means it cannot depend on storage or memory,
|
||||
/// cannot have any side-effects, but it can depend on a call-constant state of the blockchain.
|
||||
static bool movable(solidity::Instruction _instruction);
|
||||
/// @returns true if the given instruction modifies memory.
|
||||
static bool invalidatesMemory(solidity::Instruction _instruction);
|
||||
/// @returns true if the given instruction modifies storage (even indirectly).
|
||||
|
||||
Reference in New Issue
Block a user