Skip to content

Implement Stream.HasOverridenBeginEndXXX - #72252

Merged
jkotas merged 2 commits into
dotnet:mainfrom
MichalStrehovsky:hasoverriden
Jul 16, 2022
Merged

Implement Stream.HasOverridenBeginEndXXX#72252
jkotas merged 2 commits into
dotnet:mainfrom
MichalStrehovsky:hasoverriden

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

Fixesdotnet/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.

Cc @dotnet/ilc-contrib

Fixesdotnet/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.
@MichalStrehovsky

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-extra-platforms

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@jkotasjkotas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice!

@jkotas

Copy link
Copy Markdown
Member

/azp run runtime-extra-platforms

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@jkotas
jkotas merged commit fae5314 into dotnet:mainJul 16, 2022
@MichalStrehovsky
MichalStrehovsky deleted the hasoverriden branch July 16, 2022 21:21
@TonyValenti

Copy link
Copy Markdown

This seems like a good use case for the proposed methodof() c# operator.

@MichalStrehovsky

Copy link
Copy Markdown
MemberAuthor

This seems like a good use case for the proposed methodof() c# operator

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

Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NS2.0 Implement Synchronized(Stream).BeginRead() and BeginWrite()

3 participants

@MichalStrehovsky@jkotas@TonyValenti