mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
Change the way entry function is called.
This commit is contained in:
parent
4a9d08d1b0
commit
2e1c90f828
1 changed files with 17 additions and 27 deletions
|
|
@ -107,41 +107,31 @@ ReturnCode ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, RuntimeDa
|
||||||
return returnCode;
|
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<llvm::GenericValue> args{{}, llvm::GenericValue(&runtime)};
|
|
||||||
llvm::GenericValue result;
|
|
||||||
|
|
||||||
typedef ReturnCode(*EntryFuncPtr)(int, Runtime*);
|
typedef ReturnCode(*EntryFuncPtr)(int, Runtime*);
|
||||||
|
|
||||||
auto entryFuncVoidPtr = _exec.engine->getPointerToFunction(_exec.entryFunc);
|
auto entryFuncVoidPtr = _exec.engine->getPointerToFunction(_exec.entryFunc);
|
||||||
auto entryFuncPtr = static_cast<EntryFuncPtr>(entryFuncVoidPtr);
|
auto entryFuncPtr = static_cast<EntryFuncPtr>(entryFuncVoidPtr);
|
||||||
|
|
||||||
auto r = setjmp(runtime.getJmpBuf());
|
ReturnCode returnCode{};
|
||||||
if (r == 0)
|
auto sj = setjmp(_runtime->getJmpBuf());
|
||||||
{
|
if (sj == 0)
|
||||||
returnCode = entryFuncPtr(0, &runtime);
|
returnCode = entryFuncPtr(0, _runtime); // FIXME: Remove int argument
|
||||||
}
|
|
||||||
else
|
else
|
||||||
returnCode = static_cast<ReturnCode>(r);
|
returnCode = static_cast<ReturnCode>(sj);
|
||||||
|
|
||||||
|
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)
|
if (returnCode == ReturnCode::Return)
|
||||||
{
|
this->returnData = runtime.getReturnData();
|
||||||
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;
|
return returnCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue