diff --git a/src/coreclr/tools/Common/Compiler/CompilationBuilder.cs b/src/coreclr/tools/Common/Compiler/CompilationBuilder.cs index 5357e2f68234ba..4bce956704618f 100644 --- a/src/coreclr/tools/Common/Compiler/CompilationBuilder.cs +++ b/src/coreclr/tools/Common/Compiler/CompilationBuilder.cs @@ -8,6 +8,7 @@ using ILCompiler.DependencyAnalysisFramework; using Internal.IL; +using Internal.Text; namespace ILCompiler { @@ -51,7 +52,7 @@ public CompilationBuilder UseParallelism(int parallelism) public CompilationBuilder UseCompilationUnitPrefix(string prefix) { - _nameMangler.CompilationUnitPrefix = prefix; + _nameMangler.CompilationUnitPrefix = new Utf8String(prefix); return this; } diff --git a/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs b/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs index 427ee9e1e9c499..29a919a137e458 100644 --- a/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs +++ b/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs @@ -189,7 +189,7 @@ private Utf8String SanitizeNameWithHash(Utf8String literal) hash = SHA256.HashData(literal.AsSpan()); } - mangledName += "_" + Convert.ToHexString(hash); + mangledName = Utf8String.Concat(mangledName, new Utf8String("_" + Convert.ToHexString(hash))); } return mangledName; @@ -293,7 +293,7 @@ private Utf8String ComputeMangledTypeName(TypeDesc type) // This problem needs a better fix. if (isSystemPrivate) assemblyName = string.Concat("S.P.", assemblyName.AsSpan(15)); - Utf8String prependAssemblyName = SanitizeName(assemblyName); + Utf8String prependAssemblyName = new Utf8String(SanitizeName(assemblyName)); var deduplicator = new HashSet(); @@ -383,12 +383,12 @@ static void AppendTypeName(Utf8StringBuilder sb, MetadataType t) case TypeFlags.ByRef: mangledName = new Utf8StringBuilder() .Append(GetMangledTypeName(((ByRefType)type).ParameterType)) - .Append(NestMangledName("ByRef")).ToUtf8String(); + .Append(NestMangledName(new Utf8String("ByRef"u8))).ToUtf8String(); break; case TypeFlags.Pointer: mangledName = new Utf8StringBuilder() .Append(GetMangledTypeName(((PointerType)type).ParameterType)) - .Append(NestMangledName("Pointer")).ToUtf8String(); + .Append(NestMangledName(new Utf8String("Pointer"u8))).ToUtf8String(); break; case TypeFlags.FunctionPointer: { @@ -433,17 +433,17 @@ static void AppendTypeName(Utf8StringBuilder sb, MetadataType t) } else if (type is IPrefixMangledMethod) { - mangledName = GetPrefixMangledMethodName((IPrefixMangledMethod)type).ToString(); + mangledName = GetPrefixMangledMethodName((IPrefixMangledMethod)type); } else if (type is IPrefixMangledType) { - mangledName = GetPrefixMangledTypeName((IPrefixMangledType)type).ToString(); + mangledName = GetPrefixMangledTypeName((IPrefixMangledType)type); } else { // This is a type definition. Since we didn't fall in the `is EcmaType` case above, // it's likely a compiler-generated type. - mangledName = SanitizeName(((DefType)type).GetFullName()); + mangledName = new Utf8String(SanitizeName(((DefType)type).GetFullName())); } break; } diff --git a/src/coreclr/tools/Common/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/Common/Compiler/ObjectWriter/CoffObjectWriter.cs index dda356a81abd5a..8b7f6036a9f111 100644 --- a/src/coreclr/tools/Common/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/Common/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -133,7 +133,7 @@ private protected override void CreateSection(ObjectNodeSection section, Utf8Str _sectionNumberToComdatAuxRecord[_sections.Count] = auxRecord; _symbols.Add(new CoffSymbol { - Name = sectionHeader.Name, + Name = new Utf8String(sectionHeader.Name), Value = 0, SectionIndex = coffSectionIndex, StorageClass = CoffSymbolClass.IMAGE_SYM_CLASS_STATIC, @@ -266,7 +266,7 @@ private protected override void EmitSymbolTable( // Emit the feat.00 symbol that controls various linker behaviors _symbols.Add(new CoffSymbol { - Name = "@feat.00", + Name = new Utf8String("@feat.00"u8), StorageClass = CoffSymbolClass.IMAGE_SYM_CLASS_STATIC, SectionIndex = uint.MaxValue, // IMAGE_SYM_ABSOLUTE Value = (uint)feat00Flags, @@ -613,7 +613,7 @@ public void Write(Stream stream, CoffStringTable stringTable) { buffer.Clear(); buffer[0] = (byte)'/'; - uint offset = stringTable.GetStringOffset(Name); + uint offset = stringTable.GetStringOffset(new Utf8String(Name)); if (offset <= 9999999) { Span charBuffer = stackalloc char[16]; diff --git a/src/coreclr/tools/Common/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/Common/Compiler/ObjectWriter/ElfObjectWriter.cs index 3d3586fbd64890..cc3e3203947450 100644 --- a/src/coreclr/tools/Common/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/Common/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -8,10 +8,13 @@ using System.Buffers.Binary; using System.Numerics; using System.Reflection; + using ILCompiler.DependencyAnalysis; using ILCompiler.DependencyAnalysisFramework; + using Internal.Text; using Internal.TypeSystem; + using static ILCompiler.DependencyAnalysis.RelocType; using static ILCompiler.ObjectWriter.EabiNative; using static ILCompiler.ObjectWriter.ElfNative; @@ -155,9 +158,10 @@ private protected override void CreateSection(ObjectNodeSection section, Utf8Str }); // Emit section symbol into symbol table (for COMDAT the defining symbol is section symbol) + Utf8String sectionNameUtf8 = new(sectionName); if (comdatName.IsNull) { - _symbolNameToIndex[sectionName] = (uint)_symbols.Count; + _symbolNameToIndex[sectionNameUtf8] = (uint)_symbols.Count; _symbols.Add(new ElfSymbol { Section = _sections[sectionIndex], @@ -171,11 +175,11 @@ private protected override void CreateSection(ObjectNodeSection section, Utf8Str { Section = _sections[sectionIndex], Info = STT_NOTYPE, - Name = $"$t.{sectionIndex}" + Name = new Utf8String($"$t.{sectionIndex}") }); } - base.CreateSection(section, comdatName, symbolName.IsNull ? sectionName : symbolName, sectionIndex, sectionStream); + base.CreateSection(section, comdatName, symbolName.IsNull ? sectionNameUtf8 : symbolName, sectionIndex, sectionStream); } protected internal override void UpdateSectionAlignment(int sectionIndex, int alignment) @@ -256,7 +260,7 @@ protected internal override unsafe void EmitRelocation( // ld reg, reg, pcrel_lo12(.Lpcrel_hi) # note that this points at the label for 'auipc' // // Add a symbol for the auipc instruction so it can be pointed at by the LO12 relocation - string name = GetRiscV64SymbolNameForPcrelRelocation(sectionIndex, offset); + Utf8String name = new(GetRiscV64SymbolNameForPcrelRelocation(sectionIndex, offset)); EmitSymbolDefinition(sectionIndex, name, offset, 2 * 4); } @@ -305,7 +309,7 @@ private protected override void EmitSymbolTable( { sortedSymbols.Add(new ElfSymbol { - Name = $"{externSymbol}$thunk", + Name = new Utf8String($"{externSymbol}$thunk"), Value = (ulong)((thunkSymbolsIndex * 4) | 1u), Size = 4u, Section = _sections[thunkSectionIndex], @@ -340,7 +344,7 @@ private protected override void EmitSymbolTable( _sections[thunkSectionWriter.SectionIndex].RelocationStream = relocationStream; foreach (Utf8String externSymbol in undefinedSymbols) { - if (_symbolNameToIndex.TryGetValue($"{externSymbol}$thunk", out uint thunkSymbolIndex)) + if (_symbolNameToIndex.TryGetValue(new Utf8String($"{externSymbol}$thunk"), out uint thunkSymbolIndex)) { // Write the relocation to external symbol for the thunk BinaryPrimitives.WriteUInt32LittleEndian(relocationEntry, (uint)thunkSectionWriter.Position); @@ -587,7 +591,7 @@ private void EmitRelocationsRiscV64(int sectionIndex, List r if (symbolicRelocation.Type is IMAGE_REL_BASED_RISCV64_PCREL_I or IMAGE_REL_BASED_RISCV64_PCREL_S) { // Emit another relocation which points at the previous instruction - string symbolName = GetRiscV64SymbolNameForPcrelRelocation(sectionIndex, symbolicRelocation.Offset); + Utf8String symbolName = new(GetRiscV64SymbolNameForPcrelRelocation(sectionIndex, symbolicRelocation.Offset)); symbolIndex = _symbolNameToIndex[symbolName]; type = symbolicRelocation.Type is IMAGE_REL_BASED_RISCV64_PCREL_I ? R_RISCV_PCREL_LO12_I @@ -680,7 +684,7 @@ private void EmitObjectFile(Stream outputFileStream) ulong currentOffset = (ulong)ElfHeader.GetSize(); foreach (var section in _sections) { - _stringTable.ReserveString(section.Name); + _stringTable.ReserveString(new Utf8String(section.Name)); if (section.SectionHeader.Alignment > 1) { @@ -704,7 +708,7 @@ private void EmitObjectFile(Stream outputFileStream) if (section.RelocationStream != Stream.Null) { - _stringTable.ReserveString((_useInlineRelocationAddends ? ".rel" : ".rela") + section.Name); + _stringTable.ReserveString(new Utf8String((_useInlineRelocationAddends ? ".rel" : ".rela") + section.Name)); sectionCount++; } @@ -718,11 +722,11 @@ private void EmitObjectFile(Stream outputFileStream) } // Reserve names for the predefined sections - _stringTable.ReserveString(".strtab"); - _stringTable.ReserveString(".symtab"); + _stringTable.ReserveString(new Utf8String(".strtab"u8)); + _stringTable.ReserveString(new Utf8String(".symtab"u8)); if (sectionCount >= SHN_LORESERVE) { - _stringTable.ReserveString(".symtab_shndx"); + _stringTable.ReserveString(new Utf8String(".symtab_shndx"u8)); hasSymTabExtendedIndices = true; } @@ -828,7 +832,7 @@ private void EmitObjectFile(Stream outputFileStream) { section.SectionHeader.Link = section.LinkSection.SectionIndex; } - section.SectionHeader.NameIndex = _stringTable.GetStringOffset(section.Name); + section.SectionHeader.NameIndex = _stringTable.GetStringOffset(new Utf8String(section.Name)); section.SectionHeader.Write(outputFileStream); if (section.SectionHeader.Type != SHT_NOBITS && @@ -836,7 +840,7 @@ private void EmitObjectFile(Stream outputFileStream) { ElfSectionHeader relaSectionHeader = new ElfSectionHeader { - NameIndex = _stringTable.GetStringOffset((_useInlineRelocationAddends ? ".rel" : ".rela") + section.Name), + NameIndex = _stringTable.GetStringOffset(new Utf8String((_useInlineRelocationAddends ? ".rel" : ".rela") + section.Name)), Type = _useInlineRelocationAddends ? SHT_REL : SHT_RELA, Flags = (section.GroupSection is not null ? SHF_GROUP : 0u) | SHF_INFO_LINK, Address = 0u, @@ -854,7 +858,7 @@ private void EmitObjectFile(Stream outputFileStream) // String table section ElfSectionHeader stringTableSectionHeader = new ElfSectionHeader { - NameIndex = _stringTable.GetStringOffset(".strtab"), + NameIndex = _stringTable.GetStringOffset(new Utf8String(".strtab"u8)), Type = SHT_STRTAB, Flags = 0u, Address = 0u, @@ -870,7 +874,7 @@ private void EmitObjectFile(Stream outputFileStream) // Symbol table section ElfSectionHeader symbolTableSectionHeader = new ElfSectionHeader { - NameIndex = _stringTable.GetStringOffset(".symtab"), + NameIndex = _stringTable.GetStringOffset(new Utf8String(".symtab"u8)), Type = SHT_SYMTAB, Flags = 0u, Address = 0u, @@ -890,7 +894,7 @@ private void EmitObjectFile(Stream outputFileStream) { ElfSectionHeader sectionHeader = new ElfSectionHeader { - NameIndex = _stringTable.GetStringOffset(".symtab_shndx"), + NameIndex = _stringTable.GetStringOffset(new Utf8String(".symtab_shndx"u8)), Type = SHT_SYMTAB_SHNDX, Flags = 0u, Address = 0u, @@ -1090,7 +1094,7 @@ private sealed class ElfStringTable : StringTableBuilder public ElfStringTable() { // Always start the table with empty string - GetStringOffset(""); + GetStringOffset(new Utf8String(""u8)); } } } diff --git a/src/coreclr/tools/Common/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/Common/Compiler/ObjectWriter/MachObjectWriter.cs index ef8ee1bf507fe6..d11496a512d87c 100644 --- a/src/coreclr/tools/Common/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/Common/Compiler/ObjectWriter/MachObjectWriter.cs @@ -71,7 +71,7 @@ internal sealed partial class MachObjectWriter : UnixObjectWriter /// /// Base symbol to use for relocations. /// - private readonly string _baseSymbolName; + private readonly Utf8String? _baseSymbolName; public MachObjectWriter(NodeFactory factory, ObjectWritingOptions options, OutputInfoBuilder outputInfoBuilder = null) : base(factory, options, outputInfoBuilder) @@ -102,7 +102,7 @@ public MachObjectWriter(NodeFactory factory, ObjectWritingOptions options, Outpu public MachObjectWriter(NodeFactory factory, ObjectWritingOptions options, OutputInfoBuilder outputInfoBuilder, string baseSymbolName) : this(factory, options, outputInfoBuilder) { - _baseSymbolName = baseSymbolName; + _baseSymbolName = baseSymbolName is not null ? new Utf8String(baseSymbolName) : null; } private protected override bool UsesSubsectionsViaSymbols => true; @@ -121,7 +121,7 @@ private protected override void EmitSectionsAndLayout() { var machSymbol = new MachSymbol { - Name = $"lsection{sectionIndex}", + Name = new Utf8String($"lsection{sectionIndex}"), Section = section, Value = section.VirtualAddress, Descriptor = N_NO_DEAD_STRIP, @@ -375,7 +375,7 @@ private protected override void CreateSection(ObjectNodeSection section, Utf8Str _sections.Add(machSection); - base.CreateSection(section, comdatName, symbolName.IsNull ? $"lsection{sectionIndex}" : symbolName, sectionIndex, sectionStream); + base.CreateSection(section, comdatName, symbolName.IsNull ? new Utf8String($"lsection{sectionIndex}") : symbolName, sectionIndex, sectionStream); } protected internal override void UpdateSectionAlignment(int sectionIndex, int alignment) @@ -547,7 +547,7 @@ private protected override void EmitSymbolTable( // Add the base symbol as an undefined symbol. if (_baseSymbolName is not null) { - undefinedSymbols.Add(_baseSymbolName); + undefinedSymbols.Add(_baseSymbolName.Value); } foreach (Utf8String externSymbol in undefinedSymbols) @@ -686,14 +686,14 @@ private void EmitRelocationsX64(int sectionIndex, List reloc throw new NotSupportedException("A base symbol name must be provided for IMAGE_REL_BASED_ADDR32NB relocations."); } - Debug.Assert(_symbolNameToIndex.ContainsKey(_baseSymbolName)); + Debug.Assert(_symbolNameToIndex.ContainsKey(_baseSymbolName.Value)); // Represent as X86_64_RELOC_SUBTRACTOR + X86_64_RELOC_UNSIGNED against the base symbol. sectionRelocations.Add( new MachRelocation { Address = (int)symbolicRelocation.Offset, - SymbolOrSectionIndex = _symbolNameToIndex[_baseSymbolName], + SymbolOrSectionIndex = _symbolNameToIndex[_baseSymbolName.Value], Length = 4, RelocationType = X86_64_RELOC_SUBTRACTOR, IsExternal = true, @@ -849,14 +849,14 @@ private void EmitRelocationsArm64(int sectionIndex, List rel throw new NotSupportedException("A base symbol name must be provided for IMAGE_REL_BASED_ADDR32NB relocations."); } - Debug.Assert(_symbolNameToIndex.ContainsKey(_baseSymbolName)); + Debug.Assert(_symbolNameToIndex.ContainsKey(_baseSymbolName.Value)); // Represent as ARM64_RELOC_SUBTRACTOR + ARM64_RELOC_UNSIGNED against the base symbol. sectionRelocations.Add( new MachRelocation { Address = (int)symbolicRelocation.Offset, - SymbolOrSectionIndex = _symbolNameToIndex[_baseSymbolName], + SymbolOrSectionIndex = _symbolNameToIndex[_baseSymbolName.Value], Length = 4, RelocationType = ARM64_RELOC_SUBTRACTOR, IsExternal = true, @@ -1034,7 +1034,7 @@ public void Write(Stream stream) private sealed class MachSymbol { - public Utf8String Name { get; init; } = string.Empty; + public Utf8String Name { get; init; } public byte Type { get; init; } public MachSection Section { get; init; } public ushort Descriptor { get; init; } @@ -1159,7 +1159,7 @@ private sealed class MachStringTable : StringTableBuilder public MachStringTable() { // Always start the table with empty string - GetStringOffset(""); + GetStringOffset(new Utf8String(""u8)); } } } diff --git a/src/coreclr/tools/Common/Compiler/ObjectWriter/OutputInfoBuilder.cs b/src/coreclr/tools/Common/Compiler/ObjectWriter/OutputInfoBuilder.cs index 83bf11db428039..d3b62804d7efec 100644 --- a/src/coreclr/tools/Common/Compiler/ObjectWriter/OutputInfoBuilder.cs +++ b/src/coreclr/tools/Common/Compiler/ObjectWriter/OutputInfoBuilder.cs @@ -75,7 +75,7 @@ public sealed class OutputNode : OutputItem public int Relocations { get; private set; } public OutputNode(int sectionIndex, ulong offset, int length, string name) - : base(sectionIndex, offset, name) + : base(sectionIndex, offset, new Utf8String(name)) { Length = length; Relocations = 0; diff --git a/src/coreclr/tools/Common/Compiler/ObjectWriter/PEObjectWriter.cs b/src/coreclr/tools/Common/Compiler/ObjectWriter/PEObjectWriter.cs index 5243d2e214c685..d97f6b33396ddd 100644 --- a/src/coreclr/tools/Common/Compiler/ObjectWriter/PEObjectWriter.cs +++ b/src/coreclr/tools/Common/Compiler/ObjectWriter/PEObjectWriter.cs @@ -12,7 +12,9 @@ using System.Reflection.PortableExecutable; using System.Security.Cryptography; using System.Text; + using ILCompiler.DependencyAnalysis; + using Internal.Text; using Internal.TypeSystem; @@ -551,7 +553,7 @@ private void EmitExportDirectory(SectionWriter sectionWriter) List exports = [.._exportedSymbolNames]; exports.Sort(StringComparer.Ordinal); - string moduleName = Path.GetFileName(_outputPath); + Utf8String moduleName = new Utf8String(Path.GetFileName(_outputPath)); const int minOrdinal = 1; StringTableBuilder exportsStringTable = new(); @@ -559,7 +561,7 @@ private void EmitExportDirectory(SectionWriter sectionWriter) exportsStringTable.ReserveString(moduleName); foreach (var exportName in exports) { - exportsStringTable.ReserveString(exportName); + exportsStringTable.ReserveString(new Utf8String(exportName)); } string exportsStringTableSymbol = GenerateSymbolNameForReloc("exportsStringTable"); @@ -578,7 +580,7 @@ private void EmitExportDirectory(SectionWriter sectionWriter) // +0x0A: minor version sectionWriter.WriteLittleEndian(0); // +0x0C: DLL name RVA - sectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, exportsStringTableSymbol, exportsStringTable.GetStringOffset(moduleName)); + sectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, new Utf8String(exportsStringTableSymbol), exportsStringTable.GetStringOffset(moduleName)); // +0x10: ordinal base sectionWriter.WriteLittleEndian(minOrdinal); // +0x14: number of entries in the address table @@ -586,36 +588,36 @@ private void EmitExportDirectory(SectionWriter sectionWriter) // +0x18: number of name pointers sectionWriter.WriteLittleEndian(exports.Count); // +0x1C: export address table RVA - sectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, addressTableSymbol); + sectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, new Utf8String(addressTableSymbol)); // +0x20: name pointer RVA - sectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, namePointerTableSymbol); + sectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, new Utf8String(namePointerTableSymbol)); // +0x24: ordinal table RVA - sectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, ordinalPointerTableSymbol); + sectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, new Utf8String(ordinalPointerTableSymbol)); sectionWriter.EmitAlignment(4); - sectionWriter.EmitSymbolDefinition(addressTableSymbol); + sectionWriter.EmitSymbolDefinition(new Utf8String(addressTableSymbol)); foreach (var exportName in exports) { - sectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, exportName); + sectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, new Utf8String(exportName)); } sectionWriter.EmitAlignment(4); - sectionWriter.EmitSymbolDefinition(namePointerTableSymbol); + sectionWriter.EmitSymbolDefinition(new Utf8String(namePointerTableSymbol)); foreach (var exportName in exports) { - sectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, exportsStringTableSymbol, exportsStringTable.GetStringOffset(exportName)); + sectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, new Utf8String(exportsStringTableSymbol), exportsStringTable.GetStringOffset(new Utf8String(exportName))); } sectionWriter.EmitAlignment(4); - sectionWriter.EmitSymbolDefinition(ordinalPointerTableSymbol); + sectionWriter.EmitSymbolDefinition(new Utf8String(ordinalPointerTableSymbol)); for (int i = 0; i < exports.Count; i++) { sectionWriter.WriteLittleEndian(checked((ushort)i)); } - sectionWriter.EmitSymbolDefinition(exportsStringTableSymbol); + sectionWriter.EmitSymbolDefinition(new Utf8String(exportsStringTableSymbol)); MemoryStream ms = new(); exportsStringTable.Write(ms); sectionWriter.Write(ms.ToArray()); diff --git a/src/coreclr/tools/Common/Internal/Text/Utf8String.cs b/src/coreclr/tools/Common/Internal/Text/Utf8String.cs index 4c8d902809040c..e3958ec4e88d9d 100644 --- a/src/coreclr/tools/Common/Internal/Text/Utf8String.cs +++ b/src/coreclr/tools/Common/Internal/Text/Utf8String.cs @@ -18,6 +18,11 @@ public Utf8String(byte[] underlyingArray) _value = underlyingArray; } + public Utf8String(ReadOnlySpan underlyingSpan) + { + _value = underlyingSpan.ToArray(); + } + public Utf8String(string s) { _value = Encoding.UTF8.GetBytes(s); @@ -25,13 +30,6 @@ public Utf8String(string s) public int Length => _value.Length; - // For now, define implicit conversions between string and Utf8String to aid the transition - // These conversions will be removed eventually - public static implicit operator Utf8String(string s) - { - return new Utf8String(s); - } - public ReadOnlySpan AsSpan() => _value; public override string ToString() diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs index b9896e38facc76..ee2c67a3c02700 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs @@ -11,6 +11,7 @@ using Internal.IL; using Internal.IL.Stubs; +using Internal.Text; using Internal.TypeSystem; using Internal.TypeSystem.Ecma; @@ -138,7 +139,7 @@ public virtual ISymbolNode GetFieldRvaData(FieldDesc field) } else if (field is ExternSymbolMappedField externField) { - return NodeFactory.ExternVariable(externField.SymbolName); + return NodeFactory.ExternVariable(new Utf8String(externField.SymbolName)); } else { @@ -356,7 +357,7 @@ public ISymbolNode ComputeConstantLookup(ReadyToRunHelperId lookupKind, object t case ReadyToRunHelperId.ObjectAllocator: { var type = (TypeDesc)targetOfLookup; - return NodeFactory.ExternFunctionSymbol(JitHelper.GetNewObjectHelperForType(type)); + return NodeFactory.ExternFunctionSymbol(new Utf8String(JitHelper.GetNewObjectHelperForType(type))); } default: diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternEETypeSymbolNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternEETypeSymbolNode.cs index 1292076f32bde7..f3f756e894941e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternEETypeSymbolNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternEETypeSymbolNode.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using Internal.Text; using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternMethodSymbolNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternMethodSymbolNode.cs index d26a42b44192a2..3dae9910464a9d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternMethodSymbolNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternMethodSymbolNode.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using Internal.Text; using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternSymbolsImportedNodeProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternSymbolsImportedNodeProvider.cs index 1a774c511071bd..3d758bf41b847e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternSymbolsImportedNodeProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternSymbolsImportedNodeProvider.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; + +using Internal.Text; using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericLookupResult.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericLookupResult.cs index ea7849f02c3405..b15a29d99b7b2e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericLookupResult.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericLookupResult.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; + using Internal.Text; using Internal.TypeSystem; @@ -835,7 +836,7 @@ public ObjectAllocatorGenericLookupResult(TypeDesc type) public override ISymbolNode GetTarget(NodeFactory factory, GenericLookupResultContext dictionary) { TypeDesc instantiatedType = _type.GetNonRuntimeDeterminedTypeFromRuntimeDeterminedSubtypeViaSubstitution(dictionary.TypeInstantiation, dictionary.MethodInstantiation); - return factory.ExternFunctionSymbol(JitHelper.GetNewObjectHelperForType(instantiatedType)); + return factory.ExternFunctionSymbol(new Utf8String(JitHelper.GetNewObjectHelperForType(instantiatedType))); } public override void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs index 215e62af76874b..7822cfeb912b45 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs @@ -46,7 +46,7 @@ public NodeFactory( { _target = context.Target; - InitialInterfaceDispatchStub = new AddressTakenExternFunctionSymbolNode("RhpInitialDynamicInterfaceDispatch"); + InitialInterfaceDispatchStub = new AddressTakenExternFunctionSymbolNode(new Utf8String("RhpInitialDynamicInterfaceDispatch"u8)); _context = context; _compilationModuleGroup = compilationModuleGroup; @@ -1520,7 +1520,7 @@ public ISymbolNode ConstantUtf8String(string str) byte[] stringBytes = new byte[stringBytesCount + 1]; Encoding.UTF8.GetBytes(str, 0, str.Length, stringBytes, 0); - string symbolName = "__utf8str_" + NameMangler.GetMangledStringName(str); + Utf8String symbolName = new Utf8String("__utf8str_" + NameMangler.GetMangledStringName(str)); return ReadOnlyDataBlob(symbolName, stringBytes, 1); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/PInvokeModuleFixupNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/PInvokeModuleFixupNode.cs index 0adb9c4f1ab342..84ac6b9da1c83f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/PInvokeModuleFixupNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/PInvokeModuleFixupNode.cs @@ -124,7 +124,7 @@ public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb) { sb.Append(nameMangler.GetMangledTypeName(DeclaringModule.GetGlobalModuleType())); sb.Append('_'); - sb.Append(nameMangler.SanitizeName(ModuleName)); + sb.Append(nameMangler.SanitizeName(new Utf8String(ModuleName))); if (DllImportSearchPath.HasValue) { sb.Append('_'); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/RuntimeImportMethodNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/RuntimeImportMethodNode.cs index 1d4d4b47c3c4b1..8a0114e2947e64 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/RuntimeImportMethodNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/RuntimeImportMethodNode.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using Internal.Text; using Internal.TypeSystem; using Internal.TypeSystem.Ecma; @@ -14,7 +15,7 @@ public class RuntimeImportMethodNode : ExternFunctionSymbolNode, IMethodNode, IS private MethodDesc _method; public RuntimeImportMethodNode(MethodDesc method, NameMangler nameMangler) - : base(nameMangler.NodeMangler.ExternMethod(((EcmaMethod)method).GetRuntimeImportName(), method)) + : base(nameMangler.NodeMangler.ExternMethod(new Utf8String(((EcmaMethod)method).GetRuntimeImportName()), method)) { _method = method; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMReadyToRunHelperNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMReadyToRunHelperNode.cs index b7db3ab474e48c..1e0c1455f86798 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMReadyToRunHelperNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMReadyToRunHelperNode.cs @@ -3,7 +3,10 @@ using System; using System.Diagnostics; + +using Internal.Text; using Internal.TypeSystem; + using ILCompiler.DependencyAnalysis.ARM; namespace ILCompiler.DependencyAnalysis @@ -128,7 +131,7 @@ protected override void EmitCode(NodeFactory factory, ref ARMEmitter encoder, bo if (targetMethod.OwningType.IsInterface) { encoder.EmitMOV(encoder.TargetRegister.Arg1, factory.InterfaceDispatchCell(targetMethod)); - encoder.EmitJMP(factory.ExternFunctionSymbol("RhpResolveInterfaceMethod")); + encoder.EmitJMP(factory.ExternFunctionSymbol(new Utf8String("RhpResolveInterfaceMethod"u8))); } else { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM64/ARM64ReadyToRunHelperNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM64/ARM64ReadyToRunHelperNode.cs index de94d044527b2f..7f567b59b16ae0 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM64/ARM64ReadyToRunHelperNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM64/ARM64ReadyToRunHelperNode.cs @@ -5,6 +5,8 @@ using System.Diagnostics; using ILCompiler.DependencyAnalysis.ARM64; + +using Internal.Text; using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis @@ -144,7 +146,7 @@ protected override void EmitCode(NodeFactory factory, ref ARM64Emitter encoder, if (targetMethod.OwningType.IsInterface) { encoder.EmitMOV(encoder.TargetRegister.Arg1, factory.InterfaceDispatchCell(targetMethod)); - encoder.EmitJMP(factory.ExternFunctionSymbol("RhpResolveInterfaceMethod")); + encoder.EmitJMP(factory.ExternFunctionSymbol(new Utf8String("RhpResolveInterfaceMethod"u8))); } else { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_LoongArch64/LoongArch64ReadyToRunHelperNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_LoongArch64/LoongArch64ReadyToRunHelperNode.cs index 98e433a5058c4d..f1693866f825a0 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_LoongArch64/LoongArch64ReadyToRunHelperNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_LoongArch64/LoongArch64ReadyToRunHelperNode.cs @@ -5,6 +5,8 @@ using System.Diagnostics; using ILCompiler.DependencyAnalysis.LoongArch64; + +using Internal.Text; using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis @@ -136,7 +138,7 @@ protected override void EmitCode(NodeFactory factory, ref LoongArch64Emitter enc if (targetMethod.OwningType.IsInterface) { encoder.EmitMOV(encoder.TargetRegister.Arg1, factory.InterfaceDispatchCell(targetMethod)); - encoder.EmitJMP(factory.ExternFunctionSymbol("RhpResolveInterfaceMethod")); + encoder.EmitJMP(factory.ExternFunctionSymbol(new Utf8String("RhpResolveInterfaceMethod"u8))); } else { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_RiscV64/RiscV64ReadyToRunHelperNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_RiscV64/RiscV64ReadyToRunHelperNode.cs index cb217b1e2bffb2..a3c93d78a2f0bd 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_RiscV64/RiscV64ReadyToRunHelperNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_RiscV64/RiscV64ReadyToRunHelperNode.cs @@ -4,9 +4,11 @@ using System; using System.Diagnostics; -using ILCompiler.DependencyAnalysis.RiscV64; +using Internal.Text; using Internal.TypeSystem; +using ILCompiler.DependencyAnalysis.RiscV64; + namespace ILCompiler.DependencyAnalysis { /// @@ -134,7 +136,7 @@ protected override void EmitCode(NodeFactory factory, ref RiscV64Emitter encoder if (targetMethod.OwningType.IsInterface) { encoder.EmitMOV(encoder.TargetRegister.Arg1, factory.InterfaceDispatchCell(targetMethod)); - encoder.EmitJMP(factory.ExternFunctionSymbol("RhpResolveInterfaceMethod")); + encoder.EmitJMP(factory.ExternFunctionSymbol(new Utf8String("RhpResolveInterfaceMethod"u8))); } else { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_X64/X64ReadyToRunHelperNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_X64/X64ReadyToRunHelperNode.cs index c5f8cab13db3f7..45333a28ae8776 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_X64/X64ReadyToRunHelperNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_X64/X64ReadyToRunHelperNode.cs @@ -5,6 +5,8 @@ using System.Diagnostics; using ILCompiler.DependencyAnalysis.X64; + +using Internal.Text; using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis @@ -149,7 +151,7 @@ protected override void EmitCode(NodeFactory factory, ref X64Emitter encoder, bo if (targetMethod.OwningType.IsInterface) { encoder.EmitLEAQ(encoder.TargetRegister.Arg1, factory.InterfaceDispatchCell(targetMethod)); - encoder.EmitJMP(factory.ExternFunctionSymbol("RhpResolveInterfaceMethod")); + encoder.EmitJMP(factory.ExternFunctionSymbol(new Utf8String("RhpResolveInterfaceMethod"u8))); } else { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_X86/X86ReadyToRunHelperNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_X86/X86ReadyToRunHelperNode.cs index e2b8e6724aaf25..89408cff568840 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_X86/X86ReadyToRunHelperNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_X86/X86ReadyToRunHelperNode.cs @@ -6,6 +6,7 @@ using ILCompiler.DependencyAnalysis.X86; +using Internal.Text; using Internal.TypeSystem; namespace ILCompiler.DependencyAnalysis @@ -159,7 +160,7 @@ protected override void EmitCode(NodeFactory factory, ref X86Emitter encoder, bo if (targetMethod.OwningType.IsInterface) { encoder.EmitMOV(encoder.TargetRegister.Arg1, factory.InterfaceDispatchCell(targetMethod)); - encoder.EmitJMP(factory.ExternFunctionSymbol("RhpResolveInterfaceMethod")); + encoder.EmitJMP(factory.ExternFunctionSymbol(new Utf8String("RhpResolveInterfaceMethod"u8))); } else { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ThreadStaticsNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ThreadStaticsNode.cs index 26526a19f508b3..a44f88e77c5581 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ThreadStaticsNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ThreadStaticsNode.cs @@ -48,7 +48,7 @@ public static Utf8String GetMangledName(TypeDesc type, NameMangler nameMangler) public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb) { - Utf8String mangledName = _type == null ? "_inlinedThreadStatics" : GetMangledName(_type, nameMangler); + Utf8String mangledName = _type == null ? new Utf8String("_inlinedThreadStatics"u8) : GetMangledName(_type, nameMangler); sb.Append(mangledName); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ExpectedIsaFeaturesRootProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ExpectedIsaFeaturesRootProvider.cs index 9d172414a06aa2..aef028d8c0aeee 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ExpectedIsaFeaturesRootProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ExpectedIsaFeaturesRootProvider.cs @@ -3,6 +3,7 @@ using System; +using Internal.Text; using Internal.TypeSystem; namespace ILCompiler @@ -24,7 +25,7 @@ void ICompilationRootProvider.AddCompilationRoots(IRootingServiceProvider rootPr { int isaFlags = HardwareIntrinsicHelpers.GetRuntimeRequiredIsaFlags(_isaSupport); byte[] bytes = BitConverter.GetBytes(isaFlags); - rootProvider.RootReadOnlyDataBlob(bytes, 4, "ISA support flags", "g_requiredCpuFeatures", exportHidden: true); + rootProvider.RootReadOnlyDataBlob(bytes, 4, "ISA support flags", new Utf8String("g_requiredCpuFeatures"u8), exportHidden: true); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs index 598a5dec7233a5..07eca99c87b1fd 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs @@ -9,6 +9,7 @@ using ILCompiler.DependencyAnalysis; using ILCompiler.DependencyAnalysisFramework; +using Internal.Text; using Internal.IL; using Internal.IL.Stubs; using Internal.JitInterface; @@ -199,7 +200,7 @@ protected override Helper CreateValueFromKey(ReadyToRunHelper key) ISymbolNode entryPoint; if (mangledName != null) - entryPoint = _compilation.NodeFactory.ExternFunctionSymbol(mangledName); + entryPoint = _compilation.NodeFactory.ExternFunctionSymbol(new Utf8String(mangledName)); else entryPoint = _compilation.NodeFactory.MethodEntrypoint(methodDesc); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MainMethodRootProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MainMethodRootProvider.cs index 9a5460ff0cbbdf..75c6de55579702 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MainMethodRootProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MainMethodRootProvider.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using Internal.Text; using Internal.TypeSystem; using Internal.TypeSystem.Ecma; using Internal.IL.Stubs.StartupCode; @@ -40,7 +41,7 @@ public void AddCompilationRoots(IRootingServiceProvider rootProvider) TypeDesc owningType = _module.GetGlobalModuleType(); var startupCodeMain = new StartupCodeMainMethod(owningType, mainMethod, _libraryInitializers, _generateLibraryAndModuleInitializers); - rootProvider.AddCompilationRoot(startupCodeMain, "Startup Code Main Method", ManagedEntryPointMethodName); + rootProvider.AddCompilationRoot(startupCodeMain, "Startup Code Main Method", new Utf8String(ManagedEntryPointMethodName)); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NativeLibraryInitializerRootProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NativeLibraryInitializerRootProvider.cs index 759b9ca25ab5d0..4e95a1f5fd1496 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NativeLibraryInitializerRootProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NativeLibraryInitializerRootProvider.cs @@ -2,8 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; -using Internal.TypeSystem; + using Internal.IL.Stubs.StartupCode; +using Internal.Text; +using Internal.TypeSystem; namespace ILCompiler { @@ -30,7 +32,7 @@ public void AddCompilationRoots(IRootingServiceProvider rootProvider) { TypeDesc owningType = _module.GetGlobalModuleType(); NativeLibraryStartupMethod nativeLibStartupCode = new NativeLibraryStartupMethod(owningType, _libraryInitializers); - rootProvider.AddCompilationRoot(nativeLibStartupCode, "Startup Code Main Method", ManagedEntryPointMethodName); + rootProvider.AddCompilationRoot(nativeLibStartupCode, "Startup Code Main Method", new Utf8String(ManagedEntryPointMethodName)); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs index 0f63ef910c893c..ca35cb2160b7d3 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs @@ -143,12 +143,12 @@ public void WriteInfoTable( // Unit type, Address Size infoSectionWriter.Write([DW_UT_compile, _targetPointerSize]); // Abbrev offset - infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_abbrev", 0); + infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, new Utf8String(".debug_abbrev"u8), 0); } else { // Abbrev offset - infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_abbrev", 0); + infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, new Utf8String(".debug_abbrev"u8), 0); // Address Size infoSectionWriter.Write([_targetPointerSize]); } @@ -242,7 +242,7 @@ private void WriteAddressRangeTable(SectionWriter arangeSectionWriter) // Version arangeSectionWriter.WriteLittleEndian(2); // Debug Info Offset - arangeSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_info", 0); + arangeSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, new Utf8String(".debug_info"u8), 0); // Address size, Segment selector size arangeSectionWriter.Write([_targetPointerSize, 0]); // Ranges have to be aligned @@ -333,7 +333,7 @@ public uint GetArrayTypeIndex( { FieldTypeIndex = GetPrimitiveTypeIndex(TypeFlags.Int32), Offset = fieldOffset, - Name = "m_NumComponents", + Name = new Utf8String("m_NumComponents"u8), }); fieldOffset += _targetPointerSize; @@ -343,7 +343,7 @@ public uint GetArrayTypeIndex( { FieldTypeIndex = GetSimpleArrayTypeIndex(GetPrimitiveTypeIndex(TypeFlags.Int32), arrayDescriptor.Rank), Offset = fieldOffset, - Name = "m_Bounds", + Name = new Utf8String("m_Bounds"u8), }); fieldOffset += 2u * 4u * (ulong)arrayDescriptor.Rank; } @@ -352,7 +352,7 @@ public uint GetArrayTypeIndex( { FieldTypeIndex = GetSimpleArrayTypeIndex(arrayDescriptor.ElementType, 0), Offset = fieldOffset, - Name = "m_Data", + Name = new Utf8String("m_Data"u8), }); // We currently don't encode the size of the variable length data. The DWARF5 diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs index bc4d835eacac4e..c5d2fa58c28bbe 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs @@ -104,7 +104,7 @@ private void WriteCie(DwarfCie cie) if (cie.PersonalitySymbolName != null) { _sectionWriter.WriteByte(cie.PersonalityEncoding); - WriteAddress(cie.PersonalityEncoding, cie.PersonalitySymbolName); + WriteAddress(cie.PersonalityEncoding, new Utf8String(cie.PersonalitySymbolName)); } if (cie.LsdaEncoding != 0) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs index 935b6c397c6256..64d18b4c581ea2 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs @@ -102,7 +102,7 @@ public void WriteStringReference(Utf8String value) _stringTableWriter.WriteUtf8String(value); Debug.Assert(stringsOffset < uint.MaxValue); - _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_str", stringsOffset); + _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, new Utf8String(".debug_str"u8), stringsOffset); } public void WriteStringReference(string value) @@ -111,7 +111,7 @@ public void WriteStringReference(string value) _stringTableWriter.WriteUtf8String(value); Debug.Assert(stringsOffset < uint.MaxValue); - _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_str", stringsOffset); + _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, new Utf8String(".debug_str"u8), stringsOffset); } public void WriteInfoAbsReference(long offset) @@ -146,7 +146,7 @@ public void WriteCodeReference(Utf8String sectionSymbolName, long offset = 0) public void WriteLineReference(long offset) { Debug.Assert(offset < uint.MaxValue); - _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_line", offset); + _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, new Utf8String(".debug_line"u8), offset); } public DwarfExpressionBuilder GetExpressionBuilder() @@ -166,7 +166,7 @@ public void WriteStartLocationList() { long offset = _locSectionWriter.Position; Debug.Assert(offset < uint.MaxValue); - _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_loc", (int)offset); + _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, new Utf8String(".debug_loc"u8), (int)offset); } public void WriteLocationListExpression(Utf8String methodName, long startOffset, long endOffset, DwarfExpressionBuilder expressionBuilder) @@ -187,7 +187,7 @@ public void WriteStartRangeList() { long offset = _rangeSectionWriter.Position; Debug.Assert(offset < uint.MaxValue); - _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_ranges", offset); + _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, new Utf8String(".debug_ranges"u8), offset); } public void WriteRangeListEntry(Utf8String symbolName, long startOffset, long endOffset) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.Aot.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.Aot.cs index 837d3c6483291d..6fba1ffa40dc1a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.Aot.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.Aot.cs @@ -136,7 +136,7 @@ private protected override void EmitUnwindInfo( // ARM EHABI requires emitting a dummy relocation to the personality routine // to tell the linker to preserve it. - extabSectionWriter.EmitRelocation(0, unwindWord, IMAGE_REL_BASED_ABSOLUTE, personalitySymbolName, 0); + extabSectionWriter.EmitRelocation(0, unwindWord, IMAGE_REL_BASED_ABSOLUTE, new Utf8String(personalitySymbolName), 0); // Emit the unwinding code. First word specifies the personality routine, // format and first few bytes of the unwind code. For longer unwind codes diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/RootingServiceProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/RootingServiceProvider.cs index 13a55ad03fa301..f1effabc968ca8 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/RootingServiceProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/RootingServiceProvider.cs @@ -143,7 +143,7 @@ public void RootModuleMetadata(ModuleDesc module, string reason) public void RootReadOnlyDataBlob(byte[] data, int alignment, string reason, Utf8String exportName, bool exportHidden) { - var blob = _factory.ReadOnlyDataBlob("__readonlydata_" + exportName, data, alignment); + var blob = _factory.ReadOnlyDataBlob(new Utf8String($"__readonlydata_{exportName}"), data, alignment); _rootAdder(blob, reason); exportName = _factory.NameMangler.NodeMangler.ExternVariable(exportName); _factory.NodeAliases.Add(blob, (exportName, exportHidden)); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/RuntimeConfigurationRootProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/RuntimeConfigurationRootProvider.cs index 8c16f9685f8348..b7dfe018553d34 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/RuntimeConfigurationRootProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/RuntimeConfigurationRootProvider.cs @@ -51,7 +51,7 @@ public RuntimeConfigurationBlobNode(string blobName, IReadOnlyCollection public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb) { - sb.Append(nameMangler.NodeMangler.ExternVariable(_blobName)); + sb.Append(nameMangler.NodeMangler.ExternVariable(new Utf8String(_blobName))); } public override ObjectNodeSection GetSection(NodeFactory factory) => diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UnmanagedEntryPointsRootProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UnmanagedEntryPointsRootProvider.cs index ec9892c67b5d40..49eb0d21123c9a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UnmanagedEntryPointsRootProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UnmanagedEntryPointsRootProvider.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Reflection.Metadata; +using Internal.Text; using Internal.TypeSystem; using Internal.TypeSystem.Ecma; @@ -66,12 +67,12 @@ public void AddCompilationRoots(IRootingServiceProvider rootProvider) { if (ecmaMethod.IsUnmanagedCallersOnly) { - string unmanagedCallersOnlyExportName = ecmaMethod.GetUnmanagedCallersOnlyExportName(); + Utf8String unmanagedCallersOnlyExportName = new(ecmaMethod.GetUnmanagedCallersOnlyExportName()); rootProvider.AddCompilationRoot((MethodDesc)ecmaMethod, "Native callable", unmanagedCallersOnlyExportName, Hidden); } else { - string runtimeExportName = ecmaMethod.GetRuntimeExportName(); + Utf8String runtimeExportName = new(ecmaMethod.GetRuntimeExportName()); rootProvider.AddCompilationRoot((MethodDesc)ecmaMethod, "Runtime export", runtimeExportName, Hidden); } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs index 7ab79c353fc7e8..6b4aca455a2a28 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs @@ -62,7 +62,7 @@ public uint GetStateMachineThisVariableTypeIndex(TypeDesc type) ClassTypeDescriptor classTypeDescriptor = new ClassTypeDescriptor { IsStruct = 1, - Name = $"StateMachineLocals_{System.Reflection.Metadata.Ecma335.MetadataTokens.GetToken(((EcmaType)defType.GetTypeDefinition()).Handle):X}", + Name = new Utf8String($"StateMachineLocals_{System.Reflection.Metadata.Ecma335.MetadataTokens.GetToken(((EcmaType)defType.GetTypeDefinition()).Handle):X}"), InstanceSize = defType.InstanceByteCount.IsIndeterminate ? 0 : (ulong)defType.InstanceByteCount.AsInt, }; @@ -123,7 +123,7 @@ static bool TryGetGeneratedNameKind(string name, out char kind) { FieldTypeIndex = fieldTypeIndex, Offset = (ulong)fieldOffsetEmit, - Name = fieldNameEmit + Name = new Utf8String(fieldNameEmit) }; fieldsDescs.Add(field); @@ -789,7 +789,7 @@ private void InsertStaticFieldRegionMember(List fieldDescs, ClassTypeDescriptor helperClassTypeDescriptor = new ClassTypeDescriptor { IsStruct = 1, - Name = $"__ThreadStaticHelper<{classTypeDescriptor.Name}>", + Name = new Utf8String($"__ThreadStaticHelper<{classTypeDescriptor.Name}>"), BaseClassId = 0 }; var pointerTypeDescriptor = new PointerTypeDescriptor @@ -805,13 +805,13 @@ private void InsertStaticFieldRegionMember(List fieldDescs, { FieldTypeIndex = _objectWriter.GetPointerTypeIndex(pointerTypeDescriptor), Offset = 0, - Name = "TypeManagerSlot" + Name = new Utf8String("TypeManagerSlot"u8) }, new DataFieldDescriptor { FieldTypeIndex = GetVariableTypeIndex(defType.Context.GetWellKnownType(Is64Bit? WellKnownType.Int64 : WellKnownType.Int32), true), Offset = (ulong)NodeFactory.Target.PointerSize, - Name = "ClassIndex" + Name = new Utf8String("ClassIndex"u8) } }; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/WindowsNodeMangler.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/WindowsNodeMangler.cs index 336badab4639f4..b41a612223e77c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/WindowsNodeMangler.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/WindowsNodeMangler.cs @@ -15,10 +15,10 @@ public class WindowsNodeMangler : NodeMangler { private TargetDetails _target; - public static Utf8String NonGCStaticMemberName = "__NONGCSTATICS"; - public static Utf8String GCStaticMemberName = "__GCSTATICS"; - public static Utf8String ThreadStaticMemberName = "__THREADSTATICS"; - public static Utf8String ThreadStaticIndexName = "__THREADSTATICINDEX"; + public static Utf8String NonGCStaticMemberName = new Utf8String("__NONGCSTATICS"u8); + public static Utf8String GCStaticMemberName = new Utf8String("__GCSTATICS"u8); + public static Utf8String ThreadStaticMemberName = new Utf8String("__THREADSTATICS"u8); + public static Utf8String ThreadStaticIndexName = new Utf8String("__THREADSTATICINDEX"u8); public WindowsNodeMangler(TargetDetails target) { @@ -116,9 +116,9 @@ public sealed override Utf8String ExternMethod(Utf8String unmangledName, MethodD return callConv switch { - UnmanagedCallingConventions.Stdcall => $"_{unmangledName}@{signatureBytes}", - UnmanagedCallingConventions.Fastcall => $"@{unmangledName}@{signatureBytes}", - UnmanagedCallingConventions.Cdecl => $"_{unmangledName}", + UnmanagedCallingConventions.Stdcall => new Utf8String($"_{unmangledName}@{signatureBytes}"), + UnmanagedCallingConventions.Fastcall => new Utf8String($"@{unmangledName}@{signatureBytes}"), + UnmanagedCallingConventions.Cdecl => new Utf8String($"_{unmangledName}"), _ => throw new System.NotImplementedException() }; } @@ -130,7 +130,7 @@ public sealed override Utf8String ExternVariable(Utf8String unmangledName) return unmangledName; } - return $"_{unmangledName}"; + return Utf8String.Concat("_"u8, unmangledName.AsSpan()); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunCodegenNodeFactory.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunCodegenNodeFactory.cs index a3160b962d82cc..99c8cbd2126047 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunCodegenNodeFactory.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunCodegenNodeFactory.cs @@ -1067,7 +1067,7 @@ public Utf8String GetSymbolAlternateName(ISymbolNode node, out bool isHidden) isHidden = false; if (node == Header) { - return new Utf8String("RTR_HEADER"u8.ToArray()); + return new Utf8String("RTR_HEADER"u8); } return default; } diff --git a/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs b/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs index 4f705b6453141a..5186f812e6d93f 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs @@ -608,30 +608,30 @@ private ISymbolNode GetHelperFtnUncached(CorInfoHelpFunc ftnNum) id = ReadyToRunHelper.NewObject; break; case CorInfoHelpFunc.CORINFO_HELP_NEWSFAST: - return _compilation.NodeFactory.ExternFunctionSymbol("RhpNewFast"); + return _compilation.NodeFactory.ExternFunctionSymbol(new Utf8String("RhpNewFast"u8)); case CorInfoHelpFunc.CORINFO_HELP_NEWSFAST_FINALIZE: - return _compilation.NodeFactory.ExternFunctionSymbol("RhpNewFinalizable"); + return _compilation.NodeFactory.ExternFunctionSymbol(new Utf8String("RhpNewFinalizable"u8)); case CorInfoHelpFunc.CORINFO_HELP_NEWSFAST_ALIGN8: - return _compilation.NodeFactory.ExternFunctionSymbol("RhpNewFastAlign8"); + return _compilation.NodeFactory.ExternFunctionSymbol(new Utf8String("RhpNewFastAlign8"u8)); case CorInfoHelpFunc.CORINFO_HELP_NEWSFAST_ALIGN8_FINALIZE: - return _compilation.NodeFactory.ExternFunctionSymbol("RhpNewFinalizableAlign8"); + return _compilation.NodeFactory.ExternFunctionSymbol(new Utf8String("RhpNewFinalizableAlign8"u8)); case CorInfoHelpFunc.CORINFO_HELP_NEWSFAST_ALIGN8_VC: - return _compilation.NodeFactory.ExternFunctionSymbol("RhpNewFastMisalign"); + return _compilation.NodeFactory.ExternFunctionSymbol(new Utf8String("RhpNewFastMisalign"u8)); case CorInfoHelpFunc.CORINFO_HELP_NEWARR_1_DIRECT: id = ReadyToRunHelper.NewArray; break; case CorInfoHelpFunc.CORINFO_HELP_NEWARR_1_PTR: - return _compilation.NodeFactory.ExternFunctionSymbol("RhpNewPtrArrayFast"); + return _compilation.NodeFactory.ExternFunctionSymbol(new Utf8String("RhpNewPtrArrayFast"u8)); case CorInfoHelpFunc.CORINFO_HELP_NEWARR_1_ALIGN8: - return _compilation.NodeFactory.ExternFunctionSymbol("RhpNewArrayFastAlign8"); + return _compilation.NodeFactory.ExternFunctionSymbol(new Utf8String("RhpNewArrayFastAlign8"u8)); case CorInfoHelpFunc.CORINFO_HELP_NEWARR_1_VC: - return _compilation.NodeFactory.ExternFunctionSymbol("RhpNewArrayFast"); + return _compilation.NodeFactory.ExternFunctionSymbol(new Utf8String("RhpNewArrayFast"u8)); case CorInfoHelpFunc.CORINFO_HELP_STACK_PROBE: - return _compilation.NodeFactory.ExternFunctionSymbol("RhpStackProbe"); + return _compilation.NodeFactory.ExternFunctionSymbol(new Utf8String("RhpStackProbe"u8)); case CorInfoHelpFunc.CORINFO_HELP_POLL_GC: - return _compilation.NodeFactory.ExternFunctionSymbol("RhpGcPoll"); + return _compilation.NodeFactory.ExternFunctionSymbol(new Utf8String("RhpGcPoll"u8)); case CorInfoHelpFunc.CORINFO_HELP_LMUL: id = ReadyToRunHelper.LMul; @@ -788,9 +788,9 @@ private ISymbolNode GetHelperFtnUncached(CorInfoHelpFunc ftnNum) break; case CorInfoHelpFunc.CORINFO_HELP_VALIDATE_INDIRECT_CALL: - return _compilation.NodeFactory.ExternIndirectFunctionSymbol("__guard_check_icall_fptr"); + return _compilation.NodeFactory.ExternIndirectFunctionSymbol(new Utf8String("__guard_check_icall_fptr"u8)); case CorInfoHelpFunc.CORINFO_HELP_DISPATCH_INDIRECT_CALL: - return _compilation.NodeFactory.ExternIndirectFunctionSymbol("__guard_dispatch_icall_fptr"); + return _compilation.NodeFactory.ExternIndirectFunctionSymbol(new Utf8String("__guard_dispatch_icall_fptr"u8)); default: throw new NotImplementedException(ftnNum.ToString()); @@ -803,7 +803,7 @@ private ISymbolNode GetHelperFtnUncached(CorInfoHelpFunc ftnNum) ISymbolNode entryPoint; if (mangledName != null) - entryPoint = _compilation.NodeFactory.ExternFunctionSymbol(mangledName); + entryPoint = _compilation.NodeFactory.ExternFunctionSymbol(new Utf8String(mangledName)); else entryPoint = _compilation.NodeFactory.MethodEntrypoint(methodDesc); @@ -1654,7 +1654,7 @@ private void getCallInfo(ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_RESO // If this is LDVIRTFTN of an interface method that is part of a verifiable delegate creation sequence, // RyuJIT is not going to use this value. pResult->exactContextNeedsRuntimeLookup = false; - pResult->codePointerOrStubLookup.constLookup = CreateConstLookupToSymbol(_compilation.NodeFactory.ExternFunctionSymbol("NYI_LDVIRTFTN")); + pResult->codePointerOrStubLookup.constLookup = CreateConstLookupToSymbol(_compilation.NodeFactory.ExternFunctionSymbol(new Utf8String("NYI_LDVIRTFTN"u8))); } else { @@ -1923,7 +1923,7 @@ private void getAddressOfPInvokeTarget(CORINFO_METHOD_STRUCT_* method, ref CORIN { MethodDesc md = HandleToObject(method); - Utf8String externName = _compilation.PInvokeILProvider.GetDirectCallExternName(md); + Utf8String externName = new Utf8String(_compilation.PInvokeILProvider.GetDirectCallExternName(md)); externName = _compilation.NodeFactory.NameMangler.NodeMangler.ExternMethod(externName, md); pLookup = CreateConstLookupToSymbol(_compilation.NodeFactory.ExternFunctionSymbol(externName)); @@ -1933,7 +1933,7 @@ private void getGSCookie(IntPtr* pCookieVal, IntPtr** ppCookieVal) { if (ppCookieVal != null) { - *ppCookieVal = (IntPtr*)ObjectToHandle(_compilation.NodeFactory.ExternVariable("__security_cookie")); + *ppCookieVal = (IntPtr*)ObjectToHandle(_compilation.NodeFactory.ExternVariable(new Utf8String("__security_cookie"u8))); *pCookieVal = IntPtr.Zero; } else @@ -2069,7 +2069,7 @@ private void updateEntryPointForTailCall(ref CORINFO_CONST_LOOKUP entryPoint) private int* getAddrOfCaptureThreadGlobal(ref void* ppIndirection) { ppIndirection = null; - return (int*)ObjectToHandle(_compilation.NodeFactory.ExternVariable("RhpTrapThreads")); + return (int*)ObjectToHandle(_compilation.NodeFactory.ExternVariable(new Utf8String("RhpTrapThreads"u8))); } private void getFieldInfo(ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_METHOD_STRUCT_* callerHandle, CORINFO_ACCESS_FLAGS flags, CORINFO_FIELD_INFO* pResult) @@ -2482,10 +2482,10 @@ private bool getStaticBaseAddress(CORINFO_CLASS_STRUCT_* cls, bool isGc, ref COR private void getThreadLocalStaticInfo_NativeAOT(CORINFO_THREAD_STATIC_INFO_NATIVEAOT* pInfo) { pInfo->offsetOfThreadLocalStoragePointer = (uint)(11 * PointerSize); // Offset of ThreadLocalStoragePointer in the TEB - pInfo->tlsIndexObject = CreateConstLookupToSymbol(_compilation.NodeFactory.ExternDataSymbol("_tls_index")); + pInfo->tlsIndexObject = CreateConstLookupToSymbol(_compilation.NodeFactory.ExternDataSymbol(new Utf8String("_tls_index"u8))); pInfo->tlsRootObject = CreateConstLookupToSymbol(_compilation.NodeFactory.TlsRoot); pInfo->threadStaticBaseSlow = CreateConstLookupToSymbol(_compilation.NodeFactory.HelperEntrypoint(HelperEntrypoint.GetInlinedThreadStaticBaseSlow)); - pInfo->tlsGetAddrFtnPtr = CreateConstLookupToSymbol(_compilation.NodeFactory.ExternFunctionSymbol("__tls_get_addr")); + pInfo->tlsGetAddrFtnPtr = CreateConstLookupToSymbol(_compilation.NodeFactory.ExternFunctionSymbol(new Utf8String("__tls_get_addr"u8))); } #pragma warning disable CA1822 // Mark members as static