Skip to content

Commit fbcef9a

Browse files
committed
[Runtime] Use the new NonMetaClass ObjC field to have generic metaclasses point to their classes. Remove metaclass handling from the lazy class namer since it's not necessary.
rdar://problem/57674583
1 parent 6c18340 commit fbcef9a

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

stdlib/public/runtime/Metadata.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,7 +2172,10 @@ namespace {
21722172
#if __POINTER_WIDTH__ == 64
21732173
uint32_t Reserved;
21742174
#endif
2175-
const uint8_t *IvarLayout;
2175+
union {
2176+
const uint8_t *IvarLayout;
2177+
ClassMetadata *NonMetaClass;
2178+
};
21762179
const char *Name;
21772180
const void *MethodList;
21782181
const void *ProtocolList;
@@ -2249,12 +2252,7 @@ static bool installLazyClassNameHandler() {
22492252
return false;
22502253

22512254
_objc_setLazyClassNamer([](Class theClass) {
2252-
ClassMetadata *metadata;
2253-
if (class_isMetaClass(theClass)) {
2254-
metadata = (ClassMetadata *)class_getIvarLayout(theClass);
2255-
} else {
2256-
metadata = (ClassMetadata *)theClass;
2257-
}
2255+
ClassMetadata *metadata = (ClassMetadata *)theClass;
22582256
return copyGenericClassObjCName(metadata);
22592257
});
22602258
return true;
@@ -2266,7 +2264,7 @@ static void setUpGenericClassObjCName(ClassMetadata *theClass) {
22662264
getROData(theClass)->Name = nullptr;
22672265
auto theMetaclass = (ClassMetadata *)object_getClass((id)theClass);
22682266
getROData(theMetaclass)->Name = nullptr;
2269-
getROData(theMetaclass)->IvarLayout = (const uint8_t *)theClass;
2267+
getROData(theMetaclass)->NonMetaClass = theClass;
22702268
} else {
22712269
initGenericClassObjCName(theClass);
22722270
}

0 commit comments

Comments
 (0)