Use is_wasm_parameter in translating wasm calls (#1352)

* Use `is_wasm_parameter` in translating wasm calls

Added in #1329 it's now possible for multiple parameters to be non-wasm
parameters, so the previous `param_types` method is no longer suitable
for acquiring all wasm-related parameters, rather then `FuncEnvironment`
must be consulted. This removes usage of `param_types()` as a method
from the wasm translation and instead adds a custom method inline for
filtering the parameters based on `is_wasm_parameter`.

* Apply feedback

* Run rustfmt

* Don't require `mut`

* Run rustfmt
This commit is contained in:
Alex Crichton
2020-01-17 14:11:54 -06:00
committed by Dan Gohman
parent e1d513ab4b
commit 1266b68f9a
4 changed files with 35 additions and 23 deletions

View File

@@ -144,6 +144,12 @@ pub trait FuncEnvironment: TargetEnvironment {
signature.params[index].purpose == ir::ArgumentPurpose::Normal
}
/// Is the given return of the given function a wasm-level parameter, as
/// opposed to a hidden parameter added for use by the implementation?
fn is_wasm_return(&self, signature: &ir::Signature, index: usize) -> bool {
signature.returns[index].purpose == ir::ArgumentPurpose::Normal
}
/// Should the code be structured to use a single `fallthrough_return` instruction at the end
/// of the function body, rather than `return` instructions as needed? This is used by VMs
/// to append custom epilogues.