Skip to content

Commit

Permalink
Remove the duplicate base type size quirk per JanK's PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
trylek committed Jun 3, 2021
1 parent 642659b commit f14893c
Showing 1 changed file with 0 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,6 @@ protected ComputedInstanceFieldLayout ComputeExplicitFieldLayout(MetadataType ty
// It is calculated as the field whose offset and size add to the greatest value.
LayoutInt offsetBias = !type.IsValueType ? new LayoutInt(type.Context.Target.PointerSize) : LayoutInt.Zero;
LayoutInt cumulativeInstanceFieldPos = CalculateFieldBaseOffset(type, requiresAlign8: false, requiresAlignedBase: false) - offsetBias;
if (!type.IsValueType)
{
// CoreCLR runtime has a bug in field offset calculation in the presence of class inheritance
// and explicit layout: in classlayoutinfo.cpp, the calculated layout adds base class size to
// field offsets (so that they are instance-relative) but HandleExplicitLayout in methodtablebuilder
// treats them as relative to the 'instance slice' which is offset by the base class size once more,
// effectively doubling the base class offset.
cumulativeInstanceFieldPos = cumulativeInstanceFieldPos + cumulativeInstanceFieldPos;
}
LayoutInt instanceSize = cumulativeInstanceFieldPos + offsetBias;

var layoutMetadata = type.GetClassLayout();
Expand Down

0 comments on commit f14893c

Please sign in to comment.