-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
JIT: Devirtualization and inlining for GVM #112353
base: main
Are you sure you want to change the base?
Conversation
Looks like CI failures are related? also, the diffs look more like inliner actually no longer inlines what it used to? |
They should be fixed with 4b809c8, where we must not allow a method
Not sure about this for now, may need more investigation. Let's see the latest run. |
Seems that the VM can dispatch a generic method if there's no method |
Devirtualizing GVM without inlining is supported now. |
No spmi diffs and only 1 method affected in jit-diffs. Can't tell it's a big improvement for that method, but it definitely implies a poor test coverage for this optimization. Since changes around method resolving are always risky - do we want to proceed? Is there a real-world motivation behind this? |
Hmm the changes need to be separated into two parts, one for VM and another one for JIT, because it needs a JIT-EE interface guid update. Otherwise the |
Thinking twice, we don't need the extra flag in |
I think it's in a great form now, while seems that it still has some bad interactions with boxed structs during inlining, need to investigate... |
Seems that lowering on windows-x86 is unhappy about not spilling the
|
We use
FindOrCreateAssociatedMethodDesc
withallowInstParam=false
to get the exactMethodDesc
for a devirted GVM.While the resulted
MethodDesc
may be an instantiation stub, so eitherInstParam
that can be fetched fromWrappedMethodDesc
if it doesn't require a runtime lookupRUNTIMELOOKUP
node we created forldvirtftn
if it requires a runtime lookup (in this caseFindOrCreateAssociatedMethodDesc
will yield us a method handle that has shared generics in the method instantiation).So if we see a
RUNTIMELOOKUP
, we push it to the call args as theInstParam
, otherwise we can use the instantiated entry of theWrappedMethodDesc
as theInstParam
.Also extend the late devirt a bit to support devirting generic virtual methods.
To make sure we can get the method handle or
RUNTIMELOOKUP
, we need to stop spillingldvirtftn
. However, NAOT and lowering is not happy aboutgtCallAddr
being aCALL
, so we split the call after inlining is done.NativeAOT/R2R is not support yet (due to fat function pointers).
Example:
Before:
After:
/cc: @jakobbotsch @AndyAyersMS