Skip to content

Commit 2abcd97

Browse files
committed
Reflection: Remove some unused code, NFC
1 parent 8a005e6 commit 2abcd97

File tree

3 files changed

+9
-102
lines changed

3 files changed

+9
-102
lines changed

include/swift/Reflection/Records.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,16 @@ class CaptureDescriptor {
476476
}
477477

478478
public:
479+
/// The number of captures in the closure and the number of typerefs that
480+
/// immediately follow this struct.
479481
uint32_t NumCaptureTypes;
482+
483+
/// The number of sources of metadata available in the MetadataSourceMap
484+
/// directly following the list of capture's typerefs.
480485
uint32_t NumMetadataSources;
486+
487+
/// The number of items in the NecessaryBindings structure at the head of
488+
/// the closure.
481489
uint32_t NumBindings;
482490

483491
using const_iterator = FieldRecordIterator;

include/swift/Remote/MetadataReader.h

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,6 @@ class MetadataReader {
488488
using OwnedProtocolDescriptorRef =
489489
std::unique_ptr<const TargetProtocolDescriptor<Runtime>, delete_with_free>;
490490

491-
using OwnedCaptureDescriptor =
492-
std::unique_ptr<const CaptureDescriptor, delete_with_free>;
493-
494491
/// Cached isa mask.
495492
StoredPointer isaMask;
496493
bool hasIsaMask = false;
@@ -1060,39 +1057,6 @@ class MetadataReader {
10601057
return nominal;
10611058
}
10621059

1063-
/// Read the entire CaptureDescriptor in this address space, including
1064-
/// trailing capture typeref relative offsets, and GenericMetadataSource
1065-
/// pairs.
1066-
OwnedCaptureDescriptor readCaptureDescriptor(StoredPointer Address) {
1067-
1068-
uint32_t NumCaptures = 0;
1069-
uint32_t NumMetadataSources = 0;
1070-
1071-
StoredSize Offset = 0;
1072-
1073-
if (!Reader->readInteger(Address + Offset, &NumCaptures))
1074-
return nullptr;
1075-
1076-
Offset += sizeof(NumCaptures);
1077-
1078-
if (!Reader->readInteger(Address + Offset, &NumMetadataSources))
1079-
return nullptr;
1080-
1081-
StoredSize Size = sizeof(CaptureDescriptor) +
1082-
NumCaptures * sizeof(RelativeDirectPointer<const char>) +
1083-
NumMetadataSources * sizeof(GenericMetadataSource);
1084-
1085-
auto Buffer = (uint8_t *)malloc(Size);
1086-
1087-
if (!Reader->readBytes(Address, Buffer, Size)) {
1088-
free(Buffer);
1089-
return nullptr;
1090-
}
1091-
1092-
auto RawDescriptor = reinterpret_cast<const CaptureDescriptor *>(Buffer);
1093-
return OwnedCaptureDescriptor(RawDescriptor);
1094-
}
1095-
10961060
/// Given a pointer to an Objective-C class, try to read its class name.
10971061
bool readObjCClassName(StoredPointer classAddress, std::string &className) {
10981062
// The following algorithm only works on the non-fragile Apple runtime.

include/swift/Runtime/Metadata.h

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,79 +1754,14 @@ struct TargetClassMetadata : public TargetHeapMetadata<Runtime> {
17541754
};
17551755
using ClassMetadata = TargetClassMetadata<InProcess>;
17561756

1757-
/// A key-value pair in a TypeRef -> MetadataSource map.
1758-
struct GenericMetadataSource {
1759-
using Key = RelativeDirectPointer<const char>;
1760-
using Value = Key;
1761-
1762-
const Key MangledTypeName;
1763-
const Value EncodedMetadataSource;
1764-
};
1765-
1766-
/// Describes the layout of a heap closure.
1767-
///
1768-
/// For simplicity's sake and other reasons, this shouldn't contain
1769-
/// architecture-specifically sized things like direct pointers, uintptr_t, etc.
1770-
///
1771-
/// Following the CaptureDescriptor are:
1772-
/// - a list of direct relative offsets to the mangled type names of the
1773-
/// captures (these aren't in the DATA segment, however).
1774-
/// - a list of GenericMetadataSource objects - each element is a pair of:
1775-
/// - MangledTypeName (for a GenericTypeParameterTypeRef)
1776-
/// - EncodedMetadataSource (an encoded string like TypeRefs, but describe
1777-
/// the method of crawling to the metadata for that generic type parameter.
1778-
struct CaptureDescriptor {
1779-
public:
1780-
1781-
/// The number of captures in the closure and the number of typerefs that
1782-
/// immediately follow this struct.
1783-
const uint32_t NumCaptures;
1784-
1785-
/// The number of sources of metadata available in the MetadataSourceMap
1786-
/// directly following the list of capture's typerefs.
1787-
const uint32_t NumMetadataSources;
1788-
1789-
/// The number of items in the NecessaryBindings structure at the head of
1790-
/// the closure.
1791-
const uint32_t NumBindings;
1792-
1793-
/// Get the key-value pair for the ith generic metadata source.
1794-
const GenericMetadataSource &getGenericMetadataSource(size_t i) const {
1795-
assert(i <= NumMetadataSources &&
1796-
"Generic metadata source index out of range");
1797-
auto Begin = getGenericMetadataSourceBuffer();
1798-
return Begin[i];
1799-
}
1800-
1801-
/// Get the typeref (encoded as a mangled type name) of the ith
1802-
/// closure capture.
1803-
const RelativeDirectPointer<const char> &
1804-
getCaptureMangledTypeName(size_t i) const {
1805-
assert(i <= NumCaptures && "Capture index out of range");
1806-
auto Begin = getCaptureTypeRefBuffer();
1807-
return Begin[i];
1808-
}
1809-
1810-
private:
1811-
const GenericMetadataSource *getGenericMetadataSourceBuffer() const {
1812-
auto BeginTR = reinterpret_cast<const char *>(getCaptureTypeRefBuffer());
1813-
auto EndTR = BeginTR + NumCaptures * sizeof(GenericMetadataSource);
1814-
return reinterpret_cast<const GenericMetadataSource *>(EndTR);
1815-
}
1816-
1817-
const RelativeDirectPointer<const char> *getCaptureTypeRefBuffer() const {
1818-
return reinterpret_cast<const RelativeDirectPointer<const char> *>(this+1);
1819-
}
1820-
};
1821-
18221757
/// The structure of metadata for heap-allocated local variables.
18231758
/// This is non-type metadata.
18241759
template <typename Runtime>
18251760
struct TargetHeapLocalVariableMetadata
18261761
: public TargetHeapMetadata<Runtime> {
18271762
using StoredPointer = typename Runtime::StoredPointer;
18281763
uint32_t OffsetToFirstCapture;
1829-
TargetPointer<Runtime, CaptureDescriptor> CaptureDescription;
1764+
TargetPointer<Runtime, const char> CaptureDescription;
18301765
};
18311766
using HeapLocalVariableMetadata
18321767
= TargetHeapLocalVariableMetadata<InProcess>;

0 commit comments

Comments
 (0)