-
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.
[move] Fixed locals disassembly (#20747)
## Description It looks like locals are currently not disassembled correctly when running Move disassembler and this PR contains a fix. In particular, consider the following Move code: ```move module test::M1; public enum SomeEnum has drop, copy { NamedVariant { field: u64 }, PositionalVariant(u64), } public fun foo(e: SomeEnum, p1: u64, p2: u64): (u64, u64) { match (e) { SomeEnum::NamedVariant { field } => { let mut res = field + p1; res = res + p2; (res, res) }, SomeEnum::PositionalVariant(field) => (field, field) } } #[test] public fun test() { let e = SomeEnum::NamedVariant { field: 42 }; foo(e, 42, 7); } ``` When running disassembler on the `M1` module, the following 3 locals are reported in the disassembly: ``` L0: __match_tmp%#unpack_subject#1#1#0: SomeEnum L1: field#3#0: u64 L2: res#1#0: u64 ``` However, 6 locals are reported in the source map: ``` %#7 %#8 __match_tmp%#match_subject#2#2#0 __match_tmp%#unpack_subject#1#1#0 field#3#0 res#1#0 ``` The same number of locals is also reported in the trace generated out of the test function in `M1`. It looks like the disassembler incorrectly assumes that function parameters are included in the locals and only locals beyond the (optional) initial number of parameters should be counted. After making the adjustment to ignore the parameters when disassembling locals, the following is reported in the disassembly which is consistent with the number (and names) of the locals in the source map and with the types of the locals in the trace: ``` L0: %#7: u64 L1: %#8: u64 L2: __match_tmp%#match_subject#2#2#0: &SomeEnum L3: __match_tmp%#unpack_subject#1#1#0: SomeEnum L4: field#3#0: u64 L5: res#1#0: u64 ``` ## Test plan All tests should pass
- Loading branch information
Showing
13 changed files
with
40 additions
and
26 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
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
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
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