-
Notifications
You must be signed in to change notification settings - Fork 786
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
[CompilerPerf] Remove unbox.any when coercing to subsumed interfaces #2972
Conversation
src/fsharp/IlxGen.fs
Outdated
if (isInterfaceTy cenv.g tgty) then ( | ||
GenExpr cenv cgbuf eenv SPSuppress e Continue | ||
let ilToTy = GenType cenv.amap m eenv.tyenv tgty | ||
CG.EmitInstrs cgbuf (pop 1) (Push [ilToTy]) [ I_unbox_any ilToTy ] | ||
// I believe section "III.1.8.1.3 Merging stack states" of ECMA-335 implies that no unboxing |
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.
Can you please reformulate this to remove the "I"? Thx
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.
haha, well I was hoping someone who confirm that, and then it wouldn't be total based on my potentially misaken belief!
src/fsharp/IlxGen.fs
Outdated
CG.EmitInstrs cgbuf (pop 1) (Push [ilToTy]) [ I_unbox_any ilToTy ] | ||
// I believe section "III.1.8.1.3 Merging stack states" of ECMA-335 implies that no unboxing | ||
// is required, but we still push the coerce'd type on to the code gen buffer. | ||
CG.EmitInstrs cgbuf (pop 1) (Push [ilToTy]) [ (*I_unbox_any ilToTy*) ] |
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.
Please remove the commented code directly.
looks like it touched IL test. so that's a good thing I guess |
Approved once test is fixed - thanks for doing this |
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.
Interesting change. Looks good
@manofstick |
As commented upon here and manually avoided in #2587 (Such as this) this PR removes the IL instruction
unbox.any
fromupcast
s to interface types.Previously code like:
Would insert the upcast.any statement into the result of both branches, but from my reading of "III.1.8.1.3 Merging stack states" of ECMA-335 the runtime automatically will merge the stacks to the common subtype. This appears to be borne out in practice.
This PR will simplify the #2587 by removing all the manual Upcast hacks that are done.