Implement Stream.HasOverridenBeginEndXXX#72252
Merged
jkotas merged 2 commits intodotnet:mainfrom Jul 16, 2022
Merged
Conversation
Fixes dotnet/corert#3251. `Stream.HasOverriddenBeginEndRead`/`Stream.HasOverriddenBeginEndWrite` are magic methods that call into the runtime on both CoreCLR and Mono to find out whether `Stream.BeginRead`/`EndRead`/`BeginWrite`/`EndWrite` are overriden on the current class. Since we don't have a runtime in NativeAOT, implement this in the compiler. The answer to this question is expressible in IL: load function pointer to the method virtually and non-virtually and compare. I'm not calling into `FunctionPointerOps` because I can't imagine a scenario where this wouldn't work, but I can be persuaded to call to `FunctionPointerOps` to do the comparison. Should make us pass all System.IO libraries tests.
Member
Author
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Member
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
This seems like a good use case for the proposed methodof() c# operator. |
Member
Author
Methodof is reflection and I don't think we can answer this efficiently with reflection. We would need LoadFunctionPointer and LoadVirtualFunctionPointer from dotnet/roslyn#11475 |
This was referenced Jul 17, 2022
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes dotnet/corert#3251.
Stream.HasOverriddenBeginEndRead/Stream.HasOverriddenBeginEndWriteare magic methods that call into the runtime on both CoreCLR and Mono to find out whetherStream.BeginRead/EndRead/BeginWrite/EndWriteare overriden on the current class.Since we don't have a runtime in NativeAOT, implement this in the compiler. The answer to this question is expressible in IL: load function pointer to the method virtually and non-virtually and compare. I'm not calling into
FunctionPointerOpsbecause I can't imagine a scenario where this wouldn't work, but I can be persuaded to call toFunctionPointerOpsto do the comparison.Should make us pass all System.IO libraries tests.
Cc @dotnet/ilc-contrib