Depends if the language supports value types and stack allocation or not.
Many GC languages do so.
The hard part is that the difference is part of the type system, and you might need to refactor some code moving between value and reference types.