Browse Source

Implement VMFace with jit::VM

cl-refactor
Paweł Bylica 10 years ago
parent
commit
dfb283097c
  1. 7
      libevmjit/VM.cpp
  2. 14
      libevmjit/VM.h
  3. 2
      test/vm.cpp

7
libevmjit/VM.cpp

@ -1,7 +1,7 @@
#include "VM.h"
#include <libevm/VM.h>
#include <libevm/VMFace.h>
#include "ExecutionEngine.h"
#include "Compiler.h"
@ -13,7 +13,7 @@ namespace eth
namespace jit
{
bytes VM::go(ExtVMFace& _ext)
bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps)
{
auto module = Compiler().compile(_ext.code);
@ -30,7 +30,8 @@ bytes VM::go(ExtVMFace& _ext)
BOOST_THROW_EXCEPTION(StackTooSmall(1,0));
}
return std::move(engine.returnData);
m_output = std::move(engine.returnData);
return {m_output.data(), m_output.size()}; // TODO: This all bytesConstRef stuff sucks
}
}

14
libevmjit/VM.h

@ -2,6 +2,7 @@
#pragma once
#include <libdevcore/Common.h>
#include <libevm/VMFace.h>
#include <libevm/ExtVMFace.h>
namespace dev
@ -11,20 +12,15 @@ namespace eth
namespace jit
{
class VM
class VM: public VMFace
{
public:
/// Construct VM object.
explicit VM(u256 _gas = 0): m_gas(_gas) {}
explicit VM(u256 _gas = 0): VMFace(_gas) {}
void reset(u256 _gas = 0) { m_gas = _gas; }
bytes go(ExtVMFace& _ext);
u256 gas() const { return m_gas; }
virtual bytesConstRef go(ExtVMFace& _ext, OnOpFunc const& _onOp = {}, uint64_t _steps = (uint64_t)-1) final;
private:
u256 m_gas = 0;
bytes m_output;
};
}

2
test/vm.cpp

@ -524,7 +524,7 @@ void doTests(json_spirit::mValue& v, bool _fillin)
try
{
if (useJit)
output = jit.go(fev);
output = jit.go(fev).toVector();
else
output = interpreter.go(fev).toVector();
}

Loading…
Cancel
Save