gh-134584: Eliminate redundant refcounting from `_CALL_STR_1` (GH-136… · python/cpython@a154c9e · GitHub
Skip to content

Commit a154c9e

Browse files
authored
gh-134584: Eliminate redundant refcounting from _CALL_STR_1 (GH-136070)
Signed-off-by: Manjusaka <me@manjusaka.me>
1 parent d3ef5ba commit a154c9e

10 files changed

Lines changed: 58 additions & 43 deletions

File tree

Include/internal/pycore_opcode_metadata.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_ids.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_metadata.h

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/test/test_capi/test_opt.py

Lines changed: 14 additions & 0 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Eliminate redundant refcounting from ``_CALL_STR_1``.

Python/bytecodes.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4040,18 +4040,17 @@ dummy_func(
40404040
DEOPT_IF(callable_o != (PyObject *)&PyUnicode_Type);
40414041
}
40424042

4043-
op(_CALL_STR_1, (callable, null, arg -- res)) {
4043+
op(_CALL_STR_1, (callable, null, arg -- res, a)) {
40444044
PyObject *arg_o = PyStackRef_AsPyObjectBorrow(arg);
40454045

40464046
assert(oparg == 1);
40474047
STAT_INC(CALL, hit);
40484048
PyObject *res_o = PyObject_Str(arg_o);
4049-
DEAD(null);
4050-
DEAD(callable);
4051-
(void)callable; // Silence compiler warnings about unused variables
4052-
(void)null;
4053-
PyStackRef_CLOSE(arg);
4054-
ERROR_IF(res_o == NULL);
4049+
if (res_o == NULL) {
4050+
ERROR_NO_POP();
4051+
}
4052+
a = arg;
4053+
INPUTS_DEAD();
40554054
res = PyStackRef_FromPyObjectSteal(res_o);
40564055
}
40574056

@@ -4061,6 +4060,7 @@ dummy_func(
40614060
_GUARD_NOS_NULL +
40624061
_GUARD_CALLABLE_STR_1 +
40634062
_CALL_STR_1 +
4063+
POP_TOP +
40644064
_CHECK_PERIODIC_AT_END;
40654065

40664066
op(_GUARD_CALLABLE_TUPLE_1, (callable, unused, unused -- callable, unused, unused)) {

Python/executor_cases.c.h

Lines changed: 9 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 13 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/optimizer_bytecodes.c

Lines changed: 2 additions & 1 deletion

Python/optimizer_cases.c.h

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)