From: Michal Strehovský Date: Sat, 22 Jul 2023 12:54:19 +0000 (+0900) Subject: Set BaseSize of interfaces to 0 (#89343) X-Git-Tag: accepted/tizen/unified/riscv/20231226.055536~835 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a2ce8773521a111154e30ab0abe292d9f38d13e6;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Set BaseSize of interfaces to 0 (#89343) 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. --- 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 c3a5061..1e9f767 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 @@ 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;