-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Give more extra inhabitants to BridgeObject. #20416
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
Conversation
@swift-ci Please test |
@@ -167,5 +190,10 @@ tests.test("types that have extra inhabitants") { | |||
expectHasExtraInhabitant(GenericFullHouse<UnsafeRawPointer, UnsafeRawPointer>.self, nil: nil) | |||
} | |||
|
|||
tests.test("types that have more than one extra inhabitant") { | |||
expectHasAtLeastThreeExtraInhabitants(StringAlike64.self, nil: nil, someNil: .some(nil), someSomeNil: .some(.some(nil))) | |||
expectHasAtLeastThreeExtraInhabitants(StringAlike32.self, nil: nil, someNil: .some(nil), someSomeNil: .some(.some(nil))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably also worth checking that a non-nil object doesn't have the same representation as any of the nils. In particular, _bridgeObject(taggingPayload: 0)
and _bridgeObject(taggingPayload: 1)
are probably worth checking.
Build failed |
@swift-ci Please smoke test Linux |
Build failed |
67861df
to
6700eb7
Compare
The standard library never ended up needing the low extra inhabitants (<4G on 64-bit Darwin, <4K elsewhere), so BridgeObject can have the same set of extra inhabitants as the other refcounted types, allowing `String?????` and `Array??????????` to still use optimized representations. rdar://problem/45881464
6700eb7
to
ff7afcd
Compare
@swift-ci Please smoke test |
// There's only one extra inhabitant, 0. | ||
dest = IGF.Builder.CreateBitCast(dest, IGF.IGM.SizeTy->getPointerTo()); | ||
IGF.Builder.CreateStore(llvm::ConstantInt::get(IGF.IGM.SizeTy, 0), dest); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I understand why this works. As long as we're staying out of the reserved bits for tagged pointers (including BridgeObject's own notion of tagged pointers) — which the superclass implementation does — it doesn't matter if we're intruding on the BridgeObject representation because the rest of the pointer still needs to be in the valid range for objects.
The standard library never ended up needing the low extra inhabitants (<4G on 64-bit Darwin,
<4K elsewhere), so BridgeObject can have the same set of extra inhabitants as the other refcounted
types, allowing
String?????
andArray??????????
to still use optimized representations.rdar://problem/45881464