From a597961c19c170c85f0fac987c498798967d1536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Fri, 9 Sep 2022 15:44:09 +0900 Subject: [PATCH] Do not emit mangled names in mstat files There's a 16 MB limit on total number of bytes in the string heap of an ECMA-335 module. S.R.Metadata throws an exception when the limit is reached. We can't even generate MSTAT files for an ASP.NET WebApi template. MSTAT files are useful even without this information, but I would like to generate it in the future. Using some different approach. --- .../aot/ILCompiler.Compiler/Compiler/MstatObjectDumper.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MstatObjectDumper.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MstatObjectDumper.cs index 0f0af381c2e6ed..22d7bd1cc79e0d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MstatObjectDumper.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MstatObjectDumper.cs @@ -21,7 +21,7 @@ namespace ILCompiler public class MstatObjectDumper : ObjectDumper { private const int VersionMajor = 1; - private const int VersionMinor = 0; + private const int VersionMinor = 1; private readonly string _fileName; private readonly TypeSystemMetadataEmitter _emitter; @@ -82,7 +82,8 @@ private void SerializeSimpleEntry(InstructionEncoder encoder, TypeSystemEntity e { encoder.OpCode(ILOpCode.Ldtoken); encoder.Token(_emitter.EmitMetadataHandleForTypeSystemEntity(entity)); - encoder.LoadString(_emitter.GetUserStringHandle(mangledName)); + // Would like to do this but mangled names are very long and go over the 16 MB string limit quickly. + // encoder.LoadString(_emitter.GetUserStringHandle(mangledName)); encoder.LoadConstantI4(blob.Data.Length); } @@ -93,7 +94,8 @@ internal override void End() { methods.OpCode(ILOpCode.Ldtoken); methods.Token(_emitter.EmitMetadataHandleForTypeSystemEntity(m.Key)); - methods.LoadString(_emitter.GetUserStringHandle(m.Value.MangledName)); + // Would like to do this but mangled names are very long and go over the 16 MB string limit quickly. + // methods.LoadString(_emitter.GetUserStringHandle(m.Value.MangledName)); methods.LoadConstantI4(m.Value.Size); methods.LoadConstantI4(m.Value.GcInfoSize); methods.LoadConstantI4(_methodEhInfo.GetValueOrDefault(m.Key));