x64: Shrink Inst from 72 to 48 bytes (#4514)
https://github.com/bytecodealliance/wasmtime/pull/4514
This commit is contained in:
@@ -854,6 +854,7 @@
|
||||
(type BranchTarget (primitive BranchTarget))
|
||||
(type BoxJTSequenceInfo (primitive BoxJTSequenceInfo))
|
||||
(type CodeOffset (primitive CodeOffset))
|
||||
(type VecMachLabel extern (enum))
|
||||
|
||||
(type ExtendOp extern
|
||||
(enum
|
||||
|
||||
@@ -880,6 +880,7 @@
|
||||
(type BoxCallInfo (primitive BoxCallInfo))
|
||||
(type BoxCallIndInfo (primitive BoxCallIndInfo))
|
||||
(type BoxJTSequenceInfo (primitive BoxJTSequenceInfo))
|
||||
(type VecMachLabel extern (enum))
|
||||
|
||||
;; An ALU operation.
|
||||
(type ALUOp
|
||||
|
||||
@@ -371,8 +371,7 @@
|
||||
(tmp1 WritableReg)
|
||||
(tmp2 WritableReg)
|
||||
(default_target MachLabel)
|
||||
(targets VecMachLabel)
|
||||
(targets_for_term VecMachLabel))
|
||||
(targets BoxVecMachLabel))
|
||||
|
||||
;; Indirect jump: jmpq (reg mem).
|
||||
(JmpUnknown (target RegMem))
|
||||
@@ -504,6 +503,8 @@
|
||||
|
||||
(type BoxCallInfo extern (enum))
|
||||
|
||||
(type BoxVecMachLabel extern (enum))
|
||||
|
||||
;; Get the `OperandSize` for a given `Type`, rounding smaller types up to 32 bits.
|
||||
(decl operand_size_of_type_32_64 (Type) OperandSize)
|
||||
(extern constructor operand_size_of_type_32_64 operand_size_of_type_32_64)
|
||||
|
||||
@@ -48,7 +48,7 @@ pub struct CallInfo {
|
||||
fn inst_size_test() {
|
||||
// This test will help with unintentionally growing the size
|
||||
// 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 {
|
||||
|
||||
@@ -17,7 +17,7 @@ use crate::machinst::lower::*;
|
||||
use crate::machinst::*;
|
||||
use crate::result::CodegenResult;
|
||||
use crate::settings::{Flags, TlsModel};
|
||||
use alloc::vec::Vec;
|
||||
use alloc::boxed::Box;
|
||||
use log::trace;
|
||||
use smallvec::SmallVec;
|
||||
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));
|
||||
|
||||
let targets_for_term: Vec<MachLabel> = targets.to_vec();
|
||||
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 {
|
||||
idx,
|
||||
@@ -3247,7 +3247,6 @@ impl LowerBackend for X64Backend {
|
||||
tmp2,
|
||||
default_target,
|
||||
targets: jt_targets,
|
||||
targets_for_term,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -30,10 +30,12 @@ use crate::{
|
||||
VCodeConstantData,
|
||||
},
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::boxed::Box;
|
||||
use std::convert::TryFrom;
|
||||
|
||||
type BoxCallInfo = Box<CallInfo>;
|
||||
type BoxVecMachLabel = Box<SmallVec<[MachLabel; 4]>>;
|
||||
|
||||
pub struct SinkableLoad {
|
||||
inst: Inst,
|
||||
|
||||
@@ -25,7 +25,6 @@ pub type ValueRegs = crate::machinst::ValueRegs<Reg>;
|
||||
pub type WritableValueRegs = crate::machinst::ValueRegs<WritableReg>;
|
||||
pub type InstOutput = SmallVec<[ValueRegs; 2]>;
|
||||
pub type InstOutputBuilder = Cell<InstOutput>;
|
||||
pub type VecMachLabel = Vec<MachLabel>;
|
||||
pub type BoxExternalName = Box<ExternalName>;
|
||||
pub type Range = (usize, usize);
|
||||
|
||||
|
||||
@@ -195,7 +195,6 @@
|
||||
;;;; Common Mach Types ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(type MachLabel (primitive MachLabel))
|
||||
(type VecMachLabel extern (enum))
|
||||
(type ValueLabel (primitive ValueLabel))
|
||||
(type UnwindInst (primitive UnwindInst))
|
||||
(type ExternalName (primitive ExternalName))
|
||||
|
||||
Reference in New Issue
Block a user