Browse Source

Change Runtime interface

cl-refactor
Paweł Bylica 10 years ago
parent
commit
c4b9aca7ee
  1. 3
      libevmjit/ExecutionEngine.cpp
  2. 5
      libevmjit/ExecutionEngine.h
  3. 15
      libevmjit/Runtime.cpp
  4. 9
      libevmjit/Runtime.h

3
libevmjit/ExecutionEngine.cpp

@ -117,7 +117,8 @@ ReturnCode ExecutionEngine::run(RuntimeData* _data, Env* _env)
static StatsCollector statsCollector;
auto mainFuncName = codeHash(_data->codeHash);
Runtime runtime(_data, _env); // TODO: I don't know why but it must be created before getFunctionAddress() calls
Runtime runtime;
runtime.init(_data, _env);
auto entryFuncPtr = (EntryFuncPtr)ee->getFunctionAddress(mainFuncName);
if (!entryFuncPtr)

5
libevmjit/ExecutionEngine.h

@ -2,7 +2,7 @@
#include <memory>
#include "RuntimeData.h"
#include "Runtime.h"
namespace dev
{
@ -49,6 +49,9 @@ public:
/// Reference to returned data (RETURN opcode used)
bytes_ref returnData;
private:
Runtime m_runtime;
};
}

15
libevmjit/Runtime.cpp

@ -9,20 +9,21 @@ namespace eth
namespace jit
{
Runtime::Runtime(RuntimeData* _data, Env* _env) :
m_data(*_data),
m_env(*_env)
{}
void Runtime::init(RuntimeData* _data, Env* _env)
{
m_data = _data;
m_env = _env;
}
bytes_ref Runtime::getReturnData() const
{
auto data = m_data.callData;
auto size = static_cast<size_t>(m_data.callDataSize);
auto data = m_data->callData;
auto size = static_cast<size_t>(m_data->callDataSize);
if (data < m_memData || data >= m_memData + m_memSize || size == 0)
{
assert(size == 0); // data can be an invalid pointer only if size is 0
m_data.callData = nullptr;
m_data->callData = nullptr;
return {};
}

9
libevmjit/Runtime.h

@ -13,16 +13,13 @@ using MemoryImpl = bytes;
class Runtime
{
public:
Runtime(RuntimeData* _data, Env* _env);
Runtime(const Runtime&) = delete;
Runtime& operator=(const Runtime&) = delete;
void init(RuntimeData* _data, Env* _env);
bytes_ref getReturnData() const;
private:
RuntimeData& m_data; ///< Pointer to data. Expected by compiled contract.
Env& m_env; ///< Pointer to environment proxy. Expected by compiled contract.
RuntimeData* m_data = nullptr; ///< Pointer to data. Expected by compiled contract.
Env* m_env = nullptr; ///< Pointer to environment proxy. Expected by compiled contract.
byte* m_memoryData = nullptr;
i256 m_memorySize;
public:

Loading…
Cancel
Save