mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
Clean up ExecutionEngine
This commit is contained in:
parent
fe90c6f107
commit
ece7fe7782
1 changed files with 9 additions and 13 deletions
|
|
@ -48,26 +48,24 @@ ReturnCode ExecutionEngine::run(bytes const& _code, RuntimeData* _data, Env* _en
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
ReturnCode runEntryFunc(ExecBundle const& _exec, Runtime* _runtime)
|
|
||||||
|
typedef ReturnCode(*EntryFuncPtr)(Runtime*);
|
||||||
|
|
||||||
|
ReturnCode runEntryFunc(EntryFuncPtr _mainFunc, Runtime* _runtime)
|
||||||
{
|
{
|
||||||
// That function uses long jumps to handle "execeptions".
|
// That function uses long jumps to handle "execeptions".
|
||||||
// Do not create any non-POD objects here
|
// Do not create any non-POD objects here
|
||||||
|
|
||||||
typedef ReturnCode(*EntryFuncPtr)(Runtime*);
|
|
||||||
auto entryFuncPtr = (EntryFuncPtr)_exec.engine->getFunctionAddress(_exec.mainFuncName);
|
|
||||||
|
|
||||||
//std::cerr << _exec.mainFuncName << " F: " << entryFuncPtr << "\n";
|
|
||||||
ReturnCode returnCode{};
|
ReturnCode returnCode{};
|
||||||
//std::cerr << _exec.mainFuncName << " +S: " << &returnCode << "\n";
|
|
||||||
auto sj = setjmp(_runtime->getJmpBuf());
|
auto sj = setjmp(_runtime->getJmpBuf());
|
||||||
if (sj == 0)
|
if (sj == 0)
|
||||||
returnCode = entryFuncPtr(_runtime);
|
returnCode = _mainFunc(_runtime);
|
||||||
else
|
else
|
||||||
returnCode = static_cast<ReturnCode>(sj);
|
returnCode = static_cast<ReturnCode>(sj);
|
||||||
|
|
||||||
//std::cerr << _exec.mainFuncName << " -S: " << &returnCode << "\n";
|
|
||||||
return returnCode;
|
return returnCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnCode ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, RuntimeData* _data, Env* _env, bytes const& _code)
|
ReturnCode ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, RuntimeData* _data, Env* _env, bytes const& _code)
|
||||||
|
|
@ -83,8 +81,7 @@ ReturnCode ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, RuntimeDa
|
||||||
EntryFuncPtr entryFuncPtr{};
|
EntryFuncPtr entryFuncPtr{};
|
||||||
|
|
||||||
|
|
||||||
ExecBundle exec;
|
auto&& mainFuncName = _module->getModuleIdentifier();
|
||||||
exec.mainFuncName = _module->getModuleIdentifier();
|
|
||||||
|
|
||||||
if (!ee)
|
if (!ee)
|
||||||
{
|
{
|
||||||
|
|
@ -133,8 +130,6 @@ ReturnCode ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, RuntimeDa
|
||||||
//if (!exec.engine)
|
//if (!exec.engine)
|
||||||
// return ReturnCode::LLVMConfigError;
|
// return ReturnCode::LLVMConfigError;
|
||||||
|
|
||||||
exec.engine = ee.get();
|
|
||||||
|
|
||||||
// TODO: Finalization not needed when llvm::ExecutionEngine::getFunctionAddress used
|
// TODO: Finalization not needed when llvm::ExecutionEngine::getFunctionAddress used
|
||||||
//auto finalizationStartTime = std::chrono::high_resolution_clock::now();
|
//auto finalizationStartTime = std::chrono::high_resolution_clock::now();
|
||||||
//exec.engine->finalizeObject();
|
//exec.engine->finalizeObject();
|
||||||
|
|
@ -146,7 +141,8 @@ ReturnCode ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, RuntimeDa
|
||||||
std::string key{reinterpret_cast<char const*>(_code.data()), _code.size()};
|
std::string key{reinterpret_cast<char const*>(_code.data()), _code.size()};
|
||||||
//auto& cachedExec = Cache::registerExec(key, std::move(exec));
|
//auto& cachedExec = Cache::registerExec(key, std::move(exec));
|
||||||
Runtime runtime(_data, _env);
|
Runtime runtime(_data, _env);
|
||||||
auto returnCode = runEntryFunc(exec, &runtime);
|
auto mainFunc = (EntryFuncPtr)ee->getFunctionAddress(mainFuncName);
|
||||||
|
auto returnCode = runEntryFunc(mainFunc, &runtime);
|
||||||
if (returnCode == ReturnCode::Return)
|
if (returnCode == ReturnCode::Return)
|
||||||
this->returnData = runtime.getReturnData();
|
this->returnData = runtime.getReturnData();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue