Support for SpiderMonkey's "Wasm ABI 2020".

As part of a Wasm JIT update, SpiderMonkey is changing its internal
WebAssembly function ABI. The new ABI's frame format includes "caller
TLS" and "callee TLS" slots. The details of where these come from are
not important; from Cranelift's point of view, the only relevant
requirement is that we have two on-stack args that are always present
(offsetting other on-stack args), and that we define special argument
purposes so that we can supply values for these slots.

Note that this adds a *new* ABI (a variant of the Baldrdash ABI) because
we do not want to tightly couple the landing of this PR to the landing
of the changes in SpiderMonkey; it's better if both the old and new
behavior remain available in Cranelift, so SpiderMonkey can continue to
vendor Cranelift even if it does not land (or backs out) the ABI change.

Furthermore, note that this needs to be a Cranelift-level change (i.e.
cannot be done purely from the translator environment implementation)
because the special TLS arguments must always go on the stack, which
would not otherwise happen with the usual argument-placement logic; and
there is no primitive to push a value directly in CLIF code (the notion
of a stack frame is a lower-level concept).
This commit is contained in:
Chris Fallin
2020-09-22 16:53:06 -07:00
parent eb650f6fe0
commit 835db11bea
10 changed files with 204 additions and 21 deletions

View File

@@ -335,6 +335,20 @@ pub enum ArgumentPurpose {
/// This is a pointer to a stack limit. It is used to check the current stack pointer
/// against. Can only appear once in a signature.
StackLimit,
/// A callee TLS value.
///
/// In the Baldrdash-2020 calling convention, the stack upon entry to the callee contains the
/// TLS-register values for the caller and the callee. This argument is used to provide the
/// value for the callee.
CalleeTLS,
/// A caller TLS value.
///
/// In the Baldrdash-2020 calling convention, the stack upon entry to the callee contains the
/// TLS-register values for the caller and the callee. This argument is used to provide the
/// value for the caller.
CallerTLS,
}
impl fmt::Display for ArgumentPurpose {
@@ -349,6 +363,8 @@ impl fmt::Display for ArgumentPurpose {
Self::VMContext => "vmctx",
Self::SignatureId => "sigid",
Self::StackLimit => "stack_limit",
Self::CalleeTLS => "callee_tls",
Self::CallerTLS => "caller_tls",
})
}
}
@@ -470,6 +486,7 @@ mod tests {
CallConv::WindowsFastcall,
CallConv::BaldrdashSystemV,
CallConv::BaldrdashWindows,
CallConv::Baldrdash2020,
] {
assert_eq!(Ok(cc), cc.to_string().parse())
}