Skip to content

Commit

Permalink
ProjectX: Set the canonical unboxing stub as the template method for …
Browse files Browse the repository at this point in the history
…GVMs of structs

For GVMs that use the canonical implementation, if their owning types are structs, the canonical template should be the unboxing stub instead of the real target. However, the template signature should not have the IsUnboxingStub set because all template lookups performed at runtime are performed with this flag not set, since it can't always be conveniently computed for a concrete method before looking up its template.

[tfs-changeset: 1678892]
  • Loading branch information
dotnet-bot authored and A-And committed Oct 31, 2017
1 parent 4933d30 commit 3310ff3
Showing 1 changed file with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,6 @@ public enum MethodEntryFlags
{
CreateInstantiatedSignature = 1,
SaveEntryPoint = 2,
/// <summary>
/// IsUnboxingStub is not set for template methods (all template lookups performed at runtime are done with this flag not set,
/// since it can't always be conveniently computed for a concrete method before looking up its template).
/// </summary>
DisableUnboxingStub = 4
}

protected readonly MethodDesc _method;
Expand Down Expand Up @@ -226,9 +221,8 @@ private Vertex GetContainingTypeVertex(NodeFactory factory)

protected virtual IMethodNode GetMethodEntrypointNode(NodeFactory factory, out bool unboxingStub)
{
unboxingStub = (_flags & MethodEntryFlags.DisableUnboxingStub) != 0 ? false : _method.OwningType.IsValueType && !_method.Signature.IsStatic;
unboxingStub = _method.OwningType.IsValueType && !_method.Signature.IsStatic;
IMethodNode methodEntryPointNode = factory.MethodEntrypoint(_method, unboxingStub);

return methodEntryPointNode;
}
}
Expand Down Expand Up @@ -672,7 +666,7 @@ internal sealed class NativeLayoutTemplateMethodSignatureVertexNode : NativeLayo
protected override string GetName(NodeFactory factory) => "NativeLayoutTemplateMethodSignatureVertexNode_" + factory.NameMangler.GetMangledMethodName(_method);

public NativeLayoutTemplateMethodSignatureVertexNode(NodeFactory factory, MethodDesc method)
: base(factory, method, MethodEntryFlags.CreateInstantiatedSignature | MethodEntryFlags.SaveEntryPoint | MethodEntryFlags.DisableUnboxingStub)
: base(factory, method, MethodEntryFlags.CreateInstantiatedSignature | (method.IsVirtual ? MethodEntryFlags.SaveEntryPoint : 0))
{
}

Expand All @@ -683,8 +677,19 @@ public override Vertex WriteVertex(NodeFactory factory)
Vertex methodEntryVertex = base.WriteVertex(factory);
return SetSavedVertex(factory.MetadataManager.NativeLayoutInfo.TemplatesSection.Place(methodEntryVertex));
}
}

protected override IMethodNode GetMethodEntrypointNode(NodeFactory factory, out bool unboxingStub)
{
// Only GVM templates need entry points.
Debug.Assert(_method.IsVirtual);
unboxingStub = _method.OwningType.IsValueType;
IMethodNode methodEntryPointNode = factory.MethodEntrypoint(_method, unboxingStub);
// Note: We don't set the IsUnboxingStub flag on template methods (all template lookups performed at runtime are performed with this flag not set,
// since it can't always be conveniently computed for a concrete method before looking up its template)
unboxingStub = false;
return methodEntryPointNode;
}
}

public sealed class NativeLayoutDictionarySignatureNode : NativeLayoutSavedVertexNode
{
Expand Down

0 comments on commit 3310ff3

Please sign in to comment.