Skip to content
4 changes: 2 additions & 2 deletions Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Include/internal/pycore_uop_ids.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Include/internal/pycore_uop_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 22 additions & 2 deletions Lib/test/test_capi/test_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2201,7 +2201,8 @@ def test_call_builtin_o(self):
def testfunc(n):
x = 0
for _ in range(n):
y = abs(1)
my_abs = abs
y = my_abs(1)
x += y
return x

Expand All @@ -2210,7 +2211,26 @@ def testfunc(n):
self.assertIsNotNone(ex)
uops = get_opnames(ex)
self.assertIn("_CALL_BUILTIN_O", uops)
self.assertIn("_POP_TOP", uops)
self.assertNotIn("_POP_TOP", uops)
self.assertIn("_POP_TOP_NOP", uops)

def test_call_method_descriptor_o(self):
def testfunc(n):
x = 0
for _ in range(n):
y = (1, 2, 3)
z = y.count(2)
x += z
return x

res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
self.assertEqual(res, TIER2_THRESHOLD)
self.assertIsNotNone(ex)
uops = get_opnames(ex)
pop_tops = [opname for opname in iter_opnames(ex) if opname == "_POP_TOP"]
self.assertIn("_CALL_METHOD_DESCRIPTOR_O", uops)
self.assertIn("_POP_TOP_NOP", uops)
self.assertLessEqual(len(pop_tops), 1)

def test_get_len_with_const_tuple(self):
def testfunc(n):
Expand Down
18 changes: 13 additions & 5 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -4170,7 +4170,7 @@ dummy_func(
_CALL_BUILTIN_CLASS +
_CHECK_PERIODIC_AT_END;

op(_CALL_BUILTIN_O, (callable, self_or_null, args[oparg] -- res, a, c)) {
op(_CALL_BUILTIN_O, (callable, self_or_null, args[oparg] -- res, c, s)) {
/* Builtin METH_O functions */
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);

Expand All @@ -4193,8 +4193,8 @@ dummy_func(
if (res_o == NULL) {
ERROR_NO_POP();
}
a = arg;
c = callable;
s = args[0];
INPUTS_DEAD();
res = PyStackRef_FromPyObjectSteal(res_o);
}
Expand Down Expand Up @@ -4362,7 +4362,7 @@ dummy_func(
none = PyStackRef_None;
}

op(_CALL_METHOD_DESCRIPTOR_O, (callable, self_or_null, args[oparg] -- res)) {
op(_CALL_METHOD_DESCRIPTOR_O, (callable, self_or_null, args[oparg] -- res, c, s, a)) {
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);

int total_args = oparg;
Expand Down Expand Up @@ -4390,15 +4390,23 @@ dummy_func(
PyStackRef_AsPyObjectBorrow(arg_stackref));
_Py_LeaveRecursiveCallTstate(tstate);
assert((res_o != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
DECREF_INPUTS();
ERROR_IF(res_o == NULL);
if (res_o == NULL) {
ERROR_NO_POP();
}
c = callable;
s = arguments[0];
a = arguments[1];
INPUTS_DEAD();
res = PyStackRef_FromPyObjectSteal(res_o);
}

macro(CALL_METHOD_DESCRIPTOR_O) =
unused/1 +
unused/2 +
_CALL_METHOD_DESCRIPTOR_O +
POP_TOP +
POP_TOP +
POP_TOP +
_CHECK_PERIODIC_AT_END;

op(_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, (callable, self_or_null, args[oparg] -- res)) {
Expand Down
45 changes: 18 additions & 27 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 42 additions & 26 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading