Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Include/internal/pycore_opcode_metadata.h

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

15 changes: 15 additions & 0 deletions Lib/test/test_capi/test_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2011,6 +2011,21 @@ class C:
self.assertNotIn("_COMPARE_OP_INT", uops)
self.assertNotIn("_GUARD_IS_TRUE_POP", uops)

def test_call_builtin_o(self):
def testfunc(n):
x = 0
for _ in range(n):
y = abs(1)
x += y
return x

res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
self.assertEqual(res, TIER2_THRESHOLD)
self.assertIsNotNone(ex)
uops = get_opnames(ex)
self.assertIn("_CALL_BUILTIN_O", uops)
self.assertIn("_POP_TWO", uops)

def test_get_len_with_const_tuple(self):
def testfunc(n):
x = 0.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Eliminate redundant refcounting from ``_CALL_BUILTIN_O``.
11 changes: 5 additions & 6 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -4202,7 +4202,7 @@ dummy_func(
_CALL_BUILTIN_CLASS +
_CHECK_PERIODIC;

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

Expand All @@ -4222,11 +4222,9 @@ dummy_func(
PyObject *res_o = _PyCFunction_TrampolineCall(cfunc, PyCFunction_GET_SELF(callable_o), PyStackRef_AsPyObjectBorrow(arg));
_Py_LeaveRecursiveCallTstate(tstate);
assert((res_o != NULL) ^ (_PyErr_Occurred(tstate) != NULL));

PyStackRef_CLOSE(arg);
DEAD(args);
DEAD(self_or_null);
PyStackRef_CLOSE(callable);
INPUTS_DEAD();
a = arg;
c = callable;
ERROR_IF(res_o == NULL);
res = PyStackRef_FromPyObjectSteal(res_o);
}
Expand All @@ -4235,6 +4233,7 @@ dummy_func(
unused/1 +
unused/2 +
_CALL_BUILTIN_O +
_POP_TWO +
_CHECK_PERIODIC;

op(_CALL_BUILTIN_FAST, (callable, self_or_null, args[oparg] -- res)) {
Expand Down
20 changes: 10 additions & 10 deletions Python/executor_cases.c.h

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

38 changes: 24 additions & 14 deletions Python/generated_cases.c.h

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

8 changes: 7 additions & 1 deletion Python/optimizer_cases.c.h

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

Loading