LEFT | RIGHT |
1 /* Peephole optimizations for bytecode compiler. */ | 1 /* Peephole optimizations for bytecode compiler. */ |
2 | 2 |
3 #include "Python.h" | 3 #include "Python.h" |
4 | 4 |
5 #include "Python-ast.h" | 5 #include "Python-ast.h" |
6 #include "node.h" | 6 #include "node.h" |
7 #include "pyarena.h" | 7 #include "pyarena.h" |
8 #include "ast.h" | 8 #include "ast.h" |
9 #include "code.h" | 9 #include "code.h" |
10 #include "compile.h" | 10 #include "compile.h" |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 cumlc = lastlc + 1; | 401 cumlc = lastlc + 1; |
402 break; | 402 break; |
403 | 403 |
404 /* Skip over LOAD_CONST trueconst | 404 /* Skip over LOAD_CONST trueconst |
405 POP_JUMP_IF_FALSE xx. This improves | 405 POP_JUMP_IF_FALSE xx. This improves |
406 "while 1" performance. */ | 406 "while 1" performance. */ |
407 case LOAD_CONST: | 407 case LOAD_CONST: |
408 cumlc = lastlc + 1; | 408 cumlc = lastlc + 1; |
409 j = GETARG(codestr, i); | 409 j = GETARG(codestr, i); |
410 if (codestr[i+3] != POP_JUMP_IF_FALSE || | 410 if (codestr[i+3] != POP_JUMP_IF_FALSE || |
411 » » » » !ISBASICBLOCK(blocks,i,7) || | 411 » » » » !ISBASICBLOCK(blocks,i,6) || |
412 !PyObject_IsTrue(PyList_GET_ITEM(consts, j))
) | 412 !PyObject_IsTrue(PyList_GET_ITEM(consts, j))
) |
413 continue; | 413 continue; |
414 memset(codestr+i, NOP, 6); | 414 memset(codestr+i, NOP, 6); |
415 cumlc = 0; | 415 cumlc = 0; |
416 break; | 416 break; |
417 | 417 |
418 /* Try to fold tuples of constants (includes a c
ase for lists | 418 /* Try to fold tuples of constants (includes a c
ase for lists |
419 which are only used for "in" and "not in" tes
ts). | 419 which are only used for "in" and "not in" tes
ts). |
420 Skip over BUILD_SEQN 1 UNPACK_SEQN 1. | 420 Skip over BUILD_SEQN 1 UNPACK_SEQN 1. |
421 Replace BUILD_SEQN 2 UNPACK_SEQN 2 with ROT2. | 421 Replace BUILD_SEQN 2 UNPACK_SEQN 2 with ROT2. |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 exitUnchanged: | 647 exitUnchanged: |
648 if (blocks != NULL) | 648 if (blocks != NULL) |
649 PyMem_Free(blocks); | 649 PyMem_Free(blocks); |
650 if (addrmap != NULL) | 650 if (addrmap != NULL) |
651 PyMem_Free(addrmap); | 651 PyMem_Free(addrmap); |
652 if (codestr != NULL) | 652 if (codestr != NULL) |
653 PyMem_Free(codestr); | 653 PyMem_Free(codestr); |
654 Py_INCREF(code); | 654 Py_INCREF(code); |
655 return code; | 655 return code; |
656 } | 656 } |
LEFT | RIGHT |