[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
//===- ObjectLinkingLayer.h - Add object files to a JIT process -*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Contains the definition for the object layer of the JIT.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_EXECUTIONENGINE_ORC_OBJECTLINKINGLAYER_H
|
|
|
|
#define LLVM_EXECUTIONENGINE_ORC_OBJECTLINKINGLAYER_H
|
|
|
|
|
2015-02-09 01:20:51 +00:00
|
|
|
#include "JITSymbol.h"
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
#include "LookasideRTDyldMM.h"
|
|
|
|
#include "llvm/ExecutionEngine/ExecutionEngine.h"
|
|
|
|
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
|
|
|
|
#include <list>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
namespace llvm {
|
2015-02-21 20:44:36 +00:00
|
|
|
namespace orc {
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
|
|
|
|
class ObjectLinkingLayerBase {
|
|
|
|
protected:
|
2015-02-09 01:20:51 +00:00
|
|
|
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
/// @brief Holds a set of objects to be allocated/linked as a unit in the JIT.
|
|
|
|
///
|
|
|
|
/// An instance of this class will be created for each set of objects added
|
|
|
|
/// via JITObjectLayer::addObjectSet. Deleting the instance (via
|
|
|
|
/// removeObjectSet) frees its memory, removing all symbol definitions that
|
|
|
|
/// had been provided by this instance. Higher level layers are responsible
|
|
|
|
/// for taking any action required to handle the missing symbols.
|
|
|
|
class LinkedObjectSet {
|
2015-02-15 22:54:22 +00:00
|
|
|
LinkedObjectSet(const LinkedObjectSet&) = delete;
|
|
|
|
void operator=(const LinkedObjectSet&) = delete;
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
public:
|
|
|
|
LinkedObjectSet(std::unique_ptr<RTDyldMemoryManager> MM)
|
|
|
|
: MM(std::move(MM)), RTDyld(llvm::make_unique<RuntimeDyld>(&*this->MM)),
|
|
|
|
State(Raw) {}
|
|
|
|
|
2015-01-23 22:25:47 +00:00
|
|
|
// MSVC 2012 cannot infer a move constructor, so write it out longhand.
|
|
|
|
LinkedObjectSet(LinkedObjectSet &&O)
|
|
|
|
: MM(std::move(O.MM)), RTDyld(std::move(O.RTDyld)), State(O.State) {}
|
|
|
|
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
std::unique_ptr<RuntimeDyld::LoadedObjectInfo>
|
|
|
|
addObject(const object::ObjectFile &Obj) {
|
|
|
|
return RTDyld->loadObject(Obj);
|
|
|
|
}
|
|
|
|
|
2015-03-10 00:33:27 +00:00
|
|
|
TargetAddress getSymbolAddress(StringRef Name, bool ExportedSymbolsOnly) {
|
|
|
|
if (ExportedSymbolsOnly)
|
|
|
|
return RTDyld->getExportedSymbolLoadAddress(Name);
|
|
|
|
return RTDyld->getSymbolLoadAddress(Name);
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool NeedsFinalization() const { return (State == Raw); }
|
|
|
|
|
|
|
|
void Finalize() {
|
|
|
|
State = Finalizing;
|
|
|
|
RTDyld->resolveRelocations();
|
|
|
|
RTDyld->registerEHFrames();
|
|
|
|
MM->finalizeMemory();
|
2015-02-02 04:32:17 +00:00
|
|
|
OwnedBuffers.clear();
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
State = Finalized;
|
|
|
|
}
|
|
|
|
|
2015-02-09 01:20:51 +00:00
|
|
|
void mapSectionAddress(const void *LocalAddress, TargetAddress TargetAddr) {
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
assert((State != Finalized) &&
|
|
|
|
"Attempting to remap sections for finalized objects.");
|
2015-02-09 01:20:51 +00:00
|
|
|
RTDyld->mapSectionAddress(LocalAddress, TargetAddr);
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
}
|
|
|
|
|
2015-02-02 04:32:17 +00:00
|
|
|
void takeOwnershipOfBuffer(std::unique_ptr<MemoryBuffer> B) {
|
|
|
|
OwnedBuffers.push_back(std::move(B));
|
|
|
|
}
|
|
|
|
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
private:
|
|
|
|
std::unique_ptr<RTDyldMemoryManager> MM;
|
|
|
|
std::unique_ptr<RuntimeDyld> RTDyld;
|
|
|
|
enum { Raw, Finalizing, Finalized } State;
|
2015-02-02 04:32:17 +00:00
|
|
|
|
|
|
|
// FIXME: This ownership hack only exists because RuntimeDyldELF still
|
|
|
|
// wants to be able to inspect the original object when resolving
|
|
|
|
// relocations. As soon as that can be fixed this should be removed.
|
|
|
|
std::vector<std::unique_ptr<MemoryBuffer>> OwnedBuffers;
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::list<LinkedObjectSet> LinkedObjectSetListT;
|
|
|
|
|
|
|
|
public:
|
|
|
|
/// @brief Handle to a set of loaded objects.
|
2015-01-23 22:25:47 +00:00
|
|
|
typedef LinkedObjectSetListT::iterator ObjSetHandleT;
|
2015-02-02 04:32:17 +00:00
|
|
|
|
|
|
|
// Ownership hack.
|
|
|
|
// FIXME: Remove this as soon as RuntimeDyldELF can apply relocations without
|
|
|
|
// referencing the original object.
|
|
|
|
template <typename OwningMBSet>
|
|
|
|
void takeOwnershipOfBuffers(ObjSetHandleT H, OwningMBSet MBs) {
|
|
|
|
for (auto &MB : MBs)
|
|
|
|
H->takeOwnershipOfBuffer(std::move(MB));
|
|
|
|
}
|
|
|
|
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// @brief Default (no-op) action to perform when loading objects.
|
|
|
|
class DoNothingOnNotifyLoaded {
|
|
|
|
public:
|
|
|
|
template <typename ObjSetT, typename LoadResult>
|
|
|
|
void operator()(ObjectLinkingLayerBase::ObjSetHandleT, const ObjSetT &,
|
|
|
|
const LoadResult &) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// @brief Bare bones object linking layer.
|
|
|
|
///
|
|
|
|
/// This class is intended to be used as the base layer for a JIT. It allows
|
|
|
|
/// object files to be loaded into memory, linked, and the addresses of their
|
|
|
|
/// symbols queried. All objects added to this layer can see each other's
|
|
|
|
/// symbols.
|
|
|
|
template <typename NotifyLoadedFtor = DoNothingOnNotifyLoaded>
|
|
|
|
class ObjectLinkingLayer : public ObjectLinkingLayerBase {
|
|
|
|
public:
|
2015-01-23 22:11:07 +00:00
|
|
|
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
/// @brief LoadedObjectInfo list. Contains a list of owning pointers to
|
|
|
|
/// RuntimeDyld::LoadedObjectInfo instances.
|
|
|
|
typedef std::vector<std::unique_ptr<RuntimeDyld::LoadedObjectInfo>>
|
|
|
|
LoadedObjInfoList;
|
|
|
|
|
2015-01-23 22:11:07 +00:00
|
|
|
/// @brief Functor to create RTDyldMemoryManager instances.
|
|
|
|
typedef std::function<std::unique_ptr<RTDyldMemoryManager>()> CreateRTDyldMMFtor;
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
|
2015-01-23 22:11:07 +00:00
|
|
|
/// @brief Functor for receiving finalization notifications.
|
|
|
|
typedef std::function<void(ObjSetHandleT)> NotifyFinalizedFtor;
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
|
|
|
|
/// @brief Construct an ObjectLinkingLayer with the given NotifyLoaded,
|
|
|
|
/// NotifyFinalized and CreateMemoryManager functors.
|
|
|
|
ObjectLinkingLayer(
|
2015-02-02 01:03:10 +00:00
|
|
|
CreateRTDyldMMFtor CreateMemoryManager = CreateRTDyldMMFtor(),
|
|
|
|
NotifyLoadedFtor NotifyLoaded = NotifyLoadedFtor(),
|
|
|
|
NotifyFinalizedFtor NotifyFinalized = NotifyFinalizedFtor())
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
: NotifyLoaded(std::move(NotifyLoaded)),
|
|
|
|
NotifyFinalized(std::move(NotifyFinalized)),
|
|
|
|
CreateMemoryManager(std::move(CreateMemoryManager)) {}
|
|
|
|
|
|
|
|
/// @brief Add a set of objects (or archives) that will be treated as a unit
|
|
|
|
/// for the purposes of symbol lookup and memory management.
|
|
|
|
///
|
|
|
|
/// @return A pair containing (1) A handle that can be used to free the memory
|
|
|
|
/// allocated for the objects, and (2) a LoadedObjInfoList containing
|
|
|
|
/// one LoadedObjInfo instance for each object at the corresponding
|
|
|
|
/// index in the Objects list.
|
|
|
|
///
|
|
|
|
/// This version of this method allows the client to pass in an
|
|
|
|
/// RTDyldMemoryManager instance that will be used to allocate memory and look
|
|
|
|
/// up external symbol addresses for the given objects.
|
|
|
|
template <typename ObjSetT>
|
|
|
|
ObjSetHandleT addObjectSet(const ObjSetT &Objects,
|
|
|
|
std::unique_ptr<RTDyldMemoryManager> MM) {
|
|
|
|
|
|
|
|
if (!MM) {
|
|
|
|
assert(CreateMemoryManager &&
|
|
|
|
"No memory manager or memory manager creator provided.");
|
|
|
|
MM = CreateMemoryManager();
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjSetHandleT Handle = LinkedObjSetList.insert(
|
|
|
|
LinkedObjSetList.end(), LinkedObjectSet(std::move(MM)));
|
|
|
|
LinkedObjectSet &LOS = *Handle;
|
|
|
|
LoadedObjInfoList LoadedObjInfos;
|
|
|
|
|
|
|
|
for (auto &Obj : Objects)
|
|
|
|
LoadedObjInfos.push_back(LOS.addObject(*Obj));
|
|
|
|
|
|
|
|
NotifyLoaded(Handle, Objects, LoadedObjInfos);
|
|
|
|
|
|
|
|
return Handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// @brief Remove the set of objects associated with handle H.
|
|
|
|
///
|
|
|
|
/// All memory allocated for the objects will be freed, and the sections and
|
|
|
|
/// symbols they provided will no longer be available. No attempt is made to
|
|
|
|
/// re-emit the missing symbols, and any use of these symbols (directly or
|
|
|
|
/// indirectly) will result in undefined behavior. If dependence tracking is
|
|
|
|
/// required to detect or resolve such issues it should be added at a higher
|
|
|
|
/// layer.
|
|
|
|
void removeObjectSet(ObjSetHandleT H) {
|
|
|
|
// How do we invalidate the symbols in H?
|
|
|
|
LinkedObjSetList.erase(H);
|
|
|
|
}
|
|
|
|
|
2015-02-09 01:20:51 +00:00
|
|
|
/// @brief Search for the given named symbol.
|
|
|
|
/// @param Name The name of the symbol to search for.
|
|
|
|
/// @param ExportedSymbolsOnly If true, search only for exported symbols.
|
|
|
|
/// @return A handle for the given named symbol, if it exists.
|
|
|
|
JITSymbol findSymbol(StringRef Name, bool ExportedSymbolsOnly) {
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
for (auto I = LinkedObjSetList.begin(), E = LinkedObjSetList.end(); I != E;
|
|
|
|
++I)
|
2015-02-09 01:20:51 +00:00
|
|
|
if (auto Symbol = findSymbolIn(I, Name, ExportedSymbolsOnly))
|
|
|
|
return Symbol;
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
|
2015-02-09 01:20:51 +00:00
|
|
|
return nullptr;
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
}
|
|
|
|
|
2015-02-09 01:20:51 +00:00
|
|
|
/// @brief Search for the given named symbol in the context of the set of
|
|
|
|
/// loaded objects represented by the handle H.
|
|
|
|
/// @param H The handle for the object set to search in.
|
|
|
|
/// @param Name The name of the symbol to search for.
|
|
|
|
/// @param ExportedSymbolsOnly If true, search only for exported symbols.
|
|
|
|
/// @return A handle for the given named symbol, if it is found in the
|
|
|
|
/// given object set.
|
|
|
|
JITSymbol findSymbolIn(ObjSetHandleT H, StringRef Name,
|
|
|
|
bool ExportedSymbolsOnly) {
|
2015-03-10 00:33:27 +00:00
|
|
|
if (auto Addr = H->getSymbolAddress(Name, ExportedSymbolsOnly)) {
|
|
|
|
if (!H->NeedsFinalization()) {
|
|
|
|
// If this instance has already been finalized then we can just return
|
|
|
|
// the address.
|
|
|
|
return JITSymbol(Addr);
|
|
|
|
} else {
|
|
|
|
// If this instance needs finalization return a functor that will do it.
|
|
|
|
// The functor still needs to double-check whether finalization is
|
|
|
|
// required, in case someone else finalizes this set before the functor
|
|
|
|
// is called.
|
|
|
|
return JITSymbol(
|
|
|
|
[this, Addr, H]() {
|
|
|
|
if (H->NeedsFinalization()) {
|
|
|
|
H->Finalize();
|
|
|
|
if (NotifyFinalized)
|
|
|
|
NotifyFinalized(H);
|
|
|
|
}
|
|
|
|
return Addr;
|
|
|
|
});
|
2015-02-20 06:48:29 +00:00
|
|
|
}
|
|
|
|
}
|
2015-03-10 00:33:27 +00:00
|
|
|
|
2015-02-09 01:20:51 +00:00
|
|
|
return nullptr;
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
}
|
|
|
|
|
2015-02-16 22:36:25 +00:00
|
|
|
/// @brief Map section addresses for the objects associated with the handle H.
|
|
|
|
void mapSectionAddress(ObjSetHandleT H, const void *LocalAddress,
|
|
|
|
TargetAddress TargetAddr) {
|
|
|
|
H->mapSectionAddress(LocalAddress, TargetAddr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// @brief Immediately emit and finalize the object set represented by the
|
|
|
|
/// given handle.
|
|
|
|
/// @param H Handle for object set to emit/finalize.
|
|
|
|
void emitAndFinalize(ObjSetHandleT H) {
|
|
|
|
H->Finalize();
|
|
|
|
if (NotifyFinalized)
|
|
|
|
NotifyFinalized(H);
|
|
|
|
}
|
|
|
|
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
private:
|
|
|
|
LinkedObjectSetListT LinkedObjSetList;
|
|
|
|
NotifyLoadedFtor NotifyLoaded;
|
2015-01-23 22:11:07 +00:00
|
|
|
NotifyFinalizedFtor NotifyFinalized;
|
|
|
|
CreateRTDyldMMFtor CreateMemoryManager;
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
};
|
|
|
|
|
2015-02-21 20:44:36 +00:00
|
|
|
} // End namespace orc.
|
|
|
|
} // End namespace llvm
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
|
|
|
|
|
|
|
#endif // LLVM_EXECUTIONENGINE_ORC_OBJECTLINKINGLAYER_H
|