Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cranelift: Remove support for WebAssembly tables #8124

Merged
Merged
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
5 changes: 0 additions & 5 deletions cranelift/codegen/meta/src/shared/entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ pub(crate) struct EntityRefs {
/// A reference to a jump table declared in the function preamble.
pub(crate) jump_table: OperandKind,

/// A reference to a table declared in the function preamble.
pub(crate) table: OperandKind,

/// A variable-sized list of value operands. Use for Block and function call arguments.
pub(crate) varargs: OperandKind,
}
Expand Down Expand Up @@ -87,8 +84,6 @@ impl EntityRefs {

jump_table: new("table", "ir::JumpTable", "A jump table."),

table: new("table", "ir::Table", "A table."),

varargs: OperandKind::new(
"",
"&[Value]",
Expand Down
8 changes: 0 additions & 8 deletions cranelift/codegen/meta/src/shared/formats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ pub(crate) struct Formats {
pub(crate) dynamic_stack_store: Rc<InstructionFormat>,
pub(crate) store: Rc<InstructionFormat>,
pub(crate) store_no_offset: Rc<InstructionFormat>,
pub(crate) table_addr: Rc<InstructionFormat>,
pub(crate) ternary: Rc<InstructionFormat>,
pub(crate) ternary_imm8: Rc<InstructionFormat>,
pub(crate) trap: Rc<InstructionFormat>,
Expand Down Expand Up @@ -192,13 +191,6 @@ impl Formats {
.imm(&entities.dynamic_stack_slot)
.build(),

// Accessing a WebAssembly table.
table_addr: Builder::new("TableAddr")
.imm(&entities.table)
.value()
.imm(&imm.offset32)
.build(),

trap: Builder::new("Trap").imm(&imm.trapcode).build(),

cond_trap: Builder::new("CondTrap").value().imm(&imm.trapcode).build(),
Expand Down
32 changes: 0 additions & 32 deletions cranelift/codegen/meta/src/shared/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1299,38 +1299,6 @@ pub(crate) fn define(
.operands_out(vec![Operand::new("addr", iAddr)]),
);

let TableOffset = &TypeVar::new(
"TableOffset",
"An unsigned table offset",
TypeSetBuilder::new().ints(32..64).build(),
);

ig.push(
Inst::new(
"table_addr",
r#"
Bounds check and compute absolute address of a table entry.

Verify that the offset ``p`` is in bounds for the table T, and generate
an absolute address that is safe to dereference.

``Offset`` must be less than the size of a table element.

1. If ``p`` is not greater than the table bound, return an absolute
address corresponding to a byte offset of ``p`` from the table's
base address.
2. If ``p`` is greater than the table bound, generate a trap.
"#,
&formats.table_addr,
)
.operands_in(vec![
Operand::new("T", &entities.table),
Operand::new("p", TableOffset),
Operand::new("Offset", &imm.offset32).with_doc("Byte offset from element address"),
])
.operands_out(vec![Operand::new("addr", iAddr)]),
);

ig.push(
Inst::new(
"iconst",
Expand Down
36 changes: 0 additions & 36 deletions cranelift/codegen/src/ir/entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,33 +388,6 @@ impl SigRef {
}
}

/// An opaque reference to a [WebAssembly
/// table](https://developer.mozilla.org/en-US/docs/WebAssembly/Understanding_the_text_format#WebAssembly_tables).
///
/// `Table`s are used to store a list of function references.
/// They can be created with [`FuncEnvironment::make_table`](https://docs.rs/cranelift-wasm/*/cranelift_wasm/trait.FuncEnvironment.html#tymethod.make_table).
/// They can be used with
/// [`FuncEnvironment::translate_call_indirect`](https://docs.rs/cranelift-wasm/*/cranelift_wasm/trait.FuncEnvironment.html#tymethod.translate_call_indirect).
///
/// While the order is stable, it is arbitrary.
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
pub struct Table(u32);
entity_impl!(Table, "table");

impl Table {
/// Create a new table reference from its number.
///
/// This method is for use by the parser.
pub fn with_number(n: u32) -> Option<Self> {
if n < u32::MAX {
Some(Self(n))
} else {
None
}
}
}

/// An opaque reference to any of the entities defined in this module that can appear in CLIF IR.
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
Expand Down Expand Up @@ -445,8 +418,6 @@ pub enum AnyEntity {
FuncRef(FuncRef),
/// A function call signature.
SigRef(SigRef),
/// A table.
Table(Table),
/// A function's stack limit
StackLimit,
}
Expand All @@ -467,7 +438,6 @@ impl fmt::Display for AnyEntity {
Self::Constant(r) => r.fmt(f),
Self::FuncRef(r) => r.fmt(f),
Self::SigRef(r) => r.fmt(f),
Self::Table(r) => r.fmt(f),
Self::StackLimit => write!(f, "stack_limit"),
}
}
Expand Down Expand Up @@ -551,12 +521,6 @@ impl From<SigRef> for AnyEntity {
}
}

impl From<Table> for AnyEntity {
fn from(r: Table) -> Self {
Self::Table(r)
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
12 changes: 1 addition & 11 deletions cranelift/codegen/src/ir/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::ir::{
self, pcc::Fact, Block, DataFlowGraph, DynamicStackSlot, DynamicStackSlotData,
DynamicStackSlots, DynamicType, ExtFuncData, FuncRef, GlobalValue, GlobalValueData, Inst,
JumpTable, JumpTableData, Layout, MemoryType, MemoryTypeData, Opcode, SigRef, Signature,
SourceLocs, StackSlot, StackSlotData, StackSlots, Table, TableData, Type,
SourceLocs, StackSlot, StackSlotData, StackSlots, Type,
};
use crate::isa::CallConv;
use crate::write::write_function;
Expand Down Expand Up @@ -178,9 +178,6 @@ pub struct FunctionStencil {
/// Memory types for proof-carrying code.
pub memory_types: PrimaryMap<ir::MemoryType, ir::MemoryTypeData>,

/// Tables referenced.
pub tables: PrimaryMap<ir::Table, ir::TableData>,

/// Data flow graph containing the primary definition of all instructions, blocks and values.
pub dfg: DataFlowGraph,

Expand Down Expand Up @@ -209,7 +206,6 @@ impl FunctionStencil {
self.global_values.clear();
self.global_value_facts.clear();
self.memory_types.clear();
self.tables.clear();
self.dfg.clear();
self.layout.clear();
self.srclocs.clear();
Expand Down Expand Up @@ -268,11 +264,6 @@ impl FunctionStencil {
.concrete()
}

/// Declares a table accessible to the function.
pub fn create_table(&mut self, data: TableData) -> Table {
self.tables.push(data)
}

/// Find a presumed unique special-purpose function parameter value.
///
/// Returns the value of the last `purpose` parameter, or `None` if no such parameter exists.
Expand Down Expand Up @@ -423,7 +414,6 @@ impl Function {
global_values: PrimaryMap::new(),
global_value_facts: SecondaryMap::new(),
memory_types: PrimaryMap::new(),
tables: PrimaryMap::new(),
dfg: DataFlowGraph::new(),
layout: Layout::new(),
srclocs: SecondaryMap::new(),
Expand Down
4 changes: 1 addition & 3 deletions cranelift/codegen/src/ir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub mod pcc;
mod progpoint;
mod sourceloc;
pub mod stackslot;
mod table;
mod trapcode;
pub mod types;

Expand All @@ -39,7 +38,7 @@ pub use crate::ir::dfg::{BlockData, DataFlowGraph, ValueDef};
pub use crate::ir::dynamic_type::{dynamic_to_fixed, DynamicTypeData, DynamicTypes};
pub use crate::ir::entities::{
Block, Constant, DynamicStackSlot, DynamicType, FuncRef, GlobalValue, Immediate, Inst,
JumpTable, MemoryType, SigRef, StackSlot, Table, UserExternalNameRef, Value,
JumpTable, MemoryType, SigRef, StackSlot, UserExternalNameRef, Value,
};
pub use crate::ir::extfunc::{
AbiParam, ArgumentExtension, ArgumentPurpose, ExtFuncData, Signature,
Expand All @@ -63,7 +62,6 @@ pub use crate::ir::sourceloc::SourceLoc;
pub use crate::ir::stackslot::{
DynamicStackSlotData, DynamicStackSlots, StackSlotData, StackSlotKind, StackSlots,
};
pub use crate::ir::table::TableData;
pub use crate::ir::trapcode::TrapCode;
pub use crate::ir::types::Type;

Expand Down
40 changes: 0 additions & 40 deletions cranelift/codegen/src/ir/table.rs

This file was deleted.

8 changes: 0 additions & 8 deletions cranelift/codegen/src/legalizer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ use crate::isa::TargetIsa;
use crate::trace;

mod globalvalue;
mod table;

use self::globalvalue::expand_global_value;
use self::table::expand_table_addr;

fn imm_const(pos: &mut FuncCursor, arg: Value, imm: Imm64, is_signed: bool) -> Value {
let ty = pos.func.dfg.value_type(arg);
Expand Down Expand Up @@ -152,12 +150,6 @@ pub fn simple_legalize(func: &mut ir::Function, cfg: &mut ControlFlowGraph, isa:
mflags.set_aligned();
pos.func.dfg.replace(inst).store(mflags, arg, addr, 0);
}
InstructionData::TableAddr {
opcode: ir::Opcode::TableAddr,
table,
arg,
offset,
} => expand_table_addr(isa, inst, &mut pos.func, table, arg, offset),

InstructionData::BinaryImm64 { opcode, arg, imm } => {
let is_signed = match opcode {
Expand Down
114 changes: 0 additions & 114 deletions cranelift/codegen/src/legalizer/table.rs

This file was deleted.

Loading
Loading