mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Template metadata structures
- Add RuntimeTarget template This will allow for converting between metadata structures for native host and remote target architectures. - Create InProcess and External templates for stored pointers Add a few more types to abstract pointer access in the runtime structures but keep native in-process pointer access the same as that with a plain old pointer type. There is now a notion of a "stored pointer", which is just the raw value of the pointer, and the actual pointer type, which is used for loads. Decoupling these allows us to fork the behavior when looking at metadata in an external process, but keep things the same for the in-process case. There are two basic "runtime targets" that you can use to work with metadata: InProcess: Defines the pointer to be trivially a T* and stored as a uintptr_t. A Metadata * is exactly as it was before, but defined via AbstractMetadata<InProcess>. External: A template that requires a target to specify its pointer size. ExternalPointer: An opaque pointer in another address space that can't (and shouldn't) be indirected with operator* or operator->. The memory reader will fetch the data explicitly.
This commit is contained in:
@@ -73,10 +73,10 @@ namespace {
|
||||
|
||||
public:
|
||||
TypeMetadataCacheEntry(const llvm::StringRef name,
|
||||
const struct Metadata *metadata)
|
||||
const ::Metadata *metadata)
|
||||
: Name(name.str()), Metadata(metadata) {}
|
||||
|
||||
const struct Metadata *getMetadata(void) {
|
||||
const ::Metadata *getMetadata(void) {
|
||||
return Metadata;
|
||||
}
|
||||
|
||||
@@ -230,6 +230,7 @@ swift::swift_registerTypeMetadataRecords(const TypeMetadataRecord *begin,
|
||||
}
|
||||
|
||||
// copied from ProtocolConformanceRecord::getCanonicalTypeMetadata()
|
||||
template<>
|
||||
const Metadata *TypeMetadataRecord::getCanonicalTypeMetadata() const {
|
||||
switch (getTypeKind()) {
|
||||
case TypeMetadataRecordKind::UniqueDirectType:
|
||||
@@ -238,7 +239,7 @@ const Metadata *TypeMetadataRecord::getCanonicalTypeMetadata() const {
|
||||
return swift_getForeignTypeMetadata((ForeignTypeMetadata *)getDirectType());
|
||||
case TypeMetadataRecordKind::UniqueDirectClass:
|
||||
if (auto *ClassMetadata =
|
||||
static_cast<const struct ClassMetadata *>(getDirectType()))
|
||||
static_cast<const ::ClassMetadata *>(getDirectType()))
|
||||
return swift_getObjCClassMetadata(ClassMetadata);
|
||||
else
|
||||
return nullptr;
|
||||
|
||||
Reference in New Issue
Block a user