Skip to content

Commit

Permalink
Move IIDDataField out of generic types (microsoft#1340)
Browse files Browse the repository at this point in the history
  • Loading branch information
hez2010 authored and dongle-the-gadget committed Jul 29, 2023
1 parent 7033f3e commit edc9526
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Perf/IIDOptimizer/SignatureEmitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,14 @@ private void GenerateGuidFactoryFromComplexSignature(TypeDefinition implementati
case StringStep(string str):
{
byte[] segmentBytes = Encoding.UTF8.GetBytes(str);
var staticDataField = new FieldDefinition($"<SignatureDataPart={i}>", FieldAttributes.Private | FieldAttributes.InitOnly | FieldAttributes.Static | FieldAttributes.HasFieldRVA, CecilExtensions.GetOrCreateDataBlockType(implementationDetailsType, segmentBytes.Length))
var staticDataField = new FieldDefinition($"<IIDDataField>{describedType.FullName}<SignatureDataPart={i}>", FieldAttributes.Private | FieldAttributes.InitOnly | FieldAttributes.Static | FieldAttributes.HasFieldRVA, CecilExtensions.GetOrCreateDataBlockType(implementationDetailsType, segmentBytes.Length))
{
InitialValue = segmentBytes
};
cacheType.Fields.Add(staticDataField);
implementationDetailsType.Fields.Add(staticDataField);

// Load a ReadOnlySpan<byte> of the signature segment into the local for this step.
il.Emit(OpCodes.Ldsflda, new FieldReference(staticDataField.Name, staticDataField.FieldType, selfInstantiatedCacheType));
il.Emit(OpCodes.Ldsflda, new FieldReference(staticDataField.Name, staticDataField.FieldType, implementationDetailsType));
il.Emit(OpCodes.Ldc_I4, segmentBytes.Length);
il.Emit(OpCodes.Newobj, readOnlySpanOfBytePtrCtor);
il.Emit(OpCodes.Stloc, signatureParts[i]);
Expand Down

0 comments on commit edc9526

Please sign in to comment.