Skip to content

[Runtime] Don't write to rodata if values already match. #34616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions stdlib/public/runtime/Metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2721,7 +2721,12 @@ static void initClassFieldOffsetVector(ClassMetadata *self,
// situations where our entire superclass hierarchy is defined
// in Swift. (But note that ObjC might think we have a superclass
// even if Swift doesn't, because of SwiftObject.)
rodata->InstanceStart = size;
//
// The rodata may be in read-only memory if the compiler knows that the size
// it generates is already definitely correct. Don't write to this value
// unless it's necessary.
if (rodata->InstanceStart != size)
rodata->InstanceStart = size;
#endif

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

#if SWIFT_OBJC_INTEROP
// Save the size into the Objective-C metadata as well.
rodata->InstanceSize = size;
if (rodata->InstanceSize != size)
rodata->InstanceSize = size;
#endif
}

Expand Down