Skip to content
This repository was archived by the owner on Nov 13, 2026. It is now read-only.

Add support for variant interface dispatch - #1172

Merged
MichalStrehovsky merged 5 commits into
dotnet:masterfrom
MichalStrehovsky:variantDispatch
Apr 25, 2016
Merged

MichalStrehovsky merged 5 commits into
dotnet:masterfrom
MichalStrehovsky:variantDispatch

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

Depends on the updated runtime data structure from #1171.

This change is to emit the new rare fields within the EEType so that at
runtime, we can perform variant interface calls (example: call
IEnumerable<object>.GetEnumerator() on string[]).

for (int j = 0; j < _variantInterfacesImplemented.Count; j++)
{
// TODO: this should really use CanCastTo/IsAssignable
if (targetInterface.GetTypeDefinition() == _variantInterfacesImplemented[j].GetTypeDefinition())

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make CanCastTo a separate pull request to keep things clean. I'll start on it tomorrow in parallel.

@MichalStrehovsky
MichalStrehovsky force-pushed the variantDispatch branch 2 times, most recently from 9826cea to df4e178 Compare April 23, 2016 22:28
@MichalStrehovsky

Copy link
Copy Markdown
Member Author

Two more things are remaining so I'm keeping the WIP tag:

  • Measure the size on disk impact of this
  • Make it so that CppCodegen doesn't get a heart attack when it sees a generic type definition EEType being generated :/. I'll do a separate pull request.

Depends on the updated runtime data structure from dotnet#1171.

This change is to emit the new rare fields within the EEType so that at
runtime, we can perform variant interface calls (example: call
`IEnumerable<object>.GetEnumerator()` on `string[]`).
Do not try to optimize variant interfaces to just emitting them if
they're used. Determining if they're used is expensive.
@MichalStrehovsky MichalStrehovsky changed the title [WIP] Add support for variant interface dispatch Add support for variant interface dispatch Apr 25, 2016
@MichalStrehovsky

Copy link
Copy Markdown
Member Author

@jkotas @davidwrighton Pushed an updated version that removes the attempt to optimize the number of interface methods we end up implementing, and makes CppCodegen limp along for the moment (the real fix for that is to make it use the ObjectNode structures for EEType and friends).

The size on disk impact on Hello world is:

  • Master branch: Hello.obj: 3,393,505 bytes
  • This branch: Hello.obj: 4,471,857 bytes

Pretty damn big. Pretty much all the cost comes from arrays.

@davidwrighton

Copy link
Copy Markdown
Member

Sigh. Well, its no real surprise. LGTM, although this is more ammunition for wanting to come up with a way to decide to use the USG for most of these.

@MichalStrehovsky
MichalStrehovsky merged commit b2bbdbd into dotnet:master Apr 25, 2016
@MichalStrehovsky
MichalStrehovsky deleted the variantDispatch branch April 25, 2016 21:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants