diff --git a/libevmjit/ExecutionEngine.cpp b/libevmjit/ExecutionEngine.cpp index 0b2365f01..e773b1a9f 100644 --- a/libevmjit/ExecutionEngine.cpp +++ b/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) diff --git a/libevmjit/ExecutionEngine.h b/libevmjit/ExecutionEngine.h index 99cc77cce..26da6977c 100644 --- a/libevmjit/ExecutionEngine.h +++ b/libevmjit/ExecutionEngine.h @@ -2,7 +2,7 @@ #include -#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; }; } diff --git a/libevmjit/Runtime.cpp b/libevmjit/Runtime.cpp index e7953a417..78454ef4f 100644 --- a/libevmjit/Runtime.cpp +++ b/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(m_data.callDataSize); + auto data = m_data->callData; + auto size = static_cast(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 {}; } diff --git a/libevmjit/Runtime.h b/libevmjit/Runtime.h index 4fc1705c4..91f26beaa 100644 --- a/libevmjit/Runtime.h +++ b/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: