[issue17611] Move unwinding of stack for "pseudo exceptions" from interpreter to compiler.
Serhiy Storchaka
report at bugs.python.org
Mon Dec 4 07:25:34 EST 2017
Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:
I started on Antoine's PR and work on different approach (https://github.com/serhiy-storchaka/cpython/pull/1) which don't duplicate the code for continue/break/return. Instead it uses some kind of subroutines. END_FINALLY expects the one of three cases:
1. NULL (or None). Normal execution thread in try/finally. Continue from the instruction following END_FINALLY.
2. An integer. This is an address of returning. Continue from the specified address.
3. An exception (6 items). Raises the specified exception.
WITH_CLEANUP_FINISH behaves similarly.
The statements continue/break/return insert the instruction CALL_FINALLY which pushes the address of the following instruction on the stack and jumps to the start of the finally (or with cleanup) block. There can be several CALL_FINALLY instructions if you need to execute several finally blocks. At the jump instruction is inserted for continue and break, and RETURN_VALUE for return.
Currently I'm trying to simplify the code.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue17611>
_______________________________________
More information about the Python-bugs-list
mailing list