Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CppCodeGen] Enable reflection #2035

Closed
jkotas opened this Issue Oct 16, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@jkotas
Copy link
Member

jkotas commented Oct 16, 2016

@rolandh

This comment has been minimized.

Copy link

rolandh commented May 1, 2017

Do you guys have anything in mind with how you will achieve this? Will you effectively build some sort of metadata cache?

I am very interested in this.

@MichalStrehovsky

This comment has been minimized.

Copy link
Member

MichalStrehovsky commented May 1, 2017

This would reuse the same scheme we already have for the RyuJIT codegen path:

  • The compiler generates a blob of bytes that describes the metadata (namespaces, types, their members, their custom attributes, method parameters, etc.). The data is generated as a byte array in the ComputeMetadata method.
  • The metadata gets embedded as a data blob into the executable image. This is achieved by adding the blob to a "ready to run header". Ready to run header is a well known data structure that can be located by the code in the framework at runtime.
  • The ready to run header along with the blobs it refers to is emitted into the final executable.
  • At runtime, pointer to the byte array is located using the RhFindBlob API, and a parser is constructed over the array, to be used by the reflection stack.

The first step in implementing this will be to come up with a scheme where the ready to run header can be emitted into the generated code, and the byte array with the metadata can be referenced by the CppCodegen generated code. This will be something similar to what we do for the EEType data structure.

That should be enough to get Type.GetType("System.Object, System.Private.CoreLib") working with CppCodegen.

More work will be needed to emit what we call "mapping tables" that map runtime artifacts (method entrypoints, static bases for fields, runtime type structures, etc.) to the records described in the byte array. The mapping tables are necessary to get the more interesting APIs working, such as Object.GetType(), MethodInfo.Invoke(), FieldInfo.GetValue, etc. But that's a next step. The byte array with the metadata is a necessary prerequisite.

@rolandh

This comment has been minimized.

Copy link

rolandh commented Mar 7, 2018

Just wondering how this was progressing. Is it realistically ever likely to produce a working exe from a wpf project?

@MichalStrehovsky

This comment has been minimized.

Copy link
Member

MichalStrehovsky commented Jan 11, 2019

This was fixed in #6700.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.