summaryrefslogtreecommitdiffstats
path: root/Include/internal/pycore_function.h
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2023-08-17 18:29:58 (GMT)
committerGitHub <noreply@github.com>2023-08-17 18:29:58 (GMT)
commit61c7249759ce88465ea655d5c19d17d03ff3f74b (patch)
treed6dd9d45ecbfdb2436ca462517982b95491179af /Include/internal/pycore_function.h
parent292a22bdc22f2aa70c96e9e53ca6d6b0c5f8d5bf (diff)
downloadcpython-61c7249759ce88465ea655d5c19d17d03ff3f74b.zip
cpython-61c7249759ce88465ea655d5c19d17d03ff3f74b.tar.gz
cpython-61c7249759ce88465ea655d5c19d17d03ff3f74b.tar.bz2
gh-106581: Project through calls (#108067)
This finishes the work begun in gh-107760. When, while projecting a superblock, we encounter a call to a short, simple function, the superblock will now enter the function using `_PUSH_FRAME`, continue through it, and leave it using `_POP_FRAME`, and then continue through the original code. Multiple frame pushes and pops are even possible. It is also possible to stop appending to the superblock in the middle of a called function, when running out of space or encountering an unsupported bytecode.
Diffstat (limited to 'Include/internal/pycore_function.h')
-rw-r--r--Include/internal/pycore_function.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/Include/internal/pycore_function.h b/Include/internal/pycore_function.h
index e844d32..3f3da8a 100644
--- a/Include/internal/pycore_function.h
+++ b/Include/internal/pycore_function.h
@@ -16,13 +16,22 @@ extern PyObject* _PyFunction_Vectorcall(
#define FUNC_MAX_WATCHERS 8
+#define FUNC_VERSION_CACHE_SIZE (1<<12) /* Must be a power of 2 */
struct _py_func_state {
uint32_t next_version;
+ // Borrowed references to function objects whose
+ // func_version % FUNC_VERSION_CACHE_SIZE
+ // once was equal to the index in the table.
+ // They are cleared when the function is deallocated.
+ PyFunctionObject *func_version_cache[FUNC_VERSION_CACHE_SIZE];
};
extern PyFunctionObject* _PyFunction_FromConstructor(PyFrameConstructor *constr);
extern uint32_t _PyFunction_GetVersionForCurrentState(PyFunctionObject *func);
+extern void _PyFunction_SetVersion(PyFunctionObject *func, uint32_t version);
+PyFunctionObject *_PyFunction_LookupByVersion(uint32_t version);
+
extern PyObject *_Py_set_function_type_params(
PyThreadState* unused, PyObject *func, PyObject *type_params);