|
|
@ -1,7 +1,9 @@ |
|
|
|
#pragma once |
|
|
|
|
|
|
|
#include <memory> |
|
|
|
#include <unordered_map> |
|
|
|
#include <llvm/ExecutionEngine/ExecutionEngine.h> |
|
|
|
#include <llvm/ExecutionEngine/ObjectCache.h> |
|
|
|
|
|
|
|
|
|
|
|
namespace dev |
|
|
@ -26,6 +28,24 @@ public: |
|
|
|
void operator=(ExecBundle) = delete; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class ObjectCache : public llvm::ObjectCache |
|
|
|
{ |
|
|
|
public: |
|
|
|
/// notifyObjectCompiled - Provides a pointer to compiled code for Module M.
|
|
|
|
virtual void notifyObjectCompiled(llvm::Module const* _module, llvm::MemoryBuffer const* _object) final override; |
|
|
|
|
|
|
|
/// getObjectCopy - Returns a pointer to a newly allocated MemoryBuffer that
|
|
|
|
/// contains the object which corresponds with Module M, or 0 if an object is
|
|
|
|
/// not available. The caller owns both the MemoryBuffer returned by this
|
|
|
|
/// and the memory it references.
|
|
|
|
virtual llvm::MemoryBuffer* getObject(llvm::Module const* _module) final override; |
|
|
|
|
|
|
|
private: |
|
|
|
std::unordered_map<std::string, llvm::MemoryBuffer*> m_map; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class Cache |
|
|
|
{ |
|
|
|
public: |
|
|
@ -33,6 +53,8 @@ public: |
|
|
|
|
|
|
|
static ExecBundle& registerExec(Key _key, ExecBundle&& _exec); |
|
|
|
static ExecBundle* findExec(Key _key); |
|
|
|
|
|
|
|
static ObjectCache* getObjectCache(); |
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|