Runtime: Tolerate unknown metadata kinds.

We want to be able to potentially introduce new metadata kinds in future Swift compilers, so a runtime ought to be able to degrade gracefully in the face of metadata kinds it doesn't know about. Remove attempts to exhaustively switch over metadata kinds and instead treat unknown metadata kinds as opaque.
This commit is contained in:
Joe Groff
2018-05-17 15:35:06 -07:00
parent 812e94587e
commit 681a96b45c
12 changed files with 70 additions and 391 deletions

View File

@@ -54,9 +54,20 @@ enum class MetadataKind : uint32_t {
#define ABSTRACTMETADATAKIND(name, start, end) \
name##_Start = start, name##_End = end,
#include "MetadataKind.def"
/// The largest possible non-isa-pointer metadata kind value.
///
/// This is included in the enumeration to prevent against attempts to
/// exhaustively match metadata kinds. Future Swift runtimes or compilers
/// may introduce new metadata kinds, so for forward compatibility, the
/// runtime must tolerate metadata with unknown kinds.
/// This specific value is not mapped to a valid metadata kind at this time,
/// however.
LastEnumerated = 2047,
};
const unsigned LastEnumeratedMetadataKind = 2047;
const unsigned LastEnumeratedMetadataKind =
(unsigned)MetadataKind::LastEnumerated;
/// Try to translate the 'isa' value of a type/heap metadata into a value
/// of the MetadataKind enum.