Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Moves ByReference to shared CoreLib #21633

Merged
merged 2 commits into from
Dec 21, 2018
Merged

Moves ByReference to shared CoreLib #21633

merged 2 commits into from
Dec 21, 2018

Conversation

marek-safar
Copy link

No description provided.

@@ -11,26 +11,31 @@ namespace System
// around lack of first class support for byref fields in C# and IL. The JIT and
// type loader has special handling for it that turns it into a thin wrapper around ref T.
[NonVersionable]
internal readonly ref struct ByReference<T>
internal readonly ref partial struct ByReference<T>
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Does it need to be partial?

Copy link
Author

Choose a reason for hiding this comment

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

CoreRT has an additional attribute on this type so I made it partial for that reason

Copy link
Member

Choose a reason for hiding this comment

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

That attribute was a quick workaround. It should not be needed anymore. And if it is still needed I would rather put it under #if PROJECTN ifdef so that it is easy to remove. We do not bother refactoring files into partial classes just to apply temporary TODO workarounds.

cc @MichalStrehovsky

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, maybe it's not needed anymore. I've put it in dotnet/corert#3000. It should have been cleaned up when the Project N side was fixed up to support TypedReference. We'll see in the next integration and then I'll deal with it.

Copy link
Member

Choose a reason for hiding this comment

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

@jkotas Making this a readonly struct broke the contract of the class library with the code generator backend in ProjectN. I'm getting asserts in some UTC macros in precheckin. Since I don't see value in sharing this implementation detail, and I doubt I can get anyone from the UTC team to look at it, what's the cleanest way to make CoreRT opt out of participating in the sharing scheme for this file? (I don't think ridding this file with ifdefs would look great.)

We can revisit if not having ByReference<T> marked readonly is ever a problem.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think ridding this file with ifdefs would look great

Ifdefs as workarounds for bugs are fine. I do not think we need to be doing refactorings to make workarounds look pretty. Workarounds for bugs are never pretty. We always had some of these workaround PROJECTN ifdefs and kept adding and removing them as necessary.

Marking `ByReference as readonly makes the IL generated for Span and friends leaner. The IL for Span has extra locals when ByReference is not marked readonly.

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Thanks!

@MarcoRossignoli
Copy link
Member

@jkotas why this move?Some new feature?

@jkotas
Copy link
Member

jkotas commented Dec 21, 2018

@MarcoRossignoli This change contributes to https://github.com/dotnet/coreclr/issues/17904 and related issues.

For engineering efficiency, we want to have all CoreLib code that is shareable between CoreCLR, Mono and CoreRT runtimes to be in the shared CoreLib partition.

@jkotas jkotas merged commit cc68e4a into dotnet:master Dec 21, 2018
@jkotas
Copy link
Member

jkotas commented Dec 21, 2018

@Anipik Is the CoreLib mirror running?

@Anipik
Copy link

Anipik commented Dec 21, 2018

I made some changes to the mirror to add a unidirectional mirror for mono..that might have caused mirror to stop. I am out of office with no way to connect to the remote machine. I will resolve the issue in the evening or tomorrow

@jkotas
Copy link
Member

jkotas commented Dec 21, 2018

No worries. Thanks!

Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corefx that referenced this pull request Dec 22, 2018
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corert that referenced this pull request Dec 22, 2018
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/mono that referenced this pull request Dec 22, 2018
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
jkotas pushed a commit to dotnet/corefx that referenced this pull request Dec 22, 2018
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
jkotas pushed a commit to dotnet/corert that referenced this pull request Dec 22, 2018
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
marek-safar added a commit to mono/mono that referenced this pull request Dec 22, 2018
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants