-
Notifications
You must be signed in to change notification settings - Fork 10.5k
IRGen: initial pass to support async
inheritance on Windows
#39998
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 Windows platform |
I looked over the uses of i.e. I think it is fine to leave the code below as a target relative direct pointer because what will happen is that we will "copy" the indirect pointer (after resolving the relative computation) during the initClassVTable computation and any use of that indirect pointer is going to be handled by codegen (just as we would for the static vtable we emit for regular classes).
|
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.
lgtm
142ca42
to
1ae89a4
Compare
With PE/COFF, one cannot reference a data symbol directly across the binary module boundary. Instead, the reference must be indirected through the Import Address Table (IAT) to allow for position independence. When generating a reference to a AsyncFunctionPointer ({i8*, i32}), we tag the pointer as being indirected by tagging bit 1 (with the assumption that native alignment will ensure 4/8 byte alignment, freeing the bottom 2 bits at least for bit-packing). We tweak the v-table/witness table emission such that all references to the AsyncFunctionPointer are replaced with the linker synthetic import symbol with the bit packing: ~~~ .quad __imp_$s1L1CC1yyYaKFTu+1 ~~~ rather than ~~~ .quad $s1L1CC1yyYaKFTu ~~~ Upon access of the async function pointer reference, we open-code the check for the following: ~~~ pointer = (pointer & 1) ? *(void **)(pointer & ~1) : pointer; ~~~ Thanks to @DougGregor for the discussion and the suggestion for the pointer tagging. Thanks to @aschwaighofer for pointers to the code that I had missed. Also, thanks to @SeanROlszewski for the original code sample that led to the reduced test case. Fixes: SR-15399
1ae89a4
to
68bc33f
Compare
@swift-ci please test |
Build failed |
Tweak test for macOS
@swift-ci please test |
Build failed |
@swift-ci please test Linux platform |
Build failed |
@swift-ci please clean test Linux platform |
Great to see this addressed already. Thank you for driving the fix, @compnerd! |
With PE/COFF, one cannot reference a data symbol directly across the
binary module boundary. Instead, the reference must be indirected
through the Import Address Table (IAT) to allow for position
independence.
When generating a reference to a AsyncFunctionPointer ({i8*, i32}), we
tag the pointer as being indirected by tagging bit 1 (with the
assumption that native alignment will ensure 4/8 byte alignment, freeing
the bottom 2 bits at least for bit-packing). We tweak the
v-table/witness table emission such that all references to the
AsyncFunctionPointer are replaced with the linker synthetic import
symbol with the bit packing:
rather than
Upon access of the async function pointer reference, we open-code the
check for the following:
Thanks to @DougGregor for the discussion and the suggestion for the
pointer tagging. Thanks to @aschwaighofer for pointers to the code that
I had missed. Also, thanks to @SeanROlszewski for the original code
sample that led to the reduced test case.
Fixes: SR-15399
Replace this paragraph with a description of your changes and rationale. Provide links to external references/discussions if appropriate.
Resolves SR-NNNN.