Merge branch 'misc_changes' of https://github.com/bjorn3/waffle into pr/changes1
This commit is contained in:
commit
8b32f7a07e
|
@ -526,6 +526,15 @@ impl<'a> WasmFuncBackend<'a> {
|
||||||
Operator::MemoryGrow { mem } => {
|
Operator::MemoryGrow { mem } => {
|
||||||
Some(wasm_encoder::Instruction::MemoryGrow(mem.index() as u32))
|
Some(wasm_encoder::Instruction::MemoryGrow(mem.index() as u32))
|
||||||
}
|
}
|
||||||
|
Operator::MemoryCopy { dst_mem, src_mem } => {
|
||||||
|
Some(wasm_encoder::Instruction::MemoryCopy {
|
||||||
|
src_mem: src_mem.index() as u32,
|
||||||
|
dst_mem: dst_mem.index() as u32,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Operator::MemoryFill { mem } => {
|
||||||
|
Some(wasm_encoder::Instruction::MemoryFill(mem.index() as u32))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(inst) = inst {
|
if let Some(inst) = inst {
|
||||||
|
|
|
@ -224,6 +224,8 @@ pub fn op_inputs(
|
||||||
Operator::TableSize { .. } => Ok(Cow::Borrowed(&[])),
|
Operator::TableSize { .. } => Ok(Cow::Borrowed(&[])),
|
||||||
Operator::MemorySize { .. } => Ok(Cow::Borrowed(&[])),
|
Operator::MemorySize { .. } => Ok(Cow::Borrowed(&[])),
|
||||||
Operator::MemoryGrow { .. } => Ok(Cow::Borrowed(&[Type::I32])),
|
Operator::MemoryGrow { .. } => Ok(Cow::Borrowed(&[Type::I32])),
|
||||||
|
Operator::MemoryCopy { .. } => Ok(Cow::Borrowed(&[Type::I32, Type::I32, Type::I32])),
|
||||||
|
Operator::MemoryFill { .. } => Ok(Cow::Borrowed(&[Type::I32, Type::I32, Type::I32])),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,6 +433,8 @@ pub fn op_outputs(
|
||||||
Operator::TableSize { .. } => Ok(Cow::Borrowed(&[Type::I32])),
|
Operator::TableSize { .. } => Ok(Cow::Borrowed(&[Type::I32])),
|
||||||
Operator::MemorySize { .. } => Ok(Cow::Borrowed(&[Type::I32])),
|
Operator::MemorySize { .. } => Ok(Cow::Borrowed(&[Type::I32])),
|
||||||
Operator::MemoryGrow { .. } => Ok(Cow::Borrowed(&[Type::I32])),
|
Operator::MemoryGrow { .. } => Ok(Cow::Borrowed(&[Type::I32])),
|
||||||
|
Operator::MemoryCopy { .. } => Ok(Cow::Borrowed(&[])),
|
||||||
|
Operator::MemoryFill { .. } => Ok(Cow::Borrowed(&[])),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -641,6 +645,8 @@ impl Operator {
|
||||||
Operator::TableSize { .. } => &[ReadTable],
|
Operator::TableSize { .. } => &[ReadTable],
|
||||||
Operator::MemorySize { .. } => &[ReadMem],
|
Operator::MemorySize { .. } => &[ReadMem],
|
||||||
Operator::MemoryGrow { .. } => &[WriteMem, Trap],
|
Operator::MemoryGrow { .. } => &[WriteMem, Trap],
|
||||||
|
Operator::MemoryCopy { .. } => &[Trap, ReadMem, WriteMem],
|
||||||
|
Operator::MemoryFill { .. } => &[Trap, WriteMem],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -859,6 +865,10 @@ impl std::fmt::Display for Operator {
|
||||||
Operator::TableSize { table_index, .. } => write!(f, "table_size<{}>", table_index)?,
|
Operator::TableSize { table_index, .. } => write!(f, "table_size<{}>", table_index)?,
|
||||||
Operator::MemorySize { mem } => write!(f, "memory_size<{}>", mem)?,
|
Operator::MemorySize { mem } => write!(f, "memory_size<{}>", mem)?,
|
||||||
Operator::MemoryGrow { mem } => write!(f, "memory_grow<{}>", mem)?,
|
Operator::MemoryGrow { mem } => write!(f, "memory_grow<{}>", mem)?,
|
||||||
|
Operator::MemoryCopy { dst_mem, src_mem } => {
|
||||||
|
write!(f, "memory_copy<{}, {}>", dst_mem, src_mem)?
|
||||||
|
}
|
||||||
|
Operator::MemoryFill { mem } => write!(f, "memory_fill<{}>", mem)?,
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
14
src/ops.rs
14
src/ops.rs
|
@ -295,6 +295,13 @@ pub enum Operator {
|
||||||
MemoryGrow {
|
MemoryGrow {
|
||||||
mem: Memory,
|
mem: Memory,
|
||||||
},
|
},
|
||||||
|
MemoryCopy {
|
||||||
|
dst_mem: Memory,
|
||||||
|
src_mem: Memory,
|
||||||
|
},
|
||||||
|
MemoryFill {
|
||||||
|
mem: Memory,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -568,6 +575,13 @@ impl<'a, 'b> std::convert::TryFrom<&'b wasmparser::Operator<'a>> for Operator {
|
||||||
&wasmparser::Operator::MemoryGrow { mem, .. } => Ok(Operator::MemoryGrow {
|
&wasmparser::Operator::MemoryGrow { mem, .. } => Ok(Operator::MemoryGrow {
|
||||||
mem: Memory::from(mem),
|
mem: Memory::from(mem),
|
||||||
}),
|
}),
|
||||||
|
&wasmparser::Operator::MemoryCopy { dst_mem, src_mem } => Ok(Operator::MemoryCopy {
|
||||||
|
dst_mem: Memory::from(dst_mem),
|
||||||
|
src_mem: Memory::from(src_mem),
|
||||||
|
}),
|
||||||
|
&wasmparser::Operator::MemoryFill { mem } => {
|
||||||
|
Ok(Operator::MemoryFill { mem: Memory::from(mem) })
|
||||||
|
}
|
||||||
_ => Err(()),
|
_ => Err(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue