Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Reflection.Metadata;

using Internal.Text;
using Internal.TypeSystem;
using Internal.TypeSystem.Ecma;

using Debug = System.Diagnostics.Debug;
Expand Down Expand Up @@ -57,8 +58,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)

if (factory.OptimizationFlags.StripILBodies
&& factory.OptimizationFlags.CompiledMethodDefs.Contains(_method)
&& !_method.HasInstantiation
&& !_method.OwningType.HasInstantiation)
&& !MayNeedILAtRuntime(_method))
{
return new ObjectData(s_minimalILBody, Array.Empty<Relocation>(), 4, new ISymbolDefinitionNode[] { this });
}
Expand All @@ -72,6 +72,23 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
return new ObjectData(bodyBytes, Array.Empty<Relocation>(), 4, new ISymbolDefinitionNode[] { this });
}

private static bool MayNeedILAtRuntime(MethodDesc method)
{
if (method.HasInstantiation || method.OwningType.HasInstantiation)
{
// IL may be needed for new instantiations
Comment thread
jakobbotsch marked this conversation as resolved.
return true;
}

if (method.GetTypicalMethodDefinition().Signature.ReturnsTaskOrValueTask() && !method.IsAsync)
{
// IL may be needed for async version of non-async Task-returning method
Comment thread
jakobbotsch marked this conversation as resolved.
return true;
}

return false;
}

public override int ClassCode => 541651465;

public override int CompareToImpl(ISortableNode other, CompilerComparer comparer)
Expand Down
Loading