From bd0747ac5393e2ca8ae350a7f7c6440c8b9ee4fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Sat, 22 Jul 2023 15:55:53 +0900 Subject: [PATCH] Set BaseSize of interfaces to 0 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. --- .../Compiler/DependencyAnalysis/EETypeNode.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs index c3a50613b61859..1e9f7679b44cc3 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs @@ -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;