-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Implement projectExistentialAndUnwrapClass #37673
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
Implement projectExistentialAndUnwrapClass #37673
Conversation
15eff2b
to
9d9b4c2
Compare
This looks good, it would be great if we could also add a test similar to the other reflection tests in the validation test suite. |
@swift-ci test |
Please make sure to also cherry-pick this to the |
Build failed |
Seems like macOS testing hung after running all tests?
Doesn't seems to be related to the test I changed:
|
@swift-ci test |
Build failed |
Looks like there's one real failure on 32-bit watchsimulator: |
123b97c
to
f732eee
Compare
@swift-ci test |
Build failed |
f732eee
to
45dd83b
Compare
@swift-ci test |
We are going to need to swift-ci nominate this. Can you edit the PR description to include a block with more context (for example like #37493) and call out that this only adds a new API for LLDB and has no efrect on the compiler? |
Since I refactored |
It is probably a good idea to move out the NFC refactoring into a separate patch anyway, so why not do that? It makes the decision to take the remaining patch easier when it has a smaller surface area. |
8e772c1
to
d85ae9b
Compare
@swift-ci test |
@swift-ci please nominate |
Build failed |
d85ae9b
to
21863e3
Compare
Looks like I accidentally reversed one of the fixes I made to the |
@swift-ci test |
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. DereferenceAndSet
confused me momentarily, but I think I like it now.
/// may derefence and set OutStartOfInstanceData if OutInstanceTypeRef is a | ||
/// class TypeRef. | ||
SWIFT_REMOTE_MIRROR_LINKAGE | ||
int swift_reflection_projectExistentialAndUnwrapClass( |
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.
Where is this used?
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.
This is used in swift-reflection-test.c
so we can access it from the existentials.swift
test.
Implement a version of projectExistential tailored for LLDB. There are 2 differences when projecting existentials for LLDB: 1 - When it comes to existentials, LLDB stores the address of the error pointer, which must be dereferenced. 2 - When the existential wraps a class type, LLDB expects the address returned is the class instance itself and not the address of the reference. This patch also adapts the swift reflection test machinery to test projectExistentialAndUnwrapClass as well. This is done by exposing the new functionality from swift reflection test. It is tested in existentials.swift, and ensures that the typeref information is exactly the same as what is expected from projectExistential, except the out address.
21863e3
to
e36e8ee
Compare
@swift-ci test |
Explanation: Adds a new function,
projectExistentialAndUnwrapClass
, which behaves likeprojectExistential
but is tailored for LLDB, so LLDB can find the dynamic type of objects using reflection.Scope: The new function behaves like
projectExistential
, except for the following differences:1 - When it comes to existentials, LLDB stores the address of the error
pointer, which must be dereferenced before further processing.
2 - When the existential wraps a class type, LLDB expects the address
returned is the class instance itself and not the address of the
reference.
Risk: Low, this change is purely additive.
Testing: Modified /validation-test/Reflection/existentials.swift to test the new functionality.
Issue: rdar://55412978
Reviewer: Adrian Prantl (@adrian-prantl)