Skip to content

Commit

Permalink
Store size when call store_bytes (#434)
Browse files Browse the repository at this point in the history
* Store size when call store_bytes

* Fix test
  • Loading branch information
mohanson authored May 28, 2024
1 parent 62c55a5 commit ef3b064
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/snapshot2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,12 @@ impl<I: Clone + PartialEq, D: DataSource<I>> Snapshot2Context<I, D> {
id: &I,
offset: u64,
length: u64,
size_addr: u64,
) -> Result<(u64, u64), Error> {
let (data, full_length) = self.load_data(id, offset, length)?;
machine
.memory_mut()
.store64(&M::REG::from_u64(size_addr), &M::REG::from_u64(full_length))?;
self.untrack_pages(machine, addr, data.len() as u64)?;
machine.memory_mut().store_bytes(addr, &data)?;
self.track_pages(machine, addr, data.len() as u64, id, offset)?;
Expand Down
8 changes: 4 additions & 4 deletions tests/test_resume2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ impl<Mac: SupportMachine> Syscalls<Mac> for InsertDataSyscall {
self.0
.lock()
.unwrap()
.store_bytes(machine, addr, &DATA_ID, 0, size)?;
.store_bytes(machine, addr, &DATA_ID, 0, size, 0)?;

machine.add_cycles_no_checking(100000)?;

Expand Down Expand Up @@ -634,11 +634,11 @@ pub fn test_store_bytes_twice() {
Machine::Asm(ref mut inner, ref ctx) => {
ctx.lock()
.unwrap()
.store_bytes(&mut inner.machine, 0, &DATA_ID, 2, 29186)
.store_bytes(&mut inner.machine, 0, &DATA_ID, 2, 29186, 0)
.unwrap();
ctx.lock()
.unwrap()
.store_bytes(&mut inner.machine, 0, &DATA_ID, 0, 11008)
.store_bytes(&mut inner.machine, 0, &DATA_ID, 0, 11008, 0)
.unwrap();
}
_ => unimplemented!(),
Expand Down Expand Up @@ -667,7 +667,7 @@ pub fn test_mixing_snapshot2_writes_with_machine_raw_writes() {
Machine::Asm(ref mut inner, ref ctx) => {
ctx.lock()
.unwrap()
.store_bytes(&mut inner.machine, 0, &DATA_ID, 0, 29186)
.store_bytes(&mut inner.machine, 0, &DATA_ID, 0, 29186, 0)
.unwrap();
inner
.machine
Expand Down

0 comments on commit ef3b064

Please sign in to comment.