x64: Shrink Inst from 72 to 48 bytes (#4514)

https://github.com/bytecodealliance/wasmtime/pull/4514
This commit is contained in:
Trevor Elliott
2022-07-27 10:39:22 -07:00
committed by GitHub
parent 285bc5ce24
commit 7ac6134894
8 changed files with 11 additions and 9 deletions

View File

@@ -854,6 +854,7 @@
(type BranchTarget (primitive BranchTarget)) (type BranchTarget (primitive BranchTarget))
(type BoxJTSequenceInfo (primitive BoxJTSequenceInfo)) (type BoxJTSequenceInfo (primitive BoxJTSequenceInfo))
(type CodeOffset (primitive CodeOffset)) (type CodeOffset (primitive CodeOffset))
(type VecMachLabel extern (enum))
(type ExtendOp extern (type ExtendOp extern
(enum (enum

View File

@@ -880,6 +880,7 @@
(type BoxCallInfo (primitive BoxCallInfo)) (type BoxCallInfo (primitive BoxCallInfo))
(type BoxCallIndInfo (primitive BoxCallIndInfo)) (type BoxCallIndInfo (primitive BoxCallIndInfo))
(type BoxJTSequenceInfo (primitive BoxJTSequenceInfo)) (type BoxJTSequenceInfo (primitive BoxJTSequenceInfo))
(type VecMachLabel extern (enum))
;; An ALU operation. ;; An ALU operation.
(type ALUOp (type ALUOp

View File

@@ -371,8 +371,7 @@
(tmp1 WritableReg) (tmp1 WritableReg)
(tmp2 WritableReg) (tmp2 WritableReg)
(default_target MachLabel) (default_target MachLabel)
(targets VecMachLabel) (targets BoxVecMachLabel))
(targets_for_term VecMachLabel))
;; Indirect jump: jmpq (reg mem). ;; Indirect jump: jmpq (reg mem).
(JmpUnknown (target RegMem)) (JmpUnknown (target RegMem))
@@ -504,6 +503,8 @@
(type BoxCallInfo extern (enum)) (type BoxCallInfo extern (enum))
(type BoxVecMachLabel extern (enum))
;; Get the `OperandSize` for a given `Type`, rounding smaller types up to 32 bits. ;; Get the `OperandSize` for a given `Type`, rounding smaller types up to 32 bits.
(decl operand_size_of_type_32_64 (Type) OperandSize) (decl operand_size_of_type_32_64 (Type) OperandSize)
(extern constructor operand_size_of_type_32_64 operand_size_of_type_32_64) (extern constructor operand_size_of_type_32_64 operand_size_of_type_32_64)

View File

@@ -48,7 +48,7 @@ pub struct CallInfo {
fn inst_size_test() { fn inst_size_test() {
// This test will help with unintentionally growing the size // This test will help with unintentionally growing the size
// of the Inst enum. // of the Inst enum.
assert_eq!(72, std::mem::size_of::<Inst>()); assert_eq!(48, std::mem::size_of::<Inst>());
} }
pub(crate) fn low32_will_sign_extend_to_64(x: u64) -> bool { pub(crate) fn low32_will_sign_extend_to_64(x: u64) -> bool {

View File

@@ -17,7 +17,7 @@ use crate::machinst::lower::*;
use crate::machinst::*; use crate::machinst::*;
use crate::result::CodegenResult; use crate::result::CodegenResult;
use crate::settings::{Flags, TlsModel}; use crate::settings::{Flags, TlsModel};
use alloc::vec::Vec; use alloc::boxed::Box;
use log::trace; use log::trace;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::convert::TryFrom; use std::convert::TryFrom;
@@ -3236,10 +3236,10 @@ impl LowerBackend for X64Backend {
}; };
ctx.emit(Inst::cmp_rmi_r(cmp_size, RegMemImm::imm(jt_size), idx)); ctx.emit(Inst::cmp_rmi_r(cmp_size, RegMemImm::imm(jt_size), idx));
let targets_for_term: Vec<MachLabel> = targets.to_vec();
let default_target = targets[0]; let default_target = targets[0];
let jt_targets: Vec<MachLabel> = targets.iter().skip(1).cloned().collect(); let jt_targets: Box<SmallVec<[MachLabel; 4]>> =
Box::new(targets.iter().skip(1).cloned().collect());
ctx.emit(Inst::JmpTableSeq { ctx.emit(Inst::JmpTableSeq {
idx, idx,
@@ -3247,7 +3247,6 @@ impl LowerBackend for X64Backend {
tmp2, tmp2,
default_target, default_target,
targets: jt_targets, targets: jt_targets,
targets_for_term,
}); });
} }

View File

@@ -30,10 +30,12 @@ use crate::{
VCodeConstantData, VCodeConstantData,
}, },
}; };
use smallvec::SmallVec;
use std::boxed::Box; use std::boxed::Box;
use std::convert::TryFrom; use std::convert::TryFrom;
type BoxCallInfo = Box<CallInfo>; type BoxCallInfo = Box<CallInfo>;
type BoxVecMachLabel = Box<SmallVec<[MachLabel; 4]>>;
pub struct SinkableLoad { pub struct SinkableLoad {
inst: Inst, inst: Inst,

View File

@@ -25,7 +25,6 @@ pub type ValueRegs = crate::machinst::ValueRegs<Reg>;
pub type WritableValueRegs = crate::machinst::ValueRegs<WritableReg>; pub type WritableValueRegs = crate::machinst::ValueRegs<WritableReg>;
pub type InstOutput = SmallVec<[ValueRegs; 2]>; pub type InstOutput = SmallVec<[ValueRegs; 2]>;
pub type InstOutputBuilder = Cell<InstOutput>; pub type InstOutputBuilder = Cell<InstOutput>;
pub type VecMachLabel = Vec<MachLabel>;
pub type BoxExternalName = Box<ExternalName>; pub type BoxExternalName = Box<ExternalName>;
pub type Range = (usize, usize); pub type Range = (usize, usize);

View File

@@ -195,7 +195,6 @@
;;;; Common Mach Types ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; Common Mach Types ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(type MachLabel (primitive MachLabel)) (type MachLabel (primitive MachLabel))
(type VecMachLabel extern (enum))
(type ValueLabel (primitive ValueLabel)) (type ValueLabel (primitive ValueLabel))
(type UnwindInst (primitive UnwindInst)) (type UnwindInst (primitive UnwindInst))
(type ExternalName (primitive ExternalName)) (type ExternalName (primitive ExternalName))