mirror of https://github.com/python/cpython.git
teach the peepholer about SETUP_WITH
This commit is contained in:
parent
4ee8282229
commit
aafa18aa05
|
@ -259,6 +259,7 @@ markblocks(unsigned char *code, Py_ssize_t len)
|
||||||
case SETUP_LOOP:
|
case SETUP_LOOP:
|
||||||
case SETUP_EXCEPT:
|
case SETUP_EXCEPT:
|
||||||
case SETUP_FINALLY:
|
case SETUP_FINALLY:
|
||||||
|
case SETUP_WITH:
|
||||||
j = GETJUMPTGT(code, i);
|
j = GETJUMPTGT(code, i);
|
||||||
blocks[j] = 1;
|
blocks[j] = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -550,6 +551,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
|
||||||
case SETUP_LOOP:
|
case SETUP_LOOP:
|
||||||
case SETUP_EXCEPT:
|
case SETUP_EXCEPT:
|
||||||
case SETUP_FINALLY:
|
case SETUP_FINALLY:
|
||||||
|
case SETUP_WITH:
|
||||||
tgt = GETJUMPTGT(codestr, i);
|
tgt = GETJUMPTGT(codestr, i);
|
||||||
/* Replace JUMP_* to a RETURN into just a RETURN */
|
/* Replace JUMP_* to a RETURN into just a RETURN */
|
||||||
if (UNCONDITIONAL_JUMP(opcode) &&
|
if (UNCONDITIONAL_JUMP(opcode) &&
|
||||||
|
@ -628,6 +630,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
|
||||||
case SETUP_LOOP:
|
case SETUP_LOOP:
|
||||||
case SETUP_EXCEPT:
|
case SETUP_EXCEPT:
|
||||||
case SETUP_FINALLY:
|
case SETUP_FINALLY:
|
||||||
|
case SETUP_WITH:
|
||||||
j = addrmap[GETARG(codestr, i) + i + 3] - addrmap[i] - 3;
|
j = addrmap[GETARG(codestr, i) + i + 3] - addrmap[i] - 3;
|
||||||
SETARG(codestr, i, j);
|
SETARG(codestr, i, j);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue