Does a generator really stops the execution at the machine code level, and does it not use the stack?
It depends on the language implementation, but most do it by packaging the local variables of the generator function, together with the instruction pointer from where the last yield occurred, into a heap-allocated closure object. This is what is inside the opaque "generator object" that represents the stream of values in the language. The heap variables representing the saved instruction pointer and generator function locals are updated in place whenever the generator function yields, and reloaded to resume execution of the generator function whenever the next value is demanded from the generator.

It is important to remember that, when you get down to the machine code level, the computer has no concept of a "stack" and a "heap". Those are abstractions added by programming langauge runtime environments on top of the fundamental concepts of contiguous RAM and goto.

Generators are another feature that language runtimes can implement on top of these basic primitives. So the literal answer to the question "Does a generator really stop execution at the machine code level, and that next time when the iterator is invoked, then there is a jump back to that machine code location to continue the execution?" is yes, absolutely.

Generators are an instance of a more general concept called continuations and the call/cc operator. A continuation is often implemented as literally the state of the stack and instruction pointer packaged into a heap-allocated object.

Note that most programming language specifications allow the implementation total latitude as to how memory management works as long as the semantics of the language are conformed to. This is important for the implementation of lazy functional languages, which generalize the generator concept so that all data structures and subexpressions are generated lazily by default. These languages often have implementations that barely resemble the C locals+malloc model. Check out Simon Peyton Jones's books on the implementation of functional programming languages and the Spineless Tagless G-machine for more info. 1 2 3