stackrestore and create a custom intrinsic
stackalloc that directly forwards to an
alloca. Implementation and unit test at https://github.com/rust-lang/rust/pull/26059
I would like to be able to test out storing arrays with a size only known at runtime (VLA) on the stack. Also I want to test out owned Unsized types on the stack (a
StackBox<T: ?Sized> that can’t be moved). This could be done directly in the compiler by allowing such types in normal let statements, but I believe there are too many open questions to even write this out as an rfc. I want to be able to try this out in a library and play around with it to have evidence to support a more complex proposal in the future.
Compiler-support for stack allocated objects
Doing the stacksave -> alloca -> stackrestore inside the compiler directly instead of going through library types. This has a few advantages like the possibility to move such an allocation outside of a loop and probably many others.
use a global arena instead
Can be done in a lib. Basically a second stack for DST. We can invent entire new optimizations for this.
Does this have any disadvantages?
- Modifying trans and typeck without using the changes in rustc
- stack analysis becomes hard