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; static StatsCollector statsCollector;
auto mainFuncName = codeHash(_data->codeHash); 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); auto entryFuncPtr = (EntryFuncPtr)ee->getFunctionAddress(mainFuncName);
if (!entryFuncPtr) if (!entryFuncPtr)

5
libevmjit/ExecutionEngine.h

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

15
libevmjit/Runtime.cpp

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

9
libevmjit/Runtime.h

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

Loading…
Cancel
Save