Skip to content

Commit 4376246

Browse files
committed
Make it clearer to MSVC that variable doesn't escape
1 parent 4dd6992 commit 4376246

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

Modules/_testinternalcapi/test_cases.c.h

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

Python/bytecodes.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3643,7 +3643,12 @@ dummy_func(
36433643
replaced op(_FOR_ITER_VIRTUAL, (iter, null_or_index -- iter, null_or_index, next)) {
36443644
PyObject *iter_o = PyStackRef_AsPyObjectBorrow(iter);
36453645
Py_ssize_t index = PyStackRef_UntagInt(null_or_index);
3646-
PyObject *next_o = Py_TYPE(iter_o)->tp_iteritem(iter_o, &index);
3646+
PyObject *next_o;
3647+
{ // Make it clear that index doesn't escape; for MSVC tailcall
3648+
Py_ssize_t tmp = index;
3649+
next_o = Py_TYPE(iter_o)->tp_iteritem(iter_o, &tmp);
3650+
index = tmp;
3651+
}
36473652
if (next_o == NULL) {
36483653
if (index < 0) {
36493654
ERROR_NO_POP();
@@ -3652,8 +3657,8 @@ dummy_func(
36523657
JUMPBY(oparg + 1);
36533658
DISPATCH();
36543659
}
3655-
next = PyStackRef_FromPyObjectSteal(next_o);
36563660
null_or_index = PyStackRef_TagInt(index);
3661+
next = PyStackRef_FromPyObjectSteal(next_o);
36573662
}
36583663

36593664
macro(FOR_ITER_VIRTUAL) =

Python/generated_cases.c.h

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

0 commit comments

Comments
 (0)