cranelift: introduce a new WasmtimeAppleAarch64 calling convention

The previous choice to use the WasmtimeSystemV calling convention for
apple-aarch64 devices was incorrect: padding of arguments was
incorrectly computed. So we have to use some flavor of the apple-aarch64
ABI there.

Since we want to support the wasmtime custom convention for multiple
returns on apple-aarch64 too, a new custom Wasmtime calling convention
was introduced to support this.
This commit is contained in:
Benjamin Bouvier
2021-06-01 11:29:52 +02:00
parent aa2c0cd0ec
commit 51edea9e57
6 changed files with 25 additions and 11 deletions

View File

@@ -18,7 +18,7 @@ pub enum CallConv {
SystemV,
/// Windows "fastcall" convention, also used for x64 and ARM.
WindowsFastcall,
/// Mac aarch64 calling convention, which is a tweak aarch64 ABI.
/// Mac aarch64 calling convention, which is a tweaked aarch64 ABI.
AppleAarch64,
/// SpiderMonkey WebAssembly convention on systems using natively SystemV.
BaldrdashSystemV,
@@ -39,6 +39,10 @@ pub enum CallConv {
///
/// Differs from fastcall in the same way as `WasmtimeSystemV`.
WasmtimeFastcall,
/// Wasmtime equivalent of AppleAarch64, not ABI-stable.
///
/// Differs from apple-aarch64 in the same way as `WasmtimeSystemV`.
WasmtimeAppleAarch64,
}
impl CallConv {
@@ -78,6 +82,14 @@ impl CallConv {
}
}
/// Is the calling convention extending the Apple aarch64 ABI?
pub fn extends_apple_aarch64(self) -> bool {
match self {
Self::AppleAarch64 | Self::WasmtimeAppleAarch64 => true,
_ => false,
}
}
/// Is the calling convention extending the Baldrdash ABI?
pub fn extends_baldrdash(self) -> bool {
match self {
@@ -89,7 +101,7 @@ impl CallConv {
/// Is the calling convention extending the Wasmtime ABI?
pub fn extends_wasmtime(self) -> bool {
match self {
Self::WasmtimeSystemV | Self::WasmtimeFastcall => true,
Self::WasmtimeSystemV | Self::WasmtimeFastcall | Self::WasmtimeAppleAarch64 => true,
_ => false,
}
}
@@ -109,6 +121,7 @@ impl fmt::Display for CallConv {
Self::Probestack => "probestack",
Self::WasmtimeSystemV => "wasmtime_system_v",
Self::WasmtimeFastcall => "wasmtime_fastcall",
Self::WasmtimeAppleAarch64 => "wasmtime_apple_aarch64",
})
}
}
@@ -128,6 +141,7 @@ impl str::FromStr for CallConv {
"probestack" => Ok(Self::Probestack),
"wasmtime_system_v" => Ok(Self::WasmtimeSystemV),
"wasmtime_fastcall" => Ok(Self::WasmtimeFastcall),
"wasmtime_apple_aarch64" => Ok(Self::WasmtimeAppleAarch64),
_ => Err(()),
}
}