Skip to content

Add interface for lookup up of externally stored type descriptors #69556

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 4 commits into from
Nov 9, 2023

Conversation

augusto2112
Copy link
Contributor

Currently, TypeRefBuilder knows how to parse type descriptors from reflection metadata. We aim to store the same information that lives in type descriptors externally, as an effort to support embedded Swift debugging. In order to take advantage of all of the existing type information parsing code that exists today in remote mirrors, add an interface for external lookup of type descriptors, and replace all the usages of type descriptors with their generic counterpart (this patch only adds support for builtin descriptors, but follow up patches will add support for other descriptor types).

@augusto2112
Copy link
Contributor Author

@slavapestov this is my approach for looking up descriptors that live outside of reflection metadata. With this approach we can keep the entire type information building logic inside remote mirrors, and only implement in LLDB the logic to look up the descriptors.

@augusto2112
Copy link
Contributor Author

@swift-ci smoke test

@augusto2112 augusto2112 marked this pull request as ready for review November 2, 2023 01:50
@augusto2112 augusto2112 requested a review from a team as a code owner November 2, 2023 01:50
@augusto2112
Copy link
Contributor Author

swiftlang/llvm-project#7741

@swift-ci smoke test

@augusto2112
Copy link
Contributor Author

@swift-ci smoke test

@augusto2112
Copy link
Contributor Author

@swift-ci smoke test

Separate the functionality that reads descriptors from reflection
information into its own class.
@augusto2112 augusto2112 force-pushed the builtin-interface branch 2 times, most recently from 0c212b3 to d739887 Compare November 5, 2023 14:26
@augusto2112
Copy link
Contributor Author

@swift-ci smoke test

Copy link
Contributor

@adrian-prantl adrian-prantl left a comment

Choose a reason for hiding this comment

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

In general I think this looks promising, but the diff is so large due to the formatting changes that it's a bit difficult to review.

struct DescriptorFinder {
virtual ~DescriptorFinder(){};

virtual std::unique_ptr<BuiltinTypeDescriptorInterface>
Copy link
Contributor

Choose a reason for hiding this comment

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

Performance-wise, you could design the base class to already have all the data members needed by all implementations, maybe with an opaque element for implementation-specific data, then you could pass a stack-allocated object through this interface and don't need to use unique_ptr here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Personally I don't think the performance benefits would be worth the extra complexity. There's already indirection going on today when using RemoteRef, and there will be a pretty big difference in size between the DWARF version and the reflection version, so accommodating both on the base class would look a bit ugly imo.

Copy link
Contributor

Choose a reason for hiding this comment

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

If this is only used in the debugger and similar clients, I think that's reasonable. If it's used in-process then I'm not sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is only used for out of process inspection.

@augusto2112
Copy link
Contributor Author

@swift-ci smoke test

NormalizedReflectionNameCache;

/// Cache for built-in type descriptor lookups.
std::unordered_map<std::string /* normalized name */,
Copy link
Contributor

Choose a reason for hiding this comment

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

Not for this patch, but since we have LLVM here, this should probably be a StringMap for better efficiency. Same for all the other caches.

@augusto2112
Copy link
Contributor Author

@swift-ci test

@augusto2112
Copy link
Contributor Author

@swift-ci smoke test

Currently, TypeRefBuilder knows how to parse type descriptors from
reflection metadata. We aim to store the same information that lives
in type descriptors externally, as an effort to support embedded Swift
debugging. In order to take advantage of all of the existing type
information parsing code that exists today in remote mirrors, add an
interface for external lookup of type descriptors, and replace all the
usages of type descriptors with their generic counterpart (this patch
only adds support for builtin descriptors, but follow up patches will
add support for other descriptor types).
@augusto2112
Copy link
Contributor Author

@swift-ci smoke test

@augusto2112 augusto2112 merged commit 9f33d3e into swiftlang:main Nov 9, 2023
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