Skip to content
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

New CoreLib Symbols support #592

Merged
merged 19 commits into from
Sep 14, 2024
Merged

New CoreLib Symbols support #592

merged 19 commits into from
Sep 14, 2024

Conversation

wasabii
Copy link
Contributor

@wasabii wasabii commented Sep 13, 2024

Provides IKVM.CoreLib.Symbols, which contains facades for all of the reflection-like entities used: ITypeSymbol, IAssemblySymbol, etc. These interfaces are then implemented for System.Reflection and IKVM.Reflection. This allows us to start untying the Runtime from the IFDEFs that change which reflection interface is used.

There some overhead here since we're wrapping the entire APIs with interfaces. Virtual dispatch. But, we might be able to actually eak out some performance improvements with caching.

Additionally, now we have an API surface we can start evolving differently than System.Reflection. Once we start narrowing the interface down, removing the methods we do not use, etc, we might be able to add higher level more focused methods that we could then go directly to System.Reflection.Metadata for, ditching IKVM.Reflection completely.

@wasabii wasabii marked this pull request as ready for review September 13, 2024 01:56
@wasabii
Copy link
Contributor Author

wasabii commented Sep 13, 2024

Some obvious first things might be to eliminate the array copies that come from GetMethods, GetTypes, etc. System.Reflection mandates that these calls return a new array each time. And the caller is allowed to modify it. And IKVM does this in a few places. But, we could convert these to ImmutableArrays, and cache the results, reducing the number of array copies made, and let IKVM code make copies as it requires.

Other things is perhaps sorting. .NET <= 6 does not require GetTypes or GetMethods etc to be sorted. But it looks like in .NET 7 these are now sorted. So, we could potentially sort only on < 6 and cache the results, but not sort on > 7 where it's guarenteed already sorted.

@wasabii wasabii merged commit b9ffe68 into develop Sep 14, 2024
1 check passed
@wasabii wasabii deleted the symbols branch September 14, 2024 03:06
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.

1 participant