Skip to content

[IRGen][Runtime] Adjust the ObjC reserved bits on x86-64 to exactly match what the target uses. #19540

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 2 commits into from
Oct 4, 2018

Conversation

mikeash
Copy link
Contributor

@mikeash mikeash commented Sep 25, 2018

Previously we had a single mask for all x86-64 targets which included both the top and bottom bits. This accommodated simulators, which use the top bit, while macOS uses the bottom bit, but reserved one bit more than necessary on each. This change breaks out x86-64 simulators from non-simulators and reserves only the one bit used on each.

This PR also includes a new substitution in lit.cfg to allow some tests to distinguish between simulator and non-simulator targets. This was needed because x86-64 simulator and non-simulator now generate slightly different output for some tests.

rdar://problem/34805348 rdar://problem/29765919

@mikeash
Copy link
Contributor Author

mikeash commented Sep 25, 2018

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - e3fbedf0bddd97dedf4523e8e80443a96985fd49

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - e3fbedf0bddd97dedf4523e8e80443a96985fd49

@mikeash
Copy link
Contributor Author

mikeash commented Sep 25, 2018

Curse you, git add!

@mikeash mikeash force-pushed the reserved-bits-refinement branch from e3fbedf to 8ec3f75 Compare September 25, 2018 19:51
@mikeash
Copy link
Contributor Author

mikeash commented Sep 25, 2018

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - e3fbedf0bddd97dedf4523e8e80443a96985fd49

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - e3fbedf0bddd97dedf4523e8e80443a96985fd49

// Systems exist which use either bit.
#define SWIFT_ABI_X86_64_OBJC_RESERVED_BITS_MASK 0x8000000000000001ULL
// Objective-C normally reserves the low bit for tagged pointers, but
// instead reserves the high bit on iOS simulators.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is correct; doesn't it use the high bit everywhere but x86_64 Mac, so that objc_msgSend can do the clever "branch if nil or negative" trick?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant that within the context of x86-64, so it's sort of right, but not exactly clear. I think I was trying to be excessively general or something. I'll fix it.

@mikeash mikeash force-pushed the reserved-bits-refinement branch 4 times, most recently from a43d849 to 2d97218 Compare September 26, 2018 14:58
@mikeash mikeash requested a review from milseman September 26, 2018 14:59
Copy link
Member

@milseman milseman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stdlib-side LGTM

/// BridgeObject masks
#ifdef __x86_64__
// x86-64 uses a different #define from the others
#define _swift_BridgeObject_TaggedPointerBits SWIFT_ABI_X86_64_BRIDGEOBJECT_TAG
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part doesn't really make sense either. BridgeObject just always uses the high bit as a tag, regardless of what the underlying tagged pointer mechanism uses.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I think I was too caught up in how it was previously defined. I've redone it to be totally separate from anything ObjC.

@mikeash mikeash force-pushed the reserved-bits-refinement branch from 2d97218 to 95f5058 Compare September 27, 2018 21:16
@mikeash
Copy link
Contributor Author

mikeash commented Sep 27, 2018

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 8ec3f75dec822ca3f803b8c90eed39e3586b676d

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 8ec3f75dec822ca3f803b8c90eed39e3586b676d

@@ -180,6 +197,15 @@ static_assert(alignof(HeapObject) == alignof(void*),
(__swift_uintptr_t) SWIFT_ABI_DEFAULT_OBJC_RESERVED_BITS_MASK
#define _swift_abi_ObjCReservedLowBits \
(unsigned) SWIFT_ABI_DEFAULT_OBJC_NUM_RESERVED_LOW_BITS

#if defined(__LP64__) || defined(__LLP64__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: I think we've been using __POINTER_WIDTH__ == 64 elsewhere in the runtime.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks! I tried to see what was being used but didn't find that. LP64 is also used in a few places but for more platform-specific purposes, so this is definitely better.

@mikeash mikeash force-pushed the reserved-bits-refinement branch from 95f5058 to 5ba06be Compare October 1, 2018 15:56
@mikeash
Copy link
Contributor Author

mikeash commented Oct 1, 2018

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Oct 1, 2018

Build failed
Swift Test OS X Platform
Git Sha - 95f5058613c0667253ed8b460eddc8f51b3aa215

@swift-ci
Copy link
Contributor

swift-ci commented Oct 1, 2018

Build failed
Swift Test Linux Platform
Git Sha - 95f5058613c0667253ed8b460eddc8f51b3aa215

@mikeash mikeash force-pushed the reserved-bits-refinement branch from 5ba06be to e3594ab Compare October 4, 2018 16:31
@mikeash
Copy link
Contributor Author

mikeash commented Oct 4, 2018

Messed up the 32-bit mask while I was in there, now fixed.

@mikeash
Copy link
Contributor Author

mikeash commented Oct 4, 2018

@swift-ci please test

…atch what the target uses.

Previously we had a single mask for all x86-64 targets which included both the top and bottom bits. This accommodated simulators, which use the top bit, while macOS uses the bottom bit, but reserved one bit more than necessary on each. This change breaks out x86-64 simulators from non-simulators and reserves only the one bit used on each.

rdar://problem/34805348 rdar://problem/29765919
@swift-ci
Copy link
Contributor

swift-ci commented Oct 4, 2018

Build failed
Swift Test Linux Platform
Git Sha - 5ba06be52271cf33ed57ef0b08fea8d4db38b2e8

@mikeash mikeash force-pushed the reserved-bits-refinement branch from e3594ab to fa4178c Compare October 4, 2018 16:34
@swift-ci
Copy link
Contributor

swift-ci commented Oct 4, 2018

Build failed
Swift Test OS X Platform
Git Sha - 5ba06be52271cf33ed57ef0b08fea8d4db38b2e8

@mikeash
Copy link
Contributor Author

mikeash commented Oct 4, 2018

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Oct 4, 2018

Build failed
Swift Test OS X Platform
Git Sha - e3594abf9eb8a79da159f3d6dab7958da01fc72f

@swift-ci
Copy link
Contributor

swift-ci commented Oct 4, 2018

Build failed
Swift Test Linux Platform
Git Sha - e3594abf9eb8a79da159f3d6dab7958da01fc72f

@mikeash
Copy link
Contributor Author

mikeash commented Oct 4, 2018

Tests passed but the Mac run still failed with what looks like a spurious error. Trying again.

@mikeash
Copy link
Contributor Author

mikeash commented Oct 4, 2018

@swift-ci please test os x

@mikeash mikeash merged commit 3c2096f into swiftlang:master Oct 4, 2018
@mikeash mikeash mentioned this pull request Oct 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants