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

Put Crossgen2 in sync with #54235 #54438

Merged
merged 5 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -782,10 +782,9 @@ public LayoutInt CalculateFieldBaseOffset(MetadataType type, bool requiresAlign8
if (!type.IsValueType && type.HasBaseType)
{
cumulativeInstanceFieldPos = type.BaseType.InstanceByteCountUnaligned;
if (!type.BaseType.InstanceByteCountUnaligned.IsIndeterminate)
if (!cumulativeInstanceFieldPos.IsIndeterminate)
{
cumulativeInstanceFieldPos = type.BaseType.InstanceByteCountUnaligned;
if (type.BaseType.IsZeroSizedReferenceType && ((MetadataType)type.BaseType).HasLayout())
Copy link
Member

Choose a reason for hiding this comment

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

Can IsZeroSizedReferenceType propety be deleted as well? It does not appear to be used anywhere after this change.

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 suspect we still need to do something about the zero-sized layout types because runtime artificially bumps up their size to 1 even though it rolls back the change when calculating the layout for a derived type. I guess that, as a first step, I need to see how the Pri1 tests look on the different architectures after my change. Other than that, I was under the impression that IsZeroSizedReferenceType was a pre-existing NativeAOT construct, not a Crossgen2-specific addition, but I may be mistaken about this.

Copy link
Member

Choose a reason for hiding this comment

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

IsZeroSizedReferenceType was added in #46769

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for sharing the link to the original PR. ARM tests are already failing in the Pri1 tests exactly because of the missing zero-sized layout compensation, I believe the trick is not about removing the check but figuring out the proper place for it, that's my next step.

if (requiresAlignedBase && type.BaseType.IsZeroSizedReferenceType && ((MetadataType)type.BaseType).HasLayout())
{
cumulativeInstanceFieldPos += LayoutInt.One;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public static bool IsBlittableType(TypeDesc type)
&& !baseType.IsWellKnownType(WellKnownType.Object)
&& !baseType.IsWellKnownType(WellKnownType.ValueType);

// Type is blittable only if parent is also blittable and is not empty.
if (hasNonTrivialParent && (!IsBlittableType(baseType) || baseType.IsZeroSizedReferenceType))
// Type is blittable only if parent is also blittable.
if (hasNonTrivialParent && !IsBlittableType(baseType))
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ public void IsBlittableType_TypeWithBlittableBase_ReturnsTrue(string className)
[InlineData("ClassWithExplicitEmptyBase")]
[InlineData("ClassWithExplicitEmptySizeZeroBase")]
[InlineData("ClassWithSequentialEmptyBase")]
public void IsBlittableType_TypeWithEmptyBase_ReturnsFalse(string className)
public void IsBlittableType_TypeWithEmptyBase_ReturnsTrue(string className)
{
TypeDesc classWithEmptyBase = _testModule.GetType("Marshalling", className);
Assert.False(MarshalUtils.IsBlittableType(classWithEmptyBase));
Assert.True(MarshalUtils.IsBlittableType(classWithEmptyBase));
}
}
}
3 changes: 0 additions & 3 deletions src/tests/issues.targets
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@
<ExcludeList Include="$(XunitTestBinBase)/tracing/eventpipe/eventsvalidation/ThreadPool/*">
<Issue>https://github.com/dotnet/runtime/issues/48727</Issue>
</ExcludeList>
<ExcludeList Include="$(XunitTestBinBase)/Interop/LayoutClass/LayoutClassTest/*">
<Issue>https://github.com/dotnet/runtime/issues/54316</Issue>
</ExcludeList>
</ItemGroup>

<!-- All Unix targets on all runtimes -->
Expand Down