| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,21 +19,35 @@ extern "C" { | |||
| 19 | 19 | typedef union { | |
| 20 | 20 | uint16_t cache; | |
| 21 | 21 | struct { | |
| 22 | - uint8_t opcode; | ||
| 23 | - uint8_t oparg; | ||
| 24 | - }; | ||
| 22 | + uint8_t code; | ||
| 23 | + uint8_t arg; | ||
| 24 | + } op; | ||
| 25 | 25 | } _Py_CODEUNIT; | |
| 26 | 26 | ||
| 27 | - #define _Py_OPCODE(word) ((word).opcode) | ||
| 28 | - #define _Py_OPARG(word) ((word).oparg) | ||
| 27 | + | ||
| 28 | + /* These macros only remain defined for compatibility. */ | ||
| 29 | + #define _Py_OPCODE(word) ((word).op.code) | ||
| 30 | + #define _Py_OPARG(word) ((word).op.arg) | ||
| 31 | + | ||
| 32 | + static inline _Py_CODEUNIT | ||
| 33 | + _py_make_codeunit(uint8_t opcode, uint8_t oparg) | ||
| 34 | + { | ||
| 35 | + // No designated initialisers because of C++ compat | ||
| 36 | + _Py_CODEUNIT word; | ||
| 37 | + word.op.code = opcode; | ||
| 38 | + word.op.arg = oparg; | ||
| 39 | + return word; | ||
| 40 | + } | ||
| 29 | 41 | ||
| 30 | 42 | static inline void | |
| 31 | 43 | _py_set_opcode(_Py_CODEUNIT *word, uint8_t opcode) | |
| 32 | 44 | { | |
| 33 | - word->opcode = opcode; | ||
| 45 | + word->op.code = opcode; | ||
| 34 | 46 | } | |
| 35 | 47 | ||
| 36 | - #define _Py_SET_OPCODE(word, opcode) _py_set_opocde(&(word), opcode) | ||
| 48 | + #define _Py_MAKE_CODEUNIT(opcode, oparg) _py_make_codeunit((opcode), (oparg)) | ||
| 49 | + #define _Py_SET_OPCODE(word, opcode) _py_set_opcode(&(word), (opcode)) | ||
| 50 | + | ||
| 37 | 51 | ||
| 38 | 52 | typedef struct { | |
| 39 | 53 | PyObject *_co_code; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + Removes use of non-standard C++ extension in public header files. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -413,7 +413,7 @@ init_code(PyCodeObject *co, struct _PyCodeConstructor *con) | |||
| 413 | 413 | PyBytes_GET_SIZE(con->code)); | |
| 414 | 414 | int entry_point = 0; | |
| 415 | 415 | while (entry_point < Py_SIZE(co) && | |
| 416 | - _Py_OPCODE(_PyCode_CODE(co)[entry_point]) != RESUME) { | ||
| 416 | + _PyCode_CODE(co)[entry_point].op.code != RESUME) { | ||
| 417 | 417 | entry_point++; | |
| 418 | 418 | } | |
| 419 | 419 | co->_co_firsttraceable = entry_point; | |
@@ -1505,12 +1505,12 @@ deopt_code(_Py_CODEUNIT *instructions, Py_ssize_t len) | |||
| 1505 | 1505 | { | |
| 1506 | 1506 | for (int i = 0; i < len; i++) { | |
| 1507 | 1507 | _Py_CODEUNIT instruction = instructions[i]; | |
| 1508 | - int opcode = _PyOpcode_Deopt[_Py_OPCODE(instruction)]; | ||
| 1508 | + int opcode = _PyOpcode_Deopt[instruction.op.code]; | ||
| 1509 | 1509 | int caches = _PyOpcode_Caches[opcode]; | |
| 1510 | - instructions[i].opcode = opcode; | ||
| 1510 | + instructions[i].op.code = opcode; | ||
| 1511 | 1511 | while (caches--) { | |
| 1512 | - instructions[++i].opcode = CACHE; | ||
| 1513 | - instructions[i].oparg = 0; | ||
| 1512 | + instructions[++i].op.code = CACHE; | ||
| 1513 | + instructions[i].op.arg = 0; | ||
| 1514 | 1514 | } | |
| 1515 | 1515 | } | |
| 1516 | 1516 | } | |
@@ -1763,13 +1763,13 @@ code_richcompare(PyObject *self, PyObject *other, int op) | |||
| 1763 | 1763 | for (int i = 0; i < Py_SIZE(co); i++) { | |
| 1764 | 1764 | _Py_CODEUNIT co_instr = _PyCode_CODE(co)[i]; | |
| 1765 | 1765 | _Py_CODEUNIT cp_instr = _PyCode_CODE(cp)[i]; | |
| 1766 | - co_instr.opcode = _PyOpcode_Deopt[_Py_OPCODE(co_instr)]; | ||
| 1767 | - cp_instr.opcode =_PyOpcode_Deopt[_Py_OPCODE(cp_instr)]; | ||
| 1766 | + co_instr.op.code = _PyOpcode_Deopt[co_instr.op.code]; | ||
| 1767 | + cp_instr.op.code = _PyOpcode_Deopt[cp_instr.op.code]; | ||
| 1768 | 1768 | eq = co_instr.cache == cp_instr.cache; | |
| 1769 | 1769 | if (!eq) { | |
| 1770 | 1770 | goto unequal; | |
| 1771 | 1771 | } | |
| 1772 | - i += _PyOpcode_Caches[_Py_OPCODE(co_instr)]; | ||
| 1772 | + i += _PyOpcode_Caches[co_instr.op.code]; | ||
| 1773 | 1773 | } | |
| 1774 | 1774 | ||
| 1775 | 1775 | /* compare constants */ | |
@@ -1848,9 +1848,9 @@ code_hash(PyCodeObject *co) | |||
| 1848 | 1848 | SCRAMBLE_IN(co->co_firstlineno); | |
| 1849 | 1849 | SCRAMBLE_IN(Py_SIZE(co)); | |
| 1850 | 1850 | for (int i = 0; i < Py_SIZE(co); i++) { | |
| 1851 | - int deop = _PyOpcode_Deopt[_Py_OPCODE(_PyCode_CODE(co)[i])]; | ||
| 1851 | + int deop = _PyOpcode_Deopt[_PyCode_CODE(co)[i].op.code]; | ||
| 1852 | 1852 | SCRAMBLE_IN(deop); | |
| 1853 | - SCRAMBLE_IN(_Py_OPARG(_PyCode_CODE(co)[i])); | ||
| 1853 | + SCRAMBLE_IN(_PyCode_CODE(co)[i].op.arg); | ||
| 1854 | 1854 | i += _PyOpcode_Caches[deop]; | |
| 1855 | 1855 | } | |
| 1856 | 1856 | if ((Py_hash_t)uhash == -1) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -111,13 +111,13 @@ static unsigned int | |||
| 111 | 111 | get_arg(const _Py_CODEUNIT *codestr, Py_ssize_t i) | |
| 112 | 112 | { | |
| 113 | 113 | _Py_CODEUNIT word; | |
| 114 | - unsigned int oparg = _Py_OPARG(codestr[i]); | ||
| 115 | - if (i >= 1 && _Py_OPCODE(word = codestr[i-1]) == EXTENDED_ARG) { | ||
| 116 | - oparg |= _Py_OPARG(word) << 8; | ||
| 117 | - if (i >= 2 && _Py_OPCODE(word = codestr[i-2]) == EXTENDED_ARG) { | ||
| 118 | - oparg |= _Py_OPARG(word) << 16; | ||
| 119 | - if (i >= 3 && _Py_OPCODE(word = codestr[i-3]) == EXTENDED_ARG) { | ||
| 120 | - oparg |= _Py_OPARG(word) << 24; | ||
| 114 | + unsigned int oparg = codestr[i].op.arg; | ||
| 115 | + if (i >= 1 && (word = codestr[i-1]).op.code == EXTENDED_ARG) { | ||
| 116 | + oparg |= word.op.arg << 8; | ||
| 117 | + if (i >= 2 && (word = codestr[i-2]).op.code == EXTENDED_ARG) { | ||
| 118 | + oparg |= word.op.arg << 16; | ||
| 119 | + if (i >= 3 && (word = codestr[i-3]).op.code == EXTENDED_ARG) { | ||
| 120 | + oparg |= word.op.arg << 24; | ||
| 121 | 121 | } | |
| 122 | 122 | } | |
| 123 | 123 | } | |
@@ -304,7 +304,7 @@ mark_stacks(PyCodeObject *code_obj, int len) | |||
| 304 | 304 | if (next_stack == UNINITIALIZED) { | |
| 305 | 305 | continue; | |
| 306 | 306 | } | |
| 307 | - opcode = _Py_OPCODE(code[i]); | ||
| 307 | + opcode = code[i].op.code; | ||
| 308 | 308 | switch (opcode) { | |
| 309 | 309 | case JUMP_IF_FALSE_OR_POP: | |
| 310 | 310 | case JUMP_IF_TRUE_OR_POP: | |
@@ -610,7 +610,7 @@ _PyFrame_GetState(PyFrameObject *frame) | |||
| 610 | 610 | if (_PyInterpreterFrame_LASTI(frame->f_frame) < 0) { | |
| 611 | 611 | return FRAME_CREATED; | |
| 612 | 612 | } | |
| 613 | - switch (_Py_OPCODE(*frame->f_frame->prev_instr)) | ||
| 613 | + switch (frame->f_frame->prev_instr->op.code) | ||
| 614 | 614 | { | |
| 615 | 615 | case COPY_FREE_VARS: | |
| 616 | 616 | case MAKE_CELL: | |
@@ -1092,8 +1092,8 @@ _PyFrame_OpAlreadyRan(_PyInterpreterFrame *frame, int opcode, int oparg) | |||
| 1092 | 1092 | for (_Py_CODEUNIT *instruction = _PyCode_CODE(frame->f_code); | |
| 1093 | 1093 | instruction < frame->prev_instr; instruction++) | |
| 1094 | 1094 | { | |
| 1095 | - int check_opcode = _PyOpcode_Deopt[_Py_OPCODE(*instruction)]; | ||
| 1096 | - check_oparg |= _Py_OPARG(*instruction); | ||
| 1095 | + int check_opcode = _PyOpcode_Deopt[instruction->op.code]; | ||
| 1096 | + check_oparg |= instruction->op.arg; | ||
| 1097 | 1097 | if (check_opcode == opcode && check_oparg == oparg) { | |
| 1098 | 1098 | return 1; | |
| 1099 | 1099 | } | |
@@ -1117,7 +1117,7 @@ frame_init_get_vars(_PyInterpreterFrame *frame) | |||
| 1117 | 1117 | // here: | |
| 1118 | 1118 | PyCodeObject *co = frame->f_code; | |
| 1119 | 1119 | int lasti = _PyInterpreterFrame_LASTI(frame); | |
| 1120 | - if (!(lasti < 0 && _Py_OPCODE(_PyCode_CODE(co)[0]) == COPY_FREE_VARS | ||
| 1120 | + if (!(lasti < 0 && _PyCode_CODE(co)->op.code == COPY_FREE_VARS | ||
| 1121 | 1121 | && PyFunction_Check(frame->f_funcobj))) | |
| 1122 | 1122 | { | |
| 1123 | 1123 | /* Free vars are initialized */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -332,11 +332,11 @@ _PyGen_yf(PyGenObject *gen) | |||
| 332 | 332 | /* Return immediately if the frame didn't start yet. SEND | |
| 333 | 333 | always come after LOAD_CONST: a code object should not start | |
| 334 | 334 | with SEND */ | |
| 335 | - assert(_Py_OPCODE(_PyCode_CODE(gen->gi_code)[0]) != SEND); | ||
| 335 | + assert(_PyCode_CODE(gen->gi_code)[0].op.code != SEND); | ||
| 336 | 336 | return NULL; | |
| 337 | 337 | } | |
| 338 | 338 | _Py_CODEUNIT next = frame->prev_instr[1]; | |
| 339 | - if (_Py_OPCODE(next) != RESUME || _Py_OPARG(next) < 2) | ||
| 339 | + if (next.op.code != RESUME || next.op.arg < 2) | ||
| 340 | 340 | { | |
| 341 | 341 | /* Not in a yield from */ | |
| 342 | 342 | return NULL; | |
@@ -371,9 +371,9 @@ gen_close(PyGenObject *gen, PyObject *args) | |||
| 371 | 371 | _PyInterpreterFrame *frame = (_PyInterpreterFrame *)gen->gi_iframe; | |
| 372 | 372 | /* It is possible for the previous instruction to not be a | |
| 373 | 373 | * YIELD_VALUE if the debugger has changed the lineno. */ | |
| 374 | - if (err == 0 && frame->prev_instr->opcode == YIELD_VALUE) { | ||
| 375 | - assert(frame->prev_instr[1].opcode == RESUME); | ||
| 376 | - int exception_handler_depth = frame->prev_instr->oparg; | ||
| 374 | + if (err == 0 && frame->prev_instr[0].op.code == YIELD_VALUE) { | ||
| 375 | + assert(frame->prev_instr[1].op.code == RESUME); | ||
| 376 | + int exception_handler_depth = frame->prev_instr[0].op.code; | ||
| 377 | 377 | assert(exception_handler_depth > 0); | |
| 378 | 378 | /* We can safely ignore the outermost try block | |
| 379 | 379 | * as it automatically generated to handle | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9507,8 +9507,8 @@ super_init_without_args(_PyInterpreterFrame *cframe, PyCodeObject *co, | |||
| 9507 | 9507 | if (_PyInterpreterFrame_LASTI(cframe) >= 0) { | |
| 9508 | 9508 | // MAKE_CELL and COPY_FREE_VARS have no quickened forms, so no need | |
| 9509 | 9509 | // to use _PyOpcode_Deopt here: | |
| 9510 | - assert(_Py_OPCODE(_PyCode_CODE(co)[0]) == MAKE_CELL || | ||
| 9511 | - _Py_OPCODE(_PyCode_CODE(co)[0]) == COPY_FREE_VARS); | ||
| 9510 | + assert(_PyCode_CODE(co)[0].op.code == MAKE_CELL || | ||
| 9511 | + _PyCode_CODE(co)[0].op.code == COPY_FREE_VARS); | ||
| 9512 | 9512 | assert(PyCell_Check(firstarg)); | |
| 9513 | 9513 | firstarg = PyCell_GET(firstarg); | |
| 9514 | 9514 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -246,9 +246,9 @@ dummy_func( | |||
| 246 | 246 | DEOPT_IF(!PyUnicode_CheckExact(left), BINARY_OP); | |
| 247 | 247 | DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP); | |
| 248 | 248 | _Py_CODEUNIT true_next = next_instr[INLINE_CACHE_ENTRIES_BINARY_OP]; | |
| 249 | - assert(_Py_OPCODE(true_next) == STORE_FAST || | ||
| 250 | - _Py_OPCODE(true_next) == STORE_FAST__LOAD_FAST); | ||
| 251 | - PyObject **target_local = &GETLOCAL(_Py_OPARG(true_next)); | ||
| 249 | + assert(true_next.op.code == STORE_FAST || | ||
| 250 | + true_next.op.code == STORE_FAST__LOAD_FAST); | ||
| 251 | + PyObject **target_local = &GETLOCAL(true_next.op.arg); | ||
| 252 | 252 | DEOPT_IF(*target_local != left, BINARY_OP); | |
| 253 | 253 | STAT_INC(BINARY_OP, hit); | |
| 254 | 254 | /* Handle `left = left + right` or `left += right` for str. | |
@@ -1748,10 +1748,10 @@ dummy_func( | |||
| 1748 | 1748 | Py_DECREF(left); | |
| 1749 | 1749 | Py_DECREF(right); | |
| 1750 | 1750 | ERROR_IF(cond == NULL, error); | |
| 1751 | - assert(_Py_OPCODE(next_instr[1]) == POP_JUMP_IF_FALSE || | ||
| 1752 | - _Py_OPCODE(next_instr[1]) == POP_JUMP_IF_TRUE); | ||
| 1753 | - bool jump_on_true = _Py_OPCODE(next_instr[1]) == POP_JUMP_IF_TRUE; | ||
| 1754 | - int offset = _Py_OPARG(next_instr[1]); | ||
| 1751 | + assert(next_instr[1].op.code == POP_JUMP_IF_FALSE || | ||
| 1752 | + next_instr[1].op.code == POP_JUMP_IF_TRUE); | ||
| 1753 | + bool jump_on_true = next_instr[1].op.code == POP_JUMP_IF_TRUE; | ||
| 1754 | + int offset = next_instr[1].op.arg; | ||
| 1755 | 1755 | int err = PyObject_IsTrue(cond); | |
| 1756 | 1756 | Py_DECREF(cond); | |
| 1757 | 1757 | if (err < 0) { | |
@@ -1774,7 +1774,7 @@ dummy_func( | |||
| 1774 | 1774 | _Py_DECREF_SPECIALIZED(left, _PyFloat_ExactDealloc); | |
| 1775 | 1775 | _Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc); | |
| 1776 | 1776 | if (sign_ish & oparg) { | |
| 1777 | - int offset = _Py_OPARG(next_instr[1]); | ||
| 1777 | + int offset = next_instr[1].op.arg; | ||
| 1778 | 1778 | JUMPBY(offset); | |
| 1779 | 1779 | } | |
| 1780 | 1780 | } | |
@@ -1795,7 +1795,7 @@ dummy_func( | |||
| 1795 | 1795 | _Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free); | |
| 1796 | 1796 | _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); | |
| 1797 | 1797 | if (sign_ish & oparg) { | |
| 1798 | - int offset = _Py_OPARG(next_instr[1]); | ||
| 1798 | + int offset = next_instr[1].op.arg; | ||
| 1799 | 1799 | JUMPBY(offset); | |
| 1800 | 1800 | } | |
| 1801 | 1801 | } | |
@@ -1814,7 +1814,7 @@ dummy_func( | |||
| 1814 | 1814 | assert((oparg & 0xf) == COMPARISON_NOT_EQUALS || (oparg & 0xf) == COMPARISON_EQUALS); | |
| 1815 | 1815 | assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS); | |
| 1816 | 1816 | if ((res + COMPARISON_NOT_EQUALS) & oparg) { | |
| 1817 | - int offset = _Py_OPARG(next_instr[1]); | ||
| 1817 | + int offset = next_instr[1].op.arg; | ||
| 1818 | 1818 | JUMPBY(offset); | |
| 1819 | 1819 | } | |
| 1820 | 1820 | } | |
@@ -2122,7 +2122,7 @@ dummy_func( | |||
| 2122 | 2122 | _PyErr_Clear(tstate); | |
| 2123 | 2123 | } | |
| 2124 | 2124 | /* iterator ended normally */ | |
| 2125 | - assert(_Py_OPCODE(next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg]) == END_FOR); | ||
| 2125 | + assert(next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == END_FOR); | ||
| 2126 | 2126 | Py_DECREF(iter); | |
| 2127 | 2127 | STACK_SHRINK(1); | |
| 2128 | 2128 | /* Jump forward oparg, then skip following END_FOR instruction */ | |
@@ -2186,7 +2186,7 @@ dummy_func( | |||
| 2186 | 2186 | DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); | |
| 2187 | 2187 | STAT_INC(FOR_ITER, hit); | |
| 2188 | 2188 | _Py_CODEUNIT next = next_instr[INLINE_CACHE_ENTRIES_FOR_ITER]; | |
| 2189 | - assert(_PyOpcode_Deopt[_Py_OPCODE(next)] == STORE_FAST); | ||
| 2189 | + assert(_PyOpcode_Deopt[next.op.code] == STORE_FAST); | ||
| 2190 | 2190 | if (r->len <= 0) { | |
| 2191 | 2191 | STACK_SHRINK(1); | |
| 2192 | 2192 | Py_DECREF(r); | |
@@ -2197,7 +2197,7 @@ dummy_func( | |||
| 2197 | 2197 | long value = r->start; | |
| 2198 | 2198 | r->start = value + r->step; | |
| 2199 | 2199 | r->len--; | |
| 2200 | - if (_PyLong_AssignValue(&GETLOCAL(_Py_OPARG(next)), value) < 0) { | ||
| 2200 | + if (_PyLong_AssignValue(&GETLOCAL(next.op.arg), value) < 0) { | ||
| 2201 | 2201 | goto error; | |
| 2202 | 2202 | } | |
| 2203 | 2203 | // The STORE_FAST is already done. | |
@@ -2220,7 +2220,7 @@ dummy_func( | |||
| 2220 | 2220 | gen->gi_exc_state.previous_item = tstate->exc_info; | |
| 2221 | 2221 | tstate->exc_info = &gen->gi_exc_state; | |
| 2222 | 2222 | JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg); | |
| 2223 | - assert(_Py_OPCODE(*next_instr) == END_FOR); | ||
| 2223 | + assert(next_instr->op.code == END_FOR); | ||
| 2224 | 2224 | DISPATCH_INLINED(gen_frame); | |
| 2225 | 2225 | } | |
| 2226 | 2226 | ||
@@ -2809,7 +2809,7 @@ dummy_func( | |||
| 2809 | 2809 | STACK_SHRINK(3); | |
| 2810 | 2810 | // CALL + POP_TOP | |
| 2811 | 2811 | JUMPBY(INLINE_CACHE_ENTRIES_CALL + 1); | |
| 2812 | - assert(_Py_OPCODE(next_instr[-1]) == POP_TOP); | ||
| 2812 | + assert(next_instr[-1].op.code == POP_TOP); | ||
| 2813 | 2813 | DISPATCH(); | |
| 2814 | 2814 | } | |
| 2815 | 2815 | ||
@@ -3118,8 +3118,8 @@ dummy_func( | |||
| 3118 | 3118 | inst(EXTENDED_ARG, (--)) { | |
| 3119 | 3119 | assert(oparg); | |
| 3120 | 3120 | assert(cframe.use_tracing == 0); | |
| 3121 | - opcode = _Py_OPCODE(*next_instr); | ||
| 3122 | - oparg = oparg << 8 | _Py_OPARG(*next_instr); | ||
| 3121 | + opcode = next_instr->op.code; | ||
| 3122 | + oparg = oparg << 8 | next_instr->op.arg; | ||
| 3123 | 3123 | PRE_DISPATCH_GOTO(); | |
| 3124 | 3124 | DISPATCH_GOTO(); | |
| 3125 | 3125 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -132,8 +132,8 @@ lltrace_instruction(_PyInterpreterFrame *frame, | |||
| 132 | 132 | objects enters the interpreter recursively. It is also slow. | |
| 133 | 133 | So you might want to comment it out. */ | |
| 134 | 134 | dump_stack(frame, stack_pointer); | |
| 135 | - int oparg = _Py_OPARG(*next_instr); | ||
| 136 | - int opcode = _Py_OPCODE(*next_instr); | ||
| 135 | + int oparg = next_instr->op.arg; | ||
| 136 | + int opcode = next_instr->op.code; | ||
| 137 | 137 | const char *opname = _PyOpcode_OpName[opcode]; | |
| 138 | 138 | assert(opname != NULL); | |
| 139 | 139 | int offset = (int)(next_instr - _PyCode_CODE(frame->f_code)); | |
@@ -920,8 +920,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int | |||
| 920 | 920 | // CPython hasn't ever traced the instruction after an EXTENDED_ARG. | |
| 921 | 921 | // Inline the EXTENDED_ARG here, so we can avoid branching there: | |
| 922 | 922 | INSTRUCTION_START(EXTENDED_ARG); | |
| 923 | - opcode = _Py_OPCODE(*next_instr); | ||
| 924 | - oparg = oparg << 8 | _Py_OPARG(*next_instr); | ||
| 923 | + opcode = next_instr->op.code; | ||
| 924 | + oparg = oparg << 8 | next_instr->op.arg; | ||
| 925 | 925 | // Make sure the next instruction isn't a RESUME, since that needs | |
| 926 | 926 | // to trace properly (and shouldn't have an EXTENDED_ARG, anyways): | |
| 927 | 927 | assert(opcode != RESUME); | |
@@ -946,7 +946,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int | |||
| 946 | 946 | #endif | |
| 947 | 947 | /* Tell C compilers not to hold the opcode variable in the loop. | |
| 948 | 948 | next_instr points the current instruction without TARGET(). */ | |
| 949 | - opcode = _Py_OPCODE(*next_instr); | ||
| 949 | + opcode = next_instr->op.code; | ||
| 950 | 950 | _PyErr_Format(tstate, PyExc_SystemError, | |
| 951 | 951 | "%U:%d: unknown opcode %d", | |
| 952 | 952 | frame->f_code->co_filename, | |
@@ -2196,7 +2196,7 @@ maybe_call_line_trace(Py_tracefunc func, PyObject *obj, | |||
| 2196 | 2196 | (_PyInterpreterFrame_LASTI(frame) < instr_prev && | |
| 2197 | 2197 | // SEND has no quickened forms, so no need to use _PyOpcode_Deopt | |
| 2198 | 2198 | // here: | |
| 2199 | - _Py_OPCODE(*frame->prev_instr) != SEND); | ||
| 2199 | + frame->prev_instr->op.code != SEND); | ||
| 2200 | 2200 | if (trace) { | |
| 2201 | 2201 | result = call_trace(func, obj, tstate, frame, PyTrace_LINE, Py_None); | |
| 2202 | 2202 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -100,7 +100,7 @@ | |||
| 100 | 100 | ||
| 101 | 101 | #define DISPATCH_SAME_OPARG() \ | |
| 102 | 102 | { \ | |
| 103 | - opcode = _Py_OPCODE(*next_instr); \ | ||
| 103 | + opcode = next_instr->op.code; \ | ||
| 104 | 104 | PRE_DISPATCH_GOTO(); \ | |
| 105 | 105 | opcode |= cframe.use_tracing OR_DTRACE_LINE; \ | |
| 106 | 106 | DISPATCH_GOTO(); \ | |
@@ -143,8 +143,8 @@ GETITEM(PyObject *v, Py_ssize_t i) { | |||
| 143 | 143 | #define INSTR_OFFSET() ((int)(next_instr - _PyCode_CODE(frame->f_code))) | |
| 144 | 144 | #define NEXTOPARG() do { \ | |
| 145 | 145 | _Py_CODEUNIT word = *next_instr; \ | |
| 146 | - opcode = _Py_OPCODE(word); \ | ||
| 147 | - oparg = _Py_OPARG(word); \ | ||
| 146 | + opcode = word.op.code; \ | ||
| 147 | + oparg = word.op.arg; \ | ||
| 148 | 148 | } while (0) | |
| 149 | 149 | #define JUMPTO(x) (next_instr = _PyCode_CODE(frame->f_code) + (x)) | |
| 150 | 150 | #define JUMPBY(x) (next_instr += (x)) | |
@@ -180,14 +180,14 @@ GETITEM(PyObject *v, Py_ssize_t i) { | |||
| 180 | 180 | #if USE_COMPUTED_GOTOS | |
| 181 | 181 | #define PREDICT(op) if (0) goto PREDICT_ID(op) | |
| 182 | 182 | #else | |
| 183 | - #define PREDICT(op) \ | ||
| 183 | + #define PREDICT(next_op) \ | ||
| 184 | 184 | do { \ | |
| 185 | 185 | _Py_CODEUNIT word = *next_instr; \ | |
| 186 | - opcode = _Py_OPCODE(word) | cframe.use_tracing OR_DTRACE_LINE; \ | ||
| 187 | - if (opcode == op) { \ | ||
| 188 | - oparg = _Py_OPARG(word); \ | ||
| 189 | - INSTRUCTION_START(op); \ | ||
| 190 | - goto PREDICT_ID(op); \ | ||
| 186 | + opcode = word.op.code | cframe.use_tracing OR_DTRACE_LINE; \ | ||
| 187 | + if (opcode == next_op) { \ | ||
| 188 | + oparg = word.op.arg; \ | ||
| 189 | + INSTRUCTION_START(next_op); \ | ||
| 190 | + goto PREDICT_ID(next_op); \ | ||
| 191 | 191 | } \ | |
| 192 | 192 | } while(0) | |
| 193 | 193 | #endif | |
| Back | FazBrowse Home | New Git URL |
0 commit comments