Browse Source

Merge branch 'develop-evmcc' into pr-jit

cl-refactor
Paweł Bylica 10 years ago
parent
commit
3146b6d05d
  1. 1
      evmcc/CMakeLists.txt
  2. 21
      evmcc/evmcc.cpp
  3. 1
      evmcc/test/except/badinst1.evm
  4. 169
      evmcc/test/vmtests/vmPerformanceTest.json
  5. 2
      libdevcore/FixedHash.h
  6. 8
      libevm/VM.h
  7. 53
      libevmjit/Arith256.cpp
  8. 6
      libevmjit/Arith256.h
  9. 33
      libevmjit/Compiler.cpp
  10. 7
      libevmjit/CompilerHelper.h
  11. 23
      libevmjit/ExecutionEngine.cpp
  12. 21
      libevmjit/Ext.cpp
  13. 8
      libevmjit/GasMeter.cpp
  14. 2
      libevmjit/GasMeter.h
  15. 16
      libevmjit/Runtime.cpp
  16. 11
      libevmjit/Runtime.h
  17. 3
      libevmjit/Type.h
  18. 3
      libevmjit/Utils.h
  19. 11
      libevmjit/VM.cpp
  20. 46
      test/vm.cpp
  21. 2
      test/vm.h
  22. 1
      windows/LibEthereum.vcxproj.filters
  23. 2
      windows/evmcc.vcxproj

1
evmcc/CMakeLists.txt

@ -10,6 +10,7 @@ add_executable(${EXECUTABLE} ${SRC_LIST})
target_link_libraries(${EXECUTABLE} devcore) target_link_libraries(${EXECUTABLE} devcore)
target_link_libraries(${EXECUTABLE} ethcore) target_link_libraries(${EXECUTABLE} ethcore)
target_link_libraries(${EXECUTABLE} ethereum)
target_link_libraries(${EXECUTABLE} evm) target_link_libraries(${EXECUTABLE} evm)
target_link_libraries(${EXECUTABLE} evmface) target_link_libraries(${EXECUTABLE} evmface)
target_link_libraries(${EXECUTABLE} evmjit) target_link_libraries(${EXECUTABLE} evmjit)

21
evmcc/evmcc.cpp

@ -1,4 +1,5 @@
#include <chrono>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <ostream> #include <ostream>
@ -32,6 +33,7 @@ int main(int argc, char** argv)
bool opt_interpret = false; bool opt_interpret = false;
bool opt_dump_graph = false; bool opt_dump_graph = false;
bool opt_unknown = false; bool opt_unknown = false;
bool opt_verbose = false;
size_t initialGas = 10000; size_t initialGas = 10000;
for (int i = 1; i < argc; i++) for (int i = 1; i < argc; i++)
@ -45,14 +47,16 @@ int main(int argc, char** argv)
opt_dissassemble = true; opt_dissassemble = true;
else if (option == "-i") else if (option == "-i")
opt_interpret = true; opt_interpret = true;
else if (option == "-g") else if (option == "--dump-cfg")
opt_dump_graph = true; opt_dump_graph = true;
else if (option == "-G" && i + 1 < argc) else if (option == "-g" && i + 1 < argc)
{ {
std::string gasValue = argv[++i]; std::string gasValue = argv[++i];
initialGas = boost::lexical_cast<size_t>(gasValue); initialGas = boost::lexical_cast<size_t>(gasValue);
std::cerr << "Initial gas set to " << initialGas << "\n"; std::cerr << "Initial gas set to " << initialGas << "\n";
} }
else if (option == "-v")
opt_verbose = true;
else if (option[0] != '-' && input_file.empty()) else if (option[0] != '-' && input_file.empty())
input_file = option; input_file = option;
else else
@ -87,9 +91,7 @@ int main(int argc, char** argv)
bytes bytecode = fromHex(src); bytes bytecode = fromHex(src);
if (opt_show_bytes) if (opt_show_bytes)
{
std::cout << memDump(bytecode) << std::endl; std::cout << memDump(bytecode) << std::endl;
}
if (opt_dissassemble) if (opt_dissassemble)
{ {
@ -99,11 +101,22 @@ int main(int argc, char** argv)
if (opt_compile || opt_interpret) if (opt_compile || opt_interpret)
{ {
auto compilationStartTime = std::chrono::high_resolution_clock::now();
auto compiler = eth::jit::Compiler(); auto compiler = eth::jit::Compiler();
auto module = compiler.compile({bytecode.data(), bytecode.size()}); auto module = compiler.compile({bytecode.data(), bytecode.size()});
auto compilationEndTime = std::chrono::high_resolution_clock::now();
module->dump(); module->dump();
if (opt_verbose)
{
std::cerr << "*** Compilation time: "
<< std::chrono::duration_cast<std::chrono::microseconds>(compilationEndTime - compilationStartTime).count()
<< std::endl;
}
if (opt_dump_graph) if (opt_dump_graph)
{ {
std::ofstream ofs("blocks.dot"); std::ofstream ofs("blocks.dot");

1
evmcc/test/except/badinst1.evm

@ -0,0 +1 @@
4a

169
evmcc/test/vmtests/vmPerformanceTest.json

@ -0,0 +1,169 @@
{
"for100000" : {
"callcreates" : [ ],
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "256",
"currentGasLimit" : "10000000",
"currentNumber" : "0",
"currentTimestamp" : "1",
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"code" : "0x620186a06080545d60006080530b0f60295960a0536080530160a0546001608053036080546008585d",
"data" : "0x",
"gas" : "10000000",
"gasPrice" : "100000000000000",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000"
},
"gas" : "7799983",
"out" : "0x0",
"post" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"code" : "0x620186a06080545d60006080530b0f60295960a0536080530160a0546001608053036080546008585d",
"nonce" : "0",
"storage" : {
}
}
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"code" : "0x620186a06080545d60006080530b0f60295960a0536080530160a0546001608053036080546008585d",
"nonce" : "0",
"storage" : { }
}
}
},
"recloop" : {
"callcreates" : [ ],
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "256",
"currentGasLimit" : "10000000",
"currentNumber" : "0",
"currentTimestamp" : "1",
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"code" : "0x600c6204000060006015585d60005460206000f25d6000820e602e59602a60018303600183016015585d6030585d805d905090509058",
"data" : "0x",
"gas" : "10000000",
"gasPrice" : "100000000000000",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000"
},
"gas" : "4232808",
"out" : "0x0000000000000000000000000000000000000000000000000000000000040000",
"post" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"code" : "0x600c6204000060006015585d60005460206000f25d6000820e602e59602a60018303600183016015585d6030585d805d905090509058",
"nonce" : "0",
"storage" : {
}
}
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"code" : "0x600c6204000060006015585d60005460206000f25d6000820e602e59602a60018303600183016015585d6030585d805d905090509058",
"nonce" : "0",
"storage" : { }
}
}
},
"fib25" : {
"callcreates" : [
],
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "256",
"currentGasLimit" : "10000000",
"currentNumber" : "0",
"currentTimestamp" : "1",
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"code" : "0x600860196011585d60005460206000f25d6003810a6031596022600282036011585d602c600183036011585d016034585d60015d90509058",
"data" : "0x",
"gas" : "10000000",
"gasPrice" : "100000000000000",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000"
},
"gas" : "7374139",
"out" : "0x0000000000000000000000000000000000000000000000000000000000012511",
"post" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"code" : "0x600860196011585d60005460206000f25d6003810a6031596022600282036011585d602c600183036011585d016034585d60015d90509058",
"nonce" : "0",
"storage" : {
}
}
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"code" : "0x600860196011585d60005460206000f25d6003810a6031596022600282036011585d602c600183036011585d016034585d60015d90509058",
"nonce" : "0",
"storage" : {
}
}
}
},
"ackermann36" : {
"callcreates" : [
],
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "256",
"currentGasLimit" : "10000000",
"currentNumber" : "0",
"currentTimestamp" : "1",
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"code" : "0x600a600360066013585d60005460206000f25d6000820e604b596000810e603a59603660018303603284600185036013585d6013585d6047585d60466001830360016013585d5d6050585d600181015d905090509058",
"data" : "0x",
"gas" : "10000000",
"gasPrice" : "100000000000000",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000"
},
"gas" : "5865402",
"out" : "0x00000000000000000000000000000000000000000000000000000000000001fd",
"post" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"code" : "0x600a600360066013585d60005460206000f25d6000820e604b596000810e603a59603660018303603284600185036013585d6013585d6047585d60466001830360016013585d5d6050585d600181015d905090509058",
"nonce" : "0",
"storage" : {
}
}
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"code" : "0x600a600360066013585d60005460206000f25d6000820e604b596000810e603a59603660018303603284600185036013585d6013585d6047585d60466001830360016013585d5d6050585d600181015d905090509058",
"nonce" : "0",
"storage" : {
}
}
}
},
}

2
libdevcore/FixedHash.h

@ -158,7 +158,7 @@ public:
return ret; return ret;
} }
template <unsigned P, unsigned M> inline FixedHash& shiftBloom(FixedHash<M> const& _h) { return (*this |= _h.nbloom<P, N>()); } template <unsigned P, unsigned M> inline FixedHash& shiftBloom(FixedHash<M> const& _h) { return (*this |= _h.template nbloom<P, N>()); }
template <unsigned P, unsigned M> inline FixedHash<M> nbloom() const template <unsigned P, unsigned M> inline FixedHash<M> nbloom() const
{ {

8
libevm/VM.h

@ -427,9 +427,13 @@ template <class Ext> dev::bytesConstRef dev::eth::VM::go(Ext& _ext, OnOpFunc con
break; break;
case Instruction::SIGNEXTEND: case Instruction::SIGNEXTEND:
{ {
auto k = m_stack[m_stack.size() - 2]; unsigned k = m_stack.back().convert_to<unsigned>();
m_stack[m_stack.size() - 2] = m_stack.back();
m_stack.pop_back(); m_stack.pop_back();
auto& b = m_stack.back();
if (k <= 31)
if ((b >> (k * 8)) & 0x80)
for (unsigned i = 31; i > k; --i)
b |= (u256(0xff) << i);
break; break;
} }
case Instruction::SHA3: case Instruction::SHA3:

53
libevmjit/Arith256.cpp

@ -21,15 +21,20 @@ Arith256::Arith256(llvm::IRBuilder<>& _builder) :
m_result = m_builder.CreateAlloca(Type::i256, nullptr, "arith.result"); m_result = m_builder.CreateAlloca(Type::i256, nullptr, "arith.result");
m_arg1 = m_builder.CreateAlloca(Type::i256, nullptr, "arith.arg1"); m_arg1 = m_builder.CreateAlloca(Type::i256, nullptr, "arith.arg1");
m_arg2 = m_builder.CreateAlloca(Type::i256, nullptr, "arith.arg2"); m_arg2 = m_builder.CreateAlloca(Type::i256, nullptr, "arith.arg2");
m_arg3 = m_builder.CreateAlloca(Type::i256, nullptr, "arith.arg3");
using Linkage = GlobalValue::LinkageTypes; using Linkage = GlobalValue::LinkageTypes;
llvm::Type* argTypes[] = {Type::WordPtr, Type::WordPtr, Type::WordPtr}; llvm::Type* arg2Types[] = {Type::WordPtr, Type::WordPtr, Type::WordPtr};
m_mul = Function::Create(FunctionType::get(Type::Void, argTypes, false), Linkage::ExternalLinkage, "arith_mul", getModule()); llvm::Type* arg3Types[] = {Type::WordPtr, Type::WordPtr, Type::WordPtr, Type::WordPtr};
m_div = Function::Create(FunctionType::get(Type::Void, argTypes, false), Linkage::ExternalLinkage, "arith_div", getModule());
m_mod = Function::Create(FunctionType::get(Type::Void, argTypes, false), Linkage::ExternalLinkage, "arith_mod", getModule()); m_mul = Function::Create(FunctionType::get(Type::Void, arg2Types, false), Linkage::ExternalLinkage, "arith_mul", getModule());
m_sdiv = Function::Create(FunctionType::get(Type::Void, argTypes, false), Linkage::ExternalLinkage, "arith_sdiv", getModule()); m_div = Function::Create(FunctionType::get(Type::Void, arg2Types, false), Linkage::ExternalLinkage, "arith_div", getModule());
m_smod = Function::Create(FunctionType::get(Type::Void, argTypes, false), Linkage::ExternalLinkage, "arith_smod", getModule()); m_mod = Function::Create(FunctionType::get(Type::Void, arg2Types, false), Linkage::ExternalLinkage, "arith_mod", getModule());
m_sdiv = Function::Create(FunctionType::get(Type::Void, arg2Types, false), Linkage::ExternalLinkage, "arith_sdiv", getModule());
m_smod = Function::Create(FunctionType::get(Type::Void, arg2Types, false), Linkage::ExternalLinkage, "arith_smod", getModule());
m_addmod = Function::Create(FunctionType::get(Type::Void, arg3Types, false), Linkage::ExternalLinkage, "arith_addmod", getModule());
m_mulmod = Function::Create(FunctionType::get(Type::Void, arg3Types, false), Linkage::ExternalLinkage, "arith_mulmod", getModule());
} }
Arith256::~Arith256() Arith256::~Arith256()
@ -43,6 +48,15 @@ llvm::Value* Arith256::binaryOp(llvm::Function* _op, llvm::Value* _arg1, llvm::V
return m_builder.CreateLoad(m_result); return m_builder.CreateLoad(m_result);
} }
llvm::Value* Arith256::ternaryOp(llvm::Function* _op, llvm::Value* _arg1, llvm::Value* _arg2, llvm::Value* _arg3)
{
m_builder.CreateStore(_arg1, m_arg1);
m_builder.CreateStore(_arg2, m_arg2);
m_builder.CreateStore(_arg3, m_arg3);
m_builder.CreateCall4(_op, m_arg1, m_arg2, m_arg3, m_result);
return m_builder.CreateLoad(m_result);
}
llvm::Value* Arith256::mul(llvm::Value* _arg1, llvm::Value* _arg2) llvm::Value* Arith256::mul(llvm::Value* _arg1, llvm::Value* _arg2)
{ {
return binaryOp(m_mul, _arg1, _arg2); return binaryOp(m_mul, _arg1, _arg2);
@ -68,6 +82,17 @@ llvm::Value* Arith256::smod(llvm::Value* _arg1, llvm::Value* _arg2)
return binaryOp(m_smod, _arg1, _arg2); return binaryOp(m_smod, _arg1, _arg2);
} }
llvm::Value* Arith256::addmod(llvm::Value* _arg1, llvm::Value* _arg2, llvm::Value* _arg3)
{
return ternaryOp(m_addmod, _arg1, _arg2, _arg3);
}
llvm::Value* Arith256::mulmod(llvm::Value* _arg1, llvm::Value* _arg2, llvm::Value* _arg3)
{
return ternaryOp(m_mulmod, _arg1, _arg2, _arg3);
}
} }
} }
} }
@ -113,6 +138,22 @@ EXPORT void arith_smod(i256* _arg1, i256* _arg2, i256* _result)
*_result = eth2llvm(arg2 == 0 ? arg2 : dev::s2u(dev::u2s(arg1) % dev::u2s(arg2))); *_result = eth2llvm(arg2 == 0 ? arg2 : dev::s2u(dev::u2s(arg1) % dev::u2s(arg2)));
} }
EXPORT void arith_mulmod(i256* _arg1, i256* _arg2, i256* _arg3, i256* _result)
{
dev::u256 arg1 = llvm2eth(*_arg1);
dev::u256 arg2 = llvm2eth(*_arg2);
dev::u256 arg3 = llvm2eth(*_arg3);
*_result = eth2llvm(dev::u256((dev::bigint(arg1) * dev::bigint(arg2)) % arg3));
}
EXPORT void arith_addmod(i256* _arg1, i256* _arg2, i256* _arg3, i256* _result)
{
dev::u256 arg1 = llvm2eth(*_arg1);
dev::u256 arg2 = llvm2eth(*_arg2);
dev::u256 arg3 = llvm2eth(*_arg3);
*_result = eth2llvm(dev::u256((dev::bigint(arg1) + dev::bigint(arg2)) % arg3));
}
} }

6
libevmjit/Arith256.h

@ -20,18 +20,24 @@ public:
llvm::Value* mod(llvm::Value* _arg1, llvm::Value* _arg2); llvm::Value* mod(llvm::Value* _arg1, llvm::Value* _arg2);
llvm::Value* sdiv(llvm::Value* _arg1, llvm::Value* _arg2); llvm::Value* sdiv(llvm::Value* _arg1, llvm::Value* _arg2);
llvm::Value* smod(llvm::Value* _arg1, llvm::Value* _arg2); llvm::Value* smod(llvm::Value* _arg1, llvm::Value* _arg2);
llvm::Value* mulmod(llvm::Value* _arg1, llvm::Value* _arg2, llvm::Value* _arg3);
llvm::Value* addmod(llvm::Value* _arg1, llvm::Value* _arg2, llvm::Value* _arg3);
private: private:
llvm::Value* binaryOp(llvm::Function* _op, llvm::Value* _arg1, llvm::Value* _arg2); llvm::Value* binaryOp(llvm::Function* _op, llvm::Value* _arg1, llvm::Value* _arg2);
llvm::Value* ternaryOp(llvm::Function* _op, llvm::Value* _arg1, llvm::Value* _arg2, llvm::Value* _arg3);
llvm::Function* m_mul; llvm::Function* m_mul;
llvm::Function* m_div; llvm::Function* m_div;
llvm::Function* m_mod; llvm::Function* m_mod;
llvm::Function* m_sdiv; llvm::Function* m_sdiv;
llvm::Function* m_smod; llvm::Function* m_smod;
llvm::Function* m_mulmod;
llvm::Function* m_addmod;
llvm::Value* m_arg1; llvm::Value* m_arg1;
llvm::Value* m_arg2; llvm::Value* m_arg2;
llvm::Value* m_arg3;
llvm::Value* m_result; llvm::Value* m_result;
}; };

33
libevmjit/Compiler.cpp

@ -91,9 +91,12 @@ void Compiler::createBasicBlocks(bytesConstRef bytecode)
case Instruction::JUMPDEST: case Instruction::JUMPDEST:
{ {
// A basic block starts here. // A basic block starts at the next instruction.
splitPoints.insert(currentPC); if (currentPC + 1 < bytecode.size())
indirectJumpTargets.push_back(currentPC); {
splitPoints.insert(currentPC + 1);
indirectJumpTargets.push_back(currentPC + 1);
}
break; break;
} }
@ -153,8 +156,8 @@ void Compiler::createBasicBlocks(bytesConstRef bytecode)
} }
else else
{ {
std::cerr << "Bad JUMP at PC " << it->first clog(JIT) << "Bad JUMP at PC " << it->first
<< ": " << it->second << " is not a valid PC\n"; << ": " << it->second << " is not a valid PC";
m_directJumpTargets[it->first] = m_badJumpBlock->llvm(); m_directJumpTargets[it->first] = m_badJumpBlock->llvm();
} }
} }
@ -239,8 +242,8 @@ std::unique_ptr<llvm::Module> Compiler::compile(bytesConstRef bytecode)
dump(); dump();
} }
if (getenv("EVMCC_OPTIMIZE_STACK")) //if (getenv("EVMCC_OPTIMIZE_STACK"))
{ //{
std::vector<BasicBlock*> blockList; std::vector<BasicBlock*> blockList;
for (auto& entry : basicBlocks) for (auto& entry : basicBlocks)
blockList.push_back(&entry.second); blockList.push_back(&entry.second);
@ -258,7 +261,7 @@ std::unique_ptr<llvm::Module> Compiler::compile(bytesConstRef bytecode)
std::cerr << "\n\nAfter stack optimization \n\n"; std::cerr << "\n\nAfter stack optimization \n\n";
dump(); dump();
} }
} //}
for (auto& entry : basicBlocks) for (auto& entry : basicBlocks)
entry.second.localStack().synchronize(stack); entry.second.localStack().synchronize(stack);
@ -486,9 +489,8 @@ void Compiler::compileBasicBlock(BasicBlock& basicBlock, bytesConstRef bytecode,
{ {
auto lhs = stack.pop(); auto lhs = stack.pop();
auto rhs = stack.pop(); auto rhs = stack.pop();
auto sum = m_builder.CreateAdd(lhs, rhs);
auto mod = stack.pop(); auto mod = stack.pop();
auto res = arith.mod(sum, mod); auto res = arith.addmod(lhs, rhs, mod);
stack.push(res); stack.push(res);
break; break;
} }
@ -497,9 +499,8 @@ void Compiler::compileBasicBlock(BasicBlock& basicBlock, bytesConstRef bytecode,
{ {
auto lhs = stack.pop(); auto lhs = stack.pop();
auto rhs = stack.pop(); auto rhs = stack.pop();
auto prod = m_builder.CreateMul(lhs, rhs);
auto mod = stack.pop(); auto mod = stack.pop();
auto res = arith.mod(prod, mod); auto res = arith.mulmod(lhs, rhs, mod);
stack.push(res); stack.push(res);
break; break;
} }
@ -654,8 +655,7 @@ void Compiler::compileBasicBlock(BasicBlock& basicBlock, bytesConstRef bytecode,
case Instruction::JUMPDEST: case Instruction::JUMPDEST:
{ {
// Extra asserts just in case. // Nothing to do
assert(currentPC == basicBlock.begin());
break; break;
} }
@ -816,6 +816,11 @@ void Compiler::compileBasicBlock(BasicBlock& basicBlock, bytesConstRef bytecode,
break; break;
} }
default: // Invalid instruction - runtime exception
{
_runtimeManager.raiseException(ReturnCode::BadInstruction);
}
} }
} }

7
libevmjit/CompilerHelper.h

@ -31,6 +31,13 @@ protected:
llvm::IRBuilder<>& m_builder; llvm::IRBuilder<>& m_builder;
llvm::IRBuilder<>& getBuilder() { return m_builder; } llvm::IRBuilder<>& getBuilder() { return m_builder; }
template<typename ..._Args>
llvm::CallInst* createCall(llvm::Function* _func, _Args*... _args)
{
llvm::Value* args[] = {_args...};
return getBuilder().CreateCall(_func, args);
}
friend class RuntimeHelper; friend class RuntimeHelper;
}; };

23
libevmjit/ExecutionEngine.cpp

@ -75,9 +75,8 @@ int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, u256& _gas, ExtV
auto finalizationStartTime = std::chrono::high_resolution_clock::now(); auto finalizationStartTime = std::chrono::high_resolution_clock::now();
exec->finalizeObject(); exec->finalizeObject();
auto finalizationEndTime = std::chrono::high_resolution_clock::now(); auto finalizationEndTime = std::chrono::high_resolution_clock::now();
std::cerr << "*** Module finalization time: " clog(JIT) << "Module finalization time: "
<< std::chrono::duration_cast<std::chrono::microseconds>(finalizationEndTime - finalizationStartTime).count() << std::chrono::duration_cast<std::chrono::microseconds>(finalizationEndTime - finalizationStartTime).count();
<< std::endl;
// Create fake ExtVM interface // Create fake ExtVM interface
if (!_ext) if (!_ext)
@ -117,9 +116,8 @@ int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, u256& _gas, ExtV
returnCode = static_cast<ReturnCode>(result.IntVal.getZExtValue()); returnCode = static_cast<ReturnCode>(result.IntVal.getZExtValue());
auto executionEndTime = std::chrono::high_resolution_clock::now(); auto executionEndTime = std::chrono::high_resolution_clock::now();
std::cerr << "*** Execution time: " clog(JIT) << "Execution time : "
<< std::chrono::duration_cast<std::chrono::microseconds>(executionEndTime - executionStartTime).count() << std::chrono::duration_cast<std::chrono::microseconds>(executionEndTime - executionStartTime).count();
<< std::endl;
} }
else else
@ -128,19 +126,20 @@ int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, u256& _gas, ExtV
// Return remaining gas // Return remaining gas
_gas = returnCode == ReturnCode::OutOfGas ? 0 : runtime.getGas(); _gas = returnCode == ReturnCode::OutOfGas ? 0 : runtime.getGas();
std::cout << "Max stack size: " << Stack::maxStackSize << std::endl; clog(JIT) << "Max stack size: " << Stack::maxStackSize;
if (returnCode == ReturnCode::Return) if (returnCode == ReturnCode::Return)
{ {
returnData = runtime.getReturnData().toVector(); // TODO: It might be better to place is in Runtime interface returnData = runtime.getReturnData().toVector(); // TODO: It might be better to place is in Runtime interface
std::cout << "RETURN [ "; auto&& log = clog(JIT);
log << "RETURN [ ";
for (auto it = returnData.begin(), end = returnData.end(); it != end; ++it) for (auto it = returnData.begin(), end = returnData.end(); it != end; ++it)
std::cout << std::hex << std::setw(2) << std::setfill('0') << (int)*it << " "; log << std::hex << std::setw(2) << std::setfill('0') << (int)*it << " ";
std::cout << "]\n"; log << "]";
} }
else
std::cout << "RETURN CODE: " << (int)returnCode << std::endl; cslog(JIT) << "RETURN " << (int)returnCode;
return static_cast<int>(returnCode); return static_cast<int>(returnCode);
} }

21
libevmjit/Ext.cpp

@ -109,8 +109,7 @@ llvm::Value* Ext::create(llvm::Value* _endowment, llvm::Value* _initOff, llvm::V
m_builder.CreateStore(_endowment, m_args[0]); m_builder.CreateStore(_endowment, m_args[0]);
m_builder.CreateStore(_initOff, m_arg2); m_builder.CreateStore(_initOff, m_arg2);
m_builder.CreateStore(_initSize, m_arg3); m_builder.CreateStore(_initSize, m_arg3);
llvm::Value* args[] = {getRuntimeManager().getRuntimePtr(), m_args[0], m_arg2, m_arg3, m_args[1]}; createCall(m_create, getRuntimeManager().getRuntimePtr(), m_args[0], m_arg2, m_arg3, m_args[1]);
m_builder.CreateCall(m_create, args);
llvm::Value* address = m_builder.CreateLoad(m_args[1]); llvm::Value* address = m_builder.CreateLoad(m_args[1]);
address = Endianness::toNative(m_builder, address); address = Endianness::toNative(m_builder, address);
return address; return address;
@ -128,9 +127,7 @@ llvm::Value* Ext::call(llvm::Value*& _gas, llvm::Value* _receiveAddress, llvm::V
m_builder.CreateStore(_outSize, m_arg7); m_builder.CreateStore(_outSize, m_arg7);
auto codeAddress = Endianness::toBE(m_builder, _codeAddress); auto codeAddress = Endianness::toBE(m_builder, _codeAddress);
m_builder.CreateStore(codeAddress, m_arg8); m_builder.CreateStore(codeAddress, m_arg8);
createCall(m_call, getRuntimeManager().getRuntimePtr(), m_args[0], m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8, m_args[1]);
llvm::Value* args[] = {getRuntimeManager().getRuntimePtr(), m_args[0], m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8, m_args[1]};
m_builder.CreateCall(m_call, args);
_gas = m_builder.CreateLoad(m_args[0]); // Return gas _gas = m_builder.CreateLoad(m_args[0]); // Return gas
return m_builder.CreateLoad(m_args[1]); return m_builder.CreateLoad(m_args[1]);
} }
@ -139,8 +136,7 @@ llvm::Value* Ext::sha3(llvm::Value* _inOff, llvm::Value* _inSize)
{ {
m_builder.CreateStore(_inOff, m_args[0]); m_builder.CreateStore(_inOff, m_args[0]);
m_builder.CreateStore(_inSize, m_arg2); m_builder.CreateStore(_inSize, m_arg2);
llvm::Value* args[] = {getRuntimeManager().getRuntimePtr(), m_args[0], m_arg2, m_args[1]}; createCall(m_sha3, getRuntimeManager().getRuntimePtr(), m_args[0], m_arg2, m_args[1]);
m_builder.CreateCall(m_sha3, args);
llvm::Value* hash = m_builder.CreateLoad(m_args[1]); llvm::Value* hash = m_builder.CreateLoad(m_args[1]);
hash = Endianness::toNative(m_builder, hash); hash = Endianness::toNative(m_builder, hash);
return hash; return hash;
@ -148,10 +144,10 @@ llvm::Value* Ext::sha3(llvm::Value* _inOff, llvm::Value* _inSize)
llvm::Value* Ext::exp(llvm::Value* _left, llvm::Value* _right) llvm::Value* Ext::exp(llvm::Value* _left, llvm::Value* _right)
{ {
// TODO: Move ext to Arith256
m_builder.CreateStore(_left, m_args[0]); m_builder.CreateStore(_left, m_args[0]);
m_builder.CreateStore(_right, m_arg2); m_builder.CreateStore(_right, m_arg2);
llvm::Value* args[] = {getRuntimeManager().getRuntimePtr(), m_args[0], m_arg2, m_args[1]}; createCall(m_exp, getRuntimeManager().getRuntimePtr(), m_args[0], m_arg2, m_args[1]);
m_builder.CreateCall(m_exp, args);
return m_builder.CreateLoad(m_args[1]); return m_builder.CreateLoad(m_args[1]);
} }
@ -166,8 +162,7 @@ llvm::Value* Ext::codesizeAt(llvm::Value* _addr)
{ {
auto addr = Endianness::toBE(m_builder, _addr); auto addr = Endianness::toBE(m_builder, _addr);
m_builder.CreateStore(addr, m_args[0]); m_builder.CreateStore(addr, m_args[0]);
llvm::Value* args[] = {getRuntimeManager().getRuntimePtr(), m_args[0], m_args[1]}; createCall(m_codesizeAt, getRuntimeManager().getRuntimePtr(), m_args[0], m_args[1]);
m_builder.CreateCall(m_codesizeAt, args);
return m_builder.CreateLoad(m_args[1]); return m_builder.CreateLoad(m_args[1]);
} }
@ -279,7 +274,7 @@ EXPORT void ext_exp(Runtime* _rt, i256* _left, i256* _right, i256* _ret)
*_ret = eth2llvm(ret); *_ret = eth2llvm(ret);
} }
EXPORT unsigned char* ext_codeAt(Runtime* _rt, h256* _addr256) //FIXME: Check endianess EXPORT unsigned char* ext_codeAt(Runtime* _rt, h256* _addr256)
{ {
auto&& ext = _rt->getExt(); auto&& ext = _rt->getExt();
auto addr = right160(*_addr256); auto addr = right160(*_addr256);
@ -287,7 +282,7 @@ EXPORT unsigned char* ext_codeAt(Runtime* _rt, h256* _addr256) //FIXME: Check en
return const_cast<unsigned char*>(code.data()); return const_cast<unsigned char*>(code.data());
} }
EXPORT void ext_codesizeAt(Runtime* _rt, h256* _addr256, i256* _ret) //FIXME: Check endianess EXPORT void ext_codesizeAt(Runtime* _rt, h256* _addr256, i256* _ret)
{ {
auto&& ext = _rt->getExt(); auto&& ext = _rt->getExt();
auto addr = right160(*_addr256); auto addr = right160(*_addr256);

8
libevmjit/GasMeter.cpp

@ -101,11 +101,7 @@ GasMeter::GasMeter(llvm::IRBuilder<>& _builder, RuntimeManager& _runtimeManager)
m_builder.CreateCondBr(isOutOfGas, outOfGasBB, updateBB); m_builder.CreateCondBr(isOutOfGas, outOfGasBB, updateBB);
m_builder.SetInsertPoint(outOfGasBB); m_builder.SetInsertPoint(outOfGasBB);
_runtimeManager.raiseException(ReturnCode::OutOfGas);
//auto longjmpFunc = llvm::Intrinsic::getDeclaration(_module, llvm::Intrinsic::eh_sjlj_longjmp);
llvm::Type* args[] = {Type::BytePtr, m_builder.getInt32Ty()};
auto longjmpNative = llvm::Function::Create(llvm::FunctionType::get(Type::Void, args, false), llvm::Function::ExternalLinkage, "longjmp", module);
m_builder.CreateCall2(longjmpNative, m_runtimeManager.getJmpBuf(), Constant::get(ReturnCode::OutOfGas));
m_builder.CreateUnreachable(); m_builder.CreateUnreachable();
m_builder.SetInsertPoint(updateBB); m_builder.SetInsertPoint(updateBB);
@ -147,7 +143,7 @@ void GasMeter::countSStore(Ext& _ext, llvm::Value* _index, llvm::Value* _newValu
auto isDel = m_builder.CreateAnd(oldValueIsntZero, newValueIsZero, "isDel"); auto isDel = m_builder.CreateAnd(oldValueIsntZero, newValueIsZero, "isDel");
auto cost = m_builder.CreateSelect(isAdd, Constant::get(2 * sstoreCost), Constant::get(sstoreCost), "cost"); auto cost = m_builder.CreateSelect(isAdd, Constant::get(2 * sstoreCost), Constant::get(sstoreCost), "cost");
cost = m_builder.CreateSelect(isDel, Constant::get(0), cost, "cost"); cost = m_builder.CreateSelect(isDel, Constant::get(0), cost, "cost");
m_builder.CreateCall(m_gasCheckFunc, cost); createCall(m_gasCheckFunc, cost);
} }
void GasMeter::giveBack(llvm::Value* _gas) void GasMeter::giveBack(llvm::Value* _gas)

2
libevmjit/GasMeter.h

@ -13,7 +13,7 @@ namespace jit
{ {
class RuntimeManager; class RuntimeManager;
class GasMeter : public CompilerHelper class GasMeter : public CompilerHelper // TODO: Use RuntimeHelper
{ {
public: public:
GasMeter(llvm::IRBuilder<>& _builder, RuntimeManager& _runtimeManager); GasMeter(llvm::IRBuilder<>& _builder, RuntimeManager& _runtimeManager);

16
libevmjit/Runtime.cpp

@ -57,13 +57,9 @@ llvm::Twine getName(RuntimeData::Index _index)
} }
} }
static Runtime* g_runtime; // FIXME: Remove
Runtime::Runtime(u256 _gas, ExtVMFace& _ext, jmp_buf _jmpBuf): Runtime::Runtime(u256 _gas, ExtVMFace& _ext, jmp_buf _jmpBuf):
m_ext(_ext) m_ext(_ext)
{ {
assert(!g_runtime);
g_runtime = this;
set(RuntimeData::Gas, _gas); set(RuntimeData::Gas, _gas);
set(RuntimeData::Address, fromAddress(_ext.myAddress)); set(RuntimeData::Address, fromAddress(_ext.myAddress));
set(RuntimeData::Caller, fromAddress(_ext.caller)); set(RuntimeData::Caller, fromAddress(_ext.caller));
@ -83,11 +79,6 @@ Runtime::Runtime(u256 _gas, ExtVMFace& _ext, jmp_buf _jmpBuf):
m_data.jmpBuf = _jmpBuf; m_data.jmpBuf = _jmpBuf;
} }
Runtime::~Runtime()
{
g_runtime = nullptr;
}
void Runtime::set(RuntimeData::Index _index, u256 _value) void Runtime::set(RuntimeData::Index _index, u256 _value)
{ {
m_data.elems[_index] = eth2llvm(_value); m_data.elems[_index] = eth2llvm(_value);
@ -113,6 +104,8 @@ bytesConstRef Runtime::getReturnData() const
RuntimeManager::RuntimeManager(llvm::IRBuilder<>& _builder): CompilerHelper(_builder) RuntimeManager::RuntimeManager(llvm::IRBuilder<>& _builder): CompilerHelper(_builder)
{ {
m_dataPtr = new llvm::GlobalVariable(*getModule(), Type::RuntimePtr, false, llvm::GlobalVariable::PrivateLinkage, llvm::UndefValue::get(Type::RuntimePtr), "rt"); m_dataPtr = new llvm::GlobalVariable(*getModule(), Type::RuntimePtr, false, llvm::GlobalVariable::PrivateLinkage, llvm::UndefValue::get(Type::RuntimePtr), "rt");
llvm::Type* args[] = {Type::BytePtr, m_builder.getInt32Ty()};
m_longjmp = llvm::Function::Create(llvm::FunctionType::get(Type::Void, args, false), llvm::Function::ExternalLinkage, "longjmp", getModule());
// Export data // Export data
auto mainFunc = getMainFunction(); auto mainFunc = getMainFunction();
@ -149,6 +142,11 @@ void RuntimeManager::registerReturnData(llvm::Value* _offset, llvm::Value* _size
set(RuntimeData::ReturnDataSize, _size); set(RuntimeData::ReturnDataSize, _size);
} }
void RuntimeManager::raiseException(ReturnCode _returnCode)
{
m_builder.CreateCall2(m_longjmp, getJmpBuf(), Constant::get(_returnCode));
}
llvm::Value* RuntimeManager::get(Instruction _inst) llvm::Value* RuntimeManager::get(Instruction _inst)
{ {
switch (_inst) switch (_inst)

11
libevmjit/Runtime.h

@ -1,12 +1,15 @@
#pragma once #pragma once
#include <setjmp.h>
#include <vector> #include <vector>
#include <libevm/ExtVMFace.h> #include <libevm/ExtVMFace.h>
#include "CompilerHelper.h" #include "CompilerHelper.h"
#include "Utils.h" #include "Utils.h"
#include "Type.h"
#ifdef _MSC_VER #ifdef _MSC_VER
@ -62,7 +65,6 @@ class Runtime
{ {
public: public:
Runtime(u256 _gas, ExtVMFace& _ext, jmp_buf _jmpBuf); Runtime(u256 _gas, ExtVMFace& _ext, jmp_buf _jmpBuf);
~Runtime();
Runtime(const Runtime&) = delete; Runtime(const Runtime&) = delete;
void operator=(const Runtime&) = delete; void operator=(const Runtime&) = delete;
@ -99,16 +101,19 @@ public:
llvm::Value* getGas(); // TODO: Remove llvm::Value* getGas(); // TODO: Remove
llvm::Value* getCallData(); llvm::Value* getCallData();
llvm::Value* getCode(); llvm::Value* getCode();
llvm::Value* getJmpBuf();
void setGas(llvm::Value* _gas); void setGas(llvm::Value* _gas);
void registerReturnData(llvm::Value* _index, llvm::Value* _size); void registerReturnData(llvm::Value* _index, llvm::Value* _size);
void raiseException(ReturnCode _returnCode);
private: private:
llvm::Value* getPtr(RuntimeData::Index _index); llvm::Value* getPtr(RuntimeData::Index _index);
void set(RuntimeData::Index _index, llvm::Value* _value); void set(RuntimeData::Index _index, llvm::Value* _value);
llvm::Value* getJmpBuf();
llvm::GlobalVariable* m_dataPtr; llvm::GlobalVariable* m_dataPtr = nullptr;
llvm::Function* m_longjmp = nullptr;
}; };
} }

3
libevmjit/Type.h

@ -43,7 +43,8 @@ enum class ReturnCode
BadJumpDestination = 101, BadJumpDestination = 101,
OutOfGas = 102, OutOfGas = 102,
StackTooSmall = 103 StackTooSmall = 103,
BadInstruction = 104,
}; };
struct Constant struct Constant

3
libevmjit/Utils.h

@ -4,6 +4,7 @@
#include <llvm/IR/IRBuilder.h> #include <llvm/IR/IRBuilder.h>
#include <libdevcore/Common.h> #include <libdevcore/Common.h>
#include <libdevcore/Log.h>
namespace dev namespace dev
{ {
@ -12,6 +13,8 @@ namespace eth
namespace jit namespace jit
{ {
struct JIT: public NoteChannel { static const char* name() { return "JIT"; } };
/// Representation of 256-bit value binary compatible with LLVM i256 /// Representation of 256-bit value binary compatible with LLVM i256
// TODO: Replace with h256 // TODO: Replace with h256
struct i256 struct i256

11
libevmjit/VM.cpp

@ -5,6 +5,7 @@
#include "ExecutionEngine.h" #include "ExecutionEngine.h"
#include "Compiler.h" #include "Compiler.h"
#include "Type.h"
namespace dev namespace dev
{ {
@ -20,14 +21,16 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const&, uint64_t)
ExecutionEngine engine; ExecutionEngine engine;
auto exitCode = engine.run(std::move(module), m_gas, &_ext); auto exitCode = engine.run(std::move(module), m_gas, &_ext);
switch (exitCode) switch (static_cast<ReturnCode>(exitCode))
{ {
case 101: case ReturnCode::BadJumpDestination:
BOOST_THROW_EXCEPTION(BadJumpDestination()); BOOST_THROW_EXCEPTION(BadJumpDestination());
case 102: case ReturnCode::OutOfGas:
BOOST_THROW_EXCEPTION(OutOfGas()); BOOST_THROW_EXCEPTION(OutOfGas());
case 103: case ReturnCode::StackTooSmall:
BOOST_THROW_EXCEPTION(StackTooSmall(1,0)); BOOST_THROW_EXCEPTION(StackTooSmall(1,0));
case ReturnCode::BadInstruction:
BOOST_THROW_EXCEPTION(BadInstruction());
} }
m_output = std::move(engine.returnData); m_output = std::move(engine.returnData);

46
test/vm.cpp

@ -20,9 +20,9 @@
* vm test functions. * vm test functions.
*/ */
#include <chrono>
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
#include "vm.h" #include "vm.h"
//#define FILL_TESTS //#define FILL_TESTS
using namespace std; using namespace std;
@ -359,9 +359,9 @@ void FakeExtVM::importExec(mObject& _o)
code = &thisTxCode; code = &thisTxCode;
if (_o["code"].type() == str_type) if (_o["code"].type() == str_type)
if (_o["code"].get_str().find_first_of("0x") == 0) if (_o["code"].get_str().find_first_of("0x") == 0)
thisTxCode = compileLLL(_o["code"].get_str());
else
thisTxCode = fromHex(_o["code"].get_str().substr(2)); thisTxCode = fromHex(_o["code"].get_str().substr(2));
else
thisTxCode = compileLLL(_o["code"].get_str());
else if (_o["code"].type() == array_type) else if (_o["code"].type() == array_type)
for (auto const& j: _o["code"].get_array()) for (auto const& j: _o["code"].get_array())
thisTxCode.push_back(toByte(j)); thisTxCode.push_back(toByte(j));
@ -441,8 +441,8 @@ h160 FakeState::createNewAddress(Address _newAddress, Address _sender, u256 _end
m_cache[_newAddress] = AddressState(0, balance(_newAddress) + _endowment, h256(), h256()); m_cache[_newAddress] = AddressState(0, balance(_newAddress) + _endowment, h256(), h256());
// Execute init code. // Execute init code.
auto vmObj = VMFace::create(VMFace::Interpreter, *_gas); auto vmObj = VMFace::create(getVMKind(), *_gas);
VMFace& vm = *vmObj; auto& vm = *vmObj;
ExtVM evm(*this, _newAddress, _sender, _origin, _endowment, _gasPrice, bytesConstRef(), _code, o_ms, _level); ExtVM evm(*this, _newAddress, _sender, _origin, _endowment, _gasPrice, bytesConstRef(), _code, o_ms, _level);
bool revert = false; bool revert = false;
bytesConstRef out; bytesConstRef out;
@ -500,7 +500,14 @@ void doTests(json_spirit::mValue& v, bool _fillin)
BOOST_REQUIRE(o.count("pre") > 0); BOOST_REQUIRE(o.count("pre") > 0);
BOOST_REQUIRE(o.count("exec") > 0); BOOST_REQUIRE(o.count("exec") > 0);
auto argc = boost::unit_test::framework::master_test_suite().argc;
auto argv = boost::unit_test::framework::master_test_suite().argv;
auto useJit = argc >= 2 && std::string(argv[1]) == "--jit";
auto vmKind = useJit ? VMFace::JIT : VMFace::Interpreter;
dev::test::FakeExtVM fev; dev::test::FakeExtVM fev;
fev.setVMKind(vmKind);
fev.importEnv(o["env"].get_obj()); fev.importEnv(o["env"].get_obj());
fev.importState(o["pre"].get_obj()); fev.importState(o["pre"].get_obj());
@ -514,15 +521,11 @@ void doTests(json_spirit::mValue& v, bool _fillin)
fev.code = &fev.thisTxCode; fev.code = &fev.thisTxCode;
} }
auto vm = VMFace::create(fev.getVMKind(), fev.gas);
auto argc = boost::unit_test::framework::master_test_suite().argc;
auto argv = boost::unit_test::framework::master_test_suite().argv;
auto useJit = argc >= 2 && std::string(argv[1]) == "--jit";
auto vmKind = useJit ? VMFace::JIT : VMFace::Interpreter;
auto vm = VMFace::create(vmKind, fev.gas);
bytes output; bytes output;
auto outOfGas = false; auto outOfGas = false;
auto startTime = std::chrono::high_resolution_clock::now();
try try
{ {
output = vm->go(fev, fev.simpleTrace<FakeExtVM>()).toVector(); output = vm->go(fev, fev.simpleTrace<FakeExtVM>()).toVector();
@ -539,6 +542,20 @@ void doTests(json_spirit::mValue& v, bool _fillin)
{ {
cnote << "VM did throw an exception: " << _e.what(); cnote << "VM did throw an exception: " << _e.what();
} }
auto endTime = std::chrono::high_resolution_clock::now();
for (auto i = 0; i < argc; ++i)
{
if (std::string(argv[i]) == "--show-times")
{
auto testDuration = endTime - startTime;
cnote << "Execution time: "
<< std::chrono::duration_cast<std::chrono::milliseconds>(testDuration).count()
<< " ms";
}
break;
}
auto gas = vm->gas(); auto gas = vm->gas();
// delete null entries in storage for the sake of comparison // delete null entries in storage for the sake of comparison
@ -763,6 +780,11 @@ BOOST_AUTO_TEST_CASE(vmPushDupSwapTest)
dev::test::executeTests("vmPushDupSwapTest"); dev::test::executeTests("vmPushDupSwapTest");
} }
BOOST_AUTO_TEST_CASE(vmPerformanceTest)
{
dev::test::executeTests("vmPerformanceTest");
}
BOOST_AUTO_TEST_CASE(vmSystemOperationsTest) BOOST_AUTO_TEST_CASE(vmSystemOperationsTest)
{ {
dev::test::executeTests("vmSystemOperationsTest"); dev::test::executeTests("vmSystemOperationsTest");

2
test/vm.h

@ -80,6 +80,8 @@ public:
void importExec(json_spirit::mObject& _o); void importExec(json_spirit::mObject& _o);
json_spirit::mArray exportCallCreates(); json_spirit::mArray exportCallCreates();
void importCallCreates(json_spirit::mArray& _callcreates); void importCallCreates(json_spirit::mArray& _callcreates);
void setVMKind(eth::VMFace::Kind _kind) { m_s.setVMKind(_kind); }
eth::VMFace::Kind getVMKind() const { return m_s.getVMKind(); }
template<typename ExtVMType> template<typename ExtVMType>
eth::OnOpFunc simpleTrace(); eth::OnOpFunc simpleTrace();

1
windows/LibEthereum.vcxproj.filters

@ -195,6 +195,7 @@
</ClCompile> </ClCompile>
<ClCompile Include="..\libevm\VMFace.cpp"> <ClCompile Include="..\libevm\VMFace.cpp">
<Filter>libevm</Filter> <Filter>libevm</Filter>
</ClCompile>
<ClCompile Include="..\libdevcrypto\CryptoPP.cpp"> <ClCompile Include="..\libdevcrypto\CryptoPP.cpp">
<Filter>libdevcrypto</Filter> <Filter>libdevcrypto</Filter>
</ClCompile> </ClCompile>

2
windows/evmcc.vcxproj

@ -171,7 +171,6 @@
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>../../llvm-3.5.0/include;../../builds/llvm3.5/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4068;4244;4267;4800</DisableSpecificWarnings> <DisableSpecificWarnings>4068;4244;4267;4800</DisableSpecificWarnings>
<EnablePREfast>false</EnablePREfast> <EnablePREfast>false</EnablePREfast>
</ClCompile> </ClCompile>
@ -180,7 +179,6 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>LibEthereum.lib;LibEvmJit.lib;LLVMX86Disassembler.lib;LLVMX86AsmParser.lib;LLVMX86CodeGen.lib;LLVMSelectionDAG.lib;LLVMAsmPrinter.lib;LLVMCodeGen.lib;LLVMScalarOpts.lib;LLVMInstCombine.lib;LLVMTransformUtils.lib;LLVMipa.lib;LLVMAnalysis.lib;LLVMX86Desc.lib;LLVMX86Info.lib;LLVMX86AsmPrinter.lib;LLVMX86Utils.lib;LLVMMCJIT.lib;LLVMTarget.lib;LLVMRuntimeDyld.lib;LLVMObject.lib;LLVMMCParser.lib;LLVMBitReader.lib;LLVMExecutionEngine.lib;LLVMMC.lib;LLVMCore.lib;LLVMSupport.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

Loading…
Cancel
Save