Skip to content

Commit

Permalink
Set BaseSize of interfaces to 0 (#89343)
Browse files Browse the repository at this point in the history
We were computing these as the minimum object size. This number is meaningless because they don't get allocated on the GC heap. A zero compresses better. Surprisingly saves like 0.1% on Hello World despite being such an insignificant thing.
  • Loading branch information
MichalStrehovsky committed Jul 22, 2023
1 parent 2d1e284 commit a2ce877
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,13 @@ protected virtual int BaseSize
int pointerSize = _type.Context.Target.PointerSize;
int objectSize;

if (_type.IsDefType)
if (_type.IsInterface)
{
// Interfaces don't live on the GC heap. Don't bother computing a number.
// Zero compresses better than any useless number we would come up with.
return 0;
}
else if (_type.IsDefType)
{
LayoutInt instanceByteCount = ((DefType)_type).InstanceByteCount;

Expand Down

0 comments on commit a2ce877

Please sign in to comment.