-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[trace-view] Added support for marking optimized away code lines (#19306
) ## Description In Move, there isn't necessarily 1:1 correspondence between source code and bytecode due to compiler optimizations. In the following code example (admittedly somewhat artificial for presentation purposes), there will be no entry for `constant` variable in the bytecode as it will be optimized away via constant propagation: ``` fun hello(param: u64): vector<u64> { let mut res = param; let constant = 42; // optimized away if (constant >= 42) { // optimized away and turned into straight line code res = 42; }; vector::singleton(res) } ``` This PR implements a heuristic that will mark source code lines optimized away by the compiler as having grey background. We do this by analyzing source maps for a given file and marking lines that are present in the source map but not in the source file (with some exceptions, notably empty lines, lines starting with `const`, and lines that only contain right brace `}`). At this point, the "optimized away" lines include comments (we can finesse it in the future if need be, but it does in some sense reflect the spirit of this visualization) ## Test plan Tested manually to see if grey lines appear and changes throughout debugging session when going to different files, and that they are reset once debug session is finished.
- Loading branch information
Showing
4 changed files
with
192 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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