Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,8 @@ generate! { instr -> Instr = {
0x05 => Instr::ICvtOp(BitSize::B64, intop::CvtOp::TruncSatUF32),
0x06 => Instr::ICvtOp(BitSize::B64, intop::CvtOp::TruncSatSF64),
0x07 => Instr::ICvtOp(BitSize::B64, intop::CvtOp::TruncSatUF64),
0x0a => { run!(expect_byte(0x00)); run!(expect_byte(0x00)); Instr::MemCopy },
0x0b => { run!(expect_byte(0x00)); Instr::MemFill },
b => err!("Invalid saturation trunctation {:#x}", b),
}
}
Expand Down
18 changes: 18 additions & 0 deletions src/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,24 @@ fn print_instr(
}
}
}
MemFill => {
let n = pop!(i32);
let v = pop!(i32);
let addr = pop!(i32);
let addr_end = format!("({} + {})", addr, n);

Ok(format!("self.memory[{} as usize..{} as usize].fill({} as u8);",
addr, addr_end, v))
}
MemCopy => {
let n = pop!(i32);
let src = pop!(i32);
let dst = pop!(i32);
let src_end = format!("({} + {})", src, n);

Ok(format!("self.memory.copy_within({} as usize..{} as usize, {} as usize);",
src, src_end, dst))
}
MemSize => {
// Note: The spec defines Page Size = 65536
let inner_mem_size = if opts.fixed_mem_size.is_some() {
Expand Down
2 changes: 2 additions & 0 deletions src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ pub mod syntax {
MemStore(MemStore),
MemSize,
MemGrow,
MemCopy,
MemFill,

// Control instructions
Nop,
Expand Down