Skip to content
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

WDCM and WQCM: reset $of and $err #844

Merged
merged 10 commits into from
Oct 2, 2024
Merged

Conversation

acerone85
Copy link
Contributor

@acerone85 acerone85 commented Sep 27, 2024

[Link to related issue(s) here, if any]

Closes #791

[Short description of the changes.]

The specification requires that WDCM and WDQCM reset the $of and $err registers, but this was not the case.

Questions:

  • Is this a breaking change?
  • I could not find any test that I could look at for the changes. Are there any?

Checklist

  • Breaking changes are clearly marked as such in the PR description and changelog
  • New behavior is reflected in tests
  • If performance characteristic of an instruction change, update gas costs as well or make a follow-up PR for that
  • The specification matches the implemented behavior (link update PR if changes are needed)

Before requesting review

  • I have reviewed the code myself
  • I have created follow-up issues caused by this PR and linked them here

After merging, notify other teams

[Add or remove entries as needed]

Copy link
Collaborator

@xgreenx xgreenx left a comment

Choose a reason for hiding this comment

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

It would be nice to add a test case for it

@acerone85
Copy link
Contributor Author

acerone85 commented Sep 27, 2024

It would be nice to add a test case for it

Yes, I'm just not sure how, I could not find where we test the opcodes in the source

@acerone85
Copy link
Contributor Author

It would be nice to add a test case for it

4 Tests added, one for each possible combination of operand size and register to be checked).

@Dentosal Dentosal changed the title WDCM and WDQCM: reset $of and $err WDCM and WQCM: reset $of and $err Sep 30, 2024
CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Member

@Dentosal Dentosal left a comment

Choose a reason for hiding this comment

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

Good test structure. I had some small suggestions, and the changelog needs fixing, but other than that seems good to go.

CHANGELOG.md Outdated Show resolved Hide resolved
Dentosal
Dentosal previously approved these changes Sep 30, 2024
@Dentosal Dentosal added breaking A breaking api change fuel-vm Related to the `fuel-vm` crate. labels Oct 1, 2024
Comment on lines +92 to +94
*of = 0;
*err = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If I remove these lines, tests still passes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can confirm, but I don't have any idea why.
I have checked, and log does not reset the registers, so the only option is that the registers are reset already somewhere while executing the wideint compare instruction. Will check more in depth

Copy link
Member

Choose a reason for hiding this comment

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

It's because code generated by make_u128 and make_u256 used in the tests reset $err and $of as they use movi internally.

You should first create all values, and only after that call the opcodes that access flags.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wish I looked at this comment three hours ago :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed tests in 18b6008 and verified that they fail before applying the changes to the wideint cmp alu operation

@Dentosal Dentosal self-requested a review October 1, 2024 08:56
@Dentosal Dentosal dismissed their stale review October 1, 2024 08:58

Isues found by Green, will re-review

xgreenx
xgreenx previously approved these changes Oct 1, 2024
xgreenx
xgreenx previously approved these changes Oct 1, 2024
Dentosal
Dentosal previously approved these changes Oct 1, 2024
@acerone85 acerone85 added this pull request to the merge queue Oct 2, 2024
Merged via the queue into master with commit dd1756f Oct 2, 2024
39 checks passed
@acerone85 acerone85 deleted the wdcm-wdqm-follows-specs branch October 2, 2024 11:26
@xgreenx xgreenx mentioned this pull request Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking A breaking api change fuel-vm Related to the `fuel-vm` crate.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WDCM and WQCM implementation mismatch with the specification
3 participants