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

Enable native metadata generation - #916

Merged
MichalStrehovsky merged 2 commits into
dotnet:masterfrom
MichalStrehovsky:mdgenerate
Mar 16, 2016
Merged

MichalStrehovsky merged 2 commits into
dotnet:masterfrom
MichalStrehovsky:mdgenerate

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member
  • Add code to generate a metadata blob containing type definition
    metadata for all types that had an EEType generated in the current
    compilation.
  • Hook up Reflection.Execution by rooting the static constructor on
    ReflectionExecution (this constructor is eager - just rooting it makes
    it run).
  • Add mock implementation of RhFindBlob that lets us find blob 13 -
    metadata blob

This should be enough to support Type.GetType("SomeType, SomeAssembly"). It's not enough to support things like
foo.GetType().GetTypeInfo().FullName - we need mapping table
generation for that.

Remaining work:

Not needed to pass CI, but needed to light up the feature:

internal static uint RhGetLoadedModules(IntPtr[] resultArray)
{
// CORERT-TODO: This got broken within the last week or so. We don't care for single file.
if (resultArray != null)

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.

@nattress is it possible that the multifile changes broke RhGetLoadedModules and RhGetModuleFromEEType? I'm pretty sure the first one used to work.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, this got changed because of there is no 1:1 mapping between OS .dll and library for the multi file work.

To fix it:

  • Change RhGetModuleFromEEType to return *(this->m_ppModuleManager) under CORERT ifdef.
  • Change FindBlob to something like return pModuleManager->GetModuleSection(300 + blobId).
  • Store pointers to metadata blobs and mapping tables via ReadyToRunHeader in NodeFactory.cs

Hopefully, these changes will make the whole thing much cleaner.

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.

Thanks! Yes, I was expecting something like that to be the long term plan.

How about RhGetLoadedModules? Right now it seems like the runtime doesn't care about the list of modules loaded into the process. Should that be maintained at the FX level in the array initialized at the process startup, or should the runtime maintain it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it is more appropriate for System.Private.CoreLib to maintain it - storing the array of modules to a static in StartupCodeHelpers.InitializeModules should do it with what we have.

@MichalStrehovsky
MichalStrehovsky force-pushed the mdgenerate branch 3 times, most recently from 0f899e4 to 92ad500 Compare March 16, 2016 17:48
@MichalStrehovsky MichalStrehovsky changed the title [WIP] Enable native metadata generation Enable native metadata generation Mar 16, 2016
@MichalStrehovsky

Copy link
Copy Markdown
Member Author

I took out the changes that actually light up reflection to a different branch for now.

This pull request is now limited to the non-controversial parts (generating the blobs and initializing the reflection subsystem). Reflection will not work, but at least we will start exercising the code paths.

@jkotas PTAL

Comment thread src/Native/Runtime/inc/eetype.h Outdated
{ return (m_usFlags & IsGenericFlag) != 0; }

#if defined(CORERT)
ModuleManager* GetModule()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

GetModuleManager may be a better name. Also, could you please change the one existing places that does *m_ppModuleManager to call this method instead?

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.

Do we really want to stick with ModuleManager? I was thinking about proposing to rename it to Module at some point, because ModuleManager makes me think of something that manages modules (this happened on multiple occasions before I got used to it). This thing represents a module, it doesn't manage them...

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.

(Or maybe ReadyToRunModule so that it doesn't clash with the Module that is already defined in Redhawk and corresponds to the OS module.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There are too many different existing things called module. I know that ModuleManager is not a great name ... I would love to have a better name, but I think it should be something more specific than Module.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(One option may be TypeSystemManager - similar to CodeManager.)

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.

Renamed to GetModuleManager. It still feels funny though that a ModuleManager (or TypeSystemManager) would have a method called GetModuleSection that doesn't require the caller to specify what module to operate on, because the Manager is the Module. We also pretty much always store the ModuleManager in a variable called module...

Maybe the naming will become clear to me as we add more functionality to the Manager.

@jkotas

jkotas commented Mar 16, 2016

Copy link
Copy Markdown
Member

LGTM otherwise

* Add code to generate a metadata blob containing type definition
metadata for all types that had an EEType generated in the current
compilation.
* Hook up Reflection.Execution by rooting the static constructor on
ReflectionExecution (this constructor is eager - just rooting it makes
it run).
* Add mock implementation of RhFindBlob that lets us find blob 13 -
metadata blob

This should be enough to support `Type.GetType("SomeType,
SomeAssembly")`. It's not enough to support things like
`foo.GetType().GetTypeInfo().FullName` - we need mapping table
generation for that.
EETypeRva field is now an EEType pointer.
@MichalStrehovsky

Copy link
Copy Markdown
Member Author

Hmmm, this pull request has been in a permanent "build triggered" state for days. Asking dotnet bot to retest this doesn't help. I just pushed new commits to it and it still didn't change anything. Pull request 1017 I submitted after this is way ahead...

@mmitche Any idea why?

@jkotas jkotas closed this Mar 16, 2016
@jkotas jkotas reopened this Mar 16, 2016
MichalStrehovsky added a commit that referenced this pull request Mar 16, 2016
Enable native metadata generation
@MichalStrehovsky
MichalStrehovsky merged commit f4710eb into dotnet:master Mar 16, 2016
@MichalStrehovsky
MichalStrehovsky deleted the mdgenerate branch March 16, 2016 20:58
@mmitche

mmitche commented Mar 17, 2016

Copy link
Copy Markdown
Member

@MichalStrehovsky If you see a case like this, you can hit "Close Pull request" and then "Reopen pull request".

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.

4 participants