cranelift_wasm: Use the TableIndex type instead of raw u32
About half of the `FuncEnvironment::translate_table_*` methods were using the `TableIndex` newtype, while the other half were using raw `u32`s. This commit makes everything use `TableIndex`.
This commit is contained in:
@@ -1171,23 +1171,26 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
|||||||
)?);
|
)?);
|
||||||
}
|
}
|
||||||
Operator::TableGrow { table } => {
|
Operator::TableGrow { table } => {
|
||||||
|
let table_index = TableIndex::from_u32(*table);
|
||||||
let delta = state.pop1();
|
let delta = state.pop1();
|
||||||
let init_value = state.pop1();
|
let init_value = state.pop1();
|
||||||
state.push1(environ.translate_table_grow(
|
state.push1(environ.translate_table_grow(
|
||||||
builder.cursor(),
|
builder.cursor(),
|
||||||
*table,
|
table_index,
|
||||||
delta,
|
delta,
|
||||||
init_value,
|
init_value,
|
||||||
)?);
|
)?);
|
||||||
}
|
}
|
||||||
Operator::TableGet { table } => {
|
Operator::TableGet { table } => {
|
||||||
|
let table_index = TableIndex::from_u32(*table);
|
||||||
let index = state.pop1();
|
let index = state.pop1();
|
||||||
state.push1(environ.translate_table_get(builder.cursor(), *table, index)?);
|
state.push1(environ.translate_table_get(builder.cursor(), table_index, index)?);
|
||||||
}
|
}
|
||||||
Operator::TableSet { table } => {
|
Operator::TableSet { table } => {
|
||||||
|
let table_index = TableIndex::from_u32(*table);
|
||||||
let value = state.pop1();
|
let value = state.pop1();
|
||||||
let index = state.pop1();
|
let index = state.pop1();
|
||||||
environ.translate_table_set(builder.cursor(), *table, value, index)?;
|
environ.translate_table_set(builder.cursor(), table_index, value, index)?;
|
||||||
}
|
}
|
||||||
Operator::TableCopy {
|
Operator::TableCopy {
|
||||||
dst_table: dst_table_index,
|
dst_table: dst_table_index,
|
||||||
@@ -1210,10 +1213,11 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
|||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
Operator::TableFill { table } => {
|
Operator::TableFill { table } => {
|
||||||
|
let table_index = TableIndex::from_u32(*table);
|
||||||
let len = state.pop1();
|
let len = state.pop1();
|
||||||
let val = state.pop1();
|
let val = state.pop1();
|
||||||
let dest = state.pop1();
|
let dest = state.pop1();
|
||||||
environ.translate_table_fill(builder.cursor(), *table, dest, val, len)?;
|
environ.translate_table_fill(builder.cursor(), table_index, dest, val, len)?;
|
||||||
}
|
}
|
||||||
Operator::TableInit {
|
Operator::TableInit {
|
||||||
segment,
|
segment,
|
||||||
|
|||||||
@@ -433,7 +433,7 @@ impl<'dummy_environment> FuncEnvironment for DummyFuncEnvironment<'dummy_environ
|
|||||||
fn translate_table_grow(
|
fn translate_table_grow(
|
||||||
&mut self,
|
&mut self,
|
||||||
mut pos: FuncCursor,
|
mut pos: FuncCursor,
|
||||||
_table_index: u32,
|
_table_index: TableIndex,
|
||||||
_delta: ir::Value,
|
_delta: ir::Value,
|
||||||
_init_value: ir::Value,
|
_init_value: ir::Value,
|
||||||
) -> WasmResult<ir::Value> {
|
) -> WasmResult<ir::Value> {
|
||||||
@@ -443,7 +443,7 @@ impl<'dummy_environment> FuncEnvironment for DummyFuncEnvironment<'dummy_environ
|
|||||||
fn translate_table_get(
|
fn translate_table_get(
|
||||||
&mut self,
|
&mut self,
|
||||||
mut pos: FuncCursor,
|
mut pos: FuncCursor,
|
||||||
_table_index: u32,
|
_table_index: TableIndex,
|
||||||
_index: ir::Value,
|
_index: ir::Value,
|
||||||
) -> WasmResult<ir::Value> {
|
) -> WasmResult<ir::Value> {
|
||||||
Ok(pos.ins().null(self.reference_type()))
|
Ok(pos.ins().null(self.reference_type()))
|
||||||
@@ -452,7 +452,7 @@ impl<'dummy_environment> FuncEnvironment for DummyFuncEnvironment<'dummy_environ
|
|||||||
fn translate_table_set(
|
fn translate_table_set(
|
||||||
&mut self,
|
&mut self,
|
||||||
_pos: FuncCursor,
|
_pos: FuncCursor,
|
||||||
_table_index: u32,
|
_table_index: TableIndex,
|
||||||
_value: ir::Value,
|
_value: ir::Value,
|
||||||
_index: ir::Value,
|
_index: ir::Value,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
@@ -476,7 +476,7 @@ impl<'dummy_environment> FuncEnvironment for DummyFuncEnvironment<'dummy_environ
|
|||||||
fn translate_table_fill(
|
fn translate_table_fill(
|
||||||
&mut self,
|
&mut self,
|
||||||
_pos: FuncCursor,
|
_pos: FuncCursor,
|
||||||
_table_index: u32,
|
_table_index: TableIndex,
|
||||||
_dst: ir::Value,
|
_dst: ir::Value,
|
||||||
_val: ir::Value,
|
_val: ir::Value,
|
||||||
_len: ir::Value,
|
_len: ir::Value,
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ pub trait FuncEnvironment: TargetEnvironment {
|
|||||||
fn translate_table_grow(
|
fn translate_table_grow(
|
||||||
&mut self,
|
&mut self,
|
||||||
pos: FuncCursor,
|
pos: FuncCursor,
|
||||||
table_index: u32,
|
table_index: TableIndex,
|
||||||
delta: ir::Value,
|
delta: ir::Value,
|
||||||
init_value: ir::Value,
|
init_value: ir::Value,
|
||||||
) -> WasmResult<ir::Value>;
|
) -> WasmResult<ir::Value>;
|
||||||
@@ -356,7 +356,7 @@ pub trait FuncEnvironment: TargetEnvironment {
|
|||||||
fn translate_table_get(
|
fn translate_table_get(
|
||||||
&mut self,
|
&mut self,
|
||||||
pos: FuncCursor,
|
pos: FuncCursor,
|
||||||
table_index: u32,
|
table_index: TableIndex,
|
||||||
index: ir::Value,
|
index: ir::Value,
|
||||||
) -> WasmResult<ir::Value>;
|
) -> WasmResult<ir::Value>;
|
||||||
|
|
||||||
@@ -364,7 +364,7 @@ pub trait FuncEnvironment: TargetEnvironment {
|
|||||||
fn translate_table_set(
|
fn translate_table_set(
|
||||||
&mut self,
|
&mut self,
|
||||||
pos: FuncCursor,
|
pos: FuncCursor,
|
||||||
table_index: u32,
|
table_index: TableIndex,
|
||||||
value: ir::Value,
|
value: ir::Value,
|
||||||
index: ir::Value,
|
index: ir::Value,
|
||||||
) -> WasmResult<()>;
|
) -> WasmResult<()>;
|
||||||
@@ -387,7 +387,7 @@ pub trait FuncEnvironment: TargetEnvironment {
|
|||||||
fn translate_table_fill(
|
fn translate_table_fill(
|
||||||
&mut self,
|
&mut self,
|
||||||
pos: FuncCursor,
|
pos: FuncCursor,
|
||||||
table_index: u32,
|
table_index: TableIndex,
|
||||||
dst: ir::Value,
|
dst: ir::Value,
|
||||||
val: ir::Value,
|
val: ir::Value,
|
||||||
len: ir::Value,
|
len: ir::Value,
|
||||||
|
|||||||
@@ -727,7 +727,7 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
|
|||||||
fn translate_table_grow(
|
fn translate_table_grow(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: cranelift_codegen::cursor::FuncCursor<'_>,
|
_: cranelift_codegen::cursor::FuncCursor<'_>,
|
||||||
_: u32,
|
_: TableIndex,
|
||||||
_: ir::Value,
|
_: ir::Value,
|
||||||
_: ir::Value,
|
_: ir::Value,
|
||||||
) -> WasmResult<ir::Value> {
|
) -> WasmResult<ir::Value> {
|
||||||
@@ -739,7 +739,7 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
|
|||||||
fn translate_table_get(
|
fn translate_table_get(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: cranelift_codegen::cursor::FuncCursor<'_>,
|
_: cranelift_codegen::cursor::FuncCursor<'_>,
|
||||||
_: u32,
|
_: TableIndex,
|
||||||
_: ir::Value,
|
_: ir::Value,
|
||||||
) -> WasmResult<ir::Value> {
|
) -> WasmResult<ir::Value> {
|
||||||
Err(WasmError::Unsupported(
|
Err(WasmError::Unsupported(
|
||||||
@@ -750,7 +750,7 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
|
|||||||
fn translate_table_set(
|
fn translate_table_set(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: cranelift_codegen::cursor::FuncCursor<'_>,
|
_: cranelift_codegen::cursor::FuncCursor<'_>,
|
||||||
_: u32,
|
_: TableIndex,
|
||||||
_: ir::Value,
|
_: ir::Value,
|
||||||
_: ir::Value,
|
_: ir::Value,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
@@ -762,7 +762,7 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
|
|||||||
fn translate_table_fill(
|
fn translate_table_fill(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: cranelift_codegen::cursor::FuncCursor<'_>,
|
_: cranelift_codegen::cursor::FuncCursor<'_>,
|
||||||
_: u32,
|
_: TableIndex,
|
||||||
_: ir::Value,
|
_: ir::Value,
|
||||||
_: ir::Value,
|
_: ir::Value,
|
||||||
_: ir::Value,
|
_: ir::Value,
|
||||||
|
|||||||
Reference in New Issue
Block a user