Set BaseSize of interfaces to 0 (#89343)
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>
Sat, 22 Jul 2023 12:54:19 +0000 (21:54 +0900)
committerGitHub <noreply@github.com>
Sat, 22 Jul 2023 12:54:19 +0000 (05:54 -0700)
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.

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs

index c3a5061..1e9f767 100644 (file)
@@ -790,7 +790,13 @@ namespace ILCompiler.DependencyAnalysis
                 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;