1 #ifndef Py_INTERNAL_FUNCTION_H 2 #define Py_INTERNAL_FUNCTION_H 3 #ifdef __cplusplus 4 extern "C" { 5 #endif 6 7 #include "pycore_lock.h" 8 9 #ifndef Py_BUILD_CORE 10 # error "this header requires Py_BUILD_CORE define" 11 #endif 12 13 extern PyObject* _PyFunction_Vectorcall( 14 PyObject *func, 15 PyObject *const *stack, 16 size_t nargsf, 17 PyObject *kwnames); 18 19 #define FUNC_MAX_WATCHERS 8 20 21 #define FUNC_VERSION_CACHE_SIZE (1<<12) /* Must be a power of 2 */ 22 23 struct _func_version_cache_item { 24 PyFunctionObject *func; 25 PyObject *code; 26 }; 27 28 struct _py_func_state { 29 #ifdef Py_GIL_DISABLED 30 // Protects next_version 31 PyMutex mutex; 32 #endif 33 34 uint32_t next_version; 35 // Borrowed references to function and code objects whose 36 // func_version % FUNC_VERSION_CACHE_SIZE 37 // once was equal to the index in the table. 38 // They are cleared when the function or code object is deallocated. 39 struct _func_version_cache_item func_version_cache[FUNC_VERSION_CACHE_SIZE]; 40 }; 41 42 extern PyFunctionObject* _PyFunction_FromConstructor(PyFrameConstructor *constr); 43 44 extern uint32_t _PyFunction_GetVersionForCurrentState(PyFunctionObject *func); 45 PyAPI_FUNC(void) _PyFunction_SetVersion(PyFunctionObject *func, uint32_t version); 46 void _PyFunction_ClearCodeByVersion(uint32_t version); 47 PyFunctionObject *_PyFunction_LookupByVersion(uint32_t version, PyObject **p_code); 48 49 extern PyObject *_Py_set_function_type_params( 50 PyThreadState* unused, PyObject *func, PyObject *type_params); 51 52 #ifdef __cplusplus 53 } 54 #endif 55 #endif /* !Py_INTERNAL_FUNCTION_H */ 56