-
Notifications
You must be signed in to change notification settings - Fork 87
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
Add push/pop instructions #498
Conversation
try_update_stack_pointer(sp, ssp, hp, stack_range.words().end)?; | ||
|
||
// Write the registers to the stack | ||
let mut it = memory[stack_range.usizes()].chunks_exact_mut(8); |
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.
Is it possible to cross the heap here? Or is it not because we checked that inside of the try_update_stack_pointer
?
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.
try_update_stack_pointer
performs the check
fuel-vm/src/interpreter/memory.rs
Outdated
let mut it = memory[stack_range.usizes()].chunks_exact_mut(8); | ||
for (i, reg) in program_regs.segment(segment).iter().enumerate() { | ||
if (bitmask & (1 << i)) != 0 { | ||
it.next().unwrap().copy_from_slice(®.to_be_bytes()); |
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.
Could you use expect
, please, with a description of why it is impossible?=)
fuel-vm/src/interpreter/memory.rs
Outdated
|
||
// First update the new stack pointer, as that's the only error condition | ||
let count = bitmask.count_ones(); | ||
let stack_range = MemoryRange::new(*sp, (count as u64) * 8)?; |
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.
let stack_range = MemoryRange::new(*sp, (count as u64) * 8)?; | |
let stack_range = MemoryRange::new(*sp, count * 8)?; |
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.
That will not work; u32
doesn't implement ToAddr
(unless we expand the implementation to cover it). The as-cast here is extending u32
returned by count_ones()
, and is complely harmless. I'm replacing it with a .into()
cast anyway, so it looks less suspicious.
Experimenting with push/pop opcodes. See spec PR FuelLabs/fuel-specs#499 and spec issue FuelLabs/fuel-specs#407