That is exactly what escape analysis does, granted the way it is done across implementations varies.
Such hardware has been designed in the past, Lisp machines, Ada machines, the famous iAPX 432 Intel's failure.