brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.1 KiB · bb1ec33 Raw
95 lines · c
1//===--- IncrementalExecutor.h - Incremental Execution ----------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// This file implements the class which performs incremental code execution.10//11//===----------------------------------------------------------------------===//12 13#ifndef LLVM_CLANG_LIB_INTERPRETER_INCREMENTALEXECUTOR_H14#define LLVM_CLANG_LIB_INTERPRETER_INCREMENTALEXECUTOR_H15 16#include "clang/Interpreter/Interpreter.h"17#include "llvm/ADT/DenseMap.h"18#include "llvm/ADT/StringRef.h"19#include "llvm/ExecutionEngine/Orc/Core.h"20#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"21#include "llvm/ExecutionEngine/Orc/Layer.h"22#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"23#include "llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h"24#include "llvm/Support/Error.h"25 26#include <cstdint>27#include <memory>28#include <string>29 30namespace llvm {31class Error;32namespace orc {33class JITTargetMachineBuilder;34class LLJIT;35class LLJITBuilder;36class ThreadSafeContext;37} // namespace orc38} // namespace llvm39 40namespace clang {41 42struct PartialTranslationUnit;43class TargetInfo;44 45class IncrementalExecutor {46  using CtorDtorIterator = llvm::orc::CtorDtorIterator;47  std::unique_ptr<llvm::orc::LLJIT> Jit;48  llvm::orc::ThreadSafeContext &TSCtx;49  uint32_t OutOfProcessChildPid = -1;50 51  llvm::DenseMap<const PartialTranslationUnit *, llvm::orc::ResourceTrackerSP>52      ResourceTrackers;53 54protected:55  IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC);56 57public:58  enum SymbolNameKind { IRName, LinkerName };59 60  IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC,61                      llvm::orc::LLJITBuilder &JITBuilder,62                      Interpreter::JITConfig Config, llvm::Error &Err);63  virtual ~IncrementalExecutor();64 65  virtual llvm::Error addModule(PartialTranslationUnit &PTU);66  virtual llvm::Error removeModule(PartialTranslationUnit &PTU);67  virtual llvm::Error runCtors() const;68  virtual llvm::Error cleanUp();69  virtual llvm::Expected<llvm::orc::ExecutorAddr>70  getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const;71 72  llvm::orc::LLJIT &GetExecutionEngine() { return *Jit; }73 74  uint32_t getOutOfProcessChildPid() const { return OutOfProcessChildPid; }75 76  static llvm::Expected<std::unique_ptr<llvm::orc::LLJITBuilder>>77  createDefaultJITBuilder(llvm::orc::JITTargetMachineBuilder JTMB);78 79  static llvm::Expected<80      std::pair<std::unique_ptr<llvm::orc::SimpleRemoteEPC>, uint32_t>>81  launchExecutor(llvm::StringRef ExecutablePath, bool UseSharedMemory,82                 unsigned SlabAllocateSize,83                 std::function<void()> CustomizeFork = nullptr);84 85#if LLVM_ON_UNIX && LLVM_ENABLE_THREADS86  static llvm::Expected<std::unique_ptr<llvm::orc::SimpleRemoteEPC>>87  connectTCPSocket(llvm::StringRef NetworkAddress, bool UseSharedMemory,88                   unsigned SlabAllocateSize);89#endif90};91 92} // end namespace clang93 94#endif // LLVM_CLANG_LIB_INTERPRETER_INCREMENTALEXECUTOR_H95