Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit85ab405

Browse files
committed
Eliminate redundant refcounting from _CALL_TYPE_1
1 parent569fc68 commit85ab405

File tree

8 files changed

+40
-24
lines changed

8 files changed

+40
-24
lines changed

‎Include/internal/pycore_opcode_metadata.h

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

‎Include/internal/pycore_uop_metadata.h

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

‎Lib/test/test_capi/test_opt.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,6 +1841,21 @@ def testfunc(n):
18411841
uops=get_opnames(ex)
18421842
self.assertNotIn("_GUARD_IS_NOT_NONE_POP",uops)
18431843

1844+
deftest_call_type_1_pop_top(self):
1845+
deftestfunc(n):
1846+
x=0
1847+
for_inrange(n):
1848+
foo=eval('42')
1849+
x+=type(foo)isint
1850+
returnx
1851+
1852+
res,ex=self._run_with_optimizer(testfunc,TIER2_THRESHOLD)
1853+
self.assertEqual(res,TIER2_THRESHOLD)
1854+
self.assertIsNotNone(ex)
1855+
uops=get_opnames(ex)
1856+
self.assertIn("_CALL_TYPE_1",uops)
1857+
self.assertIn("_POP_TOP_NOP",uops)
1858+
18441859
deftest_call_str_1(self):
18451860
deftestfunc(n):
18461861
x=0

‎Python/bytecodes.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4030,25 +4030,23 @@ dummy_func(
40304030
DEOPT_IF(callable_o!= (PyObject*)&PyType_Type);
40314031
}
40324032

4033-
op(_CALL_TYPE_1, (callable,null,arg--res)) {
4033+
op(_CALL_TYPE_1, (callable,null,arg--res,a)) {
40344034
PyObject*arg_o=PyStackRef_AsPyObjectBorrow(arg);
40354035

40364036
assert(oparg==1);
4037-
DEAD(null);
4038-
DEAD(callable);
4039-
(void)callable;// Silence compiler warnings about unused variables
4040-
(void)null;
40414037
STAT_INC(CALL,hit);
4038+
INPUTS_DEAD();
40424039
res=PyStackRef_FromPyObjectNew(Py_TYPE(arg_o));
4043-
PyStackRef_CLOSE(arg);
4040+
a=arg;
40444041
}
40454042

40464043
macro(CALL_TYPE_1)=
40474044
unused/1+
40484045
unused/2+
40494046
_GUARD_NOS_NULL+
40504047
_GUARD_CALLABLE_TYPE_1+
4051-
_CALL_TYPE_1;
4048+
_CALL_TYPE_1+
4049+
POP_TOP;
40524050

40534051
op(_GUARD_CALLABLE_STR_1, (callable,unused,unused--callable,unused,unused)) {
40544052
PyObject*callable_o=PyStackRef_AsPyObjectBorrow(callable);

‎Python/executor_cases.c.h

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

‎Python/generated_cases.c.h

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎Python/optimizer_bytecodes.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ dummy_func(void) {
969969
next=sym_new_type(ctx,&PyLong_Type);
970970
}
971971

972-
op(_CALL_TYPE_1, (unused,unused,arg--res)) {
972+
op(_CALL_TYPE_1, (unused,unused,arg--res,a)) {
973973
PyObject*type= (PyObject*)sym_get_type(arg);
974974
if (type) {
975975
res=sym_new_const(ctx,type);
@@ -979,6 +979,7 @@ dummy_func(void) {
979979
else {
980980
res=sym_new_not_null(ctx);
981981
}
982+
a=arg;
982983
}
983984

984985
op(_CALL_STR_1, (unused,unused,arg--res)) {

‎Python/optimizer_cases.c.h

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp