12 #include <hilti/rt/filesystem.h> 13 #include <hilti/rt/library.h> 15 #include <hilti/base/util.h> 16 #include <hilti/compiler/context.h> 17 #include <hilti/compiler/detail/cxx/unit.h> 25 namespace logging::debug {
26 inline const DebugStream Jit(
"jit");
29 namespace detail::jit {
41 CxxCode(
const hilti::rt::filesystem::path& path) { load(path); }
49 CxxCode(
const std::string&
id, std::istream& code) { load(
id, code); }
64 bool save(
const hilti::rt::filesystem::path& p)
const;
72 bool save(std::ostream& out)
const;
75 auto code()
const {
return _code; }
78 auto isLoaded()
const {
return _code.has_value(); }
85 const std::string&
id()
const {
return _id; }
88 std::size_t
hash()
const {
return _hash; }
97 bool load(
const hilti::rt::filesystem::path& path);
106 bool load(
const std::string&
id, std::istream& in);
110 std::optional<std::string> _code;
111 std::size_t _hash = 0;
128 explicit JIT(
const std::shared_ptr<Context>& context,
bool dump_code =
false);
133 JIT(
JIT&&) noexcept =
delete;
134 JIT& operator=(
const JIT&) =
delete;
135 JIT& operator=(
JIT&&) noexcept =
delete;
151 void add(
const hilti::rt::filesystem::path& p);
157 bool hasInputs() {
return _codes.size() || _files.size(); }
167 auto context()
const {
return _context.lock(); }
170 auto options()
const {
return context()->options(); }
185 using JobID = uint64_t;
186 Result<JobID> _spawnJob(
const hilti::rt::filesystem::path& cmd, std::vector<std::string> args);
189 std::weak_ptr<Context> _context;
192 std::vector<hilti::rt::filesystem::path> _files;
193 std::vector<CxxCode> _codes;
194 std::vector<hilti::rt::filesystem::path> _objects;
197 std::unique_ptr<reproc::process> process;
201 void collectOutputs(
int events);
204 JobID _job_counter = 0;
205 std::map<JobID, Job> _jobs;
auto context() const
Definition: jit.h:167
const std::string & id() const
Definition: jit.h:85
CxxCode(const hilti::rt::filesystem::path &path)
Definition: jit.h:41
CxxCode(const std::string &id, std::istream &code)
Definition: jit.h:49
bool hasInputs()
Definition: jit.h:157
auto code() const
Definition: jit.h:75
std::size_t hash() const
Definition: jit.h:88
auto options() const
Definition: jit.h:170
auto isLoaded() const
Definition: jit.h:78