diff --git a/libevmjit/ExecutionEngine.cpp b/libevmjit/ExecutionEngine.cpp index b56d6bf15..742aea90a 100644 --- a/libevmjit/ExecutionEngine.cpp +++ b/libevmjit/ExecutionEngine.cpp @@ -107,41 +107,31 @@ ReturnCode ExecutionEngine::run(std::unique_ptr _module, RuntimeDa return returnCode; } -ReturnCode ExecutionEngine::run(ExecBundle const& _exec, RuntimeData* _data, Env* _env) +namespace +{ +ReturnCode runEntryFunc(ExecBundle const& _exec, Runtime* _runtime) { - ReturnCode returnCode; - Runtime runtime(_data, _env); - - - std::vector args{{}, llvm::GenericValue(&runtime)}; - llvm::GenericValue result; - typedef ReturnCode(*EntryFuncPtr)(int, Runtime*); - auto entryFuncVoidPtr = _exec.engine->getPointerToFunction(_exec.entryFunc); auto entryFuncPtr = static_cast(entryFuncVoidPtr); - auto r = setjmp(runtime.getJmpBuf()); - if (r == 0) - { - returnCode = entryFuncPtr(0, &runtime); - } + ReturnCode returnCode{}; + auto sj = setjmp(_runtime->getJmpBuf()); + if (sj == 0) + returnCode = entryFuncPtr(0, _runtime); // FIXME: Remove int argument else - returnCode = static_cast(r); + returnCode = static_cast(sj); - if (returnCode == ReturnCode::Return) - { - returnData = runtime.getReturnData(); - - auto&& log = clog(JIT); - log << "RETURN [ "; - for (auto it = returnData.begin(), end = returnData.end(); it != end; ++it) - log << std::hex << std::setw(2) << std::setfill('0') << (int)*it << " "; - log << "]"; - } - else - clog(JIT) << "RETURN " << (int)returnCode; + return returnCode; +} +} +ReturnCode ExecutionEngine::run(ExecBundle const& _exec, RuntimeData* _data, Env* _env) +{ + Runtime runtime(_data, _env); + auto returnCode = runEntryFunc(_exec, &runtime); + if (returnCode == ReturnCode::Return) + this->returnData = runtime.getReturnData(); return returnCode; }