-
Notifications
You must be signed in to change notification settings - Fork 42
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
fix(svm): fixup some arithmetics in the interpreter #620
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
🚀 New features to boost your workflow:
|
bf88f12
to
956f89a
Compare
src/vm/interpreter.zig
Outdated
Instruction.lsh => if (opcode.is64()) | ||
lhs << @truncate(rhs) | ||
else | ||
@as(u32, @truncate(lhs)) << @truncate(rhs), |
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.
Above, there is this:
const lhs: u64 = if (opcode.is64()) lhs_large else @as(u32, @truncate(lhs_large));
So, isn't it already truncated? What does the additional truncate do?
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 provides a different result type to the shift amount truncate. Honestly I should re-design this code to be generic over the bitsize of the instruction, so that I don't need to represent 32-bits in a 64-bit value, and then reduce it at each place.
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.
Did that here: 24ae663
This turned out way nicer than I thought, I had the idea to do this when I was first writing this implementation, but for some reason didn't do it. It also caught a bug in the mul32 implementation :).
24ae663
to
80263ac
Compare
80263ac
to
2f2f981
Compare
This stack of pull requests is managed by Graphite. Learn more about stacking. |
No description provided.