Author serhiy.storchaka
Recipients Mark.Shannon, benjamin.peterson, mark.dickinson, pitrou, rhettinger, serhiy.storchaka, trent
Date 2014-11-16.15:06:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1416150373.1.0.93356100639.issue17611@psf.upfronthosting.co.za>
In-reply-to
Content
I like the idea. I have not make faultfinding review yet, but one thing is questionable to me.

Is it necessary to get rid of the END_FINALLY opcode?

Currently Python code

    try:
        stmt1
    finally:
        stmt2

is compiled to:

    SETUP_FINALLY L1
    // stmt1
    POP_BLOCK
    LOAD_CONST None
L1: // stmt2
    END_FINALLY

With the patch it is compiled to:

    SETUP_FINALLY L1
    // stmt1
    POP_BLOCK
    // stmt2
    JUMP_ABSOLUTE L2
L1: // stmt2
    RERAISE
L2:

Finally body is duplicated. In case of large finally body this increases the size of the bytecode. Line numbers are duplicated in disassembly listing, this is confused. And I afraid that due to increasing the size of the bytecode, some relative jumps can became too long.

If it is absolutely necessary to remove the END_FINALLY opcode, I suggest to generate following bytecode:

    SETUP_FINALLY L1
    // stmt1
    POP_BLOCK
    LOAD_CONST None
L1: // stmt2
    POP_JUMP_IF_FALSE L2
    RERAISE
L2:

But it looks to me that special END_FINALLY opcode which combines POP_JUMP_IF_FALSE/RERAISE would be better for performance and compiled code size.
History
Date User Action Args
2014-11-16 15:06:13serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, mark.dickinson, pitrou, benjamin.peterson, trent, Mark.Shannon
2014-11-16 15:06:13serhiy.storchakasetmessageid: <1416150373.1.0.93356100639.issue17611@psf.upfronthosting.co.za>
2014-11-16 15:06:13serhiy.storchakalinkissue17611 messages
2014-11-16 15:06:12serhiy.storchakacreate