diff --git a/libevmjit/ExecutionEngine.cpp b/libevmjit/ExecutionEngine.cpp index c9578b4ee..e1c0780d9 100644 --- a/libevmjit/ExecutionEngine.cpp +++ b/libevmjit/ExecutionEngine.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "preprocessor/llvm_includes_start.h" #include @@ -119,7 +120,12 @@ ReturnCode ExecutionEngine::run(RuntimeData* _data, Env* _env) auto mainFuncName = codeHash(_data->codeHash); m_runtime.init(_data, _env); - auto entryFuncPtr = (EntryFuncPtr)ee->getFunctionAddress(mainFuncName); + EntryFuncPtr entryFuncPtr = nullptr; + static std::unordered_map funcCache; + auto it = funcCache.find(mainFuncName); + if (it != funcCache.end()) + entryFuncPtr = it->second; + if (!entryFuncPtr) { auto module = objectCache ? Cache::getObject(mainFuncName) : nullptr; @@ -146,6 +152,8 @@ ReturnCode ExecutionEngine::run(RuntimeData* _data, Env* _env) if (!CHECK(entryFuncPtr)) return ReturnCode::LLVMLinkError; + funcCache[mainFuncName] = entryFuncPtr; + listener->stateChanged(ExecState::Execution); auto returnCode = entryFuncPtr(&m_runtime); listener->stateChanged(ExecState::Return);