This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Repository navigation
Add the DebuggableAttribute to System.Runtime.CompilerServices.Unsafe. - #40772
Merged
Merged
Conversation
stephentoub
reviewed
Sep 3, 2019
| <!-- Make sure that the DebuggableAttribute is set properly. --> | ||
| <PropertyGroup> | ||
| <DebugOptimization>IMPL</DebugOptimization> | ||
| <DebugOptimization Condition="'$(ConfigurationGroup)' == 'Release'">OPT</DebugOptimization> |
Member
There was a problem hiding this comment.
Is there a downside to just always using OPT for this project?
Member
Author
There was a problem hiding this comment.
I'm not 100% sure. I was attempting to match what we see for debug and release builds on other binaries in an attempt to not make this one special.
stephentoub
approved these changes
Sep 3, 2019
stephentoub
left a comment
Member
There was a problem hiding this comment.
Assuming you've validated the resulting binaries look the way we desire, LGTM.
Member
Author
|
Excellent. Thanks. Yes, I have validated that the attribute is set correctly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
System.Runtime.CompilerServices.Unsafe.dll is produced from IL rather than C#, and so it does not by default have a DebuggableAttribute. As such, it is possible to end up in a place where JIT optimizations that are expected to be applied, such as inlining, are not due to the fact that the JIT uses the DebuggableAttribute as part of the calculation at inlining time. I believe that none of the methods in this assembly are currently affected, as they are all marked as aggressivelyinline, but going forward, any method that is not marked in such a way would likely not be inlined.
This change adds the appropriate DebuggableAttribute to Debug and Release versions of System.Runtime.CompilerServices.Unsafe.dll. This is the only assembly in the shared framework that does not have a DebuggableAttribute already. A search of CoreFx turned this assembly up as the only one that is IL-based.
NOTE: This PR is the result of a WPF performance investigation that identified the lack of a DebuggableAttribute as the reason that the JIT didn't inline things that it previously had. Ultimately, we found that the -DEBUG flag wasn't being passed to ilasm. Fixing this addressed the regression, and thus the desire to identify any other assemblies that might fall into this trap.