Track type information during component translation (#4448)

This commit augments the current translation phase of components with
extra machinery to track the type information of component items such as
instances, components, and functions. The end goal of this commit is to
enable the `Lower` instruction to know the type of the component
function being lowered. Currently during the inlining pass where
component fusion is detected the type of the lifted function is known,
but to implement fusion entirely the type of the lowered function must
be known. Note that these two types are expected to be different to
allow for the subtyping rules specified by the component model.

For now nothing is actually done with this information other than noting
its presence in the face of a lifted-then-lowered function. My hope
though was to split this out for a separate review to avoid making a
future component-adapter-compiler-containing-PR too large.
This commit is contained in:
Alex Crichton
2022-07-18 09:21:40 -05:00
committed by GitHub
parent 791af15413
commit 3032e3fcfb
2 changed files with 187 additions and 19 deletions

View File

@@ -390,6 +390,7 @@ impl<'a> Inliner<'a> {
// NB: at this time only lowered imported functions are supported.
Lower(func, options) => {
let canonical_abi = frame.translation.funcs[frame.funcs.next_key()];
let lower_ty = frame.translation.component_funcs[*func];
let options_lower = self.canonical_options(frame, options);
let func = match &frame.component_funcs[*func] {
@@ -476,13 +477,14 @@ impl<'a> Inliner<'a> {
// the return values, copy them from `options_lift` to
// `options_lower`, and then return.
ComponentFuncDef::Lifted {
ty,
ty: lift_ty,
func,
options: options_lift,
} => {
// These are the various compilation options for lifting
// and lowering.
drop(ty); // component-model function type
drop(lift_ty); // type used when lifting the core function
drop(lower_ty); // type used when lowering the core function
drop(func); // original core wasm function that was lifted
drop(options_lift); // options during `canon lift`
drop(options_lower); // options during `canon lower`