Skip to content

Conversation

@liboz
Copy link
Contributor

@liboz liboz commented Dec 24, 2016

Attempts to fix #1366

@liboz liboz changed the title Reduce IL generation in GetHashCode for Discriminated Unions [WIP] Reduce IL generation in GetHashCode for Discriminated Unions Dec 24, 2016
@liboz liboz changed the title [WIP] Reduce IL generation in GetHashCode for Discriminated Unions Reduce IL generation in GetHashCode for Discriminated Unions Dec 27, 2016
@liboz
Copy link
Contributor Author

liboz commented Dec 27, 2016

Okay this is ready for review. I had to add a boolean in the Optimizer to ensure that GetHashCode is not inlined even if it would have been possible to optimize it. This is because otherwise the hash function would not throw the expected NullReferenceException due to the reduction in IL.

(mkCombineHashGenerators g m (List.mapi (mkHash ucve) ucase1.RecdFields) (mkLocalValRef accv) acce))
Some(mkCase(Test.UnionCase(c1ref,tinst),mbuilder.AddResultTarget(test,SuppressSequencePointAtTarget)))

let nullary,nonNullary = ucases
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally please use formatting

let x,y = 
    abc def

rather than

let x,y = abc 
           def

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I'll try to remember to do so in the future. One quick clarification though: I assume it's alright if there are enough pipes in a row to put pipes on their own lines?

Also, do you want me to fix it in this PR?

@dsyme
Copy link
Contributor

dsyme commented Dec 28, 2016

Approved once tests are green

@KevinRansom KevinRansom merged commit bca9f61 into dotnet:master Dec 29, 2016
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.

Compiler creates TOO MUCH msil code in GetHashCode : IEqualityComparer -> int

4 participants