Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into for-iter-uop
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanrossum committed Nov 17, 2023
2 parents 4c72028 + dabc0d7 commit 14aea56
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Doc/library/importlib.metadata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ and metadata defined by the `Core metadata specifications <https://packaging.pyt
and one top-level *import package*
may map to multiple *distribution packages*
if it is a namespace package.
You can use :ref:`package_distributions() <package-distributions>`
You can use :ref:`packages_distributions() <package-distributions>`
to get a mapping between them.

By default, distribution metadata can live on the file system
Expand Down
14 changes: 0 additions & 14 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1399,20 +1399,6 @@ Removed

(Contributed by Victor Stinner in :gh:`105182`.)

* Remove the old aliases to functions calling functions which were kept for
backward compatibility with Python 3.8 provisional API:

* ``_PyObject_CallMethodNoArgs()``: use ``PyObject_CallMethodNoArgs()``
* ``_PyObject_CallMethodOneArg()``: use ``PyObject_CallMethodOneArg()``
* ``_PyObject_CallOneArg()``: use ``PyObject_CallOneArg()``
* ``_PyObject_FastCallDict()``: use ``PyObject_VectorcallDict()``
* ``_PyObject_Vectorcall()``: use ``PyObject_Vectorcall()``
* ``_PyObject_VectorcallMethod()``: use ``PyObject_VectorcallMethod()``
* ``_PyVectorcall_Function()``: use ``PyVectorcall_Function()``

Just remove the underscore prefix to update your code.
(Contributed by Victor Stinner in :gh:`106084`.)

* Remove private ``_PyObject_FastCall()`` function:
use ``PyObject_Vectorcall()`` which is available since Python 3.8
(:pep:`590`).
Expand Down
15 changes: 11 additions & 4 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,8 @@ static const _Py_CODEUNIT _Py_INTERPRETER_TRAMPOLINE_INSTRUCTIONS[] = {

extern const struct _PyCode_DEF(8) _Py_InitCleanup;

extern const char *_PyUopName(int index);

/* Disable unused label warnings. They are handy for debugging, even
if computed gotos aren't used. */

Expand Down Expand Up @@ -1002,11 +1004,12 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
oparg = next_uop->oparg;
operand = next_uop->operand;
DPRINTF(3,
"%4d: uop %s, oparg %d, operand %" PRIu64 ", stack_level %d\n",
"%4d: uop %s, oparg %d, operand %" PRIu64 ", target %d, stack_level %d\n",
(int)(next_uop - current_executor->trace),
opcode < 256 ? _PyOpcode_OpName[opcode] : _PyOpcode_uop_name[opcode],
_PyUopName(opcode),
oparg,
operand,
next_uop->target,
(int)(stack_pointer - _PyFrame_Stackbase(frame)));
next_uop++;
OPT_STAT_INC(uops_executed);
Expand Down Expand Up @@ -1051,7 +1054,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
pop_1_error_tier_two:
STACK_SHRINK(1);
error_tier_two:
DPRINTF(2, "Error: [Opcode %d, operand %" PRIu64 "]\n", opcode, operand);
DPRINTF(2, "Error: [Uop %d (%s), oparg %d, operand %" PRIu64 ", target %d @ %d]\n",
opcode, _PyUopName(opcode), oparg, operand, next_uop[-1].target,
(int)(next_uop - current_executor->trace - 1));
OPT_HIST(trace_uop_execution_counter, trace_run_length_hist);
frame->return_offset = 0; // Don't leave this random
_PyFrame_SetStackPointer(frame, stack_pointer);
Expand All @@ -1062,7 +1067,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
deoptimize:
// On DEOPT_IF we just repeat the last instruction.
// This presumes nothing was popped from the stack (nor pushed).
DPRINTF(2, "DEOPT: [Opcode %d, operand %" PRIu64 " @ %d]\n", opcode, operand, (int)(next_uop-current_executor->trace-1));
DPRINTF(2, "DEOPT: [Uop %d (%s), oparg %d, operand %" PRIu64 ", target %d @ %d]\n",
opcode, _PyUopName(opcode), oparg, operand, next_uop[-1].target,
(int)(next_uop - current_executor->trace - 1));
OPT_HIST(trace_uop_execution_counter, trace_run_length_hist);
UOP_STAT_INC(opcode, miss);
frame->return_offset = 0; // Dispatch to frame->instr_ptr
Expand Down
18 changes: 9 additions & 9 deletions Python/optimizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ uop_dealloc(_PyUOpExecutorObject *self) {
PyObject_Free(self);
}

static const char *
uop_name(int index)
const char *
_PyUopName(int index)
{
if (index <= MAX_REAL_OPCODE) {
return _PyOpcode_OpName[index];
Expand All @@ -347,7 +347,7 @@ uop_item(_PyUOpExecutorObject *self, Py_ssize_t index)
PyErr_SetNone(PyExc_IndexError);
return NULL;
}
const char *name = uop_name(self->trace[index].opcode);
const char *name = _PyUopName(self->trace[index].opcode);
if (name == NULL) {
name = "<nil>";
}
Expand Down Expand Up @@ -452,7 +452,7 @@ translate_bytecode_to_trace(
#define ADD_TO_TRACE(OPCODE, OPARG, OPERAND, TARGET) \
DPRINTF(2, \
" ADD_TO_TRACE(%s, %d, %" PRIu64 ")\n", \
uop_name(OPCODE), \
_PyUopName(OPCODE), \
(OPARG), \
(uint64_t)(OPERAND)); \
assert(trace_length < max_length); \
Expand All @@ -478,7 +478,7 @@ translate_bytecode_to_trace(
reserved = (n); // Keep ADD_TO_TRACE honest

// Reserve space for main+stub uops, plus 3 for _SET_IP, _CHECK_VALIDITY and _EXIT_TRACE
#define RESERVE(main, stub) RESERVE_RAW((main) + (stub) + 3, uop_name(opcode))
#define RESERVE(main, stub) RESERVE_RAW((main) + (stub) + 3, _PyUopName(opcode))

// Trace stack operations (used by _PUSH_FRAME, _POP_FRAME)
#define TRACE_STACK_PUSH() \
Expand Down Expand Up @@ -550,8 +550,8 @@ translate_bytecode_to_trace(
uint32_t uopcode = BRANCH_TO_GUARD[opcode - POP_JUMP_IF_FALSE][jump_likely];
_Py_CODEUNIT *next_instr = instr + 1 + _PyOpcode_Caches[_PyOpcode_Deopt[opcode]];
DPRINTF(4, "%s(%d): counter=%x, bitcount=%d, likely=%d, uopcode=%s\n",
uop_name(opcode), oparg,
counter, bitcount, jump_likely, uop_name(uopcode));
_PyUopName(opcode), oparg,
counter, bitcount, jump_likely, _PyUopName(uopcode));
ADD_TO_TRACE(uopcode, max_length, 0, target);
if (jump_likely) {
_Py_CODEUNIT *target_instr = next_instr + oparg;
Expand Down Expand Up @@ -716,7 +716,7 @@ translate_bytecode_to_trace(
}
break;
}
DPRINTF(2, "Unsupported opcode %s\n", uop_name(opcode));
DPRINTF(2, "Unsupported opcode %s\n", _PyUopName(opcode));
OPT_UNSUPPORTED_OPCODE(opcode);
goto done; // Break out of loop
} // End default
Expand Down Expand Up @@ -850,7 +850,7 @@ make_executor_from_uops(_PyUOpInstruction *buffer, _PyBloomFilter *dependencies)
for (int i = 0; i < length; i++) {
printf("%4d %s(%d, %d, %" PRIu64 ")\n",
i,
uop_name(executor->trace[i].opcode),
_PyUopName(executor->trace[i].opcode),
executor->trace[i].oparg,
executor->trace[i].target,
executor->trace[i].operand);
Expand Down

0 comments on commit 14aea56

Please sign in to comment.