-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Fix swift_bridgeObjectRetain() dropping integer bits #84609
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
base: main
Are you sure you want to change the base?
Fix swift_bridgeObjectRetain() dropping integer bits #84609
Conversation
In particular this was breaking deferred type-checking of arrays. Regression was introduced in swiftlang@724a9a7
|
Which bits are these? |
|
This flag in
Set e.g. here:
And later read here: swift/stdlib/public/core/Array.swift Line 755 in 7088022
As a result of this bug, deferred type checking was forgotten when copying let arr = ["abc" as NSString, "xyz" as NSString]
// native.storesOnlyElementsOfType(TargetElement.self) returns false
// constructs array with deferred type checking
let x = arr as! [@convention(block) () -> Void]
_ = x[0] // triggers assertion, as expected
let y = x // calls `swift_bridgeObjectRetain()`, but does not use it's result
_ = y[0] // also triggers assertion
var iter = x.makeIterator() // calls `swift_bridgeObjectRetain()` and stores result inside the iterator
_ = iter.next() // does not trigger assertion, returning `NSString` bit-casted to block. |
|
@swift-ci Please smoke test |
|
Got it, thanks for the explanation. I'm worried that making |
|
@swift-ci please Apple Silicon benchmark |
|
We can still make a tail call if New function ( We could ensure tail calls for |
|
The new function would take and return |
|
Thinking a little more, we may be able to just make |
|
I'm working on putting the fast paths of retain/release into a library that can be linked into users, which improves performance. I tried adding this fix to my changes there. I made it so |
|
I just put up a proper PR with my changes here: #85044 Although it's focused on providing optimized retain/release implementations that can be linked into clients, it does also fix the runtime's own |
In particular this was breaking deferred type-checking of arrays.
Regression was introduced in 724a9a7