-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Replace rethrowing map with generic typed throws #69771
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 smoke test |
@swift-ci please build toolchain |
Note that we expect some tests to fail here, because I haven't updated the expected output in a number of places. |
(Only the last two commits are actually new) |
Generally we provide these legacy ABI entrypoints via |
I prefer The |
@swift-ci please smoke test |
How fun. It's very crashy on Intel, yet fine on Apple Silicon. Time for some low-level debugging. |
We will need to be careful about this pattern going forward because one of the features I've been working on that was recently enabled on |
That’s a massively ABI breaking change that will need to go through evolution, even if it is desirable. I agree that’s probably what unavailable should have meant, but in practice it’s not what it ever has meant. |
b85412a
to
1f394c5
Compare
@swift-ci please smoke test |
x86 miscompile is addressed by #69819 |
A couple more cleanups peeled off this and put into #69824 |
1f394c5
to
3d84493
Compare
@swift-ci please smoke test |
@swift-ci please build toolchain |
Do we understand where the large changes in the two MapReduce benchmarks come from? |
It's probably because function signature optimization is disabled for indirect throws (Though I didn't verify that assumption) |
@swift-ci please smoke test |
@swift-ci please smoke test macOS |
6e88252
to
2e22518
Compare
@swift-ci please test |
@swift-ci please test source compatibility |
@swift-ci please benchmark |
I've rebased this PR and am re-running all of the tests, now that SE-0413 has been accepted and typed throws has been enabled by default |
@swift-ci please test source compatibility |
2e22518
to
29bc981
Compare
29bc981
to
e11bfc7
Compare
Adopt typed throws for the `map` operation to propagate thrown error types through the `map` API. This is done in a manner that is backward compatible for almost all cases: * The new typed-throws entrypoint is `@_alwaysEmitIntoClient` so it can back-deploy all the way back. * The old `rethrows` entrypoint is left in place, using `@usableFromInline` with `internal` so it is part of the ABI but not the public interface, and `@_disfavoredOverload` so the type checker avoids it while building the standard library itself. The old entrypoint is implemented in terms of the new one. Note that the implementation details for the existential collection "box" classes rely on method overriding of `_map` operations, and the types are frozen, so we don't get to change their signatures. However, these are only implementations, not API: the actual API `map` functions can be upgraded to typed throws. Note that this code makes use of a known hole in `rethrows` checking to allow calling between `rethrows` and typed throws. We'll need to do something about this for source-compatibility reasons, but I'll follow up with that separately.
Replace the hackish use of `@_disfavoredOverload` with the more principled use of `@_silgen_name` for the entrypoint we are maintaining, then rename these functions in source to `__rethrows_map` to indicate what they're for. While here, make them `throws` instead of `rethrows`. The ABI is the same, and `throws` allows us do avoid to do/catch tricks with rethrows functions.
…rows These class methods are internal, but because they are overridden and are part of a `@usableFromInline`, `@_fixed_layout` class, we they can't be moved over to typed throws without breaking ABI. However, they are only ever called from typed-throws functions, which already need a do...catch dance to downcast the error itself. Make them `throws` instead, which is ABI-compatible, but eliminates the need for do...catch hackery in the function itself.
SIL opaque values do not yet support typed throws, so avoid the API that uses them.
e11bfc7
to
d21c649
Compare
@swift-ci please test |
@swift-ci please test source compatibility |
@swift-ci please smoke test |
@swift-ci please test source compatibility |
swiftlang/swift-package-manager#7249 @swift-ci please test source compatibility |
The swift-testing failure involves the C++ standard library; nothing to do with typed throws. Time to merge! |
Adopt typed throws for the
map
operation to propagate thrown errortypes through the
map
API. The newmap
has a signature like this:This is done in a manner that is backward compatible for almost all cases:
@_alwaysEmitIntoClient
so it can back-deploy all the way back.rethrows
entrypoint is left in place, using@usableFromInline
withinternal
so it is part of the ABI but not the public interface,@_silgen_name
so it has the right name in the binary, and a new name__rethrows_map
so it's otherwise out of the way. The old entrypoint is implemented in terms of the new one.Note that the implementation details for the existential collection "box" classes rely on method overriding of
_map
operations, and the types are frozen, so we don't get to change their signatures. However, these are only implementations, not API: the actual APImap
functions can be upgraded to typed throws.Note that this code makes use of a known hole in
rethrows
checking to allow calling betweenrethrows
and typed throws. We'll need to do something about this for source-compatibility reasons, but I'll follow up with that separately.