diff --git a/include/swift/RemoteInspection/DescriptorFinder.h b/include/swift/RemoteInspection/DescriptorFinder.h index 9335474be6fbb..8af44a4384656 100644 --- a/include/swift/RemoteInspection/DescriptorFinder.h +++ b/include/swift/RemoteInspection/DescriptorFinder.h @@ -93,26 +93,6 @@ struct FieldDescriptorBase { getFieldRecords() = 0; }; -struct MultiPayloadEnumDescriptorBase { - virtual ~MultiPayloadEnumDescriptorBase(){}; - - virtual llvm::StringRef getMangledTypeName() = 0; - - virtual uint32_t getContentsSizeInWords() const = 0; - - virtual size_t getSizeInBytes() const = 0; - - virtual uint32_t getFlags() const = 0; - - virtual bool usesPayloadSpareBits() const = 0; - - virtual uint32_t getPayloadSpareBitMaskByteOffset() const = 0; - - virtual uint32_t getPayloadSpareBitMaskByteCount() const = 0; - - virtual const uint8_t *getPayloadSpareBits() const = 0; - -}; /// Interface for finding type descriptors. Implementors may provide descriptors /// that live inside or outside reflection metadata. struct DescriptorFinder { @@ -124,9 +104,6 @@ struct DescriptorFinder { virtual std::unique_ptr getFieldDescriptor(const TypeRef *TR) = 0; - - virtual std::unique_ptr - getMultiPayloadEnumDescriptor(const TypeRef *TR) = 0; }; } // namespace reflection diff --git a/include/swift/RemoteInspection/Records.h b/include/swift/RemoteInspection/Records.h index aa08ce3ef5b6d..1c0ceeb976257 100644 --- a/include/swift/RemoteInspection/Records.h +++ b/include/swift/RemoteInspection/Records.h @@ -378,111 +378,6 @@ class BuiltinTypeDescriptor { } }; -class MultiPayloadEnumDescriptor { -public: - const RelativeDirectPointer TypeName; - -private: - // This descriptor contains a series of 32-bit words - uint32_t contents[]; - - // Properties are stored in `contents` at particular indexes: - - // uint32_t SizeFlags; - // Upper 16 bits are the size of the contents (in 32-bit words): - // (This allows us to expand this structure in the future; - // new fields should have accessors that test whether the - // size is large enough and return "non-existent" if the - // descriptor isn't large enough to have that field.) - // Lower 16 bits are flag bits - - int getSizeFlagsIndex() const { return 0; } - - // uint32_t PayloadSpareBitMaskByteOffsetCount; - // Number of bytes in "payload spare bits", and - // offset of them within the payload area - // Only present if `usePayloadSpareBits()` - - int getPayloadSpareBitMaskByteCountIndex() const { - return getSizeFlagsIndex() + 1; - } - - // uint8_t *PayloadSpareBits; - // Variably-sized bitmask field (padded to a multiple of 4 bytes) - // Only present if `usePayloadSpareBits()` - - int getPayloadSpareBitsIndex() const { - int PayloadSpareBitMaskByteCountFieldSize = usesPayloadSpareBits() ? 1 : 0; - return getPayloadSpareBitMaskByteCountIndex() + PayloadSpareBitMaskByteCountFieldSize; - } - - // uint32_t foo; - // TODO: Some future field - // int getFooIndex() const { - // int PayloadSpareBitMaskFieldSize = (getPayloadSpareBitMaskByteCount() + 3) / 4; - // return getPayloadSpareBitsIndex() + PayloadSpareBitMaskFieldSize; - // } - - // uint32_t getFoo() const { - // if (getFooIndex() < getContentsSizeInWords()) { - // return contents[getFooIndex()]; - // } else { - // return 0; // Field isn't present - // } - // } - -public: - // - // Data derived from the above... - // - - uint32_t getContentsSizeInWords() const { - return contents[getSizeFlagsIndex()] >> 16; - } - - size_t getSizeInBytes() const { -// assert(getContentsSizeInWords() > 0 && "Malformed MPEnum reflection record"); - size_t sizeInBytes = sizeof(TypeName) + getContentsSizeInWords() * 4; - return sizeInBytes; - } - - uint32_t getFlags() const { - assert(getContentsSizeInWords() > 0 && "Malformed MPEnum reflection record"); - return contents[getSizeFlagsIndex()] & 0xffff; - } - - bool usesPayloadSpareBits() const { - return getFlags() & 1; - } - - uint32_t getPayloadSpareBitMaskByteOffset() const { - if (usesPayloadSpareBits()) { - return contents[getPayloadSpareBitMaskByteCountIndex()] >> 16; - } else { - return 0; - } - } - - uint32_t getPayloadSpareBitMaskByteCount() const { - if (usesPayloadSpareBits()) { - auto byteCount = contents[getPayloadSpareBitMaskByteCountIndex()] & 0xffff; - assert(getContentsSizeInWords() >= 2 + (byteCount + 3) / 4 - && "Malformed MPEnum reflection record: mask bigger than record"); - return byteCount; - } else { - return 0; - } - } - - const uint8_t *getPayloadSpareBits() const { - if (usesPayloadSpareBits()) { - return reinterpret_cast(&contents[getPayloadSpareBitsIndex()]); - } else { - return nullptr; - } - } -}; - class CaptureTypeRecord { public: const RelativeDirectPointer MangledTypeName; diff --git a/include/swift/RemoteInspection/ReflectionContext.h b/include/swift/RemoteInspection/ReflectionContext.h index e2384813ab4d7..8b0f109483251 100644 --- a/include/swift/RemoteInspection/ReflectionContext.h +++ b/include/swift/RemoteInspection/ReflectionContext.h @@ -335,8 +335,6 @@ class ReflectionContext ObjectFileFormat.getSectionName(ReflectionSectionKind::reflstr)); auto ConformMdSec = findMachOSectionByName( ObjectFileFormat.getSectionName(ReflectionSectionKind::conform)); - auto MPEnumMdSec = findMachOSectionByName( - ObjectFileFormat.getSectionName(ReflectionSectionKind::mpenum)); if (FieldMdSec.first == nullptr && AssocTySec.first == nullptr && @@ -344,8 +342,7 @@ class ReflectionContext CaptureSec.first == nullptr && TypeRefMdSec.first == nullptr && ReflStrMdSec.first == nullptr && - ConformMdSec.first == nullptr && - MPEnumMdSec.first == nullptr) + ConformMdSec.first == nullptr) return {}; ReflectionInfo info = {{FieldMdSec.first, FieldMdSec.second}, @@ -355,7 +352,6 @@ class ReflectionContext {TypeRefMdSec.first, TypeRefMdSec.second}, {ReflStrMdSec.first, ReflStrMdSec.second}, {ConformMdSec.first, ConformMdSec.second}, - {MPEnumMdSec.first, MPEnumMdSec.second}, PotentialModuleNames}; auto InfoID = this->addReflectionInfo(info); @@ -470,8 +466,6 @@ class ReflectionContext ObjectFileFormat.getSectionName(ReflectionSectionKind::reflstr)); auto ConformMdSec = findCOFFSectionByName( ObjectFileFormat.getSectionName(ReflectionSectionKind::conform)); - auto MPEnumMdSec = findCOFFSectionByName( - ObjectFileFormat.getSectionName(ReflectionSectionKind::mpenum)); if (FieldMdSec.first == nullptr && AssocTySec.first == nullptr && @@ -479,8 +473,7 @@ class ReflectionContext CaptureSec.first == nullptr && TypeRefMdSec.first == nullptr && ReflStrMdSec.first == nullptr && - ConformMdSec.first == nullptr && - MPEnumMdSec.first == nullptr) + ConformMdSec.first == nullptr) return {}; ReflectionInfo Info = {{FieldMdSec.first, FieldMdSec.second}, @@ -490,7 +483,6 @@ class ReflectionContext {TypeRefMdSec.first, TypeRefMdSec.second}, {ReflStrMdSec.first, ReflStrMdSec.second}, {ConformMdSec.first, ConformMdSec.second}, - {MPEnumMdSec.first, MPEnumMdSec.second}, PotentialModuleNames}; return this->addReflectionInfo(Info); } @@ -687,9 +679,6 @@ class ReflectionContext ObjectFileFormat.getSectionName(ReflectionSectionKind::reflstr), true); auto ConformMdSec = findELFSectionByName( ObjectFileFormat.getSectionName(ReflectionSectionKind::conform), true); - auto MPEnumMdSec = findELFSectionByName( - ObjectFileFormat.getSectionName(ReflectionSectionKind::mpenum), true); - if (Error) return {}; @@ -699,7 +688,7 @@ class ReflectionContext // ELF executable. if (FieldMdSec.first || AssocTySec.first || BuiltinTySec.first || CaptureSec.first || TypeRefMdSec.first || ReflStrMdSec.first || - ConformMdSec.first || MPEnumMdSec.first) { + ConformMdSec.first) { ReflectionInfo info = {{FieldMdSec.first, FieldMdSec.second}, {AssocTySec.first, AssocTySec.second}, {BuiltinTySec.first, BuiltinTySec.second}, @@ -707,7 +696,6 @@ class ReflectionContext {TypeRefMdSec.first, TypeRefMdSec.second}, {ReflStrMdSec.first, ReflStrMdSec.second}, {ConformMdSec.first, ConformMdSec.second}, - {MPEnumMdSec.first, MPEnumMdSec.second}, PotentialModuleNames}; result = this->addReflectionInfo(info); } @@ -730,15 +718,13 @@ class ReflectionContext ObjectFileFormat.getSectionName(ReflectionSectionKind::reflstr), false); ConformMdSec = findELFSectionByName( ObjectFileFormat.getSectionName(ReflectionSectionKind::conform), false); - MPEnumMdSec = findELFSectionByName( - ObjectFileFormat.getSectionName(ReflectionSectionKind::mpenum), false); if (Error) return {}; if (FieldMdSec.first || AssocTySec.first || BuiltinTySec.first || CaptureSec.first || TypeRefMdSec.first || ReflStrMdSec.first || - ConformMdSec.first || MPEnumMdSec.first) { + ConformMdSec.first) { ReflectionInfo info = {{FieldMdSec.first, FieldMdSec.second}, {AssocTySec.first, AssocTySec.second}, {BuiltinTySec.first, BuiltinTySec.second}, @@ -746,7 +732,6 @@ class ReflectionContext {TypeRefMdSec.first, TypeRefMdSec.second}, {ReflStrMdSec.first, ReflStrMdSec.second}, {ConformMdSec.first, ConformMdSec.second}, - {MPEnumMdSec.first, MPEnumMdSec.second}, PotentialModuleNames}; auto rid = this->addReflectionInfo(info); if (!result) @@ -861,7 +846,8 @@ class ReflectionContext ReflectionSectionKind::fieldmd, ReflectionSectionKind::assocty, ReflectionSectionKind::builtin, ReflectionSectionKind::capture, ReflectionSectionKind::typeref, ReflectionSectionKind::reflstr, - ReflectionSectionKind::conform, ReflectionSectionKind::mpenum}; + ReflectionSectionKind::conform + }; llvm::SmallVector, uint64_t>, 6> Pairs; for (auto Section : Sections) { @@ -887,7 +873,6 @@ class ReflectionContext {Pairs[4].first, Pairs[4].second}, {Pairs[5].first, Pairs[5].second}, {Pairs[6].first, Pairs[6].second}, - {Pairs[7].first, Pairs[7].second}, PotentialModuleNames}; return addReflectionInfo(Info); } diff --git a/include/swift/RemoteInspection/RuntimeHeaders/llvm/BinaryFormat/Swift.def b/include/swift/RemoteInspection/RuntimeHeaders/llvm/BinaryFormat/Swift.def index 05b60e40632cd..1ea0bc548b37e 100644 --- a/include/swift/RemoteInspection/RuntimeHeaders/llvm/BinaryFormat/Swift.def +++ b/include/swift/RemoteInspection/RuntimeHeaders/llvm/BinaryFormat/Swift.def @@ -30,4 +30,3 @@ HANDLE_SWIFT_SECTION(protocs, "__swift5_protos", "swift5_protocols", ".sw5prt$B") HANDLE_SWIFT_SECTION(acfuncs, "__swift5_acfuncs", "swift5_accessible_functions", ".sw5acfn$B") -HANDLE_SWIFT_SECTION(mpenum, "__swift5_mpenum", "swift5_mpenum", ".sw5mpen$B") diff --git a/include/swift/RemoteInspection/TypeRefBuilder.h b/include/swift/RemoteInspection/TypeRefBuilder.h index 0a98b782d05c2..b787b8522ded5 100644 --- a/include/swift/RemoteInspection/TypeRefBuilder.h +++ b/include/swift/RemoteInspection/TypeRefBuilder.h @@ -231,21 +231,6 @@ class CaptureDescriptorIterator }; using CaptureSection = ReflectionSection; -class MultiPayloadEnumDescriptorIterator - : public ReflectionSectionIteratorBase { -public: - MultiPayloadEnumDescriptorIterator(RemoteRef Cur, uint64_t Size) - : ReflectionSectionIteratorBase(Cur, Size, "MultiPayloadEnum") {} - - static uint64_t - getCurrentRecordSize(RemoteRef MPER) { - return MPER->getSizeInBytes(); - } -}; -using MultiPayloadEnumSection = - ReflectionSection; - using GenericSection = ReflectionSection; struct ReflectionInfo { @@ -256,7 +241,6 @@ struct ReflectionInfo { GenericSection TypeReference; GenericSection ReflectionString; GenericSection Conformance; - MultiPayloadEnumSection MultiPayloadEnum; llvm::SmallVector PotentialModuleNames; }; @@ -490,10 +474,6 @@ class TypeRefBuilder { /// Get the unsubstituted capture types for a closure context. ClosureContextInfo getClosureContextInfo(RemoteRef CD); - /// Get the multipayload enum projection information for a given TR - std::unique_ptr - getMultiPayloadEnumDescriptor(const TypeRef *TR) override; - const TypeRef *lookupTypeWitness(const std::string &MangledTypeName, const std::string &Member, StringRef Protocol); @@ -516,8 +496,6 @@ class TypeRefBuilder { /// Load unsubstituted field types for a nominal type. RemoteRef getFieldTypeInfo(const TypeRef *TR); - RemoteRef getMultiPayloadEnumInfo(const TypeRef *TR); - void populateFieldTypeInfoCacheWithReflectionAtIndex(size_t Index); std::optional> @@ -567,8 +545,7 @@ class TypeRefBuilder { public: /// - /// Dumping typerefs, field declarations, builtin types, captures, - /// multi-payload enums + /// Dumping typerefs, field declarations, builtin types, captures /// void dumpTypeRef(RemoteRef MangledName, std::ostream &stream, bool printTypeName = false); @@ -577,7 +554,6 @@ class TypeRefBuilder { void dumpFieldSection(std::ostream &stream); void dumpBuiltinTypeSection(std::ostream &stream); void dumpCaptureSection(std::ostream &stream); - void dumpMultiPayloadEnumSection(std::ostream &stream); template