You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #783 we're introducing the ability to define stack allocated types capable of storing both heap and stack allocated types. We should find a way to extend such functionality to also work for closures.
Stack allocating closures poses a few challenges:
fn types are currently assumed to be pointers, not stack allocated data
stack allocated closures don't have a uniform layout, as their size is dictated by the variables they capture
closures may assign captured variables new values, which won't work reliably if we copy the stack data similar to inline types
For closures to be stack allocated, we most likely need to treat them similarly as generic type arguments and generate specialized versions. This however is likely to require extensive changes to how we specialize types and methods, so I'm not sure about this yet.
For closures it might make more sense to keep their memory layout the same, but use escape analysis to allocate them on the stack. Most closures aren't likely to outlive the method they're defined in, so this might be good enough. This also removes the need for complex specialization changes.
Description
In #783 we're introducing the ability to define stack allocated types capable of storing both heap and stack allocated types. We should find a way to extend such functionality to also work for closures.
Stack allocating closures poses a few challenges:
fn
types are currently assumed to be pointers, not stack allocated datainline
typesFor closures to be stack allocated, we most likely need to treat them similarly as generic type arguments and generate specialized versions. This however is likely to require extensive changes to how we specialize types and methods, so I'm not sure about this yet.
Related issues
Related work
The text was updated successfully, but these errors were encountered: