mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
Fix cache key and do not compile to LLVM module when it is not needed
This commit is contained in:
parent
da02a1869d
commit
70348d9586
3 changed files with 12 additions and 8 deletions
|
|
@ -19,7 +19,10 @@ public:
|
||||||
llvm::Function* entryFunc = nullptr;
|
llvm::Function* entryFunc = nullptr;
|
||||||
|
|
||||||
ExecBundle() = default;
|
ExecBundle() = default;
|
||||||
ExecBundle(ExecBundle&&) = default;
|
ExecBundle(ExecBundle&& _other):
|
||||||
|
engine(std::move(_other.engine)),
|
||||||
|
entryFunc(_other.entryFunc) {}
|
||||||
|
|
||||||
ExecBundle(ExecBundle const&) = delete;
|
ExecBundle(ExecBundle const&) = delete;
|
||||||
void operator=(ExecBundle) = delete;
|
void operator=(ExecBundle) = delete;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -35,18 +35,18 @@ namespace jit
|
||||||
|
|
||||||
ReturnCode ExecutionEngine::run(bytes const& _code, RuntimeData* _data, Env* _env)
|
ReturnCode ExecutionEngine::run(bytes const& _code, RuntimeData* _data, Env* _env)
|
||||||
{
|
{
|
||||||
|
std::string key{reinterpret_cast<char const*>(_code.data()), _code.size()};
|
||||||
|
if (auto cachedExec = Cache::findExec(key))
|
||||||
|
{
|
||||||
|
return run(*cachedExec, _data, _env);
|
||||||
|
}
|
||||||
|
|
||||||
auto module = Compiler({}).compile(_code);
|
auto module = Compiler({}).compile(_code);
|
||||||
return run(std::move(module), _data, _env, _code);
|
return run(std::move(module), _data, _env, _code);
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
std::string key{reinterpret_cast<char const*>(_code.data()), _code.size()};
|
|
||||||
if (auto cachedExec = Cache::findExec(std::move(key)))
|
|
||||||
{
|
|
||||||
return run(*cachedExec, _data, _env);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto module = _module.get(); // Keep ownership of the module in _module
|
auto module = _module.get(); // Keep ownership of the module in _module
|
||||||
|
|
||||||
llvm::sys::PrintStackTraceOnErrorSignal();
|
llvm::sys::PrintStackTraceOnErrorSignal();
|
||||||
|
|
@ -94,6 +94,7 @@ ReturnCode ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, RuntimeDa
|
||||||
if (!exec.entryFunc)
|
if (!exec.entryFunc)
|
||||||
return ReturnCode::LLVMLinkError;
|
return ReturnCode::LLVMLinkError;
|
||||||
|
|
||||||
|
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));
|
||||||
auto returnCode = run(cachedExec, _data, _env);
|
auto returnCode = run(cachedExec, _data, _env);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ namespace jit
|
||||||
struct JIT: public NoteChannel { static const char* name() { return "JIT"; } };
|
struct JIT: public NoteChannel { static const char* name() { return "JIT"; } };
|
||||||
|
|
||||||
//#define clog(CHANNEL) std::cerr
|
//#define clog(CHANNEL) std::cerr
|
||||||
#define clog(CHANNEL) std::ostream({})
|
#define clog(CHANNEL) std::ostream(nullptr)
|
||||||
|
|
||||||
u256 llvm2eth(i256);
|
u256 llvm2eth(i256);
|
||||||
i256 eth2llvm(u256);
|
i256 eth2llvm(u256);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue