class MachOPlatform

Declaration

class MachOPlatform : public Platform { /* full declaration omitted */ };

Description

Mediates between MachO initialization and ExecutionSession state.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h:30

Inherits from: Platform

Member Variables

private llvm::orc::ExecutionSession& ES
private llvm::orc::ObjectLinkingLayer& ObjLinkingLayer
private llvm::orc::SymbolStringPtr MachOHeaderStartSymbol
private std::atomic<PlatformState> State = {BootstrapPhase1}
private llvm::orc::ExecutorAddr orc_rt_macho_platform_bootstrap
private llvm::orc::ExecutorAddr orc_rt_macho_platform_shutdown
private llvm::orc::ExecutorAddr orc_rt_macho_register_ehframe_section
private llvm::orc::ExecutorAddr orc_rt_macho_deregister_ehframe_section
private llvm::orc::ExecutorAddr orc_rt_macho_register_jitdylib
private llvm::orc::ExecutorAddr orc_rt_macho_deregister_jitdylib
private llvm::orc::ExecutorAddr orc_rt_macho_register_object_platform_sections
private llvm::orc::ExecutorAddr orc_rt_macho_deregister_object_platform_sections
private llvm::orc::ExecutorAddr orc_rt_macho_create_pthread_key
private DenseMap<llvm::orc::JITDylib*, llvm::orc::SymbolLookupSet> RegisteredInitSymbols
private std::mutex PlatformMutex
private DenseMap<llvm::orc::JITDylib*, llvm::orc::ExecutorAddr> JITDylibToHeaderAddr
private DenseMap<llvm::orc::ExecutorAddr, llvm::orc::JITDylib*> HeaderAddrToJITDylib
private DenseMap<llvm::orc::JITDylib*, uint64_t> JITDylibToPThreadKey

Method Overview

  • public static Expected<std::unique_ptr<MachOPlatform>> Create(llvm::orc::ExecutionSession & ES, llvm::orc::ObjectLinkingLayer & ObjLinkingLayer, llvm::orc::JITDylib & PlatformJD, const char * OrcRuntimePath, Optional<llvm::orc::SymbolAliasMap> RuntimeAliases = None)
  • private MachOPlatform(llvm::orc::ExecutionSession & ES, llvm::orc::ObjectLinkingLayer & ObjLinkingLayer, llvm::orc::JITDylib & PlatformJD, std::unique_ptr<DefinitionGenerator> OrcRuntimeGenerator, llvm::Error & Err)
  • private llvm::Error associateRuntimeSupportFunctions(llvm::orc::JITDylib & PlatformJD)
  • private llvm::Error bootstrapMachORuntime(llvm::orc::JITDylib & PlatformJD)
  • private Expected<uint64_t> createPThreadKey()
  • public llvm::orc::ExecutionSession & getExecutionSession() const
  • public llvm::orc::ObjectLinkingLayer & getObjectLinkingLayer() const
  • public static bool isInitializerSection(llvm::StringRef SegName, llvm::StringRef SectName)
  • public llvm::Error notifyAdding(llvm::orc::ResourceTracker & RT, const llvm::orc::MaterializationUnit & MU)
  • public llvm::Error notifyRemoving(llvm::orc::ResourceTracker & RT)
  • private void pushInitializersLoop(llvm::orc::MachOPlatform::PushInitializersSendResultFn SendResult, llvm::orc::JITDylibSP JD)
  • public static ArrayRef<std::pair<const char *, const char *>> requiredCXXAliases()
  • private void rt_lookupSymbol(llvm::orc::MachOPlatform::SendSymbolAddressFn SendResult, llvm::orc::ExecutorAddr Handle, llvm::StringRef SymbolName)
  • private void rt_pushInitializers(llvm::orc::MachOPlatform::PushInitializersSendResultFn SendResult, llvm::orc::ExecutorAddr JDHeaderAddr)
  • public llvm::Error setupJITDylib(llvm::orc::JITDylib & JD)
  • public static llvm::orc::SymbolAliasMap standardPlatformAliases(llvm::orc::ExecutionSession & ES)
  • public static ArrayRef<std::pair<const char *, const char *>> standardRuntimeUtilityAliases()
  • private static bool supportedTarget(const llvm::Triple & TT)
  • public llvm::Error teardownJITDylib(llvm::orc::JITDylib & JD)

Inherited from Platform:

Methods

static Expected<std::unique_ptr<MachOPlatform>>
Create(llvm::orc::ExecutionSession& ES,
       llvm::orc::ObjectLinkingLayer&
           ObjLinkingLayer,
       llvm::orc::JITDylib& PlatformJD,
       const char* OrcRuntimePath,
       Optional<llvm::orc::SymbolAliasMap>
           RuntimeAliases = None)

Description

Try to create a MachOPlatform instance, adding the ORC runtime to the given JITDylib. The ORC runtime requires access to a number of symbols in libc++, and requires access to symbols in libobjc, and libswiftCore to support Objective-C and Swift code. It is up to the caller to ensure that the requried symbols can be referenced by code added to PlatformJD. The standard way to achieve this is to first attach dynamic library search generators for either the given process, or for the specific required libraries, to PlatformJD, then to create the platform instance: Alternatively, these symbols could be added to another JITDylib that PlatformJD links against. Clients are also responsible for ensuring that any JIT'd code that depends on runtime functions (including any code using TLV or static destructors) can reference the runtime symbols. This is usually achieved by linking any JITDylibs containing regular code against PlatformJD. By default, MachOPlatform will add the set of aliases returned by the standardPlatformAliases function. This includes both required aliases (e.g. __cxa_atexit -> __orc_rt_macho_cxa_atexit for static destructor support), and optional aliases that provide JIT versions of common functions (e.g. dlopen -> __orc_rt_macho_jit_dlopen). Clients can override these defaults by passing a non-None value for the RuntimeAliases function, in which case the client is responsible for setting up all aliases (including the required ones).

Declared at: llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h:81

Parameters

llvm::orc::ExecutionSession& ES
llvm::orc::ObjectLinkingLayer& ObjLinkingLayer
llvm::orc::JITDylib& PlatformJD
const char* OrcRuntimePath
Optional<llvm::orc::SymbolAliasMap> RuntimeAliases = None

MachOPlatform(llvm::orc::ExecutionSession& ES,
              llvm::orc::ObjectLinkingLayer&
                  ObjLinkingLayer,
              llvm::orc::JITDylib& PlatformJD,
              std::unique_ptr<DefinitionGenerator>
                  OrcRuntimeGenerator,
              llvm::Error& Err)

Declared at: llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h:176

Parameters

llvm::orc::ExecutionSession& ES
llvm::orc::ObjectLinkingLayer& ObjLinkingLayer
llvm::orc::JITDylib& PlatformJD
std::unique_ptr<DefinitionGenerator> OrcRuntimeGenerator
llvm::Error& Err

llvm::Error associateRuntimeSupportFunctions(
    llvm::orc::JITDylib& PlatformJD)

Declared at: llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h:182

Parameters

llvm::orc::JITDylib& PlatformJD

llvm::Error bootstrapMachORuntime(
    llvm::orc::JITDylib& PlatformJD)

Declared at: llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h:199

Parameters

llvm::orc::JITDylib& PlatformJD

Expected<uint64_t> createPThreadKey()

Declared at: llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h:202

llvm::orc::ExecutionSession& getExecutionSession()
    const

Declared at: llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h:85

llvm::orc::ObjectLinkingLayer&
getObjectLinkingLayer() const

Declared at: llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h:86

static bool isInitializerSection(
    llvm::StringRef SegName,
    llvm::StringRef SectName)

Description

Returns true if the given section name is an initializer section.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h:107

Parameters

llvm::StringRef SegName
llvm::StringRef SectName

llvm::Error notifyAdding(
    llvm::orc::ResourceTracker& RT,
    const llvm::orc::MaterializationUnit& MU)

Description

This method will be called under the ExecutionSession lock each time a MaterializationUnit is added to a JITDylib.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h:90

Parameters

llvm::orc::ResourceTracker& RT
const llvm::orc::MaterializationUnit& MU

llvm::Error notifyRemoving(
    llvm::orc::ResourceTracker& RT)

Description

This method will be called under the ExecutionSession lock when a ResourceTracker is removed.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h:92

Parameters

llvm::orc::ResourceTracker& RT

void pushInitializersLoop(
    llvm::orc::MachOPlatform::
        PushInitializersSendResultFn SendResult,
    llvm::orc::JITDylibSP JD)

Declared at: llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h:187

Parameters

llvm::orc::MachOPlatform:: PushInitializersSendResultFn SendResult
llvm::orc::JITDylibSP JD

static ArrayRef<
    std::pair<const char*, const char*>>
requiredCXXAliases()

Description

Returns the array of required CXX aliases.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h:100

void rt_lookupSymbol(
    llvm::orc::MachOPlatform::SendSymbolAddressFn
        SendResult,
    llvm::orc::ExecutorAddr Handle,
    llvm::StringRef SymbolName)

Declared at: llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h:195

Parameters

llvm::orc::MachOPlatform::SendSymbolAddressFn SendResult
llvm::orc::ExecutorAddr Handle
llvm::StringRef SymbolName

void rt_pushInitializers(
    llvm::orc::MachOPlatform::
        PushInitializersSendResultFn SendResult,
    llvm::orc::ExecutorAddr JDHeaderAddr)

Declared at: llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h:191

Parameters

llvm::orc::MachOPlatform:: PushInitializersSendResultFn SendResult
llvm::orc::ExecutorAddr JDHeaderAddr

llvm::Error setupJITDylib(llvm::orc::JITDylib& JD)

Description

This method will be called outside the session lock each time a JITDylib is created (unless it is created with EmptyJITDylib set) to allow the Platform to install any JITDylib specific standard symbols (e.g __dso_handle).

Declared at: llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h:88

Parameters

llvm::orc::JITDylib& JD

static llvm::orc::SymbolAliasMap
standardPlatformAliases(
    llvm::orc::ExecutionSession& ES)

Description

Returns an AliasMap containing the default aliases for the MachOPlatform. This can be modified by clients when constructing the platform to add or remove aliases.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h:97

Parameters

llvm::orc::ExecutionSession& ES

static ArrayRef<
    std::pair<const char*, const char*>>
standardRuntimeUtilityAliases()

Description

Returns the array of standard runtime utility aliases for MachO.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h:104

static bool supportedTarget(
    const llvm::Triple& TT)

Declared at: llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h:174

Parameters

const llvm::Triple& TT

llvm::Error teardownJITDylib(
    llvm::orc::JITDylib& JD)

Description

This method will be called outside the session lock each time a JITDylib is removed to allow the Platform to remove any JITDylib-specific data.

Declared at: llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h:89

Parameters

llvm::orc::JITDylib& JD