Skip to content

Commit 672241d

Browse files
Apply Mark's suggestion
1 parent c078999 commit 672241d

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

Include/internal/pycore_code.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ PyAPI_FUNC(void) _Py_Specialize_ToBool(_PyStackRef value, _Py_CODEUNIT *instr);
323323
PyAPI_FUNC(void) _Py_Specialize_ContainsOp(_PyStackRef value, _Py_CODEUNIT *instr);
324324
PyAPI_FUNC(void) _Py_GatherStats_GetIter(_PyStackRef iterable);
325325
PyAPI_FUNC(void) _Py_Specialize_CallFunctionEx(_PyStackRef func_st, _Py_CODEUNIT *instr);
326-
PyAPI_FUNC(void) _Py_Specialize_Resume(_Py_CODEUNIT *instr, PyThreadState *tstate);
326+
PyAPI_FUNC(void) _Py_Specialize_Resume(_Py_CODEUNIT *instr, PyThreadState *tstate, _PyInterpreterFrame *frame);
327327

328328
// Utility functions for reading/writing 32/64-bit values in the inline caches.
329329
// Great care should be taken to ensure that these functions remain correct and

Modules/_testinternalcapi/test_cases.c.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.

Python/bytecodes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ dummy_func(
173173
}
174174

175175
tier1 op(_QUICKEN_RESUME, (counter/1 --)) {
176-
_Py_Specialize_Resume(this_instr, tstate);
176+
_Py_Specialize_Resume(this_instr, tstate, frame);
177177
}
178178

179179
tier1 op(_MAYBE_INSTRUMENT, (--)) {

Python/generated_cases.c.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.

Python/specialize.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2788,13 +2788,18 @@ _Py_Specialize_ContainsOp(_PyStackRef value_st, _Py_CODEUNIT *instr)
27882788

27892789

27902790
void
2791-
_Py_Specialize_Resume(_Py_CODEUNIT *instr, PyThreadState *tstate)
2791+
_Py_Specialize_Resume(_Py_CODEUNIT *instr, PyThreadState *tstate, _PyInterpreterFrame *frame)
27922792
{
27932793
if (tstate->tracing == 0 && instr->op.code == RESUME) {
27942794
if (tstate->interp->jit) {
2795-
specialize(instr, RESUME_CHECK_JIT);
2796-
set_counter((_Py_BackoffCounter *)instr + 1, initial_resume_backoff_counter(&tstate->interp->opt_config));
2797-
return;
2795+
PyCodeObject *co = (PyCodeObject *)PyStackRef_AsPyObjectBorrow(frame->f_executable);
2796+
if (co != NULL &&
2797+
PyCode_Check(co) &&
2798+
(co->co_flags & (CO_GENERATOR | CO_COROUTINE | CO_ASYNC_GENERATOR)) == 0) {
2799+
specialize(instr, RESUME_CHECK_JIT);
2800+
set_counter((_Py_BackoffCounter *)instr + 1, initial_resume_backoff_counter(&tstate->interp->opt_config));
2801+
return;
2802+
}
27982803
}
27992804
specialize(instr, RESUME_CHECK);
28002805
return;

0 commit comments

Comments
 (0)