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

[CompilerPerf] Remove unbox.any when coercing to subsumed interfaces #2972

Merged
merged 4 commits into from
May 2, 2017

Conversation

manofstick
Copy link
Contributor

As commented upon here and manually avoided in #2587 (Such as this) this PR removes the IL instruction unbox.any from upcasts to interface types.

Previously code like:

let f b : seq<_> =
    if b then upcast [||] else upcast []

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.

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
Copy link
Contributor

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

Copy link
Contributor Author

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!

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*) ]
Copy link
Contributor

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.

@forki
Copy link
Contributor

forki commented May 2, 2017

looks like it touched IL test. so that's a good thing I guess

@dsyme
Copy link
Contributor

dsyme commented May 2, 2017

Approved once test is fixed - thanks for doing this

Copy link
Member

@KevinRansom KevinRansom left a 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

@KevinRansom
Copy link
Member

@manofstick
Thank you for this, it looks good.

@KevinRansom KevinRansom merged commit 9535c7a into dotnet:master May 2, 2017
manofstick added a commit to manofstick/visualfsharp that referenced this pull request May 3, 2017
manofstick added a commit to manofstick/visualfsharp that referenced this pull request May 7, 2017
manofstick added a commit to manofstick/visualfsharp that referenced this pull request May 8, 2017
manofstick added a commit to manofstick/visualfsharp that referenced this pull request May 8, 2017
manofstick added a commit to manofstick/visualfsharp that referenced this pull request May 9, 2017
manofstick added a commit to manofstick/visualfsharp that referenced this pull request May 13, 2017
manofstick added a commit to manofstick/visualfsharp that referenced this pull request May 13, 2017
manofstick added a commit to manofstick/visualfsharp that referenced this pull request May 15, 2017
manofstick added a commit to manofstick/visualfsharp that referenced this pull request May 17, 2017
manofstick added a commit to manofstick/visualfsharp that referenced this pull request May 18, 2017
manofstick added a commit to manofstick/visualfsharp that referenced this pull request Jun 22, 2017
manofstick added a commit to manofstick/visualfsharp that referenced this pull request Jun 22, 2017
manofstick added a commit to manofstick/visualfsharp that referenced this pull request Aug 16, 2017
manofstick added a commit to manofstick/visualfsharp that referenced this pull request Aug 17, 2017
manofstick added a commit to manofstick/visualfsharp that referenced this pull request Sep 12, 2017
manofstick added a commit to manofstick/visualfsharp that referenced this pull request Sep 12, 2017
manofstick added a commit to manofstick/visualfsharp that referenced this pull request Sep 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants