This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Unambiguous licence.

  • Loading branch information...
gavofyork committed Aug 21, 2014
1 parent 0ee639d commit 2f524f645b536782085cc2f0be79289479f73d44
Showing with 910 additions and 143 deletions.
  1. +674 −19 LICENSE
  2. +1 −1 libethcore/CommonEth.cpp
  3. +44 −28 libevm/VM.h
  4. +152 −90 libevmface/Instruction.cpp
  5. +36 −2 libevmface/Instruction.h
  6. +3 −3 liblll/CodeFragment.cpp
View
693 LICENSE

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -29,7 +29,7 @@ using namespace eth;
//#define ETH_ADDRESS_DEBUG 1
-const unsigned eth::c_protocolVersion = 27;
+const unsigned eth::c_protocolVersion = 28;
const unsigned eth::c_databaseVersion = 1;
static const vector<pair<u256, string>> g_units =
View
@@ -440,39 +440,52 @@ template <class Ext> eth::bytesConstRef eth::VM::go(Ext& _ext, OnOpFunc const& _
require(1);
m_stack.pop_back();
break;
- case Instruction::DUP:
- require(1);
- m_stack.push_back(m_stack.back());
- break;
- /*case Instruction::DUPN:
+ case Instruction::DUP1:
+ case Instruction::DUP2:
+ case Instruction::DUP3:
+ case Instruction::DUP4:
+ case Instruction::DUP5:
+ case Instruction::DUP6:
+ case Instruction::DUP7:
+ case Instruction::DUP8:
+ case Instruction::DUP9:
+ case Instruction::DUP10:
+ case Instruction::DUP11:
+ case Instruction::DUP12:
+ case Instruction::DUP13:
+ case Instruction::DUP14:
+ case Instruction::DUP15:
+ case Instruction::DUP16:
{
- auto s = store(curPC + 1);
- if (s == 0 || s > stack.size())
- throw OperandOutOfRange(1, stack.size(), s);
- stack.push_back(stack[stack.size() - (uint)s]);
- nextPC = curPC + 2;
- break;
- }*/
- case Instruction::SWAP:
+ auto n = 1 + (int)inst - (int)Instruction::DUP1;
+ require(n);
+ m_stack.push_back(m_stack[m_stack.size() - n]);
+ break;
+ }
+ case Instruction::SWAP1:
+ case Instruction::SWAP2:
+ case Instruction::SWAP3:
+ case Instruction::SWAP4:
+ case Instruction::SWAP5:
+ case Instruction::SWAP6:
+ case Instruction::SWAP7:
+ case Instruction::SWAP8:
+ case Instruction::SWAP9:
+ case Instruction::SWAP10:
+ case Instruction::SWAP11:
+ case Instruction::SWAP12:
+ case Instruction::SWAP13:
+ case Instruction::SWAP14:
+ case Instruction::SWAP15:
+ case Instruction::SWAP16:
{
- require(2);
+ unsigned n = (int)inst - (int)Instruction::SWAP1 + 2;
+ require(n);
auto d = m_stack.back();
- m_stack.back() = m_stack[m_stack.size() - 2];
- m_stack[m_stack.size() - 2] = d;
+ m_stack.back() = m_stack[m_stack.size() - n];
+ m_stack[m_stack.size() - n] = d;
break;
}
- /*case Instruction::SWAPN:
- {
- require(1);
- auto d = stack.back();
- auto s = store(curPC + 1);
- if (s == 0 || s > stack.size())
- throw OperandOutOfRange(1, stack.size(), s);
- stack.back() = stack[stack.size() - (uint)s];
- stack[stack.size() - (uint)s] = d;
- nextPC = curPC + 2;
- break;
- }*/
case Instruction::MLOAD:
{
require(1);
@@ -597,6 +610,9 @@ template <class Ext> eth::bytesConstRef eth::VM::go(Ext& _ext, OnOpFunc const& _
}
case Instruction::STOP:
return bytesConstRef();
+ case Instruction::NOP1:
+ case Instruction::NOP2:
+ break;
default:
throw BadInstruction();
}
View
@@ -66,8 +66,8 @@ const std::map<std::string, Instruction> eth::c_instructions =
{ "DIFFICULTY", Instruction::DIFFICULTY },
{ "GASLIMIT", Instruction::GASLIMIT },
{ "POP", Instruction::POP },
- { "DUP", Instruction::DUP },
- { "SWAP", Instruction::SWAP },
+ { "NOP1", Instruction::NOP1 },
+ { "NOP2", Instruction::NOP2 },
{ "MLOAD", Instruction::MLOAD },
{ "MSTORE", Instruction::MSTORE },
{ "MSTORE8", Instruction::MSTORE8 },
@@ -110,101 +110,163 @@ const std::map<std::string, Instruction> eth::c_instructions =
{ "PUSH30", Instruction::PUSH30 },
{ "PUSH31", Instruction::PUSH31 },
{ "PUSH32", Instruction::PUSH32 },
+ { "DUP1", Instruction::DUP1 },
+ { "DUP2", Instruction::DUP2 },
+ { "DUP3", Instruction::DUP3 },
+ { "DUP4", Instruction::DUP4 },
+ { "DUP5", Instruction::DUP5 },
+ { "DUP6", Instruction::DUP6 },
+ { "DUP7", Instruction::DUP7 },
+ { "DUP8", Instruction::DUP8 },
+ { "DUP9", Instruction::DUP9 },
+ { "DUP10", Instruction::DUP10 },
+ { "DUP11", Instruction::DUP11 },
+ { "DUP12", Instruction::DUP12 },
+ { "DUP13", Instruction::DUP13 },
+ { "DUP14", Instruction::DUP14 },
+ { "DUP15", Instruction::DUP15 },
+ { "DUP16", Instruction::DUP16 },
+ { "SWAP1", Instruction::SWAP1 },
+ { "SWAP2", Instruction::SWAP2 },
+ { "SWAP3", Instruction::SWAP3 },
+ { "SWAP4", Instruction::SWAP4 },
+ { "SWAP5", Instruction::SWAP5 },
+ { "SWAP6", Instruction::SWAP6 },
+ { "SWAP7", Instruction::SWAP7 },
+ { "SWAP8", Instruction::SWAP8 },
+ { "SWAP9", Instruction::SWAP9 },
+ { "SWAP10", Instruction::SWAP10 },
+ { "SWAP11", Instruction::SWAP11 },
+ { "SWAP12", Instruction::SWAP12 },
+ { "SWAP13", Instruction::SWAP13 },
+ { "SWAP14", Instruction::SWAP14 },
+ { "SWAP15", Instruction::SWAP15 },
+ { "SWAP16", Instruction::SWAP16 },
{ "CREATE", Instruction::CREATE },
{ "CALL", Instruction::CALL },
{ "RETURN", Instruction::RETURN },
{ "SUICIDE", Instruction::SUICIDE }
};
const std::map<Instruction, InstructionInfo> eth::c_instructionInfo =
-{ // Add, Args, Ret
- { Instruction::STOP, { "STOP", 0, 0, 0 } },
- { Instruction::ADD, { "ADD", 0, 2, 1 } },
- { Instruction::SUB, { "SUB", 0, 2, 1 } },
- { Instruction::MUL, { "MUL", 0, 2, 1 } },
- { Instruction::DIV, { "DIV", 0, 2, 1 } },
- { Instruction::SDIV, { "SDIV", 0, 2, 1 } },
- { Instruction::MOD, { "MOD", 0, 2, 1 } },
- { Instruction::SMOD, { "SMOD", 0, 2, 1 } },
- { Instruction::EXP, { "EXP", 0, 2, 1 } },
- { Instruction::NEG, { "NEG", 0, 1, 1 } },
- { Instruction::LT, { "LT", 0, 2, 1 } },
- { Instruction::GT, { "GT", 0, 2, 1 } },
- { Instruction::SLT, { "SLT", 0, 2, 1 } },
- { Instruction::SGT, { "SGT", 0, 2, 1 } },
- { Instruction::EQ, { "EQ", 0, 2, 1 } },
- { Instruction::NOT, { "NOT", 0, 1, 1 } },
- { Instruction::AND, { "AND", 0, 2, 1 } },
- { Instruction::OR, { "OR", 0, 2, 1 } },
- { Instruction::XOR, { "XOR", 0, 2, 1 } },
- { Instruction::BYTE, { "BYTE", 0, 2, 1 } },
- { Instruction::SHA3, { "SHA3", 0, 2, 1 } },
- { Instruction::ADDRESS, { "ADDRESS", 0, 0, 1 } },
- { Instruction::BALANCE, { "BALANCE", 0, 1, 1 } },
- { Instruction::ORIGIN, { "ORIGIN", 0, 0, 1 } },
- { Instruction::CALLER, { "CALLER", 0, 0, 1 } },
- { Instruction::CALLVALUE, { "CALLVALUE", 0, 0, 1 } },
- { Instruction::CALLDATALOAD, { "CALLDATALOAD", 0, 1, 1 } },
- { Instruction::CALLDATASIZE, { "CALLDATASIZE", 0, 0, 1 } },
- { Instruction::CALLDATACOPY, { "CALLDATACOPY", 0, 3, 0 } },
- { Instruction::CODESIZE, { "CODESIZE", 0, 0, 1 } },
- { Instruction::CODECOPY, { "CODECOPY", 0, 3, 0 } },
- { Instruction::GASPRICE, { "GASPRICE", 0, 0, 1 } },
- { Instruction::PREVHASH, { "PREVHASH", 0, 0, 1 } },
- { Instruction::COINBASE, { "COINBASE", 0, 0, 1 } },
- { Instruction::TIMESTAMP, { "TIMESTAMP", 0, 0, 1 } },
- { Instruction::NUMBER, { "NUMBER", 0, 0, 1 } },
- { Instruction::DIFFICULTY, { "DIFFICULTY", 0, 0, 1 } },
- { Instruction::GASLIMIT, { "GASLIMIT", 0, 0, 1 } },
- { Instruction::POP, { "POP", 0, 1, 0 } },
- { Instruction::DUP, { "DUP", 0, 1, 2 } },
- { Instruction::SWAP, { "SWAP", 0, 2, 2 } },
- { Instruction::MLOAD, { "MLOAD", 0, 1, 1 } },
- { Instruction::MSTORE, { "MSTORE", 0, 2, 0 } },
- { Instruction::MSTORE8, { "MSTORE8", 0, 2, 0 } },
- { Instruction::SLOAD, { "SLOAD", 0, 1, 1 } },
- { Instruction::SSTORE, { "SSTORE", 0, 2, 0 } },
- { Instruction::JUMP, { "JUMP", 0, 1, 0 } },
- { Instruction::JUMPI, { "JUMPI", 0, 2, 0 } },
- { Instruction::PC, { "PC", 0, 0, 1 } },
- { Instruction::MSIZE, { "MSIZE", 0, 0, 1 } },
- { Instruction::GAS, { "GAS", 0, 0, 1 } },
- { Instruction::PUSH1, { "PUSH1", 1, 0, 1 } },
- { Instruction::PUSH2, { "PUSH2", 2, 0, 1 } },
- { Instruction::PUSH3, { "PUSH3", 3, 0, 1 } },
- { Instruction::PUSH4, { "PUSH4", 4, 0, 1 } },
- { Instruction::PUSH5, { "PUSH5", 5, 0, 1 } },
- { Instruction::PUSH6, { "PUSH6", 6, 0, 1 } },
- { Instruction::PUSH7, { "PUSH7", 7, 0, 1 } },
- { Instruction::PUSH8, { "PUSH8", 8, 0, 1 } },
- { Instruction::PUSH9, { "PUSH9", 9, 0, 1 } },
- { Instruction::PUSH10, { "PUSH10", 10, 0, 1 } },
- { Instruction::PUSH11, { "PUSH11", 11, 0, 1 } },
- { Instruction::PUSH12, { "PUSH12", 12, 0, 1 } },
- { Instruction::PUSH13, { "PUSH13", 13, 0, 1 } },
- { Instruction::PUSH14, { "PUSH14", 14, 0, 1 } },
- { Instruction::PUSH15, { "PUSH15", 15, 0, 1 } },
- { Instruction::PUSH16, { "PUSH16", 16, 0, 1 } },
- { Instruction::PUSH17, { "PUSH17", 17, 0, 1 } },
- { Instruction::PUSH18, { "PUSH18", 18, 0, 1 } },
- { Instruction::PUSH19, { "PUSH19", 19, 0, 1 } },
- { Instruction::PUSH20, { "PUSH20", 20, 0, 1 } },
- { Instruction::PUSH21, { "PUSH21", 21, 0, 1 } },
- { Instruction::PUSH22, { "PUSH22", 22, 0, 1 } },
- { Instruction::PUSH23, { "PUSH23", 23, 0, 1 } },
- { Instruction::PUSH24, { "PUSH24", 24, 0, 1 } },
- { Instruction::PUSH25, { "PUSH25", 25, 0, 1 } },
- { Instruction::PUSH26, { "PUSH26", 26, 0, 1 } },
- { Instruction::PUSH27, { "PUSH27", 27, 0, 1 } },
- { Instruction::PUSH28, { "PUSH28", 28, 0, 1 } },
- { Instruction::PUSH29, { "PUSH29", 29, 0, 1 } },
- { Instruction::PUSH30, { "PUSH30", 30, 0, 1 } },
- { Instruction::PUSH31, { "PUSH31", 31, 0, 1 } },
- { Instruction::PUSH32, { "PUSH32", 32, 0, 1 } },
- { Instruction::CREATE, { "CREATE", 0, 3, 1 } },
- { Instruction::CALL, { "CALL", 0, 7, 1 } },
- { Instruction::RETURN, { "RETURN", 0, 2, 0 } },
- { Instruction::SUICIDE, { "SUICIDE", 0, 1, 0} }
+{ // Add, Args, Ret
+ { Instruction::STOP, { "STOP", 0, 0, 0 } },
+ { Instruction::ADD, { "ADD", 0, 2, 1 } },
+ { Instruction::SUB, { "SUB", 0, 2, 1 } },
+ { Instruction::MUL, { "MUL", 0, 2, 1 } },
+ { Instruction::DIV, { "DIV", 0, 2, 1 } },
+ { Instruction::SDIV, { "SDIV", 0, 2, 1 } },
+ { Instruction::MOD, { "MOD", 0, 2, 1 } },
+ { Instruction::SMOD, { "SMOD", 0, 2, 1 } },
+ { Instruction::EXP, { "EXP", 0, 2, 1 } },
+ { Instruction::NEG, { "NEG", 0, 1, 1 } },
+ { Instruction::LT, { "LT", 0, 2, 1 } },
+ { Instruction::GT, { "GT", 0, 2, 1 } },
+ { Instruction::SLT, { "SLT", 0, 2, 1 } },
+ { Instruction::SGT, { "SGT", 0, 2, 1 } },
+ { Instruction::EQ, { "EQ", 0, 2, 1 } },
+ { Instruction::NOT, { "NOT", 0, 1, 1 } },
+ { Instruction::AND, { "AND", 0, 2, 1 } },
+ { Instruction::OR, { "OR", 0, 2, 1 } },
+ { Instruction::XOR, { "XOR", 0, 2, 1 } },
+ { Instruction::BYTE, { "BYTE", 0, 2, 1 } },
+ { Instruction::SHA3, { "SHA3", 0, 2, 1 } },
+ { Instruction::ADDRESS, { "ADDRESS", 0, 0, 1 } },
+ { Instruction::BALANCE, { "BALANCE", 0, 1, 1 } },
+ { Instruction::ORIGIN, { "ORIGIN", 0, 0, 1 } },
+ { Instruction::CALLER, { "CALLER", 0, 0, 1 } },
+ { Instruction::CALLVALUE, { "CALLVALUE", 0, 0, 1 } },
+ { Instruction::CALLDATALOAD,{ "CALLDATALOAD", 0, 1, 1 } },
+ { Instruction::CALLDATASIZE,{ "CALLDATASIZE", 0, 0, 1 } },
+ { Instruction::CALLDATACOPY,{ "CALLDATACOPY", 0, 3, 0 } },
+ { Instruction::CODESIZE, { "CODESIZE", 0, 0, 1 } },
+ { Instruction::CODECOPY, { "CODECOPY", 0, 3, 0 } },
+ { Instruction::GASPRICE, { "GASPRICE", 0, 0, 1 } },
+ { Instruction::PREVHASH, { "PREVHASH", 0, 0, 1 } },
+ { Instruction::COINBASE, { "COINBASE", 0, 0, 1 } },
+ { Instruction::TIMESTAMP, { "TIMESTAMP", 0, 0, 1 } },
+ { Instruction::NUMBER, { "NUMBER", 0, 0, 1 } },
+ { Instruction::DIFFICULTY, { "DIFFICULTY", 0, 0, 1 } },
+ { Instruction::GASLIMIT, { "GASLIMIT", 0, 0, 1 } },
+ { Instruction::POP, { "POP", 0, 1, 0 } },
+ { Instruction::MLOAD, { "MLOAD", 0, 1, 1 } },
+ { Instruction::MSTORE, { "MSTORE", 0, 2, 0 } },
+ { Instruction::MSTORE8, { "MSTORE8", 0, 2, 0 } },
+ { Instruction::SLOAD, { "SLOAD", 0, 1, 1 } },
+ { Instruction::SSTORE, { "SSTORE", 0, 2, 0 } },
+ { Instruction::JUMP, { "JUMP", 0, 1, 0 } },
+ { Instruction::JUMPI, { "JUMPI", 0, 2, 0 } },
+ { Instruction::PC, { "PC", 0, 0, 1 } },
+ { Instruction::MSIZE, { "MSIZE", 0, 0, 1 } },
+ { Instruction::GAS, { "GAS", 0, 0, 1 } },
+ { Instruction::PUSH1, { "PUSH1", 1, 0, 1 } },
+ { Instruction::PUSH2, { "PUSH2", 2, 0, 1 } },
+ { Instruction::PUSH3, { "PUSH3", 3, 0, 1 } },
+ { Instruction::PUSH4, { "PUSH4", 4, 0, 1 } },
+ { Instruction::PUSH5, { "PUSH5", 5, 0, 1 } },
+ { Instruction::PUSH6, { "PUSH6", 6, 0, 1 } },
+ { Instruction::PUSH7, { "PUSH7", 7, 0, 1 } },
+ { Instruction::PUSH8, { "PUSH8", 8, 0, 1 } },
+ { Instruction::PUSH9, { "PUSH9", 9, 0, 1 } },
+ { Instruction::PUSH10, { "PUSH10", 10, 0, 1 } },
+ { Instruction::PUSH11, { "PUSH11", 11, 0, 1 } },
+ { Instruction::PUSH12, { "PUSH12", 12, 0, 1 } },
+ { Instruction::PUSH13, { "PUSH13", 13, 0, 1 } },
+ { Instruction::PUSH14, { "PUSH14", 14, 0, 1 } },
+ { Instruction::PUSH15, { "PUSH15", 15, 0, 1 } },
+ { Instruction::PUSH16, { "PUSH16", 16, 0, 1 } },
+ { Instruction::PUSH17, { "PUSH17", 17, 0, 1 } },
+ { Instruction::PUSH18, { "PUSH18", 18, 0, 1 } },
+ { Instruction::PUSH19, { "PUSH19", 19, 0, 1 } },
+ { Instruction::PUSH20, { "PUSH20", 20, 0, 1 } },
+ { Instruction::PUSH21, { "PUSH21", 21, 0, 1 } },
+ { Instruction::PUSH22, { "PUSH22", 22, 0, 1 } },
+ { Instruction::PUSH23, { "PUSH23", 23, 0, 1 } },
+ { Instruction::PUSH24, { "PUSH24", 24, 0, 1 } },
+ { Instruction::PUSH25, { "PUSH25", 25, 0, 1 } },
+ { Instruction::PUSH26, { "PUSH26", 26, 0, 1 } },
+ { Instruction::PUSH27, { "PUSH27", 27, 0, 1 } },
+ { Instruction::PUSH28, { "PUSH28", 28, 0, 1 } },
+ { Instruction::PUSH29, { "PUSH29", 29, 0, 1 } },
+ { Instruction::PUSH30, { "PUSH30", 30, 0, 1 } },
+ { Instruction::PUSH31, { "PUSH31", 31, 0, 1 } },
+ { Instruction::PUSH32, { "PUSH32", 32, 0, 1 } },
+ { Instruction::DUP1, { "DUP1", 0, 1, 2 } },
+ { Instruction::DUP2, { "DUP2", 0, 2, 3 } },
+ { Instruction::DUP3, { "DUP3", 0, 3, 4 } },
+ { Instruction::DUP4, { "DUP4", 0, 4, 5 } },
+ { Instruction::DUP5, { "DUP5", 0, 5, 6 } },
+ { Instruction::DUP6, { "DUP6", 0, 6, 7 } },
+ { Instruction::DUP7, { "DUP7", 0, 7, 8 } },
+ { Instruction::DUP8, { "DUP8", 0, 8, 9 } },
+ { Instruction::DUP9, { "DUP9", 0, 9, 10 } },
+ { Instruction::DUP10, { "DUP10", 0, 10, 11 } },
+ { Instruction::DUP11, { "DUP11", 0, 11, 12 } },
+ { Instruction::DUP12, { "DUP12", 0, 12, 13 } },
+ { Instruction::DUP13, { "DUP13", 0, 13, 14 } },
+ { Instruction::DUP14, { "DUP14", 0, 14, 15 } },
+ { Instruction::DUP15, { "DUP15", 0, 15, 16 } },
+ { Instruction::DUP16, { "DUP16", 0, 16, 17 } },
+ { Instruction::SWAP1, { "SWAP1", 0, 2, 2 } },
+ { Instruction::SWAP2, { "SWAP2", 0, 3, 3 } },
+ { Instruction::SWAP3, { "SWAP3", 0, 4, 4 } },
+ { Instruction::SWAP4, { "SWAP4", 0, 5, 5 } },
+ { Instruction::SWAP5, { "SWAP5", 0, 6, 6 } },
+ { Instruction::SWAP6, { "SWAP6", 0, 7, 7 } },
+ { Instruction::SWAP7, { "SWAP7", 0, 8, 8 } },
+ { Instruction::SWAP8, { "SWAP8", 0, 9, 9 } },
+ { Instruction::SWAP9, { "SWAP9", 0, 10, 10 } },
+ { Instruction::SWAP10, { "SWAP10", 0, 11, 11 } },
+ { Instruction::SWAP11, { "SWAP11", 0, 12, 12 } },
+ { Instruction::SWAP12, { "SWAP12", 0, 13, 13 } },
+ { Instruction::SWAP13, { "SWAP13", 0, 14, 14 } },
+ { Instruction::SWAP14, { "SWAP14", 0, 15, 15 } },
+ { Instruction::SWAP15, { "SWAP15", 0, 16, 16 } },
+ { Instruction::SWAP16, { "SWAP16", 0, 17, 17 } },
+ { Instruction::CREATE, { "CREATE", 0, 3, 1 } },
+ { Instruction::CALL, { "CALL", 0, 7, 1 } },
+ { Instruction::RETURN, { "RETURN", 0, 2, 0 } },
+ { Instruction::SUICIDE, { "SUICIDE", 0, 1, 0} }
};
string eth::disassemble(bytes const& _mem)
Oops, something went wrong.

0 comments on commit 2f524f6

Please sign in to comment.