Author Mark.Shannon
Recipients Mark.Shannon, pablogsal
Date 2020-11-02.15:32:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1604331162.26.0.596873070589.issue42246@roundup.psfhosted.org>
In-reply-to
Content
Implementation of PEP 626 requires:

1. Implementation of the new line number table and associated APIs.
2. Removal of BEGIN_DO_NOT_EMIT_BYTECODE and END_DO_NOT_EMIT_BYTECODE from the compiler as they do not understand line numbers and may remove lines from the bytecode that they shouldn't.
3. Enhance compiler front-end and CFG optimizer to avoid the negative performance impact of PEP.
 a) Duplicate the tests in while blocks to avoid the extra jump instruction at the end of the loop.
 b) Duplicate and renumber terminator blocks that have no line numbers.

Guaranteeing that f_lineno is correct without hurting performance
-----------------------------------------------------------------

PEP 626 mandates that the f_lineno attribute of a frame is always correct, even after a return or raise, but we don't want to hurt performance.
Since the interpreter ensures that the f_lasti attribute of a frame is always correct, we can ensure correctness of f_lineno at zero cost, by ensuring that all RETURN_VALUE, RAISE_VARARGS and RERAISE instruction have a non-negative line number. Then f_lineno can always be lazily computed from f_lasti.

The front-end generates artificial RERAISEs and RETURN_VALUE that have no line number. To give these instructions a valid line number we can take advantage of the fact that such terminator blocks (blocks with no successors) can be freely duplicated. Once duplicated, each terminator block will have only one predecessor and can acquire the line number of the preceding block, without causing false line events.
History
Date User Action Args
2020-11-02 15:32:42Mark.Shannonsetrecipients: + Mark.Shannon, pablogsal
2020-11-02 15:32:42Mark.Shannonsetmessageid: <1604331162.26.0.596873070589.issue42246@roundup.psfhosted.org>
2020-11-02 15:32:42Mark.Shannonlinkissue42246 messages
2020-11-02 15:32:40Mark.Shannoncreate