Add a FuncEnvironment::make_indirect_sig() callback.

The function environment is now expected to keep track of the function
signatures in the module, and it is asked to generate Cretonne
signatures to be used for indirect calls.

The combination of make_indirect_sig() and translate_call_indirect()
callbacks allow the runtime to insert additional function arguments for
indirect calls such as vmctx pointers and CFI-style signature identifiers.
This commit is contained in:
Jakob Stoklund Olesen
2017-09-06 10:28:11 -07:00
parent 320c88f365
commit 27e9e16077
7 changed files with 103 additions and 37 deletions

View File

@@ -26,6 +26,7 @@ pub enum SectionParsingError {
/// Reads the Type Section of the wasm module and returns the corresponding function signatures.
pub fn parse_function_signatures(
parser: &mut Parser,
runtime: &mut WasmRuntime,
) -> Result<Vec<Signature>, SectionParsingError> {
let mut signatures: Vec<Signature> = Vec::new();
loop {
@@ -53,6 +54,7 @@ pub fn parse_function_signatures(
};
ArgumentType::new(cret_arg)
}));
runtime.declare_signature(&sig);
signatures.push(sig);
}
ref s => return Err(SectionParsingError::WrongSectionContent(format!("{:?}", s))),