It must happen at the language level; When it comes to execution context knowledge: what context to compile out (stackless), or what context to serialize to the heap (stackful). Programming language will always know much more about the program than the OS.
If I'm not mistaken in Erlang the programmer will provide the exact context to serialize : the actor.