New submission from Paul Pogonyshev:
This patch improves bytecode output, by removing unreachable code. It
doesn't target special cases, as now, but provides a generic implementation.
----------
components: Interpreter Core
files: unreachable-code.diff
messages: 57141
nosy: Paul Pogonyshev
severity: minor
status: open
title: simple patch, improving unreachable bytecode removing
versions: Python 2.6
Added file: http://bugs.python.org/file8699/unreachable-code.diff
__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1394>
__________________________________
Index: Python/peephole.c
===================================================================
*** Python/peephole.c (revision 58867)
--- Python/peephole.c (working copy)
***************
*** 550,566 ****
case EXTENDED_ARG:
goto exitUnchanged;
! /* Replace RETURN LOAD_CONST None RETURN with
just RETURN */
! /* Remove unreachable JUMPs after RETURN */
case RETURN_VALUE:
! if (i+4 >= codelen)
! continue;
! if (codestr[i+4] == RETURN_VALUE &&
! ISBASICBLOCK(blocks,i,5))
! memset(codestr+i+1, NOP, 4);
! else if (UNCONDITIONAL_JUMP(codestr[i+1]) &&
! ISBASICBLOCK(blocks,i,4))
! memset(codestr+i+1, NOP, 3);
break;
}
}
--- 550,571 ----
case EXTENDED_ARG:
goto exitUnchanged;
! /* Remove unreachable code completely */
! #if 0
! /* These are handled differently above */
! case CONTINUE_LOOP:
! case JUMP_FORWARD:
! case JUMP_ABSOLUTE:
! #endif
! case RAISE_VARARGS:
! case BREAK_LOOP:
case RETURN_VALUE:
! j = i + CODESIZE(codestr[i]);
! tgt = j;
! while (tgt < codelen && blocks[tgt] ==
blocks[i])
! tgt += CODESIZE(codestr[tgt]);
! if (tgt > j)
! memset(codestr+j, NOP, tgt-j);
break;
}
}
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com