Skip to content

Commit

Permalink
Revert "Make deopt more efficient"
Browse files Browse the repository at this point in the history
This reverts commit 982c51d.
  • Loading branch information
Fidget-Spinner committed Jan 10, 2025
1 parent f5b1c93 commit 637589e
Show file tree
Hide file tree
Showing 5 changed files with 460 additions and 461 deletions.
8 changes: 4 additions & 4 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#include "ceval_macros.h"

/* Flow control macros */
#define GO_TO_INSTRUCTION(instname, SIZE) ((void)0)
#define GO_TO_INSTRUCTION(instname) ((void)0)

#define inst(name, ...) case name:
#define op(name, ...) /* NAME is ignored */
Expand Down Expand Up @@ -1942,7 +1942,7 @@ dummy_func(
// cancel out the decrement that will happen in LOAD_SUPER_ATTR; we
// don't want to specialize instrumented instructions
PAUSE_ADAPTIVE_COUNTER(this_instr[1].counter);
GO_TO_INSTRUCTION(LOAD_SUPER_ATTR, INSTRUCTION_SIZE);
GO_TO_INSTRUCTION(LOAD_SUPER_ATTR);
}

family(LOAD_SUPER_ATTR, INLINE_CACHE_ENTRIES_LOAD_SUPER_ATTR) = {
Expand Down Expand Up @@ -4255,7 +4255,7 @@ dummy_func(
frame, this_instr, function, arg);
ERROR_IF(err, error);
PAUSE_ADAPTIVE_COUNTER(this_instr[1].counter);
GO_TO_INSTRUCTION(CALL_KW, INSTRUCTION_SIZE);
GO_TO_INSTRUCTION(CALL_KW);
}

op(_MAYBE_EXPAND_METHOD_KW, (callable[1], self_or_null[1], args[oparg], kwnames_in -- func[1], maybe_self[1], args[oparg], kwnames_out)) {
Expand Down Expand Up @@ -4488,7 +4488,7 @@ dummy_func(
_CHECK_PERIODIC;

inst(INSTRUMENTED_CALL_FUNCTION_EX, ( -- )) {
GO_TO_INSTRUCTION(CALL_FUNCTION_EX, INSTRUCTION_SIZE);
GO_TO_INSTRUCTION(CALL_FUNCTION_EX);
}

op(_MAKE_CALLARGS_A_TUPLE, (func, unused, callargs, kwargs_in if (oparg & 1) -- func, unused, tuple, kwargs_out if (oparg & 1))) {
Expand Down
12 changes: 6 additions & 6 deletions Python/ceval_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,14 @@ GETITEM(PyObject *v, Py_ssize_t i) {
PyStackRef_XCLOSE(tmp); } while (0)
#ifdef Py_TAIL_CALL_INTERP
#ifdef LLTRACE
#define GO_TO_INSTRUCTION(op, SIZE) do { \
#define GO_TO_INSTRUCTION(op) do { \
Py_MUSTTAIL \
return (INSTRUCTION_TABLE[op])(frame, stack_pointer, tstate, next_instr - 1 - SIZE, oparg, entry_frame, lltrace); \
return (INSTRUCTION_TABLE[op])(frame, stack_pointer, tstate, next_instr - 1 - _PyOpcode_Caches[_PyOpcode_Deopt[op]], oparg, entry_frame, lltrace); \
} while (0)
#else
#define GO_TO_INSTRUCTION(op, SIZE) do { \
#define GO_TO_INSTRUCTION(op) do { \
Py_MUSTTAIL \
return (INSTRUCTION_TABLE[op])(frame, stack_pointer, tstate, next_instr - 1 - SIZE, oparg, entry_frame); \
return (INSTRUCTION_TABLE[op])(frame, stack_pointer, tstate, next_instr - 1 - _PyOpcode_Caches[_PyOpcode_Deopt[op]], oparg, entry_frame); \
} while (0)
#endif
#else
Expand All @@ -357,12 +357,12 @@ GETITEM(PyObject *v, Py_ssize_t i) {
#define UPDATE_MISS_STATS(INSTNAME) ((void)0)
#endif

#define DEOPT_IF(COND, INSTNAME, SIZE) \
#define DEOPT_IF(COND, INSTNAME) \
if ((COND)) { \
/* This is only a single jump on release builds! */ \
UPDATE_MISS_STATS((INSTNAME)); \
/* assert(_PyOpcode_Deopt[opcode] == (INSTNAME)); */ \
GO_TO_INSTRUCTION(INSTNAME, SIZE); \
GO_TO_INSTRUCTION(INSTNAME); \
}


Expand Down
Loading

0 comments on commit 637589e

Please sign in to comment.