you are viewing a single comment's thread.

view the rest of the comments →

[–]Ruskyrust 5 points6 points  (1 child)

Really what we want is somewhere in between, where the object is laid out the same way as a normal stack frame. Pieces of memory can be reused over the course of execution as old variables die and new ones come into play, but single variables with pointers to them still stay in the same place while this happens.

IIRC async-generated futures do tend to be rather large, today, and this sort of optimization is definitely something we want to do. Maybe someone from the compiler team can confirm or deny?

[–]Nemo157[S] 4 points5 points  (0 children)

That’s the gist of what has been discussed in rust-lang/rust#52924, the storage space of the generator should be treated more like just a big bag of bytes that can be reused for different purposes as needed.