Skip to content

Add an "addressable for dependencies" flag to value witness flags. #82323

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

Conversation

jckarter
Copy link
Contributor

This may be useful for type layout of borrow fields in the future, should we decide that addressable-for-dependencies borrows should always be represented by a pointer. rdar://153650278

@jckarter
Copy link
Contributor Author

@swift-ci Please test

@jckarter jckarter force-pushed the addressable-for-dependencies-vw-flag branch from a439a52 to 16a919e Compare June 17, 2025 23:21
@jckarter
Copy link
Contributor Author

@swift-ci Please test

@jckarter jckarter force-pushed the addressable-for-dependencies-vw-flag branch from 16a919e to 4c5c8e7 Compare June 18, 2025 14:53
@jckarter
Copy link
Contributor Author

@swift-ci Please test

This may be useful for type layout of borrow fields in the future, should we
decide that addressable-for-dependencies borrows should always be represented
by a pointer. rdar://153650278
@jckarter jckarter force-pushed the addressable-for-dependencies-vw-flag branch from 4c5c8e7 to 7e99e84 Compare June 18, 2025 19:47
@jckarter
Copy link
Contributor Author

@swift-ci Please test

@jckarter
Copy link
Contributor Author

@swift-ci Please smoke test Linux

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

LGTM

@rjmccall
Copy link
Contributor

What's the story here for existing value witness tables?

@jckarter
Copy link
Contributor Author

@swift-ci Please test Linux

@jckarter
Copy link
Contributor Author

@rjmccall It seems to me that the borrow representation is likely to require new runtime support, so it's likely to be deployment target limited (though hopefully we can still support back deploying static uses that don't need runtime layout).

However, there should also at least be a limited universe of @frozen standard library and Apple framework types that were retroactively made addressable-for-dependencies, so I was thinking that if we did make the effort to back deploy dynamic borrow layout, we could bake in a list of those types to retroactively apply the flag to. (Though that wouldn't help for non-platform ABI-stable libraries; those would still need to recompile.)

@rjmccall
Copy link
Contributor

@rjmccall It seems to me that the borrow representation is likely to require new runtime support, so it's likely to be deployment target limited (though hopefully we can still support back deploying static uses that don't need runtime layout).

However, there should also at least be a limited universe of @frozen standard library and Apple framework types that were retroactively made addressable-for-dependencies, so I was thinking that if we did make the effort to back deploy dynamic borrow layout, we could bake in a list of those types to retroactively apply the flag to. (Though that wouldn't help for non-platform ABI-stable libraries; those would still need to recompile.)

Is there any problem here for a new OS running existing binaries that haven't been recompiled with the new mode? Do we need a way to recognize that case?

@jckarter
Copy link
Contributor Author

Is there any problem here for a new OS running existing binaries that haven't been recompiled with the new mode? Do we need a way to recognize that case?

@rjmccall Thinking about it for a couple hours… existing binaries wouldn't directly make use of new runtime features, but they could call in to the new OS's libraries, and the new OS could be using new language features that interpret this new bit. The setting of the bit could be different from what a new compiler would generate from the new type; however, code in the new OS can't possibly have static knowledge of the old binary it's running with, so it doesn't seem possible for there to be a static/dynamic layout disagreement. And since the old binary was built in a world where ~Escapable and lifetime dependencies weren't a thing, it shouldn't be possible for new code to return dependent values back to the old code.

So it seems like old binaries would be OK with a new OS, though I could be missing something. Do you have any counterexamples?

Copy link
Contributor

@rjmccall rjmccall left a comment

Choose a reason for hiding this comment

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

Alright. I have some concerns about that impact with existing non-OS libraries, but maybe we can address that with documentation. At any rate, I agree it's better to have this information than not.

The code that's here LGTM, but there's a runtime aspect of this that should at least be tested, and you need to make sure that the preset value witnesses in the runtime have the right values (and that we don't use them for types that disagree).

@jckarter
Copy link
Contributor Author

jckarter commented Jul 1, 2025

I was hoping to tackle the runtime updates separately (and not for the 6.2 branch, since I wanted to minimize risk there). As long as we start emitting binaries so that the bit is set properly, it seems to me we should be able to update the runtime later.

@jckarter jckarter merged commit 1c75d3b into swiftlang:main Jul 1, 2025
5 checks passed
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.

3 participants