Skip to content

Commit

Permalink
Do not generate cctor info on generic definition MethodTable (#79689)
Browse files Browse the repository at this point in the history
This is already wrong, irrespective of #79384.
  • Loading branch information
MichalStrehovsky authored Dec 15, 2022
1 parent caa0bd5 commit 53bcf1c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,6 @@ private unsafe void FinishClassConstructor(TypeDesc type, TypeBuilderState state
if (!state.HasStaticConstructor)
return;

Debug.Assert(state.ClassConstructorPointer.HasValue);
IntPtr canonicalClassConstructorFunctionPointer = state.ClassConstructorPointer.Value;

IntPtr generatedTypeStaticData = GetRuntimeTypeHandle(type).ToEETypePtr()->DynamicNonGcStaticsData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,7 @@ public ushort NumVTableSlots
public int GcDataSize;
public int ThreadDataSize;

public bool HasStaticConstructor
{
get { return TypeBeingBuilt.HasStaticConstructor; }
}
public bool HasStaticConstructor => ClassConstructorPointer.HasValue;

public IntPtr? ClassConstructorPointer;
public IntPtr GcStaticDesc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,13 @@ protected internal override TypeDesc ConvertToCanon(TypeDesc typeToConvert, Cano

protected internal override bool ComputeHasStaticConstructor(TypeDesc type)
{
if (type.RetrieveRuntimeTypeHandleIfPossible())
{
unsafe
{
return type.RuntimeTypeHandle.ToEETypePtr()->HasCctor;
}
}
Debug.Assert(type is not DefType);
return false;
// This assumes we can compute the information from a type definition
// (`type` is going to be a definition here because that's how the type system is structured).
// We don't maintain consistency for this at runtime. Different instantiations of
// a single definition may or may not have a static constructor after AOT compilation.
// Asking about this for a definition is an invalid question.
// If this is ever needed, we need to restructure things in the common type system.
throw new NotImplementedException();
}

public override bool SupportsUniversalCanon => false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ protected override ObjectData GetDehydratableData(NodeFactory factory, bool relo
EETypeRareFlags rareFlags = 0;

uint flags = EETypeBuilderHelpers.ComputeFlags(_type);
if (factory.PreinitializationManager.HasLazyStaticConstructor(_type))
rareFlags |= EETypeRareFlags.HasCctorFlag;
if (_type.IsByRefLike)
rareFlags |= EETypeRareFlags.IsByRefLikeFlag;

Expand Down

0 comments on commit 53bcf1c

Please sign in to comment.