Skip to content

Commit 14dbd5b

Browse files
alexcrichtonyurydelendik
authored andcommitted
Parse the table.fill instruction (bytecodealliance#143)
Add support for the experimental `table.fill` instruction from its proposal.
1 parent 4cb9b7d commit 14dbd5b

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/binary_reader.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,11 @@ impl<'a> BinaryReader<'a> {
12441244
Operator::TableSize { table }
12451245
}
12461246

1247+
0x11 => {
1248+
let table = self.read_var_u32()?;
1249+
Operator::TableFill { table }
1250+
}
1251+
12471252
_ => {
12481253
return Err(BinaryReaderError {
12491254
message: "Unknown 0xfc opcode",

src/operators_validator.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,6 +1704,15 @@ impl OperatorValidator {
17041704
}
17051705
self.func_state.change_frame_with_type(1, Type::I32)?;
17061706
}
1707+
Operator::TableFill { table } => {
1708+
self.check_bulk_memory_enabled()?;
1709+
let ty = match resources.tables().get(table as usize) {
1710+
Some(ty) => ty.element_type,
1711+
None => return Err("table index out of bounds"),
1712+
};
1713+
self.check_operands(&[Type::I32, ty, Type::I32])?;
1714+
self.func_state.change_frame(3)?;
1715+
}
17071716
}
17081717
Ok(FunctionEnd::No)
17091718
}

src/primitives.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ pub enum Operator<'a> {
435435
TableInit { segment: u32 },
436436
ElemDrop { segment: u32 },
437437
TableCopy,
438+
TableFill { table: u32 },
438439
TableGet { table: u32 },
439440
TableSet { table: u32 },
440441
TableGrow { table: u32 },

0 commit comments

Comments
 (0)