You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
708 B
46 lines
708 B
#include "evmjit/JIT.h"
|
|
|
|
#include <unordered_map>
|
|
|
|
namespace dev
|
|
{
|
|
namespace evmjit
|
|
{
|
|
namespace
|
|
{
|
|
|
|
class JITImpl: JIT
|
|
{
|
|
public:
|
|
std::unordered_map<h256, void*> codeMap;
|
|
|
|
static JITImpl& instance()
|
|
{
|
|
static JITImpl s_instance;
|
|
return s_instance;
|
|
}
|
|
};
|
|
|
|
} // anonymous namespace
|
|
|
|
bool JIT::isCodeReady(h256 _codeHash)
|
|
{
|
|
return JITImpl::instance().codeMap.count(_codeHash) != 0;
|
|
}
|
|
|
|
void* JIT::getCode(h256 _codeHash)
|
|
{
|
|
auto& codeMap = JITImpl::instance().codeMap;
|
|
auto it = codeMap.find(_codeHash);
|
|
if (it != codeMap.end())
|
|
return it->second;
|
|
return nullptr;
|
|
}
|
|
|
|
void JIT::mapCode(h256 _codeHash, void* _funcAddr)
|
|
{
|
|
JITImpl::instance().codeMap.insert(std::make_pair(_codeHash, _funcAddr));
|
|
}
|
|
|
|
}
|
|
}
|
|
|