Skip to content

Commit 5a8b1ae

Browse files
authored
Merge pull request swiftlang#34616 from mikeash/writers-block
[Runtime] Don't write to rodata if values already match.
2 parents a723cf7 + fd5b87f commit 5a8b1ae

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

stdlib/public/runtime/Metadata.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2721,7 +2721,12 @@ static void initClassFieldOffsetVector(ClassMetadata *self,
27212721
// situations where our entire superclass hierarchy is defined
27222722
// in Swift. (But note that ObjC might think we have a superclass
27232723
// even if Swift doesn't, because of SwiftObject.)
2724-
rodata->InstanceStart = size;
2724+
//
2725+
// The rodata may be in read-only memory if the compiler knows that the size
2726+
// it generates is already definitely correct. Don't write to this value
2727+
// unless it's necessary.
2728+
if (rodata->InstanceStart != size)
2729+
rodata->InstanceStart = size;
27252730
#endif
27262731

27272732
// Okay, now do layout.
@@ -2745,7 +2750,8 @@ static void initClassFieldOffsetVector(ClassMetadata *self,
27452750

27462751
#if SWIFT_OBJC_INTEROP
27472752
// Save the size into the Objective-C metadata as well.
2748-
rodata->InstanceSize = size;
2753+
if (rodata->InstanceSize != size)
2754+
rodata->InstanceSize = size;
27492755
#endif
27502756
}
27512757

0 commit comments

Comments
 (0)