-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Teach RemoteMirror how to project enum values #30161
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
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c4ccfef
[Reflection] Start roughing out a swift_reflection_projectEnum function.
mikeash 54de767
Merge remote-tracking branch 'github-mikeash/reflection-projectenum' …
tbkka 0dd6556
Teach RemoteMirror how to project enum values
tbkka 9e7994c
Move XI pointer configuration down to DLQ
tbkka 78f3b29
Select pointer configuration based on compile-time settings.
tbkka 0ddcf8f
Rename file
tbkka 118efad
Use Function ptr XI calculations for Thin Func ptrs
tbkka 142b5f1
Fix finding the most-capacious field
tbkka e8db4af
Use 64-bit field for 8-byte pointers.
tbkka 0abd2ef
Fix spelling `wordSize` => `WordSize`
tbkka 9b72a3e
Move readExtraInhabitantIndex into the `.cpp` file
tbkka d763b65
Fix use of Apple target macros
tbkka 89048d9
Flesh out this test with 32-bit and 64-bit options, verify that multi…
tbkka bb87e63
Merge branch 'master' into tbkka-remoteMirror-projectEnum
tbkka 2e2ad42
Merge branch 'master' into tbkka-remoteMirror-projectEnum
tbkka bc2131f
Fill in, simplify test cases
tbkka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,6 +106,7 @@ enum class TypeInfoKind : unsigned { | |
| Builtin, | ||
| Record, | ||
| Reference, | ||
| Invalid, | ||
| }; | ||
|
|
||
| class TypeInfo { | ||
|
|
@@ -124,6 +125,10 @@ class TypeInfo { | |
| assert(Alignment > 0); | ||
| } | ||
|
|
||
| TypeInfo(): Kind(TypeInfoKind::Invalid), Size(0), Alignment(0), Stride(0), | ||
| NumExtraInhabitants(0), BitwiseTakable(true) { | ||
| } | ||
|
|
||
| TypeInfoKind getKind() const { return Kind; } | ||
|
|
||
| unsigned getSize() const { return Size; } | ||
|
|
@@ -134,11 +139,24 @@ class TypeInfo { | |
|
|
||
| void dump() const; | ||
| void dump(FILE *file, unsigned Indent = 0) const; | ||
|
|
||
| // Using the provided reader, inspect our value. | ||
| // Return false if we can't inspect value. | ||
| // Set *inhabitant to <0 if the value is valid (not an XI) | ||
| // Else set *inhabitant to the XI value (counting from 0) | ||
| virtual bool readExtraInhabitantIndex(remote::MemoryReader &reader, | ||
| remote::RemoteAddress address, | ||
| int *index) const { | ||
| return false; | ||
| } | ||
|
|
||
| virtual ~TypeInfo() { } | ||
| }; | ||
|
|
||
| struct FieldInfo { | ||
| std::string Name; | ||
| unsigned Offset; | ||
| int Value; | ||
| const TypeRef *TR; | ||
| const TypeInfo &TI; | ||
| }; | ||
|
|
@@ -155,6 +173,10 @@ class BuiltinTypeInfo : public TypeInfo { | |
| return Name; | ||
| } | ||
|
|
||
| bool readExtraInhabitantIndex(remote::MemoryReader &reader, | ||
| remote::RemoteAddress address, | ||
| int *extraInhabitantIndex) const; | ||
|
|
||
| static bool classof(const TypeInfo *TI) { | ||
| return TI->getKind() == TypeInfoKind::Builtin; | ||
| } | ||
|
|
@@ -178,6 +200,10 @@ class RecordTypeInfo : public TypeInfo { | |
| unsigned getNumFields() const { return Fields.size(); } | ||
| const std::vector<FieldInfo> &getFields() const { return Fields; } | ||
|
|
||
| bool readExtraInhabitantIndex(remote::MemoryReader &reader, | ||
| remote::RemoteAddress address, | ||
| int *index) const; | ||
|
|
||
| static bool classof(const TypeInfo *TI) { | ||
| return TI->getKind() == TypeInfoKind::Record; | ||
| } | ||
|
|
@@ -206,6 +232,16 @@ class ReferenceTypeInfo : public TypeInfo { | |
| return Refcounting; | ||
| } | ||
|
|
||
| bool readExtraInhabitantIndex(remote::MemoryReader &reader, | ||
| remote::RemoteAddress address, | ||
| int *extraInhabitantIndex) const { | ||
| if (getNumExtraInhabitants() == 0) { | ||
| *extraInhabitantIndex = -1; | ||
| return true; | ||
| } | ||
| return reader.readHeapObjectExtraInhabitantIndex(address, extraInhabitantIndex); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suspect |
||
| } | ||
|
|
||
| static bool classof(const TypeInfo *TI) { | ||
| return TI->getKind() == TypeInfoKind::Reference; | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think this API is redundant. In the C API, we already have swift_reflection_childOfTypeRef()