Treat VmContext as positional when using Native CallConv (#195)

* Treat VMContext as standard positional argument when using Native CallConv.

This requires threading the CallConv through legalize_args and into ArgAssigner.

* Stash CallConv in the intel-specific Args struct, for use ArgAssigner.
This commit is contained in:
Tyler McMullen
2017-11-21 17:08:31 -08:00
committed by Jakob Stoklund Olesen
parent b5d4fb66d9
commit 7956084121

View File

@@ -6,7 +6,7 @@ use regalloc::AllocatableSet;
use settings as shared_settings;
use super::registers::{GPR, FPR, RU};
use abi::{ArgAction, ValueConversion, ArgAssigner, legalize_args};
use ir::{AbiParam, ArgumentPurpose, ArgumentLoc, ArgumentExtension};
use ir::{AbiParam, ArgumentPurpose, ArgumentLoc, ArgumentExtension, CallConv};
use std::i32;
/// Argument registers for x86-64
@@ -24,10 +24,11 @@ struct Args {
fpr_limit: usize,
fpr_used: usize,
offset: u32,
call_conv: CallConv,
}
impl Args {
fn new(bits: u16, gpr: &'static [RU], fpr_limit: usize) -> Args {
fn new(bits: u16, gpr: &'static [RU], fpr_limit: usize, call_conv: CallConv) -> Args {
Args {
pointer_bytes: u32::from(bits) / 8,
pointer_bits: bits,
@@ -37,6 +38,7 @@ impl Args {
fpr_limit,
fpr_used: 0,
offset: 0,
call_conv: call_conv,
}
}
}
@@ -66,8 +68,7 @@ impl ArgAssigner for Args {
}
// Handle special-purpose arguments.
// TODO: The registers below are for `spiderwasm`. Should we check the calling convention?
if ty.is_int() {
if ty.is_int() && self.call_conv == CallConv::SpiderWASM {
match arg.purpose {
// This is SpiderMonkey's `WasmTlsReg`.
ArgumentPurpose::VMContext => {
@@ -112,15 +113,15 @@ pub fn legalize_signature(sig: &mut ir::Signature, flags: &shared_settings::Flag
if flags.is_64bit() {
bits = 64;
args = Args::new(bits, &ARG_GPRS, 8);
args = Args::new(bits, &ARG_GPRS, 8, sig.call_conv);
} else {
bits = 32;
args = Args::new(bits, &[], 0);
args = Args::new(bits, &[], 0, sig.call_conv);
}
legalize_args(&mut sig.params, &mut args);
let mut rets = Args::new(bits, &RET_GPRS, 2);
let mut rets = Args::new(bits, &RET_GPRS, 2, sig.call_conv);
legalize_args(&mut sig.returns, &mut rets);
}