cfallin edited issue #1063:
I have a hunch that there is a decent amount of overhead from repetitive matches on
dfg[inst]. We see a lot ofmatch pos.func.dfg[inst] { ir::InstructionData::StackLoad { ... } => ..., _ => panic!(...), };when we already know that
instis astack_load.This is required by the way that
InstructionDatais defined. We can't just pass a single instruction type into a function, we must pass an instance of the entire enum.pub enum InstructionData { Unary { opcode: Opcode, arg: Value, }, UnaryImm { opcode: Opcode, imm: ir::immediates::Imm64, }, ... }I propose that we define a struct for each instruction type, as below:
struct UnaryImm { opcode: Opcode, imm: ir::immediates::Imm64, } enum InstructionData { Unary(Unary), UnaryImm(UnaryImm), ... }I think we should also go further, like bytecodealliance/wasmtime#1062 suggests and do this:
struct InstructionData { opcode: Opcode, args: ValueList, inst: Instruction, } enum Instruction { Unary(Unary), UnaryImm(UnaryImm), ... }
cfallin labeled issue #1063:
I have a hunch that there is a decent amount of overhead from repetitive matches on
dfg[inst]. We see a lot ofmatch pos.func.dfg[inst] { ir::InstructionData::StackLoad { ... } => ..., _ => panic!(...), };when we already know that
instis astack_load.This is required by the way that
InstructionDatais defined. We can't just pass a single instruction type into a function, we must pass an instance of the entire enum.pub enum InstructionData { Unary { opcode: Opcode, arg: Value, }, UnaryImm { opcode: Opcode, imm: ir::immediates::Imm64, }, ... }I propose that we define a struct for each instruction type, as below:
struct UnaryImm { opcode: Opcode, imm: ir::immediates::Imm64, } enum InstructionData { Unary(Unary), UnaryImm(UnaryImm), ... }I think we should also go further, like bytecodealliance/wasmtime#1062 suggests and do this:
struct InstructionData { opcode: Opcode, args: ValueList, inst: Instruction, } enum Instruction { Unary(Unary), UnaryImm(UnaryImm), ... }
fitzgen closed issue #1063:
I have a hunch that there is a decent amount of overhead from repetitive matches on
dfg[inst]. We see a lot ofmatch pos.func.dfg[inst] { ir::InstructionData::StackLoad { ... } => ..., _ => panic!(...), };when we already know that
instis astack_load.This is required by the way that
InstructionDatais defined. We can't just pass a single instruction type into a function, we must pass an instance of the entire enum.pub enum InstructionData { Unary { opcode: Opcode, arg: Value, }, UnaryImm { opcode: Opcode, imm: ir::immediates::Imm64, }, ... }I propose that we define a struct for each instruction type, as below:
struct UnaryImm { opcode: Opcode, imm: ir::immediates::Imm64, } enum InstructionData { Unary(Unary), UnaryImm(UnaryImm), ... }I think we should also go further, like bytecodealliance/wasmtime#1062 suggests and do this:
struct InstructionData { opcode: Opcode, args: ValueList, inst: Instruction, } enum Instruction { Unary(Unary), UnaryImm(UnaryImm), ... }
fitzgen commented on issue #1063:
I think there are potentially interesting ways to refactor our instruction data, but what is proposed will not pack as nicely as what we have today, growing the size of instructions. Feel free to file new issues or PRs for specific improvements.
Last updated: Dec 13 2025 at 19:03 UTC