Cranellift: remove Baldrdash support and related features. (#4571)
* Cranellift: remove Baldrdash support and related features.
As noted in Mozilla's bugzilla bug 1781425 [1], the SpiderMonkey team
has recently determined that their current form of integration with
Cranelift is too hard to maintain, and they have chosen to remove it
from their codebase. If and when they decide to build updated support
for Cranelift, they will adopt different approaches to several details
of the integration.
In the meantime, after discussion with the SpiderMonkey folks, they
agree that it makes sense to remove the bits of Cranelift that exist
to support the integration ("Baldrdash"), as they will not need
them. Many of these bits are difficult-to-maintain special cases that
are not actually tested in Cranelift proper: for example, the
Baldrdash integration required Cranelift to emit function bodies
without prologues/epilogues, and instead communicate very precise
information about the expected frame size and layout, then stitched
together something post-facto. This was brittle and caused a lot of
incidental complexity ("fallthrough returns", the resulting special
logic in block-ordering); this is just one example. As another
example, one particular Baldrdash ABI variant processed stack args in
reverse order, so our ABI code had to support both traversal
orders. We had a number of other Baldrdash-specific settings as well
that did various special things.
This PR removes Baldrdash ABI support, the `fallthrough_return`
instruction, and pulls some threads to remove now-unused bits as a
result of those two, with the understanding that the SpiderMonkey folks
will build new functionality as needed in the future and we can perhaps
find cleaner abstractions to make it all work.
[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1781425
* Review feedback.
* Fix (?) DWARF debug tests: add `--disable-cache` to wasmtime invocations.
The debugger tests invoke `wasmtime` from within each test case under
the control of a debugger (gdb or lldb). Some of these tests started to
inexplicably fail in CI with unrelated changes, and the failures were
only inconsistently reproducible locally. It seems to be cache related:
if we disable cached compilation on the nested `wasmtime` invocations,
the tests consistently pass.
* Review feedback.
This commit is contained in:
@@ -20,60 +20,6 @@ use std::convert::TryFrom;
|
||||
/// with 32-bit arithmetic: for now, 128 MB.
|
||||
static STACK_ARG_RET_SIZE_LIMIT: u64 = 128 * 1024 * 1024;
|
||||
|
||||
/// Offset in stack-arg area to callee-TLS slot in Baldrdash-2020 calling convention.
|
||||
static BALDRDASH_CALLEE_TLS_OFFSET: i64 = 0;
|
||||
/// Offset in stack-arg area to caller-TLS slot in Baldrdash-2020 calling convention.
|
||||
static BALDRDASH_CALLER_TLS_OFFSET: i64 = 8;
|
||||
|
||||
/// Try to fill a Baldrdash register, returning it if it was found.
|
||||
fn try_fill_baldrdash_reg(call_conv: CallConv, param: &ir::AbiParam) -> Option<ABIArg> {
|
||||
if call_conv.extends_baldrdash() {
|
||||
match ¶m.purpose {
|
||||
&ir::ArgumentPurpose::VMContext => {
|
||||
// This is SpiderMonkey's `WasmTlsReg`.
|
||||
Some(ABIArg::reg(
|
||||
regs::r14().to_real_reg().unwrap(),
|
||||
types::I64,
|
||||
param.extension,
|
||||
param.purpose,
|
||||
))
|
||||
}
|
||||
&ir::ArgumentPurpose::SignatureId => {
|
||||
// This is SpiderMonkey's `WasmTableCallSigReg`.
|
||||
Some(ABIArg::reg(
|
||||
regs::r10().to_real_reg().unwrap(),
|
||||
types::I64,
|
||||
param.extension,
|
||||
param.purpose,
|
||||
))
|
||||
}
|
||||
&ir::ArgumentPurpose::CalleeTLS => {
|
||||
// This is SpiderMonkey's callee TLS slot in the extended frame of Wasm's ABI-2020.
|
||||
assert!(call_conv == isa::CallConv::Baldrdash2020);
|
||||
Some(ABIArg::stack(
|
||||
BALDRDASH_CALLEE_TLS_OFFSET,
|
||||
ir::types::I64,
|
||||
ir::ArgumentExtension::None,
|
||||
param.purpose,
|
||||
))
|
||||
}
|
||||
&ir::ArgumentPurpose::CallerTLS => {
|
||||
// This is SpiderMonkey's caller TLS slot in the extended frame of Wasm's ABI-2020.
|
||||
assert!(call_conv == isa::CallConv::Baldrdash2020);
|
||||
Some(ABIArg::stack(
|
||||
BALDRDASH_CALLER_TLS_OFFSET,
|
||||
ir::types::I64,
|
||||
ir::ArgumentExtension::None,
|
||||
param.purpose,
|
||||
))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Support for the x64 ABI from the callee side (within a function body).
|
||||
pub(crate) type X64ABICallee = ABICalleeImpl<X64ABIMachineSpec>;
|
||||
|
||||
@@ -102,9 +48,7 @@ impl ABIMachineSpec for X64ABIMachineSpec {
|
||||
args_or_rets: ArgsOrRets,
|
||||
add_ret_area_ptr: bool,
|
||||
) -> CodegenResult<(Vec<ABIArg>, i64, Option<usize>)> {
|
||||
let is_baldrdash = call_conv.extends_baldrdash();
|
||||
let is_fastcall = call_conv.extends_windows_fastcall();
|
||||
let has_baldrdash_tls = call_conv == isa::CallConv::Baldrdash2020;
|
||||
|
||||
let mut next_gpr = 0;
|
||||
let mut next_vreg = 0;
|
||||
@@ -121,29 +65,13 @@ impl ABIMachineSpec for X64ABIMachineSpec {
|
||||
next_stack = 32;
|
||||
}
|
||||
|
||||
if args_or_rets == ArgsOrRets::Args && has_baldrdash_tls {
|
||||
// Baldrdash ABI-2020 always has two stack-arg slots reserved, for the callee and
|
||||
// caller TLS-register values, respectively.
|
||||
next_stack = 16;
|
||||
}
|
||||
|
||||
for i in 0..params.len() {
|
||||
// Process returns backward, according to the SpiderMonkey ABI (which we
|
||||
// adopt internally if `is_baldrdash` is set).
|
||||
let param = match (args_or_rets, is_baldrdash) {
|
||||
(ArgsOrRets::Args, _) => ¶ms[i],
|
||||
(ArgsOrRets::Rets, false) => ¶ms[i],
|
||||
(ArgsOrRets::Rets, true) => ¶ms[params.len() - 1 - i],
|
||||
};
|
||||
|
||||
for param in params {
|
||||
// Validate "purpose".
|
||||
match ¶m.purpose {
|
||||
&ir::ArgumentPurpose::VMContext
|
||||
| &ir::ArgumentPurpose::Normal
|
||||
| &ir::ArgumentPurpose::StackLimit
|
||||
| &ir::ArgumentPurpose::SignatureId
|
||||
| &ir::ArgumentPurpose::CalleeTLS
|
||||
| &ir::ArgumentPurpose::CallerTLS
|
||||
| &ir::ArgumentPurpose::StructReturn
|
||||
| &ir::ArgumentPurpose::StructArgument(_) => {}
|
||||
_ => panic!(
|
||||
@@ -152,11 +80,6 @@ impl ABIMachineSpec for X64ABIMachineSpec {
|
||||
),
|
||||
}
|
||||
|
||||
if let Some(param) = try_fill_baldrdash_reg(call_conv, param) {
|
||||
ret.push(param);
|
||||
continue;
|
||||
}
|
||||
|
||||
if let ir::ArgumentPurpose::StructArgument(size) = param.purpose {
|
||||
let offset = next_stack as i64;
|
||||
let size = size as u64;
|
||||
@@ -269,10 +192,6 @@ impl ABIMachineSpec for X64ABIMachineSpec {
|
||||
});
|
||||
}
|
||||
|
||||
if args_or_rets == ArgsOrRets::Rets && is_baldrdash {
|
||||
ret.reverse();
|
||||
}
|
||||
|
||||
let extra_arg = if add_ret_area_ptr {
|
||||
debug_assert!(args_or_rets == ArgsOrRets::Args);
|
||||
if let Some(reg) = get_intreg_for_arg(&call_conv, next_gpr, next_param_idx) {
|
||||
@@ -306,14 +225,8 @@ impl ABIMachineSpec for X64ABIMachineSpec {
|
||||
Ok((ret, next_stack as i64, extra_arg))
|
||||
}
|
||||
|
||||
fn fp_to_arg_offset(call_conv: isa::CallConv, flags: &settings::Flags) -> i64 {
|
||||
if call_conv.extends_baldrdash() {
|
||||
let num_words = flags.baldrdash_prologue_words() as i64;
|
||||
debug_assert!(num_words > 0, "baldrdash must set baldrdash_prologue_words");
|
||||
num_words * 8
|
||||
} else {
|
||||
16 // frame pointer + return address.
|
||||
}
|
||||
fn fp_to_arg_offset(_call_conv: isa::CallConv, _flags: &settings::Flags) -> i64 {
|
||||
16 // frame pointer + return address.
|
||||
}
|
||||
|
||||
fn gen_load_stack(mem: StackAMode, into_reg: Writable<Reg>, ty: Type) -> Self::I {
|
||||
@@ -361,10 +274,6 @@ impl ABIMachineSpec for X64ABIMachineSpec {
|
||||
Inst::ret(rets)
|
||||
}
|
||||
|
||||
fn gen_epilogue_placeholder() -> Self::I {
|
||||
Inst::epilogue_placeholder()
|
||||
}
|
||||
|
||||
fn gen_add_imm(into_reg: Writable<Reg>, from_reg: Reg, imm: u32) -> SmallInstVec<Self::I> {
|
||||
let mut ret = SmallVec::new();
|
||||
if from_reg != into_reg.to_reg() {
|
||||
@@ -396,10 +305,10 @@ impl ABIMachineSpec for X64ABIMachineSpec {
|
||||
}
|
||||
|
||||
fn get_stacklimit_reg() -> Reg {
|
||||
debug_assert!(
|
||||
!is_callee_save_systemv(regs::r10().to_real_reg().unwrap(), false)
|
||||
&& !is_callee_save_baldrdash(regs::r10().to_real_reg().unwrap())
|
||||
);
|
||||
debug_assert!(!is_callee_save_systemv(
|
||||
regs::r10().to_real_reg().unwrap(),
|
||||
false
|
||||
));
|
||||
|
||||
// As per comment on trait definition, we must return a caller-save
|
||||
// register here.
|
||||
@@ -621,17 +530,6 @@ impl ABIMachineSpec for X64ABIMachineSpec {
|
||||
));
|
||||
}
|
||||
|
||||
// If this is Baldrdash-2020, restore the callee (i.e., our) TLS
|
||||
// register. We may have allocated it for something else and clobbered
|
||||
// it, but the ABI expects us to leave the TLS register unchanged.
|
||||
if call_conv == isa::CallConv::Baldrdash2020 {
|
||||
let off = BALDRDASH_CALLEE_TLS_OFFSET + Self::fp_to_arg_offset(call_conv, flags);
|
||||
insts.push(Inst::mov64_m_r(
|
||||
Amode::imm_reg(off as u32, regs::rbp()),
|
||||
Writable::from_reg(regs::r14()),
|
||||
));
|
||||
}
|
||||
|
||||
insts
|
||||
}
|
||||
|
||||
@@ -684,8 +582,6 @@ impl ABIMachineSpec for X64ABIMachineSpec {
|
||||
src: Reg,
|
||||
size: usize,
|
||||
) -> SmallVec<[Self::I; 8]> {
|
||||
// Baldrdash should not use struct args.
|
||||
assert!(!call_conv.extends_baldrdash());
|
||||
let mut insts = SmallVec::new();
|
||||
let arg0 = get_intreg_for_arg(&call_conv, 0, 0).unwrap();
|
||||
let arg1 = get_intreg_for_arg(&call_conv, 1, 1).unwrap();
|
||||
@@ -741,33 +637,18 @@ impl ABIMachineSpec for X64ABIMachineSpec {
|
||||
}
|
||||
|
||||
fn get_regs_clobbered_by_call(call_conv_of_callee: isa::CallConv) -> PRegSet {
|
||||
let mut clobbers = if call_conv_of_callee.extends_windows_fastcall() {
|
||||
if call_conv_of_callee.extends_windows_fastcall() {
|
||||
WINDOWS_CLOBBERS
|
||||
} else {
|
||||
SYSV_CLOBBERS
|
||||
};
|
||||
|
||||
if call_conv_of_callee.extends_baldrdash() {
|
||||
clobbers.add(regs::gpr_preg(regs::ENC_R12));
|
||||
clobbers.add(regs::gpr_preg(regs::ENC_R13));
|
||||
clobbers.add(regs::gpr_preg(regs::ENC_R15));
|
||||
clobbers.add(regs::gpr_preg(regs::ENC_RBX));
|
||||
}
|
||||
|
||||
clobbers
|
||||
}
|
||||
|
||||
fn get_ext_mode(
|
||||
call_conv: isa::CallConv,
|
||||
specified: ir::ArgumentExtension,
|
||||
_call_conv: isa::CallConv,
|
||||
_specified: ir::ArgumentExtension,
|
||||
) -> ir::ArgumentExtension {
|
||||
if call_conv.extends_baldrdash() {
|
||||
// Baldrdash (SpiderMonkey) always extends args and return values to the full register.
|
||||
specified
|
||||
} else {
|
||||
// No other supported ABI on x64 does so.
|
||||
ir::ArgumentExtension::None
|
||||
}
|
||||
ir::ArgumentExtension::None
|
||||
}
|
||||
|
||||
fn get_clobbered_callee_saves(
|
||||
@@ -777,14 +658,6 @@ impl ABIMachineSpec for X64ABIMachineSpec {
|
||||
regs: &[Writable<RealReg>],
|
||||
) -> Vec<Writable<RealReg>> {
|
||||
let mut regs: Vec<Writable<RealReg>> = match call_conv {
|
||||
CallConv::BaldrdashSystemV | CallConv::Baldrdash2020 => regs
|
||||
.iter()
|
||||
.cloned()
|
||||
.filter(|r| is_callee_save_baldrdash(r.to_reg()))
|
||||
.collect(),
|
||||
CallConv::BaldrdashWindows => {
|
||||
todo!("baldrdash windows");
|
||||
}
|
||||
CallConv::Fast | CallConv::Cold | CallConv::SystemV | CallConv::WasmtimeSystemV => regs
|
||||
.iter()
|
||||
.cloned()
|
||||
@@ -905,10 +778,7 @@ fn get_intreg_for_retval(
|
||||
1 => Some(regs::rdx()),
|
||||
_ => None,
|
||||
},
|
||||
CallConv::BaldrdashSystemV
|
||||
| CallConv::Baldrdash2020
|
||||
| CallConv::WasmtimeSystemV
|
||||
| CallConv::WasmtimeFastcall => {
|
||||
CallConv::WasmtimeSystemV | CallConv::WasmtimeFastcall => {
|
||||
if intreg_idx == 0 && retval_idx == 0 {
|
||||
Some(regs::rax())
|
||||
} else {
|
||||
@@ -920,7 +790,7 @@ fn get_intreg_for_retval(
|
||||
1 => Some(regs::rdx()), // The Rust ABI for i128s needs this.
|
||||
_ => None,
|
||||
},
|
||||
CallConv::BaldrdashWindows | CallConv::Probestack => todo!(),
|
||||
CallConv::Probestack => todo!(),
|
||||
CallConv::AppleAarch64 | CallConv::WasmtimeAppleAarch64 => unreachable!(),
|
||||
}
|
||||
}
|
||||
@@ -936,10 +806,7 @@ fn get_fltreg_for_retval(
|
||||
1 => Some(regs::xmm1()),
|
||||
_ => None,
|
||||
},
|
||||
CallConv::BaldrdashSystemV
|
||||
| CallConv::Baldrdash2020
|
||||
| CallConv::WasmtimeFastcall
|
||||
| CallConv::WasmtimeSystemV => {
|
||||
CallConv::WasmtimeFastcall | CallConv::WasmtimeSystemV => {
|
||||
if fltreg_idx == 0 && retval_idx == 0 {
|
||||
Some(regs::xmm0())
|
||||
} else {
|
||||
@@ -950,7 +817,7 @@ fn get_fltreg_for_retval(
|
||||
0 => Some(regs::xmm0()),
|
||||
_ => None,
|
||||
},
|
||||
CallConv::BaldrdashWindows | CallConv::Probestack => todo!(),
|
||||
CallConv::Probestack => todo!(),
|
||||
CallConv::AppleAarch64 | CallConv::WasmtimeAppleAarch64 => unreachable!(),
|
||||
}
|
||||
}
|
||||
@@ -970,22 +837,6 @@ fn is_callee_save_systemv(r: RealReg, enable_pinned_reg: bool) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
fn is_callee_save_baldrdash(r: RealReg) -> bool {
|
||||
use regs::*;
|
||||
match r.class() {
|
||||
RegClass::Int => {
|
||||
if r.hw_enc() == ENC_R14 {
|
||||
// r14 is the WasmTlsReg and is preserved implicitly.
|
||||
false
|
||||
} else {
|
||||
// Defer to native for the other ones.
|
||||
is_callee_save_systemv(r, /* enable_pinned_reg = */ true)
|
||||
}
|
||||
}
|
||||
RegClass::Float => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn is_callee_save_fastcall(r: RealReg, enable_pinned_reg: bool) -> bool {
|
||||
use regs::*;
|
||||
match r.class() {
|
||||
|
||||
@@ -331,14 +331,9 @@
|
||||
;; Return.
|
||||
(Ret (rets VecReg))
|
||||
|
||||
;; A placeholder instruction, generating no code, meaning that a function
|
||||
;; epilogue must be inserted there.
|
||||
(EpiloguePlaceholder)
|
||||
|
||||
;; Jump to a known target: jmp simm32.
|
||||
(JmpKnown (dst MachLabel))
|
||||
|
||||
|
||||
;; One-way conditional branch: jcond cond target.
|
||||
;;
|
||||
;; This instruction is useful when we have conditional jumps depending on
|
||||
|
||||
@@ -2646,11 +2646,7 @@ pub(crate) fn emit(
|
||||
sink.put1(0x48 | ((enc_dst >> 3) & 1));
|
||||
sink.put1(0xB8 | (enc_dst & 7));
|
||||
emit_reloc(sink, Reloc::Abs8, name, *offset);
|
||||
if info.flags.emit_all_ones_funcaddrs() {
|
||||
sink.put8(u64::max_value());
|
||||
} else {
|
||||
sink.put8(0);
|
||||
}
|
||||
sink.put8(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2918,10 +2914,6 @@ pub(crate) fn emit(
|
||||
}
|
||||
}
|
||||
|
||||
Inst::EpiloguePlaceholder => {
|
||||
// Generate no code.
|
||||
}
|
||||
|
||||
Inst::ElfTlsGetAddr { ref symbol } => {
|
||||
// N.B.: Must be exactly this byte sequence; the linker requires it,
|
||||
// because it must know how to rewrite the bytes.
|
||||
|
||||
@@ -77,7 +77,6 @@ impl Inst {
|
||||
| Inst::CvtFloatToUintSeq { .. }
|
||||
| Inst::CvtUint64ToFloatSeq { .. }
|
||||
| Inst::Div { .. }
|
||||
| Inst::EpiloguePlaceholder
|
||||
| Inst::Fence { .. }
|
||||
| Inst::Hlt
|
||||
| Inst::Imm { .. }
|
||||
@@ -725,10 +724,6 @@ impl Inst {
|
||||
Inst::Ret { rets }
|
||||
}
|
||||
|
||||
pub(crate) fn epilogue_placeholder() -> Inst {
|
||||
Inst::EpiloguePlaceholder
|
||||
}
|
||||
|
||||
pub(crate) fn jmp_known(dst: MachLabel) -> Inst {
|
||||
Inst::JmpKnown { dst }
|
||||
}
|
||||
@@ -1629,8 +1624,6 @@ impl PrettyPrint for Inst {
|
||||
|
||||
Inst::Ret { .. } => "ret".to_string(),
|
||||
|
||||
Inst::EpiloguePlaceholder => "epilogue placeholder".to_string(),
|
||||
|
||||
Inst::JmpKnown { dst } => {
|
||||
format!("{} {}", ljustify("jmp".to_string()), dst.to_string())
|
||||
}
|
||||
@@ -2170,8 +2163,7 @@ fn x64_get_operands<F: Fn(VReg) -> VReg>(inst: &Inst, collector: &mut OperandCol
|
||||
}
|
||||
}
|
||||
|
||||
Inst::EpiloguePlaceholder
|
||||
| Inst::JmpKnown { .. }
|
||||
Inst::JmpKnown { .. }
|
||||
| Inst::JmpIf { .. }
|
||||
| Inst::JmpCond { .. }
|
||||
| Inst::Nop { .. }
|
||||
@@ -2247,18 +2239,10 @@ impl MachInst for Inst {
|
||||
}
|
||||
}
|
||||
|
||||
fn is_epilogue_placeholder(&self) -> bool {
|
||||
if let Self::EpiloguePlaceholder = self {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn is_term(&self) -> MachTerminator {
|
||||
match self {
|
||||
// Interesting cases.
|
||||
&Self::Ret { .. } | &Self::EpiloguePlaceholder => MachTerminator::Ret,
|
||||
&Self::Ret { .. } => MachTerminator::Ret,
|
||||
&Self::JmpKnown { .. } => MachTerminator::Uncond,
|
||||
&Self::JmpCond { .. } => MachTerminator::Cond,
|
||||
&Self::JmpTableSeq { .. } => MachTerminator::Indirect,
|
||||
|
||||
@@ -1475,15 +1475,12 @@
|
||||
(rule (lower (resumable_trap code))
|
||||
(side_effect (x64_ud2 code)))
|
||||
|
||||
;;;; Rules for `return` and `fallthrough_return` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;; Rules for `return` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; N.B.: the Ret itself is generated by the ABI.
|
||||
(rule (lower (return args))
|
||||
(lower_return (range 0 (value_slice_len args)) args))
|
||||
|
||||
(rule (lower (fallthrough_return args))
|
||||
(lower_return (range 0 (value_slice_len args)) args))
|
||||
|
||||
(decl lower_return (Range ValueSlice) InstOutput)
|
||||
(rule (lower_return (range_empty) _) (output_none))
|
||||
(rule (lower_return (range_unwrap head tail) args)
|
||||
|
||||
@@ -6,8 +6,8 @@ pub(super) mod isle;
|
||||
use crate::data_value::DataValue;
|
||||
use crate::ir::{
|
||||
condcodes::{CondCode, FloatCC, IntCC},
|
||||
types, AbiParam, ArgumentPurpose, ExternalName, Inst as IRInst, InstructionData, LibCall,
|
||||
Opcode, Signature, Type,
|
||||
types, AbiParam, ExternalName, Inst as IRInst, InstructionData, LibCall, Opcode, Signature,
|
||||
Type,
|
||||
};
|
||||
use crate::isa::x64::abi::*;
|
||||
use crate::isa::x64::inst::args::*;
|
||||
@@ -577,7 +577,6 @@ fn make_libcall_sig<C: LowerCtx<I = Inst>>(
|
||||
ctx: &mut C,
|
||||
insn: IRInst,
|
||||
call_conv: CallConv,
|
||||
ptr_ty: Type,
|
||||
) -> Signature {
|
||||
let mut sig = Signature::new(call_conv);
|
||||
for i in 0..ctx.num_inputs(insn) {
|
||||
@@ -586,11 +585,6 @@ fn make_libcall_sig<C: LowerCtx<I = Inst>>(
|
||||
for i in 0..ctx.num_outputs(insn) {
|
||||
sig.returns.push(AbiParam::new(ctx.output_ty(insn, i)));
|
||||
}
|
||||
if call_conv.extends_baldrdash() {
|
||||
// Adds the special VMContext parameter to the signature.
|
||||
sig.params
|
||||
.push(AbiParam::special(ptr_ty, ArgumentPurpose::VMContext));
|
||||
}
|
||||
sig
|
||||
}
|
||||
|
||||
@@ -613,26 +607,19 @@ fn emit_vm_call<C: LowerCtx<I = Inst>>(
|
||||
|
||||
// TODO avoid recreating signatures for every single Libcall function.
|
||||
let call_conv = CallConv::for_libcall(flags, CallConv::triple_default(triple));
|
||||
let sig = make_libcall_sig(ctx, insn, call_conv, types::I64);
|
||||
let sig = make_libcall_sig(ctx, insn, call_conv);
|
||||
let caller_conv = ctx.abi().call_conv();
|
||||
|
||||
let mut abi = X64ABICaller::from_func(&sig, &extname, dist, caller_conv, flags)?;
|
||||
|
||||
abi.emit_stack_pre_adjust(ctx);
|
||||
|
||||
let vm_context = if call_conv.extends_baldrdash() { 1 } else { 0 };
|
||||
assert_eq!(inputs.len() + vm_context, abi.num_args());
|
||||
assert_eq!(inputs.len(), abi.num_args());
|
||||
|
||||
for (i, input) in inputs.iter().enumerate() {
|
||||
let arg_reg = put_input_in_reg(ctx, *input);
|
||||
abi.emit_copy_regs_to_arg(ctx, i, ValueRegs::one(arg_reg));
|
||||
}
|
||||
if call_conv.extends_baldrdash() {
|
||||
let vm_context_vreg = ctx
|
||||
.get_vm_context()
|
||||
.expect("should have a VMContext to pass to libcall funcs");
|
||||
abi.emit_copy_regs_to_arg(ctx, inputs.len(), ValueRegs::one(vm_context_vreg));
|
||||
}
|
||||
|
||||
abi.emit_call(ctx);
|
||||
for (i, output) in outputs.iter().enumerate() {
|
||||
@@ -923,7 +910,6 @@ fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
|
||||
| Opcode::Fence
|
||||
| Opcode::FuncAddr
|
||||
| Opcode::SymbolValue
|
||||
| Opcode::FallthroughReturn
|
||||
| Opcode::Return
|
||||
| Opcode::Call
|
||||
| Opcode::CallIndirect
|
||||
|
||||
Reference in New Issue
Block a user