Add REVERT to libevmasm

This commit is contained in:
Alex Beregszaszi 2017-02-06 20:21:27 +00:00
parent 14ded4963d
commit 148f923351
5 changed files with 7 additions and 1 deletions

View File

@ -80,6 +80,7 @@ GasMeter::GasConsumption GasMeter::estimateMax(AssemblyItem const& _item, bool _
gas += GasCosts::sloadGas; gas += GasCosts::sloadGas;
break; break;
case Instruction::RETURN: case Instruction::RETURN:
case Instruction::REVERT:
gas += memoryGas(0, -1); gas += memoryGas(0, -1);
break; break;
case Instruction::MLOAD: case Instruction::MLOAD:

View File

@ -159,6 +159,7 @@ const std::map<std::string, Instruction> dev::solidity::c_instructions =
{ "CALLCODE", Instruction::CALLCODE }, { "CALLCODE", Instruction::CALLCODE },
{ "RETURN", Instruction::RETURN }, { "RETURN", Instruction::RETURN },
{ "DELEGATECALL", Instruction::DELEGATECALL }, { "DELEGATECALL", Instruction::DELEGATECALL },
{ "REVERT", Instruction::REVERT },
{ "INVALID", Instruction::INVALID }, { "INVALID", Instruction::INVALID },
{ "SELFDESTRUCT", Instruction::SELFDESTRUCT } { "SELFDESTRUCT", Instruction::SELFDESTRUCT }
}; };
@ -294,6 +295,7 @@ static const std::map<Instruction, InstructionInfo> c_instructionInfo =
{ Instruction::CALLCODE, { "CALLCODE", 0, 7, 1, true, Tier::Special } }, { Instruction::CALLCODE, { "CALLCODE", 0, 7, 1, true, Tier::Special } },
{ Instruction::RETURN, { "RETURN", 0, 2, 0, true, Tier::Zero } }, { Instruction::RETURN, { "RETURN", 0, 2, 0, true, Tier::Zero } },
{ Instruction::DELEGATECALL, { "DELEGATECALL", 0, 6, 1, true, Tier::Special } }, { Instruction::DELEGATECALL, { "DELEGATECALL", 0, 6, 1, true, Tier::Special } },
{ Instruction::REVERT, { "REVERT", 0, 2, 0, true, Tier::Zero } },
{ Instruction::INVALID, { "INVALID", 0, 0, 0, true, Tier::Zero } }, { Instruction::INVALID, { "INVALID", 0, 0, 0, true, Tier::Zero } },
{ Instruction::SELFDESTRUCT, { "SELFDESTRUCT", 0, 1, 0, true, Tier::Zero } } { Instruction::SELFDESTRUCT, { "SELFDESTRUCT", 0, 1, 0, true, Tier::Zero } }
}; };

View File

@ -177,6 +177,7 @@ enum class Instruction: uint8_t
RETURN, ///< halt execution returning output data RETURN, ///< halt execution returning output data
DELEGATECALL, ///< like CALLCODE but keeps caller's value and sender DELEGATECALL, ///< like CALLCODE but keeps caller's value and sender
REVERT = 0xfd, ///< halt execution, revert state and return output data
INVALID = 0xfe, ///< invalid instruction for expressing runtime errors (e.g., division-by-zero) INVALID = 0xfe, ///< invalid instruction for expressing runtime errors (e.g., division-by-zero)
SELFDESTRUCT = 0xff ///< halt execution and register account for later deletion SELFDESTRUCT = 0xff ///< halt execution and register account for later deletion
}; };

View File

@ -200,7 +200,8 @@ struct UnreachableCode
it[0] != Instruction::RETURN && it[0] != Instruction::RETURN &&
it[0] != Instruction::STOP && it[0] != Instruction::STOP &&
it[0] != Instruction::INVALID && it[0] != Instruction::INVALID &&
it[0] != Instruction::SELFDESTRUCT it[0] != Instruction::SELFDESTRUCT &&
it[0] != Instruction::REVERT
) )
return false; return false;

View File

@ -119,6 +119,7 @@ bool SemanticInformation::altersControlFlow(AssemblyItem const& _item)
case Instruction::SELFDESTRUCT: case Instruction::SELFDESTRUCT:
case Instruction::STOP: case Instruction::STOP:
case Instruction::INVALID: case Instruction::INVALID:
case Instruction::REVERT:
return true; return true;
default: default:
return false; return false;