diff -r 2f563908ebc5 -r be51373d99cf .gitignore --- a/.gitignore Thu Apr 26 17:05:31 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -*.cover -*.o -*.orig -*.pyc -*.pyd -*.pyo -*.rej -*~ -Doc/build/ -Doc/tools/docutils/ -Doc/tools/jinja2/ -Doc/tools/pygments/ -Doc/tools/sphinx/ -Lib/lib2to3/*.pickle -Lib/_sysconfigdata.py -Makefile -Makefile.pre -Misc/python.pc -Modules/Setup -Modules/Setup.config -Modules/Setup.local -Modules/config.c -Modules/ld_so_aix -Modules/_testembed -PCbuild/*.bsc -PCbuild/*.dll -PCbuild/*.exe -PCbuild/*.exp -PCbuild/*.lib -PCbuild/*.ncb -PCbuild/*.o -PCbuild/*.pdb -PCbuild/Win32-temp-* -Parser/pgen -__pycache__ -autom4te.cache -build/ -config.log -config.status -libpython*.a -libpython*.so* -pybuilddir.txt -pyconfig.h -python -python-gdb.py -tags -.coverage -coverage/ -htmlcov/ diff -r 2f563908ebc5 -r be51373d99cf .hgignore --- a/.hgignore Thu Apr 26 17:05:31 2012 +0200 +++ b/.hgignore Thu Apr 26 11:08:47 2012 -0700 @@ -73,3 +73,4 @@ .coverage coverage/ htmlcov/ +Python/opt/gen/ diff -r 2f563908ebc5 -r be51373d99cf Include/Python.h --- a/Include/Python.h Thu Apr 26 17:05:31 2012 +0200 +++ b/Include/Python.h Thu Apr 26 11:08:47 2012 -0700 @@ -8,6 +8,8 @@ #include "pyconfig.h" #include "pymacconfig.h" +#include "Python/opt/config.h" + #include #ifndef UCHAR_MAX diff -r 2f563908ebc5 -r be51373d99cf Include/code.h --- a/Include/code.h Thu Apr 26 17:05:31 2012 +0200 +++ b/Include/code.h Thu Apr 26 11:08:47 2012 -0700 @@ -30,15 +30,46 @@ Objects/lnotab_notes.txt for details. */ void *co_zombieframe; /* for optimization only (see frameobject.c) */ PyObject *co_weakreflist; /* to support weakrefs to code objects */ +#ifdef USE_OPT_SBR + unsigned int co_call_count; +#endif /* USE_OPT_SBR */ } PyCodeObject; + + +#ifdef USE_OPT_SBR + +#define PyCode_CallCount(OP) (OP->co_call_count) +#define PyCode_IncCallCount(OP) (++OP->co_call_count) +#define PyCode_PromoteThreshold(OP) (PyCode_CallCount(OP) = OPT_PROFILE_NO_OF_CALLS() + 1) +#define PyCode_HasReachedThreshold(OP) (PyCode_CallCount(OP) >= OPT_PROFILE_NO_OF_CALLS()) + +#define PyCode_IsNewInstrFormatFlagSet(OP) (OP->co_flags & CO_OPT_INSTRS) +#define PyCode_IsIncaFlagSet(OP) (OP->co_flags & CO_OPT_INCA) +#define PyCode_IsRcqFlagSet(OP) (OP->co_flags & CO_OPT_RCQ) + +#define PyCode_SetNewInstrFormatFlag(OP) (OP->co_flags |= CO_OPT_INSTRS) +#define PyCode_SetIncaFlag(OP) (OP->co_flags |= CO_OPT_INCA) +#define PyCode_SetRcqFlag(OP) (OP->co_flags |= CO_OPT_RCQ) + +#define PyCode_ClearNewInstrFormatFlag(OP) (OP->co_flags &= ~CO_OPT_INSTRS) +#define PyCode_ClearIncaFlag(OP) (OP->co_flags &= ~CO_OPT_INCA) +#define PyCode_ClearRcqFlag(OP) (OP->co_flags &= ~CO_OPT_RCQ) + +#define PyCode_GetNoOfLocals(OP) OP->co_nlocals +#define PyCode_GetConsts(OP) OP->co_consts + +#endif /* USE_OPT_SBR */ + + + /* Masks for co_flags above */ -#define CO_OPTIMIZED 0x0001 -#define CO_NEWLOCALS 0x0002 -#define CO_VARARGS 0x0004 -#define CO_VARKEYWORDS 0x0008 -#define CO_NESTED 0x0010 -#define CO_GENERATOR 0x0020 +#define CO_OPTIMIZED 0x0001 +#define CO_NEWLOCALS 0x0002 +#define CO_VARARGS 0x0004 +#define CO_VARKEYWORDS 0x0008 +#define CO_NESTED 0x0010 +#define CO_GENERATOR 0x0020 /* The CO_NOFREE flag is set if there are no free or cell variables. This information is redundant, but it allows a single flag test to determine whether there is any extra work to be done when the diff -r 2f563908ebc5 -r be51373d99cf Include/frameobject.h --- a/Include/frameobject.h Thu Apr 26 17:05:31 2012 +0200 +++ b/Include/frameobject.h Thu Apr 26 11:08:47 2012 -0700 @@ -51,6 +51,9 @@ } PyFrameObject; + + + /* Standard object interface */ PyAPI_DATA(PyTypeObject) PyFrame_Type; diff -r 2f563908ebc5 -r be51373d99cf Include/opcode.h --- a/Include/opcode.h Thu Apr 26 17:05:31 2012 +0200 +++ b/Include/opcode.h Thu Apr 26 11:08:47 2012 -0700 @@ -4,141 +4,148 @@ extern "C" { #endif +/* 20110831/1600/sbr: + replace the static assignments of instruction opcodes with the generated + opcode assignments from cgen... + */ +#include "Python/opt/gen/opcode.h.gen" /* Instruction opcodes for compiled code */ -#define POP_TOP 1 -#define ROT_TWO 2 -#define ROT_THREE 3 -#define DUP_TOP 4 -#define DUP_TOP_TWO 5 -#define NOP 9 +/* #define POP_TOP 1 */ +/* #define ROT_TWO 2 */ +/* #define ROT_THREE 3 */ +/* #define DUP_TOP 4 */ +/* #define DUP_TOP_TWO 5 */ +/* #define NOP 9 */ -#define UNARY_POSITIVE 10 -#define UNARY_NEGATIVE 11 -#define UNARY_NOT 12 +/* #define UNARY_POSITIVE 10 */ +/* #define UNARY_NEGATIVE 11 */ +/* #define UNARY_NOT 12 */ -#define UNARY_INVERT 15 +/* #define UNARY_INVERT 15 */ -#define BINARY_POWER 19 +/* #define BINARY_POWER 19 */ -#define BINARY_MULTIPLY 20 +/* #define BINARY_MULTIPLY 20 */ -#define BINARY_MODULO 22 -#define BINARY_ADD 23 -#define BINARY_SUBTRACT 24 -#define BINARY_SUBSCR 25 -#define BINARY_FLOOR_DIVIDE 26 -#define BINARY_TRUE_DIVIDE 27 -#define INPLACE_FLOOR_DIVIDE 28 -#define INPLACE_TRUE_DIVIDE 29 +/* #define BINARY_MODULO 22 */ +/* #define BINARY_ADD 23 */ +/* #define BINARY_SUBTRACT 24 */ +/* #define BINARY_SUBSCR 25 */ +/* #define BINARY_FLOOR_DIVIDE 26 */ +/* #define BINARY_TRUE_DIVIDE 27 */ +/* #define INPLACE_FLOOR_DIVIDE 28 */ +/* #define INPLACE_TRUE_DIVIDE 29 */ -#define STORE_MAP 54 -#define INPLACE_ADD 55 -#define INPLACE_SUBTRACT 56 -#define INPLACE_MULTIPLY 57 +/* #define STORE_MAP 54 */ +/* #define INPLACE_ADD 55 */ +/* #define INPLACE_SUBTRACT 56 */ +/* #define INPLACE_MULTIPLY 57 */ -#define INPLACE_MODULO 59 -#define STORE_SUBSCR 60 -#define DELETE_SUBSCR 61 +/* #define INPLACE_MODULO 59 */ +/* #define STORE_SUBSCR 60 */ +/* #define DELETE_SUBSCR 61 */ -#define BINARY_LSHIFT 62 -#define BINARY_RSHIFT 63 -#define BINARY_AND 64 -#define BINARY_XOR 65 -#define BINARY_OR 66 -#define INPLACE_POWER 67 -#define GET_ITER 68 -#define STORE_LOCALS 69 -#define PRINT_EXPR 70 -#define LOAD_BUILD_CLASS 71 -#define YIELD_FROM 72 +/* #define BINARY_LSHIFT 62 */ +/* #define BINARY_RSHIFT 63 */ +/* #define BINARY_AND 64 */ +/* #define BINARY_XOR 65 */ +/* #define BINARY_OR 66 */ +/* #define INPLACE_POWER 67 */ +/* #define GET_ITER 68 */ +/* #define STORE_LOCALS 69 */ +/* #define PRINT_EXPR 70 */ +/* #define LOAD_BUILD_CLASS 71 */ -#define INPLACE_LSHIFT 75 -#define INPLACE_RSHIFT 76 -#define INPLACE_AND 77 -#define INPLACE_XOR 78 -#define INPLACE_OR 79 -#define BREAK_LOOP 80 -#define WITH_CLEANUP 81 +/* #define INPLACE_LSHIFT 75 */ +/* #define INPLACE_RSHIFT 76 */ +/* #define INPLACE_AND 77 */ +/* #define INPLACE_XOR 78 */ +/* #define INPLACE_OR 79 */ +/* #define BREAK_LOOP 80 */ +/* #define WITH_CLEANUP 81 */ -#define RETURN_VALUE 83 -#define IMPORT_STAR 84 +/* #define RETURN_VALUE 83 */ +/* #define IMPORT_STAR 84 */ -#define YIELD_VALUE 86 -#define POP_BLOCK 87 -#define END_FINALLY 88 -#define POP_EXCEPT 89 +/* #define YIELD_VALUE 86 */ +/* #define POP_BLOCK 87 */ +/* #define END_FINALLY 88 */ +/* #define POP_EXCEPT 89 */ -#define HAVE_ARGUMENT 90 /* Opcodes from here have an argument: */ +/* #define HAVE_ARGUMENT 90 /\* Opcodes from here have an argument: *\/ */ -#define STORE_NAME 90 /* Index in name list */ -#define DELETE_NAME 91 /* "" */ -#define UNPACK_SEQUENCE 92 /* Number of sequence items */ -#define FOR_ITER 93 -#define UNPACK_EX 94 /* Num items before variable part + - (Num items after variable part << 8) */ +/* #define STORE_NAME 90 /\* Index in name list *\/ */ +/* #define DELETE_NAME 91 /\* "" *\/ */ +/* #define UNPACK_SEQUENCE 92 /\* Number of sequence items *\/ */ +/* #define FOR_ITER 93 */ +/* #define UNPACK_EX 94 /\* Num items before variable part + */ +/* (Num items after variable part << 8) *\/ */ -#define STORE_ATTR 95 /* Index in name list */ -#define DELETE_ATTR 96 /* "" */ -#define STORE_GLOBAL 97 /* "" */ -#define DELETE_GLOBAL 98 /* "" */ +/* #define STORE_ATTR 95 /\* Index in name list *\/ */ +/* #define DELETE_ATTR 96 /\* "" *\/ */ +/* #define STORE_GLOBAL 97 /\* "" *\/ */ +/* #define DELETE_GLOBAL 98 /\* "" *\/ */ -#define LOAD_CONST 100 /* Index in const list */ -#define LOAD_NAME 101 /* Index in name list */ -#define BUILD_TUPLE 102 /* Number of tuple items */ -#define BUILD_LIST 103 /* Number of list items */ -#define BUILD_SET 104 /* Number of set items */ -#define BUILD_MAP 105 /* Always zero for now */ -#define LOAD_ATTR 106 /* Index in name list */ -#define COMPARE_OP 107 /* Comparison operator */ -#define IMPORT_NAME 108 /* Index in name list */ -#define IMPORT_FROM 109 /* Index in name list */ +/* #define LOAD_CONST 100 /\* Index in const list *\/ */ +/* #define LOAD_NAME 101 /\* Index in name list *\/ */ +/* #define BUILD_TUPLE 102 /\* Number of tuple items *\/ */ +/* #define BUILD_LIST 103 /\* Number of list items *\/ */ +/* #define BUILD_SET 104 /\* Number of set items *\/ */ +/* #define BUILD_MAP 105 /\* Always zero for now *\/ */ +/* #define LOAD_ATTR 106 /\* Index in name list *\/ */ +/* #define COMPARE_OP 107 /\* Comparison operator *\/ */ +/* #define IMPORT_NAME 108 /\* Index in name list *\/ */ +/* #define IMPORT_FROM 109 /\* Index in name list *\/ */ -#define JUMP_FORWARD 110 /* Number of bytes to skip */ -#define JUMP_IF_FALSE_OR_POP 111 /* Target byte offset from beginning of code */ -#define JUMP_IF_TRUE_OR_POP 112 /* "" */ -#define JUMP_ABSOLUTE 113 /* "" */ -#define POP_JUMP_IF_FALSE 114 /* "" */ -#define POP_JUMP_IF_TRUE 115 /* "" */ +/* #define JUMP_FORWARD 110 /\* Number of bytes to skip *\/ */ +/* #define JUMP_IF_FALSE_OR_POP 111 /\* Target byte offset from beginning of code *\/ */ +/* #define JUMP_IF_TRUE_OR_POP 112 /\* "" *\/ */ +/* #define JUMP_ABSOLUTE 113 /\* "" *\/ */ +/* #define POP_JUMP_IF_FALSE 114 /\* "" *\/ */ +/* #define POP_JUMP_IF_TRUE 115 /\* "" *\/ */ -#define LOAD_GLOBAL 116 /* Index in name list */ +/* #define LOAD_GLOBAL 116 /\* Index in name list *\/ */ -#define CONTINUE_LOOP 119 /* Start of loop (absolute) */ -#define SETUP_LOOP 120 /* Target address (relative) */ -#define SETUP_EXCEPT 121 /* "" */ -#define SETUP_FINALLY 122 /* "" */ +/* #define CONTINUE_LOOP 119 /\* Start of loop (absolute) *\/ */ +/* #define SETUP_LOOP 120 /\* Target address (relative) *\/ */ +/* #define SETUP_EXCEPT 121 /\* "" *\/ */ +/* #define SETUP_FINALLY 122 /\* "" *\/ */ -#define LOAD_FAST 124 /* Local variable number */ -#define STORE_FAST 125 /* Local variable number */ -#define DELETE_FAST 126 /* Local variable number */ +/* #define LOAD_FAST 124 /\* Local variable number *\/ */ +/* #define STORE_FAST 125 /\* Local variable number *\/ */ +/* #define DELETE_FAST 126 /\* Local variable number *\/ */ -#define RAISE_VARARGS 130 /* Number of raise arguments (1, 2 or 3) */ -/* CALL_FUNCTION_XXX opcodes defined below depend on this definition */ -#define CALL_FUNCTION 131 /* #args + (#kwargs<<8) */ -#define MAKE_FUNCTION 132 /* #defaults + #kwdefaults<<8 + #annotations<<16 */ -#define BUILD_SLICE 133 /* Number of items */ +/* #define RAISE_VARARGS 130 /\* Number of raise arguments (1, 2 or 3) *\/ */ +/* /\* CALL_FUNCTION_XXX opcodes defined below depend on this definition *\/ */ +/* #define CALL_FUNCTION 131 /\* #args + (#kwargs<<8) *\/ */ +/* #define MAKE_FUNCTION 132 /\* #defaults + #kwdefaults<<8 + #annotations<<16 *\/ */ +/* #define BUILD_SLICE 133 /\* Number of items *\/ */ -#define MAKE_CLOSURE 134 /* same as MAKE_FUNCTION */ -#define LOAD_CLOSURE 135 /* Load free variable from closure */ -#define LOAD_DEREF 136 /* Load and dereference from closure cell */ -#define STORE_DEREF 137 /* Store into cell */ -#define DELETE_DEREF 138 /* Delete closure cell */ +/* #define MAKE_CLOSURE 134 /\* same as MAKE_FUNCTION *\/ */ +/* #define LOAD_CLOSURE 135 /\* Load free variable from closure *\/ */ +/* #define LOAD_DEREF 136 /\* Load and dereference from closure cell *\/ */ +/* #define STORE_DEREF 137 /\* Store into cell *\/ */ +/* #define DELETE_DEREF 138 /\* Delete closure cell *\/ */ -/* The next 3 opcodes must be contiguous and satisfy - (CALL_FUNCTION_VAR - CALL_FUNCTION) & 3 == 1 */ -#define CALL_FUNCTION_VAR 140 /* #args + (#kwargs<<8) */ -#define CALL_FUNCTION_KW 141 /* #args + (#kwargs<<8) */ -#define CALL_FUNCTION_VAR_KW 142 /* #args + (#kwargs<<8) */ +/* /\* The next 3 opcodes must be contiguous and satisfy */ +/* (CALL_FUNCTION_VAR - CALL_FUNCTION) & 3 == 1 *\/ */ +/* #define CALL_FUNCTION_VAR 140 /\* #args + (#kwargs<<8) *\/ */ +/* #define CALL_FUNCTION_KW 141 /\* #args + (#kwargs<<8) *\/ */ +/* #define CALL_FUNCTION_VAR_KW 142 /\* #args + (#kwargs<<8) *\/ */ -#define SETUP_WITH 143 +/* #define SETUP_WITH 143 */ -/* Support for opargs more than 16 bits long */ -#define EXTENDED_ARG 144 +/* /\* Support for opargs more than 16 bits long *\/ */ +/* #define EXTENDED_ARG 144 */ -#define LIST_APPEND 145 -#define SET_ADD 146 -#define MAP_ADD 147 +/* #define LIST_APPEND 145 */ +/* #define SET_ADD 146 */ +/* #define MAP_ADD 147 */ + +/* 20111214/1354/sbr: needed, because i have commented out the other opcode assignments... */ +#define HAVE_ARGUMENT 90 /* Opcodes from here have an argument: */ /* EXCEPT_HANDLER is a special, implicit block type which is created when @@ -149,7 +156,7 @@ enum cmp_op {PyCmp_LT=Py_LT, PyCmp_LE=Py_LE, PyCmp_EQ=Py_EQ, PyCmp_NE=Py_NE, PyCmp_GT=Py_GT, PyCmp_GE=Py_GE, - PyCmp_IN, PyCmp_NOT_IN, PyCmp_IS, PyCmp_IS_NOT, PyCmp_EXC_MATCH, PyCmp_BAD}; + PyCmp_IN, PyCmp_NOT_IN, PyCmp_IS, PyCmp_IS_NOT, PyCmp_EXC_MATCH, PyCmp_BAD}; #define HAS_ARG(op) ((op) >= HAVE_ARGUMENT) diff -r 2f563908ebc5 -r be51373d99cf Objects/abstract.c --- a/Objects/abstract.c Thu Apr 26 17:05:31 2012 +0200 +++ b/Objects/abstract.c Thu Apr 26 11:08:47 2012 -0700 @@ -6,6 +6,7 @@ #include "longintrepr.h" +#include "Python/opt/gen/rewrite-inca-fun.h.gen" /* Shorthands to return certain errors */ @@ -118,8 +119,10 @@ return null_error(); m = o->ob_type->tp_as_mapping; - if (m && m->mp_subscript) + if (m && m->mp_subscript) { + PyEval_RewriteInstr(m->mp_subscript); return m->mp_subscript(o, key); + } // if if (o->ob_type->tp_as_sequence) { if (PyIndex_Check(key)) { @@ -147,8 +150,10 @@ return -1; } m = o->ob_type->tp_as_mapping; - if (m && m->mp_ass_subscript) + if (m && m->mp_ass_subscript) { + PyEval_RewriteInstr(m->mp_ass_subscript); return m->mp_ass_subscript(o, key, value); + } // if if (o->ob_type->tp_as_sequence) { if (PyIndex_Check(key)) { @@ -777,20 +782,26 @@ if (slotv) { if (slotw && PyType_IsSubtype(w->ob_type, v->ob_type)) { x = slotw(v, w); - if (x != Py_NotImplemented) + if (x != Py_NotImplemented) { + PyEval_RewriteInstr(slotw); return x; + } // if Py_DECREF(x); /* can't do it */ slotw = NULL; } x = slotv(v, w); - if (x != Py_NotImplemented) + if (x != Py_NotImplemented) { + PyEval_RewriteInstr(slotv); return x; + } // if Py_DECREF(x); /* can't do it */ } if (slotw) { x = slotw(v, w); - if (x != Py_NotImplemented) + if (x != Py_NotImplemented) { + PyEval_RewriteInstr(slotw); return x; + } // if Py_DECREF(x); /* can't do it */ } Py_RETURN_NOTIMPLEMENTED; @@ -853,20 +864,26 @@ if (slotv) { if (slotw && PyType_IsSubtype(w->ob_type, v->ob_type)) { x = slotw(v, w, z); - if (x != Py_NotImplemented) + if (x != Py_NotImplemented) { + PyEval_RewriteInstr(slotw); return x; + } // if Py_DECREF(x); /* can't do it */ slotw = NULL; } x = slotv(v, w, z); - if (x != Py_NotImplemented) + if (x != Py_NotImplemented) { + PyEval_RewriteInstr(slotv); return x; + } // if Py_DECREF(x); /* can't do it */ } if (slotw) { x = slotw(v, w, z); - if (x != Py_NotImplemented) + if (x != Py_NotImplemented) { + PyEval_RewriteInstr(slotw); return x; + } // if Py_DECREF(x); /* can't do it */ } mz = z->ob_type->tp_as_number; @@ -876,8 +893,10 @@ slotz = NULL; if (slotz) { x = slotz(v, w, z); - if (x != Py_NotImplemented) + if (x != Py_NotImplemented) { + PyEval_RewriteInstr(slotz); return x; + } // if Py_DECREF(x); /* can't do it */ } } @@ -922,6 +941,7 @@ PySequenceMethods *m = v->ob_type->tp_as_sequence; Py_DECREF(result); if (m && m->sq_concat) { + PyEval_RewriteInstr(m->sq_concat); return (*m->sq_concat)(v, w); } result = binop_type_error(v, w, "+"); @@ -942,6 +962,7 @@ return type_error("can't multiply sequence by " "non-int of type '%.200s'", n); } + PyEval_RewriteInstr(repeatfunc); return (*repeatfunc)(seq, count); } @@ -1013,6 +1034,7 @@ if (slot) { PyObject *x = (slot)(v, w); if (x != Py_NotImplemented) { + PyEval_RewriteInstr( slot ); return x; } Py_DECREF(x); @@ -1073,8 +1095,10 @@ f = m->sq_inplace_concat; if (f == NULL) f = m->sq_concat; - if (f != NULL) + if (f != NULL) { + PyEval_RewriteInstr(f); return (*f)(v, w); + } // if } result = binop_type_error(v, w, "+="); } @@ -1140,8 +1164,10 @@ if (o == NULL) return null_error(); m = o->ob_type->tp_as_number; - if (m && m->nb_negative) + if (m && m->nb_negative) { + PyEval_RewriteInstr(m->nb_negative); return (*m->nb_negative)(o); + } // if return type_error("bad operand type for unary -: '%.200s'", o); } @@ -1154,8 +1180,10 @@ if (o == NULL) return null_error(); m = o->ob_type->tp_as_number; - if (m && m->nb_positive) + if (m && m->nb_positive) { + PyEval_RewriteInstr(m->nb_positive); return (*m->nb_positive)(o); + } // if return type_error("bad operand type for unary +: '%.200s'", o); } @@ -1168,8 +1196,10 @@ if (o == NULL) return null_error(); m = o->ob_type->tp_as_number; - if (m && m->nb_invert) + if (m && m->nb_invert) { + PyEval_RewriteInstr(m->nb_invert); return (*m->nb_invert)(o); + } // if return type_error("bad operand type for unary ~: '%.200s'", o); } @@ -1182,8 +1212,10 @@ if (o == NULL) return null_error(); m = o->ob_type->tp_as_number; - if (m && m->nb_absolute) + if (m && m->nb_absolute) { + PyEval_RewriteInstr(m->nb_absolute); return m->nb_absolute(o); + } // if return type_error("bad operand type for abs(): '%.200s'", o); } diff -r 2f563908ebc5 -r be51373d99cf Objects/codeobject.c --- a/Objects/codeobject.c Thu Apr 26 17:05:31 2012 +0200 +++ b/Objects/codeobject.c Thu Apr 26 11:08:47 2012 -0700 @@ -147,6 +147,11 @@ co->co_lnotab = lnotab; co->co_zombieframe = NULL; co->co_weakreflist = NULL; + +#ifdef USE_OPT_SBR + co->co_call_count= 0; +#endif /* USE_OPT_SBR */ + return co; } diff -r 2f563908ebc5 -r be51373d99cf Objects/object.c --- a/Objects/object.c Thu Apr 26 17:05:31 2012 +0200 +++ b/Objects/object.c Thu Apr 26 11:08:47 2012 -0700 @@ -4,6 +4,8 @@ #include "Python.h" #include "frameobject.h" +#include "Python/opt/gen/rewrite-inca-fun.h.gen" + #ifdef __cplusplus extern "C" { #endif @@ -555,8 +557,10 @@ } if ((f = v->ob_type->tp_richcompare) != NULL) { res = (*f)(v, w, op); - if (res != Py_NotImplemented) + if (res != Py_NotImplemented) { + PyEval_RewriteInstr(f); return res; + } // if Py_DECREF(res); } if (!checked_reverse_op && (f = w->ob_type->tp_richcompare) != NULL) { diff -r 2f563908ebc5 -r be51373d99cf Python/ceval.c --- a/Python/ceval.c Thu Apr 26 17:05:31 2012 +0200 +++ b/Python/ceval.c Thu Apr 26 11:08:47 2012 -0700 @@ -787,7 +787,24 @@ return PyEval_EvalFrameEx(f, 0); } -PyObject * + + +#include "Python/opt/config.h" + +#ifdef USE_OPT_SBR + +#include "Python/opt/gen/debug-opcodes.h.gen" + +#include "Python/opt/signature-defines.h" + +#include "Python/opt/interpreter-macro-defs.h" + +#endif + +#include "Python/opt/gen/rewrite-inca-fun.h.gen" + + +PyObject* PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) { #ifdef DXPAIRS @@ -804,6 +821,7 @@ register PyObject *w; register PyObject *u; register PyObject *t; + register PyObject **fastlocals, **freevars; PyObject *retval = NULL; /* Return value */ PyThreadState *tstate = PyThreadState_GET(); @@ -884,8 +902,16 @@ #if USE_COMPUTED_GOTOS /* Import the static jump table */ +#ifndef USE_OPT_SBR + #include "opcode_targets.h" +#else +/* 20111209/1621/sbr: use generated file... */ +#include "opt/gen/threaded-code.h.gen" + +#endif + /* This macro is used when several opcodes defer to the same implementation (e.g. SETUP_LOOP, SETUP_FINALLY) */ #define TARGET_WITH_IMPL(op, impl) \ @@ -952,6 +978,14 @@ #define GETITEM(v, i) PyTuple_GetItem((v), (i)) #endif + +#ifdef USE_OPT_SBR + +#include "Python/opt/interpreter-macro-redefinitions.h" + +#endif + + #ifdef WITH_TSC /* Use Pentium timestamp counter to mark certain events: inst0 -- beginning of switch statement for opcode dispatch @@ -1318,8 +1352,12 @@ opcode = NEXTOP(); oparg = 0; /* allows oparg to be stored in a register because it doesn't have to be remembered across a full loop */ + +#ifndef USE_OPT_SBR if (HAS_ARG(opcode)) oparg = NEXTARG(); +#endif + dispatch_opcode: #ifdef DYNAMIC_EXECUTION_PROFILE #ifdef DXPAIRS @@ -1347,12 +1385,24 @@ /* Main switch on opcode */ READ_TIMESTAMP(inst0); +/* 20111213/1128/sbr: of course, we need to change the dispatch here, too, since + it causes the incorrect decoding of instruction derivatives packed into the + instruction set... */ +#ifdef USE_OPT_SBR + goto *opcode_targets[opcode]; +#else switch (opcode) { - +#endif /* BEWARE! It is essential that any operation that fails sets either x to NULL, err to nonzero, or why to anything but WHY_NOT, and that no operation that succeeds does this! */ +#ifdef USE_OPT_SBR + +/* #include "opt/gen/opt-instr-set.impl.gen" */ +#include "opt/gen/instr-impl.h.gen" + +#else TARGET(NOP) FAST_DISPATCH(); @@ -2498,6 +2548,7 @@ TARGET(FOR_ITER) /* before: [iter]; after: [iter, iter()] *or* [] */ v = TOP(); + PyEval_RewriteInstr(v->ob_type->tp_iternext); x = (*v->ob_type->tp_iternext)(v); if (x != NULL) { PUSH(x); @@ -2676,8 +2727,14 @@ #ifdef WITH_TSC x = call_function(&sp, oparg, &intr0, &intr1); #else - x = call_function(&sp, oparg); -#endif + +#ifdef USE_OPT_SBR + x = quickening_call_function(&sp, oparg); +#else + x= call_function(&sp, oparg); +#endif /* USE_OPT_SBR */ +#endif /* WITH_TSC */ + stack_pointer = sp; PUSH(x); if (x != NULL) @@ -2849,23 +2906,36 @@ oparg = oparg<<16 | NEXTARG(); goto dispatch_opcode; +#endif /* USE_OPT_SBR */ + + #if USE_COMPUTED_GOTOS _unknown_opcode: #endif + +#ifndef USE_COMPUTED_GOTOS default: +#endif fprintf(stderr, "XXX lineno: %d, opcode: %d\n", PyFrame_GetLineNumber(f), opcode); PyErr_SetString(PyExc_SystemError, "unknown opcode"); why = WHY_EXCEPTION; +#ifndef USE_OPT_SBR break; +#else + goto on_error; +#endif #ifdef CASE_TOO_BIG } #endif + +#ifndef USE_OPT_SBR } /* switch */ +#endif on_error: @@ -3422,12 +3492,24 @@ f->f_back = NULL; PCALL(PCALL_GENERATOR); + if (kwcount == 0 + && PyTuple_GET_SIZE(co->co_cellvars) == 0 + && PyTuple_GET_SIZE(co->co_freevars) == 1 + && co->co_kwonlyargcount == 0 + ) + { + /* if (argcount == 1 && co->co_argcount == 1) */ + /* PyEval_SetCurInstr(FAST_CALL_GENERATOR_ONE, argcount); */ + /* else if (argcount == 2 && co->co_argcount == 2) */ + /* PyEval_SetCurInstr(FAST_CALL_GENERATOR_TWO, argcount); */ + } // if /* Create a new generator that owns the ready to run frame * and return that as the value. */ return PyGen_New(f); } + retval = PyEval_EvalFrameEx(f,0); fail: /* Jump here from prelude on failure */ @@ -4624,6 +4706,14 @@ return res; } + +#ifdef USE_OPT_SBR +/* this includes necessary copies of unicode_concatenate and call_function */ +#include "Python/opt/aux-impl.h" + +#endif + + #ifdef DYNAMIC_EXECUTION_PROFILE static PyObject * diff -r 2f563908ebc5 -r be51373d99cf Python/opt/aux-impl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Python/opt/aux-impl.h Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,233 @@ + +static inline PyObject * +quickening_call_function(PyObject ***pp_stack, int oparg) +{ + int na = oparg & 0xff; + int nk = (oparg>>8) & 0xff; + int n = na + 2 * nk; + PyObject **pfunc = (*pp_stack) - n - 1; + PyObject *func = *pfunc; + PyObject *x, *w; + + /* Always dispatch PyCFunction first, because these are + presumed to be the most frequent callable object. + */ + if (PyCFunction_Check(func) && nk == 0) { + int flags = PyCFunction_GET_FLAGS(func); + PyThreadState *tstate = PyThreadState_GET(); + + PCALL(PCALL_CFUNCTION); + if (flags & (METH_NOARGS | METH_O)) { + PyCFunction meth = PyCFunction_GET_FUNCTION(func); + PyObject *self = PyCFunction_GET_SELF(func); + if (flags & METH_NOARGS && na == 0) { +#ifdef USE_OPT_INCA + PyEval_SetCurInstr(FAST_C_ZERO, 0); +#endif /* USE_OPT_INCA */ + C_TRACE(x, (*meth)(self,NULL)); + } + else if (flags & METH_O && na == 1) { + PyObject *arg = EXT_POP(*pp_stack); +#ifdef USE_OPT_INCA + PyEval_SetCurInstr(FAST_C_ONE, 1); +#endif /* USE_OPT_INCA */ + C_TRACE(x, (*meth)(self,arg)); + Py_DECREF(arg); + } + else { + err_args(func, flags, na); + x = NULL; + } + } + else { + PyObject *callargs; + +#ifdef USE_OPT_INCA + if (flags & (METH_VARARGS | METH_KEYWORDS)) { + switch (oparg) { + case 0: PyEval_SetCurInstr(FAST_C_VARARGS_ZERO, oparg); break; + case 1: PyEval_SetCurInstr(FAST_C_VARARGS_ONE, oparg); break; + case 2: PyEval_SetCurInstr(FAST_C_VARARGS_TWO, oparg); break; + case 3: PyEval_SetCurInstr(FAST_C_VARARGS_THREE, oparg); break; + } // END switch + } // if +#endif /* USE_OPT_INCA */ + + callargs = load_args(pp_stack, na); + + C_TRACE(x, PyCFunction_Call(func,callargs,NULL)); + + Py_XDECREF(callargs); + } + } + else { + if (PyMethod_Check(func) && PyMethod_GET_SELF(func) != NULL) { + /* optimize access to bound methods */ + PyObject *self = PyMethod_GET_SELF(func); + PCALL(PCALL_METHOD); + PCALL(PCALL_BOUND_METHOD); + Py_INCREF(self); + func = PyMethod_GET_FUNCTION(func); + Py_INCREF(func); + Py_DECREF(*pfunc); + *pfunc = self; + na++; + n++; + + if (PyFunction_Check(func)) { +#ifdef USE_OPT_INCA + PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); + PyObject *argdefs = PyFunction_GET_DEFAULTS(func); + if (argdefs == NULL && co->co_argcount == n && + co->co_kwonlyargcount == 0 && nk==0 && + (unsigned char)co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE) + ) + { + switch (oparg) { + case 0: PyEval_SetCurInstr(FAST_PYMETH_ZERO, oparg); break; + case 1: PyEval_SetCurInstr(FAST_PYMETH_ONE, oparg); break; + case 2: PyEval_SetCurInstr(FAST_PYMETH_TWO, oparg); break; + case 3: PyEval_SetCurInstr(FAST_PYMETH_THREE, oparg); break; + } // END switch + } // if +#endif /* USE_OPT_INCA */ + x = fast_function(func, pp_stack, n, na, nk); + } + else { + x = do_call(func, pp_stack, na, nk); + } // if + } + else { + Py_INCREF(func); + + if (PyFunction_Check(func)) { +#ifdef USE_OPT_INCA + PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); + PyObject *argdefs = PyFunction_GET_DEFAULTS(func); + if (argdefs == NULL && co->co_argcount == n && + co->co_kwonlyargcount == 0 && nk==0 && + (unsigned char)co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE) + ) + { + switch (oparg) { + case 0: PyEval_SetCurInstr(FAST_PYFUN_ZERO, oparg); break; + case 1: PyEval_SetCurInstr(FAST_PYFUN_ONE, oparg); break; + case 2: PyEval_SetCurInstr(FAST_PYFUN_TWO, oparg); break; + } // END switch + } // if +#endif /* USE_OPT_INCA */ + x = fast_function(func, pp_stack, n, na, nk); + } + else { +#ifdef USE_OPT_INCA + if (nk == 0) { + switch (oparg) { + case 0: PyEval_SetCurInstr(FAST_PYFUN_DOCALL_ZERO, oparg); break; + case 1: PyEval_SetCurInstr(FAST_PYFUN_DOCALL_ONE, oparg); break; + case 2: PyEval_SetCurInstr(FAST_PYFUN_DOCALL_TWO, oparg); break; + } // END switch + } +#endif /* USE_OPT_INCA */ + x = do_call(func, pp_stack, na, nk); + } // if + } // if + Py_DECREF(func); + } // if + + /* Clear the stack of the function object. Also removes + the arguments in case they weren't consumed already + (fast_function() and err_args() leave them on the stack). + */ + while ((*pp_stack) > pfunc) { + w = EXT_POP(*pp_stack); + Py_DECREF(w); + PCALL(PCALL_POP); + } + return x; +} + + + + +static inline PyObject * +nonquickening_call_function(PyObject ***pp_stack, int oparg +#ifdef WITH_TSC + , uint64* pintr0, uint64* pintr1 +#endif + ) +{ + int na = oparg & 0xff; + int nk = (oparg>>8) & 0xff; + int n = na + 2 * nk; + PyObject **pfunc = (*pp_stack) - n - 1; + PyObject *func = *pfunc; + PyObject *x, *w; + + /* Always dispatch PyCFunction first, because these are + presumed to be the most frequent callable object. + */ + if (PyCFunction_Check(func) && nk == 0) { + int flags = PyCFunction_GET_FLAGS(func); + PyThreadState *tstate = PyThreadState_GET(); + + PCALL(PCALL_CFUNCTION); + if (flags & (METH_NOARGS | METH_O)) { + PyCFunction meth = PyCFunction_GET_FUNCTION(func); + PyObject *self = PyCFunction_GET_SELF(func); + if (flags & METH_NOARGS && na == 0) { + C_TRACE(x, (*meth)(self,NULL)); + } + else if (flags & METH_O && na == 1) { + PyObject *arg = EXT_POP(*pp_stack); + C_TRACE(x, (*meth)(self,arg)); + Py_DECREF(arg); + } + else { + err_args(func, flags, na); + x = NULL; + } + } + else { + PyObject *callargs; + callargs = load_args(pp_stack, na); + READ_TIMESTAMP(*pintr0); + C_TRACE(x, PyCFunction_Call(func,callargs,NULL)); + READ_TIMESTAMP(*pintr1); + Py_XDECREF(callargs); + } + } else { + if (PyMethod_Check(func) && PyMethod_GET_SELF(func) != NULL) { + /* optimize access to bound methods */ + PyObject *self = PyMethod_GET_SELF(func); + PCALL(PCALL_METHOD); + PCALL(PCALL_BOUND_METHOD); + Py_INCREF(self); + func = PyMethod_GET_FUNCTION(func); + Py_INCREF(func); + Py_DECREF(*pfunc); + *pfunc = self; + na++; + n++; + } else + Py_INCREF(func); + READ_TIMESTAMP(*pintr0); + if (PyFunction_Check(func)) + x = fast_function(func, pp_stack, n, na, nk); + else + x = do_call(func, pp_stack, na, nk); + READ_TIMESTAMP(*pintr1); + Py_DECREF(func); + } + + /* Clear the stack of the function object. Also removes + the arguments in case they weren't consumed already + (fast_function() and err_args() leave them on the stack). + */ + while ((*pp_stack) > pfunc) { + w = EXT_POP(*pp_stack); + Py_DECREF(w); + PCALL(PCALL_POP); + } + return x; +} + diff -r 2f563908ebc5 -r be51373d99cf Python/opt/config.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Python/opt/config.h Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,12 @@ + +#define OPT_PROFILE_NO_OF_CALLS() 500 + +#define USE_OPT() 1 + +#define USE_OPT_INCA() 1 +#define USE_OPT_INCA_QUICKENING_DBG_INFO() 0 + +#define USE_OPT_SBR() 1 +#define USE_OPT_ENABLE_QUICKENING() 1 + + diff -r 2f563908ebc5 -r be51373d99cf Python/opt/gen/debug-opcodes.h.gen --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Python/opt/gen/debug-opcodes.h.gen Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,226 @@ +/* + * This files was auto-generated on 2012-04-25T16:14:56.760061, please don't change! + * Project-Id: contrib-3.3 + * Years: 2010, 2011, 2012 + */ + +static inline char* +debug_opcode(int opcode) { + void* lookup[]= { + (void*)"POP_TOP ", (void*)1, + (void*)"ROT_TWO ", (void*)2, + (void*)"ROT_THREE ", (void*)3, + (void*)"DUP_TOP ", (void*)4, + (void*)"DUP_TOP_TWO ", (void*)5, + (void*)"INCA_ADD_STRINGS ", (void*)6, + (void*)"INCA_UNPACK_TUPLE_TWO ", (void*)7, + (void*)"INCA_BUILD_TUPLE_TWO ", (void*)8, + (void*)"NOP ", (void*)9, + (void*)"UNARY_POSITIVE ", (void*)10, + (void*)"UNARY_NEGATIVE ", (void*)11, + (void*)"UNARY_NOT ", (void*)12, + (void*)"INCA_UNPACK_LIST_TWO ", (void*)13, + (void*)"INCA_BUILD_LIST_TWO ", (void*)14, + (void*)"UNARY_INVERT ", (void*)15, + (void*)"INCA_UNPACK_TUPLE_THREE ", (void*)16, + (void*)"INCA_BUILD_TUPLE_THREE ", (void*)17, + (void*)"INCA_UNPACK_LIST_THREE ", (void*)18, + (void*)"BINARY_POWER ", (void*)19, + (void*)"BINARY_MULTIPLY ", (void*)20, + (void*)"INCA_BUILD_LIST_THREE ", (void*)21, + (void*)"BINARY_MODULO ", (void*)22, + (void*)"BINARY_ADD ", (void*)23, + (void*)"BINARY_SUBTRACT ", (void*)24, + (void*)"BINARY_SUBSCR ", (void*)25, + (void*)"BINARY_FLOOR_DIVIDE ", (void*)26, + (void*)"BINARY_TRUE_DIVIDE ", (void*)27, + (void*)"INPLACE_FLOOR_DIVIDE ", (void*)28, + (void*)"INPLACE_TRUE_DIVIDE ", (void*)29, + (void*)"INCA_BUILD_SLICE_TWO ", (void*)30, + (void*)"INCA_BUILD_SLICE_THREE ", (void*)31, + (void*)"INCA_CMP_FLOAT ", (void*)32, + (void*)"INCA_FLOAT_TRUE_DIVIDE ", (void*)33, + (void*)"INCA_FLOAT_SUBTRACT ", (void*)34, + (void*)"INCA_FLOAT_POWER ", (void*)35, + (void*)"INCA_FLOAT_POSITIVE ", (void*)36, + (void*)"INCA_FLOAT_REMAINDER ", (void*)37, + (void*)"INCA_FLOAT_NEGATIVE ", (void*)38, + (void*)"INCA_FLOAT_ADD ", (void*)39, + (void*)"INCA_FLOAT_MULTIPLY ", (void*)40, + (void*)"INCA_FLOAT_FLOOR_DIVIDE ", (void*)41, + (void*)"INCA_CMP_DICT ", (void*)42, + (void*)"INCA_DICT_SUBSCRIPT ", (void*)43, + (void*)"INCA_DICT_ASS_SUBSCRIPT ", (void*)44, + (void*)"FOR_ITER_ENUM ", (void*)45, + (void*)"INCA_CMP_TUPLE ", (void*)46, + (void*)"INCA_TUPLE_SUBSCRIPT ", (void*)47, + (void*)"INCA_BOOL_XOR ", (void*)48, + (void*)"INCA_BOOL_AND ", (void*)49, + (void*)"INCA_BOOL_OR ", (void*)50, + (void*)"INCA_CMP_COMPLEX ", (void*)51, + (void*)"INCA_COMPLEX_TRUE_DIVIDE ", (void*)52, + (void*)"INCA_COMPLEX_SUBTRACT ", (void*)53, + (void*)"STORE_MAP ", (void*)54, + (void*)"INPLACE_ADD ", (void*)55, + (void*)"INPLACE_SUBTRACT ", (void*)56, + (void*)"INPLACE_MULTIPLY ", (void*)57, + (void*)"INCA_COMPLEX_POWER ", (void*)58, + (void*)"INPLACE_MODULO ", (void*)59, + (void*)"STORE_SUBSCR ", (void*)60, + (void*)"DELETE_SUBSCR ", (void*)61, + (void*)"BINARY_LSHIFT ", (void*)62, + (void*)"BINARY_RSHIFT ", (void*)63, + (void*)"BINARY_AND ", (void*)64, + (void*)"BINARY_XOR ", (void*)65, + (void*)"BINARY_OR ", (void*)66, + (void*)"INPLACE_POWER ", (void*)67, + (void*)"GET_ITER ", (void*)68, + (void*)"STORE_LOCALS ", (void*)69, + (void*)"PRINT_EXPR ", (void*)70, + (void*)"LOAD_BUILD_CLASS ", (void*)71, + (void*)"YIELD_FROM ", (void*)72, + (void*)"INCA_COMPLEX_POSITIVE ", (void*)73, + (void*)"INCA_COMPLEX_REMAINDER ", (void*)74, + (void*)"INPLACE_LSHIFT ", (void*)75, + (void*)"INPLACE_RSHIFT ", (void*)76, + (void*)"INPLACE_AND ", (void*)77, + (void*)"INPLACE_XOR ", (void*)78, + (void*)"INPLACE_OR ", (void*)79, + (void*)"BREAK_LOOP ", (void*)80, + (void*)"WITH_CLEANUP ", (void*)81, + (void*)"INCA_COMPLEX_NEGATIVE ", (void*)82, + (void*)"RETURN_VALUE ", (void*)83, + (void*)"IMPORT_STAR ", (void*)84, + (void*)"INCA_COMPLEX_ADD ", (void*)85, + (void*)"YIELD_VALUE ", (void*)86, + (void*)"POP_BLOCK ", (void*)87, + (void*)"END_FINALLY ", (void*)88, + (void*)"POP_EXCEPT ", (void*)89, + (void*)"STORE_NAME ", (void*)90, + (void*)"DELETE_NAME ", (void*)91, + (void*)"UNPACK_SEQUENCE ", (void*)92, + (void*)"FOR_ITER ", (void*)93, + (void*)"UNPACK_EX ", (void*)94, + (void*)"STORE_ATTR ", (void*)95, + (void*)"DELETE_ATTR ", (void*)96, + (void*)"STORE_GLOBAL ", (void*)97, + (void*)"DELETE_GLOBAL ", (void*)98, + (void*)"INCA_COMPLEX_MULTIPLY ", (void*)99, + (void*)"LOAD_CONST ", (void*)100, + (void*)"LOAD_NAME ", (void*)101, + (void*)"BUILD_TUPLE ", (void*)102, + (void*)"BUILD_LIST ", (void*)103, + (void*)"BUILD_SET ", (void*)104, + (void*)"BUILD_MAP ", (void*)105, + (void*)"LOAD_ATTR ", (void*)106, + (void*)"COMPARE_OP ", (void*)107, + (void*)"IMPORT_NAME ", (void*)108, + (void*)"IMPORT_FROM ", (void*)109, + (void*)"JUMP_FORWARD ", (void*)110, + (void*)"JUMP_IF_FALSE_OR_POP ", (void*)111, + (void*)"JUMP_IF_TRUE_OR_POP ", (void*)112, + (void*)"JUMP_ABSOLUTE ", (void*)113, + (void*)"POP_JUMP_IF_FALSE ", (void*)114, + (void*)"POP_JUMP_IF_TRUE ", (void*)115, + (void*)"LOAD_GLOBAL ", (void*)116, + (void*)"INCA_COMPLEX_FLOOR_DIVIDE ", (void*)117, + (void*)"FOR_ITER_LONGRANGEITER ", (void*)118, + (void*)"CONTINUE_LOOP ", (void*)119, + (void*)"SETUP_LOOP ", (void*)120, + (void*)"SETUP_EXCEPT ", (void*)121, + (void*)"SETUP_FINALLY ", (void*)122, + (void*)"INCA_CMP_LIST ", (void*)123, + (void*)"LOAD_FAST ", (void*)124, + (void*)"STORE_FAST ", (void*)125, + (void*)"DELETE_FAST ", (void*)126, + (void*)"INCA_LIST_SUBSCRIPT ", (void*)127, + (void*)"INCA_LIST_ASS_SUBSCRIPT ", (void*)128, + (void*)"INCA_CMP_BYTEARRAY ", (void*)129, + (void*)"RAISE_VARARGS ", (void*)130, + (void*)"CALL_FUNCTION ", (void*)131, + (void*)"MAKE_FUNCTION ", (void*)132, + (void*)"BUILD_SLICE ", (void*)133, + (void*)"MAKE_CLOSURE ", (void*)134, + (void*)"LOAD_CLOSURE ", (void*)135, + (void*)"LOAD_DEREF ", (void*)136, + (void*)"STORE_DEREF ", (void*)137, + (void*)"DELETE_DEREF ", (void*)138, + (void*)"INCA_BYTEARRAY_SUBSCRIPT ", (void*)139, + (void*)"CALL_FUNCTION_VAR ", (void*)140, + (void*)"CALL_FUNCTION_KW ", (void*)141, + (void*)"CALL_FUNCTION_VAR_KW ", (void*)142, + (void*)"SETUP_WITH ", (void*)143, + (void*)"EXTENDED_ARG ", (void*)144, + (void*)"LIST_APPEND ", (void*)145, + (void*)"SET_ADD ", (void*)146, + (void*)"MAP_ADD ", (void*)147, + (void*)"INCA_BYTEARRAY_ASS_SUBSCRIPT ", (void*)148, + (void*)"FOR_ITER_BYTESITER ", (void*)149, + (void*)"INCA_CMP_UNICODE ", (void*)150, + (void*)"INCA_UNICODE_SUBSCRIPT ", (void*)151, + (void*)"INCA_UNICODE_REMAINDER ", (void*)152, + (void*)"FOR_ITER_RANGEITER ", (void*)153, + (void*)"INCA_CMP_LONG ", (void*)154, + (void*)"INCA_LONG_TRUE_DIVIDE ", (void*)155, + (void*)"INCA_LONG_RSHIFT ", (void*)156, + (void*)"INCA_LONG_XOR ", (void*)157, + (void*)"INCA_LONG_SUBTRACT ", (void*)158, + (void*)"INCA_LONG_AND ", (void*)159, + (void*)"INCA_LONG_POWER ", (void*)160, + (void*)"INCA_LONG_POSITIVE ", (void*)161, + (void*)"INCA_LONG_REMAINDER ", (void*)162, + (void*)"INCA_LONG_NEGATIVE ", (void*)163, + (void*)"INCA_LONG_ADD ", (void*)164, + (void*)"INCA_LONG_MULTIPLY ", (void*)165, + (void*)"INCA_LONG_FLOOR_DIVIDE ", (void*)166, + (void*)"INCA_LONG_OR ", (void*)167, + (void*)"INCA_LONG_LSHIFT ", (void*)168, + (void*)"INCA_CMP_DICTKEYS ", (void*)169, + (void*)"INCA_DICTKEYS_XOR ", (void*)170, + (void*)"INCA_DICTKEYS_SUBTRACT ", (void*)171, + (void*)"INCA_DICTKEYS_AND ", (void*)172, + (void*)"INCA_DICTKEYS_OR ", (void*)173, + (void*)"FOR_ITER_SEQITER ", (void*)174, + (void*)"FOR_ITER_CALLITER ", (void*)175, + (void*)"FOR_ITER_UNICODEITER ", (void*)176, + (void*)"INCA_CMP_SET ", (void*)177, + (void*)"INCA_SET_XOR ", (void*)178, + (void*)"INCA_SET_SUBTRACT ", (void*)179, + (void*)"INCA_SET_AND ", (void*)180, + (void*)"INCA_SET_OR ", (void*)181, + (void*)"FOR_ITER_REVERSED ", (void*)182, + (void*)"FOR_ITER_SETITER ", (void*)183, + (void*)"FOR_ITER_MAP ", (void*)184, + (void*)"FOR_ITER_BYTEARRAYITER ", (void*)185, + (void*)"FOR_ITER_LISTITER ", (void*)186, + (void*)"FOR_ITER_ZIP ", (void*)187, + (void*)"FOR_ITER_TUPLEITER ", (void*)188, + (void*)"FOR_ITER_LISTREVITER ", (void*)189, + (void*)"FAST_C_ZERO ", (void*)190, + (void*)"FAST_C_ONE ", (void*)191, + (void*)"FAST_CALL_GENERATOR_ONE ", (void*)192, + (void*)"FAST_C_VARARGS_ZERO ", (void*)193, + (void*)"FAST_C_VARARGS_ONE ", (void*)194, + (void*)"FAST_C_VARARGS_TWO ", (void*)195, + (void*)"FAST_C_VARARGS_THREE ", (void*)196, + (void*)"FAST_PYFUN_DOCALL_ZERO ", (void*)197, + (void*)"FAST_PYFUN_DOCALL_ONE ", (void*)198, + (void*)"FAST_PYFUN_DOCALL_TWO ", (void*)199, + (void*)"FAST_PYMETH_ZERO ", (void*)200, + (void*)"FAST_PYMETH_ONE ", (void*)201, + (void*)"FAST_PYMETH_TWO ", (void*)202, + (void*)"FAST_PYMETH_THREE ", (void*)203, + (void*)"FAST_PYFUN_ZERO ", (void*)204, + (void*)"FAST_PYFUN_ONE ", (void*)205, + (void*)"FAST_PYFUN_TWO ", (void*)206, + (void*)" < TAIL END > ", (void*)6666 + }; + + int i= 1; + for (i= 1; i < ( 255 * 2); i+= 2) { + int elem= lookup[i]; + if (elem == opcode) + return lookup[i - 1]; + } // for i + return " < UNKNOWN OPCODE > "; +} // END debug_opcode diff -r 2f563908ebc5 -r be51373d99cf Python/opt/gen/inca-instr-decoding.h.gen --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Python/opt/gen/inca-instr-decoding.h.gen Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,118 @@ +/* + * This files was auto-generated on 2012-04-25T16:14:56.787571, please don't change! + * Project-Id: contrib-3.3 + * Years: 2010, 2011, 2012 + */ + + +static inline int +instr_has_argument(unsigned char opcode) { + switch (opcode) { + case INCA_UNPACK_TUPLE_TWO: + case INCA_BUILD_TUPLE_TWO: + case INCA_UNPACK_LIST_TWO: + case INCA_BUILD_LIST_TWO: + case INCA_UNPACK_TUPLE_THREE: + case INCA_BUILD_TUPLE_THREE: + case INCA_UNPACK_LIST_THREE: + case INCA_BUILD_LIST_THREE: + case INCA_BUILD_SLICE_TWO: + case INCA_BUILD_SLICE_THREE: + case INCA_CMP_FLOAT: + case INCA_CMP_DICT: + case FOR_ITER_ENUM: + case INCA_CMP_TUPLE: + case INCA_CMP_COMPLEX: + case STORE_NAME: + case DELETE_NAME: + case UNPACK_SEQUENCE: + case FOR_ITER: + case UNPACK_EX: + case STORE_ATTR: + case DELETE_ATTR: + case STORE_GLOBAL: + case DELETE_GLOBAL: + case LOAD_CONST: + case LOAD_NAME: + case BUILD_TUPLE: + case BUILD_LIST: + case BUILD_SET: + case BUILD_MAP: + case LOAD_ATTR: + case COMPARE_OP: + case IMPORT_NAME: + case IMPORT_FROM: + case JUMP_FORWARD: + case JUMP_IF_FALSE_OR_POP: + case JUMP_IF_TRUE_OR_POP: + case JUMP_ABSOLUTE: + case POP_JUMP_IF_FALSE: + case POP_JUMP_IF_TRUE: + case LOAD_GLOBAL: + case FOR_ITER_LONGRANGEITER: + case CONTINUE_LOOP: + case SETUP_LOOP: + case SETUP_EXCEPT: + case SETUP_FINALLY: + case INCA_CMP_LIST: + case LOAD_FAST: + case STORE_FAST: + case DELETE_FAST: + case INCA_CMP_BYTEARRAY: + case RAISE_VARARGS: + case CALL_FUNCTION: + case MAKE_FUNCTION: + case BUILD_SLICE: + case MAKE_CLOSURE: + case LOAD_CLOSURE: + case LOAD_DEREF: + case STORE_DEREF: + case DELETE_DEREF: + case CALL_FUNCTION_VAR: + case CALL_FUNCTION_KW: + case CALL_FUNCTION_VAR_KW: + case SETUP_WITH: + case EXTENDED_ARG: + case LIST_APPEND: + case SET_ADD: + case MAP_ADD: + case FOR_ITER_BYTESITER: + case INCA_CMP_UNICODE: + case FOR_ITER_RANGEITER: + case INCA_CMP_LONG: + case INCA_CMP_DICTKEYS: + case FOR_ITER_SEQITER: + case FOR_ITER_CALLITER: + case FOR_ITER_UNICODEITER: + case INCA_CMP_SET: + case FOR_ITER_REVERSED: + case FOR_ITER_SETITER: + case FOR_ITER_MAP: + case FOR_ITER_BYTEARRAYITER: + case FOR_ITER_LISTITER: + case FOR_ITER_ZIP: + case FOR_ITER_TUPLEITER: + case FOR_ITER_LISTREVITER: + case FAST_C_ZERO: + case FAST_C_ONE: + case FAST_CALL_GENERATOR_ONE: + case FAST_C_VARARGS_ZERO: + case FAST_C_VARARGS_ONE: + case FAST_C_VARARGS_TWO: + case FAST_C_VARARGS_THREE: + case FAST_PYFUN_DOCALL_ZERO: + case FAST_PYFUN_DOCALL_ONE: + case FAST_PYFUN_DOCALL_TWO: + case FAST_PYMETH_ZERO: + case FAST_PYMETH_ONE: + case FAST_PYMETH_TWO: + case FAST_PYMETH_THREE: + case FAST_PYFUN_ZERO: + case FAST_PYFUN_ONE: + case FAST_PYFUN_TWO: + return 1; + } // switch-case + + return 0; +} // END instr_has_argument + diff -r 2f563908ebc5 -r be51373d99cf Python/opt/gen/instr-impl.h.gen --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Python/opt/gen/instr-impl.h.gen Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,4861 @@ +/* + * This files was auto-generated on 2012-04-25T16:14:56.789112, please don't change! + * Project-Id: contrib-3.3 + * Years: 2010, 2011, 2012 + */ + + + TARGET(POP_TOP) + v = POP(); + Py_DECREF(v); + FAST_DISPATCH(); + + + + TARGET(ROT_TWO) + v = TOP(); + w = SECOND(); + SET_TOP(w); + SET_SECOND(v); + FAST_DISPATCH(); + + + TARGET(ROT_THREE) + v = TOP(); + w = SECOND(); + x = THIRD(); + SET_TOP(w); + SET_SECOND(x); + SET_THIRD(v); + FAST_DISPATCH(); + + + TARGET(DUP_TOP) + v = TOP(); + Py_INCREF(v); + PUSH(v); + FAST_DISPATCH(); + + + TARGET(DUP_TOP_TWO) + x = TOP(); + Py_INCREF(x); + w = SECOND(); + Py_INCREF(w); + STACKADJ(2); + SET_TOP(x); + SET_SECOND(w); + FAST_DISPATCH(); + + + + OPT_TARGET_DECODE_NOARG(INCA_ADD_STRINGS) + w= POP(); // tos element + v= TOP(); // sec element + + if (INLINE_CACHE_MISS(v, w, PyUnicode_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* dispatch to generic implementation */ + goto TARGET_BINARY_ADD_SKIP_DISPATCH; + } // if + + x= unicode_concatenate(v, w, f, next_instr); + + Py_DECREF(w); + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + + OPT_TARGET_DECODE_ARG(INCA_UNPACK_TUPLE_TWO) + v = POP(); + + if (!(PyTuple_CheckExact(v) + && PyTuple_GET_SIZE(v) == 2)) { + /* repair stack pointer... */ + stack_pointer++; + goto TARGET_UNPACK_SEQUENCE_SKIP_DISPATCH; + } // if + + x= ((PyTupleObject *)v)->ob_item; + + Py_INCREF( GET_OBJARR_ELEM(x, 1) ); + PUSH( GET_OBJARR_ELEM(x, 1) ); + Py_INCREF( GET_OBJARR_ELEM(x, 0) ); + PUSH( GET_OBJARR_ELEM(x, 0) ); + + Py_DECREF(v); + DISPATCH(); + + + + OPT_TARGET_DECODE_ARG(INCA_BUILD_TUPLE_TWO) + x= PyTuple_New( 2 ); + if (x != NULL) { + PyTuple_SET_ITEM(x, 1, TOP()); + PyTuple_SET_ITEM(x, 0, SECOND()); + STACKADJ(-1); + SET_TOP(x); + DISPATCH(); + } // if + goto on_error; + + + + + + + TARGET(UNARY_POSITIVE) + v = TOP(); + x = PyNumber_Positive(v); + Py_DECREF(v); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + TARGET(UNARY_NEGATIVE) + v = TOP(); + x = PyNumber_Negative(v); + Py_DECREF(v); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + + TARGET(UNARY_NOT) + v = TOP(); + err = PyObject_IsTrue(v); + Py_DECREF(v); + if (err == 0) { + Py_INCREF(Py_True); + SET_TOP(Py_True); + DISPATCH(); + } + else if (err > 0) { + Py_INCREF(Py_False); + SET_TOP(Py_False); + err = 0; + DISPATCH(); + } + STACKADJ(-1); + goto on_error;; + + + + OPT_TARGET_DECODE_ARG(INCA_UNPACK_LIST_TWO) + v = POP(); + + if (!(PyList_CheckExact(v) + && PyList_GET_SIZE(v) == 2)) { + /* repair stack pointer... */ + stack_pointer++; + goto TARGET_UNPACK_SEQUENCE_SKIP_DISPATCH; + } // if + + x= ((PyListObject *)v)->ob_item; + + Py_INCREF( GET_OBJARR_ELEM(x, 1) ); + PUSH( GET_OBJARR_ELEM(x, 1) ); + Py_INCREF( GET_OBJARR_ELEM(x, 0) ); + PUSH( GET_OBJARR_ELEM(x, 0) ); + + Py_DECREF(v); + DISPATCH(); + + + + OPT_TARGET_DECODE_ARG(INCA_BUILD_LIST_TWO) + x= PyList_New( 2 ); + if (x != NULL) { + PyList_SET_ITEM(x, 1, TOP()); + PyList_SET_ITEM(x, 0, SECOND()); + STACKADJ(-1); + SET_TOP(x); + DISPATCH(); + } // if + goto on_error; + + + + + + TARGET(UNARY_INVERT) + v = TOP(); + x = PyNumber_Invert(v); + Py_DECREF(v); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + OPT_TARGET_DECODE_ARG(INCA_UNPACK_TUPLE_THREE) + v = POP(); + + if (!(PyTuple_CheckExact(v) + && PyTuple_GET_SIZE(v) == 3)) { + /* repair stack pointer... */ + stack_pointer++; + goto TARGET_UNPACK_SEQUENCE_SKIP_DISPATCH; + } // if + + x= ((PyTupleObject *)v)->ob_item; + + Py_INCREF( GET_OBJARR_ELEM(x, 2) ); + PUSH( GET_OBJARR_ELEM(x, 2) ); + Py_INCREF( GET_OBJARR_ELEM(x, 1) ); + PUSH( GET_OBJARR_ELEM(x, 1) ); + Py_INCREF( GET_OBJARR_ELEM(x, 0) ); + PUSH( GET_OBJARR_ELEM(x, 0) ); + + Py_DECREF(v); + DISPATCH(); + + + + OPT_TARGET_DECODE_ARG(INCA_BUILD_TUPLE_THREE) + x= PyTuple_New( 3 ); + if (x != NULL) { + PyTuple_SET_ITEM(x, 2, TOP()); + PyTuple_SET_ITEM(x, 1, SECOND()); + PyTuple_SET_ITEM(x, 0, THIRD()); + STACKADJ(-2); + SET_TOP(x); + DISPATCH(); + } // if + goto on_error; + + + + + + OPT_TARGET_DECODE_ARG(INCA_UNPACK_LIST_THREE) + v = POP(); + + if (!(PyList_CheckExact(v) + && PyList_GET_SIZE(v) == 3)) { + /* repair stack pointer... */ + stack_pointer++; + goto TARGET_UNPACK_SEQUENCE_SKIP_DISPATCH; + } // if + + x= ((PyListObject *)v)->ob_item; + + Py_INCREF( GET_OBJARR_ELEM(x, 2) ); + PUSH( GET_OBJARR_ELEM(x, 2) ); + Py_INCREF( GET_OBJARR_ELEM(x, 1) ); + PUSH( GET_OBJARR_ELEM(x, 1) ); + Py_INCREF( GET_OBJARR_ELEM(x, 0) ); + PUSH( GET_OBJARR_ELEM(x, 0) ); + + Py_DECREF(v); + DISPATCH(); + + + + TARGET(BINARY_POWER) + w = POP(); + v = TOP(); + x = PyNumber_Power(v, w, Py_None); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + TARGET(BINARY_MULTIPLY) + w = POP(); + v = TOP(); + x = PyNumber_Multiply(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + OPT_TARGET_DECODE_ARG(INCA_BUILD_LIST_THREE) + x= PyList_New( 3 ); + if (x != NULL) { + PyList_SET_ITEM(x, 2, TOP()); + PyList_SET_ITEM(x, 1, SECOND()); + PyList_SET_ITEM(x, 0, THIRD()); + STACKADJ(-2); + SET_TOP(x); + DISPATCH(); + } // if + goto on_error; + + + + + + TARGET(BINARY_MODULO) + w = POP(); + v = TOP(); + if (PyUnicode_CheckExact(v)) + x = PyUnicode_Format(v, w); + else + x = PyNumber_Remainder(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + TARGET(BINARY_ADD) + w = POP(); + v = TOP(); + if (PyUnicode_CheckExact(v) && + PyUnicode_CheckExact(w)) { + PyEval_SetCurInstr(INCA_ADD_STRINGS, 0); + x = unicode_concatenate(v, w, f, next_instr); + /* unicode_concatenate consumed the ref to v */ + goto skip_decref_vx; + } + else { + x = PyNumber_Add(v, w); + } + Py_DECREF(v); + skip_decref_vx: + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + TARGET(BINARY_SUBTRACT) + w = POP(); + v = TOP(); + x = PyNumber_Subtract(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + TARGET(BINARY_SUBSCR) + w = POP(); + v = TOP(); + x = PyObject_GetItem(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + TARGET(BINARY_FLOOR_DIVIDE) + w = POP(); + v = TOP(); + x = PyNumber_FloorDivide(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + TARGET(BINARY_TRUE_DIVIDE) + w = POP(); + v = TOP(); + x = PyNumber_TrueDivide(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + TARGET(INPLACE_FLOOR_DIVIDE) + w = POP(); + v = TOP(); + x = PyNumber_InPlaceFloorDivide(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + TARGET(INPLACE_TRUE_DIVIDE) + w = POP(); + v = TOP(); + x = PyNumber_InPlaceTrueDivide(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + OPT_TARGET_DECODE_ARG(INCA_BUILD_SLICE_TWO) + v = TOP(); + u = SECOND(); + STACKADJ(-1); + x = PySlice_New(u, v, NULL); + Py_DECREF(u); + Py_DECREF(v); + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + + + + OPT_TARGET_DECODE_ARG(INCA_BUILD_SLICE_THREE) + w = TOP(); + v = SECOND(); + u = THIRD(); + STACKADJ(-2); + x = PySlice_New(u, v, w); + Py_DECREF(u); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + + + + OPT_TARGET_DECODE_ARG(INCA_CMP_FLOAT) + w= POP(); // tos element + v= TOP(); // sec element + + if (INLINE_CACHE_MISS(v, w, PyFloat_Type)) goto COMPARE_OP_MISS; + x= PyFloat_Type.tp_richcompare(v, w, oparg); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + + + OPT_TARGET_DECODE_NOARG(INCA_FLOAT_TRUE_DIVIDE) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyFloat_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_TRUE_DIVIDE_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyFloat_Type.tp_as_number->nb_true_divide( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_FLOAT_SUBTRACT) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyFloat_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_SUBTRACT_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + + { + double a, b; + + PyFPE_START_PROTECT("sub", (a= 0)); + a= PyFloat_AS_DOUBLE(v); + b= PyFloat_AS_DOUBLE(w); + a -= b; + PyFPE_END_PROTECT(a); + x= PyFloat_FromDouble(a); + } + + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_FLOAT_POWER) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyFloat_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_POWER_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyFloat_Type.tp_as_number->nb_power( v, w, Py_None ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_FLOAT_POSITIVE) + /* template: IncaDerivative */ + + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyFloat_Type)) { + /* repair stack pointer */ + stack_pointer+= 0; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_UNARY_POSITIVE_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyFloat_Type.tp_as_number->nb_positive( v ); + + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_FLOAT_REMAINDER) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyFloat_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_MODULO_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyFloat_Type.tp_as_number->nb_remainder( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_FLOAT_NEGATIVE) + /* template: IncaDerivative */ + + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyFloat_Type)) { + /* repair stack pointer */ + stack_pointer+= 0; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_UNARY_NEGATIVE_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyFloat_Type.tp_as_number->nb_negative( v ); + + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_FLOAT_ADD) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyFloat_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_ADD_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + + { + double a, b; + + PyFPE_START_PROTECT("add", (a= 0)); + a= PyFloat_AS_DOUBLE(v); + b= PyFloat_AS_DOUBLE(w); + a += b; + PyFPE_END_PROTECT(a); + x= PyFloat_FromDouble(a); + } + + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_FLOAT_MULTIPLY) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyFloat_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_MULTIPLY_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + + { + double a, b; + + PyFPE_START_PROTECT("mult", (a= 0)); + a= PyFloat_AS_DOUBLE(v); + b= PyFloat_AS_DOUBLE(w); + a *= b; + PyFPE_END_PROTECT(a); + x= PyFloat_FromDouble(a); + } + + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_FLOAT_FLOOR_DIVIDE) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyFloat_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_FLOOR_DIVIDE_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyFloat_Type.tp_as_number->nb_floor_divide( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + OPT_TARGET_DECODE_ARG(INCA_CMP_DICT) + w= POP(); // tos element + v= TOP(); // sec element + + if (INLINE_CACHE_MISS(v, w, PyDict_Type)) goto COMPARE_OP_MISS; + x= PyDict_Type.tp_richcompare(v, w, oparg); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + + + OPT_TARGET_DECODE_NOARG(INCA_DICT_SUBSCRIPT) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyDict_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_SUBSCR_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyDict_Type.tp_as_mapping->mp_subscript( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + OPT_TARGET_DECODE_NOARG(INCA_DICT_ASS_SUBSCRIPT) + /* template: IncaSubscriptDerivative */ + w= TOP(); + v= SECOND(); + u= THIRD(); + + if (INLINE_CACHE_MISS_UNARY(v, PyDict_Type)) + goto TARGET_STORE_SUBSCR_SKIP_DISPATCH;; + STACKADJ(-3); + + err= PyDict_Type.tp_as_mapping->mp_ass_subscript( v, w, u ); + + Py_DECREF(v); + Py_DECREF(w); + Py_DECREF(u); + + if (err == 0) DISPATCH(); + goto on_error; + + + + OPT_TARGET_DECODE_ARG(FOR_ITER_ENUM) + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyEnum_Type)) + goto TARGET_FOR_ITER_SKIP_DISPATCH; + + x= PyEnum_Type.tp_iternext( v ); + if (x != NULL) { + PUSH(x); + DISPATCH(); + } + goto FOR_ITER_CONTINUE; + + + + + OPT_TARGET_DECODE_ARG(INCA_CMP_TUPLE) + w= POP(); // tos element + v= TOP(); // sec element + + if (INLINE_CACHE_MISS(v, w, PyTuple_Type)) goto COMPARE_OP_MISS; + x= PyTuple_Type.tp_richcompare(v, w, oparg); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + + + OPT_TARGET_DECODE_NOARG(INCA_TUPLE_SUBSCRIPT) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyTuple_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_SUBSCR_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyTuple_Type.tp_as_mapping->mp_subscript( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_BOOL_XOR) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyBool_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_XOR_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyBool_Type.tp_as_number->nb_xor( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_BOOL_AND) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyBool_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_AND_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyBool_Type.tp_as_number->nb_and( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_BOOL_OR) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyBool_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_OR_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyBool_Type.tp_as_number->nb_or( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + OPT_TARGET_DECODE_ARG(INCA_CMP_COMPLEX) + w= POP(); // tos element + v= TOP(); // sec element + + if (INLINE_CACHE_MISS(v, w, PyComplex_Type)) goto COMPARE_OP_MISS; + x= PyComplex_Type.tp_richcompare(v, w, oparg); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + + + OPT_TARGET_DECODE_NOARG(INCA_COMPLEX_TRUE_DIVIDE) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyComplex_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_TRUE_DIVIDE_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyComplex_Type.tp_as_number->nb_true_divide( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_COMPLEX_SUBTRACT) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyComplex_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_SUBTRACT_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + + #define CONVERT(OBJ) ((PyComplexObject*)(OBJ))->cval + { + Py_complex r, a, b; + a= CONVERT(v); + b= CONVERT(w); + PyFPE_START_PROTECT("complex_add", return 0); + r.real = a.real - b.real; + r.imag = a.imag - b.imag; + PyFPE_END_PROTECT(r); + x= PyComplex_FromCComplex(r); + } + #undef CONVERT + + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + TARGET(STORE_MAP) + w = TOP(); /* key */ + u = SECOND(); /* value */ + v = THIRD(); /* dict */ + STACKADJ(-2); + assert (PyDict_CheckExact(v)); + err = PyDict_SetItem(v, w, u); /* v[w] = u */ + Py_DECREF(u); + Py_DECREF(w); + if (err == 0) DISPATCH(); + goto on_error;; + + + TARGET(INPLACE_ADD) + w = POP(); + v = TOP(); + if (PyUnicode_CheckExact(v) && + PyUnicode_CheckExact(w)) { + PyEval_SetCurInstr(INCA_ADD_STRINGS, 0); + x = unicode_concatenate(v, w, f, next_instr); + /* unicode_concatenate consumed the ref to v */ + goto skip_decref_v; + } + else { + x = PyNumber_InPlaceAdd(v, w); + } + Py_DECREF(v); + skip_decref_v: + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + TARGET(INPLACE_SUBTRACT) + w = POP(); + v = TOP(); + x = PyNumber_InPlaceSubtract(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + TARGET(INPLACE_MULTIPLY) + w = POP(); + v = TOP(); + x = PyNumber_InPlaceMultiply(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + OPT_TARGET_DECODE_NOARG(INCA_COMPLEX_POWER) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyComplex_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_POWER_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyComplex_Type.tp_as_number->nb_power( v, w, Py_None ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + TARGET(INPLACE_MODULO) + w = POP(); + v = TOP(); + x = PyNumber_InPlaceRemainder(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + TARGET(STORE_SUBSCR) + w = TOP(); + v = SECOND(); + u = THIRD(); + STACKADJ(-3); + /* v[w] = u */ + err = PyObject_SetItem(v, w, u); + Py_DECREF(u); + Py_DECREF(v); + Py_DECREF(w); + if (err == 0) DISPATCH(); + goto on_error;; + + + + TARGET(DELETE_SUBSCR) + w = TOP(); + v = SECOND(); + STACKADJ(-2); + /* del v[w] */ + err = PyObject_DelItem(v, w); + Py_DECREF(v); + Py_DECREF(w); + if (err == 0) DISPATCH(); + goto on_error;; + + + + TARGET(BINARY_LSHIFT) + w = POP(); + v = TOP(); + x = PyNumber_Lshift(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + TARGET(BINARY_RSHIFT) + w = POP(); + v = TOP(); + x = PyNumber_Rshift(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + TARGET(BINARY_AND) + w = POP(); + v = TOP(); + x = PyNumber_And(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + TARGET(BINARY_XOR) + w = POP(); + v = TOP(); + x = PyNumber_Xor(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + TARGET(BINARY_OR) + w = POP(); + v = TOP(); + x = PyNumber_Or(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + TARGET(INPLACE_POWER) + w = POP(); + v = TOP(); + x = PyNumber_InPlacePower(v, w, Py_None); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + TARGET(GET_ITER) + /* before: [obj]; after [getiter(obj)] */ + v = TOP(); + x = PyObject_GetIter(v); + Py_DECREF(v); + if (x != NULL) { + SET_TOP(x); + PREDICT(FOR_ITER); + DISPATCH(); + } + STACKADJ(-1); + goto on_error;; + + + TARGET(STORE_LOCALS) + x = POP(); + v = f->f_locals; + Py_XDECREF(v); + f->f_locals = x; + DISPATCH(); + + + TARGET(PRINT_EXPR) + v = POP(); + w = PySys_GetObject("displayhook"); + if (w == NULL) { + PyErr_SetString(PyExc_RuntimeError, + "lost sys.displayhook"); + err = -1; + x = NULL; + } + if (err == 0) { + x = PyTuple_Pack(1, v); + if (x == NULL) + err = -1; + } + if (err == 0) { + w = PyEval_CallObject(w, x); + Py_XDECREF(w); + if (w == NULL) + err = -1; + } + Py_DECREF(v); + Py_XDECREF(x); + goto on_error;; + + + TARGET(LOAD_BUILD_CLASS) + { + _Py_IDENTIFIER(__build_class__); + + if (PyDict_CheckExact(f->f_builtins)) { + x = _PyDict_GetItemId(f->f_builtins, &PyId___build_class__); + if (x == NULL) { + PyErr_SetString(PyExc_NameError, + "__build_class__ not found"); + goto on_error;; + } + Py_INCREF(x); + } + else { + PyObject *build_class_str = _PyUnicode_FromId(&PyId___build_class__); + if (build_class_str == NULL) + goto on_error;; + x = PyObject_GetItem(f->f_builtins, build_class_str); + if (x == NULL) { + if (PyErr_ExceptionMatches(PyExc_KeyError)) + PyErr_SetString(PyExc_NameError, + "__build_class__ not found"); + goto on_error;; + } + } + PUSH(x); + goto on_error;; + } + + + TARGET(YIELD_FROM) + u = POP(); + x = TOP(); + /* send u to x */ + if (PyGen_CheckExact(x)) { + retval = _PyGen_Send((PyGenObject *)x, u); + } else { + _Py_IDENTIFIER(send); + if (u == Py_None) + retval = PyIter_Next(x); + else + retval = _PyObject_CallMethodId(x, &PyId_send, "O", u); + } + Py_DECREF(u); + if (!retval) { + PyObject *val; + x = POP(); /* Remove iter from stack */ + Py_DECREF(x); + err = PyGen_FetchStopIterationValue(&val); + if (err < 0) { + x = NULL; + goto on_error; + } + x = val; + PUSH(x); + goto fast_next_opcode; + } + /* x remains on stack, retval is value to be yielded */ + f->f_stacktop = stack_pointer; + why = WHY_YIELD; + /* and repeat... */ + f->f_lasti--; + goto fast_yield; + + + + OPT_TARGET_DECODE_NOARG(INCA_COMPLEX_POSITIVE) + /* template: IncaDerivative */ + + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyComplex_Type)) { + /* repair stack pointer */ + stack_pointer+= 0; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_UNARY_POSITIVE_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyComplex_Type.tp_as_number->nb_positive( v ); + + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_COMPLEX_REMAINDER) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyComplex_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_MODULO_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyComplex_Type.tp_as_number->nb_remainder( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + TARGET(INPLACE_LSHIFT) + w = POP(); + v = TOP(); + x = PyNumber_InPlaceLshift(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + TARGET(INPLACE_RSHIFT) + w = POP(); + v = TOP(); + x = PyNumber_InPlaceRshift(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + TARGET(INPLACE_AND) + w = POP(); + v = TOP(); + x = PyNumber_InPlaceAnd(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + TARGET(INPLACE_XOR) + w = POP(); + v = TOP(); + x = PyNumber_InPlaceXor(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + TARGET(INPLACE_OR) + w = POP(); + v = TOP(); + x = PyNumber_InPlaceOr(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + TARGET(BREAK_LOOP) + why = WHY_BREAK; + goto fast_block_end; + + + + TARGET(WITH_CLEANUP) + { + /* At the top of the stack are 1-3 values indicating + how/why we entered the finally clause: + - TOP = None + - (TOP, SECOND) = (WHY_{RETURN,CONTINUE}), retval + - TOP = WHY_*; no retval below it + - (TOP, SECOND, THIRD) = exc_info() + (FOURTH, FITH, SIXTH) = previous exception for EXCEPT_HANDLER + Below them is EXIT, the context.__exit__ bound method. + In the last case, we must call + EXIT(TOP, SECOND, THIRD) + otherwise we must call + EXIT(None, None, None) + + In the first two cases, we remove EXIT from the + stack, leaving the rest in the same order. In the + third case, we shift the bottom 3 values of the + stack down, and replace the empty spot with NULL. + + In addition, if the stack represents an exception, + *and* the function call returns a 'true' value, we + push WHY_SILENCED onto the stack. END_FINALLY will + then not re-raise the exception. (But non-local + gotos should still be resumed.) + */ + + PyObject *exit_func; + u = TOP(); + if (u == Py_None) { + (void)POP(); + exit_func = TOP(); + SET_TOP(u); + v = w = Py_None; + } + else if (PyLong_Check(u)) { + (void)POP(); + switch(PyLong_AsLong(u)) { + case WHY_RETURN: + case WHY_CONTINUE: + /* Retval in TOP. */ + exit_func = SECOND(); + SET_SECOND(TOP()); + SET_TOP(u); + break;;;;; + default: + exit_func = TOP(); + SET_TOP(u); + break;;;;; + } + u = v = w = Py_None; + } + else { + PyObject *tp, *exc, *tb; + PyTryBlock *block; + v = SECOND(); + w = THIRD(); + tp = FOURTH(); + exc = PEEK(5); + tb = PEEK(6); + exit_func = PEEK(7); + SET_VALUE(7, tb); + SET_VALUE(6, exc); + SET_VALUE(5, tp); + /* UNWIND_EXCEPT_HANDLER will pop this off. */ + SET_FOURTH(NULL); + /* We just shifted the stack down, so we have + to tell the except handler block that the + values are lower than it expects. */ + block = &f->f_blockstack[f->f_iblock - 1]; + assert(block->b_type == EXCEPT_HANDLER); + block->b_level--; + } + + /* XXX Not the fastest way to call it... */ + x = PyObject_CallFunctionObjArgs(exit_func, u, v, w, + NULL); + + Py_DECREF(exit_func); + if (x == NULL) + goto on_error;;;;;; /* Go to error exit */ + + if (u != Py_None) + err = PyObject_IsTrue(x); + else + err = 0; + Py_DECREF(x); + + if (err < 0) + goto on_error; /* Go to error exit */ + else if (err > 0) { + err = 0; + /* There was an exception and a True return */ + PUSH(PyLong_FromLong((long) WHY_SILENCED)); + } + PREDICT(END_FINALLY); + goto on_error;;;;;; + } + + + + OPT_TARGET_DECODE_NOARG(INCA_COMPLEX_NEGATIVE) + /* template: IncaDerivative */ + + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyComplex_Type)) { + /* repair stack pointer */ + stack_pointer+= 0; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_UNARY_NEGATIVE_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyComplex_Type.tp_as_number->nb_negative( v ); + + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + TARGET(RETURN_VALUE) + retval = POP(); + why = WHY_RETURN; + goto fast_block_end; + + + TARGET(IMPORT_STAR) + v = POP(); + PyFrame_FastToLocals(f); + if ((x = f->f_locals) == NULL) { + PyErr_SetString(PyExc_SystemError, + "no locals found during 'import *'"); + goto on_error;; + } + READ_TIMESTAMP(intr0); + err = import_all_from(x, v); + READ_TIMESTAMP(intr1); + PyFrame_LocalsToFast(f, 0); + Py_DECREF(v); + if (err == 0) DISPATCH(); + goto on_error;; + + + + + OPT_TARGET_DECODE_NOARG(INCA_COMPLEX_ADD) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyComplex_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_ADD_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + + #define CONVERT(OBJ) ((PyComplexObject*)(OBJ))->cval + { + Py_complex r, a, b; + a= CONVERT(v); + b= CONVERT(w); + PyFPE_START_PROTECT("complex_add", return 0); + r.real = a.real + b.real; + r.imag = a.imag + b.imag; + PyFPE_END_PROTECT(r); + x= PyComplex_FromCComplex(r); + } + #undef CONVERT + + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + TARGET(YIELD_VALUE) + retval = POP(); + f->f_stacktop = stack_pointer; + why = WHY_YIELD; + goto fast_yield; + + + TARGET(POP_BLOCK) + { + PyTryBlock *b = PyFrame_BlockPop(f); + UNWIND_BLOCK(b); + } + DISPATCH(); + + + PREDICTED(END_FINALLY); + TARGET(END_FINALLY) + v = POP(); + if (PyLong_Check(v)) { + why = (enum why_code) PyLong_AS_LONG(v); + assert(why != WHY_YIELD); + if (why == WHY_RETURN || + why == WHY_CONTINUE) + retval = POP(); + if (why == WHY_SILENCED) { + /* An exception was silenced by 'with', we must + manually unwind the EXCEPT_HANDLER block which was + created when the exception was caught, otherwise + the stack will be in an inconsistent state. */ + PyTryBlock *b = PyFrame_BlockPop(f); + assert(b->b_type == EXCEPT_HANDLER); + UNWIND_EXCEPT_HANDLER(b); + why = WHY_NOT; + } + } + else if (PyExceptionClass_Check(v)) { + w = POP(); + u = POP(); + PyErr_Restore(v, w, u); + why = WHY_RERAISE; + goto on_error;; + } + else if (v != Py_None) { + PyErr_SetString(PyExc_SystemError, + "'finally' pops bad exception"); + why = WHY_EXCEPTION; + } + Py_DECREF(v); + goto on_error;; + + + TARGET(POP_EXCEPT) + { + PyTryBlock *b = PyFrame_BlockPop(f); + if (b->b_type != EXCEPT_HANDLER) { + PyErr_SetString(PyExc_SystemError, + "popped block is not an except handler"); + why = WHY_EXCEPTION; + goto on_error;; + } + UNWIND_EXCEPT_HANDLER(b); + } + DISPATCH(); + + + TARGET(STORE_NAME) + w = GETITEM(names, oparg); + v = POP(); + if ((x = f->f_locals) != NULL) { + if (PyDict_CheckExact(x)) + err = PyDict_SetItem(x, w, v); + else + err = PyObject_SetItem(x, w, v); + Py_DECREF(v); + if (err == 0) DISPATCH(); + goto on_error;; + } + PyErr_Format(PyExc_SystemError, + "no locals found when storing %R", w); + goto on_error;; + + + + TARGET(DELETE_NAME) + w = GETITEM(names, oparg); + if ((x = f->f_locals) != NULL) { + if ((err = PyObject_DelItem(x, w)) != 0) + format_exc_check_arg(PyExc_NameError, + NAME_ERROR_MSG, + w); + goto on_error;; + } + PyErr_Format(PyExc_SystemError, + "no locals when deleting %R", w); + goto on_error;; + + + PREDICTED_WITH_ARG(UNPACK_SEQUENCE); + TARGET(UNPACK_SEQUENCE) + v = POP(); + if (PyTuple_CheckExact(v) && + PyTuple_GET_SIZE(v) == oparg) { + switch (oparg) { + case 2: PyEval_SetCurInstr(INCA_UNPACK_TUPLE_TWO, oparg); break; + case 3: PyEval_SetCurInstr(INCA_UNPACK_TUPLE_THREE, oparg); break; + } // switch + PyObject **items = ((PyTupleObject *)v)->ob_item; + while (oparg--) { + w = items[oparg]; + Py_INCREF(w); + PUSH(w); + } + Py_DECREF(v); + DISPATCH(); + } else if (PyList_CheckExact(v) && + PyList_GET_SIZE(v) == oparg) { + switch (oparg) { + case 2: PyEval_SetCurInstr(INCA_UNPACK_LIST_TWO, oparg); break; + case 3: PyEval_SetCurInstr(INCA_UNPACK_LIST_THREE, oparg); break; + } // switch + PyObject **items = ((PyListObject *)v)->ob_item; + while (oparg--) { + w = items[oparg]; + Py_INCREF(w); + PUSH(w); + } + } else if (unpack_iterable(v, oparg, -1, + stack_pointer + oparg)) { + stack_pointer += oparg; + } else { + /* unpack_iterable() raised an exception */ + why = WHY_EXCEPTION; + } + Py_DECREF(v); + goto on_error;; + + + + PREDICTED_WITH_ARG(FOR_ITER); + TARGET(FOR_ITER) + /* before: [iter]; after: [iter, iter()] *or* [] */ + v = TOP(); + PyEval_RewriteInstr(v->ob_type->tp_iternext); + x = (*v->ob_type->tp_iternext)(v); + if (x != NULL) { + PUSH(x); + DISPATCH(); + } + FOR_ITER_CONTINUE: + if (PyErr_Occurred()) { + if (!PyErr_ExceptionMatches( + PyExc_StopIteration)) + goto on_error;; + PyErr_Clear(); + } + /* iterator ended normally */ + x = v = POP(); + Py_DECREF(v); + JUMPBY(oparg); + DISPATCH(); + + + + TARGET(UNPACK_EX) + { + int totalargs = 1 + (oparg & 0xFF) + (oparg >> 8); + v = POP(); + + if (unpack_iterable(v, oparg & 0xFF, oparg >> 8, + stack_pointer + totalargs)) { + stack_pointer += totalargs; + } else { + why = WHY_EXCEPTION; + } + Py_DECREF(v); + goto on_error;; + } + + + + TARGET(STORE_ATTR) + w = GETITEM(names, oparg); + v = TOP(); + u = SECOND(); + STACKADJ(-2); + err = PyObject_SetAttr(v, w, u); /* v.w = u */ + Py_DECREF(v); + Py_DECREF(u); + if (err == 0) DISPATCH(); + goto on_error;; + + + TARGET(DELETE_ATTR) + w = GETITEM(names, oparg); + v = POP(); + err = PyObject_SetAttr(v, w, (PyObject *)NULL); + /* del v.w */ + Py_DECREF(v); + goto on_error;; + + + + TARGET(STORE_GLOBAL) + w = GETITEM(names, oparg); + v = POP(); + err = PyDict_SetItem(f->f_globals, w, v); + Py_DECREF(v); + if (err == 0) DISPATCH(); + goto on_error;; + + + TARGET(DELETE_GLOBAL) + w = GETITEM(names, oparg); + if ((err = PyDict_DelItem(f->f_globals, w)) != 0) + format_exc_check_arg( + PyExc_NameError, GLOBAL_NAME_ERROR_MSG, w); + goto on_error;; + + + + + OPT_TARGET_DECODE_NOARG(INCA_COMPLEX_MULTIPLY) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyComplex_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_MULTIPLY_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + + #define CONVERT(OBJ) ((PyComplexObject*)(OBJ))->cval + { + Py_complex r, a, b; + a= CONVERT(v); + b= CONVERT(w); + PyFPE_START_PROTECT("complex_mult", return 0); + r.real = a.real*b.real - a.imag*b.imag; + r.imag = a.real*b.imag + a.imag*b.real; + PyFPE_END_PROTECT(r); + x= PyComplex_FromCComplex(r); + } + #undef CONVERT + + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + TARGET(LOAD_CONST) + x = GETITEM(consts, oparg); + Py_INCREF(x); + PUSH(x); + FAST_DISPATCH(); + + + TARGET(LOAD_NAME) + w = GETITEM(names, oparg); + if ((v = f->f_locals) == NULL) { + PyErr_Format(PyExc_SystemError, + "no locals when loading %R", w); + why = WHY_EXCEPTION; + goto on_error;; + } + if (PyDict_CheckExact(v)) { + x = PyDict_GetItem(v, w); + Py_XINCREF(x); + } + else { + x = PyObject_GetItem(v, w); + if (x == NULL && PyErr_Occurred()) { + if (!PyErr_ExceptionMatches( + PyExc_KeyError)) + goto on_error;; + PyErr_Clear(); + } + } + if (x == NULL) { + x = PyDict_GetItem(f->f_globals, w); + if (x == NULL) { + x = PyDict_GetItem(f->f_builtins, w); + if (x == NULL) { + format_exc_check_arg( + PyExc_NameError, + NAME_ERROR_MSG, w); + goto on_error;; + } + } + Py_INCREF(x); + } + PUSH(x); + DISPATCH(); + + + TARGET(BUILD_TUPLE) + switch (oparg) { + case 2: PyEval_SetCurInstr(INCA_BUILD_TUPLE_TWO, 2); break; + case 3: PyEval_SetCurInstr(INCA_BUILD_TUPLE_THREE, 3); break; + } // switch + x = PyTuple_New(oparg); + if (x != NULL) { + for (; --oparg >= 0;) { + w = POP(); + PyTuple_SET_ITEM(x, oparg, w); + } + PUSH(x); + DISPATCH(); + } + goto on_error;; + + + TARGET(BUILD_LIST) + switch (oparg) { + case 2: PyEval_SetCurInstr(INCA_BUILD_LIST_TWO, 2); break; + case 3: PyEval_SetCurInstr(INCA_BUILD_LIST_THREE, 3); break; + } // switch + x = PyList_New(oparg); + if (x != NULL) { + for (; --oparg >= 0;) { + w = POP(); + PyList_SET_ITEM(x, oparg, w); + } + PUSH(x); + DISPATCH(); + } + goto on_error;; + + + + TARGET(BUILD_SET) + x = PySet_New(NULL); + if (x != NULL) { + for (; --oparg >= 0;) { + w = POP(); + if (err == 0) + err = PySet_Add(x, w); + Py_DECREF(w); + } + if (err != 0) { + Py_DECREF(x); + goto on_error;; + } + PUSH(x); + DISPATCH(); + } + goto on_error;; + + + TARGET(BUILD_MAP) + x = _PyDict_NewPresized((Py_ssize_t)oparg); + PUSH(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + TARGET(LOAD_ATTR) + w = GETITEM(names, oparg); + v = TOP(); + x = PyObject_GetAttr(v, w); + Py_DECREF(v); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + TARGET(COMPARE_OP) + w = POP(); + v = TOP(); + COMPARE_OP_MISS: + x = cmp_outcome(oparg, v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x == NULL) goto on_error;; + PREDICT(POP_JUMP_IF_FALSE); + PREDICT(POP_JUMP_IF_TRUE); + DISPATCH(); + + + TARGET(IMPORT_NAME) + w = GETITEM(names, oparg); + x = PyDict_GetItemString(f->f_builtins, "__import__"); + if (x == NULL) { + PyErr_SetString(PyExc_ImportError, + "__import__ not found"); + goto on_error;; + } + Py_INCREF(x); + v = POP(); + u = TOP(); + if (PyLong_AsLong(u) != -1 || PyErr_Occurred()) + w = PyTuple_Pack(5, + w, + f->f_globals, + f->f_locals == NULL ? + Py_None : f->f_locals, + v, + u); + else + w = PyTuple_Pack(4, + w, + f->f_globals, + f->f_locals == NULL ? + Py_None : f->f_locals, + v); + Py_DECREF(v); + Py_DECREF(u); + if (w == NULL) { + u = POP(); + Py_DECREF(x); + x = NULL; + goto on_error;; + } + READ_TIMESTAMP(intr0); + v = x; + x = PyEval_CallObject(v, w); + Py_DECREF(v); + READ_TIMESTAMP(intr1); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + TARGET(IMPORT_FROM) + w = GETITEM(names, oparg); + v = TOP(); + READ_TIMESTAMP(intr0); + x = import_from(v, w); + READ_TIMESTAMP(intr1); + PUSH(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + TARGET(JUMP_FORWARD) + JUMPBY(oparg); + FAST_DISPATCH(); + + + TARGET(JUMP_IF_FALSE_OR_POP) + w = TOP(); + if (w == Py_True) { + STACKADJ(-1); + Py_DECREF(w); + FAST_DISPATCH(); + } + if (w == Py_False) { + JUMPTO(oparg); + FAST_DISPATCH(); + } + err = PyObject_IsTrue(w); + if (err > 0) { + STACKADJ(-1); + Py_DECREF(w); + err = 0; + } + else if (err == 0) + JUMPTO(oparg); + else + goto on_error;; + DISPATCH(); + + + TARGET(JUMP_IF_TRUE_OR_POP) + w = TOP(); + if (w == Py_False) { + STACKADJ(-1); + Py_DECREF(w); + FAST_DISPATCH(); + } + if (w == Py_True) { + JUMPTO(oparg); + FAST_DISPATCH(); + } + err = PyObject_IsTrue(w); + if (err > 0) { + err = 0; + JUMPTO(oparg); + } + else if (err == 0) { + STACKADJ(-1); + Py_DECREF(w); + } + else + goto on_error;; + DISPATCH(); + + + PREDICTED_WITH_ARG(JUMP_ABSOLUTE); + TARGET(JUMP_ABSOLUTE) + JUMPTO(oparg); +#if FAST_LOOPS + /* Enabling this path speeds-up all while and for-loops by bypassing + the per-loop checks for signals. By default, this should be turned-off + because it prevents detection of a control-break in tight loops like + "while 1: pass". Compile with this option turned-on when you need + the speed-up and do not need break checking inside tight loops (ones + that contain only instructions ending with FAST_DISPATCH). + */ + FAST_DISPATCH(); +#else + DISPATCH(); +#endif + + + PREDICTED_WITH_ARG(POP_JUMP_IF_FALSE); + TARGET(POP_JUMP_IF_FALSE) + w = POP(); + if (w == Py_True) { + Py_DECREF(w); + FAST_DISPATCH(); + } + if (w == Py_False) { + Py_DECREF(w); + JUMPTO(oparg); + FAST_DISPATCH(); + } + err = PyObject_IsTrue(w); + Py_DECREF(w); + if (err > 0) + err = 0; + else if (err == 0) + JUMPTO(oparg); + else + goto on_error;; + DISPATCH(); + + + PREDICTED_WITH_ARG(POP_JUMP_IF_TRUE); + TARGET(POP_JUMP_IF_TRUE) + w = POP(); + if (w == Py_False) { + Py_DECREF(w); + FAST_DISPATCH(); + } + if (w == Py_True) { + Py_DECREF(w); + JUMPTO(oparg); + FAST_DISPATCH(); + } + err = PyObject_IsTrue(w); + Py_DECREF(w); + if (err > 0) { + err = 0; + JUMPTO(oparg); + } + else if (err == 0) + ; + else + goto on_error;; + DISPATCH(); + + + TARGET(LOAD_GLOBAL) + w = GETITEM(names, oparg); + if (PyDict_CheckExact(f->f_globals) + && PyDict_CheckExact(f->f_builtins)) { + x = _PyDict_LoadGlobal((PyDictObject *)f->f_globals, + (PyDictObject *)f->f_builtins, + w); + if (x == NULL) { + if (!PyErr_Occurred()) + format_exc_check_arg(PyExc_NameError, + GLOBAL_NAME_ERROR_MSG, w); + goto on_error; + } + } + else { + /* Slow-path if globals or builtins is not a dict */ + x = PyObject_GetItem(f->f_globals, w); + if (x == NULL) { + x = PyObject_GetItem(f->f_builtins, w); + if (x == NULL) { + if (PyErr_ExceptionMatches(PyExc_KeyError)) + format_exc_check_arg( + PyExc_NameError, + GLOBAL_NAME_ERROR_MSG, w); + goto on_error; + } + } + } + Py_INCREF(x); + PUSH(x); + DISPATCH(); + + + + OPT_TARGET_DECODE_NOARG(INCA_COMPLEX_FLOOR_DIVIDE) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyComplex_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_FLOOR_DIVIDE_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyComplex_Type.tp_as_number->nb_floor_divide( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + OPT_TARGET_DECODE_ARG(FOR_ITER_LONGRANGEITER) + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyLongRangeIter_Type)) + goto TARGET_FOR_ITER_SKIP_DISPATCH; + + x= PyLongRangeIter_Type.tp_iternext( v ); + if (x != NULL) { + PUSH(x); + DISPATCH(); + } + goto FOR_ITER_CONTINUE; + + + + + TARGET(CONTINUE_LOOP) + retval = PyLong_FromLong(oparg); + if (!retval) { + x = NULL; + goto on_error;; + } + why = WHY_CONTINUE; + goto fast_block_end; + + + + + TARGET_WITH_IMPL(SETUP_LOOP, _setup_finally) + TARGET_WITH_IMPL(SETUP_EXCEPT, _setup_finally) + TARGET(SETUP_FINALLY) + _setup_finally: + /* NOTE: If you add any new block-setup opcodes that + are not try/except/finally handlers, you may need + to update the PyGen_NeedsFinalizing() function. + */ + + PyFrame_BlockSetup(f, opcode, INSTR_OFFSET() + oparg, + STACK_LEVEL()); + DISPATCH(); + + + OPT_TARGET_DECODE_ARG(INCA_CMP_LIST) + w= POP(); // tos element + v= TOP(); // sec element + + if (INLINE_CACHE_MISS(v, w, PyList_Type)) goto COMPARE_OP_MISS; + x= PyList_Type.tp_richcompare(v, w, oparg); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + + TARGET(LOAD_FAST) + x = GETLOCAL(oparg); + if (x != NULL) { + Py_INCREF(x); + PUSH(x); + FAST_DISPATCH(); + } + format_exc_check_arg(PyExc_UnboundLocalError, + UNBOUNDLOCAL_ERROR_MSG, + PyTuple_GetItem(co->co_varnames, oparg)); + goto on_error;; + + + PREDICTED_WITH_ARG(STORE_FAST); + TARGET(STORE_FAST) + v = POP(); + SETLOCAL(oparg, v); + FAST_DISPATCH(); + + + TARGET(DELETE_FAST) + x = GETLOCAL(oparg); + if (x != NULL) { + SETLOCAL(oparg, NULL); + DISPATCH(); + } + format_exc_check_arg( + PyExc_UnboundLocalError, + UNBOUNDLOCAL_ERROR_MSG, + PyTuple_GetItem(co->co_varnames, oparg) + ); + goto on_error;; + + + + OPT_TARGET_DECODE_NOARG(INCA_LIST_SUBSCRIPT) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyList_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_SUBSCR_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyList_Type.tp_as_mapping->mp_subscript( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + OPT_TARGET_DECODE_NOARG(INCA_LIST_ASS_SUBSCRIPT) + /* template: IncaSubscriptDerivative */ + w= TOP(); + v= SECOND(); + u= THIRD(); + + if (INLINE_CACHE_MISS_UNARY(v, PyDict_Type)) + goto TARGET_STORE_SUBSCR_SKIP_DISPATCH;; + STACKADJ(-3); + + err= PyList_Type.tp_as_mapping->mp_ass_subscript( v, w, u ); + + Py_DECREF(v); + Py_DECREF(w); + Py_DECREF(u); + + if (err == 0) DISPATCH(); + goto on_error; + + + + OPT_TARGET_DECODE_ARG(INCA_CMP_BYTEARRAY) + w= POP(); // tos element + v= TOP(); // sec element + + if (INLINE_CACHE_MISS(v, w, PyByteArray_Type)) goto COMPARE_OP_MISS; + x= PyByteArray_Type.tp_richcompare(v, w, oparg); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + + TARGET(RAISE_VARARGS) + v = w = NULL; + switch (oparg) { + case 2: + v = POP(); /* cause */ + case 1: + w = POP(); /* exc */ + case 0: /* Fallthrough */ + why = do_raise(w, v); + break; + default: + PyErr_SetString(PyExc_SystemError, + "bad RAISE_VARARGS oparg"); + why = WHY_EXCEPTION; + break; + } + goto on_error;; + + + TARGET(CALL_FUNCTION) + { + PyObject **sp; + PCALL(PCALL_ALL); + sp = stack_pointer; + x= quickening_call_function(&sp, oparg); + stack_pointer = sp; + PUSH(x); + if (x != NULL) + DISPATCH(); + goto on_error;; + } + + + TARGET_WITH_IMPL(MAKE_CLOSURE, _make_function) + TARGET(MAKE_FUNCTION) + _make_function: + { + int posdefaults = oparg & 0xff; + int kwdefaults = (oparg>>8) & 0xff; + int num_annotations = (oparg >> 16) & 0x7fff; + + w = POP(); /* qualname */ + v = POP(); /* code object */ + x = PyFunction_NewWithQualName(v, f->f_globals, w); + Py_DECREF(v); + Py_DECREF(w); + + if (x != NULL && opcode == MAKE_CLOSURE) { + v = POP(); + if (PyFunction_SetClosure(x, v) != 0) { + /* Can't happen unless bytecode is corrupt. */ + why = WHY_EXCEPTION; + } + Py_DECREF(v); + } + + if (x != NULL && num_annotations > 0) { + Py_ssize_t name_ix; + u = POP(); /* names of args with annotations */ + v = PyDict_New(); + if (v == NULL) { + Py_DECREF(x); + x = NULL; + goto on_error;; + } + name_ix = PyTuple_Size(u); + assert(num_annotations == name_ix+1); + while (name_ix > 0) { + --name_ix; + t = PyTuple_GET_ITEM(u, name_ix); + w = POP(); + /* XXX(nnorwitz): check for errors */ + PyDict_SetItem(v, t, w); + Py_DECREF(w); + } + + if (PyFunction_SetAnnotations(x, v) != 0) { + /* Can't happen unless + PyFunction_SetAnnotations changes. */ + why = WHY_EXCEPTION; + } + Py_DECREF(v); + Py_DECREF(u); + } + + /* XXX Maybe this should be a separate opcode? */ + if (x != NULL && posdefaults > 0) { + v = PyTuple_New(posdefaults); + if (v == NULL) { + Py_DECREF(x); + x = NULL; + goto on_error;; + } + while (--posdefaults >= 0) { + w = POP(); + PyTuple_SET_ITEM(v, posdefaults, w); + } + if (PyFunction_SetDefaults(x, v) != 0) { + /* Can't happen unless + PyFunction_SetDefaults changes. */ + why = WHY_EXCEPTION; + } + Py_DECREF(v); + } + if (x != NULL && kwdefaults > 0) { + v = PyDict_New(); + if (v == NULL) { + Py_DECREF(x); + x = NULL; + goto on_error;; + } + while (--kwdefaults >= 0) { + w = POP(); /* default value */ + u = POP(); /* kw only arg name */ + /* XXX(nnorwitz): check for errors */ + PyDict_SetItem(v, u, w); + Py_DECREF(w); + Py_DECREF(u); + } + if (PyFunction_SetKwDefaults(x, v) != 0) { + /* Can't happen unless + PyFunction_SetKwDefaults changes. */ + why = WHY_EXCEPTION; + } + Py_DECREF(v); + } + + PUSH(x); + goto on_error;; + } + + + TARGET(BUILD_SLICE) + if (oparg == 3) + w = POP(); + else + w = NULL; + v = POP(); + u = TOP(); + x = PySlice_New(u, v, w); + Py_DECREF(u); + Py_DECREF(v); + Py_XDECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + + TARGET(LOAD_CLOSURE) + x = freevars[oparg]; + Py_INCREF(x); + PUSH(x); + if (x != NULL) DISPATCH(); + goto on_error;; + + + TARGET(LOAD_DEREF) + x = freevars[oparg]; + w = PyCell_Get(x); + if (w != NULL) { + PUSH(w); + DISPATCH(); + } + load_deref_error: + err = -1; + /* Don't stomp existing exception */ + if (PyErr_Occurred()) + goto on_error;; + if (oparg < PyTuple_GET_SIZE(co->co_cellvars)) { + v = PyTuple_GET_ITEM(co->co_cellvars, + oparg); + format_exc_check_arg( + PyExc_UnboundLocalError, + UNBOUNDLOCAL_ERROR_MSG, + v); + } else { + v = PyTuple_GET_ITEM(co->co_freevars, oparg - + PyTuple_GET_SIZE(co->co_cellvars)); + format_exc_check_arg(PyExc_NameError, + UNBOUNDFREE_ERROR_MSG, v); + } + goto on_error;; + + + TARGET(STORE_DEREF) + w = POP(); + x = freevars[oparg]; + PyCell_Set(x, w); + Py_DECREF(w); + DISPATCH(); + + + TARGET(DELETE_DEREF) + x = freevars[oparg]; + if (PyCell_GET(x) != NULL) { + PyCell_Set(x, NULL); + DISPATCH(); + } + err = -1; + format_exc_unbound(co, oparg); + goto on_error;; + + + + OPT_TARGET_DECODE_NOARG(INCA_BYTEARRAY_SUBSCRIPT) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyByteArray_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_SUBSCR_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyByteArray_Type.tp_as_mapping->mp_subscript( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + + TARGET_WITH_IMPL(CALL_FUNCTION_VAR, _call_function_var_kw) + TARGET_WITH_IMPL(CALL_FUNCTION_KW, _call_function_var_kw) + TARGET(CALL_FUNCTION_VAR_KW) + _call_function_var_kw: + { + int na = oparg & 0xff; + int nk = (oparg>>8) & 0xff; + int flags = (opcode - CALL_FUNCTION) & 3; + int n = na + 2 * nk; + PyObject **pfunc, *func, **sp; + PCALL(PCALL_ALL); + if (flags & CALL_FLAG_VAR) + n++; + if (flags & CALL_FLAG_KW) + n++; + pfunc = stack_pointer - n - 1; + func = *pfunc; + + if (PyMethod_Check(func) + && PyMethod_GET_SELF(func) != NULL) { + PyObject *self = PyMethod_GET_SELF(func); + Py_INCREF(self); + func = PyMethod_GET_FUNCTION(func); + Py_INCREF(func); + Py_DECREF(*pfunc); + *pfunc = self; + na++; + /* n++; */ + } else + Py_INCREF(func); + sp = stack_pointer; + READ_TIMESTAMP(intr0); + x = ext_do_call(func, &sp, flags, na, nk); + READ_TIMESTAMP(intr1); + stack_pointer = sp; + Py_DECREF(func); + + while (stack_pointer > pfunc) { + w = POP(); + Py_DECREF(w); + } + PUSH(x); + if (x != NULL) + DISPATCH(); + goto on_error;; + } + + + TARGET(SETUP_WITH) + { + _Py_IDENTIFIER(__exit__); + _Py_IDENTIFIER(__enter__); + w = TOP(); + x = special_lookup(w, &PyId___exit__); + if (!x) + goto on_error; + SET_TOP(x); + u = special_lookup(w, &PyId___enter__); + Py_DECREF(w); + if (!u) { + x = NULL; + goto on_error; + } + x = PyObject_CallFunctionObjArgs(u, NULL); + Py_DECREF(u); + if (!x) + goto on_error; + /* Setup the finally block before pushing the result + of __enter__ on the stack. */ + PyFrame_BlockSetup(f, SETUP_FINALLY, INSTR_OFFSET() + oparg, + STACK_LEVEL()); + + PUSH(x); + DISPATCH(); + } + + + TARGET(EXTENDED_ARG) + opcode = NEXTOP(); + oparg = oparg<<16 | NEXTARG(); + goto *opcode_no_dispatch_targets[opcode]; + + + + TARGET(LIST_APPEND) + w = POP(); + v = PEEK(oparg); + err = PyList_Append(v, w); + Py_DECREF(w); + if (err == 0) { + PREDICT(JUMP_ABSOLUTE); + DISPATCH(); + } + goto on_error;;;; + + + TARGET(SET_ADD) + w = POP(); + v = stack_pointer[-oparg]; + err = PySet_Add(v, w); + Py_DECREF(w); + if (err == 0) { + PREDICT(JUMP_ABSOLUTE); + DISPATCH(); + } + goto on_error;; + + + TARGET(MAP_ADD) + w = TOP(); /* key */ + u = SECOND(); /* value */ + STACKADJ(-2); + v = stack_pointer[-oparg]; /* dict */ + assert (PyDict_CheckExact(v)); + err = PyDict_SetItem(v, w, u); /* v[w] = u */ + Py_DECREF(u); + Py_DECREF(w); + if (err == 0) { + PREDICT(JUMP_ABSOLUTE); + DISPATCH(); + } + goto on_error;; + + + OPT_TARGET_DECODE_NOARG(INCA_BYTEARRAY_ASS_SUBSCRIPT) + /* template: IncaSubscriptDerivative */ + w= TOP(); + v= SECOND(); + u= THIRD(); + + if (INLINE_CACHE_MISS_UNARY(v, PyDict_Type)) + goto TARGET_STORE_SUBSCR_SKIP_DISPATCH;; + STACKADJ(-3); + + err= PyByteArray_Type.tp_as_mapping->mp_ass_subscript( v, w, u ); + + Py_DECREF(v); + Py_DECREF(w); + Py_DECREF(u); + + if (err == 0) DISPATCH(); + goto on_error; + + + + OPT_TARGET_DECODE_ARG(FOR_ITER_BYTESITER) + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyBytesIter_Type)) + goto TARGET_FOR_ITER_SKIP_DISPATCH; + + x= PyBytesIter_Type.tp_iternext( v ); + if (x != NULL) { + PUSH(x); + DISPATCH(); + } + goto FOR_ITER_CONTINUE; + + + + + OPT_TARGET_DECODE_ARG(INCA_CMP_UNICODE) + w= POP(); // tos element + v= TOP(); // sec element + + if (INLINE_CACHE_MISS(v, w, PyUnicode_Type)) goto COMPARE_OP_MISS; + x= PyUnicode_Type.tp_richcompare(v, w, oparg); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + + + OPT_TARGET_DECODE_NOARG(INCA_UNICODE_SUBSCRIPT) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyUnicode_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_SUBSCR_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyUnicode_Type.tp_as_mapping->mp_subscript( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_UNICODE_REMAINDER) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyUnicode_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_MODULO_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyUnicode_Type.tp_as_number->nb_remainder( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + OPT_TARGET_DECODE_ARG(FOR_ITER_RANGEITER) + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyRangeIter_Type)) + goto TARGET_FOR_ITER_SKIP_DISPATCH; + + { + typedef struct { + PyObject_HEAD + long index; + long start; + long step; + long len; + } rangeiterobject; + + if (((rangeiterobject*)v)->index < ((rangeiterobject*)v)->len) { + /* cast to unsigned to avoid possible signed overflow + in intermediate calculations. */ + x= PyLong_FromLong((long)(((rangeiterobject*)v)->start + + (unsigned long)(((rangeiterobject*)v)->index++) + * ((rangeiterobject*)v)->step)); + PUSH(x); + DISPATCH(); + } + else { + x = NULL; + goto FOR_ITER_CONTINUE; + } // if + } + + + + + + OPT_TARGET_DECODE_ARG(INCA_CMP_LONG) + w= POP(); // tos element + v= TOP(); // sec element + + if (INLINE_CACHE_MISS(v, w, PyLong_Type)) goto COMPARE_OP_MISS; + x= PyLong_Type.tp_richcompare(v, w, oparg); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + + + OPT_TARGET_DECODE_NOARG(INCA_LONG_TRUE_DIVIDE) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyLong_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_TRUE_DIVIDE_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyLong_Type.tp_as_number->nb_true_divide( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_LONG_RSHIFT) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyLong_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_RSHIFT_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyLong_Type.tp_as_number->nb_rshift( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_LONG_XOR) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyLong_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_XOR_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyLong_Type.tp_as_number->nb_xor( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_LONG_SUBTRACT) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyLong_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_SUBTRACT_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + +\ +#define MEDIUM_VALUE(x) (Py_SIZE(x) < 0 ? -(sdigit)((PyLongObject*)x)->ob_digit[0] : \ + (Py_SIZE(x) == 0 ? (sdigit)0 : \ + (sdigit)((PyLongObject*)x)->ob_digit[0])) + +#define ABS(x) ((x) < 0 ? -(x) : (x)) + + if (ABS(Py_SIZE(v)) <= 1 && ABS(Py_SIZE(w)) <= 1) + x = PyLong_FromLong(MEDIUM_VALUE(v)-MEDIUM_VALUE(w)); + else + x= PyLong_Type.tp_as_number->nb_subtract(v, w); + +#undef MEDIUM_VALUE +#undef ABS + + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_LONG_AND) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyLong_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_AND_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyLong_Type.tp_as_number->nb_and( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_LONG_POWER) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyLong_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_POWER_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyLong_Type.tp_as_number->nb_power( v, w, Py_None ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_LONG_POSITIVE) + /* template: IncaDerivative */ + + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyLong_Type)) { + /* repair stack pointer */ + stack_pointer+= 0; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_UNARY_POSITIVE_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyLong_Type.tp_as_number->nb_positive( v ); + + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_LONG_REMAINDER) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyLong_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_MODULO_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyLong_Type.tp_as_number->nb_remainder( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_LONG_NEGATIVE) + /* template: IncaDerivative */ + + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyLong_Type)) { + /* repair stack pointer */ + stack_pointer+= 0; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_UNARY_NEGATIVE_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyLong_Type.tp_as_number->nb_negative( v ); + + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_LONG_ADD) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyLong_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_ADD_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + +\ +#define MEDIUM_VALUE(x) (Py_SIZE(x) < 0 ? -(sdigit)((PyLongObject*)x)->ob_digit[0] : \ + (Py_SIZE(x) == 0 ? (sdigit)0 : \ + (sdigit)((PyLongObject*)x)->ob_digit[0])) + +#define ABS(x) ((x) < 0 ? -(x) : (x)) + + if (ABS(Py_SIZE(v)) <= 1 && ABS(Py_SIZE(w)) <= 1) + x = PyLong_FromLong(MEDIUM_VALUE(v) + + MEDIUM_VALUE(w)); + else + x= PyLong_Type.tp_as_number->nb_add(v, w); + +#undef MEDIUM_VALUE +#undef ABS + + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_LONG_MULTIPLY) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyLong_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_MULTIPLY_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + +\ +#define MEDIUM_VALUE(x) (Py_SIZE(x) < 0 ? -(sdigit)((PyLongObject*)x)->ob_digit[0] : \ + (Py_SIZE(x) == 0 ? (sdigit)0 : \ + (sdigit)((PyLongObject*)x)->ob_digit[0])) + +#define ABS(x) ((x) < 0 ? -(x) : (x)) + + if (ABS(Py_SIZE(v)) <= 1 && ABS(Py_SIZE(w)) <= 1) { + stwodigits temp = (stwodigits)(MEDIUM_VALUE(v)) * MEDIUM_VALUE(w); +#ifdef HAVE_LONG_LONG + x= PyLong_FromLongLong((PY_LONG_LONG)temp); +#else + if (temp >= LONG_MIN && temp <= LONG_MAX) + x= PyLong_FromLong((long)temp); +#endif + } + else + x= PyLong_Type.tp_as_number->nb_multiply(v, w); + +#undef MEDIUM_VALUE +#undef ABS + + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_LONG_FLOOR_DIVIDE) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyLong_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_FLOOR_DIVIDE_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyLong_Type.tp_as_number->nb_floor_divide( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_LONG_OR) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyLong_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_OR_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyLong_Type.tp_as_number->nb_or( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_LONG_LSHIFT) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyLong_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_LSHIFT_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyLong_Type.tp_as_number->nb_lshift( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + OPT_TARGET_DECODE_ARG(INCA_CMP_DICTKEYS) + w= POP(); // tos element + v= TOP(); // sec element + + if (INLINE_CACHE_MISS(v, w, PyDictKeys_Type)) goto COMPARE_OP_MISS; + x= PyDictKeys_Type.tp_richcompare(v, w, oparg); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + + + OPT_TARGET_DECODE_NOARG(INCA_DICTKEYS_XOR) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyDictKeys_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_XOR_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyDictKeys_Type.tp_as_number->nb_xor( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_DICTKEYS_SUBTRACT) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyDictKeys_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_SUBTRACT_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyDictKeys_Type.tp_as_number->nb_subtract( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_DICTKEYS_AND) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyDictKeys_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_AND_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyDictKeys_Type.tp_as_number->nb_and( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_DICTKEYS_OR) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PyDictKeys_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_OR_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PyDictKeys_Type.tp_as_number->nb_or( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + OPT_TARGET_DECODE_ARG(FOR_ITER_SEQITER) + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PySeqIter_Type)) + goto TARGET_FOR_ITER_SKIP_DISPATCH; + + x= PySeqIter_Type.tp_iternext( v ); + if (x != NULL) { + PUSH(x); + DISPATCH(); + } + goto FOR_ITER_CONTINUE; + + + + + OPT_TARGET_DECODE_ARG(FOR_ITER_CALLITER) + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyCallIter_Type)) + goto TARGET_FOR_ITER_SKIP_DISPATCH; + + x= PyCallIter_Type.tp_iternext( v ); + if (x != NULL) { + PUSH(x); + DISPATCH(); + } + goto FOR_ITER_CONTINUE; + + + + + OPT_TARGET_DECODE_ARG(FOR_ITER_UNICODEITER) + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyUnicodeIter_Type)) + goto TARGET_FOR_ITER_SKIP_DISPATCH; + + x= PyUnicodeIter_Type.tp_iternext( v ); + if (x != NULL) { + PUSH(x); + DISPATCH(); + } + goto FOR_ITER_CONTINUE; + + + + + OPT_TARGET_DECODE_ARG(INCA_CMP_SET) + w= POP(); // tos element + v= TOP(); // sec element + + if (INLINE_CACHE_MISS(v, w, PySet_Type)) goto COMPARE_OP_MISS; + x= PySet_Type.tp_richcompare(v, w, oparg); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + + + OPT_TARGET_DECODE_NOARG(INCA_SET_XOR) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PySet_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_XOR_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PySet_Type.tp_as_number->nb_xor( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_SET_SUBTRACT) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PySet_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_SUBTRACT_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PySet_Type.tp_as_number->nb_subtract( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_SET_AND) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PySet_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_AND_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PySet_Type.tp_as_number->nb_and( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_NOARG(INCA_SET_OR) + /* template: IncaDerivative */ + + w= POP(); + v= TOP(); + + if (INLINE_CACHE_MISS(v, w, PySet_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* fprintf(stderr, "generated by template inline cache miss\n"); */ + + /* dispatch to generic implementation */ + goto TARGET_BINARY_OR_SKIP_DISPATCH;; + } // if + /* fprintf(stderr, "generated by template inline cache hit\n"); */ + + x= PySet_Type.tp_as_number->nb_or( v, w ); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + OPT_TARGET_DECODE_ARG(FOR_ITER_REVERSED) + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyReversed_Type)) + goto TARGET_FOR_ITER_SKIP_DISPATCH; + + x= PyReversed_Type.tp_iternext( v ); + if (x != NULL) { + PUSH(x); + DISPATCH(); + } + goto FOR_ITER_CONTINUE; + + + + + OPT_TARGET_DECODE_ARG(FOR_ITER_SETITER) + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PySetIter_Type)) + goto TARGET_FOR_ITER_SKIP_DISPATCH; + + x= PySetIter_Type.tp_iternext( v ); + if (x != NULL) { + PUSH(x); + DISPATCH(); + } + goto FOR_ITER_CONTINUE; + + + + + OPT_TARGET_DECODE_ARG(FOR_ITER_MAP) + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyMap_Type)) + goto TARGET_FOR_ITER_SKIP_DISPATCH; + + x= PyMap_Type.tp_iternext( v ); + if (x != NULL) { + PUSH(x); + DISPATCH(); + } + goto FOR_ITER_CONTINUE; + + + + + OPT_TARGET_DECODE_ARG(FOR_ITER_BYTEARRAYITER) + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyByteArrayIter_Type)) + goto TARGET_FOR_ITER_SKIP_DISPATCH; + + x= PyByteArrayIter_Type.tp_iternext( v ); + if (x != NULL) { + PUSH(x); + DISPATCH(); + } + goto FOR_ITER_CONTINUE; + + + + + OPT_TARGET_DECODE_ARG(FOR_ITER_LISTITER) + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyListIter_Type)) + goto TARGET_FOR_ITER_SKIP_DISPATCH; + + x= PyListIter_Type.tp_iternext( v ); + if (x != NULL) { + PUSH(x); + DISPATCH(); + } + goto FOR_ITER_CONTINUE; + + + + + OPT_TARGET_DECODE_ARG(FOR_ITER_ZIP) + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyZip_Type)) + goto TARGET_FOR_ITER_SKIP_DISPATCH; + + x= PyZip_Type.tp_iternext( v ); + if (x != NULL) { + PUSH(x); + DISPATCH(); + } + goto FOR_ITER_CONTINUE; + + + + + OPT_TARGET_DECODE_ARG(FOR_ITER_TUPLEITER) + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyTupleIter_Type)) + goto TARGET_FOR_ITER_SKIP_DISPATCH; + + x= PyTupleIter_Type.tp_iternext( v ); + if (x != NULL) { + PUSH(x); + DISPATCH(); + } + goto FOR_ITER_CONTINUE; + + + + + OPT_TARGET_DECODE_ARG(FOR_ITER_LISTREVITER) + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, PyListRevIter_Type)) + goto TARGET_FOR_ITER_SKIP_DISPATCH; + + x= PyListRevIter_Type.tp_iternext( v ); + if (x != NULL) { + PUSH(x); + DISPATCH(); + } + goto FOR_ITER_CONTINUE; + + + + + OPT_TARGET_DECODE_ARG(FAST_C_ZERO) + v= TOP(); /* code pointer */ + + /* guard against inline cache misses */ + if (! (PyCFunction_Check(v) && (PyCFunction_GET_FLAGS(v) & METH_NOARGS))) { + /* fprintf(stderr, "FAST_C_ZERO inline cache miss\n"); */ + + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + /* fprintf(stderr, "FAST_C_ZERO inline cache hit\n"); */ + + + u= PyCFunction_GET_SELF(v); + x= (*((PyCFunction) PyCFunction_GET_FUNCTION(v)))(u, NULL); + + Py_DECREF(v); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_ARG(FAST_C_ONE) + w= POP(); /* TOS element, when arity is 1 */ + v= TOP(); /* code pointer */ + + /* guard against inline cache misses */ + if (! (PyCFunction_Check(v) && (PyCFunction_GET_FLAGS(v) & METH_O))) { + stack_pointer++; /* reset stack pointer */ + /* fprintf(stderr, "FAST_C_ONE inline cache miss\n"); */ + + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + /* fprintf(stderr, "FAST_C_ONE inline cache hit\n"); */ + + + u= PyCFunction_GET_SELF(v); + x= (*((PyCFunction) PyCFunction_GET_FUNCTION(v)))(u, w); + + Py_DECREF(w); + Py_DECREF(v); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + + + + OPT_TARGET_DECODE_ARG(FAST_CALL_GENERATOR_ONE) + { + if (oparg != 1) goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + w= TOP(); + v= SECOND(); + + if (! (PyMethod_Check(v) || PyFunction_Check(v))) { + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + register PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(v); + if (!co->co_flags & CO_GENERATOR) { + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + PyObject *globals= PyFunction_GET_GLOBALS(v); + PyObject *closure= PyFunction_GET_CLOSURE(v); + PyThreadState *tstate= PyThreadState_GET(); + if (globals == NULL || closure == NULL || tstate == NULL) + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + STACKADJ(-1); + register PyFrameObject *generator_frame= PyFrame_New(tstate, co, globals, NULL); + register PyObject **freevars= generator_frame->f_localsplus + co->co_nlocals; + + Py_INCREF( w ); + generator_frame->f_localsplus[ 0 ]= w; + + /* copy closure variables... */ + u= PyTuple_GET_ITEM(closure, 0); + Py_INCREF(u); + freevars[0] = u; /* closure-bound variable */ + + /* Don't need to keep the reference to f_back, it will be set + * when the generator is resumed. */ + Py_XDECREF(generator_frame->f_back); + generator_frame->f_back = NULL; + + x= PyGen_New(generator_frame); + + Py_DECREF( w ); + Py_DECREF( v ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + } + + + + + OPT_TARGET_DECODE_ARG(FAST_C_VARARGS_ZERO) + { + if (oparg != 0) goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + v= TOP(); + + /* guard against inline cache misses */ + if (! (PyCFunction_Check(v) /* starting with NOT makes it easier to debug */ + && (PyCFunction_GET_FLAGS(v) & (METH_VARARGS | METH_KEYWORDS) ))) + { + /* fprintf(stderr, "FAST_C_VARARGS_ZERO inline cache miss\n"); */ + + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + /* fprintf(stderr, "FAST_C_VARARGS_ZERO inline cache hit\n"); */ + + + register PyCFunction meth= PyCFunction_GET_FUNCTION(v); + register PyObject *self= PyCFunction_GET_SELF(v); + register PyObject *args= PyTuple_New( 0 ); + + x= (*(PyCFunctionWithKeywords)meth)(self, args, NULL); + + Py_XDECREF( args ); + Py_DECREF(v); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + } + + + + + OPT_TARGET_DECODE_ARG(FAST_C_VARARGS_ONE) + { + if (oparg != 1) goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + w= TOP(); + v= SECOND(); + + /* guard against inline cache misses */ + if (! (PyCFunction_Check(v) /* starting with NOT makes it easier to debug */ + && (PyCFunction_GET_FLAGS(v) & (METH_VARARGS | METH_KEYWORDS) ))) + { + /* fprintf(stderr, "FAST_C_VARARGS_ONE inline cache miss\n"); */ + + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + /* fprintf(stderr, "FAST_C_VARARGS_ONE inline cache hit\n"); */ + + + STACKADJ(-1); + register PyCFunction meth= PyCFunction_GET_FUNCTION(v); + register PyObject *self= PyCFunction_GET_SELF(v); + register PyObject *args= PyTuple_New( 1 ); + PyTuple_SET_ITEM(args, 0, w); + + + x= (*(PyCFunctionWithKeywords)meth)(self, args, NULL); + + Py_XDECREF( args ); + Py_DECREF(v); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + } + + + + + OPT_TARGET_DECODE_ARG(FAST_C_VARARGS_TWO) + { + if (oparg != 2) goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + u= TOP(); + w= SECOND(); + v= THIRD(); + + /* guard against inline cache misses */ + if (! (PyCFunction_Check(v) /* starting with NOT makes it easier to debug */ + && (PyCFunction_GET_FLAGS(v) & (METH_VARARGS | METH_KEYWORDS) ))) + { + /* fprintf(stderr, "FAST_C_VARARGS_TWO inline cache miss\n"); */ + + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + /* fprintf(stderr, "FAST_C_VARARGS_TWO inline cache hit\n"); */ + + + STACKADJ(-2); + register PyCFunction meth= PyCFunction_GET_FUNCTION(v); + register PyObject *self= PyCFunction_GET_SELF(v); + register PyObject *args= PyTuple_New( 2 ); + PyTuple_SET_ITEM(args, 0, w); + + PyTuple_SET_ITEM(args, 1, u); + + + x= (*(PyCFunctionWithKeywords)meth)(self, args, NULL); + + Py_XDECREF( args ); + Py_DECREF(v); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + } + + + + + OPT_TARGET_DECODE_ARG(FAST_C_VARARGS_THREE) + { + if (oparg != 3) goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + t= TOP(); + u= SECOND(); + w= THIRD(); + v= FOURTH(); + + /* guard against inline cache misses */ + if (! (PyCFunction_Check(v) /* starting with NOT makes it easier to debug */ + && (PyCFunction_GET_FLAGS(v) & (METH_VARARGS | METH_KEYWORDS) ))) + { + /* fprintf(stderr, "FAST_C_VARARGS_THREE inline cache miss\n"); */ + + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + /* fprintf(stderr, "FAST_C_VARARGS_THREE inline cache hit\n"); */ + + + STACKADJ(-3); + register PyCFunction meth= PyCFunction_GET_FUNCTION(v); + register PyObject *self= PyCFunction_GET_SELF(v); + register PyObject *args= PyTuple_New( 3 ); + PyTuple_SET_ITEM(args, 0, w); + + PyTuple_SET_ITEM(args, 1, u); + + PyTuple_SET_ITEM(args, 2, t); + + + x= (*(PyCFunctionWithKeywords)meth)(self, args, NULL); + + Py_XDECREF( args ); + Py_DECREF(v); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + } + + + + + OPT_TARGET_DECODE_ARG(FAST_PYFUN_DOCALL_ZERO) + { + if (oparg != 0) goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + v= TOP(); + + /* guard against inline cache misses */ + if (PyMethod_Check(v) && PyMethod_GET_SELF(v) != NULL) { + /* fprintf(stderr, "FAST_PYFUN_DOCALL_ZERO inline cache miss\n"); */ + + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + if (PyFunction_Check(v) || PyCFunction_Check(v)) { + /* fprintf(stderr, "FAST_PYFUN_DOCALL_ZERO inline cache miss\n"); */ + + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + register ternaryfunc call= v->ob_type->tp_call; + if (call == NULL) + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + /* fprintf(stderr, "FAST_PYFUN_DOCALL_ZERO inline cache hit\n"); */ + + + register PyObject *args= PyTuple_New( 0 ); + + if (Py_EnterRecursiveCall(" while calling a Python object")) { + x= NULL; + SET_TOP(x); + break; + } // if + + x= (*call)(v, args, NULL); + + Py_LeaveRecursiveCall(); + + if (x == NULL && !PyErr_Occurred()) + PyErr_SetString(PyExc_SystemError, "NULL result without error in PyObject_Call"); + + Py_XDECREF( args ); + + Py_DECREF(v); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + } + + + + + OPT_TARGET_DECODE_ARG(FAST_PYFUN_DOCALL_ONE) + { + if (oparg != 1) goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + w= TOP(); + v= SECOND(); + + /* guard against inline cache misses */ + if (PyMethod_Check(v) && PyMethod_GET_SELF(v) != NULL) { + /* fprintf(stderr, "FAST_PYFUN_DOCALL_ONE inline cache miss\n"); */ + + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + if (PyFunction_Check(v) || PyCFunction_Check(v)) { + /* fprintf(stderr, "FAST_PYFUN_DOCALL_ONE inline cache miss\n"); */ + + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + register ternaryfunc call= v->ob_type->tp_call; + if (call == NULL) + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + STACKADJ(-1); + /* fprintf(stderr, "FAST_PYFUN_DOCALL_ONE inline cache hit\n"); */ + + + register PyObject *args= PyTuple_New( 1 ); + PyTuple_SET_ITEM(args, 0, w); + + if (Py_EnterRecursiveCall(" while calling a Python object")) { + x= NULL; + SET_TOP(x); + break; + } // if + + x= (*call)(v, args, NULL); + + Py_LeaveRecursiveCall(); + + if (x == NULL && !PyErr_Occurred()) + PyErr_SetString(PyExc_SystemError, "NULL result without error in PyObject_Call"); + + Py_XDECREF( args ); + + Py_DECREF(v); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + } + + + + + OPT_TARGET_DECODE_ARG(FAST_PYFUN_DOCALL_TWO) + { + if (oparg != 2) goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + u= TOP(); + w= SECOND(); + v= THIRD(); + + /* guard against inline cache misses */ + if (PyMethod_Check(v) && PyMethod_GET_SELF(v) != NULL) { + /* fprintf(stderr, "FAST_PYFUN_DOCALL_TWO inline cache miss\n"); */ + + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + if (PyFunction_Check(v) || PyCFunction_Check(v)) { + /* fprintf(stderr, "FAST_PYFUN_DOCALL_TWO inline cache miss\n"); */ + + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + register ternaryfunc call= v->ob_type->tp_call; + if (call == NULL) + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + STACKADJ(-2); + /* fprintf(stderr, "FAST_PYFUN_DOCALL_TWO inline cache hit\n"); */ + + + register PyObject *args= PyTuple_New( 2 ); + PyTuple_SET_ITEM(args, 0, w); + PyTuple_SET_ITEM(args, 1, u); + + if (Py_EnterRecursiveCall(" while calling a Python object")) { + x= NULL; + SET_TOP(x); + break; + } // if + + x= (*call)(v, args, NULL); + + Py_LeaveRecursiveCall(); + + if (x == NULL && !PyErr_Occurred()) + PyErr_SetString(PyExc_SystemError, "NULL result without error in PyObject_Call"); + + Py_XDECREF( args ); + + Py_DECREF(v); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + } + + + + + OPT_TARGET_DECODE_ARG(FAST_PYMETH_ZERO) + { + if (oparg != 0) goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + v= TOP(); + + /* guard against inline cache misses */ + if (! PyMethod_Check(v)) { + /* fprintf(stderr, "FAST_PYMETH_ZERO inline cache miss\n"); */ + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + + PyObject *func= PyMethod_GET_FUNCTION(v); + PyObject *self= PyMethod_GET_SELF(v); + + if (! (PyFunction_Check(func) && self != NULL)) { + /* fprintf(stderr, "FAST_PYMETH_ZERO inline cache miss\n"); */ + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + + PyCodeObject *code= (PyCodeObject*)PyFunction_GET_CODE(func); + if (! (code->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE))) { + /* fprintf(stderr, "FAST_PYMETH_ZERO inline cache miss\n"); */ + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + + x= PyFunction_GET_DEFAULTS(func); + if (! (x == NULL)) { + /* fprintf(stderr, "FAST_PYMETH_ZERO inline cache miss\n"); */ + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + /* fprintf(stderr, "FAST_PYMETH_ZERO inline cache hit\n"); */ + + Py_INCREF(self); + Py_INCREF(func); + Py_DECREF(v); + + PyObject *globals = PyFunction_GET_GLOBALS(func); + PyThreadState *tstate = PyThreadState_GET(); + PyFrameObject *callee_frame= PyFrame_New(tstate, code, globals, NULL); + if (callee_frame == NULL) { + x= NULL; + SET_TOP(x); + break; + } // if + + callee_frame->f_localsplus[0]= self; + Py_INCREF(self); + + + x= PyEval_EvalFrameEx(callee_frame, 0); + + ++tstate->recursion_depth; + Py_DECREF(callee_frame); + --tstate->recursion_depth; + + Py_DECREF(func); + Py_DECREF(self); + + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + } + + + + + OPT_TARGET_DECODE_ARG(FAST_PYMETH_ONE) + { + if (oparg != 1) goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + w= TOP(); + v= SECOND(); + + /* guard against inline cache misses */ + if (! PyMethod_Check(v)) { + /* fprintf(stderr, "FAST_PYMETH_ONE inline cache miss\n"); */ + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + + PyObject *func= PyMethod_GET_FUNCTION(v); + PyObject *self= PyMethod_GET_SELF(v); + + if (! (PyFunction_Check(func) && self != NULL)) { + /* fprintf(stderr, "FAST_PYMETH_ONE inline cache miss\n"); */ + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + + PyCodeObject *code= (PyCodeObject*)PyFunction_GET_CODE(func); + if (! (code->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE))) { + /* fprintf(stderr, "FAST_PYMETH_ONE inline cache miss\n"); */ + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + + x= PyFunction_GET_DEFAULTS(func); + if (! (x == NULL)) { + /* fprintf(stderr, "FAST_PYMETH_ONE inline cache miss\n"); */ + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + /* fprintf(stderr, "FAST_PYMETH_ONE inline cache hit\n"); */ + STACKADJ(-1); + + Py_INCREF(self); + Py_INCREF(func); + Py_DECREF(v); + + PyObject *globals = PyFunction_GET_GLOBALS(func); + PyThreadState *tstate = PyThreadState_GET(); + PyFrameObject *callee_frame= PyFrame_New(tstate, code, globals, NULL); + if (callee_frame == NULL) { + x= NULL; + SET_TOP(x); + break; + } // if + + callee_frame->f_localsplus[0]= self; + Py_INCREF(self); + + callee_frame->f_localsplus[1]= w; + Py_INCREF( w ); + + x= PyEval_EvalFrameEx(callee_frame, 0); + + ++tstate->recursion_depth; + Py_DECREF(callee_frame); + --tstate->recursion_depth; + + Py_DECREF(func); + Py_DECREF(self); + + Py_DECREF( w ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + } + + + + + OPT_TARGET_DECODE_ARG(FAST_PYMETH_TWO) + { + if (oparg != 2) goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + u= TOP(); + w= SECOND(); + v= THIRD(); + + /* guard against inline cache misses */ + if (! PyMethod_Check(v)) { + /* fprintf(stderr, "FAST_PYMETH_TWO inline cache miss\n"); */ + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + + PyObject *func= PyMethod_GET_FUNCTION(v); + PyObject *self= PyMethod_GET_SELF(v); + + if (! (PyFunction_Check(func) && self != NULL)) { + /* fprintf(stderr, "FAST_PYMETH_TWO inline cache miss\n"); */ + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + + PyCodeObject *code= (PyCodeObject*)PyFunction_GET_CODE(func); + if (! (code->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE))) { + /* fprintf(stderr, "FAST_PYMETH_TWO inline cache miss\n"); */ + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + + x= PyFunction_GET_DEFAULTS(func); + if (! (x == NULL)) { + /* fprintf(stderr, "FAST_PYMETH_TWO inline cache miss\n"); */ + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + /* fprintf(stderr, "FAST_PYMETH_TWO inline cache hit\n"); */ + STACKADJ(-2); + + Py_INCREF(self); + Py_INCREF(func); + Py_DECREF(v); + + PyObject *globals = PyFunction_GET_GLOBALS(func); + PyThreadState *tstate = PyThreadState_GET(); + PyFrameObject *callee_frame= PyFrame_New(tstate, code, globals, NULL); + if (callee_frame == NULL) { + x= NULL; + SET_TOP(x); + break; + } // if + + callee_frame->f_localsplus[0]= self; + Py_INCREF(self); + + callee_frame->f_localsplus[1]= w; + Py_INCREF( w ); + callee_frame->f_localsplus[2]= u; + Py_INCREF( u ); + + x= PyEval_EvalFrameEx(callee_frame, 0); + + ++tstate->recursion_depth; + Py_DECREF(callee_frame); + --tstate->recursion_depth; + + Py_DECREF(func); + Py_DECREF(self); + + Py_DECREF( u ); + Py_DECREF( w ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + } + + + + + OPT_TARGET_DECODE_ARG(FAST_PYMETH_THREE) + { + if (oparg != 3) goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + t= TOP(); + u= SECOND(); + w= THIRD(); + v= FOURTH(); + + /* guard against inline cache misses */ + if (! PyMethod_Check(v)) { + /* fprintf(stderr, "FAST_PYMETH_THREE inline cache miss\n"); */ + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + + PyObject *func= PyMethod_GET_FUNCTION(v); + PyObject *self= PyMethod_GET_SELF(v); + + if (! (PyFunction_Check(func) && self != NULL)) { + /* fprintf(stderr, "FAST_PYMETH_THREE inline cache miss\n"); */ + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + + PyCodeObject *code= (PyCodeObject*)PyFunction_GET_CODE(func); + if (! (code->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE))) { + /* fprintf(stderr, "FAST_PYMETH_THREE inline cache miss\n"); */ + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + + x= PyFunction_GET_DEFAULTS(func); + if (! (x == NULL)) { + /* fprintf(stderr, "FAST_PYMETH_THREE inline cache miss\n"); */ + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + /* fprintf(stderr, "FAST_PYMETH_THREE inline cache hit\n"); */ + STACKADJ(-3); + + Py_INCREF(self); + Py_INCREF(func); + Py_DECREF(v); + + PyObject *globals = PyFunction_GET_GLOBALS(func); + PyThreadState *tstate = PyThreadState_GET(); + PyFrameObject *callee_frame= PyFrame_New(tstate, code, globals, NULL); + if (callee_frame == NULL) { + x= NULL; + SET_TOP(x); + break; + } // if + + callee_frame->f_localsplus[0]= self; + Py_INCREF(self); + + callee_frame->f_localsplus[1]= w; + Py_INCREF( w ); + callee_frame->f_localsplus[2]= u; + Py_INCREF( u ); + callee_frame->f_localsplus[3]= t; + Py_INCREF( t ); + + x= PyEval_EvalFrameEx(callee_frame, 0); + + ++tstate->recursion_depth; + Py_DECREF(callee_frame); + --tstate->recursion_depth; + + Py_DECREF(func); + Py_DECREF(self); + + Py_DECREF( t ); + Py_DECREF( u ); + Py_DECREF( w ); + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + } + + + + + OPT_TARGET_DECODE_ARG(FAST_PYFUN_ZERO) + { + if (oparg != 0) goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + v= TOP(); + + /* guard against inline cache misses */ + if (! (!(PyMethod_Check(v) && PyMethod_GET_SELF(v) != NULL) && PyFunction_Check(v))) { + /* fprintf(stderr, "FAST_PYFUN_ZERO inline cache miss\n"); */ + + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + PyCodeObject *code= (PyCodeObject*)PyFunction_GET_CODE(v); + if (code->co_argcount != 0) { + /* fprintf(stderr, "FAST_PYFUN_ZERO inline cache miss\n"); */ + + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + if (! (code->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE))) { + /* fprintf(stderr, "FAST_PYFUN_ZERO inline cache miss\n"); */ + + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + /* fprintf(stderr, "FAST_PYFUN_ZERO inline cache hit\n"); */ + + + PyObject *globals= PyFunction_GET_GLOBALS(v); + PyThreadState *tstate= PyThreadState_GET(); + PyFrameObject *callee_frame= PyFrame_New( tstate, code, globals, NULL ); + if (callee_frame == NULL) { + SET_TOP((PyObject*)NULL); + break; + } // if + + + x= PyEval_EvalFrameEx(callee_frame, 0); + + ++tstate->recursion_depth; + Py_DECREF(callee_frame); + --tstate->recursion_depth; + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + } + + + + + OPT_TARGET_DECODE_ARG(FAST_PYFUN_ONE) + { + if (oparg != 1) goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + w= TOP(); + v= SECOND(); + + /* guard against inline cache misses */ + if (! (!(PyMethod_Check(v) && PyMethod_GET_SELF(v) != NULL) && PyFunction_Check(v))) { + /* fprintf(stderr, "FAST_PYFUN_ONE inline cache miss\n"); */ + + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + PyCodeObject *code= (PyCodeObject*)PyFunction_GET_CODE(v); + if (code->co_argcount != 1) { + /* fprintf(stderr, "FAST_PYFUN_ONE inline cache miss\n"); */ + + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + if (! (code->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE))) { + /* fprintf(stderr, "FAST_PYFUN_ONE inline cache miss\n"); */ + + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + /* fprintf(stderr, "FAST_PYFUN_ONE inline cache hit\n"); */ + + + STACKADJ(-1); + PyObject *globals= PyFunction_GET_GLOBALS(v); + PyThreadState *tstate= PyThreadState_GET(); + PyFrameObject *callee_frame= PyFrame_New( tstate, code, globals, NULL ); + if (callee_frame == NULL) { + SET_TOP((PyObject*)NULL); + break; + } // if + + callee_frame->f_localsplus[0]= w; + + x= PyEval_EvalFrameEx(callee_frame, 0); + + ++tstate->recursion_depth; + Py_DECREF(callee_frame); + --tstate->recursion_depth; + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + } + + + + + OPT_TARGET_DECODE_ARG(FAST_PYFUN_TWO) + { + if (oparg != 2) goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + u= TOP(); + w= SECOND(); + v= THIRD(); + + /* guard against inline cache misses */ + if (! (!(PyMethod_Check(v) && PyMethod_GET_SELF(v) != NULL) && PyFunction_Check(v))) { + /* fprintf(stderr, "FAST_PYFUN_TWO inline cache miss\n"); */ + + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + PyCodeObject *code= (PyCodeObject*)PyFunction_GET_CODE(v); + if (code->co_argcount != 2) { + /* fprintf(stderr, "FAST_PYFUN_TWO inline cache miss\n"); */ + + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + if (! (code->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE))) { + /* fprintf(stderr, "FAST_PYFUN_TWO inline cache miss\n"); */ + + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + /* fprintf(stderr, "FAST_PYFUN_TWO inline cache hit\n"); */ + + + STACKADJ(-2); + PyObject *globals= PyFunction_GET_GLOBALS(v); + PyThreadState *tstate= PyThreadState_GET(); + PyFrameObject *callee_frame= PyFrame_New( tstate, code, globals, NULL ); + if (callee_frame == NULL) { + SET_TOP((PyObject*)NULL); + break; + } // if + + callee_frame->f_localsplus[0]= w; + callee_frame->f_localsplus[1]= u; + + x= PyEval_EvalFrameEx(callee_frame, 0); + + ++tstate->recursion_depth; + Py_DECREF(callee_frame); + --tstate->recursion_depth; + + SET_TOP(x); + + if (x != NULL) DISPATCH(); + goto on_error; + + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 2f563908ebc5 -r be51373d99cf Python/opt/gen/opcode.h.gen --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Python/opt/gen/opcode.h.gen Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,213 @@ +/* + * This files was auto-generated on 2012-04-25T16:14:56.758014, please don't change! + * Project-Id: contrib-3.3 + * Years: 2010, 2011, 2012 + */ + +#define POP_TOP 1 +#define ROT_TWO 2 +#define ROT_THREE 3 +#define DUP_TOP 4 +#define DUP_TOP_TWO 5 +#define INCA_ADD_STRINGS 6 +#define INCA_UNPACK_TUPLE_TWO 7 +#define INCA_BUILD_TUPLE_TWO 8 +#define NOP 9 +#define UNARY_POSITIVE 10 +#define UNARY_NEGATIVE 11 +#define UNARY_NOT 12 +#define INCA_UNPACK_LIST_TWO 13 +#define INCA_BUILD_LIST_TWO 14 +#define UNARY_INVERT 15 +#define INCA_UNPACK_TUPLE_THREE 16 +#define INCA_BUILD_TUPLE_THREE 17 +#define INCA_UNPACK_LIST_THREE 18 +#define BINARY_POWER 19 +#define BINARY_MULTIPLY 20 +#define INCA_BUILD_LIST_THREE 21 +#define BINARY_MODULO 22 +#define BINARY_ADD 23 +#define BINARY_SUBTRACT 24 +#define BINARY_SUBSCR 25 +#define BINARY_FLOOR_DIVIDE 26 +#define BINARY_TRUE_DIVIDE 27 +#define INPLACE_FLOOR_DIVIDE 28 +#define INPLACE_TRUE_DIVIDE 29 +#define INCA_BUILD_SLICE_TWO 30 +#define INCA_BUILD_SLICE_THREE 31 +#define INCA_CMP_FLOAT 32 +#define INCA_FLOAT_TRUE_DIVIDE 33 +#define INCA_FLOAT_SUBTRACT 34 +#define INCA_FLOAT_POWER 35 +#define INCA_FLOAT_POSITIVE 36 +#define INCA_FLOAT_REMAINDER 37 +#define INCA_FLOAT_NEGATIVE 38 +#define INCA_FLOAT_ADD 39 +#define INCA_FLOAT_MULTIPLY 40 +#define INCA_FLOAT_FLOOR_DIVIDE 41 +#define INCA_CMP_DICT 42 +#define INCA_DICT_SUBSCRIPT 43 +#define INCA_DICT_ASS_SUBSCRIPT 44 +#define FOR_ITER_ENUM 45 +#define INCA_CMP_TUPLE 46 +#define INCA_TUPLE_SUBSCRIPT 47 +#define INCA_BOOL_XOR 48 +#define INCA_BOOL_AND 49 +#define INCA_BOOL_OR 50 +#define INCA_CMP_COMPLEX 51 +#define INCA_COMPLEX_TRUE_DIVIDE 52 +#define INCA_COMPLEX_SUBTRACT 53 +#define STORE_MAP 54 +#define INPLACE_ADD 55 +#define INPLACE_SUBTRACT 56 +#define INPLACE_MULTIPLY 57 +#define INCA_COMPLEX_POWER 58 +#define INPLACE_MODULO 59 +#define STORE_SUBSCR 60 +#define DELETE_SUBSCR 61 +#define BINARY_LSHIFT 62 +#define BINARY_RSHIFT 63 +#define BINARY_AND 64 +#define BINARY_XOR 65 +#define BINARY_OR 66 +#define INPLACE_POWER 67 +#define GET_ITER 68 +#define STORE_LOCALS 69 +#define PRINT_EXPR 70 +#define LOAD_BUILD_CLASS 71 +#define YIELD_FROM 72 +#define INCA_COMPLEX_POSITIVE 73 +#define INCA_COMPLEX_REMAINDER 74 +#define INPLACE_LSHIFT 75 +#define INPLACE_RSHIFT 76 +#define INPLACE_AND 77 +#define INPLACE_XOR 78 +#define INPLACE_OR 79 +#define BREAK_LOOP 80 +#define WITH_CLEANUP 81 +#define INCA_COMPLEX_NEGATIVE 82 +#define RETURN_VALUE 83 +#define IMPORT_STAR 84 +#define INCA_COMPLEX_ADD 85 +#define YIELD_VALUE 86 +#define POP_BLOCK 87 +#define END_FINALLY 88 +#define POP_EXCEPT 89 +#define STORE_NAME 90 +#define DELETE_NAME 91 +#define UNPACK_SEQUENCE 92 +#define FOR_ITER 93 +#define UNPACK_EX 94 +#define STORE_ATTR 95 +#define DELETE_ATTR 96 +#define STORE_GLOBAL 97 +#define DELETE_GLOBAL 98 +#define INCA_COMPLEX_MULTIPLY 99 +#define LOAD_CONST 100 +#define LOAD_NAME 101 +#define BUILD_TUPLE 102 +#define BUILD_LIST 103 +#define BUILD_SET 104 +#define BUILD_MAP 105 +#define LOAD_ATTR 106 +#define COMPARE_OP 107 +#define IMPORT_NAME 108 +#define IMPORT_FROM 109 +#define JUMP_FORWARD 110 +#define JUMP_IF_FALSE_OR_POP 111 +#define JUMP_IF_TRUE_OR_POP 112 +#define JUMP_ABSOLUTE 113 +#define POP_JUMP_IF_FALSE 114 +#define POP_JUMP_IF_TRUE 115 +#define LOAD_GLOBAL 116 +#define INCA_COMPLEX_FLOOR_DIVIDE 117 +#define FOR_ITER_LONGRANGEITER 118 +#define CONTINUE_LOOP 119 +#define SETUP_LOOP 120 +#define SETUP_EXCEPT 121 +#define SETUP_FINALLY 122 +#define INCA_CMP_LIST 123 +#define LOAD_FAST 124 +#define STORE_FAST 125 +#define DELETE_FAST 126 +#define INCA_LIST_SUBSCRIPT 127 +#define INCA_LIST_ASS_SUBSCRIPT 128 +#define INCA_CMP_BYTEARRAY 129 +#define RAISE_VARARGS 130 +#define CALL_FUNCTION 131 +#define MAKE_FUNCTION 132 +#define BUILD_SLICE 133 +#define MAKE_CLOSURE 134 +#define LOAD_CLOSURE 135 +#define LOAD_DEREF 136 +#define STORE_DEREF 137 +#define DELETE_DEREF 138 +#define INCA_BYTEARRAY_SUBSCRIPT 139 +#define CALL_FUNCTION_VAR 140 +#define CALL_FUNCTION_KW 141 +#define CALL_FUNCTION_VAR_KW 142 +#define SETUP_WITH 143 +#define EXTENDED_ARG 144 +#define LIST_APPEND 145 +#define SET_ADD 146 +#define MAP_ADD 147 +#define INCA_BYTEARRAY_ASS_SUBSCRIPT 148 +#define FOR_ITER_BYTESITER 149 +#define INCA_CMP_UNICODE 150 +#define INCA_UNICODE_SUBSCRIPT 151 +#define INCA_UNICODE_REMAINDER 152 +#define FOR_ITER_RANGEITER 153 +#define INCA_CMP_LONG 154 +#define INCA_LONG_TRUE_DIVIDE 155 +#define INCA_LONG_RSHIFT 156 +#define INCA_LONG_XOR 157 +#define INCA_LONG_SUBTRACT 158 +#define INCA_LONG_AND 159 +#define INCA_LONG_POWER 160 +#define INCA_LONG_POSITIVE 161 +#define INCA_LONG_REMAINDER 162 +#define INCA_LONG_NEGATIVE 163 +#define INCA_LONG_ADD 164 +#define INCA_LONG_MULTIPLY 165 +#define INCA_LONG_FLOOR_DIVIDE 166 +#define INCA_LONG_OR 167 +#define INCA_LONG_LSHIFT 168 +#define INCA_CMP_DICTKEYS 169 +#define INCA_DICTKEYS_XOR 170 +#define INCA_DICTKEYS_SUBTRACT 171 +#define INCA_DICTKEYS_AND 172 +#define INCA_DICTKEYS_OR 173 +#define FOR_ITER_SEQITER 174 +#define FOR_ITER_CALLITER 175 +#define FOR_ITER_UNICODEITER 176 +#define INCA_CMP_SET 177 +#define INCA_SET_XOR 178 +#define INCA_SET_SUBTRACT 179 +#define INCA_SET_AND 180 +#define INCA_SET_OR 181 +#define FOR_ITER_REVERSED 182 +#define FOR_ITER_SETITER 183 +#define FOR_ITER_MAP 184 +#define FOR_ITER_BYTEARRAYITER 185 +#define FOR_ITER_LISTITER 186 +#define FOR_ITER_ZIP 187 +#define FOR_ITER_TUPLEITER 188 +#define FOR_ITER_LISTREVITER 189 +#define FAST_C_ZERO 190 +#define FAST_C_ONE 191 +#define FAST_CALL_GENERATOR_ONE 192 +#define FAST_C_VARARGS_ZERO 193 +#define FAST_C_VARARGS_ONE 194 +#define FAST_C_VARARGS_TWO 195 +#define FAST_C_VARARGS_THREE 196 +#define FAST_PYFUN_DOCALL_ZERO 197 +#define FAST_PYFUN_DOCALL_ONE 198 +#define FAST_PYFUN_DOCALL_TWO 199 +#define FAST_PYMETH_ZERO 200 +#define FAST_PYMETH_ONE 201 +#define FAST_PYMETH_TWO 202 +#define FAST_PYMETH_THREE 203 +#define FAST_PYFUN_ZERO 204 +#define FAST_PYFUN_ONE 205 +#define FAST_PYFUN_TWO 206 + diff -r 2f563908ebc5 -r be51373d99cf Python/opt/gen/rewrite-inca-fun.h.gen --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Python/opt/gen/rewrite-inca-fun.h.gen Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,387 @@ +/* + * This files was auto-generated on 2012-04-25T16:14:56.764693, please don't change! + * Project-Id: contrib-3.3 + * Years: 2010, 2011, 2012 + */ + +#include "opcode.h" +#include "pystate.h" +#include "frameobject.h" + +#define REWRITE_OPCODE(ID) *INSTR_PTR()= ID; return ID; + +#define INSTR_PTR() instr_ptr + +#ifndef USE_OPT_SBR + +#define PyEval_RewriteInstr(DONTCARE) ; + +#define PyEval_SetCurInstr(DONTCARE1, DONTCARE2) ; + +#endif + +#define CMP_TYPE() void* + +typedef int opcode_t; + +static inline opcode_t +PyEval_RewriteInstr(CMP_TYPE() selector) { + PyThreadState *tstate= PyThreadState_GET(); + register PyFrameObject *f= tstate->frame; + + if (f != NULL + && f->f_code != NULL + ) + { + register unsigned char *INSTR_PTR()= (unsigned char*)PyBytes_AS_STRING(f->f_code->co_code) + f->f_lasti; + register opcode_t prev= (opcode_t)*INSTR_PTR(); + register int oparg= ((INSTR_PTR()[2]<<8) + INSTR_PTR()[1]); + + switch (prev) { + case BINARY_ADD: + if (0) /* simplify code generation */; + else if ((CMP_TYPE())PyComplex_Type.tp_as_number->nb_add == selector) { + REWRITE_OPCODE( INCA_COMPLEX_ADD ); + } + else if ((CMP_TYPE())PyFloat_Type.tp_as_number->nb_add == selector) { + REWRITE_OPCODE( INCA_FLOAT_ADD ); + } + else if ((CMP_TYPE())PyLong_Type.tp_as_number->nb_add == selector) { + REWRITE_OPCODE( INCA_LONG_ADD ); + } + break; + case BINARY_AND: + if (0) /* simplify code generation */; + else if ((CMP_TYPE())PyBool_Type.tp_as_number->nb_and == selector) { + REWRITE_OPCODE( INCA_BOOL_AND ); + } + else if ((CMP_TYPE())PyDictKeys_Type.tp_as_number->nb_and == selector) { + REWRITE_OPCODE( INCA_DICTKEYS_AND ); + } + else if ((CMP_TYPE())PyLong_Type.tp_as_number->nb_and == selector) { + REWRITE_OPCODE( INCA_LONG_AND ); + } + else if ((CMP_TYPE())PySet_Type.tp_as_number->nb_and == selector) { + REWRITE_OPCODE( INCA_SET_AND ); + } + break; + case BINARY_FLOOR_DIVIDE: + if (0) /* simplify code generation */; + else if ((CMP_TYPE())PyComplex_Type.tp_as_number->nb_floor_divide == selector) { + REWRITE_OPCODE( INCA_COMPLEX_FLOOR_DIVIDE ); + } + else if ((CMP_TYPE())PyFloat_Type.tp_as_number->nb_floor_divide == selector) { + REWRITE_OPCODE( INCA_FLOAT_FLOOR_DIVIDE ); + } + else if ((CMP_TYPE())PyLong_Type.tp_as_number->nb_floor_divide == selector) { + REWRITE_OPCODE( INCA_LONG_FLOOR_DIVIDE ); + } + break; + case BINARY_LSHIFT: + if (0) /* simplify code generation */; + else if ((CMP_TYPE())PyLong_Type.tp_as_number->nb_lshift == selector) { + REWRITE_OPCODE( INCA_LONG_LSHIFT ); + } + break; + case BINARY_MODULO: + if (0) /* simplify code generation */; + else if ((CMP_TYPE())PyComplex_Type.tp_as_number->nb_remainder == selector) { + REWRITE_OPCODE( INCA_COMPLEX_REMAINDER ); + } + else if ((CMP_TYPE())PyFloat_Type.tp_as_number->nb_remainder == selector) { + REWRITE_OPCODE( INCA_FLOAT_REMAINDER ); + } + else if ((CMP_TYPE())PyLong_Type.tp_as_number->nb_remainder == selector) { + REWRITE_OPCODE( INCA_LONG_REMAINDER ); + } + else if ((CMP_TYPE())PyUnicode_Type.tp_as_number->nb_remainder == selector) { + REWRITE_OPCODE( INCA_UNICODE_REMAINDER ); + } + break; + case BINARY_MULTIPLY: + if (0) /* simplify code generation */; + else if ((CMP_TYPE())PyComplex_Type.tp_as_number->nb_multiply == selector) { + REWRITE_OPCODE( INCA_COMPLEX_MULTIPLY ); + } + else if ((CMP_TYPE())PyFloat_Type.tp_as_number->nb_multiply == selector) { + REWRITE_OPCODE( INCA_FLOAT_MULTIPLY ); + } + else if ((CMP_TYPE())PyLong_Type.tp_as_number->nb_multiply == selector) { + REWRITE_OPCODE( INCA_LONG_MULTIPLY ); + } + break; + case BINARY_OR: + if (0) /* simplify code generation */; + else if ((CMP_TYPE())PyBool_Type.tp_as_number->nb_or == selector) { + REWRITE_OPCODE( INCA_BOOL_OR ); + } + else if ((CMP_TYPE())PyDictKeys_Type.tp_as_number->nb_or == selector) { + REWRITE_OPCODE( INCA_DICTKEYS_OR ); + } + else if ((CMP_TYPE())PyLong_Type.tp_as_number->nb_or == selector) { + REWRITE_OPCODE( INCA_LONG_OR ); + } + else if ((CMP_TYPE())PySet_Type.tp_as_number->nb_or == selector) { + REWRITE_OPCODE( INCA_SET_OR ); + } + break; + case BINARY_POWER: + if (0) /* simplify code generation */; + else if ((CMP_TYPE())PyComplex_Type.tp_as_number->nb_power == selector) { + REWRITE_OPCODE( INCA_COMPLEX_POWER ); + } + else if ((CMP_TYPE())PyFloat_Type.tp_as_number->nb_power == selector) { + REWRITE_OPCODE( INCA_FLOAT_POWER ); + } + else if ((CMP_TYPE())PyLong_Type.tp_as_number->nb_power == selector) { + REWRITE_OPCODE( INCA_LONG_POWER ); + } + break; + case BINARY_RSHIFT: + if (0) /* simplify code generation */; + else if ((CMP_TYPE())PyLong_Type.tp_as_number->nb_rshift == selector) { + REWRITE_OPCODE( INCA_LONG_RSHIFT ); + } + break; + case BINARY_SUBSCR: + if (0) /* simplify code generation */; + else if ((CMP_TYPE())PyByteArray_Type.tp_as_mapping->mp_subscript == selector) { + REWRITE_OPCODE( INCA_BYTEARRAY_SUBSCRIPT ); + } + else if ((CMP_TYPE())PyDict_Type.tp_as_mapping->mp_subscript == selector) { + REWRITE_OPCODE( INCA_DICT_SUBSCRIPT ); + } + else if ((CMP_TYPE())PyList_Type.tp_as_mapping->mp_subscript == selector) { + REWRITE_OPCODE( INCA_LIST_SUBSCRIPT ); + } + else if ((CMP_TYPE())PyTuple_Type.tp_as_mapping->mp_subscript == selector) { + REWRITE_OPCODE( INCA_TUPLE_SUBSCRIPT ); + } + else if ((CMP_TYPE())PyUnicode_Type.tp_as_mapping->mp_subscript == selector) { + REWRITE_OPCODE( INCA_UNICODE_SUBSCRIPT ); + } + break; + case BINARY_SUBTRACT: + if (0) /* simplify code generation */; + else if ((CMP_TYPE())PyComplex_Type.tp_as_number->nb_subtract == selector) { + REWRITE_OPCODE( INCA_COMPLEX_SUBTRACT ); + } + else if ((CMP_TYPE())PyDictKeys_Type.tp_as_number->nb_subtract == selector) { + REWRITE_OPCODE( INCA_DICTKEYS_SUBTRACT ); + } + else if ((CMP_TYPE())PyFloat_Type.tp_as_number->nb_subtract == selector) { + REWRITE_OPCODE( INCA_FLOAT_SUBTRACT ); + } + else if ((CMP_TYPE())PyLong_Type.tp_as_number->nb_subtract == selector) { + REWRITE_OPCODE( INCA_LONG_SUBTRACT ); + } + else if ((CMP_TYPE())PySet_Type.tp_as_number->nb_subtract == selector) { + REWRITE_OPCODE( INCA_SET_SUBTRACT ); + } + break; + case BINARY_TRUE_DIVIDE: + if (0) /* simplify code generation */; + else if ((CMP_TYPE())PyComplex_Type.tp_as_number->nb_true_divide == selector) { + REWRITE_OPCODE( INCA_COMPLEX_TRUE_DIVIDE ); + } + else if ((CMP_TYPE())PyFloat_Type.tp_as_number->nb_true_divide == selector) { + REWRITE_OPCODE( INCA_FLOAT_TRUE_DIVIDE ); + } + else if ((CMP_TYPE())PyLong_Type.tp_as_number->nb_true_divide == selector) { + REWRITE_OPCODE( INCA_LONG_TRUE_DIVIDE ); + } + break; + case BINARY_XOR: + if (0) /* simplify code generation */; + else if ((CMP_TYPE())PyBool_Type.tp_as_number->nb_xor == selector) { + REWRITE_OPCODE( INCA_BOOL_XOR ); + } + else if ((CMP_TYPE())PyDictKeys_Type.tp_as_number->nb_xor == selector) { + REWRITE_OPCODE( INCA_DICTKEYS_XOR ); + } + else if ((CMP_TYPE())PyLong_Type.tp_as_number->nb_xor == selector) { + REWRITE_OPCODE( INCA_LONG_XOR ); + } + else if ((CMP_TYPE())PySet_Type.tp_as_number->nb_xor == selector) { + REWRITE_OPCODE( INCA_SET_XOR ); + } + break; + case BUILD_SLICE: + if (0) /* simplify code generation */; + else if ((CMP_TYPE())&PySlice_New == selector) { + REWRITE_OPCODE( INCA_BUILD_SLICE_THREE ); + } + else if ((CMP_TYPE())&PySlice_New == selector) { + REWRITE_OPCODE( INCA_BUILD_SLICE_TWO ); + } + break; + case CALL_FUNCTION: + if (0) /* simplify code generation */; + break; + case COMPARE_OP: + /* 20110905/1640/sbr: + There is an error with comparing complex data structures that called + PyObject_RichCompare on elements stored within. This would inevitably + lead to an incorrect quickening and later on cause errors, if the + operand types actually *should* match once, we would call the inline + cached derivative, even though the oparg-semantics clearly indicate + that this is not what we want... + (Case in point: Lib/test/regrtest.py -> unittest/case#assertIn) + */ + if (oparg > Py_GE) + break; + if (0) /* simplify code generation */; + else if ((CMP_TYPE())PyByteArray_Type.tp_richcompare == selector) { + REWRITE_OPCODE( INCA_CMP_BYTEARRAY ); + } + else if ((CMP_TYPE())PyComplex_Type.tp_richcompare == selector) { + REWRITE_OPCODE( INCA_CMP_COMPLEX ); + } + else if ((CMP_TYPE())PyDict_Type.tp_richcompare == selector) { + REWRITE_OPCODE( INCA_CMP_DICT ); + } + else if ((CMP_TYPE())PyDictKeys_Type.tp_richcompare == selector) { + REWRITE_OPCODE( INCA_CMP_DICTKEYS ); + } + else if ((CMP_TYPE())PyFloat_Type.tp_richcompare == selector) { + REWRITE_OPCODE( INCA_CMP_FLOAT ); + } + else if ((CMP_TYPE())PyList_Type.tp_richcompare == selector) { + REWRITE_OPCODE( INCA_CMP_LIST ); + } + else if ((CMP_TYPE())PyLong_Type.tp_richcompare == selector) { + REWRITE_OPCODE( INCA_CMP_LONG ); + } + else if ((CMP_TYPE())PySet_Type.tp_richcompare == selector) { + REWRITE_OPCODE( INCA_CMP_SET ); + } + else if ((CMP_TYPE())PyTuple_Type.tp_richcompare == selector) { + REWRITE_OPCODE( INCA_CMP_TUPLE ); + } + else if ((CMP_TYPE())PyUnicode_Type.tp_richcompare == selector) { + REWRITE_OPCODE( INCA_CMP_UNICODE ); + } + break; + case FOR_ITER: + if (0) /* simplify code generation */; + else if ((CMP_TYPE())PyByteArrayIter_Type.tp_iternext == selector) { + REWRITE_OPCODE( FOR_ITER_BYTEARRAYITER ); + } + else if ((CMP_TYPE())PyBytesIter_Type.tp_iternext == selector) { + REWRITE_OPCODE( FOR_ITER_BYTESITER ); + } + else if ((CMP_TYPE())PyCallIter_Type.tp_iternext == selector) { + REWRITE_OPCODE( FOR_ITER_CALLITER ); + } + else if ((CMP_TYPE())PyEnum_Type.tp_iternext == selector) { + REWRITE_OPCODE( FOR_ITER_ENUM ); + } + else if ((CMP_TYPE())PyListIter_Type.tp_iternext == selector) { + REWRITE_OPCODE( FOR_ITER_LISTITER ); + } + else if ((CMP_TYPE())PyListRevIter_Type.tp_iternext == selector) { + REWRITE_OPCODE( FOR_ITER_LISTREVITER ); + } + else if ((CMP_TYPE())PyLongRangeIter_Type.tp_iternext == selector) { + REWRITE_OPCODE( FOR_ITER_LONGRANGEITER ); + } + else if ((CMP_TYPE())PyMap_Type.tp_iternext == selector) { + REWRITE_OPCODE( FOR_ITER_MAP ); + } + else if ((CMP_TYPE())PyRangeIter_Type.tp_iternext == selector) { + REWRITE_OPCODE( FOR_ITER_RANGEITER ); + } + else if ((CMP_TYPE())PyReversed_Type.tp_iternext == selector) { + REWRITE_OPCODE( FOR_ITER_REVERSED ); + } + else if ((CMP_TYPE())PySeqIter_Type.tp_iternext == selector) { + REWRITE_OPCODE( FOR_ITER_SEQITER ); + } + else if ((CMP_TYPE())PySetIter_Type.tp_iternext == selector) { + REWRITE_OPCODE( FOR_ITER_SETITER ); + } + else if ((CMP_TYPE())PyTupleIter_Type.tp_iternext == selector) { + REWRITE_OPCODE( FOR_ITER_TUPLEITER ); + } + else if ((CMP_TYPE())PyUnicodeIter_Type.tp_iternext == selector) { + REWRITE_OPCODE( FOR_ITER_UNICODEITER ); + } + else if ((CMP_TYPE())PyZip_Type.tp_iternext == selector) { + REWRITE_OPCODE( FOR_ITER_ZIP ); + } + break; + case STORE_SUBSCR: + if (0) /* simplify code generation */; + else if ((CMP_TYPE())PyByteArray_Type.tp_as_mapping->mp_ass_subscript == selector) { + REWRITE_OPCODE( INCA_BYTEARRAY_ASS_SUBSCRIPT ); + } + else if ((CMP_TYPE())PyDict_Type.tp_as_mapping->mp_ass_subscript == selector) { + REWRITE_OPCODE( INCA_DICT_ASS_SUBSCRIPT ); + } + else if ((CMP_TYPE())PyList_Type.tp_as_mapping->mp_ass_subscript == selector) { + REWRITE_OPCODE( INCA_LIST_ASS_SUBSCRIPT ); + } + break; + case UNARY_NEGATIVE: + if (0) /* simplify code generation */; + else if ((CMP_TYPE())PyComplex_Type.tp_as_number->nb_negative == selector) { + REWRITE_OPCODE( INCA_COMPLEX_NEGATIVE ); + } + else if ((CMP_TYPE())PyFloat_Type.tp_as_number->nb_negative == selector) { + REWRITE_OPCODE( INCA_FLOAT_NEGATIVE ); + } + else if ((CMP_TYPE())PyLong_Type.tp_as_number->nb_negative == selector) { + REWRITE_OPCODE( INCA_LONG_NEGATIVE ); + } + break; + case UNARY_POSITIVE: + if (0) /* simplify code generation */; + else if ((CMP_TYPE())PyComplex_Type.tp_as_number->nb_positive == selector) { + REWRITE_OPCODE( INCA_COMPLEX_POSITIVE ); + } + else if ((CMP_TYPE())PyFloat_Type.tp_as_number->nb_positive == selector) { + REWRITE_OPCODE( INCA_FLOAT_POSITIVE ); + } + else if ((CMP_TYPE())PyLong_Type.tp_as_number->nb_positive == selector) { + REWRITE_OPCODE( INCA_LONG_POSITIVE ); + } + break; + case UNPACK_SEQUENCE: + if (0) /* simplify code generation */; + break; + default: + return prev; + } // switch-case + + return prev; + } // if + + return -1; +} // END + + +static inline opcode_t +PyEval_SetCurInstr(const opcode_t new, const int oparg) { + PyThreadState *tstate= PyThreadState_GET(); + register PyFrameObject *f= tstate->frame; + +#ifndef USE_OPT_ENABLE_QUICKENING + return -1; +#endif + + if (f != NULL + && f->f_code != NULL + ) + { + register unsigned char *INSTR_PTR()= (unsigned char*)PyBytes_AS_STRING(f->f_code->co_code) + f->f_lasti; + register opcode_t prev= (opcode_t)*INSTR_PTR(); + + REWRITE_OPCODE( new ); + return new; + } // if + + return -1; +} // END PyEval_SetCurInstr + +#undef REWRITE_OPCODE +#undef RW_MASK diff -r 2f563908ebc5 -r be51373d99cf Python/opt/gen/threaded-code.h.gen --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Python/opt/gen/threaded-code.h.gen Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,522 @@ +/* + * This files was auto-generated on 2012-04-25T16:14:56.762714, please don't change! + * Project-Id: contrib-3.3 + * Years: 2010, 2011, 2012 + */ + +static void *opcode_targets[ 255 ]= { + &&_unknown_opcode , // 0 + &&TARGET_POP_TOP , // 1 + &&TARGET_ROT_TWO , // 2 + &&TARGET_ROT_THREE , // 3 + &&TARGET_DUP_TOP , // 4 + &&TARGET_DUP_TOP_TWO , // 5 + &&TARGET_INCA_ADD_STRINGS , // 6 + &&TARGET_INCA_UNPACK_TUPLE_TWO , // 7 + &&TARGET_INCA_BUILD_TUPLE_TWO , // 8 + &&_unknown_opcode , // 9 + &&TARGET_UNARY_POSITIVE , // 10 + &&TARGET_UNARY_NEGATIVE , // 11 + &&TARGET_UNARY_NOT , // 12 + &&TARGET_INCA_UNPACK_LIST_TWO , // 13 + &&TARGET_INCA_BUILD_LIST_TWO , // 14 + &&TARGET_UNARY_INVERT , // 15 + &&TARGET_INCA_UNPACK_TUPLE_THREE , // 16 + &&TARGET_INCA_BUILD_TUPLE_THREE , // 17 + &&TARGET_INCA_UNPACK_LIST_THREE , // 18 + &&TARGET_BINARY_POWER , // 19 + &&TARGET_BINARY_MULTIPLY , // 20 + &&TARGET_INCA_BUILD_LIST_THREE , // 21 + &&TARGET_BINARY_MODULO , // 22 + &&TARGET_BINARY_ADD , // 23 + &&TARGET_BINARY_SUBTRACT , // 24 + &&TARGET_BINARY_SUBSCR , // 25 + &&TARGET_BINARY_FLOOR_DIVIDE , // 26 + &&TARGET_BINARY_TRUE_DIVIDE , // 27 + &&TARGET_INPLACE_FLOOR_DIVIDE , // 28 + &&TARGET_INPLACE_TRUE_DIVIDE , // 29 + &&TARGET_INCA_BUILD_SLICE_TWO , // 30 + &&TARGET_INCA_BUILD_SLICE_THREE , // 31 + &&TARGET_INCA_CMP_FLOAT , // 32 + &&TARGET_INCA_FLOAT_TRUE_DIVIDE , // 33 + &&TARGET_INCA_FLOAT_SUBTRACT , // 34 + &&TARGET_INCA_FLOAT_POWER , // 35 + &&TARGET_INCA_FLOAT_POSITIVE , // 36 + &&TARGET_INCA_FLOAT_REMAINDER , // 37 + &&TARGET_INCA_FLOAT_NEGATIVE , // 38 + &&TARGET_INCA_FLOAT_ADD , // 39 + &&TARGET_INCA_FLOAT_MULTIPLY , // 40 + &&TARGET_INCA_FLOAT_FLOOR_DIVIDE , // 41 + &&TARGET_INCA_CMP_DICT , // 42 + &&TARGET_INCA_DICT_SUBSCRIPT , // 43 + &&TARGET_INCA_DICT_ASS_SUBSCRIPT , // 44 + &&TARGET_FOR_ITER_ENUM , // 45 + &&TARGET_INCA_CMP_TUPLE , // 46 + &&TARGET_INCA_TUPLE_SUBSCRIPT , // 47 + &&TARGET_INCA_BOOL_XOR , // 48 + &&TARGET_INCA_BOOL_AND , // 49 + &&TARGET_INCA_BOOL_OR , // 50 + &&TARGET_INCA_CMP_COMPLEX , // 51 + &&TARGET_INCA_COMPLEX_TRUE_DIVIDE , // 52 + &&TARGET_INCA_COMPLEX_SUBTRACT , // 53 + &&TARGET_STORE_MAP , // 54 + &&TARGET_INPLACE_ADD , // 55 + &&TARGET_INPLACE_SUBTRACT , // 56 + &&TARGET_INPLACE_MULTIPLY , // 57 + &&TARGET_INCA_COMPLEX_POWER , // 58 + &&TARGET_INPLACE_MODULO , // 59 + &&TARGET_STORE_SUBSCR , // 60 + &&TARGET_DELETE_SUBSCR , // 61 + &&TARGET_BINARY_LSHIFT , // 62 + &&TARGET_BINARY_RSHIFT , // 63 + &&TARGET_BINARY_AND , // 64 + &&TARGET_BINARY_XOR , // 65 + &&TARGET_BINARY_OR , // 66 + &&TARGET_INPLACE_POWER , // 67 + &&TARGET_GET_ITER , // 68 + &&TARGET_STORE_LOCALS , // 69 + &&TARGET_PRINT_EXPR , // 70 + &&TARGET_LOAD_BUILD_CLASS , // 71 + &&TARGET_YIELD_FROM , // 72 + &&TARGET_INCA_COMPLEX_POSITIVE , // 73 + &&TARGET_INCA_COMPLEX_REMAINDER , // 74 + &&TARGET_INPLACE_LSHIFT , // 75 + &&TARGET_INPLACE_RSHIFT , // 76 + &&TARGET_INPLACE_AND , // 77 + &&TARGET_INPLACE_XOR , // 78 + &&TARGET_INPLACE_OR , // 79 + &&TARGET_BREAK_LOOP , // 80 + &&TARGET_WITH_CLEANUP , // 81 + &&TARGET_INCA_COMPLEX_NEGATIVE , // 82 + &&TARGET_RETURN_VALUE , // 83 + &&TARGET_IMPORT_STAR , // 84 + &&TARGET_INCA_COMPLEX_ADD , // 85 + &&TARGET_YIELD_VALUE , // 86 + &&TARGET_POP_BLOCK , // 87 + &&TARGET_END_FINALLY , // 88 + &&TARGET_POP_EXCEPT , // 89 + &&TARGET_STORE_NAME , // 90 + &&TARGET_DELETE_NAME , // 91 + &&TARGET_UNPACK_SEQUENCE , // 92 + &&TARGET_FOR_ITER , // 93 + &&TARGET_UNPACK_EX , // 94 + &&TARGET_STORE_ATTR , // 95 + &&TARGET_DELETE_ATTR , // 96 + &&TARGET_STORE_GLOBAL , // 97 + &&TARGET_DELETE_GLOBAL , // 98 + &&TARGET_INCA_COMPLEX_MULTIPLY , // 99 + &&TARGET_LOAD_CONST , // 100 + &&TARGET_LOAD_NAME , // 101 + &&TARGET_BUILD_TUPLE , // 102 + &&TARGET_BUILD_LIST , // 103 + &&TARGET_BUILD_SET , // 104 + &&TARGET_BUILD_MAP , // 105 + &&TARGET_LOAD_ATTR , // 106 + &&TARGET_COMPARE_OP , // 107 + &&TARGET_IMPORT_NAME , // 108 + &&TARGET_IMPORT_FROM , // 109 + &&TARGET_JUMP_FORWARD , // 110 + &&TARGET_JUMP_IF_FALSE_OR_POP , // 111 + &&TARGET_JUMP_IF_TRUE_OR_POP , // 112 + &&TARGET_JUMP_ABSOLUTE , // 113 + &&TARGET_POP_JUMP_IF_FALSE , // 114 + &&TARGET_POP_JUMP_IF_TRUE , // 115 + &&TARGET_LOAD_GLOBAL , // 116 + &&TARGET_INCA_COMPLEX_FLOOR_DIVIDE , // 117 + &&TARGET_FOR_ITER_LONGRANGEITER , // 118 + &&TARGET_CONTINUE_LOOP , // 119 + &&TARGET_SETUP_LOOP , // 120 + &&TARGET_SETUP_EXCEPT , // 121 + &&TARGET_SETUP_FINALLY , // 122 + &&TARGET_INCA_CMP_LIST , // 123 + &&TARGET_LOAD_FAST , // 124 + &&TARGET_STORE_FAST , // 125 + &&TARGET_DELETE_FAST , // 126 + &&TARGET_INCA_LIST_SUBSCRIPT , // 127 + &&TARGET_INCA_LIST_ASS_SUBSCRIPT , // 128 + &&TARGET_INCA_CMP_BYTEARRAY , // 129 + &&TARGET_RAISE_VARARGS , // 130 + &&TARGET_CALL_FUNCTION , // 131 + &&TARGET_MAKE_FUNCTION , // 132 + &&TARGET_BUILD_SLICE , // 133 + &&TARGET_MAKE_CLOSURE , // 134 + &&TARGET_LOAD_CLOSURE , // 135 + &&TARGET_LOAD_DEREF , // 136 + &&TARGET_STORE_DEREF , // 137 + &&TARGET_DELETE_DEREF , // 138 + &&TARGET_INCA_BYTEARRAY_SUBSCRIPT , // 139 + &&TARGET_CALL_FUNCTION_VAR , // 140 + &&TARGET_CALL_FUNCTION_KW , // 141 + &&TARGET_CALL_FUNCTION_VAR_KW , // 142 + &&TARGET_SETUP_WITH , // 143 + &&TARGET_EXTENDED_ARG , // 144 + &&TARGET_LIST_APPEND , // 145 + &&TARGET_SET_ADD , // 146 + &&TARGET_MAP_ADD , // 147 + &&TARGET_INCA_BYTEARRAY_ASS_SUBSCRIPT , // 148 + &&TARGET_FOR_ITER_BYTESITER , // 149 + &&TARGET_INCA_CMP_UNICODE , // 150 + &&TARGET_INCA_UNICODE_SUBSCRIPT , // 151 + &&TARGET_INCA_UNICODE_REMAINDER , // 152 + &&TARGET_FOR_ITER_RANGEITER , // 153 + &&TARGET_INCA_CMP_LONG , // 154 + &&TARGET_INCA_LONG_TRUE_DIVIDE , // 155 + &&TARGET_INCA_LONG_RSHIFT , // 156 + &&TARGET_INCA_LONG_XOR , // 157 + &&TARGET_INCA_LONG_SUBTRACT , // 158 + &&TARGET_INCA_LONG_AND , // 159 + &&TARGET_INCA_LONG_POWER , // 160 + &&TARGET_INCA_LONG_POSITIVE , // 161 + &&TARGET_INCA_LONG_REMAINDER , // 162 + &&TARGET_INCA_LONG_NEGATIVE , // 163 + &&TARGET_INCA_LONG_ADD , // 164 + &&TARGET_INCA_LONG_MULTIPLY , // 165 + &&TARGET_INCA_LONG_FLOOR_DIVIDE , // 166 + &&TARGET_INCA_LONG_OR , // 167 + &&TARGET_INCA_LONG_LSHIFT , // 168 + &&TARGET_INCA_CMP_DICTKEYS , // 169 + &&TARGET_INCA_DICTKEYS_XOR , // 170 + &&TARGET_INCA_DICTKEYS_SUBTRACT , // 171 + &&TARGET_INCA_DICTKEYS_AND , // 172 + &&TARGET_INCA_DICTKEYS_OR , // 173 + &&TARGET_FOR_ITER_SEQITER , // 174 + &&TARGET_FOR_ITER_CALLITER , // 175 + &&TARGET_FOR_ITER_UNICODEITER , // 176 + &&TARGET_INCA_CMP_SET , // 177 + &&TARGET_INCA_SET_XOR , // 178 + &&TARGET_INCA_SET_SUBTRACT , // 179 + &&TARGET_INCA_SET_AND , // 180 + &&TARGET_INCA_SET_OR , // 181 + &&TARGET_FOR_ITER_REVERSED , // 182 + &&TARGET_FOR_ITER_SETITER , // 183 + &&TARGET_FOR_ITER_MAP , // 184 + &&TARGET_FOR_ITER_BYTEARRAYITER , // 185 + &&TARGET_FOR_ITER_LISTITER , // 186 + &&TARGET_FOR_ITER_ZIP , // 187 + &&TARGET_FOR_ITER_TUPLEITER , // 188 + &&TARGET_FOR_ITER_LISTREVITER , // 189 + &&TARGET_FAST_C_ZERO , // 190 + &&TARGET_FAST_C_ONE , // 191 + &&TARGET_FAST_CALL_GENERATOR_ONE , // 192 + &&TARGET_FAST_C_VARARGS_ZERO , // 193 + &&TARGET_FAST_C_VARARGS_ONE , // 194 + &&TARGET_FAST_C_VARARGS_TWO , // 195 + &&TARGET_FAST_C_VARARGS_THREE , // 196 + &&TARGET_FAST_PYFUN_DOCALL_ZERO , // 197 + &&TARGET_FAST_PYFUN_DOCALL_ONE , // 198 + &&TARGET_FAST_PYFUN_DOCALL_TWO , // 199 + &&TARGET_FAST_PYMETH_ZERO , // 200 + &&TARGET_FAST_PYMETH_ONE , // 201 + &&TARGET_FAST_PYMETH_TWO , // 202 + &&TARGET_FAST_PYMETH_THREE , // 203 + &&TARGET_FAST_PYFUN_ZERO , // 204 + &&TARGET_FAST_PYFUN_ONE , // 205 + &&TARGET_FAST_PYFUN_TWO , // 206 + &&_unknown_opcode , // 207 + &&_unknown_opcode , // 208 + &&_unknown_opcode , // 209 + &&_unknown_opcode , // 210 + &&_unknown_opcode , // 211 + &&_unknown_opcode , // 212 + &&_unknown_opcode , // 213 + &&_unknown_opcode , // 214 + &&_unknown_opcode , // 215 + &&_unknown_opcode , // 216 + &&_unknown_opcode , // 217 + &&_unknown_opcode , // 218 + &&_unknown_opcode , // 219 + &&_unknown_opcode , // 220 + &&_unknown_opcode , // 221 + &&_unknown_opcode , // 222 + &&_unknown_opcode , // 223 + &&_unknown_opcode , // 224 + &&_unknown_opcode , // 225 + &&_unknown_opcode , // 226 + &&_unknown_opcode , // 227 + &&_unknown_opcode , // 228 + &&_unknown_opcode , // 229 + &&_unknown_opcode , // 230 + &&_unknown_opcode , // 231 + &&_unknown_opcode , // 232 + &&_unknown_opcode , // 233 + &&_unknown_opcode , // 234 + &&_unknown_opcode , // 235 + &&_unknown_opcode , // 236 + &&_unknown_opcode , // 237 + &&_unknown_opcode , // 238 + &&_unknown_opcode , // 239 + &&_unknown_opcode , // 240 + &&_unknown_opcode , // 241 + &&_unknown_opcode , // 242 + &&_unknown_opcode , // 243 + &&_unknown_opcode , // 244 + &&_unknown_opcode , // 245 + &&_unknown_opcode , // 246 + &&_unknown_opcode , // 247 + &&_unknown_opcode , // 248 + &&_unknown_opcode , // 249 + &&_unknown_opcode , // 250 + &&_unknown_opcode , // 251 + &&_unknown_opcode , // 252 + &&_unknown_opcode , // 253 + &&_unknown_opcode , // 254 +}; + + +static void *opcode_no_dispatch_targets[ 255 ]= { + &&_unknown_opcode , // 0 + &&TARGET_POP_TOP_SKIP_DISPATCH, // 1 + &&TARGET_ROT_TWO_SKIP_DISPATCH, // 2 + &&TARGET_ROT_THREE_SKIP_DISPATCH, // 3 + &&TARGET_DUP_TOP_SKIP_DISPATCH, // 4 + &&TARGET_DUP_TOP_TWO_SKIP_DISPATCH, // 5 + &&TARGET_INCA_ADD_STRINGS_SKIP_DISPATCH, // 6 + &&TARGET_INCA_UNPACK_TUPLE_TWO_SKIP_DISPATCH, // 7 + &&TARGET_INCA_BUILD_TUPLE_TWO_SKIP_DISPATCH, // 8 + &&_unknown_opcode , // 9 + &&TARGET_UNARY_POSITIVE_SKIP_DISPATCH, // 10 + &&TARGET_UNARY_NEGATIVE_SKIP_DISPATCH, // 11 + &&TARGET_UNARY_NOT_SKIP_DISPATCH, // 12 + &&TARGET_INCA_UNPACK_LIST_TWO_SKIP_DISPATCH, // 13 + &&TARGET_INCA_BUILD_LIST_TWO_SKIP_DISPATCH, // 14 + &&TARGET_UNARY_INVERT_SKIP_DISPATCH, // 15 + &&TARGET_INCA_UNPACK_TUPLE_THREE_SKIP_DISPATCH, // 16 + &&TARGET_INCA_BUILD_TUPLE_THREE_SKIP_DISPATCH, // 17 + &&TARGET_INCA_UNPACK_LIST_THREE_SKIP_DISPATCH, // 18 + &&TARGET_BINARY_POWER_SKIP_DISPATCH, // 19 + &&TARGET_BINARY_MULTIPLY_SKIP_DISPATCH, // 20 + &&TARGET_INCA_BUILD_LIST_THREE_SKIP_DISPATCH, // 21 + &&TARGET_BINARY_MODULO_SKIP_DISPATCH, // 22 + &&TARGET_BINARY_ADD_SKIP_DISPATCH, // 23 + &&TARGET_BINARY_SUBTRACT_SKIP_DISPATCH, // 24 + &&TARGET_BINARY_SUBSCR_SKIP_DISPATCH, // 25 + &&TARGET_BINARY_FLOOR_DIVIDE_SKIP_DISPATCH, // 26 + &&TARGET_BINARY_TRUE_DIVIDE_SKIP_DISPATCH, // 27 + &&TARGET_INPLACE_FLOOR_DIVIDE_SKIP_DISPATCH, // 28 + &&TARGET_INPLACE_TRUE_DIVIDE_SKIP_DISPATCH, // 29 + &&TARGET_INCA_BUILD_SLICE_TWO_SKIP_DISPATCH, // 30 + &&TARGET_INCA_BUILD_SLICE_THREE_SKIP_DISPATCH, // 31 + &&TARGET_INCA_CMP_FLOAT_SKIP_DISPATCH, // 32 + &&TARGET_INCA_FLOAT_TRUE_DIVIDE_SKIP_DISPATCH, // 33 + &&TARGET_INCA_FLOAT_SUBTRACT_SKIP_DISPATCH, // 34 + &&TARGET_INCA_FLOAT_POWER_SKIP_DISPATCH, // 35 + &&TARGET_INCA_FLOAT_POSITIVE_SKIP_DISPATCH, // 36 + &&TARGET_INCA_FLOAT_REMAINDER_SKIP_DISPATCH, // 37 + &&TARGET_INCA_FLOAT_NEGATIVE_SKIP_DISPATCH, // 38 + &&TARGET_INCA_FLOAT_ADD_SKIP_DISPATCH, // 39 + &&TARGET_INCA_FLOAT_MULTIPLY_SKIP_DISPATCH, // 40 + &&TARGET_INCA_FLOAT_FLOOR_DIVIDE_SKIP_DISPATCH, // 41 + &&TARGET_INCA_CMP_DICT_SKIP_DISPATCH, // 42 + &&TARGET_INCA_DICT_SUBSCRIPT_SKIP_DISPATCH, // 43 + &&TARGET_INCA_DICT_ASS_SUBSCRIPT_SKIP_DISPATCH, // 44 + &&TARGET_FOR_ITER_ENUM_SKIP_DISPATCH, // 45 + &&TARGET_INCA_CMP_TUPLE_SKIP_DISPATCH, // 46 + &&TARGET_INCA_TUPLE_SUBSCRIPT_SKIP_DISPATCH, // 47 + &&TARGET_INCA_BOOL_XOR_SKIP_DISPATCH, // 48 + &&TARGET_INCA_BOOL_AND_SKIP_DISPATCH, // 49 + &&TARGET_INCA_BOOL_OR_SKIP_DISPATCH, // 50 + &&TARGET_INCA_CMP_COMPLEX_SKIP_DISPATCH, // 51 + &&TARGET_INCA_COMPLEX_TRUE_DIVIDE_SKIP_DISPATCH, // 52 + &&TARGET_INCA_COMPLEX_SUBTRACT_SKIP_DISPATCH, // 53 + &&TARGET_STORE_MAP_SKIP_DISPATCH, // 54 + &&TARGET_INPLACE_ADD_SKIP_DISPATCH, // 55 + &&TARGET_INPLACE_SUBTRACT_SKIP_DISPATCH, // 56 + &&TARGET_INPLACE_MULTIPLY_SKIP_DISPATCH, // 57 + &&TARGET_INCA_COMPLEX_POWER_SKIP_DISPATCH, // 58 + &&TARGET_INPLACE_MODULO_SKIP_DISPATCH, // 59 + &&TARGET_STORE_SUBSCR_SKIP_DISPATCH, // 60 + &&TARGET_DELETE_SUBSCR_SKIP_DISPATCH, // 61 + &&TARGET_BINARY_LSHIFT_SKIP_DISPATCH, // 62 + &&TARGET_BINARY_RSHIFT_SKIP_DISPATCH, // 63 + &&TARGET_BINARY_AND_SKIP_DISPATCH, // 64 + &&TARGET_BINARY_XOR_SKIP_DISPATCH, // 65 + &&TARGET_BINARY_OR_SKIP_DISPATCH, // 66 + &&TARGET_INPLACE_POWER_SKIP_DISPATCH, // 67 + &&TARGET_GET_ITER_SKIP_DISPATCH, // 68 + &&TARGET_STORE_LOCALS_SKIP_DISPATCH, // 69 + &&TARGET_PRINT_EXPR_SKIP_DISPATCH, // 70 + &&TARGET_LOAD_BUILD_CLASS_SKIP_DISPATCH, // 71 + &&TARGET_YIELD_FROM_SKIP_DISPATCH, // 72 + &&TARGET_INCA_COMPLEX_POSITIVE_SKIP_DISPATCH, // 73 + &&TARGET_INCA_COMPLEX_REMAINDER_SKIP_DISPATCH, // 74 + &&TARGET_INPLACE_LSHIFT_SKIP_DISPATCH, // 75 + &&TARGET_INPLACE_RSHIFT_SKIP_DISPATCH, // 76 + &&TARGET_INPLACE_AND_SKIP_DISPATCH, // 77 + &&TARGET_INPLACE_XOR_SKIP_DISPATCH, // 78 + &&TARGET_INPLACE_OR_SKIP_DISPATCH, // 79 + &&TARGET_BREAK_LOOP_SKIP_DISPATCH, // 80 + &&TARGET_WITH_CLEANUP_SKIP_DISPATCH, // 81 + &&TARGET_INCA_COMPLEX_NEGATIVE_SKIP_DISPATCH, // 82 + &&TARGET_RETURN_VALUE_SKIP_DISPATCH, // 83 + &&TARGET_IMPORT_STAR_SKIP_DISPATCH, // 84 + &&TARGET_INCA_COMPLEX_ADD_SKIP_DISPATCH, // 85 + &&TARGET_YIELD_VALUE_SKIP_DISPATCH, // 86 + &&TARGET_POP_BLOCK_SKIP_DISPATCH, // 87 + &&TARGET_END_FINALLY_SKIP_DISPATCH, // 88 + &&TARGET_POP_EXCEPT_SKIP_DISPATCH, // 89 + &&TARGET_STORE_NAME_SKIP_DISPATCH, // 90 + &&TARGET_DELETE_NAME_SKIP_DISPATCH, // 91 + &&TARGET_UNPACK_SEQUENCE_SKIP_DISPATCH, // 92 + &&TARGET_FOR_ITER_SKIP_DISPATCH, // 93 + &&TARGET_UNPACK_EX_SKIP_DISPATCH, // 94 + &&TARGET_STORE_ATTR_SKIP_DISPATCH, // 95 + &&TARGET_DELETE_ATTR_SKIP_DISPATCH, // 96 + &&TARGET_STORE_GLOBAL_SKIP_DISPATCH, // 97 + &&TARGET_DELETE_GLOBAL_SKIP_DISPATCH, // 98 + &&TARGET_INCA_COMPLEX_MULTIPLY_SKIP_DISPATCH, // 99 + &&TARGET_LOAD_CONST_SKIP_DISPATCH, // 100 + &&TARGET_LOAD_NAME_SKIP_DISPATCH, // 101 + &&TARGET_BUILD_TUPLE_SKIP_DISPATCH, // 102 + &&TARGET_BUILD_LIST_SKIP_DISPATCH, // 103 + &&TARGET_BUILD_SET_SKIP_DISPATCH, // 104 + &&TARGET_BUILD_MAP_SKIP_DISPATCH, // 105 + &&TARGET_LOAD_ATTR_SKIP_DISPATCH, // 106 + &&TARGET_COMPARE_OP_SKIP_DISPATCH, // 107 + &&TARGET_IMPORT_NAME_SKIP_DISPATCH, // 108 + &&TARGET_IMPORT_FROM_SKIP_DISPATCH, // 109 + &&TARGET_JUMP_FORWARD_SKIP_DISPATCH, // 110 + &&TARGET_JUMP_IF_FALSE_OR_POP_SKIP_DISPATCH, // 111 + &&TARGET_JUMP_IF_TRUE_OR_POP_SKIP_DISPATCH, // 112 + &&TARGET_JUMP_ABSOLUTE_SKIP_DISPATCH, // 113 + &&TARGET_POP_JUMP_IF_FALSE_SKIP_DISPATCH, // 114 + &&TARGET_POP_JUMP_IF_TRUE_SKIP_DISPATCH, // 115 + &&TARGET_LOAD_GLOBAL_SKIP_DISPATCH, // 116 + &&TARGET_INCA_COMPLEX_FLOOR_DIVIDE_SKIP_DISPATCH, // 117 + &&TARGET_FOR_ITER_LONGRANGEITER_SKIP_DISPATCH, // 118 + &&TARGET_CONTINUE_LOOP_SKIP_DISPATCH, // 119 + &&TARGET_SETUP_LOOP_SKIP_DISPATCH, // 120 + &&TARGET_SETUP_EXCEPT_SKIP_DISPATCH, // 121 + &&TARGET_SETUP_FINALLY_SKIP_DISPATCH, // 122 + &&TARGET_INCA_CMP_LIST_SKIP_DISPATCH, // 123 + &&TARGET_LOAD_FAST_SKIP_DISPATCH, // 124 + &&TARGET_STORE_FAST_SKIP_DISPATCH, // 125 + &&TARGET_DELETE_FAST_SKIP_DISPATCH, // 126 + &&TARGET_INCA_LIST_SUBSCRIPT_SKIP_DISPATCH, // 127 + &&TARGET_INCA_LIST_ASS_SUBSCRIPT_SKIP_DISPATCH, // 128 + &&TARGET_INCA_CMP_BYTEARRAY_SKIP_DISPATCH, // 129 + &&TARGET_RAISE_VARARGS_SKIP_DISPATCH, // 130 + &&TARGET_CALL_FUNCTION_SKIP_DISPATCH, // 131 + &&TARGET_MAKE_FUNCTION_SKIP_DISPATCH, // 132 + &&TARGET_BUILD_SLICE_SKIP_DISPATCH, // 133 + &&TARGET_MAKE_CLOSURE_SKIP_DISPATCH, // 134 + &&TARGET_LOAD_CLOSURE_SKIP_DISPATCH, // 135 + &&TARGET_LOAD_DEREF_SKIP_DISPATCH, // 136 + &&TARGET_STORE_DEREF_SKIP_DISPATCH, // 137 + &&TARGET_DELETE_DEREF_SKIP_DISPATCH, // 138 + &&TARGET_INCA_BYTEARRAY_SUBSCRIPT_SKIP_DISPATCH, // 139 + &&TARGET_CALL_FUNCTION_VAR_SKIP_DISPATCH, // 140 + &&TARGET_CALL_FUNCTION_KW_SKIP_DISPATCH, // 141 + &&TARGET_CALL_FUNCTION_VAR_KW_SKIP_DISPATCH, // 142 + &&TARGET_SETUP_WITH_SKIP_DISPATCH, // 143 + &&TARGET_EXTENDED_ARG_SKIP_DISPATCH, // 144 + &&TARGET_LIST_APPEND_SKIP_DISPATCH, // 145 + &&TARGET_SET_ADD_SKIP_DISPATCH, // 146 + &&TARGET_MAP_ADD_SKIP_DISPATCH, // 147 + &&TARGET_INCA_BYTEARRAY_ASS_SUBSCRIPT_SKIP_DISPATCH, // 148 + &&TARGET_FOR_ITER_BYTESITER_SKIP_DISPATCH, // 149 + &&TARGET_INCA_CMP_UNICODE_SKIP_DISPATCH, // 150 + &&TARGET_INCA_UNICODE_SUBSCRIPT_SKIP_DISPATCH, // 151 + &&TARGET_INCA_UNICODE_REMAINDER_SKIP_DISPATCH, // 152 + &&TARGET_FOR_ITER_RANGEITER_SKIP_DISPATCH, // 153 + &&TARGET_INCA_CMP_LONG_SKIP_DISPATCH, // 154 + &&TARGET_INCA_LONG_TRUE_DIVIDE_SKIP_DISPATCH, // 155 + &&TARGET_INCA_LONG_RSHIFT_SKIP_DISPATCH, // 156 + &&TARGET_INCA_LONG_XOR_SKIP_DISPATCH, // 157 + &&TARGET_INCA_LONG_SUBTRACT_SKIP_DISPATCH, // 158 + &&TARGET_INCA_LONG_AND_SKIP_DISPATCH, // 159 + &&TARGET_INCA_LONG_POWER_SKIP_DISPATCH, // 160 + &&TARGET_INCA_LONG_POSITIVE_SKIP_DISPATCH, // 161 + &&TARGET_INCA_LONG_REMAINDER_SKIP_DISPATCH, // 162 + &&TARGET_INCA_LONG_NEGATIVE_SKIP_DISPATCH, // 163 + &&TARGET_INCA_LONG_ADD_SKIP_DISPATCH, // 164 + &&TARGET_INCA_LONG_MULTIPLY_SKIP_DISPATCH, // 165 + &&TARGET_INCA_LONG_FLOOR_DIVIDE_SKIP_DISPATCH, // 166 + &&TARGET_INCA_LONG_OR_SKIP_DISPATCH, // 167 + &&TARGET_INCA_LONG_LSHIFT_SKIP_DISPATCH, // 168 + &&TARGET_INCA_CMP_DICTKEYS_SKIP_DISPATCH, // 169 + &&TARGET_INCA_DICTKEYS_XOR_SKIP_DISPATCH, // 170 + &&TARGET_INCA_DICTKEYS_SUBTRACT_SKIP_DISPATCH, // 171 + &&TARGET_INCA_DICTKEYS_AND_SKIP_DISPATCH, // 172 + &&TARGET_INCA_DICTKEYS_OR_SKIP_DISPATCH, // 173 + &&TARGET_FOR_ITER_SEQITER_SKIP_DISPATCH, // 174 + &&TARGET_FOR_ITER_CALLITER_SKIP_DISPATCH, // 175 + &&TARGET_FOR_ITER_UNICODEITER_SKIP_DISPATCH, // 176 + &&TARGET_INCA_CMP_SET_SKIP_DISPATCH, // 177 + &&TARGET_INCA_SET_XOR_SKIP_DISPATCH, // 178 + &&TARGET_INCA_SET_SUBTRACT_SKIP_DISPATCH, // 179 + &&TARGET_INCA_SET_AND_SKIP_DISPATCH, // 180 + &&TARGET_INCA_SET_OR_SKIP_DISPATCH, // 181 + &&TARGET_FOR_ITER_REVERSED_SKIP_DISPATCH, // 182 + &&TARGET_FOR_ITER_SETITER_SKIP_DISPATCH, // 183 + &&TARGET_FOR_ITER_MAP_SKIP_DISPATCH, // 184 + &&TARGET_FOR_ITER_BYTEARRAYITER_SKIP_DISPATCH, // 185 + &&TARGET_FOR_ITER_LISTITER_SKIP_DISPATCH, // 186 + &&TARGET_FOR_ITER_ZIP_SKIP_DISPATCH, // 187 + &&TARGET_FOR_ITER_TUPLEITER_SKIP_DISPATCH, // 188 + &&TARGET_FOR_ITER_LISTREVITER_SKIP_DISPATCH, // 189 + &&TARGET_FAST_C_ZERO_SKIP_DISPATCH, // 190 + &&TARGET_FAST_C_ONE_SKIP_DISPATCH, // 191 + &&TARGET_FAST_CALL_GENERATOR_ONE_SKIP_DISPATCH, // 192 + &&TARGET_FAST_C_VARARGS_ZERO_SKIP_DISPATCH, // 193 + &&TARGET_FAST_C_VARARGS_ONE_SKIP_DISPATCH, // 194 + &&TARGET_FAST_C_VARARGS_TWO_SKIP_DISPATCH, // 195 + &&TARGET_FAST_C_VARARGS_THREE_SKIP_DISPATCH, // 196 + &&TARGET_FAST_PYFUN_DOCALL_ZERO_SKIP_DISPATCH, // 197 + &&TARGET_FAST_PYFUN_DOCALL_ONE_SKIP_DISPATCH, // 198 + &&TARGET_FAST_PYFUN_DOCALL_TWO_SKIP_DISPATCH, // 199 + &&TARGET_FAST_PYMETH_ZERO_SKIP_DISPATCH, // 200 + &&TARGET_FAST_PYMETH_ONE_SKIP_DISPATCH, // 201 + &&TARGET_FAST_PYMETH_TWO_SKIP_DISPATCH, // 202 + &&TARGET_FAST_PYMETH_THREE_SKIP_DISPATCH, // 203 + &&TARGET_FAST_PYFUN_ZERO_SKIP_DISPATCH, // 204 + &&TARGET_FAST_PYFUN_ONE_SKIP_DISPATCH, // 205 + &&TARGET_FAST_PYFUN_TWO_SKIP_DISPATCH, // 206 + &&_unknown_opcode , // 207 + &&_unknown_opcode , // 208 + &&_unknown_opcode , // 209 + &&_unknown_opcode , // 210 + &&_unknown_opcode , // 211 + &&_unknown_opcode , // 212 + &&_unknown_opcode , // 213 + &&_unknown_opcode , // 214 + &&_unknown_opcode , // 215 + &&_unknown_opcode , // 216 + &&_unknown_opcode , // 217 + &&_unknown_opcode , // 218 + &&_unknown_opcode , // 219 + &&_unknown_opcode , // 220 + &&_unknown_opcode , // 221 + &&_unknown_opcode , // 222 + &&_unknown_opcode , // 223 + &&_unknown_opcode , // 224 + &&_unknown_opcode , // 225 + &&_unknown_opcode , // 226 + &&_unknown_opcode , // 227 + &&_unknown_opcode , // 228 + &&_unknown_opcode , // 229 + &&_unknown_opcode , // 230 + &&_unknown_opcode , // 231 + &&_unknown_opcode , // 232 + &&_unknown_opcode , // 233 + &&_unknown_opcode , // 234 + &&_unknown_opcode , // 235 + &&_unknown_opcode , // 236 + &&_unknown_opcode , // 237 + &&_unknown_opcode , // 238 + &&_unknown_opcode , // 239 + &&_unknown_opcode , // 240 + &&_unknown_opcode , // 241 + &&_unknown_opcode , // 242 + &&_unknown_opcode , // 243 + &&_unknown_opcode , // 244 + &&_unknown_opcode , // 245 + &&_unknown_opcode , // 246 + &&_unknown_opcode , // 247 + &&_unknown_opcode , // 248 + &&_unknown_opcode , // 249 + &&_unknown_opcode , // 250 + &&_unknown_opcode , // 251 + &&_unknown_opcode , // 252 + &&_unknown_opcode , // 253 + &&_unknown_opcode , // 254 +}; diff -r 2f563908ebc5 -r be51373d99cf Python/opt/interpreter-macro-defs.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Python/opt/interpreter-macro-defs.h Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,13 @@ +/* 20111209/1611/sbr: definitions of necessary macros... */ + +#define Py_CUSTOM_DECREF(op,TYPE,FUNC) \ + do { \ + if ((op) != NULL && --((PyObject*)(op))->ob_refcnt == 0) \ + FUNC((TYPE*)(op)); \ + } while (0) + +#define PyFrame_GetCode(OP) (OP->f_code) + +#define GET_OBJARR_ELEM(ident,index) (((PyObject**)ident)[index]) + + diff -r 2f563908ebc5 -r be51373d99cf Python/opt/interpreter-macro-redefinitions.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Python/opt/interpreter-macro-redefinitions.h Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,56 @@ +/* 20111209/1615/sbr: + macro redefinitions necessary to make InCa work; the following changes are necessary: + - add the _SKIP_DISPATCH postfix, which is necessary because cgen generates goto-statements + for inline cache misses + - add the explicit instruction argument decoding stuff, which is necessary because the derivatives + don't use the HAVE_ARGUMENT stuff in order to get dense packing of instructions into the pre-existing + instruction set + */ + + +#undef TARGET +#undef TARGET_WITH_IMPL + + +#define TARGET(op) \ + TARGET_##op: \ + opcode = op; \ + if (HAS_ARG(op)) \ + oparg = NEXTARG(); \ + /*case op:*/ \ +TARGET_##op##_SKIP_DISPATCH: \ + + +/* 20111209/1619/sbr: explicit oparg decoding based in derivative implementation; + properly generated by cgen... */ + +#define OPT_TARGET_DECODE_NOARG(op) \ + TARGET_##op: \ + opcode = op; \ + /* case op: */ \ +TARGET_##op##_SKIP_DISPATCH: \ + + +#define OPT_TARGET_DECODE_ARG(op) \ + TARGET_##op: \ + opcode = op; \ + oparg = NEXTARG(); \ + /*case op:*/ \ +TARGET_##op##_SKIP_DISPATCH: \ + + +#define TARGET_WITH_IMPL(op, impl) \ + TARGET_##op: \ + opcode = op; \ + if (HAS_ARG(op)) \ + oparg = NEXTARG(); \ + /*case op: */ \ +TARGET_##op##_SKIP_DISPATCH: \ + goto impl; \ + + +#define INLINE_CACHE_MISS(Left, Right, ExpectedType) \ + !(((unsigned long)Left->ob_type == (unsigned long)&ExpectedType) && ((unsigned long)Right->ob_type == (unsigned long)&ExpectedType)) + +#define INLINE_CACHE_MISS_UNARY(Object, ExpectedType) \ + ((unsigned long)Object->ob_type ^ (unsigned long)&ExpectedType) diff -r 2f563908ebc5 -r be51373d99cf Python/opt/signature-defines.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Python/opt/signature-defines.h Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,5 @@ + + +static inline PyObject* quickening_call_function(PyObject ***, int); +static inline PyObject* nonquickening_call_function(PyObject ***, int); + diff -r 2f563908ebc5 -r be51373d99cf Python/opt/undef-macros.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Python/opt/undef-macros.h Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,49 @@ +/* 20100419/1711/sbr: the following list represent all macros defined in the + ceval.c main interpreter dispatch loop; they are all undefined here so as + to allow the *_SysDefault routine to properly redefine all of its macros + immaculately... + */ + +#undef TARGET_WITH_IMPL +#undef TARGET +#undef DISPATCH +#undef FAST_DISPATCH +#undef DISPATCH +#undef GETITEM + +#undef INSTR_OFFSET +#undef NEXTOP +#undef NEXTARG +#undef PEEKARG +#undef JUMPTO +#undef JUMPBY + +#undef PREDICT +#undef PREDICTED +#undef PREDICTED_WITH_ARG + + +#undef STACK_LEVEL +#undef EMPTY +#undef TOP +#undef SECOND +#undef THIRD +#undef FOURTH +#undef PEEK +#undef SET_TOP +#undef SET_SECOND +#undef SET_THIRD +#undef SET_FOURTH +#undef SET_VALUE +#undef BASIC_STACKADJ +#undef BASIC_PUSH +#undef BASIC_POP +#undef PUSH +#undef POP +#undef STACKADJ +#undef EXT_POP +#undef GETLOCAL +#undef SETLOCAL + +#undef UNWIND_BLOCK +#undef UNWIND_EXCEPT_HANDLER diff -r 2f563908ebc5 -r be51373d99cf cgen/Lib/opcode.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/Lib/opcode.py Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,180 @@ + +""" +opcode module - potentially shared between dis and other modules which +operate on bytecodes (e.g. peephole optimizers). +""" + +__all__ = ["cmp_op", "hasconst", "hasname", "hasjrel", "hasjabs", + "haslocal", "hascompare", "hasfree", "opname", "opmap", + "HAVE_ARGUMENT", "EXTENDED_ARG"] + +cmp_op = ('<', '<=', '==', '!=', '>', '>=', 'in', 'not in', 'is', + 'is not', 'exception match', 'BAD') + +hasconst = [] +hasname = [] +hasjrel = [] +hasjabs = [] +haslocal = [] +hascompare = [] +hasfree = [] + +opmap = {} +opname = [''] * 256 +for op in range(256): opname[op] = '<%r>' % (op,) +del op + +def def_op(name, op): + opname[op] = name + opmap[name] = op + +def name_op(name, op): + def_op(name, op) + hasname.append(op) + +def jrel_op(name, op): + def_op(name, op) + hasjrel.append(op) + +def jabs_op(name, op): + def_op(name, op) + hasjabs.append(op) + +# Instruction opcodes for compiled code +# Blank lines correspond to available opcodes + +def_op('POP_TOP', 1) +def_op('ROT_TWO', 2) +def_op('ROT_THREE', 3) +def_op('DUP_TOP', 4) +def_op('DUP_TOP_TWO', 5) + +def_op('NOP', 9) +def_op('UNARY_POSITIVE', 10) +def_op('UNARY_NEGATIVE', 11) +def_op('UNARY_NOT', 12) + +def_op('UNARY_INVERT', 15) + +def_op('BINARY_POWER', 19) +def_op('BINARY_MULTIPLY', 20) + +def_op('BINARY_MODULO', 22) +def_op('BINARY_ADD', 23) +def_op('BINARY_SUBTRACT', 24) +def_op('BINARY_SUBSCR', 25) +def_op('BINARY_FLOOR_DIVIDE', 26) +def_op('BINARY_TRUE_DIVIDE', 27) +def_op('INPLACE_FLOOR_DIVIDE', 28) +def_op('INPLACE_TRUE_DIVIDE', 29) + +def_op('STORE_MAP', 54) +def_op('INPLACE_ADD', 55) +def_op('INPLACE_SUBTRACT', 56) +def_op('INPLACE_MULTIPLY', 57) + +def_op('INPLACE_MODULO', 59) +def_op('STORE_SUBSCR', 60) +def_op('DELETE_SUBSCR', 61) +def_op('BINARY_LSHIFT', 62) +def_op('BINARY_RSHIFT', 63) +def_op('BINARY_AND', 64) +def_op('BINARY_XOR', 65) +def_op('BINARY_OR', 66) +def_op('INPLACE_POWER', 67) +def_op('GET_ITER', 68) +def_op('STORE_LOCALS', 69) + +def_op('PRINT_EXPR', 70) +def_op('LOAD_BUILD_CLASS', 71) +def_op('YIELD_FROM', 72) + +def_op('INPLACE_LSHIFT', 75) +def_op('INPLACE_RSHIFT', 76) +def_op('INPLACE_AND', 77) +def_op('INPLACE_XOR', 78) +def_op('INPLACE_OR', 79) +def_op('BREAK_LOOP', 80) +def_op('WITH_CLEANUP', 81) + +def_op('RETURN_VALUE', 83) +def_op('IMPORT_STAR', 84) + +def_op('YIELD_VALUE', 86) +def_op('POP_BLOCK', 87) +def_op('END_FINALLY', 88) +def_op('POP_EXCEPT', 89) + +HAVE_ARGUMENT = 90 # Opcodes from here have an argument: + +name_op('STORE_NAME', 90) # Index in name list +name_op('DELETE_NAME', 91) # "" +def_op('UNPACK_SEQUENCE', 92) # Number of tuple items +jrel_op('FOR_ITER', 93) +def_op('UNPACK_EX', 94) +name_op('STORE_ATTR', 95) # Index in name list +name_op('DELETE_ATTR', 96) # "" +name_op('STORE_GLOBAL', 97) # "" +name_op('DELETE_GLOBAL', 98) # "" +def_op('LOAD_CONST', 100) # Index in const list +hasconst.append(100) +name_op('LOAD_NAME', 101) # Index in name list +def_op('BUILD_TUPLE', 102) # Number of tuple items +def_op('BUILD_LIST', 103) # Number of list items +def_op('BUILD_SET', 104) # Number of set items +def_op('BUILD_MAP', 105) # Number of dict entries (upto 255) +name_op('LOAD_ATTR', 106) # Index in name list +def_op('COMPARE_OP', 107) # Comparison operator +hascompare.append(107) +name_op('IMPORT_NAME', 108) # Index in name list +name_op('IMPORT_FROM', 109) # Index in name list + +jrel_op('JUMP_FORWARD', 110) # Number of bytes to skip +jabs_op('JUMP_IF_FALSE_OR_POP', 111) # Target byte offset from beginning of code +jabs_op('JUMP_IF_TRUE_OR_POP', 112) # "" +jabs_op('JUMP_ABSOLUTE', 113) # "" +jabs_op('POP_JUMP_IF_FALSE', 114) # "" +jabs_op('POP_JUMP_IF_TRUE', 115) # "" + +name_op('LOAD_GLOBAL', 116) # Index in name list + +jabs_op('CONTINUE_LOOP', 119) # Target address +jrel_op('SETUP_LOOP', 120) # Distance to target address +jrel_op('SETUP_EXCEPT', 121) # "" +jrel_op('SETUP_FINALLY', 122) # "" + +def_op('LOAD_FAST', 124) # Local variable number +haslocal.append(124) +def_op('STORE_FAST', 125) # Local variable number +haslocal.append(125) +def_op('DELETE_FAST', 126) # Local variable number +haslocal.append(126) + +def_op('RAISE_VARARGS', 130) # Number of raise arguments (1, 2, or 3) +def_op('CALL_FUNCTION', 131) # #args + (#kwargs << 8) +def_op('MAKE_FUNCTION', 132) # Number of args with default values +def_op('BUILD_SLICE', 133) # Number of items +def_op('MAKE_CLOSURE', 134) +def_op('LOAD_CLOSURE', 135) +hasfree.append(135) +def_op('LOAD_DEREF', 136) +hasfree.append(136) +def_op('STORE_DEREF', 137) +hasfree.append(137) +def_op('DELETE_DEREF', 138) +hasfree.append(138) + +def_op('CALL_FUNCTION_VAR', 140) # #args + (#kwargs << 8) +def_op('CALL_FUNCTION_KW', 141) # #args + (#kwargs << 8) +def_op('CALL_FUNCTION_VAR_KW', 142) # #args + (#kwargs << 8) + +jrel_op('SETUP_WITH', 143) + +def_op('LIST_APPEND', 145) +def_op('SET_ADD', 146) +def_op('MAP_ADD', 147) + +def_op('EXTENDED_ARG', 144) +EXTENDED_ARG = 144 + +del def_op, name_op, jrel_op, jabs_op diff -r 2f563908ebc5 -r be51373d99cf cgen/cgen.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/cgen.py Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,237 @@ +#!/usr/bin/env python +"""Generates the instruction implementation derivatives that are necessary to do +quickening based inline caching (INCA). Currently, the system relies on type +information generated by "gdb" and stored in typedefs.py. + +It uses the mako template system to generate C implementation files that reside in +Python/opt/gen. Some files in Python/opt are necessary to support using the system. +In contrast to the original research in interpreter optimization techniques, this +approach uses just *one* interpreter dispatch loop, i.e., it does not rely in profiling +information to figure out which parts to optimize. Consequently, all Python code uses +INCA. + +This file implements the driver routine "generate_files", which generates all files +based on the configuration modeled by the ContribConfig class. +""" +from mako.lookup import TemplateLookup +from mako.exceptions import TopLevelLookupException + +import instructions ## contains all instruction classes +import inca, incacalls ## contains all quickening-based inline caching classes +import os, re, sys + +from datetime import datetime + + +class ContribConfig(object): + + def __init__(self): + self.instr_set_size= 255 + self.write_files= True + self.with_default_instrs= True + self.prj_id = "contrib-3.3" + self.suffix = ".gen" + self.base_path = os.path.abspath(".") + self.cgen_path = os.path.join(self.base_path, "cgen") + self.target_path = os.path.join(self.base_path, "Python/opt/gen/") + self.template_paths= [ + os.path.join(self.cgen_path, "templates"), + os.path.join(self.cgen_path, "templates/default"), + os.path.join(self.cgen_path, "templates/inlined") + ] + + self.create_inca_guards= True + self.lookup= TemplateLookup(directories=self.template_paths) + + def get_template(self, name): + try: + return self.lookup.get_template(name) + except TopLevelLookupException as e: + pretty_path = ":".join(lookup.directories) + print >> sys.stderr, "Error: %s in path %s" % (e.message, pretty_path) + quit(1) + + def resources(self, instr_set): + return [ + { 'filename': 'opcode.h', + 'template': self.get_template('opcode-defs.h.impl'), + }, + { 'filename': 'debug-opcodes.h', + 'template': self.get_template('debug-opcodes.h.impl'), + }, + { 'filename': 'threaded-code.h', + 'template': self.get_template('instr-targets.h.impl'), + }, + { 'filename' : 'rewrite-inca-fun.h', + 'template' : self.get_template('rewrite-fun.h.impl'), + 'domain' : create_domain(instr_set), + 'perform_rewrite' : True, + 'generate_set_cur_instr' : True, + 'debug' : False, + }, + { 'filename': 'inca-instr-decoding.h', + 'template': self.get_template('inca-instr-decoding.h.impl'), + }, + { 'filename': 'instr-impl.h', + 'contents': collect_instr_impls(instr_set, self), + }, + ] + + +def write_file(config, name, contents): + if not config.write_files: + return + + filename= config.target_path + name + config.suffix + now= datetime.now() + padder= ' ' * len(now.isoformat()) + years= ', '.join( [str(y) for y in range(2010, datetime.now().year + 1)] ) + + copyright= config.get_template('copyright').render(years=years, now=now.isoformat(), project=config.prj_id) + + with open(filename, "w") as f: + f.write(copyright) + f.write(contents) + + + +def create_domain(instr_set): + """Whenever we need to create a rewrite-function, e.g., from a default instruction to a + derivative instruction (either inline caching, or reference count quickening), the corresponding + template needs a map from a domain to the corresponding range. This function implements exactly + this behavior, using the inheritance relationship. + + """ + domain= {} + for x in instr_set: + if isinstance(x, instructions.DerivativeInstr): + if x.parent not in domain: + domain[x.parent]= [] + + domain[ x.parent ].append(x) + return domain + + +def process_instr_decoding_macro_substitution(instr): + """Because we pack instructions densely, i.e., we don't leave instruction opcodes unassigned, + the regular instruction decoding with the HAVE_ARGUMENT check is not valid at all times + anymore. This function replaces the TARGET macro with the corresponding optimized instruction + decoding macro, if it actually uses it in the operation implementation. + + """ + pattern= re.compile('TARGET\(') + subst= 'OPT_TARGET_DECODE_NOARG(' + try: + if ('oparg' in instr.impl) or ('oparg' in instr.parent.impl) : + subst= 'OPT_TARGET_DECODE_ARG(' + + return pattern.sub(subst, instr.impl) + except AttributeError: + return instr.impl + + +def collect_instr_impls(instr_set, config): + """This function collects the operation implementation of all instructions in the interpreter, + so that we can write it into the corresponding file from one string. It also handles the macro + substitution for instruction decoding. + + """ + + def impl(i, filter= [ instructions.DefaultInstr ]): + if i and i.has_impl(): + if type(i) not in filter: + return process_instr_decoding_macro_substitution( i ) + return i.impl + return '' + + return '\n'.join([ impl(i) for i in instr_set ]) + + +def extract_instr_ids(instr_set): + """We do not manually assign instruction identifiers, but rather use conventions from the + templates, which in turn use data available depending on the kind of instructions. + + """ + pattern= re.compile('TARGET\s*\(\s*(\w+)\s*\)\s*') + + for i in instr_set: + if i.has_impl(): + match= pattern.search(i.impl) + if match: + i.id= match.group(1) + +def add_operation_implementations(config, instr_set): + """This function uses a multi-level template look-up hierarchy to construct the actual operation + implementation for all interpreter instructions. First, it tries to find inlined code examples + for IncaDerivative and IncaIteratorDerivative objects. Next, it tries to get a default + instruction implementation (DefaultInstr objects). Iff this fails, we construct the derivative + instruction by the class name of the instruction. + + """ + lookup= TemplateLookup(directories= config.template_paths ) + + for instr in instr_set.set: + if type(instr) != instructions.UnknownInstr: + ident= instr.id.lower() + inlined, template= '', None + if type(instr) in [inca.IncaDerivative, inca.IncaIteratorDerivative]: + try: + template= lookup.get_template(instr.type_id) + inlined= template.render(instr=instr) + if inlined: + print "Found inlined implementation for %s <%s>" % (instr.id, instr.type_id) + except TopLevelLookupException: + pass + + try: + template= lookup.get_template(ident) + except TopLevelLookupException: + try: + classname= type(instr).__name__ + template= lookup.get_template(classname) + except TopLevelLookupException: + pass + + if template: + impl= template.render(instr=instr, inlined=inlined, config=config) + instr.impl= impl + + +def generate_instr_set(config): + instr_set= instructions.InstructionSet( config.instr_set_size ) + print "Effective default size w/o derivatives: %d" % instr_set.effective_size() + + inca_extension= inca.InlineCaching() + inca_extension.create_master_data() + inca_extension.extend_instr_set( instr_set ) + print "Effective size after inca derivatives: %d" % instr_set.effective_size() + + call_extension= incacalls.InlineCachingCalls() + call_extension.extend_instr_set(instr_set) + print "Effective size after call derivatives: %d" % instr_set.effective_size() + + return instr_set + +def generate_files(config= ContribConfig()): + instr_set= generate_instr_set(config) + add_operation_implementations( config, instr_set ) + extract_instr_ids(instr_set) + instr_set.pack() + + for entry in config.resources(instr_set): + filename= entry['filename'] + contents= '' + if 'contents' in entry: + contents= entry['contents'] + elif 'template' in entry: + template= entry['template'] + contents= template.render(instr_set= instr_set, + **entry) + + write_file(config, filename, contents) + + return instr_set + + +if __name__ == "__main__": + generate_files() diff -r 2f563908ebc5 -r be51373d99cf cgen/inca.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/inca.py Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,221 @@ +"""The InlineCaching class creates all non-call instruction based instruction derivatives based on +data supplied by typedefs.py. We create this type definition file by dumping C data structures in +gdb. The InlineCaching class uses this mapping to find which classes implement which functions +(create_master_data.) Based on this information we add new instruction derivatives to the +instruction set (extend_instr_set.) +""" +import typedefs +from instructions import DerivativeInstr +from itertools import product + + +INCA_DERIVATIVE_PARENTS= { + "nb_negative" : "UNARY_NEGATIVE", + "nb_positive" : "UNARY_POSITIVE", + "nb_add" : "BINARY_ADD", + "nb_subtract" : "BINARY_SUBTRACT", + "nb_multiply" : "BINARY_MULTIPLY", + "nb_remainder" : "BINARY_MODULO", + "nb_lshift" : "BINARY_LSHIFT", + "nb_rshift" : "BINARY_RSHIFT", + "nb_floor_divide" : "BINARY_FLOOR_DIVIDE", + "nb_true_divide" : "BINARY_TRUE_DIVIDE", + "nb_power" : "BINARY_POWER", + "nb_and" : "BINARY_AND", + "nb_xor" : "BINARY_XOR", + "nb_or" : "BINARY_OR", + "mp_subscript" : "BINARY_SUBSCR", + "mp_ass_subscript" : "STORE_SUBSCR", + "tp_iternext" : "FOR_ITER", + "tp_richcompare" : "COMPARE_OP", + } + + +class InlineCaching(object): + """This class manages the addition of inline caching derivatives to an instruction set. + + """ + + def __init__(self): + self.types= [] + self.variants= [] + + def extract_type_name(self, c_type_id): + """C type identifiers in python follow the 'PyXYZ_Type' convention""" + return c_type_id[2:-5] + + def extract_func_name(self, c_function_id): + """C function id prefixes are either 'tp_' or 'nb_'...""" + return c_function_id[3:] + + def create_instr_mnemonic(self, prefix, type_id, function_id): + """This creates the actual instruction mnemonic and it + covers two scenarios: + 1) operators: have the format $PREFIX _ $TYPEID _ $FUNID + e.g., INCA_LONG_ADD + 2) iterators: have the format $PREFIX _ $TYPEID + e.g., FOR_ITER_REVITER + + This distinction is necessary because the function id for an + iterator would always be iternext, which is redundant and + therefore omitted... + + """ + parts= [prefix] + parts.append( self.extract_type_name(type_id).upper() ) + if function_id: + parts.append( self.extract_func_name(function_id).upper() ) + return '_'.join(parts) + + def create_master_data(self): + """This method creates the master data that is used in a subsequent + step (method: extend_instr_set). It uses the type structure information + gathered from a gdb session and stored inside the 'typedefs' module to + build a list of available functions inside the type structure to identify + derivative instructions. + + """ + for type_id, mdict in typedefs.TYPE_DATA.items(): + name= self.extract_type_name(type_id) + if name not in self.types: + self.types.append(name) + + def recursive_dict_walker(typedict): + result= [] + for key, val in typedict.items(): + if type(val) == dict: + list= map(lambda (x,y): (key, x) , recursive_dict_walker(val)) + result.extend(list) + elif type(val) == int and val > 0: + if key in INCA_DERIVATIVE_PARENTS: + result.append( (key, None) ) + return result + + self.variants.append( (type_id, recursive_dict_walker(mdict)) ) + + def extend_instr_set(self, instr_set): + self.write_unicode_concatenate(instr_set) + self.write_unpack_sequences(instr_set) + self.write_build_slice_instrs(instr_set) + self.create_derivatives(instr_set) + + def write_build_slice_instrs(self, instr_set, supported_opargs=[2, 3]): + parent= instr_set.find('BUILD_SLICE') + for x in supported_opargs: + derivative= IncaBuildSliceDerivative(parent, '', x) + instr_set.add(derivative) + + def write_unicode_concatenate(self, instr_set): + parent= instr_set.find("BINARY_ADD") + derivative= IncaStringConcatDerivative(parent, + "INCA_ADD_STRINGS", + "PyUnicode_Type", + "unicode_concatenate") + instr_set.add(derivative) + + def write_unpack_sequences(self, instr_set): + parent= instr_set.find("UNPACK_SEQUENCE") + variants= [(2, "TWO"), (3, "THREE")] + types= ["Tuple", "List"] + variants= product(variants, types) + + for ((arity, suffix), type_id) in variants: + mnemonic= "%s_%s_%s" % ("INCA_UNPACK", type_id.upper(), suffix) + derivative= IncaUnpackDerivative(parent, mnemonic, type_id, arity) + instr_set.add(derivative) + + mnemonic= "%s_%s_%s" % ("INCA_BUILD", type_id.upper(), suffix) + derivative= IncaBuildDerivative(parent, mnemonic, type_id, arity) + instr_set.add(derivative) + + def generate_function_ptrs(self): + for type_id, functions in self.variants: + for type_fun, domain_fun in functions: + yield (type_id, type_fun, domain_fun) + + def create_derivatives(self, instr_set): + for (type_id, type_fun, domain_fun) in self.generate_function_ptrs(): + function_id= domain_fun if domain_fun else type_fun + + parent= INCA_DERIVATIVE_PARENTS[function_id] + parent= instr_set.find(parent) + + class_map= [ + ('tp_richcompare', IncaComparisonDerivative), + ('tp_iternext', IncaIteratorDerivative), + ('mp_ass_subscript', IncaSubscriptDerivative), + ('nb_', IncaDerivative), + ('sq_', IncaDerivative), + ('mp_', IncaDerivative), + ] + + for pattern, klass in class_map: + if pattern in function_id: + derivative= klass(parent, + 'generated by template', + type_id, + function_id) + instr_set.add(derivative) + break + + +class IncaDerivative(DerivativeInstr): + + def __init__(self, p, id, type_id, function_id): + DerivativeInstr.__init__(self, p) + ## set the prefix key... + self.id= id + self.type_id= type_id + self.function_id= function_id + +class IncaIteratorDerivative(IncaDerivative): + + def __init__(self, p, id, type_id, function_id): + IncaDerivative.__init__(self, p, id, type_id, function_id) + +class IncaSubscriptDerivative(IncaDerivative): + + def __init__(self, p, id, type_id, function_id): + IncaDerivative.__init__(self, p, id, type_id, function_id) + +class IncaComparisonDerivative(IncaDerivative): + + def __init__(self, p, id, type_id, function_id): + IncaDerivative.__init__(self, p, id, type_id, function_id) + +class IncaUnpackDerivative(IncaDerivative): + + def __init__(self, p, id, type_id, arity): + IncaDerivative.__init__(self, p, id, type_id, None) + ## set the prefix key... + self._arity= arity + + def arity(self): + return self._arity + +class IncaBuildDerivative(IncaDerivative): + + def __init__(self, p, id, type_id, arity): + IncaDerivative.__init__(self, p, id, type_id, None) + ## set the prefix key... + self._arity= arity + + def arity(self): + return self._arity + +class IncaBuildSliceDerivative(IncaDerivative): + + def __init__(self, p, id, arity): + IncaDerivative.__init__(self, p, id, '', 'PySlice_New') + self._arity= arity + + def arity(self): + return self._arity + +class IncaStringConcatDerivative(IncaDerivative): + + def __init__(self, p, id, type_id, function_id): + IncaDerivative.__init__(self, p, id, type_id, function_id) + + + diff -r 2f563908ebc5 -r be51373d99cf cgen/incacalls.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/incacalls.py Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,89 @@ +"""The InlineCachingCalls class creates all *call* instruction based instruction derivatives. +There are several derivative instructions depending on the the call target of each derivative, +such as a C function with variable arguments, or a Python method. +""" +from instructions import DerivativeInstr + +def alphanums(): + return ["ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX"] + + +class IncaCallDerivative(DerivativeInstr): + + def __init__(self, p, id, arity): + DerivativeInstr.__init__(self, p) + self.id= id + self.a= arity + + def arity(self): + return self.a + +class FastCFunctionDerivative(IncaCallDerivative): + + def __init__(self, p, id, a): + IncaCallDerivative.__init__(self, p, id, a) + +class FastGeneratorDerivative(IncaCallDerivative): + + def __init__(self, p, id, a): + IncaCallDerivative.__init__(self, p, id, a) + +class FastCVarArgsDerivative(IncaCallDerivative): + + def __init__(self, p, id, a): + IncaCallDerivative.__init__(self, p, id, a) + +class FastPyFunctionDoCallDerivative(IncaCallDerivative): + + def __init__(self, p, id, a): + IncaCallDerivative.__init__(self, p, id, a) + +class FastPyMethodDerivative(IncaCallDerivative): + + def __init__(self, p, id, a): + IncaCallDerivative.__init__(self, p, id, a) + +class FastPyFunctionDerivative(IncaCallDerivative): + + def __init__(self, p, id, a): + IncaCallDerivative.__init__(self, p, id, a) + + +class InlineCachingCalls(object): + + def __init__(self): + pass + + def create_master_data(self): + pass + + def extend_instr_set(self, instr_set): + parent= instr_set.find("CALL_FUNCTION") + + for arity in [0, 1]: + derivative= FastCFunctionDerivative(parent, "FAST_C_" + alphanums()[arity], arity) + instr_set.add(derivative) + + for arity in [1]: + derivative= FastGeneratorDerivative(parent, "FAST_CALL_GENERATOR_" + alphanums()[arity], arity) + instr_set.add(derivative) + + for arity in [0, 1, 2, 3]: + derivative= FastCVarArgsDerivative(parent, "FAST_C_VARARGS_" + alphanums()[arity], arity) + instr_set.add(derivative) + + for arity in [0, 1, 2]: + derivative= FastPyFunctionDoCallDerivative(parent, "FAST_PYFUN_DOCALL_" + alphanums()[arity], arity) + instr_set.add(derivative) + + for arity in [0, 1, 2, 3]: + derivative= FastPyMethodDerivative(parent, "FAST_PYMETH_" + alphanums()[arity], arity) + instr_set.add(derivative) + + for arity in [0, 1, 2]: + derivative= FastPyFunctionDerivative(parent, "FAST_PYFUN_" + alphanums()[arity], arity) + instr_set.add(derivative) + + + + diff -r 2f563908ebc5 -r be51373d99cf cgen/instructions.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/instructions.py Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,247 @@ +"""This files contains all abstractions for modeling instructions, in particular the +Instruction base class and its derived classes (UnknownInstr, DefaultInstr, +DerivativeInstr.) + +Furthermore, we use the InstructionSet class to represent the interpreter's instruction +set. We can add arbitrary instructions to this instruction set, pack it to achieve maximum +reuse of available byte opcodes, show statistics of instruction derivatives and iterate +over all member instructions. +""" +import imp, os, sys + +class Instruction(object): + """The base class for all instructions. + + """ + + def __init__(self, ident, has_arg): + self.id= ident + self.has_arg= has_arg + self.impl= None + self.environment= None + self.template= None + + def arity(self): + if 'UNARY' in self.id: + return 1 + elif 'BINARY' in self.id or "INPLACE" in self.id: + return 2 + elif self.id == "COMPARE_OP": + return 2 + elif self.id == "STORE_SUBSCR": + return 3 + + def has_impl(self): + return self.impl != None + + def generate_impl(self): + if self.environment and self.template: + self.impl= self.template(self.environment) + + +class UnknownInstr(Instruction): + """We use the unknown instruction object to pad the unassigned instruction opcodes. + + """ + def __init__(self): + Instruction.__init__(self, "_unknown_opcode", False) + + +class DefaultInstr(Instruction): + """A default instruction object corresponds to all instructions that the python interpreter uses + by default, i.e., corresponds to the non-optimized instructions. + + """ + + def __init__(self, ident, has_arg): + Instruction.__init__(self, ident, has_arg) + if ident in DEFAULT_INSTR_IMPL_FUNCTIONS: + self.function_id= DEFAULT_INSTR_IMPL_FUNCTIONS[ident] + self.type_id= None + + +class DerivativeInstr(Instruction): + """In general, we use a derivative instruction object to indicate an optimized instruction + derivative that we execute instead of a more generic instruction implementation by quickening. + The instruction itself is just a base-class for other subclasses, for INCA and RCQ + optimizations. + + """ + + def __init__(self, p): + Instruction.__init__(self, "DERIVATIVE", p.has_arg) + self.parent= p + + def arity(self): + return self.parent.arity() + + def optimized_fun_id(self, function_id): + self.function_id= function_id + + def optimized_type_id(self, type_id): + self.type_id= type_id + + + + +class InstructionSet(object): + """An instruction set is the container of all instructions, it forms the instruction set + architecture of the interpreter. It takes care of properly constructing an ISA corresponding to + the available range representable by the instruction opcodes (usually a byte.) furthermore, it + can add default instruction implementations, add new instructions via the "add" method, and + reuse the maximum amount of instructions by enabling dense packing via the "pack" method. + + """ + + def __init__(self, size, add_defaults=True): + def find_module(modname): + """Finds and returns a module in the local dist/checkout. + """ + modpath = os.path.join(os.path.dirname(__file__), "Lib") + try: + return imp.load_module(modname, *imp.find_module(modname, [modpath])) + except ImportError as e: + print >> sys.stderr, "Error: %s in path %s" % (e.message, modpath) + quit(1) + + self.set= [ UnknownInstr() ] * size + self.max_ident_len= -1 + self.max_instr_no= 0 + + if add_defaults: + opcode= find_module("opcode") + max= -1 + for opname, instr_no in opcode.opmap.items(): + if opname == "STOP_CODE": + continue + + has_arg= False + if instr_no >= opcode.HAVE_ARGUMENT: + has_arg= True + + self.place(instr_no, DefaultInstr(opname, has_arg)) + if instr_no > max: + max= instr_no + + self.max_instr_no= max + 1 + self.default_instrs= max + + def __iter__(self): + return self.set.__iter__() + + def add(self, instrobj): + if self.max_instr_no < len(self.set): + self.place(self.max_instr_no, instrobj) + self.max_instr_no+= 1 + else: + for i in range(1, self.max_instr_no): + if type(self.set[i]) == UnknownInstr: + self.place(i, instrobj) + return + + def place(self, instr_no, instr_obj): + if type(self.set[instr_no]) == UnknownInstr and instr_obj not in self.set: + if len(instr_obj.id) > self.max_ident_len: + self.max_ident_len= len(instr_obj.id) + + self.set[instr_no]= instr_obj + else: + raise KeyError("InstructionSet#place: cannot overwrite an existing instruction!") + + def find(self, instr_id): + for instr_no, instr_obj in enumerate(self.set): + if instr_obj.id == instr_id: + return instr_obj + return None + + def contains_types(self, types): + for x in self.set: + if type(x) in types: + return True + return False + + def effective_size(self): + return len([ x for x in self.set if type(x) != UnknownInstr ]) + + def show_stats(self): + grouped= {} + + for x in self.set: + if type(x) not in grouped: + grouped[type(x)]= [] + + grouped[type(x)].append(x) + + for t in sorted(grouped,key=lambda x: repr(x)): + instrs= grouped[t] + loc= 0 + instr_labels= [] + for i in instrs: + if i.has_impl() and i.impl != None: + lines= i.impl.split(os.linesep) + loc+= len(lines) + instr_labels.append(i.id) + print "%s, no of instrs: %3d, loc: %4d" % (repr(t).ljust(50), len(instrs), loc) + print " -> [%s]" % (', '.join(instr_labels)) + + def pack(self, ordering=[], not_unknown=lambda x: type(x) != UnknownInstr): + def counter(start=1, step=1): + def closure(instruction, i= start): + while not_unknown(new[i]): + i+= step + new[i]= instruction + i+= step + + return closure + + new= [ UnknownInstr() ] * len(self.set) + ## copy the default instructions, as there are dependencies (CALL_FUNCTION and friends) + for (i, obj) in enumerate(self.set): + if type(obj) == DefaultInstr: + new[i]= obj + self.set[i]= None + + ## place instructions in empty slots... + place_instr= counter() + map(place_instr, filter(lambda x: x is not None and not_unknown(x), self.set)) + self.set= new + + + + + +DEFAULT_INSTR_IMPL_FUNCTIONS= { + "UNARY_POSITIVE" : "PyNumber_Positive", + "UNARY_NEGATIVE" : "PyNumber_Negative", + "UNARY_INVERT" : "PyNumber_Invert", + "BINARY_SUBSCR" : "PyObject_GetItem", + "BINARY_ADD" : "PyNumber_Add", + "BINARY_MULTIPLY" : "PyNumber_Multiply", + "BINARY_POWER" : "PyNumber_Power", + "BINARY_TRUE_DIVIDE" : "PyNumber_TrueDivide", + "BINARY_FLOOR_DIVIDE" : "PyNumber_FloorDivide", + "BINARY_MODULO" : "PyNumber_Remainder", + "BINARY_SUBTRACT" : "PyNumber_Subtract", + "BINARY_LSHIFT" : "PyNumber_Lshift", + "BINARY_RSHIFT" : "PyNumber_Rshift", + "BINARY_AND" : "PyNumber_And", + "BINARY_XOR" : "PyNumber_Xor", + "BINARY_OR" : "PyNumber_Or", + "INPLACE_ADD" : "PyNumber_InPlaceAdd", + "INPLACE_MULTIPLY" : "PyNumber_InPlaceMultiply", + "INPLACE_POWER" : "PyNumber_InPlacePower", + "INPLACE_TRUE_DIVIDE" : "PyNumber_InPlaceTrueDivide", + "INPLACE_FLOOR_DIVIDE" : "PyNumber_InPlaceFloorDivide", + "INPLACE_MODULO" : "PyNumber_InPlaceRemainder", + "INPLACE_SUBTRACT" : "PyNumber_InPlaceSubtract", + "INPLACE_LSHIFT" : "PyNumber_InPlaceLshift", + "INPLACE_RSHIFT" : "PyNumber_InPlaceRshift", + "INPLACE_AND" : "PyNumber_InPlaceAnd", + "INPLACE_XOR" : "PyNumber_InPlaceXor", + "INPLACE_OR" : "PyNumber_InPlaceOr", + "COMPARE_OP" : "cmp_outcome", + "DELETE_SUBSCR" : "PyObject_DelItem", + "STORE_SUBSCR" : "PyObject_SetItem", + } + + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/FastCFunctionDerivative --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/FastCFunctionDerivative Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,41 @@ +<%namespace file="base.impl" import="*"/>\ + + TARGET(FAST_C_${ arity_str(instr) }) + % if instr.arity() == 1: + w= POP(); /* TOS element, when arity is 1 */ + % endif + v= TOP(); /* code pointer */ + + % if config.create_inca_guards: + /* guard against inline cache misses */ + % if instr.arity() == 0: + if (! (PyCFunction_Check(v) && (PyCFunction_GET_FLAGS(v) & METH_NOARGS))) { + % elif instr.arity() == 1: + if (! (PyCFunction_Check(v) && (PyCFunction_GET_FLAGS(v) & METH_O))) { + stack_pointer++; /* reset stack pointer */ + % endif + ${ dbg_inf_ic_miss(instr) } + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + % else: + /* guard against inline cache misses OMITTED */ + % endif + ${ dbg_inf_ic_hit(instr) } + + u= PyCFunction_GET_SELF(v); + % if instr.arity() == 0: + x= (*((PyCFunction) PyCFunction_GET_FUNCTION(v)))(u, NULL); + % elif instr.arity() == 1: + x= (*((PyCFunction) PyCFunction_GET_FUNCTION(v)))(u, w); + % endif + + % if instr.arity() == 0: + Py_DECREF(v); + % elif instr.arity() == 1: + Py_DECREF(w); + Py_DECREF(v); + % endif + + ${ push_result() } + ${ dispatch() } + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/FastCVarArgsDerivative --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/FastCVarArgsDerivative Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,55 @@ +<%namespace file="base.impl" import="*"/>\ + + TARGET(FAST_C_VARARGS_${ arity_str(instr) }) + { + % if config.create_inca_guards: + if (oparg != ${ instr.arity() }) goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + % endif + + % for operand,accessor in get_enumerated_args(instr.arity()): + ${operand}= ${accessor}(); + % endfor + + % if config.create_inca_guards: + /* guard against inline cache misses */ + if (! (PyCFunction_Check(v) /* starting with NOT makes it easier to debug */ + && (PyCFunction_GET_FLAGS(v) & (METH_VARARGS | METH_KEYWORDS) ))) + { + ${ dbg_inf_ic_miss(instr) } + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + % else: + /* guard against inline cache misses OMITTED */ + % endif + ${ dbg_inf_ic_hit(instr) } + + % if instr.arity() > 0: + STACKADJ(-${ instr.arity() }); + % endif + register PyCFunction meth= PyCFunction_GET_FUNCTION(v); + register PyObject *self= PyCFunction_GET_SELF(v); + register PyObject *args= PyTuple_New( ${ instr.arity() } ); +<% ## pass arguments... + i= 0 + revargs= get_enumerated_args(instr.arity()) + revargs.reverse() +%>\ + % for operand, accessor in revargs: + % if operand != 'v': + PyTuple_SET_ITEM(args, ${i}, ${operand}); + <% i+= 1 %> + % endif + % endfor + + x= (*(PyCFunctionWithKeywords)meth)(self, args, NULL); + + ## invokes the recursive freeing of arguments stored in the + ## tuple... + Py_XDECREF( args ); + Py_DECREF(v); + + ${ push_result() } + ${ dispatch() } + } + + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/FastGeneratorDerivative --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/FastGeneratorDerivative Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,63 @@ +<%namespace file="base.impl" import="*"/>\ + + TARGET(FAST_CALL_GENERATOR_${ arity_str(instr) }) + { + if (oparg != ${ instr.arity() }) goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + % for operand,accessor in get_enumerated_args(instr.arity()): + ${operand}= ${accessor}(); + % endfor + + if (! (PyMethod_Check(v) || PyFunction_Check(v))) { + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + register PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(v); + if (!co->co_flags & CO_GENERATOR) { + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + PyObject *globals= PyFunction_GET_GLOBALS(v); + PyObject *closure= PyFunction_GET_CLOSURE(v); + PyThreadState *tstate= PyThreadState_GET(); + if (globals == NULL || closure == NULL || tstate == NULL) + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + % if instr.arity() > 0: + STACKADJ(-${ instr.arity() }); + % endif + register PyFrameObject *generator_frame= PyFrame_New(tstate, co, globals, NULL); + register PyObject **freevars= generator_frame->f_localsplus + co->co_nlocals; +<% ## copy argument variables... + i= 0 + revargs= get_enumerated_args(instr.arity()) + revargs.reverse() +%> + % for operand, accessor in revargs: + % if operand != 'v': + Py_INCREF( ${operand} ); + generator_frame->f_localsplus[ ${i} ]= ${ operand }; + <% i+= 1 %> + % endif + % endfor + ## co->co_freevars indicates how many variables we need to fetch from the + ## closue... + /* copy closure variables... */ + u= PyTuple_GET_ITEM(closure, 0); + Py_INCREF(u); + freevars[0] = u; /* closure-bound variable */ + + /* Don't need to keep the reference to f_back, it will be set + * when the generator is resumed. */ + Py_XDECREF(generator_frame->f_back); + generator_frame->f_back = NULL; + + x= PyGen_New(generator_frame); + + % for operand, accessor in get_enumerated_args(instr.arity()): + Py_DECREF( ${ operand } ); + % endfor + + ${ push_result() } + ${ dispatch() } + } + + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/FastPyFunctionDerivative --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/FastPyFunctionDerivative Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,66 @@ +<%namespace file="base.impl" import="*"/>\ + + TARGET(FAST_PYFUN_${ arity_str(instr) }) + { + if (oparg != ${ instr.arity() }) goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + % for operand,accessor in get_enumerated_args(instr.arity()): + ${operand}= ${accessor}(); + % endfor + + ## deal with ic misses... + % if config.create_inca_guards: + /* guard against inline cache misses */ + if (! (!(PyMethod_Check(v) && PyMethod_GET_SELF(v) != NULL) && PyFunction_Check(v))) { + ${ dbg_inf_ic_miss(instr) } + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + PyCodeObject *code= (PyCodeObject*)PyFunction_GET_CODE(v); + if (code->co_argcount != ${ instr.arity() }) { + ${ dbg_inf_ic_miss(instr) } + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + if (! (code->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE))) { + ${ dbg_inf_ic_miss(instr) } + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + % else: + /* guard against inline cache misses OMITTED */ + % endif + ${ dbg_inf_ic_hit(instr) } + + % if instr.arity() > 0: + STACKADJ(-${ instr.arity() }); + % endif + PyObject *globals= PyFunction_GET_GLOBALS(v); + PyThreadState *tstate= PyThreadState_GET(); + PyFrameObject *callee_frame= PyFrame_New( tstate, code, globals, NULL ); + if (callee_frame == NULL) { + SET_TOP((PyObject*)NULL); + break; + } // if + + ## pass arguments... + <% + i= 0 + revargs= get_enumerated_args(instr.arity()) + revargs.reverse() + %>\ + % for operand, accessor in revargs: + % if operand != 'v': + callee_frame->f_localsplus[${i}]= ${ operand }; + <% i+= 1 %>\ + % endif + % endfor + + x= PyEval_EvalFrameEx(callee_frame, 0); + + ++tstate->recursion_depth; + Py_DECREF(callee_frame); + --tstate->recursion_depth; + + ${ push_result() } + ${ dispatch() } + } + + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/FastPyFunctionDoCallDerivative --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/FastPyFunctionDoCallDerivative Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,68 @@ +<%namespace file="base.impl" import="*"/>\ + + TARGET(FAST_PYFUN_DOCALL_${ arity_str(instr) }) + { + if (oparg != ${ instr.arity() }) goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + % for operand,accessor in get_enumerated_args(instr.arity()): + ${operand}= ${accessor}(); + % endfor + + /* guard against inline cache misses */ + if (PyMethod_Check(v) && PyMethod_GET_SELF(v) != NULL) { + ${ dbg_inf_ic_miss(instr) } + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + if (PyFunction_Check(v) || PyCFunction_Check(v)) { + ${ dbg_inf_ic_miss(instr) } + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + register ternaryfunc call= v->ob_type->tp_call; + if (call == NULL) + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + % if instr.arity() > 0: + STACKADJ(-${ instr.arity() }); + % endif + ${ dbg_inf_ic_hit(instr) } + + register PyObject *args= PyTuple_New( ${ instr.arity() } ); +<% ## pass arguments... + i= 0 + revargs= get_enumerated_args(instr.arity()) + revargs.reverse() +%>\ + % for operand, accessor in revargs: + % if operand != 'v': + PyTuple_SET_ITEM(args, ${i}, ${operand}); + <% i+= 1 %>\ + % endif + % endfor + + if (Py_EnterRecursiveCall(" while calling a Python object")) { + x= NULL; + SET_TOP(x); + break; + } // if + + x= (*call)(v, args, NULL); + + Py_LeaveRecursiveCall(); + + if (x == NULL && !PyErr_Occurred()) + PyErr_SetString(PyExc_SystemError, "NULL result without error in PyObject_Call"); + + ## use recursive freeing of tuple container to eliminate + ## the reference counts increased by the argument loading + ## instructions... + Py_XDECREF( args ); + + ## explicit freeing of the code object is necessary... + Py_DECREF(v); + + ## stack management and dispatch... + ${ push_result() } + ${ dispatch() } + } + + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/FastPyMethodDerivative --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/FastPyMethodDerivative Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,90 @@ +<%namespace file="base.impl" import="*"/>\ + + TARGET(FAST_PYMETH_${ arity_str(instr) }) + { + if (oparg != ${ instr.arity() }) goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + + % for operand,accessor in get_enumerated_args(instr.arity()): + ${operand}= ${accessor}(); + % endfor + + ## deal with ic misses... + /* guard against inline cache misses */ + if (! PyMethod_Check(v)) { + ${ dbg_inf_ic_miss(instr) }\ + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + + PyObject *func= PyMethod_GET_FUNCTION(v); + PyObject *self= PyMethod_GET_SELF(v); + + if (! (PyFunction_Check(func) && self != NULL)) { + ${ dbg_inf_ic_miss(instr) }\ + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + + PyCodeObject *code= (PyCodeObject*)PyFunction_GET_CODE(func); + if (! (code->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE))) { + ${ dbg_inf_ic_miss(instr) }\ + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + + x= PyFunction_GET_DEFAULTS(func); + if (! (x == NULL)) { + ${ dbg_inf_ic_miss(instr) }\ + goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; + } // if + ${ dbg_inf_ic_hit(instr) }\ + % if instr.arity() > 0: + STACKADJ(-${ instr.arity() }); + % endif + + Py_INCREF(self); + Py_INCREF(func); + Py_DECREF(v); + + PyObject *globals = PyFunction_GET_GLOBALS(func); + PyThreadState *tstate = PyThreadState_GET(); + PyFrameObject *callee_frame= PyFrame_New(tstate, code, globals, NULL); + if (callee_frame == NULL) { + x= NULL; + SET_TOP(x); + break; + } // if + + callee_frame->f_localsplus[0]= self; + Py_INCREF(self); + +<% ## pass arguments... + i= 1 ## self is always passed! + revargs= get_enumerated_args(instr.arity()) + revargs.reverse() +%>\ + % for operand, accessor in revargs: + % if operand != 'v': + callee_frame->f_localsplus[${i}]= ${operand}; + Py_INCREF( ${operand} ); + <% i+= 1 %>\ + % endif + % endfor + + x= PyEval_EvalFrameEx(callee_frame, 0); + + ++tstate->recursion_depth; + Py_DECREF(callee_frame); + --tstate->recursion_depth; + + Py_DECREF(func); + Py_DECREF(self); + + % for operand, accessor in get_enumerated_args(instr.arity()): + % if operand != 'v': + Py_DECREF( ${ operand } ); + % endif + % endfor + + ${ push_result() } + ${ dispatch() } + } + + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/IncaBuildDerivative --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/IncaBuildDerivative Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,22 @@ +<%namespace file="base.impl" import="*"/>\ + + TARGET(INCA_BUILD_${ instr.type_id.upper() }_${ arity_str(instr) }) + x= Py${ instr.type_id }_New( ${ instr.arity() } ); + if (x != NULL) { + % if instr.arity() == 3: + Py${ instr.type_id }_SET_ITEM(x, 2, TOP()); + Py${ instr.type_id }_SET_ITEM(x, 1, SECOND()); + Py${ instr.type_id }_SET_ITEM(x, 0, THIRD()); + STACKADJ(-2); + % elif instr.arity() == 2: + Py${ instr.type_id }_SET_ITEM(x, 1, TOP()); + Py${ instr.type_id }_SET_ITEM(x, 0, SECOND()); + STACKADJ(-1); + % endif + SET_TOP(x); + DISPATCH(); + } // if + goto on_error; + + + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/IncaBuildSliceDerivative --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/IncaBuildSliceDerivative Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,26 @@ +<%namespace file="base.impl" import="*"/>\ + + TARGET(INCA_BUILD_SLICE_${ arity_str(instr) }) + % if instr.arity() == 3: + w = TOP(); + v = SECOND(); + u = THIRD(); + STACKADJ(-2); + x = PySlice_New(u, v, w); + % elif instr.arity() == 2: + v = TOP(); + u = SECOND(); + STACKADJ(-1); + x = PySlice_New(u, v, NULL); + % endif + Py_DECREF(u); + Py_DECREF(v); + % if instr.arity() == 3: + Py_DECREF(w); + % endif + SET_TOP(x); + ${ dispatch() } + + + + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/IncaComparisonDerivative --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/IncaComparisonDerivative Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,14 @@ +<%namespace file="base.impl" import="*"/>\ +\ + + TARGET(INCA_CMP_${ extract_type_id( instr.type_id ) }) + w= POP(); // tos element + v= TOP(); // sec element + + if (INLINE_CACHE_MISS(v, w, ${ instr.type_id })) goto COMPARE_OP_MISS; + x= ${ instr.type_id }.tp_richcompare(v, w, oparg); + ${ decrefs(instr) } + ${ push_result() } + ${ dispatch() } + + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/IncaDerivative --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/IncaDerivative Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,25 @@ +<%namespace file="base.impl" import="*"/>\ + +% if instr.type_id == 'PyLong_Type' and instr.function_id in ['nb_add', 'nb_multiply', 'nb_subtract']: +% endif + + TARGET(INCA_${ extract_type_id( instr.type_id ) }_${ extract_action_id( instr.function_id ) }) + /* template: IncaDerivative */ +\ + ${ fetch_operands(instr) }\ + ${ inca_miss_guard(instr) }\ + % if not inlined: + % if 'nb_' in instr.function_id: + x= ${ instr.type_id }.tp_as_number->${ instr.function_id }( ${ pass_args(instr) } ); + % elif 'sq_' in instr.function_id: + x= ${ instr.type_id }.tp_as_sequence->${ instr.function_id }( ${ pass_args(instr) } ); + % elif 'mp_' in instr.function_id: + x= ${ instr.type_id }.tp_as_mapping->${ instr.function_id }( ${ pass_args(instr) } ); + % endif + % else: + ${ inlined } + % endif +\ + ${ decrefs(instr) } + ${ push_result() } + ${ dispatch() } diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/IncaIteratorDerivative --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/IncaIteratorDerivative Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,20 @@ +<%namespace file="base.impl" import="*"/>\ + + TARGET(FOR_ITER_${ extract_type_id( instr.type_id )}) + v= TOP(); + + if (INLINE_CACHE_MISS_UNARY(v, ${instr.type_id})) + goto TARGET_FOR_ITER_SKIP_DISPATCH; + + % if not inlined: + x= ${ instr.type_id }.tp_iternext( v ); + if (x != NULL) { + PUSH(x); + DISPATCH(); + } + goto FOR_ITER_CONTINUE; + % else: + ${ inlined } + % endif + + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/IncaStringConcatDerivative --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/IncaStringConcatDerivative Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,23 @@ +<%namespace file="base.impl" import="*"/>\ + + TARGET(INCA_ADD_STRINGS) + w= POP(); // tos element + v= TOP(); // sec element + + if (INLINE_CACHE_MISS(v, w, PyUnicode_Type)) { + /* repair stack pointer */ + stack_pointer+= 1; + /* dispatch to generic implementation */ + goto TARGET_BINARY_ADD_SKIP_DISPATCH; + } // if + + x= unicode_concatenate(v, w, f, next_instr); + + ## here we cannot use the 'decrefs' macro from base.impl, because + ## we cannot decrement the v reference count (is consumed by + ## unicode_concatenate)... + Py_DECREF(w); + ${ push_result() } + ${ dispatch() } + + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/IncaSubscriptDerivative --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/IncaSubscriptDerivative Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,25 @@ +<%namespace file="base.impl" import="*"/>\ +\ +<%def name="extract_action_id(c_signature)">\ +${ c_signature.split('->')[-1][3:].upper() }\ +\ + + TARGET(INCA_${ extract_type_id( instr.type_id )}_${ extract_action_id( instr.function_id ) }) + /* template: IncaSubscriptDerivative */ + w= TOP(); + v= SECOND(); + u= THIRD(); + + if (INLINE_CACHE_MISS_UNARY(v, PyDict_Type)) + goto TARGET_STORE_SUBSCR_SKIP_DISPATCH;; + STACKADJ(-3); + + err= ${ instr.type_id }.tp_as_mapping->mp_ass_subscript( v, w, u ); + + Py_DECREF(v); + Py_DECREF(w); + Py_DECREF(u); + + if (err == 0) DISPATCH(); + goto on_error; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/IncaUnpackDerivative --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/IncaUnpackDerivative Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,26 @@ +<%namespace file="base.impl" import="*"/>\ +\ + + TARGET(INCA_UNPACK_${ instr.type_id.upper() }_${ arity_str(instr) }) + v = POP(); + + if (!(Py${ instr.type_id }_CheckExact(v) + && Py${ instr.type_id }_GET_SIZE(v) == ${ instr.arity() })) { + /* repair stack pointer... */ + stack_pointer++; + goto TARGET_UNPACK_SEQUENCE_SKIP_DISPATCH; + } // if + + x= ((Py${ instr.type_id }Object *)v)->ob_item; + + ## NOTE: range function is not *INCLUSIVE*, therefore i have to + ## provide this "hack" to enumerate the arguments properly, i.e., + ## when arity:= 2, it evaluates to [1, 0]... + % for i in range(instr.arity()-1, -1, -1): + Py_INCREF( GET_OBJARR_ELEM(x, ${i}) ); + PUSH( GET_OBJARR_ELEM(x, ${i}) ); + % endfor + + Py_DECREF(v); + DISPATCH(); + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/base.impl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/base.impl Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,145 @@ +<%def name="dbg_inf_ic_miss(instr)">\ +/* fprintf(stderr, "${ instr.id } inline cache miss\n"); */ +\ + +<%def name="dbg_inf_ic_hit(instr)">\ +/* fprintf(stderr, "${ instr.id } inline cache hit\n"); */ +\ + +<%def name="inca_miss_guard(instr)"> +% if instr.arity() == 1 or (hasattr(instr, 'function_id') and instr.function_id.endswith('_subscript')): + if (INLINE_CACHE_MISS_UNARY(v, ${ instr.type_id })) { +% else: + if (INLINE_CACHE_MISS(v, w, ${ instr.type_id })) { +% endif + ## NOTE: arity is -1 because top-most element is TOP which does not change the stack_pointer... + /* repair stack pointer */ + stack_pointer+= ${ instr.arity() - 1 }; + ${ dbg_inf_ic_miss(instr) } + /* dispatch to generic implementation */ + goto TARGET_${ instr.parent.id }_SKIP_DISPATCH;; + } // if + ${ dbg_inf_ic_hit(instr) } +\ + +<%def name="extract_action_id(c_signature)">\ +${ c_signature.split('->')[-1][3:].upper() }\ +\ + +<%def name="extract_type_id(c_signature)">\ +${ c_signature[2:-5].upper() }\ +\ + +<%def name="arity_str(instr_obj)">\ + % if instr_obj.arity() == 0: +ZERO\ + % elif instr_obj.arity() == 1: +ONE\ + % elif instr_obj.arity() == 2: +TWO\ + % elif instr_obj.arity() == 3: +THREE\ + % elif instr_obj.arity() == 4: +FOUR\ + % elif instr_obj.arity() == 5: +FIVE\ + % elif instr_obj.arity() == 6: +SIX\ + % endif +\ + +<%def name="pass_args(instr)">\ +% if (hasattr(instr, 'parent') and 'POWER' in instr.parent.id) or 'POWER' in instr.id: +v, w, Py_None\ +% elif instr.id == 'COMPARE_OP': +oparg, v, w\ +% else: + % if instr.arity() == 1: +v\ + % elif instr.arity() == 2: +v, w\ + % elif instr.arity() == 3: +v, w, u\ + % endif +% endif + + +<%def name="fetch_operands(instr)"> +% if instr.arity() == 3: + u= POP(); +% endif +% if instr.arity() >= 2: + w= POP(); +% endif +% if instr.arity() >= 1: + v= TOP(); +% endif +\ + +<%def name="push_result()">\ +SET_TOP(x);\ +\ + +<%def name="dispatch()"> + if (x != NULL) DISPATCH(); + goto on_error; +\ + +<%def name="get_enumerated_args(arity)">\ +<% + ## v always holds the code pointer (last element!!!)... + data= [ + [('v', 'TOP')], + [('w', 'TOP'), ('v', 'SECOND')], + [('u', 'TOP'), ('w', 'SECOND'), ('v', 'THIRD')], + [('t', 'TOP'), ('u', 'SECOND'), ('w', 'THIRD'), ('v', 'FOURTH')], + ] + return data[arity] +%>\ +\ + +<%def name="refcount_decrements(instr)">\ + % if instr.arity() == 2: + Py_DECREF(w); /* tos */ + Py_DECREF(v); /* sec */ + % elif instr.arity() == 1: + Py_DECREF(v); /* tos */ + % endif +\ + +<%def name="decrefs(instr)"> + % if instr.arity() == 3: + Py_DECREF( u ); + % endif + % if instr.arity() >= 2: + Py_DECREF( w ); + % endif + % if instr.arity() >= 1: + Py_DECREF( v ); + % endif +\ + +<%def name="decrefs_typed(instr)">\ + % if hasattr(instr, 'type_id') and instr.type_id: + % if instr.arity() == 3: + Py_Typed_DECREF(${instr.type_id}, u ); + % endif + % if instr.arity() >= 2: + Py_Typed_DECREF(${instr.type_id}, w ); + % endif + % if instr.arity() >= 1: + Py_Typed_DECREF(${instr.type_id}, v ); + % endif + % else: + % if instr.arity() == 3: + Py_DECREF( u ); + % endif + % if instr.arity() >= 2: + Py_DECREF( w ); + % endif + % if instr.arity() >= 1: + Py_DECREF( v ); + % endif + % endif +\ + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/copyright --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/copyright Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,5 @@ +/* + * This files was auto-generated on ${now}, please don't change! + * Project-Id: ${project} + * Years: ${years} + */ diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/debug-opcodes.h.impl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/debug-opcodes.h.impl Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,23 @@ +<%! + import instructions +%>\ + +static inline char* +debug_opcode(int opcode) { + void* lookup[]= { + % for opcode, instr_obj in enumerate(instr_set): + % if type(instr_obj) != instructions.UnknownInstr: + (void*)"${instr_obj.id.ljust( instr_set.max_ident_len + 15)}", (void*)${opcode}, + % endif + % endfor + (void*)" < TAIL END > ", (void*)6666 + }; + + int i= 1; + for (i= 1; i < ( ${ len(instr_set.set) } * 2); i+= 2) { + int elem= lookup[i]; + if (elem == opcode) + return lookup[i - 1]; + } // for i + return " < UNKNOWN OPCODE > "; +} // END debug_opcode diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/binary_add --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/binary_add Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,20 @@ + + TARGET(BINARY_ADD) + w = POP(); + v = TOP(); + if (PyUnicode_CheckExact(v) && + PyUnicode_CheckExact(w)) { + PyEval_SetCurInstr(INCA_ADD_STRINGS, 0); + x = unicode_concatenate(v, w, f, next_instr); + /* unicode_concatenate consumed the ref to v */ + goto skip_decref_vx; + } + else { + x = PyNumber_Add(v, w); + } + Py_DECREF(v); + skip_decref_vx: + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/binary_and --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/binary_and Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,11 @@ + + TARGET(BINARY_AND) + w = POP(); + v = TOP(); + x = PyNumber_And(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/binary_floor_divide --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/binary_floor_divide Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,11 @@ + + TARGET(BINARY_FLOOR_DIVIDE) + w = POP(); + v = TOP(); + x = PyNumber_FloorDivide(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/binary_lshift --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/binary_lshift Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,11 @@ + + TARGET(BINARY_LSHIFT) + w = POP(); + v = TOP(); + x = PyNumber_Lshift(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/binary_modulo --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/binary_modulo Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,14 @@ + + TARGET(BINARY_MODULO) + w = POP(); + v = TOP(); + if (PyUnicode_CheckExact(v)) + x = PyUnicode_Format(v, w); + else + x = PyNumber_Remainder(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/binary_multiply --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/binary_multiply Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,11 @@ + + TARGET(BINARY_MULTIPLY) + w = POP(); + v = TOP(); + x = PyNumber_Multiply(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/binary_or --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/binary_or Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,11 @@ + + TARGET(BINARY_OR) + w = POP(); + v = TOP(); + x = PyNumber_Or(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/binary_power --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/binary_power Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,11 @@ + + TARGET(BINARY_POWER) + w = POP(); + v = TOP(); + x = PyNumber_Power(v, w, Py_None); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/binary_rshift --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/binary_rshift Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,11 @@ + + TARGET(BINARY_RSHIFT) + w = POP(); + v = TOP(); + x = PyNumber_Rshift(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/binary_subscr --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/binary_subscr Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,10 @@ + + TARGET(BINARY_SUBSCR) + w = POP(); + v = TOP(); + x = PyObject_GetItem(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/binary_subtract --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/binary_subtract Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,11 @@ + + TARGET(BINARY_SUBTRACT) + w = POP(); + v = TOP(); + x = PyNumber_Subtract(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/binary_true_divide --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/binary_true_divide Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,11 @@ + + TARGET(BINARY_TRUE_DIVIDE) + w = POP(); + v = TOP(); + x = PyNumber_TrueDivide(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/binary_xor --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/binary_xor Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,10 @@ + + TARGET(BINARY_XOR) + w = POP(); + v = TOP(); + x = PyNumber_Xor(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/break_loop --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/break_loop Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,5 @@ + + TARGET(BREAK_LOOP) + why = WHY_BREAK; + goto fast_block_end; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/build_list --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/build_list Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,17 @@ + + TARGET(BUILD_LIST) + switch (oparg) { + case 2: PyEval_SetCurInstr(INCA_BUILD_LIST_TWO, 2); break; + case 3: PyEval_SetCurInstr(INCA_BUILD_LIST_THREE, 3); break; + } // switch + x = PyList_New(oparg); + if (x != NULL) { + for (; --oparg >= 0;) { + w = POP(); + PyList_SET_ITEM(x, oparg, w); + } + PUSH(x); + DISPATCH(); + } + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/build_map --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/build_map Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,7 @@ + + TARGET(BUILD_MAP) + x = _PyDict_NewPresized((Py_ssize_t)oparg); + PUSH(x); + if (x != NULL) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/build_set --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/build_set Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,18 @@ + + TARGET(BUILD_SET) + x = PySet_New(NULL); + if (x != NULL) { + for (; --oparg >= 0;) { + w = POP(); + if (err == 0) + err = PySet_Add(x, w); + Py_DECREF(w); + } + if (err != 0) { + Py_DECREF(x); + goto on_error;; + } + PUSH(x); + DISPATCH(); + } + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/build_slice --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/build_slice Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,15 @@ + + TARGET(BUILD_SLICE) + if (oparg == 3) + w = POP(); + else + w = NULL; + v = POP(); + u = TOP(); + x = PySlice_New(u, v, w); + Py_DECREF(u); + Py_DECREF(v); + Py_XDECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/build_tuple --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/build_tuple Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,16 @@ + + TARGET(BUILD_TUPLE) + switch (oparg) { + case 2: PyEval_SetCurInstr(INCA_BUILD_TUPLE_TWO, 2); break; + case 3: PyEval_SetCurInstr(INCA_BUILD_TUPLE_THREE, 3); break; + } // switch + x = PyTuple_New(oparg); + if (x != NULL) { + for (; --oparg >= 0;) { + w = POP(); + PyTuple_SET_ITEM(x, oparg, w); + } + PUSH(x); + DISPATCH(); + } + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/call_function --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/call_function Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,13 @@ + + TARGET(CALL_FUNCTION) + { + PyObject **sp; + PCALL(PCALL_ALL); + sp = stack_pointer; + x= quickening_call_function(&sp, oparg); + stack_pointer = sp; + PUSH(x); + if (x != NULL) + DISPATCH(); + goto on_error;; + } diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/call_function_var_kw --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/call_function_var_kw Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,47 @@ + + TARGET_WITH_IMPL(CALL_FUNCTION_VAR, _call_function_var_kw) + TARGET_WITH_IMPL(CALL_FUNCTION_KW, _call_function_var_kw) + TARGET(CALL_FUNCTION_VAR_KW) + _call_function_var_kw: + { + int na = oparg & 0xff; + int nk = (oparg>>8) & 0xff; + int flags = (opcode - CALL_FUNCTION) & 3; + int n = na + 2 * nk; + PyObject **pfunc, *func, **sp; + PCALL(PCALL_ALL); + if (flags & CALL_FLAG_VAR) + n++; + if (flags & CALL_FLAG_KW) + n++; + pfunc = stack_pointer - n - 1; + func = *pfunc; + + if (PyMethod_Check(func) + && PyMethod_GET_SELF(func) != NULL) { + PyObject *self = PyMethod_GET_SELF(func); + Py_INCREF(self); + func = PyMethod_GET_FUNCTION(func); + Py_INCREF(func); + Py_DECREF(*pfunc); + *pfunc = self; + na++; + /* n++; */ + } else + Py_INCREF(func); + sp = stack_pointer; + READ_TIMESTAMP(intr0); + x = ext_do_call(func, &sp, flags, na, nk); + READ_TIMESTAMP(intr1); + stack_pointer = sp; + Py_DECREF(func); + + while (stack_pointer > pfunc) { + w = POP(); + Py_DECREF(w); + } + PUSH(x); + if (x != NULL) + DISPATCH(); + goto on_error;; + } diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/compare_op --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/compare_op Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,13 @@ + + TARGET(COMPARE_OP) + w = POP(); + v = TOP(); + COMPARE_OP_MISS: + x = cmp_outcome(oparg, v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x == NULL) goto on_error;; + PREDICT(POP_JUMP_IF_FALSE); + PREDICT(POP_JUMP_IF_TRUE); + DISPATCH(); diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/continue_loop --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/continue_loop Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,9 @@ + + TARGET(CONTINUE_LOOP) + retval = PyLong_FromLong(oparg); + if (!retval) { + x = NULL; + goto on_error;; + } + why = WHY_CONTINUE; + goto fast_block_end; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/delete_attr --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/delete_attr Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,9 @@ + + TARGET(DELETE_ATTR) + w = GETITEM(names, oparg); + v = POP(); + err = PyObject_SetAttr(v, w, (PyObject *)NULL); + /* del v.w */ + Py_DECREF(v); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/delete_deref --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/delete_deref Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,10 @@ + + TARGET(DELETE_DEREF) + x = freevars[oparg]; + if (PyCell_GET(x) != NULL) { + PyCell_Set(x, NULL); + DISPATCH(); + } + err = -1; + format_exc_unbound(co, oparg); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/delete_fast --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/delete_fast Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,13 @@ + + TARGET(DELETE_FAST) + x = GETLOCAL(oparg); + if (x != NULL) { + SETLOCAL(oparg, NULL); + DISPATCH(); + } + format_exc_check_arg( + PyExc_UnboundLocalError, + UNBOUNDLOCAL_ERROR_MSG, + PyTuple_GetItem(co->co_varnames, oparg) + ); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/delete_global --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/delete_global Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,8 @@ + + TARGET(DELETE_GLOBAL) + w = GETITEM(names, oparg); + if ((err = PyDict_DelItem(f->f_globals, w)) != 0) + format_exc_check_arg( + PyExc_NameError, GLOBAL_NAME_ERROR_MSG, w); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/delete_name --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/delete_name Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,13 @@ + + TARGET(DELETE_NAME) + w = GETITEM(names, oparg); + if ((x = f->f_locals) != NULL) { + if ((err = PyObject_DelItem(x, w)) != 0) + format_exc_check_arg(PyExc_NameError, + NAME_ERROR_MSG, + w); + goto on_error;; + } + PyErr_Format(PyExc_SystemError, + "no locals when deleting %R", w); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/delete_subscr --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/delete_subscr Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,12 @@ + + TARGET(DELETE_SUBSCR) + w = TOP(); + v = SECOND(); + STACKADJ(-2); + /* del v[w] */ + err = PyObject_DelItem(v, w); + Py_DECREF(v); + Py_DECREF(w); + if (err == 0) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/dup_top --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/dup_top Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,6 @@ + + TARGET(DUP_TOP) + v = TOP(); + Py_INCREF(v); + PUSH(v); + FAST_DISPATCH(); diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/dup_top_two --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/dup_top_two Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,11 @@ + + TARGET(DUP_TOP_TWO) + x = TOP(); + Py_INCREF(x); + w = SECOND(); + Py_INCREF(w); + STACKADJ(2); + SET_TOP(x); + SET_SECOND(w); + FAST_DISPATCH(); + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/end_finally --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/end_finally Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,35 @@ + + PREDICTED(END_FINALLY); + TARGET(END_FINALLY) + v = POP(); + if (PyLong_Check(v)) { + why = (enum why_code) PyLong_AS_LONG(v); + assert(why != WHY_YIELD); + if (why == WHY_RETURN || + why == WHY_CONTINUE) + retval = POP(); + if (why == WHY_SILENCED) { + /* An exception was silenced by 'with', we must + manually unwind the EXCEPT_HANDLER block which was + created when the exception was caught, otherwise + the stack will be in an inconsistent state. */ + PyTryBlock *b = PyFrame_BlockPop(f); + assert(b->b_type == EXCEPT_HANDLER); + UNWIND_EXCEPT_HANDLER(b); + why = WHY_NOT; + } + } + else if (PyExceptionClass_Check(v)) { + w = POP(); + u = POP(); + PyErr_Restore(v, w, u); + why = WHY_RERAISE; + goto on_error;; + } + else if (v != Py_None) { + PyErr_SetString(PyExc_SystemError, + "'finally' pops bad exception"); + why = WHY_EXCEPTION; + } + Py_DECREF(v); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/extended_arg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/extended_arg Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,6 @@ + + TARGET(EXTENDED_ARG) + opcode = NEXTOP(); + oparg = oparg<<16 | NEXTARG(); + goto *opcode_no_dispatch_targets[opcode]; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/for_iter --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/for_iter Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,24 @@ + + PREDICTED_WITH_ARG(FOR_ITER); + TARGET(FOR_ITER) + /* before: [iter]; after: [iter, iter()] *or* [] */ + v = TOP(); + PyEval_RewriteInstr(v->ob_type->tp_iternext); + x = (*v->ob_type->tp_iternext)(v); + if (x != NULL) { + PUSH(x); + DISPATCH(); + } + FOR_ITER_CONTINUE: + if (PyErr_Occurred()) { + if (!PyErr_ExceptionMatches( + PyExc_StopIteration)) + goto on_error;; + PyErr_Clear(); + } + /* iterator ended normally */ + x = v = POP(); + Py_DECREF(v); + JUMPBY(oparg); + DISPATCH(); + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/get_iter --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/get_iter Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,13 @@ + + TARGET(GET_ITER) + /* before: [obj]; after [getiter(obj)] */ + v = TOP(); + x = PyObject_GetIter(v); + Py_DECREF(v); + if (x != NULL) { + SET_TOP(x); + PREDICT(FOR_ITER); + DISPATCH(); + } + STACKADJ(-1); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/import_from --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/import_from Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,11 @@ + + TARGET(IMPORT_FROM) + w = GETITEM(names, oparg); + v = TOP(); + READ_TIMESTAMP(intr0); + x = import_from(v, w); + READ_TIMESTAMP(intr1); + PUSH(x); + if (x != NULL) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/import_name --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/import_name Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,45 @@ + + TARGET(IMPORT_NAME) + w = GETITEM(names, oparg); + x = PyDict_GetItemString(f->f_builtins, "__import__"); + if (x == NULL) { + PyErr_SetString(PyExc_ImportError, + "__import__ not found"); + goto on_error;; + } + Py_INCREF(x); + v = POP(); + u = TOP(); + if (PyLong_AsLong(u) != -1 || PyErr_Occurred()) + w = PyTuple_Pack(5, + w, + f->f_globals, + f->f_locals == NULL ? + Py_None : f->f_locals, + v, + u); + else + w = PyTuple_Pack(4, + w, + f->f_globals, + f->f_locals == NULL ? + Py_None : f->f_locals, + v); + Py_DECREF(v); + Py_DECREF(u); + if (w == NULL) { + u = POP(); + Py_DECREF(x); + x = NULL; + goto on_error;; + } + READ_TIMESTAMP(intr0); + v = x; + x = PyEval_CallObject(v, w); + Py_DECREF(v); + READ_TIMESTAMP(intr1); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/import_star --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/import_star Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,17 @@ + + TARGET(IMPORT_STAR) + v = POP(); + PyFrame_FastToLocals(f); + if ((x = f->f_locals) == NULL) { + PyErr_SetString(PyExc_SystemError, + "no locals found during 'import *'"); + goto on_error;; + } + READ_TIMESTAMP(intr0); + err = import_all_from(x, v); + READ_TIMESTAMP(intr1); + PyFrame_LocalsToFast(f, 0); + Py_DECREF(v); + if (err == 0) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/inplace_add --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/inplace_add Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,21 @@ + + TARGET(INPLACE_ADD) + w = POP(); + v = TOP(); + if (PyUnicode_CheckExact(v) && + PyUnicode_CheckExact(w)) { + PyEval_SetCurInstr(INCA_ADD_STRINGS, 0); + x = unicode_concatenate(v, w, f, next_instr); + /* unicode_concatenate consumed the ref to v */ + goto skip_decref_v; + } + else { + x = PyNumber_InPlaceAdd(v, w); + } + Py_DECREF(v); + skip_decref_v: + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/inplace_and --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/inplace_and Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,11 @@ + + TARGET(INPLACE_AND) + w = POP(); + v = TOP(); + x = PyNumber_InPlaceAnd(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/inplace_floor_divide --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/inplace_floor_divide Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,11 @@ + + TARGET(INPLACE_FLOOR_DIVIDE) + w = POP(); + v = TOP(); + x = PyNumber_InPlaceFloorDivide(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/inplace_lshift --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/inplace_lshift Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,11 @@ + + TARGET(INPLACE_LSHIFT) + w = POP(); + v = TOP(); + x = PyNumber_InPlaceLshift(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/inplace_modulo --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/inplace_modulo Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,11 @@ + + TARGET(INPLACE_MODULO) + w = POP(); + v = TOP(); + x = PyNumber_InPlaceRemainder(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/inplace_multiply --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/inplace_multiply Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,10 @@ + + TARGET(INPLACE_MULTIPLY) + w = POP(); + v = TOP(); + x = PyNumber_InPlaceMultiply(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/inplace_or --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/inplace_or Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,10 @@ + + TARGET(INPLACE_OR) + w = POP(); + v = TOP(); + x = PyNumber_InPlaceOr(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/inplace_power --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/inplace_power Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,10 @@ + + TARGET(INPLACE_POWER) + w = POP(); + v = TOP(); + x = PyNumber_InPlacePower(v, w, Py_None); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/inplace_rshift --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/inplace_rshift Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,10 @@ + + TARGET(INPLACE_RSHIFT) + w = POP(); + v = TOP(); + x = PyNumber_InPlaceRshift(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/inplace_subtract --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/inplace_subtract Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,10 @@ + + TARGET(INPLACE_SUBTRACT) + w = POP(); + v = TOP(); + x = PyNumber_InPlaceSubtract(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/inplace_true_divide --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/inplace_true_divide Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,10 @@ + + TARGET(INPLACE_TRUE_DIVIDE) + w = POP(); + v = TOP(); + x = PyNumber_InPlaceTrueDivide(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/inplace_xor --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/inplace_xor Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,10 @@ + + TARGET(INPLACE_XOR) + w = POP(); + v = TOP(); + x = PyNumber_InPlaceXor(v, w); + Py_DECREF(v); + Py_DECREF(w); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/jump_absolute --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/jump_absolute Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,16 @@ + + PREDICTED_WITH_ARG(JUMP_ABSOLUTE); + TARGET(JUMP_ABSOLUTE) + JUMPTO(oparg); +#if FAST_LOOPS + /* Enabling this path speeds-up all while and for-loops by bypassing + the per-loop checks for signals. By default, this should be turned-off + because it prevents detection of a control-break in tight loops like + "while 1: pass". Compile with this option turned-on when you need + the speed-up and do not need break checking inside tight loops (ones + that contain only instructions ending with FAST_DISPATCH). + */ + FAST_DISPATCH(); +#else + DISPATCH(); +#endif diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/jump_forward --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/jump_forward Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,4 @@ + + TARGET(JUMP_FORWARD) + JUMPBY(oparg); + FAST_DISPATCH(); diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/jump_if_false_or_pop --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/jump_if_false_or_pop Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,23 @@ + + TARGET(JUMP_IF_FALSE_OR_POP) + w = TOP(); + if (w == Py_True) { + STACKADJ(-1); + Py_DECREF(w); + FAST_DISPATCH(); + } + if (w == Py_False) { + JUMPTO(oparg); + FAST_DISPATCH(); + } + err = PyObject_IsTrue(w); + if (err > 0) { + STACKADJ(-1); + Py_DECREF(w); + err = 0; + } + else if (err == 0) + JUMPTO(oparg); + else + goto on_error;; + DISPATCH(); diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/jump_if_true_or_pop --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/jump_if_true_or_pop Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,24 @@ + + TARGET(JUMP_IF_TRUE_OR_POP) + w = TOP(); + if (w == Py_False) { + STACKADJ(-1); + Py_DECREF(w); + FAST_DISPATCH(); + } + if (w == Py_True) { + JUMPTO(oparg); + FAST_DISPATCH(); + } + err = PyObject_IsTrue(w); + if (err > 0) { + err = 0; + JUMPTO(oparg); + } + else if (err == 0) { + STACKADJ(-1); + Py_DECREF(w); + } + else + goto on_error;; + DISPATCH(); diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/list_append --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/list_append Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,11 @@ + + TARGET(LIST_APPEND) + w = POP(); + v = PEEK(oparg); + err = PyList_Append(v, w); + Py_DECREF(w); + if (err == 0) { + PREDICT(JUMP_ABSOLUTE); + DISPATCH(); + } + goto on_error;;;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/load_attr --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/load_attr Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,9 @@ + + TARGET(LOAD_ATTR) + w = GETITEM(names, oparg); + v = TOP(); + x = PyObject_GetAttr(v, w); + Py_DECREF(v); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/load_build_class --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/load_build_class Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,29 @@ + + TARGET(LOAD_BUILD_CLASS) + { + _Py_IDENTIFIER(__build_class__); + + if (PyDict_CheckExact(f->f_builtins)) { + x = _PyDict_GetItemId(f->f_builtins, &PyId___build_class__); + if (x == NULL) { + PyErr_SetString(PyExc_NameError, + "__build_class__ not found"); + goto on_error;; + } + Py_INCREF(x); + } + else { + PyObject *build_class_str = _PyUnicode_FromId(&PyId___build_class__); + if (build_class_str == NULL) + goto on_error;; + x = PyObject_GetItem(f->f_builtins, build_class_str); + if (x == NULL) { + if (PyErr_ExceptionMatches(PyExc_KeyError)) + PyErr_SetString(PyExc_NameError, + "__build_class__ not found"); + goto on_error;; + } + } + PUSH(x); + goto on_error;; + } diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/load_closure --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/load_closure Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,7 @@ + + TARGET(LOAD_CLOSURE) + x = freevars[oparg]; + Py_INCREF(x); + PUSH(x); + if (x != NULL) DISPATCH(); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/load_const --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/load_const Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,6 @@ + + TARGET(LOAD_CONST) + x = GETITEM(consts, oparg); + Py_INCREF(x); + PUSH(x); + FAST_DISPATCH(); diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/load_deref --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/load_deref Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,27 @@ + + TARGET(LOAD_DEREF) + x = freevars[oparg]; + w = PyCell_Get(x); + if (w != NULL) { + PUSH(w); + DISPATCH(); + } + load_deref_error: + err = -1; + /* Don't stomp existing exception */ + if (PyErr_Occurred()) + goto on_error;; + if (oparg < PyTuple_GET_SIZE(co->co_cellvars)) { + v = PyTuple_GET_ITEM(co->co_cellvars, + oparg); + format_exc_check_arg( + PyExc_UnboundLocalError, + UNBOUNDLOCAL_ERROR_MSG, + v); + } else { + v = PyTuple_GET_ITEM(co->co_freevars, oparg - + PyTuple_GET_SIZE(co->co_cellvars)); + format_exc_check_arg(PyExc_NameError, + UNBOUNDFREE_ERROR_MSG, v); + } + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/load_fast --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/load_fast Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,12 @@ + + TARGET(LOAD_FAST) + x = GETLOCAL(oparg); + if (x != NULL) { + Py_INCREF(x); + PUSH(x); + FAST_DISPATCH(); + } + format_exc_check_arg(PyExc_UnboundLocalError, + UNBOUNDLOCAL_ERROR_MSG, + PyTuple_GetItem(co->co_varnames, oparg)); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/load_global --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/load_global Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,32 @@ + + TARGET(LOAD_GLOBAL) + w = GETITEM(names, oparg); + if (PyDict_CheckExact(f->f_globals) + && PyDict_CheckExact(f->f_builtins)) { + x = _PyDict_LoadGlobal((PyDictObject *)f->f_globals, + (PyDictObject *)f->f_builtins, + w); + if (x == NULL) { + if (!PyErr_Occurred()) + format_exc_check_arg(PyExc_NameError, + GLOBAL_NAME_ERROR_MSG, w); + goto on_error; + } + } + else { + /* Slow-path if globals or builtins is not a dict */ + x = PyObject_GetItem(f->f_globals, w); + if (x == NULL) { + x = PyObject_GetItem(f->f_builtins, w); + if (x == NULL) { + if (PyErr_ExceptionMatches(PyExc_KeyError)) + format_exc_check_arg( + PyExc_NameError, + GLOBAL_NAME_ERROR_MSG, w); + goto on_error; + } + } + } + Py_INCREF(x); + PUSH(x); + DISPATCH(); diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/load_name --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/load_name Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,37 @@ + + TARGET(LOAD_NAME) + w = GETITEM(names, oparg); + if ((v = f->f_locals) == NULL) { + PyErr_Format(PyExc_SystemError, + "no locals when loading %R", w); + why = WHY_EXCEPTION; + goto on_error;; + } + if (PyDict_CheckExact(v)) { + x = PyDict_GetItem(v, w); + Py_XINCREF(x); + } + else { + x = PyObject_GetItem(v, w); + if (x == NULL && PyErr_Occurred()) { + if (!PyErr_ExceptionMatches( + PyExc_KeyError)) + goto on_error;; + PyErr_Clear(); + } + } + if (x == NULL) { + x = PyDict_GetItem(f->f_globals, w); + if (x == NULL) { + x = PyDict_GetItem(f->f_builtins, w); + if (x == NULL) { + format_exc_check_arg( + PyExc_NameError, + NAME_ERROR_MSG, w); + goto on_error;; + } + } + Py_INCREF(x); + } + PUSH(x); + DISPATCH(); diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/make_function --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/make_function Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,98 @@ + + TARGET_WITH_IMPL(MAKE_CLOSURE, _make_function) + TARGET(MAKE_FUNCTION) + _make_function: + { + int posdefaults = oparg & 0xff; + int kwdefaults = (oparg>>8) & 0xff; + int num_annotations = (oparg >> 16) & 0x7fff; + + w = POP(); /* qualname */ + v = POP(); /* code object */ + x = PyFunction_NewWithQualName(v, f->f_globals, w); + Py_DECREF(v); + Py_DECREF(w); + + if (x != NULL && opcode == MAKE_CLOSURE) { + v = POP(); + if (PyFunction_SetClosure(x, v) != 0) { + /* Can't happen unless bytecode is corrupt. */ + why = WHY_EXCEPTION; + } + Py_DECREF(v); + } + + if (x != NULL && num_annotations > 0) { + Py_ssize_t name_ix; + u = POP(); /* names of args with annotations */ + v = PyDict_New(); + if (v == NULL) { + Py_DECREF(x); + x = NULL; + goto on_error;; + } + name_ix = PyTuple_Size(u); + assert(num_annotations == name_ix+1); + while (name_ix > 0) { + --name_ix; + t = PyTuple_GET_ITEM(u, name_ix); + w = POP(); + /* XXX(nnorwitz): check for errors */ + PyDict_SetItem(v, t, w); + Py_DECREF(w); + } + + if (PyFunction_SetAnnotations(x, v) != 0) { + /* Can't happen unless + PyFunction_SetAnnotations changes. */ + why = WHY_EXCEPTION; + } + Py_DECREF(v); + Py_DECREF(u); + } + + /* XXX Maybe this should be a separate opcode? */ + if (x != NULL && posdefaults > 0) { + v = PyTuple_New(posdefaults); + if (v == NULL) { + Py_DECREF(x); + x = NULL; + goto on_error;; + } + while (--posdefaults >= 0) { + w = POP(); + PyTuple_SET_ITEM(v, posdefaults, w); + } + if (PyFunction_SetDefaults(x, v) != 0) { + /* Can't happen unless + PyFunction_SetDefaults changes. */ + why = WHY_EXCEPTION; + } + Py_DECREF(v); + } + if (x != NULL && kwdefaults > 0) { + v = PyDict_New(); + if (v == NULL) { + Py_DECREF(x); + x = NULL; + goto on_error;; + } + while (--kwdefaults >= 0) { + w = POP(); /* default value */ + u = POP(); /* kw only arg name */ + /* XXX(nnorwitz): check for errors */ + PyDict_SetItem(v, u, w); + Py_DECREF(w); + Py_DECREF(u); + } + if (PyFunction_SetKwDefaults(x, v) != 0) { + /* Can't happen unless + PyFunction_SetKwDefaults changes. */ + why = WHY_EXCEPTION; + } + Py_DECREF(v); + } + + PUSH(x); + goto on_error;; + } diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/map_add --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/map_add Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,15 @@ + + TARGET(MAP_ADD) + w = TOP(); /* key */ + u = SECOND(); /* value */ + STACKADJ(-2); + v = stack_pointer[-oparg]; /* dict */ + assert (PyDict_CheckExact(v)); + err = PyDict_SetItem(v, w, u); /* v[w] = u */ + Py_DECREF(u); + Py_DECREF(w); + if (err == 0) { + PREDICT(JUMP_ABSOLUTE); + DISPATCH(); + } + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/pop_block --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/pop_block Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,7 @@ + + TARGET(POP_BLOCK) + { + PyTryBlock *b = PyFrame_BlockPop(f); + UNWIND_BLOCK(b); + } + DISPATCH(); diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/pop_except --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/pop_except Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,13 @@ + + TARGET(POP_EXCEPT) + { + PyTryBlock *b = PyFrame_BlockPop(f); + if (b->b_type != EXCEPT_HANDLER) { + PyErr_SetString(PyExc_SystemError, + "popped block is not an except handler"); + why = WHY_EXCEPTION; + goto on_error;; + } + UNWIND_EXCEPT_HANDLER(b); + } + DISPATCH(); diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/pop_jump_if_false --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/pop_jump_if_false Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,22 @@ + + PREDICTED_WITH_ARG(POP_JUMP_IF_FALSE); + TARGET(POP_JUMP_IF_FALSE) + w = POP(); + if (w == Py_True) { + Py_DECREF(w); + FAST_DISPATCH(); + } + if (w == Py_False) { + Py_DECREF(w); + JUMPTO(oparg); + FAST_DISPATCH(); + } + err = PyObject_IsTrue(w); + Py_DECREF(w); + if (err > 0) + err = 0; + else if (err == 0) + JUMPTO(oparg); + else + goto on_error;; + DISPATCH(); diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/pop_jump_if_true --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/pop_jump_if_true Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,24 @@ + + PREDICTED_WITH_ARG(POP_JUMP_IF_TRUE); + TARGET(POP_JUMP_IF_TRUE) + w = POP(); + if (w == Py_False) { + Py_DECREF(w); + FAST_DISPATCH(); + } + if (w == Py_True) { + Py_DECREF(w); + JUMPTO(oparg); + FAST_DISPATCH(); + } + err = PyObject_IsTrue(w); + Py_DECREF(w); + if (err > 0) { + err = 0; + JUMPTO(oparg); + } + else if (err == 0) + ; + else + goto on_error;; + DISPATCH(); diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/pop_top --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/pop_top Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,6 @@ + + TARGET(POP_TOP) + v = POP(); + Py_DECREF(v); + FAST_DISPATCH(); + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/print_expr --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/print_expr Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,24 @@ + + TARGET(PRINT_EXPR) + v = POP(); + w = PySys_GetObject("displayhook"); + if (w == NULL) { + PyErr_SetString(PyExc_RuntimeError, + "lost sys.displayhook"); + err = -1; + x = NULL; + } + if (err == 0) { + x = PyTuple_Pack(1, v); + if (x == NULL) + err = -1; + } + if (err == 0) { + w = PyEval_CallObject(w, x); + Py_XDECREF(w); + if (w == NULL) + err = -1; + } + Py_DECREF(v); + Py_XDECREF(x); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/raise_varargs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/raise_varargs Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,18 @@ + + TARGET(RAISE_VARARGS) + v = w = NULL; + switch (oparg) { + case 2: + v = POP(); /* cause */ + case 1: + w = POP(); /* exc */ + case 0: /* Fallthrough */ + why = do_raise(w, v); + break; + default: + PyErr_SetString(PyExc_SystemError, + "bad RAISE_VARARGS oparg"); + why = WHY_EXCEPTION; + break; + } + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/return_value --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/return_value Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,5 @@ + + TARGET(RETURN_VALUE) + retval = POP(); + why = WHY_RETURN; + goto fast_block_end; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/rot_four --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/rot_four Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,11 @@ + + TARGET(ROT_FOUR) + u = TOP(); + v = SECOND(); + w = THIRD(); + x = FOURTH(); + SET_TOP(v); + SET_SECOND(w); + SET_THIRD(x); + SET_FOURTH(u); + FAST_DISPATCH(); diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/rot_three --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/rot_three Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,9 @@ + + TARGET(ROT_THREE) + v = TOP(); + w = SECOND(); + x = THIRD(); + SET_TOP(w); + SET_SECOND(x); + SET_THIRD(v); + FAST_DISPATCH(); diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/rot_two --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/rot_two Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,7 @@ + + TARGET(ROT_TWO) + v = TOP(); + w = SECOND(); + SET_TOP(w); + SET_SECOND(v); + FAST_DISPATCH(); diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/set_add --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/set_add Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,11 @@ + + TARGET(SET_ADD) + w = POP(); + v = stack_pointer[-oparg]; + err = PySet_Add(v, w); + Py_DECREF(w); + if (err == 0) { + PREDICT(JUMP_ABSOLUTE); + DISPATCH(); + } + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/setup_finally --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/setup_finally Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,13 @@ + + TARGET_WITH_IMPL(SETUP_LOOP, _setup_finally) + TARGET_WITH_IMPL(SETUP_EXCEPT, _setup_finally) + TARGET(SETUP_FINALLY) + _setup_finally: + /* NOTE: If you add any new block-setup opcodes that + are not try/except/finally handlers, you may need + to update the PyGen_NeedsFinalizing() function. + */ + + PyFrame_BlockSetup(f, opcode, INSTR_OFFSET() + oparg, + STACK_LEVEL()); + DISPATCH(); diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/setup_with --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/setup_with Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,28 @@ + + TARGET(SETUP_WITH) + { + _Py_IDENTIFIER(__exit__); + _Py_IDENTIFIER(__enter__); + w = TOP(); + x = special_lookup(w, &PyId___exit__); + if (!x) + goto on_error; + SET_TOP(x); + u = special_lookup(w, &PyId___enter__); + Py_DECREF(w); + if (!u) { + x = NULL; + goto on_error; + } + x = PyObject_CallFunctionObjArgs(u, NULL); + Py_DECREF(u); + if (!x) + goto on_error; + /* Setup the finally block before pushing the result + of __enter__ on the stack. */ + PyFrame_BlockSetup(f, SETUP_FINALLY, INSTR_OFFSET() + oparg, + STACK_LEVEL()); + + PUSH(x); + DISPATCH(); + } diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/store_attr --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/store_attr Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,11 @@ + + TARGET(STORE_ATTR) + w = GETITEM(names, oparg); + v = TOP(); + u = SECOND(); + STACKADJ(-2); + err = PyObject_SetAttr(v, w, u); /* v.w = u */ + Py_DECREF(v); + Py_DECREF(u); + if (err == 0) DISPATCH(); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/store_deref --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/store_deref Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,7 @@ + + TARGET(STORE_DEREF) + w = POP(); + x = freevars[oparg]; + PyCell_Set(x, w); + Py_DECREF(w); + DISPATCH(); diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/store_fast --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/store_fast Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,6 @@ + + PREDICTED_WITH_ARG(STORE_FAST); + TARGET(STORE_FAST) + v = POP(); + SETLOCAL(oparg, v); + FAST_DISPATCH(); diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/store_global --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/store_global Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,8 @@ + + TARGET(STORE_GLOBAL) + w = GETITEM(names, oparg); + v = POP(); + err = PyDict_SetItem(f->f_globals, w, v); + Py_DECREF(v); + if (err == 0) DISPATCH(); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/store_locals --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/store_locals Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,7 @@ + + TARGET(STORE_LOCALS) + x = POP(); + v = f->f_locals; + Py_XDECREF(v); + f->f_locals = x; + DISPATCH(); diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/store_map --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/store_map Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,12 @@ + + TARGET(STORE_MAP) + w = TOP(); /* key */ + u = SECOND(); /* value */ + v = THIRD(); /* dict */ + STACKADJ(-2); + assert (PyDict_CheckExact(v)); + err = PyDict_SetItem(v, w, u); /* v[w] = u */ + Py_DECREF(u); + Py_DECREF(w); + if (err == 0) DISPATCH(); + goto on_error;; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/store_name --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/store_name Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,17 @@ + + TARGET(STORE_NAME) + w = GETITEM(names, oparg); + v = POP(); + if ((x = f->f_locals) != NULL) { + if (PyDict_CheckExact(x)) + err = PyDict_SetItem(x, w, v); + else + err = PyObject_SetItem(x, w, v); + Py_DECREF(v); + if (err == 0) DISPATCH(); + goto on_error;; + } + PyErr_Format(PyExc_SystemError, + "no locals found when storing %R", w); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/store_subscr --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/store_subscr Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,14 @@ + + TARGET(STORE_SUBSCR) + w = TOP(); + v = SECOND(); + u = THIRD(); + STACKADJ(-3); + /* v[w] = u */ + err = PyObject_SetItem(v, w, u); + Py_DECREF(u); + Py_DECREF(v); + Py_DECREF(w); + if (err == 0) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/unary_invert --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/unary_invert Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,9 @@ + + TARGET(UNARY_INVERT) + v = TOP(); + x = PyNumber_Invert(v); + Py_DECREF(v); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/unary_negative --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/unary_negative Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,9 @@ + + TARGET(UNARY_NEGATIVE) + v = TOP(); + x = PyNumber_Negative(v); + Py_DECREF(v); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/unary_not --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/unary_not Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,20 @@ + + + TARGET(UNARY_NOT) + v = TOP(); + err = PyObject_IsTrue(v); + Py_DECREF(v); + if (err == 0) { + Py_INCREF(Py_True); + SET_TOP(Py_True); + DISPATCH(); + } + else if (err > 0) { + Py_INCREF(Py_False); + SET_TOP(Py_False); + err = 0; + DISPATCH(); + } + STACKADJ(-1); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/unary_positive --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/unary_positive Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,9 @@ + + TARGET(UNARY_POSITIVE) + v = TOP(); + x = PyNumber_Positive(v); + Py_DECREF(v); + SET_TOP(x); + if (x != NULL) DISPATCH(); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/unpack_ex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/unpack_ex Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,16 @@ + + TARGET(UNPACK_EX) + { + int totalargs = 1 + (oparg & 0xFF) + (oparg >> 8); + v = POP(); + + if (unpack_iterable(v, oparg & 0xFF, oparg >> 8, + stack_pointer + totalargs)) { + stack_pointer += totalargs; + } else { + why = WHY_EXCEPTION; + } + Py_DECREF(v); + goto on_error;; + } + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/unpack_sequence --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/unpack_sequence Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,42 @@ + + PREDICTED_WITH_ARG(UNPACK_SEQUENCE); + TARGET(UNPACK_SEQUENCE) + v = POP(); + if (PyTuple_CheckExact(v) && + PyTuple_GET_SIZE(v) == oparg) { + switch (oparg) { + case 2: PyEval_SetCurInstr(INCA_UNPACK_TUPLE_TWO, oparg); break; + case 3: PyEval_SetCurInstr(INCA_UNPACK_TUPLE_THREE, oparg); break; + } // switch + PyObject **items = \ + ((PyTupleObject *)v)->ob_item; + while (oparg--) { + w = items[oparg]; + Py_INCREF(w); + PUSH(w); + } + Py_DECREF(v); + DISPATCH(); + } else if (PyList_CheckExact(v) && + PyList_GET_SIZE(v) == oparg) { + switch (oparg) { + case 2: PyEval_SetCurInstr(INCA_UNPACK_LIST_TWO, oparg); break; + case 3: PyEval_SetCurInstr(INCA_UNPACK_LIST_THREE, oparg); break; + } // switch + PyObject **items = \ + ((PyListObject *)v)->ob_item; + while (oparg--) { + w = items[oparg]; + Py_INCREF(w); + PUSH(w); + } + } else if (unpack_iterable(v, oparg, -1, + stack_pointer + oparg)) { + stack_pointer += oparg; + } else { + /* unpack_iterable() raised an exception */ + why = WHY_EXCEPTION; + } + Py_DECREF(v); + goto on_error;; + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/with_cleanup --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/with_cleanup Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,99 @@ + + TARGET(WITH_CLEANUP) + { + /* At the top of the stack are 1-3 values indicating + how/why we entered the finally clause: + - TOP = None + - (TOP, SECOND) = (WHY_{RETURN,CONTINUE}), retval + - TOP = WHY_*; no retval below it + - (TOP, SECOND, THIRD) = exc_info() + (FOURTH, FITH, SIXTH) = previous exception for EXCEPT_HANDLER + Below them is EXIT, the context.__exit__ bound method. + In the last case, we must call + EXIT(TOP, SECOND, THIRD) + otherwise we must call + EXIT(None, None, None) + + In the first two cases, we remove EXIT from the + stack, leaving the rest in the same order. In the + third case, we shift the bottom 3 values of the + stack down, and replace the empty spot with NULL. + + In addition, if the stack represents an exception, + *and* the function call returns a 'true' value, we + push WHY_SILENCED onto the stack. END_FINALLY will + then not re-raise the exception. (But non-local + gotos should still be resumed.) + */ + + PyObject *exit_func; + u = TOP(); + if (u == Py_None) { + (void)POP(); + exit_func = TOP(); + SET_TOP(u); + v = w = Py_None; + } + else if (PyLong_Check(u)) { + (void)POP(); + switch(PyLong_AsLong(u)) { + case WHY_RETURN: + case WHY_CONTINUE: + /* Retval in TOP. */ + exit_func = SECOND(); + SET_SECOND(TOP()); + SET_TOP(u); + break;;;;; + default: + exit_func = TOP(); + SET_TOP(u); + break;;;;; + } + u = v = w = Py_None; + } + else { + PyObject *tp, *exc, *tb; + PyTryBlock *block; + v = SECOND(); + w = THIRD(); + tp = FOURTH(); + exc = PEEK(5); + tb = PEEK(6); + exit_func = PEEK(7); + SET_VALUE(7, tb); + SET_VALUE(6, exc); + SET_VALUE(5, tp); + /* UNWIND_EXCEPT_HANDLER will pop this off. */ + SET_FOURTH(NULL); + /* We just shifted the stack down, so we have + to tell the except handler block that the + values are lower than it expects. */ + block = &f->f_blockstack[f->f_iblock - 1]; + assert(block->b_type == EXCEPT_HANDLER); + block->b_level--; + } + + /* XXX Not the fastest way to call it... */ + x = PyObject_CallFunctionObjArgs(exit_func, u, v, w, + NULL); + + Py_DECREF(exit_func); + if (x == NULL) + goto on_error;;;;;; /* Go to error exit */ + + if (u != Py_None) + err = PyObject_IsTrue(x); + else + err = 0; + Py_DECREF(x); + + if (err < 0) + goto on_error; /* Go to error exit */ + else if (err > 0) { + err = 0; + /* There was an exception and a True return */ + PUSH(PyLong_FromLong((long) WHY_SILENCED)); + } + PREDICT(END_FINALLY); + goto on_error;;;;;; + } diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/yield_from --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/yield_from Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,34 @@ + + TARGET(YIELD_FROM) + u = POP(); + x = TOP(); + /* send u to x */ + if (PyGen_CheckExact(x)) { + retval = _PyGen_Send((PyGenObject *)x, u); + } else { + _Py_IDENTIFIER(send); + if (u == Py_None) + retval = PyIter_Next(x); + else + retval = _PyObject_CallMethodId(x, &PyId_send, "O", u); + } + Py_DECREF(u); + if (!retval) { + PyObject *val; + x = POP(); /* Remove iter from stack */ + Py_DECREF(x); + err = PyGen_FetchStopIterationValue(&val); + if (err < 0) { + x = NULL; + goto on_error; + } + x = val; + PUSH(x); + goto fast_next_opcode; + } + /* x remains on stack, retval is value to be yielded */ + f->f_stacktop = stack_pointer; + why = WHY_YIELD; + /* and repeat... */ + f->f_lasti--; + goto fast_yield; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/default/yield_value --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/default/yield_value Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,6 @@ + + TARGET(YIELD_VALUE) + retval = POP(); + f->f_stacktop = stack_pointer; + why = WHY_YIELD; + goto fast_yield; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/inca-instr-decoding.h.impl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/inca-instr-decoding.h.impl Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,32 @@ +<%namespace file="base.impl" import="*"/>\ +<%! +def has_arg(instr): + ## don't generate code for unknown opcodes... + if instr.id in ["_unknown_opcode", 'NOP']: + return False + ## x_WITH_IMPL instruction don't have an implementation... + if not instr.impl: + return True + ## check against the "oparg" string being present in the operation implementation... + impl= instr.impl + if hasattr(instr, 'parent'): + impl+= instr.parent.impl + if 'oparg' in impl: + return True + return False +%> + +static inline int +instr_has_argument(unsigned char opcode) { + switch (opcode) { +% for opcode, instr_obj in enumerate(instr_set): + % if has_arg(instr_obj): + case ${ instr_obj.id.upper() }: + % endif +% endfor + return 1; + } // switch-case + + return 0; +} // END instr_has_argument + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/inlined/PyComplex_Type --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/inlined/PyComplex_Type Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,27 @@ +%if instr.function_id in ['nb_add', 'nb_multiply', 'nb_subtract']: +<% inlined= True %> + #define CONVERT(OBJ) ((PyComplexObject*)(OBJ))->cval + { + Py_complex r, a, b; + a= CONVERT(v); + b= CONVERT(w); + % if instr.function_id == 'nb_add': + PyFPE_START_PROTECT("complex_add", return 0); + r.real = a.real + b.real; + r.imag = a.imag + b.imag; + PyFPE_END_PROTECT(r); + % elif instr.function_id == 'nb_multiply': + PyFPE_START_PROTECT("complex_mult", return 0); + r.real = a.real*b.real - a.imag*b.imag; + r.imag = a.real*b.imag + a.imag*b.real; + PyFPE_END_PROTECT(r); + % elif instr.function_id == 'nb_subtract': + PyFPE_START_PROTECT("complex_add", return 0); + r.real = a.real - b.real; + r.imag = a.imag - b.imag; + PyFPE_END_PROTECT(r); + % endif + x= PyComplex_FromCComplex(r); + } + #undef CONVERT +%endif diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/inlined/PyFloat_Type --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/inlined/PyFloat_Type Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,27 @@ +%if instr.function_id in ['nb_add', 'nb_multiply', 'nb_subtract']: +<% inlined= True %> + { + double a, b; + + % if instr.function_id == 'nb_add': + PyFPE_START_PROTECT("add", (a= 0)); + a= PyFloat_AS_DOUBLE(v); + b= PyFloat_AS_DOUBLE(w); + a += b; + PyFPE_END_PROTECT(a); + % elif instr.function_id == 'nb_multiply': + PyFPE_START_PROTECT("mult", (a= 0)); + a= PyFloat_AS_DOUBLE(v); + b= PyFloat_AS_DOUBLE(w); + a *= b; + PyFPE_END_PROTECT(a); + % elif instr.function_id == 'nb_subtract': + PyFPE_START_PROTECT("sub", (a= 0)); + a= PyFloat_AS_DOUBLE(v); + b= PyFloat_AS_DOUBLE(w); + a -= b; + PyFPE_END_PROTECT(a); + % endif + x= PyFloat_FromDouble(a); + } +%endif diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/inlined/PyLong_Type --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/inlined/PyLong_Type Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,38 @@ +%if instr.function_id in ['nb_add', 'nb_multiply', 'nb_subtract']: +<% inlined= True %> +<%text>\ +#define MEDIUM_VALUE(x) (Py_SIZE(x) < 0 ? -(sdigit)((PyLongObject*)x)->ob_digit[0] : \ + (Py_SIZE(x) == 0 ? (sdigit)0 : \ + (sdigit)((PyLongObject*)x)->ob_digit[0])) + +#define ABS(x) ((x) < 0 ? -(x) : (x)) +\ + + % if instr.function_id == 'nb_add': + if (ABS(Py_SIZE(v)) <= 1 && ABS(Py_SIZE(w)) <= 1) + x = PyLong_FromLong(MEDIUM_VALUE(v) + + MEDIUM_VALUE(w)); + else + x= PyLong_Type.tp_as_number->nb_add(v, w); + % elif instr.function_id == 'nb_multiply': + if (ABS(Py_SIZE(v)) <= 1 && ABS(Py_SIZE(w)) <= 1) { + stwodigits temp = (stwodigits)(MEDIUM_VALUE(v)) * MEDIUM_VALUE(w); +#ifdef HAVE_LONG_LONG + x= PyLong_FromLongLong((PY_LONG_LONG)temp); +#else + if (temp >= LONG_MIN && temp <= LONG_MAX) + x= PyLong_FromLong((long)temp); +#endif + } + else + x= PyLong_Type.tp_as_number->nb_multiply(v, w); + % elif instr.function_id == 'nb_subtract': + if (ABS(Py_SIZE(v)) <= 1 && ABS(Py_SIZE(w)) <= 1) + x = PyLong_FromLong(MEDIUM_VALUE(v)-MEDIUM_VALUE(w)); + else + x= PyLong_Type.tp_as_number->nb_subtract(v, w); + % endif + +#undef MEDIUM_VALUE +#undef ABS +%endif diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/inlined/PyRangeIter_Type --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/inlined/PyRangeIter_Type Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,23 @@ + { + typedef struct { + PyObject_HEAD + long index; + long start; + long step; + long len; + } rangeiterobject; + + if (((rangeiterobject*)v)->index < ((rangeiterobject*)v)->len) { + /* cast to unsigned to avoid possible signed overflow + in intermediate calculations. */ + x= PyLong_FromLong((long)(((rangeiterobject*)v)->start + + (unsigned long)(((rangeiterobject*)v)->index++) + * ((rangeiterobject*)v)->step)); + PUSH(x); + DISPATCH(); + } + else { + x = NULL; + goto FOR_ITER_CONTINUE; + } // if + } diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/instr-targets.h.impl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/instr-targets.h.impl Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,24 @@ +<%! + import instructions +%>\ + +static void *opcode_targets[ ${ len(instr_set.set) } ]= { + % for opcode, instr_obj in enumerate(instr_set): + % if type(instr_obj) == instructions.UnknownInstr or instr_obj.id == 'NOP': + &&${ "_unknown_opcode".ljust(instr_set.max_ident_len + 15 + 7) }, // ${opcode} + % else: + &&TARGET_${instr_obj.id.ljust( instr_set.max_ident_len + 15)}, // ${opcode} + % endif + % endfor +}; + + +static void *opcode_no_dispatch_targets[ ${ len(instr_set.set) } ]= { + % for opcode, instr_obj in enumerate(instr_set): + % if type(instr_obj) == instructions.UnknownInstr or instr_obj.id == 'NOP': + &&${ "_unknown_opcode".ljust(instr_set.max_ident_len + 15 + 7) }, // ${opcode} + % else: + &&TARGET_${ instr_obj.id.ljust( instr_set.max_ident_len + 15).strip() }_SKIP_DISPATCH, // ${opcode} + % endif + % endfor +}; diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/opcode-defs.h.impl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/opcode-defs.h.impl Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,10 @@ +<%! + import instructions +%>\ + +% for opcode, instr_obj in enumerate(instr_set): + % if type(instr_obj) != instructions.UnknownInstr: +#define ${instr_obj.id.ljust( instr_set.max_ident_len + 15)} ${opcode} + % endif +% endfor + diff -r 2f563908ebc5 -r be51373d99cf cgen/templates/rewrite-fun.h.impl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/templates/rewrite-fun.h.impl Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,119 @@ +<%! + import instructions +%>\ +\ + +#include "opcode.h" +#include "pystate.h" +#include "frameobject.h" + +#define REWRITE_OPCODE(ID) \ + *INSTR_PTR()= ID; \ + return ID; \ + + +#define INSTR_PTR() instr_ptr + +#ifndef USE_OPT_SBR + +#define PyEval_RewriteInstr(DONTCARE) ; + +#define PyEval_SetCurInstr(DONTCARE1, DONTCARE2) ; + +#endif + +#define CMP_TYPE() void* + +typedef int opcode_t; + +static inline opcode_t +PyEval_RewriteInstr(CMP_TYPE() selector) { + PyThreadState *tstate= PyThreadState_GET(); + register PyFrameObject *f= tstate->frame; + + if (f != NULL + && f->f_code != NULL + ) + { + register unsigned char *INSTR_PTR()= (unsigned char*)PyBytes_AS_STRING(f->f_code->co_code) + f->f_lasti; + register opcode_t prev= (opcode_t)*INSTR_PTR(); + register int oparg= ((INSTR_PTR()[2]<<8) + INSTR_PTR()[1]); + + switch (prev) { + % for d in sorted(domain, key=lambda x: x.id): + % if len(domain[d]) > 0: + case ${d.id}: + % if d.id == 'COMPARE_OP': + /* 20110905/1640/sbr: + There is an error with comparing complex data structures that called + PyObject_RichCompare on elements stored within. This would inevitably + lead to an incorrect quickening and later on cause errors, if the + operand types actually *should* match once, we would call the inline + cached derivative, even though the oparg-semantics clearly indicate + that this is not what we want... + (Case in point: Lib/test/regrtest.py -> unittest/case#assertIn) + */ + if (oparg > Py_GE) + break; + % endif + if (0) /* simplify code generation */; + % for r in sorted(domain[d], key=lambda x: x.id): + % if hasattr(r, 'function_id') and r.function_id and (r.function_id != 'unicode_concatenate'): + % if 'nb_' in r.function_id: + else if ((CMP_TYPE())${r.type_id}.tp_as_number->${ r.function_id } == selector) { + % elif 'sq_' in r.function_id: + else if ((CMP_TYPE())${r.type_id}.tp_as_sequence->${ r.function_id } == selector) { + % elif 'mp_' in r.function_id: + else if ((CMP_TYPE())${r.type_id}.tp_as_mapping->${ r.function_id } == selector) { + % elif 'tp_iternext' in r.function_id: + else if ((CMP_TYPE())${r.type_id}.tp_iternext == selector) { + % elif 'tp_richcompare' in r.function_id: + else if ((CMP_TYPE())${r.type_id}.tp_richcompare == selector) { + % else: + else if ((CMP_TYPE())&${r.function_id} == selector) { + % endif + REWRITE_OPCODE( ${ r.id } ); + } + % endif + % endfor + break; + % endif + % endfor + default: + return prev; + } // switch-case + + return prev; + } // if + + return -1; +} // END + + +static inline opcode_t +PyEval_SetCurInstr(const opcode_t new, const int oparg) { + PyThreadState *tstate= PyThreadState_GET(); + register PyFrameObject *f= tstate->frame; + +#ifndef USE_OPT_ENABLE_QUICKENING + return -1; +#endif + + if (f != NULL + && f->f_code != NULL + ) + { + register unsigned char *INSTR_PTR()= (unsigned char*)PyBytes_AS_STRING(f->f_code->co_code) + f->f_lasti; + register opcode_t prev= (opcode_t)*INSTR_PTR(); + + REWRITE_OPCODE( new ); + return new; + } // if + + return -1; +} // END PyEval_SetCurInstr + +## proper cleanup the defined macros such that successive invocation of this +## template do not interfere... +#undef REWRITE_OPCODE +#undef RW_MASK diff -r 2f563908ebc5 -r be51373d99cf cgen/typedefs.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgen/typedefs.py Thu Apr 26 11:08:47 2012 -0700 @@ -0,0 +1,1724 @@ +"""Contains a dump of data of the C-struct's corresponding to Python object types. +This covers mostly +""" + +TYPE_DATA= { + 'PyLong_Type' : { + 'address' : 0x7b6cc0, + 'tp_basicsize' : 24, + 'tp_itemsize' : 4, + 'tp_dealloc' : 0x510050 , ## long_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0x511a00 , ## long_repr + 'tp_as_number' : { + 'nb_add' : 0x515090 , ## long_add + 'nb_subtract' : 0x514f50 , ## long_sub + 'nb_multiply' : 0x5149f0 , ## long_mul + 'nb_remainder' : 0x5161a0 , ## long_mod + 'nb_divmod' : 0x5160d0 , ## long_divmod + 'nb_power' : 0x516f80 , ## long_pow + 'nb_negative' : 0x518170 , ## long_neg + 'nb_positive' : 0x512930 , ## long_long + 'nb_absolute' : 0x517f90 , ## long_abs + 'nb_bool' : 0x510100 , ## long_bool + 'nb_invert' : 0x5164d0 , ## long_invert + 'nb_lshift' : 0x513760 , ## long_lshift + 'nb_rshift' : 0x518a80 , ## long_rshift + 'nb_and' : 0x518a40 , ## long_and + 'nb_xor' : 0x518a00 , ## long_xor + 'nb_or' : 0x5189c0 , ## long_or + 'nb_int' : 0x512930 , ## long_long + 'nb_reserved' : 0, + 'nb_float' : 0x510b40 , ## long_float + 'nb_inplace_add' : 0, + 'nb_inplace_subtract' : 0, + 'nb_inplace_multiply' : 0, + 'nb_inplace_remainder' : 0, + 'nb_inplace_power' : 0, + 'nb_inplace_lshift' : 0, + 'nb_inplace_rshift' : 0, + 'nb_inplace_and' : 0, + 'nb_inplace_xor' : 0, + 'nb_inplace_or' : 0, + 'nb_floor_divide' : 0x516060 , ## long_div + 'nb_true_divide' : 0x510c70 , ## long_true_divide + 'nb_inplace_floor_divide' : 0, + 'nb_inplace_true_divide' : 0, + 'nb_index' : 0x512930, ## long_long + }, + 'tp_as_sequence' : 0, + 'tp_as_mapping' : 0, + 'tp_hash' : 0x510060 , ## long_hash + 'tp_call' : 0, + 'tp_str' : 0x511a00 , ## long_repr + 'tp_getattro' : 0x418110 , ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 17040384, + 'tp_traverse' : 0, + 'tp_clear' : 0, + 'tp_richcompare' : 0x510410 , ## long_richcompare + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0, + 'tp_iternext' : 0, + 'tp_methods' : 0x7b7120, + 'tp_members' : 0, + 'tp_getset' : 0x7b7260, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0, + 'tp_new' : 0x5165b0 , ## long_new + 'tp_free' : 0x41a2c0 , ## PyObject_Free + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0, + }, + + 'PyFloat_Type' : { + 'address' : 0x7b3a80, + 'tp_name' : 0x55d1b6 , ## float + 'tp_basicsize' : 24, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x5034b0 , ## float_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0x5051a0 , ## float_repr + 'tp_as_number' : { + 'nb_add' : 0x506820 , ## float_add + 'nb_subtract' : 0x506620 , ## float_sub + 'nb_multiply' : 0x506a20 , ## float_mul + 'nb_remainder' : 0x506c20 , ## float_rem + 'nb_divmod' : 0x5060a0 , ## float_divmod + 'nb_power' : 0x507550 , ## float_pow + 'nb_negative' : 0x506370 , ## float_neg + 'nb_positive' : 0x507130 , ## float_float + 'nb_absolute' : 0x506530 , ## float_abs + 'nb_bool' : 0x5034f0 , ## float_bool + 'nb_invert' : 0, + 'nb_lshift' : 0, + 'nb_rshift' : 0, + 'nb_and' : 0, + 'nb_xor' : 0, + 'nb_or' : 0, + 'nb_int' : 0x504760 , ## float_trunc + 'nb_reserved' : 0, + 'nb_float' : 0x507130 , ## float_float + 'nb_inplace_add' : 0, + 'nb_inplace_subtract' : 0, + 'nb_inplace_multiply' : 0, + 'nb_inplace_remainder' : 0, + 'nb_inplace_power' : 0, + 'nb_inplace_lshift' : 0, + 'nb_inplace_rshift' : 0, + 'nb_inplace_and' : 0, + 'nb_inplace_xor' : 0, + 'nb_inplace_or' : 0, + 'nb_floor_divide' : 0x506320 , ## float_floor_div + 'nb_true_divide' : 0x506ef0 , ## float_div + 'nb_inplace_floor_divide' : 0, + 'nb_inplace_true_divide' : 0, + 'nb_index' : 0 + }, + 'tp_as_sequence' : 0, + 'tp_as_mapping' : 0, + 'tp_hash' : 0x5040d0 , ## float_hash + 'tp_call' : 0, + 'tp_str' : 0x505120 , ## float_str + 'tp_getattro' : 0x418110 , ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 263168, + 'tp_traverse' : 0, + 'tp_clear' : 0, + 'tp_richcompare' : 0x503bf0 , ## float_richcompare + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0, + 'tp_iternext' : 0, + 'tp_methods' : 0x7b3de0, + 'tp_members' : 0, + 'tp_getset' : 0x7b3f60, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0, + 'tp_new' : 0x504ac0 , ## float_new + 'tp_free' : 0, + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0, + }, + 'PyComplex_Type' : { + 'address' : 0x7abe40, + 'tp_name' : 0x55a017 , ## complex + 'tp_basicsize' : 32, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x4f8fa0 , ## complex_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0x4f9dd0 , ## complex_repr + 'tp_as_number' : { + 'nb_add' : 0x4fa900 , ## complex_add + 'nb_subtract' : 0x4fa710 , ## complex_sub + 'nb_multiply' : 0x4fad70 , ## complex_mul + 'nb_remainder' : 0x4f9220 , ## complex_remainder + 'nb_divmod' : 0x4f9200 , ## complex_divmod + 'nb_power' : 0x4faf80 , ## complex_pow + 'nb_negative' : 0x4fa420 , ## complex_neg + 'nb_positive' : 0x4fa4a0 , ## complex_pos + 'nb_absolute' : 0x4fa140 , ## complex_abs + 'nb_bool' : 0x4f8fb0 , ## complex_bool + 'nb_invert' : 0, + 'nb_lshift' : 0, + 'nb_rshift' : 0, + 'nb_and' : 0, + 'nb_xor' : 0, + 'nb_or' : 0, + 'nb_int' : 0x4f91e0 , ## complex_int + 'nb_reserved' : 0, + 'nb_float' : 0x4f91c0 , ## complex_float + 'nb_inplace_add' : 0, + 'nb_inplace_subtract' : 0, + 'nb_inplace_multiply' : 0, + 'nb_inplace_remainder' : 0, + 'nb_inplace_power' : 0, + 'nb_inplace_lshift' : 0, + 'nb_inplace_rshift' : 0, + 'nb_inplace_and' : 0, + 'nb_inplace_xor' : 0, + 'nb_inplace_or' : 0, + 'nb_floor_divide' : 0x4f91a0 , ## complex_int_div + 'nb_true_divide' : 0x4faaf0 , ## complex_div + 'nb_inplace_floor_divide' : 0, + 'nb_inplace_true_divide' : 0, + 'nb_index' : 0, + }, + 'tp_as_sequence' : 0, + 'tp_as_mapping' : 0, + 'tp_hash' : 0x4f9de0 , ## complex_hash + 'tp_call' : 0, + 'tp_str' : 0x4f9dc0 , ## complex_str + 'tp_getattro' : 0x418110 , ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 263168, + 'tp_traverse' : 0, + 'tp_clear' : 0, + 'tp_richcompare' : 0x4fa520 , ## complex_richcompare + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0, + 'tp_iternext' : 0, + 'tp_methods' : 0x7ac1e0, + 'tp_members' : 0x7ac260, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0x425830 , ## PyType_GenericAlloc + 'tp_new' : 0x4f96f0 , ## complex_new + 'tp_free' : 0x41a2c0 , ## PyObject_Free + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0, + }, + + 'PySet_Type' : { + 'address' : 0x7818a0, + 'tp_name' : 0x55b46e , ## set + 'tp_basicsize' : 200, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x41ce30 , ## set_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0x41cc20 , ## set_repr + 'tp_as_number' : { + 'nb_add' : 0, + 'nb_subtract' : 0x41ff20 , ## set_sub + 'nb_multiply' : 0, + 'nb_remainder' : 0, + 'nb_divmod' : 0, + 'nb_power' : 0, + 'nb_negative' : 0, + 'nb_positive' : 0, + 'nb_absolute' : 0, + 'nb_bool' : 0, + 'nb_invert' : 0, + 'nb_lshift' : 0, + 'nb_rshift' : 0, + 'nb_and' : 0x420960 , ## set_and + 'nb_xor' : 0x41fa90 , ## set_xor + 'nb_or' : 0x41f410 , ## set_or + 'nb_int' : 0, + 'nb_reserved' : 0, + 'nb_float' : 0, + 'nb_inplace_add' : 0, + 'nb_inplace_subtract' : 0x41dff0 , ## set_isub + 'nb_inplace_multiply' : 0, + 'nb_inplace_remainder' : 0, + 'nb_inplace_power' : 0, + 'nb_inplace_lshift' : 0, + 'nb_inplace_rshift' : 0, + 'nb_inplace_and' : 0x420880 , ## set_iand + 'nb_inplace_xor' : 0x41f950 , ## set_ixor + 'nb_inplace_or' : 0x41e9f0 , ## set_ior + 'nb_floor_divide' : 0, + 'nb_true_divide' : 0, + 'nb_inplace_floor_divide' : 0, + 'nb_inplace_true_divide' : 0, + 'nb_index' : 0, + }, + 'tp_as_sequence' : { + 'sq_length' : 0x41c1b0 , ## set_len + 'sq_concat' : 0, + 'sq_repeat' : 0, + 'sq_item' : 0, + 'was_sq_slice' : 0, + 'sq_ass_item' : 0, + 'was_sq_ass_slice' : 0, + 'sq_contains' : 0x41f010 , ## set_contains + 'sq_inplace_concat' : 0, + 'sq_inplace_repeat' : 0, + }, + 'tp_as_mapping' : 0, + 'tp_hash' : 0x417dd0 , ## PyObject_HashNotImplemented + 'tp_call' : 0, + 'tp_str' : 0, + 'tp_getattro' : 0x418110 , ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 0x279552, + 'tp_traverse' : 0x41dc30 , ## set_traverse + 'tp_clear' : 0x41da00 , ## set_clear_internal + 'tp_richcompare' : 0x41ee50 , ## set_richcompare + 'tp_weaklistoffset' : 192, + 'tp_iter' : 0x41cb80 , ## set_iter + 'tp_iternext' : 0, + 'tp_methods' : 0x781e00, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0x41f540 , ## set_init + 'tp_alloc' : 0x425830 , ## PyType_GenericAlloc + 'tp_new' : 0x41f160 , ## set_new + 'tp_free' : 0x4b20f0 , ## PyObject_GC_Del + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0, + }, + + 'PyDict_Type' : { + 'address' : 0x7b74a0, + 'tp_name' : 0x5456d0 , ## dict + 'tp_basicsize' : 248, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x51b630 , ## dict_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0x51ca20 , ## dict_repr + 'tp_as_number' : 0, + 'tp_as_sequence' : { + 'sq_length' : 0, + 'sq_concat' : 0, + 'sq_repeat' : 0, + 'sq_item' : 0, + 'was_sq_slice' : 0, + 'sq_ass_item' : 0, + 'was_sq_ass_slice' : 0, + 'sq_contains' : 0x51a720 , ## PyDict_Contains + 'sq_inplace_concat' : 0, + 'sq_inplace_repeat' : 0 + }, + 'tp_as_mapping' : { + 'mp_length' : 0x519770 , ## dict_length + 'mp_subscript' : 0x51ac60 , ## dict_subscript + 'mp_ass_subscript' : 0x51d970 ## dict_ass_sub + }, + 'tp_hash' : 0x417dd0 , ## PyObject_HashNotImplemented + 'tp_call' : 0, + 'tp_str' : 0, + 'tp_getattro' : 0x418110 , ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 537150464, + 'tp_traverse' : 0x51c940 , ## dict_traverse + 'tp_clear' : 0x51baf0 , ## dict_tp_clear + 'tp_richcompare' : 0x51cd60 , ## dict_richcompare + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x51d250 , ## dict_iter + 'tp_iternext' : 0, + 'tp_methods' : 0x7b8200, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0x51d8b0 , ## dict_init + 'tp_alloc' : 0x425830 , ## PyType_GenericAlloc + 'tp_new' : 0x5197b0 , ## dict_new + 'tp_free' : 0x4b20f0 , ## PyObject_GC_Del + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0, + }, + + 'PyList_Type' : { + 'address' : 0x7b5f40, + 'tp_name' : 0x55cf61 , ## list + 'tp_basicsize' : 40, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x50d0c0 , ## list_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0x50e230 , ## list_repr + 'tp_as_number' : 0, + 'tp_as_sequence' : { + 'sq_length' : 0x50b650 , ## list_length + 'sq_concat' : 0x50d5e0 , ## list_concat + 'sq_repeat' : 0x50d4f0 , ## list_repeat + 'sq_item' : 0x50cc30 , ## list_item + 'was_sq_slice' : 0, + 'sq_ass_item' : 0x50f950 , ## list_ass_item + 'was_sq_ass_slice' : 0, + 'sq_contains' : 0x50be70 , ## list_contains + 'sq_inplace_concat' : 0x50f190 , ## list_inplace_concat + 'sq_inplace_repeat' : 0x50c930 ## list_inplace_repeat + }, + 'tp_as_mapping' : { + 'mp_length' : 0x50b650 , ## list_length + 'mp_subscript' : 0x50e060 , ## list_subscript + 'mp_ass_subscript' : 0x50fa20 ## list_ass_subscript + }, + 'tp_hash' : 0x417dd0 , ## PyObject_HashNotImplemented + 'tp_call' : 0, + 'tp_str' : 0, + 'tp_getattro' : 0x418110 , ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 33833984, + 'tp_traverse' : 0x50b6b0 , ## list_traverse + 'tp_clear' : 0x50b950 , ## list_clear + 'tp_richcompare' : 0x50ce20 , ## list_richcompare + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x50cd70 , ## list_iter + 'tp_iternext' : 0, + 'tp_methods' : 0x7b6560, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0x50f1d0 , ## list_init + 'tp_alloc' : 0x425830 , ## PyType_GenericAlloc + 'tp_new' : 0x422ec0 , ## PyType_GenericNew + 'tp_free' : 0x4b20f0 , ## PyObject_GC_Del + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0, + }, + + 'PyTuple_Type' : { + 'address' : 0x783060, + 'tp_name' : 0x552040 , ## tuple + 'tp_basicsize' : 24, + 'tp_itemsize' : 8, + 'tp_dealloc' : 0x421e70 , ## tupledealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0x422560 , ## tuplerepr + 'tp_as_number' : 0, + 'tp_as_sequence' : { + 'sq_length' : 0x421530 , ## tuplelength + 'sq_concat' : 0x422370 , ## tupleconcat + 'sq_repeat' : 0x422260 , ## tuplerepeat + 'sq_item' : 0x421930 , ## tupleitem + 'was_sq_slice' : 0, + 'sq_ass_item' : 0, + 'was_sq_ass_slice' : 0, + 'sq_contains' : 0x4217a0 , ## tuplecontains + 'sq_inplace_concat' : 0, + 'sq_inplace_repeat' : 0 + }, + 'tp_as_mapping' : { + 'mp_length' : 0x421530 , ## tuplelength + 'mp_subscript' : 0x422ab0 , ## tuplesubscript + 'mp_ass_subscript' : 0 + }, + 'tp_hash' : 0x421de0 , ## tuplehash + 'tp_call' : 0, + 'tp_str' : 0, + 'tp_getattro' : 0x418110 , ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 67388416, + 'tp_traverse' : 0x421540 , ## tupletraverse + 'tp_clear' : 0, + 'tp_richcompare' : 0x421be0 , ## tuplerichcompare + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x421b30 , ## tuple_iter + 'tp_iternext' : 0, + 'tp_methods' : 0x7834c0, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0, + 'tp_new' : 0x422440 , ## tuple_new + 'tp_free' : 0x4b20f0 , ## PyObject_GC_Del + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0, + }, + + 'PyRange_Type' : { + 'address' : 0x781000, + 'tp_name' : 0x55c8eb , ## range + 'tp_basicsize' : 40, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x41b0b0 , ## range_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0x41bb10 , ## range_repr + 'tp_as_number' : 0, + 'tp_as_sequence' : { + 'sq_length' : 0x41b680 , ## range_length + 'sq_concat' : 0, + 'sq_repeat' : 0, + 'sq_item' : 0x41bb60 , ## range_item + 'was_sq_slice' : 0, + 'sq_ass_item' : 0, + 'was_sq_ass_slice' : 0, + 'sq_contains' : 0, + 'sq_inplace_concat' : 0, + 'sq_inplace_repeat' : 0 + }, + 'tp_as_mapping' : 0, + 'tp_hash' : 0, + 'tp_call' : 0, + 'tp_str' : 0, + 'tp_getattro' : 0x418110 , ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 262144, + 'tp_traverse' : 0, + 'tp_clear' : 0, + 'tp_richcompare' : 0, + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x41bfd0 , ## range_iter + 'tp_iternext' : 0, + 'tp_methods' : 0x7815c0, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0, + 'tp_new' : 0x41b7c0 , ## range_new + 'tp_free' : 0, + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0 + }, + + 'PyRangeIter_Type' : { + 'address' : 0x7811a0, + 'tp_name' : 0x539f2c , ## range_iterator + 'tp_basicsize' : 48, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x41a2c0 , ## PyObject_Free + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0, + 'tp_as_number' : 0, + 'tp_as_sequence' : 0, + 'tp_as_mapping' : 0, + 'tp_hash' : 0, + 'tp_call' : 0, + 'tp_str' : 0, + 'tp_getattro' : 0x418110 , ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 262144, + 'tp_traverse' : 0, + 'tp_clear' : 0, + 'tp_richcompare' : 0, + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x417210 , ## PyObject_SelfIter + 'tp_iternext' : 0x41b150 , ## rangeiter_next + 'tp_methods' : 0x781620, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0, + 'tp_new' : 0x41b6e0 , ## rangeiter_new + 'tp_free' : 0, + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0 + + }, + + 'PyLongRangeIter_Type' : { + 'address' : 0x781340, + 'tp_name' : 0x539f28 , ## longrange_iterator + 'tp_basicsize' : 48, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x41aff0 , ## longrangeiter_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0, + 'tp_as_number' : 0, + 'tp_as_sequence' : 0, + 'tp_as_mapping' : 0, + 'tp_hash' : 0, + 'tp_call' : 0, + 'tp_str' : 0, + 'tp_getattro' : 0x418110 , ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 262144, + 'tp_traverse' : 0, + 'tp_clear' : 0, + 'tp_richcompare' : 0, + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x417210 , ## PyObject_SelfIter + 'tp_iternext' : 0x41b1a0 , ## longrangeiter_next + 'tp_methods' : 0x781660, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0, + 'tp_new' : 0, + 'tp_free' : 0, + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0 + }, + + 'PyBool_Type' : { + 'tp_name' : 0x558cfb , ## bool + 'tp_basicsize' : 32, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0, + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0x4e7390 , ## bool_repr + 'tp_as_number' : { + 'nb_add' : 0, + 'nb_subtract' : 0, + 'nb_multiply' : 0, + 'nb_remainder' : 0, + 'nb_divmod' : 0, + 'nb_power' : 0, + 'nb_negative' : 0, + 'nb_positive' : 0, + 'nb_absolute' : 0, + 'nb_bool' : 0, + 'nb_invert' : 0, + 'nb_lshift' : 0, + 'nb_rshift' : 0, + 'nb_and' : 0x4e7210 , ## bool_and + 'nb_xor' : 0x4e72c0 , ## bool_xor + 'nb_or' : 0x4e7260 , ## bool_or + 'nb_int' : 0, + 'nb_reserved' : 0, + 'nb_float' : 0, + 'nb_inplace_add' : 0, + 'nb_inplace_subtract' : 0, + 'nb_inplace_multiply' : 0, + 'nb_inplace_remainder' : 0, + 'nb_inplace_power' : 0, + 'nb_inplace_lshift' : 0, + 'nb_inplace_rshift' : 0, + 'nb_inplace_and' : 0, + 'nb_inplace_xor' : 0, + 'nb_inplace_or' : 0, + 'nb_floor_divide' : 0, + 'nb_true_divide' : 0, + 'nb_inplace_floor_divide' : 0, + 'nb_inplace_true_divide' : 0, + 'nb_index' : 0 + }, + 'tp_as_sequence' : 0, + 'tp_as_mapping' : 0, + 'tp_hash' : 0, + 'tp_call' : 0, + 'tp_str' : 0x4e7390 , ## bool_repr + 'tp_getattro' : 0, + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 262144, + 'tp_traverse' : 0, + 'tp_clear' : 0, + 'tp_richcompare' : 0, + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0, + 'tp_iternext' : 0, + 'tp_methods' : 0, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0x7b6cc0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0, + 'tp_new' : 0x4e7320 , ## bool_new + 'tp_free' : 0, + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0 + }, + + 'PyUnicode_Type' : { + 'tp_name' : 0x53c509 , ## str + 'tp_basicsize' : 56, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x437200 , ## unicode_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0x440a10 , ## unicode_repr + 'tp_as_number' : { + 'nb_add' : 0, + 'nb_subtract' : 0, + 'nb_multiply' : 0, + 'nb_remainder' : 0x446650 , ## unicode_mod + 'nb_divmod' : 0, + 'nb_power' : 0, + 'nb_negative' : 0, + 'nb_positive' : 0, + 'nb_absolute' : 0, + 'nb_bool' : 0, + 'nb_invert' : 0, + 'nb_lshift' : 0, + 'nb_rshift' : 0, + 'nb_and' : 0, + 'nb_xor' : 0, + 'nb_or' : 0, + 'nb_int' : 0, + 'nb_reserved' : 0, + 'nb_float' : 0, + 'nb_inplace_add' : 0, + 'nb_inplace_subtract' : 0, + 'nb_inplace_multiply' : 0, + 'nb_inplace_remainder' : 0, + 'nb_inplace_power' : 0, + 'nb_inplace_lshift' : 0, + 'nb_inplace_rshift' : 0, + 'nb_inplace_and' : 0, + 'nb_inplace_xor' : 0, + 'nb_inplace_or' : 0, + 'nb_floor_divide' : 0, + 'nb_true_divide' : 0, + 'nb_inplace_floor_divide' : 0, + 'nb_inplace_true_divide' : 0, + 'nb_index' : 0 + }, + 'tp_as_sequence' : { + 'sq_length' : 0x434c10 , ## unicode_length + 'sq_concat' : 0x44bc70 , ## PyUnicodeUCS2_Concat + 'sq_repeat' : 0x436210 , ## unicode_repeat + 'sq_item' : 0x444cf0 , ## unicode_getitem + 'was_sq_slice' : 0, + 'sq_ass_item' : 0, + 'was_sq_ass_slice' : 0, + 'sq_contains' : 0x449850 , ## PyUnicodeUCS2_Contains + 'sq_inplace_concat' : 0, + 'sq_inplace_repeat' : 0 + }, + 'tp_as_mapping' : { + 'mp_length' : 0x434c10 , ## unicode_length + 'mp_subscript' : 0x43bb80 , ## unicode_subscript + 'mp_ass_subscript' : 0 + }, + 'tp_hash' : 0x434b90 , ## unicode_hash + 'tp_call' : 0, + 'tp_str' : 0x4436a0 , ## unicode_str + 'tp_getattro' : 0x418110 , ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 268698624, + 'tp_traverse' : 0, + 'tp_clear' : 0, + 'tp_richcompare' : 0x4378d0 , ## PyUnicodeUCS2_RichCompare + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x437150 , ## unicode_iter + 'tp_iternext' : 0, + 'tp_methods' : 0x786400, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0x7838a0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0, + 'tp_new' : 0x44b600 , ## unicode_new + 'tp_free' : 0x41a2c0 , ## PyObject_Free + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0 + }, + + 'PyByteArray_Type' : { + 'tp_name' : 0x5591ff , ## bytearray + 'tp_basicsize' : 48, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x4e8890 , ## bytearray_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0x4e85b0 , ## bytearray_repr + 'tp_as_number' : 0, + 'tp_as_sequence' : { + 'sq_length' : 0x4e7470 , ## bytearray_length + 'sq_concat' : 0x4eafc0 , ## PyByteArray_Concat + 'sq_repeat' : 0x4e9f60 , ## bytearray_repeat + 'sq_item' : 0x4e7ee0 , ## bytearray_getitem + 'was_sq_slice' : 0, + 'sq_ass_item' : 0x4ee540 , ## bytearray_setitem + 'was_sq_ass_slice' : 0, + 'sq_contains' : 0x4e8180 , ## bytearray_contains + 'sq_inplace_concat' : 0x4ede50 , ## bytearray_iconcat + 'sq_inplace_repeat' : 0x4e8b20 ## bytearray_irepeat + }, + 'tp_as_mapping' : { + 'mp_length' : 0x4e7470 , ## bytearray_length + 'mp_subscript' : 0x4e9dd0 , ## bytearray_subscript + 'mp_ass_subscript' : 0x4ea3c0 ## bytearray_ass_subscript + }, + 'tp_hash' : 0, + 'tp_call' : 0, + 'tp_str' : 0x4e8850 , ## bytearray_str + 'tp_getattro' : 0x418110 , ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0x7a6ab0, + 'tp_flags' : 263168, + 'tp_traverse' : 0, + 'tp_clear' : 0, + 'tp_richcompare' : 0x4e83a0 , ## bytearray_richcompare + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x4e82e0 , ## bytearray_iter + 'tp_iternext' : 0, + 'tp_methods' : 0x7a6cc0, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0x4ee040 , ## bytearray_init + 'tp_alloc' : 0x425830 , ## PyType_GenericAlloc + 'tp_new' : 0x422ec0 , ## PyType_GenericNew + 'tp_free' : 0x41a2c0 , ## PyObject_Free + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0 + }, + + 'PyDictKeys_Type' : { + 'tp_name' : 0x55d945 , ## dict_keys + 'tp_basicsize' : 24, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x5198d0 , ## dictview_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0x51af80 , ## dictview_repr + 'tp_as_number' : { + 'nb_add' : 0, + 'nb_subtract' : 0x519db0 , ## dictviews_sub + 'nb_multiply' : 0, + 'nb_remainder' : 0, + 'nb_divmod' : 0, + 'nb_power' : 0, + 'nb_negative' : 0, + 'nb_positive' : 0, + 'nb_absolute' : 0, + 'nb_bool' : 0, + 'nb_invert' : 0, + 'nb_lshift' : 0, + 'nb_rshift' : 0, + 'nb_and' : 0x519d20 , ## dictviews_and + 'nb_xor' : 0x519c90 , ## dictviews_xor + 'nb_or' : 0x519c00 , ## dictviews_or + 'nb_int' : 0, + 'nb_reserved' : 0, + 'nb_float' : 0, + 'nb_inplace_add' : 0, + 'nb_inplace_subtract' : 0, + 'nb_inplace_multiply' : 0, + 'nb_inplace_remainder' : 0, + 'nb_inplace_power' : 0, + 'nb_inplace_lshift' : 0, + 'nb_inplace_rshift' : 0, + 'nb_inplace_and' : 0, + 'nb_inplace_xor' : 0, + 'nb_inplace_or' : 0, + 'nb_floor_divide' : 0, + 'nb_true_divide' : 0, + 'nb_inplace_floor_divide' : 0, + 'nb_inplace_true_divide' : 0, + 'nb_index' : 0 + }, + 'tp_as_sequence' : { + 'sq_length' : 0x5198b0 , ## dictview_len + 'sq_concat' : 0, + 'sq_repeat' : 0, + 'sq_item' : 0, + 'was_sq_slice' : 0, + 'sq_ass_item' : 0, + 'was_sq_ass_slice' : 0, + 'sq_contains' : 0x51cfa0 , ## dictkeys_contains + 'sq_inplace_concat' : 0, + 'sq_inplace_repeat' : 0 + }, + 'tp_as_mapping' : 0, + 'tp_hash' : 0, + 'tp_call' : 0, + 'tp_str' : 0, + 'tp_getattro' : 0x418110 , ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 278528, + 'tp_traverse' : 0x519890 , ## dictview_traverse + 'tp_clear' : 0, + 'tp_richcompare' : 0x51ae20 , ## dictview_richcompare + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x51d3f0 , ## dictkeys_iter + 'tp_iternext' : 0, + 'tp_methods' : 0x7dcde0, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0, + 'tp_new' : 0, + 'tp_free' : 0, + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0 + + }, + + 'PyDictValues_Type' : { + 'tp_name' : 0x55d95a , ## dict_values + 'tp_basicsize' : 24, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x5198d0 , ## dictview_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0x51af80 , ## dictview_repr + 'tp_as_number' : 0, + 'tp_as_sequence' : { + 'sq_length' : 0x5198b0 , ## dictview_len + 'sq_concat' : 0, + 'sq_repeat' : 0, + 'sq_item' : 0, + 'was_sq_slice' : 0, + 'sq_ass_item' : 0, + 'was_sq_ass_slice' : 0, + 'sq_contains' : 0, + 'sq_inplace_concat' : 0, + 'sq_inplace_repeat' : 0 + }, + 'tp_as_mapping' : 0, + 'tp_hash' : 0, + 'tp_call' : 0, + 'tp_str' : 0, + 'tp_getattro' : 0x418110 , ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 278528, + 'tp_traverse' : 0x519890 , ## dictview_traverse + 'tp_clear' : 0, + 'tp_richcompare' : 0, + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x51a810 , ## dictvalues_iter + 'tp_iternext' : 0, + 'tp_methods' : 0x7dce20, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0, + 'tp_new' : 0, + 'tp_free' : 0, + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0 + + }, + + 'PyZip_Type' : { + 'tp_name' : 0x5458ff , ## zip + 'tp_basicsize' : 40, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x453510 , ## zip_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0, + 'tp_as_number' : 0, + 'tp_as_sequence' : 0, + 'tp_as_mapping' : 0, + 'tp_hash' : 0, + 'tp_call' : 0, + 'tp_str' : 0, + 'tp_getattro' : 0x418110 , ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 279552, + 'tp_traverse' : 0x453150 , ## zip_traverse + 'tp_clear' : 0, + 'tp_richcompare' : 0, + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x417210 , ## PyObject_SelfIter + 'tp_iternext' : 0x4531c0 , ## zip_next + 'tp_methods' : 0, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0x425830 , ## PyType_GenericAlloc + 'tp_new' : 0x4532e0 , ## zip_new + 'tp_free' : 0x4b20f0 , ## PyObject_GC_Del + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0 + }, + 'PyMap_Type' : { + 'tp_name' : 0x53c162 , ## map + 'tp_basicsize' : 32, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x453580 , ## map_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0, + 'tp_as_number' : 0, + 'tp_as_sequence' : 0, + 'tp_as_mapping' : 0, + 'tp_hash' : 0, + 'tp_call' : 0, + 'tp_str' : 0, + 'tp_getattro' : 0x418110 , ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 279552, + 'tp_traverse' : 0x4530e0 , ## map_traverse + 'tp_clear' : 0, + 'tp_richcompare' : 0, + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x417210 , ## PyObject_SelfIter + 'tp_iternext' : 0x453770 , ## map_next + 'tp_methods' : 0, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0x425830 , ## PyType_GenericAlloc + 'tp_new' : 0x453660 , ## map_new + 'tp_free' : 0x4b20f0 , ## PyObject_GC_Del + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0 + + }, + 'PyEnum_Type' : { + 'tp_name' : 0x55a867 , ## enumerate + 'tp_basicsize' : 48, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x4fd7e0 , ## enum_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0, + 'tp_as_number' : 0, + 'tp_as_sequence' : 0, + 'tp_as_mapping' : 0, + 'tp_hash' : 0, + 'tp_call' : 0, + 'tp_str' : 0, + 'tp_getattro' : 0x418110 , ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 279552, + 'tp_traverse' : 0x4fd4a0 , ## enum_traverse + 'tp_clear' : 0, + 'tp_richcompare' : 0, + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x417210 , ## PyObject_SelfIter + 'tp_iternext' : 0x4fda20 , ## enum_next + 'tp_methods' : 0, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0x425830 , ## PyType_GenericAlloc + 'tp_new' : 0x4fd880 , ## enum_new + 'tp_free' : 0x4b20f0 , ## PyObject_GC_Del + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0 + }, + 'PyReversed_Type' : { + 'tp_name' : 0x5458e9 , ## reversed + 'tp_basicsize' : 32, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x4fd7a0 , ## reversed_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0, + 'tp_as_number' : 0, + 'tp_as_sequence' : 0, + 'tp_as_mapping' : 0, + 'tp_hash' : 0, + 'tp_call' : 0, + 'tp_str' : 0, + 'tp_getattro' : 0x418110 , ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 279552, + 'tp_traverse' : 0x4fd530 , ## reversed_traverse + 'tp_clear' : 0, + 'tp_richcompare' : 0, + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x417210 , ## PyObject_SelfIter + 'tp_iternext' : 0x4fd700 , ## reversed_next + 'tp_methods' : 0x7adf60, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0x425830 , ## PyType_GenericAlloc + 'tp_new' : 0x4fd5a0 , ## reversed_new + 'tp_free' : 0x4b20f1 , ## PyObject_GC_Del + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0, + }, + 'PySetIter_Type' : { + 'tp_name' : 0x53a038, ## set_iterator + 'tp_basicsize' : 48, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x41c1e0, ## setiter_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0, + 'tp_as_number' : 0, + 'tp_as_sequence' : 0, + 'tp_as_mapping' : 0, + 'tp_hash' : 0, + 'tp_call' : 0, + 'tp_str' : 0, + 'tp_getattro' : 0x418110, ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 278528, + 'tp_doc' : 0, + 'tp_traverse' : 0x41c1c0, ## setiter_traverse + 'tp_clear' : 0, + 'tp_richcompare' : 0, + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x417210, ## PyObject_SelfIter + 'tp_iternext' : 0x41ca70, ## setiter_iternext + 'tp_methods' : 0x781be0, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0, + 'tp_new' : 0, + 'tp_free' : 0, + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0 + }, + 'PyTupleIter_Type' : { + 'tp_name' : 0x53a216, ## tuple_iterator + 'tp_basicsize' : 32, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x421620, ## tupleiter_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0, + 'tp_as_number' : 0, + 'tp_as_sequence' : 0, + 'tp_as_mapping' : 0, + 'tp_hash' : 0, + 'tp_call' : 0, + 'tp_str' : 0, + 'tp_getattro' : 0x418110, ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 278528, + 'tp_doc' : 0, + 'tp_traverse' : 0x4215a0, ## tupleiter_traverse + 'tp_clear' : 0, + 'tp_richcompare' : 0, + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x417210, ## PyObject_SelfIter + 'tp_iternext' : 0x4215c0, ## tupleiter_next + 'tp_methods' : 0x783560, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0, + 'tp_new' : 0, + 'tp_free' : 0, + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0 + + }, + 'PyUnicodeIter_Type' : { + 'tp_name' : 0x53c584, ## str_iterator + 'tp_basicsize' : 32, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x436fb0, ## unicodeiter_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0, + 'tp_as_number' : 0, + 'tp_as_sequence' : 0, + 'tp_as_mapping' : 0, + 'tp_hash' : 0, + 'tp_call' : 0, + 'tp_str' : 0, + 'tp_getattro' : 0x418110, ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 278528, + 'tp_doc' : 0, + 'tp_traverse' : 0x434c20, ## unicodeiter_traverse + 'tp_clear' : 0, + 'tp_richcompare' : 0, + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x417210, ## PyObject_SelfIter + 'tp_iternext' : 0x4435a0, ## unicodeiter_next + 'tp_methods' : 0x786a00, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0, + 'tp_new' : 0, + 'tp_free' : 0, + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0 + }, + 'PyByteArrayIter_Type' : { + 'tp_name' : 0x559218, ## bytearray_iterator + 'tp_basicsize' : 32, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x4e8280, ## bytearrayiter_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0, + 'tp_as_number' : 0, + 'tp_as_sequence' : 0, + 'tp_as_mapping' : 0, + 'tp_hash' : 0, + 'tp_call' : 0, + 'tp_str' : 0, + 'tp_getattro' : 0x418110, ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 278528, + 'tp_doc' : 0, + 'tp_traverse' : 0x4e76e0, ## bytearrayiter_traverse + 'tp_clear' : 0, + 'tp_richcompare' : 0, + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x417210, ## PyObject_SelfIter + 'tp_iternext' : 0x4e7f40, ## bytearrayiter_next + 'tp_methods' : 0x7a72c0, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0, + 'tp_new' : 0, + 'tp_free' : 0, + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0 + }, + 'PyBytesIter_Type' : { + 'tp_name' : 0x5593de, ## bytes_iterator + 'tp_basicsize' : 32, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x4f0940, ## striter_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0, + 'tp_as_number' : 0, + 'tp_as_sequence' : 0, + 'tp_as_mapping' : 0, + 'tp_hash' : 0, + 'tp_call' : 0, + 'tp_str' : 0, + 'tp_getattro' : 0x418110, ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 278528, + 'tp_doc' : 0, + 'tp_traverse' : 0x4eeea0, ## striter_traverse + 'tp_clear' : 0, + 'tp_richcompare' : 0, + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x417210, ## PyObject_SelfIter + 'tp_iternext' : 0x4ef850, ## striter_next + 'tp_methods' : 0x7a9800, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0, + 'tp_new' : 0, + 'tp_free' : 0, + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0 + }, + 'PyListIter_Type' : { + 'tp_name' : 0x55cf86, ## list_iterator + 'tp_basicsize' : 32, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x50b840, ## listiter_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0, + 'tp_as_number' : 0, + 'tp_as_sequence' : 0, + 'tp_as_mapping' : 0, + 'tp_hash' : 0, + 'tp_call' : 0, + 'tp_str' : 0, + 'tp_getattro' : 0x418110, ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 278528, + 'tp_doc' : 0, + 'tp_traverse' : 0x50b710, ## listiter_traverse + 'tp_clear' : 0, + 'tp_richcompare' : 0, + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x417210, ## PyObject_SelfIter + 'tp_iternext' : 0x50b730, ## listiter_next + 'tp_methods' : 0x7b6700, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0, + 'tp_new' : 0, + 'tp_free' : 0, + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0 + }, + 'PyListRevIter_Type' : { # copied from pylistiter_type + 'tp_name' : 0x55cf86, ## list_iterator + 'tp_basicsize' : 32, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x50b840, ## listiter_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0, + 'tp_as_number' : 0, + 'tp_as_sequence' : 0, + 'tp_as_mapping' : 0, + 'tp_hash' : 0, + 'tp_call' : 0, + 'tp_str' : 0, + 'tp_getattro' : 0x418110, ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 278528, + 'tp_doc' : 0, + 'tp_traverse' : 0x50b710, ## listiter_traverse + 'tp_clear' : 0, + 'tp_richcompare' : 0, + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x417210, ## PyObject_SelfIter + 'tp_iternext' : 0x50b730, ## listiter_next + 'tp_methods' : 0x7b6700, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0, + 'tp_new' : 0, + 'tp_free' : 0, + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0 + }, + 'PyCallIter_Type' : { + 'tp_name' : 0x55ce63, ## callable_iterator + 'tp_basicsize' : 32, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x50b370, ## calliter_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0, + 'tp_as_number' : 0, + 'tp_as_sequence' : 0, + 'tp_as_mapping' : 0, + 'tp_hash' : 0, + 'tp_call' : 0, + 'tp_str' : 0, + 'tp_getattro' : 0x418110, ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 278528, + 'tp_doc' : 0, + 'tp_traverse' : 0x50b0f0, ## calliter_traverse + 'tp_clear' : 0, + 'tp_richcompare' : 0, + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x417210, ## PyObject_SelfIter + 'tp_iternext' : 0x50b1b0, ## calliter_iternext + 'tp_methods' : 0, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0, + 'tp_new' : 0, + 'tp_free' : 0, + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0 + }, + 'PySeqIter_Type' : { + 'tp_name' : 0x539f32, ## iterator + 'tp_basicsize' : 32, + 'tp_itemsize' : 0, + 'tp_dealloc' : 0x50b3f0, ## iter_dealloc + 'tp_print' : 0, + 'tp_getattr' : 0, + 'tp_setattr' : 0, + 'tp_reserved' : 0, + 'tp_repr' : 0, + 'tp_as_number' : 0, + 'tp_as_sequence' : 0, + 'tp_as_mapping' : 0, + 'tp_hash' : 0, + 'tp_call' : 0, + 'tp_str' : 0, + 'tp_getattro' : 0x418110, ## PyObject_GenericGetAttr + 'tp_setattro' : 0, + 'tp_as_buffer' : 0, + 'tp_flags' : 278528, + 'tp_doc' : 0, + 'tp_traverse' : 0x50b0d0, ## iter_traverse + 'tp_clear' : 0, + 'tp_richcompare' : 0, + 'tp_weaklistoffset' : 0, + 'tp_iter' : 0x417210, ## PyObject_SelfIter + 'tp_iternext' : 0x50b450, ## iter_iternext + 'tp_methods' : 0x7b5d20, + 'tp_members' : 0, + 'tp_getset' : 0, + 'tp_base' : 0, + 'tp_dict' : 0, + 'tp_descr_get' : 0, + 'tp_descr_set' : 0, + 'tp_dictoffset' : 0, + 'tp_init' : 0, + 'tp_alloc' : 0, + 'tp_new' : 0, + 'tp_free' : 0, + 'tp_is_gc' : 0, + 'tp_bases' : 0, + 'tp_mro' : 0, + 'tp_cache' : 0, + 'tp_subclasses' : 0, + 'tp_weaklist' : 0, + 'tp_del' : 0, + 'tp_version_tag' : 0 + }, + } +