Skip to content

RemoteAST fixes #22502

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
merged 5 commits into from
Feb 12, 2019
Merged

RemoteAST fixes #22502

merged 5 commits into from
Feb 12, 2019

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Feb 11, 2019

In the service of apple/swift-lldb#1286. Replacing lldb's existing existential projection code path with RemoteAST exposed some limitations in the latter.

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov slavapestov requested review from rjmccall and dcci and removed request for rjmccall February 11, 2019 06:22
/// pointer to its metadata address, its value address, and whether this
/// is a toll-free-bridged NSError or an actual Error existential wrapper
/// around a native Swift value.
Optional<std::tuple<RemoteAddress, RemoteAddress, bool>>
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider just making a struct, especially since this type is used multiple places throughout the reader.

@@ -104,7 +104,9 @@ class RemoteASTContextImpl {
getDeclForRemoteNominalTypeDescriptor(RemoteAddress descriptor) = 0;
virtual Result<RemoteAddress>
getHeapMetadataForObject(RemoteAddress object) = 0;
virtual Result<std::pair<Type, RemoteAddress>>
virtual OpenedExistential
getDynamicTypeAndAddressForError(RemoteAddress object) = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

The pattern was that all of these were Result-ified.

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

apple/swift-lldb#1287
@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

apple/swift-lldb#1287
@swift-ci Please smoke test macOS

@slavapestov
Copy link
Contributor Author

Looks like this breaks LLDB without my larger set of LDLB changes. I'm breaking out #22534 to fix the tagged pointer issue.

An Error existential value can directly store a
reference to an NSError instance without wrapping
it in an Error container.

When "projecting" such an existential, the dynamic type
is the NSError's isa pointer, and the payload is the
address of the instance itself.
LLDB calls getDynamicTypeAndAddressForExistential() on an existential
value without knowing if its a class existential or opaque existential.

Class existentials return the address of the instance itself here,
whereas opaque existentials always returned the address of the
payload value.

This meant the caller could not usefully operate on the payload value
if it was of class type, because there was no way of knowing if the
extra dereference had occurred or not.

Now, always load the reference if the wrapped type is a class, even
if the existential is opaque.

Will be tested on the lldb side with another change I'm working on.
The getDynamicTypeAndAddressForExistential() function takes the
address of an existential value; so when looking at an Error,
this is the address of the reference, not the address of the
instance.

lldb needs to look at Error instances too, so add a new entry
point named getDynamicTypeAndAddressForError() which avoids the
extra dereference.

This will be tested on the lldb side.
@slavapestov
Copy link
Contributor Author

apple/swift-lldb#1287
@swift-ci Please smoke test

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.

2 participants