Use the term "Function parameter" instead of "argument".
Rename the ArgumentType type to AbiParam since it describes the ABI characteristics of a parameter or return value, not just the value type. In Signature, rename members argument_types and return_types to "params" and "returns". Again, they are not just types. Fix a couple lingering references to "EBB arguments".
This commit is contained in:
@@ -100,14 +100,14 @@ impl FuncTranslator {
|
||||
}
|
||||
}
|
||||
|
||||
/// Declare local variables for the signature arguments that correspond to WebAssembly locals.
|
||||
/// Declare local variables for the signature parameters that correspond to WebAssembly locals.
|
||||
///
|
||||
/// Return the number of local variables declared.
|
||||
fn declare_wasm_arguments(builder: &mut FunctionBuilder<Local>) -> usize {
|
||||
let sig_len = builder.func.signature.argument_types.len();
|
||||
let sig_len = builder.func.signature.params.len();
|
||||
let mut next_local = 0;
|
||||
for i in 0..sig_len {
|
||||
let arg_type = builder.func.signature.argument_types[i];
|
||||
let arg_type = builder.func.signature.params[i];
|
||||
// There may be additional special-purpose arguments following the normal WebAssembly
|
||||
// signature arguments. For example, a `vmctx` pointer.
|
||||
if arg_type.purpose == ir::ArgumentPurpose::Normal {
|
||||
@@ -256,12 +256,8 @@ mod tests {
|
||||
let mut ctx = Context::new();
|
||||
|
||||
ctx.func.name = ir::FunctionName::new("small1");
|
||||
ctx.func.signature.argument_types.push(
|
||||
ir::ArgumentType::new(I32),
|
||||
);
|
||||
ctx.func.signature.return_types.push(
|
||||
ir::ArgumentType::new(I32),
|
||||
);
|
||||
ctx.func.signature.params.push(ir::AbiParam::new(I32));
|
||||
ctx.func.signature.returns.push(ir::AbiParam::new(I32));
|
||||
|
||||
trans
|
||||
.translate(&BODY, &mut ctx.func, &mut runtime.func_env())
|
||||
@@ -291,12 +287,8 @@ mod tests {
|
||||
let mut ctx = Context::new();
|
||||
|
||||
ctx.func.name = ir::FunctionName::new("small2");
|
||||
ctx.func.signature.argument_types.push(
|
||||
ir::ArgumentType::new(I32),
|
||||
);
|
||||
ctx.func.signature.return_types.push(
|
||||
ir::ArgumentType::new(I32),
|
||||
);
|
||||
ctx.func.signature.params.push(ir::AbiParam::new(I32));
|
||||
ctx.func.signature.returns.push(ir::AbiParam::new(I32));
|
||||
|
||||
trans
|
||||
.translate(&BODY, &mut ctx.func, &mut runtime.func_env())
|
||||
@@ -335,9 +327,7 @@ mod tests {
|
||||
let mut ctx = Context::new();
|
||||
|
||||
ctx.func.name = ir::FunctionName::new("infloop");
|
||||
ctx.func.signature.return_types.push(
|
||||
ir::ArgumentType::new(I32),
|
||||
);
|
||||
ctx.func.signature.returns.push(ir::AbiParam::new(I32));
|
||||
|
||||
trans
|
||||
.translate(&BODY, &mut ctx.func, &mut runtime.func_env())
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
//! interpreted on the fly.
|
||||
use translation_utils::{type_to_type, TableIndex, FunctionIndex, GlobalIndex, SignatureIndex,
|
||||
MemoryIndex, Global, GlobalInit, Table, TableElementType, Memory};
|
||||
use cretonne::ir::{Signature, ArgumentType, CallConv};
|
||||
use cretonne::ir::{Signature, AbiParam, CallConv};
|
||||
use cretonne;
|
||||
use wasmparser::{Parser, ParserState, FuncType, ImportSectionEntryType, ExternalKind, WasmDecoder,
|
||||
MemoryType, Operator};
|
||||
@@ -35,17 +35,17 @@ pub fn parse_function_signatures(
|
||||
ref returns,
|
||||
}) => {
|
||||
let mut sig = Signature::new(CallConv::Native);
|
||||
sig.argument_types.extend(params.iter().map(|ty| {
|
||||
sig.params.extend(params.iter().map(|ty| {
|
||||
let cret_arg: cretonne::ir::Type = type_to_type(ty).expect(
|
||||
"only numeric types are supported in function signatures",
|
||||
);
|
||||
ArgumentType::new(cret_arg)
|
||||
AbiParam::new(cret_arg)
|
||||
}));
|
||||
sig.return_types.extend(returns.iter().map(|ty| {
|
||||
sig.returns.extend(returns.iter().map(|ty| {
|
||||
let cret_arg: cretonne::ir::Type = type_to_type(ty).expect(
|
||||
"only numeric types are supported in function signatures",
|
||||
);
|
||||
ArgumentType::new(cret_arg)
|
||||
AbiParam::new(cret_arg)
|
||||
}));
|
||||
environ.declare_signature(&sig);
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ impl TranslationState {
|
||||
self.clear();
|
||||
self.push_block(
|
||||
exit_block,
|
||||
sig.return_types
|
||||
sig.returns
|
||||
.iter()
|
||||
.filter(|arg| arg.purpose == ir::ArgumentPurpose::Normal)
|
||||
.count(),
|
||||
@@ -323,10 +323,10 @@ impl TranslationState {
|
||||
}
|
||||
}
|
||||
|
||||
/// Count the number of normal arguments in a signature.
|
||||
/// Exclude special-purpose arguments that represent runtime stuff and not WebAssembly arguments.
|
||||
/// Count the number of normal parameters in a signature.
|
||||
/// Exclude special-purpose parameters that represent runtime stuff and not WebAssembly arguments.
|
||||
fn normal_args(sig: &ir::Signature) -> usize {
|
||||
sig.argument_types
|
||||
sig.params
|
||||
.iter()
|
||||
.filter(|arg| arg.purpose == ir::ArgumentPurpose::Normal)
|
||||
.count()
|
||||
|
||||
Reference in New Issue
Block a user