mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
IRGen: Only mark field offset globals as constant if they won't be updated at runtime
Even if we have a constant value, we might be emitting a legacy layout that can be updated in place by newer runtimes. In this case, clients cannot assume the field offsets are constant, and the globals cannot be constant either. Part of <rdar://problem/17528739>.
This commit is contained in:
@@ -993,17 +993,17 @@ void IRGenModule::emitClassDecl(ClassDecl *D) {
|
||||
SILType selfType = getSelfType(D);
|
||||
auto &classTI = getTypeInfo(selfType).as<ClassTypeInfo>();
|
||||
|
||||
// FIXME: For now, always use the fragile layout when emitting metadata.
|
||||
// Use the fragile layout when emitting metadata.
|
||||
auto &fragileLayout =
|
||||
classTI.getClassLayout(*this, selfType, /*forBackwardDeployment=*/true);
|
||||
|
||||
// ... but still compute the resilient layout for better test coverage.
|
||||
// The resilient layout tells us what parts of the metadata can be
|
||||
// updated at runtime by the Objective-C metadata update callback.
|
||||
auto &resilientLayout =
|
||||
classTI.getClassLayout(*this, selfType, /*forBackwardDeployment=*/false);
|
||||
(void) resilientLayout;
|
||||
|
||||
// Emit the class metadata.
|
||||
emitClassMetadata(*this, D, fragileLayout);
|
||||
emitClassMetadata(*this, D, fragileLayout, resilientLayout);
|
||||
|
||||
IRGen.addClassForEagerInitialization(D);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user