From f4cf76dd5eabd8af5d2a866da1f75fa745aa6f29 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Thu, 24 Apr 2003 05:45:23 +0000 Subject: Revert the previous enhancement to the bytecode optimizer. The additional code complexity and new NOP opcode were not worth it. --- Python/compile.c | 92 ++++++-------------------------------------------------- 1 file changed, 9 insertions(+), 83 deletions(-) (limited to 'Python/compile.c') diff --git a/Python/compile.c b/Python/compile.c index 4afd0eb725..57f0edb8f9 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -328,43 +328,6 @@ intern_strings(PyObject *tuple) #define ABSOLUTE_JUMP(op) (op==JUMP_ABSOLUTE || op==CONTINUE_LOOP) #define GETJUMPTGT(arr, i) (GETARG(arr,i) + (ABSOLUTE_JUMP(arr[i]) ? 0 : i+3)) #define SETARG(arr, i, val) arr[i+2] = val>>8; arr[i+1] = val & 255 -#define CODESIZE(op) (HAS_ARG(op) ? 3 : 1) -#define ISBASICBLOCK(blocks, start, bytes) (blocks[start]==blocks[start+bytes-1]) - -static unsigned int * -markblocks(unsigned char *code, int len) -{ - unsigned int *blocks = PyMem_Malloc(len*sizeof(int)); - int i,j, opcode, oldblock, newblock, blockcnt = 0; - - if (blocks == NULL) - return NULL; - memset(blocks, 0, len*sizeof(int)); - for (i=0 ; i a is not b - not a in b --> a not in b - not a is not b --> a is b - not a not in b --> a in b */ - case COMPARE_OP: - j = GETARG(codestr, i); - if (codestr[i+3] != UNARY_NOT || j < 6 || \ - j > 9 || !ISBASICBLOCK(blocks,i,4)) - continue; - SETARG(codestr, i, (j^1)); - codestr[i+3] = NOP; - break; - /* Replace jumps to unconditional jumps */ case FOR_ITER: case JUMP_FORWARD: @@ -475,7 +402,7 @@ optimize_code(PyObject *code, PyObject* consts) case SETUP_EXCEPT: case SETUP_FINALLY: tgt = GETJUMPTGT(codestr, i); - if (!UNCONDITIONAL_JUMP(codestr[tgt])) + if (!UNCONDITIONAL_JUMP(codestr[tgt])) continue; tgttgt = GETJUMPTGT(codestr, tgt); if (opcode == JUMP_FORWARD) /* JMP_ABS can go backwards */ @@ -495,7 +422,6 @@ optimize_code(PyObject *code, PyObject* consts) } code = PyString_FromStringAndSize(codestr, codelen); PyMem_Free(codestr); - PyMem_Free(blocks); return code; exitUnchanged: -- cgit v1.2.1