Hi! The ref.func validation rule has a x \in C.refs
side condition. My understanding is that this limits usage of ref.func in code segment to only reference functions that are also referenced outside the code segment (essentially in global and table segments). I'm not sure why this is needed and couldn't find a rationale in the spec. Could someone help me understand? Thanks!
If I remember the discussion around this right the rough idea was that for streaming compilers you'd know ahead of time by the time you reach the code section whether something is exported from the module or not. What you'd do with that information I'm not 100% sure, though, in a streaming context.
In Wasmtime we sort of use this information to infer what set of trampolines need to be created to enter the module. Given the set of "possibly exported" functions, those in C.refs
, it dictates which type signatures need a trampoline generated. We don't really benefit much from the streaming requirement though since Cranelift is a more heavyweight compiler than a streaming baseline compiler.
I see thanks! So it's a validity restriction on modules for to allow for streaming compilers to be possible rather than for soundness (or some other execution-related requirement).
Last updated: Dec 23 2024 at 12:05 UTC