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

Integration of changes in shared files from runtimelab/NativeAOT #61655

Merged
merged 8 commits into from
Nov 19, 2021

Conversation

MichalStrehovsky
Copy link
Member

No description provided.

else if (type.IsSequentialLayout || type.IsEnum || type.Context.Target.Abi == TargetAbi.CppCodegen)
// Sequential layout has to be respected for blittable types only. We use approximation and respect it for
// all types without GC references (ie C# unmanaged types). Universal canonical instances might be blittable.
else if (type.IsSequentialLayout && (type.IsCanonicalSubtype(CanonicalFormKind.Universal) || !type.ContainsGCPointers))
Copy link
Member

Choose a reason for hiding this comment

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

The field offsets in universal type have to match the field offsets of all non-universal types; or the field offset in universal type has to be undermined. This condition violates that invariant.

I am wondering whether it would be better to disable the tests for universal layout instead of adding this change that makes the tests work, but does not actually make the code work correctly.

Copy link
Member Author

Choose a reason for hiding this comment

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

We can key off SupportsUniversalCanon to do the old thing. I think that's what we'll have to do if we ever activate universal canon here.

@@ -92,6 +92,7 @@ protected internal virtual TypeDesc ConvertToCanon(TypeDesc typeToConvert, Canon
throw new NotSupportedException();
}

internal partial void InternalGetSupportsUniversalCanon(ref bool flag) => flag = SupportsUniversalCanon;
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need this ugly hack?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because Canon support is in partial files, we don't force canon support on every user of the type system, and ILVerify doesn't include it.

Copy link
Member

Choose a reason for hiding this comment

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

Would it better to fix this by moving the ComputeInstanceFieldLayout into the concrete type systems and leave it abstract in the base one?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about it, but that would basically mean that the change we're doing now (changing qualification for Sequential layout) would not be automatically reflected in unit tests because tests don't use the compiler type system context. So the logic would not be exercised at all unless we don't forget to keep it in sync.

Copy link
Member

Choose a reason for hiding this comment

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

I think that it is ok. There is no one right way to do field layout, so it makes sense to allow it to be configurable and unit tests testing a subset of the possible configurations.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, in that case I'll redo this on the NativeAOT side. Test changes won't be needed because we can just keep using the old logic.

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

Sign up for free to 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.

2 participants