Skip to content

Commit 34f11e2

Browse files
committed
Add CALL specializations for calling Python async functions
Add CALL_PY_ASYNC_EXACT_ARGS, CALL_PY_ASYNC_GENERAL, CALL_BOUND_METHOD_ASYNC_EXACT_ARGS and CALL_BOUND_METHOD_ASYNC_GENERAL. They apply to coroutine functions whose code starts with RETURN_GENERATOR; POP_TOP, and create the coroutine object directly instead of pushing a frame and executing RETURN_GENERATOR. The new coroutine's frame is left at the POP_TOP, as RETURN_GENERATOR leaves it.
1 parent 31146df commit 34f11e2

20 files changed

Lines changed: 1574 additions & 197 deletions

‎Include/internal/pycore_ceval.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,14 @@ _Py_VectorCall_StackRefSteal(
418418
int total_args,
419419
_PyStackRef kwnames);
420420

421+
PyAPI_FUNC(PyObject *)
422+
_PyEval_MakeCoroStackRefSteal(
423+
PyThreadState *tstate,
424+
_PyStackRef func,
425+
_PyStackRef *args,
426+
int argcount,
427+
int exact_args);
428+
421429
PyAPI_FUNC(PyObject*)
422430
_Py_VectorCallInstrumentation_StackRefSteal(
423431
_PyStackRef callable,

‎Include/internal/pycore_genobject.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ PyAPI_FUNC(PyObject *)_PyAsyncGenValueWrapperNew(PyThreadState *state, PyObject
4848
// Exported for external JIT support
4949
PyAPI_FUNC(PyObject *) _PyCoro_ComputeOrigin(int origin_depth, _PyInterpreterFrame *current_frame);
5050

51+
extern PyObject *_PyCoro_New(PyThreadState *tstate, PyFunctionObject *func,
52+
_PyInterpreterFrame *caller);
53+
5154
extern PyTypeObject _PyCoroWrapper_Type;
5255
extern PyTypeObject _PyAsyncGenWrappedValue_Type;
5356
extern PyTypeObject _PyAsyncGenAThrow_Type;

‎Include/internal/pycore_opcode_metadata.h‎

Lines changed: 32 additions & 8 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: 6 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_metadata.h‎

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

0 commit comments

Comments
 (0)