-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Generate P/Invoke transitions for CoreRT. #3044
Conversation
This change adds support for CoreRT-style P/Invoke transitions to RyuJIT. Instead of the usual inlined transition code, these transitions are made up of calls to two new JIT helpers: PInvokeTransitionFrame frame; // opaque local CORINFO_HELP_INIT_PINVOKE_FRAME(&frame); ... CORINFO_HELP_JIT_PINVOKE_BEGIN(&frame); target(...); CORINFO_HELP_JIT_PINVOKE_END(&frame); ... The preemptive mode constraints apply between calls to JIT_PINVOKE_BEGIN and JIT_PINVOKE_END: no managed references may be live only in registers and managed references may not be manipulated.
@jkotas @dotnet/jit-contrib PTAL |
@BruceForstall PTAL |
src/inc/corjit.h
Outdated
CORJIT_FLG_NO_MDIL = 0x00010000, // Generate an MDIL section but no code or CTL. Not used by the JIT, used internally by NGen only. | ||
#else // MDIL | ||
CORJIT_FLG_CFI_UNWIND = 0x00004000, // Emit CFI unwind info | ||
#endif // MDIL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you change this? It was intentional as it was, to keep identical bit patterns together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you change this?
This was part of the earlier change (which had FLG_USE_PINVOKE_HELPERS
instead of FLG_CFI_UNWIND
); I kept it when I rebased.
It was intentional as it was, to keep identical bit patterns together.
If we believe that keeping identical bit patterns together is important, then we should apply that to the rest of the file (e.g. the definitions for CORJIT_FLG_MAKEFINALCODE
and CORJIT_FLG_READYTORUN
should be next to CORJIT_FLG_MINIMAL_MDIL
and CORJIT_FLG_NO_MDIL
, respectively). I'm fine with either keeping all of the bits that are affected by an particular symbol together or keeping the bits themselves together. I have a minor preference for the former since it makes it easier to understand what changes when a given symbol is defined. Note that we already use that style for processor-specific preprocessor symbols.
It would be nice to see a comment somewhere in the code (maybe by genPInvokeProlog(?)) that describes what the p/invoke function characteristics are (i.e., what the function looks like) with the new model, with examples. |
What characteristics are you looking for? Calling convention, signature, etc.? |
Or just the shape of the generated code? |
all of the above |
Feedback has been addressed; PTAL. |
LGTM |
@dotnet-bot test this please |
Generate P/Invoke transitions for CoreRT.
This change adds support for CoreRT-style P/Invoke transitions
to RyuJIT. Instead of the usual inlined transition code, these
transitions are made up of calls to two new JIT helpers:
The preemptive mode constraints apply between calls to
JIT_PINVOKE_BEGIN and JIT_PINVOKE_END: no managed references
may be live only in registers and managed references may not
be manipulated.
Note that this is a rebased version of the code from #2817.