diff --git a/libevmjit/Cache.h b/libevmjit/Cache.h index 62875edac9..9fd695bfe5 100644 --- a/libevmjit/Cache.h +++ b/libevmjit/Cache.h @@ -19,7 +19,10 @@ public: llvm::Function* entryFunc = nullptr; ExecBundle() = default; - ExecBundle(ExecBundle&&) = default; + ExecBundle(ExecBundle&& _other): + engine(std::move(_other.engine)), + entryFunc(_other.entryFunc) {} + ExecBundle(ExecBundle const&) = delete; void operator=(ExecBundle) = delete; }; diff --git a/libevmjit/ExecutionEngine.cpp b/libevmjit/ExecutionEngine.cpp index 9368998282..3fbc1e413b 100644 --- a/libevmjit/ExecutionEngine.cpp +++ b/libevmjit/ExecutionEngine.cpp @@ -35,18 +35,18 @@ namespace jit ReturnCode ExecutionEngine::run(bytes const& _code, RuntimeData* _data, Env* _env) { + std::string key{reinterpret_cast(_code.data()), _code.size()}; + if (auto cachedExec = Cache::findExec(key)) + { + return run(*cachedExec, _data, _env); + } + auto module = Compiler({}).compile(_code); return run(std::move(module), _data, _env, _code); } ReturnCode ExecutionEngine::run(std::unique_ptr _module, RuntimeData* _data, Env* _env, bytes const& _code) { - std::string key{reinterpret_cast(_code.data()), _code.size()}; - if (auto cachedExec = Cache::findExec(std::move(key))) - { - return run(*cachedExec, _data, _env); - } - auto module = _module.get(); // Keep ownership of the module in _module llvm::sys::PrintStackTraceOnErrorSignal(); @@ -94,6 +94,7 @@ ReturnCode ExecutionEngine::run(std::unique_ptr _module, RuntimeDa if (!exec.entryFunc) return ReturnCode::LLVMLinkError; + std::string key{reinterpret_cast(_code.data()), _code.size()}; auto& cachedExec = Cache::registerExec(key, std::move(exec)); auto returnCode = run(cachedExec, _data, _env); diff --git a/libevmjit/Utils.h b/libevmjit/Utils.h index dd07e72cd1..f672365c6b 100644 --- a/libevmjit/Utils.h +++ b/libevmjit/Utils.h @@ -12,7 +12,7 @@ namespace jit struct JIT: public NoteChannel { static const char* name() { return "JIT"; } }; //#define clog(CHANNEL) std::cerr -#define clog(CHANNEL) std::ostream({}) +#define clog(CHANNEL) std::ostream(nullptr) u256 llvm2eth(i256); i256 eth2llvm(u256);