Skip to content

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

Merged
merged 1 commit into from
Nov 8, 2018

Conversation

jckarter
Copy link
Contributor

@jckarter jckarter commented Nov 8, 2018

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

@jckarter
Copy link
Contributor Author

jckarter commented Nov 8, 2018

@swift-ci Please test

@jckarter jckarter requested a review from rjmccall November 8, 2018 00:20
@@ -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)))
Copy link
Contributor

@jrose-apple jrose-apple Nov 8, 2018

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.

@swift-ci
Copy link
Contributor

swift-ci commented Nov 8, 2018

Build failed
Swift Test Linux Platform
Git Sha - 67861dfbb9350d22e68c62e60e57001e72688c32

@jckarter
Copy link
Contributor Author

jckarter commented Nov 8, 2018

@swift-ci Please smoke test Linux

@swift-ci
Copy link
Contributor

swift-ci commented Nov 8, 2018

Build failed
Swift Test OS X Platform
Git Sha - 67861dfbb9350d22e68c62e60e57001e72688c32

@jckarter jckarter force-pushed the more-bridgeobject-xi branch from 67861df to 6700eb7 Compare November 8, 2018 02:30
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
@jckarter jckarter force-pushed the more-bridgeobject-xi branch from 6700eb7 to ff7afcd Compare November 8, 2018 03:03
@jckarter
Copy link
Contributor Author

jckarter commented Nov 8, 2018

@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);
}
Copy link
Contributor

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.

@jckarter jckarter merged commit f58c722 into swiftlang:master Nov 8, 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