Skip to content

Commit 1e5cc9e

Browse files
committed
Revert "reflection: handle LMA != VMA for ELF"
This reverts commit df54b2a.
1 parent 027e4f9 commit 1e5cc9e

File tree

8 files changed

+126
-194
lines changed

8 files changed

+126
-194
lines changed

include/swift/Reflection/Records.h

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ class FieldRecord {
6363
return MangledTypeName;
6464
}
6565

66-
std::string getMangledTypeName(uintptr_t Offset) const {
67-
return MangledTypeName.get() + Offset;
66+
std::string getMangledTypeName() const {
67+
return MangledTypeName.get();
6868
}
6969

70-
std::string getFieldName(uintptr_t Offset) const {
70+
std::string getFieldName() const {
7171
if (FieldName)
72-
return FieldName.get() + Offset;
72+
return FieldName.get();
7373
return "";
7474
}
7575

@@ -188,16 +188,16 @@ class FieldDescriptor {
188188
return MangledTypeName;
189189
}
190190

191-
std::string getMangledTypeName(uintptr_t Offset) const {
192-
return MangledTypeName.get() + Offset;
191+
std::string getMangledTypeName() const {
192+
return MangledTypeName.get();
193193
}
194194

195195
bool hasSuperclass() const {
196196
return Superclass;
197197
}
198198

199-
std::string getSuperclass(uintptr_t Offset) const {
200-
return Superclass.get() + Offset;
199+
std::string getSuperclass() const {
200+
return Superclass.get();
201201
}
202202
};
203203

@@ -241,12 +241,12 @@ class AssociatedTypeRecord {
241241
const RelativeDirectPointer<const char> SubstitutedTypeName;
242242

243243
public:
244-
std::string getName(uintptr_t Offset) const {
245-
return Name.get() + Offset;
244+
std::string getName() const {
245+
return Name.get();
246246
}
247247

248-
std::string getMangledSubstitutedTypeName(uintptr_t Offset) const {
249-
return SubstitutedTypeName.get() + Offset;
248+
std::string getMangledSubstitutedTypeName() const {
249+
return SubstitutedTypeName.get();
250250
}
251251
};
252252

@@ -319,12 +319,12 @@ struct AssociatedTypeDescriptor {
319319
return const_iterator { End, End };
320320
}
321321

322-
std::string getMangledProtocolTypeName(uintptr_t Offset) const {
323-
return ProtocolTypeName.get() + Offset;
322+
std::string getMangledProtocolTypeName() const {
323+
return ProtocolTypeName.get();
324324
}
325325

326-
std::string getMangledConformingTypeName(uintptr_t Offset) const {
327-
return ConformingTypeName.get() + Offset;
326+
std::string getMangledConformingTypeName() const {
327+
return ConformingTypeName.get();
328328
}
329329
};
330330

@@ -377,8 +377,8 @@ class BuiltinTypeDescriptor {
377377
return TypeName;
378378
}
379379

380-
std::string getMangledTypeName(uintptr_t Offset) const {
381-
return TypeName.get() + Offset;
380+
std::string getMangledTypeName() const {
381+
return TypeName.get();
382382
}
383383
};
384384

@@ -424,8 +424,8 @@ class CaptureTypeRecord {
424424
return MangledTypeName;
425425
}
426426

427-
std::string getMangledTypeName(uintptr_t Offset) const {
428-
return MangledTypeName.get() + Offset;
427+
std::string getMangledTypeName() const {
428+
return MangledTypeName.get();
429429
}
430430
};
431431

@@ -470,16 +470,16 @@ class MetadataSourceRecord {
470470
return MangledTypeName;
471471
}
472472

473-
std::string getMangledTypeName(uintptr_t Offset) const {
474-
return MangledTypeName.get() + Offset;
473+
std::string getMangledTypeName() const {
474+
return MangledTypeName.get();
475475
}
476476

477477
bool hasMangledMetadataSource() const {
478478
return MangledMetadataSource;
479479
}
480480

481-
std::string getMangledMetadataSource(uintptr_t Offset) const {
482-
return MangledMetadataSource.get() + Offset;
481+
std::string getMangledMetadataSource() const {
482+
return MangledMetadataSource.get();
483483
}
484484
};
485485

include/swift/Reflection/ReflectionContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class ReflectionContext
147147
if (CD == nullptr)
148148
return nullptr;
149149

150-
auto Info = getBuilder().getClosureContextInfo(*CD, 0);
150+
auto Info = getBuilder().getClosureContextInfo(*CD);
151151

152152
return getClosureContextInfo(ObjectAddress, Info);
153153
}

include/swift/Reflection/TypeRefBuilder.h

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -73,36 +73,12 @@ using CaptureSection = ReflectionSection<CaptureDescriptorIterator>;
7373
using GenericSection = ReflectionSection<const void *>;
7474

7575
struct ReflectionInfo {
76-
struct {
77-
FieldSection Metadata;
78-
uintptr_t SectionOffset;
79-
} Field;
80-
81-
struct {
82-
AssociatedTypeSection Metadata;
83-
uintptr_t SectionOffset;
84-
} AssociatedType;
85-
86-
struct {
87-
BuiltinTypeSection Metadata;
88-
uintptr_t SectionOffset;
89-
} Builtin;
90-
91-
struct {
92-
CaptureSection Metadata;
93-
uintptr_t SectionOffset;
94-
} Capture;
95-
96-
struct {
97-
GenericSection Metadata;
98-
uintptr_t SectionOffset;
99-
} TypeReference;
100-
101-
struct {
102-
GenericSection Metadata;
103-
uintptr_t SectionOffset;
104-
} ReflectionString;
105-
76+
FieldSection fieldmd;
77+
AssociatedTypeSection assocty;
78+
BuiltinTypeSection builtin;
79+
CaptureSection capture;
80+
GenericSection typeref;
81+
GenericSection reflstr;
10682
uintptr_t LocalStartAddress;
10783
uintptr_t RemoteStartAddress;
10884
};
@@ -346,12 +322,10 @@ class TypeRefBuilder {
346322
lookupSuperclass(const TypeRef *TR);
347323

348324
/// Load unsubstituted field types for a nominal type.
349-
std::pair<const FieldDescriptor *, uintptr_t>
350-
getFieldTypeInfo(const TypeRef *TR);
325+
const FieldDescriptor *getFieldTypeInfo(const TypeRef *TR);
351326

352327
/// Get the parsed and substituted field types for a nominal type.
353-
bool getFieldTypeRefs(const TypeRef *TR,
354-
const std::pair<const FieldDescriptor *, uintptr_t> &FD,
328+
bool getFieldTypeRefs(const TypeRef *TR, const FieldDescriptor *FD,
355329
std::vector<FieldTypeInfo> &Fields);
356330

357331
/// Get the primitive type lowering for a builtin type.
@@ -362,8 +336,7 @@ class TypeRefBuilder {
362336
const CaptureDescriptor *getCaptureDescriptor(uintptr_t RemoteAddress);
363337

364338
/// Get the unsubstituted capture types for a closure context.
365-
ClosureContextInfo getClosureContextInfo(const CaptureDescriptor &CD,
366-
uintptr_t Offset);
339+
ClosureContextInfo getClosureContextInfo(const CaptureDescriptor &CD);
367340

368341
///
369342
/// Dumping typerefs, field declarations, associated types

include/swift/SwiftRemoteMirror/SwiftRemoteMirrorTypes.h

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,35 +35,12 @@ typedef struct swift_reflection_section {
3535
/// \brief Represents the set of Swift reflection sections of an image.
3636
/// Not all sections may be present.
3737
typedef struct swift_reflection_info {
38-
struct {
39-
swift_reflection_section_t section;
40-
uintptr_t offset;
41-
} field;
42-
43-
struct {
44-
swift_reflection_section_t section;
45-
uintptr_t offset;
46-
} associated_types;
47-
48-
struct {
49-
swift_reflection_section_t section;
50-
uintptr_t offset;
51-
} builtin_types;
52-
53-
struct {
54-
swift_reflection_section_t section;
55-
uintptr_t offset;
56-
} capture;
57-
58-
struct {
59-
swift_reflection_section_t section;
60-
uintptr_t offset;
61-
} type_references;
62-
63-
struct {
64-
swift_reflection_section_t section;
65-
uintptr_t offset;
66-
} reflection_strings;
38+
swift_reflection_section_t fieldmd;
39+
swift_reflection_section_t assocty;
40+
swift_reflection_section_t builtin;
41+
swift_reflection_section_t capture;
42+
swift_reflection_section_t typeref;
43+
swift_reflection_section_t reflstr;
6744

6845
// Start address in local and remote address spaces.
6946
uintptr_t LocalStartAddress;

stdlib/public/Reflection/TypeLowering.cpp

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,10 @@ void TypeInfo::dump(std::ostream &OS, unsigned Indent) const {
198198
}
199199

200200
BuiltinTypeInfo::BuiltinTypeInfo(const BuiltinTypeDescriptor *descriptor)
201-
: TypeInfo(TypeInfoKind::Builtin, descriptor->Size, descriptor->Alignment,
202-
descriptor->Stride, descriptor->NumExtraInhabitants),
203-
Name(descriptor->getMangledTypeName(0)) {}
201+
: TypeInfo(TypeInfoKind::Builtin,
202+
descriptor->Size, descriptor->Alignment,
203+
descriptor->Stride, descriptor->NumExtraInhabitants),
204+
Name(descriptor->getMangledTypeName()) {}
204205

205206
/// Utility class for building values that contain witness tables.
206207
class ExistentialTypeInfoBuilder {
@@ -236,15 +237,14 @@ class ExistentialTypeInfoBuilder {
236237
}
237238

238239
for (auto *P : Protocols) {
239-
const std::pair<const FieldDescriptor *, uintptr_t> FD =
240-
TC.getBuilder().getFieldTypeInfo(P);
241-
if (FD.first == nullptr) {
240+
const FieldDescriptor *FD = TC.getBuilder().getFieldTypeInfo(P);
241+
if (FD == nullptr) {
242242
DEBUG(std::cerr << "No field descriptor: "; P->dump())
243243
Invalid = true;
244244
continue;
245245
}
246246

247-
switch (FD.first->Kind) {
247+
switch (FD->Kind) {
248248
case FieldDescriptorKind::ObjCProtocol:
249249
// Objective-C protocols do not have any witness tables.
250250
ObjC = true;
@@ -298,16 +298,16 @@ class ExistentialTypeInfoBuilder {
298298
Invalid = true;
299299
continue;
300300
}
301-
const auto &FD = TC.getBuilder().getFieldTypeInfo(T);
302-
if (FD.first == nullptr) {
301+
auto *FD = TC.getBuilder().getFieldTypeInfo(T);
302+
if (FD == nullptr) {
303303
DEBUG(std::cerr << "No field descriptor: "; T->dump())
304304
Invalid = true;
305305
continue;
306306
}
307307

308308
// We have a valid superclass constraint. It only affects
309309
// lowering by class-constraining the entire existential.
310-
switch (FD.first->Kind) {
310+
switch (FD->Kind) {
311311
case FieldDescriptorKind::Class:
312312
Refcounting = ReferenceCounting::Native;
313313
LLVM_FALLTHROUGH;
@@ -929,9 +929,7 @@ class EnumTypeInfoBuilder {
929929
: TC(TC), Size(0), Alignment(1), NumExtraInhabitants(0),
930930
Kind(RecordKind::Invalid), Invalid(false) {}
931931

932-
const TypeInfo *
933-
build(const TypeRef *TR,
934-
const std::pair<const FieldDescriptor *, uintptr_t> &FD) {
932+
const TypeInfo *build(const TypeRef *TR, const FieldDescriptor *FD) {
935933
// Sort enum into payload and no-payload cases.
936934
unsigned NoPayloadCases = 0;
937935
std::vector<FieldTypeInfo> PayloadCases;
@@ -1066,8 +1064,8 @@ class LowerType
10661064
}
10671065

10681066
const TypeInfo *visitAnyNominalTypeRef(const TypeRef *TR) {
1069-
const auto &FD = TC.getBuilder().getFieldTypeInfo(TR);
1070-
if (FD.first == nullptr) {
1067+
auto *FD = TC.getBuilder().getFieldTypeInfo(TR);
1068+
if (FD == nullptr) {
10711069
// Maybe this type is opaque -- look for a builtin
10721070
// descriptor to see if we at least know its size
10731071
// and alignment.
@@ -1079,7 +1077,7 @@ class LowerType
10791077
return nullptr;
10801078
}
10811079

1082-
switch (FD.first->Kind) {
1080+
switch (FD->Kind) {
10831081
case FieldDescriptorKind::Class:
10841082
// A value of class type is a single retainable pointer.
10851083
return TC.getReferenceTypeInfo(ReferenceKind::Strong,
@@ -1320,14 +1318,13 @@ const TypeInfo *TypeConverter::getTypeInfo(const TypeRef *TR) {
13201318

13211319
const TypeInfo *TypeConverter::getClassInstanceTypeInfo(const TypeRef *TR,
13221320
unsigned start) {
1323-
const std::pair<const FieldDescriptor *, uintptr_t> &FD =
1324-
getBuilder().getFieldTypeInfo(TR);
1325-
if (FD.first == nullptr) {
1321+
const FieldDescriptor *FD = getBuilder().getFieldTypeInfo(TR);
1322+
if (FD == nullptr) {
13261323
DEBUG(std::cerr << "No field descriptor: "; TR->dump());
13271324
return nullptr;
13281325
}
13291326

1330-
switch (FD.first->Kind) {
1327+
switch (FD->Kind) {
13311328
case FieldDescriptorKind::Class:
13321329
case FieldDescriptorKind::ObjCClass: {
13331330
// Lower the class's fields using substitutions from the

0 commit comments

Comments
 (0)