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;
|
||||
}
|
||||
|
||||
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*);
|
||||
|
||||
auto entryFuncVoidPtr = _exec.engine->getPointerToFunction(_exec.entryFunc);
|
||||
auto entryFuncPtr = static_cast<EntryFuncPtr>(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<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)
|
||||
{
|
||||
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;
|
||||
|
||||
this->returnData = runtime.getReturnData();
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue