From: Lang Hames Date: Fri, 24 Sep 2021 03:52:21 +0000 (-0700) Subject: [ORC-RT] Rename ExecutorAddress to ExecutorAddr. X-Git-Tag: upstream/15.0.7~30645 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0820fbab99a1f1986a8c6e0a8e5cb4542ec52515;p=platform%2Fupstream%2Fllvm.git [ORC-RT] Rename ExecutorAddress to ExecutorAddr. This is an ORC-runtime counterpart to LLVM commit ef391df2b63, and the motivation is the same: to move to a shorter name to improve the ergonomics of this type before it's more widely adopted. --- diff --git a/compiler-rt/lib/orc/elfnix_platform.cpp b/compiler-rt/lib/orc/elfnix_platform.cpp index 6d44aa0..73183b3 100644 --- a/compiler-rt/lib/orc/elfnix_platform.cpp +++ b/compiler-rt/lib/orc/elfnix_platform.cpp @@ -37,7 +37,7 @@ extern "C" void __deregister_frame(const void *); namespace { Error validatePointerSectionExtent(const char *SectionName, - const ExecutorAddressRange &SE) { + const ExecutorAddrRange &SE) { if (SE.size().getValue() % sizeof(uintptr_t)) { std::ostringstream ErrMsg; ErrMsg << std::hex << "Size of " << SectionName << " 0x" @@ -48,7 +48,7 @@ Error validatePointerSectionExtent(const char *SectionName, return Error::success(); } -Error runInitArray(const std::vector &InitArraySections, +Error runInitArray(const std::vector &InitArraySections, const ELFNixJITDylibInitializers &MOJDIs) { for (const auto &ModInits : InitArraySections) { @@ -120,8 +120,8 @@ private: Error registerThreadDataSection(span ThreadDataSection); - Expected lookupSymbolInJITDylib(void *DSOHandle, - string_view Symbol); + Expected lookupSymbolInJITDylib(void *DSOHandle, + string_view Symbol); Expected getJITDylibInitializersByName(string_view Path); @@ -131,7 +131,7 @@ private: static ELFNixPlatformRuntimeState *MOPS; using InitSectionHandler = - Error (*)(const std::vector &Sections, + Error (*)(const std::vector &Sections, const ELFNixJITDylibInitializers &MOJDIs); const std::vector> InitSections = {{".init_array", runInitArray}}; @@ -318,14 +318,15 @@ Error ELFNixPlatformRuntimeState::registerThreadDataSection( return Error::success(); } -Expected +Expected ELFNixPlatformRuntimeState::lookupSymbolInJITDylib(void *DSOHandle, string_view Sym) { - Expected Result((ExecutorAddress())); - if (auto Err = WrapperFunction( - SPSExecutorAddress, - SPSString)>::call(&__orc_rt_elfnix_symbol_lookup_tag, Result, - ExecutorAddress::fromPtr(DSOHandle), Sym)) + Expected Result((ExecutorAddr())); + if (auto Err = WrapperFunction( + SPSExecutorAddr, SPSString)>::call(&__orc_rt_elfnix_symbol_lookup_tag, + Result, + ExecutorAddr::fromPtr(DSOHandle), + Sym)) return std::move(Err); return Result; } diff --git a/compiler-rt/lib/orc/elfnix_platform.h b/compiler-rt/lib/orc/elfnix_platform.h index 288ed61..5afeac5 100644 --- a/compiler-rt/lib/orc/elfnix_platform.h +++ b/compiler-rt/lib/orc/elfnix_platform.h @@ -32,19 +32,19 @@ namespace __orc_rt { namespace elfnix { struct ELFNixPerObjectSectionsToRegister { - ExecutorAddressRange EHFrameSection; - ExecutorAddressRange ThreadDataSection; + ExecutorAddrRange EHFrameSection; + ExecutorAddrRange ThreadDataSection; }; struct ELFNixJITDylibInitializers { - using SectionList = std::vector; + using SectionList = std::vector; ELFNixJITDylibInitializers() = default; - ELFNixJITDylibInitializers(std::string Name, ExecutorAddress DSOHandleAddress) + ELFNixJITDylibInitializers(std::string Name, ExecutorAddr DSOHandleAddress) : Name(std::move(Name)), DSOHandleAddress(std::move(DSOHandleAddress)) {} std::string Name; - ExecutorAddress DSOHandleAddress; + ExecutorAddr DSOHandleAddress; std::unordered_map InitSections; }; @@ -67,7 +67,7 @@ enum dlopen_mode : int { } // end namespace elfnix using SPSELFNixPerObjectSectionsToRegister = - SPSTuple; + SPSTuple; template <> class SPSSerializationTraits>; +using SPSNamedExecutorAddrRangeSequenceMap = + SPSSequence>; using SPSELFNixJITDylibInitializers = - SPSTuple; + SPSTuple; using SPSELFNixJITDylibInitializerSequence = SPSSequence; diff --git a/compiler-rt/lib/orc/executor_address.h b/compiler-rt/lib/orc/executor_address.h index cfe985b..f39f7d7 100644 --- a/compiler-rt/lib/orc/executor_address.h +++ b/compiler-rt/lib/orc/executor_address.h @@ -37,19 +37,19 @@ private: }; /// Represents an address in the executor process. -class ExecutorAddress { +class ExecutorAddr { public: - ExecutorAddress() = default; - explicit ExecutorAddress(uint64_t Addr) : Addr(Addr) {} + ExecutorAddr() = default; + explicit ExecutorAddr(uint64_t Addr) : Addr(Addr) {} - /// Create an ExecutorAddress from the given pointer. + /// Create an ExecutorAddr from the given pointer. /// Warning: This should only be used when JITing in-process. - template static ExecutorAddress fromPtr(T *Value) { - return ExecutorAddress( + template static ExecutorAddr fromPtr(T *Value) { + return ExecutorAddr( static_cast(reinterpret_cast(Value))); } - /// Cast this ExecutorAddress to a pointer of the given type. + /// Cast this ExecutorAddr to a pointer of the given type. /// Warning: This should only be esude when JITing in-process. template T toPtr() const { static_assert(std::is_pointer::value, "T must be a pointer type"); @@ -65,53 +65,47 @@ public: explicit operator bool() const { return Addr != 0; } - friend bool operator==(const ExecutorAddress &LHS, - const ExecutorAddress &RHS) { + friend bool operator==(const ExecutorAddr &LHS, const ExecutorAddr &RHS) { return LHS.Addr == RHS.Addr; } - friend bool operator!=(const ExecutorAddress &LHS, - const ExecutorAddress &RHS) { + friend bool operator!=(const ExecutorAddr &LHS, const ExecutorAddr &RHS) { return LHS.Addr != RHS.Addr; } - friend bool operator<(const ExecutorAddress &LHS, - const ExecutorAddress &RHS) { + friend bool operator<(const ExecutorAddr &LHS, const ExecutorAddr &RHS) { return LHS.Addr < RHS.Addr; } - friend bool operator<=(const ExecutorAddress &LHS, - const ExecutorAddress &RHS) { + friend bool operator<=(const ExecutorAddr &LHS, const ExecutorAddr &RHS) { return LHS.Addr <= RHS.Addr; } - friend bool operator>(const ExecutorAddress &LHS, - const ExecutorAddress &RHS) { + friend bool operator>(const ExecutorAddr &LHS, const ExecutorAddr &RHS) { return LHS.Addr > RHS.Addr; } - friend bool operator>=(const ExecutorAddress &LHS, - const ExecutorAddress &RHS) { + friend bool operator>=(const ExecutorAddr &LHS, const ExecutorAddr &RHS) { return LHS.Addr >= RHS.Addr; } - ExecutorAddress &operator++() { + ExecutorAddr &operator++() { ++Addr; return *this; } - ExecutorAddress &operator--() { + ExecutorAddr &operator--() { --Addr; return *this; } - ExecutorAddress operator++(int) { return ExecutorAddress(Addr++); } - ExecutorAddress operator--(int) { return ExecutorAddress(Addr++); } + ExecutorAddr operator++(int) { return ExecutorAddr(Addr++); } + ExecutorAddr operator--(int) { return ExecutorAddr(Addr++); } - ExecutorAddress &operator+=(const ExecutorAddrDiff Delta) { + ExecutorAddr &operator+=(const ExecutorAddrDiff Delta) { Addr += Delta.getValue(); return *this; } - ExecutorAddress &operator-=(const ExecutorAddrDiff Delta) { + ExecutorAddr &operator-=(const ExecutorAddrDiff Delta) { Addr -= Delta.getValue(); return *this; } @@ -121,27 +115,27 @@ private: }; /// Subtracting two addresses yields an offset. -inline ExecutorAddrDiff operator-(const ExecutorAddress &LHS, - const ExecutorAddress &RHS) { +inline ExecutorAddrDiff operator-(const ExecutorAddr &LHS, + const ExecutorAddr &RHS) { return ExecutorAddrDiff(LHS.getValue() - RHS.getValue()); } /// Adding an offset and an address yields an address. -inline ExecutorAddress operator+(const ExecutorAddress &LHS, - const ExecutorAddrDiff &RHS) { - return ExecutorAddress(LHS.getValue() + RHS.getValue()); +inline ExecutorAddr operator+(const ExecutorAddr &LHS, + const ExecutorAddrDiff &RHS) { + return ExecutorAddr(LHS.getValue() + RHS.getValue()); } /// Adding an address and an offset yields an address. -inline ExecutorAddress operator+(const ExecutorAddrDiff &LHS, - const ExecutorAddress &RHS) { - return ExecutorAddress(LHS.getValue() + RHS.getValue()); +inline ExecutorAddr operator+(const ExecutorAddrDiff &LHS, + const ExecutorAddr &RHS) { + return ExecutorAddr(LHS.getValue() + RHS.getValue()); } /// Represents an address range in the exceutor process. -struct ExecutorAddressRange { - ExecutorAddressRange() = default; - ExecutorAddressRange(ExecutorAddress StartAddress, ExecutorAddress EndAddress) +struct ExecutorAddrRange { + ExecutorAddrRange() = default; + ExecutorAddrRange(ExecutorAddr StartAddress, ExecutorAddr EndAddress) : StartAddress(StartAddress), EndAddress(EndAddress) {} bool empty() const { return StartAddress == EndAddress; } @@ -153,55 +147,53 @@ struct ExecutorAddressRange { return span(StartAddress.toPtr(), size().getValue() / sizeof(T)); } - ExecutorAddress StartAddress; - ExecutorAddress EndAddress; + ExecutorAddr StartAddress; + ExecutorAddr EndAddress; }; -/// SPS serializatior for ExecutorAddress. -template <> class SPSSerializationTraits { +/// SPS serializatior for ExecutorAddr. +template <> class SPSSerializationTraits { public: - static size_t size(const ExecutorAddress &EA) { + static size_t size(const ExecutorAddr &EA) { return SPSArgList::size(EA.getValue()); } - static bool serialize(SPSOutputBuffer &BOB, const ExecutorAddress &EA) { + static bool serialize(SPSOutputBuffer &BOB, const ExecutorAddr &EA) { return SPSArgList::serialize(BOB, EA.getValue()); } - static bool deserialize(SPSInputBuffer &BIB, ExecutorAddress &EA) { + static bool deserialize(SPSInputBuffer &BIB, ExecutorAddr &EA) { uint64_t Tmp; if (!SPSArgList::deserialize(BIB, Tmp)) return false; - EA = ExecutorAddress(Tmp); + EA = ExecutorAddr(Tmp); return true; } }; -using SPSExecutorAddressRange = - SPSTuple; +using SPSExecutorAddrRange = SPSTuple; /// Serialization traits for address ranges. template <> -class SPSSerializationTraits { +class SPSSerializationTraits { public: - static size_t size(const ExecutorAddressRange &Value) { - return SPSArgList::size( + static size_t size(const ExecutorAddrRange &Value) { + return SPSArgList::size( Value.StartAddress, Value.EndAddress); } - static bool serialize(SPSOutputBuffer &BOB, - const ExecutorAddressRange &Value) { - return SPSArgList::serialize( + static bool serialize(SPSOutputBuffer &BOB, const ExecutorAddrRange &Value) { + return SPSArgList::serialize( BOB, Value.StartAddress, Value.EndAddress); } - static bool deserialize(SPSInputBuffer &BIB, ExecutorAddressRange &Value) { - return SPSArgList::deserialize( + static bool deserialize(SPSInputBuffer &BIB, ExecutorAddrRange &Value) { + return SPSArgList::deserialize( BIB, Value.StartAddress, Value.EndAddress); } }; -using SPSExecutorAddressRangeSequence = SPSSequence; +using SPSExecutorAddrRangeSequence = SPSSequence; } // End namespace __orc_rt diff --git a/compiler-rt/lib/orc/macho_platform.cpp b/compiler-rt/lib/orc/macho_platform.cpp index 2a960fb..62629215 100644 --- a/compiler-rt/lib/orc/macho_platform.cpp +++ b/compiler-rt/lib/orc/macho_platform.cpp @@ -89,7 +89,7 @@ void walkEHFrameSection(span EHFrameSection, } Error validatePointerSectionExtent(const char *SectionName, - const ExecutorAddressRange &SE) { + const ExecutorAddrRange &SE) { if (SE.size().getValue() % sizeof(uintptr_t)) { std::ostringstream ErrMsg; ErrMsg << std::hex << "Size of " << SectionName << " 0x" @@ -101,7 +101,7 @@ Error validatePointerSectionExtent(const char *SectionName, } Error registerObjCSelectors( - const std::vector &ObjCSelRefsSections, + const std::vector &ObjCSelRefsSections, const MachOJITDylibInitializers &MOJDIs) { if (ORC_RT_UNLIKELY(!sel_registerName)) @@ -126,7 +126,7 @@ Error registerObjCSelectors( } Error registerObjCClasses( - const std::vector &ObjCClassListSections, + const std::vector &ObjCClassListSections, const MachOJITDylibInitializers &MOJDIs) { if (ObjCClassListSections.empty()) @@ -170,7 +170,7 @@ Error registerObjCClasses( } Error registerSwift5Protocols( - const std::vector &Swift5ProtocolSections, + const std::vector &Swift5ProtocolSections, const MachOJITDylibInitializers &MOJDIs) { if (ORC_RT_UNLIKELY(!Swift5ProtocolSections.empty() && @@ -186,7 +186,7 @@ Error registerSwift5Protocols( } Error registerSwift5ProtocolConformances( - const std::vector &Swift5ProtocolConformanceSections, + const std::vector &Swift5ProtocolConformanceSections, const MachOJITDylibInitializers &MOJDIs) { if (ORC_RT_UNLIKELY(!Swift5ProtocolConformanceSections.empty() && @@ -202,7 +202,7 @@ Error registerSwift5ProtocolConformances( return Error::success(); } -Error runModInits(const std::vector &ModInitsSections, +Error runModInits(const std::vector &ModInitsSections, const MachOJITDylibInitializers &MOJDIs) { for (const auto &ModInits : ModInitsSections) { @@ -275,8 +275,8 @@ private: Error registerThreadDataSection(span ThreadDataSec); - Expected lookupSymbolInJITDylib(void *DSOHandle, - string_view Symbol); + Expected lookupSymbolInJITDylib(void *DSOHandle, + string_view Symbol); Expected getJITDylibInitializersByName(string_view Path); @@ -286,7 +286,7 @@ private: static MachOPlatformRuntimeState *MOPS; using InitSectionHandler = - Error (*)(const std::vector &Sections, + Error (*)(const std::vector &Sections, const MachOJITDylibInitializers &MOJDIs); const std::vector> InitSections = {{"__DATA,__objc_selrefs", registerObjCSelectors}, @@ -479,14 +479,15 @@ Error MachOPlatformRuntimeState::registerThreadDataSection( return Error::success(); } -Expected +Expected MachOPlatformRuntimeState::lookupSymbolInJITDylib(void *DSOHandle, string_view Sym) { - Expected Result((ExecutorAddress())); - if (auto Err = WrapperFunction( - SPSExecutorAddress, - SPSString)>::call(&__orc_rt_macho_symbol_lookup_tag, Result, - ExecutorAddress::fromPtr(DSOHandle), Sym)) + Expected Result((ExecutorAddr())); + if (auto Err = WrapperFunction( + SPSExecutorAddr, SPSString)>::call(&__orc_rt_macho_symbol_lookup_tag, + Result, + ExecutorAddr::fromPtr(DSOHandle), + Sym)) return std::move(Err); return Result; } diff --git a/compiler-rt/lib/orc/macho_platform.h b/compiler-rt/lib/orc/macho_platform.h index 6c05e84..7f0edc6 100644 --- a/compiler-rt/lib/orc/macho_platform.h +++ b/compiler-rt/lib/orc/macho_platform.h @@ -32,22 +32,21 @@ namespace __orc_rt { namespace macho { struct MachOPerObjectSectionsToRegister { - ExecutorAddressRange EHFrameSection; - ExecutorAddressRange ThreadDataSection; + ExecutorAddrRange EHFrameSection; + ExecutorAddrRange ThreadDataSection; }; struct MachOJITDylibInitializers { - using SectionList = std::vector; + using SectionList = std::vector; MachOJITDylibInitializers() = default; - MachOJITDylibInitializers(std::string Name, - ExecutorAddress MachOHeaderAddress) + MachOJITDylibInitializers(std::string Name, ExecutorAddr MachOHeaderAddress) : Name(std::move(Name)), MachOHeaderAddress(std::move(MachOHeaderAddress)) {} std::string Name; - ExecutorAddress MachOHeaderAddress; - ExecutorAddress ObjCImageInfoAddress; + ExecutorAddr MachOHeaderAddress; + ExecutorAddr ObjCImageInfoAddress; std::unordered_map InitSections; }; @@ -69,7 +68,7 @@ enum dlopen_mode : int { } // end namespace macho using SPSMachOPerObjectSectionsToRegister = - SPSTuple; + SPSTuple; template <> class SPSSerializationTraits>; +using SPSNamedExecutorAddrRangeSequenceMap = + SPSSequence>; using SPSMachOJITDylibInitializers = - SPSTuple; + SPSTuple; using SPSMachOJITDylibInitializerSequence = SPSSequence; diff --git a/compiler-rt/lib/orc/simple_packed_serialization.h b/compiler-rt/lib/orc/simple_packed_serialization.h index b561a19..b00707e 100644 --- a/compiler-rt/lib/orc/simple_packed_serialization.h +++ b/compiler-rt/lib/orc/simple_packed_serialization.h @@ -176,7 +176,7 @@ public: class SPSEmpty {}; /// Represents an address in the executor. -class SPSExecutorAddress {}; +class SPSExecutorAddr {}; /// SPS tag type for tuples. ///