diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-02-07 04:21:27 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-02-11 06:40:12 +0800 |
commit | 148f9233516ff5ad94d81aba9bc9c0440d3afc7b (patch) | |
tree | ea5c67aba40a944e9236be845cf3bd29e55b669c | |
parent | 14ded4963d2b42443c6ddce8ad7550393ab58983 (diff) | |
download | dexon-solidity-148f9233516ff5ad94d81aba9bc9c0440d3afc7b.tar.gz dexon-solidity-148f9233516ff5ad94d81aba9bc9c0440d3afc7b.tar.zst dexon-solidity-148f9233516ff5ad94d81aba9bc9c0440d3afc7b.zip |
Add REVERT to libevmasm
-rw-r--r-- | libevmasm/GasMeter.cpp | 1 | ||||
-rw-r--r-- | libevmasm/Instruction.cpp | 2 | ||||
-rw-r--r-- | libevmasm/Instruction.h | 1 | ||||
-rw-r--r-- | libevmasm/PeepholeOptimiser.cpp | 3 | ||||
-rw-r--r-- | libevmasm/SemanticInformation.cpp | 1 |
5 files changed, 7 insertions, 1 deletions
diff --git a/libevmasm/GasMeter.cpp b/libevmasm/GasMeter.cpp index 462c09dd..a0adc35d 100644 --- a/libevmasm/GasMeter.cpp +++ b/libevmasm/GasMeter.cpp @@ -80,6 +80,7 @@ GasMeter::GasConsumption GasMeter::estimateMax(AssemblyItem const& _item, bool _ gas += GasCosts::sloadGas; break; case Instruction::RETURN: + case Instruction::REVERT: gas += memoryGas(0, -1); break; case Instruction::MLOAD: diff --git a/libevmasm/Instruction.cpp b/libevmasm/Instruction.cpp index f9ee9be1..de6630f3 100644 --- a/libevmasm/Instruction.cpp +++ b/libevmasm/Instruction.cpp @@ -159,6 +159,7 @@ const std::map<std::string, Instruction> dev::solidity::c_instructions = { "CALLCODE", Instruction::CALLCODE }, { "RETURN", Instruction::RETURN }, { "DELEGATECALL", Instruction::DELEGATECALL }, + { "REVERT", Instruction::REVERT }, { "INVALID", Instruction::INVALID }, { "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::RETURN, { "RETURN", 0, 2, 0, true, Tier::Zero } }, { 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::SELFDESTRUCT, { "SELFDESTRUCT", 0, 1, 0, true, Tier::Zero } } }; diff --git a/libevmasm/Instruction.h b/libevmasm/Instruction.h index 7f56ad3a..d79ec969 100644 --- a/libevmasm/Instruction.h +++ b/libevmasm/Instruction.h @@ -177,6 +177,7 @@ enum class Instruction: uint8_t RETURN, ///< halt execution returning output data 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) SELFDESTRUCT = 0xff ///< halt execution and register account for later deletion }; diff --git a/libevmasm/PeepholeOptimiser.cpp b/libevmasm/PeepholeOptimiser.cpp index 9a8341ab..6c92d76b 100644 --- a/libevmasm/PeepholeOptimiser.cpp +++ b/libevmasm/PeepholeOptimiser.cpp @@ -200,7 +200,8 @@ struct UnreachableCode it[0] != Instruction::RETURN && it[0] != Instruction::STOP && it[0] != Instruction::INVALID && - it[0] != Instruction::SELFDESTRUCT + it[0] != Instruction::SELFDESTRUCT && + it[0] != Instruction::REVERT ) return false; diff --git a/libevmasm/SemanticInformation.cpp b/libevmasm/SemanticInformation.cpp index 3a0843b8..61586e7b 100644 --- a/libevmasm/SemanticInformation.cpp +++ b/libevmasm/SemanticInformation.cpp @@ -119,6 +119,7 @@ bool SemanticInformation::altersControlFlow(AssemblyItem const& _item) case Instruction::SELFDESTRUCT: case Instruction::STOP: case Instruction::INVALID: + case Instruction::REVERT: return true; default: return false; |