Finish ep17 and address trivial TODOs in the context
This commit is contained in:
parent
6eaba7dbe8
commit
644cf11c89
|
@ -806,7 +806,8 @@ A thread safe container for the LLVM module.
|
|||
- [[https://www.youtube.com/watch?v=i-inxFudrgI][ORCv2 -- LLVM JIT APIs Deep Dive]]
|
||||
- [[https://www.youtube.com/watch?v=MOQG5vkh9J8][Updating ORC JIT for Concurrency]]
|
||||
- [[https://www.youtube.com/watch?v=hILdR8XRvdQ][ORC -- LLVM's Next Generation of JIT API]]
|
||||
* Eposide 16 - ORC Layers
|
||||
* DONE Eposide 16 - ORC Layers
|
||||
CLOSED: [2022-02-26 Sat 12:50]
|
||||
** Updates:
|
||||
*** Support for adding AST directly to the JIT
|
||||
*** Minor change to SLIR (big changes are coming)
|
||||
|
@ -923,3 +924,31 @@ A thread safe container for the LLVM module.
|
|||
|
||||
#+RESULTS: ep-16-jit-3
|
||||
[[file:/tmp/ep16-3.svg]]
|
||||
|
||||
* Episode 17 - Custom ORC Layers
|
||||
** Updates:
|
||||
- Finished the basic compiler wiring
|
||||
- Restructured the source tree
|
||||
- Tweaked the build system mostly for install targets
|
||||
- Refactoring, cleaning up the code and writing tests
|
||||
** Quick overview an ORC based JIT engine
|
||||
- JIT engines are made out of layers
|
||||
- Engines have a hierarchy of layers
|
||||
- Layers don't know about each other
|
||||
- Layers wrap the program representation in a =MaterializationUnit=, which is
|
||||
then stored in the =JITDylib=.
|
||||
- =MaterializationUnits= are responsible for describing the definitions they provide,
|
||||
and for unwrapping the program representation and passing it back to the layer when
|
||||
compilation is required.
|
||||
- When a =MaterializationUnit= hands a program representation back to the layer it comes
|
||||
with an associated =MaterializationResponsibility= object. This object tracks the
|
||||
definitions that must be materialized and provides a way to notify the =JITDylib= once
|
||||
they are either successfully materialized or a failure occurs.
|
||||
|
||||
** In order to build a custom layer we need:
|
||||
*** A custom materialization unit
|
||||
Let's have a look at the =MaterializationUnit= class.
|
||||
|
||||
*** And the layer class itself
|
||||
The layer classes are not special but conventionally the come with few functions
|
||||
like: =add=, =emit= and =getInterface=.
|
||||
|
|
|
@ -249,20 +249,19 @@ public:
|
|||
private:
|
||||
CompilationPhase targetPhase;
|
||||
|
||||
// TODO: Change it to a LLVM::StringMap
|
||||
// TODO: We need to keep different instances of the namespace
|
||||
// because if any one of them gets cleaned up via reference
|
||||
// count (if we are still using shared ptr for namespaces if not
|
||||
// remove this todo) then we will end up with dangling references
|
||||
// it the JIT
|
||||
|
||||
// The namespace table. Every namespace that needs to be compiled has
|
||||
// to register itself with the context and appear on this table.
|
||||
// This table acts as a cache as well.
|
||||
/// The namespace table. Every namespace that needs to be compiled has
|
||||
/// to register itself with the context and appear on this table.
|
||||
/// This table acts as a cache as well.
|
||||
std::map<std::string, NSPtr> namespaces;
|
||||
|
||||
// Why string vs pointer? We might rewrite the namespace and
|
||||
// holding a pointer means that it might point to the old version
|
||||
/// Why string vs pointer? We might rewrite the namespace and
|
||||
/// holding a pointer means that it might point to the old version
|
||||
std::string currentNS;
|
||||
|
||||
/// A vector of pointers to all the jitDylibs for namespaces. Usually
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
* Commentary:
|
||||
* Rules of a namespace:
|
||||
* - A namespace has have a name and it has to own it.
|
||||
* - A namespace may or may not be assiciated with a file
|
||||
* - A namespace may or may not be associated with a file
|
||||
* - The internal AST of a namespace is an evergrowing tree which may expand at
|
||||
* any given time. For example via iteration of a REPL
|
||||
* - `environments` vector is the owner of all the semantic envs
|
||||
|
|
|
@ -137,6 +137,7 @@ MaybeNS SereneContext::importNamespace(const std::string &name,
|
|||
}
|
||||
|
||||
llvm::orc::JITDylib *SereneContext::getLatestJITDylib(Namespace &ns) {
|
||||
|
||||
if (jitDylibs.count(ns.name) == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -207,6 +207,10 @@ NSPtr Namespace::make(SereneContext &ctx, llvm::StringRef name,
|
|||
return std::make_shared<Namespace>(ctx, name, filename);
|
||||
};
|
||||
|
||||
Namespace::~Namespace(){};
|
||||
Namespace::~Namespace() {
|
||||
// TODO: Clean up anything related to this namespace in the context
|
||||
// TODO: Remove anything related to this namespace in the JIT
|
||||
NAMESPACE_LOG("Destructing NS: " << name);
|
||||
};
|
||||
|
||||
} // namespace serene
|
||||
|
|
Loading…
Reference in New Issue