-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[move-compiler v2] Comparison testing for file-format generator #9345
Conversation
2673d36
to
8a5ed91
Compare
This adds an initial version of the generation of the external representation of Move code, the so-called file format. - Compiles from the register machine of the compiler IR into the stack machine the VM uses. Some attempts are made to optimize usage of the stack, though more can/must be done to optimize the stack machine code. - Adds a set of basic tests, but more e2e execution tests should be added. (Subsequent PRs.) - The translation can benefit from analysis results like live-var which allows it make smarter use of `CopyLoc` vs `MoveLoc` (to be added in the future)
33cb851
to
2a3d6d2
Compare
@@ -0,0 +1,69 @@ | |||
comparison between v1 and v2 failed: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you'll fix these failed tests at a later stage, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! #9343
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This extends the transactional-test-runner to support compiler V2 _and_ to do comparison testing between V1 and V2. It ports over most of the transactional tests of the V1 compiler into the V2 tree and runs comparison testing on them, fixing bugs throughout the compilation chain as needed. Closes #9334
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
✅ Forge suite
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully someone looked at the tests better than I.
@@ -63,3 +63,29 @@ pub fn format_diff(expected: impl AsRef<str>, actual: impl AsRef<str>) -> String | |||
} | |||
ret | |||
} | |||
|
|||
pub fn format_diff_no_color(expected: impl AsRef<str>, actual: impl AsRef<str>) -> String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of redundant with the code above, but I can't simplify it much in Rust, so it's fine as is. Higher-order functions in Rust are a bit verbose.
Here's a try:
pub fn format_diff_no_color(expected: impl AsRef<str>, actual: impl AsRef<str>) -> String {
format_diff_shared(
expected,
actual,
|x: &String, ret: &mut String| {
ret.push_str(&format!("= {}", x.replace('\n', "\n= ")));
ret.push('\n');
},
|x: &String, ret: &mut String| {
ret.push_str(&format!("+ {}", x.replace('\n', "\n+ ")));
ret.push('\n');
},
|x: &String, ret: &mut String| {
ret.push_str(&format!("- {}", x.replace('\n', "\n- ")));
ret.push('\n');
},
)
}
Where the code above is changed to:
fn format_diff_shared(
expected: impl AsRef<str>,
actual: impl AsRef<str>,
same_proc: impl Fn(&String, &mut String),
add_proc: impl Fn(&String, &mut String),
rem_proc: impl Fn(&String, &mut String),
) -> String {
use difference::{Changeset, Difference};
let changeset = Changeset::new(expected.as_ref(), actual.as_ref(), "\n");
let mut ret = String::new();
for seq in changeset.diffs {
match &seq {
Difference::Same(x) => {
same_proc(x, &mut ret);
},
Difference::Add(x) => {
add_proc(x, &mut ret);
},
Difference::Rem(x) => {
rem_proc(x, &mut ret);
},
}
}
ret
}
pub fn format_diff(expected: impl AsRef<str>, actual: impl AsRef<str>) -> String {
format_diff_shared(
expected,
actual,
|x: &String, ret: &mut String| {
ret.push_str(x);
ret.push('\n');
},
|x: &String, ret: &mut String| {
ret.push_str("\x1B[92m");
ret.push_str(x);
ret.push_str("\x1B[0m");
ret.push('\n');
},
|x: &String, ret: &mut String| {
ret.push_str("\x1B[91m");
ret.push_str(x);
ret.push_str("\x1B[0m");
ret.push('\n');
},
)
}
* [move-compiler v2] File-format generator first version This adds an initial version of the generation of the external representation of Move code, the so-called file format. - Compiles from the register machine of the compiler IR into the stack machine the VM uses. Some attempts are made to optimize usage of the stack, though more can/must be done to optimize the stack machine code. - Adds a set of basic tests, but more e2e execution tests should be added. (Subsequent PRs.) - The translation can benefit from analysis results like live-var which allows it make smarter use of `CopyLoc` vs `MoveLoc` (to be added in the future) * Addressing reviewer comments * More review fixes * [move-compiler v2] Comparison testing for file-format generator This extends the transactional-test-runner to support compiler V2 _and_ to do comparison testing between V1 and V2. It ports over most of the transactional tests of the V1 compiler into the V2 tree and runs comparison testing on them, fixing bugs throughout the compilation chain as needed. Closes #9334
) { | ||
let result = result.as_ref(); | ||
// First ensure the arguments are on the stack. | ||
self.abstract_push_args(ctx, result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you're pushing twice if you happen to have something on the stack. Shouldn't this be:
if self.stack.len() != 0 {
self.abstract_flush_stack(ctx, 0);
}
self.abstract_push_args(ctx, result.as_ref());
* [move-compiler v2] File-format generator first version This adds an initial version of the generation of the external representation of Move code, the so-called file format. - Compiles from the register machine of the compiler IR into the stack machine the VM uses. Some attempts are made to optimize usage of the stack, though more can/must be done to optimize the stack machine code. - Adds a set of basic tests, but more e2e execution tests should be added. (Subsequent PRs.) - The translation can benefit from analysis results like live-var which allows it make smarter use of `CopyLoc` vs `MoveLoc` (to be added in the future) * Addressing reviewer comments * More review fixes * [move-compiler v2] Comparison testing for file-format generator This extends the transactional-test-runner to support compiler V2 _and_ to do comparison testing between V1 and V2. It ports over most of the transactional tests of the V1 compiler into the V2 tree and runs comparison testing on them, fixing bugs throughout the compilation chain as needed. Closes #9334
This extends the transactional-test-runner to support compiler V2 and to do comparison testing between V1 and V2.
It ports over most of the transactional tests of the V1 compiler into the V2 tree and runs comparison testing on them, fixing bugs throughout the compilation chain as needed.
Closes #9334
NOTE: this is diffbased on #9258; only look at the latest commit.