Skip to content

Support precompiling 'ComInterfaceEntry' vtables in ILC cctor interpreter (Native AOT) #114355

@Sergio0694

Description

@Sergio0694

Follow-up to #114024

Opening this for tracking as suggested by @MichalStrehovsky. This is a follow up to getting ILC to support folding CCW/RCW vtables into RVA fields. We have a similar need to also get ILC to fold ComInterfaceEntry vtables, which is what we need to return to ComWrappers from the ComputeVtables method. We have hundreds (or thousands) of these, as they're needed by every single:

  • User-defined type that's marshalled
  • Generic type instantiation (both collections and delegate types)

We'd basically need to support this:

public struct MyTypeVtableEntries
{
    public ComInterfaceEntry IWhatever;
    public ComInterfaceEntry IStringable;
    public ComInterfaceEntry IWeakReferenceSource;
    public ComInterfaceEntry IAgileObject;
    public ComInterfaceEntry IInspectable;
    public ComInterfaceEntry IUnknown;
}

public static class MyTypeImpl
{
    [FixedAddressValueType]
    private static readonly MyTypeVtableEntries VtableEntries;

    static MyTypeImpl()
    {
        VtableEntries.IWhatever.IID = new Guid(0x1234, 0x1234, 0x1234, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89);
        VtableEntries.IWhatever.Vtable = IWhateverImpl.Vftbl;
        VtableEntries.IStringable.IID = new Guid(0x1234, 0x1234, 0x1234, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89);
        VtableEntries.IStringable.Vtable = IStringableImpl.AbiToProjectionVftablePtr;
        VtableEntries.IWeakReferenceSource.IID = new Guid(0x1234, 0x1234, 0x1234, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89);
        VtableEntries.IWeakReferenceSource.Vtable = IWeakReferenceSourceImpl.AbiToProjectionVftablePtr;
        VtableEntries.IAgileObject.IID = new Guid(0x1234, 0x1234, 0x1234, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89);
        VtableEntries.IAgileObject.Vtable = IAgileObjectImpl.AbiToProjectionVftablePtr;
        // etc...
    }
}

Where:

This doesn't need to be super general. At least on our end, we only need this to work with ComInterfaceEntry specifically (from the BCL).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions