@@ -80,12 +80,13 @@ pub struct Translator<'a, 'data> {
8080 /// The top-level import name for Wasmtime's unsafe intrinsics, if any.
8181 unsafe_intrinsics_import : Option < & ' a str > ,
8282
83- /// Whether this component contains any modules outside of leaf components.
83+ /// Whether this component contains any module instantiations outside of
84+ /// leaf components.
8485 ///
8586 /// We'll use this when generating fused adapters; if it's false, then we
8687 /// know that no guest-to-guest call can reenter a runtime instance
8788 /// recursively.
88- has_nonleaf_modules : bool ,
89+ has_nonleaf_module_instantiations : bool ,
8990}
9091
9192/// Representation of the syntactic scope of a component meaning where it is
@@ -179,12 +180,13 @@ struct Translation<'data> {
179180 /// is set to `None`.
180181 types : Option < Types > ,
181182
182- /// Whether we've encountered a module while parsing this component
183- /// (but ignoring modules found in subcomponents).
184- saw_module : bool ,
183+ /// Whether we've encountered a module instantiation while parsing this
184+ /// component (disregarding instantiations in subcomponents).
185+ saw_module_instantiation : bool ,
185186
186- /// Whether we've encountered a subcomponent while parsing this component.
187- saw_component : bool ,
187+ /// Whether we've encountered a component instantation while parsing this
188+ /// component (disregarding instantiations in subcomponents).
189+ saw_component_instantiation : bool ,
188190}
189191
190192// NB: the type information contained in `LocalInitializer` should always point
@@ -469,7 +471,7 @@ impl<'a, 'data> Translator<'a, 'data> {
469471 static_modules : Default :: default ( ) ,
470472 scope_vec,
471473 unsafe_intrinsics_import : None ,
472- has_nonleaf_modules : false ,
474+ has_nonleaf_module_instantiations : false ,
473475 }
474476 }
475477
@@ -710,7 +712,8 @@ impl<'a, 'data> Translator<'a, 'data> {
710712 assert ! ( self . result. types. is_none( ) ) ;
711713 self . result . types = Some ( self . validator . end ( offset) ?) ;
712714
713- self . has_nonleaf_modules |= self . result . saw_module && self . result . saw_component ;
715+ self . has_nonleaf_module_instantiations |=
716+ self . result . saw_module_instantiation && self . result . saw_component_instantiation ;
714717
715718 // Exit the current lexical scope. If there is no parent (no
716719 // frame currently on the stack) then translation is finished.
@@ -1211,7 +1214,6 @@ impl<'a, 'data> Translator<'a, 'data> {
12111214 parser,
12121215 unchecked_range,
12131216 } => {
1214- self . result . saw_module = true ;
12151217 let index = self . validator . types ( 0 ) . unwrap ( ) . module_count ( ) ;
12161218 self . validator . module_section ( & unchecked_range) ?;
12171219 let static_module_index = self . static_modules . next_key ( ) ;
@@ -1257,7 +1259,6 @@ impl<'a, 'data> Translator<'a, 'data> {
12571259 parser,
12581260 unchecked_range,
12591261 } => {
1260- self . result . saw_component = true ;
12611262 self . validator . component_section ( & unchecked_range) ?;
12621263 self . lexical_scopes . push ( LexicalScope {
12631264 parser : mem:: replace ( & mut self . parser , parser) ,
@@ -1271,6 +1272,7 @@ impl<'a, 'data> Translator<'a, 'data> {
12711272 // largely just records the arguments given from wasmparser into a
12721273 // `HashMap` for processing later during inlining.
12731274 Payload :: InstanceSection ( s) => {
1275+ self . result . saw_module_instantiation = true ;
12741276 self . validator . instance_section ( & s) ?;
12751277 for instance in s {
12761278 let init = match instance? {
@@ -1286,6 +1288,7 @@ impl<'a, 'data> Translator<'a, 'data> {
12861288 }
12871289 }
12881290 Payload :: ComponentInstanceSection ( s) => {
1291+ self . result . saw_component_instantiation = true ;
12891292 let mut index = self . validator . types ( 0 ) . unwrap ( ) . component_instance_count ( ) ;
12901293 self . validator . component_instance_section ( & s) ?;
12911294 for instance in s {
0 commit comments