Improved the bytecode optimizer.

* Can now test for basic blocks.
* Optimize inverted comparisions.
* Optimize unary_not followed by a conditional jump.
* Added a new opcode, NOP, to keep code size constant.
* Applied NOP to previous transformations where appropriate.

Note, the NOP would not be necessary if other functions were
added to re-target jump addresses and update the co_lnotab mapping.
That would yield slightly faster and cleaner bytecode at the
expense of optimizer simplicity and of keeping it decoupled
from the line-numbering structure.
This commit is contained in:
Raymond Hettinger 2003-04-22 06:49:11 +00:00
parent 0c83348d5c
commit 060641d511
5 changed files with 97 additions and 9 deletions

View file

@ -873,6 +873,9 @@ eval_frame(PyFrameObject *f)
/* case STOP_CODE: this is an error! */
case NOP:
goto fast_next_opcode;
case LOAD_FAST:
x = GETLOCAL(oparg);
if (x != NULL) {